view.js 870 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244
  1. /* Copyright 2017 Mozilla Foundation
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. (function(modules) {
  16. var installedModules = {};
  17. function __webpack_require__(moduleId) {
  18. if (installedModules[moduleId]) {
  19. return installedModules[moduleId].exports
  20. }
  21. var module = installedModules[moduleId] = {
  22. i: moduleId,
  23. l: false,
  24. exports: {}
  25. };
  26. modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  27. module.l = true;
  28. return module.exports
  29. }
  30. __webpack_require__.m = modules;
  31. __webpack_require__.c = installedModules;
  32. __webpack_require__.i = function(value) {
  33. return value
  34. };
  35. __webpack_require__.d = function(exports, name, getter) {
  36. if (!__webpack_require__.o(exports, name)) {
  37. Object.defineProperty(exports, name, {
  38. configurable: false,
  39. enumerable: true,
  40. get: getter
  41. })
  42. }
  43. };
  44. __webpack_require__.n = function(module) {
  45. var getter = module && module.__esModule ?
  46. function getDefault() {
  47. return module['default']
  48. }: function getModuleExports() {
  49. return module
  50. };
  51. __webpack_require__.d(getter, 'a', getter);
  52. return getter
  53. };
  54. __webpack_require__.o = function(object, property) {
  55. return Object.prototype.hasOwnProperty.call(object, property)
  56. };
  57. __webpack_require__.p = "";
  58. return __webpack_require__(__webpack_require__.s = 33)
  59. })([(function(module, exports, __webpack_require__) {
  60. "use strict";
  61. Object.defineProperty(exports, "__esModule", {
  62. value: true
  63. });
  64. exports.localized = exports.animationStarted = exports.normalizeWheelEventDelta = exports.binarySearchFirstItem = exports.watchScroll = exports.scrollIntoView = exports.getOutputScale = exports.approximateFraction = exports.roundToDivide = exports.getVisibleElements = exports.parseQueryString = exports.noContextMenuHandler = exports.getPDFFileNameFromURL = exports.ProgressBar = exports.EventBus = exports.NullL10n = exports.mozL10n = exports.RendererType = exports.cloneObj = exports.VERTICAL_PADDING = exports.SCROLLBAR_PADDING = exports.MAX_AUTO_SCALE = exports.UNKNOWN_SCALE = exports.MAX_SCALE = exports.MIN_SCALE = exports.DEFAULT_SCALE = exports.DEFAULT_SCALE_VALUE = exports.CSS_UNITS = undefined;
  65. var _createClass = function() {
  66. function defineProperties(target, props) {
  67. for (var i = 0; i < props.length; i++) {
  68. var descriptor = props[i];
  69. descriptor.enumerable = descriptor.enumerable || false;
  70. descriptor.configurable = true;
  71. if ("value" in descriptor) descriptor.writable = true;
  72. Object.defineProperty(target, descriptor.key, descriptor)
  73. }
  74. }
  75. return function(Constructor, protoProps, staticProps) {
  76. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  77. if (staticProps) defineProperties(Constructor, staticProps);
  78. return Constructor
  79. }
  80. } ();
  81. var _pdfjsLib = __webpack_require__(1);
  82. function _classCallCheck(instance, Constructor) {
  83. if (! (instance instanceof Constructor)) {
  84. throw new TypeError("Cannot call a class as a function");
  85. }
  86. }
  87. var CSS_UNITS = 96.0 / 72.0;
  88. var DEFAULT_SCALE_VALUE = 'auto';
  89. var DEFAULT_SCALE = 1.0;
  90. var MIN_SCALE = 0.25;
  91. var MAX_SCALE = 10.0;
  92. var UNKNOWN_SCALE = 0;
  93. var MAX_AUTO_SCALE = 1.25;
  94. var SCROLLBAR_PADDING = 40;
  95. var VERTICAL_PADDING = 5;
  96. var RendererType = {
  97. CANVAS: 'canvas',
  98. SVG: 'svg'
  99. };
  100. function formatL10nValue(text, args) {
  101. if (!args) {
  102. return text
  103. }
  104. return text.replace(/\{\{\s*(\w+)\s*\}\}/g,
  105. function(all, name) {
  106. return name in args ? args[name] : '{{' + name + '}}'
  107. })
  108. }
  109. var NullL10n = {
  110. get: function get(property, args, fallback) {
  111. return Promise.resolve(formatL10nValue(fallback, args))
  112. },
  113. translate: function translate(element) {
  114. return Promise.resolve()
  115. }
  116. };
  117. _pdfjsLib.PDFJS.disableFullscreen = _pdfjsLib.PDFJS.disableFullscreen === undefined ? false: _pdfjsLib.PDFJS.disableFullscreen;
  118. _pdfjsLib.PDFJS.useOnlyCssZoom = _pdfjsLib.PDFJS.useOnlyCssZoom === undefined ? false: _pdfjsLib.PDFJS.useOnlyCssZoom;
  119. _pdfjsLib.PDFJS.maxCanvasPixels = _pdfjsLib.PDFJS.maxCanvasPixels === undefined ? 16777216 : _pdfjsLib.PDFJS.maxCanvasPixels;
  120. _pdfjsLib.PDFJS.disableHistory = _pdfjsLib.PDFJS.disableHistory === undefined ? false: _pdfjsLib.PDFJS.disableHistory;
  121. _pdfjsLib.PDFJS.disableTextLayer = _pdfjsLib.PDFJS.disableTextLayer === undefined ? false: _pdfjsLib.PDFJS.disableTextLayer;
  122. _pdfjsLib.PDFJS.ignoreCurrentPositionOnZoom = _pdfjsLib.PDFJS.ignoreCurrentPositionOnZoom === undefined ? false: _pdfjsLib.PDFJS.ignoreCurrentPositionOnZoom; {
  123. _pdfjsLib.PDFJS.locale = _pdfjsLib.PDFJS.locale === undefined && typeof navigator !== 'undefined' ? navigator.language: _pdfjsLib.PDFJS.locale
  124. }
  125. function getOutputScale(ctx) {
  126. var devicePixelRatio = window.devicePixelRatio || 1;
  127. var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
  128. var pixelRatio = devicePixelRatio / backingStoreRatio;
  129. return {
  130. sx: pixelRatio,
  131. sy: pixelRatio,
  132. scaled: pixelRatio !== 1
  133. }
  134. }
  135. function scrollIntoView(element, spot) {
  136. var skipOverflowHiddenElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  137. var parent = element.offsetParent;
  138. if (!parent) {
  139. console.error('offsetParent is not set -- cannot scroll');
  140. return
  141. }
  142. var offsetY = element.offsetTop + element.clientTop;
  143. var offsetX = element.offsetLeft + element.clientLeft;
  144. while (parent.clientHeight === parent.scrollHeight || skipOverflowHiddenElements && getComputedStyle(parent).overflow === 'hidden') {
  145. if (parent.dataset._scaleY) {
  146. offsetY /= parent.dataset._scaleY;
  147. offsetX /= parent.dataset._scaleX
  148. }
  149. offsetY += parent.offsetTop;
  150. offsetX += parent.offsetLeft;
  151. parent = parent.offsetParent;
  152. if (!parent) {
  153. return
  154. }
  155. }
  156. if (spot) {
  157. if (spot.top !== undefined) {
  158. offsetY += spot.top
  159. }
  160. if (spot.left !== undefined) {
  161. offsetX += spot.left;
  162. parent.scrollLeft = offsetX
  163. }
  164. }
  165. parent.scrollTop = offsetY
  166. }
  167. function watchScroll(viewAreaElement, callback) {
  168. var debounceScroll = function debounceScroll(evt) {
  169. if (rAF) {
  170. return
  171. }
  172. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  173. rAF = null;
  174. var currentY = viewAreaElement.scrollTop;
  175. var lastY = state.lastY;
  176. if (currentY !== lastY) {
  177. state.down = currentY > lastY
  178. }
  179. state.lastY = currentY;
  180. callback(state)
  181. })
  182. };
  183. var state = {
  184. down: true,
  185. lastY: viewAreaElement.scrollTop,
  186. _eventHandler: debounceScroll
  187. };
  188. var rAF = null;
  189. viewAreaElement.addEventListener('scroll', debounceScroll, true);
  190. return state
  191. }
  192. function parseQueryString(query) {
  193. var parts = query.split('&');
  194. var params = Object.create(null);
  195. for (var i = 0,
  196. ii = parts.length; i < ii; ++i) {
  197. var param = parts[i].split('=');
  198. var key = param[0].toLowerCase();
  199. var value = param.length > 1 ? param[1] : null;
  200. params[decodeURIComponent(key)] = decodeURIComponent(value)
  201. }
  202. return params
  203. }
  204. function binarySearchFirstItem(items, condition) {
  205. var minIndex = 0;
  206. var maxIndex = items.length - 1;
  207. if (items.length === 0 || !condition(items[maxIndex])) {
  208. return items.length
  209. }
  210. if (condition(items[minIndex])) {
  211. return minIndex
  212. }
  213. while (minIndex < maxIndex) {
  214. var currentIndex = minIndex + maxIndex >> 1;
  215. var currentItem = items[currentIndex];
  216. if (condition(currentItem)) {
  217. maxIndex = currentIndex
  218. } else {
  219. minIndex = currentIndex + 1
  220. }
  221. }
  222. return minIndex
  223. }
  224. function approximateFraction(x) {
  225. if (Math.floor(x) === x) {
  226. return [x, 1]
  227. }
  228. var xinv = 1 / x;
  229. var limit = 8;
  230. if (xinv > limit) {
  231. return [1, limit]
  232. } else if (Math.floor(xinv) === xinv) {
  233. return [1, xinv]
  234. }
  235. var x_ = x > 1 ? xinv: x;
  236. var a = 0,
  237. b = 1,
  238. c = 1,
  239. d = 1;
  240. while (true) {
  241. var p = a + c,
  242. q = b + d;
  243. if (q > limit) {
  244. break
  245. }
  246. if (x_ <= p / q) {
  247. c = p;
  248. d = q
  249. } else {
  250. a = p;
  251. b = q
  252. }
  253. }
  254. var result = void 0;
  255. if (x_ - a / b < c / d - x_) {
  256. result = x_ === x ? [a, b] : [b, a]
  257. } else {
  258. result = x_ === x ? [c, d] : [d, c]
  259. }
  260. return result
  261. }
  262. function roundToDivide(x, div) {
  263. var r = x % div;
  264. return r === 0 ? x: Math.round(x - r + div)
  265. }
  266. function getVisibleElements(scrollEl, views) {
  267. var sortByVisibility = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  268. var top = scrollEl.scrollTop,
  269. bottom = top + scrollEl.clientHeight;
  270. var left = scrollEl.scrollLeft,
  271. right = left + scrollEl.clientWidth;
  272. function isElementBottomBelowViewTop(view) {
  273. var element = view.div;
  274. var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  275. return elementBottom > top
  276. }
  277. var visible = [],
  278. view = void 0,
  279. element = void 0;
  280. var currentHeight = void 0,
  281. viewHeight = void 0,
  282. hiddenHeight = void 0,
  283. percentHeight = void 0;
  284. var currentWidth = void 0,
  285. viewWidth = void 0;
  286. var firstVisibleElementInd = views.length === 0 ? 0 : binarySearchFirstItem(views, isElementBottomBelowViewTop);
  287. for (var i = firstVisibleElementInd,
  288. ii = views.length; i < ii; i++) {
  289. view = views[i];
  290. element = view.div;
  291. currentHeight = element.offsetTop + element.clientTop;
  292. viewHeight = element.clientHeight;
  293. if (currentHeight > bottom) {
  294. break
  295. }
  296. currentWidth = element.offsetLeft + element.clientLeft;
  297. viewWidth = element.clientWidth;
  298. if (currentWidth + viewWidth < left || currentWidth > right) {
  299. continue
  300. }
  301. hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, currentHeight + viewHeight - bottom);
  302. percentHeight = (viewHeight - hiddenHeight) * 100 / viewHeight | 0;
  303. visible.push({
  304. id: view.id,
  305. x: currentWidth,
  306. y: currentHeight,
  307. view: view,
  308. percent: percentHeight
  309. })
  310. }
  311. var first = visible[0];
  312. var last = visible[visible.length - 1];
  313. if (sortByVisibility) {
  314. visible.sort(function(a, b) {
  315. var pc = a.percent - b.percent;
  316. if (Math.abs(pc) > 0.001) {
  317. return - pc
  318. }
  319. return a.id - b.id
  320. })
  321. }
  322. return {
  323. first: first,
  324. last: last,
  325. views: visible
  326. }
  327. }
  328. function noContextMenuHandler(evt) {
  329. evt.preventDefault()
  330. }
  331. function isDataSchema(url) {
  332. var i = 0,
  333. ii = url.length;
  334. while (i < ii && url[i].trim() === '') {
  335. i++
  336. }
  337. return url.substr(i, 5).toLowerCase() === 'data:'
  338. }
  339. function getPDFFileNameFromURL(url) {
  340. var defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'document.pdf';
  341. if (isDataSchema(url)) {
  342. console.warn('getPDFFileNameFromURL: ' + 'ignoring "data:" URL for performance reasons.');
  343. return defaultFilename
  344. }
  345. var reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
  346. var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
  347. var splitURI = reURI.exec(url);
  348. var suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
  349. if (suggestedFilename) {
  350. suggestedFilename = suggestedFilename[0];
  351. if (suggestedFilename.indexOf('%') !== -1) {
  352. try {
  353. suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0]
  354. } catch(ex) {}
  355. }
  356. }
  357. return suggestedFilename || defaultFilename
  358. }
  359. function normalizeWheelEventDelta(evt) {
  360. var delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
  361. var angle = Math.atan2(evt.deltaY, evt.deltaX);
  362. if ( - 0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  363. delta = -delta
  364. }
  365. var MOUSE_DOM_DELTA_PIXEL_MODE = 0;
  366. var MOUSE_DOM_DELTA_LINE_MODE = 1;
  367. var MOUSE_PIXELS_PER_LINE = 30;
  368. var MOUSE_LINES_PER_PAGE = 30;
  369. if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
  370. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE
  371. } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
  372. delta /= MOUSE_LINES_PER_PAGE
  373. }
  374. return delta
  375. }
  376. function cloneObj(obj) {
  377. var result = Object.create(null);
  378. for (var i in obj) {
  379. if (Object.prototype.hasOwnProperty.call(obj, i)) {
  380. result[i] = obj[i]
  381. }
  382. }
  383. return result
  384. }
  385. var animationStarted = new Promise(function(resolve) {
  386. window.requestAnimationFrame(resolve)
  387. });
  388. var mozL10n = void 0;
  389. var localized = Promise.resolve();
  390. var EventBus = function() {
  391. function EventBus() {
  392. _classCallCheck(this, EventBus);
  393. this._listeners = Object.create(null)
  394. }
  395. _createClass(EventBus, [{
  396. key: 'on',
  397. value: function on(eventName, listener) {
  398. var eventListeners = this._listeners[eventName];
  399. if (!eventListeners) {
  400. eventListeners = [];
  401. this._listeners[eventName] = eventListeners
  402. }
  403. eventListeners.push(listener)
  404. }
  405. },
  406. {
  407. key: 'off',
  408. value: function off(eventName, listener) {
  409. var eventListeners = this._listeners[eventName];
  410. var i = void 0;
  411. if (!eventListeners || (i = eventListeners.indexOf(listener)) < 0) {
  412. return
  413. }
  414. eventListeners.splice(i, 1)
  415. }
  416. },
  417. {
  418. key: 'dispatch',
  419. value: function dispatch(eventName) {
  420. var eventListeners = this._listeners[eventName];
  421. if (!eventListeners || eventListeners.length === 0) {
  422. return
  423. }
  424. var args = Array.prototype.slice.call(arguments, 1);
  425. eventListeners.slice(0).forEach(function(listener) {
  426. listener.apply(null, args)
  427. })
  428. }
  429. }]);
  430. return EventBus
  431. } ();
  432. function clamp(v, min, max) {
  433. return Math.min(Math.max(v, min), max)
  434. }
  435. var ProgressBar = function() {
  436. function ProgressBar(id) {
  437. var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  438. height = _ref.height,
  439. width = _ref.width,
  440. units = _ref.units;
  441. _classCallCheck(this, ProgressBar);
  442. this.visible = true;
  443. this.div = document.querySelector(id + ' .progress');
  444. this.bar = this.div.parentNode;
  445. this.height = height || 100;
  446. this.width = width || 100;
  447. this.units = units || '%';
  448. this.div.style.height = this.height + this.units;
  449. this.percent = 0
  450. }
  451. _createClass(ProgressBar, [{
  452. key: '_updateBar',
  453. value: function _updateBar() {
  454. if (this._indeterminate) {
  455. this.div.classList.add('indeterminate');
  456. this.div.style.width = this.width + this.units;
  457. return
  458. }
  459. this.div.classList.remove('indeterminate');
  460. var progressSize = this.width * this._percent / 100;
  461. this.div.style.width = progressSize + this.units
  462. }
  463. },
  464. {
  465. key: 'setWidth',
  466. value: function setWidth(viewer) {
  467. if (!viewer) {
  468. return
  469. }
  470. var container = viewer.parentNode;
  471. var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  472. if (scrollbarWidth > 0) {
  473. this.bar.setAttribute('style', 'width: calc(100% - ' + scrollbarWidth + 'px);')
  474. }
  475. }
  476. },
  477. {
  478. key: 'hide',
  479. value: function hide() {
  480. if (!this.visible) {
  481. return
  482. }
  483. this.visible = false;
  484. this.bar.classList.add('hidden');
  485. document.body.classList.remove('loadingInProgress')
  486. }
  487. },
  488. {
  489. key: 'show',
  490. value: function show() {
  491. if (this.visible) {
  492. return
  493. }
  494. this.visible = true;
  495. document.body.classList.add('loadingInProgress');
  496. this.bar.classList.remove('hidden')
  497. }
  498. },
  499. {
  500. key: 'percent',
  501. get: function get() {
  502. return this._percent
  503. },
  504. set: function set(val) {
  505. this._indeterminate = isNaN(val);
  506. this._percent = clamp(val, 0, 100);
  507. this._updateBar()
  508. }
  509. }]);
  510. return ProgressBar
  511. } ();
  512. exports.CSS_UNITS = CSS_UNITS;
  513. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  514. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  515. exports.MIN_SCALE = MIN_SCALE;
  516. exports.MAX_SCALE = MAX_SCALE;
  517. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  518. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  519. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  520. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  521. exports.cloneObj = cloneObj;
  522. exports.RendererType = RendererType;
  523. exports.mozL10n = mozL10n;
  524. exports.NullL10n = NullL10n;
  525. exports.EventBus = EventBus;
  526. exports.ProgressBar = ProgressBar;
  527. exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
  528. exports.noContextMenuHandler = noContextMenuHandler;
  529. exports.parseQueryString = parseQueryString;
  530. exports.getVisibleElements = getVisibleElements;
  531. exports.roundToDivide = roundToDivide;
  532. exports.approximateFraction = approximateFraction;
  533. exports.getOutputScale = getOutputScale;
  534. exports.scrollIntoView = scrollIntoView;
  535. exports.watchScroll = watchScroll;
  536. exports.binarySearchFirstItem = binarySearchFirstItem;
  537. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  538. exports.animationStarted = animationStarted;
  539. exports.localized = localized
  540. }), (function(module, exports, __webpack_require__) {
  541. "use strict";
  542. var pdfjsLib;
  543. if (typeof window !== 'undefined' && window['pdfjs-dist/build/pdf']) {
  544. pdfjsLib = window['pdfjs-dist/build/pdf']
  545. } else {
  546. pdfjsLib = require('../build/pdf.js')
  547. }
  548. module.exports = pdfjsLib
  549. }), (function(module, exports, __webpack_require__) {
  550. "use strict";
  551. Object.defineProperty(exports, "__esModule", {
  552. value: true
  553. });
  554. exports.getGlobalEventBus = exports.attachDOMEventsToEventBus = undefined;
  555. var _ui_utils = __webpack_require__(0);
  556. function attachDOMEventsToEventBus(eventBus) {
  557. eventBus.on('documentload',
  558. function() {
  559. var event = document.createEvent('CustomEvent');
  560. event.initCustomEvent('documentload', true, true, {});
  561. window.dispatchEvent(event)
  562. });
  563. eventBus.on('pagerendered',
  564. function(evt) {
  565. var event = document.createEvent('CustomEvent');
  566. event.initCustomEvent('pagerendered', true, true, {
  567. pageNumber: evt.pageNumber,
  568. cssTransform: evt.cssTransform
  569. });
  570. evt.source.div.dispatchEvent(event)
  571. });
  572. eventBus.on('textlayerrendered',
  573. function(evt) {
  574. var event = document.createEvent('CustomEvent');
  575. event.initCustomEvent('textlayerrendered', true, true, {
  576. pageNumber: evt.pageNumber
  577. });
  578. evt.source.textLayerDiv.dispatchEvent(event)
  579. });
  580. eventBus.on('pagechange',
  581. function(evt) {
  582. var event = document.createEvent('UIEvents');
  583. event.initUIEvent('pagechange', true, true, window, 0);
  584. event.pageNumber = evt.pageNumber;
  585. evt.source.container.dispatchEvent(event)
  586. });
  587. eventBus.on('pagesinit',
  588. function(evt) {
  589. var event = document.createEvent('CustomEvent');
  590. event.initCustomEvent('pagesinit', true, true, null);
  591. evt.source.container.dispatchEvent(event)
  592. });
  593. eventBus.on('pagesloaded',
  594. function(evt) {
  595. var event = document.createEvent('CustomEvent');
  596. event.initCustomEvent('pagesloaded', true, true, {
  597. pagesCount: evt.pagesCount
  598. });
  599. evt.source.container.dispatchEvent(event)
  600. });
  601. eventBus.on('scalechange',
  602. function(evt) {
  603. var event = document.createEvent('UIEvents');
  604. event.initUIEvent('scalechange', true, true, window, 0);
  605. event.scale = evt.scale;
  606. event.presetValue = evt.presetValue;
  607. evt.source.container.dispatchEvent(event)
  608. });
  609. eventBus.on('updateviewarea',
  610. function(evt) {
  611. var event = document.createEvent('UIEvents');
  612. event.initUIEvent('updateviewarea', true, true, window, 0);
  613. event.location = evt.location;
  614. evt.source.container.dispatchEvent(event)
  615. });
  616. eventBus.on('find',
  617. function(evt) {
  618. if (evt.source === window) {
  619. return
  620. }
  621. var event = document.createEvent('CustomEvent');
  622. event.initCustomEvent('find' + evt.type, true, true, {
  623. query: evt.query,
  624. phraseSearch: evt.phraseSearch,
  625. caseSensitive: evt.caseSensitive,
  626. highlightAll: evt.highlightAll,
  627. findPrevious: evt.findPrevious
  628. });
  629. window.dispatchEvent(event)
  630. });
  631. eventBus.on('attachmentsloaded',
  632. function(evt) {
  633. var event = document.createEvent('CustomEvent');
  634. event.initCustomEvent('attachmentsloaded', true, true, {
  635. attachmentsCount: evt.attachmentsCount
  636. });
  637. evt.source.container.dispatchEvent(event)
  638. });
  639. eventBus.on('sidebarviewchanged',
  640. function(evt) {
  641. var event = document.createEvent('CustomEvent');
  642. event.initCustomEvent('sidebarviewchanged', true, true, {
  643. view: evt.view
  644. });
  645. evt.source.outerContainer.dispatchEvent(event)
  646. });
  647. eventBus.on('pagemode',
  648. function(evt) {
  649. var event = document.createEvent('CustomEvent');
  650. event.initCustomEvent('pagemode', true, true, {
  651. mode: evt.mode
  652. });
  653. evt.source.pdfViewer.container.dispatchEvent(event)
  654. });
  655. eventBus.on('namedaction',
  656. function(evt) {
  657. var event = document.createEvent('CustomEvent');
  658. event.initCustomEvent('namedaction', true, true, {
  659. action: evt.action
  660. });
  661. evt.source.pdfViewer.container.dispatchEvent(event)
  662. });
  663. eventBus.on('presentationmodechanged',
  664. function(evt) {
  665. var event = document.createEvent('CustomEvent');
  666. event.initCustomEvent('presentationmodechanged', true, true, {
  667. active: evt.active,
  668. switchInProgress: evt.switchInProgress
  669. });
  670. window.dispatchEvent(event)
  671. });
  672. eventBus.on('outlineloaded',
  673. function(evt) {
  674. var event = document.createEvent('CustomEvent');
  675. event.initCustomEvent('outlineloaded', true, true, {
  676. outlineCount: evt.outlineCount
  677. });
  678. evt.source.container.dispatchEvent(event)
  679. })
  680. }
  681. var globalEventBus = null;
  682. function getGlobalEventBus() {
  683. if (globalEventBus) {
  684. return globalEventBus
  685. }
  686. globalEventBus = new _ui_utils.EventBus();
  687. attachDOMEventsToEventBus(globalEventBus);
  688. return globalEventBus
  689. }
  690. exports.attachDOMEventsToEventBus = attachDOMEventsToEventBus;
  691. exports.getGlobalEventBus = getGlobalEventBus
  692. }), (function(module, exports, __webpack_require__) {
  693. "use strict";
  694. Object.defineProperty(exports, "__esModule", {
  695. value: true
  696. });
  697. var _createClass = function() {
  698. function defineProperties(target, props) {
  699. for (var i = 0; i < props.length; i++) {
  700. var descriptor = props[i];
  701. descriptor.enumerable = descriptor.enumerable || false;
  702. descriptor.configurable = true;
  703. if ("value" in descriptor) descriptor.writable = true;
  704. Object.defineProperty(target, descriptor.key, descriptor)
  705. }
  706. }
  707. return function(Constructor, protoProps, staticProps) {
  708. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  709. if (staticProps) defineProperties(Constructor, staticProps);
  710. return Constructor
  711. }
  712. } ();
  713. function _classCallCheck(instance, Constructor) {
  714. if (! (instance instanceof Constructor)) {
  715. throw new TypeError("Cannot call a class as a function");
  716. }
  717. }
  718. var CLEANUP_TIMEOUT = 30000;
  719. var RenderingStates = {
  720. INITIAL: 0,
  721. RUNNING: 1,
  722. PAUSED: 2,
  723. FINISHED: 3
  724. };
  725. var PDFRenderingQueue = function() {
  726. function PDFRenderingQueue() {
  727. _classCallCheck(this, PDFRenderingQueue);
  728. this.pdfViewer = null;
  729. this.pdfThumbnailViewer = null;
  730. this.onIdle = null;
  731. this.highestPriorityPage = null;
  732. this.idleTimeout = null;
  733. this.printing = false;
  734. this.isThumbnailViewEnabled = false
  735. }
  736. _createClass(PDFRenderingQueue, [{
  737. key: "setViewer",
  738. value: function setViewer(pdfViewer) {
  739. this.pdfViewer = pdfViewer
  740. }
  741. },
  742. {
  743. key: "setThumbnailViewer",
  744. value: function setThumbnailViewer(pdfThumbnailViewer) {
  745. this.pdfThumbnailViewer = pdfThumbnailViewer
  746. }
  747. },
  748. {
  749. key: "isHighestPriority",
  750. value: function isHighestPriority(view) {
  751. return this.highestPriorityPage === view.renderingId
  752. }
  753. },
  754. {
  755. key: "renderHighestPriority",
  756. value: function renderHighestPriority(currentlyVisiblePages) {
  757. if (this.idleTimeout) {
  758. clearTimeout(this.idleTimeout);
  759. this.idleTimeout = null
  760. }
  761. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  762. return
  763. }
  764. if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
  765. if (this.pdfThumbnailViewer.forceRendering()) {
  766. return
  767. }
  768. }
  769. if (this.printing) {
  770. return
  771. }
  772. if (this.onIdle) {
  773. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT)
  774. }
  775. }
  776. },
  777. {
  778. key: "getHighestPriority",
  779. value: function getHighestPriority(visible, views, scrolledDown) {
  780. var visibleViews = visible.views;
  781. var numVisible = visibleViews.length;
  782. if (numVisible === 0) {
  783. return false
  784. }
  785. for (var i = 0; i < numVisible; ++i) {
  786. var view = visibleViews[i].view;
  787. if (!this.isViewFinished(view)) {
  788. return view
  789. }
  790. }
  791. if (scrolledDown) {
  792. var nextPageIndex = visible.last.id;
  793. if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {
  794. return views[nextPageIndex]
  795. }
  796. } else {
  797. var previousPageIndex = visible.first.id - 2;
  798. if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) {
  799. return views[previousPageIndex]
  800. }
  801. }
  802. return null
  803. }
  804. },
  805. {
  806. key: "isViewFinished",
  807. value: function isViewFinished(view) {
  808. return view.renderingState === RenderingStates.FINISHED
  809. }
  810. },
  811. {
  812. key: "renderView",
  813. value: function renderView(view) {
  814. var _this = this;
  815. switch (view.renderingState) {
  816. case RenderingStates.FINISHED:
  817. return false;
  818. case RenderingStates.PAUSED:
  819. this.highestPriorityPage = view.renderingId;
  820. view.resume();
  821. break;
  822. case RenderingStates.RUNNING:
  823. this.highestPriorityPage = view.renderingId;
  824. break;
  825. case RenderingStates.INITIAL:
  826. this.highestPriorityPage = view.renderingId;
  827. var continueRendering = function continueRendering() {
  828. _this.renderHighestPriority()
  829. };
  830. view.draw().then(continueRendering, continueRendering);
  831. break
  832. }
  833. return true
  834. }
  835. }]);
  836. return PDFRenderingQueue
  837. } ();
  838. exports.RenderingStates = RenderingStates;
  839. exports.PDFRenderingQueue = PDFRenderingQueue
  840. }), (function(module, exports, __webpack_require__) {
  841. "use strict";
  842. Object.defineProperty(exports, "__esModule", {
  843. value: true
  844. });
  845. exports.PDFPrintServiceFactory = exports.DefaultExternalServices = exports.PDFViewerApplication = undefined;
  846. var _slicedToArray = function() {
  847. function sliceIterator(arr, i) {
  848. var _arr = [];
  849. var _n = true;
  850. var _d = false;
  851. var _e = undefined;
  852. try {
  853. for (var _i = arr[Symbol.iterator](), _s; ! (_n = (_s = _i.next()).done); _n = true) {
  854. _arr.push(_s.value);
  855. if (i && _arr.length === i) break
  856. }
  857. } catch(err) {
  858. _d = true;
  859. _e = err
  860. } finally {
  861. try {
  862. if (!_n && _i["return"]) _i["return"]()
  863. } finally {
  864. if (_d) throw _e;
  865. }
  866. }
  867. return _arr
  868. }
  869. return function(arr, i) {
  870. if (Array.isArray(arr)) {
  871. return arr
  872. } else if (Symbol.iterator in Object(arr)) {
  873. return sliceIterator(arr, i)
  874. } else {
  875. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  876. }
  877. }
  878. } ();
  879. var _ui_utils = __webpack_require__(0);
  880. var _pdfjsLib = __webpack_require__(1);
  881. var _pdf_cursor_tools = __webpack_require__(6);
  882. var _pdf_rendering_queue = __webpack_require__(3);
  883. var _pdf_sidebar = __webpack_require__(24);
  884. var _pdf_viewer = __webpack_require__(27);
  885. var _dom_events = __webpack_require__(2);
  886. var _overlay_manager = __webpack_require__(15);
  887. var _password_prompt = __webpack_require__(16);
  888. var _pdf_attachment_viewer = __webpack_require__(17);
  889. var _pdf_document_properties = __webpack_require__(18);
  890. var _pdf_find_bar = __webpack_require__(19);
  891. var _pdf_find_controller = __webpack_require__(7);
  892. var _pdf_history = __webpack_require__(20);
  893. var _pdf_link_service = __webpack_require__(5);
  894. var _pdf_outline_viewer = __webpack_require__(21);
  895. var _pdf_presentation_mode = __webpack_require__(23);
  896. var _pdf_thumbnail_viewer = __webpack_require__(26);
  897. var _secondary_toolbar = __webpack_require__(29);
  898. var _toolbar = __webpack_require__(31);
  899. var _view_history = __webpack_require__(32);
  900. var DEFAULT_SCALE_DELTA = 1.1;
  901. var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
  902. function configure(PDFJS) {
  903. PDFJS.imageResourcesPath = './images/';
  904. PDFJS.workerSrc = '../build/pdf.worker.js';
  905. PDFJS.cMapUrl = '../web/cmaps/';
  906. PDFJS.cMapPacked = true
  907. }
  908. var DefaultExternalServices = {
  909. updateFindControlState: function updateFindControlState(data) {},
  910. initPassiveLoading: function initPassiveLoading(callbacks) {},
  911. fallback: function fallback(data, callback) {},
  912. reportTelemetry: function reportTelemetry(data) {},
  913. createDownloadManager: function createDownloadManager() {
  914. throw new Error('Not implemented: createDownloadManager');
  915. },
  916. createPreferences: function createPreferences() {
  917. throw new Error('Not implemented: createPreferences');
  918. },
  919. createL10n: function createL10n() {
  920. throw new Error('Not implemented: createL10n');
  921. },
  922. supportsIntegratedFind: false,
  923. supportsDocumentFonts: true,
  924. supportsDocumentColors: true,
  925. supportedMouseWheelZoomModifierKeys: {
  926. ctrlKey: true,
  927. metaKey: true
  928. }
  929. };
  930. var PDFViewerApplication = {
  931. initialBookmark: document.location.hash.substring(1),
  932. initialDestination: null,
  933. initialized: false,
  934. fellback: false,
  935. appConfig: null,
  936. pdfDocument: null,
  937. pdfLoadingTask: null,
  938. printService: null,
  939. pdfViewer: null,
  940. pdfThumbnailViewer: null,
  941. pdfRenderingQueue: null,
  942. pdfPresentationMode: null,
  943. pdfDocumentProperties: null,
  944. pdfLinkService: null,
  945. pdfHistory: null,
  946. pdfSidebar: null,
  947. pdfOutlineViewer: null,
  948. pdfAttachmentViewer: null,
  949. pdfCursorTools: null,
  950. store: null,
  951. downloadManager: null,
  952. overlayManager: null,
  953. preferences: null,
  954. toolbar: null,
  955. secondaryToolbar: null,
  956. eventBus: null,
  957. l10n: null,
  958. isInitialViewSet: false,
  959. downloadComplete: false,
  960. viewerPrefs: {
  961. sidebarViewOnLoad: _pdf_sidebar.SidebarView.NONE,
  962. pdfBugEnabled: false,
  963. showPreviousViewOnLoad: true,
  964. defaultZoomValue: '',
  965. disablePageMode: false,
  966. disablePageLabels: false,
  967. renderer: 'canvas',
  968. enhanceTextSelection: false,
  969. renderInteractiveForms: false,
  970. enablePrintAutoRotate: false
  971. },
  972. isViewerEmbedded: window.parent !== window,
  973. url: '',
  974. baseUrl: '',
  975. externalServices: DefaultExternalServices,
  976. _boundEvents: {},
  977. initialize: function initialize(appConfig) {
  978. var _this = this;
  979. this.preferences = this.externalServices.createPreferences();
  980. configure(_pdfjsLib.PDFJS);
  981. this.appConfig = appConfig;
  982. return this._readPreferences().then(function() {
  983. return _this._initializeL10n()
  984. }).then(function() {
  985. return _this._initializeViewerComponents()
  986. }).then(function() {
  987. _this.bindEvents();
  988. _this.bindWindowEvents();
  989. var appContainer = appConfig.appContainer || document.documentElement;
  990. _this.l10n.translate(appContainer).then(function() {
  991. _this.eventBus.dispatch('localized')
  992. });
  993. if (_this.isViewerEmbedded && !_pdfjsLib.PDFJS.isExternalLinkTargetSet()) {
  994. _pdfjsLib.PDFJS.externalLinkTarget = _pdfjsLib.PDFJS.LinkTarget.TOP
  995. }
  996. _this.initialized = true
  997. })
  998. },
  999. _readPreferences: function _readPreferences() {
  1000. var preferences = this.preferences,
  1001. viewerPrefs = this.viewerPrefs;
  1002. return Promise.all([preferences.get('enableWebGL').then(function resolved(value) {
  1003. _pdfjsLib.PDFJS.disableWebGL = !value
  1004. }), preferences.get('sidebarViewOnLoad').then(function resolved(value) {
  1005. viewerPrefs['sidebarViewOnLoad'] = value
  1006. }), preferences.get('pdfBugEnabled').then(function resolved(value) {
  1007. viewerPrefs['pdfBugEnabled'] = value
  1008. }), preferences.get('showPreviousViewOnLoad').then(function resolved(value) {
  1009. viewerPrefs['showPreviousViewOnLoad'] = value
  1010. }), preferences.get('defaultZoomValue').then(function resolved(value) {
  1011. viewerPrefs['defaultZoomValue'] = value
  1012. }), preferences.get('enhanceTextSelection').then(function resolved(value) {
  1013. viewerPrefs['enhanceTextSelection'] = value
  1014. }), preferences.get('disableTextLayer').then(function resolved(value) {
  1015. if (_pdfjsLib.PDFJS.disableTextLayer === true) {
  1016. return
  1017. }
  1018. _pdfjsLib.PDFJS.disableTextLayer = value
  1019. }), preferences.get('disableRange').then(function resolved(value) {
  1020. if (_pdfjsLib.PDFJS.disableRange === true) {
  1021. return
  1022. }
  1023. _pdfjsLib.PDFJS.disableRange = value
  1024. }), preferences.get('disableStream').then(function resolved(value) {
  1025. if (_pdfjsLib.PDFJS.disableStream === true) {
  1026. return
  1027. }
  1028. _pdfjsLib.PDFJS.disableStream = value
  1029. }), preferences.get('disableAutoFetch').then(function resolved(value) {
  1030. _pdfjsLib.PDFJS.disableAutoFetch = value
  1031. }), preferences.get('disableFontFace').then(function resolved(value) {
  1032. if (_pdfjsLib.PDFJS.disableFontFace === true) {
  1033. return
  1034. }
  1035. _pdfjsLib.PDFJS.disableFontFace = value
  1036. }), preferences.get('useOnlyCssZoom').then(function resolved(value) {
  1037. _pdfjsLib.PDFJS.useOnlyCssZoom = value
  1038. }), preferences.get('externalLinkTarget').then(function resolved(value) {
  1039. if (_pdfjsLib.PDFJS.isExternalLinkTargetSet()) {
  1040. return
  1041. }
  1042. _pdfjsLib.PDFJS.externalLinkTarget = value
  1043. }), preferences.get('renderer').then(function resolved(value) {
  1044. viewerPrefs['renderer'] = value
  1045. }), preferences.get('renderInteractiveForms').then(function resolved(value) {
  1046. viewerPrefs['renderInteractiveForms'] = value
  1047. }), preferences.get('disablePageMode').then(function resolved(value) {
  1048. viewerPrefs['disablePageMode'] = value
  1049. }), preferences.get('disablePageLabels').then(function resolved(value) {
  1050. viewerPrefs['disablePageLabels'] = value
  1051. }), preferences.get('enablePrintAutoRotate').then(function resolved(value) {
  1052. viewerPrefs['enablePrintAutoRotate'] = value
  1053. })]).
  1054. catch(function(reason) {})
  1055. },
  1056. _initializeL10n: function _initializeL10n() {
  1057. if (this.viewerPrefs['pdfBugEnabled']) {
  1058. var hash = document.location.hash.substring(1);
  1059. var hashParams = (0, _ui_utils.parseQueryString)(hash);
  1060. if ('locale' in hashParams) {
  1061. _pdfjsLib.PDFJS.locale = hashParams['locale']
  1062. }
  1063. }
  1064. this.l10n = this.externalServices.createL10n();
  1065. return this.l10n.getDirection().then(function(dir) {
  1066. document.getElementsByTagName('html')[0].dir = dir
  1067. })
  1068. },
  1069. _initializeViewerComponents: function _initializeViewerComponents() {
  1070. var _this2 = this;
  1071. var appConfig = this.appConfig;
  1072. return new Promise(function(resolve, reject) {
  1073. _this2.overlayManager = new _overlay_manager.OverlayManager();
  1074. var eventBus = appConfig.eventBus || (0, _dom_events.getGlobalEventBus)();
  1075. _this2.eventBus = eventBus;
  1076. var pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  1077. pdfRenderingQueue.onIdle = _this2.cleanup.bind(_this2);
  1078. _this2.pdfRenderingQueue = pdfRenderingQueue;
  1079. var pdfLinkService = new _pdf_link_service.PDFLinkService({
  1080. eventBus: eventBus
  1081. });
  1082. _this2.pdfLinkService = pdfLinkService;
  1083. var downloadManager = _this2.externalServices.createDownloadManager();
  1084. _this2.downloadManager = downloadManager;
  1085. var container = appConfig.mainContainer;
  1086. var viewer = appConfig.viewerContainer;
  1087. _this2.pdfViewer = new _pdf_viewer.PDFViewer({
  1088. container: container,
  1089. viewer: viewer,
  1090. eventBus: eventBus,
  1091. renderingQueue: pdfRenderingQueue,
  1092. linkService: pdfLinkService,
  1093. downloadManager: downloadManager,
  1094. renderer: _this2.viewerPrefs['renderer'],
  1095. l10n: _this2.l10n,
  1096. enhanceTextSelection: _this2.viewerPrefs['enhanceTextSelection'],
  1097. renderInteractiveForms: _this2.viewerPrefs['renderInteractiveForms'],
  1098. enablePrintAutoRotate: _this2.viewerPrefs['enablePrintAutoRotate']
  1099. });
  1100. pdfRenderingQueue.setViewer(_this2.pdfViewer);
  1101. pdfLinkService.setViewer(_this2.pdfViewer);
  1102. var thumbnailContainer = appConfig.sidebar.thumbnailView;
  1103. _this2.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({
  1104. container: thumbnailContainer,
  1105. renderingQueue: pdfRenderingQueue,
  1106. linkService: pdfLinkService,
  1107. l10n: _this2.l10n
  1108. });
  1109. pdfRenderingQueue.setThumbnailViewer(_this2.pdfThumbnailViewer);
  1110. _this2.pdfHistory = new _pdf_history.PDFHistory({
  1111. linkService: pdfLinkService,
  1112. eventBus: eventBus
  1113. });
  1114. pdfLinkService.setHistory(_this2.pdfHistory);
  1115. _this2.findController = new _pdf_find_controller.PDFFindController({
  1116. pdfViewer: _this2.pdfViewer
  1117. });
  1118. _this2.findController.onUpdateResultsCount = function(matchCount) {
  1119. if (_this2.supportsIntegratedFind) {
  1120. return
  1121. }
  1122. _this2.findBar.updateResultsCount(matchCount)
  1123. };
  1124. _this2.findController.onUpdateState = function(state, previous, matchCount) {
  1125. if (_this2.supportsIntegratedFind) {
  1126. _this2.externalServices.updateFindControlState({
  1127. result: state,
  1128. findPrevious: previous
  1129. })
  1130. } else {
  1131. _this2.findBar.updateUIState(state, previous, matchCount)
  1132. }
  1133. };
  1134. _this2.pdfViewer.setFindController(_this2.findController);
  1135. var findBarConfig = Object.create(appConfig.findBar);
  1136. findBarConfig.findController = _this2.findController;
  1137. findBarConfig.eventBus = eventBus;
  1138. _this2.findBar = new _pdf_find_bar.PDFFindBar(findBarConfig, _this2.l10n);
  1139. _this2.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, _this2.overlayManager, _this2.l10n);
  1140. _this2.pdfCursorTools = new _pdf_cursor_tools.PDFCursorTools({
  1141. container: container,
  1142. eventBus: eventBus,
  1143. preferences: _this2.preferences
  1144. });
  1145. _this2.toolbar = new _toolbar.Toolbar(appConfig.toolbar, container, eventBus, _this2.l10n);
  1146. _this2.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus);
  1147. if (_this2.supportsFullscreen) {
  1148. _this2.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({
  1149. container: container,
  1150. viewer: viewer,
  1151. pdfViewer: _this2.pdfViewer,
  1152. eventBus: eventBus,
  1153. contextMenuItems: appConfig.fullscreen
  1154. })
  1155. }
  1156. _this2.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, _this2.overlayManager, _this2.l10n);
  1157. _this2.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({
  1158. container: appConfig.sidebar.outlineView,
  1159. eventBus: eventBus,
  1160. linkService: pdfLinkService
  1161. });
  1162. _this2.pdfAttachmentViewer = new _pdf_attachment_viewer.PDFAttachmentViewer({
  1163. container: appConfig.sidebar.attachmentsView,
  1164. eventBus: eventBus,
  1165. downloadManager: downloadManager
  1166. });
  1167. var sidebarConfig = Object.create(appConfig.sidebar);
  1168. sidebarConfig.pdfViewer = _this2.pdfViewer;
  1169. sidebarConfig.pdfThumbnailViewer = _this2.pdfThumbnailViewer;
  1170. sidebarConfig.pdfOutlineViewer = _this2.pdfOutlineViewer;
  1171. sidebarConfig.eventBus = eventBus;
  1172. _this2.pdfSidebar = new _pdf_sidebar.PDFSidebar(sidebarConfig, _this2.l10n);
  1173. _this2.pdfSidebar.onToggled = _this2.forceRendering.bind(_this2);
  1174. resolve(undefined)
  1175. })
  1176. },
  1177. run: function run(config) {
  1178. this.initialize(config).then(webViewerInitialized)
  1179. },
  1180. zoomIn: function zoomIn(ticks) {
  1181. var newScale = this.pdfViewer.currentScale;
  1182. do {
  1183. newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2);
  1184. newScale = Math.ceil(newScale * 10) / 10;
  1185. newScale = Math.min(_ui_utils.MAX_SCALE, newScale)
  1186. } while (-- ticks > 0 && newScale < _ui_utils . MAX_SCALE );
  1187. this.pdfViewer.currentScaleValue = newScale
  1188. },
  1189. zoomOut: function zoomOut(ticks) {
  1190. var newScale = this.pdfViewer.currentScale;
  1191. do {
  1192. newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2);
  1193. newScale = Math.floor(newScale * 10) / 10;
  1194. newScale = Math.max(_ui_utils.MIN_SCALE, newScale)
  1195. } while (-- ticks > 0 && newScale > _ui_utils . MIN_SCALE );
  1196. this.pdfViewer.currentScaleValue = newScale
  1197. },
  1198. get pagesCount() {
  1199. return this.pdfDocument ? this.pdfDocument.numPages: 0
  1200. },
  1201. get pageRotation() {
  1202. return this.pdfViewer.pagesRotation
  1203. },
  1204. set page(val) {
  1205. this.pdfViewer.currentPageNumber = val
  1206. },
  1207. get page() {
  1208. return this.pdfViewer.currentPageNumber
  1209. },
  1210. get printing() {
  1211. return !! this.printService
  1212. },
  1213. get supportsPrinting() {
  1214. return PDFPrintServiceFactory.instance.supportsPrinting
  1215. },
  1216. get supportsFullscreen() {
  1217. var support = void 0;
  1218. var doc = document.documentElement;
  1219. support = !!(doc.requestFullscreen || doc.mozRequestFullScreen || doc.webkitRequestFullScreen || doc.msRequestFullscreen);
  1220. if (document.fullscreenEnabled === false || document.mozFullScreenEnabled === false || document.webkitFullscreenEnabled === false || document.msFullscreenEnabled === false) {
  1221. support = false
  1222. }
  1223. if (support && _pdfjsLib.PDFJS.disableFullscreen === true) {
  1224. support = false
  1225. }
  1226. return (0, _pdfjsLib.shadow)(this, 'supportsFullscreen', support)
  1227. },
  1228. get supportsIntegratedFind() {
  1229. return this.externalServices.supportsIntegratedFind
  1230. },
  1231. get supportsDocumentFonts() {
  1232. return this.externalServices.supportsDocumentFonts
  1233. },
  1234. get supportsDocumentColors() {
  1235. return this.externalServices.supportsDocumentColors
  1236. },
  1237. get loadingBar() {
  1238. var bar = new _ui_utils.ProgressBar('#loadingBar');
  1239. return (0, _pdfjsLib.shadow)(this, 'loadingBar', bar)
  1240. },
  1241. get supportedMouseWheelZoomModifierKeys() {
  1242. return this.externalServices.supportedMouseWheelZoomModifierKeys
  1243. },
  1244. initPassiveLoading: function initPassiveLoading() {
  1245. throw new Error('Not implemented: initPassiveLoading');
  1246. },
  1247. setTitleUsingUrl: function setTitleUsingUrl(url) {
  1248. this.url = url;
  1249. this.baseUrl = url.split('#')[0];
  1250. var title = (0, _ui_utils.getPDFFileNameFromURL)(url, '');
  1251. if (!title) {
  1252. try {
  1253. title = decodeURIComponent((0, _pdfjsLib.getFilenameFromUrl)(url)) || url
  1254. } catch(ex) {
  1255. title = url
  1256. }
  1257. }
  1258. this.setTitle(title)
  1259. },
  1260. setTitle: function setTitle(title) {
  1261. if (this.isViewerEmbedded) {
  1262. return
  1263. }
  1264. document.title = title
  1265. },
  1266. close: function close() {
  1267. var errorWrapper = this.appConfig.errorWrapper.container;
  1268. errorWrapper.setAttribute('hidden', 'true');
  1269. if (!this.pdfLoadingTask) {
  1270. return Promise.resolve()
  1271. }
  1272. var promise = this.pdfLoadingTask.destroy();
  1273. this.pdfLoadingTask = null;
  1274. if (this.pdfDocument) {
  1275. this.pdfDocument = null;
  1276. this.pdfThumbnailViewer.setDocument(null);
  1277. this.pdfViewer.setDocument(null);
  1278. this.pdfLinkService.setDocument(null, null);
  1279. this.pdfDocumentProperties.setDocument(null, null)
  1280. }
  1281. this.store = null;
  1282. this.isInitialViewSet = false;
  1283. this.downloadComplete = false;
  1284. this.pdfSidebar.reset();
  1285. this.pdfOutlineViewer.reset();
  1286. this.pdfAttachmentViewer.reset();
  1287. this.findController.reset();
  1288. this.findBar.reset();
  1289. this.toolbar.reset();
  1290. this.secondaryToolbar.reset();
  1291. if (typeof PDFBug !== 'undefined') {
  1292. PDFBug.cleanup()
  1293. }
  1294. return promise
  1295. },
  1296. open: function open(file, args) {
  1297. var _this3 = this;
  1298. if (arguments.length > 2 || typeof args === 'number') {
  1299. return Promise.reject(new Error('Call of open() with obsolete signature.'))
  1300. }
  1301. if (this.pdfLoadingTask) {
  1302. return this.close().then(function() {
  1303. _this3.preferences.reload();
  1304. return _this3.open(file, args)
  1305. })
  1306. }
  1307. var parameters = Object.create(null),
  1308. scale = void 0;
  1309. if (typeof file === 'string') {
  1310. this.setTitleUsingUrl(file);
  1311. parameters.url = file
  1312. } else if (file && 'byteLength' in file) {
  1313. parameters.data = file
  1314. } else if (file.url && file.originalUrl) {
  1315. this.setTitleUsingUrl(file.originalUrl);
  1316. parameters.url = file.url
  1317. }
  1318. if (args) {
  1319. for (var prop in args) {
  1320. parameters[prop] = args[prop]
  1321. }
  1322. if (args.scale) {
  1323. scale = args.scale
  1324. }
  1325. if (args.length) {
  1326. this.pdfDocumentProperties.setFileSize(args.length)
  1327. }
  1328. }
  1329. var loadingTask = (0, _pdfjsLib.getDocument)(parameters);
  1330. this.pdfLoadingTask = loadingTask;
  1331. loadingTask.onPassword = function(updateCallback, reason) {
  1332. _this3.passwordPrompt.setUpdateCallback(updateCallback, reason);
  1333. _this3.passwordPrompt.open()
  1334. };
  1335. loadingTask.onProgress = function(_ref) {
  1336. var loaded = _ref.loaded,
  1337. total = _ref.total;
  1338. _this3.progress(loaded / total)
  1339. };
  1340. loadingTask.onUnsupportedFeature = this.fallback.bind(this);
  1341. return loadingTask.promise.then(function(pdfDocument) {
  1342. _this3.load(pdfDocument, scale)
  1343. },
  1344. function(exception) {
  1345. var message = exception && exception.message;
  1346. var loadingErrorMessage = void 0;
  1347. if (exception instanceof _pdfjsLib.InvalidPDFException) {
  1348. loadingErrorMessage = _this3.l10n.get('invalid_file_error', null, 'Invalid or corrupted PDF file.')
  1349. } else if (exception instanceof _pdfjsLib.MissingPDFException) {
  1350. loadingErrorMessage = _this3.l10n.get('missing_file_error', null, 'Missing PDF file.')
  1351. } else if (exception instanceof _pdfjsLib.UnexpectedResponseException) {
  1352. loadingErrorMessage = _this3.l10n.get('unexpected_response_error', null, 'Unexpected server response.')
  1353. } else {
  1354. loadingErrorMessage = _this3.l10n.get('loading_error', null, 'An error occurred while loading the PDF.')
  1355. }
  1356. return loadingErrorMessage.then(function(msg) {
  1357. _this3.error(msg, {
  1358. message: message
  1359. });
  1360. throw new Error(msg);
  1361. })
  1362. })
  1363. },
  1364. download: function download() {
  1365. var _this4 = this;
  1366. function downloadByUrl() {
  1367. downloadManager.downloadUrl(url, filename)
  1368. }
  1369. var url = this.baseUrl;
  1370. var filename = (0, _ui_utils.getPDFFileNameFromURL)(this.url);
  1371. var downloadManager = this.downloadManager;
  1372. downloadManager.onerror = function(err) {
  1373. _this4.error('PDF failed to download: ' + err)
  1374. };
  1375. if (!this.pdfDocument || !this.downloadComplete) {
  1376. downloadByUrl();
  1377. return
  1378. }
  1379. this.pdfDocument.getData().then(function(data) {
  1380. var blob = (0, _pdfjsLib.createBlob)(data, 'application/pdf');
  1381. downloadManager.download(blob, url, filename)
  1382. }).
  1383. catch(downloadByUrl)
  1384. },
  1385. fallback: function fallback(featureId) {},
  1386. error: function error(message, moreInfo) {
  1387. var moreInfoText = [this.l10n.get('error_version_info', {
  1388. version: _pdfjsLib.version || '?',
  1389. build: _pdfjsLib.build || '?'
  1390. },
  1391. 'PDF.js v{{version}} (build: {{build}})')];
  1392. if (moreInfo) {
  1393. moreInfoText.push(this.l10n.get('error_message', {
  1394. message: moreInfo.message
  1395. },
  1396. 'Message: {{message}}'));
  1397. if (moreInfo.stack) {
  1398. moreInfoText.push(this.l10n.get('error_stack', {
  1399. stack: moreInfo.stack
  1400. },
  1401. 'Stack: {{stack}}'))
  1402. } else {
  1403. if (moreInfo.filename) {
  1404. moreInfoText.push(this.l10n.get('error_file', {
  1405. file: moreInfo.filename
  1406. },
  1407. 'File: {{file}}'))
  1408. }
  1409. if (moreInfo.lineNumber) {
  1410. moreInfoText.push(this.l10n.get('error_line', {
  1411. line: moreInfo.lineNumber
  1412. },
  1413. 'Line: {{line}}'))
  1414. }
  1415. }
  1416. }
  1417. var errorWrapperConfig = this.appConfig.errorWrapper;
  1418. var errorWrapper = errorWrapperConfig.container;
  1419. errorWrapper.removeAttribute('hidden');
  1420. var errorMessage = errorWrapperConfig.errorMessage;
  1421. errorMessage.textContent = message;
  1422. var closeButton = errorWrapperConfig.closeButton;
  1423. closeButton.onclick = function() {
  1424. errorWrapper.setAttribute('hidden', 'true')
  1425. };
  1426. var errorMoreInfo = errorWrapperConfig.errorMoreInfo;
  1427. var moreInfoButton = errorWrapperConfig.moreInfoButton;
  1428. var lessInfoButton = errorWrapperConfig.lessInfoButton;
  1429. moreInfoButton.onclick = function() {
  1430. errorMoreInfo.removeAttribute('hidden');
  1431. moreInfoButton.setAttribute('hidden', 'true');
  1432. lessInfoButton.removeAttribute('hidden');
  1433. errorMoreInfo.style.height = errorMoreInfo.scrollHeight + 'px'
  1434. };
  1435. lessInfoButton.onclick = function() {
  1436. errorMoreInfo.setAttribute('hidden', 'true');
  1437. moreInfoButton.removeAttribute('hidden');
  1438. lessInfoButton.setAttribute('hidden', 'true')
  1439. };
  1440. moreInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1441. lessInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1442. closeButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1443. moreInfoButton.removeAttribute('hidden');
  1444. lessInfoButton.setAttribute('hidden', 'true');
  1445. Promise.all(moreInfoText).then(function(parts) {
  1446. errorMoreInfo.value = parts.join('\n')
  1447. })
  1448. },
  1449. progress: function progress(level) {
  1450. var _this5 = this;
  1451. if (this.downloadComplete) {
  1452. return
  1453. }
  1454. var percent = Math.round(level * 100);
  1455. if (percent > this.loadingBar.percent || isNaN(percent)) {
  1456. this.loadingBar.percent = percent;
  1457. if (_pdfjsLib.PDFJS.disableAutoFetch && percent) {
  1458. if (this.disableAutoFetchLoadingBarTimeout) {
  1459. clearTimeout(this.disableAutoFetchLoadingBarTimeout);
  1460. this.disableAutoFetchLoadingBarTimeout = null
  1461. }
  1462. this.loadingBar.show();
  1463. this.disableAutoFetchLoadingBarTimeout = setTimeout(function() {
  1464. _this5.loadingBar.hide();
  1465. _this5.disableAutoFetchLoadingBarTimeout = null
  1466. },
  1467. DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT)
  1468. }
  1469. }
  1470. },
  1471. load: function load(pdfDocument, scale) {
  1472. var _this6 = this;
  1473. scale = scale || _ui_utils.UNKNOWN_SCALE;
  1474. this.pdfDocument = pdfDocument;
  1475. pdfDocument.getDownloadInfo().then(function() {
  1476. _this6.downloadComplete = true;
  1477. _this6.loadingBar.hide();
  1478. firstPagePromise.then(function() {
  1479. _this6.eventBus.dispatch('documentload', {
  1480. source: _this6
  1481. })
  1482. })
  1483. });
  1484. var pageModePromise = pdfDocument.getPageMode().
  1485. catch(function() {});
  1486. this.toolbar.setPagesCount(pdfDocument.numPages, false);
  1487. this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
  1488. var id = this.documentFingerprint = pdfDocument.fingerprint;
  1489. var store = this.store = new _view_history.ViewHistory(id);
  1490. var baseDocumentUrl = void 0;
  1491. baseDocumentUrl = null;
  1492. this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
  1493. this.pdfDocumentProperties.setDocument(pdfDocument, this.url);
  1494. var pdfViewer = this.pdfViewer;
  1495. pdfViewer.setDocument(pdfDocument);
  1496. var firstPagePromise = pdfViewer.firstPagePromise;
  1497. var pagesPromise = pdfViewer.pagesPromise;
  1498. var onePageRendered = pdfViewer.onePageRendered;
  1499. var pdfThumbnailViewer = this.pdfThumbnailViewer;
  1500. pdfThumbnailViewer.setDocument(pdfDocument);
  1501. firstPagePromise.then(function(pdfPage) {
  1502. _this6.loadingBar.setWidth(_this6.appConfig.viewerContainer);
  1503. if (!_pdfjsLib.PDFJS.disableHistory && !_this6.isViewerEmbedded) {
  1504. if (!_this6.viewerPrefs['showPreviousViewOnLoad']) {
  1505. _this6.pdfHistory.clearHistoryState()
  1506. }
  1507. _this6.pdfHistory.initialize(_this6.documentFingerprint);
  1508. if (_this6.pdfHistory.initialDestination) {
  1509. _this6.initialDestination = _this6.pdfHistory.initialDestination
  1510. } else if (_this6.pdfHistory.initialBookmark) {
  1511. _this6.initialBookmark = _this6.pdfHistory.initialBookmark
  1512. }
  1513. }
  1514. var initialParams = {
  1515. destination: _this6.initialDestination,
  1516. bookmark: _this6.initialBookmark,
  1517. hash: null
  1518. };
  1519. var storePromise = store.getMultiple({
  1520. exists: false,
  1521. page: '1',
  1522. zoom: _ui_utils.DEFAULT_SCALE_VALUE,
  1523. scrollLeft: '0',
  1524. scrollTop: '0',
  1525. sidebarView: _pdf_sidebar.SidebarView.NONE
  1526. }).
  1527. catch(function() {});
  1528. Promise.all([storePromise, pageModePromise]).then(function(_ref2) {
  1529. var _ref3 = _slicedToArray(_ref2, 2),
  1530. _ref3$ = _ref3[0],
  1531. values = _ref3$ === undefined ? {}: _ref3$,
  1532. pageMode = _ref3[1];
  1533. var hash = _this6.viewerPrefs['defaultZoomValue'] ? 'zoom=' + _this6.viewerPrefs['defaultZoomValue'] : null;
  1534. var sidebarView = _this6.viewerPrefs['sidebarViewOnLoad'];
  1535. if (values.exists && _this6.viewerPrefs['showPreviousViewOnLoad']) {
  1536. hash = 'page=' + values.page + '&zoom=' + (_this6.viewerPrefs['defaultZoomValue'] || values.zoom) + ',' + values.scrollLeft + ',' + values.scrollTop;
  1537. sidebarView = sidebarView || values.sidebarView | 0
  1538. }
  1539. if (pageMode && !_this6.viewerPrefs['disablePageMode']) {
  1540. sidebarView = sidebarView || apiPageModeToSidebarView(pageMode)
  1541. }
  1542. return {
  1543. hash: hash,
  1544. sidebarView: sidebarView
  1545. }
  1546. }).then(function(_ref4) {
  1547. var hash = _ref4.hash,
  1548. sidebarView = _ref4.sidebarView;
  1549. _this6.setInitialView(hash, {
  1550. sidebarView: sidebarView,
  1551. scale: scale
  1552. });
  1553. initialParams.hash = hash;
  1554. if (!_this6.isViewerEmbedded) {
  1555. pdfViewer.focus()
  1556. }
  1557. return pagesPromise
  1558. }).then(function() {
  1559. if (!initialParams.destination && !initialParams.bookmark && !initialParams.hash) {
  1560. return
  1561. }
  1562. if (pdfViewer.hasEqualPageSizes) {
  1563. return
  1564. }
  1565. _this6.initialDestination = initialParams.destination;
  1566. _this6.initialBookmark = initialParams.bookmark;
  1567. pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;
  1568. _this6.setInitialView(initialParams.hash)
  1569. }).then(function() {
  1570. pdfViewer.update()
  1571. })
  1572. });
  1573. pdfDocument.getPageLabels().then(function(labels) {
  1574. if (!labels || _this6.viewerPrefs['disablePageLabels']) {
  1575. return
  1576. }
  1577. var i = 0,
  1578. numLabels = labels.length;
  1579. if (numLabels !== _this6.pagesCount) {
  1580. console.error('The number of Page Labels does not match ' + 'the number of pages in the document.');
  1581. return
  1582. }
  1583. while (i < numLabels && labels[i] === (i + 1).toString()) {
  1584. i++
  1585. }
  1586. if (i === numLabels) {
  1587. return
  1588. }
  1589. pdfViewer.setPageLabels(labels);
  1590. pdfThumbnailViewer.setPageLabels(labels);
  1591. _this6.toolbar.setPagesCount(pdfDocument.numPages, true);
  1592. _this6.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel)
  1593. });
  1594. pagesPromise.then(function() {
  1595. if (!_this6.supportsPrinting) {
  1596. return
  1597. }
  1598. pdfDocument.getJavaScript().then(function(javaScript) {
  1599. if (javaScript.length) {
  1600. console.warn('Warning: JavaScript is not supported');
  1601. _this6.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.javaScript)
  1602. }
  1603. var regex = /\bprint\s*\(/;
  1604. for (var i = 0,
  1605. ii = javaScript.length; i < ii; i++) {
  1606. var js = javaScript[i];
  1607. if (js && regex.test(js)) {
  1608. setTimeout(function() {
  1609. window.print()
  1610. });
  1611. return
  1612. }
  1613. }
  1614. })
  1615. });
  1616. Promise.all([onePageRendered, _ui_utils.animationStarted]).then(function() {
  1617. pdfDocument.getOutline().then(function(outline) {
  1618. _this6.pdfOutlineViewer.render({
  1619. outline: outline
  1620. })
  1621. });
  1622. pdfDocument.getAttachments().then(function(attachments) {
  1623. _this6.pdfAttachmentViewer.render({
  1624. attachments: attachments
  1625. })
  1626. })
  1627. });
  1628. pdfDocument.getMetadata().then(function(_ref5) {
  1629. var info = _ref5.info,
  1630. metadata = _ref5.metadata;
  1631. _this6.documentInfo = info;
  1632. _this6.metadata = metadata;
  1633. console.log('PDF ' + pdfDocument.fingerprint + ' [' + info.PDFFormatVersion + ' ' + (info.Producer || '-').trim() + ' / ' + (info.Creator || '-').trim() + ']' + ' (PDF.js: ' + (_pdfjsLib.version || '-') + (!_pdfjsLib.PDFJS.disableWebGL ? ' [WebGL]': '') + ')');
  1634. var pdfTitle = void 0;
  1635. if (metadata && metadata.has('dc:title')) {
  1636. var title = metadata.get('dc:title');
  1637. if (title !== 'Untitled') {
  1638. pdfTitle = title
  1639. }
  1640. }
  1641. if (!pdfTitle && info && info['Title']) {
  1642. pdfTitle = info['Title']
  1643. }
  1644. if (pdfTitle) {
  1645. _this6.setTitle(pdfTitle + ' - ' + document.title)
  1646. }
  1647. if (info.IsAcroFormPresent) {
  1648. console.warn('Warning: AcroForm/XFA is not supported');
  1649. _this6.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms)
  1650. }
  1651. })
  1652. },
  1653. setInitialView: function setInitialView(storedHash) {
  1654. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1655. var _options$scale = options.scale,
  1656. scale = _options$scale === undefined ? 0 : _options$scale,
  1657. _options$sidebarView = options.sidebarView,
  1658. sidebarView = _options$sidebarView === undefined ? _pdf_sidebar.SidebarView.NONE: _options$sidebarView;
  1659. this.isInitialViewSet = true;
  1660. this.pdfSidebar.setInitialView(sidebarView);
  1661. if (this.initialDestination) {
  1662. this.pdfLinkService.navigateTo(this.initialDestination);
  1663. this.initialDestination = null
  1664. } else if (this.initialBookmark) {
  1665. this.pdfLinkService.setHash(this.initialBookmark);
  1666. this.pdfHistory.push({
  1667. hash: this.initialBookmark
  1668. },
  1669. true);
  1670. this.initialBookmark = null
  1671. } else if (storedHash) {
  1672. this.pdfLinkService.setHash(storedHash)
  1673. } else if (scale) {
  1674. this.pdfViewer.currentScaleValue = scale;
  1675. this.page = 1
  1676. }
  1677. this.toolbar.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel);
  1678. this.secondaryToolbar.setPageNumber(this.pdfViewer.currentPageNumber);
  1679. if (!this.pdfViewer.currentScaleValue) {
  1680. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE
  1681. }
  1682. },
  1683. cleanup: function cleanup() {
  1684. if (!this.pdfDocument) {
  1685. return
  1686. }
  1687. this.pdfViewer.cleanup();
  1688. this.pdfThumbnailViewer.cleanup();
  1689. if (this.pdfViewer.renderer !== _ui_utils.RendererType.SVG) {
  1690. this.pdfDocument.cleanup()
  1691. }
  1692. },
  1693. forceRendering: function forceRendering() {
  1694. this.pdfRenderingQueue.printing = this.printing;
  1695. this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar.isThumbnailViewVisible;
  1696. this.pdfRenderingQueue.renderHighestPriority()
  1697. },
  1698. beforePrint: function beforePrint() {
  1699. var _this7 = this;
  1700. if (this.printService) {
  1701. return
  1702. }
  1703. if (!this.supportsPrinting) {
  1704. this.l10n.get('printing_not_supported', null, 'Warning: Printing is not fully supported by ' + 'this browser.').then(function(printMessage) {
  1705. _this7.error(printMessage)
  1706. });
  1707. return
  1708. }
  1709. if (!this.pdfViewer.pageViewsReady) {
  1710. this.l10n.get('printing_not_ready', null, 'Warning: The PDF is not fully loaded for printing.').then(function(notReadyMessage) {
  1711. window.alert(notReadyMessage)
  1712. });
  1713. return
  1714. }
  1715. var pagesOverview = this.pdfViewer.getPagesOverview();
  1716. var printContainer = this.appConfig.printContainer;
  1717. var printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument, pagesOverview, printContainer, this.l10n);
  1718. this.printService = printService;
  1719. this.forceRendering();
  1720. printService.layout()
  1721. },
  1722. afterPrint: function pdfViewSetupAfterPrint() {
  1723. if (this.printService) {
  1724. this.printService.destroy();
  1725. this.printService = null
  1726. }
  1727. this.forceRendering()
  1728. },
  1729. rotatePages: function rotatePages(delta) {
  1730. if (!this.pdfDocument) {
  1731. return
  1732. }
  1733. var pdfViewer = this.pdfViewer,
  1734. pdfThumbnailViewer = this.pdfThumbnailViewer;
  1735. var pageNumber = pdfViewer.currentPageNumber;
  1736. var newRotation = (pdfViewer.pagesRotation + 360 + delta) % 360;
  1737. pdfViewer.pagesRotation = newRotation;
  1738. pdfThumbnailViewer.pagesRotation = newRotation;
  1739. this.forceRendering();
  1740. pdfViewer.currentPageNumber = pageNumber
  1741. },
  1742. requestPresentationMode: function requestPresentationMode() {
  1743. if (!this.pdfPresentationMode) {
  1744. return
  1745. }
  1746. this.pdfPresentationMode.request()
  1747. },
  1748. bindEvents: function bindEvents() {
  1749. var eventBus = this.eventBus,
  1750. _boundEvents = this._boundEvents;
  1751. _boundEvents.beforePrint = this.beforePrint.bind(this);
  1752. _boundEvents.afterPrint = this.afterPrint.bind(this);
  1753. eventBus.on('resize', webViewerResize);
  1754. eventBus.on('hashchange', webViewerHashchange);
  1755. eventBus.on('beforeprint', _boundEvents.beforePrint);
  1756. eventBus.on('afterprint', _boundEvents.afterPrint);
  1757. eventBus.on('pagerendered', webViewerPageRendered);
  1758. eventBus.on('textlayerrendered', webViewerTextLayerRendered);
  1759. eventBus.on('updateviewarea', webViewerUpdateViewarea);
  1760. eventBus.on('pagechanging', webViewerPageChanging);
  1761. eventBus.on('scalechanging', webViewerScaleChanging);
  1762. eventBus.on('sidebarviewchanged', webViewerSidebarViewChanged);
  1763. eventBus.on('pagemode', webViewerPageMode);
  1764. eventBus.on('namedaction', webViewerNamedAction);
  1765. eventBus.on('presentationmodechanged', webViewerPresentationModeChanged);
  1766. eventBus.on('presentationmode', webViewerPresentationMode);
  1767. eventBus.on('openfile', webViewerOpenFile);
  1768. eventBus.on('print', webViewerPrint);
  1769. eventBus.on('download', webViewerDownload);
  1770. eventBus.on('firstpage', webViewerFirstPage);
  1771. eventBus.on('lastpage', webViewerLastPage);
  1772. eventBus.on('nextpage', webViewerNextPage);
  1773. eventBus.on('previouspage', webViewerPreviousPage);
  1774. eventBus.on('zoomin', webViewerZoomIn);
  1775. eventBus.on('zoomout', webViewerZoomOut);
  1776. eventBus.on('pagenumberchanged', webViewerPageNumberChanged);
  1777. eventBus.on('scalechanged', webViewerScaleChanged);
  1778. eventBus.on('rotatecw', webViewerRotateCw);
  1779. eventBus.on('rotateccw', webViewerRotateCcw);
  1780. eventBus.on('documentproperties', webViewerDocumentProperties);
  1781. eventBus.on('find', webViewerFind);
  1782. eventBus.on('findfromurlhash', webViewerFindFromUrlHash);
  1783. eventBus.on('fileinputchange', webViewerFileInputChange)
  1784. },
  1785. bindWindowEvents: function bindWindowEvents() {
  1786. var eventBus = this.eventBus,
  1787. _boundEvents = this._boundEvents;
  1788. _boundEvents.windowResize = function() {
  1789. eventBus.dispatch('resize')
  1790. };
  1791. _boundEvents.windowHashChange = function() {
  1792. eventBus.dispatch('hashchange', {
  1793. hash: document.location.hash.substring(1)
  1794. })
  1795. };
  1796. _boundEvents.windowBeforePrint = function() {
  1797. eventBus.dispatch('beforeprint')
  1798. };
  1799. _boundEvents.windowAfterPrint = function() {
  1800. eventBus.dispatch('afterprint')
  1801. };
  1802. window.addEventListener('wheel', webViewerWheel);
  1803. window.addEventListener('click', webViewerClick);
  1804. window.addEventListener('keydown', webViewerKeyDown);
  1805. window.addEventListener('resize', _boundEvents.windowResize);
  1806. window.addEventListener('hashchange', _boundEvents.windowHashChange);
  1807. window.addEventListener('beforeprint', _boundEvents.windowBeforePrint);
  1808. window.addEventListener('afterprint', _boundEvents.windowAfterPrint);
  1809. _boundEvents.windowChange = function(evt) {
  1810. var files = evt.target.files;
  1811. if (!files || files.length === 0) {
  1812. return
  1813. }
  1814. eventBus.dispatch('fileinputchange', {
  1815. fileInput: evt.target
  1816. })
  1817. };
  1818. window.addEventListener('change', _boundEvents.windowChange)
  1819. },
  1820. unbindEvents: function unbindEvents() {
  1821. var eventBus = this.eventBus,
  1822. _boundEvents = this._boundEvents;
  1823. eventBus.off('resize', webViewerResize);
  1824. eventBus.off('hashchange', webViewerHashchange);
  1825. eventBus.off('beforeprint', _boundEvents.beforePrint);
  1826. eventBus.off('afterprint', _boundEvents.afterPrint);
  1827. eventBus.off('pagerendered', webViewerPageRendered);
  1828. eventBus.off('textlayerrendered', webViewerTextLayerRendered);
  1829. eventBus.off('updateviewarea', webViewerUpdateViewarea);
  1830. eventBus.off('pagechanging', webViewerPageChanging);
  1831. eventBus.off('scalechanging', webViewerScaleChanging);
  1832. eventBus.off('sidebarviewchanged', webViewerSidebarViewChanged);
  1833. eventBus.off('pagemode', webViewerPageMode);
  1834. eventBus.off('namedaction', webViewerNamedAction);
  1835. eventBus.off('presentationmodechanged', webViewerPresentationModeChanged);
  1836. eventBus.off('presentationmode', webViewerPresentationMode);
  1837. eventBus.off('openfile', webViewerOpenFile);
  1838. eventBus.off('print', webViewerPrint);
  1839. eventBus.off('download', webViewerDownload);
  1840. eventBus.off('firstpage', webViewerFirstPage);
  1841. eventBus.off('lastpage', webViewerLastPage);
  1842. eventBus.off('nextpage', webViewerNextPage);
  1843. eventBus.off('previouspage', webViewerPreviousPage);
  1844. eventBus.off('zoomin', webViewerZoomIn);
  1845. eventBus.off('zoomout', webViewerZoomOut);
  1846. eventBus.off('pagenumberchanged', webViewerPageNumberChanged);
  1847. eventBus.off('scalechanged', webViewerScaleChanged);
  1848. eventBus.off('rotatecw', webViewerRotateCw);
  1849. eventBus.off('rotateccw', webViewerRotateCcw);
  1850. eventBus.off('documentproperties', webViewerDocumentProperties);
  1851. eventBus.off('find', webViewerFind);
  1852. eventBus.off('findfromurlhash', webViewerFindFromUrlHash);
  1853. eventBus.off('fileinputchange', webViewerFileInputChange);
  1854. _boundEvents.beforePrint = null;
  1855. _boundEvents.afterPrint = null
  1856. },
  1857. unbindWindowEvents: function unbindWindowEvents() {
  1858. var _boundEvents = this._boundEvents;
  1859. window.removeEventListener('wheel', webViewerWheel);
  1860. window.removeEventListener('click', webViewerClick);
  1861. window.removeEventListener('keydown', webViewerKeyDown);
  1862. window.removeEventListener('resize', _boundEvents.windowResize);
  1863. window.removeEventListener('hashchange', _boundEvents.windowHashChange);
  1864. window.removeEventListener('beforeprint', _boundEvents.windowBeforePrint);
  1865. window.removeEventListener('afterprint', _boundEvents.windowAfterPrint);
  1866. window.removeEventListener('change', _boundEvents.windowChange);
  1867. _boundEvents.windowChange = null;
  1868. _boundEvents.windowResize = null;
  1869. _boundEvents.windowHashChange = null;
  1870. _boundEvents.windowBeforePrint = null;
  1871. _boundEvents.windowAfterPrint = null
  1872. }
  1873. };
  1874. var validateFileURL = void 0; {
  1875. var HOSTED_VIEWER_ORIGINS = ['null', 'http://mozilla.github.io', 'https://mozilla.github.io'];
  1876. validateFileURL = function validateFileURL(file) {
  1877. if (file === undefined) {
  1878. return
  1879. }
  1880. try {
  1881. var viewerOrigin = new URL(window.location.href).origin || 'null';
  1882. if (HOSTED_VIEWER_ORIGINS.indexOf(viewerOrigin) >= 0) {
  1883. return
  1884. }
  1885. var fileOrigin = new URL(file, window.location.href).origin;
  1886. if (fileOrigin !== viewerOrigin) {
  1887. throw new Error('file origin does not match viewer\'s');
  1888. }
  1889. } catch(ex) {
  1890. var message = ex && ex.message;
  1891. PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.').then(function(loadingErrorMessage) {
  1892. PDFViewerApplication.error(loadingErrorMessage, {
  1893. message: message
  1894. })
  1895. });
  1896. throw ex;
  1897. }
  1898. }
  1899. }
  1900. function loadAndEnablePDFBug(enabledTabs) {
  1901. return new Promise(function(resolve, reject) {
  1902. var appConfig = PDFViewerApplication.appConfig;
  1903. var script = document.createElement('script');
  1904. script.src = appConfig.debuggerScriptPath;
  1905. script.onload = function() {
  1906. PDFBug.enable(enabledTabs);
  1907. PDFBug.init({
  1908. PDFJS: _pdfjsLib.PDFJS,
  1909. OPS: _pdfjsLib.OPS
  1910. },
  1911. appConfig.mainContainer);
  1912. resolve()
  1913. };
  1914. script.onerror = function() {
  1915. reject(new Error('Cannot load debugger at ' + script.src))
  1916. }; (document.getElementsByTagName('head')[0] || document.body).appendChild(script)
  1917. })
  1918. }
  1919. function webViewerInitialized() {
  1920. var appConfig = PDFViewerApplication.appConfig;
  1921. var file = void 0;
  1922. var queryString = document.location.search.substring(1);
  1923. var params = (0, _ui_utils.parseQueryString)(queryString);
  1924. file = 'file' in params ? params.file: appConfig.defaultUrl;
  1925. validateFileURL(file);
  1926. var waitForBeforeOpening = [];
  1927. var fileInput = document.createElement('input');
  1928. fileInput.id = appConfig.openFileInputName;
  1929. fileInput.className = 'fileInput';
  1930. fileInput.setAttribute('type', 'file');
  1931. fileInput.oncontextmenu = _ui_utils.noContextMenuHandler;
  1932. document.body.appendChild(fileInput);
  1933. if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
  1934. appConfig.toolbar.openFile.setAttribute('hidden', 'true');
  1935. appConfig.secondaryToolbar.openFileButton.setAttribute('hidden', 'true')
  1936. } else {
  1937. fileInput.value = null
  1938. }
  1939. if (PDFViewerApplication.viewerPrefs['pdfBugEnabled']) {
  1940. var hash = document.location.hash.substring(1);
  1941. var hashParams = (0, _ui_utils.parseQueryString)(hash);
  1942. if ('disableworker' in hashParams) {
  1943. _pdfjsLib.PDFJS.disableWorker = hashParams['disableworker'] === 'true'
  1944. }
  1945. if ('disablerange' in hashParams) {
  1946. _pdfjsLib.PDFJS.disableRange = hashParams['disablerange'] === 'true'
  1947. }
  1948. if ('disablestream' in hashParams) {
  1949. _pdfjsLib.PDFJS.disableStream = hashParams['disablestream'] === 'true'
  1950. }
  1951. if ('disableautofetch' in hashParams) {
  1952. _pdfjsLib.PDFJS.disableAutoFetch = hashParams['disableautofetch'] === 'true'
  1953. }
  1954. if ('disablefontface' in hashParams) {
  1955. _pdfjsLib.PDFJS.disableFontFace = hashParams['disablefontface'] === 'true'
  1956. }
  1957. if ('disablehistory' in hashParams) {
  1958. _pdfjsLib.PDFJS.disableHistory = hashParams['disablehistory'] === 'true'
  1959. }
  1960. if ('webgl' in hashParams) {
  1961. _pdfjsLib.PDFJS.disableWebGL = hashParams['webgl'] !== 'true'
  1962. }
  1963. if ('useonlycsszoom' in hashParams) {
  1964. _pdfjsLib.PDFJS.useOnlyCssZoom = hashParams['useonlycsszoom'] === 'true'
  1965. }
  1966. if ('verbosity' in hashParams) {
  1967. _pdfjsLib.PDFJS.verbosity = hashParams['verbosity'] | 0
  1968. }
  1969. if ('ignorecurrentpositiononzoom' in hashParams) {
  1970. _pdfjsLib.PDFJS.ignoreCurrentPositionOnZoom = hashParams['ignorecurrentpositiononzoom'] === 'true'
  1971. }
  1972. if ('textlayer' in hashParams) {
  1973. switch (hashParams['textlayer']) {
  1974. case 'off':
  1975. _pdfjsLib.PDFJS.disableTextLayer = true;
  1976. break;
  1977. case 'visible':
  1978. case 'shadow':
  1979. case 'hover':
  1980. var viewer = appConfig.viewerContainer;
  1981. viewer.classList.add('textLayer-' + hashParams['textlayer']);
  1982. break
  1983. }
  1984. }
  1985. if ('pdfbug' in hashParams) {
  1986. _pdfjsLib.PDFJS.pdfBug = true;
  1987. var pdfBug = hashParams['pdfbug'];
  1988. var enabled = pdfBug.split(',');
  1989. waitForBeforeOpening.push(loadAndEnablePDFBug(enabled))
  1990. }
  1991. }
  1992. if (!PDFViewerApplication.supportsPrinting) {
  1993. appConfig.toolbar.print.classList.add('hidden');
  1994. appConfig.secondaryToolbar.printButton.classList.add('hidden')
  1995. }
  1996. if (!PDFViewerApplication.supportsFullscreen) {
  1997. appConfig.toolbar.presentationModeButton.classList.add('hidden');
  1998. appConfig.secondaryToolbar.presentationModeButton.classList.add('hidden')
  1999. }
  2000. if (PDFViewerApplication.supportsIntegratedFind) {
  2001. appConfig.toolbar.viewFind.classList.add('hidden')
  2002. }
  2003. appConfig.sidebar.mainContainer.addEventListener('transitionend',
  2004. function(evt) {
  2005. if (evt.target === this) {
  2006. PDFViewerApplication.eventBus.dispatch('resize')
  2007. }
  2008. },
  2009. true);
  2010. appConfig.sidebar.toggleButton.addEventListener('click',
  2011. function() {
  2012. PDFViewerApplication.pdfSidebar.toggle()
  2013. });
  2014. Promise.all(waitForBeforeOpening).then(function() {
  2015. webViewerOpenFileViaURL(file)
  2016. }).
  2017. catch(function(reason) {
  2018. PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while opening.').then(function(msg) {
  2019. PDFViewerApplication.error(msg, reason)
  2020. })
  2021. })
  2022. }
  2023. var webViewerOpenFileViaURL = void 0; {
  2024. webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) {
  2025. if (file && file.lastIndexOf('file:', 0) === 0) {
  2026. PDFViewerApplication.setTitleUsingUrl(file);
  2027. var xhr = new XMLHttpRequest();
  2028. xhr.onload = function() {
  2029. PDFViewerApplication.open(new Uint8Array(xhr.response))
  2030. };
  2031. try {
  2032. xhr.open('GET', file);
  2033. xhr.responseType = 'arraybuffer';
  2034. xhr.send()
  2035. } catch(ex) {
  2036. PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.').then(function(msg) {
  2037. PDFViewerApplication.error(msg, ex)
  2038. })
  2039. }
  2040. return
  2041. }
  2042. if (file) {
  2043. PDFViewerApplication.open(file)
  2044. }
  2045. }
  2046. }
  2047. function webViewerPageRendered(evt) {
  2048. var pageNumber = evt.pageNumber;
  2049. var pageIndex = pageNumber - 1;
  2050. var pageView = PDFViewerApplication.pdfViewer.getPageView(pageIndex);
  2051. if (pageNumber === PDFViewerApplication.page) {
  2052. PDFViewerApplication.toolbar.updateLoadingIndicatorState(false)
  2053. }
  2054. if (!pageView) {
  2055. return
  2056. }
  2057. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  2058. var thumbnailView = PDFViewerApplication.pdfThumbnailViewer.getThumbnail(pageIndex);
  2059. thumbnailView.setImage(pageView)
  2060. }
  2061. if (_pdfjsLib.PDFJS.pdfBug && Stats.enabled && pageView.stats) {
  2062. Stats.add(pageNumber, pageView.stats)
  2063. }
  2064. if (pageView.error) {
  2065. PDFViewerApplication.l10n.get('rendering_error', null, 'An error occurred while rendering the page.').then(function(msg) {
  2066. PDFViewerApplication.error(msg, pageView.error)
  2067. })
  2068. }
  2069. }
  2070. function webViewerTextLayerRendered(evt) {}
  2071. function webViewerPageMode(evt) {
  2072. var mode = evt.mode,
  2073. view = void 0;
  2074. switch (mode) {
  2075. case 'thumbs':
  2076. view = _pdf_sidebar.SidebarView.THUMBS;
  2077. break;
  2078. case 'bookmarks':
  2079. case 'outline':
  2080. view = _pdf_sidebar.SidebarView.OUTLINE;
  2081. break;
  2082. case 'attachments':
  2083. view = _pdf_sidebar.SidebarView.ATTACHMENTS;
  2084. break;
  2085. case 'none':
  2086. view = _pdf_sidebar.SidebarView.NONE;
  2087. break;
  2088. default:
  2089. console.error('Invalid "pagemode" hash parameter: ' + mode);
  2090. return
  2091. }
  2092. PDFViewerApplication.pdfSidebar.switchView(view, true)
  2093. }
  2094. function webViewerNamedAction(evt) {
  2095. var action = evt.action;
  2096. switch (action) {
  2097. case 'GoToPage':
  2098. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  2099. break;
  2100. case 'Find':
  2101. if (!PDFViewerApplication.supportsIntegratedFind) {
  2102. PDFViewerApplication.findBar.toggle()
  2103. }
  2104. break
  2105. }
  2106. }
  2107. function webViewerPresentationModeChanged(evt) {
  2108. var active = evt.active,
  2109. switchInProgress = evt.switchInProgress;
  2110. PDFViewerApplication.pdfViewer.presentationModeState = switchInProgress ? _pdf_viewer.PresentationModeState.CHANGING: active ? _pdf_viewer.PresentationModeState.FULLSCREEN: _pdf_viewer.PresentationModeState.NORMAL
  2111. }
  2112. function webViewerSidebarViewChanged(evt) {
  2113. PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = PDFViewerApplication.pdfSidebar.isThumbnailViewVisible;
  2114. var store = PDFViewerApplication.store;
  2115. if (store && PDFViewerApplication.isInitialViewSet) {
  2116. store.set('sidebarView', evt.view).
  2117. catch(function() {})
  2118. }
  2119. }
  2120. function webViewerUpdateViewarea(evt) {
  2121. var location = evt.location,
  2122. store = PDFViewerApplication.store;
  2123. if (store && PDFViewerApplication.isInitialViewSet) {
  2124. store.setMultiple({
  2125. 'exists': true,
  2126. 'page': location.pageNumber,
  2127. 'zoom': location.scale,
  2128. 'scrollLeft': location.left,
  2129. 'scrollTop': location.top
  2130. }).
  2131. catch(function() {})
  2132. }
  2133. var href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
  2134. PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href;
  2135. PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
  2136. PDFViewerApplication.pdfHistory.updateCurrentBookmark(location.pdfOpenParams, location.pageNumber);
  2137. var currentPage = PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page - 1);
  2138. var loading = currentPage.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED;
  2139. PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading)
  2140. }
  2141. function webViewerResize() {
  2142. var pdfDocument = PDFViewerApplication.pdfDocument,
  2143. pdfViewer = PDFViewerApplication.pdfViewer;
  2144. if (!pdfDocument) {
  2145. return
  2146. }
  2147. var currentScaleValue = pdfViewer.currentScaleValue;
  2148. if (currentScaleValue === 'auto' || currentScaleValue === 'page-fit' || currentScaleValue === 'page-width') {
  2149. pdfViewer.currentScaleValue = currentScaleValue
  2150. }
  2151. pdfViewer.update()
  2152. }
  2153. function webViewerHashchange(evt) {
  2154. if (PDFViewerApplication.pdfHistory.isHashChangeUnlocked) {
  2155. var hash = evt.hash;
  2156. if (!hash) {
  2157. return
  2158. }
  2159. if (!PDFViewerApplication.isInitialViewSet) {
  2160. PDFViewerApplication.initialBookmark = hash
  2161. } else {
  2162. PDFViewerApplication.pdfLinkService.setHash(hash)
  2163. }
  2164. }
  2165. }
  2166. var webViewerFileInputChange = void 0; {
  2167. webViewerFileInputChange = function webViewerFileInputChange(evt) {
  2168. var file = evt.fileInput.files[0];
  2169. if (!_pdfjsLib.PDFJS.disableCreateObjectURL && URL.createObjectURL) {
  2170. PDFViewerApplication.open(URL.createObjectURL(file))
  2171. } else {
  2172. var fileReader = new FileReader();
  2173. fileReader.onload = function webViewerChangeFileReaderOnload(evt) {
  2174. var buffer = evt.target.result;
  2175. PDFViewerApplication.open(new Uint8Array(buffer))
  2176. };
  2177. fileReader.readAsArrayBuffer(file)
  2178. }
  2179. PDFViewerApplication.setTitleUsingUrl(file.name);
  2180. var appConfig = PDFViewerApplication.appConfig;
  2181. appConfig.toolbar.viewBookmark.setAttribute('hidden', 'true');
  2182. appConfig.secondaryToolbar.viewBookmarkButton.setAttribute('hidden', 'true');
  2183. appConfig.toolbar.download.setAttribute('hidden', 'true');
  2184. appConfig.secondaryToolbar.downloadButton.setAttribute('hidden', 'true')
  2185. }
  2186. }
  2187. function webViewerPresentationMode() {
  2188. PDFViewerApplication.requestPresentationMode()
  2189. }
  2190. function webViewerOpenFile() {
  2191. var openFileInputName = PDFViewerApplication.appConfig.openFileInputName;
  2192. document.getElementById(openFileInputName).click()
  2193. }
  2194. function webViewerPrint() {
  2195. window.print()
  2196. }
  2197. function webViewerDownload() {
  2198. PDFViewerApplication.download()
  2199. }
  2200. function webViewerFirstPage() {
  2201. if (PDFViewerApplication.pdfDocument) {
  2202. PDFViewerApplication.page = 1
  2203. }
  2204. }
  2205. function webViewerLastPage() {
  2206. if (PDFViewerApplication.pdfDocument) {
  2207. PDFViewerApplication.page = PDFViewerApplication.pagesCount
  2208. }
  2209. }
  2210. function webViewerNextPage() {
  2211. PDFViewerApplication.page++
  2212. }
  2213. function webViewerPreviousPage() {
  2214. PDFViewerApplication.page--
  2215. }
  2216. function webViewerZoomIn() {
  2217. PDFViewerApplication.zoomIn()
  2218. }
  2219. function webViewerZoomOut() {
  2220. PDFViewerApplication.zoomOut()
  2221. }
  2222. function webViewerPageNumberChanged(evt) {
  2223. var pdfViewer = PDFViewerApplication.pdfViewer;
  2224. pdfViewer.currentPageLabel = evt.value;
  2225. if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) {
  2226. PDFViewerApplication.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel)
  2227. }
  2228. }
  2229. function webViewerScaleChanged(evt) {
  2230. PDFViewerApplication.pdfViewer.currentScaleValue = evt.value
  2231. }
  2232. function webViewerRotateCw() {
  2233. PDFViewerApplication.rotatePages(90)
  2234. }
  2235. function webViewerRotateCcw() {
  2236. PDFViewerApplication.rotatePages( - 90)
  2237. }
  2238. function webViewerDocumentProperties() {
  2239. PDFViewerApplication.pdfDocumentProperties.open()
  2240. }
  2241. function webViewerFind(evt) {
  2242. PDFViewerApplication.findController.executeCommand('find' + evt.type, {
  2243. query: evt.query,
  2244. phraseSearch: evt.phraseSearch,
  2245. caseSensitive: evt.caseSensitive,
  2246. highlightAll: evt.highlightAll,
  2247. findPrevious: evt.findPrevious
  2248. })
  2249. }
  2250. function webViewerFindFromUrlHash(evt) {
  2251. PDFViewerApplication.findController.executeCommand('find', {
  2252. query: evt.query,
  2253. phraseSearch: evt.phraseSearch,
  2254. caseSensitive: false,
  2255. highlightAll: true,
  2256. findPrevious: false
  2257. })
  2258. }
  2259. function webViewerScaleChanging(evt) {
  2260. PDFViewerApplication.toolbar.setPageScale(evt.presetValue, evt.scale);
  2261. PDFViewerApplication.pdfViewer.update()
  2262. }
  2263. function webViewerPageChanging(evt) {
  2264. var page = evt.pageNumber;
  2265. PDFViewerApplication.toolbar.setPageNumber(page, evt.pageLabel || null);
  2266. PDFViewerApplication.secondaryToolbar.setPageNumber(page);
  2267. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  2268. PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(page)
  2269. }
  2270. if (_pdfjsLib.PDFJS.pdfBug && Stats.enabled) {
  2271. var pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1);
  2272. if (pageView.stats) {
  2273. Stats.add(page, pageView.stats)
  2274. }
  2275. }
  2276. }
  2277. var zoomDisabled = false,
  2278. zoomDisabledTimeout = void 0;
  2279. function webViewerWheel(evt) {
  2280. var pdfViewer = PDFViewerApplication.pdfViewer;
  2281. if (pdfViewer.isInPresentationMode) {
  2282. return
  2283. }
  2284. if (evt.ctrlKey || evt.metaKey) {
  2285. var support = PDFViewerApplication.supportedMouseWheelZoomModifierKeys;
  2286. if (evt.ctrlKey && !support.ctrlKey || evt.metaKey && !support.metaKey) {
  2287. return
  2288. }
  2289. evt.preventDefault();
  2290. if (zoomDisabled) {
  2291. return
  2292. }
  2293. var previousScale = pdfViewer.currentScale;
  2294. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  2295. var MOUSE_WHEEL_DELTA_PER_PAGE_SCALE = 3.0;
  2296. var ticks = delta * MOUSE_WHEEL_DELTA_PER_PAGE_SCALE;
  2297. if (ticks < 0) {
  2298. PDFViewerApplication.zoomOut( - ticks)
  2299. } else {
  2300. PDFViewerApplication.zoomIn(ticks)
  2301. }
  2302. var currentScale = pdfViewer.currentScale;
  2303. if (previousScale !== currentScale) {
  2304. var scaleCorrectionFactor = currentScale / previousScale - 1;
  2305. var rect = pdfViewer.container.getBoundingClientRect();
  2306. var dx = evt.clientX - rect.left;
  2307. var dy = evt.clientY - rect.top;
  2308. pdfViewer.container.scrollLeft += dx * scaleCorrectionFactor;
  2309. pdfViewer.container.scrollTop += dy * scaleCorrectionFactor
  2310. }
  2311. } else {
  2312. zoomDisabled = true;
  2313. clearTimeout(zoomDisabledTimeout);
  2314. zoomDisabledTimeout = setTimeout(function() {
  2315. zoomDisabled = false
  2316. },
  2317. 1000)
  2318. }
  2319. }
  2320. function webViewerClick(evt) {
  2321. if (!PDFViewerApplication.secondaryToolbar.isOpen) {
  2322. return
  2323. }
  2324. var appConfig = PDFViewerApplication.appConfig;
  2325. if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar.container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar.toggleButton) {
  2326. PDFViewerApplication.secondaryToolbar.close()
  2327. }
  2328. }
  2329. function webViewerKeyDown(evt) {
  2330. if (PDFViewerApplication.overlayManager.active) {
  2331. return
  2332. }
  2333. var handled = false,
  2334. ensureViewerFocused = false;
  2335. var cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0);
  2336. var pdfViewer = PDFViewerApplication.pdfViewer;
  2337. var isViewerInPresentationMode = pdfViewer && pdfViewer.isInPresentationMode;
  2338. if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
  2339. switch (evt.keyCode) {
  2340. case 70:
  2341. if (!PDFViewerApplication.supportsIntegratedFind) {
  2342. PDFViewerApplication.findBar.open();
  2343. handled = true
  2344. }
  2345. break;
  2346. case 71:
  2347. if (!PDFViewerApplication.supportsIntegratedFind) {
  2348. var findState = PDFViewerApplication.findController.state;
  2349. if (findState) {
  2350. PDFViewerApplication.findController.executeCommand('findagain', {
  2351. query: findState.query,
  2352. phraseSearch: findState.phraseSearch,
  2353. caseSensitive: findState.caseSensitive,
  2354. highlightAll: findState.highlightAll,
  2355. findPrevious: cmd === 5 || cmd === 12
  2356. })
  2357. }
  2358. handled = true
  2359. }
  2360. break;
  2361. case 61:
  2362. case 107:
  2363. case 187:
  2364. case 171:
  2365. if (!isViewerInPresentationMode) {
  2366. PDFViewerApplication.zoomIn()
  2367. }
  2368. handled = true;
  2369. break;
  2370. case 173:
  2371. case 109:
  2372. case 189:
  2373. if (!isViewerInPresentationMode) {
  2374. PDFViewerApplication.zoomOut()
  2375. }
  2376. handled = true;
  2377. break;
  2378. case 48:
  2379. case 96:
  2380. if (!isViewerInPresentationMode) {
  2381. setTimeout(function() {
  2382. pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE
  2383. });
  2384. handled = false
  2385. }
  2386. break;
  2387. case 38:
  2388. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  2389. PDFViewerApplication.page = 1;
  2390. handled = true;
  2391. ensureViewerFocused = true
  2392. }
  2393. break;
  2394. case 40:
  2395. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2396. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2397. handled = true;
  2398. ensureViewerFocused = true
  2399. }
  2400. break
  2401. }
  2402. }
  2403. if (cmd === 1 || cmd === 8) {
  2404. switch (evt.keyCode) {
  2405. case 83:
  2406. PDFViewerApplication.download();
  2407. handled = true;
  2408. break
  2409. }
  2410. }
  2411. if (cmd === 3 || cmd === 10) {
  2412. switch (evt.keyCode) {
  2413. case 80:
  2414. PDFViewerApplication.requestPresentationMode();
  2415. handled = true;
  2416. break;
  2417. case 71:
  2418. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  2419. handled = true;
  2420. break
  2421. }
  2422. }
  2423. if (handled) {
  2424. if (ensureViewerFocused && !isViewerInPresentationMode) {
  2425. pdfViewer.focus()
  2426. }
  2427. evt.preventDefault();
  2428. return
  2429. }
  2430. var curElement = document.activeElement || document.querySelector(':focus');
  2431. var curElementTagName = curElement && curElement.tagName.toUpperCase();
  2432. if (curElementTagName === 'INPUT' || curElementTagName === 'TEXTAREA' || curElementTagName === 'SELECT') {
  2433. if (evt.keyCode !== 27) {
  2434. return
  2435. }
  2436. }
  2437. if (cmd === 0) {
  2438. switch (evt.keyCode) {
  2439. case 38:
  2440. case 33:
  2441. case 8:
  2442. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== 'page-fit') {
  2443. break
  2444. }
  2445. case 37:
  2446. if (pdfViewer.isHorizontalScrollbarEnabled) {
  2447. break
  2448. }
  2449. case 75:
  2450. case 80:
  2451. if (PDFViewerApplication.page > 1) {
  2452. PDFViewerApplication.page--
  2453. }
  2454. handled = true;
  2455. break;
  2456. case 27:
  2457. if (PDFViewerApplication.secondaryToolbar.isOpen) {
  2458. PDFViewerApplication.secondaryToolbar.close();
  2459. handled = true
  2460. }
  2461. if (!PDFViewerApplication.supportsIntegratedFind && PDFViewerApplication.findBar.opened) {
  2462. PDFViewerApplication.findBar.close();
  2463. handled = true
  2464. }
  2465. break;
  2466. case 40:
  2467. case 34:
  2468. case 32:
  2469. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== 'page-fit') {
  2470. break
  2471. }
  2472. case 39:
  2473. if (pdfViewer.isHorizontalScrollbarEnabled) {
  2474. break
  2475. }
  2476. case 74:
  2477. case 78:
  2478. if (PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2479. PDFViewerApplication.page++
  2480. }
  2481. handled = true;
  2482. break;
  2483. case 36:
  2484. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  2485. PDFViewerApplication.page = 1;
  2486. handled = true;
  2487. ensureViewerFocused = true
  2488. }
  2489. break;
  2490. case 35:
  2491. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2492. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2493. handled = true;
  2494. ensureViewerFocused = true
  2495. }
  2496. break;
  2497. case 83:
  2498. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.SELECT);
  2499. break;
  2500. case 72:
  2501. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.HAND);
  2502. break;
  2503. case 82:
  2504. PDFViewerApplication.rotatePages(90);
  2505. break
  2506. }
  2507. }
  2508. if (cmd === 4) {
  2509. switch (evt.keyCode) {
  2510. case 32:
  2511. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== 'page-fit') {
  2512. break
  2513. }
  2514. if (PDFViewerApplication.page > 1) {
  2515. PDFViewerApplication.page--
  2516. }
  2517. handled = true;
  2518. break;
  2519. case 82:
  2520. PDFViewerApplication.rotatePages( - 90);
  2521. break
  2522. }
  2523. }
  2524. if (!handled && !isViewerInPresentationMode) {
  2525. if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !== 'BUTTON') {
  2526. ensureViewerFocused = true
  2527. }
  2528. }
  2529. if (cmd === 2) {
  2530. switch (evt.keyCode) {
  2531. case 37:
  2532. if (isViewerInPresentationMode) {
  2533. PDFViewerApplication.pdfHistory.back();
  2534. handled = true
  2535. }
  2536. break;
  2537. case 39:
  2538. if (isViewerInPresentationMode) {
  2539. PDFViewerApplication.pdfHistory.forward();
  2540. handled = true
  2541. }
  2542. break
  2543. }
  2544. }
  2545. if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
  2546. pdfViewer.focus()
  2547. }
  2548. if (handled) {
  2549. evt.preventDefault()
  2550. }
  2551. }
  2552. function apiPageModeToSidebarView(mode) {
  2553. switch (mode) {
  2554. case 'UseNone':
  2555. return _pdf_sidebar.SidebarView.NONE;
  2556. case 'UseThumbs':
  2557. return _pdf_sidebar.SidebarView.THUMBS;
  2558. case 'UseOutlines':
  2559. return _pdf_sidebar.SidebarView.OUTLINE;
  2560. case 'UseAttachments':
  2561. return _pdf_sidebar.SidebarView.ATTACHMENTS;
  2562. case 'UseOC':
  2563. }
  2564. return _pdf_sidebar.SidebarView.NONE
  2565. }
  2566. var PDFPrintServiceFactory = {
  2567. instance: {
  2568. supportsPrinting: false,
  2569. createPrintService: function createPrintService() {
  2570. throw new Error('Not implemented: createPrintService');
  2571. }
  2572. }
  2573. };
  2574. exports.PDFViewerApplication = PDFViewerApplication;
  2575. exports.DefaultExternalServices = DefaultExternalServices;
  2576. exports.PDFPrintServiceFactory = PDFPrintServiceFactory
  2577. }), (function(module, exports, __webpack_require__) {
  2578. "use strict";
  2579. Object.defineProperty(exports, "__esModule", {
  2580. value: true
  2581. });
  2582. exports.SimpleLinkService = exports.PDFLinkService = undefined;
  2583. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ?
  2584. function(obj) {
  2585. return typeof obj
  2586. }: function(obj) {
  2587. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol": typeof obj
  2588. };
  2589. var _createClass = function() {
  2590. function defineProperties(target, props) {
  2591. for (var i = 0; i < props.length; i++) {
  2592. var descriptor = props[i];
  2593. descriptor.enumerable = descriptor.enumerable || false;
  2594. descriptor.configurable = true;
  2595. if ("value" in descriptor) descriptor.writable = true;
  2596. Object.defineProperty(target, descriptor.key, descriptor)
  2597. }
  2598. }
  2599. return function(Constructor, protoProps, staticProps) {
  2600. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  2601. if (staticProps) defineProperties(Constructor, staticProps);
  2602. return Constructor
  2603. }
  2604. } ();
  2605. var _dom_events = __webpack_require__(2);
  2606. var _ui_utils = __webpack_require__(0);
  2607. function _classCallCheck(instance, Constructor) {
  2608. if (! (instance instanceof Constructor)) {
  2609. throw new TypeError("Cannot call a class as a function");
  2610. }
  2611. }
  2612. var PDFLinkService = function() {
  2613. function PDFLinkService() {
  2614. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  2615. eventBus = _ref.eventBus;
  2616. _classCallCheck(this, PDFLinkService);
  2617. this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)();
  2618. this.baseUrl = null;
  2619. this.pdfDocument = null;
  2620. this.pdfViewer = null;
  2621. this.pdfHistory = null;
  2622. this._pagesRefCache = null
  2623. }
  2624. _createClass(PDFLinkService, [{
  2625. key: 'setDocument',
  2626. value: function setDocument(pdfDocument, baseUrl) {
  2627. this.baseUrl = baseUrl;
  2628. this.pdfDocument = pdfDocument;
  2629. this._pagesRefCache = Object.create(null)
  2630. }
  2631. },
  2632. {
  2633. key: 'setViewer',
  2634. value: function setViewer(pdfViewer) {
  2635. this.pdfViewer = pdfViewer
  2636. }
  2637. },
  2638. {
  2639. key: 'setHistory',
  2640. value: function setHistory(pdfHistory) {
  2641. this.pdfHistory = pdfHistory
  2642. }
  2643. },
  2644. {
  2645. key: 'navigateTo',
  2646. value: function navigateTo(dest) {
  2647. var _this = this;
  2648. var goToDestination = function goToDestination(_ref2) {
  2649. var namedDest = _ref2.namedDest,
  2650. explicitDest = _ref2.explicitDest;
  2651. var destRef = explicitDest[0],
  2652. pageNumber = void 0;
  2653. if (destRef instanceof Object) {
  2654. pageNumber = _this._cachedPageNumber(destRef);
  2655. if (pageNumber === null) {
  2656. _this.pdfDocument.getPageIndex(destRef).then(function(pageIndex) {
  2657. _this.cachePageRef(pageIndex + 1, destRef);
  2658. goToDestination({
  2659. namedDest: namedDest,
  2660. explicitDest: explicitDest
  2661. })
  2662. }).
  2663. catch(function() {
  2664. console.error('PDFLinkService.navigateTo: "' + destRef + '" is not ' + ('a valid page reference, for dest="' + dest + '".'))
  2665. });
  2666. return
  2667. }
  2668. } else if ((destRef | 0) === destRef) {
  2669. pageNumber = destRef + 1
  2670. } else {
  2671. console.error('PDFLinkService.navigateTo: "' + destRef + '" is not ' + ('a valid destination reference, for dest="' + dest + '".'));
  2672. return
  2673. }
  2674. if (!pageNumber || pageNumber < 1 || pageNumber > _this.pagesCount) {
  2675. console.error('PDFLinkService.navigateTo: "' + pageNumber + '" is not ' + ('a valid page number, for dest="' + dest + '".'));
  2676. return
  2677. }
  2678. _this.pdfViewer.scrollPageIntoView({
  2679. pageNumber: pageNumber,
  2680. destArray: explicitDest
  2681. });
  2682. if (_this.pdfHistory) {
  2683. _this.pdfHistory.push({
  2684. dest: explicitDest,
  2685. hash: namedDest,
  2686. page: pageNumber
  2687. })
  2688. }
  2689. };
  2690. new Promise(function(resolve, reject) {
  2691. if (typeof dest === 'string') {
  2692. _this.pdfDocument.getDestination(dest).then(function(destArray) {
  2693. resolve({
  2694. namedDest: dest,
  2695. explicitDest: destArray
  2696. })
  2697. });
  2698. return
  2699. }
  2700. resolve({
  2701. namedDest: '',
  2702. explicitDest: dest
  2703. })
  2704. }).then(function(data) {
  2705. if (! (data.explicitDest instanceof Array)) {
  2706. console.error('PDFLinkService.navigateTo: "' + data.explicitDest + '" is' + (' not a valid destination array, for dest="' + dest + '".'));
  2707. return
  2708. }
  2709. goToDestination(data)
  2710. })
  2711. }
  2712. },
  2713. {
  2714. key: 'getDestinationHash',
  2715. value: function getDestinationHash(dest) {
  2716. if (typeof dest === 'string') {
  2717. return this.getAnchorUrl('#' + escape(dest))
  2718. }
  2719. if (dest instanceof Array) {
  2720. var str = JSON.stringify(dest);
  2721. return this.getAnchorUrl('#' + escape(str))
  2722. }
  2723. return this.getAnchorUrl('')
  2724. }
  2725. },
  2726. {
  2727. key: 'getAnchorUrl',
  2728. value: function getAnchorUrl(anchor) {
  2729. return (this.baseUrl || '') + anchor
  2730. }
  2731. },
  2732. {
  2733. key: 'setHash',
  2734. value: function setHash(hash) {
  2735. var pageNumber = void 0,
  2736. dest = void 0;
  2737. if (hash.indexOf('=') >= 0) {
  2738. var params = (0, _ui_utils.parseQueryString)(hash);
  2739. if ('search' in params) {
  2740. this.eventBus.dispatch('findfromurlhash', {
  2741. source: this,
  2742. query: params['search'].replace(/"/g, ''),
  2743. phraseSearch: params['phrase'] === 'true'
  2744. })
  2745. }
  2746. if ('nameddest' in params) {
  2747. if (this.pdfHistory) {
  2748. this.pdfHistory.updateNextHashParam(params.nameddest)
  2749. }
  2750. this.navigateTo(params.nameddest);
  2751. return
  2752. }
  2753. if ('page' in params) {
  2754. pageNumber = params.page | 0 || 1
  2755. }
  2756. if ('zoom' in params) {
  2757. var zoomArgs = params.zoom.split(',');
  2758. var zoomArg = zoomArgs[0];
  2759. var zoomArgNumber = parseFloat(zoomArg);
  2760. if (zoomArg.indexOf('Fit') === -1) {
  2761. dest = [null, {
  2762. name: 'XYZ'
  2763. },
  2764. zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg]
  2765. } else {
  2766. if (zoomArg === 'Fit' || zoomArg === 'FitB') {
  2767. dest = [null, {
  2768. name: zoomArg
  2769. }]
  2770. } else if (zoomArg === 'FitH' || zoomArg === 'FitBH' || zoomArg === 'FitV' || zoomArg === 'FitBV') {
  2771. dest = [null, {
  2772. name: zoomArg
  2773. },
  2774. zoomArgs.length > 1 ? zoomArgs[1] | 0 : null]
  2775. } else if (zoomArg === 'FitR') {
  2776. if (zoomArgs.length !== 5) {
  2777. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".')
  2778. } else {
  2779. dest = [null, {
  2780. name: zoomArg
  2781. },
  2782. zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0]
  2783. }
  2784. } else {
  2785. console.error('PDFLinkService.setHash: "' + zoomArg + '" is not ' + 'a valid zoom value.')
  2786. }
  2787. }
  2788. }
  2789. if (dest) {
  2790. this.pdfViewer.scrollPageIntoView({
  2791. pageNumber: pageNumber || this.page,
  2792. destArray: dest,
  2793. allowNegativeOffset: true
  2794. })
  2795. } else if (pageNumber) {
  2796. this.page = pageNumber
  2797. }
  2798. if ('pagemode' in params) {
  2799. this.eventBus.dispatch('pagemode', {
  2800. source: this,
  2801. mode: params.pagemode
  2802. })
  2803. }
  2804. } else {
  2805. if (/^\d+$/.test(hash) && hash <= this.pagesCount) {
  2806. console.warn('PDFLinkService_setHash: specifying a page number ' + 'directly after the hash symbol (#) is deprecated, ' + ('please use the "#page=' + hash + '" form instead.'));
  2807. this.page = hash | 0
  2808. }
  2809. dest = unescape(hash);
  2810. try {
  2811. dest = JSON.parse(dest);
  2812. if (! (dest instanceof Array)) {
  2813. dest = dest.toString()
  2814. }
  2815. } catch(ex) {}
  2816. if (typeof dest === 'string' || isValidExplicitDestination(dest)) {
  2817. if (this.pdfHistory) {
  2818. this.pdfHistory.updateNextHashParam(dest)
  2819. }
  2820. this.navigateTo(dest);
  2821. return
  2822. }
  2823. console.error('PDFLinkService.setHash: "' + unescape(hash) + '" is not ' + 'a valid destination.')
  2824. }
  2825. }
  2826. },
  2827. {
  2828. key: 'executeNamedAction',
  2829. value: function executeNamedAction(action) {
  2830. switch (action) {
  2831. case 'GoBack':
  2832. if (this.pdfHistory) {
  2833. this.pdfHistory.back()
  2834. }
  2835. break;
  2836. case 'GoForward':
  2837. if (this.pdfHistory) {
  2838. this.pdfHistory.forward()
  2839. }
  2840. break;
  2841. case 'NextPage':
  2842. if (this.page < this.pagesCount) {
  2843. this.page++
  2844. }
  2845. break;
  2846. case 'PrevPage':
  2847. if (this.page > 1) {
  2848. this.page--
  2849. }
  2850. break;
  2851. case 'LastPage':
  2852. this.page = this.pagesCount;
  2853. break;
  2854. case 'FirstPage':
  2855. this.page = 1;
  2856. break;
  2857. default:
  2858. break
  2859. }
  2860. this.eventBus.dispatch('namedaction', {
  2861. source: this,
  2862. action: action
  2863. })
  2864. }
  2865. },
  2866. {
  2867. key: 'onFileAttachmentAnnotation',
  2868. value: function onFileAttachmentAnnotation(_ref3) {
  2869. var id = _ref3.id,
  2870. filename = _ref3.filename,
  2871. content = _ref3.content;
  2872. this.eventBus.dispatch('fileattachmentannotation', {
  2873. source: this,
  2874. id: id,
  2875. filename: filename,
  2876. content: content
  2877. })
  2878. }
  2879. },
  2880. {
  2881. key: 'cachePageRef',
  2882. value: function cachePageRef(pageNum, pageRef) {
  2883. var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
  2884. this._pagesRefCache[refStr] = pageNum
  2885. }
  2886. },
  2887. {
  2888. key: '_cachedPageNumber',
  2889. value: function _cachedPageNumber(pageRef) {
  2890. var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
  2891. return this._pagesRefCache && this._pagesRefCache[refStr] || null
  2892. }
  2893. },
  2894. {
  2895. key: 'pagesCount',
  2896. get: function get() {
  2897. return this.pdfDocument ? this.pdfDocument.numPages: 0
  2898. }
  2899. },
  2900. {
  2901. key: 'page',
  2902. get: function get() {
  2903. return this.pdfViewer.currentPageNumber
  2904. },
  2905. set: function set(value) {
  2906. this.pdfViewer.currentPageNumber = value
  2907. }
  2908. }]);
  2909. return PDFLinkService
  2910. } ();
  2911. function isValidExplicitDestination(dest) {
  2912. if (! (dest instanceof Array)) {
  2913. return false
  2914. }
  2915. var destLength = dest.length,
  2916. allowNull = true;
  2917. if (destLength < 2) {
  2918. return false
  2919. }
  2920. var page = dest[0];
  2921. if (! ((typeof page === 'undefined' ? 'undefined': _typeof(page)) === 'object' && typeof page.num === 'number' && (page.num | 0) === page.num && typeof page.gen === 'number' && (page.gen | 0) === page.gen) && !(typeof page === 'number' && (page | 0) === page && page >= 0)) {
  2922. return false
  2923. }
  2924. var zoom = dest[1];
  2925. if (! ((typeof zoom === 'undefined' ? 'undefined': _typeof(zoom)) === 'object' && typeof zoom.name === 'string')) {
  2926. return false
  2927. }
  2928. switch (zoom.name) {
  2929. case 'XYZ':
  2930. if (destLength !== 5) {
  2931. return false
  2932. }
  2933. break;
  2934. case 'Fit':
  2935. case 'FitB':
  2936. return destLength === 2;
  2937. case 'FitH':
  2938. case 'FitBH':
  2939. case 'FitV':
  2940. case 'FitBV':
  2941. if (destLength !== 3) {
  2942. return false
  2943. }
  2944. break;
  2945. case 'FitR':
  2946. if (destLength !== 6) {
  2947. return false
  2948. }
  2949. allowNull = false;
  2950. break;
  2951. default:
  2952. return false
  2953. }
  2954. for (var i = 2; i < destLength; i++) {
  2955. var param = dest[i];
  2956. if (! (typeof param === 'number' || allowNull && param === null)) {
  2957. return false
  2958. }
  2959. }
  2960. return true
  2961. }
  2962. var SimpleLinkService = function() {
  2963. function SimpleLinkService() {
  2964. _classCallCheck(this, SimpleLinkService)
  2965. }
  2966. _createClass(SimpleLinkService, [{
  2967. key: 'navigateTo',
  2968. value: function navigateTo(dest) {}
  2969. },
  2970. {
  2971. key: 'getDestinationHash',
  2972. value: function getDestinationHash(dest) {
  2973. return '#'
  2974. }
  2975. },
  2976. {
  2977. key: 'getAnchorUrl',
  2978. value: function getAnchorUrl(hash) {
  2979. return '#'
  2980. }
  2981. },
  2982. {
  2983. key: 'setHash',
  2984. value: function setHash(hash) {}
  2985. },
  2986. {
  2987. key: 'executeNamedAction',
  2988. value: function executeNamedAction(action) {}
  2989. },
  2990. {
  2991. key: 'onFileAttachmentAnnotation',
  2992. value: function onFileAttachmentAnnotation(_ref4) {
  2993. var id = _ref4.id,
  2994. filename = _ref4.filename,
  2995. content = _ref4.content
  2996. }
  2997. },
  2998. {
  2999. key: 'cachePageRef',
  3000. value: function cachePageRef(pageNum, pageRef) {}
  3001. },
  3002. {
  3003. key: 'page',
  3004. get: function get() {
  3005. return 0
  3006. },
  3007. set: function set(value) {}
  3008. }]);
  3009. return SimpleLinkService
  3010. } ();
  3011. exports.PDFLinkService = PDFLinkService;
  3012. exports.SimpleLinkService = SimpleLinkService
  3013. }), (function(module, exports, __webpack_require__) {
  3014. "use strict";
  3015. Object.defineProperty(exports, "__esModule", {
  3016. value: true
  3017. });
  3018. exports.PDFCursorTools = exports.CursorTool = undefined;
  3019. var _slicedToArray = function() {
  3020. function sliceIterator(arr, i) {
  3021. var _arr = [];
  3022. var _n = true;
  3023. var _d = false;
  3024. var _e = undefined;
  3025. try {
  3026. for (var _i = arr[Symbol.iterator](), _s; ! (_n = (_s = _i.next()).done); _n = true) {
  3027. _arr.push(_s.value);
  3028. if (i && _arr.length === i) break
  3029. }
  3030. } catch(err) {
  3031. _d = true;
  3032. _e = err
  3033. } finally {
  3034. try {
  3035. if (!_n && _i["return"]) _i["return"]()
  3036. } finally {
  3037. if (_d) throw _e;
  3038. }
  3039. }
  3040. return _arr
  3041. }
  3042. return function(arr, i) {
  3043. if (Array.isArray(arr)) {
  3044. return arr
  3045. } else if (Symbol.iterator in Object(arr)) {
  3046. return sliceIterator(arr, i)
  3047. } else {
  3048. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  3049. }
  3050. }
  3051. } ();
  3052. var _createClass = function() {
  3053. function defineProperties(target, props) {
  3054. for (var i = 0; i < props.length; i++) {
  3055. var descriptor = props[i];
  3056. descriptor.enumerable = descriptor.enumerable || false;
  3057. descriptor.configurable = true;
  3058. if ("value" in descriptor) descriptor.writable = true;
  3059. Object.defineProperty(target, descriptor.key, descriptor)
  3060. }
  3061. }
  3062. return function(Constructor, protoProps, staticProps) {
  3063. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  3064. if (staticProps) defineProperties(Constructor, staticProps);
  3065. return Constructor
  3066. }
  3067. } ();
  3068. var _grab_to_pan = __webpack_require__(14);
  3069. function _classCallCheck(instance, Constructor) {
  3070. if (! (instance instanceof Constructor)) {
  3071. throw new TypeError("Cannot call a class as a function");
  3072. }
  3073. }
  3074. var CursorTool = {
  3075. SELECT: 0,
  3076. HAND: 1,
  3077. ZOOM: 2
  3078. };
  3079. var PDFCursorTools = function() {
  3080. function PDFCursorTools(_ref) {
  3081. var _this = this;
  3082. var container = _ref.container,
  3083. eventBus = _ref.eventBus,
  3084. preferences = _ref.preferences;
  3085. _classCallCheck(this, PDFCursorTools);
  3086. this.container = container;
  3087. this.eventBus = eventBus;
  3088. this.active = CursorTool.SELECT;
  3089. this.activeBeforePresentationMode = null;
  3090. this.handTool = new _grab_to_pan.GrabToPan({
  3091. element: this.container
  3092. });
  3093. this._addEventListeners();
  3094. Promise.all([preferences.get('cursorToolOnLoad'), preferences.get('enableHandToolOnLoad')]).then(function(_ref2) {
  3095. var _ref3 = _slicedToArray(_ref2, 2),
  3096. cursorToolPref = _ref3[0],
  3097. handToolPref = _ref3[1];
  3098. if (handToolPref === true) {
  3099. preferences.set('enableHandToolOnLoad', false);
  3100. if (cursorToolPref === CursorTool.SELECT) {
  3101. cursorToolPref = CursorTool.HAND;
  3102. preferences.set('cursorToolOnLoad', cursorToolPref).
  3103. catch(function() {})
  3104. }
  3105. }
  3106. _this.switchTool(cursorToolPref)
  3107. }).
  3108. catch(function() {})
  3109. }
  3110. _createClass(PDFCursorTools, [{
  3111. key: 'switchTool',
  3112. value: function switchTool(tool) {
  3113. var _this2 = this;
  3114. if (this.activeBeforePresentationMode !== null) {
  3115. return
  3116. }
  3117. if (tool === this.active) {
  3118. return
  3119. }
  3120. var disableActiveTool = function disableActiveTool() {
  3121. switch (_this2.active) {
  3122. case CursorTool.SELECT:
  3123. break;
  3124. case CursorTool.HAND:
  3125. _this2.handTool.deactivate();
  3126. break;
  3127. case CursorTool.ZOOM:
  3128. }
  3129. };
  3130. switch (tool) {
  3131. case CursorTool.SELECT:
  3132. disableActiveTool();
  3133. break;
  3134. case CursorTool.HAND:
  3135. disableActiveTool();
  3136. this.handTool.activate();
  3137. break;
  3138. case CursorTool.ZOOM:
  3139. default:
  3140. console.error('switchTool: "' + tool + '" is an unsupported value.');
  3141. return
  3142. }
  3143. this.active = tool;
  3144. this._dispatchEvent()
  3145. }
  3146. },
  3147. {
  3148. key: '_dispatchEvent',
  3149. value: function _dispatchEvent() {
  3150. this.eventBus.dispatch('cursortoolchanged', {
  3151. source: this,
  3152. tool: this.active
  3153. })
  3154. }
  3155. },
  3156. {
  3157. key: '_addEventListeners',
  3158. value: function _addEventListeners() {
  3159. var _this3 = this;
  3160. this.eventBus.on('switchcursortool',
  3161. function(evt) {
  3162. _this3.switchTool(evt.tool)
  3163. });
  3164. this.eventBus.on('presentationmodechanged',
  3165. function(evt) {
  3166. if (evt.switchInProgress) {
  3167. return
  3168. }
  3169. var previouslyActive = void 0;
  3170. if (evt.active) {
  3171. previouslyActive = _this3.active;
  3172. _this3.switchTool(CursorTool.SELECT);
  3173. _this3.activeBeforePresentationMode = previouslyActive
  3174. } else {
  3175. previouslyActive = _this3.activeBeforePresentationMode;
  3176. _this3.activeBeforePresentationMode = null;
  3177. _this3.switchTool(previouslyActive)
  3178. }
  3179. })
  3180. }
  3181. },
  3182. {
  3183. key: 'activeTool',
  3184. get: function get() {
  3185. return this.active
  3186. }
  3187. }]);
  3188. return PDFCursorTools
  3189. } ();
  3190. exports.CursorTool = CursorTool;
  3191. exports.PDFCursorTools = PDFCursorTools
  3192. }), (function(module, exports, __webpack_require__) {
  3193. "use strict";
  3194. Object.defineProperty(exports, "__esModule", {
  3195. value: true
  3196. });
  3197. exports.PDFFindController = exports.FindState = undefined;
  3198. var _createClass = function() {
  3199. function defineProperties(target, props) {
  3200. for (var i = 0; i < props.length; i++) {
  3201. var descriptor = props[i];
  3202. descriptor.enumerable = descriptor.enumerable || false;
  3203. descriptor.configurable = true;
  3204. if ("value" in descriptor) descriptor.writable = true;
  3205. Object.defineProperty(target, descriptor.key, descriptor)
  3206. }
  3207. }
  3208. return function(Constructor, protoProps, staticProps) {
  3209. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  3210. if (staticProps) defineProperties(Constructor, staticProps);
  3211. return Constructor
  3212. }
  3213. } ();
  3214. var _pdfjsLib = __webpack_require__(1);
  3215. var _ui_utils = __webpack_require__(0);
  3216. function _classCallCheck(instance, Constructor) {
  3217. if (! (instance instanceof Constructor)) {
  3218. throw new TypeError("Cannot call a class as a function");
  3219. }
  3220. }
  3221. var FindState = {
  3222. FOUND: 0,
  3223. NOT_FOUND: 1,
  3224. WRAPPED: 2,
  3225. PENDING: 3
  3226. };
  3227. var FIND_SCROLL_OFFSET_TOP = -50;
  3228. var FIND_SCROLL_OFFSET_LEFT = -400;
  3229. var FIND_TIMEOUT = 250;
  3230. var CHARACTERS_TO_NORMALIZE = {
  3231. '\u2018': '\'',
  3232. '\u2019': '\'',
  3233. '\u201A': '\'',
  3234. '\u201B': '\'',
  3235. '\u201C': '"',
  3236. '\u201D': '"',
  3237. '\u201E': '"',
  3238. '\u201F': '"',
  3239. '\xBC': '1/4',
  3240. '\xBD': '1/2',
  3241. '\xBE': '3/4'
  3242. };
  3243. var PDFFindController = function() {
  3244. function PDFFindController(_ref) {
  3245. var pdfViewer = _ref.pdfViewer;
  3246. _classCallCheck(this, PDFFindController);
  3247. this.pdfViewer = pdfViewer;
  3248. this.onUpdateResultsCount = null;
  3249. this.onUpdateState = null;
  3250. this.reset();
  3251. var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join('');
  3252. this.normalizationRegex = new RegExp('[' + replace + ']', 'g')
  3253. }
  3254. _createClass(PDFFindController, [{
  3255. key: 'reset',
  3256. value: function reset() {
  3257. var _this = this;
  3258. this.startedTextExtraction = false;
  3259. this.extractTextPromises = [];
  3260. this.pendingFindMatches = Object.create(null);
  3261. this.active = false;
  3262. this.pageContents = [];
  3263. this.pageMatches = [];
  3264. this.pageMatchesLength = null;
  3265. this.matchCount = 0;
  3266. this.selected = {
  3267. pageIdx: -1,
  3268. matchIdx: -1
  3269. };
  3270. this.offset = {
  3271. pageIdx: null,
  3272. matchIdx: null
  3273. };
  3274. this.pagesToSearch = null;
  3275. this.resumePageIdx = null;
  3276. this.state = null;
  3277. this.dirtyMatch = false;
  3278. this.findTimeout = null;
  3279. this._firstPagePromise = new Promise(function(resolve) {
  3280. _this.resolveFirstPage = resolve
  3281. })
  3282. }
  3283. },
  3284. {
  3285. key: 'normalize',
  3286. value: function normalize(text) {
  3287. return text.replace(this.normalizationRegex,
  3288. function(ch) {
  3289. return CHARACTERS_TO_NORMALIZE[ch]
  3290. })
  3291. }
  3292. },
  3293. {
  3294. key: '_prepareMatches',
  3295. value: function _prepareMatches(matchesWithLength, matches, matchesLength) {
  3296. function isSubTerm(matchesWithLength, currentIndex) {
  3297. var currentElem = matchesWithLength[currentIndex];
  3298. var nextElem = matchesWithLength[currentIndex + 1];
  3299. if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {
  3300. currentElem.skipped = true;
  3301. return true
  3302. }
  3303. for (var i = currentIndex - 1; i >= 0; i--) {
  3304. var prevElem = matchesWithLength[i];
  3305. if (prevElem.skipped) {
  3306. continue
  3307. }
  3308. if (prevElem.match + prevElem.matchLength < currentElem.match) {
  3309. break
  3310. }
  3311. if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {
  3312. currentElem.skipped = true;
  3313. return true
  3314. }
  3315. }
  3316. return false
  3317. }
  3318. matchesWithLength.sort(function(a, b) {
  3319. return a.match === b.match ? a.matchLength - b.matchLength: a.match - b.match
  3320. });
  3321. for (var i = 0,
  3322. len = matchesWithLength.length; i < len; i++) {
  3323. if (isSubTerm(matchesWithLength, i)) {
  3324. continue
  3325. }
  3326. matches.push(matchesWithLength[i].match);
  3327. matchesLength.push(matchesWithLength[i].matchLength)
  3328. }
  3329. }
  3330. },
  3331. {
  3332. key: 'calcFindPhraseMatch',
  3333. value: function calcFindPhraseMatch(query, pageIndex, pageContent) {
  3334. var matches = [];
  3335. var queryLen = query.length;
  3336. var matchIdx = -queryLen;
  3337. while (true) {
  3338. matchIdx = pageContent.indexOf(query, matchIdx + queryLen);
  3339. if (matchIdx === -1) {
  3340. break
  3341. }
  3342. matches.push(matchIdx)
  3343. }
  3344. this.pageMatches[pageIndex] = matches
  3345. }
  3346. },
  3347. {
  3348. key: 'calcFindWordMatch',
  3349. value: function calcFindWordMatch(query, pageIndex, pageContent) {
  3350. var matchesWithLength = [];
  3351. var queryArray = query.match(/\S+/g);
  3352. for (var i = 0,
  3353. len = queryArray.length; i < len; i++) {
  3354. var subquery = queryArray[i];
  3355. var subqueryLen = subquery.length;
  3356. var matchIdx = -subqueryLen;
  3357. while (true) {
  3358. matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen);
  3359. if (matchIdx === -1) {
  3360. break
  3361. }
  3362. matchesWithLength.push({
  3363. match: matchIdx,
  3364. matchLength: subqueryLen,
  3365. skipped: false
  3366. })
  3367. }
  3368. }
  3369. if (!this.pageMatchesLength) {
  3370. this.pageMatchesLength = []
  3371. }
  3372. this.pageMatchesLength[pageIndex] = [];
  3373. this.pageMatches[pageIndex] = [];
  3374. this._prepareMatches(matchesWithLength, this.pageMatches[pageIndex], this.pageMatchesLength[pageIndex])
  3375. }
  3376. },
  3377. {
  3378. key: 'calcFindMatch',
  3379. value: function calcFindMatch(pageIndex) {
  3380. var pageContent = this.normalize(this.pageContents[pageIndex]);
  3381. var query = this.normalize(this.state.query);
  3382. var caseSensitive = this.state.caseSensitive;
  3383. var phraseSearch = this.state.phraseSearch;
  3384. var queryLen = query.length;
  3385. if (queryLen === 0) {
  3386. return
  3387. }
  3388. if (!caseSensitive) {
  3389. pageContent = pageContent.toLowerCase();
  3390. query = query.toLowerCase()
  3391. }
  3392. if (phraseSearch) {
  3393. this.calcFindPhraseMatch(query, pageIndex, pageContent)
  3394. } else {
  3395. this.calcFindWordMatch(query, pageIndex, pageContent)
  3396. }
  3397. this.updatePage(pageIndex);
  3398. if (this.resumePageIdx === pageIndex) {
  3399. this.resumePageIdx = null;
  3400. this.nextPageMatch()
  3401. }
  3402. if (this.pageMatches[pageIndex].length > 0) {
  3403. this.matchCount += this.pageMatches[pageIndex].length;
  3404. this.updateUIResultsCount()
  3405. }
  3406. }
  3407. },
  3408. {
  3409. key: 'extractText',
  3410. value: function extractText() {
  3411. var _this2 = this;
  3412. if (this.startedTextExtraction) {
  3413. return
  3414. }
  3415. this.startedTextExtraction = true;
  3416. this.pageContents.length = 0;
  3417. var promise = Promise.resolve();
  3418. var _loop = function _loop(i, ii) {
  3419. var extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
  3420. _this2.extractTextPromises[i] = extractTextCapability.promise;
  3421. promise = promise.then(function() {
  3422. return _this2.pdfViewer.getPageTextContent(i).then(function(textContent) {
  3423. var textItems = textContent.items;
  3424. var strBuf = [];
  3425. for (var j = 0,
  3426. jj = textItems.length; j < jj; j++) {
  3427. strBuf.push(textItems[j].str)
  3428. }
  3429. _this2.pageContents[i] = strBuf.join('');
  3430. extractTextCapability.resolve(i)
  3431. },
  3432. function(reason) {
  3433. console.error('Unable to get page ' + (i + 1) + ' text content', reason);
  3434. _this2.pageContents[i] = '';
  3435. extractTextCapability.resolve(i)
  3436. })
  3437. })
  3438. };
  3439. for (var i = 0,
  3440. ii = this.pdfViewer.pagesCount; i < ii; i++) {
  3441. _loop(i, ii)
  3442. }
  3443. }
  3444. },
  3445. {
  3446. key: 'executeCommand',
  3447. value: function executeCommand(cmd, state) {
  3448. var _this3 = this;
  3449. if (this.state === null || cmd !== 'findagain') {
  3450. this.dirtyMatch = true
  3451. }
  3452. this.state = state;
  3453. this.updateUIState(FindState.PENDING);
  3454. this._firstPagePromise.then(function() {
  3455. _this3.extractText();
  3456. clearTimeout(_this3.findTimeout);
  3457. if (cmd === 'find') {
  3458. _this3.findTimeout = setTimeout(_this3.nextMatch.bind(_this3), FIND_TIMEOUT)
  3459. } else {
  3460. _this3.nextMatch()
  3461. }
  3462. })
  3463. }
  3464. },
  3465. {
  3466. key: 'updatePage',
  3467. value: function updatePage(index) {
  3468. if (this.selected.pageIdx === index) {
  3469. this.pdfViewer.currentPageNumber = index + 1
  3470. }
  3471. var page = this.pdfViewer.getPageView(index);
  3472. if (page.textLayer) {
  3473. page.textLayer.updateMatches()
  3474. }
  3475. }
  3476. },
  3477. {
  3478. key: 'nextMatch',
  3479. value: function nextMatch() {
  3480. var _this4 = this;
  3481. var previous = this.state.findPrevious;
  3482. var currentPageIndex = this.pdfViewer.currentPageNumber - 1;
  3483. var numPages = this.pdfViewer.pagesCount;
  3484. this.active = true;
  3485. if (this.dirtyMatch) {
  3486. this.dirtyMatch = false;
  3487. this.selected.pageIdx = this.selected.matchIdx = -1;
  3488. this.offset.pageIdx = currentPageIndex;
  3489. this.offset.matchIdx = null;
  3490. this.hadMatch = false;
  3491. this.resumePageIdx = null;
  3492. this.pageMatches = [];
  3493. this.matchCount = 0;
  3494. this.pageMatchesLength = null;
  3495. for (var i = 0; i < numPages; i++) {
  3496. this.updatePage(i);
  3497. if (! (i in this.pendingFindMatches)) {
  3498. this.pendingFindMatches[i] = true;
  3499. this.extractTextPromises[i].then(function(pageIdx) {
  3500. delete _this4.pendingFindMatches[pageIdx];
  3501. _this4.calcFindMatch(pageIdx)
  3502. })
  3503. }
  3504. }
  3505. }
  3506. if (this.state.query === '') {
  3507. this.updateUIState(FindState.FOUND);
  3508. return
  3509. }
  3510. if (this.resumePageIdx) {
  3511. return
  3512. }
  3513. var offset = this.offset;
  3514. this.pagesToSearch = numPages;
  3515. if (offset.matchIdx !== null) {
  3516. var numPageMatches = this.pageMatches[offset.pageIdx].length;
  3517. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  3518. this.hadMatch = true;
  3519. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  3520. this.updateMatch(true);
  3521. return
  3522. }
  3523. this.advanceOffsetPage(previous)
  3524. }
  3525. this.nextPageMatch()
  3526. }
  3527. },
  3528. {
  3529. key: 'matchesReady',
  3530. value: function matchesReady(matches) {
  3531. var offset = this.offset;
  3532. var numMatches = matches.length;
  3533. var previous = this.state.findPrevious;
  3534. if (numMatches) {
  3535. this.hadMatch = true;
  3536. offset.matchIdx = previous ? numMatches - 1 : 0;
  3537. this.updateMatch(true);
  3538. return true
  3539. }
  3540. this.advanceOffsetPage(previous);
  3541. if (offset.wrapped) {
  3542. offset.matchIdx = null;
  3543. if (this.pagesToSearch < 0) {
  3544. this.updateMatch(false);
  3545. return true
  3546. }
  3547. }
  3548. return false
  3549. }
  3550. },
  3551. {
  3552. key: 'updateMatchPosition',
  3553. value: function updateMatchPosition(pageIndex, matchIndex, elements, beginIdx) {
  3554. if (this.selected.matchIdx === matchIndex && this.selected.pageIdx === pageIndex) {
  3555. var spot = {
  3556. top: FIND_SCROLL_OFFSET_TOP,
  3557. left: FIND_SCROLL_OFFSET_LEFT
  3558. }; (0, _ui_utils.scrollIntoView)(elements[beginIdx], spot, true)
  3559. }
  3560. }
  3561. },
  3562. {
  3563. key: 'nextPageMatch',
  3564. value: function nextPageMatch() {
  3565. if (this.resumePageIdx !== null) {
  3566. console.error('There can only be one pending page.')
  3567. }
  3568. var matches = null;
  3569. do {
  3570. var pageIdx = this.offset.pageIdx;
  3571. matches = this.pageMatches[pageIdx];
  3572. if (!matches) {
  3573. this.resumePageIdx = pageIdx;
  3574. break
  3575. }
  3576. } while (! this . matchesReady ( matches ))
  3577. }
  3578. },
  3579. {
  3580. key: 'advanceOffsetPage',
  3581. value: function advanceOffsetPage(previous) {
  3582. var offset = this.offset;
  3583. var numPages = this.extractTextPromises.length;
  3584. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  3585. offset.matchIdx = null;
  3586. this.pagesToSearch--;
  3587. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  3588. offset.pageIdx = previous ? numPages - 1 : 0;
  3589. offset.wrapped = true
  3590. }
  3591. }
  3592. },
  3593. {
  3594. key: 'updateMatch',
  3595. value: function updateMatch() {
  3596. var found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  3597. var state = FindState.NOT_FOUND;
  3598. var wrapped = this.offset.wrapped;
  3599. this.offset.wrapped = false;
  3600. if (found) {
  3601. var previousPage = this.selected.pageIdx;
  3602. this.selected.pageIdx = this.offset.pageIdx;
  3603. this.selected.matchIdx = this.offset.matchIdx;
  3604. state = wrapped ? FindState.WRAPPED: FindState.FOUND;
  3605. if (previousPage !== -1 && previousPage !== this.selected.pageIdx) {
  3606. this.updatePage(previousPage)
  3607. }
  3608. }
  3609. this.updateUIState(state, this.state.findPrevious);
  3610. if (this.selected.pageIdx !== -1) {
  3611. this.updatePage(this.selected.pageIdx)
  3612. }
  3613. }
  3614. },
  3615. {
  3616. key: 'updateUIResultsCount',
  3617. value: function updateUIResultsCount() {
  3618. if (this.onUpdateResultsCount) {
  3619. this.onUpdateResultsCount(this.matchCount)
  3620. }
  3621. }
  3622. },
  3623. {
  3624. key: 'updateUIState',
  3625. value: function updateUIState(state, previous) {
  3626. if (this.onUpdateState) {
  3627. this.onUpdateState(state, previous, this.matchCount)
  3628. }
  3629. }
  3630. }]);
  3631. return PDFFindController
  3632. } ();
  3633. exports.FindState = FindState;
  3634. exports.PDFFindController = PDFFindController
  3635. }), (function(module, exports, __webpack_require__) {
  3636. "use strict";
  3637. Object.defineProperty(exports, "__esModule", {
  3638. value: true
  3639. });
  3640. exports.GenericCom = undefined;
  3641. var _createClass = function() {
  3642. function defineProperties(target, props) {
  3643. for (var i = 0; i < props.length; i++) {
  3644. var descriptor = props[i];
  3645. descriptor.enumerable = descriptor.enumerable || false;
  3646. descriptor.configurable = true;
  3647. if ("value" in descriptor) descriptor.writable = true;
  3648. Object.defineProperty(target, descriptor.key, descriptor)
  3649. }
  3650. }
  3651. return function(Constructor, protoProps, staticProps) {
  3652. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  3653. if (staticProps) defineProperties(Constructor, staticProps);
  3654. return Constructor
  3655. }
  3656. } ();
  3657. var _app = __webpack_require__(4);
  3658. var _preferences = __webpack_require__(28);
  3659. var _download_manager = __webpack_require__(12);
  3660. var _genericl10n = __webpack_require__(13);
  3661. var _pdfjsLib = __webpack_require__(1);
  3662. function _classCallCheck(instance, Constructor) {
  3663. if (! (instance instanceof Constructor)) {
  3664. throw new TypeError("Cannot call a class as a function");
  3665. }
  3666. }
  3667. function _possibleConstructorReturn(self, call) {
  3668. if (!self) {
  3669. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  3670. }
  3671. return call && (typeof call === "object" || typeof call === "function") ? call: self
  3672. }
  3673. function _inherits(subClass, superClass) {
  3674. if (typeof superClass !== "function" && superClass !== null) {
  3675. throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
  3676. }
  3677. subClass.prototype = Object.create(superClass && superClass.prototype, {
  3678. constructor: {
  3679. value: subClass,
  3680. enumerable: false,
  3681. writable: true,
  3682. configurable: true
  3683. }
  3684. });
  3685. if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass
  3686. };
  3687. var GenericCom = {};
  3688. var GenericPreferences = function(_BasePreferences) {
  3689. _inherits(GenericPreferences, _BasePreferences);
  3690. function GenericPreferences() {
  3691. _classCallCheck(this, GenericPreferences);
  3692. return _possibleConstructorReturn(this, (GenericPreferences.__proto__ || Object.getPrototypeOf(GenericPreferences)).apply(this, arguments))
  3693. }
  3694. _createClass(GenericPreferences, [{
  3695. key: '_writeToStorage',
  3696. value: function _writeToStorage(prefObj) {
  3697. return new Promise(function(resolve) {
  3698. localStorage.setItem('pdfjs.preferences', JSON.stringify(prefObj));
  3699. resolve()
  3700. })
  3701. }
  3702. },
  3703. {
  3704. key: '_readFromStorage',
  3705. value: function _readFromStorage(prefObj) {
  3706. return new Promise(function(resolve) {
  3707. var readPrefs = JSON.parse(localStorage.getItem('pdfjs.preferences'));
  3708. resolve(readPrefs)
  3709. })
  3710. }
  3711. }]);
  3712. return GenericPreferences
  3713. } (_preferences.BasePreferences);
  3714. var GenericExternalServices = Object.create(_app.DefaultExternalServices);
  3715. GenericExternalServices.createDownloadManager = function() {
  3716. return new _download_manager.DownloadManager()
  3717. };
  3718. GenericExternalServices.createPreferences = function() {
  3719. return new GenericPreferences()
  3720. };
  3721. GenericExternalServices.createL10n = function() {
  3722. return new _genericl10n.GenericL10n(_pdfjsLib.PDFJS.locale)
  3723. };
  3724. _app.PDFViewerApplication.externalServices = GenericExternalServices;
  3725. exports.GenericCom = GenericCom
  3726. }), (function(module, exports, __webpack_require__) {
  3727. "use strict";
  3728. Object.defineProperty(exports, "__esModule", {
  3729. value: true
  3730. });
  3731. exports.PDFPrintService = undefined;
  3732. var _ui_utils = __webpack_require__(0);
  3733. var _app = __webpack_require__(4);
  3734. var _pdfjsLib = __webpack_require__(1);
  3735. var activeService = null;
  3736. var overlayManager = null;
  3737. function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size) {
  3738. var scratchCanvas = activeService.scratchCanvas;
  3739. var PRINT_RESOLUTION = 150;
  3740. var PRINT_UNITS = PRINT_RESOLUTION / 72.0;
  3741. scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
  3742. scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
  3743. var width = Math.floor(size.width * _ui_utils.CSS_UNITS) + 'px';
  3744. var height = Math.floor(size.height * _ui_utils.CSS_UNITS) + 'px';
  3745. var ctx = scratchCanvas.getContext('2d');
  3746. ctx.save();
  3747. ctx.fillStyle = 'rgb(255, 255, 255)';
  3748. ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height);
  3749. ctx.restore();
  3750. return pdfDocument.getPage(pageNumber).then(function(pdfPage) {
  3751. var renderContext = {
  3752. canvasContext: ctx,
  3753. transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
  3754. viewport: pdfPage.getViewport(1, size.rotation),
  3755. intent: 'print'
  3756. };
  3757. return pdfPage.render(renderContext).promise
  3758. }).then(function() {
  3759. return {
  3760. width: width,
  3761. height: height
  3762. }
  3763. })
  3764. }
  3765. function PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
  3766. this.pdfDocument = pdfDocument;
  3767. this.pagesOverview = pagesOverview;
  3768. this.printContainer = printContainer;
  3769. this.l10n = l10n || _ui_utils.NullL10n;
  3770. this.currentPage = -1;
  3771. this.scratchCanvas = document.createElement('canvas')
  3772. }
  3773. PDFPrintService.prototype = {
  3774. layout: function layout() {
  3775. this.throwIfInactive();
  3776. var body = document.querySelector('body');
  3777. body.setAttribute('data-pdfjsprinting', true);
  3778. var hasEqualPageSizes = this.pagesOverview.every(function(size) {
  3779. return size.width === this.pagesOverview[0].width && size.height === this.pagesOverview[0].height
  3780. },
  3781. this);
  3782. if (!hasEqualPageSizes) {
  3783. console.warn('Not all pages have the same size. The printed ' + 'result may be incorrect!')
  3784. }
  3785. this.pageStyleSheet = document.createElement('style');
  3786. var pageSize = this.pagesOverview[0];
  3787. this.pageStyleSheet.textContent = '@supports ((size:A4) and (size:1pt 1pt)) {' + '@page { size: ' + pageSize.width + 'pt ' + pageSize.height + 'pt;}' + '}';
  3788. body.appendChild(this.pageStyleSheet)
  3789. },
  3790. destroy: function destroy() {
  3791. if (activeService !== this) {
  3792. return
  3793. }
  3794. this.printContainer.textContent = '';
  3795. if (this.pageStyleSheet && this.pageStyleSheet.parentNode) {
  3796. this.pageStyleSheet.parentNode.removeChild(this.pageStyleSheet);
  3797. this.pageStyleSheet = null
  3798. }
  3799. this.scratchCanvas.width = this.scratchCanvas.height = 0;
  3800. this.scratchCanvas = null;
  3801. activeService = null;
  3802. ensureOverlay().then(function() {
  3803. if (overlayManager.active !== 'printServiceOverlay') {
  3804. return
  3805. }
  3806. overlayManager.close('printServiceOverlay')
  3807. })
  3808. },
  3809. renderPages: function renderPages() {
  3810. var _this = this;
  3811. var pageCount = this.pagesOverview.length;
  3812. var renderNextPage = function renderNextPage(resolve, reject) {
  3813. _this.throwIfInactive();
  3814. if (++_this.currentPage >= pageCount) {
  3815. renderProgress(pageCount, pageCount, _this.l10n);
  3816. resolve();
  3817. return
  3818. }
  3819. var index = _this.currentPage;
  3820. renderProgress(index, pageCount, _this.l10n);
  3821. renderPage(_this, _this.pdfDocument, index + 1, _this.pagesOverview[index]).then(_this.useRenderedPage.bind(_this)).then(function() {
  3822. renderNextPage(resolve, reject)
  3823. },
  3824. reject)
  3825. };
  3826. return new Promise(renderNextPage)
  3827. },
  3828. useRenderedPage: function useRenderedPage(printItem) {
  3829. this.throwIfInactive();
  3830. var img = document.createElement('img');
  3831. img.style.width = printItem.width;
  3832. img.style.height = printItem.height;
  3833. var scratchCanvas = this.scratchCanvas;
  3834. if ('toBlob' in scratchCanvas && !_pdfjsLib.PDFJS.disableCreateObjectURL) {
  3835. scratchCanvas.toBlob(function(blob) {
  3836. img.src = URL.createObjectURL(blob)
  3837. })
  3838. } else {
  3839. img.src = scratchCanvas.toDataURL()
  3840. }
  3841. var wrapper = document.createElement('div');
  3842. wrapper.appendChild(img);
  3843. this.printContainer.appendChild(wrapper);
  3844. return new Promise(function(resolve, reject) {
  3845. img.onload = resolve;
  3846. img.onerror = reject
  3847. })
  3848. },
  3849. performPrint: function performPrint() {
  3850. var _this2 = this;
  3851. this.throwIfInactive();
  3852. return new Promise(function(resolve) {
  3853. setTimeout(function() {
  3854. if (!_this2.active) {
  3855. resolve();
  3856. return
  3857. }
  3858. print.call(window);
  3859. setTimeout(resolve, 20)
  3860. },
  3861. 0)
  3862. })
  3863. },
  3864. get active() {
  3865. return this === activeService
  3866. },
  3867. throwIfInactive: function throwIfInactive() {
  3868. if (!this.active) {
  3869. throw new Error('This print request was cancelled or completed.');
  3870. }
  3871. }
  3872. };
  3873. var print = window.print;
  3874. window.print = function print() {
  3875. if (activeService) {
  3876. console.warn('Ignored window.print() because of a pending print job.');
  3877. return
  3878. }
  3879. ensureOverlay().then(function() {
  3880. if (activeService) {
  3881. overlayManager.open('printServiceOverlay')
  3882. }
  3883. });
  3884. try {
  3885. dispatchEvent('beforeprint')
  3886. } finally {
  3887. if (!activeService) {
  3888. console.error('Expected print service to be initialized.');
  3889. ensureOverlay().then(function() {
  3890. if (overlayManager.active === 'printServiceOverlay') {
  3891. overlayManager.close('printServiceOverlay')
  3892. }
  3893. });
  3894. return
  3895. }
  3896. var activeServiceOnEntry = activeService;
  3897. activeService.renderPages().then(function() {
  3898. return activeServiceOnEntry.performPrint()
  3899. }).
  3900. catch(function() {}).then(function() {
  3901. if (activeServiceOnEntry.active) {
  3902. abort()
  3903. }
  3904. })
  3905. }
  3906. };
  3907. function dispatchEvent(eventType) {
  3908. var event = document.createEvent('CustomEvent');
  3909. event.initCustomEvent(eventType, false, false, 'custom');
  3910. window.dispatchEvent(event)
  3911. }
  3912. function abort() {
  3913. if (activeService) {
  3914. activeService.destroy();
  3915. dispatchEvent('afterprint')
  3916. }
  3917. }
  3918. function renderProgress(index, total, l10n) {
  3919. var progressContainer = document.getElementById('printServiceOverlay');
  3920. var progress = Math.round(100 * index / total);
  3921. var progressBar = progressContainer.querySelector('progress');
  3922. var progressPerc = progressContainer.querySelector('.relative-progress');
  3923. progressBar.value = progress;
  3924. l10n.get('print_progress_percent', {
  3925. progress: progress
  3926. },
  3927. progress + '%').then(function(msg) {
  3928. progressPerc.textContent = msg
  3929. })
  3930. }
  3931. var hasAttachEvent = !!document.attachEvent;
  3932. window.addEventListener('keydown',
  3933. function(event) {
  3934. if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
  3935. window.print();
  3936. if (hasAttachEvent) {
  3937. return
  3938. }
  3939. event.preventDefault();
  3940. if (event.stopImmediatePropagation) {
  3941. event.stopImmediatePropagation()
  3942. } else {
  3943. event.stopPropagation()
  3944. }
  3945. return
  3946. }
  3947. },
  3948. true);
  3949. if (hasAttachEvent) {
  3950. document.attachEvent('onkeydown',
  3951. function(event) {
  3952. event = event || window.event;
  3953. if (event.keyCode === 80 && event.ctrlKey) {
  3954. event.keyCode = 0;
  3955. return false
  3956. }
  3957. })
  3958. }
  3959. if ('onbeforeprint' in window) {
  3960. var stopPropagationIfNeeded = function stopPropagationIfNeeded(event) {
  3961. if (event.detail !== 'custom' && event.stopImmediatePropagation) {
  3962. event.stopImmediatePropagation()
  3963. }
  3964. };
  3965. window.addEventListener('beforeprint', stopPropagationIfNeeded);
  3966. window.addEventListener('afterprint', stopPropagationIfNeeded)
  3967. }
  3968. var overlayPromise;
  3969. function ensureOverlay() {
  3970. if (!overlayPromise) {
  3971. overlayManager = _app.PDFViewerApplication.overlayManager;
  3972. if (!overlayManager) {
  3973. throw new Error('The overlay manager has not yet been initialized.');
  3974. }
  3975. overlayPromise = overlayManager.register('printServiceOverlay', document.getElementById('printServiceOverlay'), abort, true);
  3976. document.getElementById('printCancel').onclick = abort
  3977. }
  3978. return overlayPromise
  3979. }
  3980. _app.PDFPrintServiceFactory.instance = {
  3981. supportsPrinting: true,
  3982. createPrintService: function createPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
  3983. if (activeService) {
  3984. throw new Error('The print service is created and active.');
  3985. }
  3986. activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n);
  3987. return activeService
  3988. }
  3989. };
  3990. exports.PDFPrintService = PDFPrintService
  3991. }), (function(module, exports, __webpack_require__) {
  3992. "use strict";
  3993. document.webL10n = function(window, document, undefined) {
  3994. var gL10nData = {};
  3995. var gTextData = '';
  3996. var gTextProp = 'textContent';
  3997. var gLanguage = '';
  3998. var gMacros = {};
  3999. var gReadyState = 'loading';
  4000. var gAsyncResourceLoading = true;
  4001. function getL10nResourceLinks() {
  4002. return document.querySelectorAll('link[type="application/l10n"]')
  4003. }
  4004. function getL10nDictionary() {
  4005. var script = document.querySelector('script[type="application/l10n"]');
  4006. return script ? JSON.parse(script.innerHTML) : null
  4007. }
  4008. function getTranslatableChildren(element) {
  4009. return element ? element.querySelectorAll('*[data-l10n-id]') : []
  4010. }
  4011. function getL10nAttributes(element) {
  4012. if (!element) return {};
  4013. var l10nId = element.getAttribute('data-l10n-id');
  4014. var l10nArgs = element.getAttribute('data-l10n-args');
  4015. var args = {};
  4016. if (l10nArgs) {
  4017. try {
  4018. args = JSON.parse(l10nArgs)
  4019. } catch(e) {
  4020. console.warn('could not parse arguments for #' + l10nId)
  4021. }
  4022. }
  4023. return {
  4024. id: l10nId,
  4025. args: args
  4026. }
  4027. }
  4028. function fireL10nReadyEvent(lang) {
  4029. var evtObject = document.createEvent('Event');
  4030. evtObject.initEvent('localized', true, false);
  4031. evtObject.language = lang;
  4032. document.dispatchEvent(evtObject)
  4033. }
  4034. function xhrLoadText(url, onSuccess, onFailure) {
  4035. onSuccess = onSuccess ||
  4036. function _onSuccess(data) {};
  4037. onFailure = onFailure ||
  4038. function _onFailure() {};
  4039. var xhr = new XMLHttpRequest();
  4040. xhr.open('GET', url, gAsyncResourceLoading);
  4041. if (xhr.overrideMimeType) {
  4042. xhr.overrideMimeType('text/plain; charset=utf-8')
  4043. }
  4044. xhr.onreadystatechange = function() {
  4045. if (xhr.readyState == 4) {
  4046. if (xhr.status == 200 || xhr.status === 0) {
  4047. onSuccess(xhr.responseText)
  4048. } else {
  4049. onFailure()
  4050. }
  4051. }
  4052. };
  4053. xhr.onerror = onFailure;
  4054. xhr.ontimeout = onFailure;
  4055. try {
  4056. xhr.send(null)
  4057. } catch(e) {
  4058. onFailure()
  4059. }
  4060. }
  4061. function parseResource(href, lang, successCallback, failureCallback) {
  4062. var baseURL = href.replace(/[^\/]*$/, '') || './';
  4063. function evalString(text) {
  4064. if (text.lastIndexOf('\\') < 0) return text;
  4065. return text.replace(/\\\\/g, '\\').replace(/\\n/g, '\n').replace(/\\r/g, '\r').replace(/\\t/g, '\t').replace(/\\b/g, '\b').replace(/\\f/g, '\f').replace(/\\{/g, '{').replace(/\\}/g, '}').replace(/\\"/g, '"').replace(/\\'/g, "'")
  4066. }
  4067. function parseProperties(text, parsedPropertiesCallback) {
  4068. var dictionary = {};
  4069. var reBlank = /^\s*|\s*$/;
  4070. var reComment = /^\s*#|^\s*$/;
  4071. var reSection = /^\s*\[(.*)\]\s*$/;
  4072. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  4073. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  4074. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  4075. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  4076. var currentLang = '*';
  4077. var genericLang = lang.split('-', 1)[0];
  4078. var skipLang = false;
  4079. var match = '';
  4080. function nextEntry() {
  4081. while (true) {
  4082. if (!entries.length) {
  4083. parsedRawLinesCallback();
  4084. return
  4085. }
  4086. var line = entries.shift();
  4087. if (reComment.test(line)) continue;
  4088. if (extendedSyntax) {
  4089. match = reSection.exec(line);
  4090. if (match) {
  4091. currentLang = match[1].toLowerCase();
  4092. skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
  4093. continue
  4094. } else if (skipLang) {
  4095. continue
  4096. }
  4097. match = reImport.exec(line);
  4098. if (match) {
  4099. loadImport(baseURL + match[1], nextEntry);
  4100. return
  4101. }
  4102. }
  4103. var tmp = line.match(reSplit);
  4104. if (tmp && tmp.length == 3) {
  4105. dictionary[tmp[1]] = evalString(tmp[2])
  4106. }
  4107. }
  4108. }
  4109. nextEntry()
  4110. }
  4111. function loadImport(url, callback) {
  4112. xhrLoadText(url,
  4113. function(content) {
  4114. parseRawLines(content, false, callback)
  4115. },
  4116. function() {
  4117. console.warn(url + ' not found.');
  4118. callback()
  4119. })
  4120. }
  4121. parseRawLines(text, true,
  4122. function() {
  4123. parsedPropertiesCallback(dictionary)
  4124. })
  4125. }
  4126. xhrLoadText(href,
  4127. function(response) {
  4128. gTextData += response;
  4129. parseProperties(response,
  4130. function(data) {
  4131. for (var key in data) {
  4132. var id, prop, index = key.lastIndexOf('.');
  4133. if (index > 0) {
  4134. id = key.substring(0, index);
  4135. prop = key.substr(index + 1)
  4136. } else {
  4137. id = key;
  4138. prop = gTextProp
  4139. }
  4140. if (!gL10nData[id]) {
  4141. gL10nData[id] = {}
  4142. }
  4143. gL10nData[id][prop] = data[key]
  4144. }
  4145. if (successCallback) {
  4146. successCallback()
  4147. }
  4148. })
  4149. },
  4150. failureCallback)
  4151. }
  4152. function loadLocale(lang, callback) {
  4153. if (lang) {
  4154. lang = lang.toLowerCase()
  4155. }
  4156. callback = callback ||
  4157. function _callback() {};
  4158. clear();
  4159. gLanguage = lang;
  4160. var langLinks = getL10nResourceLinks();
  4161. var langCount = langLinks.length;
  4162. if (langCount === 0) {
  4163. var dict = getL10nDictionary();
  4164. if (dict && dict.locales && dict.default_locale) {
  4165. console.log('using the embedded JSON directory, early way out');
  4166. gL10nData = dict.locales[lang];
  4167. if (!gL10nData) {
  4168. var defaultLocale = dict.default_locale.toLowerCase();
  4169. for (var anyCaseLang in dict.locales) {
  4170. anyCaseLang = anyCaseLang.toLowerCase();
  4171. if (anyCaseLang === lang) {
  4172. gL10nData = dict.locales[lang];
  4173. break
  4174. } else if (anyCaseLang === defaultLocale) {
  4175. gL10nData = dict.locales[defaultLocale]
  4176. }
  4177. }
  4178. }
  4179. callback()
  4180. } else {
  4181. console.log('no resource to load, early way out')
  4182. }
  4183. fireL10nReadyEvent(lang);
  4184. gReadyState = 'complete';
  4185. return
  4186. }
  4187. var onResourceLoaded = null;
  4188. var gResourceCount = 0;
  4189. onResourceLoaded = function onResourceLoaded() {
  4190. gResourceCount++;
  4191. if (gResourceCount >= langCount) {
  4192. callback();
  4193. fireL10nReadyEvent(lang);
  4194. gReadyState = 'complete'
  4195. }
  4196. };
  4197. function L10nResourceLink(link) {
  4198. var href = link.href;
  4199. this.load = function(lang, callback) {
  4200. parseResource(href, lang, callback,
  4201. function() {
  4202. console.warn(href + ' not found.');
  4203. console.warn('"' + lang + '" resource not found');
  4204. gLanguage = '';
  4205. callback()
  4206. })
  4207. }
  4208. }
  4209. for (var i = 0; i < langCount; i++) {
  4210. var resource = new L10nResourceLink(langLinks[i]);
  4211. resource.load(lang, onResourceLoaded)
  4212. }
  4213. }
  4214. function clear() {
  4215. gL10nData = {};
  4216. gTextData = '';
  4217. gLanguage = ''
  4218. }
  4219. function getPluralRules(lang) {
  4220. var locales2rules = {
  4221. 'af': 3,
  4222. 'ak': 4,
  4223. 'am': 4,
  4224. 'ar': 1,
  4225. 'asa': 3,
  4226. 'az': 0,
  4227. 'be': 11,
  4228. 'bem': 3,
  4229. 'bez': 3,
  4230. 'bg': 3,
  4231. 'bh': 4,
  4232. 'bm': 0,
  4233. 'bn': 3,
  4234. 'bo': 0,
  4235. 'br': 20,
  4236. 'brx': 3,
  4237. 'bs': 11,
  4238. 'ca': 3,
  4239. 'cgg': 3,
  4240. 'chr': 3,
  4241. 'cs': 12,
  4242. 'cy': 17,
  4243. 'da': 3,
  4244. 'de': 3,
  4245. 'dv': 3,
  4246. 'dz': 0,
  4247. 'ee': 3,
  4248. 'el': 3,
  4249. 'en': 3,
  4250. 'eo': 3,
  4251. 'es': 3,
  4252. 'et': 3,
  4253. 'eu': 3,
  4254. 'fa': 0,
  4255. 'ff': 5,
  4256. 'fi': 3,
  4257. 'fil': 4,
  4258. 'fo': 3,
  4259. 'fr': 5,
  4260. 'fur': 3,
  4261. 'fy': 3,
  4262. 'ga': 8,
  4263. 'gd': 24,
  4264. 'gl': 3,
  4265. 'gsw': 3,
  4266. 'gu': 3,
  4267. 'guw': 4,
  4268. 'gv': 23,
  4269. 'ha': 3,
  4270. 'haw': 3,
  4271. 'he': 2,
  4272. 'hi': 4,
  4273. 'hr': 11,
  4274. 'hu': 0,
  4275. 'id': 0,
  4276. 'ig': 0,
  4277. 'ii': 0,
  4278. 'is': 3,
  4279. 'it': 3,
  4280. 'iu': 7,
  4281. 'ja': 0,
  4282. 'jmc': 3,
  4283. 'jv': 0,
  4284. 'ka': 0,
  4285. 'kab': 5,
  4286. 'kaj': 3,
  4287. 'kcg': 3,
  4288. 'kde': 0,
  4289. 'kea': 0,
  4290. 'kk': 3,
  4291. 'kl': 3,
  4292. 'km': 0,
  4293. 'kn': 0,
  4294. 'ko': 0,
  4295. 'ksb': 3,
  4296. 'ksh': 21,
  4297. 'ku': 3,
  4298. 'kw': 7,
  4299. 'lag': 18,
  4300. 'lb': 3,
  4301. 'lg': 3,
  4302. 'ln': 4,
  4303. 'lo': 0,
  4304. 'lt': 10,
  4305. 'lv': 6,
  4306. 'mas': 3,
  4307. 'mg': 4,
  4308. 'mk': 16,
  4309. 'ml': 3,
  4310. 'mn': 3,
  4311. 'mo': 9,
  4312. 'mr': 3,
  4313. 'ms': 0,
  4314. 'mt': 15,
  4315. 'my': 0,
  4316. 'nah': 3,
  4317. 'naq': 7,
  4318. 'nb': 3,
  4319. 'nd': 3,
  4320. 'ne': 3,
  4321. 'nl': 3,
  4322. 'nn': 3,
  4323. 'no': 3,
  4324. 'nr': 3,
  4325. 'nso': 4,
  4326. 'ny': 3,
  4327. 'nyn': 3,
  4328. 'om': 3,
  4329. 'or': 3,
  4330. 'pa': 3,
  4331. 'pap': 3,
  4332. 'pl': 13,
  4333. 'ps': 3,
  4334. 'pt': 3,
  4335. 'rm': 3,
  4336. 'ro': 9,
  4337. 'rof': 3,
  4338. 'ru': 11,
  4339. 'rwk': 3,
  4340. 'sah': 0,
  4341. 'saq': 3,
  4342. 'se': 7,
  4343. 'seh': 3,
  4344. 'ses': 0,
  4345. 'sg': 0,
  4346. 'sh': 11,
  4347. 'shi': 19,
  4348. 'sk': 12,
  4349. 'sl': 14,
  4350. 'sma': 7,
  4351. 'smi': 7,
  4352. 'smj': 7,
  4353. 'smn': 7,
  4354. 'sms': 7,
  4355. 'sn': 3,
  4356. 'so': 3,
  4357. 'sq': 3,
  4358. 'sr': 11,
  4359. 'ss': 3,
  4360. 'ssy': 3,
  4361. 'st': 3,
  4362. 'sv': 3,
  4363. 'sw': 3,
  4364. 'syr': 3,
  4365. 'ta': 3,
  4366. 'te': 3,
  4367. 'teo': 3,
  4368. 'th': 0,
  4369. 'ti': 4,
  4370. 'tig': 3,
  4371. 'tk': 3,
  4372. 'tl': 4,
  4373. 'tn': 3,
  4374. 'to': 0,
  4375. 'tr': 0,
  4376. 'ts': 3,
  4377. 'tzm': 22,
  4378. 'uk': 11,
  4379. 'ur': 3,
  4380. 've': 3,
  4381. 'vi': 0,
  4382. 'vun': 3,
  4383. 'wa': 4,
  4384. 'wae': 3,
  4385. 'wo': 0,
  4386. 'xh': 3,
  4387. 'xog': 3,
  4388. 'yo': 0,
  4389. 'zh': 0,
  4390. 'zu': 3
  4391. };
  4392. function isIn(n, list) {
  4393. return list.indexOf(n) !== -1
  4394. }
  4395. function isBetween(n, start, end) {
  4396. return start <= n && n <= end
  4397. }
  4398. var pluralRules = {
  4399. '0': function _(n) {
  4400. return 'other'
  4401. },
  4402. '1': function _(n) {
  4403. if (isBetween(n % 100, 3, 10)) return 'few';
  4404. if (n === 0) return 'zero';
  4405. if (isBetween(n % 100, 11, 99)) return 'many';
  4406. if (n == 2) return 'two';
  4407. if (n == 1) return 'one';
  4408. return 'other'
  4409. },
  4410. '2': function _(n) {
  4411. if (n !== 0 && n % 10 === 0) return 'many';
  4412. if (n == 2) return 'two';
  4413. if (n == 1) return 'one';
  4414. return 'other'
  4415. },
  4416. '3': function _(n) {
  4417. if (n == 1) return 'one';
  4418. return 'other'
  4419. },
  4420. '4': function _(n) {
  4421. if (isBetween(n, 0, 1)) return 'one';
  4422. return 'other'
  4423. },
  4424. '5': function _(n) {
  4425. if (isBetween(n, 0, 2) && n != 2) return 'one';
  4426. return 'other'
  4427. },
  4428. '6': function _(n) {
  4429. if (n === 0) return 'zero';
  4430. if (n % 10 == 1 && n % 100 != 11) return 'one';
  4431. return 'other'
  4432. },
  4433. '7': function _(n) {
  4434. if (n == 2) return 'two';
  4435. if (n == 1) return 'one';
  4436. return 'other'
  4437. },
  4438. '8': function _(n) {
  4439. if (isBetween(n, 3, 6)) return 'few';
  4440. if (isBetween(n, 7, 10)) return 'many';
  4441. if (n == 2) return 'two';
  4442. if (n == 1) return 'one';
  4443. return 'other'
  4444. },
  4445. '9': function _(n) {
  4446. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  4447. if (n == 1) return 'one';
  4448. return 'other'
  4449. },
  4450. '10': function _(n) {
  4451. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  4452. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  4453. return 'other'
  4454. },
  4455. '11': function _(n) {
  4456. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  4457. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
  4458. if (n % 10 == 1 && n % 100 != 11) return 'one';
  4459. return 'other'
  4460. },
  4461. '12': function _(n) {
  4462. if (isBetween(n, 2, 4)) return 'few';
  4463. if (n == 1) return 'one';
  4464. return 'other'
  4465. },
  4466. '13': function _(n) {
  4467. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  4468. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
  4469. if (n == 1) return 'one';
  4470. return 'other'
  4471. },
  4472. '14': function _(n) {
  4473. if (isBetween(n % 100, 3, 4)) return 'few';
  4474. if (n % 100 == 2) return 'two';
  4475. if (n % 100 == 1) return 'one';
  4476. return 'other'
  4477. },
  4478. '15': function _(n) {
  4479. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  4480. if (isBetween(n % 100, 11, 19)) return 'many';
  4481. if (n == 1) return 'one';
  4482. return 'other'
  4483. },
  4484. '16': function _(n) {
  4485. if (n % 10 == 1 && n != 11) return 'one';
  4486. return 'other'
  4487. },
  4488. '17': function _(n) {
  4489. if (n == 3) return 'few';
  4490. if (n === 0) return 'zero';
  4491. if (n == 6) return 'many';
  4492. if (n == 2) return 'two';
  4493. if (n == 1) return 'one';
  4494. return 'other'
  4495. },
  4496. '18': function _(n) {
  4497. if (n === 0) return 'zero';
  4498. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  4499. return 'other'
  4500. },
  4501. '19': function _(n) {
  4502. if (isBetween(n, 2, 10)) return 'few';
  4503. if (isBetween(n, 0, 1)) return 'one';
  4504. return 'other'
  4505. },
  4506. '20': function _(n) {
  4507. if ((isBetween(n % 10, 3, 4) || n % 10 == 9) && !(isBetween(n % 100, 10, 19) || isBetween(n % 100, 70, 79) || isBetween(n % 100, 90, 99))) return 'few';
  4508. if (n % 1000000 === 0 && n !== 0) return 'many';
  4509. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  4510. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  4511. return 'other'
  4512. },
  4513. '21': function _(n) {
  4514. if (n === 0) return 'zero';
  4515. if (n == 1) return 'one';
  4516. return 'other'
  4517. },
  4518. '22': function _(n) {
  4519. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  4520. return 'other'
  4521. },
  4522. '23': function _(n) {
  4523. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  4524. return 'other'
  4525. },
  4526. '24': function _(n) {
  4527. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  4528. if (isIn(n, [2, 12])) return 'two';
  4529. if (isIn(n, [1, 11])) return 'one';
  4530. return 'other'
  4531. }
  4532. };
  4533. var index = locales2rules[lang.replace(/-.*$/, '')];
  4534. if (! (index in pluralRules)) {
  4535. console.warn('plural form unknown for [' + lang + ']');
  4536. return function() {
  4537. return 'other'
  4538. }
  4539. }
  4540. return pluralRules[index]
  4541. }
  4542. gMacros.plural = function(str, param, key, prop) {
  4543. var n = parseFloat(param);
  4544. if (isNaN(n)) return str;
  4545. if (prop != gTextProp) return str;
  4546. if (!gMacros._pluralRules) {
  4547. gMacros._pluralRules = getPluralRules(gLanguage)
  4548. }
  4549. var index = '[' + gMacros._pluralRules(n) + ']';
  4550. if (n === 0 && key + '[zero]' in gL10nData) {
  4551. str = gL10nData[key + '[zero]'][prop]
  4552. } else if (n == 1 && key + '[one]' in gL10nData) {
  4553. str = gL10nData[key + '[one]'][prop]
  4554. } else if (n == 2 && key + '[two]' in gL10nData) {
  4555. str = gL10nData[key + '[two]'][prop]
  4556. } else if (key + index in gL10nData) {
  4557. str = gL10nData[key + index][prop]
  4558. } else if (key + '[other]' in gL10nData) {
  4559. str = gL10nData[key + '[other]'][prop]
  4560. }
  4561. return str
  4562. };
  4563. function getL10nData(key, args, fallback) {
  4564. var data = gL10nData[key];
  4565. if (!data) {
  4566. console.warn('#' + key + ' is undefined.');
  4567. if (!fallback) {
  4568. return null
  4569. }
  4570. data = fallback
  4571. }
  4572. var rv = {};
  4573. for (var prop in data) {
  4574. var str = data[prop];
  4575. str = substIndexes(str, args, key, prop);
  4576. str = substArguments(str, args, key);
  4577. rv[prop] = str
  4578. }
  4579. return rv
  4580. }
  4581. function substIndexes(str, args, key, prop) {
  4582. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  4583. var reMatch = reIndex.exec(str);
  4584. if (!reMatch || !reMatch.length) return str;
  4585. var macroName = reMatch[1];
  4586. var paramName = reMatch[2];
  4587. var param;
  4588. if (args && paramName in args) {
  4589. param = args[paramName]
  4590. } else if (paramName in gL10nData) {
  4591. param = gL10nData[paramName]
  4592. }
  4593. if (macroName in gMacros) {
  4594. var macro = gMacros[macroName];
  4595. str = macro(str, param, key, prop)
  4596. }
  4597. return str
  4598. }
  4599. function substArguments(str, args, key) {
  4600. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  4601. return str.replace(reArgs,
  4602. function(matched_text, arg) {
  4603. if (args && arg in args) {
  4604. return args[arg]
  4605. }
  4606. if (arg in gL10nData) {
  4607. return gL10nData[arg]
  4608. }
  4609. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  4610. return matched_text
  4611. })
  4612. }
  4613. function translateElement(element) {
  4614. var l10n = getL10nAttributes(element);
  4615. if (!l10n.id) return;
  4616. var data = getL10nData(l10n.id, l10n.args);
  4617. if (!data) {
  4618. console.warn('#' + l10n.id + ' is undefined.');
  4619. return
  4620. }
  4621. if (data[gTextProp]) {
  4622. if (getChildElementCount(element) === 0) {
  4623. element[gTextProp] = data[gTextProp]
  4624. } else {
  4625. var children = element.childNodes;
  4626. var found = false;
  4627. for (var i = 0,
  4628. l = children.length; i < l; i++) {
  4629. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  4630. if (found) {
  4631. children[i].nodeValue = ''
  4632. } else {
  4633. children[i].nodeValue = data[gTextProp];
  4634. found = true
  4635. }
  4636. }
  4637. }
  4638. if (!found) {
  4639. var textNode = document.createTextNode(data[gTextProp]);
  4640. element.insertBefore(textNode, element.firstChild)
  4641. }
  4642. }
  4643. delete data[gTextProp]
  4644. }
  4645. for (var k in data) {
  4646. element[k] = data[k]
  4647. }
  4648. }
  4649. function getChildElementCount(element) {
  4650. if (element.children) {
  4651. return element.children.length
  4652. }
  4653. if (typeof element.childElementCount !== 'undefined') {
  4654. return element.childElementCount
  4655. }
  4656. var count = 0;
  4657. for (var i = 0; i < element.childNodes.length; i++) {
  4658. count += element.nodeType === 1 ? 1 : 0
  4659. }
  4660. return count
  4661. }
  4662. function translateFragment(element) {
  4663. element = element || document.documentElement;
  4664. var children = getTranslatableChildren(element);
  4665. var elementCount = children.length;
  4666. for (var i = 0; i < elementCount; i++) {
  4667. translateElement(children[i])
  4668. }
  4669. translateElement(element)
  4670. }
  4671. return {
  4672. get: function get(key, args, fallbackString) {
  4673. var index = key.lastIndexOf('.');
  4674. var prop = gTextProp;
  4675. if (index > 0) {
  4676. prop = key.substr(index + 1);
  4677. key = key.substring(0, index)
  4678. }
  4679. var fallback;
  4680. if (fallbackString) {
  4681. fallback = {};
  4682. fallback[prop] = fallbackString
  4683. }
  4684. var data = getL10nData(key, args, fallback);
  4685. if (data && prop in data) {
  4686. return data[prop]
  4687. }
  4688. return '{{' + key + '}}'
  4689. },
  4690. getData: function getData() {
  4691. return gL10nData
  4692. },
  4693. getText: function getText() {
  4694. return gTextData
  4695. },
  4696. getLanguage: function getLanguage() {
  4697. return gLanguage
  4698. },
  4699. setLanguage: function setLanguage(lang, callback) {
  4700. loadLocale(lang,
  4701. function() {
  4702. if (callback) callback()
  4703. })
  4704. },
  4705. getDirection: function getDirection() {
  4706. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  4707. var shortCode = gLanguage.split('-', 1)[0];
  4708. return rtlList.indexOf(shortCode) >= 0 ? 'rtl': 'ltr'
  4709. },
  4710. translate: translateFragment,
  4711. getReadyState: function getReadyState() {
  4712. return gReadyState
  4713. },
  4714. ready: function ready(callback) {
  4715. if (!callback) {
  4716. return
  4717. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  4718. window.setTimeout(function() {
  4719. callback()
  4720. })
  4721. } else if (document.addEventListener) {
  4722. document.addEventListener('localized',
  4723. function once() {
  4724. document.removeEventListener('localized', once);
  4725. callback()
  4726. })
  4727. }
  4728. }
  4729. }
  4730. } (window, document)
  4731. }), (function(module, exports, __webpack_require__) {
  4732. "use strict";
  4733. Object.defineProperty(exports, "__esModule", {
  4734. value: true
  4735. });
  4736. exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = undefined;
  4737. var _createClass = function() {
  4738. function defineProperties(target, props) {
  4739. for (var i = 0; i < props.length; i++) {
  4740. var descriptor = props[i];
  4741. descriptor.enumerable = descriptor.enumerable || false;
  4742. descriptor.configurable = true;
  4743. if ("value" in descriptor) descriptor.writable = true;
  4744. Object.defineProperty(target, descriptor.key, descriptor)
  4745. }
  4746. }
  4747. return function(Constructor, protoProps, staticProps) {
  4748. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  4749. if (staticProps) defineProperties(Constructor, staticProps);
  4750. return Constructor
  4751. }
  4752. } ();
  4753. var _pdfjsLib = __webpack_require__(1);
  4754. var _ui_utils = __webpack_require__(0);
  4755. var _pdf_link_service = __webpack_require__(5);
  4756. function _classCallCheck(instance, Constructor) {
  4757. if (! (instance instanceof Constructor)) {
  4758. throw new TypeError("Cannot call a class as a function");
  4759. }
  4760. }
  4761. var AnnotationLayerBuilder = function() {
  4762. function AnnotationLayerBuilder(_ref) {
  4763. var pageDiv = _ref.pageDiv,
  4764. pdfPage = _ref.pdfPage,
  4765. linkService = _ref.linkService,
  4766. downloadManager = _ref.downloadManager,
  4767. _ref$renderInteractiv = _ref.renderInteractiveForms,
  4768. renderInteractiveForms = _ref$renderInteractiv === undefined ? false: _ref$renderInteractiv,
  4769. _ref$l10n = _ref.l10n,
  4770. l10n = _ref$l10n === undefined ? _ui_utils.NullL10n: _ref$l10n;
  4771. _classCallCheck(this, AnnotationLayerBuilder);
  4772. this.pageDiv = pageDiv;
  4773. this.pdfPage = pdfPage;
  4774. this.linkService = linkService;
  4775. this.downloadManager = downloadManager;
  4776. this.renderInteractiveForms = renderInteractiveForms;
  4777. this.l10n = l10n;
  4778. this.div = null
  4779. }
  4780. _createClass(AnnotationLayerBuilder, [{
  4781. key: 'render',
  4782. value: function render(viewport) {
  4783. var _this = this;
  4784. var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'display';
  4785. this.pdfPage.getAnnotations({
  4786. intent: intent
  4787. }).then(function(annotations) {
  4788. var parameters = {
  4789. viewport: viewport.clone({
  4790. dontFlip: true
  4791. }),
  4792. div: _this.div,
  4793. annotations: annotations,
  4794. page: _this.pdfPage,
  4795. renderInteractiveForms: _this.renderInteractiveForms,
  4796. linkService: _this.linkService,
  4797. downloadManager: _this.downloadManager
  4798. };
  4799. if (_this.div) {
  4800. _pdfjsLib.AnnotationLayer.update(parameters)
  4801. } else {
  4802. if (annotations.length === 0) {
  4803. return
  4804. }
  4805. _this.div = document.createElement('div');
  4806. _this.div.className = 'annotationLayer';
  4807. _this.pageDiv.appendChild(_this.div);
  4808. parameters.div = _this.div;
  4809. _pdfjsLib.AnnotationLayer.render(parameters);
  4810. _this.l10n.translate(_this.div)
  4811. }
  4812. })
  4813. }
  4814. },
  4815. {
  4816. key: 'hide',
  4817. value: function hide() {
  4818. if (!this.div) {
  4819. return
  4820. }
  4821. this.div.setAttribute('hidden', 'true')
  4822. }
  4823. }]);
  4824. return AnnotationLayerBuilder
  4825. } ();
  4826. var DefaultAnnotationLayerFactory = function() {
  4827. function DefaultAnnotationLayerFactory() {
  4828. _classCallCheck(this, DefaultAnnotationLayerFactory)
  4829. }
  4830. _createClass(DefaultAnnotationLayerFactory, [{
  4831. key: 'createAnnotationLayerBuilder',
  4832. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  4833. var renderInteractiveForms = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  4834. var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
  4835. return new AnnotationLayerBuilder({
  4836. pageDiv: pageDiv,
  4837. pdfPage: pdfPage,
  4838. renderInteractiveForms: renderInteractiveForms,
  4839. linkService: new _pdf_link_service.SimpleLinkService(),
  4840. l10n: l10n
  4841. })
  4842. }
  4843. }]);
  4844. return DefaultAnnotationLayerFactory
  4845. } ();
  4846. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  4847. exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory
  4848. }), (function(module, exports, __webpack_require__) {
  4849. "use strict";
  4850. Object.defineProperty(exports, "__esModule", {
  4851. value: true
  4852. });
  4853. exports.DownloadManager = undefined;
  4854. var _createClass = function() {
  4855. function defineProperties(target, props) {
  4856. for (var i = 0; i < props.length; i++) {
  4857. var descriptor = props[i];
  4858. descriptor.enumerable = descriptor.enumerable || false;
  4859. descriptor.configurable = true;
  4860. if ("value" in descriptor) descriptor.writable = true;
  4861. Object.defineProperty(target, descriptor.key, descriptor)
  4862. }
  4863. }
  4864. return function(Constructor, protoProps, staticProps) {
  4865. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  4866. if (staticProps) defineProperties(Constructor, staticProps);
  4867. return Constructor
  4868. }
  4869. } ();
  4870. var _pdfjsLib = __webpack_require__(1);
  4871. function _classCallCheck(instance, Constructor) {
  4872. if (! (instance instanceof Constructor)) {
  4873. throw new TypeError("Cannot call a class as a function");
  4874. }
  4875. };
  4876. function _download(blobUrl, filename) {
  4877. var a = document.createElement('a');
  4878. if (a.click) {
  4879. a.href = blobUrl;
  4880. a.target = '_parent';
  4881. if ('download' in a) {
  4882. a.download = filename
  4883. } (document.body || document.documentElement).appendChild(a);
  4884. a.click();
  4885. a.parentNode.removeChild(a)
  4886. } else {
  4887. if (window.top === window && blobUrl.split('#')[0] === window.location.href.split('#')[0]) {
  4888. var padCharacter = blobUrl.indexOf('?') === -1 ? '?': '&';
  4889. blobUrl = blobUrl.replace(/#|$/, padCharacter + '$&')
  4890. }
  4891. window.open(blobUrl, '_parent')
  4892. }
  4893. }
  4894. var DownloadManager = function() {
  4895. function DownloadManager() {
  4896. _classCallCheck(this, DownloadManager)
  4897. }
  4898. _createClass(DownloadManager, [{
  4899. key: 'downloadUrl',
  4900. value: function downloadUrl(url, filename) {
  4901. if (! (0, _pdfjsLib.createValidAbsoluteUrl)(url, 'http://example.com')) {
  4902. return
  4903. }
  4904. _download(url + '#pdfjs.action=download', filename)
  4905. }
  4906. },
  4907. {
  4908. key: 'downloadData',
  4909. value: function downloadData(data, filename, contentType) {
  4910. if (navigator.msSaveBlob) {
  4911. return navigator.msSaveBlob(new Blob([data], {
  4912. type: contentType
  4913. }), filename)
  4914. }
  4915. var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, _pdfjsLib.PDFJS.disableCreateObjectURL);
  4916. _download(blobUrl, filename)
  4917. }
  4918. },
  4919. {
  4920. key: 'download',
  4921. value: function download(blob, url, filename) {
  4922. if (navigator.msSaveBlob) {
  4923. if (!navigator.msSaveBlob(blob, filename)) {
  4924. this.downloadUrl(url, filename)
  4925. }
  4926. return
  4927. }
  4928. if (_pdfjsLib.PDFJS.disableCreateObjectURL) {
  4929. this.downloadUrl(url, filename);
  4930. return
  4931. }
  4932. var blobUrl = URL.createObjectURL(blob);
  4933. _download(blobUrl, filename)
  4934. }
  4935. }]);
  4936. return DownloadManager
  4937. } ();
  4938. exports.DownloadManager = DownloadManager
  4939. }), (function(module, exports, __webpack_require__) {
  4940. "use strict";
  4941. Object.defineProperty(exports, "__esModule", {
  4942. value: true
  4943. });
  4944. exports.GenericL10n = undefined;
  4945. var _createClass = function() {
  4946. function defineProperties(target, props) {
  4947. for (var i = 0; i < props.length; i++) {
  4948. var descriptor = props[i];
  4949. descriptor.enumerable = descriptor.enumerable || false;
  4950. descriptor.configurable = true;
  4951. if ("value" in descriptor) descriptor.writable = true;
  4952. Object.defineProperty(target, descriptor.key, descriptor)
  4953. }
  4954. }
  4955. return function(Constructor, protoProps, staticProps) {
  4956. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  4957. if (staticProps) defineProperties(Constructor, staticProps);
  4958. return Constructor
  4959. }
  4960. } ();
  4961. __webpack_require__(10);
  4962. function _classCallCheck(instance, Constructor) {
  4963. if (! (instance instanceof Constructor)) {
  4964. throw new TypeError("Cannot call a class as a function");
  4965. }
  4966. }
  4967. var webL10n = document.webL10n;
  4968. var GenericL10n = function() {
  4969. function GenericL10n(lang) {
  4970. _classCallCheck(this, GenericL10n);
  4971. this._lang = lang;
  4972. this._ready = new Promise(function(resolve, reject) {
  4973. webL10n.setLanguage(lang,
  4974. function() {
  4975. resolve(webL10n)
  4976. })
  4977. })
  4978. }
  4979. _createClass(GenericL10n, [{
  4980. key: 'getDirection',
  4981. value: function getDirection() {
  4982. return this._ready.then(function(l10n) {
  4983. return l10n.getDirection()
  4984. })
  4985. }
  4986. },
  4987. {
  4988. key: 'get',
  4989. value: function get(property, args, fallback) {
  4990. return this._ready.then(function(l10n) {
  4991. return l10n.get(property, args, fallback)
  4992. })
  4993. }
  4994. },
  4995. {
  4996. key: 'translate',
  4997. value: function translate(element) {
  4998. return this._ready.then(function(l10n) {
  4999. return l10n.translate(element)
  5000. })
  5001. }
  5002. }]);
  5003. return GenericL10n
  5004. } ();
  5005. exports.GenericL10n = GenericL10n
  5006. }), (function(module, exports, __webpack_require__) {
  5007. "use strict";
  5008. Object.defineProperty(exports, "__esModule", {
  5009. value: true
  5010. });
  5011. function GrabToPan(options) {
  5012. this.element = options.element;
  5013. this.document = options.element.ownerDocument;
  5014. if (typeof options.ignoreTarget === 'function') {
  5015. this.ignoreTarget = options.ignoreTarget
  5016. }
  5017. this.onActiveChanged = options.onActiveChanged;
  5018. this.activate = this.activate.bind(this);
  5019. this.deactivate = this.deactivate.bind(this);
  5020. this.toggle = this.toggle.bind(this);
  5021. this._onmousedown = this._onmousedown.bind(this);
  5022. this._onmousemove = this._onmousemove.bind(this);
  5023. this._endPan = this._endPan.bind(this);
  5024. var overlay = this.overlay = document.createElement('div');
  5025. overlay.className = 'grab-to-pan-grabbing'
  5026. }
  5027. GrabToPan.prototype = {
  5028. CSS_CLASS_GRAB: 'grab-to-pan-grab',
  5029. activate: function GrabToPan_activate() {
  5030. if (!this.active) {
  5031. this.active = true;
  5032. this.element.addEventListener('mousedown', this._onmousedown, true);
  5033. this.element.classList.add(this.CSS_CLASS_GRAB);
  5034. if (this.onActiveChanged) {
  5035. this.onActiveChanged(true)
  5036. }
  5037. }
  5038. },
  5039. deactivate: function GrabToPan_deactivate() {
  5040. if (this.active) {
  5041. this.active = false;
  5042. this.element.removeEventListener('mousedown', this._onmousedown, true);
  5043. this._endPan();
  5044. this.element.classList.remove(this.CSS_CLASS_GRAB);
  5045. if (this.onActiveChanged) {
  5046. this.onActiveChanged(false)
  5047. }
  5048. }
  5049. },
  5050. toggle: function GrabToPan_toggle() {
  5051. if (this.active) {
  5052. this.deactivate()
  5053. } else {
  5054. this.activate()
  5055. }
  5056. },
  5057. ignoreTarget: function GrabToPan_ignoreTarget(node) {
  5058. return node[matchesSelector]('a[href], a[href] *, input, textarea, button, button *, select, option')
  5059. },
  5060. _onmousedown: function GrabToPan__onmousedown(event) {
  5061. if (event.button !== 0 || this.ignoreTarget(event.target)) {
  5062. return
  5063. }
  5064. if (event.originalTarget) {
  5065. try {
  5066. event.originalTarget.tagName
  5067. } catch(e) {
  5068. return
  5069. }
  5070. }
  5071. this.scrollLeftStart = this.element.scrollLeft;
  5072. this.scrollTopStart = this.element.scrollTop;
  5073. this.clientXStart = event.clientX;
  5074. this.clientYStart = event.clientY;
  5075. this.document.addEventListener('mousemove', this._onmousemove, true);
  5076. this.document.addEventListener('mouseup', this._endPan, true);
  5077. this.element.addEventListener('scroll', this._endPan, true);
  5078. event.preventDefault();
  5079. event.stopPropagation();
  5080. var focusedElement = document.activeElement;
  5081. if (focusedElement && !focusedElement.contains(event.target)) {
  5082. focusedElement.blur()
  5083. }
  5084. },
  5085. _onmousemove: function GrabToPan__onmousemove(event) {
  5086. this.element.removeEventListener('scroll', this._endPan, true);
  5087. if (isLeftMouseReleased(event)) {
  5088. this._endPan();
  5089. return
  5090. }
  5091. var xDiff = event.clientX - this.clientXStart;
  5092. var yDiff = event.clientY - this.clientYStart;
  5093. var scrollTop = this.scrollTopStart - yDiff;
  5094. var scrollLeft = this.scrollLeftStart - xDiff;
  5095. if (this.element.scrollTo) {
  5096. this.element.scrollTo({
  5097. top: scrollTop,
  5098. left: scrollLeft,
  5099. behavior: 'instant'
  5100. })
  5101. } else {
  5102. this.element.scrollTop = scrollTop;
  5103. this.element.scrollLeft = scrollLeft
  5104. }
  5105. if (!this.overlay.parentNode) {
  5106. document.body.appendChild(this.overlay)
  5107. }
  5108. },
  5109. _endPan: function GrabToPan__endPan() {
  5110. this.element.removeEventListener('scroll', this._endPan, true);
  5111. this.document.removeEventListener('mousemove', this._onmousemove, true);
  5112. this.document.removeEventListener('mouseup', this._endPan, true);
  5113. this.overlay.remove()
  5114. }
  5115. };
  5116. var matchesSelector; ['webkitM', 'mozM', 'msM', 'oM', 'm'].some(function(prefix) {
  5117. var name = prefix + 'atches';
  5118. if (name in document.documentElement) {
  5119. matchesSelector = name
  5120. }
  5121. name += 'Selector';
  5122. if (name in document.documentElement) {
  5123. matchesSelector = name
  5124. }
  5125. return matchesSelector
  5126. });
  5127. var isNotIEorIsIE10plus = !document.documentMode || document.documentMode > 9;
  5128. var chrome = window.chrome;
  5129. var isChrome15OrOpera15plus = chrome && (chrome.webstore || chrome.app);
  5130. var isSafari6plus = /Apple/.test(navigator.vendor) && /Version\/([6-9]\d*|[1-5]\d+)/.test(navigator.userAgent);
  5131. function isLeftMouseReleased(event) {
  5132. if ('buttons' in event && isNotIEorIsIE10plus) {
  5133. return ! (event.buttons & 1)
  5134. }
  5135. if (isChrome15OrOpera15plus || isSafari6plus) {
  5136. return event.which === 0
  5137. }
  5138. }
  5139. exports.GrabToPan = GrabToPan
  5140. }), (function(module, exports, __webpack_require__) {
  5141. "use strict";
  5142. Object.defineProperty(exports, "__esModule", {
  5143. value: true
  5144. });
  5145. var _createClass = function() {
  5146. function defineProperties(target, props) {
  5147. for (var i = 0; i < props.length; i++) {
  5148. var descriptor = props[i];
  5149. descriptor.enumerable = descriptor.enumerable || false;
  5150. descriptor.configurable = true;
  5151. if ("value" in descriptor) descriptor.writable = true;
  5152. Object.defineProperty(target, descriptor.key, descriptor)
  5153. }
  5154. }
  5155. return function(Constructor, protoProps, staticProps) {
  5156. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  5157. if (staticProps) defineProperties(Constructor, staticProps);
  5158. return Constructor
  5159. }
  5160. } ();
  5161. function _classCallCheck(instance, Constructor) {
  5162. if (! (instance instanceof Constructor)) {
  5163. throw new TypeError("Cannot call a class as a function");
  5164. }
  5165. }
  5166. var OverlayManager = function() {
  5167. function OverlayManager() {
  5168. _classCallCheck(this, OverlayManager);
  5169. this._overlays = {};
  5170. this._active = null;
  5171. this._keyDownBound = this._keyDown.bind(this)
  5172. }
  5173. _createClass(OverlayManager, [{
  5174. key: 'register',
  5175. value: function register(name, element) {
  5176. var _this = this;
  5177. var callerCloseMethod = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  5178. var canForceClose = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  5179. return new Promise(function(resolve) {
  5180. var container = void 0;
  5181. if (!name || !element || !(container = element.parentNode)) {
  5182. throw new Error('Not enough parameters.');
  5183. } else if (_this._overlays[name]) {
  5184. throw new Error('The overlay is already registered.');
  5185. }
  5186. _this._overlays[name] = {
  5187. element: element,
  5188. container: container,
  5189. callerCloseMethod: callerCloseMethod,
  5190. canForceClose: canForceClose
  5191. };
  5192. resolve()
  5193. })
  5194. }
  5195. },
  5196. {
  5197. key: 'unregister',
  5198. value: function unregister(name) {
  5199. var _this2 = this;
  5200. return new Promise(function(resolve) {
  5201. if (!_this2._overlays[name]) {
  5202. throw new Error('The overlay does not exist.');
  5203. } else if (_this2._active === name) {
  5204. throw new Error('The overlay cannot be removed while it is active.');
  5205. }
  5206. delete _this2._overlays[name];
  5207. resolve()
  5208. })
  5209. }
  5210. },
  5211. {
  5212. key: 'open',
  5213. value: function open(name) {
  5214. var _this3 = this;
  5215. return new Promise(function(resolve) {
  5216. if (!_this3._overlays[name]) {
  5217. throw new Error('The overlay does not exist.');
  5218. } else if (_this3._active) {
  5219. if (_this3._overlays[name].canForceClose) {
  5220. _this3._closeThroughCaller()
  5221. } else if (_this3._active === name) {
  5222. throw new Error('The overlay is already active.');
  5223. } else {
  5224. throw new Error('Another overlay is currently active.');
  5225. }
  5226. }
  5227. _this3._active = name;
  5228. _this3._overlays[_this3._active].element.classList.remove('hidden');
  5229. _this3._overlays[_this3._active].container.classList.remove('hidden');
  5230. window.addEventListener('keydown', _this3._keyDownBound);
  5231. resolve()
  5232. })
  5233. }
  5234. },
  5235. {
  5236. key: 'close',
  5237. value: function close(name) {
  5238. var _this4 = this;
  5239. return new Promise(function(resolve) {
  5240. if (!_this4._overlays[name]) {
  5241. throw new Error('The overlay does not exist.');
  5242. } else if (!_this4._active) {
  5243. throw new Error('The overlay is currently not active.');
  5244. } else if (_this4._active !== name) {
  5245. throw new Error('Another overlay is currently active.');
  5246. }
  5247. _this4._overlays[_this4._active].container.classList.add('hidden');
  5248. _this4._overlays[_this4._active].element.classList.add('hidden');
  5249. _this4._active = null;
  5250. window.removeEventListener('keydown', _this4._keyDownBound);
  5251. resolve()
  5252. })
  5253. }
  5254. },
  5255. {
  5256. key: '_keyDown',
  5257. value: function _keyDown(evt) {
  5258. if (this._active && evt.keyCode === 27) {
  5259. this._closeThroughCaller();
  5260. evt.preventDefault()
  5261. }
  5262. }
  5263. },
  5264. {
  5265. key: '_closeThroughCaller',
  5266. value: function _closeThroughCaller() {
  5267. if (this._overlays[this._active].callerCloseMethod) {
  5268. this._overlays[this._active].callerCloseMethod()
  5269. }
  5270. if (this._active) {
  5271. this.close(this._active)
  5272. }
  5273. }
  5274. },
  5275. {
  5276. key: 'active',
  5277. get: function get() {
  5278. return this._active
  5279. }
  5280. }]);
  5281. return OverlayManager
  5282. } ();
  5283. exports.OverlayManager = OverlayManager
  5284. }), (function(module, exports, __webpack_require__) {
  5285. "use strict";
  5286. Object.defineProperty(exports, "__esModule", {
  5287. value: true
  5288. });
  5289. exports.PasswordPrompt = undefined;
  5290. var _createClass = function() {
  5291. function defineProperties(target, props) {
  5292. for (var i = 0; i < props.length; i++) {
  5293. var descriptor = props[i];
  5294. descriptor.enumerable = descriptor.enumerable || false;
  5295. descriptor.configurable = true;
  5296. if ("value" in descriptor) descriptor.writable = true;
  5297. Object.defineProperty(target, descriptor.key, descriptor)
  5298. }
  5299. }
  5300. return function(Constructor, protoProps, staticProps) {
  5301. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  5302. if (staticProps) defineProperties(Constructor, staticProps);
  5303. return Constructor
  5304. }
  5305. } ();
  5306. var _ui_utils = __webpack_require__(0);
  5307. var _pdfjsLib = __webpack_require__(1);
  5308. function _classCallCheck(instance, Constructor) {
  5309. if (! (instance instanceof Constructor)) {
  5310. throw new TypeError("Cannot call a class as a function");
  5311. }
  5312. }
  5313. var PasswordPrompt = function() {
  5314. function PasswordPrompt(options, overlayManager) {
  5315. var _this = this;
  5316. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  5317. _classCallCheck(this, PasswordPrompt);
  5318. this.overlayName = options.overlayName;
  5319. this.container = options.container;
  5320. this.label = options.label;
  5321. this.input = options.input;
  5322. this.submitButton = options.submitButton;
  5323. this.cancelButton = options.cancelButton;
  5324. this.overlayManager = overlayManager;
  5325. this.l10n = l10n;
  5326. this.updateCallback = null;
  5327. this.reason = null;
  5328. this.submitButton.addEventListener('click', this.verify.bind(this));
  5329. this.cancelButton.addEventListener('click', this.close.bind(this));
  5330. this.input.addEventListener('keydown',
  5331. function(e) {
  5332. if (e.keyCode === 13) {
  5333. _this.verify()
  5334. }
  5335. });
  5336. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this), true)
  5337. }
  5338. _createClass(PasswordPrompt, [{
  5339. key: 'open',
  5340. value: function open() {
  5341. var _this2 = this;
  5342. this.overlayManager.open(this.overlayName).then(function() {
  5343. _this2.input.focus();
  5344. var promptString = void 0;
  5345. if (_this2.reason === _pdfjsLib.PasswordResponses.INCORRECT_PASSWORD) {
  5346. promptString = _this2.l10n.get('password_invalid', null, 'Invalid password. Please try again.')
  5347. } else {
  5348. promptString = _this2.l10n.get('password_label', null, 'Enter the password to open this PDF file.')
  5349. }
  5350. promptString.then(function(msg) {
  5351. _this2.label.textContent = msg
  5352. })
  5353. })
  5354. }
  5355. },
  5356. {
  5357. key: 'close',
  5358. value: function close() {
  5359. var _this3 = this;
  5360. this.overlayManager.close(this.overlayName).then(function() {
  5361. _this3.input.value = ''
  5362. })
  5363. }
  5364. },
  5365. {
  5366. key: 'verify',
  5367. value: function verify() {
  5368. var password = this.input.value;
  5369. if (password && password.length > 0) {
  5370. this.close();
  5371. return this.updateCallback(password)
  5372. }
  5373. }
  5374. },
  5375. {
  5376. key: 'setUpdateCallback',
  5377. value: function setUpdateCallback(updateCallback, reason) {
  5378. this.updateCallback = updateCallback;
  5379. this.reason = reason
  5380. }
  5381. }]);
  5382. return PasswordPrompt
  5383. } ();
  5384. exports.PasswordPrompt = PasswordPrompt
  5385. }), (function(module, exports, __webpack_require__) {
  5386. "use strict";
  5387. Object.defineProperty(exports, "__esModule", {
  5388. value: true
  5389. });
  5390. exports.PDFAttachmentViewer = undefined;
  5391. var _createClass = function() {
  5392. function defineProperties(target, props) {
  5393. for (var i = 0; i < props.length; i++) {
  5394. var descriptor = props[i];
  5395. descriptor.enumerable = descriptor.enumerable || false;
  5396. descriptor.configurable = true;
  5397. if ("value" in descriptor) descriptor.writable = true;
  5398. Object.defineProperty(target, descriptor.key, descriptor)
  5399. }
  5400. }
  5401. return function(Constructor, protoProps, staticProps) {
  5402. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  5403. if (staticProps) defineProperties(Constructor, staticProps);
  5404. return Constructor
  5405. }
  5406. } ();
  5407. var _pdfjsLib = __webpack_require__(1);
  5408. function _classCallCheck(instance, Constructor) {
  5409. if (! (instance instanceof Constructor)) {
  5410. throw new TypeError("Cannot call a class as a function");
  5411. }
  5412. }
  5413. var PDFAttachmentViewer = function() {
  5414. function PDFAttachmentViewer(_ref) {
  5415. var container = _ref.container,
  5416. eventBus = _ref.eventBus,
  5417. downloadManager = _ref.downloadManager;
  5418. _classCallCheck(this, PDFAttachmentViewer);
  5419. this.attachments = null;
  5420. this.container = container;
  5421. this.eventBus = eventBus;
  5422. this.downloadManager = downloadManager;
  5423. this._renderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  5424. this.eventBus.on('fileattachmentannotation', this._appendAttachment.bind(this))
  5425. }
  5426. _createClass(PDFAttachmentViewer, [{
  5427. key: 'reset',
  5428. value: function reset() {
  5429. var keepRenderedCapability = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5430. this.attachments = null;
  5431. this.container.textContent = '';
  5432. if (!keepRenderedCapability) {
  5433. this._renderedCapability = (0, _pdfjsLib.createPromiseCapability)()
  5434. }
  5435. }
  5436. },
  5437. {
  5438. key: '_dispatchEvent',
  5439. value: function _dispatchEvent(attachmentsCount) {
  5440. this.eventBus.dispatch('attachmentsloaded', {
  5441. source: this,
  5442. attachmentsCount: attachmentsCount
  5443. });
  5444. this._renderedCapability.resolve()
  5445. }
  5446. },
  5447. {
  5448. key: '_bindPdfLink',
  5449. value: function _bindPdfLink(button, content, filename) {
  5450. if (_pdfjsLib.PDFJS.disableCreateObjectURL) {
  5451. throw new Error('bindPdfLink: ' + 'Unsupported "PDFJS.disableCreateObjectURL" value.');
  5452. }
  5453. var blobUrl = void 0;
  5454. button.onclick = function() {
  5455. if (!blobUrl) {
  5456. blobUrl = (0, _pdfjsLib.createObjectURL)(content, 'application/pdf')
  5457. }
  5458. var viewerUrl = void 0;
  5459. viewerUrl = '?file=' + encodeURIComponent(blobUrl + '#' + filename);
  5460. window.open(viewerUrl);
  5461. return false
  5462. }
  5463. }
  5464. },
  5465. {
  5466. key: '_bindLink',
  5467. value: function _bindLink(button, content, filename) {
  5468. var _this = this;
  5469. button.onclick = function() {
  5470. _this.downloadManager.downloadData(content, filename, '');
  5471. return false
  5472. }
  5473. }
  5474. },
  5475. {
  5476. key: 'render',
  5477. value: function render(_ref2) {
  5478. var attachments = _ref2.attachments,
  5479. _ref2$keepRenderedCap = _ref2.keepRenderedCapability,
  5480. keepRenderedCapability = _ref2$keepRenderedCap === undefined ? false: _ref2$keepRenderedCap;
  5481. var attachmentsCount = 0;
  5482. if (this.attachments) {
  5483. this.reset(keepRenderedCapability === true)
  5484. }
  5485. this.attachments = attachments || null;
  5486. if (!attachments) {
  5487. this._dispatchEvent(attachmentsCount);
  5488. return
  5489. }
  5490. var names = Object.keys(attachments).sort(function(a, b) {
  5491. return a.toLowerCase().localeCompare(b.toLowerCase())
  5492. });
  5493. attachmentsCount = names.length;
  5494. for (var i = 0; i < attachmentsCount; i++) {
  5495. var item = attachments[names[i]];
  5496. var filename = (0, _pdfjsLib.removeNullCharacters)((0, _pdfjsLib.getFilenameFromUrl)(item.filename));
  5497. var div = document.createElement('div');
  5498. div.className = 'attachmentsItem';
  5499. var button = document.createElement('button');
  5500. button.textContent = filename;
  5501. if (/\.pdf$/i.test(filename) && !_pdfjsLib.PDFJS.disableCreateObjectURL) {
  5502. this._bindPdfLink(button, item.content, filename)
  5503. } else {
  5504. this._bindLink(button, item.content, filename)
  5505. }
  5506. div.appendChild(button);
  5507. this.container.appendChild(div)
  5508. }
  5509. this._dispatchEvent(attachmentsCount)
  5510. }
  5511. },
  5512. {
  5513. key: '_appendAttachment',
  5514. value: function _appendAttachment(_ref3) {
  5515. var _this2 = this;
  5516. var id = _ref3.id,
  5517. filename = _ref3.filename,
  5518. content = _ref3.content;
  5519. this._renderedCapability.promise.then(function() {
  5520. var attachments = _this2.attachments;
  5521. if (!attachments) {
  5522. attachments = Object.create(null)
  5523. } else {
  5524. for (var name in attachments) {
  5525. if (id === name) {
  5526. return
  5527. }
  5528. }
  5529. }
  5530. attachments[id] = {
  5531. filename: filename,
  5532. content: content
  5533. };
  5534. _this2.render({
  5535. attachments: attachments,
  5536. keepRenderedCapability: true
  5537. })
  5538. })
  5539. }
  5540. }]);
  5541. return PDFAttachmentViewer
  5542. } ();
  5543. exports.PDFAttachmentViewer = PDFAttachmentViewer
  5544. }), (function(module, exports, __webpack_require__) {
  5545. "use strict";
  5546. Object.defineProperty(exports, "__esModule", {
  5547. value: true
  5548. });
  5549. exports.PDFDocumentProperties = undefined;
  5550. var _slicedToArray = function() {
  5551. function sliceIterator(arr, i) {
  5552. var _arr = [];
  5553. var _n = true;
  5554. var _d = false;
  5555. var _e = undefined;
  5556. try {
  5557. for (var _i = arr[Symbol.iterator](), _s; ! (_n = (_s = _i.next()).done); _n = true) {
  5558. _arr.push(_s.value);
  5559. if (i && _arr.length === i) break
  5560. }
  5561. } catch(err) {
  5562. _d = true;
  5563. _e = err
  5564. } finally {
  5565. try {
  5566. if (!_n && _i["return"]) _i["return"]()
  5567. } finally {
  5568. if (_d) throw _e;
  5569. }
  5570. }
  5571. return _arr
  5572. }
  5573. return function(arr, i) {
  5574. if (Array.isArray(arr)) {
  5575. return arr
  5576. } else if (Symbol.iterator in Object(arr)) {
  5577. return sliceIterator(arr, i)
  5578. } else {
  5579. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  5580. }
  5581. }
  5582. } ();
  5583. var _createClass = function() {
  5584. function defineProperties(target, props) {
  5585. for (var i = 0; i < props.length; i++) {
  5586. var descriptor = props[i];
  5587. descriptor.enumerable = descriptor.enumerable || false;
  5588. descriptor.configurable = true;
  5589. if ("value" in descriptor) descriptor.writable = true;
  5590. Object.defineProperty(target, descriptor.key, descriptor)
  5591. }
  5592. }
  5593. return function(Constructor, protoProps, staticProps) {
  5594. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  5595. if (staticProps) defineProperties(Constructor, staticProps);
  5596. return Constructor
  5597. }
  5598. } ();
  5599. var _ui_utils = __webpack_require__(0);
  5600. var _pdfjsLib = __webpack_require__(1);
  5601. function _classCallCheck(instance, Constructor) {
  5602. if (! (instance instanceof Constructor)) {
  5603. throw new TypeError("Cannot call a class as a function");
  5604. }
  5605. }
  5606. var DEFAULT_FIELD_CONTENT = '-';
  5607. var PDFDocumentProperties = function() {
  5608. function PDFDocumentProperties(_ref, overlayManager) {
  5609. var overlayName = _ref.overlayName,
  5610. fields = _ref.fields,
  5611. container = _ref.container,
  5612. closeButton = _ref.closeButton;
  5613. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  5614. _classCallCheck(this, PDFDocumentProperties);
  5615. this.overlayName = overlayName;
  5616. this.fields = fields;
  5617. this.container = container;
  5618. this.overlayManager = overlayManager;
  5619. this.l10n = l10n;
  5620. this._reset();
  5621. if (closeButton) {
  5622. closeButton.addEventListener('click', this.close.bind(this))
  5623. }
  5624. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this))
  5625. }
  5626. _createClass(PDFDocumentProperties, [{
  5627. key: 'open',
  5628. value: function open() {
  5629. var _this = this;
  5630. var freezeFieldData = function freezeFieldData(data) {
  5631. Object.defineProperty(_this, 'fieldData', {
  5632. value: Object.freeze(data),
  5633. writable: false,
  5634. enumerable: true,
  5635. configurable: true
  5636. })
  5637. };
  5638. Promise.all([this.overlayManager.open(this.overlayName), this._dataAvailableCapability.promise]).then(function() {
  5639. if (_this.fieldData) {
  5640. _this._updateUI();
  5641. return
  5642. }
  5643. _this.pdfDocument.getMetadata().then(function(_ref2) {
  5644. var info = _ref2.info,
  5645. metadata = _ref2.metadata;
  5646. return Promise.all([info, metadata, _this._parseFileSize(_this.maybeFileSize), _this._parseDate(info.CreationDate), _this._parseDate(info.ModDate)])
  5647. }).then(function(_ref3) {
  5648. var _ref4 = _slicedToArray(_ref3, 5),
  5649. info = _ref4[0],
  5650. metadata = _ref4[1],
  5651. fileSize = _ref4[2],
  5652. creationDate = _ref4[3],
  5653. modificationDate = _ref4[4];
  5654. freezeFieldData({
  5655. 'fileName': (0, _ui_utils.getPDFFileNameFromURL)(_this.url),
  5656. 'fileSize': fileSize,
  5657. 'title': info.Title,
  5658. 'author': info.Author,
  5659. 'subject': info.Subject,
  5660. 'keywords': info.Keywords,
  5661. 'creationDate': creationDate,
  5662. 'modificationDate': modificationDate,
  5663. 'creator': info.Creator,
  5664. 'producer': info.Producer,
  5665. 'version': info.PDFFormatVersion,
  5666. 'pageCount': _this.pdfDocument.numPages
  5667. });
  5668. _this._updateUI();
  5669. return _this.pdfDocument.getDownloadInfo()
  5670. }).then(function(_ref5) {
  5671. var length = _ref5.length;
  5672. return _this._parseFileSize(length)
  5673. }).then(function(fileSize) {
  5674. var data = (0, _ui_utils.cloneObj)(_this.fieldData);
  5675. data['fileSize'] = fileSize;
  5676. freezeFieldData(data);
  5677. _this._updateUI()
  5678. })
  5679. })
  5680. }
  5681. },
  5682. {
  5683. key: 'close',
  5684. value: function close() {
  5685. this.overlayManager.close(this.overlayName)
  5686. }
  5687. },
  5688. {
  5689. key: 'setDocument',
  5690. value: function setDocument(pdfDocument, url) {
  5691. if (this.pdfDocument) {
  5692. this._reset();
  5693. this._updateUI(true)
  5694. }
  5695. if (!pdfDocument) {
  5696. return
  5697. }
  5698. this.pdfDocument = pdfDocument;
  5699. this.url = url;
  5700. this._dataAvailableCapability.resolve()
  5701. }
  5702. },
  5703. {
  5704. key: 'setFileSize',
  5705. value: function setFileSize(fileSize) {
  5706. if (typeof fileSize === 'number' && fileSize > 0) {
  5707. this.maybeFileSize = fileSize
  5708. }
  5709. }
  5710. },
  5711. {
  5712. key: '_reset',
  5713. value: function _reset() {
  5714. this.pdfDocument = null;
  5715. this.url = null;
  5716. this.maybeFileSize = 0;
  5717. delete this.fieldData;
  5718. this._dataAvailableCapability = (0, _pdfjsLib.createPromiseCapability)()
  5719. }
  5720. },
  5721. {
  5722. key: '_updateUI',
  5723. value: function _updateUI() {
  5724. var reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5725. if (reset || !this.fieldData) {
  5726. for (var id in this.fields) {
  5727. this.fields[id].textContent = DEFAULT_FIELD_CONTENT
  5728. }
  5729. return
  5730. }
  5731. if (this.overlayManager.active !== this.overlayName) {
  5732. return
  5733. }
  5734. for (var _id in this.fields) {
  5735. var content = this.fieldData[_id];
  5736. this.fields[_id].textContent = content || content === 0 ? content: DEFAULT_FIELD_CONTENT
  5737. }
  5738. }
  5739. },
  5740. {
  5741. key: '_parseFileSize',
  5742. value: function _parseFileSize() {
  5743. var fileSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  5744. var kb = fileSize / 1024;
  5745. if (!kb) {
  5746. return Promise.resolve(undefined)
  5747. } else if (kb < 1024) {
  5748. return this.l10n.get('document_properties_kb', {
  5749. size_kb: ( + kb.toPrecision(3)).toLocaleString(),
  5750. size_b: fileSize.toLocaleString()
  5751. },
  5752. '{{size_kb}} KB ({{size_b}} bytes)')
  5753. }
  5754. return this.l10n.get('document_properties_mb', {
  5755. size_mb: ( + (kb / 1024).toPrecision(3)).toLocaleString(),
  5756. size_b: fileSize.toLocaleString()
  5757. },
  5758. '{{size_mb}} MB ({{size_b}} bytes)')
  5759. }
  5760. },
  5761. {
  5762. key: '_parseDate',
  5763. value: function _parseDate(inputDate) {
  5764. if (!inputDate) {
  5765. return
  5766. }
  5767. var dateToParse = inputDate;
  5768. if (dateToParse.substring(0, 2) === 'D:') {
  5769. dateToParse = dateToParse.substring(2)
  5770. }
  5771. var year = parseInt(dateToParse.substring(0, 4), 10);
  5772. var month = parseInt(dateToParse.substring(4, 6), 10) - 1;
  5773. var day = parseInt(dateToParse.substring(6, 8), 10);
  5774. var hours = parseInt(dateToParse.substring(8, 10), 10);
  5775. var minutes = parseInt(dateToParse.substring(10, 12), 10);
  5776. var seconds = parseInt(dateToParse.substring(12, 14), 10);
  5777. var utRel = dateToParse.substring(14, 15);
  5778. var offsetHours = parseInt(dateToParse.substring(15, 17), 10);
  5779. var offsetMinutes = parseInt(dateToParse.substring(18, 20), 10);
  5780. if (utRel === '-') {
  5781. hours += offsetHours;
  5782. minutes += offsetMinutes
  5783. } else if (utRel === '+') {
  5784. hours -= offsetHours;
  5785. minutes -= offsetMinutes
  5786. }
  5787. var date = new Date(Date.UTC(year, month, day, hours, minutes, seconds));
  5788. var dateString = date.toLocaleDateString();
  5789. var timeString = date.toLocaleTimeString();
  5790. return this.l10n.get('document_properties_date_string', {
  5791. date: dateString,
  5792. time: timeString
  5793. },
  5794. '{{date}}, {{time}}')
  5795. }
  5796. }]);
  5797. return PDFDocumentProperties
  5798. } ();
  5799. exports.PDFDocumentProperties = PDFDocumentProperties
  5800. }), (function(module, exports, __webpack_require__) {
  5801. "use strict";
  5802. Object.defineProperty(exports, "__esModule", {
  5803. value: true
  5804. });
  5805. exports.PDFFindBar = undefined;
  5806. var _createClass = function() {
  5807. function defineProperties(target, props) {
  5808. for (var i = 0; i < props.length; i++) {
  5809. var descriptor = props[i];
  5810. descriptor.enumerable = descriptor.enumerable || false;
  5811. descriptor.configurable = true;
  5812. if ("value" in descriptor) descriptor.writable = true;
  5813. Object.defineProperty(target, descriptor.key, descriptor)
  5814. }
  5815. }
  5816. return function(Constructor, protoProps, staticProps) {
  5817. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  5818. if (staticProps) defineProperties(Constructor, staticProps);
  5819. return Constructor
  5820. }
  5821. } ();
  5822. var _pdf_find_controller = __webpack_require__(7);
  5823. var _ui_utils = __webpack_require__(0);
  5824. function _classCallCheck(instance, Constructor) {
  5825. if (! (instance instanceof Constructor)) {
  5826. throw new TypeError("Cannot call a class as a function");
  5827. }
  5828. }
  5829. var PDFFindBar = function() {
  5830. function PDFFindBar(options) {
  5831. var _this = this;
  5832. var l10n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _ui_utils.NullL10n;
  5833. _classCallCheck(this, PDFFindBar);
  5834. this.opened = false;
  5835. this.bar = options.bar || null;
  5836. this.toggleButton = options.toggleButton || null;
  5837. this.findField = options.findField || null;
  5838. this.highlightAll = options.highlightAllCheckbox || null;
  5839. this.caseSensitive = options.caseSensitiveCheckbox || null;
  5840. this.findMsg = options.findMsg || null;
  5841. this.findResultsCount = options.findResultsCount || null;
  5842. this.findStatusIcon = options.findStatusIcon || null;
  5843. this.findPreviousButton = options.findPreviousButton || null;
  5844. this.findNextButton = options.findNextButton || null;
  5845. this.findController = options.findController || null;
  5846. this.eventBus = options.eventBus;
  5847. this.l10n = l10n;
  5848. if (this.findController === null) {
  5849. throw new Error('PDFFindBar cannot be used without a ' + 'PDFFindController instance.');
  5850. }
  5851. this.toggleButton.addEventListener('click',
  5852. function() {
  5853. _this.toggle()
  5854. });
  5855. this.findField.addEventListener('input',
  5856. function() {
  5857. _this.dispatchEvent('')
  5858. });
  5859. this.bar.addEventListener('keydown',
  5860. function(e) {
  5861. switch (e.keyCode) {
  5862. case 13:
  5863. if (e.target === _this.findField) {
  5864. _this.dispatchEvent('again', e.shiftKey)
  5865. }
  5866. break;
  5867. case 27:
  5868. _this.close();
  5869. break
  5870. }
  5871. });
  5872. this.findPreviousButton.addEventListener('click',
  5873. function() {
  5874. _this.dispatchEvent('again', true)
  5875. });
  5876. this.findNextButton.addEventListener('click',
  5877. function() {
  5878. _this.dispatchEvent('again', false)
  5879. });
  5880. this.highlightAll.addEventListener('click',
  5881. function() {
  5882. _this.dispatchEvent('highlightallchange')
  5883. });
  5884. this.caseSensitive.addEventListener('click',
  5885. function() {
  5886. _this.dispatchEvent('casesensitivitychange')
  5887. });
  5888. this.eventBus.on('resize', this._adjustWidth.bind(this))
  5889. }
  5890. _createClass(PDFFindBar, [{
  5891. key: 'reset',
  5892. value: function reset() {
  5893. this.updateUIState()
  5894. }
  5895. },
  5896. {
  5897. key: 'dispatchEvent',
  5898. value: function dispatchEvent(type, findPrev) {
  5899. this.eventBus.dispatch('find', {
  5900. source: this,
  5901. type: type,
  5902. query: this.findField.value,
  5903. caseSensitive: this.caseSensitive.checked,
  5904. phraseSearch: true,
  5905. highlightAll: this.highlightAll.checked,
  5906. findPrevious: findPrev
  5907. })
  5908. }
  5909. },
  5910. {
  5911. key: 'updateUIState',
  5912. value: function updateUIState(state, previous, matchCount) {
  5913. var _this2 = this;
  5914. var notFound = false;
  5915. var findMsg = '';
  5916. var status = '';
  5917. switch (state) {
  5918. case _pdf_find_controller.FindState.FOUND:
  5919. break;
  5920. case _pdf_find_controller.FindState.PENDING:
  5921. status = 'pending';
  5922. break;
  5923. case _pdf_find_controller.FindState.NOT_FOUND:
  5924. findMsg = this.l10n.get('find_not_found', null, 'Phrase not found');
  5925. notFound = true;
  5926. break;
  5927. case _pdf_find_controller.FindState.WRAPPED:
  5928. if (previous) {
  5929. findMsg = this.l10n.get('find_reached_top', null, 'Reached top of document, continued from bottom')
  5930. } else {
  5931. findMsg = this.l10n.get('find_reached_bottom', null, 'Reached end of document, continued from top')
  5932. }
  5933. break
  5934. }
  5935. if (notFound) {
  5936. this.findField.classList.add('notFound')
  5937. } else {
  5938. this.findField.classList.remove('notFound')
  5939. }
  5940. this.findField.setAttribute('data-status', status);
  5941. Promise.resolve(findMsg).then(function(msg) {
  5942. _this2.findMsg.textContent = msg;
  5943. _this2._adjustWidth()
  5944. });
  5945. this.updateResultsCount(matchCount)
  5946. }
  5947. },
  5948. {
  5949. key: 'updateResultsCount',
  5950. value: function updateResultsCount(matchCount) {
  5951. if (!this.findResultsCount) {
  5952. return
  5953. }
  5954. if (!matchCount) {
  5955. this.findResultsCount.classList.add('hidden');
  5956. this.findResultsCount.textContent = ''
  5957. } else {
  5958. this.findResultsCount.textContent = matchCount.toLocaleString();
  5959. this.findResultsCount.classList.remove('hidden')
  5960. }
  5961. this._adjustWidth()
  5962. }
  5963. },
  5964. {
  5965. key: 'open',
  5966. value: function open() {
  5967. if (!this.opened) {
  5968. this.opened = true;
  5969. this.toggleButton.classList.add('toggled');
  5970. this.bar.classList.remove('hidden')
  5971. }
  5972. this.findField.select();
  5973. this.findField.focus();
  5974. this._adjustWidth()
  5975. }
  5976. },
  5977. {
  5978. key: 'close',
  5979. value: function close() {
  5980. if (!this.opened) {
  5981. return
  5982. }
  5983. this.opened = false;
  5984. this.toggleButton.classList.remove('toggled');
  5985. this.bar.classList.add('hidden');
  5986. this.findController.active = false
  5987. }
  5988. },
  5989. {
  5990. key: 'toggle',
  5991. value: function toggle() {
  5992. if (this.opened) {
  5993. this.close()
  5994. } else {
  5995. this.open()
  5996. }
  5997. }
  5998. },
  5999. {
  6000. key: '_adjustWidth',
  6001. value: function _adjustWidth() {
  6002. if (!this.opened) {
  6003. return
  6004. }
  6005. this.bar.classList.remove('wrapContainers');
  6006. var findbarHeight = this.bar.clientHeight;
  6007. var inputContainerHeight = this.bar.firstElementChild.clientHeight;
  6008. if (findbarHeight > inputContainerHeight) {
  6009. this.bar.classList.add('wrapContainers')
  6010. }
  6011. }
  6012. }]);
  6013. return PDFFindBar
  6014. } ();
  6015. exports.PDFFindBar = PDFFindBar
  6016. }), (function(module, exports, __webpack_require__) {
  6017. "use strict";
  6018. Object.defineProperty(exports, "__esModule", {
  6019. value: true
  6020. });
  6021. exports.PDFHistory = undefined;
  6022. var _dom_events = __webpack_require__(2);
  6023. function PDFHistory(options) {
  6024. this.linkService = options.linkService;
  6025. this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)();
  6026. this.initialized = false;
  6027. this.initialDestination = null;
  6028. this.initialBookmark = null
  6029. }
  6030. PDFHistory.prototype = {
  6031. initialize: function pdfHistoryInitialize(fingerprint) {
  6032. this.initialized = true;
  6033. this.reInitialized = false;
  6034. this.allowHashChange = true;
  6035. this.historyUnlocked = true;
  6036. this.isViewerInPresentationMode = false;
  6037. this.previousHash = window.location.hash.substring(1);
  6038. this.currentBookmark = '';
  6039. this.currentPage = 0;
  6040. this.updatePreviousBookmark = false;
  6041. this.previousBookmark = '';
  6042. this.previousPage = 0;
  6043. this.nextHashParam = '';
  6044. this.fingerprint = fingerprint;
  6045. this.currentUid = this.uid = 0;
  6046. this.current = {};
  6047. var state = window.history.state;
  6048. if (this._isStateObjectDefined(state)) {
  6049. if (state.target.dest) {
  6050. this.initialDestination = state.target.dest
  6051. } else {
  6052. this.initialBookmark = state.target.hash
  6053. }
  6054. this.currentUid = state.uid;
  6055. this.uid = state.uid + 1;
  6056. this.current = state.target
  6057. } else {
  6058. if (state && state.fingerprint && this.fingerprint !== state.fingerprint) {
  6059. this.reInitialized = true
  6060. }
  6061. this._pushOrReplaceState({
  6062. fingerprint: this.fingerprint
  6063. },
  6064. true)
  6065. }
  6066. var self = this;
  6067. window.addEventListener('popstate',
  6068. function pdfHistoryPopstate(evt) {
  6069. if (!self.historyUnlocked) {
  6070. return
  6071. }
  6072. if (evt.state) {
  6073. self._goTo(evt.state);
  6074. return
  6075. }
  6076. if (self.uid === 0) {
  6077. var previousParams = self.previousHash && self.currentBookmark && self.previousHash !== self.currentBookmark ? {
  6078. hash: self.currentBookmark,
  6079. page: self.currentPage
  6080. }: {
  6081. page: 1
  6082. };
  6083. replacePreviousHistoryState(previousParams,
  6084. function() {
  6085. updateHistoryWithCurrentHash()
  6086. })
  6087. } else {
  6088. updateHistoryWithCurrentHash()
  6089. }
  6090. });
  6091. function updateHistoryWithCurrentHash() {
  6092. self.previousHash = window.location.hash.slice(1);
  6093. self._pushToHistory({
  6094. hash: self.previousHash
  6095. },
  6096. false, true);
  6097. self._updatePreviousBookmark()
  6098. }
  6099. function replacePreviousHistoryState(params, callback) {
  6100. self.historyUnlocked = false;
  6101. self.allowHashChange = false;
  6102. window.addEventListener('popstate', rewriteHistoryAfterBack);
  6103. history.back();
  6104. function rewriteHistoryAfterBack() {
  6105. window.removeEventListener('popstate', rewriteHistoryAfterBack);
  6106. window.addEventListener('popstate', rewriteHistoryAfterForward);
  6107. self._pushToHistory(params, false, true);
  6108. history.forward()
  6109. }
  6110. function rewriteHistoryAfterForward() {
  6111. window.removeEventListener('popstate', rewriteHistoryAfterForward);
  6112. self.allowHashChange = true;
  6113. self.historyUnlocked = true;
  6114. callback()
  6115. }
  6116. }
  6117. function pdfHistoryBeforeUnload() {
  6118. var previousParams = self._getPreviousParams(null, true);
  6119. if (previousParams) {
  6120. var replacePrevious = !self.current.dest && self.current.hash !== self.previousHash;
  6121. self._pushToHistory(previousParams, false, replacePrevious);
  6122. self._updatePreviousBookmark()
  6123. }
  6124. window.removeEventListener('beforeunload', pdfHistoryBeforeUnload)
  6125. }
  6126. window.addEventListener('beforeunload', pdfHistoryBeforeUnload);
  6127. window.addEventListener('pageshow',
  6128. function pdfHistoryPageShow(evt) {
  6129. window.addEventListener('beforeunload', pdfHistoryBeforeUnload)
  6130. });
  6131. self.eventBus.on('presentationmodechanged',
  6132. function(e) {
  6133. self.isViewerInPresentationMode = e.active
  6134. })
  6135. },
  6136. clearHistoryState: function pdfHistory_clearHistoryState() {
  6137. this._pushOrReplaceState(null, true)
  6138. },
  6139. _isStateObjectDefined: function pdfHistory_isStateObjectDefined(state) {
  6140. return state && state.uid >= 0 && state.fingerprint && this.fingerprint === state.fingerprint && state.target && state.target.hash ? true: false
  6141. },
  6142. _pushOrReplaceState: function pdfHistory_pushOrReplaceState(stateObj, replace) {
  6143. if (replace) {
  6144. window.history.replaceState(stateObj, '', document.URL)
  6145. } else {
  6146. window.history.pushState(stateObj, '', document.URL)
  6147. }
  6148. },
  6149. get isHashChangeUnlocked() {
  6150. if (!this.initialized) {
  6151. return true
  6152. }
  6153. return this.allowHashChange
  6154. },
  6155. _updatePreviousBookmark: function pdfHistory_updatePreviousBookmark() {
  6156. if (this.updatePreviousBookmark && this.currentBookmark && this.currentPage) {
  6157. this.previousBookmark = this.currentBookmark;
  6158. this.previousPage = this.currentPage;
  6159. this.updatePreviousBookmark = false
  6160. }
  6161. },
  6162. updateCurrentBookmark: function pdfHistoryUpdateCurrentBookmark(bookmark, pageNum) {
  6163. if (this.initialized) {
  6164. this.currentBookmark = bookmark.substring(1);
  6165. this.currentPage = pageNum | 0;
  6166. this._updatePreviousBookmark()
  6167. }
  6168. },
  6169. updateNextHashParam: function pdfHistoryUpdateNextHashParam(param) {
  6170. if (this.initialized) {
  6171. this.nextHashParam = param
  6172. }
  6173. },
  6174. push: function pdfHistoryPush(params, isInitialBookmark) {
  6175. if (! (this.initialized && this.historyUnlocked)) {
  6176. return
  6177. }
  6178. if (params.dest && !params.hash) {
  6179. params.hash = this.current.hash && this.current.dest && this.current.dest === params.dest ? this.current.hash: this.linkService.getDestinationHash(params.dest).split('#')[1]
  6180. }
  6181. if (params.page) {
  6182. params.page |= 0
  6183. }
  6184. if (isInitialBookmark) {
  6185. var target = window.history.state.target;
  6186. if (!target) {
  6187. this._pushToHistory(params, false);
  6188. this.previousHash = window.location.hash.substring(1)
  6189. }
  6190. this.updatePreviousBookmark = this.nextHashParam ? false: true;
  6191. if (target) {
  6192. this._updatePreviousBookmark()
  6193. }
  6194. return
  6195. }
  6196. if (this.nextHashParam) {
  6197. if (this.nextHashParam === params.hash) {
  6198. this.nextHashParam = null;
  6199. this.updatePreviousBookmark = true;
  6200. return
  6201. }
  6202. this.nextHashParam = null
  6203. }
  6204. if (params.hash) {
  6205. if (this.current.hash) {
  6206. if (this.current.hash !== params.hash) {
  6207. this._pushToHistory(params, true)
  6208. } else {
  6209. if (!this.current.page && params.page) {
  6210. this._pushToHistory(params, false, true)
  6211. }
  6212. this.updatePreviousBookmark = true
  6213. }
  6214. } else {
  6215. this._pushToHistory(params, true)
  6216. }
  6217. } else if (this.current.page && params.page && this.current.page !== params.page) {
  6218. this._pushToHistory(params, true)
  6219. }
  6220. },
  6221. _getPreviousParams: function pdfHistory_getPreviousParams(onlyCheckPage, beforeUnload) {
  6222. if (! (this.currentBookmark && this.currentPage)) {
  6223. return null
  6224. } else if (this.updatePreviousBookmark) {
  6225. this.updatePreviousBookmark = false
  6226. }
  6227. if (this.uid > 0 && !(this.previousBookmark && this.previousPage)) {
  6228. return null
  6229. }
  6230. if (!this.current.dest && !onlyCheckPage || beforeUnload) {
  6231. if (this.previousBookmark === this.currentBookmark) {
  6232. return null
  6233. }
  6234. } else if (this.current.page || onlyCheckPage) {
  6235. if (this.previousPage === this.currentPage) {
  6236. return null
  6237. }
  6238. } else {
  6239. return null
  6240. }
  6241. var params = {
  6242. hash: this.currentBookmark,
  6243. page: this.currentPage
  6244. };
  6245. if (this.isViewerInPresentationMode) {
  6246. params.hash = null
  6247. }
  6248. return params
  6249. },
  6250. _stateObj: function pdfHistory_stateObj(params) {
  6251. return {
  6252. fingerprint: this.fingerprint,
  6253. uid: this.uid,
  6254. target: params
  6255. }
  6256. },
  6257. _pushToHistory: function pdfHistory_pushToHistory(params, addPrevious, overwrite) {
  6258. if (!this.initialized) {
  6259. return
  6260. }
  6261. if (!params.hash && params.page) {
  6262. params.hash = 'page=' + params.page
  6263. }
  6264. if (addPrevious && !overwrite) {
  6265. var previousParams = this._getPreviousParams();
  6266. if (previousParams) {
  6267. var replacePrevious = !this.current.dest && this.current.hash !== this.previousHash;
  6268. this._pushToHistory(previousParams, false, replacePrevious)
  6269. }
  6270. }
  6271. this._pushOrReplaceState(this._stateObj(params), overwrite || this.uid === 0);
  6272. this.currentUid = this.uid++;
  6273. this.current = params;
  6274. this.updatePreviousBookmark = true
  6275. },
  6276. _goTo: function pdfHistory_goTo(state) {
  6277. if (! (this.initialized && this.historyUnlocked && this._isStateObjectDefined(state))) {
  6278. return
  6279. }
  6280. if (!this.reInitialized && state.uid < this.currentUid) {
  6281. var previousParams = this._getPreviousParams(true);
  6282. if (previousParams) {
  6283. this._pushToHistory(this.current, false);
  6284. this._pushToHistory(previousParams, false);
  6285. this.currentUid = state.uid;
  6286. window.history.back();
  6287. return
  6288. }
  6289. }
  6290. this.historyUnlocked = false;
  6291. if (state.target.dest) {
  6292. this.linkService.navigateTo(state.target.dest)
  6293. } else {
  6294. this.linkService.setHash(state.target.hash)
  6295. }
  6296. this.currentUid = state.uid;
  6297. if (state.uid > this.uid) {
  6298. this.uid = state.uid
  6299. }
  6300. this.current = state.target;
  6301. this.updatePreviousBookmark = true;
  6302. var currentHash = window.location.hash.substring(1);
  6303. if (this.previousHash !== currentHash) {
  6304. this.allowHashChange = false
  6305. }
  6306. this.previousHash = currentHash;
  6307. this.historyUnlocked = true
  6308. },
  6309. back: function pdfHistoryBack() {
  6310. this.go( - 1)
  6311. },
  6312. forward: function pdfHistoryForward() {
  6313. this.go(1)
  6314. },
  6315. go: function pdfHistoryGo(direction) {
  6316. if (this.initialized && this.historyUnlocked) {
  6317. var state = window.history.state;
  6318. if (direction === -1 && state && state.uid > 0) {
  6319. window.history.back()
  6320. } else if (direction === 1 && state && state.uid < this.uid - 1) {
  6321. window.history.forward()
  6322. }
  6323. }
  6324. }
  6325. };
  6326. exports.PDFHistory = PDFHistory
  6327. }), (function(module, exports, __webpack_require__) {
  6328. "use strict";
  6329. Object.defineProperty(exports, "__esModule", {
  6330. value: true
  6331. });
  6332. exports.PDFOutlineViewer = undefined;
  6333. var _createClass = function() {
  6334. function defineProperties(target, props) {
  6335. for (var i = 0; i < props.length; i++) {
  6336. var descriptor = props[i];
  6337. descriptor.enumerable = descriptor.enumerable || false;
  6338. descriptor.configurable = true;
  6339. if ("value" in descriptor) descriptor.writable = true;
  6340. Object.defineProperty(target, descriptor.key, descriptor)
  6341. }
  6342. }
  6343. return function(Constructor, protoProps, staticProps) {
  6344. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  6345. if (staticProps) defineProperties(Constructor, staticProps);
  6346. return Constructor
  6347. }
  6348. } ();
  6349. var _pdfjsLib = __webpack_require__(1);
  6350. function _classCallCheck(instance, Constructor) {
  6351. if (! (instance instanceof Constructor)) {
  6352. throw new TypeError("Cannot call a class as a function");
  6353. }
  6354. }
  6355. var DEFAULT_TITLE = '\u2013';
  6356. var PDFOutlineViewer = function() {
  6357. function PDFOutlineViewer(_ref) {
  6358. var container = _ref.container,
  6359. linkService = _ref.linkService,
  6360. eventBus = _ref.eventBus;
  6361. _classCallCheck(this, PDFOutlineViewer);
  6362. this.outline = null;
  6363. this.lastToggleIsShow = true;
  6364. this.container = container;
  6365. this.linkService = linkService;
  6366. this.eventBus = eventBus
  6367. }
  6368. _createClass(PDFOutlineViewer, [{
  6369. key: 'reset',
  6370. value: function reset() {
  6371. this.outline = null;
  6372. this.lastToggleIsShow = true;
  6373. this.container.textContent = '';
  6374. this.container.classList.remove('outlineWithDeepNesting')
  6375. }
  6376. },
  6377. {
  6378. key: '_dispatchEvent',
  6379. value: function _dispatchEvent(outlineCount) {
  6380. this.eventBus.dispatch('outlineloaded', {
  6381. source: this,
  6382. outlineCount: outlineCount
  6383. })
  6384. }
  6385. },
  6386. {
  6387. key: '_bindLink',
  6388. value: function _bindLink(element, item) {
  6389. var _this = this;
  6390. if (item.url) { (0, _pdfjsLib.addLinkAttributes)(element, {
  6391. url: item.url,
  6392. target: item.newWindow ? _pdfjsLib.PDFJS.LinkTarget.BLANK: undefined
  6393. });
  6394. return
  6395. }
  6396. var destination = item.dest;
  6397. element.href = this.linkService.getDestinationHash(destination);
  6398. element.onclick = function() {
  6399. if (destination) {
  6400. _this.linkService.navigateTo(destination)
  6401. }
  6402. return false
  6403. }
  6404. }
  6405. },
  6406. {
  6407. key: '_setStyles',
  6408. value: function _setStyles(element, item) {
  6409. var styleStr = '';
  6410. if (item.bold) {
  6411. styleStr += 'font-weight: bold;'
  6412. }
  6413. if (item.italic) {
  6414. styleStr += 'font-style: italic;'
  6415. }
  6416. if (styleStr) {
  6417. element.setAttribute('style', styleStr)
  6418. }
  6419. }
  6420. },
  6421. {
  6422. key: '_addToggleButton',
  6423. value: function _addToggleButton(div) {
  6424. var _this2 = this;
  6425. var toggler = document.createElement('div');
  6426. toggler.className = 'outlineItemToggler';
  6427. toggler.onclick = function(evt) {
  6428. evt.stopPropagation();
  6429. toggler.classList.toggle('outlineItemsHidden');
  6430. if (evt.shiftKey) {
  6431. var shouldShowAll = !toggler.classList.contains('outlineItemsHidden');
  6432. _this2._toggleOutlineItem(div, shouldShowAll)
  6433. }
  6434. };
  6435. div.insertBefore(toggler, div.firstChild)
  6436. }
  6437. },
  6438. {
  6439. key: '_toggleOutlineItem',
  6440. value: function _toggleOutlineItem(root, show) {
  6441. this.lastToggleIsShow = show;
  6442. var togglers = root.querySelectorAll('.outlineItemToggler');
  6443. for (var i = 0,
  6444. ii = togglers.length; i < ii; ++i) {
  6445. togglers[i].classList[show ? 'remove': 'add']('outlineItemsHidden')
  6446. }
  6447. }
  6448. },
  6449. {
  6450. key: 'toggleOutlineTree',
  6451. value: function toggleOutlineTree() {
  6452. if (!this.outline) {
  6453. return
  6454. }
  6455. this._toggleOutlineItem(this.container, !this.lastToggleIsShow)
  6456. }
  6457. },
  6458. {
  6459. key: 'render',
  6460. value: function render(_ref2) {
  6461. var outline = _ref2.outline;
  6462. var outlineCount = 0;
  6463. if (this.outline) {
  6464. this.reset()
  6465. }
  6466. this.outline = outline || null;
  6467. if (!outline) {
  6468. this._dispatchEvent(outlineCount);
  6469. return
  6470. }
  6471. var fragment = document.createDocumentFragment();
  6472. var queue = [{
  6473. parent: fragment,
  6474. items: this.outline
  6475. }];
  6476. var hasAnyNesting = false;
  6477. while (queue.length > 0) {
  6478. var levelData = queue.shift();
  6479. for (var i = 0,
  6480. len = levelData.items.length; i < len; i++) {
  6481. var item = levelData.items[i];
  6482. var div = document.createElement('div');
  6483. div.className = 'outlineItem';
  6484. var element = document.createElement('a');
  6485. this._bindLink(element, item);
  6486. this._setStyles(element, item);
  6487. element.textContent = (0, _pdfjsLib.removeNullCharacters)(item.title) || DEFAULT_TITLE;
  6488. div.appendChild(element);
  6489. if (item.items.length > 0) {
  6490. hasAnyNesting = true;
  6491. this._addToggleButton(div);
  6492. var itemsDiv = document.createElement('div');
  6493. itemsDiv.className = 'outlineItems';
  6494. div.appendChild(itemsDiv);
  6495. queue.push({
  6496. parent: itemsDiv,
  6497. items: item.items
  6498. })
  6499. }
  6500. levelData.parent.appendChild(div);
  6501. outlineCount++
  6502. }
  6503. }
  6504. if (hasAnyNesting) {
  6505. this.container.classList.add('outlineWithDeepNesting')
  6506. }
  6507. this.container.appendChild(fragment);
  6508. this._dispatchEvent(outlineCount)
  6509. }
  6510. }]);
  6511. return PDFOutlineViewer
  6512. } ();
  6513. exports.PDFOutlineViewer = PDFOutlineViewer
  6514. }), (function(module, exports, __webpack_require__) {
  6515. "use strict";
  6516. Object.defineProperty(exports, "__esModule", {
  6517. value: true
  6518. });
  6519. exports.PDFPageView = undefined;
  6520. var _createClass = function() {
  6521. function defineProperties(target, props) {
  6522. for (var i = 0; i < props.length; i++) {
  6523. var descriptor = props[i];
  6524. descriptor.enumerable = descriptor.enumerable || false;
  6525. descriptor.configurable = true;
  6526. if ("value" in descriptor) descriptor.writable = true;
  6527. Object.defineProperty(target, descriptor.key, descriptor)
  6528. }
  6529. }
  6530. return function(Constructor, protoProps, staticProps) {
  6531. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  6532. if (staticProps) defineProperties(Constructor, staticProps);
  6533. return Constructor
  6534. }
  6535. } ();
  6536. var _ui_utils = __webpack_require__(0);
  6537. var _pdfjsLib = __webpack_require__(1);
  6538. var _dom_events = __webpack_require__(2);
  6539. var _pdf_rendering_queue = __webpack_require__(3);
  6540. function _classCallCheck(instance, Constructor) {
  6541. if (! (instance instanceof Constructor)) {
  6542. throw new TypeError("Cannot call a class as a function");
  6543. }
  6544. }
  6545. var PDFPageView = function() {
  6546. function PDFPageView(options) {
  6547. _classCallCheck(this, PDFPageView);
  6548. var container = options.container;
  6549. var defaultViewport = options.defaultViewport;
  6550. this.id = options.id;
  6551. this.renderingId = 'page' + this.id;
  6552. this.pdfPage = null;
  6553. this.pageLabel = null;
  6554. this.rotation = 0;
  6555. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  6556. this.viewport = defaultViewport;
  6557. this.pdfPageRotate = defaultViewport.rotation;
  6558. this.hasRestrictedScaling = false;
  6559. this.enhanceTextSelection = options.enhanceTextSelection || false;
  6560. this.renderInteractiveForms = options.renderInteractiveForms || false;
  6561. this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)();
  6562. this.renderingQueue = options.renderingQueue;
  6563. this.textLayerFactory = options.textLayerFactory;
  6564. this.annotationLayerFactory = options.annotationLayerFactory;
  6565. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  6566. this.l10n = options.l10n || _ui_utils.NullL10n;
  6567. this.paintTask = null;
  6568. this.paintedViewportMap = new WeakMap();
  6569. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  6570. this.resume = null;
  6571. this.error = null;
  6572. this.onBeforeDraw = null;
  6573. this.onAfterDraw = null;
  6574. this.annotationLayer = null;
  6575. this.textLayer = null;
  6576. this.zoomLayer = null;
  6577. var div = document.createElement('div');
  6578. div.className = 'page';
  6579. div.style.width = Math.floor(this.viewport.width) + 'px';
  6580. div.style.height = Math.floor(this.viewport.height) + 'px';
  6581. div.setAttribute('data-page-number', this.id);
  6582. this.div = div;
  6583. container.appendChild(div)
  6584. }
  6585. _createClass(PDFPageView, [{
  6586. key: 'setPdfPage',
  6587. value: function setPdfPage(pdfPage) {
  6588. this.pdfPage = pdfPage;
  6589. this.pdfPageRotate = pdfPage.rotate;
  6590. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  6591. this.viewport = pdfPage.getViewport(this.scale * _ui_utils.CSS_UNITS, totalRotation);
  6592. this.stats = pdfPage.stats;
  6593. this.reset()
  6594. }
  6595. },
  6596. {
  6597. key: 'destroy',
  6598. value: function destroy() {
  6599. this.reset();
  6600. if (this.pdfPage) {
  6601. this.pdfPage.cleanup();
  6602. this.pdfPage = null
  6603. }
  6604. }
  6605. },
  6606. {
  6607. key: '_resetZoomLayer',
  6608. value: function _resetZoomLayer() {
  6609. var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6610. if (!this.zoomLayer) {
  6611. return
  6612. }
  6613. var zoomLayerCanvas = this.zoomLayer.firstChild;
  6614. this.paintedViewportMap.delete(zoomLayerCanvas);
  6615. zoomLayerCanvas.width = 0;
  6616. zoomLayerCanvas.height = 0;
  6617. if (removeFromDOM) {
  6618. this.zoomLayer.remove()
  6619. }
  6620. this.zoomLayer = null
  6621. }
  6622. },
  6623. {
  6624. key: 'reset',
  6625. value: function reset() {
  6626. var keepZoomLayer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6627. var keepAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6628. this.cancelRendering();
  6629. var div = this.div;
  6630. div.style.width = Math.floor(this.viewport.width) + 'px';
  6631. div.style.height = Math.floor(this.viewport.height) + 'px';
  6632. var childNodes = div.childNodes;
  6633. var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
  6634. var currentAnnotationNode = keepAnnotations && this.annotationLayer && this.annotationLayer.div || null;
  6635. for (var i = childNodes.length - 1; i >= 0; i--) {
  6636. var node = childNodes[i];
  6637. if (currentZoomLayerNode === node || currentAnnotationNode === node) {
  6638. continue
  6639. }
  6640. div.removeChild(node)
  6641. }
  6642. div.removeAttribute('data-loaded');
  6643. if (currentAnnotationNode) {
  6644. this.annotationLayer.hide()
  6645. } else {
  6646. this.annotationLayer = null
  6647. }
  6648. if (!currentZoomLayerNode) {
  6649. if (this.canvas) {
  6650. this.paintedViewportMap.delete(this.canvas);
  6651. this.canvas.width = 0;
  6652. this.canvas.height = 0;
  6653. delete this.canvas
  6654. }
  6655. this._resetZoomLayer()
  6656. }
  6657. if (this.svg) {
  6658. this.paintedViewportMap.delete(this.svg);
  6659. delete this.svg
  6660. }
  6661. this.loadingIconDiv = document.createElement('div');
  6662. this.loadingIconDiv.className = 'loadingIcon';
  6663. div.appendChild(this.loadingIconDiv)
  6664. }
  6665. },
  6666. {
  6667. key: 'update',
  6668. value: function update(scale, rotation) {
  6669. this.scale = scale || this.scale;
  6670. if (typeof rotation !== 'undefined') {
  6671. this.rotation = rotation
  6672. }
  6673. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  6674. this.viewport = this.viewport.clone({
  6675. scale: this.scale * _ui_utils.CSS_UNITS,
  6676. rotation: totalRotation
  6677. });
  6678. if (this.svg) {
  6679. this.cssTransform(this.svg, true);
  6680. this.eventBus.dispatch('pagerendered', {
  6681. source: this,
  6682. pageNumber: this.id,
  6683. cssTransform: true
  6684. });
  6685. return
  6686. }
  6687. var isScalingRestricted = false;
  6688. if (this.canvas && _pdfjsLib.PDFJS.maxCanvasPixels > 0) {
  6689. var outputScale = this.outputScale;
  6690. if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > _pdfjsLib.PDFJS.maxCanvasPixels) {
  6691. isScalingRestricted = true
  6692. }
  6693. }
  6694. if (this.canvas) {
  6695. if (_pdfjsLib.PDFJS.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
  6696. this.cssTransform(this.canvas, true);
  6697. this.eventBus.dispatch('pagerendered', {
  6698. source: this,
  6699. pageNumber: this.id,
  6700. cssTransform: true
  6701. });
  6702. return
  6703. }
  6704. if (!this.zoomLayer && !this.canvas.hasAttribute('hidden')) {
  6705. this.zoomLayer = this.canvas.parentNode;
  6706. this.zoomLayer.style.position = 'absolute'
  6707. }
  6708. }
  6709. if (this.zoomLayer) {
  6710. this.cssTransform(this.zoomLayer.firstChild)
  6711. }
  6712. this.reset(true, true)
  6713. }
  6714. },
  6715. {
  6716. key: 'cancelRendering',
  6717. value: function cancelRendering() {
  6718. if (this.paintTask) {
  6719. this.paintTask.cancel();
  6720. this.paintTask = null
  6721. }
  6722. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  6723. this.resume = null;
  6724. if (this.textLayer) {
  6725. this.textLayer.cancel();
  6726. this.textLayer = null
  6727. }
  6728. }
  6729. },
  6730. {
  6731. key: 'cssTransform',
  6732. value: function cssTransform(target) {
  6733. var redrawAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6734. var width = this.viewport.width;
  6735. var height = this.viewport.height;
  6736. var div = this.div;
  6737. target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + 'px';
  6738. target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + 'px';
  6739. var relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
  6740. var absRotation = Math.abs(relativeRotation);
  6741. var scaleX = 1,
  6742. scaleY = 1;
  6743. if (absRotation === 90 || absRotation === 270) {
  6744. scaleX = height / width;
  6745. scaleY = width / height
  6746. }
  6747. var cssTransform = 'rotate(' + relativeRotation + 'deg) ' + 'scale(' + scaleX + ',' + scaleY + ')';
  6748. _pdfjsLib.CustomStyle.setProp('transform', target, cssTransform);
  6749. if (this.textLayer) {
  6750. var textLayerViewport = this.textLayer.viewport;
  6751. var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
  6752. var textAbsRotation = Math.abs(textRelativeRotation);
  6753. var scale = width / textLayerViewport.width;
  6754. if (textAbsRotation === 90 || textAbsRotation === 270) {
  6755. scale = width / textLayerViewport.height
  6756. }
  6757. var textLayerDiv = this.textLayer.textLayerDiv;
  6758. var transX = void 0,
  6759. transY = void 0;
  6760. switch (textAbsRotation) {
  6761. case 0:
  6762. transX = transY = 0;
  6763. break;
  6764. case 90:
  6765. transX = 0;
  6766. transY = '-' + textLayerDiv.style.height;
  6767. break;
  6768. case 180:
  6769. transX = '-' + textLayerDiv.style.width;
  6770. transY = '-' + textLayerDiv.style.height;
  6771. break;
  6772. case 270:
  6773. transX = '-' + textLayerDiv.style.width;
  6774. transY = 0;
  6775. break;
  6776. default:
  6777. console.error('Bad rotation value.');
  6778. break
  6779. }
  6780. _pdfjsLib.CustomStyle.setProp('transform', textLayerDiv, 'rotate(' + textAbsRotation + 'deg) ' + 'scale(' + scale + ', ' + scale + ') ' + 'translate(' + transX + ', ' + transY + ')');
  6781. _pdfjsLib.CustomStyle.setProp('transformOrigin', textLayerDiv, '0% 0%')
  6782. }
  6783. if (redrawAnnotations && this.annotationLayer) {
  6784. this.annotationLayer.render(this.viewport, 'display')
  6785. }
  6786. }
  6787. },
  6788. {
  6789. key: 'getPagePoint',
  6790. value: function getPagePoint(x, y) {
  6791. return this.viewport.convertToPdfPoint(x, y)
  6792. }
  6793. },
  6794. {
  6795. key: 'draw',
  6796. value: function draw() {
  6797. var _this = this;
  6798. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  6799. console.error('Must be in new state before drawing');
  6800. this.reset()
  6801. }
  6802. if (!this.pdfPage) {
  6803. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  6804. return Promise.reject(new Error('Page is not loaded'))
  6805. }
  6806. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  6807. var pdfPage = this.pdfPage;
  6808. var div = this.div;
  6809. var canvasWrapper = document.createElement('div');
  6810. canvasWrapper.style.width = div.style.width;
  6811. canvasWrapper.style.height = div.style.height;
  6812. canvasWrapper.classList.add('canvasWrapper');
  6813. if (this.annotationLayer && this.annotationLayer.div) {
  6814. div.insertBefore(canvasWrapper, this.annotationLayer.div)
  6815. } else {
  6816. div.appendChild(canvasWrapper)
  6817. }
  6818. var textLayer = null;
  6819. if (this.textLayerFactory) {
  6820. var textLayerDiv = document.createElement('div');
  6821. textLayerDiv.className = 'textLayer';
  6822. textLayerDiv.style.width = canvasWrapper.style.width;
  6823. textLayerDiv.style.height = canvasWrapper.style.height;
  6824. if (this.annotationLayer && this.annotationLayer.div) {
  6825. div.insertBefore(textLayerDiv, this.annotationLayer.div)
  6826. } else {
  6827. div.appendChild(textLayerDiv)
  6828. }
  6829. textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.enhanceTextSelection)
  6830. }
  6831. this.textLayer = textLayer;
  6832. var renderContinueCallback = null;
  6833. if (this.renderingQueue) {
  6834. renderContinueCallback = function renderContinueCallback(cont) {
  6835. if (!_this.renderingQueue.isHighestPriority(_this)) {
  6836. _this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  6837. _this.resume = function() {
  6838. _this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  6839. cont()
  6840. };
  6841. return
  6842. }
  6843. cont()
  6844. }
  6845. }
  6846. var finishPaintTask = function finishPaintTask(error) {
  6847. if (paintTask === _this.paintTask) {
  6848. _this.paintTask = null
  6849. }
  6850. if (error === 'cancelled' || error instanceof _pdfjsLib.RenderingCancelledException) {
  6851. _this.error = null;
  6852. return Promise.resolve(undefined)
  6853. }
  6854. _this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  6855. if (_this.loadingIconDiv) {
  6856. div.removeChild(_this.loadingIconDiv);
  6857. delete _this.loadingIconDiv
  6858. }
  6859. _this._resetZoomLayer(true);
  6860. _this.error = error;
  6861. _this.stats = pdfPage.stats;
  6862. if (_this.onAfterDraw) {
  6863. _this.onAfterDraw()
  6864. }
  6865. _this.eventBus.dispatch('pagerendered', {
  6866. source: _this,
  6867. pageNumber: _this.id,
  6868. cssTransform: false
  6869. });
  6870. if (error) {
  6871. return Promise.reject(error)
  6872. }
  6873. return Promise.resolve(undefined)
  6874. };
  6875. var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
  6876. paintTask.onRenderContinue = renderContinueCallback;
  6877. this.paintTask = paintTask;
  6878. var resultPromise = paintTask.promise.then(function() {
  6879. return finishPaintTask(null).then(function() {
  6880. if (textLayer) {
  6881. var readableStream = pdfPage.streamTextContent({
  6882. normalizeWhitespace: true
  6883. });
  6884. textLayer.setTextContentStream(readableStream);
  6885. textLayer.render()
  6886. }
  6887. })
  6888. },
  6889. function(reason) {
  6890. return finishPaintTask(reason)
  6891. });
  6892. if (this.annotationLayerFactory) {
  6893. if (!this.annotationLayer) {
  6894. this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this.renderInteractiveForms, this.l10n)
  6895. }
  6896. this.annotationLayer.render(this.viewport, 'display')
  6897. }
  6898. div.setAttribute('data-loaded', true);
  6899. if (this.onBeforeDraw) {
  6900. this.onBeforeDraw()
  6901. }
  6902. return resultPromise
  6903. }
  6904. },
  6905. {
  6906. key: 'paintOnCanvas',
  6907. value: function paintOnCanvas(canvasWrapper) {
  6908. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  6909. var result = {
  6910. promise: renderCapability.promise,
  6911. onRenderContinue: function onRenderContinue(cont) {
  6912. cont()
  6913. },
  6914. cancel: function cancel() {
  6915. renderTask.cancel()
  6916. }
  6917. };
  6918. var viewport = this.viewport;
  6919. var canvas = document.createElement('canvas');
  6920. canvas.id = this.renderingId;
  6921. canvas.setAttribute('hidden', 'hidden');
  6922. var isCanvasHidden = true;
  6923. var showCanvas = function showCanvas() {
  6924. if (isCanvasHidden) {
  6925. canvas.removeAttribute('hidden');
  6926. isCanvasHidden = false
  6927. }
  6928. };
  6929. canvasWrapper.appendChild(canvas);
  6930. this.canvas = canvas;
  6931. canvas.mozOpaque = true;
  6932. var ctx = canvas.getContext('2d', {
  6933. alpha: false
  6934. });
  6935. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  6936. this.outputScale = outputScale;
  6937. if (_pdfjsLib.PDFJS.useOnlyCssZoom) {
  6938. var actualSizeViewport = viewport.clone({
  6939. scale: _ui_utils.CSS_UNITS
  6940. });
  6941. outputScale.sx *= actualSizeViewport.width / viewport.width;
  6942. outputScale.sy *= actualSizeViewport.height / viewport.height;
  6943. outputScale.scaled = true
  6944. }
  6945. if (_pdfjsLib.PDFJS.maxCanvasPixels > 0) {
  6946. var pixelsInViewport = viewport.width * viewport.height;
  6947. var maxScale = Math.sqrt(_pdfjsLib.PDFJS.maxCanvasPixels / pixelsInViewport);
  6948. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  6949. outputScale.sx = maxScale;
  6950. outputScale.sy = maxScale;
  6951. outputScale.scaled = true;
  6952. this.hasRestrictedScaling = true
  6953. } else {
  6954. this.hasRestrictedScaling = false
  6955. }
  6956. }
  6957. var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  6958. var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  6959. canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
  6960. canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
  6961. canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + 'px';
  6962. canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + 'px';
  6963. this.paintedViewportMap.set(canvas, viewport);
  6964. var transform = !outputScale.scaled ? null: [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
  6965. var renderContext = {
  6966. canvasContext: ctx,
  6967. transform: transform,
  6968. viewport: this.viewport,
  6969. renderInteractiveForms: this.renderInteractiveForms
  6970. };
  6971. var renderTask = this.pdfPage.render(renderContext);
  6972. renderTask.onContinue = function(cont) {
  6973. showCanvas();
  6974. if (result.onRenderContinue) {
  6975. result.onRenderContinue(cont)
  6976. } else {
  6977. cont()
  6978. }
  6979. };
  6980. renderTask.promise.then(function() {
  6981. showCanvas();
  6982. renderCapability.resolve(undefined)
  6983. },
  6984. function(error) {
  6985. showCanvas();
  6986. renderCapability.reject(error)
  6987. });
  6988. return result
  6989. }
  6990. },
  6991. {
  6992. key: 'paintOnSvg',
  6993. value: function paintOnSvg(wrapper) {
  6994. var _this2 = this;
  6995. var cancelled = false;
  6996. var ensureNotCancelled = function ensureNotCancelled() {
  6997. if (cancelled) {
  6998. if (_pdfjsLib.PDFJS.pdfjsNext) {
  6999. throw new _pdfjsLib.RenderingCancelledException('Rendering cancelled, page ' + _this2.id, 'svg');
  7000. } else {
  7001. throw 'cancelled';
  7002. }
  7003. }
  7004. };
  7005. var pdfPage = this.pdfPage;
  7006. var actualSizeViewport = this.viewport.clone({
  7007. scale: _ui_utils.CSS_UNITS
  7008. });
  7009. var promise = pdfPage.getOperatorList().then(function(opList) {
  7010. ensureNotCancelled();
  7011. var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
  7012. return svgGfx.getSVG(opList, actualSizeViewport).then(function(svg) {
  7013. ensureNotCancelled();
  7014. _this2.svg = svg;
  7015. _this2.paintedViewportMap.set(svg, actualSizeViewport);
  7016. svg.style.width = wrapper.style.width;
  7017. svg.style.height = wrapper.style.height;
  7018. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  7019. wrapper.appendChild(svg)
  7020. })
  7021. });
  7022. return {
  7023. promise: promise,
  7024. onRenderContinue: function onRenderContinue(cont) {
  7025. cont()
  7026. },
  7027. cancel: function cancel() {
  7028. cancelled = true
  7029. }
  7030. }
  7031. }
  7032. },
  7033. {
  7034. key: 'setPageLabel',
  7035. value: function setPageLabel(label) {
  7036. this.pageLabel = typeof label === 'string' ? label: null;
  7037. if (this.pageLabel !== null) {
  7038. this.div.setAttribute('data-page-label', this.pageLabel)
  7039. } else {
  7040. this.div.removeAttribute('data-page-label')
  7041. }
  7042. }
  7043. },
  7044. {
  7045. key: 'width',
  7046. get: function get() {
  7047. return this.viewport.width
  7048. }
  7049. },
  7050. {
  7051. key: 'height',
  7052. get: function get() {
  7053. return this.viewport.height
  7054. }
  7055. }]);
  7056. return PDFPageView
  7057. } ();
  7058. exports.PDFPageView = PDFPageView
  7059. }), (function(module, exports, __webpack_require__) {
  7060. "use strict";
  7061. Object.defineProperty(exports, "__esModule", {
  7062. value: true
  7063. });
  7064. exports.PDFPresentationMode = undefined;
  7065. var _createClass = function() {
  7066. function defineProperties(target, props) {
  7067. for (var i = 0; i < props.length; i++) {
  7068. var descriptor = props[i];
  7069. descriptor.enumerable = descriptor.enumerable || false;
  7070. descriptor.configurable = true;
  7071. if ("value" in descriptor) descriptor.writable = true;
  7072. Object.defineProperty(target, descriptor.key, descriptor)
  7073. }
  7074. }
  7075. return function(Constructor, protoProps, staticProps) {
  7076. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  7077. if (staticProps) defineProperties(Constructor, staticProps);
  7078. return Constructor
  7079. }
  7080. } ();
  7081. var _ui_utils = __webpack_require__(0);
  7082. function _classCallCheck(instance, Constructor) {
  7083. if (! (instance instanceof Constructor)) {
  7084. throw new TypeError("Cannot call a class as a function");
  7085. }
  7086. }
  7087. var DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1500;
  7088. var DELAY_BEFORE_HIDING_CONTROLS = 3000;
  7089. var ACTIVE_SELECTOR = 'pdfPresentationMode';
  7090. var CONTROLS_SELECTOR = 'pdfPresentationModeControls';
  7091. var MOUSE_SCROLL_COOLDOWN_TIME = 50;
  7092. var PAGE_SWITCH_THRESHOLD = 0.1;
  7093. var SWIPE_MIN_DISTANCE_THRESHOLD = 50;
  7094. var SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
  7095. var PDFPresentationMode = function() {
  7096. function PDFPresentationMode(_ref) {
  7097. var _this = this;
  7098. var container = _ref.container,
  7099. _ref$viewer = _ref.viewer,
  7100. viewer = _ref$viewer === undefined ? null: _ref$viewer,
  7101. pdfViewer = _ref.pdfViewer,
  7102. eventBus = _ref.eventBus,
  7103. _ref$contextMenuItems = _ref.contextMenuItems,
  7104. contextMenuItems = _ref$contextMenuItems === undefined ? null: _ref$contextMenuItems;
  7105. _classCallCheck(this, PDFPresentationMode);
  7106. this.container = container;
  7107. this.viewer = viewer || container.firstElementChild;
  7108. this.pdfViewer = pdfViewer;
  7109. this.eventBus = eventBus;
  7110. this.active = false;
  7111. this.args = null;
  7112. this.contextMenuOpen = false;
  7113. this.mouseScrollTimeStamp = 0;
  7114. this.mouseScrollDelta = 0;
  7115. this.touchSwipeState = null;
  7116. if (contextMenuItems) {
  7117. contextMenuItems.contextFirstPage.addEventListener('click',
  7118. function() {
  7119. _this.contextMenuOpen = false;
  7120. _this.eventBus.dispatch('firstpage')
  7121. });
  7122. contextMenuItems.contextLastPage.addEventListener('click',
  7123. function() {
  7124. _this.contextMenuOpen = false;
  7125. _this.eventBus.dispatch('lastpage')
  7126. });
  7127. contextMenuItems.contextPageRotateCw.addEventListener('click',
  7128. function() {
  7129. _this.contextMenuOpen = false;
  7130. _this.eventBus.dispatch('rotatecw')
  7131. });
  7132. contextMenuItems.contextPageRotateCcw.addEventListener('click',
  7133. function() {
  7134. _this.contextMenuOpen = false;
  7135. _this.eventBus.dispatch('rotateccw')
  7136. })
  7137. }
  7138. }
  7139. _createClass(PDFPresentationMode, [{
  7140. key: 'request',
  7141. value: function request() {
  7142. if (this.switchInProgress || this.active || !this.viewer.hasChildNodes()) {
  7143. return false
  7144. }
  7145. this._addFullscreenChangeListeners();
  7146. this._setSwitchInProgress();
  7147. this._notifyStateChange();
  7148. if (this.container.requestFullscreen) {
  7149. this.container.requestFullscreen()
  7150. } else if (this.container.mozRequestFullScreen) {
  7151. this.container.mozRequestFullScreen()
  7152. } else if (this.container.webkitRequestFullscreen) {
  7153. this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT)
  7154. } else if (this.container.msRequestFullscreen) {
  7155. this.container.msRequestFullscreen()
  7156. } else {
  7157. return false
  7158. }
  7159. this.args = {
  7160. page: this.pdfViewer.currentPageNumber,
  7161. previousScale: this.pdfViewer.currentScaleValue
  7162. };
  7163. return true
  7164. }
  7165. },
  7166. {
  7167. key: '_mouseWheel',
  7168. value: function _mouseWheel(evt) {
  7169. if (!this.active) {
  7170. return
  7171. }
  7172. evt.preventDefault();
  7173. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  7174. var currentTime = new Date().getTime();
  7175. var storedTime = this.mouseScrollTimeStamp;
  7176. if (currentTime > storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {
  7177. return
  7178. }
  7179. if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) {
  7180. this._resetMouseScrollState()
  7181. }
  7182. this.mouseScrollDelta += delta;
  7183. if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
  7184. var totalDelta = this.mouseScrollDelta;
  7185. this._resetMouseScrollState();
  7186. var success = totalDelta > 0 ? this._goToPreviousPage() : this._goToNextPage();
  7187. if (success) {
  7188. this.mouseScrollTimeStamp = currentTime
  7189. }
  7190. }
  7191. }
  7192. },
  7193. {
  7194. key: '_goToPreviousPage',
  7195. value: function _goToPreviousPage() {
  7196. var page = this.pdfViewer.currentPageNumber;
  7197. if (page <= 1) {
  7198. return false
  7199. }
  7200. this.pdfViewer.currentPageNumber = page - 1;
  7201. return true
  7202. }
  7203. },
  7204. {
  7205. key: '_goToNextPage',
  7206. value: function _goToNextPage() {
  7207. var page = this.pdfViewer.currentPageNumber;
  7208. if (page >= this.pdfViewer.pagesCount) {
  7209. return false
  7210. }
  7211. this.pdfViewer.currentPageNumber = page + 1;
  7212. return true
  7213. }
  7214. },
  7215. {
  7216. key: '_notifyStateChange',
  7217. value: function _notifyStateChange() {
  7218. this.eventBus.dispatch('presentationmodechanged', {
  7219. source: this,
  7220. active: this.active,
  7221. switchInProgress: !!this.switchInProgress
  7222. })
  7223. }
  7224. },
  7225. {
  7226. key: '_setSwitchInProgress',
  7227. value: function _setSwitchInProgress() {
  7228. var _this2 = this;
  7229. if (this.switchInProgress) {
  7230. clearTimeout(this.switchInProgress)
  7231. }
  7232. this.switchInProgress = setTimeout(function() {
  7233. _this2._removeFullscreenChangeListeners();
  7234. delete _this2.switchInProgress;
  7235. _this2._notifyStateChange()
  7236. },
  7237. DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS)
  7238. }
  7239. },
  7240. {
  7241. key: '_resetSwitchInProgress',
  7242. value: function _resetSwitchInProgress() {
  7243. if (this.switchInProgress) {
  7244. clearTimeout(this.switchInProgress);
  7245. delete this.switchInProgress
  7246. }
  7247. }
  7248. },
  7249. {
  7250. key: '_enter',
  7251. value: function _enter() {
  7252. var _this3 = this;
  7253. this.active = true;
  7254. this._resetSwitchInProgress();
  7255. this._notifyStateChange();
  7256. this.container.classList.add(ACTIVE_SELECTOR);
  7257. setTimeout(function() {
  7258. _this3.pdfViewer.currentPageNumber = _this3.args.page;
  7259. _this3.pdfViewer.currentScaleValue = 'page-fit'
  7260. },
  7261. 0);
  7262. this._addWindowListeners();
  7263. this._showControls();
  7264. this.contextMenuOpen = false;
  7265. this.container.setAttribute('contextmenu', 'viewerContextMenu');
  7266. window.getSelection().removeAllRanges()
  7267. }
  7268. },
  7269. {
  7270. key: '_exit',
  7271. value: function _exit() {
  7272. var _this4 = this;
  7273. var page = this.pdfViewer.currentPageNumber;
  7274. this.container.classList.remove(ACTIVE_SELECTOR);
  7275. setTimeout(function() {
  7276. _this4.active = false;
  7277. _this4._removeFullscreenChangeListeners();
  7278. _this4._notifyStateChange();
  7279. _this4.pdfViewer.currentScaleValue = _this4.args.previousScale;
  7280. _this4.pdfViewer.currentPageNumber = page;
  7281. _this4.args = null
  7282. },
  7283. 0);
  7284. this._removeWindowListeners();
  7285. this._hideControls();
  7286. this._resetMouseScrollState();
  7287. this.container.removeAttribute('contextmenu');
  7288. this.contextMenuOpen = false
  7289. }
  7290. },
  7291. {
  7292. key: '_mouseDown',
  7293. value: function _mouseDown(evt) {
  7294. if (this.contextMenuOpen) {
  7295. this.contextMenuOpen = false;
  7296. evt.preventDefault();
  7297. return
  7298. }
  7299. if (evt.button === 0) {
  7300. var isInternalLink = evt.target.href && evt.target.classList.contains('internalLink');
  7301. if (!isInternalLink) {
  7302. evt.preventDefault();
  7303. if (evt.shiftKey) {
  7304. this._goToPreviousPage()
  7305. } else {
  7306. this._goToNextPage()
  7307. }
  7308. }
  7309. }
  7310. }
  7311. },
  7312. {
  7313. key: '_contextMenu',
  7314. value: function _contextMenu() {
  7315. this.contextMenuOpen = true
  7316. }
  7317. },
  7318. {
  7319. key: '_showControls',
  7320. value: function _showControls() {
  7321. var _this5 = this;
  7322. if (this.controlsTimeout) {
  7323. clearTimeout(this.controlsTimeout)
  7324. } else {
  7325. this.container.classList.add(CONTROLS_SELECTOR)
  7326. }
  7327. this.controlsTimeout = setTimeout(function() {
  7328. _this5.container.classList.remove(CONTROLS_SELECTOR);
  7329. delete _this5.controlsTimeout
  7330. },
  7331. DELAY_BEFORE_HIDING_CONTROLS)
  7332. }
  7333. },
  7334. {
  7335. key: '_hideControls',
  7336. value: function _hideControls() {
  7337. if (!this.controlsTimeout) {
  7338. return
  7339. }
  7340. clearTimeout(this.controlsTimeout);
  7341. this.container.classList.remove(CONTROLS_SELECTOR);
  7342. delete this.controlsTimeout
  7343. }
  7344. },
  7345. {
  7346. key: '_resetMouseScrollState',
  7347. value: function _resetMouseScrollState() {
  7348. this.mouseScrollTimeStamp = 0;
  7349. this.mouseScrollDelta = 0
  7350. }
  7351. },
  7352. {
  7353. key: '_touchSwipe',
  7354. value: function _touchSwipe(evt) {
  7355. if (!this.active) {
  7356. return
  7357. }
  7358. if (evt.touches.length > 1) {
  7359. this.touchSwipeState = null;
  7360. return
  7361. }
  7362. switch (evt.type) {
  7363. case 'touchstart':
  7364. this.touchSwipeState = {
  7365. startX: evt.touches[0].pageX,
  7366. startY: evt.touches[0].pageY,
  7367. endX: evt.touches[0].pageX,
  7368. endY: evt.touches[0].pageY
  7369. };
  7370. break;
  7371. case 'touchmove':
  7372. if (this.touchSwipeState === null) {
  7373. return
  7374. }
  7375. this.touchSwipeState.endX = evt.touches[0].pageX;
  7376. this.touchSwipeState.endY = evt.touches[0].pageY;
  7377. evt.preventDefault();
  7378. break;
  7379. case 'touchend':
  7380. if (this.touchSwipeState === null) {
  7381. return
  7382. }
  7383. var delta = 0;
  7384. var dx = this.touchSwipeState.endX - this.touchSwipeState.startX;
  7385. var dy = this.touchSwipeState.endY - this.touchSwipeState.startY;
  7386. var absAngle = Math.abs(Math.atan2(dy, dx));
  7387. if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <= SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI - SWIPE_ANGLE_THRESHOLD)) {
  7388. delta = dx
  7389. } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math.abs(absAngle - Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) {
  7390. delta = dy
  7391. }
  7392. if (delta > 0) {
  7393. this._goToPreviousPage()
  7394. } else if (delta < 0) {
  7395. this._goToNextPage()
  7396. }
  7397. break
  7398. }
  7399. }
  7400. },
  7401. {
  7402. key: '_addWindowListeners',
  7403. value: function _addWindowListeners() {
  7404. this.showControlsBind = this._showControls.bind(this);
  7405. this.mouseDownBind = this._mouseDown.bind(this);
  7406. this.mouseWheelBind = this._mouseWheel.bind(this);
  7407. this.resetMouseScrollStateBind = this._resetMouseScrollState.bind(this);
  7408. this.contextMenuBind = this._contextMenu.bind(this);
  7409. this.touchSwipeBind = this._touchSwipe.bind(this);
  7410. window.addEventListener('mousemove', this.showControlsBind);
  7411. window.addEventListener('mousedown', this.mouseDownBind);
  7412. window.addEventListener('wheel', this.mouseWheelBind);
  7413. window.addEventListener('keydown', this.resetMouseScrollStateBind);
  7414. window.addEventListener('contextmenu', this.contextMenuBind);
  7415. window.addEventListener('touchstart', this.touchSwipeBind);
  7416. window.addEventListener('touchmove', this.touchSwipeBind);
  7417. window.addEventListener('touchend', this.touchSwipeBind)
  7418. }
  7419. },
  7420. {
  7421. key: '_removeWindowListeners',
  7422. value: function _removeWindowListeners() {
  7423. window.removeEventListener('mousemove', this.showControlsBind);
  7424. window.removeEventListener('mousedown', this.mouseDownBind);
  7425. window.removeEventListener('wheel', this.mouseWheelBind);
  7426. window.removeEventListener('keydown', this.resetMouseScrollStateBind);
  7427. window.removeEventListener('contextmenu', this.contextMenuBind);
  7428. window.removeEventListener('touchstart', this.touchSwipeBind);
  7429. window.removeEventListener('touchmove', this.touchSwipeBind);
  7430. window.removeEventListener('touchend', this.touchSwipeBind);
  7431. delete this.showControlsBind;
  7432. delete this.mouseDownBind;
  7433. delete this.mouseWheelBind;
  7434. delete this.resetMouseScrollStateBind;
  7435. delete this.contextMenuBind;
  7436. delete this.touchSwipeBind
  7437. }
  7438. },
  7439. {
  7440. key: '_fullscreenChange',
  7441. value: function _fullscreenChange() {
  7442. if (this.isFullscreen) {
  7443. this._enter()
  7444. } else {
  7445. this._exit()
  7446. }
  7447. }
  7448. },
  7449. {
  7450. key: '_addFullscreenChangeListeners',
  7451. value: function _addFullscreenChangeListeners() {
  7452. this.fullscreenChangeBind = this._fullscreenChange.bind(this);
  7453. window.addEventListener('fullscreenchange', this.fullscreenChangeBind);
  7454. window.addEventListener('mozfullscreenchange', this.fullscreenChangeBind);
  7455. window.addEventListener('webkitfullscreenchange', this.fullscreenChangeBind);
  7456. window.addEventListener('MSFullscreenChange', this.fullscreenChangeBind)
  7457. }
  7458. },
  7459. {
  7460. key: '_removeFullscreenChangeListeners',
  7461. value: function _removeFullscreenChangeListeners() {
  7462. window.removeEventListener('fullscreenchange', this.fullscreenChangeBind);
  7463. window.removeEventListener('mozfullscreenchange', this.fullscreenChangeBind);
  7464. window.removeEventListener('webkitfullscreenchange', this.fullscreenChangeBind);
  7465. window.removeEventListener('MSFullscreenChange', this.fullscreenChangeBind);
  7466. delete this.fullscreenChangeBind
  7467. }
  7468. },
  7469. {
  7470. key: 'isFullscreen',
  7471. get: function get() {
  7472. return !! (document.fullscreenElement || document.mozFullScreen || document.webkitIsFullScreen || document.msFullscreenElement)
  7473. }
  7474. }]);
  7475. return PDFPresentationMode
  7476. } ();
  7477. exports.PDFPresentationMode = PDFPresentationMode
  7478. }), (function(module, exports, __webpack_require__) {
  7479. "use strict";
  7480. Object.defineProperty(exports, "__esModule", {
  7481. value: true
  7482. });
  7483. exports.PDFSidebar = exports.SidebarView = undefined;
  7484. var _createClass = function() {
  7485. function defineProperties(target, props) {
  7486. for (var i = 0; i < props.length; i++) {
  7487. var descriptor = props[i];
  7488. descriptor.enumerable = descriptor.enumerable || false;
  7489. descriptor.configurable = true;
  7490. if ("value" in descriptor) descriptor.writable = true;
  7491. Object.defineProperty(target, descriptor.key, descriptor)
  7492. }
  7493. }
  7494. return function(Constructor, protoProps, staticProps) {
  7495. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  7496. if (staticProps) defineProperties(Constructor, staticProps);
  7497. return Constructor
  7498. }
  7499. } ();
  7500. var _ui_utils = __webpack_require__(0);
  7501. var _pdf_rendering_queue = __webpack_require__(3);
  7502. function _classCallCheck(instance, Constructor) {
  7503. if (! (instance instanceof Constructor)) {
  7504. throw new TypeError("Cannot call a class as a function");
  7505. }
  7506. }
  7507. var UI_NOTIFICATION_CLASS = 'pdfSidebarNotification';
  7508. var SidebarView = {
  7509. NONE: 0,
  7510. THUMBS: 1,
  7511. OUTLINE: 2,
  7512. ATTACHMENTS: 3
  7513. };
  7514. var PDFSidebar = function() {
  7515. function PDFSidebar(options) {
  7516. var l10n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _ui_utils.NullL10n;
  7517. _classCallCheck(this, PDFSidebar);
  7518. this.isOpen = false;
  7519. this.active = SidebarView.THUMBS;
  7520. this.isInitialViewSet = false;
  7521. this.onToggled = null;
  7522. this.pdfViewer = options.pdfViewer;
  7523. this.pdfThumbnailViewer = options.pdfThumbnailViewer;
  7524. this.pdfOutlineViewer = options.pdfOutlineViewer;
  7525. this.mainContainer = options.mainContainer;
  7526. this.outerContainer = options.outerContainer;
  7527. this.eventBus = options.eventBus;
  7528. this.toggleButton = options.toggleButton;
  7529. this.thumbnailButton = options.thumbnailButton;
  7530. this.outlineButton = options.outlineButton;
  7531. this.attachmentsButton = options.attachmentsButton;
  7532. this.thumbnailView = options.thumbnailView;
  7533. this.outlineView = options.outlineView;
  7534. this.attachmentsView = options.attachmentsView;
  7535. this.disableNotification = options.disableNotification || false;
  7536. this.l10n = l10n;
  7537. this._addEventListeners()
  7538. }
  7539. _createClass(PDFSidebar, [{
  7540. key: 'reset',
  7541. value: function reset() {
  7542. this.isInitialViewSet = false;
  7543. this._hideUINotification(null);
  7544. this.switchView(SidebarView.THUMBS);
  7545. this.outlineButton.disabled = false;
  7546. this.attachmentsButton.disabled = false
  7547. }
  7548. },
  7549. {
  7550. key: 'setInitialView',
  7551. value: function setInitialView(view) {
  7552. if (this.isInitialViewSet) {
  7553. return
  7554. }
  7555. this.isInitialViewSet = true;
  7556. if (this.isOpen && view === SidebarView.NONE) {
  7557. this._dispatchEvent();
  7558. return
  7559. }
  7560. var isViewPreserved = view === this.visibleView;
  7561. this.switchView(view, true);
  7562. if (isViewPreserved) {
  7563. this._dispatchEvent()
  7564. }
  7565. }
  7566. },
  7567. {
  7568. key: 'switchView',
  7569. value: function switchView(view) {
  7570. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7571. if (view === SidebarView.NONE) {
  7572. this.close();
  7573. return
  7574. }
  7575. var isViewChanged = view !== this.active;
  7576. var shouldForceRendering = false;
  7577. switch (view) {
  7578. case SidebarView.THUMBS:
  7579. this.thumbnailButton.classList.add('toggled');
  7580. this.outlineButton.classList.remove('toggled');
  7581. this.attachmentsButton.classList.remove('toggled');
  7582. this.thumbnailView.classList.remove('hidden');
  7583. this.outlineView.classList.add('hidden');
  7584. this.attachmentsView.classList.add('hidden');
  7585. if (this.isOpen && isViewChanged) {
  7586. this._updateThumbnailViewer();
  7587. shouldForceRendering = true
  7588. }
  7589. break;
  7590. case SidebarView.OUTLINE:
  7591. if (this.outlineButton.disabled) {
  7592. return
  7593. }
  7594. this.thumbnailButton.classList.remove('toggled');
  7595. this.outlineButton.classList.add('toggled');
  7596. this.attachmentsButton.classList.remove('toggled');
  7597. this.thumbnailView.classList.add('hidden');
  7598. this.outlineView.classList.remove('hidden');
  7599. this.attachmentsView.classList.add('hidden');
  7600. break;
  7601. case SidebarView.ATTACHMENTS:
  7602. if (this.attachmentsButton.disabled) {
  7603. return
  7604. }
  7605. this.thumbnailButton.classList.remove('toggled');
  7606. this.outlineButton.classList.remove('toggled');
  7607. this.attachmentsButton.classList.add('toggled');
  7608. this.thumbnailView.classList.add('hidden');
  7609. this.outlineView.classList.add('hidden');
  7610. this.attachmentsView.classList.remove('hidden');
  7611. break;
  7612. default:
  7613. console.error('PDFSidebar_switchView: "' + view + '" is an unsupported value.');
  7614. return
  7615. }
  7616. this.active = view | 0;
  7617. if (forceOpen && !this.isOpen) {
  7618. this.open();
  7619. return
  7620. }
  7621. if (shouldForceRendering) {
  7622. this._forceRendering()
  7623. }
  7624. if (isViewChanged) {
  7625. this._dispatchEvent()
  7626. }
  7627. this._hideUINotification(this.active)
  7628. }
  7629. },
  7630. {
  7631. key: 'open',
  7632. value: function open() {
  7633. if (this.isOpen) {
  7634. return
  7635. }
  7636. this.isOpen = true;
  7637. this.toggleButton.classList.add('toggled');
  7638. this.outerContainer.classList.add('sidebarMoving');
  7639. this.outerContainer.classList.add('sidebarOpen');
  7640. if (this.active === SidebarView.THUMBS) {
  7641. this._updateThumbnailViewer()
  7642. }
  7643. this._forceRendering();
  7644. this._dispatchEvent();
  7645. this._hideUINotification(this.active)
  7646. }
  7647. },
  7648. {
  7649. key: 'close',
  7650. value: function close() {
  7651. if (!this.isOpen) {
  7652. return
  7653. }
  7654. this.isOpen = false;
  7655. this.toggleButton.classList.remove('toggled');
  7656. this.outerContainer.classList.add('sidebarMoving');
  7657. this.outerContainer.classList.remove('sidebarOpen');
  7658. this._forceRendering();
  7659. this._dispatchEvent()
  7660. }
  7661. },
  7662. {
  7663. key: 'toggle',
  7664. value: function toggle() {
  7665. if (this.isOpen) {
  7666. this.close()
  7667. } else {
  7668. this.open()
  7669. }
  7670. }
  7671. },
  7672. {
  7673. key: '_dispatchEvent',
  7674. value: function _dispatchEvent() {
  7675. this.eventBus.dispatch('sidebarviewchanged', {
  7676. source: this,
  7677. view: this.visibleView
  7678. })
  7679. }
  7680. },
  7681. {
  7682. key: '_forceRendering',
  7683. value: function _forceRendering() {
  7684. if (this.onToggled) {
  7685. this.onToggled()
  7686. } else {
  7687. this.pdfViewer.forceRendering();
  7688. this.pdfThumbnailViewer.forceRendering()
  7689. }
  7690. }
  7691. },
  7692. {
  7693. key: '_updateThumbnailViewer',
  7694. value: function _updateThumbnailViewer() {
  7695. var pdfViewer = this.pdfViewer,
  7696. pdfThumbnailViewer = this.pdfThumbnailViewer;
  7697. var pagesCount = pdfViewer.pagesCount;
  7698. for (var pageIndex = 0; pageIndex < pagesCount; pageIndex++) {
  7699. var pageView = pdfViewer.getPageView(pageIndex);
  7700. if (pageView && pageView.renderingState === _pdf_rendering_queue.RenderingStates.FINISHED) {
  7701. var thumbnailView = pdfThumbnailViewer.getThumbnail(pageIndex);
  7702. thumbnailView.setImage(pageView)
  7703. }
  7704. }
  7705. pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber)
  7706. }
  7707. },
  7708. {
  7709. key: '_showUINotification',
  7710. value: function _showUINotification(view) {
  7711. var _this = this;
  7712. if (this.disableNotification) {
  7713. return
  7714. }
  7715. this.l10n.get('toggle_sidebar_notification.title', null, 'Toggle Sidebar (document contains outline/attachments)').then(function(msg) {
  7716. _this.toggleButton.title = msg
  7717. });
  7718. if (!this.isOpen) {
  7719. this.toggleButton.classList.add(UI_NOTIFICATION_CLASS)
  7720. } else if (view === this.active) {
  7721. return
  7722. }
  7723. switch (view) {
  7724. case SidebarView.OUTLINE:
  7725. this.outlineButton.classList.add(UI_NOTIFICATION_CLASS);
  7726. break;
  7727. case SidebarView.ATTACHMENTS:
  7728. this.attachmentsButton.classList.add(UI_NOTIFICATION_CLASS);
  7729. break
  7730. }
  7731. }
  7732. },
  7733. {
  7734. key: '_hideUINotification',
  7735. value: function _hideUINotification(view) {
  7736. var _this2 = this;
  7737. if (this.disableNotification) {
  7738. return
  7739. }
  7740. var removeNotification = function removeNotification(view) {
  7741. switch (view) {
  7742. case SidebarView.OUTLINE:
  7743. _this2.outlineButton.classList.remove(UI_NOTIFICATION_CLASS);
  7744. break;
  7745. case SidebarView.ATTACHMENTS:
  7746. _this2.attachmentsButton.classList.remove(UI_NOTIFICATION_CLASS);
  7747. break
  7748. }
  7749. };
  7750. if (!this.isOpen && view !== null) {
  7751. return
  7752. }
  7753. this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
  7754. if (view !== null) {
  7755. removeNotification(view);
  7756. return
  7757. }
  7758. for (view in SidebarView) {
  7759. removeNotification(SidebarView[view])
  7760. }
  7761. this.l10n.get('toggle_sidebar.title', null, 'Toggle Sidebar').then(function(msg) {
  7762. _this2.toggleButton.title = msg
  7763. })
  7764. }
  7765. },
  7766. {
  7767. key: '_addEventListeners',
  7768. value: function _addEventListeners() {
  7769. var _this3 = this;
  7770. this.mainContainer.addEventListener('transitionend',
  7771. function(evt) {
  7772. if (evt.target === _this3.mainContainer) {
  7773. _this3.outerContainer.classList.remove('sidebarMoving')
  7774. }
  7775. });
  7776. this.thumbnailButton.addEventListener('click',
  7777. function() {
  7778. _this3.switchView(SidebarView.THUMBS)
  7779. });
  7780. this.outlineButton.addEventListener('click',
  7781. function() {
  7782. _this3.switchView(SidebarView.OUTLINE)
  7783. });
  7784. this.outlineButton.addEventListener('dblclick',
  7785. function() {
  7786. _this3.pdfOutlineViewer.toggleOutlineTree()
  7787. });
  7788. this.attachmentsButton.addEventListener('click',
  7789. function() {
  7790. _this3.switchView(SidebarView.ATTACHMENTS)
  7791. });
  7792. this.eventBus.on('outlineloaded',
  7793. function(evt) {
  7794. var outlineCount = evt.outlineCount;
  7795. _this3.outlineButton.disabled = !outlineCount;
  7796. if (outlineCount) {
  7797. _this3._showUINotification(SidebarView.OUTLINE)
  7798. } else if (_this3.active === SidebarView.OUTLINE) {
  7799. _this3.switchView(SidebarView.THUMBS)
  7800. }
  7801. });
  7802. this.eventBus.on('attachmentsloaded',
  7803. function(evt) {
  7804. var attachmentsCount = evt.attachmentsCount;
  7805. _this3.attachmentsButton.disabled = !attachmentsCount;
  7806. if (attachmentsCount) {
  7807. _this3._showUINotification(SidebarView.ATTACHMENTS)
  7808. } else if (_this3.active === SidebarView.ATTACHMENTS) {
  7809. _this3.switchView(SidebarView.THUMBS)
  7810. }
  7811. });
  7812. this.eventBus.on('presentationmodechanged',
  7813. function(evt) {
  7814. if (!evt.active && !evt.switchInProgress && _this3.isThumbnailViewVisible) {
  7815. _this3._updateThumbnailViewer()
  7816. }
  7817. })
  7818. }
  7819. },
  7820. {
  7821. key: 'visibleView',
  7822. get: function get() {
  7823. return this.isOpen ? this.active: SidebarView.NONE
  7824. }
  7825. },
  7826. {
  7827. key: 'isThumbnailViewVisible',
  7828. get: function get() {
  7829. return this.isOpen && this.active === SidebarView.THUMBS
  7830. }
  7831. },
  7832. {
  7833. key: 'isOutlineViewVisible',
  7834. get: function get() {
  7835. return this.isOpen && this.active === SidebarView.OUTLINE
  7836. }
  7837. },
  7838. {
  7839. key: 'isAttachmentsViewVisible',
  7840. get: function get() {
  7841. return this.isOpen && this.active === SidebarView.ATTACHMENTS
  7842. }
  7843. }]);
  7844. return PDFSidebar
  7845. } ();
  7846. exports.SidebarView = SidebarView;
  7847. exports.PDFSidebar = PDFSidebar
  7848. }), (function(module, exports, __webpack_require__) {
  7849. "use strict";
  7850. Object.defineProperty(exports, "__esModule", {
  7851. value: true
  7852. });
  7853. exports.PDFThumbnailView = undefined;
  7854. var _createClass = function() {
  7855. function defineProperties(target, props) {
  7856. for (var i = 0; i < props.length; i++) {
  7857. var descriptor = props[i];
  7858. descriptor.enumerable = descriptor.enumerable || false;
  7859. descriptor.configurable = true;
  7860. if ("value" in descriptor) descriptor.writable = true;
  7861. Object.defineProperty(target, descriptor.key, descriptor)
  7862. }
  7863. }
  7864. return function(Constructor, protoProps, staticProps) {
  7865. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  7866. if (staticProps) defineProperties(Constructor, staticProps);
  7867. return Constructor
  7868. }
  7869. } ();
  7870. var _pdfjsLib = __webpack_require__(1);
  7871. var _ui_utils = __webpack_require__(0);
  7872. var _pdf_rendering_queue = __webpack_require__(3);
  7873. function _classCallCheck(instance, Constructor) {
  7874. if (! (instance instanceof Constructor)) {
  7875. throw new TypeError("Cannot call a class as a function");
  7876. }
  7877. }
  7878. var MAX_NUM_SCALING_STEPS = 3;
  7879. var THUMBNAIL_CANVAS_BORDER_WIDTH = 1;
  7880. var THUMBNAIL_WIDTH = 98;
  7881. var TempImageFactory = function TempImageFactoryClosure() {
  7882. var tempCanvasCache = null;
  7883. return {
  7884. getCanvas: function getCanvas(width, height) {
  7885. var tempCanvas = tempCanvasCache;
  7886. if (!tempCanvas) {
  7887. tempCanvas = document.createElement('canvas');
  7888. tempCanvasCache = tempCanvas
  7889. }
  7890. tempCanvas.width = width;
  7891. tempCanvas.height = height;
  7892. tempCanvas.mozOpaque = true;
  7893. var ctx = tempCanvas.getContext('2d', {
  7894. alpha: false
  7895. });
  7896. ctx.save();
  7897. ctx.fillStyle = 'rgb(255, 255, 255)';
  7898. ctx.fillRect(0, 0, width, height);
  7899. ctx.restore();
  7900. return tempCanvas
  7901. },
  7902. destroyCanvas: function destroyCanvas() {
  7903. var tempCanvas = tempCanvasCache;
  7904. if (tempCanvas) {
  7905. tempCanvas.width = 0;
  7906. tempCanvas.height = 0
  7907. }
  7908. tempCanvasCache = null
  7909. }
  7910. }
  7911. } ();
  7912. var PDFThumbnailView = function() {
  7913. function PDFThumbnailView(_ref) {
  7914. var container = _ref.container,
  7915. id = _ref.id,
  7916. defaultViewport = _ref.defaultViewport,
  7917. linkService = _ref.linkService,
  7918. renderingQueue = _ref.renderingQueue,
  7919. _ref$disableCanvasToI = _ref.disableCanvasToImageConversion,
  7920. disableCanvasToImageConversion = _ref$disableCanvasToI === undefined ? false: _ref$disableCanvasToI,
  7921. _ref$l10n = _ref.l10n,
  7922. l10n = _ref$l10n === undefined ? _ui_utils.NullL10n: _ref$l10n;
  7923. _classCallCheck(this, PDFThumbnailView);
  7924. this.id = id;
  7925. this.renderingId = 'thumbnail' + id;
  7926. this.pageLabel = null;
  7927. this.pdfPage = null;
  7928. this.rotation = 0;
  7929. this.viewport = defaultViewport;
  7930. this.pdfPageRotate = defaultViewport.rotation;
  7931. this.linkService = linkService;
  7932. this.renderingQueue = renderingQueue;
  7933. this.renderTask = null;
  7934. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  7935. this.resume = null;
  7936. this.disableCanvasToImageConversion = disableCanvasToImageConversion;
  7937. this.pageWidth = this.viewport.width;
  7938. this.pageHeight = this.viewport.height;
  7939. this.pageRatio = this.pageWidth / this.pageHeight;
  7940. this.canvasWidth = THUMBNAIL_WIDTH;
  7941. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  7942. this.scale = this.canvasWidth / this.pageWidth;
  7943. this.l10n = l10n;
  7944. var anchor = document.createElement('a');
  7945. anchor.href = linkService.getAnchorUrl('#page=' + id);
  7946. this.l10n.get('thumb_page_title', {
  7947. page: id
  7948. },
  7949. 'Page {{page}}').then(function(msg) {
  7950. anchor.title = msg
  7951. });
  7952. anchor.onclick = function() {
  7953. linkService.page = id;
  7954. return false
  7955. };
  7956. this.anchor = anchor;
  7957. var div = document.createElement('div');
  7958. div.className = 'thumbnail';
  7959. div.setAttribute('data-page-number', this.id);
  7960. this.div = div;
  7961. if (id === 1) {
  7962. div.classList.add('selected')
  7963. }
  7964. var ring = document.createElement('div');
  7965. ring.className = 'thumbnailSelectionRing';
  7966. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  7967. ring.style.width = this.canvasWidth + borderAdjustment + 'px';
  7968. ring.style.height = this.canvasHeight + borderAdjustment + 'px';
  7969. this.ring = ring;
  7970. div.appendChild(ring);
  7971. anchor.appendChild(div);
  7972. container.appendChild(anchor)
  7973. }
  7974. _createClass(PDFThumbnailView, [{
  7975. key: 'setPdfPage',
  7976. value: function setPdfPage(pdfPage) {
  7977. this.pdfPage = pdfPage;
  7978. this.pdfPageRotate = pdfPage.rotate;
  7979. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  7980. this.viewport = pdfPage.getViewport(1, totalRotation);
  7981. this.reset()
  7982. }
  7983. },
  7984. {
  7985. key: 'reset',
  7986. value: function reset() {
  7987. this.cancelRendering();
  7988. this.pageWidth = this.viewport.width;
  7989. this.pageHeight = this.viewport.height;
  7990. this.pageRatio = this.pageWidth / this.pageHeight;
  7991. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  7992. this.scale = this.canvasWidth / this.pageWidth;
  7993. this.div.removeAttribute('data-loaded');
  7994. var ring = this.ring;
  7995. var childNodes = ring.childNodes;
  7996. for (var i = childNodes.length - 1; i >= 0; i--) {
  7997. ring.removeChild(childNodes[i])
  7998. }
  7999. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  8000. ring.style.width = this.canvasWidth + borderAdjustment + 'px';
  8001. ring.style.height = this.canvasHeight + borderAdjustment + 'px';
  8002. if (this.canvas) {
  8003. this.canvas.width = 0;
  8004. this.canvas.height = 0;
  8005. delete this.canvas
  8006. }
  8007. if (this.image) {
  8008. this.image.removeAttribute('src');
  8009. delete this.image
  8010. }
  8011. }
  8012. },
  8013. {
  8014. key: 'update',
  8015. value: function update(rotation) {
  8016. if (typeof rotation !== 'undefined') {
  8017. this.rotation = rotation
  8018. }
  8019. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  8020. this.viewport = this.viewport.clone({
  8021. scale: 1,
  8022. rotation: totalRotation
  8023. });
  8024. this.reset()
  8025. }
  8026. },
  8027. {
  8028. key: 'cancelRendering',
  8029. value: function cancelRendering() {
  8030. if (this.renderTask) {
  8031. this.renderTask.cancel();
  8032. this.renderTask = null
  8033. }
  8034. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  8035. this.resume = null
  8036. }
  8037. },
  8038. {
  8039. key: '_getPageDrawContext',
  8040. value: function _getPageDrawContext() {
  8041. var noCtxScale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  8042. var canvas = document.createElement('canvas');
  8043. this.canvas = canvas;
  8044. canvas.mozOpaque = true;
  8045. var ctx = canvas.getContext('2d', {
  8046. alpha: false
  8047. });
  8048. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  8049. canvas.width = this.canvasWidth * outputScale.sx | 0;
  8050. canvas.height = this.canvasHeight * outputScale.sy | 0;
  8051. canvas.style.width = this.canvasWidth + 'px';
  8052. canvas.style.height = this.canvasHeight + 'px';
  8053. if (!noCtxScale && outputScale.scaled) {
  8054. ctx.scale(outputScale.sx, outputScale.sy)
  8055. }
  8056. return ctx
  8057. }
  8058. },
  8059. {
  8060. key: '_convertCanvasToImage',
  8061. value: function _convertCanvasToImage() {
  8062. var _this = this;
  8063. if (!this.canvas) {
  8064. return
  8065. }
  8066. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  8067. return
  8068. }
  8069. var id = this.renderingId;
  8070. var className = 'thumbnailImage';
  8071. if (this.disableCanvasToImageConversion) {
  8072. this.canvas.id = id;
  8073. this.canvas.className = className;
  8074. this.l10n.get('thumb_page_canvas', {
  8075. page: this.pageId
  8076. },
  8077. 'Thumbnail of Page {{page}}').then(function(msg) {
  8078. _this.canvas.setAttribute('aria-label', msg)
  8079. });
  8080. this.div.setAttribute('data-loaded', true);
  8081. this.ring.appendChild(this.canvas);
  8082. return
  8083. }
  8084. var image = document.createElement('img');
  8085. image.id = id;
  8086. image.className = className;
  8087. this.l10n.get('thumb_page_canvas', {
  8088. page: this.pageId
  8089. },
  8090. 'Thumbnail of Page {{page}}').then(function(msg) {
  8091. image.setAttribute('aria-label', msg)
  8092. });
  8093. image.style.width = this.canvasWidth + 'px';
  8094. image.style.height = this.canvasHeight + 'px';
  8095. image.src = this.canvas.toDataURL();
  8096. this.image = image;
  8097. this.div.setAttribute('data-loaded', true);
  8098. this.ring.appendChild(image);
  8099. this.canvas.width = 0;
  8100. this.canvas.height = 0;
  8101. delete this.canvas
  8102. }
  8103. },
  8104. {
  8105. key: 'draw',
  8106. value: function draw() {
  8107. var _this2 = this;
  8108. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  8109. console.error('Must be in new state before drawing');
  8110. return Promise.resolve(undefined)
  8111. }
  8112. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  8113. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  8114. var finishRenderTask = function finishRenderTask(error) {
  8115. if (renderTask === _this2.renderTask) {
  8116. _this2.renderTask = null
  8117. }
  8118. if (error === 'cancelled' || error instanceof _pdfjsLib.RenderingCancelledException) {
  8119. renderCapability.resolve(undefined);
  8120. return
  8121. }
  8122. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  8123. _this2._convertCanvasToImage();
  8124. if (!error) {
  8125. renderCapability.resolve(undefined)
  8126. } else {
  8127. renderCapability.reject(error)
  8128. }
  8129. };
  8130. var ctx = this._getPageDrawContext();
  8131. var drawViewport = this.viewport.clone({
  8132. scale: this.scale
  8133. });
  8134. var renderContinueCallback = function renderContinueCallback(cont) {
  8135. if (!_this2.renderingQueue.isHighestPriority(_this2)) {
  8136. _this2.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  8137. _this2.resume = function() {
  8138. _this2.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  8139. cont()
  8140. };
  8141. return
  8142. }
  8143. cont()
  8144. };
  8145. var renderContext = {
  8146. canvasContext: ctx,
  8147. viewport: drawViewport
  8148. };
  8149. var renderTask = this.renderTask = this.pdfPage.render(renderContext);
  8150. renderTask.onContinue = renderContinueCallback;
  8151. renderTask.promise.then(function() {
  8152. finishRenderTask(null)
  8153. },
  8154. function(error) {
  8155. finishRenderTask(error)
  8156. });
  8157. return renderCapability.promise
  8158. }
  8159. },
  8160. {
  8161. key: 'setImage',
  8162. value: function setImage(pageView) {
  8163. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  8164. return
  8165. }
  8166. var img = pageView.canvas;
  8167. if (!img) {
  8168. return
  8169. }
  8170. if (!this.pdfPage) {
  8171. this.setPdfPage(pageView.pdfPage)
  8172. }
  8173. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  8174. var ctx = this._getPageDrawContext(true);
  8175. var canvas = ctx.canvas;
  8176. if (img.width <= 2 * canvas.width) {
  8177. ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height);
  8178. this._convertCanvasToImage();
  8179. return
  8180. }
  8181. var reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
  8182. var reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
  8183. var reducedImage = TempImageFactory.getCanvas(reducedWidth, reducedHeight);
  8184. var reducedImageCtx = reducedImage.getContext('2d');
  8185. while (reducedWidth > img.width || reducedHeight > img.height) {
  8186. reducedWidth >>= 1;
  8187. reducedHeight >>= 1
  8188. }
  8189. reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0, reducedWidth, reducedHeight);
  8190. while (reducedWidth > 2 * canvas.width) {
  8191. reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, reducedWidth >> 1, reducedHeight >> 1);
  8192. reducedWidth >>= 1;
  8193. reducedHeight >>= 1
  8194. }
  8195. ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height);
  8196. this._convertCanvasToImage()
  8197. }
  8198. },
  8199. {
  8200. key: 'setPageLabel',
  8201. value: function setPageLabel(label) {
  8202. var _this3 = this;
  8203. this.pageLabel = typeof label === 'string' ? label: null;
  8204. this.l10n.get('thumb_page_title', {
  8205. page: this.pageId
  8206. },
  8207. 'Page {{page}}').then(function(msg) {
  8208. _this3.anchor.title = msg
  8209. });
  8210. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  8211. return
  8212. }
  8213. this.l10n.get('thumb_page_canvas', {
  8214. page: this.pageId
  8215. },
  8216. 'Thumbnail of Page {{page}}').then(function(ariaLabel) {
  8217. if (_this3.image) {
  8218. _this3.image.setAttribute('aria-label', ariaLabel)
  8219. } else if (_this3.disableCanvasToImageConversion && _this3.canvas) {
  8220. _this3.canvas.setAttribute('aria-label', ariaLabel)
  8221. }
  8222. })
  8223. }
  8224. },
  8225. {
  8226. key: 'pageId',
  8227. get: function get() {
  8228. return this.pageLabel !== null ? this.pageLabel: this.id
  8229. }
  8230. }], [{
  8231. key: 'cleanup',
  8232. value: function cleanup() {
  8233. TempImageFactory.destroyCanvas()
  8234. }
  8235. }]);
  8236. return PDFThumbnailView
  8237. } ();
  8238. exports.PDFThumbnailView = PDFThumbnailView
  8239. }), (function(module, exports, __webpack_require__) {
  8240. "use strict";
  8241. Object.defineProperty(exports, "__esModule", {
  8242. value: true
  8243. });
  8244. exports.PDFThumbnailViewer = undefined;
  8245. var _createClass = function() {
  8246. function defineProperties(target, props) {
  8247. for (var i = 0; i < props.length; i++) {
  8248. var descriptor = props[i];
  8249. descriptor.enumerable = descriptor.enumerable || false;
  8250. descriptor.configurable = true;
  8251. if ("value" in descriptor) descriptor.writable = true;
  8252. Object.defineProperty(target, descriptor.key, descriptor)
  8253. }
  8254. }
  8255. return function(Constructor, protoProps, staticProps) {
  8256. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  8257. if (staticProps) defineProperties(Constructor, staticProps);
  8258. return Constructor
  8259. }
  8260. } ();
  8261. var _ui_utils = __webpack_require__(0);
  8262. var _pdf_thumbnail_view = __webpack_require__(25);
  8263. function _classCallCheck(instance, Constructor) {
  8264. if (! (instance instanceof Constructor)) {
  8265. throw new TypeError("Cannot call a class as a function");
  8266. }
  8267. }
  8268. var THUMBNAIL_SCROLL_MARGIN = -19;
  8269. var PDFThumbnailViewer = function() {
  8270. function PDFThumbnailViewer(_ref) {
  8271. var container = _ref.container,
  8272. linkService = _ref.linkService,
  8273. renderingQueue = _ref.renderingQueue,
  8274. _ref$l10n = _ref.l10n,
  8275. l10n = _ref$l10n === undefined ? _ui_utils.NullL10n: _ref$l10n;
  8276. _classCallCheck(this, PDFThumbnailViewer);
  8277. this.container = container;
  8278. this.linkService = linkService;
  8279. this.renderingQueue = renderingQueue;
  8280. this.l10n = l10n;
  8281. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdated.bind(this));
  8282. this._resetView()
  8283. }
  8284. _createClass(PDFThumbnailViewer, [{
  8285. key: '_scrollUpdated',
  8286. value: function _scrollUpdated() {
  8287. this.renderingQueue.renderHighestPriority()
  8288. }
  8289. },
  8290. {
  8291. key: 'getThumbnail',
  8292. value: function getThumbnail(index) {
  8293. return this._thumbnails[index]
  8294. }
  8295. },
  8296. {
  8297. key: '_getVisibleThumbs',
  8298. value: function _getVisibleThumbs() {
  8299. return (0, _ui_utils.getVisibleElements)(this.container, this._thumbnails)
  8300. }
  8301. },
  8302. {
  8303. key: 'scrollThumbnailIntoView',
  8304. value: function scrollThumbnailIntoView(page) {
  8305. var selected = document.querySelector('.thumbnail.selected');
  8306. if (selected) {
  8307. selected.classList.remove('selected')
  8308. }
  8309. var thumbnail = document.querySelector('div.thumbnail[data-page-number="' + page + '"]');
  8310. if (thumbnail) {
  8311. thumbnail.classList.add('selected')
  8312. }
  8313. var visibleThumbs = this._getVisibleThumbs();
  8314. var numVisibleThumbs = visibleThumbs.views.length;
  8315. if (numVisibleThumbs > 0) {
  8316. var first = visibleThumbs.first.id;
  8317. var last = numVisibleThumbs > 1 ? visibleThumbs.last.id: first;
  8318. if (page <= first || page >= last) { (0, _ui_utils.scrollIntoView)(thumbnail, {
  8319. top: THUMBNAIL_SCROLL_MARGIN
  8320. })
  8321. }
  8322. }
  8323. }
  8324. },
  8325. {
  8326. key: 'cleanup',
  8327. value: function cleanup() {
  8328. _pdf_thumbnail_view.PDFThumbnailView.cleanup()
  8329. }
  8330. },
  8331. {
  8332. key: '_resetView',
  8333. value: function _resetView() {
  8334. this._thumbnails = [];
  8335. this._pageLabels = null;
  8336. this._pagesRotation = 0;
  8337. this._pagesRequests = [];
  8338. this.container.textContent = ''
  8339. }
  8340. },
  8341. {
  8342. key: 'setDocument',
  8343. value: function setDocument(pdfDocument) {
  8344. var _this = this;
  8345. if (this.pdfDocument) {
  8346. this._cancelRendering();
  8347. this._resetView()
  8348. }
  8349. this.pdfDocument = pdfDocument;
  8350. if (!pdfDocument) {
  8351. return
  8352. }
  8353. pdfDocument.getPage(1).then(function(firstPage) {
  8354. var pagesCount = pdfDocument.numPages;
  8355. var viewport = firstPage.getViewport(1.0);
  8356. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  8357. var thumbnail = new _pdf_thumbnail_view.PDFThumbnailView({
  8358. container: _this.container,
  8359. id: pageNum,
  8360. defaultViewport: viewport.clone(),
  8361. linkService: _this.linkService,
  8362. renderingQueue: _this.renderingQueue,
  8363. disableCanvasToImageConversion: false,
  8364. l10n: _this.l10n
  8365. });
  8366. _this._thumbnails.push(thumbnail)
  8367. }
  8368. }).
  8369. catch(function(reason) {
  8370. console.error('Unable to initialize thumbnail viewer', reason)
  8371. })
  8372. }
  8373. },
  8374. {
  8375. key: '_cancelRendering',
  8376. value: function _cancelRendering() {
  8377. for (var i = 0,
  8378. ii = this._thumbnails.length; i < ii; i++) {
  8379. if (this._thumbnails[i]) {
  8380. this._thumbnails[i].cancelRendering()
  8381. }
  8382. }
  8383. }
  8384. },
  8385. {
  8386. key: 'setPageLabels',
  8387. value: function setPageLabels(labels) {
  8388. if (!this.pdfDocument) {
  8389. return
  8390. }
  8391. if (!labels) {
  8392. this._pageLabels = null
  8393. } else if (! (labels instanceof Array && this.pdfDocument.numPages === labels.length)) {
  8394. this._pageLabels = null;
  8395. console.error('PDFThumbnailViewer_setPageLabels: Invalid page labels.')
  8396. } else {
  8397. this._pageLabels = labels
  8398. }
  8399. for (var i = 0,
  8400. ii = this._thumbnails.length; i < ii; i++) {
  8401. var label = this._pageLabels && this._pageLabels[i];
  8402. this._thumbnails[i].setPageLabel(label)
  8403. }
  8404. }
  8405. },
  8406. {
  8407. key: '_ensurePdfPageLoaded',
  8408. value: function _ensurePdfPageLoaded(thumbView) {
  8409. var _this2 = this;
  8410. if (thumbView.pdfPage) {
  8411. return Promise.resolve(thumbView.pdfPage)
  8412. }
  8413. var pageNumber = thumbView.id;
  8414. if (this._pagesRequests[pageNumber]) {
  8415. return this._pagesRequests[pageNumber]
  8416. }
  8417. var promise = this.pdfDocument.getPage(pageNumber).then(function(pdfPage) {
  8418. thumbView.setPdfPage(pdfPage);
  8419. _this2._pagesRequests[pageNumber] = null;
  8420. return pdfPage
  8421. }).
  8422. catch(function(reason) {
  8423. console.error('Unable to get page for thumb view', reason);
  8424. _this2._pagesRequests[pageNumber] = null
  8425. });
  8426. this._pagesRequests[pageNumber] = promise;
  8427. return promise
  8428. }
  8429. },
  8430. {
  8431. key: 'forceRendering',
  8432. value: function forceRendering() {
  8433. var _this3 = this;
  8434. var visibleThumbs = this._getVisibleThumbs();
  8435. var thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, this.scroll.down);
  8436. if (thumbView) {
  8437. this._ensurePdfPageLoaded(thumbView).then(function() {
  8438. _this3.renderingQueue.renderView(thumbView)
  8439. });
  8440. return true
  8441. }
  8442. return false
  8443. }
  8444. },
  8445. {
  8446. key: 'pagesRotation',
  8447. get: function get() {
  8448. return this._pagesRotation
  8449. },
  8450. set: function set(rotation) {
  8451. if (! (typeof rotation === 'number' && rotation % 90 === 0)) {
  8452. throw new Error('Invalid thumbnails rotation angle.');
  8453. }
  8454. if (!this.pdfDocument) {
  8455. return
  8456. }
  8457. this._pagesRotation = rotation;
  8458. for (var i = 0,
  8459. ii = this._thumbnails.length; i < ii; i++) {
  8460. this._thumbnails[i].update(rotation)
  8461. }
  8462. }
  8463. }]);
  8464. return PDFThumbnailViewer
  8465. } ();
  8466. exports.PDFThumbnailViewer = PDFThumbnailViewer
  8467. }), (function(module, exports, __webpack_require__) {
  8468. "use strict";
  8469. Object.defineProperty(exports, "__esModule", {
  8470. value: true
  8471. });
  8472. exports.PDFViewer = exports.PresentationModeState = undefined;
  8473. var _createClass = function() {
  8474. function defineProperties(target, props) {
  8475. for (var i = 0; i < props.length; i++) {
  8476. var descriptor = props[i];
  8477. descriptor.enumerable = descriptor.enumerable || false;
  8478. descriptor.configurable = true;
  8479. if ("value" in descriptor) descriptor.writable = true;
  8480. Object.defineProperty(target, descriptor.key, descriptor)
  8481. }
  8482. }
  8483. return function(Constructor, protoProps, staticProps) {
  8484. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  8485. if (staticProps) defineProperties(Constructor, staticProps);
  8486. return Constructor
  8487. }
  8488. } ();
  8489. var _pdfjsLib = __webpack_require__(1);
  8490. var _ui_utils = __webpack_require__(0);
  8491. var _pdf_rendering_queue = __webpack_require__(3);
  8492. var _annotation_layer_builder = __webpack_require__(11);
  8493. var _dom_events = __webpack_require__(2);
  8494. var _pdf_page_view = __webpack_require__(22);
  8495. var _pdf_link_service = __webpack_require__(5);
  8496. var _text_layer_builder = __webpack_require__(30);
  8497. function _classCallCheck(instance, Constructor) {
  8498. if (! (instance instanceof Constructor)) {
  8499. throw new TypeError("Cannot call a class as a function");
  8500. }
  8501. }
  8502. var PresentationModeState = {
  8503. UNKNOWN: 0,
  8504. NORMAL: 1,
  8505. CHANGING: 2,
  8506. FULLSCREEN: 3
  8507. };
  8508. var DEFAULT_CACHE_SIZE = 10;
  8509. function PDFPageViewBuffer(size) {
  8510. var data = [];
  8511. this.push = function cachePush(view) {
  8512. var i = data.indexOf(view);
  8513. if (i >= 0) {
  8514. data.splice(i, 1)
  8515. }
  8516. data.push(view);
  8517. if (data.length > size) {
  8518. data.shift().destroy()
  8519. }
  8520. };
  8521. this.resize = function(newSize) {
  8522. size = newSize;
  8523. while (data.length > size) {
  8524. data.shift().destroy()
  8525. }
  8526. }
  8527. }
  8528. function isSameScale(oldScale, newScale) {
  8529. if (newScale === oldScale) {
  8530. return true
  8531. }
  8532. if (Math.abs(newScale - oldScale) < 1e-15) {
  8533. return true
  8534. }
  8535. return false
  8536. }
  8537. function isPortraitOrientation(size) {
  8538. return size.width <= size.height
  8539. }
  8540. var PDFViewer = function() {
  8541. function PDFViewer(options) {
  8542. _classCallCheck(this, PDFViewer);
  8543. this.container = options.container;
  8544. this.viewer = options.viewer || options.container.firstElementChild;
  8545. this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)();
  8546. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  8547. this.downloadManager = options.downloadManager || null;
  8548. this.removePageBorders = options.removePageBorders || false;
  8549. this.enhanceTextSelection = options.enhanceTextSelection || false;
  8550. this.renderInteractiveForms = options.renderInteractiveForms || false;
  8551. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  8552. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  8553. this.l10n = options.l10n || _ui_utils.NullL10n;
  8554. this.defaultRenderingQueue = !options.renderingQueue;
  8555. if (this.defaultRenderingQueue) {
  8556. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  8557. this.renderingQueue.setViewer(this)
  8558. } else {
  8559. this.renderingQueue = options.renderingQueue
  8560. }
  8561. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  8562. this.presentationModeState = PresentationModeState.UNKNOWN;
  8563. this._resetView();
  8564. if (this.removePageBorders) {
  8565. this.viewer.classList.add('removePageBorders')
  8566. }
  8567. }
  8568. _createClass(PDFViewer, [{
  8569. key: 'getPageView',
  8570. value: function getPageView(index) {
  8571. return this._pages[index]
  8572. }
  8573. },
  8574. {
  8575. key: '_setCurrentPageNumber',
  8576. value: function _setCurrentPageNumber(val) {
  8577. var resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  8578. if (this._currentPageNumber === val) {
  8579. if (resetCurrentPageView) {
  8580. this._resetCurrentPageView()
  8581. }
  8582. return
  8583. }
  8584. if (! (0 < val && val <= this.pagesCount)) {
  8585. console.error('PDFViewer._setCurrentPageNumber: "' + val + '" is out of bounds.');
  8586. return
  8587. }
  8588. var arg = {
  8589. source: this,
  8590. pageNumber: val,
  8591. pageLabel: this._pageLabels && this._pageLabels[val - 1]
  8592. };
  8593. this._currentPageNumber = val;
  8594. this.eventBus.dispatch('pagechanging', arg);
  8595. this.eventBus.dispatch('pagechange', arg);
  8596. if (resetCurrentPageView) {
  8597. this._resetCurrentPageView()
  8598. }
  8599. }
  8600. },
  8601. {
  8602. key: 'setDocument',
  8603. value: function setDocument(pdfDocument) {
  8604. var _this = this;
  8605. if (this.pdfDocument) {
  8606. this._cancelRendering();
  8607. this._resetView()
  8608. }
  8609. this.pdfDocument = pdfDocument;
  8610. if (!pdfDocument) {
  8611. return
  8612. }
  8613. var pagesCount = pdfDocument.numPages;
  8614. var pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
  8615. this.pagesPromise = pagesCapability.promise;
  8616. pagesCapability.promise.then(function() {
  8617. _this._pageViewsReady = true;
  8618. _this.eventBus.dispatch('pagesloaded', {
  8619. source: _this,
  8620. pagesCount: pagesCount
  8621. })
  8622. });
  8623. var isOnePageRenderedResolved = false;
  8624. var onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  8625. this.onePageRendered = onePageRenderedCapability.promise;
  8626. var bindOnAfterAndBeforeDraw = function bindOnAfterAndBeforeDraw(pageView) {
  8627. pageView.onBeforeDraw = function() {
  8628. _this._buffer.push(pageView)
  8629. };
  8630. pageView.onAfterDraw = function() {
  8631. if (!isOnePageRenderedResolved) {
  8632. isOnePageRenderedResolved = true;
  8633. onePageRenderedCapability.resolve()
  8634. }
  8635. }
  8636. };
  8637. var firstPagePromise = pdfDocument.getPage(1);
  8638. this.firstPagePromise = firstPagePromise;
  8639. firstPagePromise.then(function(pdfPage) {
  8640. var scale = _this.currentScale;
  8641. var viewport = pdfPage.getViewport(scale * _ui_utils.CSS_UNITS);
  8642. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  8643. var textLayerFactory = null;
  8644. if (!_pdfjsLib.PDFJS.disableTextLayer) {
  8645. textLayerFactory = _this
  8646. }
  8647. var pageView = new _pdf_page_view.PDFPageView({
  8648. container: _this.viewer,
  8649. eventBus: _this.eventBus,
  8650. id: pageNum,
  8651. scale: scale,
  8652. defaultViewport: viewport.clone(),
  8653. renderingQueue: _this.renderingQueue,
  8654. textLayerFactory: textLayerFactory,
  8655. annotationLayerFactory: _this,
  8656. enhanceTextSelection: _this.enhanceTextSelection,
  8657. renderInteractiveForms: _this.renderInteractiveForms,
  8658. renderer: _this.renderer,
  8659. l10n: _this.l10n
  8660. });
  8661. bindOnAfterAndBeforeDraw(pageView);
  8662. _this._pages.push(pageView)
  8663. }
  8664. onePageRenderedCapability.promise.then(function() {
  8665. if (_pdfjsLib.PDFJS.disableAutoFetch) {
  8666. pagesCapability.resolve();
  8667. return
  8668. }
  8669. var getPagesLeft = pagesCount;
  8670. var _loop = function _loop(_pageNum) {
  8671. pdfDocument.getPage(_pageNum).then(function(pdfPage) {
  8672. var pageView = _this._pages[_pageNum - 1];
  8673. if (!pageView.pdfPage) {
  8674. pageView.setPdfPage(pdfPage)
  8675. }
  8676. _this.linkService.cachePageRef(_pageNum, pdfPage.ref);
  8677. if (--getPagesLeft === 0) {
  8678. pagesCapability.resolve()
  8679. }
  8680. },
  8681. function(reason) {
  8682. console.error('Unable to get page ' + _pageNum + ' to initialize viewer', reason);
  8683. if (--getPagesLeft === 0) {
  8684. pagesCapability.resolve()
  8685. }
  8686. })
  8687. };
  8688. for (var _pageNum = 1; _pageNum <= pagesCount; ++_pageNum) {
  8689. _loop(_pageNum)
  8690. }
  8691. });
  8692. _this.eventBus.dispatch('pagesinit', {
  8693. source: _this
  8694. });
  8695. if (_this.defaultRenderingQueue) {
  8696. _this.update()
  8697. }
  8698. if (_this.findController) {
  8699. _this.findController.resolveFirstPage()
  8700. }
  8701. }).
  8702. catch(function(reason) {
  8703. console.error('Unable to initialize viewer', reason)
  8704. })
  8705. }
  8706. },
  8707. {
  8708. key: 'setPageLabels',
  8709. value: function setPageLabels(labels) {
  8710. if (!this.pdfDocument) {
  8711. return
  8712. }
  8713. if (!labels) {
  8714. this._pageLabels = null
  8715. } else if (! (labels instanceof Array && this.pdfDocument.numPages === labels.length)) {
  8716. this._pageLabels = null;
  8717. console.error('PDFViewer.setPageLabels: Invalid page labels.')
  8718. } else {
  8719. this._pageLabels = labels
  8720. }
  8721. for (var i = 0,
  8722. ii = this._pages.length; i < ii; i++) {
  8723. var pageView = this._pages[i];
  8724. var label = this._pageLabels && this._pageLabels[i];
  8725. pageView.setPageLabel(label)
  8726. }
  8727. }
  8728. },
  8729. {
  8730. key: '_resetView',
  8731. value: function _resetView() {
  8732. this._pages = [];
  8733. this._currentPageNumber = 1;
  8734. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  8735. this._currentScaleValue = null;
  8736. this._pageLabels = null;
  8737. this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  8738. this._location = null;
  8739. this._pagesRotation = 0;
  8740. this._pagesRequests = [];
  8741. this._pageViewsReady = false;
  8742. this.viewer.textContent = ''
  8743. }
  8744. },
  8745. {
  8746. key: '_scrollUpdate',
  8747. value: function _scrollUpdate() {
  8748. if (this.pagesCount === 0) {
  8749. return
  8750. }
  8751. this.update()
  8752. }
  8753. },
  8754. {
  8755. key: '_setScaleDispatchEvent',
  8756. value: function _setScaleDispatchEvent(newScale, newValue) {
  8757. var preset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  8758. var arg = {
  8759. source: this,
  8760. scale: newScale,
  8761. presetValue: preset ? newValue: undefined
  8762. };
  8763. this.eventBus.dispatch('scalechanging', arg);
  8764. this.eventBus.dispatch('scalechange', arg)
  8765. }
  8766. },
  8767. {
  8768. key: '_setScaleUpdatePages',
  8769. value: function _setScaleUpdatePages(newScale, newValue) {
  8770. var noScroll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  8771. var preset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  8772. this._currentScaleValue = newValue.toString();
  8773. if (isSameScale(this._currentScale, newScale)) {
  8774. if (preset) {
  8775. this._setScaleDispatchEvent(newScale, newValue, true)
  8776. }
  8777. return
  8778. }
  8779. for (var i = 0,
  8780. ii = this._pages.length; i < ii; i++) {
  8781. this._pages[i].update(newScale)
  8782. }
  8783. this._currentScale = newScale;
  8784. if (!noScroll) {
  8785. var page = this._currentPageNumber,
  8786. dest = void 0;
  8787. if (this._location && !_pdfjsLib.PDFJS.ignoreCurrentPositionOnZoom && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  8788. page = this._location.pageNumber;
  8789. dest = [null, {
  8790. name: 'XYZ'
  8791. },
  8792. this._location.left, this._location.top, null]
  8793. }
  8794. this.scrollPageIntoView({
  8795. pageNumber: page,
  8796. destArray: dest,
  8797. allowNegativeOffset: true
  8798. })
  8799. }
  8800. this._setScaleDispatchEvent(newScale, newValue, preset);
  8801. if (this.defaultRenderingQueue) {
  8802. this.update()
  8803. }
  8804. }
  8805. },
  8806. {
  8807. key: '_setScale',
  8808. value: function _setScale(value) {
  8809. var noScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  8810. var scale = parseFloat(value);
  8811. if (scale > 0) {
  8812. this._setScaleUpdatePages(scale, value, noScroll, false)
  8813. } else {
  8814. var currentPage = this._pages[this._currentPageNumber - 1];
  8815. if (!currentPage) {
  8816. return
  8817. }
  8818. var hPadding = this.isInPresentationMode || this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  8819. var vPadding = this.isInPresentationMode || this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  8820. var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale;
  8821. var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  8822. switch (value) {
  8823. case 'page-actual':
  8824. scale = 1;
  8825. break;
  8826. case 'page-width':
  8827. scale = pageWidthScale;
  8828. break;
  8829. case 'page-height':
  8830. scale = pageHeightScale;
  8831. break;
  8832. case 'page-fit':
  8833. scale = Math.min(pageWidthScale, pageHeightScale);
  8834. break;
  8835. case 'auto':
  8836. var isLandscape = currentPage.width > currentPage.height;
  8837. var horizontalScale = isLandscape ? Math.min(pageHeightScale, pageWidthScale) : pageWidthScale;
  8838. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  8839. break;
  8840. default:
  8841. console.error('PDFViewer._setScale: "' + value + '" is an unknown zoom value.');
  8842. return
  8843. }
  8844. this._setScaleUpdatePages(scale, value, noScroll, true)
  8845. }
  8846. }
  8847. },
  8848. {
  8849. key: '_resetCurrentPageView',
  8850. value: function _resetCurrentPageView() {
  8851. if (this.isInPresentationMode) {
  8852. this._setScale(this._currentScaleValue, true)
  8853. }
  8854. var pageView = this._pages[this._currentPageNumber - 1]; (0, _ui_utils.scrollIntoView)(pageView.div)
  8855. }
  8856. },
  8857. {
  8858. key: 'scrollPageIntoView',
  8859. value: function scrollPageIntoView(params) {
  8860. if (!this.pdfDocument) {
  8861. return
  8862. }
  8863. if (arguments.length > 1 || typeof params === 'number') {
  8864. console.warn('Call of scrollPageIntoView() with obsolete signature.');
  8865. var paramObj = {};
  8866. if (typeof params === 'number') {
  8867. paramObj.pageNumber = params
  8868. }
  8869. if (arguments[1] instanceof Array) {
  8870. paramObj.destArray = arguments[1]
  8871. }
  8872. params = paramObj
  8873. }
  8874. var pageNumber = params.pageNumber || 0;
  8875. var dest = params.destArray || null;
  8876. var allowNegativeOffset = params.allowNegativeOffset || false;
  8877. if (this.isInPresentationMode || !dest) {
  8878. this._setCurrentPageNumber(pageNumber, true);
  8879. return
  8880. }
  8881. var pageView = this._pages[pageNumber - 1];
  8882. if (!pageView) {
  8883. console.error('PDFViewer.scrollPageIntoView: Invalid "pageNumber" parameter.');
  8884. return
  8885. }
  8886. var x = 0,
  8887. y = 0;
  8888. var width = 0,
  8889. height = 0,
  8890. widthScale = void 0,
  8891. heightScale = void 0;
  8892. var changeOrientation = pageView.rotation % 180 === 0 ? false: true;
  8893. var pageWidth = (changeOrientation ? pageView.height: pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;
  8894. var pageHeight = (changeOrientation ? pageView.width: pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;
  8895. var scale = 0;
  8896. switch (dest[1].name) {
  8897. case 'XYZ':
  8898. x = dest[2];
  8899. y = dest[3];
  8900. scale = dest[4];
  8901. x = x !== null ? x: 0;
  8902. y = y !== null ? y: pageHeight;
  8903. break;
  8904. case 'Fit':
  8905. case 'FitB':
  8906. scale = 'page-fit';
  8907. break;
  8908. case 'FitH':
  8909. case 'FitBH':
  8910. y = dest[2];
  8911. scale = 'page-width';
  8912. if (y === null && this._location) {
  8913. x = this._location.left;
  8914. y = this._location.top
  8915. }
  8916. break;
  8917. case 'FitV':
  8918. case 'FitBV':
  8919. x = dest[2];
  8920. width = pageWidth;
  8921. height = pageHeight;
  8922. scale = 'page-height';
  8923. break;
  8924. case 'FitR':
  8925. x = dest[2];
  8926. y = dest[3];
  8927. width = dest[4] - x;
  8928. height = dest[5] - y;
  8929. var hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  8930. var vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  8931. widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;
  8932. heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;
  8933. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  8934. break;
  8935. default:
  8936. console.error('PDFViewer.scrollPageIntoView: "' + dest[1].name + '" ' + 'is not a valid destination type.');
  8937. return
  8938. }
  8939. if (scale && scale !== this._currentScale) {
  8940. this.currentScaleValue = scale
  8941. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  8942. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE
  8943. }
  8944. if (scale === 'page-fit' && !dest[4]) { (0, _ui_utils.scrollIntoView)(pageView.div);
  8945. return
  8946. }
  8947. var boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  8948. var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  8949. var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  8950. if (!allowNegativeOffset) {
  8951. left = Math.max(left, 0);
  8952. top = Math.max(top, 0)
  8953. } (0, _ui_utils.scrollIntoView)(pageView.div, {
  8954. left: left,
  8955. top: top
  8956. })
  8957. }
  8958. },
  8959. {
  8960. key: '_updateLocation',
  8961. value: function _updateLocation(firstPage) {
  8962. var currentScale = this._currentScale;
  8963. var currentScaleValue = this._currentScaleValue;
  8964. var normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  8965. var pageNumber = firstPage.id;
  8966. var pdfOpenParams = '#page=' + pageNumber;
  8967. pdfOpenParams += '&zoom=' + normalizedScaleValue;
  8968. var currentPageView = this._pages[pageNumber - 1];
  8969. var container = this.container;
  8970. var topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  8971. var intLeft = Math.round(topLeft[0]);
  8972. var intTop = Math.round(topLeft[1]);
  8973. pdfOpenParams += ',' + intLeft + ',' + intTop;
  8974. this._location = {
  8975. pageNumber: pageNumber,
  8976. scale: normalizedScaleValue,
  8977. top: intTop,
  8978. left: intLeft,
  8979. pdfOpenParams: pdfOpenParams
  8980. }
  8981. }
  8982. },
  8983. {
  8984. key: 'update',
  8985. value: function update() {
  8986. var visible = this._getVisiblePages();
  8987. var visiblePages = visible.views;
  8988. if (visiblePages.length === 0) {
  8989. return
  8990. }
  8991. var suggestedCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * visiblePages.length + 1);
  8992. this._buffer.resize(suggestedCacheSize);
  8993. this.renderingQueue.renderHighestPriority(visible);
  8994. var currentId = this._currentPageNumber;
  8995. var firstPage = visible.first;
  8996. var stillFullyVisible = false;
  8997. for (var i = 0,
  8998. ii = visiblePages.length; i < ii; ++i) {
  8999. var page = visiblePages[i];
  9000. if (page.percent < 100) {
  9001. break
  9002. }
  9003. if (page.id === currentId) {
  9004. stillFullyVisible = true;
  9005. break
  9006. }
  9007. }
  9008. if (!stillFullyVisible) {
  9009. currentId = visiblePages[0].id
  9010. }
  9011. if (!this.isInPresentationMode) {
  9012. this._setCurrentPageNumber(currentId)
  9013. }
  9014. this._updateLocation(firstPage);
  9015. this.eventBus.dispatch('updateviewarea', {
  9016. source: this,
  9017. location: this._location
  9018. })
  9019. }
  9020. },
  9021. {
  9022. key: 'containsElement',
  9023. value: function containsElement(element) {
  9024. return this.container.contains(element)
  9025. }
  9026. },
  9027. {
  9028. key: 'focus',
  9029. value: function focus() {
  9030. this.container.focus()
  9031. }
  9032. },
  9033. {
  9034. key: '_getVisiblePages',
  9035. value: function _getVisiblePages() {
  9036. if (!this.isInPresentationMode) {
  9037. return (0, _ui_utils.getVisibleElements)(this.container, this._pages, true)
  9038. }
  9039. var visible = [];
  9040. var currentPage = this._pages[this._currentPageNumber - 1];
  9041. visible.push({
  9042. id: currentPage.id,
  9043. view: currentPage
  9044. });
  9045. return {
  9046. first: currentPage,
  9047. last: currentPage,
  9048. views: visible
  9049. }
  9050. }
  9051. },
  9052. {
  9053. key: 'cleanup',
  9054. value: function cleanup() {
  9055. for (var i = 0,
  9056. ii = this._pages.length; i < ii; i++) {
  9057. if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  9058. this._pages[i].reset()
  9059. }
  9060. }
  9061. }
  9062. },
  9063. {
  9064. key: '_cancelRendering',
  9065. value: function _cancelRendering() {
  9066. for (var i = 0,
  9067. ii = this._pages.length; i < ii; i++) {
  9068. if (this._pages[i]) {
  9069. this._pages[i].cancelRendering()
  9070. }
  9071. }
  9072. }
  9073. },
  9074. {
  9075. key: '_ensurePdfPageLoaded',
  9076. value: function _ensurePdfPageLoaded(pageView) {
  9077. var _this2 = this;
  9078. if (pageView.pdfPage) {
  9079. return Promise.resolve(pageView.pdfPage)
  9080. }
  9081. var pageNumber = pageView.id;
  9082. if (this._pagesRequests[pageNumber]) {
  9083. return this._pagesRequests[pageNumber]
  9084. }
  9085. var promise = this.pdfDocument.getPage(pageNumber).then(function(pdfPage) {
  9086. if (!pageView.pdfPage) {
  9087. pageView.setPdfPage(pdfPage)
  9088. }
  9089. _this2._pagesRequests[pageNumber] = null;
  9090. return pdfPage
  9091. }).
  9092. catch(function(reason) {
  9093. console.error('Unable to get page for page view', reason);
  9094. _this2._pagesRequests[pageNumber] = null
  9095. });
  9096. this._pagesRequests[pageNumber] = promise;
  9097. return promise
  9098. }
  9099. },
  9100. {
  9101. key: 'forceRendering',
  9102. value: function forceRendering(currentlyVisiblePages) {
  9103. var _this3 = this;
  9104. var visiblePages = currentlyVisiblePages || this._getVisiblePages();
  9105. var pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, this.scroll.down);
  9106. if (pageView) {
  9107. this._ensurePdfPageLoaded(pageView).then(function() {
  9108. _this3.renderingQueue.renderView(pageView)
  9109. });
  9110. return true
  9111. }
  9112. return false
  9113. }
  9114. },
  9115. {
  9116. key: 'getPageTextContent',
  9117. value: function getPageTextContent(pageIndex) {
  9118. return this.pdfDocument.getPage(pageIndex + 1).then(function(page) {
  9119. return page.getTextContent({
  9120. normalizeWhitespace: true
  9121. })
  9122. })
  9123. }
  9124. },
  9125. {
  9126. key: 'createTextLayerBuilder',
  9127. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  9128. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9129. return new _text_layer_builder.TextLayerBuilder({
  9130. textLayerDiv: textLayerDiv,
  9131. eventBus: this.eventBus,
  9132. pageIndex: pageIndex,
  9133. viewport: viewport,
  9134. findController: this.isInPresentationMode ? null: this.findController,
  9135. enhanceTextSelection: this.isInPresentationMode ? false: enhanceTextSelection
  9136. })
  9137. }
  9138. },
  9139. {
  9140. key: 'createAnnotationLayerBuilder',
  9141. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  9142. var renderInteractiveForms = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  9143. var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
  9144. return new _annotation_layer_builder.AnnotationLayerBuilder({
  9145. pageDiv: pageDiv,
  9146. pdfPage: pdfPage,
  9147. renderInteractiveForms: renderInteractiveForms,
  9148. linkService: this.linkService,
  9149. downloadManager: this.downloadManager,
  9150. l10n: l10n
  9151. })
  9152. }
  9153. },
  9154. {
  9155. key: 'setFindController',
  9156. value: function setFindController(findController) {
  9157. this.findController = findController
  9158. }
  9159. },
  9160. {
  9161. key: 'getPagesOverview',
  9162. value: function getPagesOverview() {
  9163. var pagesOverview = this._pages.map(function(pageView) {
  9164. var viewport = pageView.pdfPage.getViewport(1);
  9165. return {
  9166. width: viewport.width,
  9167. height: viewport.height,
  9168. rotation: viewport.rotation
  9169. }
  9170. });
  9171. if (!this.enablePrintAutoRotate) {
  9172. return pagesOverview
  9173. }
  9174. var isFirstPagePortrait = isPortraitOrientation(pagesOverview[0]);
  9175. return pagesOverview.map(function(size) {
  9176. if (isFirstPagePortrait === isPortraitOrientation(size)) {
  9177. return size
  9178. }
  9179. return {
  9180. width: size.height,
  9181. height: size.width,
  9182. rotation: (size.rotation + 90) % 360
  9183. }
  9184. })
  9185. }
  9186. },
  9187. {
  9188. key: 'pagesCount',
  9189. get: function get() {
  9190. return this._pages.length
  9191. }
  9192. },
  9193. {
  9194. key: 'pageViewsReady',
  9195. get: function get() {
  9196. return this._pageViewsReady
  9197. }
  9198. },
  9199. {
  9200. key: 'currentPageNumber',
  9201. get: function get() {
  9202. return this._currentPageNumber
  9203. },
  9204. set: function set(val) {
  9205. if ((val | 0) !== val) {
  9206. throw new Error('Invalid page number.');
  9207. }
  9208. if (!this.pdfDocument) {
  9209. return
  9210. }
  9211. this._setCurrentPageNumber(val, true)
  9212. }
  9213. },
  9214. {
  9215. key: 'currentPageLabel',
  9216. get: function get() {
  9217. return this._pageLabels && this._pageLabels[this._currentPageNumber - 1]
  9218. },
  9219. set: function set(val) {
  9220. var pageNumber = val | 0;
  9221. if (this._pageLabels) {
  9222. var i = this._pageLabels.indexOf(val);
  9223. if (i >= 0) {
  9224. pageNumber = i + 1
  9225. }
  9226. }
  9227. this.currentPageNumber = pageNumber
  9228. }
  9229. },
  9230. {
  9231. key: 'currentScale',
  9232. get: function get() {
  9233. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale: _ui_utils.DEFAULT_SCALE
  9234. },
  9235. set: function set(val) {
  9236. if (isNaN(val)) {
  9237. throw new Error('Invalid numeric scale');
  9238. }
  9239. if (!this.pdfDocument) {
  9240. return
  9241. }
  9242. this._setScale(val, false)
  9243. }
  9244. },
  9245. {
  9246. key: 'currentScaleValue',
  9247. get: function get() {
  9248. return this._currentScaleValue
  9249. },
  9250. set: function set(val) {
  9251. if (!this.pdfDocument) {
  9252. return
  9253. }
  9254. this._setScale(val, false)
  9255. }
  9256. },
  9257. {
  9258. key: 'pagesRotation',
  9259. get: function get() {
  9260. return this._pagesRotation
  9261. },
  9262. set: function set(rotation) {
  9263. if (! (typeof rotation === 'number' && rotation % 90 === 0)) {
  9264. throw new Error('Invalid pages rotation angle.');
  9265. }
  9266. if (!this.pdfDocument) {
  9267. return
  9268. }
  9269. this._pagesRotation = rotation;
  9270. for (var i = 0,
  9271. ii = this._pages.length; i < ii; i++) {
  9272. var pageView = this._pages[i];
  9273. pageView.update(pageView.scale, rotation)
  9274. }
  9275. this._setScale(this._currentScaleValue, true);
  9276. if (this.defaultRenderingQueue) {
  9277. this.update()
  9278. }
  9279. }
  9280. },
  9281. {
  9282. key: 'isInPresentationMode',
  9283. get: function get() {
  9284. return this.presentationModeState === PresentationModeState.FULLSCREEN
  9285. }
  9286. },
  9287. {
  9288. key: 'isChangingPresentationMode',
  9289. get: function get() {
  9290. return this.presentationModeState === PresentationModeState.CHANGING
  9291. }
  9292. },
  9293. {
  9294. key: 'isHorizontalScrollbarEnabled',
  9295. get: function get() {
  9296. return this.isInPresentationMode ? false: this.container.scrollWidth > this.container.clientWidth
  9297. }
  9298. },
  9299. {
  9300. key: 'hasEqualPageSizes',
  9301. get: function get() {
  9302. var firstPageView = this._pages[0];
  9303. for (var i = 1,
  9304. ii = this._pages.length; i < ii; ++i) {
  9305. var pageView = this._pages[i];
  9306. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  9307. return false
  9308. }
  9309. }
  9310. return true
  9311. }
  9312. }]);
  9313. return PDFViewer
  9314. } ();
  9315. exports.PresentationModeState = PresentationModeState;
  9316. exports.PDFViewer = PDFViewer
  9317. }), (function(module, exports, __webpack_require__) {
  9318. "use strict";
  9319. Object.defineProperty(exports, "__esModule", {
  9320. value: true
  9321. });
  9322. exports.BasePreferences = undefined;
  9323. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ?
  9324. function(obj) {
  9325. return typeof obj
  9326. }: function(obj) {
  9327. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol": typeof obj
  9328. };
  9329. var _createClass = function() {
  9330. function defineProperties(target, props) {
  9331. for (var i = 0; i < props.length; i++) {
  9332. var descriptor = props[i];
  9333. descriptor.enumerable = descriptor.enumerable || false;
  9334. descriptor.configurable = true;
  9335. if ("value" in descriptor) descriptor.writable = true;
  9336. Object.defineProperty(target, descriptor.key, descriptor)
  9337. }
  9338. }
  9339. return function(Constructor, protoProps, staticProps) {
  9340. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  9341. if (staticProps) defineProperties(Constructor, staticProps);
  9342. return Constructor
  9343. }
  9344. } ();
  9345. var _ui_utils = __webpack_require__(0);
  9346. function _classCallCheck(instance, Constructor) {
  9347. if (! (instance instanceof Constructor)) {
  9348. throw new TypeError("Cannot call a class as a function");
  9349. }
  9350. }
  9351. var defaultPreferences = null;
  9352. function getDefaultPreferences() {
  9353. if (!defaultPreferences) {
  9354. defaultPreferences = Promise.resolve({
  9355. "showPreviousViewOnLoad": true,
  9356. "defaultZoomValue": "",
  9357. "sidebarViewOnLoad": 0,
  9358. "enableHandToolOnLoad": false,
  9359. "cursorToolOnLoad": 0,
  9360. "enableWebGL": false,
  9361. "pdfBugEnabled": false,
  9362. "disableRange": false,
  9363. "disableStream": false,
  9364. "disableAutoFetch": false,
  9365. "disableFontFace": false,
  9366. "disableTextLayer": false,
  9367. "useOnlyCssZoom": false,
  9368. "externalLinkTarget": 0,
  9369. "enhanceTextSelection": false,
  9370. "renderer": "canvas",
  9371. "renderInteractiveForms": false,
  9372. "enablePrintAutoRotate": false,
  9373. "disablePageMode": false,
  9374. "disablePageLabels": false
  9375. })
  9376. }
  9377. return defaultPreferences
  9378. }
  9379. var BasePreferences = function() {
  9380. function BasePreferences() {
  9381. var _this = this;
  9382. _classCallCheck(this, BasePreferences);
  9383. if (this.constructor === BasePreferences) {
  9384. throw new Error('Cannot initialize BasePreferences.');
  9385. }
  9386. this.prefs = null;
  9387. this._initializedPromise = getDefaultPreferences().then(function(defaults) {
  9388. Object.defineProperty(_this, 'defaults', {
  9389. value: Object.freeze(defaults),
  9390. writable: false,
  9391. enumerable: true,
  9392. configurable: false
  9393. });
  9394. _this.prefs = (0, _ui_utils.cloneObj)(defaults);
  9395. return _this._readFromStorage(defaults)
  9396. }).then(function(prefObj) {
  9397. if (prefObj) {
  9398. _this.prefs = prefObj
  9399. }
  9400. })
  9401. }
  9402. _createClass(BasePreferences, [{
  9403. key: "_writeToStorage",
  9404. value: function _writeToStorage(prefObj) {
  9405. return Promise.reject(new Error('Not implemented: _writeToStorage'))
  9406. }
  9407. },
  9408. {
  9409. key: "_readFromStorage",
  9410. value: function _readFromStorage(prefObj) {
  9411. return Promise.reject(new Error('Not implemented: _readFromStorage'))
  9412. }
  9413. },
  9414. {
  9415. key: "reset",
  9416. value: function reset() {
  9417. var _this2 = this;
  9418. return this._initializedPromise.then(function() {
  9419. _this2.prefs = (0, _ui_utils.cloneObj)(_this2.defaults);
  9420. return _this2._writeToStorage(_this2.defaults)
  9421. })
  9422. }
  9423. },
  9424. {
  9425. key: "reload",
  9426. value: function reload() {
  9427. var _this3 = this;
  9428. return this._initializedPromise.then(function() {
  9429. return _this3._readFromStorage(_this3.defaults)
  9430. }).then(function(prefObj) {
  9431. if (prefObj) {
  9432. _this3.prefs = prefObj
  9433. }
  9434. })
  9435. }
  9436. },
  9437. {
  9438. key: "set",
  9439. value: function set(name, value) {
  9440. var _this4 = this;
  9441. return this._initializedPromise.then(function() {
  9442. if (_this4.defaults[name] === undefined) {
  9443. throw new Error("Set preference: \"" + name + "\" is undefined.");
  9444. } else if (value === undefined) {
  9445. throw new Error('Set preference: no value is specified.');
  9446. }
  9447. var valueType = typeof value === "undefined" ? "undefined": _typeof(value);
  9448. var defaultType = _typeof(_this4.defaults[name]);
  9449. if (valueType !== defaultType) {
  9450. if (valueType === 'number' && defaultType === 'string') {
  9451. value = value.toString()
  9452. } else {
  9453. throw new Error("Set preference: \"" + value + "\" is a " + valueType + ", " + ("expected a " + defaultType + "."));
  9454. }
  9455. } else {
  9456. if (valueType === 'number' && (value | 0) !== value) {
  9457. throw new Error("Set preference: \"" + value + "\" must be an integer.");
  9458. }
  9459. }
  9460. _this4.prefs[name] = value;
  9461. return _this4._writeToStorage(_this4.prefs)
  9462. })
  9463. }
  9464. },
  9465. {
  9466. key: "get",
  9467. value: function get(name) {
  9468. var _this5 = this;
  9469. return this._initializedPromise.then(function() {
  9470. var defaultValue = _this5.defaults[name];
  9471. if (defaultValue === undefined) {
  9472. throw new Error("Get preference: \"" + name + "\" is undefined.");
  9473. } else {
  9474. var prefValue = _this5.prefs[name];
  9475. if (prefValue !== undefined) {
  9476. return prefValue
  9477. }
  9478. }
  9479. return defaultValue
  9480. })
  9481. }
  9482. }]);
  9483. return BasePreferences
  9484. } ();
  9485. exports.BasePreferences = BasePreferences
  9486. }), (function(module, exports, __webpack_require__) {
  9487. "use strict";
  9488. Object.defineProperty(exports, "__esModule", {
  9489. value: true
  9490. });
  9491. exports.SecondaryToolbar = undefined;
  9492. var _createClass = function() {
  9493. function defineProperties(target, props) {
  9494. for (var i = 0; i < props.length; i++) {
  9495. var descriptor = props[i];
  9496. descriptor.enumerable = descriptor.enumerable || false;
  9497. descriptor.configurable = true;
  9498. if ("value" in descriptor) descriptor.writable = true;
  9499. Object.defineProperty(target, descriptor.key, descriptor)
  9500. }
  9501. }
  9502. return function(Constructor, protoProps, staticProps) {
  9503. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  9504. if (staticProps) defineProperties(Constructor, staticProps);
  9505. return Constructor
  9506. }
  9507. } ();
  9508. var _pdf_cursor_tools = __webpack_require__(6);
  9509. var _ui_utils = __webpack_require__(0);
  9510. function _classCallCheck(instance, Constructor) {
  9511. if (! (instance instanceof Constructor)) {
  9512. throw new TypeError("Cannot call a class as a function");
  9513. }
  9514. }
  9515. var SecondaryToolbar = function() {
  9516. function SecondaryToolbar(options, mainContainer, eventBus) {
  9517. _classCallCheck(this, SecondaryToolbar);
  9518. this.toolbar = options.toolbar;
  9519. this.toggleButton = options.toggleButton;
  9520. this.toolbarButtonContainer = options.toolbarButtonContainer;
  9521. this.buttons = [{
  9522. element: options.presentationModeButton,
  9523. eventName: 'presentationmode',
  9524. close: true
  9525. },
  9526. {
  9527. element: options.openFileButton,
  9528. eventName: 'openfile',
  9529. close: true
  9530. },
  9531. {
  9532. element: options.printButton,
  9533. eventName: 'print',
  9534. close: true
  9535. },
  9536. {
  9537. element: options.downloadButton,
  9538. eventName: 'download',
  9539. close: true
  9540. },
  9541. {
  9542. element: options.viewBookmarkButton,
  9543. eventName: null,
  9544. close: true
  9545. },
  9546. {
  9547. element: options.firstPageButton,
  9548. eventName: 'firstpage',
  9549. close: true
  9550. },
  9551. {
  9552. element: options.lastPageButton,
  9553. eventName: 'lastpage',
  9554. close: true
  9555. },
  9556. {
  9557. element: options.pageRotateCwButton,
  9558. eventName: 'rotatecw',
  9559. close: false
  9560. },
  9561. {
  9562. element: options.pageRotateCcwButton,
  9563. eventName: 'rotateccw',
  9564. close: false
  9565. },
  9566. {
  9567. element: options.cursorSelectToolButton,
  9568. eventName: 'switchcursortool',
  9569. eventDetails: {
  9570. tool: _pdf_cursor_tools.CursorTool.SELECT
  9571. },
  9572. close: true
  9573. },
  9574. {
  9575. element: options.cursorHandToolButton,
  9576. eventName: 'switchcursortool',
  9577. eventDetails: {
  9578. tool: _pdf_cursor_tools.CursorTool.HAND
  9579. },
  9580. close: true
  9581. },
  9582. {
  9583. element: options.documentPropertiesButton,
  9584. eventName: 'documentproperties',
  9585. close: true
  9586. }];
  9587. this.items = {
  9588. firstPage: options.firstPageButton,
  9589. lastPage: options.lastPageButton,
  9590. pageRotateCw: options.pageRotateCwButton,
  9591. pageRotateCcw: options.pageRotateCcwButton
  9592. };
  9593. this.mainContainer = mainContainer;
  9594. this.eventBus = eventBus;
  9595. this.opened = false;
  9596. this.containerHeight = null;
  9597. this.previousContainerHeight = null;
  9598. this.reset();
  9599. this._bindClickListeners();
  9600. this._bindCursorToolsListener(options);
  9601. this.eventBus.on('resize', this._setMaxHeight.bind(this))
  9602. }
  9603. _createClass(SecondaryToolbar, [{
  9604. key: 'setPageNumber',
  9605. value: function setPageNumber(pageNumber) {
  9606. this.pageNumber = pageNumber;
  9607. this._updateUIState()
  9608. }
  9609. },
  9610. {
  9611. key: 'setPagesCount',
  9612. value: function setPagesCount(pagesCount) {
  9613. this.pagesCount = pagesCount;
  9614. this._updateUIState()
  9615. }
  9616. },
  9617. {
  9618. key: 'reset',
  9619. value: function reset() {
  9620. this.pageNumber = 0;
  9621. this.pagesCount = 0;
  9622. this._updateUIState()
  9623. }
  9624. },
  9625. {
  9626. key: '_updateUIState',
  9627. value: function _updateUIState() {
  9628. this.items.firstPage.disabled = this.pageNumber <= 1;
  9629. this.items.lastPage.disabled = this.pageNumber >= this.pagesCount;
  9630. this.items.pageRotateCw.disabled = this.pagesCount === 0;
  9631. this.items.pageRotateCcw.disabled = this.pagesCount === 0
  9632. }
  9633. },
  9634. {
  9635. key: '_bindClickListeners',
  9636. value: function _bindClickListeners() {
  9637. var _this = this;
  9638. this.toggleButton.addEventListener('click', this.toggle.bind(this));
  9639. var _loop = function _loop(button) {
  9640. var _buttons$button = _this.buttons[button],
  9641. element = _buttons$button.element,
  9642. eventName = _buttons$button.eventName,
  9643. close = _buttons$button.close,
  9644. eventDetails = _buttons$button.eventDetails;
  9645. element.addEventListener('click',
  9646. function(evt) {
  9647. if (eventName !== null) {
  9648. var details = {
  9649. source: _this
  9650. };
  9651. for (var property in eventDetails) {
  9652. details[property] = eventDetails[property]
  9653. }
  9654. _this.eventBus.dispatch(eventName, details)
  9655. }
  9656. if (close) {
  9657. _this.close()
  9658. }
  9659. })
  9660. };
  9661. for (var button in this.buttons) {
  9662. _loop(button)
  9663. }
  9664. }
  9665. },
  9666. {
  9667. key: '_bindCursorToolsListener',
  9668. value: function _bindCursorToolsListener(buttons) {
  9669. this.eventBus.on('cursortoolchanged',
  9670. function(evt) {
  9671. buttons.cursorSelectToolButton.classList.remove('toggled');
  9672. buttons.cursorHandToolButton.classList.remove('toggled');
  9673. switch (evt.tool) {
  9674. case _pdf_cursor_tools.CursorTool.SELECT:
  9675. buttons.cursorSelectToolButton.classList.add('toggled');
  9676. break;
  9677. case _pdf_cursor_tools.CursorTool.HAND:
  9678. buttons.cursorHandToolButton.classList.add('toggled');
  9679. break
  9680. }
  9681. })
  9682. }
  9683. },
  9684. {
  9685. key: 'open',
  9686. value: function open() {
  9687. if (this.opened) {
  9688. return
  9689. }
  9690. this.opened = true;
  9691. this._setMaxHeight();
  9692. this.toggleButton.classList.add('toggled');
  9693. this.toolbar.classList.remove('hidden')
  9694. }
  9695. },
  9696. {
  9697. key: 'close',
  9698. value: function close() {
  9699. if (!this.opened) {
  9700. return
  9701. }
  9702. this.opened = false;
  9703. this.toolbar.classList.add('hidden');
  9704. this.toggleButton.classList.remove('toggled')
  9705. }
  9706. },
  9707. {
  9708. key: 'toggle',
  9709. value: function toggle() {
  9710. if (this.opened) {
  9711. this.close()
  9712. } else {
  9713. this.open()
  9714. }
  9715. }
  9716. },
  9717. {
  9718. key: '_setMaxHeight',
  9719. value: function _setMaxHeight() {
  9720. if (!this.opened) {
  9721. return
  9722. }
  9723. this.containerHeight = this.mainContainer.clientHeight;
  9724. if (this.containerHeight === this.previousContainerHeight) {
  9725. return
  9726. }
  9727. this.toolbarButtonContainer.setAttribute('style', 'max-height: ' + (this.containerHeight - _ui_utils.SCROLLBAR_PADDING) + 'px;');
  9728. this.previousContainerHeight = this.containerHeight
  9729. }
  9730. },
  9731. {
  9732. key: 'isOpen',
  9733. get: function get() {
  9734. return this.opened
  9735. }
  9736. }]);
  9737. return SecondaryToolbar
  9738. } ();
  9739. exports.SecondaryToolbar = SecondaryToolbar
  9740. }), (function(module, exports, __webpack_require__) {
  9741. "use strict";
  9742. Object.defineProperty(exports, "__esModule", {
  9743. value: true
  9744. });
  9745. exports.DefaultTextLayerFactory = exports.TextLayerBuilder = undefined;
  9746. var _createClass = function() {
  9747. function defineProperties(target, props) {
  9748. for (var i = 0; i < props.length; i++) {
  9749. var descriptor = props[i];
  9750. descriptor.enumerable = descriptor.enumerable || false;
  9751. descriptor.configurable = true;
  9752. if ("value" in descriptor) descriptor.writable = true;
  9753. Object.defineProperty(target, descriptor.key, descriptor)
  9754. }
  9755. }
  9756. return function(Constructor, protoProps, staticProps) {
  9757. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  9758. if (staticProps) defineProperties(Constructor, staticProps);
  9759. return Constructor
  9760. }
  9761. } ();
  9762. var _dom_events = __webpack_require__(2);
  9763. var _pdfjsLib = __webpack_require__(1);
  9764. function _classCallCheck(instance, Constructor) {
  9765. if (! (instance instanceof Constructor)) {
  9766. throw new TypeError("Cannot call a class as a function");
  9767. }
  9768. }
  9769. var EXPAND_DIVS_TIMEOUT = 300;
  9770. var TextLayerBuilder = function() {
  9771. function TextLayerBuilder(_ref) {
  9772. var textLayerDiv = _ref.textLayerDiv,
  9773. eventBus = _ref.eventBus,
  9774. pageIndex = _ref.pageIndex,
  9775. viewport = _ref.viewport,
  9776. _ref$findController = _ref.findController,
  9777. findController = _ref$findController === undefined ? null: _ref$findController,
  9778. _ref$enhanceTextSelec = _ref.enhanceTextSelection,
  9779. enhanceTextSelection = _ref$enhanceTextSelec === undefined ? false: _ref$enhanceTextSelec;
  9780. _classCallCheck(this, TextLayerBuilder);
  9781. this.textLayerDiv = textLayerDiv;
  9782. this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)();
  9783. this.textContent = null;
  9784. this.textContentItemsStr = [];
  9785. this.textContentStream = null;
  9786. this.renderingDone = false;
  9787. this.pageIdx = pageIndex;
  9788. this.pageNumber = this.pageIdx + 1;
  9789. this.matches = [];
  9790. this.viewport = viewport;
  9791. this.textDivs = [];
  9792. this.findController = findController;
  9793. this.textLayerRenderTask = null;
  9794. this.enhanceTextSelection = enhanceTextSelection;
  9795. this._bindMouse()
  9796. }
  9797. _createClass(TextLayerBuilder, [{
  9798. key: '_finishRendering',
  9799. value: function _finishRendering() {
  9800. this.renderingDone = true;
  9801. if (!this.enhanceTextSelection) {
  9802. var endOfContent = document.createElement('div');
  9803. endOfContent.className = 'endOfContent';
  9804. this.textLayerDiv.appendChild(endOfContent)
  9805. }
  9806. this.eventBus.dispatch('textlayerrendered', {
  9807. source: this,
  9808. pageNumber: this.pageNumber,
  9809. numTextDivs: this.textDivs.length
  9810. })
  9811. }
  9812. },
  9813. {
  9814. key: 'render',
  9815. value: function render() {
  9816. var _this = this;
  9817. var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  9818. if (! (this.textContent || this.textContentStream) || this.renderingDone) {
  9819. return
  9820. }
  9821. this.cancel();
  9822. this.textDivs = [];
  9823. var textLayerFrag = document.createDocumentFragment();
  9824. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  9825. textContent: this.textContent,
  9826. textContentStream: this.textContentStream,
  9827. container: textLayerFrag,
  9828. viewport: this.viewport,
  9829. textDivs: this.textDivs,
  9830. textContentItemsStr: this.textContentItemsStr,
  9831. timeout: timeout,
  9832. enhanceTextSelection: this.enhanceTextSelection
  9833. });
  9834. this.textLayerRenderTask.promise.then(function() {
  9835. _this.textLayerDiv.appendChild(textLayerFrag);
  9836. _this._finishRendering();
  9837. _this.updateMatches()
  9838. },
  9839. function(reason) {})
  9840. }
  9841. },
  9842. {
  9843. key: 'cancel',
  9844. value: function cancel() {
  9845. if (this.textLayerRenderTask) {
  9846. this.textLayerRenderTask.cancel();
  9847. this.textLayerRenderTask = null
  9848. }
  9849. }
  9850. },
  9851. {
  9852. key: 'setTextContentStream',
  9853. value: function setTextContentStream(readableStream) {
  9854. this.cancel();
  9855. this.textContentStream = readableStream
  9856. }
  9857. },
  9858. {
  9859. key: 'setTextContent',
  9860. value: function setTextContent(textContent) {
  9861. this.cancel();
  9862. this.textContent = textContent
  9863. }
  9864. },
  9865. {
  9866. key: 'convertMatches',
  9867. value: function convertMatches(matches, matchesLength) {
  9868. var i = 0;
  9869. var iIndex = 0;
  9870. var textContentItemsStr = this.textContentItemsStr;
  9871. var end = textContentItemsStr.length - 1;
  9872. var queryLen = this.findController === null ? 0 : this.findController.state.query.length;
  9873. var ret = [];
  9874. if (!matches) {
  9875. return ret
  9876. }
  9877. for (var m = 0,
  9878. len = matches.length; m < len; m++) {
  9879. var matchIdx = matches[m];
  9880. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  9881. iIndex += textContentItemsStr[i].length;
  9882. i++
  9883. }
  9884. if (i === textContentItemsStr.length) {
  9885. console.error('Could not find a matching mapping')
  9886. }
  9887. var match = {
  9888. begin: {
  9889. divIdx: i,
  9890. offset: matchIdx - iIndex
  9891. }
  9892. };
  9893. if (matchesLength) {
  9894. matchIdx += matchesLength[m]
  9895. } else {
  9896. matchIdx += queryLen
  9897. }
  9898. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  9899. iIndex += textContentItemsStr[i].length;
  9900. i++
  9901. }
  9902. match.end = {
  9903. divIdx: i,
  9904. offset: matchIdx - iIndex
  9905. };
  9906. ret.push(match)
  9907. }
  9908. return ret
  9909. }
  9910. },
  9911. {
  9912. key: 'renderMatches',
  9913. value: function renderMatches(matches) {
  9914. if (matches.length === 0) {
  9915. return
  9916. }
  9917. var textContentItemsStr = this.textContentItemsStr;
  9918. var textDivs = this.textDivs;
  9919. var prevEnd = null;
  9920. var pageIdx = this.pageIdx;
  9921. var isSelectedPage = this.findController === null ? false: pageIdx === this.findController.selected.pageIdx;
  9922. var selectedMatchIdx = this.findController === null ? -1 : this.findController.selected.matchIdx;
  9923. var highlightAll = this.findController === null ? false: this.findController.state.highlightAll;
  9924. var infinity = {
  9925. divIdx: -1,
  9926. offset: undefined
  9927. };
  9928. function beginText(begin, className) {
  9929. var divIdx = begin.divIdx;
  9930. textDivs[divIdx].textContent = '';
  9931. appendTextToDiv(divIdx, 0, begin.offset, className)
  9932. }
  9933. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  9934. var div = textDivs[divIdx];
  9935. var content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  9936. var node = document.createTextNode(content);
  9937. if (className) {
  9938. var span = document.createElement('span');
  9939. span.className = className;
  9940. span.appendChild(node);
  9941. div.appendChild(span);
  9942. return
  9943. }
  9944. div.appendChild(node)
  9945. }
  9946. var i0 = selectedMatchIdx,
  9947. i1 = i0 + 1;
  9948. if (highlightAll) {
  9949. i0 = 0;
  9950. i1 = matches.length
  9951. } else if (!isSelectedPage) {
  9952. return
  9953. }
  9954. for (var i = i0; i < i1; i++) {
  9955. var match = matches[i];
  9956. var begin = match.begin;
  9957. var end = match.end;
  9958. var isSelected = isSelectedPage && i === selectedMatchIdx;
  9959. var highlightSuffix = isSelected ? ' selected': '';
  9960. if (this.findController) {
  9961. this.findController.updateMatchPosition(pageIdx, i, textDivs, begin.divIdx)
  9962. }
  9963. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  9964. if (prevEnd !== null) {
  9965. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset)
  9966. }
  9967. beginText(begin)
  9968. } else {
  9969. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset)
  9970. }
  9971. if (begin.divIdx === end.divIdx) {
  9972. appendTextToDiv(begin.divIdx, begin.offset, end.offset, 'highlight' + highlightSuffix)
  9973. } else {
  9974. appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, 'highlight begin' + highlightSuffix);
  9975. for (var n0 = begin.divIdx + 1,
  9976. n1 = end.divIdx; n0 < n1; n0++) {
  9977. textDivs[n0].className = 'highlight middle' + highlightSuffix
  9978. }
  9979. beginText(end, 'highlight end' + highlightSuffix)
  9980. }
  9981. prevEnd = end
  9982. }
  9983. if (prevEnd) {
  9984. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset)
  9985. }
  9986. }
  9987. },
  9988. {
  9989. key: 'updateMatches',
  9990. value: function updateMatches() {
  9991. if (!this.renderingDone) {
  9992. return
  9993. }
  9994. var matches = this.matches;
  9995. var textDivs = this.textDivs;
  9996. var textContentItemsStr = this.textContentItemsStr;
  9997. var clearedUntilDivIdx = -1;
  9998. for (var i = 0,
  9999. len = matches.length; i < len; i++) {
  10000. var match = matches[i];
  10001. var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  10002. for (var n = begin,
  10003. end = match.end.divIdx; n <= end; n++) {
  10004. var div = textDivs[n];
  10005. div.textContent = textContentItemsStr[n];
  10006. div.className = ''
  10007. }
  10008. clearedUntilDivIdx = match.end.divIdx + 1
  10009. }
  10010. if (this.findController === null || !this.findController.active) {
  10011. return
  10012. }
  10013. var pageMatches = void 0,
  10014. pageMatchesLength = void 0;
  10015. if (this.findController !== null) {
  10016. pageMatches = this.findController.pageMatches[this.pageIdx] || null;
  10017. pageMatchesLength = this.findController.pageMatchesLength ? this.findController.pageMatchesLength[this.pageIdx] || null: null
  10018. }
  10019. this.matches = this.convertMatches(pageMatches, pageMatchesLength);
  10020. this.renderMatches(this.matches)
  10021. }
  10022. },
  10023. {
  10024. key: '_bindMouse',
  10025. value: function _bindMouse() {
  10026. var _this2 = this;
  10027. var div = this.textLayerDiv;
  10028. var expandDivsTimer = null;
  10029. div.addEventListener('mousedown',
  10030. function(evt) {
  10031. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  10032. _this2.textLayerRenderTask.expandTextDivs(true);
  10033. if (expandDivsTimer) {
  10034. clearTimeout(expandDivsTimer);
  10035. expandDivsTimer = null
  10036. }
  10037. return
  10038. }
  10039. var end = div.querySelector('.endOfContent');
  10040. if (!end) {
  10041. return
  10042. }
  10043. var adjustTop = evt.target !== div;
  10044. adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue('-moz-user-select') !== 'none';
  10045. if (adjustTop) {
  10046. var divBounds = div.getBoundingClientRect();
  10047. var r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  10048. end.style.top = (r * 100).toFixed(2) + '%'
  10049. }
  10050. end.classList.add('active')
  10051. });
  10052. div.addEventListener('mouseup',
  10053. function() {
  10054. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  10055. expandDivsTimer = setTimeout(function() {
  10056. if (_this2.textLayerRenderTask) {
  10057. _this2.textLayerRenderTask.expandTextDivs(false)
  10058. }
  10059. expandDivsTimer = null
  10060. },
  10061. EXPAND_DIVS_TIMEOUT);
  10062. return
  10063. }
  10064. var end = div.querySelector('.endOfContent');
  10065. if (!end) {
  10066. return
  10067. }
  10068. end.style.top = '';
  10069. end.classList.remove('active')
  10070. })
  10071. }
  10072. }]);
  10073. return TextLayerBuilder
  10074. } ();
  10075. var DefaultTextLayerFactory = function() {
  10076. function DefaultTextLayerFactory() {
  10077. _classCallCheck(this, DefaultTextLayerFactory)
  10078. }
  10079. _createClass(DefaultTextLayerFactory, [{
  10080. key: 'createTextLayerBuilder',
  10081. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  10082. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  10083. return new TextLayerBuilder({
  10084. textLayerDiv: textLayerDiv,
  10085. pageIndex: pageIndex,
  10086. viewport: viewport,
  10087. enhanceTextSelection: enhanceTextSelection
  10088. })
  10089. }
  10090. }]);
  10091. return DefaultTextLayerFactory
  10092. } ();
  10093. exports.TextLayerBuilder = TextLayerBuilder;
  10094. exports.DefaultTextLayerFactory = DefaultTextLayerFactory
  10095. }), (function(module, exports, __webpack_require__) {
  10096. "use strict";
  10097. Object.defineProperty(exports, "__esModule", {
  10098. value: true
  10099. });
  10100. exports.Toolbar = undefined;
  10101. var _createClass = function() {
  10102. function defineProperties(target, props) {
  10103. for (var i = 0; i < props.length; i++) {
  10104. var descriptor = props[i];
  10105. descriptor.enumerable = descriptor.enumerable || false;
  10106. descriptor.configurable = true;
  10107. if ("value" in descriptor) descriptor.writable = true;
  10108. Object.defineProperty(target, descriptor.key, descriptor)
  10109. }
  10110. }
  10111. return function(Constructor, protoProps, staticProps) {
  10112. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  10113. if (staticProps) defineProperties(Constructor, staticProps);
  10114. return Constructor
  10115. }
  10116. } ();
  10117. var _ui_utils = __webpack_require__(0);
  10118. function _classCallCheck(instance, Constructor) {
  10119. if (! (instance instanceof Constructor)) {
  10120. throw new TypeError("Cannot call a class as a function");
  10121. }
  10122. }
  10123. var PAGE_NUMBER_LOADING_INDICATOR = 'visiblePageIsLoading';
  10124. var SCALE_SELECT_CONTAINER_PADDING = 8;
  10125. var SCALE_SELECT_PADDING = 22;
  10126. var Toolbar = function() {
  10127. function Toolbar(options, mainContainer, eventBus) {
  10128. var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
  10129. _classCallCheck(this, Toolbar);
  10130. this.toolbar = options.container;
  10131. this.mainContainer = mainContainer;
  10132. this.eventBus = eventBus;
  10133. this.l10n = l10n;
  10134. this.items = options;
  10135. this._wasLocalized = false;
  10136. this.reset();
  10137. this._bindListeners()
  10138. }
  10139. _createClass(Toolbar, [{
  10140. key: 'setPageNumber',
  10141. value: function setPageNumber(pageNumber, pageLabel) {
  10142. this.pageNumber = pageNumber;
  10143. this.pageLabel = pageLabel;
  10144. this._updateUIState(false)
  10145. }
  10146. },
  10147. {
  10148. key: 'setPagesCount',
  10149. value: function setPagesCount(pagesCount, hasPageLabels) {
  10150. this.pagesCount = pagesCount;
  10151. this.hasPageLabels = hasPageLabels;
  10152. this._updateUIState(true)
  10153. }
  10154. },
  10155. {
  10156. key: 'setPageScale',
  10157. value: function setPageScale(pageScaleValue, pageScale) {
  10158. this.pageScaleValue = pageScaleValue;
  10159. this.pageScale = pageScale;
  10160. this._updateUIState(false)
  10161. }
  10162. },
  10163. {
  10164. key: 'reset',
  10165. value: function reset() {
  10166. this.pageNumber = 0;
  10167. this.pageLabel = null;
  10168. this.hasPageLabels = false;
  10169. this.pagesCount = 0;
  10170. this.pageScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  10171. this.pageScale = _ui_utils.DEFAULT_SCALE;
  10172. this._updateUIState(true)
  10173. }
  10174. },
  10175. {
  10176. key: '_bindListeners',
  10177. value: function _bindListeners() {
  10178. var _this = this;
  10179. var eventBus = this.eventBus,
  10180. items = this.items;
  10181. var self = this;
  10182. items.previous.addEventListener('click',
  10183. function() {
  10184. eventBus.dispatch('previouspage')
  10185. });
  10186. items.next.addEventListener('click',
  10187. function() {
  10188. eventBus.dispatch('nextpage')
  10189. });
  10190. items.zoomIn.addEventListener('click',
  10191. function() {
  10192. eventBus.dispatch('zoomin')
  10193. });
  10194. items.zoomOut.addEventListener('click',
  10195. function() {
  10196. eventBus.dispatch('zoomout')
  10197. });
  10198. items.pageNumber.addEventListener('click',
  10199. function() {
  10200. this.select()
  10201. });
  10202. items.pageNumber.addEventListener('change',
  10203. function() {
  10204. eventBus.dispatch('pagenumberchanged', {
  10205. source: self,
  10206. value: this.value
  10207. })
  10208. });
  10209. items.scaleSelect.addEventListener('change',
  10210. function() {
  10211. if (this.value === 'custom') {
  10212. return
  10213. }
  10214. eventBus.dispatch('scalechanged', {
  10215. source: self,
  10216. value: this.value
  10217. })
  10218. });
  10219. items.presentationModeButton.addEventListener('click',
  10220. function() {
  10221. eventBus.dispatch('presentationmode')
  10222. });
  10223. items.openFile.addEventListener('click',
  10224. function() {
  10225. eventBus.dispatch('openfile')
  10226. });
  10227. items.print.addEventListener('click',
  10228. function() {
  10229. eventBus.dispatch('print')
  10230. });
  10231. items.download.addEventListener('click',
  10232. function() {
  10233. eventBus.dispatch('download')
  10234. });
  10235. items.scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler;
  10236. eventBus.on('localized',
  10237. function() {
  10238. _this._localized()
  10239. })
  10240. }
  10241. },
  10242. {
  10243. key: '_localized',
  10244. value: function _localized() {
  10245. this._wasLocalized = true;
  10246. this._adjustScaleWidth();
  10247. this._updateUIState(true)
  10248. }
  10249. },
  10250. {
  10251. key: '_updateUIState',
  10252. value: function _updateUIState() {
  10253. var resetNumPages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  10254. if (!this._wasLocalized) {
  10255. return
  10256. }
  10257. var pageNumber = this.pageNumber,
  10258. pagesCount = this.pagesCount,
  10259. items = this.items;
  10260. var scaleValue = (this.pageScaleValue || this.pageScale).toString();
  10261. var scale = this.pageScale;
  10262. if (resetNumPages) {
  10263. if (this.hasPageLabels) {
  10264. items.pageNumber.type = 'text'
  10265. } else {
  10266. items.pageNumber.type = 'number';
  10267. this.l10n.get('of_pages', {
  10268. pagesCount: pagesCount
  10269. },
  10270. 'of {{pagesCount}}').then(function(msg) {
  10271. items.numPages.textContent = msg
  10272. })
  10273. }
  10274. items.pageNumber.max = pagesCount
  10275. }
  10276. if (this.hasPageLabels) {
  10277. items.pageNumber.value = this.pageLabel;
  10278. this.l10n.get('page_of_pages', {
  10279. pageNumber: pageNumber,
  10280. pagesCount: pagesCount
  10281. },
  10282. '({{pageNumber}} of {{pagesCount}})').then(function(msg) {
  10283. items.numPages.textContent = msg
  10284. })
  10285. } else {
  10286. items.pageNumber.value = pageNumber
  10287. }
  10288. items.previous.disabled = pageNumber <= 1;
  10289. items.next.disabled = pageNumber >= pagesCount;
  10290. items.zoomOut.disabled = scale <= _ui_utils.MIN_SCALE;
  10291. items.zoomIn.disabled = scale >= _ui_utils.MAX_SCALE;
  10292. var customScale = Math.round(scale * 10000) / 100;
  10293. this.l10n.get('page_scale_percent', {
  10294. scale: customScale
  10295. },
  10296. '{{scale}}%').then(function(msg) {
  10297. var options = items.scaleSelect.options;
  10298. var predefinedValueFound = false;
  10299. for (var i = 0,
  10300. ii = options.length; i < ii; i++) {
  10301. var option = options[i];
  10302. if (option.value !== scaleValue) {
  10303. option.selected = false;
  10304. continue
  10305. }
  10306. option.selected = true;
  10307. predefinedValueFound = true
  10308. }
  10309. if (!predefinedValueFound) {
  10310. items.customScaleOption.textContent = msg;
  10311. items.customScaleOption.selected = true
  10312. }
  10313. })
  10314. }
  10315. },
  10316. {
  10317. key: 'updateLoadingIndicatorState',
  10318. value: function updateLoadingIndicatorState() {
  10319. var loading = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  10320. var pageNumberInput = this.items.pageNumber;
  10321. if (loading) {
  10322. pageNumberInput.classList.add(PAGE_NUMBER_LOADING_INDICATOR)
  10323. } else {
  10324. pageNumberInput.classList.remove(PAGE_NUMBER_LOADING_INDICATOR)
  10325. }
  10326. }
  10327. },
  10328. {
  10329. key: '_adjustScaleWidth',
  10330. value: function _adjustScaleWidth() {
  10331. var container = this.items.scaleSelectContainer;
  10332. var select = this.items.scaleSelect;
  10333. _ui_utils.animationStarted.then(function() {
  10334. if (container.clientWidth === 0) {
  10335. container.setAttribute('style', 'display: inherit;')
  10336. }
  10337. if (container.clientWidth > 0) {
  10338. select.setAttribute('style', 'min-width: inherit;');
  10339. var width = select.clientWidth + SCALE_SELECT_CONTAINER_PADDING;
  10340. select.setAttribute('style', 'min-width: ' + (width + SCALE_SELECT_PADDING) + 'px;');
  10341. container.setAttribute('style', 'min-width: ' + width + 'px; ' + 'max-width: ' + width + 'px;')
  10342. }
  10343. })
  10344. }
  10345. }]);
  10346. return Toolbar
  10347. } ();
  10348. exports.Toolbar = Toolbar
  10349. }), (function(module, exports, __webpack_require__) {
  10350. "use strict";
  10351. Object.defineProperty(exports, "__esModule", {
  10352. value: true
  10353. });
  10354. var _createClass = function() {
  10355. function defineProperties(target, props) {
  10356. for (var i = 0; i < props.length; i++) {
  10357. var descriptor = props[i];
  10358. descriptor.enumerable = descriptor.enumerable || false;
  10359. descriptor.configurable = true;
  10360. if ("value" in descriptor) descriptor.writable = true;
  10361. Object.defineProperty(target, descriptor.key, descriptor)
  10362. }
  10363. }
  10364. return function(Constructor, protoProps, staticProps) {
  10365. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  10366. if (staticProps) defineProperties(Constructor, staticProps);
  10367. return Constructor
  10368. }
  10369. } ();
  10370. function _classCallCheck(instance, Constructor) {
  10371. if (! (instance instanceof Constructor)) {
  10372. throw new TypeError("Cannot call a class as a function");
  10373. }
  10374. }
  10375. var DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
  10376. var ViewHistory = function() {
  10377. function ViewHistory(fingerprint) {
  10378. var _this = this;
  10379. var cacheSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_VIEW_HISTORY_CACHE_SIZE;
  10380. _classCallCheck(this, ViewHistory);
  10381. this.fingerprint = fingerprint;
  10382. this.cacheSize = cacheSize;
  10383. this._initializedPromise = this._readFromStorage().then(function(databaseStr) {
  10384. var database = JSON.parse(databaseStr || '{}');
  10385. if (! ('files' in database)) {
  10386. database.files = []
  10387. }
  10388. if (database.files.length >= _this.cacheSize) {
  10389. database.files.shift()
  10390. }
  10391. var index = void 0;
  10392. for (var i = 0,
  10393. length = database.files.length; i < length; i++) {
  10394. var branch = database.files[i];
  10395. if (branch.fingerprint === _this.fingerprint) {
  10396. index = i;
  10397. break
  10398. }
  10399. }
  10400. if (typeof index !== 'number') {
  10401. index = database.files.push({
  10402. fingerprint: _this.fingerprint
  10403. }) - 1
  10404. }
  10405. _this.file = database.files[index];
  10406. _this.database = database
  10407. })
  10408. }
  10409. _createClass(ViewHistory, [{
  10410. key: '_writeToStorage',
  10411. value: function _writeToStorage() {
  10412. var _this2 = this;
  10413. return new Promise(function(resolve) {
  10414. var databaseStr = JSON.stringify(_this2.database);
  10415. localStorage.setItem('pdfjs.history', databaseStr);
  10416. resolve()
  10417. })
  10418. }
  10419. },
  10420. {
  10421. key: '_readFromStorage',
  10422. value: function _readFromStorage() {
  10423. return new Promise(function(resolve) {
  10424. var value = localStorage.getItem('pdfjs.history');
  10425. if (!value) {
  10426. var databaseStr = localStorage.getItem('database');
  10427. if (databaseStr) {
  10428. try {
  10429. var database = JSON.parse(databaseStr);
  10430. if (typeof database.files[0].fingerprint === 'string') {
  10431. localStorage.setItem('pdfjs.history', databaseStr);
  10432. localStorage.removeItem('database');
  10433. value = databaseStr
  10434. }
  10435. } catch(ex) {}
  10436. }
  10437. }
  10438. resolve(value)
  10439. })
  10440. }
  10441. },
  10442. {
  10443. key: 'set',
  10444. value: function set(name, val) {
  10445. var _this3 = this;
  10446. return this._initializedPromise.then(function() {
  10447. _this3.file[name] = val;
  10448. return _this3._writeToStorage()
  10449. })
  10450. }
  10451. },
  10452. {
  10453. key: 'setMultiple',
  10454. value: function setMultiple(properties) {
  10455. var _this4 = this;
  10456. return this._initializedPromise.then(function() {
  10457. for (var name in properties) {
  10458. _this4.file[name] = properties[name]
  10459. }
  10460. return _this4._writeToStorage()
  10461. })
  10462. }
  10463. },
  10464. {
  10465. key: 'get',
  10466. value: function get(name, defaultValue) {
  10467. var _this5 = this;
  10468. return this._initializedPromise.then(function() {
  10469. var val = _this5.file[name];
  10470. return val !== undefined ? val: defaultValue
  10471. })
  10472. }
  10473. },
  10474. {
  10475. key: 'getMultiple',
  10476. value: function getMultiple(properties) {
  10477. var _this6 = this;
  10478. return this._initializedPromise.then(function() {
  10479. var values = Object.create(null);
  10480. for (var name in properties) {
  10481. var val = _this6.file[name];
  10482. values[name] = val !== undefined ? val: properties[name]
  10483. }
  10484. return values
  10485. })
  10486. }
  10487. }]);
  10488. return ViewHistory
  10489. } ();
  10490. exports.ViewHistory = ViewHistory
  10491. }), (function(module, exports, __webpack_require__) {
  10492. "use strict";
  10493. var DEFAULT_URL = cgl_pdf_src;
  10494. var pdfjsWebApp = void 0; {
  10495. pdfjsWebApp = __webpack_require__(4)
  10496. }; {
  10497. __webpack_require__(8)
  10498. }; {
  10499. __webpack_require__(9)
  10500. }
  10501. function getViewerConfiguration() {
  10502. return {
  10503. appContainer: document.body,
  10504. mainContainer: document.getElementById('viewerContainer'),
  10505. viewerContainer: document.getElementById('viewer'),
  10506. eventBus: null,
  10507. toolbar: {
  10508. container: document.getElementById('toolbarViewer'),
  10509. numPages: document.getElementById('numPages'),
  10510. pageNumber: document.getElementById('pageNumber'),
  10511. scaleSelectContainer: document.getElementById('scaleSelectContainer'),
  10512. scaleSelect: document.getElementById('scaleSelect'),
  10513. customScaleOption: document.getElementById('customScaleOption'),
  10514. previous: document.getElementById('previous'),
  10515. next: document.getElementById('next'),
  10516. zoomIn: document.getElementById('zoomIn'),
  10517. zoomOut: document.getElementById('zoomOut'),
  10518. viewFind: document.getElementById('viewFind'),
  10519. openFile: document.getElementById('openFile'),
  10520. print: document.getElementById('print'),
  10521. presentationModeButton: document.getElementById('presentationMode'),
  10522. download: document.getElementById('download'),
  10523. viewBookmark: document.getElementById('viewBookmark')
  10524. },
  10525. secondaryToolbar: {
  10526. toolbar: document.getElementById('secondaryToolbar'),
  10527. toggleButton: document.getElementById('secondaryToolbarToggle'),
  10528. toolbarButtonContainer: document.getElementById('secondaryToolbarButtonContainer'),
  10529. presentationModeButton: document.getElementById('secondaryPresentationMode'),
  10530. openFileButton: document.getElementById('secondaryOpenFile'),
  10531. printButton: document.getElementById('secondaryPrint'),
  10532. downloadButton: document.getElementById('secondaryDownload'),
  10533. viewBookmarkButton: document.getElementById('secondaryViewBookmark'),
  10534. firstPageButton: document.getElementById('firstPage'),
  10535. lastPageButton: document.getElementById('lastPage'),
  10536. pageRotateCwButton: document.getElementById('pageRotateCw'),
  10537. pageRotateCcwButton: document.getElementById('pageRotateCcw'),
  10538. cursorSelectToolButton: document.getElementById('cursorSelectTool'),
  10539. cursorHandToolButton: document.getElementById('cursorHandTool'),
  10540. documentPropertiesButton: document.getElementById('documentProperties')
  10541. },
  10542. fullscreen: {
  10543. contextFirstPage: document.getElementById('contextFirstPage'),
  10544. contextLastPage: document.getElementById('contextLastPage'),
  10545. contextPageRotateCw: document.getElementById('contextPageRotateCw'),
  10546. contextPageRotateCcw: document.getElementById('contextPageRotateCcw')
  10547. },
  10548. sidebar: {
  10549. mainContainer: document.getElementById('mainContainer'),
  10550. outerContainer: document.getElementById('outerContainer'),
  10551. toggleButton: document.getElementById('sidebarToggle'),
  10552. thumbnailButton: document.getElementById('viewThumbnail'),
  10553. outlineButton: document.getElementById('viewOutline'),
  10554. attachmentsButton: document.getElementById('viewAttachments'),
  10555. thumbnailView: document.getElementById('thumbnailView'),
  10556. outlineView: document.getElementById('outlineView'),
  10557. attachmentsView: document.getElementById('attachmentsView')
  10558. },
  10559. findBar: {
  10560. bar: document.getElementById('findbar'),
  10561. toggleButton: document.getElementById('viewFind'),
  10562. findField: document.getElementById('findInput'),
  10563. highlightAllCheckbox: document.getElementById('findHighlightAll'),
  10564. caseSensitiveCheckbox: document.getElementById('findMatchCase'),
  10565. findMsg: document.getElementById('findMsg'),
  10566. findResultsCount: document.getElementById('findResultsCount'),
  10567. findStatusIcon: document.getElementById('findStatusIcon'),
  10568. findPreviousButton: document.getElementById('findPrevious'),
  10569. findNextButton: document.getElementById('findNext')
  10570. },
  10571. passwordOverlay: {
  10572. overlayName: 'passwordOverlay',
  10573. container: document.getElementById('passwordOverlay'),
  10574. label: document.getElementById('passwordText'),
  10575. input: document.getElementById('password'),
  10576. submitButton: document.getElementById('passwordSubmit'),
  10577. cancelButton: document.getElementById('passwordCancel')
  10578. },
  10579. documentProperties: {
  10580. overlayName: 'documentPropertiesOverlay',
  10581. container: document.getElementById('documentPropertiesOverlay'),
  10582. closeButton: document.getElementById('documentPropertiesClose'),
  10583. fields: {
  10584. 'fileName': document.getElementById('fileNameField'),
  10585. 'fileSize': document.getElementById('fileSizeField'),
  10586. 'title': document.getElementById('titleField'),
  10587. 'author': document.getElementById('authorField'),
  10588. 'subject': document.getElementById('subjectField'),
  10589. 'keywords': document.getElementById('keywordsField'),
  10590. 'creationDate': document.getElementById('creationDateField'),
  10591. 'modificationDate': document.getElementById('modificationDateField'),
  10592. 'creator': document.getElementById('creatorField'),
  10593. 'producer': document.getElementById('producerField'),
  10594. 'version': document.getElementById('versionField'),
  10595. 'pageCount': document.getElementById('pageCountField')
  10596. }
  10597. },
  10598. errorWrapper: {
  10599. container: document.getElementById('errorWrapper'),
  10600. errorMessage: document.getElementById('errorMessage'),
  10601. closeButton: document.getElementById('errorClose'),
  10602. errorMoreInfo: document.getElementById('errorMoreInfo'),
  10603. moreInfoButton: document.getElementById('errorShowMore'),
  10604. lessInfoButton: document.getElementById('errorShowLess')
  10605. },
  10606. printContainer: document.getElementById('printContainer'),
  10607. openFileInputName: 'fileInput',
  10608. debuggerScriptPath: './debugger.js',
  10609. defaultUrl: DEFAULT_URL
  10610. }
  10611. }
  10612. function webViewerLoad() {
  10613. var config = getViewerConfiguration();
  10614. window.PDFViewerApplication = pdfjsWebApp.PDFViewerApplication;
  10615. pdfjsWebApp.PDFViewerApplication.run(config)
  10616. }
  10617. if (document.readyState === 'interactive' || document.readyState === 'complete') {
  10618. webViewerLoad()
  10619. } else {
  10620. document.addEventListener('DOMContentLoaded', webViewerLoad, true)
  10621. }
  10622. })]);
  10623. /* Copyright 2017 Mozilla Foundation
  10624. *
  10625. * Licensed under the Apache License, Version 2.0 (the "License");
  10626. * you may not use this file except in compliance with the License.
  10627. * You may obtain a copy of the License at
  10628. *
  10629. * http://www.apache.org/licenses/LICENSE-2.0
  10630. *
  10631. * Unless required by applicable law or agreed to in writing, software
  10632. * distributed under the License is distributed on an "AS IS" BASIS,
  10633. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10634. * See the License for the specific language governing permissions and
  10635. * limitations under the License.
  10636. */
  10637. (function(modules) {
  10638. var installedModules = {};
  10639. function __webpack_require__(moduleId) {
  10640. if (installedModules[moduleId]) {
  10641. return installedModules[moduleId].exports
  10642. }
  10643. var module = installedModules[moduleId] = {
  10644. i: moduleId,
  10645. l: false,
  10646. exports: {}
  10647. };
  10648. modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  10649. module.l = true;
  10650. return module.exports
  10651. }
  10652. __webpack_require__.m = modules;
  10653. __webpack_require__.c = installedModules;
  10654. __webpack_require__.i = function(value) {
  10655. return value
  10656. };
  10657. __webpack_require__.d = function(exports, name, getter) {
  10658. if (!__webpack_require__.o(exports, name)) {
  10659. Object.defineProperty(exports, name, {
  10660. configurable: false,
  10661. enumerable: true,
  10662. get: getter
  10663. })
  10664. }
  10665. };
  10666. __webpack_require__.n = function(module) {
  10667. var getter = module && module.__esModule ?
  10668. function getDefault() {
  10669. return module['default']
  10670. }: function getModuleExports() {
  10671. return module
  10672. };
  10673. __webpack_require__.d(getter, 'a', getter);
  10674. return getter
  10675. };
  10676. __webpack_require__.o = function(object, property) {
  10677. return Object.prototype.hasOwnProperty.call(object, property)
  10678. };
  10679. __webpack_require__.p = "";
  10680. return __webpack_require__(__webpack_require__.s = 33)
  10681. })([(function(module, exports, __webpack_require__) {
  10682. "use strict";
  10683. Object.defineProperty(exports, "__esModule", {
  10684. value: true
  10685. });
  10686. exports.localized = exports.animationStarted = exports.normalizeWheelEventDelta = exports.binarySearchFirstItem = exports.watchScroll = exports.scrollIntoView = exports.getOutputScale = exports.approximateFraction = exports.roundToDivide = exports.getVisibleElements = exports.parseQueryString = exports.noContextMenuHandler = exports.getPDFFileNameFromURL = exports.ProgressBar = exports.EventBus = exports.NullL10n = exports.mozL10n = exports.RendererType = exports.cloneObj = exports.VERTICAL_PADDING = exports.SCROLLBAR_PADDING = exports.MAX_AUTO_SCALE = exports.UNKNOWN_SCALE = exports.MAX_SCALE = exports.MIN_SCALE = exports.DEFAULT_SCALE = exports.DEFAULT_SCALE_VALUE = exports.CSS_UNITS = undefined;
  10687. var _createClass = function() {
  10688. function defineProperties(target, props) {
  10689. for (var i = 0; i < props.length; i++) {
  10690. var descriptor = props[i];
  10691. descriptor.enumerable = descriptor.enumerable || false;
  10692. descriptor.configurable = true;
  10693. if ("value" in descriptor) descriptor.writable = true;
  10694. Object.defineProperty(target, descriptor.key, descriptor)
  10695. }
  10696. }
  10697. return function(Constructor, protoProps, staticProps) {
  10698. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  10699. if (staticProps) defineProperties(Constructor, staticProps);
  10700. return Constructor
  10701. }
  10702. } ();
  10703. var _pdfjsLib = __webpack_require__(1);
  10704. function _classCallCheck(instance, Constructor) {
  10705. if (! (instance instanceof Constructor)) {
  10706. throw new TypeError("Cannot call a class as a function");
  10707. }
  10708. }
  10709. var CSS_UNITS = 96.0 / 72.0;
  10710. var DEFAULT_SCALE_VALUE = 'auto';
  10711. var DEFAULT_SCALE = 1.0;
  10712. var MIN_SCALE = 0.25;
  10713. var MAX_SCALE = 10.0;
  10714. var UNKNOWN_SCALE = 0;
  10715. var MAX_AUTO_SCALE = 1.25;
  10716. var SCROLLBAR_PADDING = 40;
  10717. var VERTICAL_PADDING = 5;
  10718. var RendererType = {
  10719. CANVAS: 'canvas',
  10720. SVG: 'svg'
  10721. };
  10722. function formatL10nValue(text, args) {
  10723. if (!args) {
  10724. return text
  10725. }
  10726. return text.replace(/\{\{\s*(\w+)\s*\}\}/g,
  10727. function(all, name) {
  10728. return name in args ? args[name] : '{{' + name + '}}'
  10729. })
  10730. }
  10731. var NullL10n = {
  10732. get: function get(property, args, fallback) {
  10733. return Promise.resolve(formatL10nValue(fallback, args))
  10734. },
  10735. translate: function translate(element) {
  10736. return Promise.resolve()
  10737. }
  10738. };
  10739. _pdfjsLib.PDFJS.disableFullscreen = _pdfjsLib.PDFJS.disableFullscreen === undefined ? false: _pdfjsLib.PDFJS.disableFullscreen;
  10740. _pdfjsLib.PDFJS.useOnlyCssZoom = _pdfjsLib.PDFJS.useOnlyCssZoom === undefined ? false: _pdfjsLib.PDFJS.useOnlyCssZoom;
  10741. _pdfjsLib.PDFJS.maxCanvasPixels = _pdfjsLib.PDFJS.maxCanvasPixels === undefined ? 16777216 : _pdfjsLib.PDFJS.maxCanvasPixels;
  10742. _pdfjsLib.PDFJS.disableHistory = _pdfjsLib.PDFJS.disableHistory === undefined ? false: _pdfjsLib.PDFJS.disableHistory;
  10743. _pdfjsLib.PDFJS.disableTextLayer = _pdfjsLib.PDFJS.disableTextLayer === undefined ? false: _pdfjsLib.PDFJS.disableTextLayer;
  10744. _pdfjsLib.PDFJS.ignoreCurrentPositionOnZoom = _pdfjsLib.PDFJS.ignoreCurrentPositionOnZoom === undefined ? false: _pdfjsLib.PDFJS.ignoreCurrentPositionOnZoom; {
  10745. _pdfjsLib.PDFJS.locale = _pdfjsLib.PDFJS.locale === undefined && typeof navigator !== 'undefined' ? navigator.language: _pdfjsLib.PDFJS.locale
  10746. }
  10747. function getOutputScale(ctx) {
  10748. var devicePixelRatio = window.devicePixelRatio || 1;
  10749. var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
  10750. var pixelRatio = devicePixelRatio / backingStoreRatio;
  10751. return {
  10752. sx: pixelRatio,
  10753. sy: pixelRatio,
  10754. scaled: pixelRatio !== 1
  10755. }
  10756. }
  10757. function scrollIntoView(element, spot) {
  10758. var skipOverflowHiddenElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  10759. var parent = element.offsetParent;
  10760. if (!parent) {
  10761. console.error('offsetParent is not set -- cannot scroll');
  10762. return
  10763. }
  10764. var offsetY = element.offsetTop + element.clientTop;
  10765. var offsetX = element.offsetLeft + element.clientLeft;
  10766. while (parent.clientHeight === parent.scrollHeight || skipOverflowHiddenElements && getComputedStyle(parent).overflow === 'hidden') {
  10767. if (parent.dataset._scaleY) {
  10768. offsetY /= parent.dataset._scaleY;
  10769. offsetX /= parent.dataset._scaleX
  10770. }
  10771. offsetY += parent.offsetTop;
  10772. offsetX += parent.offsetLeft;
  10773. parent = parent.offsetParent;
  10774. if (!parent) {
  10775. return
  10776. }
  10777. }
  10778. if (spot) {
  10779. if (spot.top !== undefined) {
  10780. offsetY += spot.top
  10781. }
  10782. if (spot.left !== undefined) {
  10783. offsetX += spot.left;
  10784. parent.scrollLeft = offsetX
  10785. }
  10786. }
  10787. parent.scrollTop = offsetY
  10788. }
  10789. function watchScroll(viewAreaElement, callback) {
  10790. var debounceScroll = function debounceScroll(evt) {
  10791. if (rAF) {
  10792. return
  10793. }
  10794. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  10795. rAF = null;
  10796. var currentY = viewAreaElement.scrollTop;
  10797. var lastY = state.lastY;
  10798. if (currentY !== lastY) {
  10799. state.down = currentY > lastY
  10800. }
  10801. state.lastY = currentY;
  10802. callback(state)
  10803. })
  10804. };
  10805. var state = {
  10806. down: true,
  10807. lastY: viewAreaElement.scrollTop,
  10808. _eventHandler: debounceScroll
  10809. };
  10810. var rAF = null;
  10811. viewAreaElement.addEventListener('scroll', debounceScroll, true);
  10812. return state
  10813. }
  10814. function parseQueryString(query) {
  10815. var parts = query.split('&');
  10816. var params = Object.create(null);
  10817. for (var i = 0,
  10818. ii = parts.length; i < ii; ++i) {
  10819. var param = parts[i].split('=');
  10820. var key = param[0].toLowerCase();
  10821. var value = param.length > 1 ? param[1] : null;
  10822. params[decodeURIComponent(key)] = decodeURIComponent(value)
  10823. }
  10824. return params
  10825. }
  10826. function binarySearchFirstItem(items, condition) {
  10827. var minIndex = 0;
  10828. var maxIndex = items.length - 1;
  10829. if (items.length === 0 || !condition(items[maxIndex])) {
  10830. return items.length
  10831. }
  10832. if (condition(items[minIndex])) {
  10833. return minIndex
  10834. }
  10835. while (minIndex < maxIndex) {
  10836. var currentIndex = minIndex + maxIndex >> 1;
  10837. var currentItem = items[currentIndex];
  10838. if (condition(currentItem)) {
  10839. maxIndex = currentIndex
  10840. } else {
  10841. minIndex = currentIndex + 1
  10842. }
  10843. }
  10844. return minIndex
  10845. }
  10846. function approximateFraction(x) {
  10847. if (Math.floor(x) === x) {
  10848. return [x, 1]
  10849. }
  10850. var xinv = 1 / x;
  10851. var limit = 8;
  10852. if (xinv > limit) {
  10853. return [1, limit]
  10854. } else if (Math.floor(xinv) === xinv) {
  10855. return [1, xinv]
  10856. }
  10857. var x_ = x > 1 ? xinv: x;
  10858. var a = 0,
  10859. b = 1,
  10860. c = 1,
  10861. d = 1;
  10862. while (true) {
  10863. var p = a + c,
  10864. q = b + d;
  10865. if (q > limit) {
  10866. break
  10867. }
  10868. if (x_ <= p / q) {
  10869. c = p;
  10870. d = q
  10871. } else {
  10872. a = p;
  10873. b = q
  10874. }
  10875. }
  10876. var result = void 0;
  10877. if (x_ - a / b < c / d - x_) {
  10878. result = x_ === x ? [a, b] : [b, a]
  10879. } else {
  10880. result = x_ === x ? [c, d] : [d, c]
  10881. }
  10882. return result
  10883. }
  10884. function roundToDivide(x, div) {
  10885. var r = x % div;
  10886. return r === 0 ? x: Math.round(x - r + div)
  10887. }
  10888. function getVisibleElements(scrollEl, views) {
  10889. var sortByVisibility = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  10890. var top = scrollEl.scrollTop,
  10891. bottom = top + scrollEl.clientHeight;
  10892. var left = scrollEl.scrollLeft,
  10893. right = left + scrollEl.clientWidth;
  10894. function isElementBottomBelowViewTop(view) {
  10895. var element = view.div;
  10896. var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  10897. return elementBottom > top
  10898. }
  10899. var visible = [],
  10900. view = void 0,
  10901. element = void 0;
  10902. var currentHeight = void 0,
  10903. viewHeight = void 0,
  10904. hiddenHeight = void 0,
  10905. percentHeight = void 0;
  10906. var currentWidth = void 0,
  10907. viewWidth = void 0;
  10908. var firstVisibleElementInd = views.length === 0 ? 0 : binarySearchFirstItem(views, isElementBottomBelowViewTop);
  10909. for (var i = firstVisibleElementInd,
  10910. ii = views.length; i < ii; i++) {
  10911. view = views[i];
  10912. element = view.div;
  10913. currentHeight = element.offsetTop + element.clientTop;
  10914. viewHeight = element.clientHeight;
  10915. if (currentHeight > bottom) {
  10916. break
  10917. }
  10918. currentWidth = element.offsetLeft + element.clientLeft;
  10919. viewWidth = element.clientWidth;
  10920. if (currentWidth + viewWidth < left || currentWidth > right) {
  10921. continue
  10922. }
  10923. hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, currentHeight + viewHeight - bottom);
  10924. percentHeight = (viewHeight - hiddenHeight) * 100 / viewHeight | 0;
  10925. visible.push({
  10926. id: view.id,
  10927. x: currentWidth,
  10928. y: currentHeight,
  10929. view: view,
  10930. percent: percentHeight
  10931. })
  10932. }
  10933. var first = visible[0];
  10934. var last = visible[visible.length - 1];
  10935. if (sortByVisibility) {
  10936. visible.sort(function(a, b) {
  10937. var pc = a.percent - b.percent;
  10938. if (Math.abs(pc) > 0.001) {
  10939. return - pc
  10940. }
  10941. return a.id - b.id
  10942. })
  10943. }
  10944. return {
  10945. first: first,
  10946. last: last,
  10947. views: visible
  10948. }
  10949. }
  10950. function noContextMenuHandler(evt) {
  10951. evt.preventDefault()
  10952. }
  10953. function isDataSchema(url) {
  10954. var i = 0,
  10955. ii = url.length;
  10956. while (i < ii && url[i].trim() === '') {
  10957. i++
  10958. }
  10959. return url.substr(i, 5).toLowerCase() === 'data:'
  10960. }
  10961. function getPDFFileNameFromURL(url) {
  10962. var defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'document.pdf';
  10963. if (isDataSchema(url)) {
  10964. console.warn('getPDFFileNameFromURL: ' + 'ignoring "data:" URL for performance reasons.');
  10965. return defaultFilename
  10966. }
  10967. var reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
  10968. var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
  10969. var splitURI = reURI.exec(url);
  10970. var suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
  10971. if (suggestedFilename) {
  10972. suggestedFilename = suggestedFilename[0];
  10973. if (suggestedFilename.indexOf('%') !== -1) {
  10974. try {
  10975. suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0]
  10976. } catch(ex) {}
  10977. }
  10978. }
  10979. return suggestedFilename || defaultFilename
  10980. }
  10981. function normalizeWheelEventDelta(evt) {
  10982. var delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
  10983. var angle = Math.atan2(evt.deltaY, evt.deltaX);
  10984. if ( - 0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  10985. delta = -delta
  10986. }
  10987. var MOUSE_DOM_DELTA_PIXEL_MODE = 0;
  10988. var MOUSE_DOM_DELTA_LINE_MODE = 1;
  10989. var MOUSE_PIXELS_PER_LINE = 30;
  10990. var MOUSE_LINES_PER_PAGE = 30;
  10991. if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
  10992. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE
  10993. } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
  10994. delta /= MOUSE_LINES_PER_PAGE
  10995. }
  10996. return delta
  10997. }
  10998. function cloneObj(obj) {
  10999. var result = Object.create(null);
  11000. for (var i in obj) {
  11001. if (Object.prototype.hasOwnProperty.call(obj, i)) {
  11002. result[i] = obj[i]
  11003. }
  11004. }
  11005. return result
  11006. }
  11007. var animationStarted = new Promise(function(resolve) {
  11008. window.requestAnimationFrame(resolve)
  11009. });
  11010. var mozL10n = void 0;
  11011. var localized = Promise.resolve();
  11012. var EventBus = function() {
  11013. function EventBus() {
  11014. _classCallCheck(this, EventBus);
  11015. this._listeners = Object.create(null)
  11016. }
  11017. _createClass(EventBus, [{
  11018. key: 'on',
  11019. value: function on(eventName, listener) {
  11020. var eventListeners = this._listeners[eventName];
  11021. if (!eventListeners) {
  11022. eventListeners = [];
  11023. this._listeners[eventName] = eventListeners
  11024. }
  11025. eventListeners.push(listener)
  11026. }
  11027. },
  11028. {
  11029. key: 'off',
  11030. value: function off(eventName, listener) {
  11031. var eventListeners = this._listeners[eventName];
  11032. var i = void 0;
  11033. if (!eventListeners || (i = eventListeners.indexOf(listener)) < 0) {
  11034. return
  11035. }
  11036. eventListeners.splice(i, 1)
  11037. }
  11038. },
  11039. {
  11040. key: 'dispatch',
  11041. value: function dispatch(eventName) {
  11042. var eventListeners = this._listeners[eventName];
  11043. if (!eventListeners || eventListeners.length === 0) {
  11044. return
  11045. }
  11046. var args = Array.prototype.slice.call(arguments, 1);
  11047. eventListeners.slice(0).forEach(function(listener) {
  11048. listener.apply(null, args)
  11049. })
  11050. }
  11051. }]);
  11052. return EventBus
  11053. } ();
  11054. function clamp(v, min, max) {
  11055. return Math.min(Math.max(v, min), max)
  11056. }
  11057. var ProgressBar = function() {
  11058. function ProgressBar(id) {
  11059. var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  11060. height = _ref.height,
  11061. width = _ref.width,
  11062. units = _ref.units;
  11063. _classCallCheck(this, ProgressBar);
  11064. this.visible = true;
  11065. this.div = document.querySelector(id + ' .progress');
  11066. this.bar = this.div.parentNode;
  11067. this.height = height || 100;
  11068. this.width = width || 100;
  11069. this.units = units || '%';
  11070. this.div.style.height = this.height + this.units;
  11071. this.percent = 0
  11072. }
  11073. _createClass(ProgressBar, [{
  11074. key: '_updateBar',
  11075. value: function _updateBar() {
  11076. if (this._indeterminate) {
  11077. this.div.classList.add('indeterminate');
  11078. this.div.style.width = this.width + this.units;
  11079. return
  11080. }
  11081. this.div.classList.remove('indeterminate');
  11082. var progressSize = this.width * this._percent / 100;
  11083. this.div.style.width = progressSize + this.units
  11084. }
  11085. },
  11086. {
  11087. key: 'setWidth',
  11088. value: function setWidth(viewer) {
  11089. if (!viewer) {
  11090. return
  11091. }
  11092. var container = viewer.parentNode;
  11093. var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  11094. if (scrollbarWidth > 0) {
  11095. this.bar.setAttribute('style', 'width: calc(100% - ' + scrollbarWidth + 'px);')
  11096. }
  11097. }
  11098. },
  11099. {
  11100. key: 'hide',
  11101. value: function hide() {
  11102. if (!this.visible) {
  11103. return
  11104. }
  11105. this.visible = false;
  11106. this.bar.classList.add('hidden');
  11107. document.body.classList.remove('loadingInProgress')
  11108. }
  11109. },
  11110. {
  11111. key: 'show',
  11112. value: function show() {
  11113. if (this.visible) {
  11114. return
  11115. }
  11116. this.visible = true;
  11117. document.body.classList.add('loadingInProgress');
  11118. this.bar.classList.remove('hidden')
  11119. }
  11120. },
  11121. {
  11122. key: 'percent',
  11123. get: function get() {
  11124. return this._percent
  11125. },
  11126. set: function set(val) {
  11127. this._indeterminate = isNaN(val);
  11128. this._percent = clamp(val, 0, 100);
  11129. this._updateBar()
  11130. }
  11131. }]);
  11132. return ProgressBar
  11133. } ();
  11134. exports.CSS_UNITS = CSS_UNITS;
  11135. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  11136. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  11137. exports.MIN_SCALE = MIN_SCALE;
  11138. exports.MAX_SCALE = MAX_SCALE;
  11139. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  11140. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  11141. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  11142. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  11143. exports.cloneObj = cloneObj;
  11144. exports.RendererType = RendererType;
  11145. exports.mozL10n = mozL10n;
  11146. exports.NullL10n = NullL10n;
  11147. exports.EventBus = EventBus;
  11148. exports.ProgressBar = ProgressBar;
  11149. exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
  11150. exports.noContextMenuHandler = noContextMenuHandler;
  11151. exports.parseQueryString = parseQueryString;
  11152. exports.getVisibleElements = getVisibleElements;
  11153. exports.roundToDivide = roundToDivide;
  11154. exports.approximateFraction = approximateFraction;
  11155. exports.getOutputScale = getOutputScale;
  11156. exports.scrollIntoView = scrollIntoView;
  11157. exports.watchScroll = watchScroll;
  11158. exports.binarySearchFirstItem = binarySearchFirstItem;
  11159. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  11160. exports.animationStarted = animationStarted;
  11161. exports.localized = localized
  11162. }), (function(module, exports, __webpack_require__) {
  11163. "use strict";
  11164. var pdfjsLib;
  11165. if (typeof window !== 'undefined' && window['pdfjs-dist/build/pdf']) {
  11166. pdfjsLib = window['pdfjs-dist/build/pdf']
  11167. } else {
  11168. pdfjsLib = require('../build/pdf.js')
  11169. }
  11170. module.exports = pdfjsLib
  11171. }), (function(module, exports, __webpack_require__) {
  11172. "use strict";
  11173. Object.defineProperty(exports, "__esModule", {
  11174. value: true
  11175. });
  11176. exports.getGlobalEventBus = exports.attachDOMEventsToEventBus = undefined;
  11177. var _ui_utils = __webpack_require__(0);
  11178. function attachDOMEventsToEventBus(eventBus) {
  11179. eventBus.on('documentload',
  11180. function() {
  11181. var event = document.createEvent('CustomEvent');
  11182. event.initCustomEvent('documentload', true, true, {});
  11183. window.dispatchEvent(event)
  11184. });
  11185. eventBus.on('pagerendered',
  11186. function(evt) {
  11187. var event = document.createEvent('CustomEvent');
  11188. event.initCustomEvent('pagerendered', true, true, {
  11189. pageNumber: evt.pageNumber,
  11190. cssTransform: evt.cssTransform
  11191. });
  11192. evt.source.div.dispatchEvent(event)
  11193. });
  11194. eventBus.on('textlayerrendered',
  11195. function(evt) {
  11196. var event = document.createEvent('CustomEvent');
  11197. event.initCustomEvent('textlayerrendered', true, true, {
  11198. pageNumber: evt.pageNumber
  11199. });
  11200. evt.source.textLayerDiv.dispatchEvent(event)
  11201. });
  11202. eventBus.on('pagechange',
  11203. function(evt) {
  11204. var event = document.createEvent('UIEvents');
  11205. event.initUIEvent('pagechange', true, true, window, 0);
  11206. event.pageNumber = evt.pageNumber;
  11207. evt.source.container.dispatchEvent(event)
  11208. });
  11209. eventBus.on('pagesinit',
  11210. function(evt) {
  11211. var event = document.createEvent('CustomEvent');
  11212. event.initCustomEvent('pagesinit', true, true, null);
  11213. evt.source.container.dispatchEvent(event)
  11214. });
  11215. eventBus.on('pagesloaded',
  11216. function(evt) {
  11217. var event = document.createEvent('CustomEvent');
  11218. event.initCustomEvent('pagesloaded', true, true, {
  11219. pagesCount: evt.pagesCount
  11220. });
  11221. evt.source.container.dispatchEvent(event)
  11222. });
  11223. eventBus.on('scalechange',
  11224. function(evt) {
  11225. var event = document.createEvent('UIEvents');
  11226. event.initUIEvent('scalechange', true, true, window, 0);
  11227. event.scale = evt.scale;
  11228. event.presetValue = evt.presetValue;
  11229. evt.source.container.dispatchEvent(event)
  11230. });
  11231. eventBus.on('updateviewarea',
  11232. function(evt) {
  11233. var event = document.createEvent('UIEvents');
  11234. event.initUIEvent('updateviewarea', true, true, window, 0);
  11235. event.location = evt.location;
  11236. evt.source.container.dispatchEvent(event)
  11237. });
  11238. eventBus.on('find',
  11239. function(evt) {
  11240. if (evt.source === window) {
  11241. return
  11242. }
  11243. var event = document.createEvent('CustomEvent');
  11244. event.initCustomEvent('find' + evt.type, true, true, {
  11245. query: evt.query,
  11246. phraseSearch: evt.phraseSearch,
  11247. caseSensitive: evt.caseSensitive,
  11248. highlightAll: evt.highlightAll,
  11249. findPrevious: evt.findPrevious
  11250. });
  11251. window.dispatchEvent(event)
  11252. });
  11253. eventBus.on('attachmentsloaded',
  11254. function(evt) {
  11255. var event = document.createEvent('CustomEvent');
  11256. event.initCustomEvent('attachmentsloaded', true, true, {
  11257. attachmentsCount: evt.attachmentsCount
  11258. });
  11259. evt.source.container.dispatchEvent(event)
  11260. });
  11261. eventBus.on('sidebarviewchanged',
  11262. function(evt) {
  11263. var event = document.createEvent('CustomEvent');
  11264. event.initCustomEvent('sidebarviewchanged', true, true, {
  11265. view: evt.view
  11266. });
  11267. evt.source.outerContainer.dispatchEvent(event)
  11268. });
  11269. eventBus.on('pagemode',
  11270. function(evt) {
  11271. var event = document.createEvent('CustomEvent');
  11272. event.initCustomEvent('pagemode', true, true, {
  11273. mode: evt.mode
  11274. });
  11275. evt.source.pdfViewer.container.dispatchEvent(event)
  11276. });
  11277. eventBus.on('namedaction',
  11278. function(evt) {
  11279. var event = document.createEvent('CustomEvent');
  11280. event.initCustomEvent('namedaction', true, true, {
  11281. action: evt.action
  11282. });
  11283. evt.source.pdfViewer.container.dispatchEvent(event)
  11284. });
  11285. eventBus.on('presentationmodechanged',
  11286. function(evt) {
  11287. var event = document.createEvent('CustomEvent');
  11288. event.initCustomEvent('presentationmodechanged', true, true, {
  11289. active: evt.active,
  11290. switchInProgress: evt.switchInProgress
  11291. });
  11292. window.dispatchEvent(event)
  11293. });
  11294. eventBus.on('outlineloaded',
  11295. function(evt) {
  11296. var event = document.createEvent('CustomEvent');
  11297. event.initCustomEvent('outlineloaded', true, true, {
  11298. outlineCount: evt.outlineCount
  11299. });
  11300. evt.source.container.dispatchEvent(event)
  11301. })
  11302. }
  11303. var globalEventBus = null;
  11304. function getGlobalEventBus() {
  11305. if (globalEventBus) {
  11306. return globalEventBus
  11307. }
  11308. globalEventBus = new _ui_utils.EventBus();
  11309. attachDOMEventsToEventBus(globalEventBus);
  11310. return globalEventBus
  11311. }
  11312. exports.attachDOMEventsToEventBus = attachDOMEventsToEventBus;
  11313. exports.getGlobalEventBus = getGlobalEventBus
  11314. }), (function(module, exports, __webpack_require__) {
  11315. "use strict";
  11316. Object.defineProperty(exports, "__esModule", {
  11317. value: true
  11318. });
  11319. var _createClass = function() {
  11320. function defineProperties(target, props) {
  11321. for (var i = 0; i < props.length; i++) {
  11322. var descriptor = props[i];
  11323. descriptor.enumerable = descriptor.enumerable || false;
  11324. descriptor.configurable = true;
  11325. if ("value" in descriptor) descriptor.writable = true;
  11326. Object.defineProperty(target, descriptor.key, descriptor)
  11327. }
  11328. }
  11329. return function(Constructor, protoProps, staticProps) {
  11330. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  11331. if (staticProps) defineProperties(Constructor, staticProps);
  11332. return Constructor
  11333. }
  11334. } ();
  11335. function _classCallCheck(instance, Constructor) {
  11336. if (! (instance instanceof Constructor)) {
  11337. throw new TypeError("Cannot call a class as a function");
  11338. }
  11339. }
  11340. var CLEANUP_TIMEOUT = 30000;
  11341. var RenderingStates = {
  11342. INITIAL: 0,
  11343. RUNNING: 1,
  11344. PAUSED: 2,
  11345. FINISHED: 3
  11346. };
  11347. var PDFRenderingQueue = function() {
  11348. function PDFRenderingQueue() {
  11349. _classCallCheck(this, PDFRenderingQueue);
  11350. this.pdfViewer = null;
  11351. this.pdfThumbnailViewer = null;
  11352. this.onIdle = null;
  11353. this.highestPriorityPage = null;
  11354. this.idleTimeout = null;
  11355. this.printing = false;
  11356. this.isThumbnailViewEnabled = false
  11357. }
  11358. _createClass(PDFRenderingQueue, [{
  11359. key: "setViewer",
  11360. value: function setViewer(pdfViewer) {
  11361. this.pdfViewer = pdfViewer
  11362. }
  11363. },
  11364. {
  11365. key: "setThumbnailViewer",
  11366. value: function setThumbnailViewer(pdfThumbnailViewer) {
  11367. this.pdfThumbnailViewer = pdfThumbnailViewer
  11368. }
  11369. },
  11370. {
  11371. key: "isHighestPriority",
  11372. value: function isHighestPriority(view) {
  11373. return this.highestPriorityPage === view.renderingId
  11374. }
  11375. },
  11376. {
  11377. key: "renderHighestPriority",
  11378. value: function renderHighestPriority(currentlyVisiblePages) {
  11379. if (this.idleTimeout) {
  11380. clearTimeout(this.idleTimeout);
  11381. this.idleTimeout = null
  11382. }
  11383. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  11384. return
  11385. }
  11386. if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
  11387. if (this.pdfThumbnailViewer.forceRendering()) {
  11388. return
  11389. }
  11390. }
  11391. if (this.printing) {
  11392. return
  11393. }
  11394. if (this.onIdle) {
  11395. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT)
  11396. }
  11397. }
  11398. },
  11399. {
  11400. key: "getHighestPriority",
  11401. value: function getHighestPriority(visible, views, scrolledDown) {
  11402. var visibleViews = visible.views;
  11403. var numVisible = visibleViews.length;
  11404. if (numVisible === 0) {
  11405. return false
  11406. }
  11407. for (var i = 0; i < numVisible; ++i) {
  11408. var view = visibleViews[i].view;
  11409. if (!this.isViewFinished(view)) {
  11410. return view
  11411. }
  11412. }
  11413. if (scrolledDown) {
  11414. var nextPageIndex = visible.last.id;
  11415. if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {
  11416. return views[nextPageIndex]
  11417. }
  11418. } else {
  11419. var previousPageIndex = visible.first.id - 2;
  11420. if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) {
  11421. return views[previousPageIndex]
  11422. }
  11423. }
  11424. return null
  11425. }
  11426. },
  11427. {
  11428. key: "isViewFinished",
  11429. value: function isViewFinished(view) {
  11430. return view.renderingState === RenderingStates.FINISHED
  11431. }
  11432. },
  11433. {
  11434. key: "renderView",
  11435. value: function renderView(view) {
  11436. var _this = this;
  11437. switch (view.renderingState) {
  11438. case RenderingStates.FINISHED:
  11439. return false;
  11440. case RenderingStates.PAUSED:
  11441. this.highestPriorityPage = view.renderingId;
  11442. view.resume();
  11443. break;
  11444. case RenderingStates.RUNNING:
  11445. this.highestPriorityPage = view.renderingId;
  11446. break;
  11447. case RenderingStates.INITIAL:
  11448. this.highestPriorityPage = view.renderingId;
  11449. var continueRendering = function continueRendering() {
  11450. _this.renderHighestPriority()
  11451. };
  11452. view.draw().then(continueRendering, continueRendering);
  11453. break
  11454. }
  11455. return true
  11456. }
  11457. }]);
  11458. return PDFRenderingQueue
  11459. } ();
  11460. exports.RenderingStates = RenderingStates;
  11461. exports.PDFRenderingQueue = PDFRenderingQueue
  11462. }), (function(module, exports, __webpack_require__) {
  11463. "use strict";
  11464. Object.defineProperty(exports, "__esModule", {
  11465. value: true
  11466. });
  11467. exports.PDFPrintServiceFactory = exports.DefaultExternalServices = exports.PDFViewerApplication = undefined;
  11468. var _slicedToArray = function() {
  11469. function sliceIterator(arr, i) {
  11470. var _arr = [];
  11471. var _n = true;
  11472. var _d = false;
  11473. var _e = undefined;
  11474. try {
  11475. for (var _i = arr[Symbol.iterator](), _s; ! (_n = (_s = _i.next()).done); _n = true) {
  11476. _arr.push(_s.value);
  11477. if (i && _arr.length === i) break
  11478. }
  11479. } catch(err) {
  11480. _d = true;
  11481. _e = err
  11482. } finally {
  11483. try {
  11484. if (!_n && _i["return"]) _i["return"]()
  11485. } finally {
  11486. if (_d) throw _e;
  11487. }
  11488. }
  11489. return _arr
  11490. }
  11491. return function(arr, i) {
  11492. if (Array.isArray(arr)) {
  11493. return arr
  11494. } else if (Symbol.iterator in Object(arr)) {
  11495. return sliceIterator(arr, i)
  11496. } else {
  11497. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  11498. }
  11499. }
  11500. } ();
  11501. var _ui_utils = __webpack_require__(0);
  11502. var _pdfjsLib = __webpack_require__(1);
  11503. var _pdf_cursor_tools = __webpack_require__(6);
  11504. var _pdf_rendering_queue = __webpack_require__(3);
  11505. var _pdf_sidebar = __webpack_require__(24);
  11506. var _pdf_viewer = __webpack_require__(27);
  11507. var _dom_events = __webpack_require__(2);
  11508. var _overlay_manager = __webpack_require__(15);
  11509. var _password_prompt = __webpack_require__(16);
  11510. var _pdf_attachment_viewer = __webpack_require__(17);
  11511. var _pdf_document_properties = __webpack_require__(18);
  11512. var _pdf_find_bar = __webpack_require__(19);
  11513. var _pdf_find_controller = __webpack_require__(7);
  11514. var _pdf_history = __webpack_require__(20);
  11515. var _pdf_link_service = __webpack_require__(5);
  11516. var _pdf_outline_viewer = __webpack_require__(21);
  11517. var _pdf_presentation_mode = __webpack_require__(23);
  11518. var _pdf_thumbnail_viewer = __webpack_require__(26);
  11519. var _secondary_toolbar = __webpack_require__(29);
  11520. var _toolbar = __webpack_require__(31);
  11521. var _view_history = __webpack_require__(32);
  11522. var DEFAULT_SCALE_DELTA = 1.1;
  11523. var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
  11524. function configure(PDFJS) {
  11525. PDFJS.imageResourcesPath = './images/';
  11526. PDFJS.workerSrc = '../build/pdf.worker.js';
  11527. PDFJS.cMapUrl = '../web/cmaps/';
  11528. PDFJS.cMapPacked = true
  11529. }
  11530. var DefaultExternalServices = {
  11531. updateFindControlState: function updateFindControlState(data) {},
  11532. initPassiveLoading: function initPassiveLoading(callbacks) {},
  11533. fallback: function fallback(data, callback) {},
  11534. reportTelemetry: function reportTelemetry(data) {},
  11535. createDownloadManager: function createDownloadManager() {
  11536. throw new Error('Not implemented: createDownloadManager');
  11537. },
  11538. createPreferences: function createPreferences() {
  11539. throw new Error('Not implemented: createPreferences');
  11540. },
  11541. createL10n: function createL10n() {
  11542. throw new Error('Not implemented: createL10n');
  11543. },
  11544. supportsIntegratedFind: false,
  11545. supportsDocumentFonts: true,
  11546. supportsDocumentColors: true,
  11547. supportedMouseWheelZoomModifierKeys: {
  11548. ctrlKey: true,
  11549. metaKey: true
  11550. }
  11551. };
  11552. var PDFViewerApplication = {
  11553. initialBookmark: document.location.hash.substring(1),
  11554. initialDestination: null,
  11555. initialized: false,
  11556. fellback: false,
  11557. appConfig: null,
  11558. pdfDocument: null,
  11559. pdfLoadingTask: null,
  11560. printService: null,
  11561. pdfViewer: null,
  11562. pdfThumbnailViewer: null,
  11563. pdfRenderingQueue: null,
  11564. pdfPresentationMode: null,
  11565. pdfDocumentProperties: null,
  11566. pdfLinkService: null,
  11567. pdfHistory: null,
  11568. pdfSidebar: null,
  11569. pdfOutlineViewer: null,
  11570. pdfAttachmentViewer: null,
  11571. pdfCursorTools: null,
  11572. store: null,
  11573. downloadManager: null,
  11574. overlayManager: null,
  11575. preferences: null,
  11576. toolbar: null,
  11577. secondaryToolbar: null,
  11578. eventBus: null,
  11579. l10n: null,
  11580. isInitialViewSet: false,
  11581. downloadComplete: false,
  11582. viewerPrefs: {
  11583. sidebarViewOnLoad: _pdf_sidebar.SidebarView.NONE,
  11584. pdfBugEnabled: false,
  11585. showPreviousViewOnLoad: true,
  11586. defaultZoomValue: '',
  11587. disablePageMode: false,
  11588. disablePageLabels: false,
  11589. renderer: 'canvas',
  11590. enhanceTextSelection: false,
  11591. renderInteractiveForms: false,
  11592. enablePrintAutoRotate: false
  11593. },
  11594. isViewerEmbedded: window.parent !== window,
  11595. url: '',
  11596. baseUrl: '',
  11597. externalServices: DefaultExternalServices,
  11598. _boundEvents: {},
  11599. initialize: function initialize(appConfig) {
  11600. var _this = this;
  11601. this.preferences = this.externalServices.createPreferences();
  11602. configure(_pdfjsLib.PDFJS);
  11603. this.appConfig = appConfig;
  11604. return this._readPreferences().then(function() {
  11605. return _this._initializeL10n()
  11606. }).then(function() {
  11607. return _this._initializeViewerComponents()
  11608. }).then(function() {
  11609. _this.bindEvents();
  11610. _this.bindWindowEvents();
  11611. var appContainer = appConfig.appContainer || document.documentElement;
  11612. _this.l10n.translate(appContainer).then(function() {
  11613. _this.eventBus.dispatch('localized')
  11614. });
  11615. if (_this.isViewerEmbedded && !_pdfjsLib.PDFJS.isExternalLinkTargetSet()) {
  11616. _pdfjsLib.PDFJS.externalLinkTarget = _pdfjsLib.PDFJS.LinkTarget.TOP
  11617. }
  11618. _this.initialized = true
  11619. })
  11620. },
  11621. _readPreferences: function _readPreferences() {
  11622. var preferences = this.preferences,
  11623. viewerPrefs = this.viewerPrefs;
  11624. return Promise.all([preferences.get('enableWebGL').then(function resolved(value) {
  11625. _pdfjsLib.PDFJS.disableWebGL = !value
  11626. }), preferences.get('sidebarViewOnLoad').then(function resolved(value) {
  11627. viewerPrefs['sidebarViewOnLoad'] = value
  11628. }), preferences.get('pdfBugEnabled').then(function resolved(value) {
  11629. viewerPrefs['pdfBugEnabled'] = value
  11630. }), preferences.get('showPreviousViewOnLoad').then(function resolved(value) {
  11631. viewerPrefs['showPreviousViewOnLoad'] = value
  11632. }), preferences.get('defaultZoomValue').then(function resolved(value) {
  11633. viewerPrefs['defaultZoomValue'] = value
  11634. }), preferences.get('enhanceTextSelection').then(function resolved(value) {
  11635. viewerPrefs['enhanceTextSelection'] = value
  11636. }), preferences.get('disableTextLayer').then(function resolved(value) {
  11637. if (_pdfjsLib.PDFJS.disableTextLayer === true) {
  11638. return
  11639. }
  11640. _pdfjsLib.PDFJS.disableTextLayer = value
  11641. }), preferences.get('disableRange').then(function resolved(value) {
  11642. if (_pdfjsLib.PDFJS.disableRange === true) {
  11643. return
  11644. }
  11645. _pdfjsLib.PDFJS.disableRange = value
  11646. }), preferences.get('disableStream').then(function resolved(value) {
  11647. if (_pdfjsLib.PDFJS.disableStream === true) {
  11648. return
  11649. }
  11650. _pdfjsLib.PDFJS.disableStream = value
  11651. }), preferences.get('disableAutoFetch').then(function resolved(value) {
  11652. _pdfjsLib.PDFJS.disableAutoFetch = value
  11653. }), preferences.get('disableFontFace').then(function resolved(value) {
  11654. if (_pdfjsLib.PDFJS.disableFontFace === true) {
  11655. return
  11656. }
  11657. _pdfjsLib.PDFJS.disableFontFace = value
  11658. }), preferences.get('useOnlyCssZoom').then(function resolved(value) {
  11659. _pdfjsLib.PDFJS.useOnlyCssZoom = value
  11660. }), preferences.get('externalLinkTarget').then(function resolved(value) {
  11661. if (_pdfjsLib.PDFJS.isExternalLinkTargetSet()) {
  11662. return
  11663. }
  11664. _pdfjsLib.PDFJS.externalLinkTarget = value
  11665. }), preferences.get('renderer').then(function resolved(value) {
  11666. viewerPrefs['renderer'] = value
  11667. }), preferences.get('renderInteractiveForms').then(function resolved(value) {
  11668. viewerPrefs['renderInteractiveForms'] = value
  11669. }), preferences.get('disablePageMode').then(function resolved(value) {
  11670. viewerPrefs['disablePageMode'] = value
  11671. }), preferences.get('disablePageLabels').then(function resolved(value) {
  11672. viewerPrefs['disablePageLabels'] = value
  11673. }), preferences.get('enablePrintAutoRotate').then(function resolved(value) {
  11674. viewerPrefs['enablePrintAutoRotate'] = value
  11675. })]).
  11676. catch(function(reason) {})
  11677. },
  11678. _initializeL10n: function _initializeL10n() {
  11679. if (this.viewerPrefs['pdfBugEnabled']) {
  11680. var hash = document.location.hash.substring(1);
  11681. var hashParams = (0, _ui_utils.parseQueryString)(hash);
  11682. if ('locale' in hashParams) {
  11683. _pdfjsLib.PDFJS.locale = hashParams['locale']
  11684. }
  11685. }
  11686. this.l10n = this.externalServices.createL10n();
  11687. return this.l10n.getDirection().then(function(dir) {
  11688. document.getElementsByTagName('html')[0].dir = dir
  11689. })
  11690. },
  11691. _initializeViewerComponents: function _initializeViewerComponents() {
  11692. var _this2 = this;
  11693. var appConfig = this.appConfig;
  11694. return new Promise(function(resolve, reject) {
  11695. _this2.overlayManager = new _overlay_manager.OverlayManager();
  11696. var eventBus = appConfig.eventBus || (0, _dom_events.getGlobalEventBus)();
  11697. _this2.eventBus = eventBus;
  11698. var pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  11699. pdfRenderingQueue.onIdle = _this2.cleanup.bind(_this2);
  11700. _this2.pdfRenderingQueue = pdfRenderingQueue;
  11701. var pdfLinkService = new _pdf_link_service.PDFLinkService({
  11702. eventBus: eventBus
  11703. });
  11704. _this2.pdfLinkService = pdfLinkService;
  11705. var downloadManager = _this2.externalServices.createDownloadManager();
  11706. _this2.downloadManager = downloadManager;
  11707. var container = appConfig.mainContainer;
  11708. var viewer = appConfig.viewerContainer;
  11709. _this2.pdfViewer = new _pdf_viewer.PDFViewer({
  11710. container: container,
  11711. viewer: viewer,
  11712. eventBus: eventBus,
  11713. renderingQueue: pdfRenderingQueue,
  11714. linkService: pdfLinkService,
  11715. downloadManager: downloadManager,
  11716. renderer: _this2.viewerPrefs['renderer'],
  11717. l10n: _this2.l10n,
  11718. enhanceTextSelection: _this2.viewerPrefs['enhanceTextSelection'],
  11719. renderInteractiveForms: _this2.viewerPrefs['renderInteractiveForms'],
  11720. enablePrintAutoRotate: _this2.viewerPrefs['enablePrintAutoRotate']
  11721. });
  11722. pdfRenderingQueue.setViewer(_this2.pdfViewer);
  11723. pdfLinkService.setViewer(_this2.pdfViewer);
  11724. var thumbnailContainer = appConfig.sidebar.thumbnailView;
  11725. _this2.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({
  11726. container: thumbnailContainer,
  11727. renderingQueue: pdfRenderingQueue,
  11728. linkService: pdfLinkService,
  11729. l10n: _this2.l10n
  11730. });
  11731. pdfRenderingQueue.setThumbnailViewer(_this2.pdfThumbnailViewer);
  11732. _this2.pdfHistory = new _pdf_history.PDFHistory({
  11733. linkService: pdfLinkService,
  11734. eventBus: eventBus
  11735. });
  11736. pdfLinkService.setHistory(_this2.pdfHistory);
  11737. _this2.findController = new _pdf_find_controller.PDFFindController({
  11738. pdfViewer: _this2.pdfViewer
  11739. });
  11740. _this2.findController.onUpdateResultsCount = function(matchCount) {
  11741. if (_this2.supportsIntegratedFind) {
  11742. return
  11743. }
  11744. _this2.findBar.updateResultsCount(matchCount)
  11745. };
  11746. _this2.findController.onUpdateState = function(state, previous, matchCount) {
  11747. if (_this2.supportsIntegratedFind) {
  11748. _this2.externalServices.updateFindControlState({
  11749. result: state,
  11750. findPrevious: previous
  11751. })
  11752. } else {
  11753. _this2.findBar.updateUIState(state, previous, matchCount)
  11754. }
  11755. };
  11756. _this2.pdfViewer.setFindController(_this2.findController);
  11757. var findBarConfig = Object.create(appConfig.findBar);
  11758. findBarConfig.findController = _this2.findController;
  11759. findBarConfig.eventBus = eventBus;
  11760. _this2.findBar = new _pdf_find_bar.PDFFindBar(findBarConfig, _this2.l10n);
  11761. _this2.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, _this2.overlayManager, _this2.l10n);
  11762. _this2.pdfCursorTools = new _pdf_cursor_tools.PDFCursorTools({
  11763. container: container,
  11764. eventBus: eventBus,
  11765. preferences: _this2.preferences
  11766. });
  11767. _this2.toolbar = new _toolbar.Toolbar(appConfig.toolbar, container, eventBus, _this2.l10n);
  11768. _this2.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus);
  11769. if (_this2.supportsFullscreen) {
  11770. _this2.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({
  11771. container: container,
  11772. viewer: viewer,
  11773. pdfViewer: _this2.pdfViewer,
  11774. eventBus: eventBus,
  11775. contextMenuItems: appConfig.fullscreen
  11776. })
  11777. }
  11778. _this2.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, _this2.overlayManager, _this2.l10n);
  11779. _this2.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({
  11780. container: appConfig.sidebar.outlineView,
  11781. eventBus: eventBus,
  11782. linkService: pdfLinkService
  11783. });
  11784. _this2.pdfAttachmentViewer = new _pdf_attachment_viewer.PDFAttachmentViewer({
  11785. container: appConfig.sidebar.attachmentsView,
  11786. eventBus: eventBus,
  11787. downloadManager: downloadManager
  11788. });
  11789. var sidebarConfig = Object.create(appConfig.sidebar);
  11790. sidebarConfig.pdfViewer = _this2.pdfViewer;
  11791. sidebarConfig.pdfThumbnailViewer = _this2.pdfThumbnailViewer;
  11792. sidebarConfig.pdfOutlineViewer = _this2.pdfOutlineViewer;
  11793. sidebarConfig.eventBus = eventBus;
  11794. _this2.pdfSidebar = new _pdf_sidebar.PDFSidebar(sidebarConfig, _this2.l10n);
  11795. _this2.pdfSidebar.onToggled = _this2.forceRendering.bind(_this2);
  11796. resolve(undefined)
  11797. })
  11798. },
  11799. run: function run(config) {
  11800. this.initialize(config).then(webViewerInitialized)
  11801. },
  11802. zoomIn: function zoomIn(ticks) {
  11803. var newScale = this.pdfViewer.currentScale;
  11804. do {
  11805. newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2);
  11806. newScale = Math.ceil(newScale * 10) / 10;
  11807. newScale = Math.min(_ui_utils.MAX_SCALE, newScale)
  11808. } while (-- ticks > 0 && newScale < _ui_utils . MAX_SCALE );
  11809. this.pdfViewer.currentScaleValue = newScale
  11810. },
  11811. zoomOut: function zoomOut(ticks) {
  11812. var newScale = this.pdfViewer.currentScale;
  11813. do {
  11814. newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2);
  11815. newScale = Math.floor(newScale * 10) / 10;
  11816. newScale = Math.max(_ui_utils.MIN_SCALE, newScale)
  11817. } while (-- ticks > 0 && newScale > _ui_utils . MIN_SCALE );
  11818. this.pdfViewer.currentScaleValue = newScale
  11819. },
  11820. get pagesCount() {
  11821. return this.pdfDocument ? this.pdfDocument.numPages: 0
  11822. },
  11823. get pageRotation() {
  11824. return this.pdfViewer.pagesRotation
  11825. },
  11826. set page(val) {
  11827. this.pdfViewer.currentPageNumber = val
  11828. },
  11829. get page() {
  11830. return this.pdfViewer.currentPageNumber
  11831. },
  11832. get printing() {
  11833. return !! this.printService
  11834. },
  11835. get supportsPrinting() {
  11836. return PDFPrintServiceFactory.instance.supportsPrinting
  11837. },
  11838. get supportsFullscreen() {
  11839. var support = void 0;
  11840. var doc = document.documentElement;
  11841. support = !!(doc.requestFullscreen || doc.mozRequestFullScreen || doc.webkitRequestFullScreen || doc.msRequestFullscreen);
  11842. if (document.fullscreenEnabled === false || document.mozFullScreenEnabled === false || document.webkitFullscreenEnabled === false || document.msFullscreenEnabled === false) {
  11843. support = false
  11844. }
  11845. if (support && _pdfjsLib.PDFJS.disableFullscreen === true) {
  11846. support = false
  11847. }
  11848. return (0, _pdfjsLib.shadow)(this, 'supportsFullscreen', support)
  11849. },
  11850. get supportsIntegratedFind() {
  11851. return this.externalServices.supportsIntegratedFind
  11852. },
  11853. get supportsDocumentFonts() {
  11854. return this.externalServices.supportsDocumentFonts
  11855. },
  11856. get supportsDocumentColors() {
  11857. return this.externalServices.supportsDocumentColors
  11858. },
  11859. get loadingBar() {
  11860. var bar = new _ui_utils.ProgressBar('#loadingBar');
  11861. return (0, _pdfjsLib.shadow)(this, 'loadingBar', bar)
  11862. },
  11863. get supportedMouseWheelZoomModifierKeys() {
  11864. return this.externalServices.supportedMouseWheelZoomModifierKeys
  11865. },
  11866. initPassiveLoading: function initPassiveLoading() {
  11867. throw new Error('Not implemented: initPassiveLoading');
  11868. },
  11869. setTitleUsingUrl: function setTitleUsingUrl(url) {
  11870. this.url = url;
  11871. this.baseUrl = url.split('#')[0];
  11872. var title = (0, _ui_utils.getPDFFileNameFromURL)(url, '');
  11873. if (!title) {
  11874. try {
  11875. title = decodeURIComponent((0, _pdfjsLib.getFilenameFromUrl)(url)) || url
  11876. } catch(ex) {
  11877. title = url
  11878. }
  11879. }
  11880. this.setTitle(title)
  11881. },
  11882. setTitle: function setTitle(title) {
  11883. if (this.isViewerEmbedded) {
  11884. return
  11885. }
  11886. document.title = title
  11887. },
  11888. close: function close() {
  11889. var errorWrapper = this.appConfig.errorWrapper.container;
  11890. errorWrapper.setAttribute('hidden', 'true');
  11891. if (!this.pdfLoadingTask) {
  11892. return Promise.resolve()
  11893. }
  11894. var promise = this.pdfLoadingTask.destroy();
  11895. this.pdfLoadingTask = null;
  11896. if (this.pdfDocument) {
  11897. this.pdfDocument = null;
  11898. this.pdfThumbnailViewer.setDocument(null);
  11899. this.pdfViewer.setDocument(null);
  11900. this.pdfLinkService.setDocument(null, null);
  11901. this.pdfDocumentProperties.setDocument(null, null)
  11902. }
  11903. this.store = null;
  11904. this.isInitialViewSet = false;
  11905. this.downloadComplete = false;
  11906. this.pdfSidebar.reset();
  11907. this.pdfOutlineViewer.reset();
  11908. this.pdfAttachmentViewer.reset();
  11909. this.findController.reset();
  11910. this.findBar.reset();
  11911. this.toolbar.reset();
  11912. this.secondaryToolbar.reset();
  11913. if (typeof PDFBug !== 'undefined') {
  11914. PDFBug.cleanup()
  11915. }
  11916. return promise
  11917. },
  11918. open: function open(file, args) {
  11919. var _this3 = this;
  11920. if (arguments.length > 2 || typeof args === 'number') {
  11921. return Promise.reject(new Error('Call of open() with obsolete signature.'))
  11922. }
  11923. if (this.pdfLoadingTask) {
  11924. return this.close().then(function() {
  11925. _this3.preferences.reload();
  11926. return _this3.open(file, args)
  11927. })
  11928. }
  11929. var parameters = Object.create(null),
  11930. scale = void 0;
  11931. if (typeof file === 'string') {
  11932. this.setTitleUsingUrl(file);
  11933. parameters.url = file
  11934. } else if (file && 'byteLength' in file) {
  11935. parameters.data = file
  11936. } else if (file.url && file.originalUrl) {
  11937. this.setTitleUsingUrl(file.originalUrl);
  11938. parameters.url = file.url
  11939. }
  11940. if (args) {
  11941. for (var prop in args) {
  11942. parameters[prop] = args[prop]
  11943. }
  11944. if (args.scale) {
  11945. scale = args.scale
  11946. }
  11947. if (args.length) {
  11948. this.pdfDocumentProperties.setFileSize(args.length)
  11949. }
  11950. }
  11951. var loadingTask = (0, _pdfjsLib.getDocument)(parameters);
  11952. this.pdfLoadingTask = loadingTask;
  11953. loadingTask.onPassword = function(updateCallback, reason) {
  11954. _this3.passwordPrompt.setUpdateCallback(updateCallback, reason);
  11955. _this3.passwordPrompt.open()
  11956. };
  11957. loadingTask.onProgress = function(_ref) {
  11958. var loaded = _ref.loaded,
  11959. total = _ref.total;
  11960. _this3.progress(loaded / total)
  11961. };
  11962. loadingTask.onUnsupportedFeature = this.fallback.bind(this);
  11963. return loadingTask.promise.then(function(pdfDocument) {
  11964. _this3.load(pdfDocument, scale)
  11965. },
  11966. function(exception) {
  11967. var message = exception && exception.message;
  11968. var loadingErrorMessage = void 0;
  11969. if (exception instanceof _pdfjsLib.InvalidPDFException) {
  11970. loadingErrorMessage = _this3.l10n.get('invalid_file_error', null, 'Invalid or corrupted PDF file.')
  11971. } else if (exception instanceof _pdfjsLib.MissingPDFException) {
  11972. loadingErrorMessage = _this3.l10n.get('missing_file_error', null, 'Missing PDF file.')
  11973. } else if (exception instanceof _pdfjsLib.UnexpectedResponseException) {
  11974. loadingErrorMessage = _this3.l10n.get('unexpected_response_error', null, 'Unexpected server response.')
  11975. } else {
  11976. loadingErrorMessage = _this3.l10n.get('loading_error', null, 'An error occurred while loading the PDF.')
  11977. }
  11978. return loadingErrorMessage.then(function(msg) {
  11979. _this3.error(msg, {
  11980. message: message
  11981. });
  11982. throw new Error(msg);
  11983. })
  11984. })
  11985. },
  11986. download: function download() {
  11987. var _this4 = this;
  11988. function downloadByUrl() {
  11989. downloadManager.downloadUrl(url, filename)
  11990. }
  11991. var url = this.baseUrl;
  11992. var filename = (0, _ui_utils.getPDFFileNameFromURL)(this.url);
  11993. var downloadManager = this.downloadManager;
  11994. downloadManager.onerror = function(err) {
  11995. _this4.error('PDF failed to download: ' + err)
  11996. };
  11997. if (!this.pdfDocument || !this.downloadComplete) {
  11998. downloadByUrl();
  11999. return
  12000. }
  12001. this.pdfDocument.getData().then(function(data) {
  12002. var blob = (0, _pdfjsLib.createBlob)(data, 'application/pdf');
  12003. downloadManager.download(blob, url, filename)
  12004. }).
  12005. catch(downloadByUrl)
  12006. },
  12007. fallback: function fallback(featureId) {},
  12008. error: function error(message, moreInfo) {
  12009. var moreInfoText = [this.l10n.get('error_version_info', {
  12010. version: _pdfjsLib.version || '?',
  12011. build: _pdfjsLib.build || '?'
  12012. },
  12013. 'PDF.js v{{version}} (build: {{build}})')];
  12014. if (moreInfo) {
  12015. moreInfoText.push(this.l10n.get('error_message', {
  12016. message: moreInfo.message
  12017. },
  12018. 'Message: {{message}}'));
  12019. if (moreInfo.stack) {
  12020. moreInfoText.push(this.l10n.get('error_stack', {
  12021. stack: moreInfo.stack
  12022. },
  12023. 'Stack: {{stack}}'))
  12024. } else {
  12025. if (moreInfo.filename) {
  12026. moreInfoText.push(this.l10n.get('error_file', {
  12027. file: moreInfo.filename
  12028. },
  12029. 'File: {{file}}'))
  12030. }
  12031. if (moreInfo.lineNumber) {
  12032. moreInfoText.push(this.l10n.get('error_line', {
  12033. line: moreInfo.lineNumber
  12034. },
  12035. 'Line: {{line}}'))
  12036. }
  12037. }
  12038. }
  12039. var errorWrapperConfig = this.appConfig.errorWrapper;
  12040. var errorWrapper = errorWrapperConfig.container;
  12041. errorWrapper.removeAttribute('hidden');
  12042. var errorMessage = errorWrapperConfig.errorMessage;
  12043. errorMessage.textContent = message;
  12044. var closeButton = errorWrapperConfig.closeButton;
  12045. closeButton.onclick = function() {
  12046. errorWrapper.setAttribute('hidden', 'true')
  12047. };
  12048. var errorMoreInfo = errorWrapperConfig.errorMoreInfo;
  12049. var moreInfoButton = errorWrapperConfig.moreInfoButton;
  12050. var lessInfoButton = errorWrapperConfig.lessInfoButton;
  12051. moreInfoButton.onclick = function() {
  12052. errorMoreInfo.removeAttribute('hidden');
  12053. moreInfoButton.setAttribute('hidden', 'true');
  12054. lessInfoButton.removeAttribute('hidden');
  12055. errorMoreInfo.style.height = errorMoreInfo.scrollHeight + 'px'
  12056. };
  12057. lessInfoButton.onclick = function() {
  12058. errorMoreInfo.setAttribute('hidden', 'true');
  12059. moreInfoButton.removeAttribute('hidden');
  12060. lessInfoButton.setAttribute('hidden', 'true')
  12061. };
  12062. moreInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  12063. lessInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  12064. closeButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  12065. moreInfoButton.removeAttribute('hidden');
  12066. lessInfoButton.setAttribute('hidden', 'true');
  12067. Promise.all(moreInfoText).then(function(parts) {
  12068. errorMoreInfo.value = parts.join('\n')
  12069. })
  12070. },
  12071. progress: function progress(level) {
  12072. var _this5 = this;
  12073. if (this.downloadComplete) {
  12074. return
  12075. }
  12076. var percent = Math.round(level * 100);
  12077. if (percent > this.loadingBar.percent || isNaN(percent)) {
  12078. this.loadingBar.percent = percent;
  12079. if (_pdfjsLib.PDFJS.disableAutoFetch && percent) {
  12080. if (this.disableAutoFetchLoadingBarTimeout) {
  12081. clearTimeout(this.disableAutoFetchLoadingBarTimeout);
  12082. this.disableAutoFetchLoadingBarTimeout = null
  12083. }
  12084. this.loadingBar.show();
  12085. this.disableAutoFetchLoadingBarTimeout = setTimeout(function() {
  12086. _this5.loadingBar.hide();
  12087. _this5.disableAutoFetchLoadingBarTimeout = null
  12088. },
  12089. DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT)
  12090. }
  12091. }
  12092. },
  12093. load: function load(pdfDocument, scale) {
  12094. var _this6 = this;
  12095. scale = scale || _ui_utils.UNKNOWN_SCALE;
  12096. this.pdfDocument = pdfDocument;
  12097. pdfDocument.getDownloadInfo().then(function() {
  12098. _this6.downloadComplete = true;
  12099. _this6.loadingBar.hide();
  12100. firstPagePromise.then(function() {
  12101. _this6.eventBus.dispatch('documentload', {
  12102. source: _this6
  12103. })
  12104. })
  12105. });
  12106. var pageModePromise = pdfDocument.getPageMode().
  12107. catch(function() {});
  12108. this.toolbar.setPagesCount(pdfDocument.numPages, false);
  12109. this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
  12110. var id = this.documentFingerprint = pdfDocument.fingerprint;
  12111. var store = this.store = new _view_history.ViewHistory(id);
  12112. var baseDocumentUrl = void 0;
  12113. baseDocumentUrl = null;
  12114. this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
  12115. this.pdfDocumentProperties.setDocument(pdfDocument, this.url);
  12116. var pdfViewer = this.pdfViewer;
  12117. pdfViewer.setDocument(pdfDocument);
  12118. var firstPagePromise = pdfViewer.firstPagePromise;
  12119. var pagesPromise = pdfViewer.pagesPromise;
  12120. var onePageRendered = pdfViewer.onePageRendered;
  12121. var pdfThumbnailViewer = this.pdfThumbnailViewer;
  12122. pdfThumbnailViewer.setDocument(pdfDocument);
  12123. firstPagePromise.then(function(pdfPage) {
  12124. _this6.loadingBar.setWidth(_this6.appConfig.viewerContainer);
  12125. if (!_pdfjsLib.PDFJS.disableHistory && !_this6.isViewerEmbedded) {
  12126. if (!_this6.viewerPrefs['showPreviousViewOnLoad']) {
  12127. _this6.pdfHistory.clearHistoryState()
  12128. }
  12129. _this6.pdfHistory.initialize(_this6.documentFingerprint);
  12130. if (_this6.pdfHistory.initialDestination) {
  12131. _this6.initialDestination = _this6.pdfHistory.initialDestination
  12132. } else if (_this6.pdfHistory.initialBookmark) {
  12133. _this6.initialBookmark = _this6.pdfHistory.initialBookmark
  12134. }
  12135. }
  12136. var initialParams = {
  12137. destination: _this6.initialDestination,
  12138. bookmark: _this6.initialBookmark,
  12139. hash: null
  12140. };
  12141. var storePromise = store.getMultiple({
  12142. exists: false,
  12143. page: '1',
  12144. zoom: _ui_utils.DEFAULT_SCALE_VALUE,
  12145. scrollLeft: '0',
  12146. scrollTop: '0',
  12147. sidebarView: _pdf_sidebar.SidebarView.NONE
  12148. }).
  12149. catch(function() {});
  12150. Promise.all([storePromise, pageModePromise]).then(function(_ref2) {
  12151. var _ref3 = _slicedToArray(_ref2, 2),
  12152. _ref3$ = _ref3[0],
  12153. values = _ref3$ === undefined ? {}: _ref3$,
  12154. pageMode = _ref3[1];
  12155. var hash = _this6.viewerPrefs['defaultZoomValue'] ? 'zoom=' + _this6.viewerPrefs['defaultZoomValue'] : null;
  12156. var sidebarView = _this6.viewerPrefs['sidebarViewOnLoad'];
  12157. if (values.exists && _this6.viewerPrefs['showPreviousViewOnLoad']) {
  12158. hash = 'page=' + values.page + '&zoom=' + (_this6.viewerPrefs['defaultZoomValue'] || values.zoom) + ',' + values.scrollLeft + ',' + values.scrollTop;
  12159. sidebarView = sidebarView || values.sidebarView | 0
  12160. }
  12161. if (pageMode && !_this6.viewerPrefs['disablePageMode']) {
  12162. sidebarView = sidebarView || apiPageModeToSidebarView(pageMode)
  12163. }
  12164. return {
  12165. hash: hash,
  12166. sidebarView: sidebarView
  12167. }
  12168. }).then(function(_ref4) {
  12169. var hash = _ref4.hash,
  12170. sidebarView = _ref4.sidebarView;
  12171. _this6.setInitialView(hash, {
  12172. sidebarView: sidebarView,
  12173. scale: scale
  12174. });
  12175. initialParams.hash = hash;
  12176. if (!_this6.isViewerEmbedded) {
  12177. pdfViewer.focus()
  12178. }
  12179. return pagesPromise
  12180. }).then(function() {
  12181. if (!initialParams.destination && !initialParams.bookmark && !initialParams.hash) {
  12182. return
  12183. }
  12184. if (pdfViewer.hasEqualPageSizes) {
  12185. return
  12186. }
  12187. _this6.initialDestination = initialParams.destination;
  12188. _this6.initialBookmark = initialParams.bookmark;
  12189. pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;
  12190. _this6.setInitialView(initialParams.hash)
  12191. }).then(function() {
  12192. pdfViewer.update()
  12193. })
  12194. });
  12195. pdfDocument.getPageLabels().then(function(labels) {
  12196. if (!labels || _this6.viewerPrefs['disablePageLabels']) {
  12197. return
  12198. }
  12199. var i = 0,
  12200. numLabels = labels.length;
  12201. if (numLabels !== _this6.pagesCount) {
  12202. console.error('The number of Page Labels does not match ' + 'the number of pages in the document.');
  12203. return
  12204. }
  12205. while (i < numLabels && labels[i] === (i + 1).toString()) {
  12206. i++
  12207. }
  12208. if (i === numLabels) {
  12209. return
  12210. }
  12211. pdfViewer.setPageLabels(labels);
  12212. pdfThumbnailViewer.setPageLabels(labels);
  12213. _this6.toolbar.setPagesCount(pdfDocument.numPages, true);
  12214. _this6.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel)
  12215. });
  12216. pagesPromise.then(function() {
  12217. if (!_this6.supportsPrinting) {
  12218. return
  12219. }
  12220. pdfDocument.getJavaScript().then(function(javaScript) {
  12221. if (javaScript.length) {
  12222. console.warn('Warning: JavaScript is not supported');
  12223. _this6.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.javaScript)
  12224. }
  12225. var regex = /\bprint\s*\(/;
  12226. for (var i = 0,
  12227. ii = javaScript.length; i < ii; i++) {
  12228. var js = javaScript[i];
  12229. if (js && regex.test(js)) {
  12230. setTimeout(function() {
  12231. window.print()
  12232. });
  12233. return
  12234. }
  12235. }
  12236. })
  12237. });
  12238. Promise.all([onePageRendered, _ui_utils.animationStarted]).then(function() {
  12239. pdfDocument.getOutline().then(function(outline) {
  12240. _this6.pdfOutlineViewer.render({
  12241. outline: outline
  12242. })
  12243. });
  12244. pdfDocument.getAttachments().then(function(attachments) {
  12245. _this6.pdfAttachmentViewer.render({
  12246. attachments: attachments
  12247. })
  12248. })
  12249. });
  12250. pdfDocument.getMetadata().then(function(_ref5) {
  12251. var info = _ref5.info,
  12252. metadata = _ref5.metadata;
  12253. _this6.documentInfo = info;
  12254. _this6.metadata = metadata;
  12255. console.log('PDF ' + pdfDocument.fingerprint + ' [' + info.PDFFormatVersion + ' ' + (info.Producer || '-').trim() + ' / ' + (info.Creator || '-').trim() + ']' + ' (PDF.js: ' + (_pdfjsLib.version || '-') + (!_pdfjsLib.PDFJS.disableWebGL ? ' [WebGL]': '') + ')');
  12256. var pdfTitle = void 0;
  12257. if (metadata && metadata.has('dc:title')) {
  12258. var title = metadata.get('dc:title');
  12259. if (title !== 'Untitled') {
  12260. pdfTitle = title
  12261. }
  12262. }
  12263. if (!pdfTitle && info && info['Title']) {
  12264. pdfTitle = info['Title']
  12265. }
  12266. if (pdfTitle) {
  12267. _this6.setTitle(pdfTitle + ' - ' + document.title)
  12268. }
  12269. if (info.IsAcroFormPresent) {
  12270. console.warn('Warning: AcroForm/XFA is not supported');
  12271. _this6.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms)
  12272. }
  12273. })
  12274. },
  12275. setInitialView: function setInitialView(storedHash) {
  12276. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  12277. var _options$scale = options.scale,
  12278. scale = _options$scale === undefined ? 0 : _options$scale,
  12279. _options$sidebarView = options.sidebarView,
  12280. sidebarView = _options$sidebarView === undefined ? _pdf_sidebar.SidebarView.NONE: _options$sidebarView;
  12281. this.isInitialViewSet = true;
  12282. this.pdfSidebar.setInitialView(sidebarView);
  12283. if (this.initialDestination) {
  12284. this.pdfLinkService.navigateTo(this.initialDestination);
  12285. this.initialDestination = null
  12286. } else if (this.initialBookmark) {
  12287. this.pdfLinkService.setHash(this.initialBookmark);
  12288. this.pdfHistory.push({
  12289. hash: this.initialBookmark
  12290. },
  12291. true);
  12292. this.initialBookmark = null
  12293. } else if (storedHash) {
  12294. this.pdfLinkService.setHash(storedHash)
  12295. } else if (scale) {
  12296. this.pdfViewer.currentScaleValue = scale;
  12297. this.page = 1
  12298. }
  12299. this.toolbar.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel);
  12300. this.secondaryToolbar.setPageNumber(this.pdfViewer.currentPageNumber);
  12301. if (!this.pdfViewer.currentScaleValue) {
  12302. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE
  12303. }
  12304. },
  12305. cleanup: function cleanup() {
  12306. if (!this.pdfDocument) {
  12307. return
  12308. }
  12309. this.pdfViewer.cleanup();
  12310. this.pdfThumbnailViewer.cleanup();
  12311. if (this.pdfViewer.renderer !== _ui_utils.RendererType.SVG) {
  12312. this.pdfDocument.cleanup()
  12313. }
  12314. },
  12315. forceRendering: function forceRendering() {
  12316. this.pdfRenderingQueue.printing = this.printing;
  12317. this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar.isThumbnailViewVisible;
  12318. this.pdfRenderingQueue.renderHighestPriority()
  12319. },
  12320. beforePrint: function beforePrint() {
  12321. var _this7 = this;
  12322. if (this.printService) {
  12323. return
  12324. }
  12325. if (!this.supportsPrinting) {
  12326. this.l10n.get('printing_not_supported', null, 'Warning: Printing is not fully supported by ' + 'this browser.').then(function(printMessage) {
  12327. _this7.error(printMessage)
  12328. });
  12329. return
  12330. }
  12331. if (!this.pdfViewer.pageViewsReady) {
  12332. this.l10n.get('printing_not_ready', null, 'Warning: The PDF is not fully loaded for printing.').then(function(notReadyMessage) {
  12333. window.alert(notReadyMessage)
  12334. });
  12335. return
  12336. }
  12337. var pagesOverview = this.pdfViewer.getPagesOverview();
  12338. var printContainer = this.appConfig.printContainer;
  12339. var printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument, pagesOverview, printContainer, this.l10n);
  12340. this.printService = printService;
  12341. this.forceRendering();
  12342. printService.layout()
  12343. },
  12344. afterPrint: function pdfViewSetupAfterPrint() {
  12345. if (this.printService) {
  12346. this.printService.destroy();
  12347. this.printService = null
  12348. }
  12349. this.forceRendering()
  12350. },
  12351. rotatePages: function rotatePages(delta) {
  12352. if (!this.pdfDocument) {
  12353. return
  12354. }
  12355. var pdfViewer = this.pdfViewer,
  12356. pdfThumbnailViewer = this.pdfThumbnailViewer;
  12357. var pageNumber = pdfViewer.currentPageNumber;
  12358. var newRotation = (pdfViewer.pagesRotation + 360 + delta) % 360;
  12359. pdfViewer.pagesRotation = newRotation;
  12360. pdfThumbnailViewer.pagesRotation = newRotation;
  12361. this.forceRendering();
  12362. pdfViewer.currentPageNumber = pageNumber
  12363. },
  12364. requestPresentationMode: function requestPresentationMode() {
  12365. if (!this.pdfPresentationMode) {
  12366. return
  12367. }
  12368. this.pdfPresentationMode.request()
  12369. },
  12370. bindEvents: function bindEvents() {
  12371. var eventBus = this.eventBus,
  12372. _boundEvents = this._boundEvents;
  12373. _boundEvents.beforePrint = this.beforePrint.bind(this);
  12374. _boundEvents.afterPrint = this.afterPrint.bind(this);
  12375. eventBus.on('resize', webViewerResize);
  12376. eventBus.on('hashchange', webViewerHashchange);
  12377. eventBus.on('beforeprint', _boundEvents.beforePrint);
  12378. eventBus.on('afterprint', _boundEvents.afterPrint);
  12379. eventBus.on('pagerendered', webViewerPageRendered);
  12380. eventBus.on('textlayerrendered', webViewerTextLayerRendered);
  12381. eventBus.on('updateviewarea', webViewerUpdateViewarea);
  12382. eventBus.on('pagechanging', webViewerPageChanging);
  12383. eventBus.on('scalechanging', webViewerScaleChanging);
  12384. eventBus.on('sidebarviewchanged', webViewerSidebarViewChanged);
  12385. eventBus.on('pagemode', webViewerPageMode);
  12386. eventBus.on('namedaction', webViewerNamedAction);
  12387. eventBus.on('presentationmodechanged', webViewerPresentationModeChanged);
  12388. eventBus.on('presentationmode', webViewerPresentationMode);
  12389. eventBus.on('openfile', webViewerOpenFile);
  12390. eventBus.on('print', webViewerPrint);
  12391. eventBus.on('download', webViewerDownload);
  12392. eventBus.on('firstpage', webViewerFirstPage);
  12393. eventBus.on('lastpage', webViewerLastPage);
  12394. eventBus.on('nextpage', webViewerNextPage);
  12395. eventBus.on('previouspage', webViewerPreviousPage);
  12396. eventBus.on('zoomin', webViewerZoomIn);
  12397. eventBus.on('zoomout', webViewerZoomOut);
  12398. eventBus.on('pagenumberchanged', webViewerPageNumberChanged);
  12399. eventBus.on('scalechanged', webViewerScaleChanged);
  12400. eventBus.on('rotatecw', webViewerRotateCw);
  12401. eventBus.on('rotateccw', webViewerRotateCcw);
  12402. eventBus.on('documentproperties', webViewerDocumentProperties);
  12403. eventBus.on('find', webViewerFind);
  12404. eventBus.on('findfromurlhash', webViewerFindFromUrlHash);
  12405. eventBus.on('fileinputchange', webViewerFileInputChange)
  12406. },
  12407. bindWindowEvents: function bindWindowEvents() {
  12408. var eventBus = this.eventBus,
  12409. _boundEvents = this._boundEvents;
  12410. _boundEvents.windowResize = function() {
  12411. eventBus.dispatch('resize')
  12412. };
  12413. _boundEvents.windowHashChange = function() {
  12414. eventBus.dispatch('hashchange', {
  12415. hash: document.location.hash.substring(1)
  12416. })
  12417. };
  12418. _boundEvents.windowBeforePrint = function() {
  12419. eventBus.dispatch('beforeprint')
  12420. };
  12421. _boundEvents.windowAfterPrint = function() {
  12422. eventBus.dispatch('afterprint')
  12423. };
  12424. window.addEventListener('wheel', webViewerWheel);
  12425. window.addEventListener('click', webViewerClick);
  12426. window.addEventListener('keydown', webViewerKeyDown);
  12427. window.addEventListener('resize', _boundEvents.windowResize);
  12428. window.addEventListener('hashchange', _boundEvents.windowHashChange);
  12429. window.addEventListener('beforeprint', _boundEvents.windowBeforePrint);
  12430. window.addEventListener('afterprint', _boundEvents.windowAfterPrint);
  12431. _boundEvents.windowChange = function(evt) {
  12432. var files = evt.target.files;
  12433. if (!files || files.length === 0) {
  12434. return
  12435. }
  12436. eventBus.dispatch('fileinputchange', {
  12437. fileInput: evt.target
  12438. })
  12439. };
  12440. window.addEventListener('change', _boundEvents.windowChange)
  12441. },
  12442. unbindEvents: function unbindEvents() {
  12443. var eventBus = this.eventBus,
  12444. _boundEvents = this._boundEvents;
  12445. eventBus.off('resize', webViewerResize);
  12446. eventBus.off('hashchange', webViewerHashchange);
  12447. eventBus.off('beforeprint', _boundEvents.beforePrint);
  12448. eventBus.off('afterprint', _boundEvents.afterPrint);
  12449. eventBus.off('pagerendered', webViewerPageRendered);
  12450. eventBus.off('textlayerrendered', webViewerTextLayerRendered);
  12451. eventBus.off('updateviewarea', webViewerUpdateViewarea);
  12452. eventBus.off('pagechanging', webViewerPageChanging);
  12453. eventBus.off('scalechanging', webViewerScaleChanging);
  12454. eventBus.off('sidebarviewchanged', webViewerSidebarViewChanged);
  12455. eventBus.off('pagemode', webViewerPageMode);
  12456. eventBus.off('namedaction', webViewerNamedAction);
  12457. eventBus.off('presentationmodechanged', webViewerPresentationModeChanged);
  12458. eventBus.off('presentationmode', webViewerPresentationMode);
  12459. eventBus.off('openfile', webViewerOpenFile);
  12460. eventBus.off('print', webViewerPrint);
  12461. eventBus.off('download', webViewerDownload);
  12462. eventBus.off('firstpage', webViewerFirstPage);
  12463. eventBus.off('lastpage', webViewerLastPage);
  12464. eventBus.off('nextpage', webViewerNextPage);
  12465. eventBus.off('previouspage', webViewerPreviousPage);
  12466. eventBus.off('zoomin', webViewerZoomIn);
  12467. eventBus.off('zoomout', webViewerZoomOut);
  12468. eventBus.off('pagenumberchanged', webViewerPageNumberChanged);
  12469. eventBus.off('scalechanged', webViewerScaleChanged);
  12470. eventBus.off('rotatecw', webViewerRotateCw);
  12471. eventBus.off('rotateccw', webViewerRotateCcw);
  12472. eventBus.off('documentproperties', webViewerDocumentProperties);
  12473. eventBus.off('find', webViewerFind);
  12474. eventBus.off('findfromurlhash', webViewerFindFromUrlHash);
  12475. eventBus.off('fileinputchange', webViewerFileInputChange);
  12476. _boundEvents.beforePrint = null;
  12477. _boundEvents.afterPrint = null
  12478. },
  12479. unbindWindowEvents: function unbindWindowEvents() {
  12480. var _boundEvents = this._boundEvents;
  12481. window.removeEventListener('wheel', webViewerWheel);
  12482. window.removeEventListener('click', webViewerClick);
  12483. window.removeEventListener('keydown', webViewerKeyDown);
  12484. window.removeEventListener('resize', _boundEvents.windowResize);
  12485. window.removeEventListener('hashchange', _boundEvents.windowHashChange);
  12486. window.removeEventListener('beforeprint', _boundEvents.windowBeforePrint);
  12487. window.removeEventListener('afterprint', _boundEvents.windowAfterPrint);
  12488. window.removeEventListener('change', _boundEvents.windowChange);
  12489. _boundEvents.windowChange = null;
  12490. _boundEvents.windowResize = null;
  12491. _boundEvents.windowHashChange = null;
  12492. _boundEvents.windowBeforePrint = null;
  12493. _boundEvents.windowAfterPrint = null
  12494. }
  12495. };
  12496. var validateFileURL = void 0; {
  12497. var HOSTED_VIEWER_ORIGINS = ['null', 'http://mozilla.github.io', 'https://mozilla.github.io'];
  12498. validateFileURL = function validateFileURL(file) {
  12499. if (file === undefined) {
  12500. return
  12501. }
  12502. try {
  12503. var viewerOrigin = new URL(window.location.href).origin || 'null';
  12504. if (HOSTED_VIEWER_ORIGINS.indexOf(viewerOrigin) >= 0) {
  12505. return
  12506. }
  12507. var fileOrigin = new URL(file, window.location.href).origin;
  12508. if (fileOrigin !== viewerOrigin) {
  12509. throw new Error('file origin does not match viewer\'s');
  12510. }
  12511. } catch(ex) {
  12512. var message = ex && ex.message;
  12513. PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.').then(function(loadingErrorMessage) {
  12514. PDFViewerApplication.error(loadingErrorMessage, {
  12515. message: message
  12516. })
  12517. });
  12518. throw ex;
  12519. }
  12520. }
  12521. }
  12522. function loadAndEnablePDFBug(enabledTabs) {
  12523. return new Promise(function(resolve, reject) {
  12524. var appConfig = PDFViewerApplication.appConfig;
  12525. var script = document.createElement('script');
  12526. script.src = appConfig.debuggerScriptPath;
  12527. script.onload = function() {
  12528. PDFBug.enable(enabledTabs);
  12529. PDFBug.init({
  12530. PDFJS: _pdfjsLib.PDFJS,
  12531. OPS: _pdfjsLib.OPS
  12532. },
  12533. appConfig.mainContainer);
  12534. resolve()
  12535. };
  12536. script.onerror = function() {
  12537. reject(new Error('Cannot load debugger at ' + script.src))
  12538. }; (document.getElementsByTagName('head')[0] || document.body).appendChild(script)
  12539. })
  12540. }
  12541. function webViewerInitialized() {
  12542. var appConfig = PDFViewerApplication.appConfig;
  12543. var file = void 0;
  12544. var queryString = document.location.search.substring(1);
  12545. var params = (0, _ui_utils.parseQueryString)(queryString);
  12546. file = 'file' in params ? params.file: appConfig.defaultUrl;
  12547. validateFileURL(file);
  12548. var waitForBeforeOpening = [];
  12549. var fileInput = document.createElement('input');
  12550. fileInput.id = appConfig.openFileInputName;
  12551. fileInput.className = 'fileInput';
  12552. fileInput.setAttribute('type', 'file');
  12553. fileInput.oncontextmenu = _ui_utils.noContextMenuHandler;
  12554. document.body.appendChild(fileInput);
  12555. if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
  12556. appConfig.toolbar.openFile.setAttribute('hidden', 'true');
  12557. appConfig.secondaryToolbar.openFileButton.setAttribute('hidden', 'true')
  12558. } else {
  12559. fileInput.value = null
  12560. }
  12561. if (PDFViewerApplication.viewerPrefs['pdfBugEnabled']) {
  12562. var hash = document.location.hash.substring(1);
  12563. var hashParams = (0, _ui_utils.parseQueryString)(hash);
  12564. if ('disableworker' in hashParams) {
  12565. _pdfjsLib.PDFJS.disableWorker = hashParams['disableworker'] === 'true'
  12566. }
  12567. if ('disablerange' in hashParams) {
  12568. _pdfjsLib.PDFJS.disableRange = hashParams['disablerange'] === 'true'
  12569. }
  12570. if ('disablestream' in hashParams) {
  12571. _pdfjsLib.PDFJS.disableStream = hashParams['disablestream'] === 'true'
  12572. }
  12573. if ('disableautofetch' in hashParams) {
  12574. _pdfjsLib.PDFJS.disableAutoFetch = hashParams['disableautofetch'] === 'true'
  12575. }
  12576. if ('disablefontface' in hashParams) {
  12577. _pdfjsLib.PDFJS.disableFontFace = hashParams['disablefontface'] === 'true'
  12578. }
  12579. if ('disablehistory' in hashParams) {
  12580. _pdfjsLib.PDFJS.disableHistory = hashParams['disablehistory'] === 'true'
  12581. }
  12582. if ('webgl' in hashParams) {
  12583. _pdfjsLib.PDFJS.disableWebGL = hashParams['webgl'] !== 'true'
  12584. }
  12585. if ('useonlycsszoom' in hashParams) {
  12586. _pdfjsLib.PDFJS.useOnlyCssZoom = hashParams['useonlycsszoom'] === 'true'
  12587. }
  12588. if ('verbosity' in hashParams) {
  12589. _pdfjsLib.PDFJS.verbosity = hashParams['verbosity'] | 0
  12590. }
  12591. if ('ignorecurrentpositiononzoom' in hashParams) {
  12592. _pdfjsLib.PDFJS.ignoreCurrentPositionOnZoom = hashParams['ignorecurrentpositiononzoom'] === 'true'
  12593. }
  12594. if ('textlayer' in hashParams) {
  12595. switch (hashParams['textlayer']) {
  12596. case 'off':
  12597. _pdfjsLib.PDFJS.disableTextLayer = true;
  12598. break;
  12599. case 'visible':
  12600. case 'shadow':
  12601. case 'hover':
  12602. var viewer = appConfig.viewerContainer;
  12603. viewer.classList.add('textLayer-' + hashParams['textlayer']);
  12604. break
  12605. }
  12606. }
  12607. if ('pdfbug' in hashParams) {
  12608. _pdfjsLib.PDFJS.pdfBug = true;
  12609. var pdfBug = hashParams['pdfbug'];
  12610. var enabled = pdfBug.split(',');
  12611. waitForBeforeOpening.push(loadAndEnablePDFBug(enabled))
  12612. }
  12613. }
  12614. if (!PDFViewerApplication.supportsPrinting) {
  12615. appConfig.toolbar.print.classList.add('hidden');
  12616. appConfig.secondaryToolbar.printButton.classList.add('hidden')
  12617. }
  12618. if (!PDFViewerApplication.supportsFullscreen) {
  12619. appConfig.toolbar.presentationModeButton.classList.add('hidden');
  12620. appConfig.secondaryToolbar.presentationModeButton.classList.add('hidden')
  12621. }
  12622. if (PDFViewerApplication.supportsIntegratedFind) {
  12623. appConfig.toolbar.viewFind.classList.add('hidden')
  12624. }
  12625. appConfig.sidebar.mainContainer.addEventListener('transitionend',
  12626. function(evt) {
  12627. if (evt.target === this) {
  12628. PDFViewerApplication.eventBus.dispatch('resize')
  12629. }
  12630. },
  12631. true);
  12632. appConfig.sidebar.toggleButton.addEventListener('click',
  12633. function() {
  12634. PDFViewerApplication.pdfSidebar.toggle()
  12635. });
  12636. Promise.all(waitForBeforeOpening).then(function() {
  12637. webViewerOpenFileViaURL(file)
  12638. }).
  12639. catch(function(reason) {
  12640. PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while opening.').then(function(msg) {
  12641. PDFViewerApplication.error(msg, reason)
  12642. })
  12643. })
  12644. }
  12645. var webViewerOpenFileViaURL = void 0; {
  12646. webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) {
  12647. if (file && file.lastIndexOf('file:', 0) === 0) {
  12648. PDFViewerApplication.setTitleUsingUrl(file);
  12649. var xhr = new XMLHttpRequest();
  12650. xhr.onload = function() {
  12651. PDFViewerApplication.open(new Uint8Array(xhr.response))
  12652. };
  12653. try {
  12654. xhr.open('GET', file);
  12655. xhr.responseType = 'arraybuffer';
  12656. xhr.send()
  12657. } catch(ex) {
  12658. PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.').then(function(msg) {
  12659. PDFViewerApplication.error(msg, ex)
  12660. })
  12661. }
  12662. return
  12663. }
  12664. if (file) {
  12665. PDFViewerApplication.open(file)
  12666. }
  12667. }
  12668. }
  12669. function webViewerPageRendered(evt) {
  12670. var pageNumber = evt.pageNumber;
  12671. var pageIndex = pageNumber - 1;
  12672. var pageView = PDFViewerApplication.pdfViewer.getPageView(pageIndex);
  12673. if (pageNumber === PDFViewerApplication.page) {
  12674. PDFViewerApplication.toolbar.updateLoadingIndicatorState(false)
  12675. }
  12676. if (!pageView) {
  12677. return
  12678. }
  12679. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  12680. var thumbnailView = PDFViewerApplication.pdfThumbnailViewer.getThumbnail(pageIndex);
  12681. thumbnailView.setImage(pageView)
  12682. }
  12683. if (_pdfjsLib.PDFJS.pdfBug && Stats.enabled && pageView.stats) {
  12684. Stats.add(pageNumber, pageView.stats)
  12685. }
  12686. if (pageView.error) {
  12687. PDFViewerApplication.l10n.get('rendering_error', null, 'An error occurred while rendering the page.').then(function(msg) {
  12688. PDFViewerApplication.error(msg, pageView.error)
  12689. })
  12690. }
  12691. }
  12692. function webViewerTextLayerRendered(evt) {}
  12693. function webViewerPageMode(evt) {
  12694. var mode = evt.mode,
  12695. view = void 0;
  12696. switch (mode) {
  12697. case 'thumbs':
  12698. view = _pdf_sidebar.SidebarView.THUMBS;
  12699. break;
  12700. case 'bookmarks':
  12701. case 'outline':
  12702. view = _pdf_sidebar.SidebarView.OUTLINE;
  12703. break;
  12704. case 'attachments':
  12705. view = _pdf_sidebar.SidebarView.ATTACHMENTS;
  12706. break;
  12707. case 'none':
  12708. view = _pdf_sidebar.SidebarView.NONE;
  12709. break;
  12710. default:
  12711. console.error('Invalid "pagemode" hash parameter: ' + mode);
  12712. return
  12713. }
  12714. PDFViewerApplication.pdfSidebar.switchView(view, true)
  12715. }
  12716. function webViewerNamedAction(evt) {
  12717. var action = evt.action;
  12718. switch (action) {
  12719. case 'GoToPage':
  12720. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  12721. break;
  12722. case 'Find':
  12723. if (!PDFViewerApplication.supportsIntegratedFind) {
  12724. PDFViewerApplication.findBar.toggle()
  12725. }
  12726. break
  12727. }
  12728. }
  12729. function webViewerPresentationModeChanged(evt) {
  12730. var active = evt.active,
  12731. switchInProgress = evt.switchInProgress;
  12732. PDFViewerApplication.pdfViewer.presentationModeState = switchInProgress ? _pdf_viewer.PresentationModeState.CHANGING: active ? _pdf_viewer.PresentationModeState.FULLSCREEN: _pdf_viewer.PresentationModeState.NORMAL
  12733. }
  12734. function webViewerSidebarViewChanged(evt) {
  12735. PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = PDFViewerApplication.pdfSidebar.isThumbnailViewVisible;
  12736. var store = PDFViewerApplication.store;
  12737. if (store && PDFViewerApplication.isInitialViewSet) {
  12738. store.set('sidebarView', evt.view).
  12739. catch(function() {})
  12740. }
  12741. }
  12742. function webViewerUpdateViewarea(evt) {
  12743. var location = evt.location,
  12744. store = PDFViewerApplication.store;
  12745. if (store && PDFViewerApplication.isInitialViewSet) {
  12746. store.setMultiple({
  12747. 'exists': true,
  12748. 'page': location.pageNumber,
  12749. 'zoom': location.scale,
  12750. 'scrollLeft': location.left,
  12751. 'scrollTop': location.top
  12752. }).
  12753. catch(function() {})
  12754. }
  12755. var href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
  12756. PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href;
  12757. PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
  12758. PDFViewerApplication.pdfHistory.updateCurrentBookmark(location.pdfOpenParams, location.pageNumber);
  12759. var currentPage = PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page - 1);
  12760. var loading = currentPage.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED;
  12761. PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading)
  12762. }
  12763. function webViewerResize() {
  12764. var pdfDocument = PDFViewerApplication.pdfDocument,
  12765. pdfViewer = PDFViewerApplication.pdfViewer;
  12766. if (!pdfDocument) {
  12767. return
  12768. }
  12769. var currentScaleValue = pdfViewer.currentScaleValue;
  12770. if (currentScaleValue === 'auto' || currentScaleValue === 'page-fit' || currentScaleValue === 'page-width') {
  12771. pdfViewer.currentScaleValue = currentScaleValue
  12772. }
  12773. pdfViewer.update()
  12774. }
  12775. function webViewerHashchange(evt) {
  12776. if (PDFViewerApplication.pdfHistory.isHashChangeUnlocked) {
  12777. var hash = evt.hash;
  12778. if (!hash) {
  12779. return
  12780. }
  12781. if (!PDFViewerApplication.isInitialViewSet) {
  12782. PDFViewerApplication.initialBookmark = hash
  12783. } else {
  12784. PDFViewerApplication.pdfLinkService.setHash(hash)
  12785. }
  12786. }
  12787. }
  12788. var webViewerFileInputChange = void 0; {
  12789. webViewerFileInputChange = function webViewerFileInputChange(evt) {
  12790. var file = evt.fileInput.files[0];
  12791. if (!_pdfjsLib.PDFJS.disableCreateObjectURL && URL.createObjectURL) {
  12792. PDFViewerApplication.open(URL.createObjectURL(file))
  12793. } else {
  12794. var fileReader = new FileReader();
  12795. fileReader.onload = function webViewerChangeFileReaderOnload(evt) {
  12796. var buffer = evt.target.result;
  12797. PDFViewerApplication.open(new Uint8Array(buffer))
  12798. };
  12799. fileReader.readAsArrayBuffer(file)
  12800. }
  12801. PDFViewerApplication.setTitleUsingUrl(file.name);
  12802. var appConfig = PDFViewerApplication.appConfig;
  12803. appConfig.toolbar.viewBookmark.setAttribute('hidden', 'true');
  12804. appConfig.secondaryToolbar.viewBookmarkButton.setAttribute('hidden', 'true');
  12805. appConfig.toolbar.download.setAttribute('hidden', 'true');
  12806. appConfig.secondaryToolbar.downloadButton.setAttribute('hidden', 'true')
  12807. }
  12808. }
  12809. function webViewerPresentationMode() {
  12810. PDFViewerApplication.requestPresentationMode()
  12811. }
  12812. function webViewerOpenFile() {
  12813. var openFileInputName = PDFViewerApplication.appConfig.openFileInputName;
  12814. document.getElementById(openFileInputName).click()
  12815. }
  12816. function webViewerPrint() {
  12817. window.print()
  12818. }
  12819. function webViewerDownload() {
  12820. PDFViewerApplication.download()
  12821. }
  12822. function webViewerFirstPage() {
  12823. if (PDFViewerApplication.pdfDocument) {
  12824. PDFViewerApplication.page = 1
  12825. }
  12826. }
  12827. function webViewerLastPage() {
  12828. if (PDFViewerApplication.pdfDocument) {
  12829. PDFViewerApplication.page = PDFViewerApplication.pagesCount
  12830. }
  12831. }
  12832. function webViewerNextPage() {
  12833. PDFViewerApplication.page++
  12834. }
  12835. function webViewerPreviousPage() {
  12836. PDFViewerApplication.page--
  12837. }
  12838. function webViewerZoomIn() {
  12839. PDFViewerApplication.zoomIn()
  12840. }
  12841. function webViewerZoomOut() {
  12842. PDFViewerApplication.zoomOut()
  12843. }
  12844. function webViewerPageNumberChanged(evt) {
  12845. var pdfViewer = PDFViewerApplication.pdfViewer;
  12846. pdfViewer.currentPageLabel = evt.value;
  12847. if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) {
  12848. PDFViewerApplication.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel)
  12849. }
  12850. }
  12851. function webViewerScaleChanged(evt) {
  12852. PDFViewerApplication.pdfViewer.currentScaleValue = evt.value
  12853. }
  12854. function webViewerRotateCw() {
  12855. PDFViewerApplication.rotatePages(90)
  12856. }
  12857. function webViewerRotateCcw() {
  12858. PDFViewerApplication.rotatePages( - 90)
  12859. }
  12860. function webViewerDocumentProperties() {
  12861. PDFViewerApplication.pdfDocumentProperties.open()
  12862. }
  12863. function webViewerFind(evt) {
  12864. PDFViewerApplication.findController.executeCommand('find' + evt.type, {
  12865. query: evt.query,
  12866. phraseSearch: evt.phraseSearch,
  12867. caseSensitive: evt.caseSensitive,
  12868. highlightAll: evt.highlightAll,
  12869. findPrevious: evt.findPrevious
  12870. })
  12871. }
  12872. function webViewerFindFromUrlHash(evt) {
  12873. PDFViewerApplication.findController.executeCommand('find', {
  12874. query: evt.query,
  12875. phraseSearch: evt.phraseSearch,
  12876. caseSensitive: false,
  12877. highlightAll: true,
  12878. findPrevious: false
  12879. })
  12880. }
  12881. function webViewerScaleChanging(evt) {
  12882. PDFViewerApplication.toolbar.setPageScale(evt.presetValue, evt.scale);
  12883. PDFViewerApplication.pdfViewer.update()
  12884. }
  12885. function webViewerPageChanging(evt) {
  12886. var page = evt.pageNumber;
  12887. PDFViewerApplication.toolbar.setPageNumber(page, evt.pageLabel || null);
  12888. PDFViewerApplication.secondaryToolbar.setPageNumber(page);
  12889. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  12890. PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(page)
  12891. }
  12892. if (_pdfjsLib.PDFJS.pdfBug && Stats.enabled) {
  12893. var pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1);
  12894. if (pageView.stats) {
  12895. Stats.add(page, pageView.stats)
  12896. }
  12897. }
  12898. }
  12899. var zoomDisabled = false,
  12900. zoomDisabledTimeout = void 0;
  12901. function webViewerWheel(evt) {
  12902. var pdfViewer = PDFViewerApplication.pdfViewer;
  12903. if (pdfViewer.isInPresentationMode) {
  12904. return
  12905. }
  12906. if (evt.ctrlKey || evt.metaKey) {
  12907. var support = PDFViewerApplication.supportedMouseWheelZoomModifierKeys;
  12908. if (evt.ctrlKey && !support.ctrlKey || evt.metaKey && !support.metaKey) {
  12909. return
  12910. }
  12911. evt.preventDefault();
  12912. if (zoomDisabled) {
  12913. return
  12914. }
  12915. var previousScale = pdfViewer.currentScale;
  12916. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  12917. var MOUSE_WHEEL_DELTA_PER_PAGE_SCALE = 3.0;
  12918. var ticks = delta * MOUSE_WHEEL_DELTA_PER_PAGE_SCALE;
  12919. if (ticks < 0) {
  12920. PDFViewerApplication.zoomOut( - ticks)
  12921. } else {
  12922. PDFViewerApplication.zoomIn(ticks)
  12923. }
  12924. var currentScale = pdfViewer.currentScale;
  12925. if (previousScale !== currentScale) {
  12926. var scaleCorrectionFactor = currentScale / previousScale - 1;
  12927. var rect = pdfViewer.container.getBoundingClientRect();
  12928. var dx = evt.clientX - rect.left;
  12929. var dy = evt.clientY - rect.top;
  12930. pdfViewer.container.scrollLeft += dx * scaleCorrectionFactor;
  12931. pdfViewer.container.scrollTop += dy * scaleCorrectionFactor
  12932. }
  12933. } else {
  12934. zoomDisabled = true;
  12935. clearTimeout(zoomDisabledTimeout);
  12936. zoomDisabledTimeout = setTimeout(function() {
  12937. zoomDisabled = false
  12938. },
  12939. 1000)
  12940. }
  12941. }
  12942. function webViewerClick(evt) {
  12943. if (!PDFViewerApplication.secondaryToolbar.isOpen) {
  12944. return
  12945. }
  12946. var appConfig = PDFViewerApplication.appConfig;
  12947. if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar.container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar.toggleButton) {
  12948. PDFViewerApplication.secondaryToolbar.close()
  12949. }
  12950. }
  12951. function webViewerKeyDown(evt) {
  12952. if (PDFViewerApplication.overlayManager.active) {
  12953. return
  12954. }
  12955. var handled = false,
  12956. ensureViewerFocused = false;
  12957. var cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0);
  12958. var pdfViewer = PDFViewerApplication.pdfViewer;
  12959. var isViewerInPresentationMode = pdfViewer && pdfViewer.isInPresentationMode;
  12960. if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
  12961. switch (evt.keyCode) {
  12962. case 70:
  12963. if (!PDFViewerApplication.supportsIntegratedFind) {
  12964. PDFViewerApplication.findBar.open();
  12965. handled = true
  12966. }
  12967. break;
  12968. case 71:
  12969. if (!PDFViewerApplication.supportsIntegratedFind) {
  12970. var findState = PDFViewerApplication.findController.state;
  12971. if (findState) {
  12972. PDFViewerApplication.findController.executeCommand('findagain', {
  12973. query: findState.query,
  12974. phraseSearch: findState.phraseSearch,
  12975. caseSensitive: findState.caseSensitive,
  12976. highlightAll: findState.highlightAll,
  12977. findPrevious: cmd === 5 || cmd === 12
  12978. })
  12979. }
  12980. handled = true
  12981. }
  12982. break;
  12983. case 61:
  12984. case 107:
  12985. case 187:
  12986. case 171:
  12987. if (!isViewerInPresentationMode) {
  12988. PDFViewerApplication.zoomIn()
  12989. }
  12990. handled = true;
  12991. break;
  12992. case 173:
  12993. case 109:
  12994. case 189:
  12995. if (!isViewerInPresentationMode) {
  12996. PDFViewerApplication.zoomOut()
  12997. }
  12998. handled = true;
  12999. break;
  13000. case 48:
  13001. case 96:
  13002. if (!isViewerInPresentationMode) {
  13003. setTimeout(function() {
  13004. pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE
  13005. });
  13006. handled = false
  13007. }
  13008. break;
  13009. case 38:
  13010. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  13011. PDFViewerApplication.page = 1;
  13012. handled = true;
  13013. ensureViewerFocused = true
  13014. }
  13015. break;
  13016. case 40:
  13017. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  13018. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  13019. handled = true;
  13020. ensureViewerFocused = true
  13021. }
  13022. break
  13023. }
  13024. }
  13025. if (cmd === 1 || cmd === 8) {
  13026. switch (evt.keyCode) {
  13027. case 83:
  13028. PDFViewerApplication.download();
  13029. handled = true;
  13030. break
  13031. }
  13032. }
  13033. if (cmd === 3 || cmd === 10) {
  13034. switch (evt.keyCode) {
  13035. case 80:
  13036. PDFViewerApplication.requestPresentationMode();
  13037. handled = true;
  13038. break;
  13039. case 71:
  13040. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  13041. handled = true;
  13042. break
  13043. }
  13044. }
  13045. if (handled) {
  13046. if (ensureViewerFocused && !isViewerInPresentationMode) {
  13047. pdfViewer.focus()
  13048. }
  13049. evt.preventDefault();
  13050. return
  13051. }
  13052. var curElement = document.activeElement || document.querySelector(':focus');
  13053. var curElementTagName = curElement && curElement.tagName.toUpperCase();
  13054. if (curElementTagName === 'INPUT' || curElementTagName === 'TEXTAREA' || curElementTagName === 'SELECT') {
  13055. if (evt.keyCode !== 27) {
  13056. return
  13057. }
  13058. }
  13059. if (cmd === 0) {
  13060. switch (evt.keyCode) {
  13061. case 38:
  13062. case 33:
  13063. case 8:
  13064. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== 'page-fit') {
  13065. break
  13066. }
  13067. case 37:
  13068. if (pdfViewer.isHorizontalScrollbarEnabled) {
  13069. break
  13070. }
  13071. case 75:
  13072. case 80:
  13073. if (PDFViewerApplication.page > 1) {
  13074. PDFViewerApplication.page--
  13075. }
  13076. handled = true;
  13077. break;
  13078. case 27:
  13079. if (PDFViewerApplication.secondaryToolbar.isOpen) {
  13080. PDFViewerApplication.secondaryToolbar.close();
  13081. handled = true
  13082. }
  13083. if (!PDFViewerApplication.supportsIntegratedFind && PDFViewerApplication.findBar.opened) {
  13084. PDFViewerApplication.findBar.close();
  13085. handled = true
  13086. }
  13087. break;
  13088. case 40:
  13089. case 34:
  13090. case 32:
  13091. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== 'page-fit') {
  13092. break
  13093. }
  13094. case 39:
  13095. if (pdfViewer.isHorizontalScrollbarEnabled) {
  13096. break
  13097. }
  13098. case 74:
  13099. case 78:
  13100. if (PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  13101. PDFViewerApplication.page++
  13102. }
  13103. handled = true;
  13104. break;
  13105. case 36:
  13106. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  13107. PDFViewerApplication.page = 1;
  13108. handled = true;
  13109. ensureViewerFocused = true
  13110. }
  13111. break;
  13112. case 35:
  13113. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  13114. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  13115. handled = true;
  13116. ensureViewerFocused = true
  13117. }
  13118. break;
  13119. case 83:
  13120. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.SELECT);
  13121. break;
  13122. case 72:
  13123. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.HAND);
  13124. break;
  13125. case 82:
  13126. PDFViewerApplication.rotatePages(90);
  13127. break
  13128. }
  13129. }
  13130. if (cmd === 4) {
  13131. switch (evt.keyCode) {
  13132. case 32:
  13133. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== 'page-fit') {
  13134. break
  13135. }
  13136. if (PDFViewerApplication.page > 1) {
  13137. PDFViewerApplication.page--
  13138. }
  13139. handled = true;
  13140. break;
  13141. case 82:
  13142. PDFViewerApplication.rotatePages( - 90);
  13143. break
  13144. }
  13145. }
  13146. if (!handled && !isViewerInPresentationMode) {
  13147. if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !== 'BUTTON') {
  13148. ensureViewerFocused = true
  13149. }
  13150. }
  13151. if (cmd === 2) {
  13152. switch (evt.keyCode) {
  13153. case 37:
  13154. if (isViewerInPresentationMode) {
  13155. PDFViewerApplication.pdfHistory.back();
  13156. handled = true
  13157. }
  13158. break;
  13159. case 39:
  13160. if (isViewerInPresentationMode) {
  13161. PDFViewerApplication.pdfHistory.forward();
  13162. handled = true
  13163. }
  13164. break
  13165. }
  13166. }
  13167. if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
  13168. pdfViewer.focus()
  13169. }
  13170. if (handled) {
  13171. evt.preventDefault()
  13172. }
  13173. }
  13174. function apiPageModeToSidebarView(mode) {
  13175. switch (mode) {
  13176. case 'UseNone':
  13177. return _pdf_sidebar.SidebarView.NONE;
  13178. case 'UseThumbs':
  13179. return _pdf_sidebar.SidebarView.THUMBS;
  13180. case 'UseOutlines':
  13181. return _pdf_sidebar.SidebarView.OUTLINE;
  13182. case 'UseAttachments':
  13183. return _pdf_sidebar.SidebarView.ATTACHMENTS;
  13184. case 'UseOC':
  13185. }
  13186. return _pdf_sidebar.SidebarView.NONE
  13187. }
  13188. var PDFPrintServiceFactory = {
  13189. instance: {
  13190. supportsPrinting: false,
  13191. createPrintService: function createPrintService() {
  13192. throw new Error('Not implemented: createPrintService');
  13193. }
  13194. }
  13195. };
  13196. exports.PDFViewerApplication = PDFViewerApplication;
  13197. exports.DefaultExternalServices = DefaultExternalServices;
  13198. exports.PDFPrintServiceFactory = PDFPrintServiceFactory
  13199. }), (function(module, exports, __webpack_require__) {
  13200. "use strict";
  13201. Object.defineProperty(exports, "__esModule", {
  13202. value: true
  13203. });
  13204. exports.SimpleLinkService = exports.PDFLinkService = undefined;
  13205. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ?
  13206. function(obj) {
  13207. return typeof obj
  13208. }: function(obj) {
  13209. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol": typeof obj
  13210. };
  13211. var _createClass = function() {
  13212. function defineProperties(target, props) {
  13213. for (var i = 0; i < props.length; i++) {
  13214. var descriptor = props[i];
  13215. descriptor.enumerable = descriptor.enumerable || false;
  13216. descriptor.configurable = true;
  13217. if ("value" in descriptor) descriptor.writable = true;
  13218. Object.defineProperty(target, descriptor.key, descriptor)
  13219. }
  13220. }
  13221. return function(Constructor, protoProps, staticProps) {
  13222. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  13223. if (staticProps) defineProperties(Constructor, staticProps);
  13224. return Constructor
  13225. }
  13226. } ();
  13227. var _dom_events = __webpack_require__(2);
  13228. var _ui_utils = __webpack_require__(0);
  13229. function _classCallCheck(instance, Constructor) {
  13230. if (! (instance instanceof Constructor)) {
  13231. throw new TypeError("Cannot call a class as a function");
  13232. }
  13233. }
  13234. var PDFLinkService = function() {
  13235. function PDFLinkService() {
  13236. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  13237. eventBus = _ref.eventBus;
  13238. _classCallCheck(this, PDFLinkService);
  13239. this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)();
  13240. this.baseUrl = null;
  13241. this.pdfDocument = null;
  13242. this.pdfViewer = null;
  13243. this.pdfHistory = null;
  13244. this._pagesRefCache = null
  13245. }
  13246. _createClass(PDFLinkService, [{
  13247. key: 'setDocument',
  13248. value: function setDocument(pdfDocument, baseUrl) {
  13249. this.baseUrl = baseUrl;
  13250. this.pdfDocument = pdfDocument;
  13251. this._pagesRefCache = Object.create(null)
  13252. }
  13253. },
  13254. {
  13255. key: 'setViewer',
  13256. value: function setViewer(pdfViewer) {
  13257. this.pdfViewer = pdfViewer
  13258. }
  13259. },
  13260. {
  13261. key: 'setHistory',
  13262. value: function setHistory(pdfHistory) {
  13263. this.pdfHistory = pdfHistory
  13264. }
  13265. },
  13266. {
  13267. key: 'navigateTo',
  13268. value: function navigateTo(dest) {
  13269. var _this = this;
  13270. var goToDestination = function goToDestination(_ref2) {
  13271. var namedDest = _ref2.namedDest,
  13272. explicitDest = _ref2.explicitDest;
  13273. var destRef = explicitDest[0],
  13274. pageNumber = void 0;
  13275. if (destRef instanceof Object) {
  13276. pageNumber = _this._cachedPageNumber(destRef);
  13277. if (pageNumber === null) {
  13278. _this.pdfDocument.getPageIndex(destRef).then(function(pageIndex) {
  13279. _this.cachePageRef(pageIndex + 1, destRef);
  13280. goToDestination({
  13281. namedDest: namedDest,
  13282. explicitDest: explicitDest
  13283. })
  13284. }).
  13285. catch(function() {
  13286. console.error('PDFLinkService.navigateTo: "' + destRef + '" is not ' + ('a valid page reference, for dest="' + dest + '".'))
  13287. });
  13288. return
  13289. }
  13290. } else if ((destRef | 0) === destRef) {
  13291. pageNumber = destRef + 1
  13292. } else {
  13293. console.error('PDFLinkService.navigateTo: "' + destRef + '" is not ' + ('a valid destination reference, for dest="' + dest + '".'));
  13294. return
  13295. }
  13296. if (!pageNumber || pageNumber < 1 || pageNumber > _this.pagesCount) {
  13297. console.error('PDFLinkService.navigateTo: "' + pageNumber + '" is not ' + ('a valid page number, for dest="' + dest + '".'));
  13298. return
  13299. }
  13300. _this.pdfViewer.scrollPageIntoView({
  13301. pageNumber: pageNumber,
  13302. destArray: explicitDest
  13303. });
  13304. if (_this.pdfHistory) {
  13305. _this.pdfHistory.push({
  13306. dest: explicitDest,
  13307. hash: namedDest,
  13308. page: pageNumber
  13309. })
  13310. }
  13311. };
  13312. new Promise(function(resolve, reject) {
  13313. if (typeof dest === 'string') {
  13314. _this.pdfDocument.getDestination(dest).then(function(destArray) {
  13315. resolve({
  13316. namedDest: dest,
  13317. explicitDest: destArray
  13318. })
  13319. });
  13320. return
  13321. }
  13322. resolve({
  13323. namedDest: '',
  13324. explicitDest: dest
  13325. })
  13326. }).then(function(data) {
  13327. if (! (data.explicitDest instanceof Array)) {
  13328. console.error('PDFLinkService.navigateTo: "' + data.explicitDest + '" is' + (' not a valid destination array, for dest="' + dest + '".'));
  13329. return
  13330. }
  13331. goToDestination(data)
  13332. })
  13333. }
  13334. },
  13335. {
  13336. key: 'getDestinationHash',
  13337. value: function getDestinationHash(dest) {
  13338. if (typeof dest === 'string') {
  13339. return this.getAnchorUrl('#' + escape(dest))
  13340. }
  13341. if (dest instanceof Array) {
  13342. var str = JSON.stringify(dest);
  13343. return this.getAnchorUrl('#' + escape(str))
  13344. }
  13345. return this.getAnchorUrl('')
  13346. }
  13347. },
  13348. {
  13349. key: 'getAnchorUrl',
  13350. value: function getAnchorUrl(anchor) {
  13351. return (this.baseUrl || '') + anchor
  13352. }
  13353. },
  13354. {
  13355. key: 'setHash',
  13356. value: function setHash(hash) {
  13357. var pageNumber = void 0,
  13358. dest = void 0;
  13359. if (hash.indexOf('=') >= 0) {
  13360. var params = (0, _ui_utils.parseQueryString)(hash);
  13361. if ('search' in params) {
  13362. this.eventBus.dispatch('findfromurlhash', {
  13363. source: this,
  13364. query: params['search'].replace(/"/g, ''),
  13365. phraseSearch: params['phrase'] === 'true'
  13366. })
  13367. }
  13368. if ('nameddest' in params) {
  13369. if (this.pdfHistory) {
  13370. this.pdfHistory.updateNextHashParam(params.nameddest)
  13371. }
  13372. this.navigateTo(params.nameddest);
  13373. return
  13374. }
  13375. if ('page' in params) {
  13376. pageNumber = params.page | 0 || 1
  13377. }
  13378. if ('zoom' in params) {
  13379. var zoomArgs = params.zoom.split(',');
  13380. var zoomArg = zoomArgs[0];
  13381. var zoomArgNumber = parseFloat(zoomArg);
  13382. if (zoomArg.indexOf('Fit') === -1) {
  13383. dest = [null, {
  13384. name: 'XYZ'
  13385. },
  13386. zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg]
  13387. } else {
  13388. if (zoomArg === 'Fit' || zoomArg === 'FitB') {
  13389. dest = [null, {
  13390. name: zoomArg
  13391. }]
  13392. } else if (zoomArg === 'FitH' || zoomArg === 'FitBH' || zoomArg === 'FitV' || zoomArg === 'FitBV') {
  13393. dest = [null, {
  13394. name: zoomArg
  13395. },
  13396. zoomArgs.length > 1 ? zoomArgs[1] | 0 : null]
  13397. } else if (zoomArg === 'FitR') {
  13398. if (zoomArgs.length !== 5) {
  13399. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".')
  13400. } else {
  13401. dest = [null, {
  13402. name: zoomArg
  13403. },
  13404. zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0]
  13405. }
  13406. } else {
  13407. console.error('PDFLinkService.setHash: "' + zoomArg + '" is not ' + 'a valid zoom value.')
  13408. }
  13409. }
  13410. }
  13411. if (dest) {
  13412. this.pdfViewer.scrollPageIntoView({
  13413. pageNumber: pageNumber || this.page,
  13414. destArray: dest,
  13415. allowNegativeOffset: true
  13416. })
  13417. } else if (pageNumber) {
  13418. this.page = pageNumber
  13419. }
  13420. if ('pagemode' in params) {
  13421. this.eventBus.dispatch('pagemode', {
  13422. source: this,
  13423. mode: params.pagemode
  13424. })
  13425. }
  13426. } else {
  13427. if (/^\d+$/.test(hash) && hash <= this.pagesCount) {
  13428. console.warn('PDFLinkService_setHash: specifying a page number ' + 'directly after the hash symbol (#) is deprecated, ' + ('please use the "#page=' + hash + '" form instead.'));
  13429. this.page = hash | 0
  13430. }
  13431. dest = unescape(hash);
  13432. try {
  13433. dest = JSON.parse(dest);
  13434. if (! (dest instanceof Array)) {
  13435. dest = dest.toString()
  13436. }
  13437. } catch(ex) {}
  13438. if (typeof dest === 'string' || isValidExplicitDestination(dest)) {
  13439. if (this.pdfHistory) {
  13440. this.pdfHistory.updateNextHashParam(dest)
  13441. }
  13442. this.navigateTo(dest);
  13443. return
  13444. }
  13445. console.error('PDFLinkService.setHash: "' + unescape(hash) + '" is not ' + 'a valid destination.')
  13446. }
  13447. }
  13448. },
  13449. {
  13450. key: 'executeNamedAction',
  13451. value: function executeNamedAction(action) {
  13452. switch (action) {
  13453. case 'GoBack':
  13454. if (this.pdfHistory) {
  13455. this.pdfHistory.back()
  13456. }
  13457. break;
  13458. case 'GoForward':
  13459. if (this.pdfHistory) {
  13460. this.pdfHistory.forward()
  13461. }
  13462. break;
  13463. case 'NextPage':
  13464. if (this.page < this.pagesCount) {
  13465. this.page++
  13466. }
  13467. break;
  13468. case 'PrevPage':
  13469. if (this.page > 1) {
  13470. this.page--
  13471. }
  13472. break;
  13473. case 'LastPage':
  13474. this.page = this.pagesCount;
  13475. break;
  13476. case 'FirstPage':
  13477. this.page = 1;
  13478. break;
  13479. default:
  13480. break
  13481. }
  13482. this.eventBus.dispatch('namedaction', {
  13483. source: this,
  13484. action: action
  13485. })
  13486. }
  13487. },
  13488. {
  13489. key: 'onFileAttachmentAnnotation',
  13490. value: function onFileAttachmentAnnotation(_ref3) {
  13491. var id = _ref3.id,
  13492. filename = _ref3.filename,
  13493. content = _ref3.content;
  13494. this.eventBus.dispatch('fileattachmentannotation', {
  13495. source: this,
  13496. id: id,
  13497. filename: filename,
  13498. content: content
  13499. })
  13500. }
  13501. },
  13502. {
  13503. key: 'cachePageRef',
  13504. value: function cachePageRef(pageNum, pageRef) {
  13505. var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
  13506. this._pagesRefCache[refStr] = pageNum
  13507. }
  13508. },
  13509. {
  13510. key: '_cachedPageNumber',
  13511. value: function _cachedPageNumber(pageRef) {
  13512. var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
  13513. return this._pagesRefCache && this._pagesRefCache[refStr] || null
  13514. }
  13515. },
  13516. {
  13517. key: 'pagesCount',
  13518. get: function get() {
  13519. return this.pdfDocument ? this.pdfDocument.numPages: 0
  13520. }
  13521. },
  13522. {
  13523. key: 'page',
  13524. get: function get() {
  13525. return this.pdfViewer.currentPageNumber
  13526. },
  13527. set: function set(value) {
  13528. this.pdfViewer.currentPageNumber = value
  13529. }
  13530. }]);
  13531. return PDFLinkService
  13532. } ();
  13533. function isValidExplicitDestination(dest) {
  13534. if (! (dest instanceof Array)) {
  13535. return false
  13536. }
  13537. var destLength = dest.length,
  13538. allowNull = true;
  13539. if (destLength < 2) {
  13540. return false
  13541. }
  13542. var page = dest[0];
  13543. if (! ((typeof page === 'undefined' ? 'undefined': _typeof(page)) === 'object' && typeof page.num === 'number' && (page.num | 0) === page.num && typeof page.gen === 'number' && (page.gen | 0) === page.gen) && !(typeof page === 'number' && (page | 0) === page && page >= 0)) {
  13544. return false
  13545. }
  13546. var zoom = dest[1];
  13547. if (! ((typeof zoom === 'undefined' ? 'undefined': _typeof(zoom)) === 'object' && typeof zoom.name === 'string')) {
  13548. return false
  13549. }
  13550. switch (zoom.name) {
  13551. case 'XYZ':
  13552. if (destLength !== 5) {
  13553. return false
  13554. }
  13555. break;
  13556. case 'Fit':
  13557. case 'FitB':
  13558. return destLength === 2;
  13559. case 'FitH':
  13560. case 'FitBH':
  13561. case 'FitV':
  13562. case 'FitBV':
  13563. if (destLength !== 3) {
  13564. return false
  13565. }
  13566. break;
  13567. case 'FitR':
  13568. if (destLength !== 6) {
  13569. return false
  13570. }
  13571. allowNull = false;
  13572. break;
  13573. default:
  13574. return false
  13575. }
  13576. for (var i = 2; i < destLength; i++) {
  13577. var param = dest[i];
  13578. if (! (typeof param === 'number' || allowNull && param === null)) {
  13579. return false
  13580. }
  13581. }
  13582. return true
  13583. }
  13584. var SimpleLinkService = function() {
  13585. function SimpleLinkService() {
  13586. _classCallCheck(this, SimpleLinkService)
  13587. }
  13588. _createClass(SimpleLinkService, [{
  13589. key: 'navigateTo',
  13590. value: function navigateTo(dest) {}
  13591. },
  13592. {
  13593. key: 'getDestinationHash',
  13594. value: function getDestinationHash(dest) {
  13595. return '#'
  13596. }
  13597. },
  13598. {
  13599. key: 'getAnchorUrl',
  13600. value: function getAnchorUrl(hash) {
  13601. return '#'
  13602. }
  13603. },
  13604. {
  13605. key: 'setHash',
  13606. value: function setHash(hash) {}
  13607. },
  13608. {
  13609. key: 'executeNamedAction',
  13610. value: function executeNamedAction(action) {}
  13611. },
  13612. {
  13613. key: 'onFileAttachmentAnnotation',
  13614. value: function onFileAttachmentAnnotation(_ref4) {
  13615. var id = _ref4.id,
  13616. filename = _ref4.filename,
  13617. content = _ref4.content
  13618. }
  13619. },
  13620. {
  13621. key: 'cachePageRef',
  13622. value: function cachePageRef(pageNum, pageRef) {}
  13623. },
  13624. {
  13625. key: 'page',
  13626. get: function get() {
  13627. return 0
  13628. },
  13629. set: function set(value) {}
  13630. }]);
  13631. return SimpleLinkService
  13632. } ();
  13633. exports.PDFLinkService = PDFLinkService;
  13634. exports.SimpleLinkService = SimpleLinkService
  13635. }), (function(module, exports, __webpack_require__) {
  13636. "use strict";
  13637. Object.defineProperty(exports, "__esModule", {
  13638. value: true
  13639. });
  13640. exports.PDFCursorTools = exports.CursorTool = undefined;
  13641. var _slicedToArray = function() {
  13642. function sliceIterator(arr, i) {
  13643. var _arr = [];
  13644. var _n = true;
  13645. var _d = false;
  13646. var _e = undefined;
  13647. try {
  13648. for (var _i = arr[Symbol.iterator](), _s; ! (_n = (_s = _i.next()).done); _n = true) {
  13649. _arr.push(_s.value);
  13650. if (i && _arr.length === i) break
  13651. }
  13652. } catch(err) {
  13653. _d = true;
  13654. _e = err
  13655. } finally {
  13656. try {
  13657. if (!_n && _i["return"]) _i["return"]()
  13658. } finally {
  13659. if (_d) throw _e;
  13660. }
  13661. }
  13662. return _arr
  13663. }
  13664. return function(arr, i) {
  13665. if (Array.isArray(arr)) {
  13666. return arr
  13667. } else if (Symbol.iterator in Object(arr)) {
  13668. return sliceIterator(arr, i)
  13669. } else {
  13670. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  13671. }
  13672. }
  13673. } ();
  13674. var _createClass = function() {
  13675. function defineProperties(target, props) {
  13676. for (var i = 0; i < props.length; i++) {
  13677. var descriptor = props[i];
  13678. descriptor.enumerable = descriptor.enumerable || false;
  13679. descriptor.configurable = true;
  13680. if ("value" in descriptor) descriptor.writable = true;
  13681. Object.defineProperty(target, descriptor.key, descriptor)
  13682. }
  13683. }
  13684. return function(Constructor, protoProps, staticProps) {
  13685. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  13686. if (staticProps) defineProperties(Constructor, staticProps);
  13687. return Constructor
  13688. }
  13689. } ();
  13690. var _grab_to_pan = __webpack_require__(14);
  13691. function _classCallCheck(instance, Constructor) {
  13692. if (! (instance instanceof Constructor)) {
  13693. throw new TypeError("Cannot call a class as a function");
  13694. }
  13695. }
  13696. var CursorTool = {
  13697. SELECT: 0,
  13698. HAND: 1,
  13699. ZOOM: 2
  13700. };
  13701. var PDFCursorTools = function() {
  13702. function PDFCursorTools(_ref) {
  13703. var _this = this;
  13704. var container = _ref.container,
  13705. eventBus = _ref.eventBus,
  13706. preferences = _ref.preferences;
  13707. _classCallCheck(this, PDFCursorTools);
  13708. this.container = container;
  13709. this.eventBus = eventBus;
  13710. this.active = CursorTool.SELECT;
  13711. this.activeBeforePresentationMode = null;
  13712. this.handTool = new _grab_to_pan.GrabToPan({
  13713. element: this.container
  13714. });
  13715. this._addEventListeners();
  13716. Promise.all([preferences.get('cursorToolOnLoad'), preferences.get('enableHandToolOnLoad')]).then(function(_ref2) {
  13717. var _ref3 = _slicedToArray(_ref2, 2),
  13718. cursorToolPref = _ref3[0],
  13719. handToolPref = _ref3[1];
  13720. if (handToolPref === true) {
  13721. preferences.set('enableHandToolOnLoad', false);
  13722. if (cursorToolPref === CursorTool.SELECT) {
  13723. cursorToolPref = CursorTool.HAND;
  13724. preferences.set('cursorToolOnLoad', cursorToolPref).
  13725. catch(function() {})
  13726. }
  13727. }
  13728. _this.switchTool(cursorToolPref)
  13729. }).
  13730. catch(function() {})
  13731. }
  13732. _createClass(PDFCursorTools, [{
  13733. key: 'switchTool',
  13734. value: function switchTool(tool) {
  13735. var _this2 = this;
  13736. if (this.activeBeforePresentationMode !== null) {
  13737. return
  13738. }
  13739. if (tool === this.active) {
  13740. return
  13741. }
  13742. var disableActiveTool = function disableActiveTool() {
  13743. switch (_this2.active) {
  13744. case CursorTool.SELECT:
  13745. break;
  13746. case CursorTool.HAND:
  13747. _this2.handTool.deactivate();
  13748. break;
  13749. case CursorTool.ZOOM:
  13750. }
  13751. };
  13752. switch (tool) {
  13753. case CursorTool.SELECT:
  13754. disableActiveTool();
  13755. break;
  13756. case CursorTool.HAND:
  13757. disableActiveTool();
  13758. this.handTool.activate();
  13759. break;
  13760. case CursorTool.ZOOM:
  13761. default:
  13762. console.error('switchTool: "' + tool + '" is an unsupported value.');
  13763. return
  13764. }
  13765. this.active = tool;
  13766. this._dispatchEvent()
  13767. }
  13768. },
  13769. {
  13770. key: '_dispatchEvent',
  13771. value: function _dispatchEvent() {
  13772. this.eventBus.dispatch('cursortoolchanged', {
  13773. source: this,
  13774. tool: this.active
  13775. })
  13776. }
  13777. },
  13778. {
  13779. key: '_addEventListeners',
  13780. value: function _addEventListeners() {
  13781. var _this3 = this;
  13782. this.eventBus.on('switchcursortool',
  13783. function(evt) {
  13784. _this3.switchTool(evt.tool)
  13785. });
  13786. this.eventBus.on('presentationmodechanged',
  13787. function(evt) {
  13788. if (evt.switchInProgress) {
  13789. return
  13790. }
  13791. var previouslyActive = void 0;
  13792. if (evt.active) {
  13793. previouslyActive = _this3.active;
  13794. _this3.switchTool(CursorTool.SELECT);
  13795. _this3.activeBeforePresentationMode = previouslyActive
  13796. } else {
  13797. previouslyActive = _this3.activeBeforePresentationMode;
  13798. _this3.activeBeforePresentationMode = null;
  13799. _this3.switchTool(previouslyActive)
  13800. }
  13801. })
  13802. }
  13803. },
  13804. {
  13805. key: 'activeTool',
  13806. get: function get() {
  13807. return this.active
  13808. }
  13809. }]);
  13810. return PDFCursorTools
  13811. } ();
  13812. exports.CursorTool = CursorTool;
  13813. exports.PDFCursorTools = PDFCursorTools
  13814. }), (function(module, exports, __webpack_require__) {
  13815. "use strict";
  13816. Object.defineProperty(exports, "__esModule", {
  13817. value: true
  13818. });
  13819. exports.PDFFindController = exports.FindState = undefined;
  13820. var _createClass = function() {
  13821. function defineProperties(target, props) {
  13822. for (var i = 0; i < props.length; i++) {
  13823. var descriptor = props[i];
  13824. descriptor.enumerable = descriptor.enumerable || false;
  13825. descriptor.configurable = true;
  13826. if ("value" in descriptor) descriptor.writable = true;
  13827. Object.defineProperty(target, descriptor.key, descriptor)
  13828. }
  13829. }
  13830. return function(Constructor, protoProps, staticProps) {
  13831. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  13832. if (staticProps) defineProperties(Constructor, staticProps);
  13833. return Constructor
  13834. }
  13835. } ();
  13836. var _pdfjsLib = __webpack_require__(1);
  13837. var _ui_utils = __webpack_require__(0);
  13838. function _classCallCheck(instance, Constructor) {
  13839. if (! (instance instanceof Constructor)) {
  13840. throw new TypeError("Cannot call a class as a function");
  13841. }
  13842. }
  13843. var FindState = {
  13844. FOUND: 0,
  13845. NOT_FOUND: 1,
  13846. WRAPPED: 2,
  13847. PENDING: 3
  13848. };
  13849. var FIND_SCROLL_OFFSET_TOP = -50;
  13850. var FIND_SCROLL_OFFSET_LEFT = -400;
  13851. var FIND_TIMEOUT = 250;
  13852. var CHARACTERS_TO_NORMALIZE = {
  13853. '\u2018': '\'',
  13854. '\u2019': '\'',
  13855. '\u201A': '\'',
  13856. '\u201B': '\'',
  13857. '\u201C': '"',
  13858. '\u201D': '"',
  13859. '\u201E': '"',
  13860. '\u201F': '"',
  13861. '\xBC': '1/4',
  13862. '\xBD': '1/2',
  13863. '\xBE': '3/4'
  13864. };
  13865. var PDFFindController = function() {
  13866. function PDFFindController(_ref) {
  13867. var pdfViewer = _ref.pdfViewer;
  13868. _classCallCheck(this, PDFFindController);
  13869. this.pdfViewer = pdfViewer;
  13870. this.onUpdateResultsCount = null;
  13871. this.onUpdateState = null;
  13872. this.reset();
  13873. var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join('');
  13874. this.normalizationRegex = new RegExp('[' + replace + ']', 'g')
  13875. }
  13876. _createClass(PDFFindController, [{
  13877. key: 'reset',
  13878. value: function reset() {
  13879. var _this = this;
  13880. this.startedTextExtraction = false;
  13881. this.extractTextPromises = [];
  13882. this.pendingFindMatches = Object.create(null);
  13883. this.active = false;
  13884. this.pageContents = [];
  13885. this.pageMatches = [];
  13886. this.pageMatchesLength = null;
  13887. this.matchCount = 0;
  13888. this.selected = {
  13889. pageIdx: -1,
  13890. matchIdx: -1
  13891. };
  13892. this.offset = {
  13893. pageIdx: null,
  13894. matchIdx: null
  13895. };
  13896. this.pagesToSearch = null;
  13897. this.resumePageIdx = null;
  13898. this.state = null;
  13899. this.dirtyMatch = false;
  13900. this.findTimeout = null;
  13901. this._firstPagePromise = new Promise(function(resolve) {
  13902. _this.resolveFirstPage = resolve
  13903. })
  13904. }
  13905. },
  13906. {
  13907. key: 'normalize',
  13908. value: function normalize(text) {
  13909. return text.replace(this.normalizationRegex,
  13910. function(ch) {
  13911. return CHARACTERS_TO_NORMALIZE[ch]
  13912. })
  13913. }
  13914. },
  13915. {
  13916. key: '_prepareMatches',
  13917. value: function _prepareMatches(matchesWithLength, matches, matchesLength) {
  13918. function isSubTerm(matchesWithLength, currentIndex) {
  13919. var currentElem = matchesWithLength[currentIndex];
  13920. var nextElem = matchesWithLength[currentIndex + 1];
  13921. if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {
  13922. currentElem.skipped = true;
  13923. return true
  13924. }
  13925. for (var i = currentIndex - 1; i >= 0; i--) {
  13926. var prevElem = matchesWithLength[i];
  13927. if (prevElem.skipped) {
  13928. continue
  13929. }
  13930. if (prevElem.match + prevElem.matchLength < currentElem.match) {
  13931. break
  13932. }
  13933. if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {
  13934. currentElem.skipped = true;
  13935. return true
  13936. }
  13937. }
  13938. return false
  13939. }
  13940. matchesWithLength.sort(function(a, b) {
  13941. return a.match === b.match ? a.matchLength - b.matchLength: a.match - b.match
  13942. });
  13943. for (var i = 0,
  13944. len = matchesWithLength.length; i < len; i++) {
  13945. if (isSubTerm(matchesWithLength, i)) {
  13946. continue
  13947. }
  13948. matches.push(matchesWithLength[i].match);
  13949. matchesLength.push(matchesWithLength[i].matchLength)
  13950. }
  13951. }
  13952. },
  13953. {
  13954. key: 'calcFindPhraseMatch',
  13955. value: function calcFindPhraseMatch(query, pageIndex, pageContent) {
  13956. var matches = [];
  13957. var queryLen = query.length;
  13958. var matchIdx = -queryLen;
  13959. while (true) {
  13960. matchIdx = pageContent.indexOf(query, matchIdx + queryLen);
  13961. if (matchIdx === -1) {
  13962. break
  13963. }
  13964. matches.push(matchIdx)
  13965. }
  13966. this.pageMatches[pageIndex] = matches
  13967. }
  13968. },
  13969. {
  13970. key: 'calcFindWordMatch',
  13971. value: function calcFindWordMatch(query, pageIndex, pageContent) {
  13972. var matchesWithLength = [];
  13973. var queryArray = query.match(/\S+/g);
  13974. for (var i = 0,
  13975. len = queryArray.length; i < len; i++) {
  13976. var subquery = queryArray[i];
  13977. var subqueryLen = subquery.length;
  13978. var matchIdx = -subqueryLen;
  13979. while (true) {
  13980. matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen);
  13981. if (matchIdx === -1) {
  13982. break
  13983. }
  13984. matchesWithLength.push({
  13985. match: matchIdx,
  13986. matchLength: subqueryLen,
  13987. skipped: false
  13988. })
  13989. }
  13990. }
  13991. if (!this.pageMatchesLength) {
  13992. this.pageMatchesLength = []
  13993. }
  13994. this.pageMatchesLength[pageIndex] = [];
  13995. this.pageMatches[pageIndex] = [];
  13996. this._prepareMatches(matchesWithLength, this.pageMatches[pageIndex], this.pageMatchesLength[pageIndex])
  13997. }
  13998. },
  13999. {
  14000. key: 'calcFindMatch',
  14001. value: function calcFindMatch(pageIndex) {
  14002. var pageContent = this.normalize(this.pageContents[pageIndex]);
  14003. var query = this.normalize(this.state.query);
  14004. var caseSensitive = this.state.caseSensitive;
  14005. var phraseSearch = this.state.phraseSearch;
  14006. var queryLen = query.length;
  14007. if (queryLen === 0) {
  14008. return
  14009. }
  14010. if (!caseSensitive) {
  14011. pageContent = pageContent.toLowerCase();
  14012. query = query.toLowerCase()
  14013. }
  14014. if (phraseSearch) {
  14015. this.calcFindPhraseMatch(query, pageIndex, pageContent)
  14016. } else {
  14017. this.calcFindWordMatch(query, pageIndex, pageContent)
  14018. }
  14019. this.updatePage(pageIndex);
  14020. if (this.resumePageIdx === pageIndex) {
  14021. this.resumePageIdx = null;
  14022. this.nextPageMatch()
  14023. }
  14024. if (this.pageMatches[pageIndex].length > 0) {
  14025. this.matchCount += this.pageMatches[pageIndex].length;
  14026. this.updateUIResultsCount()
  14027. }
  14028. }
  14029. },
  14030. {
  14031. key: 'extractText',
  14032. value: function extractText() {
  14033. var _this2 = this;
  14034. if (this.startedTextExtraction) {
  14035. return
  14036. }
  14037. this.startedTextExtraction = true;
  14038. this.pageContents.length = 0;
  14039. var promise = Promise.resolve();
  14040. var _loop = function _loop(i, ii) {
  14041. var extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
  14042. _this2.extractTextPromises[i] = extractTextCapability.promise;
  14043. promise = promise.then(function() {
  14044. return _this2.pdfViewer.getPageTextContent(i).then(function(textContent) {
  14045. var textItems = textContent.items;
  14046. var strBuf = [];
  14047. for (var j = 0,
  14048. jj = textItems.length; j < jj; j++) {
  14049. strBuf.push(textItems[j].str)
  14050. }
  14051. _this2.pageContents[i] = strBuf.join('');
  14052. extractTextCapability.resolve(i)
  14053. },
  14054. function(reason) {
  14055. console.error('Unable to get page ' + (i + 1) + ' text content', reason);
  14056. _this2.pageContents[i] = '';
  14057. extractTextCapability.resolve(i)
  14058. })
  14059. })
  14060. };
  14061. for (var i = 0,
  14062. ii = this.pdfViewer.pagesCount; i < ii; i++) {
  14063. _loop(i, ii)
  14064. }
  14065. }
  14066. },
  14067. {
  14068. key: 'executeCommand',
  14069. value: function executeCommand(cmd, state) {
  14070. var _this3 = this;
  14071. if (this.state === null || cmd !== 'findagain') {
  14072. this.dirtyMatch = true
  14073. }
  14074. this.state = state;
  14075. this.updateUIState(FindState.PENDING);
  14076. this._firstPagePromise.then(function() {
  14077. _this3.extractText();
  14078. clearTimeout(_this3.findTimeout);
  14079. if (cmd === 'find') {
  14080. _this3.findTimeout = setTimeout(_this3.nextMatch.bind(_this3), FIND_TIMEOUT)
  14081. } else {
  14082. _this3.nextMatch()
  14083. }
  14084. })
  14085. }
  14086. },
  14087. {
  14088. key: 'updatePage',
  14089. value: function updatePage(index) {
  14090. if (this.selected.pageIdx === index) {
  14091. this.pdfViewer.currentPageNumber = index + 1
  14092. }
  14093. var page = this.pdfViewer.getPageView(index);
  14094. if (page.textLayer) {
  14095. page.textLayer.updateMatches()
  14096. }
  14097. }
  14098. },
  14099. {
  14100. key: 'nextMatch',
  14101. value: function nextMatch() {
  14102. var _this4 = this;
  14103. var previous = this.state.findPrevious;
  14104. var currentPageIndex = this.pdfViewer.currentPageNumber - 1;
  14105. var numPages = this.pdfViewer.pagesCount;
  14106. this.active = true;
  14107. if (this.dirtyMatch) {
  14108. this.dirtyMatch = false;
  14109. this.selected.pageIdx = this.selected.matchIdx = -1;
  14110. this.offset.pageIdx = currentPageIndex;
  14111. this.offset.matchIdx = null;
  14112. this.hadMatch = false;
  14113. this.resumePageIdx = null;
  14114. this.pageMatches = [];
  14115. this.matchCount = 0;
  14116. this.pageMatchesLength = null;
  14117. for (var i = 0; i < numPages; i++) {
  14118. this.updatePage(i);
  14119. if (! (i in this.pendingFindMatches)) {
  14120. this.pendingFindMatches[i] = true;
  14121. this.extractTextPromises[i].then(function(pageIdx) {
  14122. delete _this4.pendingFindMatches[pageIdx];
  14123. _this4.calcFindMatch(pageIdx)
  14124. })
  14125. }
  14126. }
  14127. }
  14128. if (this.state.query === '') {
  14129. this.updateUIState(FindState.FOUND);
  14130. return
  14131. }
  14132. if (this.resumePageIdx) {
  14133. return
  14134. }
  14135. var offset = this.offset;
  14136. this.pagesToSearch = numPages;
  14137. if (offset.matchIdx !== null) {
  14138. var numPageMatches = this.pageMatches[offset.pageIdx].length;
  14139. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  14140. this.hadMatch = true;
  14141. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  14142. this.updateMatch(true);
  14143. return
  14144. }
  14145. this.advanceOffsetPage(previous)
  14146. }
  14147. this.nextPageMatch()
  14148. }
  14149. },
  14150. {
  14151. key: 'matchesReady',
  14152. value: function matchesReady(matches) {
  14153. var offset = this.offset;
  14154. var numMatches = matches.length;
  14155. var previous = this.state.findPrevious;
  14156. if (numMatches) {
  14157. this.hadMatch = true;
  14158. offset.matchIdx = previous ? numMatches - 1 : 0;
  14159. this.updateMatch(true);
  14160. return true
  14161. }
  14162. this.advanceOffsetPage(previous);
  14163. if (offset.wrapped) {
  14164. offset.matchIdx = null;
  14165. if (this.pagesToSearch < 0) {
  14166. this.updateMatch(false);
  14167. return true
  14168. }
  14169. }
  14170. return false
  14171. }
  14172. },
  14173. {
  14174. key: 'updateMatchPosition',
  14175. value: function updateMatchPosition(pageIndex, matchIndex, elements, beginIdx) {
  14176. if (this.selected.matchIdx === matchIndex && this.selected.pageIdx === pageIndex) {
  14177. var spot = {
  14178. top: FIND_SCROLL_OFFSET_TOP,
  14179. left: FIND_SCROLL_OFFSET_LEFT
  14180. }; (0, _ui_utils.scrollIntoView)(elements[beginIdx], spot, true)
  14181. }
  14182. }
  14183. },
  14184. {
  14185. key: 'nextPageMatch',
  14186. value: function nextPageMatch() {
  14187. if (this.resumePageIdx !== null) {
  14188. console.error('There can only be one pending page.')
  14189. }
  14190. var matches = null;
  14191. do {
  14192. var pageIdx = this.offset.pageIdx;
  14193. matches = this.pageMatches[pageIdx];
  14194. if (!matches) {
  14195. this.resumePageIdx = pageIdx;
  14196. break
  14197. }
  14198. } while (! this . matchesReady ( matches ))
  14199. }
  14200. },
  14201. {
  14202. key: 'advanceOffsetPage',
  14203. value: function advanceOffsetPage(previous) {
  14204. var offset = this.offset;
  14205. var numPages = this.extractTextPromises.length;
  14206. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  14207. offset.matchIdx = null;
  14208. this.pagesToSearch--;
  14209. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  14210. offset.pageIdx = previous ? numPages - 1 : 0;
  14211. offset.wrapped = true
  14212. }
  14213. }
  14214. },
  14215. {
  14216. key: 'updateMatch',
  14217. value: function updateMatch() {
  14218. var found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  14219. var state = FindState.NOT_FOUND;
  14220. var wrapped = this.offset.wrapped;
  14221. this.offset.wrapped = false;
  14222. if (found) {
  14223. var previousPage = this.selected.pageIdx;
  14224. this.selected.pageIdx = this.offset.pageIdx;
  14225. this.selected.matchIdx = this.offset.matchIdx;
  14226. state = wrapped ? FindState.WRAPPED: FindState.FOUND;
  14227. if (previousPage !== -1 && previousPage !== this.selected.pageIdx) {
  14228. this.updatePage(previousPage)
  14229. }
  14230. }
  14231. this.updateUIState(state, this.state.findPrevious);
  14232. if (this.selected.pageIdx !== -1) {
  14233. this.updatePage(this.selected.pageIdx)
  14234. }
  14235. }
  14236. },
  14237. {
  14238. key: 'updateUIResultsCount',
  14239. value: function updateUIResultsCount() {
  14240. if (this.onUpdateResultsCount) {
  14241. this.onUpdateResultsCount(this.matchCount)
  14242. }
  14243. }
  14244. },
  14245. {
  14246. key: 'updateUIState',
  14247. value: function updateUIState(state, previous) {
  14248. if (this.onUpdateState) {
  14249. this.onUpdateState(state, previous, this.matchCount)
  14250. }
  14251. }
  14252. }]);
  14253. return PDFFindController
  14254. } ();
  14255. exports.FindState = FindState;
  14256. exports.PDFFindController = PDFFindController
  14257. }), (function(module, exports, __webpack_require__) {
  14258. "use strict";
  14259. Object.defineProperty(exports, "__esModule", {
  14260. value: true
  14261. });
  14262. exports.GenericCom = undefined;
  14263. var _createClass = function() {
  14264. function defineProperties(target, props) {
  14265. for (var i = 0; i < props.length; i++) {
  14266. var descriptor = props[i];
  14267. descriptor.enumerable = descriptor.enumerable || false;
  14268. descriptor.configurable = true;
  14269. if ("value" in descriptor) descriptor.writable = true;
  14270. Object.defineProperty(target, descriptor.key, descriptor)
  14271. }
  14272. }
  14273. return function(Constructor, protoProps, staticProps) {
  14274. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  14275. if (staticProps) defineProperties(Constructor, staticProps);
  14276. return Constructor
  14277. }
  14278. } ();
  14279. var _app = __webpack_require__(4);
  14280. var _preferences = __webpack_require__(28);
  14281. var _download_manager = __webpack_require__(12);
  14282. var _genericl10n = __webpack_require__(13);
  14283. var _pdfjsLib = __webpack_require__(1);
  14284. function _classCallCheck(instance, Constructor) {
  14285. if (! (instance instanceof Constructor)) {
  14286. throw new TypeError("Cannot call a class as a function");
  14287. }
  14288. }
  14289. function _possibleConstructorReturn(self, call) {
  14290. if (!self) {
  14291. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  14292. }
  14293. return call && (typeof call === "object" || typeof call === "function") ? call: self
  14294. }
  14295. function _inherits(subClass, superClass) {
  14296. if (typeof superClass !== "function" && superClass !== null) {
  14297. throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
  14298. }
  14299. subClass.prototype = Object.create(superClass && superClass.prototype, {
  14300. constructor: {
  14301. value: subClass,
  14302. enumerable: false,
  14303. writable: true,
  14304. configurable: true
  14305. }
  14306. });
  14307. if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass
  14308. };
  14309. var GenericCom = {};
  14310. var GenericPreferences = function(_BasePreferences) {
  14311. _inherits(GenericPreferences, _BasePreferences);
  14312. function GenericPreferences() {
  14313. _classCallCheck(this, GenericPreferences);
  14314. return _possibleConstructorReturn(this, (GenericPreferences.__proto__ || Object.getPrototypeOf(GenericPreferences)).apply(this, arguments))
  14315. }
  14316. _createClass(GenericPreferences, [{
  14317. key: '_writeToStorage',
  14318. value: function _writeToStorage(prefObj) {
  14319. return new Promise(function(resolve) {
  14320. localStorage.setItem('pdfjs.preferences', JSON.stringify(prefObj));
  14321. resolve()
  14322. })
  14323. }
  14324. },
  14325. {
  14326. key: '_readFromStorage',
  14327. value: function _readFromStorage(prefObj) {
  14328. return new Promise(function(resolve) {
  14329. var readPrefs = JSON.parse(localStorage.getItem('pdfjs.preferences'));
  14330. resolve(readPrefs)
  14331. })
  14332. }
  14333. }]);
  14334. return GenericPreferences
  14335. } (_preferences.BasePreferences);
  14336. var GenericExternalServices = Object.create(_app.DefaultExternalServices);
  14337. GenericExternalServices.createDownloadManager = function() {
  14338. return new _download_manager.DownloadManager()
  14339. };
  14340. GenericExternalServices.createPreferences = function() {
  14341. return new GenericPreferences()
  14342. };
  14343. GenericExternalServices.createL10n = function() {
  14344. return new _genericl10n.GenericL10n(_pdfjsLib.PDFJS.locale)
  14345. };
  14346. _app.PDFViewerApplication.externalServices = GenericExternalServices;
  14347. exports.GenericCom = GenericCom
  14348. }), (function(module, exports, __webpack_require__) {
  14349. "use strict";
  14350. Object.defineProperty(exports, "__esModule", {
  14351. value: true
  14352. });
  14353. exports.PDFPrintService = undefined;
  14354. var _ui_utils = __webpack_require__(0);
  14355. var _app = __webpack_require__(4);
  14356. var _pdfjsLib = __webpack_require__(1);
  14357. var activeService = null;
  14358. var overlayManager = null;
  14359. function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size) {
  14360. var scratchCanvas = activeService.scratchCanvas;
  14361. var PRINT_RESOLUTION = 150;
  14362. var PRINT_UNITS = PRINT_RESOLUTION / 72.0;
  14363. scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
  14364. scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
  14365. var width = Math.floor(size.width * _ui_utils.CSS_UNITS) + 'px';
  14366. var height = Math.floor(size.height * _ui_utils.CSS_UNITS) + 'px';
  14367. var ctx = scratchCanvas.getContext('2d');
  14368. ctx.save();
  14369. ctx.fillStyle = 'rgb(255, 255, 255)';
  14370. ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height);
  14371. ctx.restore();
  14372. return pdfDocument.getPage(pageNumber).then(function(pdfPage) {
  14373. var renderContext = {
  14374. canvasContext: ctx,
  14375. transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
  14376. viewport: pdfPage.getViewport(1, size.rotation),
  14377. intent: 'print'
  14378. };
  14379. return pdfPage.render(renderContext).promise
  14380. }).then(function() {
  14381. return {
  14382. width: width,
  14383. height: height
  14384. }
  14385. })
  14386. }
  14387. function PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
  14388. this.pdfDocument = pdfDocument;
  14389. this.pagesOverview = pagesOverview;
  14390. this.printContainer = printContainer;
  14391. this.l10n = l10n || _ui_utils.NullL10n;
  14392. this.currentPage = -1;
  14393. this.scratchCanvas = document.createElement('canvas')
  14394. }
  14395. PDFPrintService.prototype = {
  14396. layout: function layout() {
  14397. this.throwIfInactive();
  14398. var body = document.querySelector('body');
  14399. body.setAttribute('data-pdfjsprinting', true);
  14400. var hasEqualPageSizes = this.pagesOverview.every(function(size) {
  14401. return size.width === this.pagesOverview[0].width && size.height === this.pagesOverview[0].height
  14402. },
  14403. this);
  14404. if (!hasEqualPageSizes) {
  14405. console.warn('Not all pages have the same size. The printed ' + 'result may be incorrect!')
  14406. }
  14407. this.pageStyleSheet = document.createElement('style');
  14408. var pageSize = this.pagesOverview[0];
  14409. this.pageStyleSheet.textContent = '@supports ((size:A4) and (size:1pt 1pt)) {' + '@page { size: ' + pageSize.width + 'pt ' + pageSize.height + 'pt;}' + '}';
  14410. body.appendChild(this.pageStyleSheet)
  14411. },
  14412. destroy: function destroy() {
  14413. if (activeService !== this) {
  14414. return
  14415. }
  14416. this.printContainer.textContent = '';
  14417. if (this.pageStyleSheet && this.pageStyleSheet.parentNode) {
  14418. this.pageStyleSheet.parentNode.removeChild(this.pageStyleSheet);
  14419. this.pageStyleSheet = null
  14420. }
  14421. this.scratchCanvas.width = this.scratchCanvas.height = 0;
  14422. this.scratchCanvas = null;
  14423. activeService = null;
  14424. ensureOverlay().then(function() {
  14425. if (overlayManager.active !== 'printServiceOverlay') {
  14426. return
  14427. }
  14428. overlayManager.close('printServiceOverlay')
  14429. })
  14430. },
  14431. renderPages: function renderPages() {
  14432. var _this = this;
  14433. var pageCount = this.pagesOverview.length;
  14434. var renderNextPage = function renderNextPage(resolve, reject) {
  14435. _this.throwIfInactive();
  14436. if (++_this.currentPage >= pageCount) {
  14437. renderProgress(pageCount, pageCount, _this.l10n);
  14438. resolve();
  14439. return
  14440. }
  14441. var index = _this.currentPage;
  14442. renderProgress(index, pageCount, _this.l10n);
  14443. renderPage(_this, _this.pdfDocument, index + 1, _this.pagesOverview[index]).then(_this.useRenderedPage.bind(_this)).then(function() {
  14444. renderNextPage(resolve, reject)
  14445. },
  14446. reject)
  14447. };
  14448. return new Promise(renderNextPage)
  14449. },
  14450. useRenderedPage: function useRenderedPage(printItem) {
  14451. this.throwIfInactive();
  14452. var img = document.createElement('img');
  14453. img.style.width = printItem.width;
  14454. img.style.height = printItem.height;
  14455. var scratchCanvas = this.scratchCanvas;
  14456. if ('toBlob' in scratchCanvas && !_pdfjsLib.PDFJS.disableCreateObjectURL) {
  14457. scratchCanvas.toBlob(function(blob) {
  14458. img.src = URL.createObjectURL(blob)
  14459. })
  14460. } else {
  14461. img.src = scratchCanvas.toDataURL()
  14462. }
  14463. var wrapper = document.createElement('div');
  14464. wrapper.appendChild(img);
  14465. this.printContainer.appendChild(wrapper);
  14466. return new Promise(function(resolve, reject) {
  14467. img.onload = resolve;
  14468. img.onerror = reject
  14469. })
  14470. },
  14471. performPrint: function performPrint() {
  14472. var _this2 = this;
  14473. this.throwIfInactive();
  14474. return new Promise(function(resolve) {
  14475. setTimeout(function() {
  14476. if (!_this2.active) {
  14477. resolve();
  14478. return
  14479. }
  14480. print.call(window);
  14481. setTimeout(resolve, 20)
  14482. },
  14483. 0)
  14484. })
  14485. },
  14486. get active() {
  14487. return this === activeService
  14488. },
  14489. throwIfInactive: function throwIfInactive() {
  14490. if (!this.active) {
  14491. throw new Error('This print request was cancelled or completed.');
  14492. }
  14493. }
  14494. };
  14495. var print = window.print;
  14496. window.print = function print() {
  14497. if (activeService) {
  14498. console.warn('Ignored window.print() because of a pending print job.');
  14499. return
  14500. }
  14501. ensureOverlay().then(function() {
  14502. if (activeService) {
  14503. overlayManager.open('printServiceOverlay')
  14504. }
  14505. });
  14506. try {
  14507. dispatchEvent('beforeprint')
  14508. } finally {
  14509. if (!activeService) {
  14510. console.error('Expected print service to be initialized.');
  14511. ensureOverlay().then(function() {
  14512. if (overlayManager.active === 'printServiceOverlay') {
  14513. overlayManager.close('printServiceOverlay')
  14514. }
  14515. });
  14516. return
  14517. }
  14518. var activeServiceOnEntry = activeService;
  14519. activeService.renderPages().then(function() {
  14520. return activeServiceOnEntry.performPrint()
  14521. }).
  14522. catch(function() {}).then(function() {
  14523. if (activeServiceOnEntry.active) {
  14524. abort()
  14525. }
  14526. })
  14527. }
  14528. };
  14529. function dispatchEvent(eventType) {
  14530. var event = document.createEvent('CustomEvent');
  14531. event.initCustomEvent(eventType, false, false, 'custom');
  14532. window.dispatchEvent(event)
  14533. }
  14534. function abort() {
  14535. if (activeService) {
  14536. activeService.destroy();
  14537. dispatchEvent('afterprint')
  14538. }
  14539. }
  14540. function renderProgress(index, total, l10n) {
  14541. var progressContainer = document.getElementById('printServiceOverlay');
  14542. var progress = Math.round(100 * index / total);
  14543. var progressBar = progressContainer.querySelector('progress');
  14544. var progressPerc = progressContainer.querySelector('.relative-progress');
  14545. progressBar.value = progress;
  14546. l10n.get('print_progress_percent', {
  14547. progress: progress
  14548. },
  14549. progress + '%').then(function(msg) {
  14550. progressPerc.textContent = msg
  14551. })
  14552. }
  14553. var hasAttachEvent = !!document.attachEvent;
  14554. window.addEventListener('keydown',
  14555. function(event) {
  14556. if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
  14557. window.print();
  14558. if (hasAttachEvent) {
  14559. return
  14560. }
  14561. event.preventDefault();
  14562. if (event.stopImmediatePropagation) {
  14563. event.stopImmediatePropagation()
  14564. } else {
  14565. event.stopPropagation()
  14566. }
  14567. return
  14568. }
  14569. },
  14570. true);
  14571. if (hasAttachEvent) {
  14572. document.attachEvent('onkeydown',
  14573. function(event) {
  14574. event = event || window.event;
  14575. if (event.keyCode === 80 && event.ctrlKey) {
  14576. event.keyCode = 0;
  14577. return false
  14578. }
  14579. })
  14580. }
  14581. if ('onbeforeprint' in window) {
  14582. var stopPropagationIfNeeded = function stopPropagationIfNeeded(event) {
  14583. if (event.detail !== 'custom' && event.stopImmediatePropagation) {
  14584. event.stopImmediatePropagation()
  14585. }
  14586. };
  14587. window.addEventListener('beforeprint', stopPropagationIfNeeded);
  14588. window.addEventListener('afterprint', stopPropagationIfNeeded)
  14589. }
  14590. var overlayPromise;
  14591. function ensureOverlay() {
  14592. if (!overlayPromise) {
  14593. overlayManager = _app.PDFViewerApplication.overlayManager;
  14594. if (!overlayManager) {
  14595. throw new Error('The overlay manager has not yet been initialized.');
  14596. }
  14597. overlayPromise = overlayManager.register('printServiceOverlay', document.getElementById('printServiceOverlay'), abort, true);
  14598. document.getElementById('printCancel').onclick = abort
  14599. }
  14600. return overlayPromise
  14601. }
  14602. _app.PDFPrintServiceFactory.instance = {
  14603. supportsPrinting: true,
  14604. createPrintService: function createPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
  14605. if (activeService) {
  14606. throw new Error('The print service is created and active.');
  14607. }
  14608. activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n);
  14609. return activeService
  14610. }
  14611. };
  14612. exports.PDFPrintService = PDFPrintService
  14613. }), (function(module, exports, __webpack_require__) {
  14614. "use strict";
  14615. document.webL10n = function(window, document, undefined) {
  14616. var gL10nData = {};
  14617. var gTextData = '';
  14618. var gTextProp = 'textContent';
  14619. var gLanguage = '';
  14620. var gMacros = {};
  14621. var gReadyState = 'loading';
  14622. var gAsyncResourceLoading = true;
  14623. function getL10nResourceLinks() {
  14624. return document.querySelectorAll('link[type="application/l10n"]')
  14625. }
  14626. function getL10nDictionary() {
  14627. var script = document.querySelector('script[type="application/l10n"]');
  14628. return script ? JSON.parse(script.innerHTML) : null
  14629. }
  14630. function getTranslatableChildren(element) {
  14631. return element ? element.querySelectorAll('*[data-l10n-id]') : []
  14632. }
  14633. function getL10nAttributes(element) {
  14634. if (!element) return {};
  14635. var l10nId = element.getAttribute('data-l10n-id');
  14636. var l10nArgs = element.getAttribute('data-l10n-args');
  14637. var args = {};
  14638. if (l10nArgs) {
  14639. try {
  14640. args = JSON.parse(l10nArgs)
  14641. } catch(e) {
  14642. console.warn('could not parse arguments for #' + l10nId)
  14643. }
  14644. }
  14645. return {
  14646. id: l10nId,
  14647. args: args
  14648. }
  14649. }
  14650. function fireL10nReadyEvent(lang) {
  14651. var evtObject = document.createEvent('Event');
  14652. evtObject.initEvent('localized', true, false);
  14653. evtObject.language = lang;
  14654. document.dispatchEvent(evtObject)
  14655. }
  14656. function xhrLoadText(url, onSuccess, onFailure) {
  14657. onSuccess = onSuccess ||
  14658. function _onSuccess(data) {};
  14659. onFailure = onFailure ||
  14660. function _onFailure() {};
  14661. var xhr = new XMLHttpRequest();
  14662. xhr.open('GET', url, gAsyncResourceLoading);
  14663. if (xhr.overrideMimeType) {
  14664. xhr.overrideMimeType('text/plain; charset=utf-8')
  14665. }
  14666. xhr.onreadystatechange = function() {
  14667. if (xhr.readyState == 4) {
  14668. if (xhr.status == 200 || xhr.status === 0) {
  14669. onSuccess(xhr.responseText)
  14670. } else {
  14671. onFailure()
  14672. }
  14673. }
  14674. };
  14675. xhr.onerror = onFailure;
  14676. xhr.ontimeout = onFailure;
  14677. try {
  14678. xhr.send(null)
  14679. } catch(e) {
  14680. onFailure()
  14681. }
  14682. }
  14683. function parseResource(href, lang, successCallback, failureCallback) {
  14684. var baseURL = href.replace(/[^\/]*$/, '') || './';
  14685. function evalString(text) {
  14686. if (text.lastIndexOf('\\') < 0) return text;
  14687. return text.replace(/\\\\/g, '\\').replace(/\\n/g, '\n').replace(/\\r/g, '\r').replace(/\\t/g, '\t').replace(/\\b/g, '\b').replace(/\\f/g, '\f').replace(/\\{/g, '{').replace(/\\}/g, '}').replace(/\\"/g, '"').replace(/\\'/g, "'")
  14688. }
  14689. function parseProperties(text, parsedPropertiesCallback) {
  14690. var dictionary = {};
  14691. var reBlank = /^\s*|\s*$/;
  14692. var reComment = /^\s*#|^\s*$/;
  14693. var reSection = /^\s*\[(.*)\]\s*$/;
  14694. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  14695. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  14696. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  14697. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  14698. var currentLang = '*';
  14699. var genericLang = lang.split('-', 1)[0];
  14700. var skipLang = false;
  14701. var match = '';
  14702. function nextEntry() {
  14703. while (true) {
  14704. if (!entries.length) {
  14705. parsedRawLinesCallback();
  14706. return
  14707. }
  14708. var line = entries.shift();
  14709. if (reComment.test(line)) continue;
  14710. if (extendedSyntax) {
  14711. match = reSection.exec(line);
  14712. if (match) {
  14713. currentLang = match[1].toLowerCase();
  14714. skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
  14715. continue
  14716. } else if (skipLang) {
  14717. continue
  14718. }
  14719. match = reImport.exec(line);
  14720. if (match) {
  14721. loadImport(baseURL + match[1], nextEntry);
  14722. return
  14723. }
  14724. }
  14725. var tmp = line.match(reSplit);
  14726. if (tmp && tmp.length == 3) {
  14727. dictionary[tmp[1]] = evalString(tmp[2])
  14728. }
  14729. }
  14730. }
  14731. nextEntry()
  14732. }
  14733. function loadImport(url, callback) {
  14734. xhrLoadText(url,
  14735. function(content) {
  14736. parseRawLines(content, false, callback)
  14737. },
  14738. function() {
  14739. console.warn(url + ' not found.');
  14740. callback()
  14741. })
  14742. }
  14743. parseRawLines(text, true,
  14744. function() {
  14745. parsedPropertiesCallback(dictionary)
  14746. })
  14747. }
  14748. xhrLoadText(href,
  14749. function(response) {
  14750. gTextData += response;
  14751. parseProperties(response,
  14752. function(data) {
  14753. for (var key in data) {
  14754. var id, prop, index = key.lastIndexOf('.');
  14755. if (index > 0) {
  14756. id = key.substring(0, index);
  14757. prop = key.substr(index + 1)
  14758. } else {
  14759. id = key;
  14760. prop = gTextProp
  14761. }
  14762. if (!gL10nData[id]) {
  14763. gL10nData[id] = {}
  14764. }
  14765. gL10nData[id][prop] = data[key]
  14766. }
  14767. if (successCallback) {
  14768. successCallback()
  14769. }
  14770. })
  14771. },
  14772. failureCallback)
  14773. }
  14774. function loadLocale(lang, callback) {
  14775. if (lang) {
  14776. lang = lang.toLowerCase()
  14777. }
  14778. callback = callback ||
  14779. function _callback() {};
  14780. clear();
  14781. gLanguage = lang;
  14782. var langLinks = getL10nResourceLinks();
  14783. var langCount = langLinks.length;
  14784. if (langCount === 0) {
  14785. var dict = getL10nDictionary();
  14786. if (dict && dict.locales && dict.default_locale) {
  14787. console.log('using the embedded JSON directory, early way out');
  14788. gL10nData = dict.locales[lang];
  14789. if (!gL10nData) {
  14790. var defaultLocale = dict.default_locale.toLowerCase();
  14791. for (var anyCaseLang in dict.locales) {
  14792. anyCaseLang = anyCaseLang.toLowerCase();
  14793. if (anyCaseLang === lang) {
  14794. gL10nData = dict.locales[lang];
  14795. break
  14796. } else if (anyCaseLang === defaultLocale) {
  14797. gL10nData = dict.locales[defaultLocale]
  14798. }
  14799. }
  14800. }
  14801. callback()
  14802. } else {
  14803. console.log('no resource to load, early way out')
  14804. }
  14805. fireL10nReadyEvent(lang);
  14806. gReadyState = 'complete';
  14807. return
  14808. }
  14809. var onResourceLoaded = null;
  14810. var gResourceCount = 0;
  14811. onResourceLoaded = function onResourceLoaded() {
  14812. gResourceCount++;
  14813. if (gResourceCount >= langCount) {
  14814. callback();
  14815. fireL10nReadyEvent(lang);
  14816. gReadyState = 'complete'
  14817. }
  14818. };
  14819. function L10nResourceLink(link) {
  14820. var href = link.href;
  14821. this.load = function(lang, callback) {
  14822. parseResource(href, lang, callback,
  14823. function() {
  14824. console.warn(href + ' not found.');
  14825. console.warn('"' + lang + '" resource not found');
  14826. gLanguage = '';
  14827. callback()
  14828. })
  14829. }
  14830. }
  14831. for (var i = 0; i < langCount; i++) {
  14832. var resource = new L10nResourceLink(langLinks[i]);
  14833. resource.load(lang, onResourceLoaded)
  14834. }
  14835. }
  14836. function clear() {
  14837. gL10nData = {};
  14838. gTextData = '';
  14839. gLanguage = ''
  14840. }
  14841. function getPluralRules(lang) {
  14842. var locales2rules = {
  14843. 'af': 3,
  14844. 'ak': 4,
  14845. 'am': 4,
  14846. 'ar': 1,
  14847. 'asa': 3,
  14848. 'az': 0,
  14849. 'be': 11,
  14850. 'bem': 3,
  14851. 'bez': 3,
  14852. 'bg': 3,
  14853. 'bh': 4,
  14854. 'bm': 0,
  14855. 'bn': 3,
  14856. 'bo': 0,
  14857. 'br': 20,
  14858. 'brx': 3,
  14859. 'bs': 11,
  14860. 'ca': 3,
  14861. 'cgg': 3,
  14862. 'chr': 3,
  14863. 'cs': 12,
  14864. 'cy': 17,
  14865. 'da': 3,
  14866. 'de': 3,
  14867. 'dv': 3,
  14868. 'dz': 0,
  14869. 'ee': 3,
  14870. 'el': 3,
  14871. 'en': 3,
  14872. 'eo': 3,
  14873. 'es': 3,
  14874. 'et': 3,
  14875. 'eu': 3,
  14876. 'fa': 0,
  14877. 'ff': 5,
  14878. 'fi': 3,
  14879. 'fil': 4,
  14880. 'fo': 3,
  14881. 'fr': 5,
  14882. 'fur': 3,
  14883. 'fy': 3,
  14884. 'ga': 8,
  14885. 'gd': 24,
  14886. 'gl': 3,
  14887. 'gsw': 3,
  14888. 'gu': 3,
  14889. 'guw': 4,
  14890. 'gv': 23,
  14891. 'ha': 3,
  14892. 'haw': 3,
  14893. 'he': 2,
  14894. 'hi': 4,
  14895. 'hr': 11,
  14896. 'hu': 0,
  14897. 'id': 0,
  14898. 'ig': 0,
  14899. 'ii': 0,
  14900. 'is': 3,
  14901. 'it': 3,
  14902. 'iu': 7,
  14903. 'ja': 0,
  14904. 'jmc': 3,
  14905. 'jv': 0,
  14906. 'ka': 0,
  14907. 'kab': 5,
  14908. 'kaj': 3,
  14909. 'kcg': 3,
  14910. 'kde': 0,
  14911. 'kea': 0,
  14912. 'kk': 3,
  14913. 'kl': 3,
  14914. 'km': 0,
  14915. 'kn': 0,
  14916. 'ko': 0,
  14917. 'ksb': 3,
  14918. 'ksh': 21,
  14919. 'ku': 3,
  14920. 'kw': 7,
  14921. 'lag': 18,
  14922. 'lb': 3,
  14923. 'lg': 3,
  14924. 'ln': 4,
  14925. 'lo': 0,
  14926. 'lt': 10,
  14927. 'lv': 6,
  14928. 'mas': 3,
  14929. 'mg': 4,
  14930. 'mk': 16,
  14931. 'ml': 3,
  14932. 'mn': 3,
  14933. 'mo': 9,
  14934. 'mr': 3,
  14935. 'ms': 0,
  14936. 'mt': 15,
  14937. 'my': 0,
  14938. 'nah': 3,
  14939. 'naq': 7,
  14940. 'nb': 3,
  14941. 'nd': 3,
  14942. 'ne': 3,
  14943. 'nl': 3,
  14944. 'nn': 3,
  14945. 'no': 3,
  14946. 'nr': 3,
  14947. 'nso': 4,
  14948. 'ny': 3,
  14949. 'nyn': 3,
  14950. 'om': 3,
  14951. 'or': 3,
  14952. 'pa': 3,
  14953. 'pap': 3,
  14954. 'pl': 13,
  14955. 'ps': 3,
  14956. 'pt': 3,
  14957. 'rm': 3,
  14958. 'ro': 9,
  14959. 'rof': 3,
  14960. 'ru': 11,
  14961. 'rwk': 3,
  14962. 'sah': 0,
  14963. 'saq': 3,
  14964. 'se': 7,
  14965. 'seh': 3,
  14966. 'ses': 0,
  14967. 'sg': 0,
  14968. 'sh': 11,
  14969. 'shi': 19,
  14970. 'sk': 12,
  14971. 'sl': 14,
  14972. 'sma': 7,
  14973. 'smi': 7,
  14974. 'smj': 7,
  14975. 'smn': 7,
  14976. 'sms': 7,
  14977. 'sn': 3,
  14978. 'so': 3,
  14979. 'sq': 3,
  14980. 'sr': 11,
  14981. 'ss': 3,
  14982. 'ssy': 3,
  14983. 'st': 3,
  14984. 'sv': 3,
  14985. 'sw': 3,
  14986. 'syr': 3,
  14987. 'ta': 3,
  14988. 'te': 3,
  14989. 'teo': 3,
  14990. 'th': 0,
  14991. 'ti': 4,
  14992. 'tig': 3,
  14993. 'tk': 3,
  14994. 'tl': 4,
  14995. 'tn': 3,
  14996. 'to': 0,
  14997. 'tr': 0,
  14998. 'ts': 3,
  14999. 'tzm': 22,
  15000. 'uk': 11,
  15001. 'ur': 3,
  15002. 've': 3,
  15003. 'vi': 0,
  15004. 'vun': 3,
  15005. 'wa': 4,
  15006. 'wae': 3,
  15007. 'wo': 0,
  15008. 'xh': 3,
  15009. 'xog': 3,
  15010. 'yo': 0,
  15011. 'zh': 0,
  15012. 'zu': 3
  15013. };
  15014. function isIn(n, list) {
  15015. return list.indexOf(n) !== -1
  15016. }
  15017. function isBetween(n, start, end) {
  15018. return start <= n && n <= end
  15019. }
  15020. var pluralRules = {
  15021. '0': function _(n) {
  15022. return 'other'
  15023. },
  15024. '1': function _(n) {
  15025. if (isBetween(n % 100, 3, 10)) return 'few';
  15026. if (n === 0) return 'zero';
  15027. if (isBetween(n % 100, 11, 99)) return 'many';
  15028. if (n == 2) return 'two';
  15029. if (n == 1) return 'one';
  15030. return 'other'
  15031. },
  15032. '2': function _(n) {
  15033. if (n !== 0 && n % 10 === 0) return 'many';
  15034. if (n == 2) return 'two';
  15035. if (n == 1) return 'one';
  15036. return 'other'
  15037. },
  15038. '3': function _(n) {
  15039. if (n == 1) return 'one';
  15040. return 'other'
  15041. },
  15042. '4': function _(n) {
  15043. if (isBetween(n, 0, 1)) return 'one';
  15044. return 'other'
  15045. },
  15046. '5': function _(n) {
  15047. if (isBetween(n, 0, 2) && n != 2) return 'one';
  15048. return 'other'
  15049. },
  15050. '6': function _(n) {
  15051. if (n === 0) return 'zero';
  15052. if (n % 10 == 1 && n % 100 != 11) return 'one';
  15053. return 'other'
  15054. },
  15055. '7': function _(n) {
  15056. if (n == 2) return 'two';
  15057. if (n == 1) return 'one';
  15058. return 'other'
  15059. },
  15060. '8': function _(n) {
  15061. if (isBetween(n, 3, 6)) return 'few';
  15062. if (isBetween(n, 7, 10)) return 'many';
  15063. if (n == 2) return 'two';
  15064. if (n == 1) return 'one';
  15065. return 'other'
  15066. },
  15067. '9': function _(n) {
  15068. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  15069. if (n == 1) return 'one';
  15070. return 'other'
  15071. },
  15072. '10': function _(n) {
  15073. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  15074. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  15075. return 'other'
  15076. },
  15077. '11': function _(n) {
  15078. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  15079. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
  15080. if (n % 10 == 1 && n % 100 != 11) return 'one';
  15081. return 'other'
  15082. },
  15083. '12': function _(n) {
  15084. if (isBetween(n, 2, 4)) return 'few';
  15085. if (n == 1) return 'one';
  15086. return 'other'
  15087. },
  15088. '13': function _(n) {
  15089. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  15090. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
  15091. if (n == 1) return 'one';
  15092. return 'other'
  15093. },
  15094. '14': function _(n) {
  15095. if (isBetween(n % 100, 3, 4)) return 'few';
  15096. if (n % 100 == 2) return 'two';
  15097. if (n % 100 == 1) return 'one';
  15098. return 'other'
  15099. },
  15100. '15': function _(n) {
  15101. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  15102. if (isBetween(n % 100, 11, 19)) return 'many';
  15103. if (n == 1) return 'one';
  15104. return 'other'
  15105. },
  15106. '16': function _(n) {
  15107. if (n % 10 == 1 && n != 11) return 'one';
  15108. return 'other'
  15109. },
  15110. '17': function _(n) {
  15111. if (n == 3) return 'few';
  15112. if (n === 0) return 'zero';
  15113. if (n == 6) return 'many';
  15114. if (n == 2) return 'two';
  15115. if (n == 1) return 'one';
  15116. return 'other'
  15117. },
  15118. '18': function _(n) {
  15119. if (n === 0) return 'zero';
  15120. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  15121. return 'other'
  15122. },
  15123. '19': function _(n) {
  15124. if (isBetween(n, 2, 10)) return 'few';
  15125. if (isBetween(n, 0, 1)) return 'one';
  15126. return 'other'
  15127. },
  15128. '20': function _(n) {
  15129. if ((isBetween(n % 10, 3, 4) || n % 10 == 9) && !(isBetween(n % 100, 10, 19) || isBetween(n % 100, 70, 79) || isBetween(n % 100, 90, 99))) return 'few';
  15130. if (n % 1000000 === 0 && n !== 0) return 'many';
  15131. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  15132. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  15133. return 'other'
  15134. },
  15135. '21': function _(n) {
  15136. if (n === 0) return 'zero';
  15137. if (n == 1) return 'one';
  15138. return 'other'
  15139. },
  15140. '22': function _(n) {
  15141. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  15142. return 'other'
  15143. },
  15144. '23': function _(n) {
  15145. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  15146. return 'other'
  15147. },
  15148. '24': function _(n) {
  15149. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  15150. if (isIn(n, [2, 12])) return 'two';
  15151. if (isIn(n, [1, 11])) return 'one';
  15152. return 'other'
  15153. }
  15154. };
  15155. var index = locales2rules[lang.replace(/-.*$/, '')];
  15156. if (! (index in pluralRules)) {
  15157. console.warn('plural form unknown for [' + lang + ']');
  15158. return function() {
  15159. return 'other'
  15160. }
  15161. }
  15162. return pluralRules[index]
  15163. }
  15164. gMacros.plural = function(str, param, key, prop) {
  15165. var n = parseFloat(param);
  15166. if (isNaN(n)) return str;
  15167. if (prop != gTextProp) return str;
  15168. if (!gMacros._pluralRules) {
  15169. gMacros._pluralRules = getPluralRules(gLanguage)
  15170. }
  15171. var index = '[' + gMacros._pluralRules(n) + ']';
  15172. if (n === 0 && key + '[zero]' in gL10nData) {
  15173. str = gL10nData[key + '[zero]'][prop]
  15174. } else if (n == 1 && key + '[one]' in gL10nData) {
  15175. str = gL10nData[key + '[one]'][prop]
  15176. } else if (n == 2 && key + '[two]' in gL10nData) {
  15177. str = gL10nData[key + '[two]'][prop]
  15178. } else if (key + index in gL10nData) {
  15179. str = gL10nData[key + index][prop]
  15180. } else if (key + '[other]' in gL10nData) {
  15181. str = gL10nData[key + '[other]'][prop]
  15182. }
  15183. return str
  15184. };
  15185. function getL10nData(key, args, fallback) {
  15186. var data = gL10nData[key];
  15187. if (!data) {
  15188. console.warn('#' + key + ' is undefined.');
  15189. if (!fallback) {
  15190. return null
  15191. }
  15192. data = fallback
  15193. }
  15194. var rv = {};
  15195. for (var prop in data) {
  15196. var str = data[prop];
  15197. str = substIndexes(str, args, key, prop);
  15198. str = substArguments(str, args, key);
  15199. rv[prop] = str
  15200. }
  15201. return rv
  15202. }
  15203. function substIndexes(str, args, key, prop) {
  15204. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  15205. var reMatch = reIndex.exec(str);
  15206. if (!reMatch || !reMatch.length) return str;
  15207. var macroName = reMatch[1];
  15208. var paramName = reMatch[2];
  15209. var param;
  15210. if (args && paramName in args) {
  15211. param = args[paramName]
  15212. } else if (paramName in gL10nData) {
  15213. param = gL10nData[paramName]
  15214. }
  15215. if (macroName in gMacros) {
  15216. var macro = gMacros[macroName];
  15217. str = macro(str, param, key, prop)
  15218. }
  15219. return str
  15220. }
  15221. function substArguments(str, args, key) {
  15222. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  15223. return str.replace(reArgs,
  15224. function(matched_text, arg) {
  15225. if (args && arg in args) {
  15226. return args[arg]
  15227. }
  15228. if (arg in gL10nData) {
  15229. return gL10nData[arg]
  15230. }
  15231. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  15232. return matched_text
  15233. })
  15234. }
  15235. function translateElement(element) {
  15236. var l10n = getL10nAttributes(element);
  15237. if (!l10n.id) return;
  15238. var data = getL10nData(l10n.id, l10n.args);
  15239. if (!data) {
  15240. console.warn('#' + l10n.id + ' is undefined.');
  15241. return
  15242. }
  15243. if (data[gTextProp]) {
  15244. if (getChildElementCount(element) === 0) {
  15245. element[gTextProp] = data[gTextProp]
  15246. } else {
  15247. var children = element.childNodes;
  15248. var found = false;
  15249. for (var i = 0,
  15250. l = children.length; i < l; i++) {
  15251. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  15252. if (found) {
  15253. children[i].nodeValue = ''
  15254. } else {
  15255. children[i].nodeValue = data[gTextProp];
  15256. found = true
  15257. }
  15258. }
  15259. }
  15260. if (!found) {
  15261. var textNode = document.createTextNode(data[gTextProp]);
  15262. element.insertBefore(textNode, element.firstChild)
  15263. }
  15264. }
  15265. delete data[gTextProp]
  15266. }
  15267. for (var k in data) {
  15268. element[k] = data[k]
  15269. }
  15270. }
  15271. function getChildElementCount(element) {
  15272. if (element.children) {
  15273. return element.children.length
  15274. }
  15275. if (typeof element.childElementCount !== 'undefined') {
  15276. return element.childElementCount
  15277. }
  15278. var count = 0;
  15279. for (var i = 0; i < element.childNodes.length; i++) {
  15280. count += element.nodeType === 1 ? 1 : 0
  15281. }
  15282. return count
  15283. }
  15284. function translateFragment(element) {
  15285. element = element || document.documentElement;
  15286. var children = getTranslatableChildren(element);
  15287. var elementCount = children.length;
  15288. for (var i = 0; i < elementCount; i++) {
  15289. translateElement(children[i])
  15290. }
  15291. translateElement(element)
  15292. }
  15293. return {
  15294. get: function get(key, args, fallbackString) {
  15295. var index = key.lastIndexOf('.');
  15296. var prop = gTextProp;
  15297. if (index > 0) {
  15298. prop = key.substr(index + 1);
  15299. key = key.substring(0, index)
  15300. }
  15301. var fallback;
  15302. if (fallbackString) {
  15303. fallback = {};
  15304. fallback[prop] = fallbackString
  15305. }
  15306. var data = getL10nData(key, args, fallback);
  15307. if (data && prop in data) {
  15308. return data[prop]
  15309. }
  15310. return '{{' + key + '}}'
  15311. },
  15312. getData: function getData() {
  15313. return gL10nData
  15314. },
  15315. getText: function getText() {
  15316. return gTextData
  15317. },
  15318. getLanguage: function getLanguage() {
  15319. return gLanguage
  15320. },
  15321. setLanguage: function setLanguage(lang, callback) {
  15322. loadLocale(lang,
  15323. function() {
  15324. if (callback) callback()
  15325. })
  15326. },
  15327. getDirection: function getDirection() {
  15328. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  15329. var shortCode = gLanguage.split('-', 1)[0];
  15330. return rtlList.indexOf(shortCode) >= 0 ? 'rtl': 'ltr'
  15331. },
  15332. translate: translateFragment,
  15333. getReadyState: function getReadyState() {
  15334. return gReadyState
  15335. },
  15336. ready: function ready(callback) {
  15337. if (!callback) {
  15338. return
  15339. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  15340. window.setTimeout(function() {
  15341. callback()
  15342. })
  15343. } else if (document.addEventListener) {
  15344. document.addEventListener('localized',
  15345. function once() {
  15346. document.removeEventListener('localized', once);
  15347. callback()
  15348. })
  15349. }
  15350. }
  15351. }
  15352. } (window, document)
  15353. }), (function(module, exports, __webpack_require__) {
  15354. "use strict";
  15355. Object.defineProperty(exports, "__esModule", {
  15356. value: true
  15357. });
  15358. exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = undefined;
  15359. var _createClass = function() {
  15360. function defineProperties(target, props) {
  15361. for (var i = 0; i < props.length; i++) {
  15362. var descriptor = props[i];
  15363. descriptor.enumerable = descriptor.enumerable || false;
  15364. descriptor.configurable = true;
  15365. if ("value" in descriptor) descriptor.writable = true;
  15366. Object.defineProperty(target, descriptor.key, descriptor)
  15367. }
  15368. }
  15369. return function(Constructor, protoProps, staticProps) {
  15370. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  15371. if (staticProps) defineProperties(Constructor, staticProps);
  15372. return Constructor
  15373. }
  15374. } ();
  15375. var _pdfjsLib = __webpack_require__(1);
  15376. var _ui_utils = __webpack_require__(0);
  15377. var _pdf_link_service = __webpack_require__(5);
  15378. function _classCallCheck(instance, Constructor) {
  15379. if (! (instance instanceof Constructor)) {
  15380. throw new TypeError("Cannot call a class as a function");
  15381. }
  15382. }
  15383. var AnnotationLayerBuilder = function() {
  15384. function AnnotationLayerBuilder(_ref) {
  15385. var pageDiv = _ref.pageDiv,
  15386. pdfPage = _ref.pdfPage,
  15387. linkService = _ref.linkService,
  15388. downloadManager = _ref.downloadManager,
  15389. _ref$renderInteractiv = _ref.renderInteractiveForms,
  15390. renderInteractiveForms = _ref$renderInteractiv === undefined ? false: _ref$renderInteractiv,
  15391. _ref$l10n = _ref.l10n,
  15392. l10n = _ref$l10n === undefined ? _ui_utils.NullL10n: _ref$l10n;
  15393. _classCallCheck(this, AnnotationLayerBuilder);
  15394. this.pageDiv = pageDiv;
  15395. this.pdfPage = pdfPage;
  15396. this.linkService = linkService;
  15397. this.downloadManager = downloadManager;
  15398. this.renderInteractiveForms = renderInteractiveForms;
  15399. this.l10n = l10n;
  15400. this.div = null
  15401. }
  15402. _createClass(AnnotationLayerBuilder, [{
  15403. key: 'render',
  15404. value: function render(viewport) {
  15405. var _this = this;
  15406. var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'display';
  15407. this.pdfPage.getAnnotations({
  15408. intent: intent
  15409. }).then(function(annotations) {
  15410. var parameters = {
  15411. viewport: viewport.clone({
  15412. dontFlip: true
  15413. }),
  15414. div: _this.div,
  15415. annotations: annotations,
  15416. page: _this.pdfPage,
  15417. renderInteractiveForms: _this.renderInteractiveForms,
  15418. linkService: _this.linkService,
  15419. downloadManager: _this.downloadManager
  15420. };
  15421. if (_this.div) {
  15422. _pdfjsLib.AnnotationLayer.update(parameters)
  15423. } else {
  15424. if (annotations.length === 0) {
  15425. return
  15426. }
  15427. _this.div = document.createElement('div');
  15428. _this.div.className = 'annotationLayer';
  15429. _this.pageDiv.appendChild(_this.div);
  15430. parameters.div = _this.div;
  15431. _pdfjsLib.AnnotationLayer.render(parameters);
  15432. _this.l10n.translate(_this.div)
  15433. }
  15434. })
  15435. }
  15436. },
  15437. {
  15438. key: 'hide',
  15439. value: function hide() {
  15440. if (!this.div) {
  15441. return
  15442. }
  15443. this.div.setAttribute('hidden', 'true')
  15444. }
  15445. }]);
  15446. return AnnotationLayerBuilder
  15447. } ();
  15448. var DefaultAnnotationLayerFactory = function() {
  15449. function DefaultAnnotationLayerFactory() {
  15450. _classCallCheck(this, DefaultAnnotationLayerFactory)
  15451. }
  15452. _createClass(DefaultAnnotationLayerFactory, [{
  15453. key: 'createAnnotationLayerBuilder',
  15454. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  15455. var renderInteractiveForms = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  15456. var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
  15457. return new AnnotationLayerBuilder({
  15458. pageDiv: pageDiv,
  15459. pdfPage: pdfPage,
  15460. renderInteractiveForms: renderInteractiveForms,
  15461. linkService: new _pdf_link_service.SimpleLinkService(),
  15462. l10n: l10n
  15463. })
  15464. }
  15465. }]);
  15466. return DefaultAnnotationLayerFactory
  15467. } ();
  15468. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  15469. exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory
  15470. }), (function(module, exports, __webpack_require__) {
  15471. "use strict";
  15472. Object.defineProperty(exports, "__esModule", {
  15473. value: true
  15474. });
  15475. exports.DownloadManager = undefined;
  15476. var _createClass = function() {
  15477. function defineProperties(target, props) {
  15478. for (var i = 0; i < props.length; i++) {
  15479. var descriptor = props[i];
  15480. descriptor.enumerable = descriptor.enumerable || false;
  15481. descriptor.configurable = true;
  15482. if ("value" in descriptor) descriptor.writable = true;
  15483. Object.defineProperty(target, descriptor.key, descriptor)
  15484. }
  15485. }
  15486. return function(Constructor, protoProps, staticProps) {
  15487. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  15488. if (staticProps) defineProperties(Constructor, staticProps);
  15489. return Constructor
  15490. }
  15491. } ();
  15492. var _pdfjsLib = __webpack_require__(1);
  15493. function _classCallCheck(instance, Constructor) {
  15494. if (! (instance instanceof Constructor)) {
  15495. throw new TypeError("Cannot call a class as a function");
  15496. }
  15497. };
  15498. function _download(blobUrl, filename) {
  15499. var a = document.createElement('a');
  15500. if (a.click) {
  15501. a.href = blobUrl;
  15502. a.target = '_parent';
  15503. if ('download' in a) {
  15504. a.download = filename
  15505. } (document.body || document.documentElement).appendChild(a);
  15506. a.click();
  15507. a.parentNode.removeChild(a)
  15508. } else {
  15509. if (window.top === window && blobUrl.split('#')[0] === window.location.href.split('#')[0]) {
  15510. var padCharacter = blobUrl.indexOf('?') === -1 ? '?': '&';
  15511. blobUrl = blobUrl.replace(/#|$/, padCharacter + '$&')
  15512. }
  15513. window.open(blobUrl, '_parent')
  15514. }
  15515. }
  15516. var DownloadManager = function() {
  15517. function DownloadManager() {
  15518. _classCallCheck(this, DownloadManager)
  15519. }
  15520. _createClass(DownloadManager, [{
  15521. key: 'downloadUrl',
  15522. value: function downloadUrl(url, filename) {
  15523. if (! (0, _pdfjsLib.createValidAbsoluteUrl)(url, 'http://example.com')) {
  15524. return
  15525. }
  15526. _download(url + '#pdfjs.action=download', filename)
  15527. }
  15528. },
  15529. {
  15530. key: 'downloadData',
  15531. value: function downloadData(data, filename, contentType) {
  15532. if (navigator.msSaveBlob) {
  15533. return navigator.msSaveBlob(new Blob([data], {
  15534. type: contentType
  15535. }), filename)
  15536. }
  15537. var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, _pdfjsLib.PDFJS.disableCreateObjectURL);
  15538. _download(blobUrl, filename)
  15539. }
  15540. },
  15541. {
  15542. key: 'download',
  15543. value: function download(blob, url, filename) {
  15544. if (navigator.msSaveBlob) {
  15545. if (!navigator.msSaveBlob(blob, filename)) {
  15546. this.downloadUrl(url, filename)
  15547. }
  15548. return
  15549. }
  15550. if (_pdfjsLib.PDFJS.disableCreateObjectURL) {
  15551. this.downloadUrl(url, filename);
  15552. return
  15553. }
  15554. var blobUrl = URL.createObjectURL(blob);
  15555. _download(blobUrl, filename)
  15556. }
  15557. }]);
  15558. return DownloadManager
  15559. } ();
  15560. exports.DownloadManager = DownloadManager
  15561. }), (function(module, exports, __webpack_require__) {
  15562. "use strict";
  15563. Object.defineProperty(exports, "__esModule", {
  15564. value: true
  15565. });
  15566. exports.GenericL10n = undefined;
  15567. var _createClass = function() {
  15568. function defineProperties(target, props) {
  15569. for (var i = 0; i < props.length; i++) {
  15570. var descriptor = props[i];
  15571. descriptor.enumerable = descriptor.enumerable || false;
  15572. descriptor.configurable = true;
  15573. if ("value" in descriptor) descriptor.writable = true;
  15574. Object.defineProperty(target, descriptor.key, descriptor)
  15575. }
  15576. }
  15577. return function(Constructor, protoProps, staticProps) {
  15578. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  15579. if (staticProps) defineProperties(Constructor, staticProps);
  15580. return Constructor
  15581. }
  15582. } ();
  15583. __webpack_require__(10);
  15584. function _classCallCheck(instance, Constructor) {
  15585. if (! (instance instanceof Constructor)) {
  15586. throw new TypeError("Cannot call a class as a function");
  15587. }
  15588. }
  15589. var webL10n = document.webL10n;
  15590. var GenericL10n = function() {
  15591. function GenericL10n(lang) {
  15592. _classCallCheck(this, GenericL10n);
  15593. this._lang = lang;
  15594. this._ready = new Promise(function(resolve, reject) {
  15595. webL10n.setLanguage(lang,
  15596. function() {
  15597. resolve(webL10n)
  15598. })
  15599. })
  15600. }
  15601. _createClass(GenericL10n, [{
  15602. key: 'getDirection',
  15603. value: function getDirection() {
  15604. return this._ready.then(function(l10n) {
  15605. return l10n.getDirection()
  15606. })
  15607. }
  15608. },
  15609. {
  15610. key: 'get',
  15611. value: function get(property, args, fallback) {
  15612. return this._ready.then(function(l10n) {
  15613. return l10n.get(property, args, fallback)
  15614. })
  15615. }
  15616. },
  15617. {
  15618. key: 'translate',
  15619. value: function translate(element) {
  15620. return this._ready.then(function(l10n) {
  15621. return l10n.translate(element)
  15622. })
  15623. }
  15624. }]);
  15625. return GenericL10n
  15626. } ();
  15627. exports.GenericL10n = GenericL10n
  15628. }), (function(module, exports, __webpack_require__) {
  15629. "use strict";
  15630. Object.defineProperty(exports, "__esModule", {
  15631. value: true
  15632. });
  15633. function GrabToPan(options) {
  15634. this.element = options.element;
  15635. this.document = options.element.ownerDocument;
  15636. if (typeof options.ignoreTarget === 'function') {
  15637. this.ignoreTarget = options.ignoreTarget
  15638. }
  15639. this.onActiveChanged = options.onActiveChanged;
  15640. this.activate = this.activate.bind(this);
  15641. this.deactivate = this.deactivate.bind(this);
  15642. this.toggle = this.toggle.bind(this);
  15643. this._onmousedown = this._onmousedown.bind(this);
  15644. this._onmousemove = this._onmousemove.bind(this);
  15645. this._endPan = this._endPan.bind(this);
  15646. var overlay = this.overlay = document.createElement('div');
  15647. overlay.className = 'grab-to-pan-grabbing'
  15648. }
  15649. GrabToPan.prototype = {
  15650. CSS_CLASS_GRAB: 'grab-to-pan-grab',
  15651. activate: function GrabToPan_activate() {
  15652. if (!this.active) {
  15653. this.active = true;
  15654. this.element.addEventListener('mousedown', this._onmousedown, true);
  15655. this.element.classList.add(this.CSS_CLASS_GRAB);
  15656. if (this.onActiveChanged) {
  15657. this.onActiveChanged(true)
  15658. }
  15659. }
  15660. },
  15661. deactivate: function GrabToPan_deactivate() {
  15662. if (this.active) {
  15663. this.active = false;
  15664. this.element.removeEventListener('mousedown', this._onmousedown, true);
  15665. this._endPan();
  15666. this.element.classList.remove(this.CSS_CLASS_GRAB);
  15667. if (this.onActiveChanged) {
  15668. this.onActiveChanged(false)
  15669. }
  15670. }
  15671. },
  15672. toggle: function GrabToPan_toggle() {
  15673. if (this.active) {
  15674. this.deactivate()
  15675. } else {
  15676. this.activate()
  15677. }
  15678. },
  15679. ignoreTarget: function GrabToPan_ignoreTarget(node) {
  15680. return node[matchesSelector]('a[href], a[href] *, input, textarea, button, button *, select, option')
  15681. },
  15682. _onmousedown: function GrabToPan__onmousedown(event) {
  15683. if (event.button !== 0 || this.ignoreTarget(event.target)) {
  15684. return
  15685. }
  15686. if (event.originalTarget) {
  15687. try {
  15688. event.originalTarget.tagName
  15689. } catch(e) {
  15690. return
  15691. }
  15692. }
  15693. this.scrollLeftStart = this.element.scrollLeft;
  15694. this.scrollTopStart = this.element.scrollTop;
  15695. this.clientXStart = event.clientX;
  15696. this.clientYStart = event.clientY;
  15697. this.document.addEventListener('mousemove', this._onmousemove, true);
  15698. this.document.addEventListener('mouseup', this._endPan, true);
  15699. this.element.addEventListener('scroll', this._endPan, true);
  15700. event.preventDefault();
  15701. event.stopPropagation();
  15702. var focusedElement = document.activeElement;
  15703. if (focusedElement && !focusedElement.contains(event.target)) {
  15704. focusedElement.blur()
  15705. }
  15706. },
  15707. _onmousemove: function GrabToPan__onmousemove(event) {
  15708. this.element.removeEventListener('scroll', this._endPan, true);
  15709. if (isLeftMouseReleased(event)) {
  15710. this._endPan();
  15711. return
  15712. }
  15713. var xDiff = event.clientX - this.clientXStart;
  15714. var yDiff = event.clientY - this.clientYStart;
  15715. var scrollTop = this.scrollTopStart - yDiff;
  15716. var scrollLeft = this.scrollLeftStart - xDiff;
  15717. if (this.element.scrollTo) {
  15718. this.element.scrollTo({
  15719. top: scrollTop,
  15720. left: scrollLeft,
  15721. behavior: 'instant'
  15722. })
  15723. } else {
  15724. this.element.scrollTop = scrollTop;
  15725. this.element.scrollLeft = scrollLeft
  15726. }
  15727. if (!this.overlay.parentNode) {
  15728. document.body.appendChild(this.overlay)
  15729. }
  15730. },
  15731. _endPan: function GrabToPan__endPan() {
  15732. this.element.removeEventListener('scroll', this._endPan, true);
  15733. this.document.removeEventListener('mousemove', this._onmousemove, true);
  15734. this.document.removeEventListener('mouseup', this._endPan, true);
  15735. this.overlay.remove()
  15736. }
  15737. };
  15738. var matchesSelector; ['webkitM', 'mozM', 'msM', 'oM', 'm'].some(function(prefix) {
  15739. var name = prefix + 'atches';
  15740. if (name in document.documentElement) {
  15741. matchesSelector = name
  15742. }
  15743. name += 'Selector';
  15744. if (name in document.documentElement) {
  15745. matchesSelector = name
  15746. }
  15747. return matchesSelector
  15748. });
  15749. var isNotIEorIsIE10plus = !document.documentMode || document.documentMode > 9;
  15750. var chrome = window.chrome;
  15751. var isChrome15OrOpera15plus = chrome && (chrome.webstore || chrome.app);
  15752. var isSafari6plus = /Apple/.test(navigator.vendor) && /Version\/([6-9]\d*|[1-5]\d+)/.test(navigator.userAgent);
  15753. function isLeftMouseReleased(event) {
  15754. if ('buttons' in event && isNotIEorIsIE10plus) {
  15755. return ! (event.buttons & 1)
  15756. }
  15757. if (isChrome15OrOpera15plus || isSafari6plus) {
  15758. return event.which === 0
  15759. }
  15760. }
  15761. exports.GrabToPan = GrabToPan
  15762. }), (function(module, exports, __webpack_require__) {
  15763. "use strict";
  15764. Object.defineProperty(exports, "__esModule", {
  15765. value: true
  15766. });
  15767. var _createClass = function() {
  15768. function defineProperties(target, props) {
  15769. for (var i = 0; i < props.length; i++) {
  15770. var descriptor = props[i];
  15771. descriptor.enumerable = descriptor.enumerable || false;
  15772. descriptor.configurable = true;
  15773. if ("value" in descriptor) descriptor.writable = true;
  15774. Object.defineProperty(target, descriptor.key, descriptor)
  15775. }
  15776. }
  15777. return function(Constructor, protoProps, staticProps) {
  15778. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  15779. if (staticProps) defineProperties(Constructor, staticProps);
  15780. return Constructor
  15781. }
  15782. } ();
  15783. function _classCallCheck(instance, Constructor) {
  15784. if (! (instance instanceof Constructor)) {
  15785. throw new TypeError("Cannot call a class as a function");
  15786. }
  15787. }
  15788. var OverlayManager = function() {
  15789. function OverlayManager() {
  15790. _classCallCheck(this, OverlayManager);
  15791. this._overlays = {};
  15792. this._active = null;
  15793. this._keyDownBound = this._keyDown.bind(this)
  15794. }
  15795. _createClass(OverlayManager, [{
  15796. key: 'register',
  15797. value: function register(name, element) {
  15798. var _this = this;
  15799. var callerCloseMethod = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  15800. var canForceClose = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  15801. return new Promise(function(resolve) {
  15802. var container = void 0;
  15803. if (!name || !element || !(container = element.parentNode)) {
  15804. throw new Error('Not enough parameters.');
  15805. } else if (_this._overlays[name]) {
  15806. throw new Error('The overlay is already registered.');
  15807. }
  15808. _this._overlays[name] = {
  15809. element: element,
  15810. container: container,
  15811. callerCloseMethod: callerCloseMethod,
  15812. canForceClose: canForceClose
  15813. };
  15814. resolve()
  15815. })
  15816. }
  15817. },
  15818. {
  15819. key: 'unregister',
  15820. value: function unregister(name) {
  15821. var _this2 = this;
  15822. return new Promise(function(resolve) {
  15823. if (!_this2._overlays[name]) {
  15824. throw new Error('The overlay does not exist.');
  15825. } else if (_this2._active === name) {
  15826. throw new Error('The overlay cannot be removed while it is active.');
  15827. }
  15828. delete _this2._overlays[name];
  15829. resolve()
  15830. })
  15831. }
  15832. },
  15833. {
  15834. key: 'open',
  15835. value: function open(name) {
  15836. var _this3 = this;
  15837. return new Promise(function(resolve) {
  15838. if (!_this3._overlays[name]) {
  15839. throw new Error('The overlay does not exist.');
  15840. } else if (_this3._active) {
  15841. if (_this3._overlays[name].canForceClose) {
  15842. _this3._closeThroughCaller()
  15843. } else if (_this3._active === name) {
  15844. throw new Error('The overlay is already active.');
  15845. } else {
  15846. throw new Error('Another overlay is currently active.');
  15847. }
  15848. }
  15849. _this3._active = name;
  15850. _this3._overlays[_this3._active].element.classList.remove('hidden');
  15851. _this3._overlays[_this3._active].container.classList.remove('hidden');
  15852. window.addEventListener('keydown', _this3._keyDownBound);
  15853. resolve()
  15854. })
  15855. }
  15856. },
  15857. {
  15858. key: 'close',
  15859. value: function close(name) {
  15860. var _this4 = this;
  15861. return new Promise(function(resolve) {
  15862. if (!_this4._overlays[name]) {
  15863. throw new Error('The overlay does not exist.');
  15864. } else if (!_this4._active) {
  15865. throw new Error('The overlay is currently not active.');
  15866. } else if (_this4._active !== name) {
  15867. throw new Error('Another overlay is currently active.');
  15868. }
  15869. _this4._overlays[_this4._active].container.classList.add('hidden');
  15870. _this4._overlays[_this4._active].element.classList.add('hidden');
  15871. _this4._active = null;
  15872. window.removeEventListener('keydown', _this4._keyDownBound);
  15873. resolve()
  15874. })
  15875. }
  15876. },
  15877. {
  15878. key: '_keyDown',
  15879. value: function _keyDown(evt) {
  15880. if (this._active && evt.keyCode === 27) {
  15881. this._closeThroughCaller();
  15882. evt.preventDefault()
  15883. }
  15884. }
  15885. },
  15886. {
  15887. key: '_closeThroughCaller',
  15888. value: function _closeThroughCaller() {
  15889. if (this._overlays[this._active].callerCloseMethod) {
  15890. this._overlays[this._active].callerCloseMethod()
  15891. }
  15892. if (this._active) {
  15893. this.close(this._active)
  15894. }
  15895. }
  15896. },
  15897. {
  15898. key: 'active',
  15899. get: function get() {
  15900. return this._active
  15901. }
  15902. }]);
  15903. return OverlayManager
  15904. } ();
  15905. exports.OverlayManager = OverlayManager
  15906. }), (function(module, exports, __webpack_require__) {
  15907. "use strict";
  15908. Object.defineProperty(exports, "__esModule", {
  15909. value: true
  15910. });
  15911. exports.PasswordPrompt = undefined;
  15912. var _createClass = function() {
  15913. function defineProperties(target, props) {
  15914. for (var i = 0; i < props.length; i++) {
  15915. var descriptor = props[i];
  15916. descriptor.enumerable = descriptor.enumerable || false;
  15917. descriptor.configurable = true;
  15918. if ("value" in descriptor) descriptor.writable = true;
  15919. Object.defineProperty(target, descriptor.key, descriptor)
  15920. }
  15921. }
  15922. return function(Constructor, protoProps, staticProps) {
  15923. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  15924. if (staticProps) defineProperties(Constructor, staticProps);
  15925. return Constructor
  15926. }
  15927. } ();
  15928. var _ui_utils = __webpack_require__(0);
  15929. var _pdfjsLib = __webpack_require__(1);
  15930. function _classCallCheck(instance, Constructor) {
  15931. if (! (instance instanceof Constructor)) {
  15932. throw new TypeError("Cannot call a class as a function");
  15933. }
  15934. }
  15935. var PasswordPrompt = function() {
  15936. function PasswordPrompt(options, overlayManager) {
  15937. var _this = this;
  15938. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  15939. _classCallCheck(this, PasswordPrompt);
  15940. this.overlayName = options.overlayName;
  15941. this.container = options.container;
  15942. this.label = options.label;
  15943. this.input = options.input;
  15944. this.submitButton = options.submitButton;
  15945. this.cancelButton = options.cancelButton;
  15946. this.overlayManager = overlayManager;
  15947. this.l10n = l10n;
  15948. this.updateCallback = null;
  15949. this.reason = null;
  15950. this.submitButton.addEventListener('click', this.verify.bind(this));
  15951. this.cancelButton.addEventListener('click', this.close.bind(this));
  15952. this.input.addEventListener('keydown',
  15953. function(e) {
  15954. if (e.keyCode === 13) {
  15955. _this.verify()
  15956. }
  15957. });
  15958. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this), true)
  15959. }
  15960. _createClass(PasswordPrompt, [{
  15961. key: 'open',
  15962. value: function open() {
  15963. var _this2 = this;
  15964. this.overlayManager.open(this.overlayName).then(function() {
  15965. _this2.input.focus();
  15966. var promptString = void 0;
  15967. if (_this2.reason === _pdfjsLib.PasswordResponses.INCORRECT_PASSWORD) {
  15968. promptString = _this2.l10n.get('password_invalid', null, 'Invalid password. Please try again.')
  15969. } else {
  15970. promptString = _this2.l10n.get('password_label', null, 'Enter the password to open this PDF file.')
  15971. }
  15972. promptString.then(function(msg) {
  15973. _this2.label.textContent = msg
  15974. })
  15975. })
  15976. }
  15977. },
  15978. {
  15979. key: 'close',
  15980. value: function close() {
  15981. var _this3 = this;
  15982. this.overlayManager.close(this.overlayName).then(function() {
  15983. _this3.input.value = ''
  15984. })
  15985. }
  15986. },
  15987. {
  15988. key: 'verify',
  15989. value: function verify() {
  15990. var password = this.input.value;
  15991. if (password && password.length > 0) {
  15992. this.close();
  15993. return this.updateCallback(password)
  15994. }
  15995. }
  15996. },
  15997. {
  15998. key: 'setUpdateCallback',
  15999. value: function setUpdateCallback(updateCallback, reason) {
  16000. this.updateCallback = updateCallback;
  16001. this.reason = reason
  16002. }
  16003. }]);
  16004. return PasswordPrompt
  16005. } ();
  16006. exports.PasswordPrompt = PasswordPrompt
  16007. }), (function(module, exports, __webpack_require__) {
  16008. "use strict";
  16009. Object.defineProperty(exports, "__esModule", {
  16010. value: true
  16011. });
  16012. exports.PDFAttachmentViewer = undefined;
  16013. var _createClass = function() {
  16014. function defineProperties(target, props) {
  16015. for (var i = 0; i < props.length; i++) {
  16016. var descriptor = props[i];
  16017. descriptor.enumerable = descriptor.enumerable || false;
  16018. descriptor.configurable = true;
  16019. if ("value" in descriptor) descriptor.writable = true;
  16020. Object.defineProperty(target, descriptor.key, descriptor)
  16021. }
  16022. }
  16023. return function(Constructor, protoProps, staticProps) {
  16024. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  16025. if (staticProps) defineProperties(Constructor, staticProps);
  16026. return Constructor
  16027. }
  16028. } ();
  16029. var _pdfjsLib = __webpack_require__(1);
  16030. function _classCallCheck(instance, Constructor) {
  16031. if (! (instance instanceof Constructor)) {
  16032. throw new TypeError("Cannot call a class as a function");
  16033. }
  16034. }
  16035. var PDFAttachmentViewer = function() {
  16036. function PDFAttachmentViewer(_ref) {
  16037. var container = _ref.container,
  16038. eventBus = _ref.eventBus,
  16039. downloadManager = _ref.downloadManager;
  16040. _classCallCheck(this, PDFAttachmentViewer);
  16041. this.attachments = null;
  16042. this.container = container;
  16043. this.eventBus = eventBus;
  16044. this.downloadManager = downloadManager;
  16045. this._renderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  16046. this.eventBus.on('fileattachmentannotation', this._appendAttachment.bind(this))
  16047. }
  16048. _createClass(PDFAttachmentViewer, [{
  16049. key: 'reset',
  16050. value: function reset() {
  16051. var keepRenderedCapability = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  16052. this.attachments = null;
  16053. this.container.textContent = '';
  16054. if (!keepRenderedCapability) {
  16055. this._renderedCapability = (0, _pdfjsLib.createPromiseCapability)()
  16056. }
  16057. }
  16058. },
  16059. {
  16060. key: '_dispatchEvent',
  16061. value: function _dispatchEvent(attachmentsCount) {
  16062. this.eventBus.dispatch('attachmentsloaded', {
  16063. source: this,
  16064. attachmentsCount: attachmentsCount
  16065. });
  16066. this._renderedCapability.resolve()
  16067. }
  16068. },
  16069. {
  16070. key: '_bindPdfLink',
  16071. value: function _bindPdfLink(button, content, filename) {
  16072. if (_pdfjsLib.PDFJS.disableCreateObjectURL) {
  16073. throw new Error('bindPdfLink: ' + 'Unsupported "PDFJS.disableCreateObjectURL" value.');
  16074. }
  16075. var blobUrl = void 0;
  16076. button.onclick = function() {
  16077. if (!blobUrl) {
  16078. blobUrl = (0, _pdfjsLib.createObjectURL)(content, 'application/pdf')
  16079. }
  16080. var viewerUrl = void 0;
  16081. viewerUrl = '?file=' + encodeURIComponent(blobUrl + '#' + filename);
  16082. window.open(viewerUrl);
  16083. return false
  16084. }
  16085. }
  16086. },
  16087. {
  16088. key: '_bindLink',
  16089. value: function _bindLink(button, content, filename) {
  16090. var _this = this;
  16091. button.onclick = function() {
  16092. _this.downloadManager.downloadData(content, filename, '');
  16093. return false
  16094. }
  16095. }
  16096. },
  16097. {
  16098. key: 'render',
  16099. value: function render(_ref2) {
  16100. var attachments = _ref2.attachments,
  16101. _ref2$keepRenderedCap = _ref2.keepRenderedCapability,
  16102. keepRenderedCapability = _ref2$keepRenderedCap === undefined ? false: _ref2$keepRenderedCap;
  16103. var attachmentsCount = 0;
  16104. if (this.attachments) {
  16105. this.reset(keepRenderedCapability === true)
  16106. }
  16107. this.attachments = attachments || null;
  16108. if (!attachments) {
  16109. this._dispatchEvent(attachmentsCount);
  16110. return
  16111. }
  16112. var names = Object.keys(attachments).sort(function(a, b) {
  16113. return a.toLowerCase().localeCompare(b.toLowerCase())
  16114. });
  16115. attachmentsCount = names.length;
  16116. for (var i = 0; i < attachmentsCount; i++) {
  16117. var item = attachments[names[i]];
  16118. var filename = (0, _pdfjsLib.removeNullCharacters)((0, _pdfjsLib.getFilenameFromUrl)(item.filename));
  16119. var div = document.createElement('div');
  16120. div.className = 'attachmentsItem';
  16121. var button = document.createElement('button');
  16122. button.textContent = filename;
  16123. if (/\.pdf$/i.test(filename) && !_pdfjsLib.PDFJS.disableCreateObjectURL) {
  16124. this._bindPdfLink(button, item.content, filename)
  16125. } else {
  16126. this._bindLink(button, item.content, filename)
  16127. }
  16128. div.appendChild(button);
  16129. this.container.appendChild(div)
  16130. }
  16131. this._dispatchEvent(attachmentsCount)
  16132. }
  16133. },
  16134. {
  16135. key: '_appendAttachment',
  16136. value: function _appendAttachment(_ref3) {
  16137. var _this2 = this;
  16138. var id = _ref3.id,
  16139. filename = _ref3.filename,
  16140. content = _ref3.content;
  16141. this._renderedCapability.promise.then(function() {
  16142. var attachments = _this2.attachments;
  16143. if (!attachments) {
  16144. attachments = Object.create(null)
  16145. } else {
  16146. for (var name in attachments) {
  16147. if (id === name) {
  16148. return
  16149. }
  16150. }
  16151. }
  16152. attachments[id] = {
  16153. filename: filename,
  16154. content: content
  16155. };
  16156. _this2.render({
  16157. attachments: attachments,
  16158. keepRenderedCapability: true
  16159. })
  16160. })
  16161. }
  16162. }]);
  16163. return PDFAttachmentViewer
  16164. } ();
  16165. exports.PDFAttachmentViewer = PDFAttachmentViewer
  16166. }), (function(module, exports, __webpack_require__) {
  16167. "use strict";
  16168. Object.defineProperty(exports, "__esModule", {
  16169. value: true
  16170. });
  16171. exports.PDFDocumentProperties = undefined;
  16172. var _slicedToArray = function() {
  16173. function sliceIterator(arr, i) {
  16174. var _arr = [];
  16175. var _n = true;
  16176. var _d = false;
  16177. var _e = undefined;
  16178. try {
  16179. for (var _i = arr[Symbol.iterator](), _s; ! (_n = (_s = _i.next()).done); _n = true) {
  16180. _arr.push(_s.value);
  16181. if (i && _arr.length === i) break
  16182. }
  16183. } catch(err) {
  16184. _d = true;
  16185. _e = err
  16186. } finally {
  16187. try {
  16188. if (!_n && _i["return"]) _i["return"]()
  16189. } finally {
  16190. if (_d) throw _e;
  16191. }
  16192. }
  16193. return _arr
  16194. }
  16195. return function(arr, i) {
  16196. if (Array.isArray(arr)) {
  16197. return arr
  16198. } else if (Symbol.iterator in Object(arr)) {
  16199. return sliceIterator(arr, i)
  16200. } else {
  16201. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  16202. }
  16203. }
  16204. } ();
  16205. var _createClass = function() {
  16206. function defineProperties(target, props) {
  16207. for (var i = 0; i < props.length; i++) {
  16208. var descriptor = props[i];
  16209. descriptor.enumerable = descriptor.enumerable || false;
  16210. descriptor.configurable = true;
  16211. if ("value" in descriptor) descriptor.writable = true;
  16212. Object.defineProperty(target, descriptor.key, descriptor)
  16213. }
  16214. }
  16215. return function(Constructor, protoProps, staticProps) {
  16216. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  16217. if (staticProps) defineProperties(Constructor, staticProps);
  16218. return Constructor
  16219. }
  16220. } ();
  16221. var _ui_utils = __webpack_require__(0);
  16222. var _pdfjsLib = __webpack_require__(1);
  16223. function _classCallCheck(instance, Constructor) {
  16224. if (! (instance instanceof Constructor)) {
  16225. throw new TypeError("Cannot call a class as a function");
  16226. }
  16227. }
  16228. var DEFAULT_FIELD_CONTENT = '-';
  16229. var PDFDocumentProperties = function() {
  16230. function PDFDocumentProperties(_ref, overlayManager) {
  16231. var overlayName = _ref.overlayName,
  16232. fields = _ref.fields,
  16233. container = _ref.container,
  16234. closeButton = _ref.closeButton;
  16235. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  16236. _classCallCheck(this, PDFDocumentProperties);
  16237. this.overlayName = overlayName;
  16238. this.fields = fields;
  16239. this.container = container;
  16240. this.overlayManager = overlayManager;
  16241. this.l10n = l10n;
  16242. this._reset();
  16243. if (closeButton) {
  16244. closeButton.addEventListener('click', this.close.bind(this))
  16245. }
  16246. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this))
  16247. }
  16248. _createClass(PDFDocumentProperties, [{
  16249. key: 'open',
  16250. value: function open() {
  16251. var _this = this;
  16252. var freezeFieldData = function freezeFieldData(data) {
  16253. Object.defineProperty(_this, 'fieldData', {
  16254. value: Object.freeze(data),
  16255. writable: false,
  16256. enumerable: true,
  16257. configurable: true
  16258. })
  16259. };
  16260. Promise.all([this.overlayManager.open(this.overlayName), this._dataAvailableCapability.promise]).then(function() {
  16261. if (_this.fieldData) {
  16262. _this._updateUI();
  16263. return
  16264. }
  16265. _this.pdfDocument.getMetadata().then(function(_ref2) {
  16266. var info = _ref2.info,
  16267. metadata = _ref2.metadata;
  16268. return Promise.all([info, metadata, _this._parseFileSize(_this.maybeFileSize), _this._parseDate(info.CreationDate), _this._parseDate(info.ModDate)])
  16269. }).then(function(_ref3) {
  16270. var _ref4 = _slicedToArray(_ref3, 5),
  16271. info = _ref4[0],
  16272. metadata = _ref4[1],
  16273. fileSize = _ref4[2],
  16274. creationDate = _ref4[3],
  16275. modificationDate = _ref4[4];
  16276. freezeFieldData({
  16277. 'fileName': (0, _ui_utils.getPDFFileNameFromURL)(_this.url),
  16278. 'fileSize': fileSize,
  16279. 'title': info.Title,
  16280. 'author': info.Author,
  16281. 'subject': info.Subject,
  16282. 'keywords': info.Keywords,
  16283. 'creationDate': creationDate,
  16284. 'modificationDate': modificationDate,
  16285. 'creator': info.Creator,
  16286. 'producer': info.Producer,
  16287. 'version': info.PDFFormatVersion,
  16288. 'pageCount': _this.pdfDocument.numPages
  16289. });
  16290. _this._updateUI();
  16291. return _this.pdfDocument.getDownloadInfo()
  16292. }).then(function(_ref5) {
  16293. var length = _ref5.length;
  16294. return _this._parseFileSize(length)
  16295. }).then(function(fileSize) {
  16296. var data = (0, _ui_utils.cloneObj)(_this.fieldData);
  16297. data['fileSize'] = fileSize;
  16298. freezeFieldData(data);
  16299. _this._updateUI()
  16300. })
  16301. })
  16302. }
  16303. },
  16304. {
  16305. key: 'close',
  16306. value: function close() {
  16307. this.overlayManager.close(this.overlayName)
  16308. }
  16309. },
  16310. {
  16311. key: 'setDocument',
  16312. value: function setDocument(pdfDocument, url) {
  16313. if (this.pdfDocument) {
  16314. this._reset();
  16315. this._updateUI(true)
  16316. }
  16317. if (!pdfDocument) {
  16318. return
  16319. }
  16320. this.pdfDocument = pdfDocument;
  16321. this.url = url;
  16322. this._dataAvailableCapability.resolve()
  16323. }
  16324. },
  16325. {
  16326. key: 'setFileSize',
  16327. value: function setFileSize(fileSize) {
  16328. if (typeof fileSize === 'number' && fileSize > 0) {
  16329. this.maybeFileSize = fileSize
  16330. }
  16331. }
  16332. },
  16333. {
  16334. key: '_reset',
  16335. value: function _reset() {
  16336. this.pdfDocument = null;
  16337. this.url = null;
  16338. this.maybeFileSize = 0;
  16339. delete this.fieldData;
  16340. this._dataAvailableCapability = (0, _pdfjsLib.createPromiseCapability)()
  16341. }
  16342. },
  16343. {
  16344. key: '_updateUI',
  16345. value: function _updateUI() {
  16346. var reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  16347. if (reset || !this.fieldData) {
  16348. for (var id in this.fields) {
  16349. this.fields[id].textContent = DEFAULT_FIELD_CONTENT
  16350. }
  16351. return
  16352. }
  16353. if (this.overlayManager.active !== this.overlayName) {
  16354. return
  16355. }
  16356. for (var _id in this.fields) {
  16357. var content = this.fieldData[_id];
  16358. this.fields[_id].textContent = content || content === 0 ? content: DEFAULT_FIELD_CONTENT
  16359. }
  16360. }
  16361. },
  16362. {
  16363. key: '_parseFileSize',
  16364. value: function _parseFileSize() {
  16365. var fileSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  16366. var kb = fileSize / 1024;
  16367. if (!kb) {
  16368. return Promise.resolve(undefined)
  16369. } else if (kb < 1024) {
  16370. return this.l10n.get('document_properties_kb', {
  16371. size_kb: ( + kb.toPrecision(3)).toLocaleString(),
  16372. size_b: fileSize.toLocaleString()
  16373. },
  16374. '{{size_kb}} KB ({{size_b}} bytes)')
  16375. }
  16376. return this.l10n.get('document_properties_mb', {
  16377. size_mb: ( + (kb / 1024).toPrecision(3)).toLocaleString(),
  16378. size_b: fileSize.toLocaleString()
  16379. },
  16380. '{{size_mb}} MB ({{size_b}} bytes)')
  16381. }
  16382. },
  16383. {
  16384. key: '_parseDate',
  16385. value: function _parseDate(inputDate) {
  16386. if (!inputDate) {
  16387. return
  16388. }
  16389. var dateToParse = inputDate;
  16390. if (dateToParse.substring(0, 2) === 'D:') {
  16391. dateToParse = dateToParse.substring(2)
  16392. }
  16393. var year = parseInt(dateToParse.substring(0, 4), 10);
  16394. var month = parseInt(dateToParse.substring(4, 6), 10) - 1;
  16395. var day = parseInt(dateToParse.substring(6, 8), 10);
  16396. var hours = parseInt(dateToParse.substring(8, 10), 10);
  16397. var minutes = parseInt(dateToParse.substring(10, 12), 10);
  16398. var seconds = parseInt(dateToParse.substring(12, 14), 10);
  16399. var utRel = dateToParse.substring(14, 15);
  16400. var offsetHours = parseInt(dateToParse.substring(15, 17), 10);
  16401. var offsetMinutes = parseInt(dateToParse.substring(18, 20), 10);
  16402. if (utRel === '-') {
  16403. hours += offsetHours;
  16404. minutes += offsetMinutes
  16405. } else if (utRel === '+') {
  16406. hours -= offsetHours;
  16407. minutes -= offsetMinutes
  16408. }
  16409. var date = new Date(Date.UTC(year, month, day, hours, minutes, seconds));
  16410. var dateString = date.toLocaleDateString();
  16411. var timeString = date.toLocaleTimeString();
  16412. return this.l10n.get('document_properties_date_string', {
  16413. date: dateString,
  16414. time: timeString
  16415. },
  16416. '{{date}}, {{time}}')
  16417. }
  16418. }]);
  16419. return PDFDocumentProperties
  16420. } ();
  16421. exports.PDFDocumentProperties = PDFDocumentProperties
  16422. }), (function(module, exports, __webpack_require__) {
  16423. "use strict";
  16424. Object.defineProperty(exports, "__esModule", {
  16425. value: true
  16426. });
  16427. exports.PDFFindBar = undefined;
  16428. var _createClass = function() {
  16429. function defineProperties(target, props) {
  16430. for (var i = 0; i < props.length; i++) {
  16431. var descriptor = props[i];
  16432. descriptor.enumerable = descriptor.enumerable || false;
  16433. descriptor.configurable = true;
  16434. if ("value" in descriptor) descriptor.writable = true;
  16435. Object.defineProperty(target, descriptor.key, descriptor)
  16436. }
  16437. }
  16438. return function(Constructor, protoProps, staticProps) {
  16439. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  16440. if (staticProps) defineProperties(Constructor, staticProps);
  16441. return Constructor
  16442. }
  16443. } ();
  16444. var _pdf_find_controller = __webpack_require__(7);
  16445. var _ui_utils = __webpack_require__(0);
  16446. function _classCallCheck(instance, Constructor) {
  16447. if (! (instance instanceof Constructor)) {
  16448. throw new TypeError("Cannot call a class as a function");
  16449. }
  16450. }
  16451. var PDFFindBar = function() {
  16452. function PDFFindBar(options) {
  16453. var _this = this;
  16454. var l10n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _ui_utils.NullL10n;
  16455. _classCallCheck(this, PDFFindBar);
  16456. this.opened = false;
  16457. this.bar = options.bar || null;
  16458. this.toggleButton = options.toggleButton || null;
  16459. this.findField = options.findField || null;
  16460. this.highlightAll = options.highlightAllCheckbox || null;
  16461. this.caseSensitive = options.caseSensitiveCheckbox || null;
  16462. this.findMsg = options.findMsg || null;
  16463. this.findResultsCount = options.findResultsCount || null;
  16464. this.findStatusIcon = options.findStatusIcon || null;
  16465. this.findPreviousButton = options.findPreviousButton || null;
  16466. this.findNextButton = options.findNextButton || null;
  16467. this.findController = options.findController || null;
  16468. this.eventBus = options.eventBus;
  16469. this.l10n = l10n;
  16470. if (this.findController === null) {
  16471. throw new Error('PDFFindBar cannot be used without a ' + 'PDFFindController instance.');
  16472. }
  16473. this.toggleButton.addEventListener('click',
  16474. function() {
  16475. _this.toggle()
  16476. });
  16477. this.findField.addEventListener('input',
  16478. function() {
  16479. _this.dispatchEvent('')
  16480. });
  16481. this.bar.addEventListener('keydown',
  16482. function(e) {
  16483. switch (e.keyCode) {
  16484. case 13:
  16485. if (e.target === _this.findField) {
  16486. _this.dispatchEvent('again', e.shiftKey)
  16487. }
  16488. break;
  16489. case 27:
  16490. _this.close();
  16491. break
  16492. }
  16493. });
  16494. this.findPreviousButton.addEventListener('click',
  16495. function() {
  16496. _this.dispatchEvent('again', true)
  16497. });
  16498. this.findNextButton.addEventListener('click',
  16499. function() {
  16500. _this.dispatchEvent('again', false)
  16501. });
  16502. this.highlightAll.addEventListener('click',
  16503. function() {
  16504. _this.dispatchEvent('highlightallchange')
  16505. });
  16506. this.caseSensitive.addEventListener('click',
  16507. function() {
  16508. _this.dispatchEvent('casesensitivitychange')
  16509. });
  16510. this.eventBus.on('resize', this._adjustWidth.bind(this))
  16511. }
  16512. _createClass(PDFFindBar, [{
  16513. key: 'reset',
  16514. value: function reset() {
  16515. this.updateUIState()
  16516. }
  16517. },
  16518. {
  16519. key: 'dispatchEvent',
  16520. value: function dispatchEvent(type, findPrev) {
  16521. this.eventBus.dispatch('find', {
  16522. source: this,
  16523. type: type,
  16524. query: this.findField.value,
  16525. caseSensitive: this.caseSensitive.checked,
  16526. phraseSearch: true,
  16527. highlightAll: this.highlightAll.checked,
  16528. findPrevious: findPrev
  16529. })
  16530. }
  16531. },
  16532. {
  16533. key: 'updateUIState',
  16534. value: function updateUIState(state, previous, matchCount) {
  16535. var _this2 = this;
  16536. var notFound = false;
  16537. var findMsg = '';
  16538. var status = '';
  16539. switch (state) {
  16540. case _pdf_find_controller.FindState.FOUND:
  16541. break;
  16542. case _pdf_find_controller.FindState.PENDING:
  16543. status = 'pending';
  16544. break;
  16545. case _pdf_find_controller.FindState.NOT_FOUND:
  16546. findMsg = this.l10n.get('find_not_found', null, 'Phrase not found');
  16547. notFound = true;
  16548. break;
  16549. case _pdf_find_controller.FindState.WRAPPED:
  16550. if (previous) {
  16551. findMsg = this.l10n.get('find_reached_top', null, 'Reached top of document, continued from bottom')
  16552. } else {
  16553. findMsg = this.l10n.get('find_reached_bottom', null, 'Reached end of document, continued from top')
  16554. }
  16555. break
  16556. }
  16557. if (notFound) {
  16558. this.findField.classList.add('notFound')
  16559. } else {
  16560. this.findField.classList.remove('notFound')
  16561. }
  16562. this.findField.setAttribute('data-status', status);
  16563. Promise.resolve(findMsg).then(function(msg) {
  16564. _this2.findMsg.textContent = msg;
  16565. _this2._adjustWidth()
  16566. });
  16567. this.updateResultsCount(matchCount)
  16568. }
  16569. },
  16570. {
  16571. key: 'updateResultsCount',
  16572. value: function updateResultsCount(matchCount) {
  16573. if (!this.findResultsCount) {
  16574. return
  16575. }
  16576. if (!matchCount) {
  16577. this.findResultsCount.classList.add('hidden');
  16578. this.findResultsCount.textContent = ''
  16579. } else {
  16580. this.findResultsCount.textContent = matchCount.toLocaleString();
  16581. this.findResultsCount.classList.remove('hidden')
  16582. }
  16583. this._adjustWidth()
  16584. }
  16585. },
  16586. {
  16587. key: 'open',
  16588. value: function open() {
  16589. if (!this.opened) {
  16590. this.opened = true;
  16591. this.toggleButton.classList.add('toggled');
  16592. this.bar.classList.remove('hidden')
  16593. }
  16594. this.findField.select();
  16595. this.findField.focus();
  16596. this._adjustWidth()
  16597. }
  16598. },
  16599. {
  16600. key: 'close',
  16601. value: function close() {
  16602. if (!this.opened) {
  16603. return
  16604. }
  16605. this.opened = false;
  16606. this.toggleButton.classList.remove('toggled');
  16607. this.bar.classList.add('hidden');
  16608. this.findController.active = false
  16609. }
  16610. },
  16611. {
  16612. key: 'toggle',
  16613. value: function toggle() {
  16614. if (this.opened) {
  16615. this.close()
  16616. } else {
  16617. this.open()
  16618. }
  16619. }
  16620. },
  16621. {
  16622. key: '_adjustWidth',
  16623. value: function _adjustWidth() {
  16624. if (!this.opened) {
  16625. return
  16626. }
  16627. this.bar.classList.remove('wrapContainers');
  16628. var findbarHeight = this.bar.clientHeight;
  16629. var inputContainerHeight = this.bar.firstElementChild.clientHeight;
  16630. if (findbarHeight > inputContainerHeight) {
  16631. this.bar.classList.add('wrapContainers')
  16632. }
  16633. }
  16634. }]);
  16635. return PDFFindBar
  16636. } ();
  16637. exports.PDFFindBar = PDFFindBar
  16638. }), (function(module, exports, __webpack_require__) {
  16639. "use strict";
  16640. Object.defineProperty(exports, "__esModule", {
  16641. value: true
  16642. });
  16643. exports.PDFHistory = undefined;
  16644. var _dom_events = __webpack_require__(2);
  16645. function PDFHistory(options) {
  16646. this.linkService = options.linkService;
  16647. this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)();
  16648. this.initialized = false;
  16649. this.initialDestination = null;
  16650. this.initialBookmark = null
  16651. }
  16652. PDFHistory.prototype = {
  16653. initialize: function pdfHistoryInitialize(fingerprint) {
  16654. this.initialized = true;
  16655. this.reInitialized = false;
  16656. this.allowHashChange = true;
  16657. this.historyUnlocked = true;
  16658. this.isViewerInPresentationMode = false;
  16659. this.previousHash = window.location.hash.substring(1);
  16660. this.currentBookmark = '';
  16661. this.currentPage = 0;
  16662. this.updatePreviousBookmark = false;
  16663. this.previousBookmark = '';
  16664. this.previousPage = 0;
  16665. this.nextHashParam = '';
  16666. this.fingerprint = fingerprint;
  16667. this.currentUid = this.uid = 0;
  16668. this.current = {};
  16669. var state = window.history.state;
  16670. if (this._isStateObjectDefined(state)) {
  16671. if (state.target.dest) {
  16672. this.initialDestination = state.target.dest
  16673. } else {
  16674. this.initialBookmark = state.target.hash
  16675. }
  16676. this.currentUid = state.uid;
  16677. this.uid = state.uid + 1;
  16678. this.current = state.target
  16679. } else {
  16680. if (state && state.fingerprint && this.fingerprint !== state.fingerprint) {
  16681. this.reInitialized = true
  16682. }
  16683. this._pushOrReplaceState({
  16684. fingerprint: this.fingerprint
  16685. },
  16686. true)
  16687. }
  16688. var self = this;
  16689. window.addEventListener('popstate',
  16690. function pdfHistoryPopstate(evt) {
  16691. if (!self.historyUnlocked) {
  16692. return
  16693. }
  16694. if (evt.state) {
  16695. self._goTo(evt.state);
  16696. return
  16697. }
  16698. if (self.uid === 0) {
  16699. var previousParams = self.previousHash && self.currentBookmark && self.previousHash !== self.currentBookmark ? {
  16700. hash: self.currentBookmark,
  16701. page: self.currentPage
  16702. }: {
  16703. page: 1
  16704. };
  16705. replacePreviousHistoryState(previousParams,
  16706. function() {
  16707. updateHistoryWithCurrentHash()
  16708. })
  16709. } else {
  16710. updateHistoryWithCurrentHash()
  16711. }
  16712. });
  16713. function updateHistoryWithCurrentHash() {
  16714. self.previousHash = window.location.hash.slice(1);
  16715. self._pushToHistory({
  16716. hash: self.previousHash
  16717. },
  16718. false, true);
  16719. self._updatePreviousBookmark()
  16720. }
  16721. function replacePreviousHistoryState(params, callback) {
  16722. self.historyUnlocked = false;
  16723. self.allowHashChange = false;
  16724. window.addEventListener('popstate', rewriteHistoryAfterBack);
  16725. history.back();
  16726. function rewriteHistoryAfterBack() {
  16727. window.removeEventListener('popstate', rewriteHistoryAfterBack);
  16728. window.addEventListener('popstate', rewriteHistoryAfterForward);
  16729. self._pushToHistory(params, false, true);
  16730. history.forward()
  16731. }
  16732. function rewriteHistoryAfterForward() {
  16733. window.removeEventListener('popstate', rewriteHistoryAfterForward);
  16734. self.allowHashChange = true;
  16735. self.historyUnlocked = true;
  16736. callback()
  16737. }
  16738. }
  16739. function pdfHistoryBeforeUnload() {
  16740. var previousParams = self._getPreviousParams(null, true);
  16741. if (previousParams) {
  16742. var replacePrevious = !self.current.dest && self.current.hash !== self.previousHash;
  16743. self._pushToHistory(previousParams, false, replacePrevious);
  16744. self._updatePreviousBookmark()
  16745. }
  16746. window.removeEventListener('beforeunload', pdfHistoryBeforeUnload)
  16747. }
  16748. window.addEventListener('beforeunload', pdfHistoryBeforeUnload);
  16749. window.addEventListener('pageshow',
  16750. function pdfHistoryPageShow(evt) {
  16751. window.addEventListener('beforeunload', pdfHistoryBeforeUnload)
  16752. });
  16753. self.eventBus.on('presentationmodechanged',
  16754. function(e) {
  16755. self.isViewerInPresentationMode = e.active
  16756. })
  16757. },
  16758. clearHistoryState: function pdfHistory_clearHistoryState() {
  16759. this._pushOrReplaceState(null, true)
  16760. },
  16761. _isStateObjectDefined: function pdfHistory_isStateObjectDefined(state) {
  16762. return state && state.uid >= 0 && state.fingerprint && this.fingerprint === state.fingerprint && state.target && state.target.hash ? true: false
  16763. },
  16764. _pushOrReplaceState: function pdfHistory_pushOrReplaceState(stateObj, replace) {
  16765. if (replace) {
  16766. window.history.replaceState(stateObj, '', document.URL)
  16767. } else {
  16768. window.history.pushState(stateObj, '', document.URL)
  16769. }
  16770. },
  16771. get isHashChangeUnlocked() {
  16772. if (!this.initialized) {
  16773. return true
  16774. }
  16775. return this.allowHashChange
  16776. },
  16777. _updatePreviousBookmark: function pdfHistory_updatePreviousBookmark() {
  16778. if (this.updatePreviousBookmark && this.currentBookmark && this.currentPage) {
  16779. this.previousBookmark = this.currentBookmark;
  16780. this.previousPage = this.currentPage;
  16781. this.updatePreviousBookmark = false
  16782. }
  16783. },
  16784. updateCurrentBookmark: function pdfHistoryUpdateCurrentBookmark(bookmark, pageNum) {
  16785. if (this.initialized) {
  16786. this.currentBookmark = bookmark.substring(1);
  16787. this.currentPage = pageNum | 0;
  16788. this._updatePreviousBookmark()
  16789. }
  16790. },
  16791. updateNextHashParam: function pdfHistoryUpdateNextHashParam(param) {
  16792. if (this.initialized) {
  16793. this.nextHashParam = param
  16794. }
  16795. },
  16796. push: function pdfHistoryPush(params, isInitialBookmark) {
  16797. if (! (this.initialized && this.historyUnlocked)) {
  16798. return
  16799. }
  16800. if (params.dest && !params.hash) {
  16801. params.hash = this.current.hash && this.current.dest && this.current.dest === params.dest ? this.current.hash: this.linkService.getDestinationHash(params.dest).split('#')[1]
  16802. }
  16803. if (params.page) {
  16804. params.page |= 0
  16805. }
  16806. if (isInitialBookmark) {
  16807. var target = window.history.state.target;
  16808. if (!target) {
  16809. this._pushToHistory(params, false);
  16810. this.previousHash = window.location.hash.substring(1)
  16811. }
  16812. this.updatePreviousBookmark = this.nextHashParam ? false: true;
  16813. if (target) {
  16814. this._updatePreviousBookmark()
  16815. }
  16816. return
  16817. }
  16818. if (this.nextHashParam) {
  16819. if (this.nextHashParam === params.hash) {
  16820. this.nextHashParam = null;
  16821. this.updatePreviousBookmark = true;
  16822. return
  16823. }
  16824. this.nextHashParam = null
  16825. }
  16826. if (params.hash) {
  16827. if (this.current.hash) {
  16828. if (this.current.hash !== params.hash) {
  16829. this._pushToHistory(params, true)
  16830. } else {
  16831. if (!this.current.page && params.page) {
  16832. this._pushToHistory(params, false, true)
  16833. }
  16834. this.updatePreviousBookmark = true
  16835. }
  16836. } else {
  16837. this._pushToHistory(params, true)
  16838. }
  16839. } else if (this.current.page && params.page && this.current.page !== params.page) {
  16840. this._pushToHistory(params, true)
  16841. }
  16842. },
  16843. _getPreviousParams: function pdfHistory_getPreviousParams(onlyCheckPage, beforeUnload) {
  16844. if (! (this.currentBookmark && this.currentPage)) {
  16845. return null
  16846. } else if (this.updatePreviousBookmark) {
  16847. this.updatePreviousBookmark = false
  16848. }
  16849. if (this.uid > 0 && !(this.previousBookmark && this.previousPage)) {
  16850. return null
  16851. }
  16852. if (!this.current.dest && !onlyCheckPage || beforeUnload) {
  16853. if (this.previousBookmark === this.currentBookmark) {
  16854. return null
  16855. }
  16856. } else if (this.current.page || onlyCheckPage) {
  16857. if (this.previousPage === this.currentPage) {
  16858. return null
  16859. }
  16860. } else {
  16861. return null
  16862. }
  16863. var params = {
  16864. hash: this.currentBookmark,
  16865. page: this.currentPage
  16866. };
  16867. if (this.isViewerInPresentationMode) {
  16868. params.hash = null
  16869. }
  16870. return params
  16871. },
  16872. _stateObj: function pdfHistory_stateObj(params) {
  16873. return {
  16874. fingerprint: this.fingerprint,
  16875. uid: this.uid,
  16876. target: params
  16877. }
  16878. },
  16879. _pushToHistory: function pdfHistory_pushToHistory(params, addPrevious, overwrite) {
  16880. if (!this.initialized) {
  16881. return
  16882. }
  16883. if (!params.hash && params.page) {
  16884. params.hash = 'page=' + params.page
  16885. }
  16886. if (addPrevious && !overwrite) {
  16887. var previousParams = this._getPreviousParams();
  16888. if (previousParams) {
  16889. var replacePrevious = !this.current.dest && this.current.hash !== this.previousHash;
  16890. this._pushToHistory(previousParams, false, replacePrevious)
  16891. }
  16892. }
  16893. this._pushOrReplaceState(this._stateObj(params), overwrite || this.uid === 0);
  16894. this.currentUid = this.uid++;
  16895. this.current = params;
  16896. this.updatePreviousBookmark = true
  16897. },
  16898. _goTo: function pdfHistory_goTo(state) {
  16899. if (! (this.initialized && this.historyUnlocked && this._isStateObjectDefined(state))) {
  16900. return
  16901. }
  16902. if (!this.reInitialized && state.uid < this.currentUid) {
  16903. var previousParams = this._getPreviousParams(true);
  16904. if (previousParams) {
  16905. this._pushToHistory(this.current, false);
  16906. this._pushToHistory(previousParams, false);
  16907. this.currentUid = state.uid;
  16908. window.history.back();
  16909. return
  16910. }
  16911. }
  16912. this.historyUnlocked = false;
  16913. if (state.target.dest) {
  16914. this.linkService.navigateTo(state.target.dest)
  16915. } else {
  16916. this.linkService.setHash(state.target.hash)
  16917. }
  16918. this.currentUid = state.uid;
  16919. if (state.uid > this.uid) {
  16920. this.uid = state.uid
  16921. }
  16922. this.current = state.target;
  16923. this.updatePreviousBookmark = true;
  16924. var currentHash = window.location.hash.substring(1);
  16925. if (this.previousHash !== currentHash) {
  16926. this.allowHashChange = false
  16927. }
  16928. this.previousHash = currentHash;
  16929. this.historyUnlocked = true
  16930. },
  16931. back: function pdfHistoryBack() {
  16932. this.go( - 1)
  16933. },
  16934. forward: function pdfHistoryForward() {
  16935. this.go(1)
  16936. },
  16937. go: function pdfHistoryGo(direction) {
  16938. if (this.initialized && this.historyUnlocked) {
  16939. var state = window.history.state;
  16940. if (direction === -1 && state && state.uid > 0) {
  16941. window.history.back()
  16942. } else if (direction === 1 && state && state.uid < this.uid - 1) {
  16943. window.history.forward()
  16944. }
  16945. }
  16946. }
  16947. };
  16948. exports.PDFHistory = PDFHistory
  16949. }), (function(module, exports, __webpack_require__) {
  16950. "use strict";
  16951. Object.defineProperty(exports, "__esModule", {
  16952. value: true
  16953. });
  16954. exports.PDFOutlineViewer = undefined;
  16955. var _createClass = function() {
  16956. function defineProperties(target, props) {
  16957. for (var i = 0; i < props.length; i++) {
  16958. var descriptor = props[i];
  16959. descriptor.enumerable = descriptor.enumerable || false;
  16960. descriptor.configurable = true;
  16961. if ("value" in descriptor) descriptor.writable = true;
  16962. Object.defineProperty(target, descriptor.key, descriptor)
  16963. }
  16964. }
  16965. return function(Constructor, protoProps, staticProps) {
  16966. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  16967. if (staticProps) defineProperties(Constructor, staticProps);
  16968. return Constructor
  16969. }
  16970. } ();
  16971. var _pdfjsLib = __webpack_require__(1);
  16972. function _classCallCheck(instance, Constructor) {
  16973. if (! (instance instanceof Constructor)) {
  16974. throw new TypeError("Cannot call a class as a function");
  16975. }
  16976. }
  16977. var DEFAULT_TITLE = '\u2013';
  16978. var PDFOutlineViewer = function() {
  16979. function PDFOutlineViewer(_ref) {
  16980. var container = _ref.container,
  16981. linkService = _ref.linkService,
  16982. eventBus = _ref.eventBus;
  16983. _classCallCheck(this, PDFOutlineViewer);
  16984. this.outline = null;
  16985. this.lastToggleIsShow = true;
  16986. this.container = container;
  16987. this.linkService = linkService;
  16988. this.eventBus = eventBus
  16989. }
  16990. _createClass(PDFOutlineViewer, [{
  16991. key: 'reset',
  16992. value: function reset() {
  16993. this.outline = null;
  16994. this.lastToggleIsShow = true;
  16995. this.container.textContent = '';
  16996. this.container.classList.remove('outlineWithDeepNesting')
  16997. }
  16998. },
  16999. {
  17000. key: '_dispatchEvent',
  17001. value: function _dispatchEvent(outlineCount) {
  17002. this.eventBus.dispatch('outlineloaded', {
  17003. source: this,
  17004. outlineCount: outlineCount
  17005. })
  17006. }
  17007. },
  17008. {
  17009. key: '_bindLink',
  17010. value: function _bindLink(element, item) {
  17011. var _this = this;
  17012. if (item.url) { (0, _pdfjsLib.addLinkAttributes)(element, {
  17013. url: item.url,
  17014. target: item.newWindow ? _pdfjsLib.PDFJS.LinkTarget.BLANK: undefined
  17015. });
  17016. return
  17017. }
  17018. var destination = item.dest;
  17019. element.href = this.linkService.getDestinationHash(destination);
  17020. element.onclick = function() {
  17021. if (destination) {
  17022. _this.linkService.navigateTo(destination)
  17023. }
  17024. return false
  17025. }
  17026. }
  17027. },
  17028. {
  17029. key: '_setStyles',
  17030. value: function _setStyles(element, item) {
  17031. var styleStr = '';
  17032. if (item.bold) {
  17033. styleStr += 'font-weight: bold;'
  17034. }
  17035. if (item.italic) {
  17036. styleStr += 'font-style: italic;'
  17037. }
  17038. if (styleStr) {
  17039. element.setAttribute('style', styleStr)
  17040. }
  17041. }
  17042. },
  17043. {
  17044. key: '_addToggleButton',
  17045. value: function _addToggleButton(div) {
  17046. var _this2 = this;
  17047. var toggler = document.createElement('div');
  17048. toggler.className = 'outlineItemToggler';
  17049. toggler.onclick = function(evt) {
  17050. evt.stopPropagation();
  17051. toggler.classList.toggle('outlineItemsHidden');
  17052. if (evt.shiftKey) {
  17053. var shouldShowAll = !toggler.classList.contains('outlineItemsHidden');
  17054. _this2._toggleOutlineItem(div, shouldShowAll)
  17055. }
  17056. };
  17057. div.insertBefore(toggler, div.firstChild)
  17058. }
  17059. },
  17060. {
  17061. key: '_toggleOutlineItem',
  17062. value: function _toggleOutlineItem(root, show) {
  17063. this.lastToggleIsShow = show;
  17064. var togglers = root.querySelectorAll('.outlineItemToggler');
  17065. for (var i = 0,
  17066. ii = togglers.length; i < ii; ++i) {
  17067. togglers[i].classList[show ? 'remove': 'add']('outlineItemsHidden')
  17068. }
  17069. }
  17070. },
  17071. {
  17072. key: 'toggleOutlineTree',
  17073. value: function toggleOutlineTree() {
  17074. if (!this.outline) {
  17075. return
  17076. }
  17077. this._toggleOutlineItem(this.container, !this.lastToggleIsShow)
  17078. }
  17079. },
  17080. {
  17081. key: 'render',
  17082. value: function render(_ref2) {
  17083. var outline = _ref2.outline;
  17084. var outlineCount = 0;
  17085. if (this.outline) {
  17086. this.reset()
  17087. }
  17088. this.outline = outline || null;
  17089. if (!outline) {
  17090. this._dispatchEvent(outlineCount);
  17091. return
  17092. }
  17093. var fragment = document.createDocumentFragment();
  17094. var queue = [{
  17095. parent: fragment,
  17096. items: this.outline
  17097. }];
  17098. var hasAnyNesting = false;
  17099. while (queue.length > 0) {
  17100. var levelData = queue.shift();
  17101. for (var i = 0,
  17102. len = levelData.items.length; i < len; i++) {
  17103. var item = levelData.items[i];
  17104. var div = document.createElement('div');
  17105. div.className = 'outlineItem';
  17106. var element = document.createElement('a');
  17107. this._bindLink(element, item);
  17108. this._setStyles(element, item);
  17109. element.textContent = (0, _pdfjsLib.removeNullCharacters)(item.title) || DEFAULT_TITLE;
  17110. div.appendChild(element);
  17111. if (item.items.length > 0) {
  17112. hasAnyNesting = true;
  17113. this._addToggleButton(div);
  17114. var itemsDiv = document.createElement('div');
  17115. itemsDiv.className = 'outlineItems';
  17116. div.appendChild(itemsDiv);
  17117. queue.push({
  17118. parent: itemsDiv,
  17119. items: item.items
  17120. })
  17121. }
  17122. levelData.parent.appendChild(div);
  17123. outlineCount++
  17124. }
  17125. }
  17126. if (hasAnyNesting) {
  17127. this.container.classList.add('outlineWithDeepNesting')
  17128. }
  17129. this.container.appendChild(fragment);
  17130. this._dispatchEvent(outlineCount)
  17131. }
  17132. }]);
  17133. return PDFOutlineViewer
  17134. } ();
  17135. exports.PDFOutlineViewer = PDFOutlineViewer
  17136. }), (function(module, exports, __webpack_require__) {
  17137. "use strict";
  17138. Object.defineProperty(exports, "__esModule", {
  17139. value: true
  17140. });
  17141. exports.PDFPageView = undefined;
  17142. var _createClass = function() {
  17143. function defineProperties(target, props) {
  17144. for (var i = 0; i < props.length; i++) {
  17145. var descriptor = props[i];
  17146. descriptor.enumerable = descriptor.enumerable || false;
  17147. descriptor.configurable = true;
  17148. if ("value" in descriptor) descriptor.writable = true;
  17149. Object.defineProperty(target, descriptor.key, descriptor)
  17150. }
  17151. }
  17152. return function(Constructor, protoProps, staticProps) {
  17153. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  17154. if (staticProps) defineProperties(Constructor, staticProps);
  17155. return Constructor
  17156. }
  17157. } ();
  17158. var _ui_utils = __webpack_require__(0);
  17159. var _pdfjsLib = __webpack_require__(1);
  17160. var _dom_events = __webpack_require__(2);
  17161. var _pdf_rendering_queue = __webpack_require__(3);
  17162. function _classCallCheck(instance, Constructor) {
  17163. if (! (instance instanceof Constructor)) {
  17164. throw new TypeError("Cannot call a class as a function");
  17165. }
  17166. }
  17167. var PDFPageView = function() {
  17168. function PDFPageView(options) {
  17169. _classCallCheck(this, PDFPageView);
  17170. var container = options.container;
  17171. var defaultViewport = options.defaultViewport;
  17172. this.id = options.id;
  17173. this.renderingId = 'page' + this.id;
  17174. this.pdfPage = null;
  17175. this.pageLabel = null;
  17176. this.rotation = 0;
  17177. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  17178. this.viewport = defaultViewport;
  17179. this.pdfPageRotate = defaultViewport.rotation;
  17180. this.hasRestrictedScaling = false;
  17181. this.enhanceTextSelection = options.enhanceTextSelection || false;
  17182. this.renderInteractiveForms = options.renderInteractiveForms || false;
  17183. this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)();
  17184. this.renderingQueue = options.renderingQueue;
  17185. this.textLayerFactory = options.textLayerFactory;
  17186. this.annotationLayerFactory = options.annotationLayerFactory;
  17187. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  17188. this.l10n = options.l10n || _ui_utils.NullL10n;
  17189. this.paintTask = null;
  17190. this.paintedViewportMap = new WeakMap();
  17191. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  17192. this.resume = null;
  17193. this.error = null;
  17194. this.onBeforeDraw = null;
  17195. this.onAfterDraw = null;
  17196. this.annotationLayer = null;
  17197. this.textLayer = null;
  17198. this.zoomLayer = null;
  17199. var div = document.createElement('div');
  17200. div.className = 'page';
  17201. div.style.width = Math.floor(this.viewport.width) + 'px';
  17202. div.style.height = Math.floor(this.viewport.height) + 'px';
  17203. div.setAttribute('data-page-number', this.id);
  17204. this.div = div;
  17205. container.appendChild(div)
  17206. }
  17207. _createClass(PDFPageView, [{
  17208. key: 'setPdfPage',
  17209. value: function setPdfPage(pdfPage) {
  17210. this.pdfPage = pdfPage;
  17211. this.pdfPageRotate = pdfPage.rotate;
  17212. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  17213. this.viewport = pdfPage.getViewport(this.scale * _ui_utils.CSS_UNITS, totalRotation);
  17214. this.stats = pdfPage.stats;
  17215. this.reset()
  17216. }
  17217. },
  17218. {
  17219. key: 'destroy',
  17220. value: function destroy() {
  17221. this.reset();
  17222. if (this.pdfPage) {
  17223. this.pdfPage.cleanup();
  17224. this.pdfPage = null
  17225. }
  17226. }
  17227. },
  17228. {
  17229. key: '_resetZoomLayer',
  17230. value: function _resetZoomLayer() {
  17231. var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  17232. if (!this.zoomLayer) {
  17233. return
  17234. }
  17235. var zoomLayerCanvas = this.zoomLayer.firstChild;
  17236. this.paintedViewportMap.delete(zoomLayerCanvas);
  17237. zoomLayerCanvas.width = 0;
  17238. zoomLayerCanvas.height = 0;
  17239. if (removeFromDOM) {
  17240. this.zoomLayer.remove()
  17241. }
  17242. this.zoomLayer = null
  17243. }
  17244. },
  17245. {
  17246. key: 'reset',
  17247. value: function reset() {
  17248. var keepZoomLayer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  17249. var keepAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  17250. this.cancelRendering();
  17251. var div = this.div;
  17252. div.style.width = Math.floor(this.viewport.width) + 'px';
  17253. div.style.height = Math.floor(this.viewport.height) + 'px';
  17254. var childNodes = div.childNodes;
  17255. var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
  17256. var currentAnnotationNode = keepAnnotations && this.annotationLayer && this.annotationLayer.div || null;
  17257. for (var i = childNodes.length - 1; i >= 0; i--) {
  17258. var node = childNodes[i];
  17259. if (currentZoomLayerNode === node || currentAnnotationNode === node) {
  17260. continue
  17261. }
  17262. div.removeChild(node)
  17263. }
  17264. div.removeAttribute('data-loaded');
  17265. if (currentAnnotationNode) {
  17266. this.annotationLayer.hide()
  17267. } else {
  17268. this.annotationLayer = null
  17269. }
  17270. if (!currentZoomLayerNode) {
  17271. if (this.canvas) {
  17272. this.paintedViewportMap.delete(this.canvas);
  17273. this.canvas.width = 0;
  17274. this.canvas.height = 0;
  17275. delete this.canvas
  17276. }
  17277. this._resetZoomLayer()
  17278. }
  17279. if (this.svg) {
  17280. this.paintedViewportMap.delete(this.svg);
  17281. delete this.svg
  17282. }
  17283. this.loadingIconDiv = document.createElement('div');
  17284. this.loadingIconDiv.className = 'loadingIcon';
  17285. div.appendChild(this.loadingIconDiv)
  17286. }
  17287. },
  17288. {
  17289. key: 'update',
  17290. value: function update(scale, rotation) {
  17291. this.scale = scale || this.scale;
  17292. if (typeof rotation !== 'undefined') {
  17293. this.rotation = rotation
  17294. }
  17295. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  17296. this.viewport = this.viewport.clone({
  17297. scale: this.scale * _ui_utils.CSS_UNITS,
  17298. rotation: totalRotation
  17299. });
  17300. if (this.svg) {
  17301. this.cssTransform(this.svg, true);
  17302. this.eventBus.dispatch('pagerendered', {
  17303. source: this,
  17304. pageNumber: this.id,
  17305. cssTransform: true
  17306. });
  17307. return
  17308. }
  17309. var isScalingRestricted = false;
  17310. if (this.canvas && _pdfjsLib.PDFJS.maxCanvasPixels > 0) {
  17311. var outputScale = this.outputScale;
  17312. if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > _pdfjsLib.PDFJS.maxCanvasPixels) {
  17313. isScalingRestricted = true
  17314. }
  17315. }
  17316. if (this.canvas) {
  17317. if (_pdfjsLib.PDFJS.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
  17318. this.cssTransform(this.canvas, true);
  17319. this.eventBus.dispatch('pagerendered', {
  17320. source: this,
  17321. pageNumber: this.id,
  17322. cssTransform: true
  17323. });
  17324. return
  17325. }
  17326. if (!this.zoomLayer && !this.canvas.hasAttribute('hidden')) {
  17327. this.zoomLayer = this.canvas.parentNode;
  17328. this.zoomLayer.style.position = 'absolute'
  17329. }
  17330. }
  17331. if (this.zoomLayer) {
  17332. this.cssTransform(this.zoomLayer.firstChild)
  17333. }
  17334. this.reset(true, true)
  17335. }
  17336. },
  17337. {
  17338. key: 'cancelRendering',
  17339. value: function cancelRendering() {
  17340. if (this.paintTask) {
  17341. this.paintTask.cancel();
  17342. this.paintTask = null
  17343. }
  17344. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  17345. this.resume = null;
  17346. if (this.textLayer) {
  17347. this.textLayer.cancel();
  17348. this.textLayer = null
  17349. }
  17350. }
  17351. },
  17352. {
  17353. key: 'cssTransform',
  17354. value: function cssTransform(target) {
  17355. var redrawAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  17356. var width = this.viewport.width;
  17357. var height = this.viewport.height;
  17358. var div = this.div;
  17359. target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + 'px';
  17360. target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + 'px';
  17361. var relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
  17362. var absRotation = Math.abs(relativeRotation);
  17363. var scaleX = 1,
  17364. scaleY = 1;
  17365. if (absRotation === 90 || absRotation === 270) {
  17366. scaleX = height / width;
  17367. scaleY = width / height
  17368. }
  17369. var cssTransform = 'rotate(' + relativeRotation + 'deg) ' + 'scale(' + scaleX + ',' + scaleY + ')';
  17370. _pdfjsLib.CustomStyle.setProp('transform', target, cssTransform);
  17371. if (this.textLayer) {
  17372. var textLayerViewport = this.textLayer.viewport;
  17373. var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
  17374. var textAbsRotation = Math.abs(textRelativeRotation);
  17375. var scale = width / textLayerViewport.width;
  17376. if (textAbsRotation === 90 || textAbsRotation === 270) {
  17377. scale = width / textLayerViewport.height
  17378. }
  17379. var textLayerDiv = this.textLayer.textLayerDiv;
  17380. var transX = void 0,
  17381. transY = void 0;
  17382. switch (textAbsRotation) {
  17383. case 0:
  17384. transX = transY = 0;
  17385. break;
  17386. case 90:
  17387. transX = 0;
  17388. transY = '-' + textLayerDiv.style.height;
  17389. break;
  17390. case 180:
  17391. transX = '-' + textLayerDiv.style.width;
  17392. transY = '-' + textLayerDiv.style.height;
  17393. break;
  17394. case 270:
  17395. transX = '-' + textLayerDiv.style.width;
  17396. transY = 0;
  17397. break;
  17398. default:
  17399. console.error('Bad rotation value.');
  17400. break
  17401. }
  17402. _pdfjsLib.CustomStyle.setProp('transform', textLayerDiv, 'rotate(' + textAbsRotation + 'deg) ' + 'scale(' + scale + ', ' + scale + ') ' + 'translate(' + transX + ', ' + transY + ')');
  17403. _pdfjsLib.CustomStyle.setProp('transformOrigin', textLayerDiv, '0% 0%')
  17404. }
  17405. if (redrawAnnotations && this.annotationLayer) {
  17406. this.annotationLayer.render(this.viewport, 'display')
  17407. }
  17408. }
  17409. },
  17410. {
  17411. key: 'getPagePoint',
  17412. value: function getPagePoint(x, y) {
  17413. return this.viewport.convertToPdfPoint(x, y)
  17414. }
  17415. },
  17416. {
  17417. key: 'draw',
  17418. value: function draw() {
  17419. var _this = this;
  17420. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  17421. console.error('Must be in new state before drawing');
  17422. this.reset()
  17423. }
  17424. if (!this.pdfPage) {
  17425. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  17426. return Promise.reject(new Error('Page is not loaded'))
  17427. }
  17428. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  17429. var pdfPage = this.pdfPage;
  17430. var div = this.div;
  17431. var canvasWrapper = document.createElement('div');
  17432. canvasWrapper.style.width = div.style.width;
  17433. canvasWrapper.style.height = div.style.height;
  17434. canvasWrapper.classList.add('canvasWrapper');
  17435. if (this.annotationLayer && this.annotationLayer.div) {
  17436. div.insertBefore(canvasWrapper, this.annotationLayer.div)
  17437. } else {
  17438. div.appendChild(canvasWrapper)
  17439. }
  17440. var textLayer = null;
  17441. if (this.textLayerFactory) {
  17442. var textLayerDiv = document.createElement('div');
  17443. textLayerDiv.className = 'textLayer';
  17444. textLayerDiv.style.width = canvasWrapper.style.width;
  17445. textLayerDiv.style.height = canvasWrapper.style.height;
  17446. if (this.annotationLayer && this.annotationLayer.div) {
  17447. div.insertBefore(textLayerDiv, this.annotationLayer.div)
  17448. } else {
  17449. div.appendChild(textLayerDiv)
  17450. }
  17451. textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.enhanceTextSelection)
  17452. }
  17453. this.textLayer = textLayer;
  17454. var renderContinueCallback = null;
  17455. if (this.renderingQueue) {
  17456. renderContinueCallback = function renderContinueCallback(cont) {
  17457. if (!_this.renderingQueue.isHighestPriority(_this)) {
  17458. _this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  17459. _this.resume = function() {
  17460. _this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  17461. cont()
  17462. };
  17463. return
  17464. }
  17465. cont()
  17466. }
  17467. }
  17468. var finishPaintTask = function finishPaintTask(error) {
  17469. if (paintTask === _this.paintTask) {
  17470. _this.paintTask = null
  17471. }
  17472. if (error === 'cancelled' || error instanceof _pdfjsLib.RenderingCancelledException) {
  17473. _this.error = null;
  17474. return Promise.resolve(undefined)
  17475. }
  17476. _this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  17477. if (_this.loadingIconDiv) {
  17478. div.removeChild(_this.loadingIconDiv);
  17479. delete _this.loadingIconDiv
  17480. }
  17481. _this._resetZoomLayer(true);
  17482. _this.error = error;
  17483. _this.stats = pdfPage.stats;
  17484. if (_this.onAfterDraw) {
  17485. _this.onAfterDraw()
  17486. }
  17487. _this.eventBus.dispatch('pagerendered', {
  17488. source: _this,
  17489. pageNumber: _this.id,
  17490. cssTransform: false
  17491. });
  17492. if (error) {
  17493. return Promise.reject(error)
  17494. }
  17495. return Promise.resolve(undefined)
  17496. };
  17497. var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
  17498. paintTask.onRenderContinue = renderContinueCallback;
  17499. this.paintTask = paintTask;
  17500. var resultPromise = paintTask.promise.then(function() {
  17501. return finishPaintTask(null).then(function() {
  17502. if (textLayer) {
  17503. var readableStream = pdfPage.streamTextContent({
  17504. normalizeWhitespace: true
  17505. });
  17506. textLayer.setTextContentStream(readableStream);
  17507. textLayer.render()
  17508. }
  17509. })
  17510. },
  17511. function(reason) {
  17512. return finishPaintTask(reason)
  17513. });
  17514. if (this.annotationLayerFactory) {
  17515. if (!this.annotationLayer) {
  17516. this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this.renderInteractiveForms, this.l10n)
  17517. }
  17518. this.annotationLayer.render(this.viewport, 'display')
  17519. }
  17520. div.setAttribute('data-loaded', true);
  17521. if (this.onBeforeDraw) {
  17522. this.onBeforeDraw()
  17523. }
  17524. return resultPromise
  17525. }
  17526. },
  17527. {
  17528. key: 'paintOnCanvas',
  17529. value: function paintOnCanvas(canvasWrapper) {
  17530. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  17531. var result = {
  17532. promise: renderCapability.promise,
  17533. onRenderContinue: function onRenderContinue(cont) {
  17534. cont()
  17535. },
  17536. cancel: function cancel() {
  17537. renderTask.cancel()
  17538. }
  17539. };
  17540. var viewport = this.viewport;
  17541. var canvas = document.createElement('canvas');
  17542. canvas.id = this.renderingId;
  17543. canvas.setAttribute('hidden', 'hidden');
  17544. var isCanvasHidden = true;
  17545. var showCanvas = function showCanvas() {
  17546. if (isCanvasHidden) {
  17547. canvas.removeAttribute('hidden');
  17548. isCanvasHidden = false
  17549. }
  17550. };
  17551. canvasWrapper.appendChild(canvas);
  17552. this.canvas = canvas;
  17553. canvas.mozOpaque = true;
  17554. var ctx = canvas.getContext('2d', {
  17555. alpha: false
  17556. });
  17557. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  17558. this.outputScale = outputScale;
  17559. if (_pdfjsLib.PDFJS.useOnlyCssZoom) {
  17560. var actualSizeViewport = viewport.clone({
  17561. scale: _ui_utils.CSS_UNITS
  17562. });
  17563. outputScale.sx *= actualSizeViewport.width / viewport.width;
  17564. outputScale.sy *= actualSizeViewport.height / viewport.height;
  17565. outputScale.scaled = true
  17566. }
  17567. if (_pdfjsLib.PDFJS.maxCanvasPixels > 0) {
  17568. var pixelsInViewport = viewport.width * viewport.height;
  17569. var maxScale = Math.sqrt(_pdfjsLib.PDFJS.maxCanvasPixels / pixelsInViewport);
  17570. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  17571. outputScale.sx = maxScale;
  17572. outputScale.sy = maxScale;
  17573. outputScale.scaled = true;
  17574. this.hasRestrictedScaling = true
  17575. } else {
  17576. this.hasRestrictedScaling = false
  17577. }
  17578. }
  17579. var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  17580. var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  17581. canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
  17582. canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
  17583. canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + 'px';
  17584. canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + 'px';
  17585. this.paintedViewportMap.set(canvas, viewport);
  17586. var transform = !outputScale.scaled ? null: [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
  17587. var renderContext = {
  17588. canvasContext: ctx,
  17589. transform: transform,
  17590. viewport: this.viewport,
  17591. renderInteractiveForms: this.renderInteractiveForms
  17592. };
  17593. var renderTask = this.pdfPage.render(renderContext);
  17594. renderTask.onContinue = function(cont) {
  17595. showCanvas();
  17596. if (result.onRenderContinue) {
  17597. result.onRenderContinue(cont)
  17598. } else {
  17599. cont()
  17600. }
  17601. };
  17602. renderTask.promise.then(function() {
  17603. showCanvas();
  17604. renderCapability.resolve(undefined)
  17605. },
  17606. function(error) {
  17607. showCanvas();
  17608. renderCapability.reject(error)
  17609. });
  17610. return result
  17611. }
  17612. },
  17613. {
  17614. key: 'paintOnSvg',
  17615. value: function paintOnSvg(wrapper) {
  17616. var _this2 = this;
  17617. var cancelled = false;
  17618. var ensureNotCancelled = function ensureNotCancelled() {
  17619. if (cancelled) {
  17620. if (_pdfjsLib.PDFJS.pdfjsNext) {
  17621. throw new _pdfjsLib.RenderingCancelledException('Rendering cancelled, page ' + _this2.id, 'svg');
  17622. } else {
  17623. throw 'cancelled';
  17624. }
  17625. }
  17626. };
  17627. var pdfPage = this.pdfPage;
  17628. var actualSizeViewport = this.viewport.clone({
  17629. scale: _ui_utils.CSS_UNITS
  17630. });
  17631. var promise = pdfPage.getOperatorList().then(function(opList) {
  17632. ensureNotCancelled();
  17633. var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
  17634. return svgGfx.getSVG(opList, actualSizeViewport).then(function(svg) {
  17635. ensureNotCancelled();
  17636. _this2.svg = svg;
  17637. _this2.paintedViewportMap.set(svg, actualSizeViewport);
  17638. svg.style.width = wrapper.style.width;
  17639. svg.style.height = wrapper.style.height;
  17640. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  17641. wrapper.appendChild(svg)
  17642. })
  17643. });
  17644. return {
  17645. promise: promise,
  17646. onRenderContinue: function onRenderContinue(cont) {
  17647. cont()
  17648. },
  17649. cancel: function cancel() {
  17650. cancelled = true
  17651. }
  17652. }
  17653. }
  17654. },
  17655. {
  17656. key: 'setPageLabel',
  17657. value: function setPageLabel(label) {
  17658. this.pageLabel = typeof label === 'string' ? label: null;
  17659. if (this.pageLabel !== null) {
  17660. this.div.setAttribute('data-page-label', this.pageLabel)
  17661. } else {
  17662. this.div.removeAttribute('data-page-label')
  17663. }
  17664. }
  17665. },
  17666. {
  17667. key: 'width',
  17668. get: function get() {
  17669. return this.viewport.width
  17670. }
  17671. },
  17672. {
  17673. key: 'height',
  17674. get: function get() {
  17675. return this.viewport.height
  17676. }
  17677. }]);
  17678. return PDFPageView
  17679. } ();
  17680. exports.PDFPageView = PDFPageView
  17681. }), (function(module, exports, __webpack_require__) {
  17682. "use strict";
  17683. Object.defineProperty(exports, "__esModule", {
  17684. value: true
  17685. });
  17686. exports.PDFPresentationMode = undefined;
  17687. var _createClass = function() {
  17688. function defineProperties(target, props) {
  17689. for (var i = 0; i < props.length; i++) {
  17690. var descriptor = props[i];
  17691. descriptor.enumerable = descriptor.enumerable || false;
  17692. descriptor.configurable = true;
  17693. if ("value" in descriptor) descriptor.writable = true;
  17694. Object.defineProperty(target, descriptor.key, descriptor)
  17695. }
  17696. }
  17697. return function(Constructor, protoProps, staticProps) {
  17698. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  17699. if (staticProps) defineProperties(Constructor, staticProps);
  17700. return Constructor
  17701. }
  17702. } ();
  17703. var _ui_utils = __webpack_require__(0);
  17704. function _classCallCheck(instance, Constructor) {
  17705. if (! (instance instanceof Constructor)) {
  17706. throw new TypeError("Cannot call a class as a function");
  17707. }
  17708. }
  17709. var DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1500;
  17710. var DELAY_BEFORE_HIDING_CONTROLS = 3000;
  17711. var ACTIVE_SELECTOR = 'pdfPresentationMode';
  17712. var CONTROLS_SELECTOR = 'pdfPresentationModeControls';
  17713. var MOUSE_SCROLL_COOLDOWN_TIME = 50;
  17714. var PAGE_SWITCH_THRESHOLD = 0.1;
  17715. var SWIPE_MIN_DISTANCE_THRESHOLD = 50;
  17716. var SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
  17717. var PDFPresentationMode = function() {
  17718. function PDFPresentationMode(_ref) {
  17719. var _this = this;
  17720. var container = _ref.container,
  17721. _ref$viewer = _ref.viewer,
  17722. viewer = _ref$viewer === undefined ? null: _ref$viewer,
  17723. pdfViewer = _ref.pdfViewer,
  17724. eventBus = _ref.eventBus,
  17725. _ref$contextMenuItems = _ref.contextMenuItems,
  17726. contextMenuItems = _ref$contextMenuItems === undefined ? null: _ref$contextMenuItems;
  17727. _classCallCheck(this, PDFPresentationMode);
  17728. this.container = container;
  17729. this.viewer = viewer || container.firstElementChild;
  17730. this.pdfViewer = pdfViewer;
  17731. this.eventBus = eventBus;
  17732. this.active = false;
  17733. this.args = null;
  17734. this.contextMenuOpen = false;
  17735. this.mouseScrollTimeStamp = 0;
  17736. this.mouseScrollDelta = 0;
  17737. this.touchSwipeState = null;
  17738. if (contextMenuItems) {
  17739. contextMenuItems.contextFirstPage.addEventListener('click',
  17740. function() {
  17741. _this.contextMenuOpen = false;
  17742. _this.eventBus.dispatch('firstpage')
  17743. });
  17744. contextMenuItems.contextLastPage.addEventListener('click',
  17745. function() {
  17746. _this.contextMenuOpen = false;
  17747. _this.eventBus.dispatch('lastpage')
  17748. });
  17749. contextMenuItems.contextPageRotateCw.addEventListener('click',
  17750. function() {
  17751. _this.contextMenuOpen = false;
  17752. _this.eventBus.dispatch('rotatecw')
  17753. });
  17754. contextMenuItems.contextPageRotateCcw.addEventListener('click',
  17755. function() {
  17756. _this.contextMenuOpen = false;
  17757. _this.eventBus.dispatch('rotateccw')
  17758. })
  17759. }
  17760. }
  17761. _createClass(PDFPresentationMode, [{
  17762. key: 'request',
  17763. value: function request() {
  17764. if (this.switchInProgress || this.active || !this.viewer.hasChildNodes()) {
  17765. return false
  17766. }
  17767. this._addFullscreenChangeListeners();
  17768. this._setSwitchInProgress();
  17769. this._notifyStateChange();
  17770. if (this.container.requestFullscreen) {
  17771. this.container.requestFullscreen()
  17772. } else if (this.container.mozRequestFullScreen) {
  17773. this.container.mozRequestFullScreen()
  17774. } else if (this.container.webkitRequestFullscreen) {
  17775. this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT)
  17776. } else if (this.container.msRequestFullscreen) {
  17777. this.container.msRequestFullscreen()
  17778. } else {
  17779. return false
  17780. }
  17781. this.args = {
  17782. page: this.pdfViewer.currentPageNumber,
  17783. previousScale: this.pdfViewer.currentScaleValue
  17784. };
  17785. return true
  17786. }
  17787. },
  17788. {
  17789. key: '_mouseWheel',
  17790. value: function _mouseWheel(evt) {
  17791. if (!this.active) {
  17792. return
  17793. }
  17794. evt.preventDefault();
  17795. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  17796. var currentTime = new Date().getTime();
  17797. var storedTime = this.mouseScrollTimeStamp;
  17798. if (currentTime > storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {
  17799. return
  17800. }
  17801. if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) {
  17802. this._resetMouseScrollState()
  17803. }
  17804. this.mouseScrollDelta += delta;
  17805. if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
  17806. var totalDelta = this.mouseScrollDelta;
  17807. this._resetMouseScrollState();
  17808. var success = totalDelta > 0 ? this._goToPreviousPage() : this._goToNextPage();
  17809. if (success) {
  17810. this.mouseScrollTimeStamp = currentTime
  17811. }
  17812. }
  17813. }
  17814. },
  17815. {
  17816. key: '_goToPreviousPage',
  17817. value: function _goToPreviousPage() {
  17818. var page = this.pdfViewer.currentPageNumber;
  17819. if (page <= 1) {
  17820. return false
  17821. }
  17822. this.pdfViewer.currentPageNumber = page - 1;
  17823. return true
  17824. }
  17825. },
  17826. {
  17827. key: '_goToNextPage',
  17828. value: function _goToNextPage() {
  17829. var page = this.pdfViewer.currentPageNumber;
  17830. if (page >= this.pdfViewer.pagesCount) {
  17831. return false
  17832. }
  17833. this.pdfViewer.currentPageNumber = page + 1;
  17834. return true
  17835. }
  17836. },
  17837. {
  17838. key: '_notifyStateChange',
  17839. value: function _notifyStateChange() {
  17840. this.eventBus.dispatch('presentationmodechanged', {
  17841. source: this,
  17842. active: this.active,
  17843. switchInProgress: !!this.switchInProgress
  17844. })
  17845. }
  17846. },
  17847. {
  17848. key: '_setSwitchInProgress',
  17849. value: function _setSwitchInProgress() {
  17850. var _this2 = this;
  17851. if (this.switchInProgress) {
  17852. clearTimeout(this.switchInProgress)
  17853. }
  17854. this.switchInProgress = setTimeout(function() {
  17855. _this2._removeFullscreenChangeListeners();
  17856. delete _this2.switchInProgress;
  17857. _this2._notifyStateChange()
  17858. },
  17859. DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS)
  17860. }
  17861. },
  17862. {
  17863. key: '_resetSwitchInProgress',
  17864. value: function _resetSwitchInProgress() {
  17865. if (this.switchInProgress) {
  17866. clearTimeout(this.switchInProgress);
  17867. delete this.switchInProgress
  17868. }
  17869. }
  17870. },
  17871. {
  17872. key: '_enter',
  17873. value: function _enter() {
  17874. var _this3 = this;
  17875. this.active = true;
  17876. this._resetSwitchInProgress();
  17877. this._notifyStateChange();
  17878. this.container.classList.add(ACTIVE_SELECTOR);
  17879. setTimeout(function() {
  17880. _this3.pdfViewer.currentPageNumber = _this3.args.page;
  17881. _this3.pdfViewer.currentScaleValue = 'page-fit'
  17882. },
  17883. 0);
  17884. this._addWindowListeners();
  17885. this._showControls();
  17886. this.contextMenuOpen = false;
  17887. this.container.setAttribute('contextmenu', 'viewerContextMenu');
  17888. window.getSelection().removeAllRanges()
  17889. }
  17890. },
  17891. {
  17892. key: '_exit',
  17893. value: function _exit() {
  17894. var _this4 = this;
  17895. var page = this.pdfViewer.currentPageNumber;
  17896. this.container.classList.remove(ACTIVE_SELECTOR);
  17897. setTimeout(function() {
  17898. _this4.active = false;
  17899. _this4._removeFullscreenChangeListeners();
  17900. _this4._notifyStateChange();
  17901. _this4.pdfViewer.currentScaleValue = _this4.args.previousScale;
  17902. _this4.pdfViewer.currentPageNumber = page;
  17903. _this4.args = null
  17904. },
  17905. 0);
  17906. this._removeWindowListeners();
  17907. this._hideControls();
  17908. this._resetMouseScrollState();
  17909. this.container.removeAttribute('contextmenu');
  17910. this.contextMenuOpen = false
  17911. }
  17912. },
  17913. {
  17914. key: '_mouseDown',
  17915. value: function _mouseDown(evt) {
  17916. if (this.contextMenuOpen) {
  17917. this.contextMenuOpen = false;
  17918. evt.preventDefault();
  17919. return
  17920. }
  17921. if (evt.button === 0) {
  17922. var isInternalLink = evt.target.href && evt.target.classList.contains('internalLink');
  17923. if (!isInternalLink) {
  17924. evt.preventDefault();
  17925. if (evt.shiftKey) {
  17926. this._goToPreviousPage()
  17927. } else {
  17928. this._goToNextPage()
  17929. }
  17930. }
  17931. }
  17932. }
  17933. },
  17934. {
  17935. key: '_contextMenu',
  17936. value: function _contextMenu() {
  17937. this.contextMenuOpen = true
  17938. }
  17939. },
  17940. {
  17941. key: '_showControls',
  17942. value: function _showControls() {
  17943. var _this5 = this;
  17944. if (this.controlsTimeout) {
  17945. clearTimeout(this.controlsTimeout)
  17946. } else {
  17947. this.container.classList.add(CONTROLS_SELECTOR)
  17948. }
  17949. this.controlsTimeout = setTimeout(function() {
  17950. _this5.container.classList.remove(CONTROLS_SELECTOR);
  17951. delete _this5.controlsTimeout
  17952. },
  17953. DELAY_BEFORE_HIDING_CONTROLS)
  17954. }
  17955. },
  17956. {
  17957. key: '_hideControls',
  17958. value: function _hideControls() {
  17959. if (!this.controlsTimeout) {
  17960. return
  17961. }
  17962. clearTimeout(this.controlsTimeout);
  17963. this.container.classList.remove(CONTROLS_SELECTOR);
  17964. delete this.controlsTimeout
  17965. }
  17966. },
  17967. {
  17968. key: '_resetMouseScrollState',
  17969. value: function _resetMouseScrollState() {
  17970. this.mouseScrollTimeStamp = 0;
  17971. this.mouseScrollDelta = 0
  17972. }
  17973. },
  17974. {
  17975. key: '_touchSwipe',
  17976. value: function _touchSwipe(evt) {
  17977. if (!this.active) {
  17978. return
  17979. }
  17980. if (evt.touches.length > 1) {
  17981. this.touchSwipeState = null;
  17982. return
  17983. }
  17984. switch (evt.type) {
  17985. case 'touchstart':
  17986. this.touchSwipeState = {
  17987. startX: evt.touches[0].pageX,
  17988. startY: evt.touches[0].pageY,
  17989. endX: evt.touches[0].pageX,
  17990. endY: evt.touches[0].pageY
  17991. };
  17992. break;
  17993. case 'touchmove':
  17994. if (this.touchSwipeState === null) {
  17995. return
  17996. }
  17997. this.touchSwipeState.endX = evt.touches[0].pageX;
  17998. this.touchSwipeState.endY = evt.touches[0].pageY;
  17999. evt.preventDefault();
  18000. break;
  18001. case 'touchend':
  18002. if (this.touchSwipeState === null) {
  18003. return
  18004. }
  18005. var delta = 0;
  18006. var dx = this.touchSwipeState.endX - this.touchSwipeState.startX;
  18007. var dy = this.touchSwipeState.endY - this.touchSwipeState.startY;
  18008. var absAngle = Math.abs(Math.atan2(dy, dx));
  18009. if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <= SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI - SWIPE_ANGLE_THRESHOLD)) {
  18010. delta = dx
  18011. } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math.abs(absAngle - Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) {
  18012. delta = dy
  18013. }
  18014. if (delta > 0) {
  18015. this._goToPreviousPage()
  18016. } else if (delta < 0) {
  18017. this._goToNextPage()
  18018. }
  18019. break
  18020. }
  18021. }
  18022. },
  18023. {
  18024. key: '_addWindowListeners',
  18025. value: function _addWindowListeners() {
  18026. this.showControlsBind = this._showControls.bind(this);
  18027. this.mouseDownBind = this._mouseDown.bind(this);
  18028. this.mouseWheelBind = this._mouseWheel.bind(this);
  18029. this.resetMouseScrollStateBind = this._resetMouseScrollState.bind(this);
  18030. this.contextMenuBind = this._contextMenu.bind(this);
  18031. this.touchSwipeBind = this._touchSwipe.bind(this);
  18032. window.addEventListener('mousemove', this.showControlsBind);
  18033. window.addEventListener('mousedown', this.mouseDownBind);
  18034. window.addEventListener('wheel', this.mouseWheelBind);
  18035. window.addEventListener('keydown', this.resetMouseScrollStateBind);
  18036. window.addEventListener('contextmenu', this.contextMenuBind);
  18037. window.addEventListener('touchstart', this.touchSwipeBind);
  18038. window.addEventListener('touchmove', this.touchSwipeBind);
  18039. window.addEventListener('touchend', this.touchSwipeBind)
  18040. }
  18041. },
  18042. {
  18043. key: '_removeWindowListeners',
  18044. value: function _removeWindowListeners() {
  18045. window.removeEventListener('mousemove', this.showControlsBind);
  18046. window.removeEventListener('mousedown', this.mouseDownBind);
  18047. window.removeEventListener('wheel', this.mouseWheelBind);
  18048. window.removeEventListener('keydown', this.resetMouseScrollStateBind);
  18049. window.removeEventListener('contextmenu', this.contextMenuBind);
  18050. window.removeEventListener('touchstart', this.touchSwipeBind);
  18051. window.removeEventListener('touchmove', this.touchSwipeBind);
  18052. window.removeEventListener('touchend', this.touchSwipeBind);
  18053. delete this.showControlsBind;
  18054. delete this.mouseDownBind;
  18055. delete this.mouseWheelBind;
  18056. delete this.resetMouseScrollStateBind;
  18057. delete this.contextMenuBind;
  18058. delete this.touchSwipeBind
  18059. }
  18060. },
  18061. {
  18062. key: '_fullscreenChange',
  18063. value: function _fullscreenChange() {
  18064. if (this.isFullscreen) {
  18065. this._enter()
  18066. } else {
  18067. this._exit()
  18068. }
  18069. }
  18070. },
  18071. {
  18072. key: '_addFullscreenChangeListeners',
  18073. value: function _addFullscreenChangeListeners() {
  18074. this.fullscreenChangeBind = this._fullscreenChange.bind(this);
  18075. window.addEventListener('fullscreenchange', this.fullscreenChangeBind);
  18076. window.addEventListener('mozfullscreenchange', this.fullscreenChangeBind);
  18077. window.addEventListener('webkitfullscreenchange', this.fullscreenChangeBind);
  18078. window.addEventListener('MSFullscreenChange', this.fullscreenChangeBind)
  18079. }
  18080. },
  18081. {
  18082. key: '_removeFullscreenChangeListeners',
  18083. value: function _removeFullscreenChangeListeners() {
  18084. window.removeEventListener('fullscreenchange', this.fullscreenChangeBind);
  18085. window.removeEventListener('mozfullscreenchange', this.fullscreenChangeBind);
  18086. window.removeEventListener('webkitfullscreenchange', this.fullscreenChangeBind);
  18087. window.removeEventListener('MSFullscreenChange', this.fullscreenChangeBind);
  18088. delete this.fullscreenChangeBind
  18089. }
  18090. },
  18091. {
  18092. key: 'isFullscreen',
  18093. get: function get() {
  18094. return !! (document.fullscreenElement || document.mozFullScreen || document.webkitIsFullScreen || document.msFullscreenElement)
  18095. }
  18096. }]);
  18097. return PDFPresentationMode
  18098. } ();
  18099. exports.PDFPresentationMode = PDFPresentationMode
  18100. }), (function(module, exports, __webpack_require__) {
  18101. "use strict";
  18102. Object.defineProperty(exports, "__esModule", {
  18103. value: true
  18104. });
  18105. exports.PDFSidebar = exports.SidebarView = undefined;
  18106. var _createClass = function() {
  18107. function defineProperties(target, props) {
  18108. for (var i = 0; i < props.length; i++) {
  18109. var descriptor = props[i];
  18110. descriptor.enumerable = descriptor.enumerable || false;
  18111. descriptor.configurable = true;
  18112. if ("value" in descriptor) descriptor.writable = true;
  18113. Object.defineProperty(target, descriptor.key, descriptor)
  18114. }
  18115. }
  18116. return function(Constructor, protoProps, staticProps) {
  18117. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  18118. if (staticProps) defineProperties(Constructor, staticProps);
  18119. return Constructor
  18120. }
  18121. } ();
  18122. var _ui_utils = __webpack_require__(0);
  18123. var _pdf_rendering_queue = __webpack_require__(3);
  18124. function _classCallCheck(instance, Constructor) {
  18125. if (! (instance instanceof Constructor)) {
  18126. throw new TypeError("Cannot call a class as a function");
  18127. }
  18128. }
  18129. var UI_NOTIFICATION_CLASS = 'pdfSidebarNotification';
  18130. var SidebarView = {
  18131. NONE: 0,
  18132. THUMBS: 1,
  18133. OUTLINE: 2,
  18134. ATTACHMENTS: 3
  18135. };
  18136. var PDFSidebar = function() {
  18137. function PDFSidebar(options) {
  18138. var l10n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _ui_utils.NullL10n;
  18139. _classCallCheck(this, PDFSidebar);
  18140. this.isOpen = false;
  18141. this.active = SidebarView.THUMBS;
  18142. this.isInitialViewSet = false;
  18143. this.onToggled = null;
  18144. this.pdfViewer = options.pdfViewer;
  18145. this.pdfThumbnailViewer = options.pdfThumbnailViewer;
  18146. this.pdfOutlineViewer = options.pdfOutlineViewer;
  18147. this.mainContainer = options.mainContainer;
  18148. this.outerContainer = options.outerContainer;
  18149. this.eventBus = options.eventBus;
  18150. this.toggleButton = options.toggleButton;
  18151. this.thumbnailButton = options.thumbnailButton;
  18152. this.outlineButton = options.outlineButton;
  18153. this.attachmentsButton = options.attachmentsButton;
  18154. this.thumbnailView = options.thumbnailView;
  18155. this.outlineView = options.outlineView;
  18156. this.attachmentsView = options.attachmentsView;
  18157. this.disableNotification = options.disableNotification || false;
  18158. this.l10n = l10n;
  18159. this._addEventListeners()
  18160. }
  18161. _createClass(PDFSidebar, [{
  18162. key: 'reset',
  18163. value: function reset() {
  18164. this.isInitialViewSet = false;
  18165. this._hideUINotification(null);
  18166. this.switchView(SidebarView.THUMBS);
  18167. this.outlineButton.disabled = false;
  18168. this.attachmentsButton.disabled = false
  18169. }
  18170. },
  18171. {
  18172. key: 'setInitialView',
  18173. value: function setInitialView(view) {
  18174. if (this.isInitialViewSet) {
  18175. return
  18176. }
  18177. this.isInitialViewSet = true;
  18178. if (this.isOpen && view === SidebarView.NONE) {
  18179. this._dispatchEvent();
  18180. return
  18181. }
  18182. var isViewPreserved = view === this.visibleView;
  18183. this.switchView(view, true);
  18184. if (isViewPreserved) {
  18185. this._dispatchEvent()
  18186. }
  18187. }
  18188. },
  18189. {
  18190. key: 'switchView',
  18191. value: function switchView(view) {
  18192. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  18193. if (view === SidebarView.NONE) {
  18194. this.close();
  18195. return
  18196. }
  18197. var isViewChanged = view !== this.active;
  18198. var shouldForceRendering = false;
  18199. switch (view) {
  18200. case SidebarView.THUMBS:
  18201. this.thumbnailButton.classList.add('toggled');
  18202. this.outlineButton.classList.remove('toggled');
  18203. this.attachmentsButton.classList.remove('toggled');
  18204. this.thumbnailView.classList.remove('hidden');
  18205. this.outlineView.classList.add('hidden');
  18206. this.attachmentsView.classList.add('hidden');
  18207. if (this.isOpen && isViewChanged) {
  18208. this._updateThumbnailViewer();
  18209. shouldForceRendering = true
  18210. }
  18211. break;
  18212. case SidebarView.OUTLINE:
  18213. if (this.outlineButton.disabled) {
  18214. return
  18215. }
  18216. this.thumbnailButton.classList.remove('toggled');
  18217. this.outlineButton.classList.add('toggled');
  18218. this.attachmentsButton.classList.remove('toggled');
  18219. this.thumbnailView.classList.add('hidden');
  18220. this.outlineView.classList.remove('hidden');
  18221. this.attachmentsView.classList.add('hidden');
  18222. break;
  18223. case SidebarView.ATTACHMENTS:
  18224. if (this.attachmentsButton.disabled) {
  18225. return
  18226. }
  18227. this.thumbnailButton.classList.remove('toggled');
  18228. this.outlineButton.classList.remove('toggled');
  18229. this.attachmentsButton.classList.add('toggled');
  18230. this.thumbnailView.classList.add('hidden');
  18231. this.outlineView.classList.add('hidden');
  18232. this.attachmentsView.classList.remove('hidden');
  18233. break;
  18234. default:
  18235. console.error('PDFSidebar_switchView: "' + view + '" is an unsupported value.');
  18236. return
  18237. }
  18238. this.active = view | 0;
  18239. if (forceOpen && !this.isOpen) {
  18240. this.open();
  18241. return
  18242. }
  18243. if (shouldForceRendering) {
  18244. this._forceRendering()
  18245. }
  18246. if (isViewChanged) {
  18247. this._dispatchEvent()
  18248. }
  18249. this._hideUINotification(this.active)
  18250. }
  18251. },
  18252. {
  18253. key: 'open',
  18254. value: function open() {
  18255. if (this.isOpen) {
  18256. return
  18257. }
  18258. this.isOpen = true;
  18259. this.toggleButton.classList.add('toggled');
  18260. this.outerContainer.classList.add('sidebarMoving');
  18261. this.outerContainer.classList.add('sidebarOpen');
  18262. if (this.active === SidebarView.THUMBS) {
  18263. this._updateThumbnailViewer()
  18264. }
  18265. this._forceRendering();
  18266. this._dispatchEvent();
  18267. this._hideUINotification(this.active)
  18268. }
  18269. },
  18270. {
  18271. key: 'close',
  18272. value: function close() {
  18273. if (!this.isOpen) {
  18274. return
  18275. }
  18276. this.isOpen = false;
  18277. this.toggleButton.classList.remove('toggled');
  18278. this.outerContainer.classList.add('sidebarMoving');
  18279. this.outerContainer.classList.remove('sidebarOpen');
  18280. this._forceRendering();
  18281. this._dispatchEvent()
  18282. }
  18283. },
  18284. {
  18285. key: 'toggle',
  18286. value: function toggle() {
  18287. if (this.isOpen) {
  18288. this.close()
  18289. } else {
  18290. this.open()
  18291. }
  18292. }
  18293. },
  18294. {
  18295. key: '_dispatchEvent',
  18296. value: function _dispatchEvent() {
  18297. this.eventBus.dispatch('sidebarviewchanged', {
  18298. source: this,
  18299. view: this.visibleView
  18300. })
  18301. }
  18302. },
  18303. {
  18304. key: '_forceRendering',
  18305. value: function _forceRendering() {
  18306. if (this.onToggled) {
  18307. this.onToggled()
  18308. } else {
  18309. this.pdfViewer.forceRendering();
  18310. this.pdfThumbnailViewer.forceRendering()
  18311. }
  18312. }
  18313. },
  18314. {
  18315. key: '_updateThumbnailViewer',
  18316. value: function _updateThumbnailViewer() {
  18317. var pdfViewer = this.pdfViewer,
  18318. pdfThumbnailViewer = this.pdfThumbnailViewer;
  18319. var pagesCount = pdfViewer.pagesCount;
  18320. for (var pageIndex = 0; pageIndex < pagesCount; pageIndex++) {
  18321. var pageView = pdfViewer.getPageView(pageIndex);
  18322. if (pageView && pageView.renderingState === _pdf_rendering_queue.RenderingStates.FINISHED) {
  18323. var thumbnailView = pdfThumbnailViewer.getThumbnail(pageIndex);
  18324. thumbnailView.setImage(pageView)
  18325. }
  18326. }
  18327. pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber)
  18328. }
  18329. },
  18330. {
  18331. key: '_showUINotification',
  18332. value: function _showUINotification(view) {
  18333. var _this = this;
  18334. if (this.disableNotification) {
  18335. return
  18336. }
  18337. this.l10n.get('toggle_sidebar_notification.title', null, 'Toggle Sidebar (document contains outline/attachments)').then(function(msg) {
  18338. _this.toggleButton.title = msg
  18339. });
  18340. if (!this.isOpen) {
  18341. this.toggleButton.classList.add(UI_NOTIFICATION_CLASS)
  18342. } else if (view === this.active) {
  18343. return
  18344. }
  18345. switch (view) {
  18346. case SidebarView.OUTLINE:
  18347. this.outlineButton.classList.add(UI_NOTIFICATION_CLASS);
  18348. break;
  18349. case SidebarView.ATTACHMENTS:
  18350. this.attachmentsButton.classList.add(UI_NOTIFICATION_CLASS);
  18351. break
  18352. }
  18353. }
  18354. },
  18355. {
  18356. key: '_hideUINotification',
  18357. value: function _hideUINotification(view) {
  18358. var _this2 = this;
  18359. if (this.disableNotification) {
  18360. return
  18361. }
  18362. var removeNotification = function removeNotification(view) {
  18363. switch (view) {
  18364. case SidebarView.OUTLINE:
  18365. _this2.outlineButton.classList.remove(UI_NOTIFICATION_CLASS);
  18366. break;
  18367. case SidebarView.ATTACHMENTS:
  18368. _this2.attachmentsButton.classList.remove(UI_NOTIFICATION_CLASS);
  18369. break
  18370. }
  18371. };
  18372. if (!this.isOpen && view !== null) {
  18373. return
  18374. }
  18375. this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
  18376. if (view !== null) {
  18377. removeNotification(view);
  18378. return
  18379. }
  18380. for (view in SidebarView) {
  18381. removeNotification(SidebarView[view])
  18382. }
  18383. this.l10n.get('toggle_sidebar.title', null, 'Toggle Sidebar').then(function(msg) {
  18384. _this2.toggleButton.title = msg
  18385. })
  18386. }
  18387. },
  18388. {
  18389. key: '_addEventListeners',
  18390. value: function _addEventListeners() {
  18391. var _this3 = this;
  18392. this.mainContainer.addEventListener('transitionend',
  18393. function(evt) {
  18394. if (evt.target === _this3.mainContainer) {
  18395. _this3.outerContainer.classList.remove('sidebarMoving')
  18396. }
  18397. });
  18398. this.thumbnailButton.addEventListener('click',
  18399. function() {
  18400. _this3.switchView(SidebarView.THUMBS)
  18401. });
  18402. this.outlineButton.addEventListener('click',
  18403. function() {
  18404. _this3.switchView(SidebarView.OUTLINE)
  18405. });
  18406. this.outlineButton.addEventListener('dblclick',
  18407. function() {
  18408. _this3.pdfOutlineViewer.toggleOutlineTree()
  18409. });
  18410. this.attachmentsButton.addEventListener('click',
  18411. function() {
  18412. _this3.switchView(SidebarView.ATTACHMENTS)
  18413. });
  18414. this.eventBus.on('outlineloaded',
  18415. function(evt) {
  18416. var outlineCount = evt.outlineCount;
  18417. _this3.outlineButton.disabled = !outlineCount;
  18418. if (outlineCount) {
  18419. _this3._showUINotification(SidebarView.OUTLINE)
  18420. } else if (_this3.active === SidebarView.OUTLINE) {
  18421. _this3.switchView(SidebarView.THUMBS)
  18422. }
  18423. });
  18424. this.eventBus.on('attachmentsloaded',
  18425. function(evt) {
  18426. var attachmentsCount = evt.attachmentsCount;
  18427. _this3.attachmentsButton.disabled = !attachmentsCount;
  18428. if (attachmentsCount) {
  18429. _this3._showUINotification(SidebarView.ATTACHMENTS)
  18430. } else if (_this3.active === SidebarView.ATTACHMENTS) {
  18431. _this3.switchView(SidebarView.THUMBS)
  18432. }
  18433. });
  18434. this.eventBus.on('presentationmodechanged',
  18435. function(evt) {
  18436. if (!evt.active && !evt.switchInProgress && _this3.isThumbnailViewVisible) {
  18437. _this3._updateThumbnailViewer()
  18438. }
  18439. })
  18440. }
  18441. },
  18442. {
  18443. key: 'visibleView',
  18444. get: function get() {
  18445. return this.isOpen ? this.active: SidebarView.NONE
  18446. }
  18447. },
  18448. {
  18449. key: 'isThumbnailViewVisible',
  18450. get: function get() {
  18451. return this.isOpen && this.active === SidebarView.THUMBS
  18452. }
  18453. },
  18454. {
  18455. key: 'isOutlineViewVisible',
  18456. get: function get() {
  18457. return this.isOpen && this.active === SidebarView.OUTLINE
  18458. }
  18459. },
  18460. {
  18461. key: 'isAttachmentsViewVisible',
  18462. get: function get() {
  18463. return this.isOpen && this.active === SidebarView.ATTACHMENTS
  18464. }
  18465. }]);
  18466. return PDFSidebar
  18467. } ();
  18468. exports.SidebarView = SidebarView;
  18469. exports.PDFSidebar = PDFSidebar
  18470. }), (function(module, exports, __webpack_require__) {
  18471. "use strict";
  18472. Object.defineProperty(exports, "__esModule", {
  18473. value: true
  18474. });
  18475. exports.PDFThumbnailView = undefined;
  18476. var _createClass = function() {
  18477. function defineProperties(target, props) {
  18478. for (var i = 0; i < props.length; i++) {
  18479. var descriptor = props[i];
  18480. descriptor.enumerable = descriptor.enumerable || false;
  18481. descriptor.configurable = true;
  18482. if ("value" in descriptor) descriptor.writable = true;
  18483. Object.defineProperty(target, descriptor.key, descriptor)
  18484. }
  18485. }
  18486. return function(Constructor, protoProps, staticProps) {
  18487. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  18488. if (staticProps) defineProperties(Constructor, staticProps);
  18489. return Constructor
  18490. }
  18491. } ();
  18492. var _pdfjsLib = __webpack_require__(1);
  18493. var _ui_utils = __webpack_require__(0);
  18494. var _pdf_rendering_queue = __webpack_require__(3);
  18495. function _classCallCheck(instance, Constructor) {
  18496. if (! (instance instanceof Constructor)) {
  18497. throw new TypeError("Cannot call a class as a function");
  18498. }
  18499. }
  18500. var MAX_NUM_SCALING_STEPS = 3;
  18501. var THUMBNAIL_CANVAS_BORDER_WIDTH = 1;
  18502. var THUMBNAIL_WIDTH = 98;
  18503. var TempImageFactory = function TempImageFactoryClosure() {
  18504. var tempCanvasCache = null;
  18505. return {
  18506. getCanvas: function getCanvas(width, height) {
  18507. var tempCanvas = tempCanvasCache;
  18508. if (!tempCanvas) {
  18509. tempCanvas = document.createElement('canvas');
  18510. tempCanvasCache = tempCanvas
  18511. }
  18512. tempCanvas.width = width;
  18513. tempCanvas.height = height;
  18514. tempCanvas.mozOpaque = true;
  18515. var ctx = tempCanvas.getContext('2d', {
  18516. alpha: false
  18517. });
  18518. ctx.save();
  18519. ctx.fillStyle = 'rgb(255, 255, 255)';
  18520. ctx.fillRect(0, 0, width, height);
  18521. ctx.restore();
  18522. return tempCanvas
  18523. },
  18524. destroyCanvas: function destroyCanvas() {
  18525. var tempCanvas = tempCanvasCache;
  18526. if (tempCanvas) {
  18527. tempCanvas.width = 0;
  18528. tempCanvas.height = 0
  18529. }
  18530. tempCanvasCache = null
  18531. }
  18532. }
  18533. } ();
  18534. var PDFThumbnailView = function() {
  18535. function PDFThumbnailView(_ref) {
  18536. var container = _ref.container,
  18537. id = _ref.id,
  18538. defaultViewport = _ref.defaultViewport,
  18539. linkService = _ref.linkService,
  18540. renderingQueue = _ref.renderingQueue,
  18541. _ref$disableCanvasToI = _ref.disableCanvasToImageConversion,
  18542. disableCanvasToImageConversion = _ref$disableCanvasToI === undefined ? false: _ref$disableCanvasToI,
  18543. _ref$l10n = _ref.l10n,
  18544. l10n = _ref$l10n === undefined ? _ui_utils.NullL10n: _ref$l10n;
  18545. _classCallCheck(this, PDFThumbnailView);
  18546. this.id = id;
  18547. this.renderingId = 'thumbnail' + id;
  18548. this.pageLabel = null;
  18549. this.pdfPage = null;
  18550. this.rotation = 0;
  18551. this.viewport = defaultViewport;
  18552. this.pdfPageRotate = defaultViewport.rotation;
  18553. this.linkService = linkService;
  18554. this.renderingQueue = renderingQueue;
  18555. this.renderTask = null;
  18556. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  18557. this.resume = null;
  18558. this.disableCanvasToImageConversion = disableCanvasToImageConversion;
  18559. this.pageWidth = this.viewport.width;
  18560. this.pageHeight = this.viewport.height;
  18561. this.pageRatio = this.pageWidth / this.pageHeight;
  18562. this.canvasWidth = THUMBNAIL_WIDTH;
  18563. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  18564. this.scale = this.canvasWidth / this.pageWidth;
  18565. this.l10n = l10n;
  18566. var anchor = document.createElement('a');
  18567. anchor.href = linkService.getAnchorUrl('#page=' + id);
  18568. this.l10n.get('thumb_page_title', {
  18569. page: id
  18570. },
  18571. 'Page {{page}}').then(function(msg) {
  18572. anchor.title = msg
  18573. });
  18574. anchor.onclick = function() {
  18575. linkService.page = id;
  18576. return false
  18577. };
  18578. this.anchor = anchor;
  18579. var div = document.createElement('div');
  18580. div.className = 'thumbnail';
  18581. div.setAttribute('data-page-number', this.id);
  18582. this.div = div;
  18583. if (id === 1) {
  18584. div.classList.add('selected')
  18585. }
  18586. var ring = document.createElement('div');
  18587. ring.className = 'thumbnailSelectionRing';
  18588. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  18589. ring.style.width = this.canvasWidth + borderAdjustment + 'px';
  18590. ring.style.height = this.canvasHeight + borderAdjustment + 'px';
  18591. this.ring = ring;
  18592. div.appendChild(ring);
  18593. anchor.appendChild(div);
  18594. container.appendChild(anchor)
  18595. }
  18596. _createClass(PDFThumbnailView, [{
  18597. key: 'setPdfPage',
  18598. value: function setPdfPage(pdfPage) {
  18599. this.pdfPage = pdfPage;
  18600. this.pdfPageRotate = pdfPage.rotate;
  18601. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  18602. this.viewport = pdfPage.getViewport(1, totalRotation);
  18603. this.reset()
  18604. }
  18605. },
  18606. {
  18607. key: 'reset',
  18608. value: function reset() {
  18609. this.cancelRendering();
  18610. this.pageWidth = this.viewport.width;
  18611. this.pageHeight = this.viewport.height;
  18612. this.pageRatio = this.pageWidth / this.pageHeight;
  18613. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  18614. this.scale = this.canvasWidth / this.pageWidth;
  18615. this.div.removeAttribute('data-loaded');
  18616. var ring = this.ring;
  18617. var childNodes = ring.childNodes;
  18618. for (var i = childNodes.length - 1; i >= 0; i--) {
  18619. ring.removeChild(childNodes[i])
  18620. }
  18621. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  18622. ring.style.width = this.canvasWidth + borderAdjustment + 'px';
  18623. ring.style.height = this.canvasHeight + borderAdjustment + 'px';
  18624. if (this.canvas) {
  18625. this.canvas.width = 0;
  18626. this.canvas.height = 0;
  18627. delete this.canvas
  18628. }
  18629. if (this.image) {
  18630. this.image.removeAttribute('src');
  18631. delete this.image
  18632. }
  18633. }
  18634. },
  18635. {
  18636. key: 'update',
  18637. value: function update(rotation) {
  18638. if (typeof rotation !== 'undefined') {
  18639. this.rotation = rotation
  18640. }
  18641. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  18642. this.viewport = this.viewport.clone({
  18643. scale: 1,
  18644. rotation: totalRotation
  18645. });
  18646. this.reset()
  18647. }
  18648. },
  18649. {
  18650. key: 'cancelRendering',
  18651. value: function cancelRendering() {
  18652. if (this.renderTask) {
  18653. this.renderTask.cancel();
  18654. this.renderTask = null
  18655. }
  18656. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  18657. this.resume = null
  18658. }
  18659. },
  18660. {
  18661. key: '_getPageDrawContext',
  18662. value: function _getPageDrawContext() {
  18663. var noCtxScale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  18664. var canvas = document.createElement('canvas');
  18665. this.canvas = canvas;
  18666. canvas.mozOpaque = true;
  18667. var ctx = canvas.getContext('2d', {
  18668. alpha: false
  18669. });
  18670. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  18671. canvas.width = this.canvasWidth * outputScale.sx | 0;
  18672. canvas.height = this.canvasHeight * outputScale.sy | 0;
  18673. canvas.style.width = this.canvasWidth + 'px';
  18674. canvas.style.height = this.canvasHeight + 'px';
  18675. if (!noCtxScale && outputScale.scaled) {
  18676. ctx.scale(outputScale.sx, outputScale.sy)
  18677. }
  18678. return ctx
  18679. }
  18680. },
  18681. {
  18682. key: '_convertCanvasToImage',
  18683. value: function _convertCanvasToImage() {
  18684. var _this = this;
  18685. if (!this.canvas) {
  18686. return
  18687. }
  18688. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  18689. return
  18690. }
  18691. var id = this.renderingId;
  18692. var className = 'thumbnailImage';
  18693. if (this.disableCanvasToImageConversion) {
  18694. this.canvas.id = id;
  18695. this.canvas.className = className;
  18696. this.l10n.get('thumb_page_canvas', {
  18697. page: this.pageId
  18698. },
  18699. 'Thumbnail of Page {{page}}').then(function(msg) {
  18700. _this.canvas.setAttribute('aria-label', msg)
  18701. });
  18702. this.div.setAttribute('data-loaded', true);
  18703. this.ring.appendChild(this.canvas);
  18704. return
  18705. }
  18706. var image = document.createElement('img');
  18707. image.id = id;
  18708. image.className = className;
  18709. this.l10n.get('thumb_page_canvas', {
  18710. page: this.pageId
  18711. },
  18712. 'Thumbnail of Page {{page}}').then(function(msg) {
  18713. image.setAttribute('aria-label', msg)
  18714. });
  18715. image.style.width = this.canvasWidth + 'px';
  18716. image.style.height = this.canvasHeight + 'px';
  18717. image.src = this.canvas.toDataURL();
  18718. this.image = image;
  18719. this.div.setAttribute('data-loaded', true);
  18720. this.ring.appendChild(image);
  18721. this.canvas.width = 0;
  18722. this.canvas.height = 0;
  18723. delete this.canvas
  18724. }
  18725. },
  18726. {
  18727. key: 'draw',
  18728. value: function draw() {
  18729. var _this2 = this;
  18730. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  18731. console.error('Must be in new state before drawing');
  18732. return Promise.resolve(undefined)
  18733. }
  18734. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  18735. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  18736. var finishRenderTask = function finishRenderTask(error) {
  18737. if (renderTask === _this2.renderTask) {
  18738. _this2.renderTask = null
  18739. }
  18740. if (error === 'cancelled' || error instanceof _pdfjsLib.RenderingCancelledException) {
  18741. renderCapability.resolve(undefined);
  18742. return
  18743. }
  18744. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  18745. _this2._convertCanvasToImage();
  18746. if (!error) {
  18747. renderCapability.resolve(undefined)
  18748. } else {
  18749. renderCapability.reject(error)
  18750. }
  18751. };
  18752. var ctx = this._getPageDrawContext();
  18753. var drawViewport = this.viewport.clone({
  18754. scale: this.scale
  18755. });
  18756. var renderContinueCallback = function renderContinueCallback(cont) {
  18757. if (!_this2.renderingQueue.isHighestPriority(_this2)) {
  18758. _this2.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  18759. _this2.resume = function() {
  18760. _this2.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  18761. cont()
  18762. };
  18763. return
  18764. }
  18765. cont()
  18766. };
  18767. var renderContext = {
  18768. canvasContext: ctx,
  18769. viewport: drawViewport
  18770. };
  18771. var renderTask = this.renderTask = this.pdfPage.render(renderContext);
  18772. renderTask.onContinue = renderContinueCallback;
  18773. renderTask.promise.then(function() {
  18774. finishRenderTask(null)
  18775. },
  18776. function(error) {
  18777. finishRenderTask(error)
  18778. });
  18779. return renderCapability.promise
  18780. }
  18781. },
  18782. {
  18783. key: 'setImage',
  18784. value: function setImage(pageView) {
  18785. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  18786. return
  18787. }
  18788. var img = pageView.canvas;
  18789. if (!img) {
  18790. return
  18791. }
  18792. if (!this.pdfPage) {
  18793. this.setPdfPage(pageView.pdfPage)
  18794. }
  18795. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  18796. var ctx = this._getPageDrawContext(true);
  18797. var canvas = ctx.canvas;
  18798. if (img.width <= 2 * canvas.width) {
  18799. ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height);
  18800. this._convertCanvasToImage();
  18801. return
  18802. }
  18803. var reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
  18804. var reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
  18805. var reducedImage = TempImageFactory.getCanvas(reducedWidth, reducedHeight);
  18806. var reducedImageCtx = reducedImage.getContext('2d');
  18807. while (reducedWidth > img.width || reducedHeight > img.height) {
  18808. reducedWidth >>= 1;
  18809. reducedHeight >>= 1
  18810. }
  18811. reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0, reducedWidth, reducedHeight);
  18812. while (reducedWidth > 2 * canvas.width) {
  18813. reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, reducedWidth >> 1, reducedHeight >> 1);
  18814. reducedWidth >>= 1;
  18815. reducedHeight >>= 1
  18816. }
  18817. ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height);
  18818. this._convertCanvasToImage()
  18819. }
  18820. },
  18821. {
  18822. key: 'setPageLabel',
  18823. value: function setPageLabel(label) {
  18824. var _this3 = this;
  18825. this.pageLabel = typeof label === 'string' ? label: null;
  18826. this.l10n.get('thumb_page_title', {
  18827. page: this.pageId
  18828. },
  18829. 'Page {{page}}').then(function(msg) {
  18830. _this3.anchor.title = msg
  18831. });
  18832. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  18833. return
  18834. }
  18835. this.l10n.get('thumb_page_canvas', {
  18836. page: this.pageId
  18837. },
  18838. 'Thumbnail of Page {{page}}').then(function(ariaLabel) {
  18839. if (_this3.image) {
  18840. _this3.image.setAttribute('aria-label', ariaLabel)
  18841. } else if (_this3.disableCanvasToImageConversion && _this3.canvas) {
  18842. _this3.canvas.setAttribute('aria-label', ariaLabel)
  18843. }
  18844. })
  18845. }
  18846. },
  18847. {
  18848. key: 'pageId',
  18849. get: function get() {
  18850. return this.pageLabel !== null ? this.pageLabel: this.id
  18851. }
  18852. }], [{
  18853. key: 'cleanup',
  18854. value: function cleanup() {
  18855. TempImageFactory.destroyCanvas()
  18856. }
  18857. }]);
  18858. return PDFThumbnailView
  18859. } ();
  18860. exports.PDFThumbnailView = PDFThumbnailView
  18861. }), (function(module, exports, __webpack_require__) {
  18862. "use strict";
  18863. Object.defineProperty(exports, "__esModule", {
  18864. value: true
  18865. });
  18866. exports.PDFThumbnailViewer = undefined;
  18867. var _createClass = function() {
  18868. function defineProperties(target, props) {
  18869. for (var i = 0; i < props.length; i++) {
  18870. var descriptor = props[i];
  18871. descriptor.enumerable = descriptor.enumerable || false;
  18872. descriptor.configurable = true;
  18873. if ("value" in descriptor) descriptor.writable = true;
  18874. Object.defineProperty(target, descriptor.key, descriptor)
  18875. }
  18876. }
  18877. return function(Constructor, protoProps, staticProps) {
  18878. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  18879. if (staticProps) defineProperties(Constructor, staticProps);
  18880. return Constructor
  18881. }
  18882. } ();
  18883. var _ui_utils = __webpack_require__(0);
  18884. var _pdf_thumbnail_view = __webpack_require__(25);
  18885. function _classCallCheck(instance, Constructor) {
  18886. if (! (instance instanceof Constructor)) {
  18887. throw new TypeError("Cannot call a class as a function");
  18888. }
  18889. }
  18890. var THUMBNAIL_SCROLL_MARGIN = -19;
  18891. var PDFThumbnailViewer = function() {
  18892. function PDFThumbnailViewer(_ref) {
  18893. var container = _ref.container,
  18894. linkService = _ref.linkService,
  18895. renderingQueue = _ref.renderingQueue,
  18896. _ref$l10n = _ref.l10n,
  18897. l10n = _ref$l10n === undefined ? _ui_utils.NullL10n: _ref$l10n;
  18898. _classCallCheck(this, PDFThumbnailViewer);
  18899. this.container = container;
  18900. this.linkService = linkService;
  18901. this.renderingQueue = renderingQueue;
  18902. this.l10n = l10n;
  18903. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdated.bind(this));
  18904. this._resetView()
  18905. }
  18906. _createClass(PDFThumbnailViewer, [{
  18907. key: '_scrollUpdated',
  18908. value: function _scrollUpdated() {
  18909. this.renderingQueue.renderHighestPriority()
  18910. }
  18911. },
  18912. {
  18913. key: 'getThumbnail',
  18914. value: function getThumbnail(index) {
  18915. return this._thumbnails[index]
  18916. }
  18917. },
  18918. {
  18919. key: '_getVisibleThumbs',
  18920. value: function _getVisibleThumbs() {
  18921. return (0, _ui_utils.getVisibleElements)(this.container, this._thumbnails)
  18922. }
  18923. },
  18924. {
  18925. key: 'scrollThumbnailIntoView',
  18926. value: function scrollThumbnailIntoView(page) {
  18927. var selected = document.querySelector('.thumbnail.selected');
  18928. if (selected) {
  18929. selected.classList.remove('selected')
  18930. }
  18931. var thumbnail = document.querySelector('div.thumbnail[data-page-number="' + page + '"]');
  18932. if (thumbnail) {
  18933. thumbnail.classList.add('selected')
  18934. }
  18935. var visibleThumbs = this._getVisibleThumbs();
  18936. var numVisibleThumbs = visibleThumbs.views.length;
  18937. if (numVisibleThumbs > 0) {
  18938. var first = visibleThumbs.first.id;
  18939. var last = numVisibleThumbs > 1 ? visibleThumbs.last.id: first;
  18940. if (page <= first || page >= last) { (0, _ui_utils.scrollIntoView)(thumbnail, {
  18941. top: THUMBNAIL_SCROLL_MARGIN
  18942. })
  18943. }
  18944. }
  18945. }
  18946. },
  18947. {
  18948. key: 'cleanup',
  18949. value: function cleanup() {
  18950. _pdf_thumbnail_view.PDFThumbnailView.cleanup()
  18951. }
  18952. },
  18953. {
  18954. key: '_resetView',
  18955. value: function _resetView() {
  18956. this._thumbnails = [];
  18957. this._pageLabels = null;
  18958. this._pagesRotation = 0;
  18959. this._pagesRequests = [];
  18960. this.container.textContent = ''
  18961. }
  18962. },
  18963. {
  18964. key: 'setDocument',
  18965. value: function setDocument(pdfDocument) {
  18966. var _this = this;
  18967. if (this.pdfDocument) {
  18968. this._cancelRendering();
  18969. this._resetView()
  18970. }
  18971. this.pdfDocument = pdfDocument;
  18972. if (!pdfDocument) {
  18973. return
  18974. }
  18975. pdfDocument.getPage(1).then(function(firstPage) {
  18976. var pagesCount = pdfDocument.numPages;
  18977. var viewport = firstPage.getViewport(1.0);
  18978. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  18979. var thumbnail = new _pdf_thumbnail_view.PDFThumbnailView({
  18980. container: _this.container,
  18981. id: pageNum,
  18982. defaultViewport: viewport.clone(),
  18983. linkService: _this.linkService,
  18984. renderingQueue: _this.renderingQueue,
  18985. disableCanvasToImageConversion: false,
  18986. l10n: _this.l10n
  18987. });
  18988. _this._thumbnails.push(thumbnail)
  18989. }
  18990. }).
  18991. catch(function(reason) {
  18992. console.error('Unable to initialize thumbnail viewer', reason)
  18993. })
  18994. }
  18995. },
  18996. {
  18997. key: '_cancelRendering',
  18998. value: function _cancelRendering() {
  18999. for (var i = 0,
  19000. ii = this._thumbnails.length; i < ii; i++) {
  19001. if (this._thumbnails[i]) {
  19002. this._thumbnails[i].cancelRendering()
  19003. }
  19004. }
  19005. }
  19006. },
  19007. {
  19008. key: 'setPageLabels',
  19009. value: function setPageLabels(labels) {
  19010. if (!this.pdfDocument) {
  19011. return
  19012. }
  19013. if (!labels) {
  19014. this._pageLabels = null
  19015. } else if (! (labels instanceof Array && this.pdfDocument.numPages === labels.length)) {
  19016. this._pageLabels = null;
  19017. console.error('PDFThumbnailViewer_setPageLabels: Invalid page labels.')
  19018. } else {
  19019. this._pageLabels = labels
  19020. }
  19021. for (var i = 0,
  19022. ii = this._thumbnails.length; i < ii; i++) {
  19023. var label = this._pageLabels && this._pageLabels[i];
  19024. this._thumbnails[i].setPageLabel(label)
  19025. }
  19026. }
  19027. },
  19028. {
  19029. key: '_ensurePdfPageLoaded',
  19030. value: function _ensurePdfPageLoaded(thumbView) {
  19031. var _this2 = this;
  19032. if (thumbView.pdfPage) {
  19033. return Promise.resolve(thumbView.pdfPage)
  19034. }
  19035. var pageNumber = thumbView.id;
  19036. if (this._pagesRequests[pageNumber]) {
  19037. return this._pagesRequests[pageNumber]
  19038. }
  19039. var promise = this.pdfDocument.getPage(pageNumber).then(function(pdfPage) {
  19040. thumbView.setPdfPage(pdfPage);
  19041. _this2._pagesRequests[pageNumber] = null;
  19042. return pdfPage
  19043. }).
  19044. catch(function(reason) {
  19045. console.error('Unable to get page for thumb view', reason);
  19046. _this2._pagesRequests[pageNumber] = null
  19047. });
  19048. this._pagesRequests[pageNumber] = promise;
  19049. return promise
  19050. }
  19051. },
  19052. {
  19053. key: 'forceRendering',
  19054. value: function forceRendering() {
  19055. var _this3 = this;
  19056. var visibleThumbs = this._getVisibleThumbs();
  19057. var thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, this.scroll.down);
  19058. if (thumbView) {
  19059. this._ensurePdfPageLoaded(thumbView).then(function() {
  19060. _this3.renderingQueue.renderView(thumbView)
  19061. });
  19062. return true
  19063. }
  19064. return false
  19065. }
  19066. },
  19067. {
  19068. key: 'pagesRotation',
  19069. get: function get() {
  19070. return this._pagesRotation
  19071. },
  19072. set: function set(rotation) {
  19073. if (! (typeof rotation === 'number' && rotation % 90 === 0)) {
  19074. throw new Error('Invalid thumbnails rotation angle.');
  19075. }
  19076. if (!this.pdfDocument) {
  19077. return
  19078. }
  19079. this._pagesRotation = rotation;
  19080. for (var i = 0,
  19081. ii = this._thumbnails.length; i < ii; i++) {
  19082. this._thumbnails[i].update(rotation)
  19083. }
  19084. }
  19085. }]);
  19086. return PDFThumbnailViewer
  19087. } ();
  19088. exports.PDFThumbnailViewer = PDFThumbnailViewer
  19089. }), (function(module, exports, __webpack_require__) {
  19090. "use strict";
  19091. Object.defineProperty(exports, "__esModule", {
  19092. value: true
  19093. });
  19094. exports.PDFViewer = exports.PresentationModeState = undefined;
  19095. var _createClass = function() {
  19096. function defineProperties(target, props) {
  19097. for (var i = 0; i < props.length; i++) {
  19098. var descriptor = props[i];
  19099. descriptor.enumerable = descriptor.enumerable || false;
  19100. descriptor.configurable = true;
  19101. if ("value" in descriptor) descriptor.writable = true;
  19102. Object.defineProperty(target, descriptor.key, descriptor)
  19103. }
  19104. }
  19105. return function(Constructor, protoProps, staticProps) {
  19106. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  19107. if (staticProps) defineProperties(Constructor, staticProps);
  19108. return Constructor
  19109. }
  19110. } ();
  19111. var _pdfjsLib = __webpack_require__(1);
  19112. var _ui_utils = __webpack_require__(0);
  19113. var _pdf_rendering_queue = __webpack_require__(3);
  19114. var _annotation_layer_builder = __webpack_require__(11);
  19115. var _dom_events = __webpack_require__(2);
  19116. var _pdf_page_view = __webpack_require__(22);
  19117. var _pdf_link_service = __webpack_require__(5);
  19118. var _text_layer_builder = __webpack_require__(30);
  19119. function _classCallCheck(instance, Constructor) {
  19120. if (! (instance instanceof Constructor)) {
  19121. throw new TypeError("Cannot call a class as a function");
  19122. }
  19123. }
  19124. var PresentationModeState = {
  19125. UNKNOWN: 0,
  19126. NORMAL: 1,
  19127. CHANGING: 2,
  19128. FULLSCREEN: 3
  19129. };
  19130. var DEFAULT_CACHE_SIZE = 10;
  19131. function PDFPageViewBuffer(size) {
  19132. var data = [];
  19133. this.push = function cachePush(view) {
  19134. var i = data.indexOf(view);
  19135. if (i >= 0) {
  19136. data.splice(i, 1)
  19137. }
  19138. data.push(view);
  19139. if (data.length > size) {
  19140. data.shift().destroy()
  19141. }
  19142. };
  19143. this.resize = function(newSize) {
  19144. size = newSize;
  19145. while (data.length > size) {
  19146. data.shift().destroy()
  19147. }
  19148. }
  19149. }
  19150. function isSameScale(oldScale, newScale) {
  19151. if (newScale === oldScale) {
  19152. return true
  19153. }
  19154. if (Math.abs(newScale - oldScale) < 1e-15) {
  19155. return true
  19156. }
  19157. return false
  19158. }
  19159. function isPortraitOrientation(size) {
  19160. return size.width <= size.height
  19161. }
  19162. var PDFViewer = function() {
  19163. function PDFViewer(options) {
  19164. _classCallCheck(this, PDFViewer);
  19165. this.container = options.container;
  19166. this.viewer = options.viewer || options.container.firstElementChild;
  19167. this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)();
  19168. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  19169. this.downloadManager = options.downloadManager || null;
  19170. this.removePageBorders = options.removePageBorders || false;
  19171. this.enhanceTextSelection = options.enhanceTextSelection || false;
  19172. this.renderInteractiveForms = options.renderInteractiveForms || false;
  19173. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  19174. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  19175. this.l10n = options.l10n || _ui_utils.NullL10n;
  19176. this.defaultRenderingQueue = !options.renderingQueue;
  19177. if (this.defaultRenderingQueue) {
  19178. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  19179. this.renderingQueue.setViewer(this)
  19180. } else {
  19181. this.renderingQueue = options.renderingQueue
  19182. }
  19183. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  19184. this.presentationModeState = PresentationModeState.UNKNOWN;
  19185. this._resetView();
  19186. if (this.removePageBorders) {
  19187. this.viewer.classList.add('removePageBorders')
  19188. }
  19189. }
  19190. _createClass(PDFViewer, [{
  19191. key: 'getPageView',
  19192. value: function getPageView(index) {
  19193. return this._pages[index]
  19194. }
  19195. },
  19196. {
  19197. key: '_setCurrentPageNumber',
  19198. value: function _setCurrentPageNumber(val) {
  19199. var resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  19200. if (this._currentPageNumber === val) {
  19201. if (resetCurrentPageView) {
  19202. this._resetCurrentPageView()
  19203. }
  19204. return
  19205. }
  19206. if (! (0 < val && val <= this.pagesCount)) {
  19207. console.error('PDFViewer._setCurrentPageNumber: "' + val + '" is out of bounds.');
  19208. return
  19209. }
  19210. var arg = {
  19211. source: this,
  19212. pageNumber: val,
  19213. pageLabel: this._pageLabels && this._pageLabels[val - 1]
  19214. };
  19215. this._currentPageNumber = val;
  19216. this.eventBus.dispatch('pagechanging', arg);
  19217. this.eventBus.dispatch('pagechange', arg);
  19218. if (resetCurrentPageView) {
  19219. this._resetCurrentPageView()
  19220. }
  19221. }
  19222. },
  19223. {
  19224. key: 'setDocument',
  19225. value: function setDocument(pdfDocument) {
  19226. var _this = this;
  19227. if (this.pdfDocument) {
  19228. this._cancelRendering();
  19229. this._resetView()
  19230. }
  19231. this.pdfDocument = pdfDocument;
  19232. if (!pdfDocument) {
  19233. return
  19234. }
  19235. var pagesCount = pdfDocument.numPages;
  19236. var pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
  19237. this.pagesPromise = pagesCapability.promise;
  19238. pagesCapability.promise.then(function() {
  19239. _this._pageViewsReady = true;
  19240. _this.eventBus.dispatch('pagesloaded', {
  19241. source: _this,
  19242. pagesCount: pagesCount
  19243. })
  19244. });
  19245. var isOnePageRenderedResolved = false;
  19246. var onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  19247. this.onePageRendered = onePageRenderedCapability.promise;
  19248. var bindOnAfterAndBeforeDraw = function bindOnAfterAndBeforeDraw(pageView) {
  19249. pageView.onBeforeDraw = function() {
  19250. _this._buffer.push(pageView)
  19251. };
  19252. pageView.onAfterDraw = function() {
  19253. if (!isOnePageRenderedResolved) {
  19254. isOnePageRenderedResolved = true;
  19255. onePageRenderedCapability.resolve()
  19256. }
  19257. }
  19258. };
  19259. var firstPagePromise = pdfDocument.getPage(1);
  19260. this.firstPagePromise = firstPagePromise;
  19261. firstPagePromise.then(function(pdfPage) {
  19262. var scale = _this.currentScale;
  19263. var viewport = pdfPage.getViewport(scale * _ui_utils.CSS_UNITS);
  19264. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  19265. var textLayerFactory = null;
  19266. if (!_pdfjsLib.PDFJS.disableTextLayer) {
  19267. textLayerFactory = _this
  19268. }
  19269. var pageView = new _pdf_page_view.PDFPageView({
  19270. container: _this.viewer,
  19271. eventBus: _this.eventBus,
  19272. id: pageNum,
  19273. scale: scale,
  19274. defaultViewport: viewport.clone(),
  19275. renderingQueue: _this.renderingQueue,
  19276. textLayerFactory: textLayerFactory,
  19277. annotationLayerFactory: _this,
  19278. enhanceTextSelection: _this.enhanceTextSelection,
  19279. renderInteractiveForms: _this.renderInteractiveForms,
  19280. renderer: _this.renderer,
  19281. l10n: _this.l10n
  19282. });
  19283. bindOnAfterAndBeforeDraw(pageView);
  19284. _this._pages.push(pageView)
  19285. }
  19286. onePageRenderedCapability.promise.then(function() {
  19287. if (_pdfjsLib.PDFJS.disableAutoFetch) {
  19288. pagesCapability.resolve();
  19289. return
  19290. }
  19291. var getPagesLeft = pagesCount;
  19292. var _loop = function _loop(_pageNum) {
  19293. pdfDocument.getPage(_pageNum).then(function(pdfPage) {
  19294. var pageView = _this._pages[_pageNum - 1];
  19295. if (!pageView.pdfPage) {
  19296. pageView.setPdfPage(pdfPage)
  19297. }
  19298. _this.linkService.cachePageRef(_pageNum, pdfPage.ref);
  19299. if (--getPagesLeft === 0) {
  19300. pagesCapability.resolve()
  19301. }
  19302. },
  19303. function(reason) {
  19304. console.error('Unable to get page ' + _pageNum + ' to initialize viewer', reason);
  19305. if (--getPagesLeft === 0) {
  19306. pagesCapability.resolve()
  19307. }
  19308. })
  19309. };
  19310. for (var _pageNum = 1; _pageNum <= pagesCount; ++_pageNum) {
  19311. _loop(_pageNum)
  19312. }
  19313. });
  19314. _this.eventBus.dispatch('pagesinit', {
  19315. source: _this
  19316. });
  19317. if (_this.defaultRenderingQueue) {
  19318. _this.update()
  19319. }
  19320. if (_this.findController) {
  19321. _this.findController.resolveFirstPage()
  19322. }
  19323. }).
  19324. catch(function(reason) {
  19325. console.error('Unable to initialize viewer', reason)
  19326. })
  19327. }
  19328. },
  19329. {
  19330. key: 'setPageLabels',
  19331. value: function setPageLabels(labels) {
  19332. if (!this.pdfDocument) {
  19333. return
  19334. }
  19335. if (!labels) {
  19336. this._pageLabels = null
  19337. } else if (! (labels instanceof Array && this.pdfDocument.numPages === labels.length)) {
  19338. this._pageLabels = null;
  19339. console.error('PDFViewer.setPageLabels: Invalid page labels.')
  19340. } else {
  19341. this._pageLabels = labels
  19342. }
  19343. for (var i = 0,
  19344. ii = this._pages.length; i < ii; i++) {
  19345. var pageView = this._pages[i];
  19346. var label = this._pageLabels && this._pageLabels[i];
  19347. pageView.setPageLabel(label)
  19348. }
  19349. }
  19350. },
  19351. {
  19352. key: '_resetView',
  19353. value: function _resetView() {
  19354. this._pages = [];
  19355. this._currentPageNumber = 1;
  19356. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  19357. this._currentScaleValue = null;
  19358. this._pageLabels = null;
  19359. this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  19360. this._location = null;
  19361. this._pagesRotation = 0;
  19362. this._pagesRequests = [];
  19363. this._pageViewsReady = false;
  19364. this.viewer.textContent = ''
  19365. }
  19366. },
  19367. {
  19368. key: '_scrollUpdate',
  19369. value: function _scrollUpdate() {
  19370. if (this.pagesCount === 0) {
  19371. return
  19372. }
  19373. this.update()
  19374. }
  19375. },
  19376. {
  19377. key: '_setScaleDispatchEvent',
  19378. value: function _setScaleDispatchEvent(newScale, newValue) {
  19379. var preset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  19380. var arg = {
  19381. source: this,
  19382. scale: newScale,
  19383. presetValue: preset ? newValue: undefined
  19384. };
  19385. this.eventBus.dispatch('scalechanging', arg);
  19386. this.eventBus.dispatch('scalechange', arg)
  19387. }
  19388. },
  19389. {
  19390. key: '_setScaleUpdatePages',
  19391. value: function _setScaleUpdatePages(newScale, newValue) {
  19392. var noScroll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  19393. var preset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  19394. this._currentScaleValue = newValue.toString();
  19395. if (isSameScale(this._currentScale, newScale)) {
  19396. if (preset) {
  19397. this._setScaleDispatchEvent(newScale, newValue, true)
  19398. }
  19399. return
  19400. }
  19401. for (var i = 0,
  19402. ii = this._pages.length; i < ii; i++) {
  19403. this._pages[i].update(newScale)
  19404. }
  19405. this._currentScale = newScale;
  19406. if (!noScroll) {
  19407. var page = this._currentPageNumber,
  19408. dest = void 0;
  19409. if (this._location && !_pdfjsLib.PDFJS.ignoreCurrentPositionOnZoom && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  19410. page = this._location.pageNumber;
  19411. dest = [null, {
  19412. name: 'XYZ'
  19413. },
  19414. this._location.left, this._location.top, null]
  19415. }
  19416. this.scrollPageIntoView({
  19417. pageNumber: page,
  19418. destArray: dest,
  19419. allowNegativeOffset: true
  19420. })
  19421. }
  19422. this._setScaleDispatchEvent(newScale, newValue, preset);
  19423. if (this.defaultRenderingQueue) {
  19424. this.update()
  19425. }
  19426. }
  19427. },
  19428. {
  19429. key: '_setScale',
  19430. value: function _setScale(value) {
  19431. var noScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  19432. var scale = parseFloat(value);
  19433. if (scale > 0) {
  19434. this._setScaleUpdatePages(scale, value, noScroll, false)
  19435. } else {
  19436. var currentPage = this._pages[this._currentPageNumber - 1];
  19437. if (!currentPage) {
  19438. return
  19439. }
  19440. var hPadding = this.isInPresentationMode || this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  19441. var vPadding = this.isInPresentationMode || this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  19442. var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale;
  19443. var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  19444. switch (value) {
  19445. case 'page-actual':
  19446. scale = 1;
  19447. break;
  19448. case 'page-width':
  19449. scale = pageWidthScale;
  19450. break;
  19451. case 'page-height':
  19452. scale = pageHeightScale;
  19453. break;
  19454. case 'page-fit':
  19455. scale = Math.min(pageWidthScale, pageHeightScale);
  19456. break;
  19457. case 'auto':
  19458. var isLandscape = currentPage.width > currentPage.height;
  19459. var horizontalScale = isLandscape ? Math.min(pageHeightScale, pageWidthScale) : pageWidthScale;
  19460. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  19461. break;
  19462. default:
  19463. console.error('PDFViewer._setScale: "' + value + '" is an unknown zoom value.');
  19464. return
  19465. }
  19466. this._setScaleUpdatePages(scale, value, noScroll, true)
  19467. }
  19468. }
  19469. },
  19470. {
  19471. key: '_resetCurrentPageView',
  19472. value: function _resetCurrentPageView() {
  19473. if (this.isInPresentationMode) {
  19474. this._setScale(this._currentScaleValue, true)
  19475. }
  19476. var pageView = this._pages[this._currentPageNumber - 1]; (0, _ui_utils.scrollIntoView)(pageView.div)
  19477. }
  19478. },
  19479. {
  19480. key: 'scrollPageIntoView',
  19481. value: function scrollPageIntoView(params) {
  19482. if (!this.pdfDocument) {
  19483. return
  19484. }
  19485. if (arguments.length > 1 || typeof params === 'number') {
  19486. console.warn('Call of scrollPageIntoView() with obsolete signature.');
  19487. var paramObj = {};
  19488. if (typeof params === 'number') {
  19489. paramObj.pageNumber = params
  19490. }
  19491. if (arguments[1] instanceof Array) {
  19492. paramObj.destArray = arguments[1]
  19493. }
  19494. params = paramObj
  19495. }
  19496. var pageNumber = params.pageNumber || 0;
  19497. var dest = params.destArray || null;
  19498. var allowNegativeOffset = params.allowNegativeOffset || false;
  19499. if (this.isInPresentationMode || !dest) {
  19500. this._setCurrentPageNumber(pageNumber, true);
  19501. return
  19502. }
  19503. var pageView = this._pages[pageNumber - 1];
  19504. if (!pageView) {
  19505. console.error('PDFViewer.scrollPageIntoView: Invalid "pageNumber" parameter.');
  19506. return
  19507. }
  19508. var x = 0,
  19509. y = 0;
  19510. var width = 0,
  19511. height = 0,
  19512. widthScale = void 0,
  19513. heightScale = void 0;
  19514. var changeOrientation = pageView.rotation % 180 === 0 ? false: true;
  19515. var pageWidth = (changeOrientation ? pageView.height: pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;
  19516. var pageHeight = (changeOrientation ? pageView.width: pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;
  19517. var scale = 0;
  19518. switch (dest[1].name) {
  19519. case 'XYZ':
  19520. x = dest[2];
  19521. y = dest[3];
  19522. scale = dest[4];
  19523. x = x !== null ? x: 0;
  19524. y = y !== null ? y: pageHeight;
  19525. break;
  19526. case 'Fit':
  19527. case 'FitB':
  19528. scale = 'page-fit';
  19529. break;
  19530. case 'FitH':
  19531. case 'FitBH':
  19532. y = dest[2];
  19533. scale = 'page-width';
  19534. if (y === null && this._location) {
  19535. x = this._location.left;
  19536. y = this._location.top
  19537. }
  19538. break;
  19539. case 'FitV':
  19540. case 'FitBV':
  19541. x = dest[2];
  19542. width = pageWidth;
  19543. height = pageHeight;
  19544. scale = 'page-height';
  19545. break;
  19546. case 'FitR':
  19547. x = dest[2];
  19548. y = dest[3];
  19549. width = dest[4] - x;
  19550. height = dest[5] - y;
  19551. var hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  19552. var vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  19553. widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;
  19554. heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;
  19555. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  19556. break;
  19557. default:
  19558. console.error('PDFViewer.scrollPageIntoView: "' + dest[1].name + '" ' + 'is not a valid destination type.');
  19559. return
  19560. }
  19561. if (scale && scale !== this._currentScale) {
  19562. this.currentScaleValue = scale
  19563. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  19564. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE
  19565. }
  19566. if (scale === 'page-fit' && !dest[4]) { (0, _ui_utils.scrollIntoView)(pageView.div);
  19567. return
  19568. }
  19569. var boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  19570. var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  19571. var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  19572. if (!allowNegativeOffset) {
  19573. left = Math.max(left, 0);
  19574. top = Math.max(top, 0)
  19575. } (0, _ui_utils.scrollIntoView)(pageView.div, {
  19576. left: left,
  19577. top: top
  19578. })
  19579. }
  19580. },
  19581. {
  19582. key: '_updateLocation',
  19583. value: function _updateLocation(firstPage) {
  19584. var currentScale = this._currentScale;
  19585. var currentScaleValue = this._currentScaleValue;
  19586. var normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  19587. var pageNumber = firstPage.id;
  19588. var pdfOpenParams = '#page=' + pageNumber;
  19589. pdfOpenParams += '&zoom=' + normalizedScaleValue;
  19590. var currentPageView = this._pages[pageNumber - 1];
  19591. var container = this.container;
  19592. var topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  19593. var intLeft = Math.round(topLeft[0]);
  19594. var intTop = Math.round(topLeft[1]);
  19595. pdfOpenParams += ',' + intLeft + ',' + intTop;
  19596. this._location = {
  19597. pageNumber: pageNumber,
  19598. scale: normalizedScaleValue,
  19599. top: intTop,
  19600. left: intLeft,
  19601. pdfOpenParams: pdfOpenParams
  19602. }
  19603. }
  19604. },
  19605. {
  19606. key: 'update',
  19607. value: function update() {
  19608. var visible = this._getVisiblePages();
  19609. var visiblePages = visible.views;
  19610. if (visiblePages.length === 0) {
  19611. return
  19612. }
  19613. var suggestedCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * visiblePages.length + 1);
  19614. this._buffer.resize(suggestedCacheSize);
  19615. this.renderingQueue.renderHighestPriority(visible);
  19616. var currentId = this._currentPageNumber;
  19617. var firstPage = visible.first;
  19618. var stillFullyVisible = false;
  19619. for (var i = 0,
  19620. ii = visiblePages.length; i < ii; ++i) {
  19621. var page = visiblePages[i];
  19622. if (page.percent < 100) {
  19623. break
  19624. }
  19625. if (page.id === currentId) {
  19626. stillFullyVisible = true;
  19627. break
  19628. }
  19629. }
  19630. if (!stillFullyVisible) {
  19631. currentId = visiblePages[0].id
  19632. }
  19633. if (!this.isInPresentationMode) {
  19634. this._setCurrentPageNumber(currentId)
  19635. }
  19636. this._updateLocation(firstPage);
  19637. this.eventBus.dispatch('updateviewarea', {
  19638. source: this,
  19639. location: this._location
  19640. })
  19641. }
  19642. },
  19643. {
  19644. key: 'containsElement',
  19645. value: function containsElement(element) {
  19646. return this.container.contains(element)
  19647. }
  19648. },
  19649. {
  19650. key: 'focus',
  19651. value: function focus() {
  19652. this.container.focus()
  19653. }
  19654. },
  19655. {
  19656. key: '_getVisiblePages',
  19657. value: function _getVisiblePages() {
  19658. if (!this.isInPresentationMode) {
  19659. return (0, _ui_utils.getVisibleElements)(this.container, this._pages, true)
  19660. }
  19661. var visible = [];
  19662. var currentPage = this._pages[this._currentPageNumber - 1];
  19663. visible.push({
  19664. id: currentPage.id,
  19665. view: currentPage
  19666. });
  19667. return {
  19668. first: currentPage,
  19669. last: currentPage,
  19670. views: visible
  19671. }
  19672. }
  19673. },
  19674. {
  19675. key: 'cleanup',
  19676. value: function cleanup() {
  19677. for (var i = 0,
  19678. ii = this._pages.length; i < ii; i++) {
  19679. if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  19680. this._pages[i].reset()
  19681. }
  19682. }
  19683. }
  19684. },
  19685. {
  19686. key: '_cancelRendering',
  19687. value: function _cancelRendering() {
  19688. for (var i = 0,
  19689. ii = this._pages.length; i < ii; i++) {
  19690. if (this._pages[i]) {
  19691. this._pages[i].cancelRendering()
  19692. }
  19693. }
  19694. }
  19695. },
  19696. {
  19697. key: '_ensurePdfPageLoaded',
  19698. value: function _ensurePdfPageLoaded(pageView) {
  19699. var _this2 = this;
  19700. if (pageView.pdfPage) {
  19701. return Promise.resolve(pageView.pdfPage)
  19702. }
  19703. var pageNumber = pageView.id;
  19704. if (this._pagesRequests[pageNumber]) {
  19705. return this._pagesRequests[pageNumber]
  19706. }
  19707. var promise = this.pdfDocument.getPage(pageNumber).then(function(pdfPage) {
  19708. if (!pageView.pdfPage) {
  19709. pageView.setPdfPage(pdfPage)
  19710. }
  19711. _this2._pagesRequests[pageNumber] = null;
  19712. return pdfPage
  19713. }).
  19714. catch(function(reason) {
  19715. console.error('Unable to get page for page view', reason);
  19716. _this2._pagesRequests[pageNumber] = null
  19717. });
  19718. this._pagesRequests[pageNumber] = promise;
  19719. return promise
  19720. }
  19721. },
  19722. {
  19723. key: 'forceRendering',
  19724. value: function forceRendering(currentlyVisiblePages) {
  19725. var _this3 = this;
  19726. var visiblePages = currentlyVisiblePages || this._getVisiblePages();
  19727. var pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, this.scroll.down);
  19728. if (pageView) {
  19729. this._ensurePdfPageLoaded(pageView).then(function() {
  19730. _this3.renderingQueue.renderView(pageView)
  19731. });
  19732. return true
  19733. }
  19734. return false
  19735. }
  19736. },
  19737. {
  19738. key: 'getPageTextContent',
  19739. value: function getPageTextContent(pageIndex) {
  19740. return this.pdfDocument.getPage(pageIndex + 1).then(function(page) {
  19741. return page.getTextContent({
  19742. normalizeWhitespace: true
  19743. })
  19744. })
  19745. }
  19746. },
  19747. {
  19748. key: 'createTextLayerBuilder',
  19749. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  19750. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  19751. return new _text_layer_builder.TextLayerBuilder({
  19752. textLayerDiv: textLayerDiv,
  19753. eventBus: this.eventBus,
  19754. pageIndex: pageIndex,
  19755. viewport: viewport,
  19756. findController: this.isInPresentationMode ? null: this.findController,
  19757. enhanceTextSelection: this.isInPresentationMode ? false: enhanceTextSelection
  19758. })
  19759. }
  19760. },
  19761. {
  19762. key: 'createAnnotationLayerBuilder',
  19763. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  19764. var renderInteractiveForms = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  19765. var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
  19766. return new _annotation_layer_builder.AnnotationLayerBuilder({
  19767. pageDiv: pageDiv,
  19768. pdfPage: pdfPage,
  19769. renderInteractiveForms: renderInteractiveForms,
  19770. linkService: this.linkService,
  19771. downloadManager: this.downloadManager,
  19772. l10n: l10n
  19773. })
  19774. }
  19775. },
  19776. {
  19777. key: 'setFindController',
  19778. value: function setFindController(findController) {
  19779. this.findController = findController
  19780. }
  19781. },
  19782. {
  19783. key: 'getPagesOverview',
  19784. value: function getPagesOverview() {
  19785. var pagesOverview = this._pages.map(function(pageView) {
  19786. var viewport = pageView.pdfPage.getViewport(1);
  19787. return {
  19788. width: viewport.width,
  19789. height: viewport.height,
  19790. rotation: viewport.rotation
  19791. }
  19792. });
  19793. if (!this.enablePrintAutoRotate) {
  19794. return pagesOverview
  19795. }
  19796. var isFirstPagePortrait = isPortraitOrientation(pagesOverview[0]);
  19797. return pagesOverview.map(function(size) {
  19798. if (isFirstPagePortrait === isPortraitOrientation(size)) {
  19799. return size
  19800. }
  19801. return {
  19802. width: size.height,
  19803. height: size.width,
  19804. rotation: (size.rotation + 90) % 360
  19805. }
  19806. })
  19807. }
  19808. },
  19809. {
  19810. key: 'pagesCount',
  19811. get: function get() {
  19812. return this._pages.length
  19813. }
  19814. },
  19815. {
  19816. key: 'pageViewsReady',
  19817. get: function get() {
  19818. return this._pageViewsReady
  19819. }
  19820. },
  19821. {
  19822. key: 'currentPageNumber',
  19823. get: function get() {
  19824. return this._currentPageNumber
  19825. },
  19826. set: function set(val) {
  19827. if ((val | 0) !== val) {
  19828. throw new Error('Invalid page number.');
  19829. }
  19830. if (!this.pdfDocument) {
  19831. return
  19832. }
  19833. this._setCurrentPageNumber(val, true)
  19834. }
  19835. },
  19836. {
  19837. key: 'currentPageLabel',
  19838. get: function get() {
  19839. return this._pageLabels && this._pageLabels[this._currentPageNumber - 1]
  19840. },
  19841. set: function set(val) {
  19842. var pageNumber = val | 0;
  19843. if (this._pageLabels) {
  19844. var i = this._pageLabels.indexOf(val);
  19845. if (i >= 0) {
  19846. pageNumber = i + 1
  19847. }
  19848. }
  19849. this.currentPageNumber = pageNumber
  19850. }
  19851. },
  19852. {
  19853. key: 'currentScale',
  19854. get: function get() {
  19855. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale: _ui_utils.DEFAULT_SCALE
  19856. },
  19857. set: function set(val) {
  19858. if (isNaN(val)) {
  19859. throw new Error('Invalid numeric scale');
  19860. }
  19861. if (!this.pdfDocument) {
  19862. return
  19863. }
  19864. this._setScale(val, false)
  19865. }
  19866. },
  19867. {
  19868. key: 'currentScaleValue',
  19869. get: function get() {
  19870. return this._currentScaleValue
  19871. },
  19872. set: function set(val) {
  19873. if (!this.pdfDocument) {
  19874. return
  19875. }
  19876. this._setScale(val, false)
  19877. }
  19878. },
  19879. {
  19880. key: 'pagesRotation',
  19881. get: function get() {
  19882. return this._pagesRotation
  19883. },
  19884. set: function set(rotation) {
  19885. if (! (typeof rotation === 'number' && rotation % 90 === 0)) {
  19886. throw new Error('Invalid pages rotation angle.');
  19887. }
  19888. if (!this.pdfDocument) {
  19889. return
  19890. }
  19891. this._pagesRotation = rotation;
  19892. for (var i = 0,
  19893. ii = this._pages.length; i < ii; i++) {
  19894. var pageView = this._pages[i];
  19895. pageView.update(pageView.scale, rotation)
  19896. }
  19897. this._setScale(this._currentScaleValue, true);
  19898. if (this.defaultRenderingQueue) {
  19899. this.update()
  19900. }
  19901. }
  19902. },
  19903. {
  19904. key: 'isInPresentationMode',
  19905. get: function get() {
  19906. return this.presentationModeState === PresentationModeState.FULLSCREEN
  19907. }
  19908. },
  19909. {
  19910. key: 'isChangingPresentationMode',
  19911. get: function get() {
  19912. return this.presentationModeState === PresentationModeState.CHANGING
  19913. }
  19914. },
  19915. {
  19916. key: 'isHorizontalScrollbarEnabled',
  19917. get: function get() {
  19918. return this.isInPresentationMode ? false: this.container.scrollWidth > this.container.clientWidth
  19919. }
  19920. },
  19921. {
  19922. key: 'hasEqualPageSizes',
  19923. get: function get() {
  19924. var firstPageView = this._pages[0];
  19925. for (var i = 1,
  19926. ii = this._pages.length; i < ii; ++i) {
  19927. var pageView = this._pages[i];
  19928. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  19929. return false
  19930. }
  19931. }
  19932. return true
  19933. }
  19934. }]);
  19935. return PDFViewer
  19936. } ();
  19937. exports.PresentationModeState = PresentationModeState;
  19938. exports.PDFViewer = PDFViewer
  19939. }), (function(module, exports, __webpack_require__) {
  19940. "use strict";
  19941. Object.defineProperty(exports, "__esModule", {
  19942. value: true
  19943. });
  19944. exports.BasePreferences = undefined;
  19945. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ?
  19946. function(obj) {
  19947. return typeof obj
  19948. }: function(obj) {
  19949. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol": typeof obj
  19950. };
  19951. var _createClass = function() {
  19952. function defineProperties(target, props) {
  19953. for (var i = 0; i < props.length; i++) {
  19954. var descriptor = props[i];
  19955. descriptor.enumerable = descriptor.enumerable || false;
  19956. descriptor.configurable = true;
  19957. if ("value" in descriptor) descriptor.writable = true;
  19958. Object.defineProperty(target, descriptor.key, descriptor)
  19959. }
  19960. }
  19961. return function(Constructor, protoProps, staticProps) {
  19962. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  19963. if (staticProps) defineProperties(Constructor, staticProps);
  19964. return Constructor
  19965. }
  19966. } ();
  19967. var _ui_utils = __webpack_require__(0);
  19968. function _classCallCheck(instance, Constructor) {
  19969. if (! (instance instanceof Constructor)) {
  19970. throw new TypeError("Cannot call a class as a function");
  19971. }
  19972. }
  19973. var defaultPreferences = null;
  19974. function getDefaultPreferences() {
  19975. if (!defaultPreferences) {
  19976. defaultPreferences = Promise.resolve({
  19977. "showPreviousViewOnLoad": true,
  19978. "defaultZoomValue": "",
  19979. "sidebarViewOnLoad": 0,
  19980. "enableHandToolOnLoad": false,
  19981. "cursorToolOnLoad": 0,
  19982. "enableWebGL": false,
  19983. "pdfBugEnabled": false,
  19984. "disableRange": false,
  19985. "disableStream": false,
  19986. "disableAutoFetch": false,
  19987. "disableFontFace": false,
  19988. "disableTextLayer": false,
  19989. "useOnlyCssZoom": false,
  19990. "externalLinkTarget": 0,
  19991. "enhanceTextSelection": false,
  19992. "renderer": "canvas",
  19993. "renderInteractiveForms": false,
  19994. "enablePrintAutoRotate": false,
  19995. "disablePageMode": false,
  19996. "disablePageLabels": false
  19997. })
  19998. }
  19999. return defaultPreferences
  20000. }
  20001. var BasePreferences = function() {
  20002. function BasePreferences() {
  20003. var _this = this;
  20004. _classCallCheck(this, BasePreferences);
  20005. if (this.constructor === BasePreferences) {
  20006. throw new Error('Cannot initialize BasePreferences.');
  20007. }
  20008. this.prefs = null;
  20009. this._initializedPromise = getDefaultPreferences().then(function(defaults) {
  20010. Object.defineProperty(_this, 'defaults', {
  20011. value: Object.freeze(defaults),
  20012. writable: false,
  20013. enumerable: true,
  20014. configurable: false
  20015. });
  20016. _this.prefs = (0, _ui_utils.cloneObj)(defaults);
  20017. return _this._readFromStorage(defaults)
  20018. }).then(function(prefObj) {
  20019. if (prefObj) {
  20020. _this.prefs = prefObj
  20021. }
  20022. })
  20023. }
  20024. _createClass(BasePreferences, [{
  20025. key: "_writeToStorage",
  20026. value: function _writeToStorage(prefObj) {
  20027. return Promise.reject(new Error('Not implemented: _writeToStorage'))
  20028. }
  20029. },
  20030. {
  20031. key: "_readFromStorage",
  20032. value: function _readFromStorage(prefObj) {
  20033. return Promise.reject(new Error('Not implemented: _readFromStorage'))
  20034. }
  20035. },
  20036. {
  20037. key: "reset",
  20038. value: function reset() {
  20039. var _this2 = this;
  20040. return this._initializedPromise.then(function() {
  20041. _this2.prefs = (0, _ui_utils.cloneObj)(_this2.defaults);
  20042. return _this2._writeToStorage(_this2.defaults)
  20043. })
  20044. }
  20045. },
  20046. {
  20047. key: "reload",
  20048. value: function reload() {
  20049. var _this3 = this;
  20050. return this._initializedPromise.then(function() {
  20051. return _this3._readFromStorage(_this3.defaults)
  20052. }).then(function(prefObj) {
  20053. if (prefObj) {
  20054. _this3.prefs = prefObj
  20055. }
  20056. })
  20057. }
  20058. },
  20059. {
  20060. key: "set",
  20061. value: function set(name, value) {
  20062. var _this4 = this;
  20063. return this._initializedPromise.then(function() {
  20064. if (_this4.defaults[name] === undefined) {
  20065. throw new Error("Set preference: \"" + name + "\" is undefined.");
  20066. } else if (value === undefined) {
  20067. throw new Error('Set preference: no value is specified.');
  20068. }
  20069. var valueType = typeof value === "undefined" ? "undefined": _typeof(value);
  20070. var defaultType = _typeof(_this4.defaults[name]);
  20071. if (valueType !== defaultType) {
  20072. if (valueType === 'number' && defaultType === 'string') {
  20073. value = value.toString()
  20074. } else {
  20075. throw new Error("Set preference: \"" + value + "\" is a " + valueType + ", " + ("expected a " + defaultType + "."));
  20076. }
  20077. } else {
  20078. if (valueType === 'number' && (value | 0) !== value) {
  20079. throw new Error("Set preference: \"" + value + "\" must be an integer.");
  20080. }
  20081. }
  20082. _this4.prefs[name] = value;
  20083. return _this4._writeToStorage(_this4.prefs)
  20084. })
  20085. }
  20086. },
  20087. {
  20088. key: "get",
  20089. value: function get(name) {
  20090. var _this5 = this;
  20091. return this._initializedPromise.then(function() {
  20092. var defaultValue = _this5.defaults[name];
  20093. if (defaultValue === undefined) {
  20094. throw new Error("Get preference: \"" + name + "\" is undefined.");
  20095. } else {
  20096. var prefValue = _this5.prefs[name];
  20097. if (prefValue !== undefined) {
  20098. return prefValue
  20099. }
  20100. }
  20101. return defaultValue
  20102. })
  20103. }
  20104. }]);
  20105. return BasePreferences
  20106. } ();
  20107. exports.BasePreferences = BasePreferences
  20108. }), (function(module, exports, __webpack_require__) {
  20109. "use strict";
  20110. Object.defineProperty(exports, "__esModule", {
  20111. value: true
  20112. });
  20113. exports.SecondaryToolbar = undefined;
  20114. var _createClass = function() {
  20115. function defineProperties(target, props) {
  20116. for (var i = 0; i < props.length; i++) {
  20117. var descriptor = props[i];
  20118. descriptor.enumerable = descriptor.enumerable || false;
  20119. descriptor.configurable = true;
  20120. if ("value" in descriptor) descriptor.writable = true;
  20121. Object.defineProperty(target, descriptor.key, descriptor)
  20122. }
  20123. }
  20124. return function(Constructor, protoProps, staticProps) {
  20125. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  20126. if (staticProps) defineProperties(Constructor, staticProps);
  20127. return Constructor
  20128. }
  20129. } ();
  20130. var _pdf_cursor_tools = __webpack_require__(6);
  20131. var _ui_utils = __webpack_require__(0);
  20132. function _classCallCheck(instance, Constructor) {
  20133. if (! (instance instanceof Constructor)) {
  20134. throw new TypeError("Cannot call a class as a function");
  20135. }
  20136. }
  20137. var SecondaryToolbar = function() {
  20138. function SecondaryToolbar(options, mainContainer, eventBus) {
  20139. _classCallCheck(this, SecondaryToolbar);
  20140. this.toolbar = options.toolbar;
  20141. this.toggleButton = options.toggleButton;
  20142. this.toolbarButtonContainer = options.toolbarButtonContainer;
  20143. this.buttons = [{
  20144. element: options.presentationModeButton,
  20145. eventName: 'presentationmode',
  20146. close: true
  20147. },
  20148. {
  20149. element: options.openFileButton,
  20150. eventName: 'openfile',
  20151. close: true
  20152. },
  20153. {
  20154. element: options.printButton,
  20155. eventName: 'print',
  20156. close: true
  20157. },
  20158. {
  20159. element: options.downloadButton,
  20160. eventName: 'download',
  20161. close: true
  20162. },
  20163. {
  20164. element: options.viewBookmarkButton,
  20165. eventName: null,
  20166. close: true
  20167. },
  20168. {
  20169. element: options.firstPageButton,
  20170. eventName: 'firstpage',
  20171. close: true
  20172. },
  20173. {
  20174. element: options.lastPageButton,
  20175. eventName: 'lastpage',
  20176. close: true
  20177. },
  20178. {
  20179. element: options.pageRotateCwButton,
  20180. eventName: 'rotatecw',
  20181. close: false
  20182. },
  20183. {
  20184. element: options.pageRotateCcwButton,
  20185. eventName: 'rotateccw',
  20186. close: false
  20187. },
  20188. {
  20189. element: options.cursorSelectToolButton,
  20190. eventName: 'switchcursortool',
  20191. eventDetails: {
  20192. tool: _pdf_cursor_tools.CursorTool.SELECT
  20193. },
  20194. close: true
  20195. },
  20196. {
  20197. element: options.cursorHandToolButton,
  20198. eventName: 'switchcursortool',
  20199. eventDetails: {
  20200. tool: _pdf_cursor_tools.CursorTool.HAND
  20201. },
  20202. close: true
  20203. },
  20204. {
  20205. element: options.documentPropertiesButton,
  20206. eventName: 'documentproperties',
  20207. close: true
  20208. }];
  20209. this.items = {
  20210. firstPage: options.firstPageButton,
  20211. lastPage: options.lastPageButton,
  20212. pageRotateCw: options.pageRotateCwButton,
  20213. pageRotateCcw: options.pageRotateCcwButton
  20214. };
  20215. this.mainContainer = mainContainer;
  20216. this.eventBus = eventBus;
  20217. this.opened = false;
  20218. this.containerHeight = null;
  20219. this.previousContainerHeight = null;
  20220. this.reset();
  20221. this._bindClickListeners();
  20222. this._bindCursorToolsListener(options);
  20223. this.eventBus.on('resize', this._setMaxHeight.bind(this))
  20224. }
  20225. _createClass(SecondaryToolbar, [{
  20226. key: 'setPageNumber',
  20227. value: function setPageNumber(pageNumber) {
  20228. this.pageNumber = pageNumber;
  20229. this._updateUIState()
  20230. }
  20231. },
  20232. {
  20233. key: 'setPagesCount',
  20234. value: function setPagesCount(pagesCount) {
  20235. this.pagesCount = pagesCount;
  20236. this._updateUIState()
  20237. }
  20238. },
  20239. {
  20240. key: 'reset',
  20241. value: function reset() {
  20242. this.pageNumber = 0;
  20243. this.pagesCount = 0;
  20244. this._updateUIState()
  20245. }
  20246. },
  20247. {
  20248. key: '_updateUIState',
  20249. value: function _updateUIState() {
  20250. this.items.firstPage.disabled = this.pageNumber <= 1;
  20251. this.items.lastPage.disabled = this.pageNumber >= this.pagesCount;
  20252. this.items.pageRotateCw.disabled = this.pagesCount === 0;
  20253. this.items.pageRotateCcw.disabled = this.pagesCount === 0
  20254. }
  20255. },
  20256. {
  20257. key: '_bindClickListeners',
  20258. value: function _bindClickListeners() {
  20259. var _this = this;
  20260. this.toggleButton.addEventListener('click', this.toggle.bind(this));
  20261. var _loop = function _loop(button) {
  20262. var _buttons$button = _this.buttons[button],
  20263. element = _buttons$button.element,
  20264. eventName = _buttons$button.eventName,
  20265. close = _buttons$button.close,
  20266. eventDetails = _buttons$button.eventDetails;
  20267. element.addEventListener('click',
  20268. function(evt) {
  20269. if (eventName !== null) {
  20270. var details = {
  20271. source: _this
  20272. };
  20273. for (var property in eventDetails) {
  20274. details[property] = eventDetails[property]
  20275. }
  20276. _this.eventBus.dispatch(eventName, details)
  20277. }
  20278. if (close) {
  20279. _this.close()
  20280. }
  20281. })
  20282. };
  20283. for (var button in this.buttons) {
  20284. _loop(button)
  20285. }
  20286. }
  20287. },
  20288. {
  20289. key: '_bindCursorToolsListener',
  20290. value: function _bindCursorToolsListener(buttons) {
  20291. this.eventBus.on('cursortoolchanged',
  20292. function(evt) {
  20293. buttons.cursorSelectToolButton.classList.remove('toggled');
  20294. buttons.cursorHandToolButton.classList.remove('toggled');
  20295. switch (evt.tool) {
  20296. case _pdf_cursor_tools.CursorTool.SELECT:
  20297. buttons.cursorSelectToolButton.classList.add('toggled');
  20298. break;
  20299. case _pdf_cursor_tools.CursorTool.HAND:
  20300. buttons.cursorHandToolButton.classList.add('toggled');
  20301. break
  20302. }
  20303. })
  20304. }
  20305. },
  20306. {
  20307. key: 'open',
  20308. value: function open() {
  20309. if (this.opened) {
  20310. return
  20311. }
  20312. this.opened = true;
  20313. this._setMaxHeight();
  20314. this.toggleButton.classList.add('toggled');
  20315. this.toolbar.classList.remove('hidden')
  20316. }
  20317. },
  20318. {
  20319. key: 'close',
  20320. value: function close() {
  20321. if (!this.opened) {
  20322. return
  20323. }
  20324. this.opened = false;
  20325. this.toolbar.classList.add('hidden');
  20326. this.toggleButton.classList.remove('toggled')
  20327. }
  20328. },
  20329. {
  20330. key: 'toggle',
  20331. value: function toggle() {
  20332. if (this.opened) {
  20333. this.close()
  20334. } else {
  20335. this.open()
  20336. }
  20337. }
  20338. },
  20339. {
  20340. key: '_setMaxHeight',
  20341. value: function _setMaxHeight() {
  20342. if (!this.opened) {
  20343. return
  20344. }
  20345. this.containerHeight = this.mainContainer.clientHeight;
  20346. if (this.containerHeight === this.previousContainerHeight) {
  20347. return
  20348. }
  20349. this.toolbarButtonContainer.setAttribute('style', 'max-height: ' + (this.containerHeight - _ui_utils.SCROLLBAR_PADDING) + 'px;');
  20350. this.previousContainerHeight = this.containerHeight
  20351. }
  20352. },
  20353. {
  20354. key: 'isOpen',
  20355. get: function get() {
  20356. return this.opened
  20357. }
  20358. }]);
  20359. return SecondaryToolbar
  20360. } ();
  20361. exports.SecondaryToolbar = SecondaryToolbar
  20362. }), (function(module, exports, __webpack_require__) {
  20363. "use strict";
  20364. Object.defineProperty(exports, "__esModule", {
  20365. value: true
  20366. });
  20367. exports.DefaultTextLayerFactory = exports.TextLayerBuilder = undefined;
  20368. var _createClass = function() {
  20369. function defineProperties(target, props) {
  20370. for (var i = 0; i < props.length; i++) {
  20371. var descriptor = props[i];
  20372. descriptor.enumerable = descriptor.enumerable || false;
  20373. descriptor.configurable = true;
  20374. if ("value" in descriptor) descriptor.writable = true;
  20375. Object.defineProperty(target, descriptor.key, descriptor)
  20376. }
  20377. }
  20378. return function(Constructor, protoProps, staticProps) {
  20379. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  20380. if (staticProps) defineProperties(Constructor, staticProps);
  20381. return Constructor
  20382. }
  20383. } ();
  20384. var _dom_events = __webpack_require__(2);
  20385. var _pdfjsLib = __webpack_require__(1);
  20386. function _classCallCheck(instance, Constructor) {
  20387. if (! (instance instanceof Constructor)) {
  20388. throw new TypeError("Cannot call a class as a function");
  20389. }
  20390. }
  20391. var EXPAND_DIVS_TIMEOUT = 300;
  20392. var TextLayerBuilder = function() {
  20393. function TextLayerBuilder(_ref) {
  20394. var textLayerDiv = _ref.textLayerDiv,
  20395. eventBus = _ref.eventBus,
  20396. pageIndex = _ref.pageIndex,
  20397. viewport = _ref.viewport,
  20398. _ref$findController = _ref.findController,
  20399. findController = _ref$findController === undefined ? null: _ref$findController,
  20400. _ref$enhanceTextSelec = _ref.enhanceTextSelection,
  20401. enhanceTextSelection = _ref$enhanceTextSelec === undefined ? false: _ref$enhanceTextSelec;
  20402. _classCallCheck(this, TextLayerBuilder);
  20403. this.textLayerDiv = textLayerDiv;
  20404. this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)();
  20405. this.textContent = null;
  20406. this.textContentItemsStr = [];
  20407. this.textContentStream = null;
  20408. this.renderingDone = false;
  20409. this.pageIdx = pageIndex;
  20410. this.pageNumber = this.pageIdx + 1;
  20411. this.matches = [];
  20412. this.viewport = viewport;
  20413. this.textDivs = [];
  20414. this.findController = findController;
  20415. this.textLayerRenderTask = null;
  20416. this.enhanceTextSelection = enhanceTextSelection;
  20417. this._bindMouse()
  20418. }
  20419. _createClass(TextLayerBuilder, [{
  20420. key: '_finishRendering',
  20421. value: function _finishRendering() {
  20422. this.renderingDone = true;
  20423. if (!this.enhanceTextSelection) {
  20424. var endOfContent = document.createElement('div');
  20425. endOfContent.className = 'endOfContent';
  20426. this.textLayerDiv.appendChild(endOfContent)
  20427. }
  20428. this.eventBus.dispatch('textlayerrendered', {
  20429. source: this,
  20430. pageNumber: this.pageNumber,
  20431. numTextDivs: this.textDivs.length
  20432. })
  20433. }
  20434. },
  20435. {
  20436. key: 'render',
  20437. value: function render() {
  20438. var _this = this;
  20439. var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  20440. if (! (this.textContent || this.textContentStream) || this.renderingDone) {
  20441. return
  20442. }
  20443. this.cancel();
  20444. this.textDivs = [];
  20445. var textLayerFrag = document.createDocumentFragment();
  20446. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  20447. textContent: this.textContent,
  20448. textContentStream: this.textContentStream,
  20449. container: textLayerFrag,
  20450. viewport: this.viewport,
  20451. textDivs: this.textDivs,
  20452. textContentItemsStr: this.textContentItemsStr,
  20453. timeout: timeout,
  20454. enhanceTextSelection: this.enhanceTextSelection
  20455. });
  20456. this.textLayerRenderTask.promise.then(function() {
  20457. _this.textLayerDiv.appendChild(textLayerFrag);
  20458. _this._finishRendering();
  20459. _this.updateMatches()
  20460. },
  20461. function(reason) {})
  20462. }
  20463. },
  20464. {
  20465. key: 'cancel',
  20466. value: function cancel() {
  20467. if (this.textLayerRenderTask) {
  20468. this.textLayerRenderTask.cancel();
  20469. this.textLayerRenderTask = null
  20470. }
  20471. }
  20472. },
  20473. {
  20474. key: 'setTextContentStream',
  20475. value: function setTextContentStream(readableStream) {
  20476. this.cancel();
  20477. this.textContentStream = readableStream
  20478. }
  20479. },
  20480. {
  20481. key: 'setTextContent',
  20482. value: function setTextContent(textContent) {
  20483. this.cancel();
  20484. this.textContent = textContent
  20485. }
  20486. },
  20487. {
  20488. key: 'convertMatches',
  20489. value: function convertMatches(matches, matchesLength) {
  20490. var i = 0;
  20491. var iIndex = 0;
  20492. var textContentItemsStr = this.textContentItemsStr;
  20493. var end = textContentItemsStr.length - 1;
  20494. var queryLen = this.findController === null ? 0 : this.findController.state.query.length;
  20495. var ret = [];
  20496. if (!matches) {
  20497. return ret
  20498. }
  20499. for (var m = 0,
  20500. len = matches.length; m < len; m++) {
  20501. var matchIdx = matches[m];
  20502. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  20503. iIndex += textContentItemsStr[i].length;
  20504. i++
  20505. }
  20506. if (i === textContentItemsStr.length) {
  20507. console.error('Could not find a matching mapping')
  20508. }
  20509. var match = {
  20510. begin: {
  20511. divIdx: i,
  20512. offset: matchIdx - iIndex
  20513. }
  20514. };
  20515. if (matchesLength) {
  20516. matchIdx += matchesLength[m]
  20517. } else {
  20518. matchIdx += queryLen
  20519. }
  20520. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  20521. iIndex += textContentItemsStr[i].length;
  20522. i++
  20523. }
  20524. match.end = {
  20525. divIdx: i,
  20526. offset: matchIdx - iIndex
  20527. };
  20528. ret.push(match)
  20529. }
  20530. return ret
  20531. }
  20532. },
  20533. {
  20534. key: 'renderMatches',
  20535. value: function renderMatches(matches) {
  20536. if (matches.length === 0) {
  20537. return
  20538. }
  20539. var textContentItemsStr = this.textContentItemsStr;
  20540. var textDivs = this.textDivs;
  20541. var prevEnd = null;
  20542. var pageIdx = this.pageIdx;
  20543. var isSelectedPage = this.findController === null ? false: pageIdx === this.findController.selected.pageIdx;
  20544. var selectedMatchIdx = this.findController === null ? -1 : this.findController.selected.matchIdx;
  20545. var highlightAll = this.findController === null ? false: this.findController.state.highlightAll;
  20546. var infinity = {
  20547. divIdx: -1,
  20548. offset: undefined
  20549. };
  20550. function beginText(begin, className) {
  20551. var divIdx = begin.divIdx;
  20552. textDivs[divIdx].textContent = '';
  20553. appendTextToDiv(divIdx, 0, begin.offset, className)
  20554. }
  20555. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  20556. var div = textDivs[divIdx];
  20557. var content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  20558. var node = document.createTextNode(content);
  20559. if (className) {
  20560. var span = document.createElement('span');
  20561. span.className = className;
  20562. span.appendChild(node);
  20563. div.appendChild(span);
  20564. return
  20565. }
  20566. div.appendChild(node)
  20567. }
  20568. var i0 = selectedMatchIdx,
  20569. i1 = i0 + 1;
  20570. if (highlightAll) {
  20571. i0 = 0;
  20572. i1 = matches.length
  20573. } else if (!isSelectedPage) {
  20574. return
  20575. }
  20576. for (var i = i0; i < i1; i++) {
  20577. var match = matches[i];
  20578. var begin = match.begin;
  20579. var end = match.end;
  20580. var isSelected = isSelectedPage && i === selectedMatchIdx;
  20581. var highlightSuffix = isSelected ? ' selected': '';
  20582. if (this.findController) {
  20583. this.findController.updateMatchPosition(pageIdx, i, textDivs, begin.divIdx)
  20584. }
  20585. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  20586. if (prevEnd !== null) {
  20587. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset)
  20588. }
  20589. beginText(begin)
  20590. } else {
  20591. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset)
  20592. }
  20593. if (begin.divIdx === end.divIdx) {
  20594. appendTextToDiv(begin.divIdx, begin.offset, end.offset, 'highlight' + highlightSuffix)
  20595. } else {
  20596. appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, 'highlight begin' + highlightSuffix);
  20597. for (var n0 = begin.divIdx + 1,
  20598. n1 = end.divIdx; n0 < n1; n0++) {
  20599. textDivs[n0].className = 'highlight middle' + highlightSuffix
  20600. }
  20601. beginText(end, 'highlight end' + highlightSuffix)
  20602. }
  20603. prevEnd = end
  20604. }
  20605. if (prevEnd) {
  20606. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset)
  20607. }
  20608. }
  20609. },
  20610. {
  20611. key: 'updateMatches',
  20612. value: function updateMatches() {
  20613. if (!this.renderingDone) {
  20614. return
  20615. }
  20616. var matches = this.matches;
  20617. var textDivs = this.textDivs;
  20618. var textContentItemsStr = this.textContentItemsStr;
  20619. var clearedUntilDivIdx = -1;
  20620. for (var i = 0,
  20621. len = matches.length; i < len; i++) {
  20622. var match = matches[i];
  20623. var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  20624. for (var n = begin,
  20625. end = match.end.divIdx; n <= end; n++) {
  20626. var div = textDivs[n];
  20627. div.textContent = textContentItemsStr[n];
  20628. div.className = ''
  20629. }
  20630. clearedUntilDivIdx = match.end.divIdx + 1
  20631. }
  20632. if (this.findController === null || !this.findController.active) {
  20633. return
  20634. }
  20635. var pageMatches = void 0,
  20636. pageMatchesLength = void 0;
  20637. if (this.findController !== null) {
  20638. pageMatches = this.findController.pageMatches[this.pageIdx] || null;
  20639. pageMatchesLength = this.findController.pageMatchesLength ? this.findController.pageMatchesLength[this.pageIdx] || null: null
  20640. }
  20641. this.matches = this.convertMatches(pageMatches, pageMatchesLength);
  20642. this.renderMatches(this.matches)
  20643. }
  20644. },
  20645. {
  20646. key: '_bindMouse',
  20647. value: function _bindMouse() {
  20648. var _this2 = this;
  20649. var div = this.textLayerDiv;
  20650. var expandDivsTimer = null;
  20651. div.addEventListener('mousedown',
  20652. function(evt) {
  20653. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  20654. _this2.textLayerRenderTask.expandTextDivs(true);
  20655. if (expandDivsTimer) {
  20656. clearTimeout(expandDivsTimer);
  20657. expandDivsTimer = null
  20658. }
  20659. return
  20660. }
  20661. var end = div.querySelector('.endOfContent');
  20662. if (!end) {
  20663. return
  20664. }
  20665. var adjustTop = evt.target !== div;
  20666. adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue('-moz-user-select') !== 'none';
  20667. if (adjustTop) {
  20668. var divBounds = div.getBoundingClientRect();
  20669. var r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  20670. end.style.top = (r * 100).toFixed(2) + '%'
  20671. }
  20672. end.classList.add('active')
  20673. });
  20674. div.addEventListener('mouseup',
  20675. function() {
  20676. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  20677. expandDivsTimer = setTimeout(function() {
  20678. if (_this2.textLayerRenderTask) {
  20679. _this2.textLayerRenderTask.expandTextDivs(false)
  20680. }
  20681. expandDivsTimer = null
  20682. },
  20683. EXPAND_DIVS_TIMEOUT);
  20684. return
  20685. }
  20686. var end = div.querySelector('.endOfContent');
  20687. if (!end) {
  20688. return
  20689. }
  20690. end.style.top = '';
  20691. end.classList.remove('active')
  20692. })
  20693. }
  20694. }]);
  20695. return TextLayerBuilder
  20696. } ();
  20697. var DefaultTextLayerFactory = function() {
  20698. function DefaultTextLayerFactory() {
  20699. _classCallCheck(this, DefaultTextLayerFactory)
  20700. }
  20701. _createClass(DefaultTextLayerFactory, [{
  20702. key: 'createTextLayerBuilder',
  20703. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  20704. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  20705. return new TextLayerBuilder({
  20706. textLayerDiv: textLayerDiv,
  20707. pageIndex: pageIndex,
  20708. viewport: viewport,
  20709. enhanceTextSelection: enhanceTextSelection
  20710. })
  20711. }
  20712. }]);
  20713. return DefaultTextLayerFactory
  20714. } ();
  20715. exports.TextLayerBuilder = TextLayerBuilder;
  20716. exports.DefaultTextLayerFactory = DefaultTextLayerFactory
  20717. }), (function(module, exports, __webpack_require__) {
  20718. "use strict";
  20719. Object.defineProperty(exports, "__esModule", {
  20720. value: true
  20721. });
  20722. exports.Toolbar = undefined;
  20723. var _createClass = function() {
  20724. function defineProperties(target, props) {
  20725. for (var i = 0; i < props.length; i++) {
  20726. var descriptor = props[i];
  20727. descriptor.enumerable = descriptor.enumerable || false;
  20728. descriptor.configurable = true;
  20729. if ("value" in descriptor) descriptor.writable = true;
  20730. Object.defineProperty(target, descriptor.key, descriptor)
  20731. }
  20732. }
  20733. return function(Constructor, protoProps, staticProps) {
  20734. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  20735. if (staticProps) defineProperties(Constructor, staticProps);
  20736. return Constructor
  20737. }
  20738. } ();
  20739. var _ui_utils = __webpack_require__(0);
  20740. function _classCallCheck(instance, Constructor) {
  20741. if (! (instance instanceof Constructor)) {
  20742. throw new TypeError("Cannot call a class as a function");
  20743. }
  20744. }
  20745. var PAGE_NUMBER_LOADING_INDICATOR = 'visiblePageIsLoading';
  20746. var SCALE_SELECT_CONTAINER_PADDING = 8;
  20747. var SCALE_SELECT_PADDING = 22;
  20748. var Toolbar = function() {
  20749. function Toolbar(options, mainContainer, eventBus) {
  20750. var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
  20751. _classCallCheck(this, Toolbar);
  20752. this.toolbar = options.container;
  20753. this.mainContainer = mainContainer;
  20754. this.eventBus = eventBus;
  20755. this.l10n = l10n;
  20756. this.items = options;
  20757. this._wasLocalized = false;
  20758. this.reset();
  20759. this._bindListeners()
  20760. }
  20761. _createClass(Toolbar, [{
  20762. key: 'setPageNumber',
  20763. value: function setPageNumber(pageNumber, pageLabel) {
  20764. this.pageNumber = pageNumber;
  20765. this.pageLabel = pageLabel;
  20766. this._updateUIState(false)
  20767. }
  20768. },
  20769. {
  20770. key: 'setPagesCount',
  20771. value: function setPagesCount(pagesCount, hasPageLabels) {
  20772. this.pagesCount = pagesCount;
  20773. this.hasPageLabels = hasPageLabels;
  20774. this._updateUIState(true)
  20775. }
  20776. },
  20777. {
  20778. key: 'setPageScale',
  20779. value: function setPageScale(pageScaleValue, pageScale) {
  20780. this.pageScaleValue = pageScaleValue;
  20781. this.pageScale = pageScale;
  20782. this._updateUIState(false)
  20783. }
  20784. },
  20785. {
  20786. key: 'reset',
  20787. value: function reset() {
  20788. this.pageNumber = 0;
  20789. this.pageLabel = null;
  20790. this.hasPageLabels = false;
  20791. this.pagesCount = 0;
  20792. this.pageScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  20793. this.pageScale = _ui_utils.DEFAULT_SCALE;
  20794. this._updateUIState(true)
  20795. }
  20796. },
  20797. {
  20798. key: '_bindListeners',
  20799. value: function _bindListeners() {
  20800. var _this = this;
  20801. var eventBus = this.eventBus,
  20802. items = this.items;
  20803. var self = this;
  20804. items.previous.addEventListener('click',
  20805. function() {
  20806. eventBus.dispatch('previouspage')
  20807. });
  20808. items.next.addEventListener('click',
  20809. function() {
  20810. eventBus.dispatch('nextpage')
  20811. });
  20812. items.zoomIn.addEventListener('click',
  20813. function() {
  20814. eventBus.dispatch('zoomin')
  20815. });
  20816. items.zoomOut.addEventListener('click',
  20817. function() {
  20818. eventBus.dispatch('zoomout')
  20819. });
  20820. items.pageNumber.addEventListener('click',
  20821. function() {
  20822. this.select()
  20823. });
  20824. items.pageNumber.addEventListener('change',
  20825. function() {
  20826. eventBus.dispatch('pagenumberchanged', {
  20827. source: self,
  20828. value: this.value
  20829. })
  20830. });
  20831. items.scaleSelect.addEventListener('change',
  20832. function() {
  20833. if (this.value === 'custom') {
  20834. return
  20835. }
  20836. eventBus.dispatch('scalechanged', {
  20837. source: self,
  20838. value: this.value
  20839. })
  20840. });
  20841. items.presentationModeButton.addEventListener('click',
  20842. function() {
  20843. eventBus.dispatch('presentationmode')
  20844. });
  20845. items.openFile.addEventListener('click',
  20846. function() {
  20847. eventBus.dispatch('openfile')
  20848. });
  20849. items.print.addEventListener('click',
  20850. function() {
  20851. eventBus.dispatch('print')
  20852. });
  20853. items.download.addEventListener('click',
  20854. function() {
  20855. eventBus.dispatch('download')
  20856. });
  20857. items.scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler;
  20858. eventBus.on('localized',
  20859. function() {
  20860. _this._localized()
  20861. })
  20862. }
  20863. },
  20864. {
  20865. key: '_localized',
  20866. value: function _localized() {
  20867. this._wasLocalized = true;
  20868. this._adjustScaleWidth();
  20869. this._updateUIState(true)
  20870. }
  20871. },
  20872. {
  20873. key: '_updateUIState',
  20874. value: function _updateUIState() {
  20875. var resetNumPages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  20876. if (!this._wasLocalized) {
  20877. return
  20878. }
  20879. var pageNumber = this.pageNumber,
  20880. pagesCount = this.pagesCount,
  20881. items = this.items;
  20882. var scaleValue = (this.pageScaleValue || this.pageScale).toString();
  20883. var scale = this.pageScale;
  20884. if (resetNumPages) {
  20885. if (this.hasPageLabels) {
  20886. items.pageNumber.type = 'text'
  20887. } else {
  20888. items.pageNumber.type = 'number';
  20889. this.l10n.get('of_pages', {
  20890. pagesCount: pagesCount
  20891. },
  20892. 'of {{pagesCount}}').then(function(msg) {
  20893. items.numPages.textContent = msg
  20894. })
  20895. }
  20896. items.pageNumber.max = pagesCount
  20897. }
  20898. if (this.hasPageLabels) {
  20899. items.pageNumber.value = this.pageLabel;
  20900. this.l10n.get('page_of_pages', {
  20901. pageNumber: pageNumber,
  20902. pagesCount: pagesCount
  20903. },
  20904. '({{pageNumber}} of {{pagesCount}})').then(function(msg) {
  20905. items.numPages.textContent = msg
  20906. })
  20907. } else {
  20908. items.pageNumber.value = pageNumber
  20909. }
  20910. items.previous.disabled = pageNumber <= 1;
  20911. items.next.disabled = pageNumber >= pagesCount;
  20912. items.zoomOut.disabled = scale <= _ui_utils.MIN_SCALE;
  20913. items.zoomIn.disabled = scale >= _ui_utils.MAX_SCALE;
  20914. var customScale = Math.round(scale * 10000) / 100;
  20915. this.l10n.get('page_scale_percent', {
  20916. scale: customScale
  20917. },
  20918. '{{scale}}%').then(function(msg) {
  20919. var options = items.scaleSelect.options;
  20920. var predefinedValueFound = false;
  20921. for (var i = 0,
  20922. ii = options.length; i < ii; i++) {
  20923. var option = options[i];
  20924. if (option.value !== scaleValue) {
  20925. option.selected = false;
  20926. continue
  20927. }
  20928. option.selected = true;
  20929. predefinedValueFound = true
  20930. }
  20931. if (!predefinedValueFound) {
  20932. items.customScaleOption.textContent = msg;
  20933. items.customScaleOption.selected = true
  20934. }
  20935. })
  20936. }
  20937. },
  20938. {
  20939. key: 'updateLoadingIndicatorState',
  20940. value: function updateLoadingIndicatorState() {
  20941. var loading = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  20942. var pageNumberInput = this.items.pageNumber;
  20943. if (loading) {
  20944. pageNumberInput.classList.add(PAGE_NUMBER_LOADING_INDICATOR)
  20945. } else {
  20946. pageNumberInput.classList.remove(PAGE_NUMBER_LOADING_INDICATOR)
  20947. }
  20948. }
  20949. },
  20950. {
  20951. key: '_adjustScaleWidth',
  20952. value: function _adjustScaleWidth() {
  20953. var container = this.items.scaleSelectContainer;
  20954. var select = this.items.scaleSelect;
  20955. _ui_utils.animationStarted.then(function() {
  20956. if (container.clientWidth === 0) {
  20957. container.setAttribute('style', 'display: inherit;')
  20958. }
  20959. if (container.clientWidth > 0) {
  20960. select.setAttribute('style', 'min-width: inherit;');
  20961. var width = select.clientWidth + SCALE_SELECT_CONTAINER_PADDING;
  20962. select.setAttribute('style', 'min-width: ' + (width + SCALE_SELECT_PADDING) + 'px;');
  20963. container.setAttribute('style', 'min-width: ' + width + 'px; ' + 'max-width: ' + width + 'px;')
  20964. }
  20965. })
  20966. }
  20967. }]);
  20968. return Toolbar
  20969. } ();
  20970. exports.Toolbar = Toolbar
  20971. }), (function(module, exports, __webpack_require__) {
  20972. "use strict";
  20973. Object.defineProperty(exports, "__esModule", {
  20974. value: true
  20975. });
  20976. var _createClass = function() {
  20977. function defineProperties(target, props) {
  20978. for (var i = 0; i < props.length; i++) {
  20979. var descriptor = props[i];
  20980. descriptor.enumerable = descriptor.enumerable || false;
  20981. descriptor.configurable = true;
  20982. if ("value" in descriptor) descriptor.writable = true;
  20983. Object.defineProperty(target, descriptor.key, descriptor)
  20984. }
  20985. }
  20986. return function(Constructor, protoProps, staticProps) {
  20987. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  20988. if (staticProps) defineProperties(Constructor, staticProps);
  20989. return Constructor
  20990. }
  20991. } ();
  20992. function _classCallCheck(instance, Constructor) {
  20993. if (! (instance instanceof Constructor)) {
  20994. throw new TypeError("Cannot call a class as a function");
  20995. }
  20996. }
  20997. var DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
  20998. var ViewHistory = function() {
  20999. function ViewHistory(fingerprint) {
  21000. var _this = this;
  21001. var cacheSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_VIEW_HISTORY_CACHE_SIZE;
  21002. _classCallCheck(this, ViewHistory);
  21003. this.fingerprint = fingerprint;
  21004. this.cacheSize = cacheSize;
  21005. this._initializedPromise = this._readFromStorage().then(function(databaseStr) {
  21006. var database = JSON.parse(databaseStr || '{}');
  21007. if (! ('files' in database)) {
  21008. database.files = []
  21009. }
  21010. if (database.files.length >= _this.cacheSize) {
  21011. database.files.shift()
  21012. }
  21013. var index = void 0;
  21014. for (var i = 0,
  21015. length = database.files.length; i < length; i++) {
  21016. var branch = database.files[i];
  21017. if (branch.fingerprint === _this.fingerprint) {
  21018. index = i;
  21019. break
  21020. }
  21021. }
  21022. if (typeof index !== 'number') {
  21023. index = database.files.push({
  21024. fingerprint: _this.fingerprint
  21025. }) - 1
  21026. }
  21027. _this.file = database.files[index];
  21028. _this.database = database
  21029. })
  21030. }
  21031. _createClass(ViewHistory, [{
  21032. key: '_writeToStorage',
  21033. value: function _writeToStorage() {
  21034. var _this2 = this;
  21035. return new Promise(function(resolve) {
  21036. var databaseStr = JSON.stringify(_this2.database);
  21037. localStorage.setItem('pdfjs.history', databaseStr);
  21038. resolve()
  21039. })
  21040. }
  21041. },
  21042. {
  21043. key: '_readFromStorage',
  21044. value: function _readFromStorage() {
  21045. return new Promise(function(resolve) {
  21046. var value = localStorage.getItem('pdfjs.history');
  21047. if (!value) {
  21048. var databaseStr = localStorage.getItem('database');
  21049. if (databaseStr) {
  21050. try {
  21051. var database = JSON.parse(databaseStr);
  21052. if (typeof database.files[0].fingerprint === 'string') {
  21053. localStorage.setItem('pdfjs.history', databaseStr);
  21054. localStorage.removeItem('database');
  21055. value = databaseStr
  21056. }
  21057. } catch(ex) {}
  21058. }
  21059. }
  21060. resolve(value)
  21061. })
  21062. }
  21063. },
  21064. {
  21065. key: 'set',
  21066. value: function set(name, val) {
  21067. var _this3 = this;
  21068. return this._initializedPromise.then(function() {
  21069. _this3.file[name] = val;
  21070. return _this3._writeToStorage()
  21071. })
  21072. }
  21073. },
  21074. {
  21075. key: 'setMultiple',
  21076. value: function setMultiple(properties) {
  21077. var _this4 = this;
  21078. return this._initializedPromise.then(function() {
  21079. for (var name in properties) {
  21080. _this4.file[name] = properties[name]
  21081. }
  21082. return _this4._writeToStorage()
  21083. })
  21084. }
  21085. },
  21086. {
  21087. key: 'get',
  21088. value: function get(name, defaultValue) {
  21089. var _this5 = this;
  21090. return this._initializedPromise.then(function() {
  21091. var val = _this5.file[name];
  21092. return val !== undefined ? val: defaultValue
  21093. })
  21094. }
  21095. },
  21096. {
  21097. key: 'getMultiple',
  21098. value: function getMultiple(properties) {
  21099. var _this6 = this;
  21100. return this._initializedPromise.then(function() {
  21101. var values = Object.create(null);
  21102. for (var name in properties) {
  21103. var val = _this6.file[name];
  21104. values[name] = val !== undefined ? val: properties[name]
  21105. }
  21106. return values
  21107. })
  21108. }
  21109. }]);
  21110. return ViewHistory
  21111. } ();
  21112. exports.ViewHistory = ViewHistory
  21113. }), (function(module, exports, __webpack_require__) {
  21114. "use strict";
  21115. var DEFAULT_URL = cgl_pdf_src;
  21116. var pdfjsWebApp = void 0; {
  21117. pdfjsWebApp = __webpack_require__(4)
  21118. }; {
  21119. __webpack_require__(8)
  21120. }; {
  21121. __webpack_require__(9)
  21122. }
  21123. function getViewerConfiguration() {
  21124. return {
  21125. appContainer: document.body,
  21126. mainContainer: document.getElementById('viewerContainer'),
  21127. viewerContainer: document.getElementById('viewer'),
  21128. eventBus: null,
  21129. toolbar: {
  21130. container: document.getElementById('toolbarViewer'),
  21131. numPages: document.getElementById('numPages'),
  21132. pageNumber: document.getElementById('pageNumber'),
  21133. scaleSelectContainer: document.getElementById('scaleSelectContainer'),
  21134. scaleSelect: document.getElementById('scaleSelect'),
  21135. customScaleOption: document.getElementById('customScaleOption'),
  21136. previous: document.getElementById('previous'),
  21137. next: document.getElementById('next'),
  21138. zoomIn: document.getElementById('zoomIn'),
  21139. zoomOut: document.getElementById('zoomOut'),
  21140. viewFind: document.getElementById('viewFind'),
  21141. openFile: document.getElementById('openFile'),
  21142. print: document.getElementById('print'),
  21143. presentationModeButton: document.getElementById('presentationMode'),
  21144. download: document.getElementById('download'),
  21145. viewBookmark: document.getElementById('viewBookmark')
  21146. },
  21147. secondaryToolbar: {
  21148. toolbar: document.getElementById('secondaryToolbar'),
  21149. toggleButton: document.getElementById('secondaryToolbarToggle'),
  21150. toolbarButtonContainer: document.getElementById('secondaryToolbarButtonContainer'),
  21151. presentationModeButton: document.getElementById('secondaryPresentationMode'),
  21152. openFileButton: document.getElementById('secondaryOpenFile'),
  21153. printButton: document.getElementById('secondaryPrint'),
  21154. downloadButton: document.getElementById('secondaryDownload'),
  21155. viewBookmarkButton: document.getElementById('secondaryViewBookmark'),
  21156. firstPageButton: document.getElementById('firstPage'),
  21157. lastPageButton: document.getElementById('lastPage'),
  21158. pageRotateCwButton: document.getElementById('pageRotateCw'),
  21159. pageRotateCcwButton: document.getElementById('pageRotateCcw'),
  21160. cursorSelectToolButton: document.getElementById('cursorSelectTool'),
  21161. cursorHandToolButton: document.getElementById('cursorHandTool'),
  21162. documentPropertiesButton: document.getElementById('documentProperties')
  21163. },
  21164. fullscreen: {
  21165. contextFirstPage: document.getElementById('contextFirstPage'),
  21166. contextLastPage: document.getElementById('contextLastPage'),
  21167. contextPageRotateCw: document.getElementById('contextPageRotateCw'),
  21168. contextPageRotateCcw: document.getElementById('contextPageRotateCcw')
  21169. },
  21170. sidebar: {
  21171. mainContainer: document.getElementById('mainContainer'),
  21172. outerContainer: document.getElementById('outerContainer'),
  21173. toggleButton: document.getElementById('sidebarToggle'),
  21174. thumbnailButton: document.getElementById('viewThumbnail'),
  21175. outlineButton: document.getElementById('viewOutline'),
  21176. attachmentsButton: document.getElementById('viewAttachments'),
  21177. thumbnailView: document.getElementById('thumbnailView'),
  21178. outlineView: document.getElementById('outlineView'),
  21179. attachmentsView: document.getElementById('attachmentsView')
  21180. },
  21181. findBar: {
  21182. bar: document.getElementById('findbar'),
  21183. toggleButton: document.getElementById('viewFind'),
  21184. findField: document.getElementById('findInput'),
  21185. highlightAllCheckbox: document.getElementById('findHighlightAll'),
  21186. caseSensitiveCheckbox: document.getElementById('findMatchCase'),
  21187. findMsg: document.getElementById('findMsg'),
  21188. findResultsCount: document.getElementById('findResultsCount'),
  21189. findStatusIcon: document.getElementById('findStatusIcon'),
  21190. findPreviousButton: document.getElementById('findPrevious'),
  21191. findNextButton: document.getElementById('findNext')
  21192. },
  21193. passwordOverlay: {
  21194. overlayName: 'passwordOverlay',
  21195. container: document.getElementById('passwordOverlay'),
  21196. label: document.getElementById('passwordText'),
  21197. input: document.getElementById('password'),
  21198. submitButton: document.getElementById('passwordSubmit'),
  21199. cancelButton: document.getElementById('passwordCancel')
  21200. },
  21201. documentProperties: {
  21202. overlayName: 'documentPropertiesOverlay',
  21203. container: document.getElementById('documentPropertiesOverlay'),
  21204. closeButton: document.getElementById('documentPropertiesClose'),
  21205. fields: {
  21206. 'fileName': document.getElementById('fileNameField'),
  21207. 'fileSize': document.getElementById('fileSizeField'),
  21208. 'title': document.getElementById('titleField'),
  21209. 'author': document.getElementById('authorField'),
  21210. 'subject': document.getElementById('subjectField'),
  21211. 'keywords': document.getElementById('keywordsField'),
  21212. 'creationDate': document.getElementById('creationDateField'),
  21213. 'modificationDate': document.getElementById('modificationDateField'),
  21214. 'creator': document.getElementById('creatorField'),
  21215. 'producer': document.getElementById('producerField'),
  21216. 'version': document.getElementById('versionField'),
  21217. 'pageCount': document.getElementById('pageCountField')
  21218. }
  21219. },
  21220. errorWrapper: {
  21221. container: document.getElementById('errorWrapper'),
  21222. errorMessage: document.getElementById('errorMessage'),
  21223. closeButton: document.getElementById('errorClose'),
  21224. errorMoreInfo: document.getElementById('errorMoreInfo'),
  21225. moreInfoButton: document.getElementById('errorShowMore'),
  21226. lessInfoButton: document.getElementById('errorShowLess')
  21227. },
  21228. printContainer: document.getElementById('printContainer'),
  21229. openFileInputName: 'fileInput',
  21230. debuggerScriptPath: './debugger.js',
  21231. defaultUrl: DEFAULT_URL
  21232. }
  21233. }
  21234. function webViewerLoad() {
  21235. var config = getViewerConfiguration();
  21236. window.PDFViewerApplication = pdfjsWebApp.PDFViewerApplication;
  21237. pdfjsWebApp.PDFViewerApplication.run(config)
  21238. }
  21239. if (document.readyState === 'interactive' || document.readyState === 'complete') {
  21240. webViewerLoad()
  21241. } else {
  21242. document.addEventListener('DOMContentLoaded', webViewerLoad, true)
  21243. }
  21244. })]);