pdfviewerwithwatermask.js 462 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2018 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * Javascript code in this page
  21. */
  22. /******/ (function(modules) { // webpackBootstrap
  23. /******/ // The module cache
  24. /******/ var installedModules = {};
  25. /******/
  26. /******/ // The require function
  27. /******/ function __webpack_require__(moduleId) {
  28. /******/
  29. /******/ // Check if module is in cache
  30. /******/ if(installedModules[moduleId]) {
  31. /******/ return installedModules[moduleId].exports;
  32. /******/ }
  33. /******/ // Create a new module (and put it into the cache)
  34. /******/ var module = installedModules[moduleId] = {
  35. /******/ i: moduleId,
  36. /******/ l: false,
  37. /******/ exports: {}
  38. /******/ };
  39. /******/
  40. /******/ // Execute the module function
  41. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  42. /******/
  43. /******/ // Flag the module as loaded
  44. /******/ module.l = true;
  45. /******/
  46. /******/ // Return the exports of the module
  47. /******/ return module.exports;
  48. /******/ }
  49. /******/
  50. /******/
  51. /******/ // expose the modules object (__webpack_modules__)
  52. /******/ __webpack_require__.m = modules;
  53. /******/
  54. /******/ // expose the module cache
  55. /******/ __webpack_require__.c = installedModules;
  56. /******/
  57. /******/ // define getter function for harmony exports
  58. /******/ __webpack_require__.d = function(exports, name, getter) {
  59. /******/ if(!__webpack_require__.o(exports, name)) {
  60. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  61. /******/ }
  62. /******/ };
  63. /******/
  64. /******/ // define __esModule on exports
  65. /******/ __webpack_require__.r = function(exports) {
  66. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  67. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  68. /******/ }
  69. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  70. /******/ };
  71. /******/
  72. /******/ // create a fake namespace object
  73. /******/ // mode & 1: value is a module id, require it
  74. /******/ // mode & 2: merge all properties of value into the ns
  75. /******/ // mode & 4: return value when already ns object
  76. /******/ // mode & 8|1: behave like require
  77. /******/ __webpack_require__.t = function(value, mode) {
  78. /******/ if(mode & 1) value = __webpack_require__(value);
  79. /******/ if(mode & 8) return value;
  80. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  81. /******/ var ns = Object.create(null);
  82. /******/ __webpack_require__.r(ns);
  83. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  84. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  85. /******/ return ns;
  86. /******/ };
  87. /******/
  88. /******/ // getDefaultExport function for compatibility with non-harmony modules
  89. /******/ __webpack_require__.n = function(module) {
  90. /******/ var getter = module && module.__esModule ?
  91. /******/ function getDefault() { return module['default']; } :
  92. /******/ function getModuleExports() { return module; };
  93. /******/ __webpack_require__.d(getter, 'a', getter);
  94. /******/ return getter;
  95. /******/ };
  96. /******/
  97. /******/ // Object.prototype.hasOwnProperty.call
  98. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  99. /******/
  100. /******/ // __webpack_public_path__
  101. /******/ __webpack_require__.p = "";
  102. /******/
  103. /******/
  104. /******/ // Load entry module and return exports
  105. /******/ return __webpack_require__(__webpack_require__.s = 0);
  106. /******/ })
  107. /************************************************************************/
  108. /******/ ([
  109. /* 0 */
  110. /***/ (function(module, exports, __webpack_require__) {
  111. "use strict";
  112. ;
  113. var pdfjsWebApp, pdfjsWebAppOptions;
  114. {
  115. pdfjsWebApp = __webpack_require__(1);
  116. pdfjsWebAppOptions = __webpack_require__(12);
  117. }
  118. ;
  119. {
  120. __webpack_require__(37);
  121. }
  122. ;
  123. {
  124. __webpack_require__(42);
  125. }
  126. function getViewerConfiguration() {
  127. return {
  128. appContainer: document.body,
  129. mainContainer: document.getElementById('viewerContainer'),
  130. viewerContainer: document.getElementById('viewer'),
  131. eventBus: null,
  132. toolbar: {
  133. container: document.getElementById('toolbarViewer'),
  134. numPages: document.getElementById('numPages'),
  135. pageNumber: document.getElementById('pageNumber'),
  136. scaleSelectContainer: document.getElementById('scaleSelectContainer'),
  137. scaleSelect: document.getElementById('scaleSelect'),
  138. customScaleOption: document.getElementById('customScaleOption'),
  139. previous: document.getElementById('previous'),
  140. next: document.getElementById('next'),
  141. zoomIn: document.getElementById('zoomIn'),
  142. zoomOut: document.getElementById('zoomOut'),
  143. viewFind: document.getElementById('viewFind'),
  144. openFile: document.getElementById('openFile'),
  145. print: document.getElementById('print'),
  146. presentationModeButton: document.getElementById('presentationMode'),
  147. download: document.getElementById('download'),
  148. viewBookmark: document.getElementById('viewBookmark')
  149. },
  150. secondaryToolbar: {
  151. toolbar: document.getElementById('secondaryToolbar'),
  152. toggleButton: document.getElementById('secondaryToolbarToggle'),
  153. toolbarButtonContainer: document.getElementById('secondaryToolbarButtonContainer'),
  154. presentationModeButton: document.getElementById('secondaryPresentationMode'),
  155. openFileButton: document.getElementById('secondaryOpenFile'),
  156. printButton: document.getElementById('secondaryPrint'),
  157. downloadButton: document.getElementById('secondaryDownload'),
  158. viewBookmarkButton: document.getElementById('secondaryViewBookmark'),
  159. firstPageButton: document.getElementById('firstPage'),
  160. lastPageButton: document.getElementById('lastPage'),
  161. pageRotateCwButton: document.getElementById('pageRotateCw'),
  162. pageRotateCcwButton: document.getElementById('pageRotateCcw'),
  163. cursorSelectToolButton: document.getElementById('cursorSelectTool'),
  164. cursorHandToolButton: document.getElementById('cursorHandTool'),
  165. scrollVerticalButton: document.getElementById('scrollVertical'),
  166. scrollHorizontalButton: document.getElementById('scrollHorizontal'),
  167. scrollWrappedButton: document.getElementById('scrollWrapped'),
  168. spreadNoneButton: document.getElementById('spreadNone'),
  169. spreadOddButton: document.getElementById('spreadOdd'),
  170. spreadEvenButton: document.getElementById('spreadEven'),
  171. documentPropertiesButton: document.getElementById('documentProperties')
  172. },
  173. fullscreen: {
  174. contextFirstPage: document.getElementById('contextFirstPage'),
  175. contextLastPage: document.getElementById('contextLastPage'),
  176. contextPageRotateCw: document.getElementById('contextPageRotateCw'),
  177. contextPageRotateCcw: document.getElementById('contextPageRotateCcw')
  178. },
  179. sidebar: {
  180. outerContainer: document.getElementById('outerContainer'),
  181. viewerContainer: document.getElementById('viewerContainer'),
  182. toggleButton: document.getElementById('sidebarToggle'),
  183. thumbnailButton: document.getElementById('viewThumbnail'),
  184. outlineButton: document.getElementById('viewOutline'),
  185. attachmentsButton: document.getElementById('viewAttachments'),
  186. thumbnailView: document.getElementById('thumbnailView'),
  187. outlineView: document.getElementById('outlineView'),
  188. attachmentsView: document.getElementById('attachmentsView')
  189. },
  190. sidebarResizer: {
  191. outerContainer: document.getElementById('outerContainer'),
  192. resizer: document.getElementById('sidebarResizer')
  193. },
  194. findBar: {
  195. bar: document.getElementById('findbar'),
  196. toggleButton: document.getElementById('viewFind'),
  197. findField: document.getElementById('findInput'),
  198. highlightAllCheckbox: document.getElementById('findHighlightAll'),
  199. caseSensitiveCheckbox: document.getElementById('findMatchCase'),
  200. entireWordCheckbox: document.getElementById('findEntireWord'),
  201. findMsg: document.getElementById('findMsg'),
  202. findResultsCount: document.getElementById('findResultsCount'),
  203. findPreviousButton: document.getElementById('findPrevious'),
  204. findNextButton: document.getElementById('findNext')
  205. },
  206. passwordOverlay: {
  207. overlayName: 'passwordOverlay',
  208. container: document.getElementById('passwordOverlay'),
  209. label: document.getElementById('passwordText'),
  210. input: document.getElementById('password'),
  211. submitButton: document.getElementById('passwordSubmit'),
  212. cancelButton: document.getElementById('passwordCancel')
  213. },
  214. documentProperties: {
  215. overlayName: 'documentPropertiesOverlay',
  216. container: document.getElementById('documentPropertiesOverlay'),
  217. closeButton: document.getElementById('documentPropertiesClose'),
  218. fields: {
  219. 'fileName': document.getElementById('fileNameField'),
  220. 'fileSize': document.getElementById('fileSizeField'),
  221. 'title': document.getElementById('titleField'),
  222. 'author': document.getElementById('authorField'),
  223. 'subject': document.getElementById('subjectField'),
  224. 'keywords': document.getElementById('keywordsField'),
  225. 'creationDate': document.getElementById('creationDateField'),
  226. 'modificationDate': document.getElementById('modificationDateField'),
  227. 'creator': document.getElementById('creatorField'),
  228. 'producer': document.getElementById('producerField'),
  229. 'version': document.getElementById('versionField'),
  230. 'pageCount': document.getElementById('pageCountField'),
  231. 'pageSize': document.getElementById('pageSizeField'),
  232. 'linearized': document.getElementById('linearizedField')
  233. }
  234. },
  235. errorWrapper: {
  236. container: document.getElementById('errorWrapper'),
  237. errorMessage: document.getElementById('errorMessage'),
  238. closeButton: document.getElementById('errorClose'),
  239. errorMoreInfo: document.getElementById('errorMoreInfo'),
  240. moreInfoButton: document.getElementById('errorShowMore'),
  241. lessInfoButton: document.getElementById('errorShowLess')
  242. },
  243. printContainer: document.getElementById('printContainer'),
  244. openFileInputName: 'fileInput',
  245. debuggerScriptPath: '../o2_lib/pdfjs/web/debugger.js'
  246. };
  247. }
  248. function webViewerLoad() {
  249. var config = getViewerConfiguration();
  250. window.PDFViewerApplication = pdfjsWebApp.PDFViewerApplication;
  251. window.PDFViewerApplicationOptions = pdfjsWebAppOptions.AppOptions;
  252. var event = document.createEvent('CustomEvent');
  253. event.initCustomEvent('webviewerloaded', true, true, {});
  254. document.dispatchEvent(event);
  255. pdfjsWebApp.PDFViewerApplication.run(config);
  256. }
  257. if (document.readyState === 'interactive' || document.readyState === 'complete') {
  258. webViewerLoad();
  259. } else {
  260. document.addEventListener('DOMContentLoaded', webViewerLoad, true);
  261. }
  262. /***/ }),
  263. /* 1 */
  264. /***/ (function(module, exports, __webpack_require__) {
  265. "use strict";
  266. Object.defineProperty(exports, "__esModule", {
  267. value: true
  268. });
  269. exports.PDFPrintServiceFactory = exports.DefaultExternalServices = exports.PDFViewerApplication = void 0;
  270. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  271. var _ui_utils = __webpack_require__(6);
  272. var _pdfjsLib = __webpack_require__(7);
  273. var _pdf_cursor_tools = __webpack_require__(8);
  274. var _pdf_rendering_queue = __webpack_require__(10);
  275. var _pdf_sidebar = __webpack_require__(11);
  276. var _app_options = __webpack_require__(12);
  277. var _overlay_manager = __webpack_require__(14);
  278. var _password_prompt = __webpack_require__(15);
  279. var _pdf_attachment_viewer = __webpack_require__(16);
  280. var _pdf_document_properties = __webpack_require__(17);
  281. var _pdf_find_bar = __webpack_require__(18);
  282. var _pdf_find_controller = __webpack_require__(19);
  283. var _pdf_history = __webpack_require__(21);
  284. var _pdf_link_service = __webpack_require__(22);
  285. var _pdf_outline_viewer = __webpack_require__(23);
  286. var _pdf_presentation_mode = __webpack_require__(24);
  287. var _pdf_sidebar_resizer = __webpack_require__(25);
  288. var _pdf_thumbnail_viewer = __webpack_require__(26);
  289. var _pdf_viewer = __webpack_require__(28);
  290. var _secondary_toolbar = __webpack_require__(33);
  291. var _toolbar = __webpack_require__(35);
  292. var _view_history = __webpack_require__(36);
  293. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  294. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
  295. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
  296. function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  297. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  298. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  299. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  300. var DEFAULT_SCALE_DELTA = 1.1;
  301. var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
  302. var FORCE_PAGES_LOADED_TIMEOUT = 10000;
  303. var WHEEL_ZOOM_DISABLED_TIMEOUT = 1000;
  304. var ViewOnLoad = {
  305. UNKNOWN: -1,
  306. PREVIOUS: 0,
  307. INITIAL: 1
  308. };
  309. var DefaultExternalServices = {
  310. updateFindControlState: function updateFindControlState(data) {},
  311. updateFindMatchesCount: function updateFindMatchesCount(data) {},
  312. initPassiveLoading: function initPassiveLoading(callbacks) {},
  313. fallback: function fallback(data, callback) {},
  314. reportTelemetry: function reportTelemetry(data) {},
  315. createDownloadManager: function createDownloadManager(options) {
  316. throw new Error('Not implemented: createDownloadManager');
  317. },
  318. createPreferences: function createPreferences() {
  319. throw new Error('Not implemented: createPreferences');
  320. },
  321. createL10n: function createL10n(options) {
  322. throw new Error('Not implemented: createL10n');
  323. },
  324. supportsIntegratedFind: false,
  325. supportsDocumentFonts: true,
  326. supportsDocumentColors: true,
  327. supportedMouseWheelZoomModifierKeys: {
  328. ctrlKey: true,
  329. metaKey: true
  330. }
  331. };
  332. exports.DefaultExternalServices = DefaultExternalServices;
  333. var PDFViewerApplication = {
  334. initialBookmark: document.location.hash.substring(1),
  335. initialized: false,
  336. fellback: false,
  337. appConfig: null,
  338. pdfDocument: null,
  339. pdfLoadingTask: null,
  340. printService: null,
  341. pdfViewer: null,
  342. pdfThumbnailViewer: null,
  343. pdfRenderingQueue: null,
  344. pdfPresentationMode: null,
  345. pdfDocumentProperties: null,
  346. pdfLinkService: null,
  347. pdfHistory: null,
  348. pdfSidebar: null,
  349. pdfSidebarResizer: null,
  350. pdfOutlineViewer: null,
  351. pdfAttachmentViewer: null,
  352. pdfCursorTools: null,
  353. store: null,
  354. downloadManager: null,
  355. overlayManager: null,
  356. preferences: null,
  357. toolbar: null,
  358. secondaryToolbar: null,
  359. eventBus: null,
  360. l10n: null,
  361. isInitialViewSet: false,
  362. downloadComplete: false,
  363. isViewerEmbedded: window.parent !== window,
  364. url: '',
  365. baseUrl: '',
  366. externalServices: DefaultExternalServices,
  367. _boundEvents: {},
  368. contentDispositionFilename: null,
  369. initialize: function () {
  370. var _initialize = _asyncToGenerator(
  371. /*#__PURE__*/
  372. _regenerator.default.mark(function _callee(appConfig) {
  373. var _this = this;
  374. var appContainer;
  375. return _regenerator.default.wrap(function _callee$(_context) {
  376. while (1) {
  377. switch (_context.prev = _context.next) {
  378. case 0:
  379. this.preferences = this.externalServices.createPreferences();
  380. this.appConfig = appConfig;
  381. _context.next = 4;
  382. return this._readPreferences();
  383. case 4:
  384. _context.next = 6;
  385. return this._parseHashParameters();
  386. case 6:
  387. _context.next = 8;
  388. return this._initializeL10n();
  389. case 8:
  390. if (this.isViewerEmbedded && _app_options.AppOptions.get('externalLinkTarget') === _pdfjsLib.LinkTarget.NONE) {
  391. _app_options.AppOptions.set('externalLinkTarget', _pdfjsLib.LinkTarget.TOP);
  392. }
  393. _context.next = 11;
  394. return this._initializeViewerComponents();
  395. case 11:
  396. this.bindEvents();
  397. this.bindWindowEvents();
  398. appContainer = appConfig.appContainer || document.documentElement;
  399. this.l10n.translate(appContainer).then(function () {
  400. _this.eventBus.dispatch('localized', {
  401. source: _this
  402. });
  403. });
  404. this.initialized = true;
  405. case 16:
  406. case "end":
  407. return _context.stop();
  408. }
  409. }
  410. }, _callee, this);
  411. }));
  412. function initialize(_x) {
  413. return _initialize.apply(this, arguments);
  414. }
  415. return initialize;
  416. }(),
  417. _readPreferences: function () {
  418. var _readPreferences2 = _asyncToGenerator(
  419. /*#__PURE__*/
  420. _regenerator.default.mark(function _callee2() {
  421. var prefs, name;
  422. return _regenerator.default.wrap(function _callee2$(_context2) {
  423. while (1) {
  424. switch (_context2.prev = _context2.next) {
  425. case 0:
  426. if (!(_app_options.AppOptions.get('disablePreferences') === true)) {
  427. _context2.next = 2;
  428. break;
  429. }
  430. return _context2.abrupt("return");
  431. case 2:
  432. _context2.prev = 2;
  433. _context2.next = 5;
  434. return this.preferences.getAll();
  435. case 5:
  436. prefs = _context2.sent;
  437. for (name in prefs) {
  438. _app_options.AppOptions.set(name, prefs[name]);
  439. }
  440. _context2.next = 11;
  441. break;
  442. case 9:
  443. _context2.prev = 9;
  444. _context2.t0 = _context2["catch"](2);
  445. case 11:
  446. case "end":
  447. return _context2.stop();
  448. }
  449. }
  450. }, _callee2, this, [[2, 9]]);
  451. }));
  452. function _readPreferences() {
  453. return _readPreferences2.apply(this, arguments);
  454. }
  455. return _readPreferences;
  456. }(),
  457. _parseHashParameters: function () {
  458. var _parseHashParameters2 = _asyncToGenerator(
  459. /*#__PURE__*/
  460. _regenerator.default.mark(function _callee3() {
  461. var waitOn, hash, hashParams, viewer, enabled;
  462. return _regenerator.default.wrap(function _callee3$(_context3) {
  463. while (1) {
  464. switch (_context3.prev = _context3.next) {
  465. case 0:
  466. if (_app_options.AppOptions.get('pdfBugEnabled')) {
  467. _context3.next = 2;
  468. break;
  469. }
  470. return _context3.abrupt("return");
  471. case 2:
  472. waitOn = [];
  473. hash = document.location.hash.substring(1);
  474. hashParams = (0, _ui_utils.parseQueryString)(hash);
  475. if ('disableworker' in hashParams && hashParams['disableworker'] === 'true') {
  476. waitOn.push(loadFakeWorker());
  477. }
  478. if ('disablerange' in hashParams) {
  479. _app_options.AppOptions.set('disableRange', hashParams['disablerange'] === 'true');
  480. }
  481. if ('disablestream' in hashParams) {
  482. _app_options.AppOptions.set('disableStream', hashParams['disablestream'] === 'true');
  483. }
  484. if ('disableautofetch' in hashParams) {
  485. _app_options.AppOptions.set('disableAutoFetch', hashParams['disableautofetch'] === 'true');
  486. }
  487. if ('disablefontface' in hashParams) {
  488. _app_options.AppOptions.set('disableFontFace', hashParams['disablefontface'] === 'true');
  489. }
  490. if ('disablehistory' in hashParams) {
  491. _app_options.AppOptions.set('disableHistory', hashParams['disablehistory'] === 'true');
  492. }
  493. if ('webgl' in hashParams) {
  494. _app_options.AppOptions.set('enableWebGL', hashParams['webgl'] === 'true');
  495. }
  496. if ('useonlycsszoom' in hashParams) {
  497. _app_options.AppOptions.set('useOnlyCssZoom', hashParams['useonlycsszoom'] === 'true');
  498. }
  499. if ('verbosity' in hashParams) {
  500. _app_options.AppOptions.set('verbosity', hashParams['verbosity'] | 0);
  501. }
  502. if (!('textlayer' in hashParams)) {
  503. _context3.next = 23;
  504. break;
  505. }
  506. _context3.t0 = hashParams['textlayer'];
  507. _context3.next = _context3.t0 === 'off' ? 18 : _context3.t0 === 'visible' ? 20 : _context3.t0 === 'shadow' ? 20 : _context3.t0 === 'hover' ? 20 : 23;
  508. break;
  509. case 18:
  510. _app_options.AppOptions.set('textLayerMode', _ui_utils.TextLayerMode.DISABLE);
  511. return _context3.abrupt("break", 23);
  512. case 20:
  513. viewer = this.appConfig.viewerContainer;
  514. viewer.classList.add('textLayer-' + hashParams['textlayer']);
  515. return _context3.abrupt("break", 23);
  516. case 23:
  517. if ('pdfbug' in hashParams) {
  518. _app_options.AppOptions.set('pdfBug', true);
  519. enabled = hashParams['pdfbug'].split(',');
  520. waitOn.push(loadAndEnablePDFBug(enabled));
  521. }
  522. if ('locale' in hashParams) {
  523. _app_options.AppOptions.set('locale', hashParams['locale']);
  524. }
  525. return _context3.abrupt("return", Promise.all(waitOn).catch(function (reason) {
  526. console.error("_parseHashParameters: \"".concat(reason.message, "\"."));
  527. }));
  528. case 26:
  529. case "end":
  530. return _context3.stop();
  531. }
  532. }
  533. }, _callee3, this);
  534. }));
  535. function _parseHashParameters() {
  536. return _parseHashParameters2.apply(this, arguments);
  537. }
  538. return _parseHashParameters;
  539. }(),
  540. _initializeL10n: function () {
  541. var _initializeL10n2 = _asyncToGenerator(
  542. /*#__PURE__*/
  543. _regenerator.default.mark(function _callee4() {
  544. var dir;
  545. return _regenerator.default.wrap(function _callee4$(_context4) {
  546. while (1) {
  547. switch (_context4.prev = _context4.next) {
  548. case 0:
  549. this.l10n = this.externalServices.createL10n({
  550. locale: _app_options.AppOptions.get('locale')
  551. });
  552. _context4.next = 3;
  553. return this.l10n.getDirection();
  554. case 3:
  555. dir = _context4.sent;
  556. document.getElementsByTagName('html')[0].dir = dir;
  557. case 5:
  558. case "end":
  559. return _context4.stop();
  560. }
  561. }
  562. }, _callee4, this);
  563. }));
  564. function _initializeL10n() {
  565. return _initializeL10n2.apply(this, arguments);
  566. }
  567. return _initializeL10n;
  568. }(),
  569. _initializeViewerComponents: function () {
  570. var _initializeViewerComponents2 = _asyncToGenerator(
  571. /*#__PURE__*/
  572. _regenerator.default.mark(function _callee5() {
  573. var appConfig, dispatchToDOM, eventBus, pdfRenderingQueue, pdfLinkService, downloadManager, findController, container, viewer, thumbnailContainer, sidebarConfig;
  574. return _regenerator.default.wrap(function _callee5$(_context5) {
  575. while (1) {
  576. switch (_context5.prev = _context5.next) {
  577. case 0:
  578. appConfig = this.appConfig;
  579. this.overlayManager = new _overlay_manager.OverlayManager();
  580. dispatchToDOM = _app_options.AppOptions.get('eventBusDispatchToDOM');
  581. eventBus = appConfig.eventBus || (0, _ui_utils.getGlobalEventBus)(dispatchToDOM);
  582. this.eventBus = eventBus;
  583. pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  584. pdfRenderingQueue.onIdle = this.cleanup.bind(this);
  585. this.pdfRenderingQueue = pdfRenderingQueue;
  586. pdfLinkService = new _pdf_link_service.PDFLinkService({
  587. eventBus: eventBus,
  588. externalLinkTarget: _app_options.AppOptions.get('externalLinkTarget'),
  589. externalLinkRel: _app_options.AppOptions.get('externalLinkRel')
  590. });
  591. this.pdfLinkService = pdfLinkService;
  592. downloadManager = this.externalServices.createDownloadManager({
  593. disableCreateObjectURL: _app_options.AppOptions.get('disableCreateObjectURL')
  594. });
  595. this.downloadManager = downloadManager;
  596. findController = new _pdf_find_controller.PDFFindController({
  597. linkService: pdfLinkService,
  598. eventBus: eventBus
  599. });
  600. this.findController = findController;
  601. container = appConfig.mainContainer;
  602. viewer = appConfig.viewerContainer;
  603. this.pdfViewer = new _pdf_viewer.PDFViewer({
  604. container: container,
  605. viewer: viewer,
  606. eventBus: eventBus,
  607. renderingQueue: pdfRenderingQueue,
  608. linkService: pdfLinkService,
  609. downloadManager: downloadManager,
  610. findController: findController,
  611. renderer: _app_options.AppOptions.get('renderer'),
  612. enableWebGL: _app_options.AppOptions.get('enableWebGL'),
  613. l10n: this.l10n,
  614. textLayerMode: _app_options.AppOptions.get('textLayerMode'),
  615. imageResourcesPath: _app_options.AppOptions.get('imageResourcesPath'),
  616. renderInteractiveForms: _app_options.AppOptions.get('renderInteractiveForms'),
  617. enablePrintAutoRotate: _app_options.AppOptions.get('enablePrintAutoRotate'),
  618. useOnlyCssZoom: _app_options.AppOptions.get('useOnlyCssZoom'),
  619. maxCanvasPixels: _app_options.AppOptions.get('maxCanvasPixels')
  620. });
  621. pdfRenderingQueue.setViewer(this.pdfViewer);
  622. pdfLinkService.setViewer(this.pdfViewer);
  623. thumbnailContainer = appConfig.sidebar.thumbnailView;
  624. this.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({
  625. container: thumbnailContainer,
  626. renderingQueue: pdfRenderingQueue,
  627. linkService: pdfLinkService,
  628. l10n: this.l10n
  629. });
  630. pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer);
  631. this.pdfHistory = new _pdf_history.PDFHistory({
  632. linkService: pdfLinkService,
  633. eventBus: eventBus
  634. });
  635. pdfLinkService.setHistory(this.pdfHistory);
  636. this.findBar = new _pdf_find_bar.PDFFindBar(appConfig.findBar, eventBus, this.l10n);
  637. this.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, this.overlayManager, eventBus, this.l10n);
  638. this.pdfCursorTools = new _pdf_cursor_tools.PDFCursorTools({
  639. container: container,
  640. eventBus: eventBus,
  641. cursorToolOnLoad: _app_options.AppOptions.get('cursorToolOnLoad')
  642. });
  643. this.toolbar = new _toolbar.Toolbar(appConfig.toolbar, eventBus, this.l10n);
  644. this.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus);
  645. if (this.supportsFullscreen) {
  646. this.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({
  647. container: container,
  648. viewer: viewer,
  649. pdfViewer: this.pdfViewer,
  650. eventBus: eventBus,
  651. contextMenuItems: appConfig.fullscreen
  652. });
  653. }
  654. this.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, this.overlayManager, this.l10n);
  655. this.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({
  656. container: appConfig.sidebar.outlineView,
  657. eventBus: eventBus,
  658. linkService: pdfLinkService
  659. });
  660. this.pdfAttachmentViewer = new _pdf_attachment_viewer.PDFAttachmentViewer({
  661. container: appConfig.sidebar.attachmentsView,
  662. eventBus: eventBus,
  663. downloadManager: downloadManager
  664. });
  665. sidebarConfig = Object.create(appConfig.sidebar);
  666. sidebarConfig.pdfViewer = this.pdfViewer;
  667. sidebarConfig.pdfThumbnailViewer = this.pdfThumbnailViewer;
  668. this.pdfSidebar = new _pdf_sidebar.PDFSidebar(sidebarConfig, eventBus, this.l10n);
  669. this.pdfSidebar.onToggled = this.forceRendering.bind(this);
  670. this.pdfSidebarResizer = new _pdf_sidebar_resizer.PDFSidebarResizer(appConfig.sidebarResizer, eventBus, this.l10n);
  671. case 39:
  672. case "end":
  673. return _context5.stop();
  674. }
  675. }
  676. }, _callee5, this);
  677. }));
  678. function _initializeViewerComponents() {
  679. return _initializeViewerComponents2.apply(this, arguments);
  680. }
  681. return _initializeViewerComponents;
  682. }(),
  683. run: function run(config) {
  684. this.initialize(config).then(webViewerInitialized);
  685. },
  686. zoomIn: function zoomIn(ticks) {
  687. var newScale = this.pdfViewer.currentScale;
  688. do {
  689. newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2);
  690. newScale = Math.ceil(newScale * 10) / 10;
  691. newScale = Math.min(_ui_utils.MAX_SCALE, newScale);
  692. } while (--ticks > 0 && newScale < _ui_utils.MAX_SCALE);
  693. this.pdfViewer.currentScaleValue = newScale;
  694. },
  695. zoomOut: function zoomOut(ticks) {
  696. var newScale = this.pdfViewer.currentScale;
  697. do {
  698. newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2);
  699. newScale = Math.floor(newScale * 10) / 10;
  700. newScale = Math.max(_ui_utils.MIN_SCALE, newScale);
  701. } while (--ticks > 0 && newScale > _ui_utils.MIN_SCALE);
  702. this.pdfViewer.currentScaleValue = newScale;
  703. },
  704. get pagesCount() {
  705. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  706. },
  707. set page(val) {
  708. this.pdfViewer.currentPageNumber = val;
  709. },
  710. get page() {
  711. return this.pdfViewer.currentPageNumber;
  712. },
  713. get printing() {
  714. return !!this.printService;
  715. },
  716. get supportsPrinting() {
  717. return PDFPrintServiceFactory.instance.supportsPrinting;
  718. },
  719. get supportsFullscreen() {
  720. var support;
  721. var doc = document.documentElement;
  722. support = !!(doc.requestFullscreen || doc.mozRequestFullScreen || doc.webkitRequestFullScreen || doc.msRequestFullscreen);
  723. if (document.fullscreenEnabled === false || document.mozFullScreenEnabled === false || document.webkitFullscreenEnabled === false || document.msFullscreenEnabled === false) {
  724. support = false;
  725. }
  726. return (0, _pdfjsLib.shadow)(this, 'supportsFullscreen', support);
  727. },
  728. get supportsIntegratedFind() {
  729. return this.externalServices.supportsIntegratedFind;
  730. },
  731. get supportsDocumentFonts() {
  732. return this.externalServices.supportsDocumentFonts;
  733. },
  734. get supportsDocumentColors() {
  735. return this.externalServices.supportsDocumentColors;
  736. },
  737. get loadingBar() {
  738. var bar = new _ui_utils.ProgressBar('#loadingBar');
  739. return (0, _pdfjsLib.shadow)(this, 'loadingBar', bar);
  740. },
  741. get supportedMouseWheelZoomModifierKeys() {
  742. return this.externalServices.supportedMouseWheelZoomModifierKeys;
  743. },
  744. initPassiveLoading: function initPassiveLoading() {
  745. throw new Error('Not implemented: initPassiveLoading');
  746. },
  747. setTitleUsingUrl: function setTitleUsingUrl() {
  748. var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  749. this.url = url;
  750. this.baseUrl = url.split('#')[0];
  751. var title = (0, _ui_utils.getPDFFileNameFromURL)(url, '');
  752. if (!title) {
  753. try {
  754. title = decodeURIComponent((0, _pdfjsLib.getFilenameFromUrl)(url)) || url;
  755. } catch (ex) {
  756. title = url;
  757. }
  758. }
  759. this.setTitle(title);
  760. },
  761. setTitle: function setTitle(title) {
  762. if (this.isViewerEmbedded) {
  763. return;
  764. }
  765. document.title = title;
  766. },
  767. close: function () {
  768. var _close = _asyncToGenerator(
  769. /*#__PURE__*/
  770. _regenerator.default.mark(function _callee6() {
  771. var errorWrapper, promise;
  772. return _regenerator.default.wrap(function _callee6$(_context6) {
  773. while (1) {
  774. switch (_context6.prev = _context6.next) {
  775. case 0:
  776. errorWrapper = this.appConfig.errorWrapper.container;
  777. errorWrapper.setAttribute('hidden', 'true');
  778. if (this.pdfLoadingTask) {
  779. _context6.next = 4;
  780. break;
  781. }
  782. return _context6.abrupt("return");
  783. case 4:
  784. promise = this.pdfLoadingTask.destroy();
  785. this.pdfLoadingTask = null;
  786. if (this.pdfDocument) {
  787. this.pdfDocument = null;
  788. this.pdfThumbnailViewer.setDocument(null);
  789. this.pdfViewer.setDocument(null);
  790. this.pdfLinkService.setDocument(null);
  791. this.pdfDocumentProperties.setDocument(null);
  792. }
  793. this.store = null;
  794. this.isInitialViewSet = false;
  795. this.downloadComplete = false;
  796. this.url = '';
  797. this.baseUrl = '';
  798. this.contentDispositionFilename = null;
  799. this.pdfSidebar.reset();
  800. this.pdfOutlineViewer.reset();
  801. this.pdfAttachmentViewer.reset();
  802. this.findBar.reset();
  803. this.toolbar.reset();
  804. this.secondaryToolbar.reset();
  805. if (typeof PDFBug !== 'undefined') {
  806. PDFBug.cleanup();
  807. }
  808. return _context6.abrupt("return", promise);
  809. case 21:
  810. case "end":
  811. return _context6.stop();
  812. }
  813. }
  814. }, _callee6, this);
  815. }));
  816. function close() {
  817. return _close.apply(this, arguments);
  818. }
  819. return close;
  820. }(),
  821. open: function () {
  822. var _open = _asyncToGenerator(
  823. /*#__PURE__*/
  824. _regenerator.default.mark(function _callee7(file, args) {
  825. var _this2 = this;
  826. var workerParameters, key, parameters, apiParameters, _key, prop, loadingTask;
  827. return _regenerator.default.wrap(function _callee7$(_context7) {
  828. while (1) {
  829. switch (_context7.prev = _context7.next) {
  830. case 0:
  831. if (!this.pdfLoadingTask) {
  832. _context7.next = 3;
  833. break;
  834. }
  835. _context7.next = 3;
  836. return this.close();
  837. case 3:
  838. workerParameters = _app_options.AppOptions.getAll('worker');
  839. for (key in workerParameters) {
  840. _pdfjsLib.GlobalWorkerOptions[key] = workerParameters[key];
  841. }
  842. parameters = Object.create(null);
  843. if (typeof file === 'string') {
  844. this.setTitleUsingUrl(file);
  845. parameters.url = file;
  846. } else if (file && 'byteLength' in file) {
  847. parameters.data = file;
  848. } else if (file.url && file.originalUrl) {
  849. this.setTitleUsingUrl(file.originalUrl);
  850. parameters.url = file.url;
  851. }
  852. apiParameters = _app_options.AppOptions.getAll('api');
  853. for (_key in apiParameters) {
  854. parameters[_key] = apiParameters[_key];
  855. }
  856. if (args) {
  857. for (prop in args) {
  858. if (prop === 'length') {
  859. this.pdfDocumentProperties.setFileSize(args[prop]);
  860. }
  861. parameters[prop] = args[prop];
  862. }
  863. }
  864. loadingTask = (0, _pdfjsLib.getDocument)(parameters);
  865. this.pdfLoadingTask = loadingTask;
  866. loadingTask.onPassword = function (updateCallback, reason) {
  867. _this2.passwordPrompt.setUpdateCallback(updateCallback, reason);
  868. _this2.passwordPrompt.open();
  869. };
  870. loadingTask.onProgress = function (_ref) {
  871. var loaded = _ref.loaded,
  872. total = _ref.total;
  873. _this2.progress(loaded / total);
  874. };
  875. loadingTask.onUnsupportedFeature = this.fallback.bind(this);
  876. return _context7.abrupt("return", loadingTask.promise.then(function (pdfDocument) {
  877. _this2.load(pdfDocument);
  878. }, function (exception) {
  879. if (loadingTask !== _this2.pdfLoadingTask) {
  880. return;
  881. }
  882. var message = exception && exception.message;
  883. var loadingErrorMessage;
  884. if (exception instanceof _pdfjsLib.InvalidPDFException) {
  885. loadingErrorMessage = _this2.l10n.get('invalid_file_error', null, 'Invalid or corrupted PDF file.');
  886. } else if (exception instanceof _pdfjsLib.MissingPDFException) {
  887. loadingErrorMessage = _this2.l10n.get('missing_file_error', null, 'Missing PDF file.');
  888. } else if (exception instanceof _pdfjsLib.UnexpectedResponseException) {
  889. loadingErrorMessage = _this2.l10n.get('unexpected_response_error', null, 'Unexpected server response.');
  890. } else {
  891. loadingErrorMessage = _this2.l10n.get('loading_error', null, 'An error occurred while loading the PDF.');
  892. }
  893. return loadingErrorMessage.then(function (msg) {
  894. _this2.error(msg, {
  895. message: message
  896. });
  897. throw new Error(msg);
  898. });
  899. }));
  900. case 16:
  901. case "end":
  902. return _context7.stop();
  903. }
  904. }
  905. }, _callee7, this);
  906. }));
  907. function open(_x2, _x3) {
  908. return _open.apply(this, arguments);
  909. }
  910. return open;
  911. }(),
  912. download: function download() {
  913. var _this3 = this;
  914. function downloadByUrl() {
  915. downloadManager.downloadUrl(url, filename);
  916. }
  917. var url = this.baseUrl;
  918. var filename = this.contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(this.url);
  919. var downloadManager = this.downloadManager;
  920. downloadManager.onerror = function (err) {
  921. _this3.error("PDF failed to download: ".concat(err));
  922. };
  923. if (!this.pdfDocument || !this.downloadComplete) {
  924. downloadByUrl();
  925. return;
  926. }
  927. this.pdfDocument.getData().then(function (data) {
  928. var blob = new Blob([data], {
  929. type: 'application/pdf'
  930. });
  931. downloadManager.download(blob, url, filename);
  932. }).catch(downloadByUrl);
  933. },
  934. fallback: function fallback(featureId) {},
  935. error: function error(message, moreInfo) {
  936. var moreInfoText = [this.l10n.get('error_version_info', {
  937. version: _pdfjsLib.version || '?',
  938. build: _pdfjsLib.build || '?'
  939. }, 'PDF.js v{{version}} (build: {{build}})')];
  940. if (moreInfo) {
  941. moreInfoText.push(this.l10n.get('error_message', {
  942. message: moreInfo.message
  943. }, 'Message: {{message}}'));
  944. if (moreInfo.stack) {
  945. moreInfoText.push(this.l10n.get('error_stack', {
  946. stack: moreInfo.stack
  947. }, 'Stack: {{stack}}'));
  948. } else {
  949. if (moreInfo.filename) {
  950. moreInfoText.push(this.l10n.get('error_file', {
  951. file: moreInfo.filename
  952. }, 'File: {{file}}'));
  953. }
  954. if (moreInfo.lineNumber) {
  955. moreInfoText.push(this.l10n.get('error_line', {
  956. line: moreInfo.lineNumber
  957. }, 'Line: {{line}}'));
  958. }
  959. }
  960. }
  961. var errorWrapperConfig = this.appConfig.errorWrapper;
  962. var errorWrapper = errorWrapperConfig.container;
  963. errorWrapper.removeAttribute('hidden');
  964. var errorMessage = errorWrapperConfig.errorMessage;
  965. errorMessage.textContent = message;
  966. var closeButton = errorWrapperConfig.closeButton;
  967. closeButton.onclick = function () {
  968. errorWrapper.setAttribute('hidden', 'true');
  969. };
  970. var errorMoreInfo = errorWrapperConfig.errorMoreInfo;
  971. var moreInfoButton = errorWrapperConfig.moreInfoButton;
  972. var lessInfoButton = errorWrapperConfig.lessInfoButton;
  973. moreInfoButton.onclick = function () {
  974. errorMoreInfo.removeAttribute('hidden');
  975. moreInfoButton.setAttribute('hidden', 'true');
  976. lessInfoButton.removeAttribute('hidden');
  977. errorMoreInfo.style.height = errorMoreInfo.scrollHeight + 'px';
  978. };
  979. lessInfoButton.onclick = function () {
  980. errorMoreInfo.setAttribute('hidden', 'true');
  981. moreInfoButton.removeAttribute('hidden');
  982. lessInfoButton.setAttribute('hidden', 'true');
  983. };
  984. moreInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  985. lessInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  986. closeButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  987. moreInfoButton.removeAttribute('hidden');
  988. lessInfoButton.setAttribute('hidden', 'true');
  989. Promise.all(moreInfoText).then(function (parts) {
  990. errorMoreInfo.value = parts.join('\n');
  991. });
  992. },
  993. progress: function progress(level) {
  994. var _this4 = this;
  995. if (this.downloadComplete) {
  996. return;
  997. }
  998. var percent = Math.round(level * 100);
  999. if (percent > this.loadingBar.percent || isNaN(percent)) {
  1000. this.loadingBar.percent = percent;
  1001. var disableAutoFetch = this.pdfDocument ? this.pdfDocument.loadingParams['disableAutoFetch'] : _app_options.AppOptions.get('disableAutoFetch');
  1002. if (disableAutoFetch && percent) {
  1003. if (this.disableAutoFetchLoadingBarTimeout) {
  1004. clearTimeout(this.disableAutoFetchLoadingBarTimeout);
  1005. this.disableAutoFetchLoadingBarTimeout = null;
  1006. }
  1007. this.loadingBar.show();
  1008. this.disableAutoFetchLoadingBarTimeout = setTimeout(function () {
  1009. _this4.loadingBar.hide();
  1010. _this4.disableAutoFetchLoadingBarTimeout = null;
  1011. }, DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT);
  1012. }
  1013. }
  1014. },
  1015. load: function load(pdfDocument) {
  1016. var _this5 = this;
  1017. this.pdfDocument = pdfDocument;
  1018. pdfDocument.getDownloadInfo().then(function () {
  1019. _this5.downloadComplete = true;
  1020. _this5.loadingBar.hide();
  1021. firstPagePromise.then(function () {
  1022. _this5.eventBus.dispatch('documentloaded', {
  1023. source: _this5
  1024. });
  1025. });
  1026. });
  1027. var pageModePromise = pdfDocument.getPageMode().catch(function () {});
  1028. var openActionDestPromise = pdfDocument.getOpenActionDestination().catch(function () {});
  1029. this.toolbar.setPagesCount(pdfDocument.numPages, false);
  1030. this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
  1031. var store = this.store = new _view_history.ViewHistory(pdfDocument.fingerprint);
  1032. var baseDocumentUrl;
  1033. baseDocumentUrl = null;
  1034. this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
  1035. this.pdfDocumentProperties.setDocument(pdfDocument, this.url);
  1036. var pdfViewer = this.pdfViewer;
  1037. pdfViewer.setDocument(pdfDocument);
  1038. var firstPagePromise = pdfViewer.firstPagePromise;
  1039. var pagesPromise = pdfViewer.pagesPromise;
  1040. var onePageRendered = pdfViewer.onePageRendered;
  1041. var pdfThumbnailViewer = this.pdfThumbnailViewer;
  1042. pdfThumbnailViewer.setDocument(pdfDocument);
  1043. firstPagePromise.then(function (pdfPage) {
  1044. _this5.loadingBar.setWidth(_this5.appConfig.viewerContainer);
  1045. var storePromise = store.getMultiple({
  1046. page: null,
  1047. zoom: _ui_utils.DEFAULT_SCALE_VALUE,
  1048. scrollLeft: '0',
  1049. scrollTop: '0',
  1050. rotation: null,
  1051. sidebarView: _pdf_sidebar.SidebarView.UNKNOWN,
  1052. scrollMode: _ui_utils.ScrollMode.UNKNOWN,
  1053. spreadMode: _ui_utils.SpreadMode.UNKNOWN
  1054. }).catch(function () {});
  1055. Promise.all([storePromise, pageModePromise, openActionDestPromise]).then(
  1056. /*#__PURE__*/
  1057. function () {
  1058. var _ref3 = _asyncToGenerator(
  1059. /*#__PURE__*/
  1060. _regenerator.default.mark(function _callee8(_ref2) {
  1061. var _ref4, _ref4$, values, pageMode, openActionDest, viewOnLoad, initialBookmark, zoom, hash, rotation, sidebarView, scrollMode, spreadMode;
  1062. return _regenerator.default.wrap(function _callee8$(_context8) {
  1063. while (1) {
  1064. switch (_context8.prev = _context8.next) {
  1065. case 0:
  1066. _ref4 = _slicedToArray(_ref2, 3), _ref4$ = _ref4[0], values = _ref4$ === void 0 ? {} : _ref4$, pageMode = _ref4[1], openActionDest = _ref4[2];
  1067. viewOnLoad = _app_options.AppOptions.get('viewOnLoad');
  1068. _this5._initializePdfHistory({
  1069. fingerprint: pdfDocument.fingerprint,
  1070. viewOnLoad: viewOnLoad,
  1071. initialDest: openActionDest
  1072. });
  1073. initialBookmark = _this5.initialBookmark;
  1074. zoom = _app_options.AppOptions.get('defaultZoomValue');
  1075. hash = zoom ? "zoom=".concat(zoom) : null;
  1076. rotation = null;
  1077. sidebarView = _app_options.AppOptions.get('sidebarViewOnLoad');
  1078. scrollMode = _app_options.AppOptions.get('scrollModeOnLoad');
  1079. spreadMode = _app_options.AppOptions.get('spreadModeOnLoad');
  1080. if (values.page && viewOnLoad !== ViewOnLoad.INITIAL) {
  1081. hash = "page=".concat(values.page, "&zoom=").concat(zoom || values.zoom, ",") + "".concat(values.scrollLeft, ",").concat(values.scrollTop);
  1082. rotation = parseInt(values.rotation, 10);
  1083. if (sidebarView === _pdf_sidebar.SidebarView.UNKNOWN) {
  1084. sidebarView = values.sidebarView | 0;
  1085. }
  1086. if (scrollMode === _ui_utils.ScrollMode.UNKNOWN) {
  1087. scrollMode = values.scrollMode | 0;
  1088. }
  1089. if (spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
  1090. spreadMode = values.spreadMode | 0;
  1091. }
  1092. }
  1093. if (pageMode && sidebarView === _pdf_sidebar.SidebarView.UNKNOWN) {
  1094. sidebarView = apiPageModeToSidebarView(pageMode);
  1095. }
  1096. _this5.setInitialView(hash, {
  1097. rotation: rotation,
  1098. sidebarView: sidebarView,
  1099. scrollMode: scrollMode,
  1100. spreadMode: spreadMode
  1101. });
  1102. _this5.eventBus.dispatch('documentinit', {
  1103. source: _this5
  1104. });
  1105. if (!_this5.isViewerEmbedded) {
  1106. pdfViewer.focus();
  1107. }
  1108. _context8.next = 17;
  1109. return Promise.race([pagesPromise, new Promise(function (resolve) {
  1110. setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT);
  1111. })]);
  1112. case 17:
  1113. if (!(!initialBookmark && !hash)) {
  1114. _context8.next = 19;
  1115. break;
  1116. }
  1117. return _context8.abrupt("return");
  1118. case 19:
  1119. if (!pdfViewer.hasEqualPageSizes) {
  1120. _context8.next = 21;
  1121. break;
  1122. }
  1123. return _context8.abrupt("return");
  1124. case 21:
  1125. _this5.initialBookmark = initialBookmark;
  1126. pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;
  1127. _this5.setInitialView(hash);
  1128. case 24:
  1129. case "end":
  1130. return _context8.stop();
  1131. }
  1132. }
  1133. }, _callee8, this);
  1134. }));
  1135. return function (_x4) {
  1136. return _ref3.apply(this, arguments);
  1137. };
  1138. }()).catch(function () {
  1139. _this5.setInitialView();
  1140. }).then(function () {
  1141. pdfViewer.update();
  1142. });
  1143. });
  1144. pdfDocument.getPageLabels().then(function (labels) {
  1145. if (!labels || _app_options.AppOptions.get('disablePageLabels')) {
  1146. return;
  1147. }
  1148. var i = 0,
  1149. numLabels = labels.length;
  1150. if (numLabels !== _this5.pagesCount) {
  1151. console.error('The number of Page Labels does not match ' + 'the number of pages in the document.');
  1152. return;
  1153. }
  1154. while (i < numLabels && labels[i] === (i + 1).toString()) {
  1155. i++;
  1156. }
  1157. if (i === numLabels) {
  1158. return;
  1159. }
  1160. pdfViewer.setPageLabels(labels);
  1161. pdfThumbnailViewer.setPageLabels(labels);
  1162. _this5.toolbar.setPagesCount(pdfDocument.numPages, true);
  1163. _this5.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  1164. });
  1165. pagesPromise.then(function () {
  1166. if (!_this5.supportsPrinting) {
  1167. return;
  1168. }
  1169. pdfDocument.getJavaScript().then(function (javaScript) {
  1170. if (!javaScript) {
  1171. return;
  1172. }
  1173. javaScript.some(function (js) {
  1174. if (!js) {
  1175. return false;
  1176. }
  1177. console.warn('Warning: JavaScript is not supported');
  1178. _this5.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.javaScript);
  1179. return true;
  1180. });
  1181. var regex = /\bprint\s*\(/;
  1182. for (var i = 0, ii = javaScript.length; i < ii; i++) {
  1183. var js = javaScript[i];
  1184. if (js && regex.test(js)) {
  1185. setTimeout(function () {
  1186. window.print();
  1187. });
  1188. return;
  1189. }
  1190. }
  1191. });
  1192. });
  1193. Promise.all([onePageRendered, _ui_utils.animationStarted]).then(function () {
  1194. pdfDocument.getOutline().then(function (outline) {
  1195. _this5.pdfOutlineViewer.render({
  1196. outline: outline
  1197. });
  1198. });
  1199. pdfDocument.getAttachments().then(function (attachments) {
  1200. _this5.pdfAttachmentViewer.render({
  1201. attachments: attachments
  1202. });
  1203. });
  1204. });
  1205. pdfDocument.getMetadata().then(function (_ref5) {
  1206. var info = _ref5.info,
  1207. metadata = _ref5.metadata,
  1208. contentDispositionFilename = _ref5.contentDispositionFilename;
  1209. _this5.documentInfo = info;
  1210. _this5.metadata = metadata;
  1211. _this5.contentDispositionFilename = contentDispositionFilename;
  1212. console.log('PDF ' + pdfDocument.fingerprint + ' [' + info.PDFFormatVersion + ' ' + (info.Producer || '-').trim() + ' / ' + (info.Creator || '-').trim() + ']' + ' (PDF.js: ' + (_pdfjsLib.version || '-') + (_app_options.AppOptions.get('enableWebGL') ? ' [WebGL]' : '') + ')');
  1213. var pdfTitle;
  1214. if (metadata && metadata.has('dc:title')) {
  1215. var title = metadata.get('dc:title');
  1216. if (title !== 'Untitled') {
  1217. pdfTitle = title;
  1218. }
  1219. }
  1220. if (!pdfTitle && info && info['Title']) {
  1221. pdfTitle = info['Title'];
  1222. }
  1223. if (pdfTitle) {
  1224. _this5.setTitle("".concat(pdfTitle, " - ").concat(contentDispositionFilename || document.title));
  1225. } else if (contentDispositionFilename) {
  1226. _this5.setTitle(contentDispositionFilename);
  1227. }
  1228. if (info.IsAcroFormPresent) {
  1229. console.warn('Warning: AcroForm/XFA is not supported');
  1230. _this5.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms);
  1231. }
  1232. });
  1233. },
  1234. _initializePdfHistory: function _initializePdfHistory(_ref6) {
  1235. var fingerprint = _ref6.fingerprint,
  1236. viewOnLoad = _ref6.viewOnLoad,
  1237. _ref6$initialDest = _ref6.initialDest,
  1238. initialDest = _ref6$initialDest === void 0 ? null : _ref6$initialDest;
  1239. if (_app_options.AppOptions.get('disableHistory') || this.isViewerEmbedded) {
  1240. return;
  1241. }
  1242. this.pdfHistory.initialize({
  1243. fingerprint: fingerprint,
  1244. resetHistory: viewOnLoad === ViewOnLoad.INITIAL,
  1245. updateUrl: _app_options.AppOptions.get('historyUpdateUrl')
  1246. });
  1247. if (this.pdfHistory.initialBookmark) {
  1248. this.initialBookmark = this.pdfHistory.initialBookmark;
  1249. this.initialRotation = this.pdfHistory.initialRotation;
  1250. }
  1251. if (initialDest && !this.initialBookmark && viewOnLoad === ViewOnLoad.UNKNOWN) {
  1252. this.initialBookmark = JSON.stringify(initialDest);
  1253. this.pdfHistory.push({
  1254. explicitDest: initialDest,
  1255. pageNumber: null
  1256. });
  1257. }
  1258. },
  1259. setInitialView: function setInitialView(storedHash) {
  1260. var _this6 = this;
  1261. var _ref7 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  1262. rotation = _ref7.rotation,
  1263. sidebarView = _ref7.sidebarView,
  1264. scrollMode = _ref7.scrollMode,
  1265. spreadMode = _ref7.spreadMode;
  1266. var setRotation = function setRotation(angle) {
  1267. if ((0, _ui_utils.isValidRotation)(angle)) {
  1268. _this6.pdfViewer.pagesRotation = angle;
  1269. }
  1270. };
  1271. var setViewerModes = function setViewerModes(scroll, spread) {
  1272. if ((0, _ui_utils.isValidScrollMode)(scroll)) {
  1273. _this6.pdfViewer.scrollMode = scroll;
  1274. }
  1275. if ((0, _ui_utils.isValidSpreadMode)(spread)) {
  1276. _this6.pdfViewer.spreadMode = spread;
  1277. }
  1278. };
  1279. this.isInitialViewSet = true;
  1280. this.pdfSidebar.setInitialView(sidebarView);
  1281. setViewerModes(scrollMode, spreadMode);
  1282. if (this.initialBookmark) {
  1283. setRotation(this.initialRotation);
  1284. delete this.initialRotation;
  1285. this.pdfLinkService.setHash(this.initialBookmark);
  1286. this.initialBookmark = null;
  1287. } else if (storedHash) {
  1288. setRotation(rotation);
  1289. this.pdfLinkService.setHash(storedHash);
  1290. }
  1291. this.toolbar.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel);
  1292. this.secondaryToolbar.setPageNumber(this.pdfViewer.currentPageNumber);
  1293. if (!this.pdfViewer.currentScaleValue) {
  1294. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  1295. }
  1296. },
  1297. cleanup: function cleanup() {
  1298. if (!this.pdfDocument) {
  1299. return;
  1300. }
  1301. this.pdfViewer.cleanup();
  1302. this.pdfThumbnailViewer.cleanup();
  1303. if (this.pdfViewer.renderer !== _ui_utils.RendererType.SVG) {
  1304. this.pdfDocument.cleanup();
  1305. }
  1306. },
  1307. forceRendering: function forceRendering() {
  1308. this.pdfRenderingQueue.printing = this.printing;
  1309. this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar.isThumbnailViewVisible;
  1310. this.pdfRenderingQueue.renderHighestPriority();
  1311. },
  1312. beforePrint: function beforePrint() {
  1313. var _this7 = this;
  1314. if (this.printService) {
  1315. return;
  1316. }
  1317. if (!this.supportsPrinting) {
  1318. this.l10n.get('printing_not_supported', null, 'Warning: Printing is not fully supported by ' + 'this browser.').then(function (printMessage) {
  1319. _this7.error(printMessage);
  1320. });
  1321. return;
  1322. }
  1323. if (!this.pdfViewer.pageViewsReady) {
  1324. this.l10n.get('printing_not_ready', null, 'Warning: The PDF is not fully loaded for printing.').then(function (notReadyMessage) {
  1325. window.alert(notReadyMessage);
  1326. });
  1327. return;
  1328. }
  1329. var pagesOverview = this.pdfViewer.getPagesOverview();
  1330. var printContainer = this.appConfig.printContainer;
  1331. var printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument, pagesOverview, printContainer, this.l10n);
  1332. this.printService = printService;
  1333. this.forceRendering();
  1334. printService.layout();
  1335. },
  1336. afterPrint: function pdfViewSetupAfterPrint() {
  1337. if (this.printService) {
  1338. this.printService.destroy();
  1339. this.printService = null;
  1340. }
  1341. this.forceRendering();
  1342. },
  1343. rotatePages: function rotatePages(delta) {
  1344. if (!this.pdfDocument) {
  1345. return;
  1346. }
  1347. var newRotation = (this.pdfViewer.pagesRotation + 360 + delta) % 360;
  1348. this.pdfViewer.pagesRotation = newRotation;
  1349. },
  1350. requestPresentationMode: function requestPresentationMode() {
  1351. if (!this.pdfPresentationMode) {
  1352. return;
  1353. }
  1354. this.pdfPresentationMode.request();
  1355. },
  1356. bindEvents: function bindEvents() {
  1357. var eventBus = this.eventBus,
  1358. _boundEvents = this._boundEvents;
  1359. _boundEvents.beforePrint = this.beforePrint.bind(this);
  1360. _boundEvents.afterPrint = this.afterPrint.bind(this);
  1361. eventBus.on('resize', webViewerResize);
  1362. eventBus.on('hashchange', webViewerHashchange);
  1363. eventBus.on('beforeprint', _boundEvents.beforePrint);
  1364. eventBus.on('afterprint', _boundEvents.afterPrint);
  1365. eventBus.on('pagerendered', webViewerPageRendered);
  1366. eventBus.on('textlayerrendered', webViewerTextLayerRendered);
  1367. eventBus.on('updateviewarea', webViewerUpdateViewarea);
  1368. eventBus.on('pagechanging', webViewerPageChanging);
  1369. eventBus.on('scalechanging', webViewerScaleChanging);
  1370. eventBus.on('rotationchanging', webViewerRotationChanging);
  1371. eventBus.on('sidebarviewchanged', webViewerSidebarViewChanged);
  1372. eventBus.on('pagemode', webViewerPageMode);
  1373. eventBus.on('namedaction', webViewerNamedAction);
  1374. eventBus.on('presentationmodechanged', webViewerPresentationModeChanged);
  1375. eventBus.on('presentationmode', webViewerPresentationMode);
  1376. eventBus.on('openfile', webViewerOpenFile);
  1377. eventBus.on('print', webViewerPrint);
  1378. eventBus.on('download', webViewerDownload);
  1379. eventBus.on('firstpage', webViewerFirstPage);
  1380. eventBus.on('lastpage', webViewerLastPage);
  1381. eventBus.on('nextpage', webViewerNextPage);
  1382. eventBus.on('previouspage', webViewerPreviousPage);
  1383. eventBus.on('zoomin', webViewerZoomIn);
  1384. eventBus.on('zoomout', webViewerZoomOut);
  1385. eventBus.on('pagenumberchanged', webViewerPageNumberChanged);
  1386. eventBus.on('scalechanged', webViewerScaleChanged);
  1387. eventBus.on('rotatecw', webViewerRotateCw);
  1388. eventBus.on('rotateccw', webViewerRotateCcw);
  1389. eventBus.on('switchscrollmode', webViewerSwitchScrollMode);
  1390. eventBus.on('scrollmodechanged', webViewerScrollModeChanged);
  1391. eventBus.on('switchspreadmode', webViewerSwitchSpreadMode);
  1392. eventBus.on('spreadmodechanged', webViewerSpreadModeChanged);
  1393. eventBus.on('documentproperties', webViewerDocumentProperties);
  1394. eventBus.on('find', webViewerFind);
  1395. eventBus.on('findfromurlhash', webViewerFindFromUrlHash);
  1396. eventBus.on('updatefindmatchescount', webViewerUpdateFindMatchesCount);
  1397. eventBus.on('updatefindcontrolstate', webViewerUpdateFindControlState);
  1398. eventBus.on('fileinputchange', webViewerFileInputChange);
  1399. },
  1400. bindWindowEvents: function bindWindowEvents() {
  1401. var eventBus = this.eventBus,
  1402. _boundEvents = this._boundEvents;
  1403. _boundEvents.windowResize = function () {
  1404. eventBus.dispatch('resize', {
  1405. source: window
  1406. });
  1407. };
  1408. _boundEvents.windowHashChange = function () {
  1409. eventBus.dispatch('hashchange', {
  1410. source: window,
  1411. hash: document.location.hash.substring(1)
  1412. });
  1413. };
  1414. _boundEvents.windowBeforePrint = function () {
  1415. eventBus.dispatch('beforeprint', {
  1416. source: window
  1417. });
  1418. };
  1419. _boundEvents.windowAfterPrint = function () {
  1420. eventBus.dispatch('afterprint', {
  1421. source: window
  1422. });
  1423. };
  1424. window.addEventListener('visibilitychange', webViewerVisibilityChange);
  1425. window.addEventListener('wheel', webViewerWheel);
  1426. window.addEventListener('click', webViewerClick);
  1427. window.addEventListener('keydown', webViewerKeyDown);
  1428. window.addEventListener('resize', _boundEvents.windowResize);
  1429. window.addEventListener('hashchange', _boundEvents.windowHashChange);
  1430. window.addEventListener('beforeprint', _boundEvents.windowBeforePrint);
  1431. window.addEventListener('afterprint', _boundEvents.windowAfterPrint);
  1432. },
  1433. unbindEvents: function unbindEvents() {
  1434. var eventBus = this.eventBus,
  1435. _boundEvents = this._boundEvents;
  1436. eventBus.off('resize', webViewerResize);
  1437. eventBus.off('hashchange', webViewerHashchange);
  1438. eventBus.off('beforeprint', _boundEvents.beforePrint);
  1439. eventBus.off('afterprint', _boundEvents.afterPrint);
  1440. eventBus.off('pagerendered', webViewerPageRendered);
  1441. eventBus.off('textlayerrendered', webViewerTextLayerRendered);
  1442. eventBus.off('updateviewarea', webViewerUpdateViewarea);
  1443. eventBus.off('pagechanging', webViewerPageChanging);
  1444. eventBus.off('scalechanging', webViewerScaleChanging);
  1445. eventBus.off('rotationchanging', webViewerRotationChanging);
  1446. eventBus.off('sidebarviewchanged', webViewerSidebarViewChanged);
  1447. eventBus.off('pagemode', webViewerPageMode);
  1448. eventBus.off('namedaction', webViewerNamedAction);
  1449. eventBus.off('presentationmodechanged', webViewerPresentationModeChanged);
  1450. eventBus.off('presentationmode', webViewerPresentationMode);
  1451. eventBus.off('openfile', webViewerOpenFile);
  1452. eventBus.off('print', webViewerPrint);
  1453. eventBus.off('download', webViewerDownload);
  1454. eventBus.off('firstpage', webViewerFirstPage);
  1455. eventBus.off('lastpage', webViewerLastPage);
  1456. eventBus.off('nextpage', webViewerNextPage);
  1457. eventBus.off('previouspage', webViewerPreviousPage);
  1458. eventBus.off('zoomin', webViewerZoomIn);
  1459. eventBus.off('zoomout', webViewerZoomOut);
  1460. eventBus.off('pagenumberchanged', webViewerPageNumberChanged);
  1461. eventBus.off('scalechanged', webViewerScaleChanged);
  1462. eventBus.off('rotatecw', webViewerRotateCw);
  1463. eventBus.off('rotateccw', webViewerRotateCcw);
  1464. eventBus.off('switchscrollmode', webViewerSwitchScrollMode);
  1465. eventBus.off('scrollmodechanged', webViewerScrollModeChanged);
  1466. eventBus.off('switchspreadmode', webViewerSwitchSpreadMode);
  1467. eventBus.off('spreadmodechanged', webViewerSpreadModeChanged);
  1468. eventBus.off('documentproperties', webViewerDocumentProperties);
  1469. eventBus.off('find', webViewerFind);
  1470. eventBus.off('findfromurlhash', webViewerFindFromUrlHash);
  1471. eventBus.off('updatefindmatchescount', webViewerUpdateFindMatchesCount);
  1472. eventBus.off('updatefindcontrolstate', webViewerUpdateFindControlState);
  1473. eventBus.off('fileinputchange', webViewerFileInputChange);
  1474. _boundEvents.beforePrint = null;
  1475. _boundEvents.afterPrint = null;
  1476. },
  1477. unbindWindowEvents: function unbindWindowEvents() {
  1478. var _boundEvents = this._boundEvents;
  1479. window.removeEventListener('visibilitychange', webViewerVisibilityChange);
  1480. window.removeEventListener('wheel', webViewerWheel);
  1481. window.removeEventListener('click', webViewerClick);
  1482. window.removeEventListener('keydown', webViewerKeyDown);
  1483. window.removeEventListener('resize', _boundEvents.windowResize);
  1484. window.removeEventListener('hashchange', _boundEvents.windowHashChange);
  1485. window.removeEventListener('beforeprint', _boundEvents.windowBeforePrint);
  1486. window.removeEventListener('afterprint', _boundEvents.windowAfterPrint);
  1487. _boundEvents.windowResize = null;
  1488. _boundEvents.windowHashChange = null;
  1489. _boundEvents.windowBeforePrint = null;
  1490. _boundEvents.windowAfterPrint = null;
  1491. }
  1492. };
  1493. exports.PDFViewerApplication = PDFViewerApplication;
  1494. var validateFileURL;
  1495. {
  1496. var HOSTED_VIEWER_ORIGINS = ['null', 'http://mozilla.github.io', 'https://mozilla.github.io'];
  1497. validateFileURL = function validateFileURL(file) {
  1498. if (file === undefined) {
  1499. return;
  1500. }
  1501. try {
  1502. var viewerOrigin = new _pdfjsLib.URL(window.location.href).origin || 'null';
  1503. if (HOSTED_VIEWER_ORIGINS.includes(viewerOrigin)) {
  1504. return;
  1505. }
  1506. var _ref8 = new _pdfjsLib.URL(file, window.location.href),
  1507. origin = _ref8.origin,
  1508. protocol = _ref8.protocol;
  1509. if (origin !== viewerOrigin && protocol !== 'blob:') {
  1510. //throw new Error('file origin does not match viewer\'s');
  1511. }
  1512. } catch (ex) {
  1513. var message = ex && ex.message;
  1514. PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.').then(function (loadingErrorMessage) {
  1515. PDFViewerApplication.error(loadingErrorMessage, {
  1516. message: message
  1517. });
  1518. });
  1519. throw ex;
  1520. }
  1521. };
  1522. }
  1523. function loadFakeWorker() {
  1524. if (!_pdfjsLib.GlobalWorkerOptions.workerSrc) {
  1525. _pdfjsLib.GlobalWorkerOptions.workerSrc = _app_options.AppOptions.get('workerSrc');
  1526. }
  1527. return (0, _pdfjsLib.loadScript)(_pdfjsLib.PDFWorker.getWorkerSrc());
  1528. }
  1529. function loadAndEnablePDFBug(enabledTabs) {
  1530. var appConfig = PDFViewerApplication.appConfig;
  1531. return (0, _pdfjsLib.loadScript)(appConfig.debuggerScriptPath).then(function () {
  1532. PDFBug.enable(enabledTabs);
  1533. PDFBug.init({
  1534. OPS: _pdfjsLib.OPS,
  1535. createObjectURL: _pdfjsLib.createObjectURL
  1536. }, appConfig.mainContainer);
  1537. });
  1538. }
  1539. function webViewerInitialized() {
  1540. var appConfig = PDFViewerApplication.appConfig;
  1541. var file;
  1542. var queryString = document.location.search.substring(1);
  1543. var params = (0, _ui_utils.parseQueryString)(queryString);
  1544. file = 'file' in params ? params.file : _app_options.AppOptions.get('defaultUrl');
  1545. validateFileURL(file);
  1546. var fileInput = document.createElement('input');
  1547. fileInput.id = appConfig.openFileInputName;
  1548. fileInput.className = 'fileInput';
  1549. fileInput.setAttribute('type', 'file');
  1550. fileInput.oncontextmenu = _ui_utils.noContextMenuHandler;
  1551. document.body.appendChild(fileInput);
  1552. if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
  1553. appConfig.toolbar.openFile.setAttribute('hidden', 'true');
  1554. appConfig.secondaryToolbar.openFileButton.setAttribute('hidden', 'true');
  1555. } else {
  1556. fileInput.value = null;
  1557. }
  1558. fileInput.addEventListener('change', function (evt) {
  1559. var files = evt.target.files;
  1560. if (!files || files.length === 0) {
  1561. return;
  1562. }
  1563. PDFViewerApplication.eventBus.dispatch('fileinputchange', {
  1564. source: this,
  1565. fileInput: evt.target
  1566. });
  1567. });
  1568. appConfig.mainContainer.addEventListener('dragover', function (evt) {
  1569. evt.preventDefault();
  1570. evt.dataTransfer.dropEffect = 'move';
  1571. });
  1572. appConfig.mainContainer.addEventListener('drop', function (evt) {
  1573. evt.preventDefault();
  1574. var files = evt.dataTransfer.files;
  1575. if (!files || files.length === 0) {
  1576. return;
  1577. }
  1578. PDFViewerApplication.eventBus.dispatch('fileinputchange', {
  1579. source: this,
  1580. fileInput: evt.dataTransfer
  1581. });
  1582. });
  1583. if (!PDFViewerApplication.supportsPrinting) {
  1584. appConfig.toolbar.print.classList.add('hidden');
  1585. appConfig.secondaryToolbar.printButton.classList.add('hidden');
  1586. }
  1587. if (!PDFViewerApplication.supportsFullscreen) {
  1588. appConfig.toolbar.presentationModeButton.classList.add('hidden');
  1589. appConfig.secondaryToolbar.presentationModeButton.classList.add('hidden');
  1590. }
  1591. if (PDFViewerApplication.supportsIntegratedFind) {
  1592. appConfig.toolbar.viewFind.classList.add('hidden');
  1593. }
  1594. appConfig.mainContainer.addEventListener('transitionend', function (evt) {
  1595. if (evt.target === this) {
  1596. PDFViewerApplication.eventBus.dispatch('resize', {
  1597. source: this
  1598. });
  1599. }
  1600. }, true);
  1601. appConfig.sidebar.toggleButton.addEventListener('click', function () {
  1602. PDFViewerApplication.pdfSidebar.toggle();
  1603. });
  1604. try {
  1605. webViewerOpenFileViaURL(file);
  1606. } catch (reason) {
  1607. PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.').then(function (msg) {
  1608. PDFViewerApplication.error(msg, reason);
  1609. });
  1610. }
  1611. }
  1612. var webViewerOpenFileViaURL;
  1613. {
  1614. webViewerOpenFileViaURL = async function webViewerOpenFileViaURL(file) {
  1615. if (file && file.lastIndexOf('file:', 0) === 0) {
  1616. PDFViewerApplication.setTitleUsingUrl(file);
  1617. var xhr = new XMLHttpRequest();
  1618. xhr.onload = function () {
  1619. PDFViewerApplication.open(new Uint8Array(xhr.response));
  1620. };
  1621. xhr.open('GET', file);
  1622. xhr.responseType = 'arraybuffer';
  1623. xhr.send();
  1624. return;
  1625. }
  1626. if (file) {
  1627. // 使用pdf-lib 添加水印
  1628. const watermaskPdf = await addWatermask(file);
  1629. PDFViewerApplication.open(watermaskPdf);
  1630. }
  1631. };
  1632. }
  1633. function webViewerPageRendered(evt) {
  1634. var pageNumber = evt.pageNumber;
  1635. var pageIndex = pageNumber - 1;
  1636. var pageView = PDFViewerApplication.pdfViewer.getPageView(pageIndex);
  1637. if (pageNumber === PDFViewerApplication.page) {
  1638. PDFViewerApplication.toolbar.updateLoadingIndicatorState(false);
  1639. }
  1640. if (!pageView) {
  1641. return;
  1642. }
  1643. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  1644. var thumbnailView = PDFViewerApplication.pdfThumbnailViewer.getThumbnail(pageIndex);
  1645. thumbnailView.setImage(pageView);
  1646. }
  1647. if (typeof Stats !== 'undefined' && Stats.enabled && pageView.stats) {
  1648. Stats.add(pageNumber, pageView.stats);
  1649. }
  1650. if (pageView.error) {
  1651. PDFViewerApplication.l10n.get('rendering_error', null, 'An error occurred while rendering the page.').then(function (msg) {
  1652. PDFViewerApplication.error(msg, pageView.error);
  1653. });
  1654. }
  1655. }
  1656. function webViewerTextLayerRendered(evt) {}
  1657. function webViewerPageMode(evt) {
  1658. var mode = evt.mode,
  1659. view;
  1660. switch (mode) {
  1661. case 'thumbs':
  1662. view = _pdf_sidebar.SidebarView.THUMBS;
  1663. break;
  1664. case 'bookmarks':
  1665. case 'outline':
  1666. view = _pdf_sidebar.SidebarView.OUTLINE;
  1667. break;
  1668. case 'attachments':
  1669. view = _pdf_sidebar.SidebarView.ATTACHMENTS;
  1670. break;
  1671. case 'none':
  1672. view = _pdf_sidebar.SidebarView.NONE;
  1673. break;
  1674. default:
  1675. console.error('Invalid "pagemode" hash parameter: ' + mode);
  1676. return;
  1677. }
  1678. PDFViewerApplication.pdfSidebar.switchView(view, true);
  1679. }
  1680. function webViewerNamedAction(evt) {
  1681. var action = evt.action;
  1682. switch (action) {
  1683. case 'GoToPage':
  1684. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  1685. break;
  1686. case 'Find':
  1687. if (!PDFViewerApplication.supportsIntegratedFind) {
  1688. PDFViewerApplication.findBar.toggle();
  1689. }
  1690. break;
  1691. }
  1692. }
  1693. function webViewerPresentationModeChanged(evt) {
  1694. var active = evt.active,
  1695. switchInProgress = evt.switchInProgress;
  1696. PDFViewerApplication.pdfViewer.presentationModeState = switchInProgress ? _ui_utils.PresentationModeState.CHANGING : active ? _ui_utils.PresentationModeState.FULLSCREEN : _ui_utils.PresentationModeState.NORMAL;
  1697. }
  1698. function webViewerSidebarViewChanged(evt) {
  1699. PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = PDFViewerApplication.pdfSidebar.isThumbnailViewVisible;
  1700. var store = PDFViewerApplication.store;
  1701. if (store && PDFViewerApplication.isInitialViewSet) {
  1702. store.set('sidebarView', evt.view).catch(function () {});
  1703. }
  1704. }
  1705. function webViewerUpdateViewarea(evt) {
  1706. var location = evt.location,
  1707. store = PDFViewerApplication.store;
  1708. if (store && PDFViewerApplication.isInitialViewSet) {
  1709. store.setMultiple({
  1710. 'page': location.pageNumber,
  1711. 'zoom': location.scale,
  1712. 'scrollLeft': location.left,
  1713. 'scrollTop': location.top,
  1714. 'rotation': location.rotation
  1715. }).catch(function () {});
  1716. }
  1717. var href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
  1718. PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href;
  1719. PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
  1720. var currentPage = PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page - 1);
  1721. var loading = currentPage.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED;
  1722. PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading);
  1723. }
  1724. function webViewerScrollModeChanged(evt) {
  1725. var store = PDFViewerApplication.store;
  1726. if (store && PDFViewerApplication.isInitialViewSet) {
  1727. store.set('scrollMode', evt.mode).catch(function () {});
  1728. }
  1729. }
  1730. function webViewerSpreadModeChanged(evt) {
  1731. var store = PDFViewerApplication.store;
  1732. if (store && PDFViewerApplication.isInitialViewSet) {
  1733. store.set('spreadMode', evt.mode).catch(function () {});
  1734. }
  1735. }
  1736. function webViewerResize() {
  1737. var pdfDocument = PDFViewerApplication.pdfDocument,
  1738. pdfViewer = PDFViewerApplication.pdfViewer;
  1739. if (!pdfDocument) {
  1740. return;
  1741. }
  1742. var currentScaleValue = pdfViewer.currentScaleValue;
  1743. if (currentScaleValue === 'auto' || currentScaleValue === 'page-fit' || currentScaleValue === 'page-width') {
  1744. pdfViewer.currentScaleValue = currentScaleValue;
  1745. }
  1746. pdfViewer.update();
  1747. }
  1748. function webViewerHashchange(evt) {
  1749. var hash = evt.hash;
  1750. if (!hash) {
  1751. return;
  1752. }
  1753. if (!PDFViewerApplication.isInitialViewSet) {
  1754. PDFViewerApplication.initialBookmark = hash;
  1755. } else if (!PDFViewerApplication.pdfHistory.popStateInProgress) {
  1756. PDFViewerApplication.pdfLinkService.setHash(hash);
  1757. }
  1758. }
  1759. var webViewerFileInputChange;
  1760. {
  1761. webViewerFileInputChange = function webViewerFileInputChange(evt) {
  1762. if (PDFViewerApplication.pdfViewer && PDFViewerApplication.pdfViewer.isInPresentationMode) {
  1763. return;
  1764. }
  1765. var file = evt.fileInput.files[0];
  1766. if (_pdfjsLib.URL.createObjectURL && !_app_options.AppOptions.get('disableCreateObjectURL')) {
  1767. var url = _pdfjsLib.URL.createObjectURL(file);
  1768. if (file.name) {
  1769. url = {
  1770. url: url,
  1771. originalUrl: file.name
  1772. };
  1773. }
  1774. PDFViewerApplication.open(url);
  1775. } else {
  1776. PDFViewerApplication.setTitleUsingUrl(file.name);
  1777. var fileReader = new FileReader();
  1778. fileReader.onload = function webViewerChangeFileReaderOnload(evt) {
  1779. var buffer = evt.target.result;
  1780. PDFViewerApplication.open(new Uint8Array(buffer));
  1781. };
  1782. fileReader.readAsArrayBuffer(file);
  1783. }
  1784. var appConfig = PDFViewerApplication.appConfig;
  1785. appConfig.toolbar.viewBookmark.setAttribute('hidden', 'true');
  1786. appConfig.secondaryToolbar.viewBookmarkButton.setAttribute('hidden', 'true');
  1787. appConfig.toolbar.download.setAttribute('hidden', 'true');
  1788. appConfig.secondaryToolbar.downloadButton.setAttribute('hidden', 'true');
  1789. };
  1790. }
  1791. function webViewerPresentationMode() {
  1792. PDFViewerApplication.requestPresentationMode();
  1793. }
  1794. function webViewerOpenFile() {
  1795. var openFileInputName = PDFViewerApplication.appConfig.openFileInputName;
  1796. document.getElementById(openFileInputName).click();
  1797. }
  1798. function webViewerPrint() {
  1799. window.print();
  1800. }
  1801. function webViewerDownload() {
  1802. PDFViewerApplication.download();
  1803. }
  1804. function webViewerFirstPage() {
  1805. if (PDFViewerApplication.pdfDocument) {
  1806. PDFViewerApplication.page = 1;
  1807. }
  1808. }
  1809. function webViewerLastPage() {
  1810. if (PDFViewerApplication.pdfDocument) {
  1811. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  1812. }
  1813. }
  1814. function webViewerNextPage() {
  1815. PDFViewerApplication.page++;
  1816. }
  1817. function webViewerPreviousPage() {
  1818. PDFViewerApplication.page--;
  1819. }
  1820. function webViewerZoomIn() {
  1821. PDFViewerApplication.zoomIn();
  1822. }
  1823. function webViewerZoomOut() {
  1824. PDFViewerApplication.zoomOut();
  1825. }
  1826. function webViewerPageNumberChanged(evt) {
  1827. var pdfViewer = PDFViewerApplication.pdfViewer;
  1828. if (evt.value !== '') {
  1829. pdfViewer.currentPageLabel = evt.value;
  1830. }
  1831. if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) {
  1832. PDFViewerApplication.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  1833. }
  1834. }
  1835. function webViewerScaleChanged(evt) {
  1836. PDFViewerApplication.pdfViewer.currentScaleValue = evt.value;
  1837. }
  1838. function webViewerRotateCw() {
  1839. PDFViewerApplication.rotatePages(90);
  1840. }
  1841. function webViewerRotateCcw() {
  1842. PDFViewerApplication.rotatePages(-90);
  1843. }
  1844. function webViewerSwitchScrollMode(evt) {
  1845. PDFViewerApplication.pdfViewer.scrollMode = evt.mode;
  1846. }
  1847. function webViewerSwitchSpreadMode(evt) {
  1848. PDFViewerApplication.pdfViewer.spreadMode = evt.mode;
  1849. }
  1850. function webViewerDocumentProperties() {
  1851. PDFViewerApplication.pdfDocumentProperties.open();
  1852. }
  1853. function webViewerFind(evt) {
  1854. PDFViewerApplication.findController.executeCommand('find' + evt.type, {
  1855. query: evt.query,
  1856. phraseSearch: evt.phraseSearch,
  1857. caseSensitive: evt.caseSensitive,
  1858. entireWord: evt.entireWord,
  1859. highlightAll: evt.highlightAll,
  1860. findPrevious: evt.findPrevious
  1861. });
  1862. }
  1863. function webViewerFindFromUrlHash(evt) {
  1864. PDFViewerApplication.findController.executeCommand('find', {
  1865. query: evt.query,
  1866. phraseSearch: evt.phraseSearch,
  1867. caseSensitive: false,
  1868. entireWord: false,
  1869. highlightAll: true,
  1870. findPrevious: false
  1871. });
  1872. }
  1873. function webViewerUpdateFindMatchesCount(_ref9) {
  1874. var matchesCount = _ref9.matchesCount;
  1875. if (PDFViewerApplication.supportsIntegratedFind) {
  1876. PDFViewerApplication.externalServices.updateFindMatchesCount(matchesCount);
  1877. } else {
  1878. PDFViewerApplication.findBar.updateResultsCount(matchesCount);
  1879. }
  1880. }
  1881. function webViewerUpdateFindControlState(_ref10) {
  1882. var state = _ref10.state,
  1883. previous = _ref10.previous,
  1884. matchesCount = _ref10.matchesCount;
  1885. if (PDFViewerApplication.supportsIntegratedFind) {
  1886. PDFViewerApplication.externalServices.updateFindControlState({
  1887. result: state,
  1888. findPrevious: previous,
  1889. matchesCount: matchesCount
  1890. });
  1891. } else {
  1892. PDFViewerApplication.findBar.updateUIState(state, previous, matchesCount);
  1893. }
  1894. }
  1895. function webViewerScaleChanging(evt) {
  1896. PDFViewerApplication.toolbar.setPageScale(evt.presetValue, evt.scale);
  1897. PDFViewerApplication.pdfViewer.update();
  1898. }
  1899. function webViewerRotationChanging(evt) {
  1900. PDFViewerApplication.pdfThumbnailViewer.pagesRotation = evt.pagesRotation;
  1901. PDFViewerApplication.forceRendering();
  1902. PDFViewerApplication.pdfViewer.currentPageNumber = evt.pageNumber;
  1903. }
  1904. function webViewerPageChanging(evt) {
  1905. var page = evt.pageNumber;
  1906. PDFViewerApplication.toolbar.setPageNumber(page, evt.pageLabel || null);
  1907. PDFViewerApplication.secondaryToolbar.setPageNumber(page);
  1908. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  1909. PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(page);
  1910. }
  1911. if (typeof Stats !== 'undefined' && Stats.enabled) {
  1912. var pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1);
  1913. if (pageView && pageView.stats) {
  1914. Stats.add(page, pageView.stats);
  1915. }
  1916. }
  1917. }
  1918. function webViewerVisibilityChange(evt) {
  1919. if (document.visibilityState === 'visible') {
  1920. setZoomDisabledTimeout();
  1921. }
  1922. }
  1923. var zoomDisabledTimeout = null;
  1924. function setZoomDisabledTimeout() {
  1925. if (zoomDisabledTimeout) {
  1926. clearTimeout(zoomDisabledTimeout);
  1927. }
  1928. zoomDisabledTimeout = setTimeout(function () {
  1929. zoomDisabledTimeout = null;
  1930. }, WHEEL_ZOOM_DISABLED_TIMEOUT);
  1931. }
  1932. function webViewerWheel(evt) {
  1933. var pdfViewer = PDFViewerApplication.pdfViewer;
  1934. if (pdfViewer.isInPresentationMode) {
  1935. return;
  1936. }
  1937. if (evt.ctrlKey || evt.metaKey) {
  1938. var support = PDFViewerApplication.supportedMouseWheelZoomModifierKeys;
  1939. if (evt.ctrlKey && !support.ctrlKey || evt.metaKey && !support.metaKey) {
  1940. return;
  1941. }
  1942. evt.preventDefault();
  1943. if (zoomDisabledTimeout || document.visibilityState === 'hidden') {
  1944. return;
  1945. }
  1946. var previousScale = pdfViewer.currentScale;
  1947. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  1948. var MOUSE_WHEEL_DELTA_PER_PAGE_SCALE = 3.0;
  1949. var ticks = delta * MOUSE_WHEEL_DELTA_PER_PAGE_SCALE;
  1950. if (ticks < 0) {
  1951. PDFViewerApplication.zoomOut(-ticks);
  1952. } else {
  1953. PDFViewerApplication.zoomIn(ticks);
  1954. }
  1955. var currentScale = pdfViewer.currentScale;
  1956. if (previousScale !== currentScale) {
  1957. var scaleCorrectionFactor = currentScale / previousScale - 1;
  1958. var rect = pdfViewer.container.getBoundingClientRect();
  1959. var dx = evt.clientX - rect.left;
  1960. var dy = evt.clientY - rect.top;
  1961. pdfViewer.container.scrollLeft += dx * scaleCorrectionFactor;
  1962. pdfViewer.container.scrollTop += dy * scaleCorrectionFactor;
  1963. }
  1964. } else {
  1965. setZoomDisabledTimeout();
  1966. }
  1967. }
  1968. function webViewerClick(evt) {
  1969. if (!PDFViewerApplication.secondaryToolbar.isOpen) {
  1970. return;
  1971. }
  1972. var appConfig = PDFViewerApplication.appConfig;
  1973. if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar.container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar.toggleButton) {
  1974. PDFViewerApplication.secondaryToolbar.close();
  1975. }
  1976. }
  1977. function webViewerKeyDown(evt) {
  1978. if (PDFViewerApplication.overlayManager.active) {
  1979. return;
  1980. }
  1981. var handled = false,
  1982. ensureViewerFocused = false;
  1983. var cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0);
  1984. var pdfViewer = PDFViewerApplication.pdfViewer;
  1985. var isViewerInPresentationMode = pdfViewer && pdfViewer.isInPresentationMode;
  1986. if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
  1987. switch (evt.keyCode) {
  1988. case 70:
  1989. if (!PDFViewerApplication.supportsIntegratedFind) {
  1990. PDFViewerApplication.findBar.open();
  1991. handled = true;
  1992. }
  1993. break;
  1994. case 71:
  1995. if (!PDFViewerApplication.supportsIntegratedFind) {
  1996. var findState = PDFViewerApplication.findController.state;
  1997. if (findState) {
  1998. PDFViewerApplication.findController.executeCommand('findagain', {
  1999. query: findState.query,
  2000. phraseSearch: findState.phraseSearch,
  2001. caseSensitive: findState.caseSensitive,
  2002. entireWord: findState.entireWord,
  2003. highlightAll: findState.highlightAll,
  2004. findPrevious: cmd === 5 || cmd === 12
  2005. });
  2006. }
  2007. handled = true;
  2008. }
  2009. break;
  2010. case 61:
  2011. case 107:
  2012. case 187:
  2013. case 171:
  2014. if (!isViewerInPresentationMode) {
  2015. PDFViewerApplication.zoomIn();
  2016. }
  2017. handled = true;
  2018. break;
  2019. case 173:
  2020. case 109:
  2021. case 189:
  2022. if (!isViewerInPresentationMode) {
  2023. PDFViewerApplication.zoomOut();
  2024. }
  2025. handled = true;
  2026. break;
  2027. case 48:
  2028. case 96:
  2029. if (!isViewerInPresentationMode) {
  2030. setTimeout(function () {
  2031. pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  2032. });
  2033. handled = false;
  2034. }
  2035. break;
  2036. case 38:
  2037. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  2038. PDFViewerApplication.page = 1;
  2039. handled = true;
  2040. ensureViewerFocused = true;
  2041. }
  2042. break;
  2043. case 40:
  2044. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2045. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2046. handled = true;
  2047. ensureViewerFocused = true;
  2048. }
  2049. break;
  2050. }
  2051. }
  2052. if (cmd === 1 || cmd === 8) {
  2053. switch (evt.keyCode) {
  2054. case 83:
  2055. PDFViewerApplication.download();
  2056. handled = true;
  2057. break;
  2058. }
  2059. }
  2060. if (cmd === 3 || cmd === 10) {
  2061. switch (evt.keyCode) {
  2062. case 80:
  2063. PDFViewerApplication.requestPresentationMode();
  2064. handled = true;
  2065. break;
  2066. case 71:
  2067. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  2068. handled = true;
  2069. break;
  2070. }
  2071. }
  2072. if (handled) {
  2073. if (ensureViewerFocused && !isViewerInPresentationMode) {
  2074. pdfViewer.focus();
  2075. }
  2076. evt.preventDefault();
  2077. return;
  2078. }
  2079. var curElement = document.activeElement || document.querySelector(':focus');
  2080. var curElementTagName = curElement && curElement.tagName.toUpperCase();
  2081. if (curElementTagName === 'INPUT' || curElementTagName === 'TEXTAREA' || curElementTagName === 'SELECT') {
  2082. if (evt.keyCode !== 27) {
  2083. return;
  2084. }
  2085. }
  2086. if (cmd === 0) {
  2087. var turnPage = 0,
  2088. turnOnlyIfPageFit = false;
  2089. switch (evt.keyCode) {
  2090. case 38:
  2091. case 33:
  2092. if (pdfViewer.isVerticalScrollbarEnabled) {
  2093. turnOnlyIfPageFit = true;
  2094. }
  2095. turnPage = -1;
  2096. break;
  2097. case 8:
  2098. if (!isViewerInPresentationMode) {
  2099. turnOnlyIfPageFit = true;
  2100. }
  2101. turnPage = -1;
  2102. break;
  2103. case 37:
  2104. if (pdfViewer.isHorizontalScrollbarEnabled) {
  2105. turnOnlyIfPageFit = true;
  2106. }
  2107. case 75:
  2108. case 80:
  2109. turnPage = -1;
  2110. break;
  2111. case 27:
  2112. if (PDFViewerApplication.secondaryToolbar.isOpen) {
  2113. PDFViewerApplication.secondaryToolbar.close();
  2114. handled = true;
  2115. }
  2116. if (!PDFViewerApplication.supportsIntegratedFind && PDFViewerApplication.findBar.opened) {
  2117. PDFViewerApplication.findBar.close();
  2118. handled = true;
  2119. }
  2120. break;
  2121. case 40:
  2122. case 34:
  2123. if (pdfViewer.isVerticalScrollbarEnabled) {
  2124. turnOnlyIfPageFit = true;
  2125. }
  2126. turnPage = 1;
  2127. break;
  2128. case 13:
  2129. case 32:
  2130. if (!isViewerInPresentationMode) {
  2131. turnOnlyIfPageFit = true;
  2132. }
  2133. turnPage = 1;
  2134. break;
  2135. case 39:
  2136. if (pdfViewer.isHorizontalScrollbarEnabled) {
  2137. turnOnlyIfPageFit = true;
  2138. }
  2139. case 74:
  2140. case 78:
  2141. turnPage = 1;
  2142. break;
  2143. case 36:
  2144. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  2145. PDFViewerApplication.page = 1;
  2146. handled = true;
  2147. ensureViewerFocused = true;
  2148. }
  2149. break;
  2150. case 35:
  2151. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2152. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2153. handled = true;
  2154. ensureViewerFocused = true;
  2155. }
  2156. break;
  2157. case 83:
  2158. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.SELECT);
  2159. break;
  2160. case 72:
  2161. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.HAND);
  2162. break;
  2163. case 82:
  2164. PDFViewerApplication.rotatePages(90);
  2165. break;
  2166. case 115:
  2167. PDFViewerApplication.pdfSidebar.toggle();
  2168. break;
  2169. }
  2170. if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === 'page-fit')) {
  2171. if (turnPage > 0) {
  2172. if (PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2173. PDFViewerApplication.page++;
  2174. }
  2175. } else {
  2176. if (PDFViewerApplication.page > 1) {
  2177. PDFViewerApplication.page--;
  2178. }
  2179. }
  2180. handled = true;
  2181. }
  2182. }
  2183. if (cmd === 4) {
  2184. switch (evt.keyCode) {
  2185. case 13:
  2186. case 32:
  2187. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== 'page-fit') {
  2188. break;
  2189. }
  2190. if (PDFViewerApplication.page > 1) {
  2191. PDFViewerApplication.page--;
  2192. }
  2193. handled = true;
  2194. break;
  2195. case 82:
  2196. PDFViewerApplication.rotatePages(-90);
  2197. break;
  2198. }
  2199. }
  2200. if (!handled && !isViewerInPresentationMode) {
  2201. if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !== 'BUTTON') {
  2202. ensureViewerFocused = true;
  2203. }
  2204. }
  2205. if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
  2206. pdfViewer.focus();
  2207. }
  2208. if (handled) {
  2209. evt.preventDefault();
  2210. }
  2211. }
  2212. function apiPageModeToSidebarView(mode) {
  2213. switch (mode) {
  2214. case 'UseNone':
  2215. return _pdf_sidebar.SidebarView.NONE;
  2216. case 'UseThumbs':
  2217. return _pdf_sidebar.SidebarView.THUMBS;
  2218. case 'UseOutlines':
  2219. return _pdf_sidebar.SidebarView.OUTLINE;
  2220. case 'UseAttachments':
  2221. return _pdf_sidebar.SidebarView.ATTACHMENTS;
  2222. case 'UseOC':
  2223. }
  2224. return _pdf_sidebar.SidebarView.NONE;
  2225. }
  2226. var PDFPrintServiceFactory = {
  2227. instance: {
  2228. supportsPrinting: false,
  2229. createPrintService: function createPrintService() {
  2230. throw new Error('Not implemented: createPrintService');
  2231. }
  2232. }
  2233. };
  2234. exports.PDFPrintServiceFactory = PDFPrintServiceFactory;
  2235. /***/ }),
  2236. /* 2 */
  2237. /***/ (function(module, exports, __webpack_require__) {
  2238. "use strict";
  2239. module.exports = __webpack_require__(3);
  2240. /***/ }),
  2241. /* 3 */
  2242. /***/ (function(module, exports, __webpack_require__) {
  2243. "use strict";
  2244. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  2245. var g = function () {
  2246. return this || (typeof self === "undefined" ? "undefined" : _typeof(self)) === "object" && self;
  2247. }() || Function("return this")();
  2248. var hadRuntime = g.regeneratorRuntime && Object.getOwnPropertyNames(g).indexOf("regeneratorRuntime") >= 0;
  2249. var oldRuntime = hadRuntime && g.regeneratorRuntime;
  2250. g.regeneratorRuntime = undefined;
  2251. module.exports = __webpack_require__(4);
  2252. if (hadRuntime) {
  2253. g.regeneratorRuntime = oldRuntime;
  2254. } else {
  2255. try {
  2256. delete g.regeneratorRuntime;
  2257. } catch (e) {
  2258. g.regeneratorRuntime = undefined;
  2259. }
  2260. }
  2261. /***/ }),
  2262. /* 4 */
  2263. /***/ (function(module, exports, __webpack_require__) {
  2264. "use strict";
  2265. /* WEBPACK VAR INJECTION */(function(module) {
  2266. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  2267. !function (global) {
  2268. "use strict";
  2269. var Op = Object.prototype;
  2270. var hasOwn = Op.hasOwnProperty;
  2271. var undefined;
  2272. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  2273. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  2274. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  2275. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  2276. var inModule = ( false ? undefined : _typeof(module)) === "object";
  2277. var runtime = global.regeneratorRuntime;
  2278. if (runtime) {
  2279. if (inModule) {
  2280. module.exports = runtime;
  2281. }
  2282. return;
  2283. }
  2284. runtime = global.regeneratorRuntime = inModule ? module.exports : {};
  2285. function wrap(innerFn, outerFn, self, tryLocsList) {
  2286. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  2287. var generator = Object.create(protoGenerator.prototype);
  2288. var context = new Context(tryLocsList || []);
  2289. generator._invoke = makeInvokeMethod(innerFn, self, context);
  2290. return generator;
  2291. }
  2292. runtime.wrap = wrap;
  2293. function tryCatch(fn, obj, arg) {
  2294. try {
  2295. return {
  2296. type: "normal",
  2297. arg: fn.call(obj, arg)
  2298. };
  2299. } catch (err) {
  2300. return {
  2301. type: "throw",
  2302. arg: err
  2303. };
  2304. }
  2305. }
  2306. var GenStateSuspendedStart = "suspendedStart";
  2307. var GenStateSuspendedYield = "suspendedYield";
  2308. var GenStateExecuting = "executing";
  2309. var GenStateCompleted = "completed";
  2310. var ContinueSentinel = {};
  2311. function Generator() {}
  2312. function GeneratorFunction() {}
  2313. function GeneratorFunctionPrototype() {}
  2314. var IteratorPrototype = {};
  2315. IteratorPrototype[iteratorSymbol] = function () {
  2316. return this;
  2317. };
  2318. var getProto = Object.getPrototypeOf;
  2319. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  2320. if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  2321. IteratorPrototype = NativeIteratorPrototype;
  2322. }
  2323. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
  2324. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  2325. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  2326. GeneratorFunctionPrototype[toStringTagSymbol] = GeneratorFunction.displayName = "GeneratorFunction";
  2327. function defineIteratorMethods(prototype) {
  2328. ["next", "throw", "return"].forEach(function (method) {
  2329. prototype[method] = function (arg) {
  2330. return this._invoke(method, arg);
  2331. };
  2332. });
  2333. }
  2334. runtime.isGeneratorFunction = function (genFun) {
  2335. var ctor = typeof genFun === "function" && genFun.constructor;
  2336. return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
  2337. };
  2338. runtime.mark = function (genFun) {
  2339. if (Object.setPrototypeOf) {
  2340. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  2341. } else {
  2342. genFun.__proto__ = GeneratorFunctionPrototype;
  2343. if (!(toStringTagSymbol in genFun)) {
  2344. genFun[toStringTagSymbol] = "GeneratorFunction";
  2345. }
  2346. }
  2347. genFun.prototype = Object.create(Gp);
  2348. return genFun;
  2349. };
  2350. runtime.awrap = function (arg) {
  2351. return {
  2352. __await: arg
  2353. };
  2354. };
  2355. function AsyncIterator(generator) {
  2356. function invoke(method, arg, resolve, reject) {
  2357. var record = tryCatch(generator[method], generator, arg);
  2358. if (record.type === "throw") {
  2359. reject(record.arg);
  2360. } else {
  2361. var result = record.arg;
  2362. var value = result.value;
  2363. if (value && _typeof(value) === "object" && hasOwn.call(value, "__await")) {
  2364. return Promise.resolve(value.__await).then(function (value) {
  2365. invoke("next", value, resolve, reject);
  2366. }, function (err) {
  2367. invoke("throw", err, resolve, reject);
  2368. });
  2369. }
  2370. return Promise.resolve(value).then(function (unwrapped) {
  2371. result.value = unwrapped;
  2372. resolve(result);
  2373. }, function (error) {
  2374. return invoke("throw", error, resolve, reject);
  2375. });
  2376. }
  2377. }
  2378. var previousPromise;
  2379. function enqueue(method, arg) {
  2380. function callInvokeWithMethodAndArg() {
  2381. return new Promise(function (resolve, reject) {
  2382. invoke(method, arg, resolve, reject);
  2383. });
  2384. }
  2385. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  2386. }
  2387. this._invoke = enqueue;
  2388. }
  2389. defineIteratorMethods(AsyncIterator.prototype);
  2390. AsyncIterator.prototype[asyncIteratorSymbol] = function () {
  2391. return this;
  2392. };
  2393. runtime.AsyncIterator = AsyncIterator;
  2394. runtime.async = function (innerFn, outerFn, self, tryLocsList) {
  2395. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList));
  2396. return runtime.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  2397. return result.done ? result.value : iter.next();
  2398. });
  2399. };
  2400. function makeInvokeMethod(innerFn, self, context) {
  2401. var state = GenStateSuspendedStart;
  2402. return function invoke(method, arg) {
  2403. if (state === GenStateExecuting) {
  2404. throw new Error("Generator is already running");
  2405. }
  2406. if (state === GenStateCompleted) {
  2407. if (method === "throw") {
  2408. throw arg;
  2409. }
  2410. return doneResult();
  2411. }
  2412. context.method = method;
  2413. context.arg = arg;
  2414. while (true) {
  2415. var delegate = context.delegate;
  2416. if (delegate) {
  2417. var delegateResult = maybeInvokeDelegate(delegate, context);
  2418. if (delegateResult) {
  2419. if (delegateResult === ContinueSentinel) continue;
  2420. return delegateResult;
  2421. }
  2422. }
  2423. if (context.method === "next") {
  2424. context.sent = context._sent = context.arg;
  2425. } else if (context.method === "throw") {
  2426. if (state === GenStateSuspendedStart) {
  2427. state = GenStateCompleted;
  2428. throw context.arg;
  2429. }
  2430. context.dispatchException(context.arg);
  2431. } else if (context.method === "return") {
  2432. context.abrupt("return", context.arg);
  2433. }
  2434. state = GenStateExecuting;
  2435. var record = tryCatch(innerFn, self, context);
  2436. if (record.type === "normal") {
  2437. state = context.done ? GenStateCompleted : GenStateSuspendedYield;
  2438. if (record.arg === ContinueSentinel) {
  2439. continue;
  2440. }
  2441. return {
  2442. value: record.arg,
  2443. done: context.done
  2444. };
  2445. } else if (record.type === "throw") {
  2446. state = GenStateCompleted;
  2447. context.method = "throw";
  2448. context.arg = record.arg;
  2449. }
  2450. }
  2451. };
  2452. }
  2453. function maybeInvokeDelegate(delegate, context) {
  2454. var method = delegate.iterator[context.method];
  2455. if (method === undefined) {
  2456. context.delegate = null;
  2457. if (context.method === "throw") {
  2458. if (delegate.iterator.return) {
  2459. context.method = "return";
  2460. context.arg = undefined;
  2461. maybeInvokeDelegate(delegate, context);
  2462. if (context.method === "throw") {
  2463. return ContinueSentinel;
  2464. }
  2465. }
  2466. context.method = "throw";
  2467. context.arg = new TypeError("The iterator does not provide a 'throw' method");
  2468. }
  2469. return ContinueSentinel;
  2470. }
  2471. var record = tryCatch(method, delegate.iterator, context.arg);
  2472. if (record.type === "throw") {
  2473. context.method = "throw";
  2474. context.arg = record.arg;
  2475. context.delegate = null;
  2476. return ContinueSentinel;
  2477. }
  2478. var info = record.arg;
  2479. if (!info) {
  2480. context.method = "throw";
  2481. context.arg = new TypeError("iterator result is not an object");
  2482. context.delegate = null;
  2483. return ContinueSentinel;
  2484. }
  2485. if (info.done) {
  2486. context[delegate.resultName] = info.value;
  2487. context.next = delegate.nextLoc;
  2488. if (context.method !== "return") {
  2489. context.method = "next";
  2490. context.arg = undefined;
  2491. }
  2492. } else {
  2493. return info;
  2494. }
  2495. context.delegate = null;
  2496. return ContinueSentinel;
  2497. }
  2498. defineIteratorMethods(Gp);
  2499. Gp[toStringTagSymbol] = "Generator";
  2500. Gp[iteratorSymbol] = function () {
  2501. return this;
  2502. };
  2503. Gp.toString = function () {
  2504. return "[object Generator]";
  2505. };
  2506. function pushTryEntry(locs) {
  2507. var entry = {
  2508. tryLoc: locs[0]
  2509. };
  2510. if (1 in locs) {
  2511. entry.catchLoc = locs[1];
  2512. }
  2513. if (2 in locs) {
  2514. entry.finallyLoc = locs[2];
  2515. entry.afterLoc = locs[3];
  2516. }
  2517. this.tryEntries.push(entry);
  2518. }
  2519. function resetTryEntry(entry) {
  2520. var record = entry.completion || {};
  2521. record.type = "normal";
  2522. delete record.arg;
  2523. entry.completion = record;
  2524. }
  2525. function Context(tryLocsList) {
  2526. this.tryEntries = [{
  2527. tryLoc: "root"
  2528. }];
  2529. tryLocsList.forEach(pushTryEntry, this);
  2530. this.reset(true);
  2531. }
  2532. runtime.keys = function (object) {
  2533. var keys = [];
  2534. for (var key in object) {
  2535. keys.push(key);
  2536. }
  2537. keys.reverse();
  2538. return function next() {
  2539. while (keys.length) {
  2540. var key = keys.pop();
  2541. if (key in object) {
  2542. next.value = key;
  2543. next.done = false;
  2544. return next;
  2545. }
  2546. }
  2547. next.done = true;
  2548. return next;
  2549. };
  2550. };
  2551. function values(iterable) {
  2552. if (iterable) {
  2553. var iteratorMethod = iterable[iteratorSymbol];
  2554. if (iteratorMethod) {
  2555. return iteratorMethod.call(iterable);
  2556. }
  2557. if (typeof iterable.next === "function") {
  2558. return iterable;
  2559. }
  2560. if (!isNaN(iterable.length)) {
  2561. var i = -1,
  2562. next = function next() {
  2563. while (++i < iterable.length) {
  2564. if (hasOwn.call(iterable, i)) {
  2565. next.value = iterable[i];
  2566. next.done = false;
  2567. return next;
  2568. }
  2569. }
  2570. next.value = undefined;
  2571. next.done = true;
  2572. return next;
  2573. };
  2574. return next.next = next;
  2575. }
  2576. }
  2577. return {
  2578. next: doneResult
  2579. };
  2580. }
  2581. runtime.values = values;
  2582. function doneResult() {
  2583. return {
  2584. value: undefined,
  2585. done: true
  2586. };
  2587. }
  2588. Context.prototype = {
  2589. constructor: Context,
  2590. reset: function reset(skipTempReset) {
  2591. this.prev = 0;
  2592. this.next = 0;
  2593. this.sent = this._sent = undefined;
  2594. this.done = false;
  2595. this.delegate = null;
  2596. this.method = "next";
  2597. this.arg = undefined;
  2598. this.tryEntries.forEach(resetTryEntry);
  2599. if (!skipTempReset) {
  2600. for (var name in this) {
  2601. if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
  2602. this[name] = undefined;
  2603. }
  2604. }
  2605. }
  2606. },
  2607. stop: function stop() {
  2608. this.done = true;
  2609. var rootEntry = this.tryEntries[0];
  2610. var rootRecord = rootEntry.completion;
  2611. if (rootRecord.type === "throw") {
  2612. throw rootRecord.arg;
  2613. }
  2614. return this.rval;
  2615. },
  2616. dispatchException: function dispatchException(exception) {
  2617. if (this.done) {
  2618. throw exception;
  2619. }
  2620. var context = this;
  2621. function handle(loc, caught) {
  2622. record.type = "throw";
  2623. record.arg = exception;
  2624. context.next = loc;
  2625. if (caught) {
  2626. context.method = "next";
  2627. context.arg = undefined;
  2628. }
  2629. return !!caught;
  2630. }
  2631. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  2632. var entry = this.tryEntries[i];
  2633. var record = entry.completion;
  2634. if (entry.tryLoc === "root") {
  2635. return handle("end");
  2636. }
  2637. if (entry.tryLoc <= this.prev) {
  2638. var hasCatch = hasOwn.call(entry, "catchLoc");
  2639. var hasFinally = hasOwn.call(entry, "finallyLoc");
  2640. if (hasCatch && hasFinally) {
  2641. if (this.prev < entry.catchLoc) {
  2642. return handle(entry.catchLoc, true);
  2643. } else if (this.prev < entry.finallyLoc) {
  2644. return handle(entry.finallyLoc);
  2645. }
  2646. } else if (hasCatch) {
  2647. if (this.prev < entry.catchLoc) {
  2648. return handle(entry.catchLoc, true);
  2649. }
  2650. } else if (hasFinally) {
  2651. if (this.prev < entry.finallyLoc) {
  2652. return handle(entry.finallyLoc);
  2653. }
  2654. } else {
  2655. throw new Error("try statement without catch or finally");
  2656. }
  2657. }
  2658. }
  2659. },
  2660. abrupt: function abrupt(type, arg) {
  2661. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  2662. var entry = this.tryEntries[i];
  2663. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  2664. var finallyEntry = entry;
  2665. break;
  2666. }
  2667. }
  2668. if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
  2669. finallyEntry = null;
  2670. }
  2671. var record = finallyEntry ? finallyEntry.completion : {};
  2672. record.type = type;
  2673. record.arg = arg;
  2674. if (finallyEntry) {
  2675. this.method = "next";
  2676. this.next = finallyEntry.finallyLoc;
  2677. return ContinueSentinel;
  2678. }
  2679. return this.complete(record);
  2680. },
  2681. complete: function complete(record, afterLoc) {
  2682. if (record.type === "throw") {
  2683. throw record.arg;
  2684. }
  2685. if (record.type === "break" || record.type === "continue") {
  2686. this.next = record.arg;
  2687. } else if (record.type === "return") {
  2688. this.rval = this.arg = record.arg;
  2689. this.method = "return";
  2690. this.next = "end";
  2691. } else if (record.type === "normal" && afterLoc) {
  2692. this.next = afterLoc;
  2693. }
  2694. return ContinueSentinel;
  2695. },
  2696. finish: function finish(finallyLoc) {
  2697. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  2698. var entry = this.tryEntries[i];
  2699. if (entry.finallyLoc === finallyLoc) {
  2700. this.complete(entry.completion, entry.afterLoc);
  2701. resetTryEntry(entry);
  2702. return ContinueSentinel;
  2703. }
  2704. }
  2705. },
  2706. "catch": function _catch(tryLoc) {
  2707. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  2708. var entry = this.tryEntries[i];
  2709. if (entry.tryLoc === tryLoc) {
  2710. var record = entry.completion;
  2711. if (record.type === "throw") {
  2712. var thrown = record.arg;
  2713. resetTryEntry(entry);
  2714. }
  2715. return thrown;
  2716. }
  2717. }
  2718. throw new Error("illegal catch attempt");
  2719. },
  2720. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  2721. this.delegate = {
  2722. iterator: values(iterable),
  2723. resultName: resultName,
  2724. nextLoc: nextLoc
  2725. };
  2726. if (this.method === "next") {
  2727. this.arg = undefined;
  2728. }
  2729. return ContinueSentinel;
  2730. }
  2731. };
  2732. }(function () {
  2733. return this || (typeof self === "undefined" ? "undefined" : _typeof(self)) === "object" && self;
  2734. }() || Function("return this")());
  2735. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(5)(module)))
  2736. /***/ }),
  2737. /* 5 */
  2738. /***/ (function(module, exports, __webpack_require__) {
  2739. "use strict";
  2740. module.exports = function (module) {
  2741. if (!module.webpackPolyfill) {
  2742. module.deprecate = function () {};
  2743. module.paths = [];
  2744. if (!module.children) module.children = [];
  2745. Object.defineProperty(module, "loaded", {
  2746. enumerable: true,
  2747. get: function get() {
  2748. return module.l;
  2749. }
  2750. });
  2751. Object.defineProperty(module, "id", {
  2752. enumerable: true,
  2753. get: function get() {
  2754. return module.i;
  2755. }
  2756. });
  2757. module.webpackPolyfill = 1;
  2758. }
  2759. return module;
  2760. };
  2761. /***/ }),
  2762. /* 6 */
  2763. /***/ (function(module, exports, __webpack_require__) {
  2764. "use strict";
  2765. Object.defineProperty(exports, "__esModule", {
  2766. value: true
  2767. });
  2768. exports.isValidRotation = isValidRotation;
  2769. exports.isValidScrollMode = isValidScrollMode;
  2770. exports.isValidSpreadMode = isValidSpreadMode;
  2771. exports.isPortraitOrientation = isPortraitOrientation;
  2772. exports.getGlobalEventBus = getGlobalEventBus;
  2773. exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
  2774. exports.noContextMenuHandler = noContextMenuHandler;
  2775. exports.parseQueryString = parseQueryString;
  2776. exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
  2777. exports.getVisibleElements = getVisibleElements;
  2778. exports.roundToDivide = roundToDivide;
  2779. exports.getPageSizeInches = getPageSizeInches;
  2780. exports.approximateFraction = approximateFraction;
  2781. exports.getOutputScale = getOutputScale;
  2782. exports.scrollIntoView = scrollIntoView;
  2783. exports.watchScroll = watchScroll;
  2784. exports.binarySearchFirstItem = binarySearchFirstItem;
  2785. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  2786. exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
  2787. exports.moveToEndOfArray = moveToEndOfArray;
  2788. exports.WaitOnType = exports.animationStarted = exports.ProgressBar = exports.EventBus = exports.NullL10n = exports.SpreadMode = exports.ScrollMode = exports.TextLayerMode = exports.RendererType = exports.PresentationModeState = 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 = void 0;
  2789. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  2790. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2791. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2792. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  2793. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2794. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  2795. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
  2796. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
  2797. function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  2798. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  2799. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  2800. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  2801. var CSS_UNITS = 96.0 / 72.0;
  2802. exports.CSS_UNITS = CSS_UNITS;
  2803. var DEFAULT_SCALE_VALUE = 'auto';
  2804. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  2805. var DEFAULT_SCALE = 1.0;
  2806. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  2807. var MIN_SCALE = 0.10;
  2808. exports.MIN_SCALE = MIN_SCALE;
  2809. var MAX_SCALE = 10.0;
  2810. exports.MAX_SCALE = MAX_SCALE;
  2811. var UNKNOWN_SCALE = 0;
  2812. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  2813. var MAX_AUTO_SCALE = 1.25;
  2814. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  2815. var SCROLLBAR_PADDING = 40;
  2816. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  2817. var VERTICAL_PADDING = 5;
  2818. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  2819. var PresentationModeState = {
  2820. UNKNOWN: 0,
  2821. NORMAL: 1,
  2822. CHANGING: 2,
  2823. FULLSCREEN: 3
  2824. };
  2825. exports.PresentationModeState = PresentationModeState;
  2826. var RendererType = {
  2827. CANVAS: 'canvas',
  2828. SVG: 'svg'
  2829. };
  2830. exports.RendererType = RendererType;
  2831. var TextLayerMode = {
  2832. DISABLE: 0,
  2833. ENABLE: 1,
  2834. ENABLE_ENHANCE: 2
  2835. };
  2836. exports.TextLayerMode = TextLayerMode;
  2837. var ScrollMode = {
  2838. UNKNOWN: -1,
  2839. VERTICAL: 0,
  2840. HORIZONTAL: 1,
  2841. WRAPPED: 2
  2842. };
  2843. exports.ScrollMode = ScrollMode;
  2844. var SpreadMode = {
  2845. UNKNOWN: -1,
  2846. NONE: 0,
  2847. ODD: 1,
  2848. EVEN: 2
  2849. };
  2850. exports.SpreadMode = SpreadMode;
  2851. function formatL10nValue(text, args) {
  2852. if (!args) {
  2853. return text;
  2854. }
  2855. return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function (all, name) {
  2856. return name in args ? args[name] : '{{' + name + '}}';
  2857. });
  2858. }
  2859. var NullL10n = {
  2860. getLanguage: function () {
  2861. var _getLanguage = _asyncToGenerator(
  2862. /*#__PURE__*/
  2863. _regenerator.default.mark(function _callee() {
  2864. return _regenerator.default.wrap(function _callee$(_context) {
  2865. while (1) {
  2866. switch (_context.prev = _context.next) {
  2867. case 0:
  2868. return _context.abrupt("return", 'en-us');
  2869. case 1:
  2870. case "end":
  2871. return _context.stop();
  2872. }
  2873. }
  2874. }, _callee, this);
  2875. }));
  2876. function getLanguage() {
  2877. return _getLanguage.apply(this, arguments);
  2878. }
  2879. return getLanguage;
  2880. }(),
  2881. getDirection: function () {
  2882. var _getDirection = _asyncToGenerator(
  2883. /*#__PURE__*/
  2884. _regenerator.default.mark(function _callee2() {
  2885. return _regenerator.default.wrap(function _callee2$(_context2) {
  2886. while (1) {
  2887. switch (_context2.prev = _context2.next) {
  2888. case 0:
  2889. return _context2.abrupt("return", 'ltr');
  2890. case 1:
  2891. case "end":
  2892. return _context2.stop();
  2893. }
  2894. }
  2895. }, _callee2, this);
  2896. }));
  2897. function getDirection() {
  2898. return _getDirection.apply(this, arguments);
  2899. }
  2900. return getDirection;
  2901. }(),
  2902. get: function () {
  2903. var _get = _asyncToGenerator(
  2904. /*#__PURE__*/
  2905. _regenerator.default.mark(function _callee3(property, args, fallback) {
  2906. return _regenerator.default.wrap(function _callee3$(_context3) {
  2907. while (1) {
  2908. switch (_context3.prev = _context3.next) {
  2909. case 0:
  2910. return _context3.abrupt("return", formatL10nValue(fallback, args));
  2911. case 1:
  2912. case "end":
  2913. return _context3.stop();
  2914. }
  2915. }
  2916. }, _callee3, this);
  2917. }));
  2918. function get(_x, _x2, _x3) {
  2919. return _get.apply(this, arguments);
  2920. }
  2921. return get;
  2922. }(),
  2923. translate: function () {
  2924. var _translate = _asyncToGenerator(
  2925. /*#__PURE__*/
  2926. _regenerator.default.mark(function _callee4(element) {
  2927. return _regenerator.default.wrap(function _callee4$(_context4) {
  2928. while (1) {
  2929. switch (_context4.prev = _context4.next) {
  2930. case 0:
  2931. case "end":
  2932. return _context4.stop();
  2933. }
  2934. }
  2935. }, _callee4, this);
  2936. }));
  2937. function translate(_x4) {
  2938. return _translate.apply(this, arguments);
  2939. }
  2940. return translate;
  2941. }()
  2942. };
  2943. exports.NullL10n = NullL10n;
  2944. function getOutputScale(ctx) {
  2945. var devicePixelRatio = window.devicePixelRatio || 1;
  2946. var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
  2947. var pixelRatio = devicePixelRatio / backingStoreRatio;
  2948. return {
  2949. sx: pixelRatio,
  2950. sy: pixelRatio,
  2951. scaled: pixelRatio !== 1
  2952. };
  2953. }
  2954. function scrollIntoView(element, spot) {
  2955. var skipOverflowHiddenElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  2956. var parent = element.offsetParent;
  2957. if (!parent) {
  2958. console.error('offsetParent is not set -- cannot scroll');
  2959. return;
  2960. }
  2961. var offsetY = element.offsetTop + element.clientTop;
  2962. var offsetX = element.offsetLeft + element.clientLeft;
  2963. while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || skipOverflowHiddenElements && getComputedStyle(parent).overflow === 'hidden') {
  2964. if (parent.dataset._scaleY) {
  2965. offsetY /= parent.dataset._scaleY;
  2966. offsetX /= parent.dataset._scaleX;
  2967. }
  2968. offsetY += parent.offsetTop;
  2969. offsetX += parent.offsetLeft;
  2970. parent = parent.offsetParent;
  2971. if (!parent) {
  2972. return;
  2973. }
  2974. }
  2975. if (spot) {
  2976. if (spot.top !== undefined) {
  2977. offsetY += spot.top;
  2978. }
  2979. if (spot.left !== undefined) {
  2980. offsetX += spot.left;
  2981. parent.scrollLeft = offsetX;
  2982. }
  2983. }
  2984. parent.scrollTop = offsetY;
  2985. }
  2986. function watchScroll(viewAreaElement, callback) {
  2987. var debounceScroll = function debounceScroll(evt) {
  2988. if (rAF) {
  2989. return;
  2990. }
  2991. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  2992. rAF = null;
  2993. var currentX = viewAreaElement.scrollLeft;
  2994. var lastX = state.lastX;
  2995. if (currentX !== lastX) {
  2996. state.right = currentX > lastX;
  2997. }
  2998. state.lastX = currentX;
  2999. var currentY = viewAreaElement.scrollTop;
  3000. var lastY = state.lastY;
  3001. if (currentY !== lastY) {
  3002. state.down = currentY > lastY;
  3003. }
  3004. state.lastY = currentY;
  3005. callback(state);
  3006. });
  3007. };
  3008. var state = {
  3009. right: true,
  3010. down: true,
  3011. lastX: viewAreaElement.scrollLeft,
  3012. lastY: viewAreaElement.scrollTop,
  3013. _eventHandler: debounceScroll
  3014. };
  3015. var rAF = null;
  3016. viewAreaElement.addEventListener('scroll', debounceScroll, true);
  3017. return state;
  3018. }
  3019. function parseQueryString(query) {
  3020. var parts = query.split('&');
  3021. var params = Object.create(null);
  3022. for (var i = 0, ii = parts.length; i < ii; ++i) {
  3023. var param = parts[i].split('=');
  3024. var key = param[0].toLowerCase();
  3025. var value = param.length > 1 ? param[1] : null;
  3026. params[decodeURIComponent(key)] = decodeURIComponent(value);
  3027. }
  3028. return params;
  3029. }
  3030. function binarySearchFirstItem(items, condition) {
  3031. var minIndex = 0;
  3032. var maxIndex = items.length - 1;
  3033. if (items.length === 0 || !condition(items[maxIndex])) {
  3034. return items.length;
  3035. }
  3036. if (condition(items[minIndex])) {
  3037. return minIndex;
  3038. }
  3039. while (minIndex < maxIndex) {
  3040. var currentIndex = minIndex + maxIndex >> 1;
  3041. var currentItem = items[currentIndex];
  3042. if (condition(currentItem)) {
  3043. maxIndex = currentIndex;
  3044. } else {
  3045. minIndex = currentIndex + 1;
  3046. }
  3047. }
  3048. return minIndex;
  3049. }
  3050. function approximateFraction(x) {
  3051. if (Math.floor(x) === x) {
  3052. return [x, 1];
  3053. }
  3054. var xinv = 1 / x;
  3055. var limit = 8;
  3056. if (xinv > limit) {
  3057. return [1, limit];
  3058. } else if (Math.floor(xinv) === xinv) {
  3059. return [1, xinv];
  3060. }
  3061. var x_ = x > 1 ? xinv : x;
  3062. var a = 0,
  3063. b = 1,
  3064. c = 1,
  3065. d = 1;
  3066. while (true) {
  3067. var p = a + c,
  3068. q = b + d;
  3069. if (q > limit) {
  3070. break;
  3071. }
  3072. if (x_ <= p / q) {
  3073. c = p;
  3074. d = q;
  3075. } else {
  3076. a = p;
  3077. b = q;
  3078. }
  3079. }
  3080. var result;
  3081. if (x_ - a / b < c / d - x_) {
  3082. result = x_ === x ? [a, b] : [b, a];
  3083. } else {
  3084. result = x_ === x ? [c, d] : [d, c];
  3085. }
  3086. return result;
  3087. }
  3088. function roundToDivide(x, div) {
  3089. var r = x % div;
  3090. return r === 0 ? x : Math.round(x - r + div);
  3091. }
  3092. function getPageSizeInches(_ref) {
  3093. var view = _ref.view,
  3094. userUnit = _ref.userUnit,
  3095. rotate = _ref.rotate;
  3096. var _view = _slicedToArray(view, 4),
  3097. x1 = _view[0],
  3098. y1 = _view[1],
  3099. x2 = _view[2],
  3100. y2 = _view[3];
  3101. var changeOrientation = rotate % 180 !== 0;
  3102. var width = (x2 - x1) / 72 * userUnit;
  3103. var height = (y2 - y1) / 72 * userUnit;
  3104. return {
  3105. width: changeOrientation ? height : width,
  3106. height: changeOrientation ? width : height
  3107. };
  3108. }
  3109. function backtrackBeforeAllVisibleElements(index, views, top) {
  3110. if (index < 2) {
  3111. return index;
  3112. }
  3113. var elt = views[index].div;
  3114. var pageTop = elt.offsetTop + elt.clientTop;
  3115. if (pageTop >= top) {
  3116. elt = views[index - 1].div;
  3117. pageTop = elt.offsetTop + elt.clientTop;
  3118. }
  3119. for (var i = index - 2; i >= 0; --i) {
  3120. elt = views[i].div;
  3121. if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
  3122. break;
  3123. }
  3124. index = i;
  3125. }
  3126. return index;
  3127. }
  3128. function getVisibleElements(scrollEl, views) {
  3129. var sortByVisibility = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  3130. var horizontal = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  3131. var top = scrollEl.scrollTop,
  3132. bottom = top + scrollEl.clientHeight;
  3133. var left = scrollEl.scrollLeft,
  3134. right = left + scrollEl.clientWidth;
  3135. function isElementBottomAfterViewTop(view) {
  3136. var element = view.div;
  3137. var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  3138. return elementBottom > top;
  3139. }
  3140. function isElementRightAfterViewLeft(view) {
  3141. var element = view.div;
  3142. var elementRight = element.offsetLeft + element.clientLeft + element.clientWidth;
  3143. return elementRight > left;
  3144. }
  3145. var visible = [],
  3146. numViews = views.length;
  3147. var firstVisibleElementInd = numViews === 0 ? 0 : binarySearchFirstItem(views, horizontal ? isElementRightAfterViewLeft : isElementBottomAfterViewTop);
  3148. if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
  3149. firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
  3150. }
  3151. var lastEdge = horizontal ? right : -1;
  3152. for (var i = firstVisibleElementInd; i < numViews; i++) {
  3153. var view = views[i],
  3154. element = view.div;
  3155. var currentWidth = element.offsetLeft + element.clientLeft;
  3156. var currentHeight = element.offsetTop + element.clientTop;
  3157. var viewWidth = element.clientWidth,
  3158. viewHeight = element.clientHeight;
  3159. var viewRight = currentWidth + viewWidth;
  3160. var viewBottom = currentHeight + viewHeight;
  3161. if (lastEdge === -1) {
  3162. if (viewBottom >= bottom) {
  3163. lastEdge = viewBottom;
  3164. }
  3165. } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
  3166. break;
  3167. }
  3168. if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) {
  3169. continue;
  3170. }
  3171. var hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
  3172. var hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
  3173. var percent = (viewHeight - hiddenHeight) * (viewWidth - hiddenWidth) * 100 / viewHeight / viewWidth | 0;
  3174. visible.push({
  3175. id: view.id,
  3176. x: currentWidth,
  3177. y: currentHeight,
  3178. view: view,
  3179. percent: percent
  3180. });
  3181. }
  3182. var first = visible[0],
  3183. last = visible[visible.length - 1];
  3184. if (sortByVisibility) {
  3185. visible.sort(function (a, b) {
  3186. var pc = a.percent - b.percent;
  3187. if (Math.abs(pc) > 0.001) {
  3188. return -pc;
  3189. }
  3190. return a.id - b.id;
  3191. });
  3192. }
  3193. return {
  3194. first: first,
  3195. last: last,
  3196. views: visible
  3197. };
  3198. }
  3199. function noContextMenuHandler(evt) {
  3200. evt.preventDefault();
  3201. }
  3202. function isDataSchema(url) {
  3203. var i = 0,
  3204. ii = url.length;
  3205. while (i < ii && url[i].trim() === '') {
  3206. i++;
  3207. }
  3208. return url.substring(i, i + 5).toLowerCase() === 'data:';
  3209. }
  3210. function getPDFFileNameFromURL(url) {
  3211. var defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'document.pdf';
  3212. if (typeof url !== 'string') {
  3213. return defaultFilename;
  3214. }
  3215. if (isDataSchema(url)) {
  3216. console.warn('getPDFFileNameFromURL: ' + 'ignoring "data:" URL for performance reasons.');
  3217. return defaultFilename;
  3218. }
  3219. var reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
  3220. var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
  3221. var splitURI = reURI.exec(url);
  3222. var suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
  3223. if (suggestedFilename) {
  3224. suggestedFilename = suggestedFilename[0];
  3225. if (suggestedFilename.includes('%')) {
  3226. try {
  3227. suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
  3228. } catch (ex) {}
  3229. }
  3230. }
  3231. return suggestedFilename || defaultFilename;
  3232. }
  3233. function normalizeWheelEventDelta(evt) {
  3234. var delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
  3235. var angle = Math.atan2(evt.deltaY, evt.deltaX);
  3236. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  3237. delta = -delta;
  3238. }
  3239. var MOUSE_DOM_DELTA_PIXEL_MODE = 0;
  3240. var MOUSE_DOM_DELTA_LINE_MODE = 1;
  3241. var MOUSE_PIXELS_PER_LINE = 30;
  3242. var MOUSE_LINES_PER_PAGE = 30;
  3243. if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
  3244. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  3245. } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
  3246. delta /= MOUSE_LINES_PER_PAGE;
  3247. }
  3248. return delta;
  3249. }
  3250. function isValidRotation(angle) {
  3251. return Number.isInteger(angle) && angle % 90 === 0;
  3252. }
  3253. function isValidScrollMode(mode) {
  3254. return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN;
  3255. }
  3256. function isValidSpreadMode(mode) {
  3257. return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN;
  3258. }
  3259. function isPortraitOrientation(size) {
  3260. return size.width <= size.height;
  3261. }
  3262. var WaitOnType = {
  3263. EVENT: 'event',
  3264. TIMEOUT: 'timeout'
  3265. };
  3266. exports.WaitOnType = WaitOnType;
  3267. function waitOnEventOrTimeout(_ref2) {
  3268. var target = _ref2.target,
  3269. name = _ref2.name,
  3270. _ref2$delay = _ref2.delay,
  3271. delay = _ref2$delay === void 0 ? 0 : _ref2$delay;
  3272. return new Promise(function (resolve, reject) {
  3273. if (_typeof(target) !== 'object' || !(name && typeof name === 'string') || !(Number.isInteger(delay) && delay >= 0)) {
  3274. throw new Error('waitOnEventOrTimeout - invalid parameters.');
  3275. }
  3276. function handler(type) {
  3277. if (target instanceof EventBus) {
  3278. target.off(name, eventHandler);
  3279. } else {
  3280. target.removeEventListener(name, eventHandler);
  3281. }
  3282. if (timeout) {
  3283. clearTimeout(timeout);
  3284. }
  3285. resolve(type);
  3286. }
  3287. var eventHandler = handler.bind(null, WaitOnType.EVENT);
  3288. if (target instanceof EventBus) {
  3289. target.on(name, eventHandler);
  3290. } else {
  3291. target.addEventListener(name, eventHandler);
  3292. }
  3293. var timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
  3294. var timeout = setTimeout(timeoutHandler, delay);
  3295. });
  3296. }
  3297. var animationStarted = new Promise(function (resolve) {
  3298. window.requestAnimationFrame(resolve);
  3299. });
  3300. exports.animationStarted = animationStarted;
  3301. var EventBus =
  3302. /*#__PURE__*/
  3303. function () {
  3304. function EventBus() {
  3305. var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  3306. _ref3$dispatchToDOM = _ref3.dispatchToDOM,
  3307. dispatchToDOM = _ref3$dispatchToDOM === void 0 ? false : _ref3$dispatchToDOM;
  3308. _classCallCheck(this, EventBus);
  3309. this._listeners = Object.create(null);
  3310. this._dispatchToDOM = dispatchToDOM === true;
  3311. }
  3312. _createClass(EventBus, [{
  3313. key: "on",
  3314. value: function on(eventName, listener) {
  3315. var eventListeners = this._listeners[eventName];
  3316. if (!eventListeners) {
  3317. eventListeners = [];
  3318. this._listeners[eventName] = eventListeners;
  3319. }
  3320. eventListeners.push(listener);
  3321. }
  3322. }, {
  3323. key: "off",
  3324. value: function off(eventName, listener) {
  3325. var eventListeners = this._listeners[eventName];
  3326. var i;
  3327. if (!eventListeners || (i = eventListeners.indexOf(listener)) < 0) {
  3328. return;
  3329. }
  3330. eventListeners.splice(i, 1);
  3331. }
  3332. }, {
  3333. key: "dispatch",
  3334. value: function dispatch(eventName) {
  3335. var eventListeners = this._listeners[eventName];
  3336. if (!eventListeners || eventListeners.length === 0) {
  3337. if (this._dispatchToDOM) {
  3338. var _args5 = Array.prototype.slice.call(arguments, 1);
  3339. this._dispatchDOMEvent(eventName, _args5);
  3340. }
  3341. return;
  3342. }
  3343. var args = Array.prototype.slice.call(arguments, 1);
  3344. eventListeners.slice(0).forEach(function (listener) {
  3345. listener.apply(null, args);
  3346. });
  3347. if (this._dispatchToDOM) {
  3348. this._dispatchDOMEvent(eventName, args);
  3349. }
  3350. }
  3351. }, {
  3352. key: "_dispatchDOMEvent",
  3353. value: function _dispatchDOMEvent(eventName) {
  3354. var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  3355. var details = Object.create(null);
  3356. if (args && args.length > 0) {
  3357. var obj = args[0];
  3358. for (var key in obj) {
  3359. var value = obj[key];
  3360. if (key === 'source') {
  3361. if (value === window || value === document) {
  3362. return;
  3363. }
  3364. continue;
  3365. }
  3366. details[key] = value;
  3367. }
  3368. }
  3369. var event = document.createEvent('CustomEvent');
  3370. event.initCustomEvent(eventName, true, true, details);
  3371. document.dispatchEvent(event);
  3372. }
  3373. }]);
  3374. return EventBus;
  3375. }();
  3376. exports.EventBus = EventBus;
  3377. var globalEventBus = null;
  3378. function getGlobalEventBus() {
  3379. var dispatchToDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  3380. if (!globalEventBus) {
  3381. globalEventBus = new EventBus({
  3382. dispatchToDOM: dispatchToDOM
  3383. });
  3384. }
  3385. return globalEventBus;
  3386. }
  3387. function clamp(v, min, max) {
  3388. return Math.min(Math.max(v, min), max);
  3389. }
  3390. var ProgressBar =
  3391. /*#__PURE__*/
  3392. function () {
  3393. function ProgressBar(id) {
  3394. var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  3395. height = _ref4.height,
  3396. width = _ref4.width,
  3397. units = _ref4.units;
  3398. _classCallCheck(this, ProgressBar);
  3399. this.visible = true;
  3400. this.div = document.querySelector(id + ' .progress');
  3401. this.bar = this.div.parentNode;
  3402. this.height = height || 100;
  3403. this.width = width || 100;
  3404. this.units = units || '%';
  3405. this.div.style.height = this.height + this.units;
  3406. this.percent = 0;
  3407. }
  3408. _createClass(ProgressBar, [{
  3409. key: "_updateBar",
  3410. value: function _updateBar() {
  3411. if (this._indeterminate) {
  3412. this.div.classList.add('indeterminate');
  3413. this.div.style.width = this.width + this.units;
  3414. return;
  3415. }
  3416. this.div.classList.remove('indeterminate');
  3417. var progressSize = this.width * this._percent / 100;
  3418. this.div.style.width = progressSize + this.units;
  3419. }
  3420. }, {
  3421. key: "setWidth",
  3422. value: function setWidth(viewer) {
  3423. if (!viewer) {
  3424. return;
  3425. }
  3426. var container = viewer.parentNode;
  3427. var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  3428. if (scrollbarWidth > 0) {
  3429. this.bar.setAttribute('style', 'width: calc(100% - ' + scrollbarWidth + 'px);');
  3430. }
  3431. }
  3432. }, {
  3433. key: "hide",
  3434. value: function hide() {
  3435. if (!this.visible) {
  3436. return;
  3437. }
  3438. this.visible = false;
  3439. this.bar.classList.add('hidden');
  3440. document.body.classList.remove('loadingInProgress');
  3441. }
  3442. }, {
  3443. key: "show",
  3444. value: function show() {
  3445. if (this.visible) {
  3446. return;
  3447. }
  3448. this.visible = true;
  3449. document.body.classList.add('loadingInProgress');
  3450. this.bar.classList.remove('hidden');
  3451. }
  3452. }, {
  3453. key: "percent",
  3454. get: function get() {
  3455. return this._percent;
  3456. },
  3457. set: function set(val) {
  3458. this._indeterminate = isNaN(val);
  3459. this._percent = clamp(val, 0, 100);
  3460. this._updateBar();
  3461. }
  3462. }]);
  3463. return ProgressBar;
  3464. }();
  3465. exports.ProgressBar = ProgressBar;
  3466. function moveToEndOfArray(arr, condition) {
  3467. var moved = [],
  3468. len = arr.length;
  3469. var write = 0;
  3470. for (var read = 0; read < len; ++read) {
  3471. if (condition(arr[read])) {
  3472. moved.push(arr[read]);
  3473. } else {
  3474. arr[write] = arr[read];
  3475. ++write;
  3476. }
  3477. }
  3478. for (var _read = 0; write < len; ++_read, ++write) {
  3479. arr[write] = moved[_read];
  3480. }
  3481. }
  3482. /***/ }),
  3483. /* 7 */
  3484. /***/ (function(module, exports, __webpack_require__) {
  3485. "use strict";
  3486. var pdfjsLib;
  3487. if (typeof window !== 'undefined' && window['pdfjs-dist/build/pdf']) {
  3488. pdfjsLib = window['pdfjs-dist/build/pdf'];
  3489. } else {
  3490. pdfjsLib = require('../o2_lib/pdfjs/build/pdf.js');
  3491. }
  3492. module.exports = pdfjsLib;
  3493. /***/ }),
  3494. /* 8 */
  3495. /***/ (function(module, exports, __webpack_require__) {
  3496. "use strict";
  3497. Object.defineProperty(exports, "__esModule", {
  3498. value: true
  3499. });
  3500. exports.PDFCursorTools = exports.CursorTool = void 0;
  3501. var _grab_to_pan = __webpack_require__(9);
  3502. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3503. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  3504. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3505. var CursorTool = {
  3506. SELECT: 0,
  3507. HAND: 1,
  3508. ZOOM: 2
  3509. };
  3510. exports.CursorTool = CursorTool;
  3511. var PDFCursorTools =
  3512. /*#__PURE__*/
  3513. function () {
  3514. function PDFCursorTools(_ref) {
  3515. var _this = this;
  3516. var container = _ref.container,
  3517. eventBus = _ref.eventBus,
  3518. _ref$cursorToolOnLoad = _ref.cursorToolOnLoad,
  3519. cursorToolOnLoad = _ref$cursorToolOnLoad === void 0 ? CursorTool.SELECT : _ref$cursorToolOnLoad;
  3520. _classCallCheck(this, PDFCursorTools);
  3521. this.container = container;
  3522. this.eventBus = eventBus;
  3523. this.active = CursorTool.SELECT;
  3524. this.activeBeforePresentationMode = null;
  3525. this.handTool = new _grab_to_pan.GrabToPan({
  3526. element: this.container
  3527. });
  3528. this._addEventListeners();
  3529. Promise.resolve().then(function () {
  3530. _this.switchTool(cursorToolOnLoad);
  3531. });
  3532. }
  3533. _createClass(PDFCursorTools, [{
  3534. key: "switchTool",
  3535. value: function switchTool(tool) {
  3536. var _this2 = this;
  3537. if (this.activeBeforePresentationMode !== null) {
  3538. return;
  3539. }
  3540. if (tool === this.active) {
  3541. return;
  3542. }
  3543. var disableActiveTool = function disableActiveTool() {
  3544. switch (_this2.active) {
  3545. case CursorTool.SELECT:
  3546. break;
  3547. case CursorTool.HAND:
  3548. _this2.handTool.deactivate();
  3549. break;
  3550. case CursorTool.ZOOM:
  3551. }
  3552. };
  3553. switch (tool) {
  3554. case CursorTool.SELECT:
  3555. disableActiveTool();
  3556. break;
  3557. case CursorTool.HAND:
  3558. disableActiveTool();
  3559. this.handTool.activate();
  3560. break;
  3561. case CursorTool.ZOOM:
  3562. default:
  3563. console.error("switchTool: \"".concat(tool, "\" is an unsupported value."));
  3564. return;
  3565. }
  3566. this.active = tool;
  3567. this._dispatchEvent();
  3568. }
  3569. }, {
  3570. key: "_dispatchEvent",
  3571. value: function _dispatchEvent() {
  3572. this.eventBus.dispatch('cursortoolchanged', {
  3573. source: this,
  3574. tool: this.active
  3575. });
  3576. }
  3577. }, {
  3578. key: "_addEventListeners",
  3579. value: function _addEventListeners() {
  3580. var _this3 = this;
  3581. this.eventBus.on('switchcursortool', function (evt) {
  3582. _this3.switchTool(evt.tool);
  3583. });
  3584. this.eventBus.on('presentationmodechanged', function (evt) {
  3585. if (evt.switchInProgress) {
  3586. return;
  3587. }
  3588. var previouslyActive;
  3589. if (evt.active) {
  3590. previouslyActive = _this3.active;
  3591. _this3.switchTool(CursorTool.SELECT);
  3592. _this3.activeBeforePresentationMode = previouslyActive;
  3593. } else {
  3594. previouslyActive = _this3.activeBeforePresentationMode;
  3595. _this3.activeBeforePresentationMode = null;
  3596. _this3.switchTool(previouslyActive);
  3597. }
  3598. });
  3599. }
  3600. }, {
  3601. key: "activeTool",
  3602. get: function get() {
  3603. return this.active;
  3604. }
  3605. }]);
  3606. return PDFCursorTools;
  3607. }();
  3608. exports.PDFCursorTools = PDFCursorTools;
  3609. /***/ }),
  3610. /* 9 */
  3611. /***/ (function(module, exports, __webpack_require__) {
  3612. "use strict";
  3613. Object.defineProperty(exports, "__esModule", {
  3614. value: true
  3615. });
  3616. exports.GrabToPan = GrabToPan;
  3617. function GrabToPan(options) {
  3618. this.element = options.element;
  3619. this.document = options.element.ownerDocument;
  3620. if (typeof options.ignoreTarget === 'function') {
  3621. this.ignoreTarget = options.ignoreTarget;
  3622. }
  3623. this.onActiveChanged = options.onActiveChanged;
  3624. this.activate = this.activate.bind(this);
  3625. this.deactivate = this.deactivate.bind(this);
  3626. this.toggle = this.toggle.bind(this);
  3627. this._onmousedown = this._onmousedown.bind(this);
  3628. this._onmousemove = this._onmousemove.bind(this);
  3629. this._endPan = this._endPan.bind(this);
  3630. var overlay = this.overlay = document.createElement('div');
  3631. overlay.className = 'grab-to-pan-grabbing';
  3632. }
  3633. GrabToPan.prototype = {
  3634. CSS_CLASS_GRAB: 'grab-to-pan-grab',
  3635. activate: function GrabToPan_activate() {
  3636. if (!this.active) {
  3637. this.active = true;
  3638. this.element.addEventListener('mousedown', this._onmousedown, true);
  3639. this.element.classList.add(this.CSS_CLASS_GRAB);
  3640. if (this.onActiveChanged) {
  3641. this.onActiveChanged(true);
  3642. }
  3643. }
  3644. },
  3645. deactivate: function GrabToPan_deactivate() {
  3646. if (this.active) {
  3647. this.active = false;
  3648. this.element.removeEventListener('mousedown', this._onmousedown, true);
  3649. this._endPan();
  3650. this.element.classList.remove(this.CSS_CLASS_GRAB);
  3651. if (this.onActiveChanged) {
  3652. this.onActiveChanged(false);
  3653. }
  3654. }
  3655. },
  3656. toggle: function GrabToPan_toggle() {
  3657. if (this.active) {
  3658. this.deactivate();
  3659. } else {
  3660. this.activate();
  3661. }
  3662. },
  3663. ignoreTarget: function GrabToPan_ignoreTarget(node) {
  3664. return node[matchesSelector]('a[href], a[href] *, input, textarea, button, button *, select, option');
  3665. },
  3666. _onmousedown: function GrabToPan__onmousedown(event) {
  3667. if (event.button !== 0 || this.ignoreTarget(event.target)) {
  3668. return;
  3669. }
  3670. if (event.originalTarget) {
  3671. try {
  3672. event.originalTarget.tagName;
  3673. } catch (e) {
  3674. return;
  3675. }
  3676. }
  3677. this.scrollLeftStart = this.element.scrollLeft;
  3678. this.scrollTopStart = this.element.scrollTop;
  3679. this.clientXStart = event.clientX;
  3680. this.clientYStart = event.clientY;
  3681. this.document.addEventListener('mousemove', this._onmousemove, true);
  3682. this.document.addEventListener('mouseup', this._endPan, true);
  3683. this.element.addEventListener('scroll', this._endPan, true);
  3684. event.preventDefault();
  3685. event.stopPropagation();
  3686. var focusedElement = document.activeElement;
  3687. if (focusedElement && !focusedElement.contains(event.target)) {
  3688. focusedElement.blur();
  3689. }
  3690. },
  3691. _onmousemove: function GrabToPan__onmousemove(event) {
  3692. this.element.removeEventListener('scroll', this._endPan, true);
  3693. if (isLeftMouseReleased(event)) {
  3694. this._endPan();
  3695. return;
  3696. }
  3697. var xDiff = event.clientX - this.clientXStart;
  3698. var yDiff = event.clientY - this.clientYStart;
  3699. var scrollTop = this.scrollTopStart - yDiff;
  3700. var scrollLeft = this.scrollLeftStart - xDiff;
  3701. if (this.element.scrollTo) {
  3702. this.element.scrollTo({
  3703. top: scrollTop,
  3704. left: scrollLeft,
  3705. behavior: 'instant'
  3706. });
  3707. } else {
  3708. this.element.scrollTop = scrollTop;
  3709. this.element.scrollLeft = scrollLeft;
  3710. }
  3711. if (!this.overlay.parentNode) {
  3712. document.body.appendChild(this.overlay);
  3713. }
  3714. },
  3715. _endPan: function GrabToPan__endPan() {
  3716. this.element.removeEventListener('scroll', this._endPan, true);
  3717. this.document.removeEventListener('mousemove', this._onmousemove, true);
  3718. this.document.removeEventListener('mouseup', this._endPan, true);
  3719. this.overlay.remove();
  3720. }
  3721. };
  3722. var matchesSelector;
  3723. ['webkitM', 'mozM', 'msM', 'oM', 'm'].some(function (prefix) {
  3724. var name = prefix + 'atches';
  3725. if (name in document.documentElement) {
  3726. matchesSelector = name;
  3727. }
  3728. name += 'Selector';
  3729. if (name in document.documentElement) {
  3730. matchesSelector = name;
  3731. }
  3732. return matchesSelector;
  3733. });
  3734. var isNotIEorIsIE10plus = !document.documentMode || document.documentMode > 9;
  3735. var chrome = window.chrome;
  3736. var isChrome15OrOpera15plus = chrome && (chrome.webstore || chrome.app);
  3737. var isSafari6plus = /Apple/.test(navigator.vendor) && /Version\/([6-9]\d*|[1-5]\d+)/.test(navigator.userAgent);
  3738. function isLeftMouseReleased(event) {
  3739. if ('buttons' in event && isNotIEorIsIE10plus) {
  3740. return !(event.buttons & 1);
  3741. }
  3742. if (isChrome15OrOpera15plus || isSafari6plus) {
  3743. return event.which === 0;
  3744. }
  3745. }
  3746. /***/ }),
  3747. /* 10 */
  3748. /***/ (function(module, exports, __webpack_require__) {
  3749. "use strict";
  3750. Object.defineProperty(exports, "__esModule", {
  3751. value: true
  3752. });
  3753. exports.PDFRenderingQueue = exports.RenderingStates = void 0;
  3754. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3755. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  3756. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3757. var CLEANUP_TIMEOUT = 30000;
  3758. var RenderingStates = {
  3759. INITIAL: 0,
  3760. RUNNING: 1,
  3761. PAUSED: 2,
  3762. FINISHED: 3
  3763. };
  3764. exports.RenderingStates = RenderingStates;
  3765. var PDFRenderingQueue =
  3766. /*#__PURE__*/
  3767. function () {
  3768. function PDFRenderingQueue() {
  3769. _classCallCheck(this, PDFRenderingQueue);
  3770. this.pdfViewer = null;
  3771. this.pdfThumbnailViewer = null;
  3772. this.onIdle = null;
  3773. this.highestPriorityPage = null;
  3774. this.idleTimeout = null;
  3775. this.printing = false;
  3776. this.isThumbnailViewEnabled = false;
  3777. }
  3778. _createClass(PDFRenderingQueue, [{
  3779. key: "setViewer",
  3780. value: function setViewer(pdfViewer) {
  3781. this.pdfViewer = pdfViewer;
  3782. }
  3783. }, {
  3784. key: "setThumbnailViewer",
  3785. value: function setThumbnailViewer(pdfThumbnailViewer) {
  3786. this.pdfThumbnailViewer = pdfThumbnailViewer;
  3787. }
  3788. }, {
  3789. key: "isHighestPriority",
  3790. value: function isHighestPriority(view) {
  3791. return this.highestPriorityPage === view.renderingId;
  3792. }
  3793. }, {
  3794. key: "renderHighestPriority",
  3795. value: function renderHighestPriority(currentlyVisiblePages) {
  3796. if (this.idleTimeout) {
  3797. clearTimeout(this.idleTimeout);
  3798. this.idleTimeout = null;
  3799. }
  3800. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  3801. return;
  3802. }
  3803. if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
  3804. if (this.pdfThumbnailViewer.forceRendering()) {
  3805. return;
  3806. }
  3807. }
  3808. if (this.printing) {
  3809. return;
  3810. }
  3811. if (this.onIdle) {
  3812. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
  3813. }
  3814. }
  3815. }, {
  3816. key: "getHighestPriority",
  3817. value: function getHighestPriority(visible, views, scrolledDown) {
  3818. var visibleViews = visible.views;
  3819. var numVisible = visibleViews.length;
  3820. if (numVisible === 0) {
  3821. return false;
  3822. }
  3823. for (var i = 0; i < numVisible; ++i) {
  3824. var view = visibleViews[i].view;
  3825. if (!this.isViewFinished(view)) {
  3826. return view;
  3827. }
  3828. }
  3829. if (scrolledDown) {
  3830. var nextPageIndex = visible.last.id;
  3831. if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {
  3832. return views[nextPageIndex];
  3833. }
  3834. } else {
  3835. var previousPageIndex = visible.first.id - 2;
  3836. if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) {
  3837. return views[previousPageIndex];
  3838. }
  3839. }
  3840. return null;
  3841. }
  3842. }, {
  3843. key: "isViewFinished",
  3844. value: function isViewFinished(view) {
  3845. return view.renderingState === RenderingStates.FINISHED;
  3846. }
  3847. }, {
  3848. key: "renderView",
  3849. value: function renderView(view) {
  3850. var _this = this;
  3851. switch (view.renderingState) {
  3852. case RenderingStates.FINISHED:
  3853. return false;
  3854. case RenderingStates.PAUSED:
  3855. this.highestPriorityPage = view.renderingId;
  3856. view.resume();
  3857. break;
  3858. case RenderingStates.RUNNING:
  3859. this.highestPriorityPage = view.renderingId;
  3860. break;
  3861. case RenderingStates.INITIAL:
  3862. this.highestPriorityPage = view.renderingId;
  3863. var continueRendering = function continueRendering() {
  3864. _this.renderHighestPriority();
  3865. };
  3866. view.draw().then(continueRendering, continueRendering);
  3867. break;
  3868. }
  3869. return true;
  3870. }
  3871. }]);
  3872. return PDFRenderingQueue;
  3873. }();
  3874. exports.PDFRenderingQueue = PDFRenderingQueue;
  3875. /***/ }),
  3876. /* 11 */
  3877. /***/ (function(module, exports, __webpack_require__) {
  3878. "use strict";
  3879. Object.defineProperty(exports, "__esModule", {
  3880. value: true
  3881. });
  3882. exports.PDFSidebar = exports.SidebarView = void 0;
  3883. var _ui_utils = __webpack_require__(6);
  3884. var _pdf_rendering_queue = __webpack_require__(10);
  3885. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3886. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  3887. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3888. var UI_NOTIFICATION_CLASS = 'pdfSidebarNotification';
  3889. var SidebarView = {
  3890. UNKNOWN: -1,
  3891. NONE: 0,
  3892. THUMBS: 1,
  3893. OUTLINE: 2,
  3894. ATTACHMENTS: 3,
  3895. LAYERS: 4
  3896. };
  3897. exports.SidebarView = SidebarView;
  3898. var PDFSidebar =
  3899. /*#__PURE__*/
  3900. function () {
  3901. function PDFSidebar(options, eventBus) {
  3902. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  3903. _classCallCheck(this, PDFSidebar);
  3904. this.isOpen = false;
  3905. this.active = SidebarView.THUMBS;
  3906. this.isInitialViewSet = false;
  3907. this.onToggled = null;
  3908. this.pdfViewer = options.pdfViewer;
  3909. this.pdfThumbnailViewer = options.pdfThumbnailViewer;
  3910. this.outerContainer = options.outerContainer;
  3911. this.viewerContainer = options.viewerContainer;
  3912. this.toggleButton = options.toggleButton;
  3913. this.thumbnailButton = options.thumbnailButton;
  3914. this.outlineButton = options.outlineButton;
  3915. this.attachmentsButton = options.attachmentsButton;
  3916. this.thumbnailView = options.thumbnailView;
  3917. this.outlineView = options.outlineView;
  3918. this.attachmentsView = options.attachmentsView;
  3919. this.disableNotification = options.disableNotification || false;
  3920. this.eventBus = eventBus;
  3921. this.l10n = l10n;
  3922. this._addEventListeners();
  3923. }
  3924. _createClass(PDFSidebar, [{
  3925. key: "reset",
  3926. value: function reset() {
  3927. this.isInitialViewSet = false;
  3928. this._hideUINotification(null);
  3929. this.switchView(SidebarView.THUMBS);
  3930. this.outlineButton.disabled = false;
  3931. this.attachmentsButton.disabled = false;
  3932. }
  3933. }, {
  3934. key: "setInitialView",
  3935. value: function setInitialView() {
  3936. var view = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : SidebarView.NONE;
  3937. if (this.isInitialViewSet) {
  3938. return;
  3939. }
  3940. this.isInitialViewSet = true;
  3941. if (view === SidebarView.NONE || view === SidebarView.UNKNOWN) {
  3942. this._dispatchEvent();
  3943. return;
  3944. }
  3945. if (!this._switchView(view, true)) {
  3946. this._dispatchEvent();
  3947. }
  3948. }
  3949. }, {
  3950. key: "switchView",
  3951. value: function switchView(view) {
  3952. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  3953. this._switchView(view, forceOpen);
  3954. }
  3955. }, {
  3956. key: "_switchView",
  3957. value: function _switchView(view) {
  3958. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  3959. var isViewChanged = view !== this.active;
  3960. var shouldForceRendering = false;
  3961. switch (view) {
  3962. case SidebarView.NONE:
  3963. if (this.isOpen) {
  3964. this.close();
  3965. return true;
  3966. }
  3967. return false;
  3968. case SidebarView.THUMBS:
  3969. if (this.isOpen && isViewChanged) {
  3970. shouldForceRendering = true;
  3971. }
  3972. break;
  3973. case SidebarView.OUTLINE:
  3974. if (this.outlineButton.disabled) {
  3975. return false;
  3976. }
  3977. break;
  3978. case SidebarView.ATTACHMENTS:
  3979. if (this.attachmentsButton.disabled) {
  3980. return false;
  3981. }
  3982. break;
  3983. default:
  3984. console.error("PDFSidebar._switchView: \"".concat(view, "\" is not a valid view."));
  3985. return false;
  3986. }
  3987. this.active = view;
  3988. this.thumbnailButton.classList.toggle('toggled', view === SidebarView.THUMBS);
  3989. this.outlineButton.classList.toggle('toggled', view === SidebarView.OUTLINE);
  3990. this.attachmentsButton.classList.toggle('toggled', view === SidebarView.ATTACHMENTS);
  3991. this.thumbnailView.classList.toggle('hidden', view !== SidebarView.THUMBS);
  3992. this.outlineView.classList.toggle('hidden', view !== SidebarView.OUTLINE);
  3993. this.attachmentsView.classList.toggle('hidden', view !== SidebarView.ATTACHMENTS);
  3994. if (forceOpen && !this.isOpen) {
  3995. this.open();
  3996. return true;
  3997. }
  3998. if (shouldForceRendering) {
  3999. this._updateThumbnailViewer();
  4000. this._forceRendering();
  4001. }
  4002. if (isViewChanged) {
  4003. this._dispatchEvent();
  4004. }
  4005. this._hideUINotification(this.active);
  4006. return isViewChanged;
  4007. }
  4008. }, {
  4009. key: "open",
  4010. value: function open() {
  4011. if (this.isOpen) {
  4012. return;
  4013. }
  4014. this.isOpen = true;
  4015. this.toggleButton.classList.add('toggled');
  4016. this.outerContainer.classList.add('sidebarMoving', 'sidebarOpen');
  4017. if (this.active === SidebarView.THUMBS) {
  4018. this._updateThumbnailViewer();
  4019. }
  4020. this._forceRendering();
  4021. this._dispatchEvent();
  4022. this._hideUINotification(this.active);
  4023. }
  4024. }, {
  4025. key: "close",
  4026. value: function close() {
  4027. if (!this.isOpen) {
  4028. return;
  4029. }
  4030. this.isOpen = false;
  4031. this.toggleButton.classList.remove('toggled');
  4032. this.outerContainer.classList.add('sidebarMoving');
  4033. this.outerContainer.classList.remove('sidebarOpen');
  4034. this._forceRendering();
  4035. this._dispatchEvent();
  4036. }
  4037. }, {
  4038. key: "toggle",
  4039. value: function toggle() {
  4040. if (this.isOpen) {
  4041. this.close();
  4042. } else {
  4043. this.open();
  4044. }
  4045. }
  4046. }, {
  4047. key: "_dispatchEvent",
  4048. value: function _dispatchEvent() {
  4049. this.eventBus.dispatch('sidebarviewchanged', {
  4050. source: this,
  4051. view: this.visibleView
  4052. });
  4053. }
  4054. }, {
  4055. key: "_forceRendering",
  4056. value: function _forceRendering() {
  4057. if (this.onToggled) {
  4058. this.onToggled();
  4059. } else {
  4060. this.pdfViewer.forceRendering();
  4061. this.pdfThumbnailViewer.forceRendering();
  4062. }
  4063. }
  4064. }, {
  4065. key: "_updateThumbnailViewer",
  4066. value: function _updateThumbnailViewer() {
  4067. var pdfViewer = this.pdfViewer,
  4068. pdfThumbnailViewer = this.pdfThumbnailViewer;
  4069. var pagesCount = pdfViewer.pagesCount;
  4070. for (var pageIndex = 0; pageIndex < pagesCount; pageIndex++) {
  4071. var pageView = pdfViewer.getPageView(pageIndex);
  4072. if (pageView && pageView.renderingState === _pdf_rendering_queue.RenderingStates.FINISHED) {
  4073. var thumbnailView = pdfThumbnailViewer.getThumbnail(pageIndex);
  4074. thumbnailView.setImage(pageView);
  4075. }
  4076. }
  4077. pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
  4078. }
  4079. }, {
  4080. key: "_showUINotification",
  4081. value: function _showUINotification(view) {
  4082. var _this = this;
  4083. if (this.disableNotification) {
  4084. return;
  4085. }
  4086. this.l10n.get('toggle_sidebar_notification.title', null, 'Toggle Sidebar (document contains outline/attachments)').then(function (msg) {
  4087. _this.toggleButton.title = msg;
  4088. });
  4089. if (!this.isOpen) {
  4090. this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
  4091. } else if (view === this.active) {
  4092. return;
  4093. }
  4094. switch (view) {
  4095. case SidebarView.OUTLINE:
  4096. this.outlineButton.classList.add(UI_NOTIFICATION_CLASS);
  4097. break;
  4098. case SidebarView.ATTACHMENTS:
  4099. this.attachmentsButton.classList.add(UI_NOTIFICATION_CLASS);
  4100. break;
  4101. }
  4102. }
  4103. }, {
  4104. key: "_hideUINotification",
  4105. value: function _hideUINotification(view) {
  4106. var _this2 = this;
  4107. if (this.disableNotification) {
  4108. return;
  4109. }
  4110. var removeNotification = function removeNotification(view) {
  4111. switch (view) {
  4112. case SidebarView.OUTLINE:
  4113. _this2.outlineButton.classList.remove(UI_NOTIFICATION_CLASS);
  4114. break;
  4115. case SidebarView.ATTACHMENTS:
  4116. _this2.attachmentsButton.classList.remove(UI_NOTIFICATION_CLASS);
  4117. break;
  4118. }
  4119. };
  4120. if (!this.isOpen && view !== null) {
  4121. return;
  4122. }
  4123. this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
  4124. if (view !== null) {
  4125. removeNotification(view);
  4126. return;
  4127. }
  4128. for (view in SidebarView) {
  4129. removeNotification(SidebarView[view]);
  4130. }
  4131. this.l10n.get('toggle_sidebar.title', null, 'Toggle Sidebar').then(function (msg) {
  4132. _this2.toggleButton.title = msg;
  4133. });
  4134. }
  4135. }, {
  4136. key: "_addEventListeners",
  4137. value: function _addEventListeners() {
  4138. var _this3 = this;
  4139. this.viewerContainer.addEventListener('transitionend', function (evt) {
  4140. if (evt.target === _this3.viewerContainer) {
  4141. _this3.outerContainer.classList.remove('sidebarMoving');
  4142. }
  4143. });
  4144. this.thumbnailButton.addEventListener('click', function () {
  4145. _this3.switchView(SidebarView.THUMBS);
  4146. });
  4147. this.outlineButton.addEventListener('click', function () {
  4148. _this3.switchView(SidebarView.OUTLINE);
  4149. });
  4150. this.outlineButton.addEventListener('dblclick', function () {
  4151. _this3.eventBus.dispatch('toggleoutlinetree', {
  4152. source: _this3
  4153. });
  4154. });
  4155. this.attachmentsButton.addEventListener('click', function () {
  4156. _this3.switchView(SidebarView.ATTACHMENTS);
  4157. });
  4158. this.eventBus.on('outlineloaded', function (evt) {
  4159. var outlineCount = evt.outlineCount;
  4160. _this3.outlineButton.disabled = !outlineCount;
  4161. if (outlineCount) {
  4162. _this3._showUINotification(SidebarView.OUTLINE);
  4163. } else if (_this3.active === SidebarView.OUTLINE) {
  4164. _this3.switchView(SidebarView.THUMBS);
  4165. }
  4166. });
  4167. this.eventBus.on('attachmentsloaded', function (evt) {
  4168. if (evt.attachmentsCount) {
  4169. _this3.attachmentsButton.disabled = false;
  4170. _this3._showUINotification(SidebarView.ATTACHMENTS);
  4171. return;
  4172. }
  4173. Promise.resolve().then(function () {
  4174. if (_this3.attachmentsView.hasChildNodes()) {
  4175. return;
  4176. }
  4177. _this3.attachmentsButton.disabled = true;
  4178. if (_this3.active === SidebarView.ATTACHMENTS) {
  4179. _this3.switchView(SidebarView.THUMBS);
  4180. }
  4181. });
  4182. });
  4183. this.eventBus.on('presentationmodechanged', function (evt) {
  4184. if (!evt.active && !evt.switchInProgress && _this3.isThumbnailViewVisible) {
  4185. _this3._updateThumbnailViewer();
  4186. }
  4187. });
  4188. }
  4189. }, {
  4190. key: "visibleView",
  4191. get: function get() {
  4192. return this.isOpen ? this.active : SidebarView.NONE;
  4193. }
  4194. }, {
  4195. key: "isThumbnailViewVisible",
  4196. get: function get() {
  4197. return this.isOpen && this.active === SidebarView.THUMBS;
  4198. }
  4199. }, {
  4200. key: "isOutlineViewVisible",
  4201. get: function get() {
  4202. return this.isOpen && this.active === SidebarView.OUTLINE;
  4203. }
  4204. }, {
  4205. key: "isAttachmentsViewVisible",
  4206. get: function get() {
  4207. return this.isOpen && this.active === SidebarView.ATTACHMENTS;
  4208. }
  4209. }]);
  4210. return PDFSidebar;
  4211. }();
  4212. exports.PDFSidebar = PDFSidebar;
  4213. /***/ }),
  4214. /* 12 */
  4215. /***/ (function(module, exports, __webpack_require__) {
  4216. "use strict";
  4217. Object.defineProperty(exports, "__esModule", {
  4218. value: true
  4219. });
  4220. exports.OptionKind = exports.AppOptions = void 0;
  4221. var _pdfjsLib = __webpack_require__(7);
  4222. var _viewer_compatibility = __webpack_require__(13);
  4223. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4224. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  4225. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4226. var OptionKind = {
  4227. VIEWER: 'viewer',
  4228. API: 'api',
  4229. WORKER: 'worker'
  4230. };
  4231. exports.OptionKind = OptionKind;
  4232. var defaultOptions = {
  4233. cursorToolOnLoad: {
  4234. value: 0,
  4235. kind: OptionKind.VIEWER
  4236. },
  4237. defaultUrl: {
  4238. value: 'compressed.tracemonkey-pldi-09.pdf',
  4239. kind: OptionKind.VIEWER
  4240. },
  4241. defaultZoomValue: {
  4242. value: '',
  4243. kind: OptionKind.VIEWER
  4244. },
  4245. disableHistory: {
  4246. value: false,
  4247. kind: OptionKind.VIEWER
  4248. },
  4249. disablePageLabels: {
  4250. value: false,
  4251. kind: OptionKind.VIEWER
  4252. },
  4253. enablePrintAutoRotate: {
  4254. value: false,
  4255. kind: OptionKind.VIEWER
  4256. },
  4257. enableWebGL: {
  4258. value: false,
  4259. kind: OptionKind.VIEWER
  4260. },
  4261. eventBusDispatchToDOM: {
  4262. value: false,
  4263. kind: OptionKind.VIEWER
  4264. },
  4265. externalLinkRel: {
  4266. value: 'noopener noreferrer nofollow',
  4267. kind: OptionKind.VIEWER
  4268. },
  4269. externalLinkTarget: {
  4270. value: 0,
  4271. kind: OptionKind.VIEWER
  4272. },
  4273. historyUpdateUrl: {
  4274. value: false,
  4275. kind: OptionKind.VIEWER
  4276. },
  4277. imageResourcesPath: {
  4278. value: '../o2_lib/pdfjs/web/images/',
  4279. kind: OptionKind.VIEWER
  4280. },
  4281. maxCanvasPixels: {
  4282. value: 16777216,
  4283. compatibility: _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels,
  4284. kind: OptionKind.VIEWER
  4285. },
  4286. pdfBugEnabled: {
  4287. value: false,
  4288. kind: OptionKind.VIEWER
  4289. },
  4290. renderer: {
  4291. value: 'canvas',
  4292. kind: OptionKind.VIEWER
  4293. },
  4294. renderInteractiveForms: {
  4295. value: false,
  4296. kind: OptionKind.VIEWER
  4297. },
  4298. sidebarViewOnLoad: {
  4299. value: -1,
  4300. kind: OptionKind.VIEWER
  4301. },
  4302. scrollModeOnLoad: {
  4303. value: -1,
  4304. kind: OptionKind.VIEWER
  4305. },
  4306. spreadModeOnLoad: {
  4307. value: -1,
  4308. kind: OptionKind.VIEWER
  4309. },
  4310. textLayerMode: {
  4311. value: 1,
  4312. kind: OptionKind.VIEWER
  4313. },
  4314. useOnlyCssZoom: {
  4315. value: false,
  4316. kind: OptionKind.VIEWER
  4317. },
  4318. viewOnLoad: {
  4319. value: 0,
  4320. kind: OptionKind.VIEWER
  4321. },
  4322. cMapPacked: {
  4323. value: true,
  4324. kind: OptionKind.API
  4325. },
  4326. cMapUrl: {
  4327. value: '../o2_lib/pdfjs/web/cmaps/',
  4328. kind: OptionKind.API
  4329. },
  4330. disableAutoFetch: {
  4331. value: false,
  4332. kind: OptionKind.API
  4333. },
  4334. disableCreateObjectURL: {
  4335. value: false,
  4336. compatibility: _pdfjsLib.apiCompatibilityParams.disableCreateObjectURL,
  4337. kind: OptionKind.API
  4338. },
  4339. disableFontFace: {
  4340. value: false,
  4341. kind: OptionKind.API
  4342. },
  4343. disableRange: {
  4344. value: false,
  4345. kind: OptionKind.API
  4346. },
  4347. disableStream: {
  4348. value: false,
  4349. kind: OptionKind.API
  4350. },
  4351. isEvalSupported: {
  4352. value: true,
  4353. kind: OptionKind.API
  4354. },
  4355. maxImageSize: {
  4356. value: -1,
  4357. kind: OptionKind.API
  4358. },
  4359. pdfBug: {
  4360. value: false,
  4361. kind: OptionKind.API
  4362. },
  4363. postMessageTransfers: {
  4364. value: true,
  4365. kind: OptionKind.API
  4366. },
  4367. verbosity: {
  4368. value: 1,
  4369. kind: OptionKind.API
  4370. },
  4371. workerPort: {
  4372. value: null,
  4373. kind: OptionKind.WORKER
  4374. },
  4375. workerSrc: {
  4376. value: '../o2_lib/pdfjs/build/pdf.worker.js',
  4377. kind: OptionKind.WORKER
  4378. }
  4379. };
  4380. {
  4381. defaultOptions.disablePreferences = {
  4382. value: false,
  4383. kind: OptionKind.VIEWER
  4384. };
  4385. defaultOptions.locale = {
  4386. value: typeof navigator !== 'undefined' ? navigator.language : 'en-US',
  4387. kind: OptionKind.VIEWER
  4388. };
  4389. }
  4390. var userOptions = Object.create(null);
  4391. var AppOptions =
  4392. /*#__PURE__*/
  4393. function () {
  4394. function AppOptions() {
  4395. _classCallCheck(this, AppOptions);
  4396. throw new Error('Cannot initialize AppOptions.');
  4397. }
  4398. _createClass(AppOptions, null, [{
  4399. key: "get",
  4400. value: function get(name) {
  4401. var userOption = userOptions[name];
  4402. if (userOption !== undefined) {
  4403. return userOption;
  4404. }
  4405. var defaultOption = defaultOptions[name];
  4406. if (defaultOption !== undefined) {
  4407. return defaultOption.compatibility || defaultOption.value;
  4408. }
  4409. return undefined;
  4410. }
  4411. }, {
  4412. key: "getAll",
  4413. value: function getAll() {
  4414. var kind = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  4415. var options = Object.create(null);
  4416. for (var name in defaultOptions) {
  4417. var defaultOption = defaultOptions[name];
  4418. if (kind && kind !== defaultOption.kind) {
  4419. continue;
  4420. }
  4421. var userOption = userOptions[name];
  4422. options[name] = userOption !== undefined ? userOption : defaultOption.compatibility || defaultOption.value;
  4423. }
  4424. return options;
  4425. }
  4426. }, {
  4427. key: "set",
  4428. value: function set(name, value) {
  4429. userOptions[name] = value;
  4430. }
  4431. }, {
  4432. key: "remove",
  4433. value: function remove(name) {
  4434. delete userOptions[name];
  4435. }
  4436. }]);
  4437. return AppOptions;
  4438. }();
  4439. exports.AppOptions = AppOptions;
  4440. /***/ }),
  4441. /* 13 */
  4442. /***/ (function(module, exports, __webpack_require__) {
  4443. "use strict";
  4444. var compatibilityParams = Object.create(null);
  4445. {
  4446. var userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
  4447. var isAndroid = /Android/.test(userAgent);
  4448. var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent);
  4449. (function checkCanvasSizeLimitation() {
  4450. if (isIOS || isAndroid) {
  4451. compatibilityParams.maxCanvasPixels = 5242880;
  4452. }
  4453. })();
  4454. }
  4455. exports.viewerCompatibilityParams = Object.freeze(compatibilityParams);
  4456. /***/ }),
  4457. /* 14 */
  4458. /***/ (function(module, exports, __webpack_require__) {
  4459. "use strict";
  4460. Object.defineProperty(exports, "__esModule", {
  4461. value: true
  4462. });
  4463. exports.OverlayManager = void 0;
  4464. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  4465. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4466. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  4467. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  4468. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4469. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  4470. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4471. var OverlayManager =
  4472. /*#__PURE__*/
  4473. function () {
  4474. function OverlayManager() {
  4475. _classCallCheck(this, OverlayManager);
  4476. this._overlays = {};
  4477. this._active = null;
  4478. this._keyDownBound = this._keyDown.bind(this);
  4479. }
  4480. _createClass(OverlayManager, [{
  4481. key: "register",
  4482. value: function () {
  4483. var _register = _asyncToGenerator(
  4484. /*#__PURE__*/
  4485. _regenerator.default.mark(function _callee(name, element) {
  4486. var callerCloseMethod,
  4487. canForceClose,
  4488. container,
  4489. _args = arguments;
  4490. return _regenerator.default.wrap(function _callee$(_context) {
  4491. while (1) {
  4492. switch (_context.prev = _context.next) {
  4493. case 0:
  4494. callerCloseMethod = _args.length > 2 && _args[2] !== undefined ? _args[2] : null;
  4495. canForceClose = _args.length > 3 && _args[3] !== undefined ? _args[3] : false;
  4496. if (!(!name || !element || !(container = element.parentNode))) {
  4497. _context.next = 6;
  4498. break;
  4499. }
  4500. throw new Error('Not enough parameters.');
  4501. case 6:
  4502. if (!this._overlays[name]) {
  4503. _context.next = 8;
  4504. break;
  4505. }
  4506. throw new Error('The overlay is already registered.');
  4507. case 8:
  4508. this._overlays[name] = {
  4509. element: element,
  4510. container: container,
  4511. callerCloseMethod: callerCloseMethod,
  4512. canForceClose: canForceClose
  4513. };
  4514. case 9:
  4515. case "end":
  4516. return _context.stop();
  4517. }
  4518. }
  4519. }, _callee, this);
  4520. }));
  4521. function register(_x, _x2) {
  4522. return _register.apply(this, arguments);
  4523. }
  4524. return register;
  4525. }()
  4526. }, {
  4527. key: "unregister",
  4528. value: function () {
  4529. var _unregister = _asyncToGenerator(
  4530. /*#__PURE__*/
  4531. _regenerator.default.mark(function _callee2(name) {
  4532. return _regenerator.default.wrap(function _callee2$(_context2) {
  4533. while (1) {
  4534. switch (_context2.prev = _context2.next) {
  4535. case 0:
  4536. if (this._overlays[name]) {
  4537. _context2.next = 4;
  4538. break;
  4539. }
  4540. throw new Error('The overlay does not exist.');
  4541. case 4:
  4542. if (!(this._active === name)) {
  4543. _context2.next = 6;
  4544. break;
  4545. }
  4546. throw new Error('The overlay cannot be removed while it is active.');
  4547. case 6:
  4548. delete this._overlays[name];
  4549. case 7:
  4550. case "end":
  4551. return _context2.stop();
  4552. }
  4553. }
  4554. }, _callee2, this);
  4555. }));
  4556. function unregister(_x3) {
  4557. return _unregister.apply(this, arguments);
  4558. }
  4559. return unregister;
  4560. }()
  4561. }, {
  4562. key: "open",
  4563. value: function () {
  4564. var _open = _asyncToGenerator(
  4565. /*#__PURE__*/
  4566. _regenerator.default.mark(function _callee3(name) {
  4567. return _regenerator.default.wrap(function _callee3$(_context3) {
  4568. while (1) {
  4569. switch (_context3.prev = _context3.next) {
  4570. case 0:
  4571. if (this._overlays[name]) {
  4572. _context3.next = 4;
  4573. break;
  4574. }
  4575. throw new Error('The overlay does not exist.');
  4576. case 4:
  4577. if (!this._active) {
  4578. _context3.next = 14;
  4579. break;
  4580. }
  4581. if (!this._overlays[name].canForceClose) {
  4582. _context3.next = 9;
  4583. break;
  4584. }
  4585. this._closeThroughCaller();
  4586. _context3.next = 14;
  4587. break;
  4588. case 9:
  4589. if (!(this._active === name)) {
  4590. _context3.next = 13;
  4591. break;
  4592. }
  4593. throw new Error('The overlay is already active.');
  4594. case 13:
  4595. throw new Error('Another overlay is currently active.');
  4596. case 14:
  4597. this._active = name;
  4598. this._overlays[this._active].element.classList.remove('hidden');
  4599. this._overlays[this._active].container.classList.remove('hidden');
  4600. window.addEventListener('keydown', this._keyDownBound);
  4601. case 18:
  4602. case "end":
  4603. return _context3.stop();
  4604. }
  4605. }
  4606. }, _callee3, this);
  4607. }));
  4608. function open(_x4) {
  4609. return _open.apply(this, arguments);
  4610. }
  4611. return open;
  4612. }()
  4613. }, {
  4614. key: "close",
  4615. value: function () {
  4616. var _close = _asyncToGenerator(
  4617. /*#__PURE__*/
  4618. _regenerator.default.mark(function _callee4(name) {
  4619. return _regenerator.default.wrap(function _callee4$(_context4) {
  4620. while (1) {
  4621. switch (_context4.prev = _context4.next) {
  4622. case 0:
  4623. if (this._overlays[name]) {
  4624. _context4.next = 4;
  4625. break;
  4626. }
  4627. throw new Error('The overlay does not exist.');
  4628. case 4:
  4629. if (this._active) {
  4630. _context4.next = 8;
  4631. break;
  4632. }
  4633. throw new Error('The overlay is currently not active.');
  4634. case 8:
  4635. if (!(this._active !== name)) {
  4636. _context4.next = 10;
  4637. break;
  4638. }
  4639. throw new Error('Another overlay is currently active.');
  4640. case 10:
  4641. this._overlays[this._active].container.classList.add('hidden');
  4642. this._overlays[this._active].element.classList.add('hidden');
  4643. this._active = null;
  4644. window.removeEventListener('keydown', this._keyDownBound);
  4645. case 14:
  4646. case "end":
  4647. return _context4.stop();
  4648. }
  4649. }
  4650. }, _callee4, this);
  4651. }));
  4652. function close(_x5) {
  4653. return _close.apply(this, arguments);
  4654. }
  4655. return close;
  4656. }()
  4657. }, {
  4658. key: "_keyDown",
  4659. value: function _keyDown(evt) {
  4660. if (this._active && evt.keyCode === 27) {
  4661. this._closeThroughCaller();
  4662. evt.preventDefault();
  4663. }
  4664. }
  4665. }, {
  4666. key: "_closeThroughCaller",
  4667. value: function _closeThroughCaller() {
  4668. if (this._overlays[this._active].callerCloseMethod) {
  4669. this._overlays[this._active].callerCloseMethod();
  4670. }
  4671. if (this._active) {
  4672. this.close(this._active);
  4673. }
  4674. }
  4675. }, {
  4676. key: "active",
  4677. get: function get() {
  4678. return this._active;
  4679. }
  4680. }]);
  4681. return OverlayManager;
  4682. }();
  4683. exports.OverlayManager = OverlayManager;
  4684. /***/ }),
  4685. /* 15 */
  4686. /***/ (function(module, exports, __webpack_require__) {
  4687. "use strict";
  4688. Object.defineProperty(exports, "__esModule", {
  4689. value: true
  4690. });
  4691. exports.PasswordPrompt = void 0;
  4692. var _ui_utils = __webpack_require__(6);
  4693. var _pdfjsLib = __webpack_require__(7);
  4694. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4695. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  4696. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4697. var PasswordPrompt =
  4698. /*#__PURE__*/
  4699. function () {
  4700. function PasswordPrompt(options, overlayManager) {
  4701. var _this = this;
  4702. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  4703. _classCallCheck(this, PasswordPrompt);
  4704. this.overlayName = options.overlayName;
  4705. this.container = options.container;
  4706. this.label = options.label;
  4707. this.input = options.input;
  4708. this.submitButton = options.submitButton;
  4709. this.cancelButton = options.cancelButton;
  4710. this.overlayManager = overlayManager;
  4711. this.l10n = l10n;
  4712. this.updateCallback = null;
  4713. this.reason = null;
  4714. this.submitButton.addEventListener('click', this.verify.bind(this));
  4715. this.cancelButton.addEventListener('click', this.close.bind(this));
  4716. this.input.addEventListener('keydown', function (e) {
  4717. if (e.keyCode === 13) {
  4718. _this.verify();
  4719. }
  4720. });
  4721. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this), true);
  4722. }
  4723. _createClass(PasswordPrompt, [{
  4724. key: "open",
  4725. value: function open() {
  4726. var _this2 = this;
  4727. this.overlayManager.open(this.overlayName).then(function () {
  4728. _this2.input.focus();
  4729. var promptString;
  4730. if (_this2.reason === _pdfjsLib.PasswordResponses.INCORRECT_PASSWORD) {
  4731. promptString = _this2.l10n.get('password_invalid', null, 'Invalid password. Please try again.');
  4732. } else {
  4733. promptString = _this2.l10n.get('password_label', null, 'Enter the password to open this PDF file.');
  4734. }
  4735. promptString.then(function (msg) {
  4736. _this2.label.textContent = msg;
  4737. });
  4738. });
  4739. }
  4740. }, {
  4741. key: "close",
  4742. value: function close() {
  4743. var _this3 = this;
  4744. this.overlayManager.close(this.overlayName).then(function () {
  4745. _this3.input.value = '';
  4746. });
  4747. }
  4748. }, {
  4749. key: "verify",
  4750. value: function verify() {
  4751. var password = this.input.value;
  4752. if (password && password.length > 0) {
  4753. this.close();
  4754. return this.updateCallback(password);
  4755. }
  4756. }
  4757. }, {
  4758. key: "setUpdateCallback",
  4759. value: function setUpdateCallback(updateCallback, reason) {
  4760. this.updateCallback = updateCallback;
  4761. this.reason = reason;
  4762. }
  4763. }]);
  4764. return PasswordPrompt;
  4765. }();
  4766. exports.PasswordPrompt = PasswordPrompt;
  4767. /***/ }),
  4768. /* 16 */
  4769. /***/ (function(module, exports, __webpack_require__) {
  4770. "use strict";
  4771. Object.defineProperty(exports, "__esModule", {
  4772. value: true
  4773. });
  4774. exports.PDFAttachmentViewer = void 0;
  4775. var _pdfjsLib = __webpack_require__(7);
  4776. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4777. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  4778. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4779. var PDFAttachmentViewer =
  4780. /*#__PURE__*/
  4781. function () {
  4782. function PDFAttachmentViewer(_ref) {
  4783. var container = _ref.container,
  4784. eventBus = _ref.eventBus,
  4785. downloadManager = _ref.downloadManager;
  4786. _classCallCheck(this, PDFAttachmentViewer);
  4787. this.container = container;
  4788. this.eventBus = eventBus;
  4789. this.downloadManager = downloadManager;
  4790. this.reset();
  4791. this.eventBus.on('fileattachmentannotation', this._appendAttachment.bind(this));
  4792. }
  4793. _createClass(PDFAttachmentViewer, [{
  4794. key: "reset",
  4795. value: function reset() {
  4796. var keepRenderedCapability = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4797. this.attachments = null;
  4798. this.container.textContent = '';
  4799. if (!keepRenderedCapability) {
  4800. this._renderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  4801. }
  4802. }
  4803. }, {
  4804. key: "_dispatchEvent",
  4805. value: function _dispatchEvent(attachmentsCount) {
  4806. this._renderedCapability.resolve();
  4807. this.eventBus.dispatch('attachmentsloaded', {
  4808. source: this,
  4809. attachmentsCount: attachmentsCount
  4810. });
  4811. }
  4812. }, {
  4813. key: "_bindPdfLink",
  4814. value: function _bindPdfLink(button, content, filename) {
  4815. if (this.downloadManager.disableCreateObjectURL) {
  4816. throw new Error('bindPdfLink: Unsupported "disableCreateObjectURL" value.');
  4817. }
  4818. var blobUrl;
  4819. button.onclick = function () {
  4820. if (!blobUrl) {
  4821. blobUrl = (0, _pdfjsLib.createObjectURL)(content, 'application/pdf');
  4822. }
  4823. var viewerUrl;
  4824. viewerUrl = '?file=' + encodeURIComponent(blobUrl + '#' + filename);
  4825. window.open(viewerUrl);
  4826. return false;
  4827. };
  4828. }
  4829. }, {
  4830. key: "_bindLink",
  4831. value: function _bindLink(button, content, filename) {
  4832. var _this = this;
  4833. button.onclick = function () {
  4834. _this.downloadManager.downloadData(content, filename, '');
  4835. return false;
  4836. };
  4837. }
  4838. }, {
  4839. key: "render",
  4840. value: function render(_ref2) {
  4841. var attachments = _ref2.attachments,
  4842. _ref2$keepRenderedCap = _ref2.keepRenderedCapability,
  4843. keepRenderedCapability = _ref2$keepRenderedCap === void 0 ? false : _ref2$keepRenderedCap;
  4844. var attachmentsCount = 0;
  4845. if (this.attachments) {
  4846. this.reset(keepRenderedCapability === true);
  4847. }
  4848. this.attachments = attachments || null;
  4849. if (!attachments) {
  4850. this._dispatchEvent(attachmentsCount);
  4851. return;
  4852. }
  4853. var names = Object.keys(attachments).sort(function (a, b) {
  4854. return a.toLowerCase().localeCompare(b.toLowerCase());
  4855. });
  4856. attachmentsCount = names.length;
  4857. for (var i = 0; i < attachmentsCount; i++) {
  4858. var item = attachments[names[i]];
  4859. var filename = (0, _pdfjsLib.removeNullCharacters)((0, _pdfjsLib.getFilenameFromUrl)(item.filename));
  4860. var div = document.createElement('div');
  4861. div.className = 'attachmentsItem';
  4862. var button = document.createElement('button');
  4863. button.textContent = filename;
  4864. if (/\.pdf$/i.test(filename) && !this.downloadManager.disableCreateObjectURL) {
  4865. this._bindPdfLink(button, item.content, filename);
  4866. } else {
  4867. this._bindLink(button, item.content, filename);
  4868. }
  4869. div.appendChild(button);
  4870. this.container.appendChild(div);
  4871. }
  4872. this._dispatchEvent(attachmentsCount);
  4873. }
  4874. }, {
  4875. key: "_appendAttachment",
  4876. value: function _appendAttachment(_ref3) {
  4877. var _this2 = this;
  4878. var id = _ref3.id,
  4879. filename = _ref3.filename,
  4880. content = _ref3.content;
  4881. this._renderedCapability.promise.then(function () {
  4882. var attachments = _this2.attachments;
  4883. if (!attachments) {
  4884. attachments = Object.create(null);
  4885. } else {
  4886. for (var name in attachments) {
  4887. if (id === name) {
  4888. return;
  4889. }
  4890. }
  4891. }
  4892. attachments[id] = {
  4893. filename: filename,
  4894. content: content
  4895. };
  4896. _this2.render({
  4897. attachments: attachments,
  4898. keepRenderedCapability: true
  4899. });
  4900. });
  4901. }
  4902. }]);
  4903. return PDFAttachmentViewer;
  4904. }();
  4905. exports.PDFAttachmentViewer = PDFAttachmentViewer;
  4906. /***/ }),
  4907. /* 17 */
  4908. /***/ (function(module, exports, __webpack_require__) {
  4909. "use strict";
  4910. Object.defineProperty(exports, "__esModule", {
  4911. value: true
  4912. });
  4913. exports.PDFDocumentProperties = void 0;
  4914. var _ui_utils = __webpack_require__(6);
  4915. var _pdfjsLib = __webpack_require__(7);
  4916. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
  4917. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
  4918. function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  4919. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  4920. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4921. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  4922. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4923. var DEFAULT_FIELD_CONTENT = '-';
  4924. var NON_METRIC_LOCALES = ['en-us', 'en-lr', 'my'];
  4925. var US_PAGE_NAMES = {
  4926. '8.5x11': 'Letter',
  4927. '8.5x14': 'Legal'
  4928. };
  4929. var METRIC_PAGE_NAMES = {
  4930. '297x420': 'A3',
  4931. '210x297': 'A4'
  4932. };
  4933. function getPageName(size, isPortrait, pageNames) {
  4934. var width = isPortrait ? size.width : size.height;
  4935. var height = isPortrait ? size.height : size.width;
  4936. return pageNames["".concat(width, "x").concat(height)];
  4937. }
  4938. var PDFDocumentProperties =
  4939. /*#__PURE__*/
  4940. function () {
  4941. function PDFDocumentProperties(_ref, overlayManager, eventBus) {
  4942. var _this = this;
  4943. var overlayName = _ref.overlayName,
  4944. fields = _ref.fields,
  4945. container = _ref.container,
  4946. closeButton = _ref.closeButton;
  4947. var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
  4948. _classCallCheck(this, PDFDocumentProperties);
  4949. this.overlayName = overlayName;
  4950. this.fields = fields;
  4951. this.container = container;
  4952. this.overlayManager = overlayManager;
  4953. this.l10n = l10n;
  4954. this._reset();
  4955. if (closeButton) {
  4956. closeButton.addEventListener('click', this.close.bind(this));
  4957. }
  4958. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this));
  4959. if (eventBus) {
  4960. eventBus.on('pagechanging', function (evt) {
  4961. _this._currentPageNumber = evt.pageNumber;
  4962. });
  4963. eventBus.on('rotationchanging', function (evt) {
  4964. _this._pagesRotation = evt.pagesRotation;
  4965. });
  4966. }
  4967. this._isNonMetricLocale = true;
  4968. l10n.getLanguage().then(function (locale) {
  4969. _this._isNonMetricLocale = NON_METRIC_LOCALES.includes(locale);
  4970. });
  4971. }
  4972. _createClass(PDFDocumentProperties, [{
  4973. key: "open",
  4974. value: function open() {
  4975. var _this2 = this;
  4976. var freezeFieldData = function freezeFieldData(data) {
  4977. Object.defineProperty(_this2, 'fieldData', {
  4978. value: Object.freeze(data),
  4979. writable: false,
  4980. enumerable: true,
  4981. configurable: true
  4982. });
  4983. };
  4984. Promise.all([this.overlayManager.open(this.overlayName), this._dataAvailableCapability.promise]).then(function () {
  4985. var currentPageNumber = _this2._currentPageNumber;
  4986. var pagesRotation = _this2._pagesRotation;
  4987. if (_this2.fieldData && currentPageNumber === _this2.fieldData['_currentPageNumber'] && pagesRotation === _this2.fieldData['_pagesRotation']) {
  4988. _this2._updateUI();
  4989. return;
  4990. }
  4991. _this2.pdfDocument.getMetadata().then(function (_ref2) {
  4992. var info = _ref2.info,
  4993. metadata = _ref2.metadata,
  4994. contentDispositionFilename = _ref2.contentDispositionFilename;
  4995. return Promise.all([info, metadata, contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(_this2.url || ''), _this2._parseFileSize(_this2.maybeFileSize), _this2._parseDate(info.CreationDate), _this2._parseDate(info.ModDate), _this2.pdfDocument.getPage(currentPageNumber).then(function (pdfPage) {
  4996. return _this2._parsePageSize((0, _ui_utils.getPageSizeInches)(pdfPage), pagesRotation);
  4997. }), _this2._parseLinearization(info.IsLinearized)]);
  4998. }).then(function (_ref3) {
  4999. var _ref4 = _slicedToArray(_ref3, 8),
  5000. info = _ref4[0],
  5001. metadata = _ref4[1],
  5002. fileName = _ref4[2],
  5003. fileSize = _ref4[3],
  5004. creationDate = _ref4[4],
  5005. modDate = _ref4[5],
  5006. pageSize = _ref4[6],
  5007. isLinearized = _ref4[7];
  5008. freezeFieldData({
  5009. 'fileName': fileName,
  5010. 'fileSize': fileSize,
  5011. 'title': info.Title,
  5012. 'author': info.Author,
  5013. 'subject': info.Subject,
  5014. 'keywords': info.Keywords,
  5015. 'creationDate': creationDate,
  5016. 'modificationDate': modDate,
  5017. 'creator': info.Creator,
  5018. 'producer': info.Producer,
  5019. 'version': info.PDFFormatVersion,
  5020. 'pageCount': _this2.pdfDocument.numPages,
  5021. 'pageSize': pageSize,
  5022. 'linearized': isLinearized,
  5023. '_currentPageNumber': currentPageNumber,
  5024. '_pagesRotation': pagesRotation
  5025. });
  5026. _this2._updateUI();
  5027. return _this2.pdfDocument.getDownloadInfo();
  5028. }).then(function (_ref5) {
  5029. var length = _ref5.length;
  5030. _this2.maybeFileSize = length;
  5031. return _this2._parseFileSize(length);
  5032. }).then(function (fileSize) {
  5033. if (fileSize === _this2.fieldData['fileSize']) {
  5034. return;
  5035. }
  5036. var data = Object.assign(Object.create(null), _this2.fieldData);
  5037. data['fileSize'] = fileSize;
  5038. freezeFieldData(data);
  5039. _this2._updateUI();
  5040. });
  5041. });
  5042. }
  5043. }, {
  5044. key: "close",
  5045. value: function close() {
  5046. this.overlayManager.close(this.overlayName);
  5047. }
  5048. }, {
  5049. key: "setDocument",
  5050. value: function setDocument(pdfDocument) {
  5051. var url = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  5052. if (this.pdfDocument) {
  5053. this._reset();
  5054. this._updateUI(true);
  5055. }
  5056. if (!pdfDocument) {
  5057. return;
  5058. }
  5059. this.pdfDocument = pdfDocument;
  5060. this.url = url;
  5061. this._dataAvailableCapability.resolve();
  5062. }
  5063. }, {
  5064. key: "setFileSize",
  5065. value: function setFileSize(fileSize) {
  5066. if (Number.isInteger(fileSize) && fileSize > 0) {
  5067. this.maybeFileSize = fileSize;
  5068. }
  5069. }
  5070. }, {
  5071. key: "_reset",
  5072. value: function _reset() {
  5073. this.pdfDocument = null;
  5074. this.url = null;
  5075. this.maybeFileSize = 0;
  5076. delete this.fieldData;
  5077. this._dataAvailableCapability = (0, _pdfjsLib.createPromiseCapability)();
  5078. this._currentPageNumber = 1;
  5079. this._pagesRotation = 0;
  5080. }
  5081. }, {
  5082. key: "_updateUI",
  5083. value: function _updateUI() {
  5084. var reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5085. if (reset || !this.fieldData) {
  5086. for (var id in this.fields) {
  5087. this.fields[id].textContent = DEFAULT_FIELD_CONTENT;
  5088. }
  5089. return;
  5090. }
  5091. if (this.overlayManager.active !== this.overlayName) {
  5092. return;
  5093. }
  5094. for (var _id in this.fields) {
  5095. var content = this.fieldData[_id];
  5096. this.fields[_id].textContent = content || content === 0 ? content : DEFAULT_FIELD_CONTENT;
  5097. }
  5098. }
  5099. }, {
  5100. key: "_parseFileSize",
  5101. value: function _parseFileSize() {
  5102. var fileSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  5103. var kb = fileSize / 1024;
  5104. if (!kb) {
  5105. return Promise.resolve(undefined);
  5106. } else if (kb < 1024) {
  5107. return this.l10n.get('document_properties_kb', {
  5108. size_kb: (+kb.toPrecision(3)).toLocaleString(),
  5109. size_b: fileSize.toLocaleString()
  5110. }, '{{size_kb}} KB ({{size_b}} bytes)');
  5111. }
  5112. return this.l10n.get('document_properties_mb', {
  5113. size_mb: (+(kb / 1024).toPrecision(3)).toLocaleString(),
  5114. size_b: fileSize.toLocaleString()
  5115. }, '{{size_mb}} MB ({{size_b}} bytes)');
  5116. }
  5117. }, {
  5118. key: "_parsePageSize",
  5119. value: function _parsePageSize(pageSizeInches, pagesRotation) {
  5120. var _this3 = this;
  5121. if (!pageSizeInches) {
  5122. return Promise.resolve(undefined);
  5123. }
  5124. if (pagesRotation % 180 !== 0) {
  5125. pageSizeInches = {
  5126. width: pageSizeInches.height,
  5127. height: pageSizeInches.width
  5128. };
  5129. }
  5130. var isPortrait = (0, _ui_utils.isPortraitOrientation)(pageSizeInches);
  5131. var sizeInches = {
  5132. width: Math.round(pageSizeInches.width * 100) / 100,
  5133. height: Math.round(pageSizeInches.height * 100) / 100
  5134. };
  5135. var sizeMillimeters = {
  5136. width: Math.round(pageSizeInches.width * 25.4 * 10) / 10,
  5137. height: Math.round(pageSizeInches.height * 25.4 * 10) / 10
  5138. };
  5139. var pageName = null;
  5140. var name = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES);
  5141. if (!name && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(sizeMillimeters.height))) {
  5142. var exactMillimeters = {
  5143. width: pageSizeInches.width * 25.4,
  5144. height: pageSizeInches.height * 25.4
  5145. };
  5146. var intMillimeters = {
  5147. width: Math.round(sizeMillimeters.width),
  5148. height: Math.round(sizeMillimeters.height)
  5149. };
  5150. if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) {
  5151. name = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES);
  5152. if (name) {
  5153. sizeInches = {
  5154. width: Math.round(intMillimeters.width / 25.4 * 100) / 100,
  5155. height: Math.round(intMillimeters.height / 25.4 * 100) / 100
  5156. };
  5157. sizeMillimeters = intMillimeters;
  5158. }
  5159. }
  5160. }
  5161. if (name) {
  5162. pageName = this.l10n.get('document_properties_page_size_name_' + name.toLowerCase(), null, name);
  5163. }
  5164. return Promise.all([this._isNonMetricLocale ? sizeInches : sizeMillimeters, this.l10n.get('document_properties_page_size_unit_' + (this._isNonMetricLocale ? 'inches' : 'millimeters'), null, this._isNonMetricLocale ? 'in' : 'mm'), pageName, this.l10n.get('document_properties_page_size_orientation_' + (isPortrait ? 'portrait' : 'landscape'), null, isPortrait ? 'portrait' : 'landscape')]).then(function (_ref6) {
  5165. var _ref7 = _slicedToArray(_ref6, 4),
  5166. _ref7$ = _ref7[0],
  5167. width = _ref7$.width,
  5168. height = _ref7$.height,
  5169. unit = _ref7[1],
  5170. name = _ref7[2],
  5171. orientation = _ref7[3];
  5172. return _this3.l10n.get('document_properties_page_size_dimension_' + (name ? 'name_' : '') + 'string', {
  5173. width: width.toLocaleString(),
  5174. height: height.toLocaleString(),
  5175. unit: unit,
  5176. name: name,
  5177. orientation: orientation
  5178. }, '{{width}} × {{height}} {{unit}} (' + (name ? '{{name}}, ' : '') + '{{orientation}})');
  5179. });
  5180. }
  5181. }, {
  5182. key: "_parseDate",
  5183. value: function _parseDate(inputDate) {
  5184. if (!inputDate) {
  5185. return;
  5186. }
  5187. var dateToParse = inputDate;
  5188. if (dateToParse.substring(0, 2) === 'D:') {
  5189. dateToParse = dateToParse.substring(2);
  5190. }
  5191. var year = parseInt(dateToParse.substring(0, 4), 10);
  5192. var month = parseInt(dateToParse.substring(4, 6), 10) - 1;
  5193. var day = parseInt(dateToParse.substring(6, 8), 10);
  5194. var hours = parseInt(dateToParse.substring(8, 10), 10);
  5195. var minutes = parseInt(dateToParse.substring(10, 12), 10);
  5196. var seconds = parseInt(dateToParse.substring(12, 14), 10);
  5197. var utRel = dateToParse.substring(14, 15);
  5198. var offsetHours = parseInt(dateToParse.substring(15, 17), 10);
  5199. var offsetMinutes = parseInt(dateToParse.substring(18, 20), 10);
  5200. if (utRel === '-') {
  5201. hours += offsetHours;
  5202. minutes += offsetMinutes;
  5203. } else if (utRel === '+') {
  5204. hours -= offsetHours;
  5205. minutes -= offsetMinutes;
  5206. }
  5207. var date = new Date(Date.UTC(year, month, day, hours, minutes, seconds));
  5208. var dateString = date.toLocaleDateString();
  5209. var timeString = date.toLocaleTimeString();
  5210. return this.l10n.get('document_properties_date_string', {
  5211. date: dateString,
  5212. time: timeString
  5213. }, '{{date}}, {{time}}');
  5214. }
  5215. }, {
  5216. key: "_parseLinearization",
  5217. value: function _parseLinearization(isLinearized) {
  5218. return this.l10n.get('document_properties_linearized_' + (isLinearized ? 'yes' : 'no'), null, isLinearized ? 'Yes' : 'No');
  5219. }
  5220. }]);
  5221. return PDFDocumentProperties;
  5222. }();
  5223. exports.PDFDocumentProperties = PDFDocumentProperties;
  5224. /***/ }),
  5225. /* 18 */
  5226. /***/ (function(module, exports, __webpack_require__) {
  5227. "use strict";
  5228. Object.defineProperty(exports, "__esModule", {
  5229. value: true
  5230. });
  5231. exports.PDFFindBar = void 0;
  5232. var _ui_utils = __webpack_require__(6);
  5233. var _pdf_find_controller = __webpack_require__(19);
  5234. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5235. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  5236. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5237. var MATCHES_COUNT_LIMIT = 1000;
  5238. var PDFFindBar =
  5239. /*#__PURE__*/
  5240. function () {
  5241. function PDFFindBar(options) {
  5242. var _this = this;
  5243. var eventBus = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (0, _ui_utils.getGlobalEventBus)();
  5244. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  5245. _classCallCheck(this, PDFFindBar);
  5246. this.opened = false;
  5247. this.bar = options.bar || null;
  5248. this.toggleButton = options.toggleButton || null;
  5249. this.findField = options.findField || null;
  5250. this.highlightAll = options.highlightAllCheckbox || null;
  5251. this.caseSensitive = options.caseSensitiveCheckbox || null;
  5252. this.entireWord = options.entireWordCheckbox || null;
  5253. this.findMsg = options.findMsg || null;
  5254. this.findResultsCount = options.findResultsCount || null;
  5255. this.findPreviousButton = options.findPreviousButton || null;
  5256. this.findNextButton = options.findNextButton || null;
  5257. this.eventBus = eventBus;
  5258. this.l10n = l10n;
  5259. this.toggleButton.addEventListener('click', function () {
  5260. _this.toggle();
  5261. });
  5262. this.findField.addEventListener('input', function () {
  5263. _this.dispatchEvent('');
  5264. });
  5265. this.bar.addEventListener('keydown', function (e) {
  5266. switch (e.keyCode) {
  5267. case 13:
  5268. if (e.target === _this.findField) {
  5269. _this.dispatchEvent('again', e.shiftKey);
  5270. }
  5271. break;
  5272. case 27:
  5273. _this.close();
  5274. break;
  5275. }
  5276. });
  5277. this.findPreviousButton.addEventListener('click', function () {
  5278. _this.dispatchEvent('again', true);
  5279. });
  5280. this.findNextButton.addEventListener('click', function () {
  5281. _this.dispatchEvent('again', false);
  5282. });
  5283. this.highlightAll.addEventListener('click', function () {
  5284. _this.dispatchEvent('highlightallchange');
  5285. });
  5286. this.caseSensitive.addEventListener('click', function () {
  5287. _this.dispatchEvent('casesensitivitychange');
  5288. });
  5289. this.entireWord.addEventListener('click', function () {
  5290. _this.dispatchEvent('entirewordchange');
  5291. });
  5292. this.eventBus.on('resize', this._adjustWidth.bind(this));
  5293. }
  5294. _createClass(PDFFindBar, [{
  5295. key: "reset",
  5296. value: function reset() {
  5297. this.updateUIState();
  5298. }
  5299. }, {
  5300. key: "dispatchEvent",
  5301. value: function dispatchEvent(type, findPrev) {
  5302. this.eventBus.dispatch('find', {
  5303. source: this,
  5304. type: type,
  5305. query: this.findField.value,
  5306. phraseSearch: true,
  5307. caseSensitive: this.caseSensitive.checked,
  5308. entireWord: this.entireWord.checked,
  5309. highlightAll: this.highlightAll.checked,
  5310. findPrevious: findPrev
  5311. });
  5312. }
  5313. }, {
  5314. key: "updateUIState",
  5315. value: function updateUIState(state, previous, matchesCount) {
  5316. var _this2 = this;
  5317. var notFound = false;
  5318. var findMsg = '';
  5319. var status = '';
  5320. switch (state) {
  5321. case _pdf_find_controller.FindState.FOUND:
  5322. break;
  5323. case _pdf_find_controller.FindState.PENDING:
  5324. status = 'pending';
  5325. break;
  5326. case _pdf_find_controller.FindState.NOT_FOUND:
  5327. findMsg = this.l10n.get('find_not_found', null, 'Phrase not found');
  5328. notFound = true;
  5329. break;
  5330. case _pdf_find_controller.FindState.WRAPPED:
  5331. if (previous) {
  5332. findMsg = this.l10n.get('find_reached_top', null, 'Reached top of document, continued from bottom');
  5333. } else {
  5334. findMsg = this.l10n.get('find_reached_bottom', null, 'Reached end of document, continued from top');
  5335. }
  5336. break;
  5337. }
  5338. this.findField.classList.toggle('notFound', notFound);
  5339. this.findField.setAttribute('data-status', status);
  5340. Promise.resolve(findMsg).then(function (msg) {
  5341. _this2.findMsg.textContent = msg;
  5342. _this2._adjustWidth();
  5343. });
  5344. this.updateResultsCount(matchesCount);
  5345. }
  5346. }, {
  5347. key: "updateResultsCount",
  5348. value: function updateResultsCount() {
  5349. var _this3 = this;
  5350. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  5351. _ref$current = _ref.current,
  5352. current = _ref$current === void 0 ? 0 : _ref$current,
  5353. _ref$total = _ref.total,
  5354. total = _ref$total === void 0 ? 0 : _ref$total;
  5355. if (!this.findResultsCount) {
  5356. return;
  5357. }
  5358. var matchesCountMsg = '',
  5359. limit = MATCHES_COUNT_LIMIT;
  5360. if (total > 0) {
  5361. if (total > limit) {
  5362. matchesCountMsg = this.l10n.get('find_match_count_limit', {
  5363. limit: limit
  5364. }, 'More than {{limit}} match' + (limit !== 1 ? 'es' : ''));
  5365. } else {
  5366. matchesCountMsg = this.l10n.get('find_match_count', {
  5367. current: current,
  5368. total: total
  5369. }, '{{current}} of {{total}} match' + (total !== 1 ? 'es' : ''));
  5370. }
  5371. }
  5372. Promise.resolve(matchesCountMsg).then(function (msg) {
  5373. _this3.findResultsCount.textContent = msg;
  5374. _this3.findResultsCount.classList.toggle('hidden', !total);
  5375. _this3._adjustWidth();
  5376. });
  5377. }
  5378. }, {
  5379. key: "open",
  5380. value: function open() {
  5381. if (!this.opened) {
  5382. this.opened = true;
  5383. this.toggleButton.classList.add('toggled');
  5384. this.bar.classList.remove('hidden');
  5385. }
  5386. this.findField.select();
  5387. this.findField.focus();
  5388. this._adjustWidth();
  5389. }
  5390. }, {
  5391. key: "close",
  5392. value: function close() {
  5393. if (!this.opened) {
  5394. return;
  5395. }
  5396. this.opened = false;
  5397. this.toggleButton.classList.remove('toggled');
  5398. this.bar.classList.add('hidden');
  5399. this.eventBus.dispatch('findbarclose', {
  5400. source: this
  5401. });
  5402. }
  5403. }, {
  5404. key: "toggle",
  5405. value: function toggle() {
  5406. if (this.opened) {
  5407. this.close();
  5408. } else {
  5409. this.open();
  5410. }
  5411. }
  5412. }, {
  5413. key: "_adjustWidth",
  5414. value: function _adjustWidth() {
  5415. if (!this.opened) {
  5416. return;
  5417. }
  5418. this.bar.classList.remove('wrapContainers');
  5419. var findbarHeight = this.bar.clientHeight;
  5420. var inputContainerHeight = this.bar.firstElementChild.clientHeight;
  5421. if (findbarHeight > inputContainerHeight) {
  5422. this.bar.classList.add('wrapContainers');
  5423. }
  5424. }
  5425. }]);
  5426. return PDFFindBar;
  5427. }();
  5428. exports.PDFFindBar = PDFFindBar;
  5429. /***/ }),
  5430. /* 19 */
  5431. /***/ (function(module, exports, __webpack_require__) {
  5432. "use strict";
  5433. Object.defineProperty(exports, "__esModule", {
  5434. value: true
  5435. });
  5436. exports.PDFFindController = exports.FindState = void 0;
  5437. var _ui_utils = __webpack_require__(6);
  5438. var _pdfjsLib = __webpack_require__(7);
  5439. var _pdf_find_utils = __webpack_require__(20);
  5440. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5441. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  5442. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5443. var FindState = {
  5444. FOUND: 0,
  5445. NOT_FOUND: 1,
  5446. WRAPPED: 2,
  5447. PENDING: 3
  5448. };
  5449. exports.FindState = FindState;
  5450. var FIND_TIMEOUT = 250;
  5451. var MATCH_SCROLL_OFFSET_TOP = -50;
  5452. var MATCH_SCROLL_OFFSET_LEFT = -400;
  5453. var CHARACTERS_TO_NORMALIZE = {
  5454. "\u2018": '\'',
  5455. "\u2019": '\'',
  5456. "\u201A": '\'',
  5457. "\u201B": '\'',
  5458. "\u201C": '"',
  5459. "\u201D": '"',
  5460. "\u201E": '"',
  5461. "\u201F": '"',
  5462. "\xBC": '1/4',
  5463. "\xBD": '1/2',
  5464. "\xBE": '3/4'
  5465. };
  5466. var normalizationRegex = null;
  5467. function normalize(text) {
  5468. if (!normalizationRegex) {
  5469. var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join('');
  5470. normalizationRegex = new RegExp("[".concat(replace, "]"), 'g');
  5471. }
  5472. return text.replace(normalizationRegex, function (ch) {
  5473. return CHARACTERS_TO_NORMALIZE[ch];
  5474. });
  5475. }
  5476. var PDFFindController =
  5477. /*#__PURE__*/
  5478. function () {
  5479. function PDFFindController(_ref) {
  5480. var linkService = _ref.linkService,
  5481. _ref$eventBus = _ref.eventBus,
  5482. eventBus = _ref$eventBus === void 0 ? (0, _ui_utils.getGlobalEventBus)() : _ref$eventBus;
  5483. _classCallCheck(this, PDFFindController);
  5484. this._linkService = linkService;
  5485. this._eventBus = eventBus;
  5486. this._reset();
  5487. eventBus.on('findbarclose', this._onFindBarClose.bind(this));
  5488. }
  5489. _createClass(PDFFindController, [{
  5490. key: "setDocument",
  5491. value: function setDocument(pdfDocument) {
  5492. if (this._pdfDocument) {
  5493. this._reset();
  5494. }
  5495. if (!pdfDocument) {
  5496. return;
  5497. }
  5498. this._pdfDocument = pdfDocument;
  5499. this._firstPageCapability.resolve();
  5500. }
  5501. }, {
  5502. key: "executeCommand",
  5503. value: function executeCommand(cmd, state) {
  5504. var _this = this;
  5505. if (!state) {
  5506. return;
  5507. }
  5508. var pdfDocument = this._pdfDocument;
  5509. if (this._state === null || this._shouldDirtyMatch(cmd, state)) {
  5510. this._dirtyMatch = true;
  5511. }
  5512. this._state = state;
  5513. if (cmd !== 'findhighlightallchange') {
  5514. this._updateUIState(FindState.PENDING);
  5515. }
  5516. this._firstPageCapability.promise.then(function () {
  5517. if (!_this._pdfDocument || pdfDocument && _this._pdfDocument !== pdfDocument) {
  5518. return;
  5519. }
  5520. _this._extractText();
  5521. var findbarClosed = !_this._highlightMatches;
  5522. var pendingTimeout = !!_this._findTimeout;
  5523. if (_this._findTimeout) {
  5524. clearTimeout(_this._findTimeout);
  5525. _this._findTimeout = null;
  5526. }
  5527. if (cmd === 'find') {
  5528. _this._findTimeout = setTimeout(function () {
  5529. _this._nextMatch();
  5530. _this._findTimeout = null;
  5531. }, FIND_TIMEOUT);
  5532. } else if (_this._dirtyMatch) {
  5533. _this._nextMatch();
  5534. } else if (cmd === 'findagain') {
  5535. _this._nextMatch();
  5536. if (findbarClosed && _this._state.highlightAll) {
  5537. _this._updateAllPages();
  5538. }
  5539. } else if (cmd === 'findhighlightallchange') {
  5540. if (pendingTimeout) {
  5541. _this._nextMatch();
  5542. } else {
  5543. _this._highlightMatches = true;
  5544. }
  5545. _this._updateAllPages();
  5546. } else {
  5547. _this._nextMatch();
  5548. }
  5549. });
  5550. }
  5551. }, {
  5552. key: "scrollMatchIntoView",
  5553. value: function scrollMatchIntoView(_ref2) {
  5554. var _ref2$element = _ref2.element,
  5555. element = _ref2$element === void 0 ? null : _ref2$element,
  5556. _ref2$pageIndex = _ref2.pageIndex,
  5557. pageIndex = _ref2$pageIndex === void 0 ? -1 : _ref2$pageIndex,
  5558. _ref2$matchIndex = _ref2.matchIndex,
  5559. matchIndex = _ref2$matchIndex === void 0 ? -1 : _ref2$matchIndex;
  5560. if (!this._scrollMatches || !element) {
  5561. return;
  5562. } else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) {
  5563. return;
  5564. } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) {
  5565. return;
  5566. }
  5567. this._scrollMatches = false;
  5568. var spot = {
  5569. top: MATCH_SCROLL_OFFSET_TOP,
  5570. left: MATCH_SCROLL_OFFSET_LEFT
  5571. };
  5572. (0, _ui_utils.scrollIntoView)(element, spot, true);
  5573. }
  5574. }, {
  5575. key: "_reset",
  5576. value: function _reset() {
  5577. this._highlightMatches = false;
  5578. this._scrollMatches = false;
  5579. this._pdfDocument = null;
  5580. this._pageMatches = [];
  5581. this._pageMatchesLength = [];
  5582. this._state = null;
  5583. this._selected = {
  5584. pageIdx: -1,
  5585. matchIdx: -1
  5586. };
  5587. this._offset = {
  5588. pageIdx: null,
  5589. matchIdx: null,
  5590. wrapped: false
  5591. };
  5592. this._extractTextPromises = [];
  5593. this._pageContents = [];
  5594. this._matchesCountTotal = 0;
  5595. this._pagesToSearch = null;
  5596. this._pendingFindMatches = Object.create(null);
  5597. this._resumePageIdx = null;
  5598. this._dirtyMatch = false;
  5599. clearTimeout(this._findTimeout);
  5600. this._findTimeout = null;
  5601. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  5602. }
  5603. }, {
  5604. key: "_shouldDirtyMatch",
  5605. value: function _shouldDirtyMatch(cmd, state) {
  5606. if (state.query !== this._state.query) {
  5607. return true;
  5608. }
  5609. switch (cmd) {
  5610. case 'findagain':
  5611. var pageNumber = this._selected.pageIdx + 1;
  5612. var linkService = this._linkService;
  5613. if (pageNumber >= 1 && pageNumber <= linkService.pagesCount && linkService.page !== pageNumber && linkService.isPageVisible && !linkService.isPageVisible(pageNumber)) {
  5614. break;
  5615. }
  5616. return false;
  5617. case 'findhighlightallchange':
  5618. return false;
  5619. }
  5620. return true;
  5621. }
  5622. }, {
  5623. key: "_prepareMatches",
  5624. value: function _prepareMatches(matchesWithLength, matches, matchesLength) {
  5625. function isSubTerm(matchesWithLength, currentIndex) {
  5626. var currentElem = matchesWithLength[currentIndex];
  5627. var nextElem = matchesWithLength[currentIndex + 1];
  5628. if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {
  5629. currentElem.skipped = true;
  5630. return true;
  5631. }
  5632. for (var i = currentIndex - 1; i >= 0; i--) {
  5633. var prevElem = matchesWithLength[i];
  5634. if (prevElem.skipped) {
  5635. continue;
  5636. }
  5637. if (prevElem.match + prevElem.matchLength < currentElem.match) {
  5638. break;
  5639. }
  5640. if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {
  5641. currentElem.skipped = true;
  5642. return true;
  5643. }
  5644. }
  5645. return false;
  5646. }
  5647. matchesWithLength.sort(function (a, b) {
  5648. return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match;
  5649. });
  5650. for (var i = 0, len = matchesWithLength.length; i < len; i++) {
  5651. if (isSubTerm(matchesWithLength, i)) {
  5652. continue;
  5653. }
  5654. matches.push(matchesWithLength[i].match);
  5655. matchesLength.push(matchesWithLength[i].matchLength);
  5656. }
  5657. }
  5658. }, {
  5659. key: "_isEntireWord",
  5660. value: function _isEntireWord(content, startIdx, length) {
  5661. if (startIdx > 0) {
  5662. var first = content.charCodeAt(startIdx);
  5663. var limit = content.charCodeAt(startIdx - 1);
  5664. if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils.getCharacterType)(limit)) {
  5665. return false;
  5666. }
  5667. }
  5668. var endIdx = startIdx + length - 1;
  5669. if (endIdx < content.length - 1) {
  5670. var last = content.charCodeAt(endIdx);
  5671. var _limit = content.charCodeAt(endIdx + 1);
  5672. if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils.getCharacterType)(_limit)) {
  5673. return false;
  5674. }
  5675. }
  5676. return true;
  5677. }
  5678. }, {
  5679. key: "_calculatePhraseMatch",
  5680. value: function _calculatePhraseMatch(query, pageIndex, pageContent, entireWord) {
  5681. var matches = [];
  5682. var queryLen = query.length;
  5683. var matchIdx = -queryLen;
  5684. while (true) {
  5685. matchIdx = pageContent.indexOf(query, matchIdx + queryLen);
  5686. if (matchIdx === -1) {
  5687. break;
  5688. }
  5689. if (entireWord && !this._isEntireWord(pageContent, matchIdx, queryLen)) {
  5690. continue;
  5691. }
  5692. matches.push(matchIdx);
  5693. }
  5694. this._pageMatches[pageIndex] = matches;
  5695. }
  5696. }, {
  5697. key: "_calculateWordMatch",
  5698. value: function _calculateWordMatch(query, pageIndex, pageContent, entireWord) {
  5699. var matchesWithLength = [];
  5700. var queryArray = query.match(/\S+/g);
  5701. for (var i = 0, len = queryArray.length; i < len; i++) {
  5702. var subquery = queryArray[i];
  5703. var subqueryLen = subquery.length;
  5704. var matchIdx = -subqueryLen;
  5705. while (true) {
  5706. matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen);
  5707. if (matchIdx === -1) {
  5708. break;
  5709. }
  5710. if (entireWord && !this._isEntireWord(pageContent, matchIdx, subqueryLen)) {
  5711. continue;
  5712. }
  5713. matchesWithLength.push({
  5714. match: matchIdx,
  5715. matchLength: subqueryLen,
  5716. skipped: false
  5717. });
  5718. }
  5719. }
  5720. this._pageMatchesLength[pageIndex] = [];
  5721. this._pageMatches[pageIndex] = [];
  5722. this._prepareMatches(matchesWithLength, this._pageMatches[pageIndex], this._pageMatchesLength[pageIndex]);
  5723. }
  5724. }, {
  5725. key: "_calculateMatch",
  5726. value: function _calculateMatch(pageIndex) {
  5727. var pageContent = this._pageContents[pageIndex];
  5728. var query = this._query;
  5729. var _this$_state = this._state,
  5730. caseSensitive = _this$_state.caseSensitive,
  5731. entireWord = _this$_state.entireWord,
  5732. phraseSearch = _this$_state.phraseSearch;
  5733. if (query.length === 0) {
  5734. return;
  5735. }
  5736. if (!caseSensitive) {
  5737. pageContent = pageContent.toLowerCase();
  5738. query = query.toLowerCase();
  5739. }
  5740. if (phraseSearch) {
  5741. this._calculatePhraseMatch(query, pageIndex, pageContent, entireWord);
  5742. } else {
  5743. this._calculateWordMatch(query, pageIndex, pageContent, entireWord);
  5744. }
  5745. if (this._state.highlightAll) {
  5746. this._updatePage(pageIndex);
  5747. }
  5748. if (this._resumePageIdx === pageIndex) {
  5749. this._resumePageIdx = null;
  5750. this._nextPageMatch();
  5751. }
  5752. var pageMatchesCount = this._pageMatches[pageIndex].length;
  5753. if (pageMatchesCount > 0) {
  5754. this._matchesCountTotal += pageMatchesCount;
  5755. this._updateUIResultsCount();
  5756. }
  5757. }
  5758. }, {
  5759. key: "_extractText",
  5760. value: function _extractText() {
  5761. var _this2 = this;
  5762. if (this._extractTextPromises.length > 0) {
  5763. return;
  5764. }
  5765. var promise = Promise.resolve();
  5766. var _loop = function _loop(i, ii) {
  5767. var extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
  5768. _this2._extractTextPromises[i] = extractTextCapability.promise;
  5769. promise = promise.then(function () {
  5770. return _this2._pdfDocument.getPage(i + 1).then(function (pdfPage) {
  5771. return pdfPage.getTextContent({
  5772. normalizeWhitespace: true
  5773. });
  5774. }).then(function (textContent) {
  5775. var textItems = textContent.items;
  5776. var strBuf = [];
  5777. for (var j = 0, jj = textItems.length; j < jj; j++) {
  5778. strBuf.push(textItems[j].str);
  5779. }
  5780. _this2._pageContents[i] = normalize(strBuf.join(''));
  5781. extractTextCapability.resolve(i);
  5782. }, function (reason) {
  5783. console.error("Unable to get text content for page ".concat(i + 1), reason);
  5784. _this2._pageContents[i] = '';
  5785. extractTextCapability.resolve(i);
  5786. });
  5787. });
  5788. };
  5789. for (var i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
  5790. _loop(i, ii);
  5791. }
  5792. }
  5793. }, {
  5794. key: "_updatePage",
  5795. value: function _updatePage(index) {
  5796. if (this._scrollMatches && this._selected.pageIdx === index) {
  5797. this._linkService.page = index + 1;
  5798. }
  5799. this._eventBus.dispatch('updatetextlayermatches', {
  5800. source: this,
  5801. pageIndex: index
  5802. });
  5803. }
  5804. }, {
  5805. key: "_updateAllPages",
  5806. value: function _updateAllPages() {
  5807. this._eventBus.dispatch('updatetextlayermatches', {
  5808. source: this,
  5809. pageIndex: -1
  5810. });
  5811. }
  5812. }, {
  5813. key: "_nextMatch",
  5814. value: function _nextMatch() {
  5815. var _this3 = this;
  5816. var previous = this._state.findPrevious;
  5817. var currentPageIndex = this._linkService.page - 1;
  5818. var numPages = this._linkService.pagesCount;
  5819. this._highlightMatches = true;
  5820. if (this._dirtyMatch) {
  5821. this._dirtyMatch = false;
  5822. this._selected.pageIdx = this._selected.matchIdx = -1;
  5823. this._offset.pageIdx = currentPageIndex;
  5824. this._offset.matchIdx = null;
  5825. this._offset.wrapped = false;
  5826. this._resumePageIdx = null;
  5827. this._pageMatches.length = 0;
  5828. this._pageMatchesLength.length = 0;
  5829. this._matchesCountTotal = 0;
  5830. this._updateAllPages();
  5831. for (var i = 0; i < numPages; i++) {
  5832. if (this._pendingFindMatches[i] === true) {
  5833. continue;
  5834. }
  5835. this._pendingFindMatches[i] = true;
  5836. this._extractTextPromises[i].then(function (pageIdx) {
  5837. delete _this3._pendingFindMatches[pageIdx];
  5838. _this3._calculateMatch(pageIdx);
  5839. });
  5840. }
  5841. }
  5842. if (this._query === '') {
  5843. this._updateUIState(FindState.FOUND);
  5844. return;
  5845. }
  5846. if (this._resumePageIdx) {
  5847. return;
  5848. }
  5849. var offset = this._offset;
  5850. this._pagesToSearch = numPages;
  5851. if (offset.matchIdx !== null) {
  5852. var numPageMatches = this._pageMatches[offset.pageIdx].length;
  5853. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  5854. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  5855. this._updateMatch(true);
  5856. return;
  5857. }
  5858. this._advanceOffsetPage(previous);
  5859. }
  5860. this._nextPageMatch();
  5861. }
  5862. }, {
  5863. key: "_matchesReady",
  5864. value: function _matchesReady(matches) {
  5865. var offset = this._offset;
  5866. var numMatches = matches.length;
  5867. var previous = this._state.findPrevious;
  5868. if (numMatches) {
  5869. offset.matchIdx = previous ? numMatches - 1 : 0;
  5870. this._updateMatch(true);
  5871. return true;
  5872. }
  5873. this._advanceOffsetPage(previous);
  5874. if (offset.wrapped) {
  5875. offset.matchIdx = null;
  5876. if (this._pagesToSearch < 0) {
  5877. this._updateMatch(false);
  5878. return true;
  5879. }
  5880. }
  5881. return false;
  5882. }
  5883. }, {
  5884. key: "_nextPageMatch",
  5885. value: function _nextPageMatch() {
  5886. if (this._resumePageIdx !== null) {
  5887. console.error('There can only be one pending page.');
  5888. }
  5889. var matches = null;
  5890. do {
  5891. var pageIdx = this._offset.pageIdx;
  5892. matches = this._pageMatches[pageIdx];
  5893. if (!matches) {
  5894. this._resumePageIdx = pageIdx;
  5895. break;
  5896. }
  5897. } while (!this._matchesReady(matches));
  5898. }
  5899. }, {
  5900. key: "_advanceOffsetPage",
  5901. value: function _advanceOffsetPage(previous) {
  5902. var offset = this._offset;
  5903. var numPages = this._linkService.pagesCount;
  5904. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  5905. offset.matchIdx = null;
  5906. this._pagesToSearch--;
  5907. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  5908. offset.pageIdx = previous ? numPages - 1 : 0;
  5909. offset.wrapped = true;
  5910. }
  5911. }
  5912. }, {
  5913. key: "_updateMatch",
  5914. value: function _updateMatch() {
  5915. var found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5916. var state = FindState.NOT_FOUND;
  5917. var wrapped = this._offset.wrapped;
  5918. this._offset.wrapped = false;
  5919. if (found) {
  5920. var previousPage = this._selected.pageIdx;
  5921. this._selected.pageIdx = this._offset.pageIdx;
  5922. this._selected.matchIdx = this._offset.matchIdx;
  5923. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  5924. if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {
  5925. this._updatePage(previousPage);
  5926. }
  5927. }
  5928. this._updateUIState(state, this._state.findPrevious);
  5929. if (this._selected.pageIdx !== -1) {
  5930. this._scrollMatches = true;
  5931. this._updatePage(this._selected.pageIdx);
  5932. }
  5933. }
  5934. }, {
  5935. key: "_onFindBarClose",
  5936. value: function _onFindBarClose(evt) {
  5937. var _this4 = this;
  5938. var pdfDocument = this._pdfDocument;
  5939. this._firstPageCapability.promise.then(function () {
  5940. if (!_this4._pdfDocument || pdfDocument && _this4._pdfDocument !== pdfDocument) {
  5941. return;
  5942. }
  5943. if (_this4._findTimeout) {
  5944. clearTimeout(_this4._findTimeout);
  5945. _this4._findTimeout = null;
  5946. }
  5947. if (_this4._resumePageIdx) {
  5948. _this4._resumePageIdx = null;
  5949. _this4._dirtyMatch = true;
  5950. }
  5951. _this4._updateUIState(FindState.FOUND);
  5952. _this4._highlightMatches = false;
  5953. _this4._updateAllPages();
  5954. });
  5955. }
  5956. }, {
  5957. key: "_requestMatchesCount",
  5958. value: function _requestMatchesCount() {
  5959. var _this$_selected = this._selected,
  5960. pageIdx = _this$_selected.pageIdx,
  5961. matchIdx = _this$_selected.matchIdx;
  5962. var current = 0,
  5963. total = this._matchesCountTotal;
  5964. if (matchIdx !== -1) {
  5965. for (var i = 0; i < pageIdx; i++) {
  5966. current += this._pageMatches[i] && this._pageMatches[i].length || 0;
  5967. }
  5968. current += matchIdx + 1;
  5969. }
  5970. if (current < 1 || current > total) {
  5971. current = total = 0;
  5972. }
  5973. return {
  5974. current: current,
  5975. total: total
  5976. };
  5977. }
  5978. }, {
  5979. key: "_updateUIResultsCount",
  5980. value: function _updateUIResultsCount() {
  5981. this._eventBus.dispatch('updatefindmatchescount', {
  5982. source: this,
  5983. matchesCount: this._requestMatchesCount()
  5984. });
  5985. }
  5986. }, {
  5987. key: "_updateUIState",
  5988. value: function _updateUIState(state, previous) {
  5989. this._eventBus.dispatch('updatefindcontrolstate', {
  5990. source: this,
  5991. state: state,
  5992. previous: previous,
  5993. matchesCount: this._requestMatchesCount()
  5994. });
  5995. }
  5996. }, {
  5997. key: "highlightMatches",
  5998. get: function get() {
  5999. return this._highlightMatches;
  6000. }
  6001. }, {
  6002. key: "pageMatches",
  6003. get: function get() {
  6004. return this._pageMatches;
  6005. }
  6006. }, {
  6007. key: "pageMatchesLength",
  6008. get: function get() {
  6009. return this._pageMatchesLength;
  6010. }
  6011. }, {
  6012. key: "selected",
  6013. get: function get() {
  6014. return this._selected;
  6015. }
  6016. }, {
  6017. key: "state",
  6018. get: function get() {
  6019. return this._state;
  6020. }
  6021. }, {
  6022. key: "_query",
  6023. get: function get() {
  6024. if (this._state.query !== this._rawQuery) {
  6025. this._rawQuery = this._state.query;
  6026. this._normalizedQuery = normalize(this._state.query);
  6027. }
  6028. return this._normalizedQuery;
  6029. }
  6030. }]);
  6031. return PDFFindController;
  6032. }();
  6033. exports.PDFFindController = PDFFindController;
  6034. /***/ }),
  6035. /* 20 */
  6036. /***/ (function(module, exports, __webpack_require__) {
  6037. "use strict";
  6038. Object.defineProperty(exports, "__esModule", {
  6039. value: true
  6040. });
  6041. exports.getCharacterType = getCharacterType;
  6042. exports.CharacterType = void 0;
  6043. var CharacterType = {
  6044. SPACE: 0,
  6045. ALPHA_LETTER: 1,
  6046. PUNCT: 2,
  6047. HAN_LETTER: 3,
  6048. KATAKANA_LETTER: 4,
  6049. HIRAGANA_LETTER: 5,
  6050. HALFWIDTH_KATAKANA_LETTER: 6,
  6051. THAI_LETTER: 7
  6052. };
  6053. exports.CharacterType = CharacterType;
  6054. function isAlphabeticalScript(charCode) {
  6055. return charCode < 0x2E80;
  6056. }
  6057. function isAscii(charCode) {
  6058. return (charCode & 0xFF80) === 0;
  6059. }
  6060. function isAsciiAlpha(charCode) {
  6061. return charCode >= 0x61 && charCode <= 0x7A || charCode >= 0x41 && charCode <= 0x5A;
  6062. }
  6063. function isAsciiDigit(charCode) {
  6064. return charCode >= 0x30 && charCode <= 0x39;
  6065. }
  6066. function isAsciiSpace(charCode) {
  6067. return charCode === 0x20 || charCode === 0x09 || charCode === 0x0D || charCode === 0x0A;
  6068. }
  6069. function isHan(charCode) {
  6070. return charCode >= 0x3400 && charCode <= 0x9FFF || charCode >= 0xF900 && charCode <= 0xFAFF;
  6071. }
  6072. function isKatakana(charCode) {
  6073. return charCode >= 0x30A0 && charCode <= 0x30FF;
  6074. }
  6075. function isHiragana(charCode) {
  6076. return charCode >= 0x3040 && charCode <= 0x309F;
  6077. }
  6078. function isHalfwidthKatakana(charCode) {
  6079. return charCode >= 0xFF60 && charCode <= 0xFF9F;
  6080. }
  6081. function isThai(charCode) {
  6082. return (charCode & 0xFF80) === 0x0E00;
  6083. }
  6084. function getCharacterType(charCode) {
  6085. if (isAlphabeticalScript(charCode)) {
  6086. if (isAscii(charCode)) {
  6087. if (isAsciiSpace(charCode)) {
  6088. return CharacterType.SPACE;
  6089. } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5F) {
  6090. return CharacterType.ALPHA_LETTER;
  6091. }
  6092. return CharacterType.PUNCT;
  6093. } else if (isThai(charCode)) {
  6094. return CharacterType.THAI_LETTER;
  6095. } else if (charCode === 0xA0) {
  6096. return CharacterType.SPACE;
  6097. }
  6098. return CharacterType.ALPHA_LETTER;
  6099. }
  6100. if (isHan(charCode)) {
  6101. return CharacterType.HAN_LETTER;
  6102. } else if (isKatakana(charCode)) {
  6103. return CharacterType.KATAKANA_LETTER;
  6104. } else if (isHiragana(charCode)) {
  6105. return CharacterType.HIRAGANA_LETTER;
  6106. } else if (isHalfwidthKatakana(charCode)) {
  6107. return CharacterType.HALFWIDTH_KATAKANA_LETTER;
  6108. }
  6109. return CharacterType.ALPHA_LETTER;
  6110. }
  6111. /***/ }),
  6112. /* 21 */
  6113. /***/ (function(module, exports, __webpack_require__) {
  6114. "use strict";
  6115. Object.defineProperty(exports, "__esModule", {
  6116. value: true
  6117. });
  6118. exports.isDestHashesEqual = isDestHashesEqual;
  6119. exports.isDestArraysEqual = isDestArraysEqual;
  6120. exports.PDFHistory = void 0;
  6121. var _ui_utils = __webpack_require__(6);
  6122. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  6123. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
  6124. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
  6125. function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  6126. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  6127. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6128. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  6129. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6130. var HASH_CHANGE_TIMEOUT = 1000;
  6131. var POSITION_UPDATED_THRESHOLD = 50;
  6132. var UPDATE_VIEWAREA_TIMEOUT = 1000;
  6133. function getCurrentHash() {
  6134. return document.location.hash;
  6135. }
  6136. function parseCurrentHash(linkService) {
  6137. var hash = unescape(getCurrentHash()).substring(1);
  6138. var params = (0, _ui_utils.parseQueryString)(hash);
  6139. var page = params.page | 0;
  6140. if (!(Number.isInteger(page) && page > 0 && page <= linkService.pagesCount)) {
  6141. page = null;
  6142. }
  6143. return {
  6144. hash: hash,
  6145. page: page,
  6146. rotation: linkService.rotation
  6147. };
  6148. }
  6149. var PDFHistory =
  6150. /*#__PURE__*/
  6151. function () {
  6152. function PDFHistory(_ref) {
  6153. var _this = this;
  6154. var linkService = _ref.linkService,
  6155. eventBus = _ref.eventBus;
  6156. _classCallCheck(this, PDFHistory);
  6157. this.linkService = linkService;
  6158. this.eventBus = eventBus || (0, _ui_utils.getGlobalEventBus)();
  6159. this.initialized = false;
  6160. this.initialBookmark = null;
  6161. this.initialRotation = null;
  6162. this._boundEvents = Object.create(null);
  6163. this._isViewerInPresentationMode = false;
  6164. this._isPagesLoaded = false;
  6165. this.eventBus.on('presentationmodechanged', function (evt) {
  6166. _this._isViewerInPresentationMode = evt.active || evt.switchInProgress;
  6167. });
  6168. this.eventBus.on('pagesloaded', function (evt) {
  6169. _this._isPagesLoaded = !!evt.pagesCount;
  6170. });
  6171. }
  6172. _createClass(PDFHistory, [{
  6173. key: "initialize",
  6174. value: function initialize(_ref2) {
  6175. var fingerprint = _ref2.fingerprint,
  6176. _ref2$resetHistory = _ref2.resetHistory,
  6177. resetHistory = _ref2$resetHistory === void 0 ? false : _ref2$resetHistory,
  6178. _ref2$updateUrl = _ref2.updateUrl,
  6179. updateUrl = _ref2$updateUrl === void 0 ? false : _ref2$updateUrl;
  6180. if (!fingerprint || typeof fingerprint !== 'string') {
  6181. console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
  6182. return;
  6183. }
  6184. var reInitialized = this.initialized && this.fingerprint !== fingerprint;
  6185. this.fingerprint = fingerprint;
  6186. this._updateUrl = updateUrl === true;
  6187. if (!this.initialized) {
  6188. this._bindEvents();
  6189. }
  6190. var state = window.history.state;
  6191. this.initialized = true;
  6192. this.initialBookmark = null;
  6193. this.initialRotation = null;
  6194. this._popStateInProgress = false;
  6195. this._blockHashChange = 0;
  6196. this._currentHash = getCurrentHash();
  6197. this._numPositionUpdates = 0;
  6198. this._uid = this._maxUid = 0;
  6199. this._destination = null;
  6200. this._position = null;
  6201. if (!this._isValidState(state, true) || resetHistory) {
  6202. var _parseCurrentHash = parseCurrentHash(this.linkService),
  6203. hash = _parseCurrentHash.hash,
  6204. page = _parseCurrentHash.page,
  6205. rotation = _parseCurrentHash.rotation;
  6206. if (!hash || reInitialized || resetHistory) {
  6207. this._pushOrReplaceState(null, true);
  6208. return;
  6209. }
  6210. this._pushOrReplaceState({
  6211. hash: hash,
  6212. page: page,
  6213. rotation: rotation
  6214. }, true);
  6215. return;
  6216. }
  6217. var destination = state.destination;
  6218. this._updateInternalState(destination, state.uid, true);
  6219. if (this._uid > this._maxUid) {
  6220. this._maxUid = this._uid;
  6221. }
  6222. if (destination.rotation !== undefined) {
  6223. this.initialRotation = destination.rotation;
  6224. }
  6225. if (destination.dest) {
  6226. this.initialBookmark = JSON.stringify(destination.dest);
  6227. this._destination.page = null;
  6228. } else if (destination.hash) {
  6229. this.initialBookmark = destination.hash;
  6230. } else if (destination.page) {
  6231. this.initialBookmark = "page=".concat(destination.page);
  6232. }
  6233. }
  6234. }, {
  6235. key: "push",
  6236. value: function push(_ref3) {
  6237. var _this2 = this;
  6238. var _ref3$namedDest = _ref3.namedDest,
  6239. namedDest = _ref3$namedDest === void 0 ? null : _ref3$namedDest,
  6240. explicitDest = _ref3.explicitDest,
  6241. pageNumber = _ref3.pageNumber;
  6242. if (!this.initialized) {
  6243. return;
  6244. }
  6245. if (namedDest && typeof namedDest !== 'string') {
  6246. console.error('PDFHistory.push: ' + "\"".concat(namedDest, "\" is not a valid namedDest parameter."));
  6247. return;
  6248. } else if (!Array.isArray(explicitDest)) {
  6249. console.error('PDFHistory.push: ' + "\"".concat(explicitDest, "\" is not a valid explicitDest parameter."));
  6250. return;
  6251. } else if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {
  6252. if (pageNumber !== null || this._destination) {
  6253. console.error('PDFHistory.push: ' + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  6254. return;
  6255. }
  6256. }
  6257. var hash = namedDest || JSON.stringify(explicitDest);
  6258. if (!hash) {
  6259. return;
  6260. }
  6261. var forceReplace = false;
  6262. if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
  6263. if (this._destination.page) {
  6264. return;
  6265. }
  6266. forceReplace = true;
  6267. }
  6268. if (this._popStateInProgress && !forceReplace) {
  6269. return;
  6270. }
  6271. this._pushOrReplaceState({
  6272. dest: explicitDest,
  6273. hash: hash,
  6274. page: pageNumber,
  6275. rotation: this.linkService.rotation
  6276. }, forceReplace);
  6277. if (!this._popStateInProgress) {
  6278. this._popStateInProgress = true;
  6279. Promise.resolve().then(function () {
  6280. _this2._popStateInProgress = false;
  6281. });
  6282. }
  6283. }
  6284. }, {
  6285. key: "pushCurrentPosition",
  6286. value: function pushCurrentPosition() {
  6287. if (!this.initialized || this._popStateInProgress) {
  6288. return;
  6289. }
  6290. this._tryPushCurrentPosition();
  6291. }
  6292. }, {
  6293. key: "back",
  6294. value: function back() {
  6295. if (!this.initialized || this._popStateInProgress) {
  6296. return;
  6297. }
  6298. var state = window.history.state;
  6299. if (this._isValidState(state) && state.uid > 0) {
  6300. window.history.back();
  6301. }
  6302. }
  6303. }, {
  6304. key: "forward",
  6305. value: function forward() {
  6306. if (!this.initialized || this._popStateInProgress) {
  6307. return;
  6308. }
  6309. var state = window.history.state;
  6310. if (this._isValidState(state) && state.uid < this._maxUid) {
  6311. window.history.forward();
  6312. }
  6313. }
  6314. }, {
  6315. key: "_pushOrReplaceState",
  6316. value: function _pushOrReplaceState(destination) {
  6317. var forceReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6318. var shouldReplace = forceReplace || !this._destination;
  6319. var newState = {
  6320. fingerprint: this.fingerprint,
  6321. uid: shouldReplace ? this._uid : this._uid + 1,
  6322. destination: destination
  6323. };
  6324. this._updateInternalState(destination, newState.uid);
  6325. var newUrl;
  6326. if (this._updateUrl && destination && destination.hash) {
  6327. var baseUrl = document.location.href.split('#')[0];
  6328. if (!baseUrl.startsWith('file://')) {
  6329. newUrl = "".concat(baseUrl, "#").concat(destination.hash);
  6330. }
  6331. }
  6332. if (shouldReplace) {
  6333. if (newUrl) {
  6334. window.history.replaceState(newState, '', newUrl);
  6335. } else {
  6336. window.history.replaceState(newState, '');
  6337. }
  6338. } else {
  6339. this._maxUid = this._uid;
  6340. if (newUrl) {
  6341. window.history.pushState(newState, '', newUrl);
  6342. } else {
  6343. window.history.pushState(newState, '');
  6344. }
  6345. }
  6346. }
  6347. }, {
  6348. key: "_tryPushCurrentPosition",
  6349. value: function _tryPushCurrentPosition() {
  6350. var temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6351. if (!this._position) {
  6352. return;
  6353. }
  6354. var position = this._position;
  6355. if (temporary) {
  6356. position = Object.assign(Object.create(null), this._position);
  6357. position.temporary = true;
  6358. }
  6359. if (!this._destination) {
  6360. this._pushOrReplaceState(position);
  6361. return;
  6362. }
  6363. if (this._destination.temporary) {
  6364. this._pushOrReplaceState(position, true);
  6365. return;
  6366. }
  6367. if (this._destination.hash === position.hash) {
  6368. return;
  6369. }
  6370. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  6371. return;
  6372. }
  6373. var forceReplace = false;
  6374. if (this._destination.page >= position.first && this._destination.page <= position.page) {
  6375. if (this._destination.dest || !this._destination.first) {
  6376. return;
  6377. }
  6378. forceReplace = true;
  6379. }
  6380. this._pushOrReplaceState(position, forceReplace);
  6381. }
  6382. }, {
  6383. key: "_isValidState",
  6384. value: function _isValidState(state) {
  6385. var checkReload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6386. if (!state) {
  6387. return false;
  6388. }
  6389. if (state.fingerprint !== this.fingerprint) {
  6390. if (checkReload) {
  6391. if (typeof state.fingerprint !== 'string' || state.fingerprint.length !== this.fingerprint.length) {
  6392. return false;
  6393. }
  6394. var _performance$getEntri = performance.getEntriesByType('navigation'),
  6395. _performance$getEntri2 = _slicedToArray(_performance$getEntri, 1),
  6396. perfEntry = _performance$getEntri2[0];
  6397. if (!perfEntry || perfEntry.type !== 'reload') {
  6398. return false;
  6399. }
  6400. } else {
  6401. return false;
  6402. }
  6403. }
  6404. if (!Number.isInteger(state.uid) || state.uid < 0) {
  6405. return false;
  6406. }
  6407. if (state.destination === null || _typeof(state.destination) !== 'object') {
  6408. return false;
  6409. }
  6410. return true;
  6411. }
  6412. }, {
  6413. key: "_updateInternalState",
  6414. value: function _updateInternalState(destination, uid) {
  6415. var removeTemporary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  6416. if (this._updateViewareaTimeout) {
  6417. clearTimeout(this._updateViewareaTimeout);
  6418. this._updateViewareaTimeout = null;
  6419. }
  6420. if (removeTemporary && destination && destination.temporary) {
  6421. delete destination.temporary;
  6422. }
  6423. this._destination = destination;
  6424. this._uid = uid;
  6425. this._numPositionUpdates = 0;
  6426. }
  6427. }, {
  6428. key: "_updateViewarea",
  6429. value: function _updateViewarea(_ref4) {
  6430. var _this3 = this;
  6431. var location = _ref4.location;
  6432. if (this._updateViewareaTimeout) {
  6433. clearTimeout(this._updateViewareaTimeout);
  6434. this._updateViewareaTimeout = null;
  6435. }
  6436. this._position = {
  6437. hash: this._isViewerInPresentationMode ? "page=".concat(location.pageNumber) : location.pdfOpenParams.substring(1),
  6438. page: this.linkService.page,
  6439. first: location.pageNumber,
  6440. rotation: location.rotation
  6441. };
  6442. if (this._popStateInProgress) {
  6443. return;
  6444. }
  6445. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
  6446. this._numPositionUpdates++;
  6447. }
  6448. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  6449. this._updateViewareaTimeout = setTimeout(function () {
  6450. if (!_this3._popStateInProgress) {
  6451. _this3._tryPushCurrentPosition(true);
  6452. }
  6453. _this3._updateViewareaTimeout = null;
  6454. }, UPDATE_VIEWAREA_TIMEOUT);
  6455. }
  6456. }
  6457. }, {
  6458. key: "_popState",
  6459. value: function _popState(_ref5) {
  6460. var _this4 = this;
  6461. var state = _ref5.state;
  6462. var newHash = getCurrentHash(),
  6463. hashChanged = this._currentHash !== newHash;
  6464. this._currentHash = newHash;
  6465. if (!state || false) {
  6466. this._uid++;
  6467. var _parseCurrentHash2 = parseCurrentHash(this.linkService),
  6468. hash = _parseCurrentHash2.hash,
  6469. page = _parseCurrentHash2.page,
  6470. rotation = _parseCurrentHash2.rotation;
  6471. this._pushOrReplaceState({
  6472. hash: hash,
  6473. page: page,
  6474. rotation: rotation
  6475. }, true);
  6476. return;
  6477. }
  6478. if (!this._isValidState(state)) {
  6479. return;
  6480. }
  6481. this._popStateInProgress = true;
  6482. if (hashChanged) {
  6483. this._blockHashChange++;
  6484. (0, _ui_utils.waitOnEventOrTimeout)({
  6485. target: window,
  6486. name: 'hashchange',
  6487. delay: HASH_CHANGE_TIMEOUT
  6488. }).then(function () {
  6489. _this4._blockHashChange--;
  6490. });
  6491. }
  6492. var destination = state.destination;
  6493. this._updateInternalState(destination, state.uid, true);
  6494. if (this._uid > this._maxUid) {
  6495. this._maxUid = this._uid;
  6496. }
  6497. if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
  6498. this.linkService.rotation = destination.rotation;
  6499. }
  6500. if (destination.dest) {
  6501. this.linkService.navigateTo(destination.dest);
  6502. } else if (destination.hash) {
  6503. this.linkService.setHash(destination.hash);
  6504. } else if (destination.page) {
  6505. this.linkService.page = destination.page;
  6506. }
  6507. Promise.resolve().then(function () {
  6508. _this4._popStateInProgress = false;
  6509. });
  6510. }
  6511. }, {
  6512. key: "_bindEvents",
  6513. value: function _bindEvents() {
  6514. var _this5 = this;
  6515. var _boundEvents = this._boundEvents,
  6516. eventBus = this.eventBus;
  6517. _boundEvents.updateViewarea = this._updateViewarea.bind(this);
  6518. _boundEvents.popState = this._popState.bind(this);
  6519. _boundEvents.pageHide = function (evt) {
  6520. if (!_this5._destination || _this5._destination.temporary) {
  6521. _this5._tryPushCurrentPosition();
  6522. }
  6523. };
  6524. eventBus.on('updateviewarea', _boundEvents.updateViewarea);
  6525. window.addEventListener('popstate', _boundEvents.popState);
  6526. window.addEventListener('pagehide', _boundEvents.pageHide);
  6527. }
  6528. }, {
  6529. key: "popStateInProgress",
  6530. get: function get() {
  6531. return this.initialized && (this._popStateInProgress || this._blockHashChange > 0);
  6532. }
  6533. }]);
  6534. return PDFHistory;
  6535. }();
  6536. exports.PDFHistory = PDFHistory;
  6537. function isDestHashesEqual(destHash, pushHash) {
  6538. if (typeof destHash !== 'string' || typeof pushHash !== 'string') {
  6539. return false;
  6540. }
  6541. if (destHash === pushHash) {
  6542. return true;
  6543. }
  6544. var _parseQueryString = (0, _ui_utils.parseQueryString)(destHash),
  6545. nameddest = _parseQueryString.nameddest;
  6546. if (nameddest === pushHash) {
  6547. return true;
  6548. }
  6549. return false;
  6550. }
  6551. function isDestArraysEqual(firstDest, secondDest) {
  6552. function isEntryEqual(first, second) {
  6553. if (_typeof(first) !== _typeof(second)) {
  6554. return false;
  6555. }
  6556. if (Array.isArray(first) || Array.isArray(second)) {
  6557. return false;
  6558. }
  6559. if (first !== null && _typeof(first) === 'object' && second !== null) {
  6560. if (Object.keys(first).length !== Object.keys(second).length) {
  6561. return false;
  6562. }
  6563. for (var key in first) {
  6564. if (!isEntryEqual(first[key], second[key])) {
  6565. return false;
  6566. }
  6567. }
  6568. return true;
  6569. }
  6570. return first === second || Number.isNaN(first) && Number.isNaN(second);
  6571. }
  6572. if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
  6573. return false;
  6574. }
  6575. if (firstDest.length !== secondDest.length) {
  6576. return false;
  6577. }
  6578. for (var i = 0, ii = firstDest.length; i < ii; i++) {
  6579. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  6580. return false;
  6581. }
  6582. }
  6583. return true;
  6584. }
  6585. /***/ }),
  6586. /* 22 */
  6587. /***/ (function(module, exports, __webpack_require__) {
  6588. "use strict";
  6589. Object.defineProperty(exports, "__esModule", {
  6590. value: true
  6591. });
  6592. exports.SimpleLinkService = exports.PDFLinkService = void 0;
  6593. var _ui_utils = __webpack_require__(6);
  6594. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  6595. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6596. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  6597. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6598. var PDFLinkService =
  6599. /*#__PURE__*/
  6600. function () {
  6601. function PDFLinkService() {
  6602. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  6603. eventBus = _ref.eventBus,
  6604. _ref$externalLinkTarg = _ref.externalLinkTarget,
  6605. externalLinkTarget = _ref$externalLinkTarg === void 0 ? null : _ref$externalLinkTarg,
  6606. _ref$externalLinkRel = _ref.externalLinkRel,
  6607. externalLinkRel = _ref$externalLinkRel === void 0 ? null : _ref$externalLinkRel;
  6608. _classCallCheck(this, PDFLinkService);
  6609. this.eventBus = eventBus || (0, _ui_utils.getGlobalEventBus)();
  6610. this.externalLinkTarget = externalLinkTarget;
  6611. this.externalLinkRel = externalLinkRel;
  6612. this.baseUrl = null;
  6613. this.pdfDocument = null;
  6614. this.pdfViewer = null;
  6615. this.pdfHistory = null;
  6616. this._pagesRefCache = null;
  6617. }
  6618. _createClass(PDFLinkService, [{
  6619. key: "setDocument",
  6620. value: function setDocument(pdfDocument) {
  6621. var baseUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  6622. this.baseUrl = baseUrl;
  6623. this.pdfDocument = pdfDocument;
  6624. this._pagesRefCache = Object.create(null);
  6625. }
  6626. }, {
  6627. key: "setViewer",
  6628. value: function setViewer(pdfViewer) {
  6629. this.pdfViewer = pdfViewer;
  6630. }
  6631. }, {
  6632. key: "setHistory",
  6633. value: function setHistory(pdfHistory) {
  6634. this.pdfHistory = pdfHistory;
  6635. }
  6636. }, {
  6637. key: "navigateTo",
  6638. value: function navigateTo(dest) {
  6639. var _this = this;
  6640. var goToDestination = function goToDestination(_ref2) {
  6641. var namedDest = _ref2.namedDest,
  6642. explicitDest = _ref2.explicitDest;
  6643. var destRef = explicitDest[0],
  6644. pageNumber;
  6645. if (destRef instanceof Object) {
  6646. pageNumber = _this._cachedPageNumber(destRef);
  6647. if (pageNumber === null) {
  6648. _this.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
  6649. _this.cachePageRef(pageIndex + 1, destRef);
  6650. goToDestination({
  6651. namedDest: namedDest,
  6652. explicitDest: explicitDest
  6653. });
  6654. }).catch(function () {
  6655. console.error("PDFLinkService.navigateTo: \"".concat(destRef, "\" is not ") + "a valid page reference, for dest=\"".concat(dest, "\"."));
  6656. });
  6657. return;
  6658. }
  6659. } else if (Number.isInteger(destRef)) {
  6660. pageNumber = destRef + 1;
  6661. } else {
  6662. console.error("PDFLinkService.navigateTo: \"".concat(destRef, "\" is not ") + "a valid destination reference, for dest=\"".concat(dest, "\"."));
  6663. return;
  6664. }
  6665. if (!pageNumber || pageNumber < 1 || pageNumber > _this.pagesCount) {
  6666. console.error("PDFLinkService.navigateTo: \"".concat(pageNumber, "\" is not ") + "a valid page number, for dest=\"".concat(dest, "\"."));
  6667. return;
  6668. }
  6669. if (_this.pdfHistory) {
  6670. _this.pdfHistory.pushCurrentPosition();
  6671. _this.pdfHistory.push({
  6672. namedDest: namedDest,
  6673. explicitDest: explicitDest,
  6674. pageNumber: pageNumber
  6675. });
  6676. }
  6677. _this.pdfViewer.scrollPageIntoView({
  6678. pageNumber: pageNumber,
  6679. destArray: explicitDest
  6680. });
  6681. };
  6682. new Promise(function (resolve, reject) {
  6683. if (typeof dest === 'string') {
  6684. _this.pdfDocument.getDestination(dest).then(function (destArray) {
  6685. resolve({
  6686. namedDest: dest,
  6687. explicitDest: destArray
  6688. });
  6689. });
  6690. return;
  6691. }
  6692. resolve({
  6693. namedDest: '',
  6694. explicitDest: dest
  6695. });
  6696. }).then(function (data) {
  6697. if (!Array.isArray(data.explicitDest)) {
  6698. console.error("PDFLinkService.navigateTo: \"".concat(data.explicitDest, "\" is") + " not a valid destination array, for dest=\"".concat(dest, "\"."));
  6699. return;
  6700. }
  6701. goToDestination(data);
  6702. });
  6703. }
  6704. }, {
  6705. key: "getDestinationHash",
  6706. value: function getDestinationHash(dest) {
  6707. if (typeof dest === 'string') {
  6708. return this.getAnchorUrl('#' + escape(dest));
  6709. }
  6710. if (Array.isArray(dest)) {
  6711. var str = JSON.stringify(dest);
  6712. return this.getAnchorUrl('#' + escape(str));
  6713. }
  6714. return this.getAnchorUrl('');
  6715. }
  6716. }, {
  6717. key: "getAnchorUrl",
  6718. value: function getAnchorUrl(anchor) {
  6719. return (this.baseUrl || '') + anchor;
  6720. }
  6721. }, {
  6722. key: "setHash",
  6723. value: function setHash(hash) {
  6724. var pageNumber, dest;
  6725. if (hash.includes('=')) {
  6726. var params = (0, _ui_utils.parseQueryString)(hash);
  6727. if ('search' in params) {
  6728. this.eventBus.dispatch('findfromurlhash', {
  6729. source: this,
  6730. query: params['search'].replace(/"/g, ''),
  6731. phraseSearch: params['phrase'] === 'true'
  6732. });
  6733. }
  6734. if ('nameddest' in params) {
  6735. this.navigateTo(params.nameddest);
  6736. return;
  6737. }
  6738. if ('page' in params) {
  6739. pageNumber = params.page | 0 || 1;
  6740. }
  6741. if ('zoom' in params) {
  6742. var zoomArgs = params.zoom.split(',');
  6743. var zoomArg = zoomArgs[0];
  6744. var zoomArgNumber = parseFloat(zoomArg);
  6745. if (!zoomArg.includes('Fit')) {
  6746. dest = [null, {
  6747. name: 'XYZ'
  6748. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
  6749. } else {
  6750. if (zoomArg === 'Fit' || zoomArg === 'FitB') {
  6751. dest = [null, {
  6752. name: zoomArg
  6753. }];
  6754. } else if (zoomArg === 'FitH' || zoomArg === 'FitBH' || zoomArg === 'FitV' || zoomArg === 'FitBV') {
  6755. dest = [null, {
  6756. name: zoomArg
  6757. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  6758. } else if (zoomArg === 'FitR') {
  6759. if (zoomArgs.length !== 5) {
  6760. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
  6761. } else {
  6762. dest = [null, {
  6763. name: zoomArg
  6764. }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
  6765. }
  6766. } else {
  6767. console.error("PDFLinkService.setHash: \"".concat(zoomArg, "\" is not ") + 'a valid zoom value.');
  6768. }
  6769. }
  6770. }
  6771. if (dest) {
  6772. this.pdfViewer.scrollPageIntoView({
  6773. pageNumber: pageNumber || this.page,
  6774. destArray: dest,
  6775. allowNegativeOffset: true
  6776. });
  6777. } else if (pageNumber) {
  6778. this.page = pageNumber;
  6779. }
  6780. if ('pagemode' in params) {
  6781. this.eventBus.dispatch('pagemode', {
  6782. source: this,
  6783. mode: params.pagemode
  6784. });
  6785. }
  6786. } else {
  6787. dest = unescape(hash);
  6788. try {
  6789. dest = JSON.parse(dest);
  6790. if (!Array.isArray(dest)) {
  6791. dest = dest.toString();
  6792. }
  6793. } catch (ex) {}
  6794. if (typeof dest === 'string' || isValidExplicitDestination(dest)) {
  6795. this.navigateTo(dest);
  6796. return;
  6797. }
  6798. console.error("PDFLinkService.setHash: \"".concat(unescape(hash), "\" is not ") + 'a valid destination.');
  6799. }
  6800. }
  6801. }, {
  6802. key: "executeNamedAction",
  6803. value: function executeNamedAction(action) {
  6804. switch (action) {
  6805. case 'GoBack':
  6806. if (this.pdfHistory) {
  6807. this.pdfHistory.back();
  6808. }
  6809. break;
  6810. case 'GoForward':
  6811. if (this.pdfHistory) {
  6812. this.pdfHistory.forward();
  6813. }
  6814. break;
  6815. case 'NextPage':
  6816. if (this.page < this.pagesCount) {
  6817. this.page++;
  6818. }
  6819. break;
  6820. case 'PrevPage':
  6821. if (this.page > 1) {
  6822. this.page--;
  6823. }
  6824. break;
  6825. case 'LastPage':
  6826. this.page = this.pagesCount;
  6827. break;
  6828. case 'FirstPage':
  6829. this.page = 1;
  6830. break;
  6831. default:
  6832. break;
  6833. }
  6834. this.eventBus.dispatch('namedaction', {
  6835. source: this,
  6836. action: action
  6837. });
  6838. }
  6839. }, {
  6840. key: "cachePageRef",
  6841. value: function cachePageRef(pageNum, pageRef) {
  6842. if (!pageRef) {
  6843. return;
  6844. }
  6845. var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
  6846. this._pagesRefCache[refStr] = pageNum;
  6847. }
  6848. }, {
  6849. key: "_cachedPageNumber",
  6850. value: function _cachedPageNumber(pageRef) {
  6851. var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
  6852. return this._pagesRefCache && this._pagesRefCache[refStr] || null;
  6853. }
  6854. }, {
  6855. key: "isPageVisible",
  6856. value: function isPageVisible(pageNumber) {
  6857. return this.pdfViewer.isPageVisible(pageNumber);
  6858. }
  6859. }, {
  6860. key: "pagesCount",
  6861. get: function get() {
  6862. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  6863. }
  6864. }, {
  6865. key: "page",
  6866. get: function get() {
  6867. return this.pdfViewer.currentPageNumber;
  6868. },
  6869. set: function set(value) {
  6870. this.pdfViewer.currentPageNumber = value;
  6871. }
  6872. }, {
  6873. key: "rotation",
  6874. get: function get() {
  6875. return this.pdfViewer.pagesRotation;
  6876. },
  6877. set: function set(value) {
  6878. this.pdfViewer.pagesRotation = value;
  6879. }
  6880. }]);
  6881. return PDFLinkService;
  6882. }();
  6883. exports.PDFLinkService = PDFLinkService;
  6884. function isValidExplicitDestination(dest) {
  6885. if (!Array.isArray(dest)) {
  6886. return false;
  6887. }
  6888. var destLength = dest.length,
  6889. allowNull = true;
  6890. if (destLength < 2) {
  6891. return false;
  6892. }
  6893. var page = dest[0];
  6894. if (!(_typeof(page) === 'object' && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
  6895. return false;
  6896. }
  6897. var zoom = dest[1];
  6898. if (!(_typeof(zoom) === 'object' && typeof zoom.name === 'string')) {
  6899. return false;
  6900. }
  6901. switch (zoom.name) {
  6902. case 'XYZ':
  6903. if (destLength !== 5) {
  6904. return false;
  6905. }
  6906. break;
  6907. case 'Fit':
  6908. case 'FitB':
  6909. return destLength === 2;
  6910. case 'FitH':
  6911. case 'FitBH':
  6912. case 'FitV':
  6913. case 'FitBV':
  6914. if (destLength !== 3) {
  6915. return false;
  6916. }
  6917. break;
  6918. case 'FitR':
  6919. if (destLength !== 6) {
  6920. return false;
  6921. }
  6922. allowNull = false;
  6923. break;
  6924. default:
  6925. return false;
  6926. }
  6927. for (var i = 2; i < destLength; i++) {
  6928. var param = dest[i];
  6929. if (!(typeof param === 'number' || allowNull && param === null)) {
  6930. return false;
  6931. }
  6932. }
  6933. return true;
  6934. }
  6935. var SimpleLinkService =
  6936. /*#__PURE__*/
  6937. function () {
  6938. function SimpleLinkService() {
  6939. _classCallCheck(this, SimpleLinkService);
  6940. this.externalLinkTarget = null;
  6941. this.externalLinkRel = null;
  6942. }
  6943. _createClass(SimpleLinkService, [{
  6944. key: "navigateTo",
  6945. value: function navigateTo(dest) {}
  6946. }, {
  6947. key: "getDestinationHash",
  6948. value: function getDestinationHash(dest) {
  6949. return '#';
  6950. }
  6951. }, {
  6952. key: "getAnchorUrl",
  6953. value: function getAnchorUrl(hash) {
  6954. return '#';
  6955. }
  6956. }, {
  6957. key: "setHash",
  6958. value: function setHash(hash) {}
  6959. }, {
  6960. key: "executeNamedAction",
  6961. value: function executeNamedAction(action) {}
  6962. }, {
  6963. key: "cachePageRef",
  6964. value: function cachePageRef(pageNum, pageRef) {}
  6965. }, {
  6966. key: "isPageVisible",
  6967. value: function isPageVisible(pageNumber) {
  6968. return true;
  6969. }
  6970. }, {
  6971. key: "pagesCount",
  6972. get: function get() {
  6973. return 0;
  6974. }
  6975. }, {
  6976. key: "page",
  6977. get: function get() {
  6978. return 0;
  6979. },
  6980. set: function set(value) {}
  6981. }, {
  6982. key: "rotation",
  6983. get: function get() {
  6984. return 0;
  6985. },
  6986. set: function set(value) {}
  6987. }]);
  6988. return SimpleLinkService;
  6989. }();
  6990. exports.SimpleLinkService = SimpleLinkService;
  6991. /***/ }),
  6992. /* 23 */
  6993. /***/ (function(module, exports, __webpack_require__) {
  6994. "use strict";
  6995. Object.defineProperty(exports, "__esModule", {
  6996. value: true
  6997. });
  6998. exports.PDFOutlineViewer = void 0;
  6999. var _pdfjsLib = __webpack_require__(7);
  7000. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7001. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  7002. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7003. var DEFAULT_TITLE = "\u2013";
  7004. var PDFOutlineViewer =
  7005. /*#__PURE__*/
  7006. function () {
  7007. function PDFOutlineViewer(_ref) {
  7008. var container = _ref.container,
  7009. linkService = _ref.linkService,
  7010. eventBus = _ref.eventBus;
  7011. _classCallCheck(this, PDFOutlineViewer);
  7012. this.container = container;
  7013. this.linkService = linkService;
  7014. this.eventBus = eventBus;
  7015. this.reset();
  7016. eventBus.on('toggleoutlinetree', this.toggleOutlineTree.bind(this));
  7017. }
  7018. _createClass(PDFOutlineViewer, [{
  7019. key: "reset",
  7020. value: function reset() {
  7021. this.outline = null;
  7022. this.lastToggleIsShow = true;
  7023. this.container.textContent = '';
  7024. this.container.classList.remove('outlineWithDeepNesting');
  7025. }
  7026. }, {
  7027. key: "_dispatchEvent",
  7028. value: function _dispatchEvent(outlineCount) {
  7029. this.eventBus.dispatch('outlineloaded', {
  7030. source: this,
  7031. outlineCount: outlineCount
  7032. });
  7033. }
  7034. }, {
  7035. key: "_bindLink",
  7036. value: function _bindLink(element, _ref2) {
  7037. var url = _ref2.url,
  7038. newWindow = _ref2.newWindow,
  7039. dest = _ref2.dest;
  7040. var linkService = this.linkService;
  7041. if (url) {
  7042. (0, _pdfjsLib.addLinkAttributes)(element, {
  7043. url: url,
  7044. target: newWindow ? _pdfjsLib.LinkTarget.BLANK : linkService.externalLinkTarget,
  7045. rel: linkService.externalLinkRel
  7046. });
  7047. return;
  7048. }
  7049. element.href = linkService.getDestinationHash(dest);
  7050. element.onclick = function () {
  7051. if (dest) {
  7052. linkService.navigateTo(dest);
  7053. }
  7054. return false;
  7055. };
  7056. }
  7057. }, {
  7058. key: "_setStyles",
  7059. value: function _setStyles(element, _ref3) {
  7060. var bold = _ref3.bold,
  7061. italic = _ref3.italic;
  7062. var styleStr = '';
  7063. if (bold) {
  7064. styleStr += 'font-weight: bold;';
  7065. }
  7066. if (italic) {
  7067. styleStr += 'font-style: italic;';
  7068. }
  7069. if (styleStr) {
  7070. element.setAttribute('style', styleStr);
  7071. }
  7072. }
  7073. }, {
  7074. key: "_addToggleButton",
  7075. value: function _addToggleButton(div) {
  7076. var _this = this;
  7077. var toggler = document.createElement('div');
  7078. toggler.className = 'outlineItemToggler';
  7079. toggler.onclick = function (evt) {
  7080. evt.stopPropagation();
  7081. toggler.classList.toggle('outlineItemsHidden');
  7082. if (evt.shiftKey) {
  7083. var shouldShowAll = !toggler.classList.contains('outlineItemsHidden');
  7084. _this._toggleOutlineItem(div, shouldShowAll);
  7085. }
  7086. };
  7087. div.insertBefore(toggler, div.firstChild);
  7088. }
  7089. }, {
  7090. key: "_toggleOutlineItem",
  7091. value: function _toggleOutlineItem(root) {
  7092. var show = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7093. this.lastToggleIsShow = show;
  7094. var _iteratorNormalCompletion = true;
  7095. var _didIteratorError = false;
  7096. var _iteratorError = undefined;
  7097. try {
  7098. for (var _iterator = root.querySelectorAll('.outlineItemToggler')[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  7099. var toggler = _step.value;
  7100. toggler.classList.toggle('outlineItemsHidden', !show);
  7101. }
  7102. } catch (err) {
  7103. _didIteratorError = true;
  7104. _iteratorError = err;
  7105. } finally {
  7106. try {
  7107. if (!_iteratorNormalCompletion && _iterator.return != null) {
  7108. _iterator.return();
  7109. }
  7110. } finally {
  7111. if (_didIteratorError) {
  7112. throw _iteratorError;
  7113. }
  7114. }
  7115. }
  7116. }
  7117. }, {
  7118. key: "toggleOutlineTree",
  7119. value: function toggleOutlineTree() {
  7120. if (!this.outline) {
  7121. return;
  7122. }
  7123. this._toggleOutlineItem(this.container, !this.lastToggleIsShow);
  7124. }
  7125. }, {
  7126. key: "render",
  7127. value: function render(_ref4) {
  7128. var outline = _ref4.outline;
  7129. var outlineCount = 0;
  7130. if (this.outline) {
  7131. this.reset();
  7132. }
  7133. this.outline = outline || null;
  7134. if (!outline) {
  7135. this._dispatchEvent(outlineCount);
  7136. return;
  7137. }
  7138. var fragment = document.createDocumentFragment();
  7139. var queue = [{
  7140. parent: fragment,
  7141. items: this.outline
  7142. }];
  7143. var hasAnyNesting = false;
  7144. while (queue.length > 0) {
  7145. var levelData = queue.shift();
  7146. for (var i = 0, len = levelData.items.length; i < len; i++) {
  7147. var item = levelData.items[i];
  7148. var div = document.createElement('div');
  7149. div.className = 'outlineItem';
  7150. var element = document.createElement('a');
  7151. this._bindLink(element, item);
  7152. this._setStyles(element, item);
  7153. element.textContent = (0, _pdfjsLib.removeNullCharacters)(item.title) || DEFAULT_TITLE;
  7154. div.appendChild(element);
  7155. if (item.items.length > 0) {
  7156. hasAnyNesting = true;
  7157. this._addToggleButton(div);
  7158. var itemsDiv = document.createElement('div');
  7159. itemsDiv.className = 'outlineItems';
  7160. div.appendChild(itemsDiv);
  7161. queue.push({
  7162. parent: itemsDiv,
  7163. items: item.items
  7164. });
  7165. }
  7166. levelData.parent.appendChild(div);
  7167. outlineCount++;
  7168. }
  7169. }
  7170. if (hasAnyNesting) {
  7171. this.container.classList.add('outlineWithDeepNesting');
  7172. }
  7173. this.container.appendChild(fragment);
  7174. this._dispatchEvent(outlineCount);
  7175. }
  7176. }]);
  7177. return PDFOutlineViewer;
  7178. }();
  7179. exports.PDFOutlineViewer = PDFOutlineViewer;
  7180. /***/ }),
  7181. /* 24 */
  7182. /***/ (function(module, exports, __webpack_require__) {
  7183. "use strict";
  7184. Object.defineProperty(exports, "__esModule", {
  7185. value: true
  7186. });
  7187. exports.PDFPresentationMode = void 0;
  7188. var _ui_utils = __webpack_require__(6);
  7189. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7190. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  7191. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7192. var DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1500;
  7193. var DELAY_BEFORE_HIDING_CONTROLS = 3000;
  7194. var ACTIVE_SELECTOR = 'pdfPresentationMode';
  7195. var CONTROLS_SELECTOR = 'pdfPresentationModeControls';
  7196. var MOUSE_SCROLL_COOLDOWN_TIME = 50;
  7197. var PAGE_SWITCH_THRESHOLD = 0.1;
  7198. var SWIPE_MIN_DISTANCE_THRESHOLD = 50;
  7199. var SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
  7200. var PDFPresentationMode =
  7201. /*#__PURE__*/
  7202. function () {
  7203. function PDFPresentationMode(_ref) {
  7204. var _this = this;
  7205. var container = _ref.container,
  7206. _ref$viewer = _ref.viewer,
  7207. viewer = _ref$viewer === void 0 ? null : _ref$viewer,
  7208. pdfViewer = _ref.pdfViewer,
  7209. eventBus = _ref.eventBus,
  7210. _ref$contextMenuItems = _ref.contextMenuItems,
  7211. contextMenuItems = _ref$contextMenuItems === void 0 ? null : _ref$contextMenuItems;
  7212. _classCallCheck(this, PDFPresentationMode);
  7213. this.container = container;
  7214. this.viewer = viewer || container.firstElementChild;
  7215. this.pdfViewer = pdfViewer;
  7216. this.eventBus = eventBus;
  7217. this.active = false;
  7218. this.args = null;
  7219. this.contextMenuOpen = false;
  7220. this.mouseScrollTimeStamp = 0;
  7221. this.mouseScrollDelta = 0;
  7222. this.touchSwipeState = null;
  7223. if (contextMenuItems) {
  7224. contextMenuItems.contextFirstPage.addEventListener('click', function () {
  7225. _this.contextMenuOpen = false;
  7226. _this.eventBus.dispatch('firstpage', {
  7227. source: _this
  7228. });
  7229. });
  7230. contextMenuItems.contextLastPage.addEventListener('click', function () {
  7231. _this.contextMenuOpen = false;
  7232. _this.eventBus.dispatch('lastpage', {
  7233. source: _this
  7234. });
  7235. });
  7236. contextMenuItems.contextPageRotateCw.addEventListener('click', function () {
  7237. _this.contextMenuOpen = false;
  7238. _this.eventBus.dispatch('rotatecw', {
  7239. source: _this
  7240. });
  7241. });
  7242. contextMenuItems.contextPageRotateCcw.addEventListener('click', function () {
  7243. _this.contextMenuOpen = false;
  7244. _this.eventBus.dispatch('rotateccw', {
  7245. source: _this
  7246. });
  7247. });
  7248. }
  7249. }
  7250. _createClass(PDFPresentationMode, [{
  7251. key: "request",
  7252. value: function request() {
  7253. if (this.switchInProgress || this.active || !this.viewer.hasChildNodes()) {
  7254. return false;
  7255. }
  7256. this._addFullscreenChangeListeners();
  7257. this._setSwitchInProgress();
  7258. this._notifyStateChange();
  7259. if (this.container.requestFullscreen) {
  7260. this.container.requestFullscreen();
  7261. } else if (this.container.mozRequestFullScreen) {
  7262. this.container.mozRequestFullScreen();
  7263. } else if (this.container.webkitRequestFullscreen) {
  7264. this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
  7265. } else if (this.container.msRequestFullscreen) {
  7266. this.container.msRequestFullscreen();
  7267. } else {
  7268. return false;
  7269. }
  7270. this.args = {
  7271. page: this.pdfViewer.currentPageNumber,
  7272. previousScale: this.pdfViewer.currentScaleValue
  7273. };
  7274. return true;
  7275. }
  7276. }, {
  7277. key: "_mouseWheel",
  7278. value: function _mouseWheel(evt) {
  7279. if (!this.active) {
  7280. return;
  7281. }
  7282. evt.preventDefault();
  7283. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  7284. var currentTime = new Date().getTime();
  7285. var storedTime = this.mouseScrollTimeStamp;
  7286. if (currentTime > storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {
  7287. return;
  7288. }
  7289. if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) {
  7290. this._resetMouseScrollState();
  7291. }
  7292. this.mouseScrollDelta += delta;
  7293. if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
  7294. var totalDelta = this.mouseScrollDelta;
  7295. this._resetMouseScrollState();
  7296. var success = totalDelta > 0 ? this._goToPreviousPage() : this._goToNextPage();
  7297. if (success) {
  7298. this.mouseScrollTimeStamp = currentTime;
  7299. }
  7300. }
  7301. }
  7302. }, {
  7303. key: "_goToPreviousPage",
  7304. value: function _goToPreviousPage() {
  7305. var page = this.pdfViewer.currentPageNumber;
  7306. if (page <= 1) {
  7307. return false;
  7308. }
  7309. this.pdfViewer.currentPageNumber = page - 1;
  7310. return true;
  7311. }
  7312. }, {
  7313. key: "_goToNextPage",
  7314. value: function _goToNextPage() {
  7315. var page = this.pdfViewer.currentPageNumber;
  7316. if (page >= this.pdfViewer.pagesCount) {
  7317. return false;
  7318. }
  7319. this.pdfViewer.currentPageNumber = page + 1;
  7320. return true;
  7321. }
  7322. }, {
  7323. key: "_notifyStateChange",
  7324. value: function _notifyStateChange() {
  7325. this.eventBus.dispatch('presentationmodechanged', {
  7326. source: this,
  7327. active: this.active,
  7328. switchInProgress: !!this.switchInProgress
  7329. });
  7330. }
  7331. }, {
  7332. key: "_setSwitchInProgress",
  7333. value: function _setSwitchInProgress() {
  7334. var _this2 = this;
  7335. if (this.switchInProgress) {
  7336. clearTimeout(this.switchInProgress);
  7337. }
  7338. this.switchInProgress = setTimeout(function () {
  7339. _this2._removeFullscreenChangeListeners();
  7340. delete _this2.switchInProgress;
  7341. _this2._notifyStateChange();
  7342. }, DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS);
  7343. }
  7344. }, {
  7345. key: "_resetSwitchInProgress",
  7346. value: function _resetSwitchInProgress() {
  7347. if (this.switchInProgress) {
  7348. clearTimeout(this.switchInProgress);
  7349. delete this.switchInProgress;
  7350. }
  7351. }
  7352. }, {
  7353. key: "_enter",
  7354. value: function _enter() {
  7355. var _this3 = this;
  7356. this.active = true;
  7357. this._resetSwitchInProgress();
  7358. this._notifyStateChange();
  7359. this.container.classList.add(ACTIVE_SELECTOR);
  7360. setTimeout(function () {
  7361. _this3.pdfViewer.currentPageNumber = _this3.args.page;
  7362. _this3.pdfViewer.currentScaleValue = 'page-fit';
  7363. }, 0);
  7364. this._addWindowListeners();
  7365. this._showControls();
  7366. this.contextMenuOpen = false;
  7367. this.container.setAttribute('contextmenu', 'viewerContextMenu');
  7368. window.getSelection().removeAllRanges();
  7369. }
  7370. }, {
  7371. key: "_exit",
  7372. value: function _exit() {
  7373. var _this4 = this;
  7374. var page = this.pdfViewer.currentPageNumber;
  7375. this.container.classList.remove(ACTIVE_SELECTOR);
  7376. setTimeout(function () {
  7377. _this4.active = false;
  7378. _this4._removeFullscreenChangeListeners();
  7379. _this4._notifyStateChange();
  7380. _this4.pdfViewer.currentScaleValue = _this4.args.previousScale;
  7381. _this4.pdfViewer.currentPageNumber = page;
  7382. _this4.args = null;
  7383. }, 0);
  7384. this._removeWindowListeners();
  7385. this._hideControls();
  7386. this._resetMouseScrollState();
  7387. this.container.removeAttribute('contextmenu');
  7388. this.contextMenuOpen = false;
  7389. }
  7390. }, {
  7391. key: "_mouseDown",
  7392. value: function _mouseDown(evt) {
  7393. if (this.contextMenuOpen) {
  7394. this.contextMenuOpen = false;
  7395. evt.preventDefault();
  7396. return;
  7397. }
  7398. if (evt.button === 0) {
  7399. var isInternalLink = evt.target.href && evt.target.classList.contains('internalLink');
  7400. if (!isInternalLink) {
  7401. evt.preventDefault();
  7402. if (evt.shiftKey) {
  7403. this._goToPreviousPage();
  7404. } else {
  7405. this._goToNextPage();
  7406. }
  7407. }
  7408. }
  7409. }
  7410. }, {
  7411. key: "_contextMenu",
  7412. value: function _contextMenu() {
  7413. this.contextMenuOpen = true;
  7414. }
  7415. }, {
  7416. key: "_showControls",
  7417. value: function _showControls() {
  7418. var _this5 = this;
  7419. if (this.controlsTimeout) {
  7420. clearTimeout(this.controlsTimeout);
  7421. } else {
  7422. this.container.classList.add(CONTROLS_SELECTOR);
  7423. }
  7424. this.controlsTimeout = setTimeout(function () {
  7425. _this5.container.classList.remove(CONTROLS_SELECTOR);
  7426. delete _this5.controlsTimeout;
  7427. }, DELAY_BEFORE_HIDING_CONTROLS);
  7428. }
  7429. }, {
  7430. key: "_hideControls",
  7431. value: function _hideControls() {
  7432. if (!this.controlsTimeout) {
  7433. return;
  7434. }
  7435. clearTimeout(this.controlsTimeout);
  7436. this.container.classList.remove(CONTROLS_SELECTOR);
  7437. delete this.controlsTimeout;
  7438. }
  7439. }, {
  7440. key: "_resetMouseScrollState",
  7441. value: function _resetMouseScrollState() {
  7442. this.mouseScrollTimeStamp = 0;
  7443. this.mouseScrollDelta = 0;
  7444. }
  7445. }, {
  7446. key: "_touchSwipe",
  7447. value: function _touchSwipe(evt) {
  7448. if (!this.active) {
  7449. return;
  7450. }
  7451. if (evt.touches.length > 1) {
  7452. this.touchSwipeState = null;
  7453. return;
  7454. }
  7455. switch (evt.type) {
  7456. case 'touchstart':
  7457. this.touchSwipeState = {
  7458. startX: evt.touches[0].pageX,
  7459. startY: evt.touches[0].pageY,
  7460. endX: evt.touches[0].pageX,
  7461. endY: evt.touches[0].pageY
  7462. };
  7463. break;
  7464. case 'touchmove':
  7465. if (this.touchSwipeState === null) {
  7466. return;
  7467. }
  7468. this.touchSwipeState.endX = evt.touches[0].pageX;
  7469. this.touchSwipeState.endY = evt.touches[0].pageY;
  7470. evt.preventDefault();
  7471. break;
  7472. case 'touchend':
  7473. if (this.touchSwipeState === null) {
  7474. return;
  7475. }
  7476. var delta = 0;
  7477. var dx = this.touchSwipeState.endX - this.touchSwipeState.startX;
  7478. var dy = this.touchSwipeState.endY - this.touchSwipeState.startY;
  7479. var absAngle = Math.abs(Math.atan2(dy, dx));
  7480. if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <= SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI - SWIPE_ANGLE_THRESHOLD)) {
  7481. delta = dx;
  7482. } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math.abs(absAngle - Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) {
  7483. delta = dy;
  7484. }
  7485. if (delta > 0) {
  7486. this._goToPreviousPage();
  7487. } else if (delta < 0) {
  7488. this._goToNextPage();
  7489. }
  7490. break;
  7491. }
  7492. }
  7493. }, {
  7494. key: "_addWindowListeners",
  7495. value: function _addWindowListeners() {
  7496. this.showControlsBind = this._showControls.bind(this);
  7497. this.mouseDownBind = this._mouseDown.bind(this);
  7498. this.mouseWheelBind = this._mouseWheel.bind(this);
  7499. this.resetMouseScrollStateBind = this._resetMouseScrollState.bind(this);
  7500. this.contextMenuBind = this._contextMenu.bind(this);
  7501. this.touchSwipeBind = this._touchSwipe.bind(this);
  7502. window.addEventListener('mousemove', this.showControlsBind);
  7503. window.addEventListener('mousedown', this.mouseDownBind);
  7504. window.addEventListener('wheel', this.mouseWheelBind);
  7505. window.addEventListener('keydown', this.resetMouseScrollStateBind);
  7506. window.addEventListener('contextmenu', this.contextMenuBind);
  7507. window.addEventListener('touchstart', this.touchSwipeBind);
  7508. window.addEventListener('touchmove', this.touchSwipeBind);
  7509. window.addEventListener('touchend', this.touchSwipeBind);
  7510. }
  7511. }, {
  7512. key: "_removeWindowListeners",
  7513. value: function _removeWindowListeners() {
  7514. window.removeEventListener('mousemove', this.showControlsBind);
  7515. window.removeEventListener('mousedown', this.mouseDownBind);
  7516. window.removeEventListener('wheel', this.mouseWheelBind);
  7517. window.removeEventListener('keydown', this.resetMouseScrollStateBind);
  7518. window.removeEventListener('contextmenu', this.contextMenuBind);
  7519. window.removeEventListener('touchstart', this.touchSwipeBind);
  7520. window.removeEventListener('touchmove', this.touchSwipeBind);
  7521. window.removeEventListener('touchend', this.touchSwipeBind);
  7522. delete this.showControlsBind;
  7523. delete this.mouseDownBind;
  7524. delete this.mouseWheelBind;
  7525. delete this.resetMouseScrollStateBind;
  7526. delete this.contextMenuBind;
  7527. delete this.touchSwipeBind;
  7528. }
  7529. }, {
  7530. key: "_fullscreenChange",
  7531. value: function _fullscreenChange() {
  7532. if (this.isFullscreen) {
  7533. this._enter();
  7534. } else {
  7535. this._exit();
  7536. }
  7537. }
  7538. }, {
  7539. key: "_addFullscreenChangeListeners",
  7540. value: function _addFullscreenChangeListeners() {
  7541. this.fullscreenChangeBind = this._fullscreenChange.bind(this);
  7542. window.addEventListener('fullscreenchange', this.fullscreenChangeBind);
  7543. window.addEventListener('mozfullscreenchange', this.fullscreenChangeBind);
  7544. window.addEventListener('webkitfullscreenchange', this.fullscreenChangeBind);
  7545. window.addEventListener('MSFullscreenChange', this.fullscreenChangeBind);
  7546. }
  7547. }, {
  7548. key: "_removeFullscreenChangeListeners",
  7549. value: function _removeFullscreenChangeListeners() {
  7550. window.removeEventListener('fullscreenchange', this.fullscreenChangeBind);
  7551. window.removeEventListener('mozfullscreenchange', this.fullscreenChangeBind);
  7552. window.removeEventListener('webkitfullscreenchange', this.fullscreenChangeBind);
  7553. window.removeEventListener('MSFullscreenChange', this.fullscreenChangeBind);
  7554. delete this.fullscreenChangeBind;
  7555. }
  7556. }, {
  7557. key: "isFullscreen",
  7558. get: function get() {
  7559. return !!(document.fullscreenElement || document.mozFullScreen || document.webkitIsFullScreen || document.msFullscreenElement);
  7560. }
  7561. }]);
  7562. return PDFPresentationMode;
  7563. }();
  7564. exports.PDFPresentationMode = PDFPresentationMode;
  7565. /***/ }),
  7566. /* 25 */
  7567. /***/ (function(module, exports, __webpack_require__) {
  7568. "use strict";
  7569. Object.defineProperty(exports, "__esModule", {
  7570. value: true
  7571. });
  7572. exports.PDFSidebarResizer = void 0;
  7573. var _ui_utils = __webpack_require__(6);
  7574. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7575. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  7576. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7577. var SIDEBAR_WIDTH_VAR = '--sidebar-width';
  7578. var SIDEBAR_MIN_WIDTH = 200;
  7579. var SIDEBAR_RESIZING_CLASS = 'sidebarResizing';
  7580. var PDFSidebarResizer =
  7581. /*#__PURE__*/
  7582. function () {
  7583. function PDFSidebarResizer(options, eventBus) {
  7584. var _this = this;
  7585. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  7586. _classCallCheck(this, PDFSidebarResizer);
  7587. this.enabled = false;
  7588. this.isRTL = false;
  7589. this.sidebarOpen = false;
  7590. this.doc = document.documentElement;
  7591. this._width = null;
  7592. this._outerContainerWidth = null;
  7593. this._boundEvents = Object.create(null);
  7594. this.outerContainer = options.outerContainer;
  7595. this.resizer = options.resizer;
  7596. this.eventBus = eventBus;
  7597. this.l10n = l10n;
  7598. if (typeof CSS === 'undefined' || typeof CSS.supports !== 'function' || !CSS.supports(SIDEBAR_WIDTH_VAR, "calc(-1 * ".concat(SIDEBAR_MIN_WIDTH, "px)"))) {
  7599. console.warn('PDFSidebarResizer: ' + 'The browser does not support resizing of the sidebar.');
  7600. return;
  7601. }
  7602. this.enabled = true;
  7603. this.resizer.classList.remove('hidden');
  7604. this.l10n.getDirection().then(function (dir) {
  7605. _this.isRTL = dir === 'rtl';
  7606. });
  7607. this._addEventListeners();
  7608. }
  7609. _createClass(PDFSidebarResizer, [{
  7610. key: "_updateWidth",
  7611. value: function _updateWidth() {
  7612. var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  7613. if (!this.enabled) {
  7614. return false;
  7615. }
  7616. var maxWidth = Math.floor(this.outerContainerWidth / 2);
  7617. if (width > maxWidth) {
  7618. width = maxWidth;
  7619. }
  7620. if (width < SIDEBAR_MIN_WIDTH) {
  7621. width = SIDEBAR_MIN_WIDTH;
  7622. }
  7623. if (width === this._width) {
  7624. return false;
  7625. }
  7626. this._width = width;
  7627. this.doc.style.setProperty(SIDEBAR_WIDTH_VAR, "".concat(width, "px"));
  7628. return true;
  7629. }
  7630. }, {
  7631. key: "_mouseMove",
  7632. value: function _mouseMove(evt) {
  7633. var width = evt.clientX;
  7634. if (this.isRTL) {
  7635. width = this.outerContainerWidth - width;
  7636. }
  7637. this._updateWidth(width);
  7638. }
  7639. }, {
  7640. key: "_mouseUp",
  7641. value: function _mouseUp(evt) {
  7642. this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  7643. this.eventBus.dispatch('resize', {
  7644. source: this
  7645. });
  7646. var _boundEvents = this._boundEvents;
  7647. window.removeEventListener('mousemove', _boundEvents.mouseMove);
  7648. window.removeEventListener('mouseup', _boundEvents.mouseUp);
  7649. }
  7650. }, {
  7651. key: "_addEventListeners",
  7652. value: function _addEventListeners() {
  7653. var _this2 = this;
  7654. if (!this.enabled) {
  7655. return;
  7656. }
  7657. var _boundEvents = this._boundEvents;
  7658. _boundEvents.mouseMove = this._mouseMove.bind(this);
  7659. _boundEvents.mouseUp = this._mouseUp.bind(this);
  7660. this.resizer.addEventListener('mousedown', function (evt) {
  7661. if (evt.button !== 0) {
  7662. return;
  7663. }
  7664. _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  7665. window.addEventListener('mousemove', _boundEvents.mouseMove);
  7666. window.addEventListener('mouseup', _boundEvents.mouseUp);
  7667. });
  7668. this.eventBus.on('sidebarviewchanged', function (evt) {
  7669. _this2.sidebarOpen = !!(evt && evt.view);
  7670. });
  7671. this.eventBus.on('resize', function (evt) {
  7672. if (evt && evt.source === window) {
  7673. _this2._outerContainerWidth = null;
  7674. if (_this2._width) {
  7675. if (_this2.sidebarOpen) {
  7676. _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  7677. var updated = _this2._updateWidth(_this2._width);
  7678. Promise.resolve().then(function () {
  7679. _this2.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  7680. if (updated) {
  7681. _this2.eventBus.dispatch('resize', {
  7682. source: _this2
  7683. });
  7684. }
  7685. });
  7686. } else {
  7687. _this2._updateWidth(_this2._width);
  7688. }
  7689. }
  7690. }
  7691. });
  7692. }
  7693. }, {
  7694. key: "outerContainerWidth",
  7695. get: function get() {
  7696. if (!this._outerContainerWidth) {
  7697. this._outerContainerWidth = this.outerContainer.clientWidth;
  7698. }
  7699. return this._outerContainerWidth;
  7700. }
  7701. }]);
  7702. return PDFSidebarResizer;
  7703. }();
  7704. exports.PDFSidebarResizer = PDFSidebarResizer;
  7705. /***/ }),
  7706. /* 26 */
  7707. /***/ (function(module, exports, __webpack_require__) {
  7708. "use strict";
  7709. Object.defineProperty(exports, "__esModule", {
  7710. value: true
  7711. });
  7712. exports.PDFThumbnailViewer = void 0;
  7713. var _ui_utils = __webpack_require__(6);
  7714. var _pdf_thumbnail_view = __webpack_require__(27);
  7715. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7716. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  7717. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7718. var THUMBNAIL_SCROLL_MARGIN = -19;
  7719. var THUMBNAIL_SELECTED_CLASS = 'selected';
  7720. var PDFThumbnailViewer =
  7721. /*#__PURE__*/
  7722. function () {
  7723. function PDFThumbnailViewer(_ref) {
  7724. var container = _ref.container,
  7725. linkService = _ref.linkService,
  7726. renderingQueue = _ref.renderingQueue,
  7727. _ref$l10n = _ref.l10n,
  7728. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  7729. _classCallCheck(this, PDFThumbnailViewer);
  7730. this.container = container;
  7731. this.linkService = linkService;
  7732. this.renderingQueue = renderingQueue;
  7733. this.l10n = l10n;
  7734. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdated.bind(this));
  7735. this._resetView();
  7736. }
  7737. _createClass(PDFThumbnailViewer, [{
  7738. key: "_scrollUpdated",
  7739. value: function _scrollUpdated() {
  7740. this.renderingQueue.renderHighestPriority();
  7741. }
  7742. }, {
  7743. key: "getThumbnail",
  7744. value: function getThumbnail(index) {
  7745. return this._thumbnails[index];
  7746. }
  7747. }, {
  7748. key: "_getVisibleThumbs",
  7749. value: function _getVisibleThumbs() {
  7750. return (0, _ui_utils.getVisibleElements)(this.container, this._thumbnails);
  7751. }
  7752. }, {
  7753. key: "scrollThumbnailIntoView",
  7754. value: function scrollThumbnailIntoView(pageNumber) {
  7755. if (!this.pdfDocument) {
  7756. return;
  7757. }
  7758. var thumbnailView = this._thumbnails[pageNumber - 1];
  7759. if (!thumbnailView) {
  7760. console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');
  7761. return;
  7762. }
  7763. if (pageNumber !== this._currentPageNumber) {
  7764. var prevThumbnailView = this._thumbnails[this._currentPageNumber - 1];
  7765. prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS);
  7766. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  7767. }
  7768. var visibleThumbs = this._getVisibleThumbs();
  7769. var numVisibleThumbs = visibleThumbs.views.length;
  7770. if (numVisibleThumbs > 0) {
  7771. var first = visibleThumbs.first.id;
  7772. var last = numVisibleThumbs > 1 ? visibleThumbs.last.id : first;
  7773. var shouldScroll = false;
  7774. if (pageNumber <= first || pageNumber >= last) {
  7775. shouldScroll = true;
  7776. } else {
  7777. visibleThumbs.views.some(function (view) {
  7778. if (view.id !== pageNumber) {
  7779. return false;
  7780. }
  7781. shouldScroll = view.percent < 100;
  7782. return true;
  7783. });
  7784. }
  7785. if (shouldScroll) {
  7786. (0, _ui_utils.scrollIntoView)(thumbnailView.div, {
  7787. top: THUMBNAIL_SCROLL_MARGIN
  7788. });
  7789. }
  7790. }
  7791. this._currentPageNumber = pageNumber;
  7792. }
  7793. }, {
  7794. key: "cleanup",
  7795. value: function cleanup() {
  7796. _pdf_thumbnail_view.PDFThumbnailView.cleanup();
  7797. }
  7798. }, {
  7799. key: "_resetView",
  7800. value: function _resetView() {
  7801. this._thumbnails = [];
  7802. this._currentPageNumber = 1;
  7803. this._pageLabels = null;
  7804. this._pagesRotation = 0;
  7805. this._pagesRequests = [];
  7806. this.container.textContent = '';
  7807. }
  7808. }, {
  7809. key: "setDocument",
  7810. value: function setDocument(pdfDocument) {
  7811. var _this = this;
  7812. if (this.pdfDocument) {
  7813. this._cancelRendering();
  7814. this._resetView();
  7815. }
  7816. this.pdfDocument = pdfDocument;
  7817. if (!pdfDocument) {
  7818. return;
  7819. }
  7820. pdfDocument.getPage(1).then(function (firstPage) {
  7821. var pagesCount = pdfDocument.numPages;
  7822. var viewport = firstPage.getViewport({
  7823. scale: 1
  7824. });
  7825. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  7826. var thumbnail = new _pdf_thumbnail_view.PDFThumbnailView({
  7827. container: _this.container,
  7828. id: pageNum,
  7829. defaultViewport: viewport.clone(),
  7830. linkService: _this.linkService,
  7831. renderingQueue: _this.renderingQueue,
  7832. disableCanvasToImageConversion: false,
  7833. l10n: _this.l10n
  7834. });
  7835. _this._thumbnails.push(thumbnail);
  7836. }
  7837. var thumbnailView = _this._thumbnails[_this._currentPageNumber - 1];
  7838. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  7839. }).catch(function (reason) {
  7840. console.error('Unable to initialize thumbnail viewer', reason);
  7841. });
  7842. }
  7843. }, {
  7844. key: "_cancelRendering",
  7845. value: function _cancelRendering() {
  7846. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  7847. if (this._thumbnails[i]) {
  7848. this._thumbnails[i].cancelRendering();
  7849. }
  7850. }
  7851. }
  7852. }, {
  7853. key: "setPageLabels",
  7854. value: function setPageLabels(labels) {
  7855. if (!this.pdfDocument) {
  7856. return;
  7857. }
  7858. if (!labels) {
  7859. this._pageLabels = null;
  7860. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  7861. this._pageLabels = null;
  7862. console.error('PDFThumbnailViewer_setPageLabels: Invalid page labels.');
  7863. } else {
  7864. this._pageLabels = labels;
  7865. }
  7866. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  7867. var label = this._pageLabels && this._pageLabels[i];
  7868. this._thumbnails[i].setPageLabel(label);
  7869. }
  7870. }
  7871. }, {
  7872. key: "_ensurePdfPageLoaded",
  7873. value: function _ensurePdfPageLoaded(thumbView) {
  7874. var _this2 = this;
  7875. if (thumbView.pdfPage) {
  7876. return Promise.resolve(thumbView.pdfPage);
  7877. }
  7878. var pageNumber = thumbView.id;
  7879. if (this._pagesRequests[pageNumber]) {
  7880. return this._pagesRequests[pageNumber];
  7881. }
  7882. var promise = this.pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  7883. thumbView.setPdfPage(pdfPage);
  7884. _this2._pagesRequests[pageNumber] = null;
  7885. return pdfPage;
  7886. }).catch(function (reason) {
  7887. console.error('Unable to get page for thumb view', reason);
  7888. _this2._pagesRequests[pageNumber] = null;
  7889. });
  7890. this._pagesRequests[pageNumber] = promise;
  7891. return promise;
  7892. }
  7893. }, {
  7894. key: "forceRendering",
  7895. value: function forceRendering() {
  7896. var _this3 = this;
  7897. var visibleThumbs = this._getVisibleThumbs();
  7898. var thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, this.scroll.down);
  7899. if (thumbView) {
  7900. this._ensurePdfPageLoaded(thumbView).then(function () {
  7901. _this3.renderingQueue.renderView(thumbView);
  7902. });
  7903. return true;
  7904. }
  7905. return false;
  7906. }
  7907. }, {
  7908. key: "pagesRotation",
  7909. get: function get() {
  7910. return this._pagesRotation;
  7911. },
  7912. set: function set(rotation) {
  7913. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  7914. throw new Error('Invalid thumbnails rotation angle.');
  7915. }
  7916. if (!this.pdfDocument) {
  7917. return;
  7918. }
  7919. if (this._pagesRotation === rotation) {
  7920. return;
  7921. }
  7922. this._pagesRotation = rotation;
  7923. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  7924. this._thumbnails[i].update(rotation);
  7925. }
  7926. }
  7927. }]);
  7928. return PDFThumbnailViewer;
  7929. }();
  7930. exports.PDFThumbnailViewer = PDFThumbnailViewer;
  7931. /***/ }),
  7932. /* 27 */
  7933. /***/ (function(module, exports, __webpack_require__) {
  7934. "use strict";
  7935. Object.defineProperty(exports, "__esModule", {
  7936. value: true
  7937. });
  7938. exports.PDFThumbnailView = void 0;
  7939. var _pdfjsLib = __webpack_require__(7);
  7940. var _ui_utils = __webpack_require__(6);
  7941. var _pdf_rendering_queue = __webpack_require__(10);
  7942. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7943. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  7944. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7945. var MAX_NUM_SCALING_STEPS = 3;
  7946. var THUMBNAIL_CANVAS_BORDER_WIDTH = 1;
  7947. var THUMBNAIL_WIDTH = 98;
  7948. var TempImageFactory = function TempImageFactoryClosure() {
  7949. var tempCanvasCache = null;
  7950. return {
  7951. getCanvas: function getCanvas(width, height) {
  7952. var tempCanvas = tempCanvasCache;
  7953. if (!tempCanvas) {
  7954. tempCanvas = document.createElement('canvas');
  7955. tempCanvasCache = tempCanvas;
  7956. }
  7957. tempCanvas.width = width;
  7958. tempCanvas.height = height;
  7959. tempCanvas.mozOpaque = true;
  7960. var ctx = tempCanvas.getContext('2d', {
  7961. alpha: false
  7962. });
  7963. ctx.save();
  7964. ctx.fillStyle = 'rgb(255, 255, 255)';
  7965. ctx.fillRect(0, 0, width, height);
  7966. ctx.restore();
  7967. return tempCanvas;
  7968. },
  7969. destroyCanvas: function destroyCanvas() {
  7970. var tempCanvas = tempCanvasCache;
  7971. if (tempCanvas) {
  7972. tempCanvas.width = 0;
  7973. tempCanvas.height = 0;
  7974. }
  7975. tempCanvasCache = null;
  7976. }
  7977. };
  7978. }();
  7979. var PDFThumbnailView =
  7980. /*#__PURE__*/
  7981. function () {
  7982. function PDFThumbnailView(_ref) {
  7983. var container = _ref.container,
  7984. id = _ref.id,
  7985. defaultViewport = _ref.defaultViewport,
  7986. linkService = _ref.linkService,
  7987. renderingQueue = _ref.renderingQueue,
  7988. _ref$disableCanvasToI = _ref.disableCanvasToImageConversion,
  7989. disableCanvasToImageConversion = _ref$disableCanvasToI === void 0 ? false : _ref$disableCanvasToI,
  7990. _ref$l10n = _ref.l10n,
  7991. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  7992. _classCallCheck(this, PDFThumbnailView);
  7993. this.id = id;
  7994. this.renderingId = 'thumbnail' + id;
  7995. this.pageLabel = null;
  7996. this.pdfPage = null;
  7997. this.rotation = 0;
  7998. this.viewport = defaultViewport;
  7999. this.pdfPageRotate = defaultViewport.rotation;
  8000. this.linkService = linkService;
  8001. this.renderingQueue = renderingQueue;
  8002. this.renderTask = null;
  8003. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  8004. this.resume = null;
  8005. this.disableCanvasToImageConversion = disableCanvasToImageConversion;
  8006. this.pageWidth = this.viewport.width;
  8007. this.pageHeight = this.viewport.height;
  8008. this.pageRatio = this.pageWidth / this.pageHeight;
  8009. this.canvasWidth = THUMBNAIL_WIDTH;
  8010. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  8011. this.scale = this.canvasWidth / this.pageWidth;
  8012. this.l10n = l10n;
  8013. var anchor = document.createElement('a');
  8014. anchor.href = linkService.getAnchorUrl('#page=' + id);
  8015. this.l10n.get('thumb_page_title', {
  8016. page: id
  8017. }, 'Page {{page}}').then(function (msg) {
  8018. anchor.title = msg;
  8019. });
  8020. anchor.onclick = function () {
  8021. linkService.page = id;
  8022. return false;
  8023. };
  8024. this.anchor = anchor;
  8025. var div = document.createElement('div');
  8026. div.className = 'thumbnail';
  8027. div.setAttribute('data-page-number', this.id);
  8028. this.div = div;
  8029. var ring = document.createElement('div');
  8030. ring.className = 'thumbnailSelectionRing';
  8031. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  8032. ring.style.width = this.canvasWidth + borderAdjustment + 'px';
  8033. ring.style.height = this.canvasHeight + borderAdjustment + 'px';
  8034. this.ring = ring;
  8035. div.appendChild(ring);
  8036. anchor.appendChild(div);
  8037. container.appendChild(anchor);
  8038. }
  8039. _createClass(PDFThumbnailView, [{
  8040. key: "setPdfPage",
  8041. value: function setPdfPage(pdfPage) {
  8042. this.pdfPage = pdfPage;
  8043. this.pdfPageRotate = pdfPage.rotate;
  8044. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  8045. this.viewport = pdfPage.getViewport({
  8046. scale: 1,
  8047. rotation: totalRotation
  8048. });
  8049. this.reset();
  8050. }
  8051. }, {
  8052. key: "reset",
  8053. value: function reset() {
  8054. this.cancelRendering();
  8055. this.pageWidth = this.viewport.width;
  8056. this.pageHeight = this.viewport.height;
  8057. this.pageRatio = this.pageWidth / this.pageHeight;
  8058. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  8059. this.scale = this.canvasWidth / this.pageWidth;
  8060. this.div.removeAttribute('data-loaded');
  8061. var ring = this.ring;
  8062. var childNodes = ring.childNodes;
  8063. for (var i = childNodes.length - 1; i >= 0; i--) {
  8064. ring.removeChild(childNodes[i]);
  8065. }
  8066. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  8067. ring.style.width = this.canvasWidth + borderAdjustment + 'px';
  8068. ring.style.height = this.canvasHeight + borderAdjustment + 'px';
  8069. if (this.canvas) {
  8070. this.canvas.width = 0;
  8071. this.canvas.height = 0;
  8072. delete this.canvas;
  8073. }
  8074. if (this.image) {
  8075. this.image.removeAttribute('src');
  8076. delete this.image;
  8077. }
  8078. }
  8079. }, {
  8080. key: "update",
  8081. value: function update(rotation) {
  8082. if (typeof rotation !== 'undefined') {
  8083. this.rotation = rotation;
  8084. }
  8085. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  8086. this.viewport = this.viewport.clone({
  8087. scale: 1,
  8088. rotation: totalRotation
  8089. });
  8090. this.reset();
  8091. }
  8092. }, {
  8093. key: "cancelRendering",
  8094. value: function cancelRendering() {
  8095. if (this.renderTask) {
  8096. this.renderTask.cancel();
  8097. this.renderTask = null;
  8098. }
  8099. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  8100. this.resume = null;
  8101. }
  8102. }, {
  8103. key: "_getPageDrawContext",
  8104. value: function _getPageDrawContext() {
  8105. var noCtxScale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  8106. var canvas = document.createElement('canvas');
  8107. this.canvas = canvas;
  8108. canvas.mozOpaque = true;
  8109. var ctx = canvas.getContext('2d', {
  8110. alpha: false
  8111. });
  8112. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  8113. canvas.width = this.canvasWidth * outputScale.sx | 0;
  8114. canvas.height = this.canvasHeight * outputScale.sy | 0;
  8115. canvas.style.width = this.canvasWidth + 'px';
  8116. canvas.style.height = this.canvasHeight + 'px';
  8117. if (!noCtxScale && outputScale.scaled) {
  8118. ctx.scale(outputScale.sx, outputScale.sy);
  8119. }
  8120. return ctx;
  8121. }
  8122. }, {
  8123. key: "_convertCanvasToImage",
  8124. value: function _convertCanvasToImage() {
  8125. var _this = this;
  8126. if (!this.canvas) {
  8127. return;
  8128. }
  8129. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  8130. return;
  8131. }
  8132. var id = this.renderingId;
  8133. var className = 'thumbnailImage';
  8134. if (this.disableCanvasToImageConversion) {
  8135. this.canvas.id = id;
  8136. this.canvas.className = className;
  8137. this.l10n.get('thumb_page_canvas', {
  8138. page: this.pageId
  8139. }, 'Thumbnail of Page {{page}}').then(function (msg) {
  8140. _this.canvas.setAttribute('aria-label', msg);
  8141. });
  8142. this.div.setAttribute('data-loaded', true);
  8143. this.ring.appendChild(this.canvas);
  8144. return;
  8145. }
  8146. var image = document.createElement('img');
  8147. image.id = id;
  8148. image.className = className;
  8149. this.l10n.get('thumb_page_canvas', {
  8150. page: this.pageId
  8151. }, 'Thumbnail of Page {{page}}').then(function (msg) {
  8152. image.setAttribute('aria-label', msg);
  8153. });
  8154. image.style.width = this.canvasWidth + 'px';
  8155. image.style.height = this.canvasHeight + 'px';
  8156. image.src = this.canvas.toDataURL();
  8157. this.image = image;
  8158. this.div.setAttribute('data-loaded', true);
  8159. this.ring.appendChild(image);
  8160. this.canvas.width = 0;
  8161. this.canvas.height = 0;
  8162. delete this.canvas;
  8163. }
  8164. }, {
  8165. key: "draw",
  8166. value: function draw() {
  8167. var _this2 = this;
  8168. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  8169. console.error('Must be in new state before drawing');
  8170. return Promise.resolve(undefined);
  8171. }
  8172. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  8173. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  8174. var finishRenderTask = function finishRenderTask(error) {
  8175. if (renderTask === _this2.renderTask) {
  8176. _this2.renderTask = null;
  8177. }
  8178. if (error instanceof _pdfjsLib.RenderingCancelledException) {
  8179. renderCapability.resolve(undefined);
  8180. return;
  8181. }
  8182. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  8183. _this2._convertCanvasToImage();
  8184. if (!error) {
  8185. renderCapability.resolve(undefined);
  8186. } else {
  8187. renderCapability.reject(error);
  8188. }
  8189. };
  8190. var ctx = this._getPageDrawContext();
  8191. var drawViewport = this.viewport.clone({
  8192. scale: this.scale
  8193. });
  8194. var renderContinueCallback = function renderContinueCallback(cont) {
  8195. if (!_this2.renderingQueue.isHighestPriority(_this2)) {
  8196. _this2.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  8197. _this2.resume = function () {
  8198. _this2.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  8199. cont();
  8200. };
  8201. return;
  8202. }
  8203. cont();
  8204. };
  8205. var renderContext = {
  8206. canvasContext: ctx,
  8207. viewport: drawViewport
  8208. };
  8209. var renderTask = this.renderTask = this.pdfPage.render(renderContext);
  8210. renderTask.onContinue = renderContinueCallback;
  8211. renderTask.promise.then(function () {
  8212. finishRenderTask(null);
  8213. }, function (error) {
  8214. finishRenderTask(error);
  8215. });
  8216. return renderCapability.promise;
  8217. }
  8218. }, {
  8219. key: "setImage",
  8220. value: function setImage(pageView) {
  8221. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  8222. return;
  8223. }
  8224. var img = pageView.canvas;
  8225. if (!img) {
  8226. return;
  8227. }
  8228. if (!this.pdfPage) {
  8229. this.setPdfPage(pageView.pdfPage);
  8230. }
  8231. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  8232. var ctx = this._getPageDrawContext(true);
  8233. var canvas = ctx.canvas;
  8234. if (img.width <= 2 * canvas.width) {
  8235. ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height);
  8236. this._convertCanvasToImage();
  8237. return;
  8238. }
  8239. var reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
  8240. var reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
  8241. var reducedImage = TempImageFactory.getCanvas(reducedWidth, reducedHeight);
  8242. var reducedImageCtx = reducedImage.getContext('2d');
  8243. while (reducedWidth > img.width || reducedHeight > img.height) {
  8244. reducedWidth >>= 1;
  8245. reducedHeight >>= 1;
  8246. }
  8247. reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0, reducedWidth, reducedHeight);
  8248. while (reducedWidth > 2 * canvas.width) {
  8249. reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, reducedWidth >> 1, reducedHeight >> 1);
  8250. reducedWidth >>= 1;
  8251. reducedHeight >>= 1;
  8252. }
  8253. ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height);
  8254. this._convertCanvasToImage();
  8255. }
  8256. }, {
  8257. key: "setPageLabel",
  8258. value: function setPageLabel(label) {
  8259. var _this3 = this;
  8260. this.pageLabel = typeof label === 'string' ? label : null;
  8261. this.l10n.get('thumb_page_title', {
  8262. page: this.pageId
  8263. }, 'Page {{page}}').then(function (msg) {
  8264. _this3.anchor.title = msg;
  8265. });
  8266. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  8267. return;
  8268. }
  8269. this.l10n.get('thumb_page_canvas', {
  8270. page: this.pageId
  8271. }, 'Thumbnail of Page {{page}}').then(function (ariaLabel) {
  8272. if (_this3.image) {
  8273. _this3.image.setAttribute('aria-label', ariaLabel);
  8274. } else if (_this3.disableCanvasToImageConversion && _this3.canvas) {
  8275. _this3.canvas.setAttribute('aria-label', ariaLabel);
  8276. }
  8277. });
  8278. }
  8279. }, {
  8280. key: "pageId",
  8281. get: function get() {
  8282. return this.pageLabel !== null ? this.pageLabel : this.id;
  8283. }
  8284. }], [{
  8285. key: "cleanup",
  8286. value: function cleanup() {
  8287. TempImageFactory.destroyCanvas();
  8288. }
  8289. }]);
  8290. return PDFThumbnailView;
  8291. }();
  8292. exports.PDFThumbnailView = PDFThumbnailView;
  8293. /***/ }),
  8294. /* 28 */
  8295. /***/ (function(module, exports, __webpack_require__) {
  8296. "use strict";
  8297. Object.defineProperty(exports, "__esModule", {
  8298. value: true
  8299. });
  8300. exports.PDFViewer = void 0;
  8301. var _base_viewer = __webpack_require__(29);
  8302. var _pdfjsLib = __webpack_require__(7);
  8303. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  8304. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8305. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  8306. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8307. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  8308. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  8309. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  8310. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  8311. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  8312. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  8313. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  8314. var PDFViewer =
  8315. /*#__PURE__*/
  8316. function (_BaseViewer) {
  8317. _inherits(PDFViewer, _BaseViewer);
  8318. function PDFViewer() {
  8319. _classCallCheck(this, PDFViewer);
  8320. return _possibleConstructorReturn(this, _getPrototypeOf(PDFViewer).apply(this, arguments));
  8321. }
  8322. _createClass(PDFViewer, [{
  8323. key: "_scrollIntoView",
  8324. value: function _scrollIntoView(_ref) {
  8325. var pageDiv = _ref.pageDiv,
  8326. _ref$pageSpot = _ref.pageSpot,
  8327. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  8328. _ref$pageNumber = _ref.pageNumber,
  8329. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  8330. if (!pageSpot && !this.isInPresentationMode) {
  8331. var left = pageDiv.offsetLeft + pageDiv.clientLeft;
  8332. var right = left + pageDiv.clientWidth;
  8333. var _this$container = this.container,
  8334. scrollLeft = _this$container.scrollLeft,
  8335. clientWidth = _this$container.clientWidth;
  8336. if (this._isScrollModeHorizontal || left < scrollLeft || right > scrollLeft + clientWidth) {
  8337. pageSpot = {
  8338. left: 0,
  8339. top: 0
  8340. };
  8341. }
  8342. }
  8343. _get(_getPrototypeOf(PDFViewer.prototype), "_scrollIntoView", this).call(this, {
  8344. pageDiv: pageDiv,
  8345. pageSpot: pageSpot,
  8346. pageNumber: pageNumber
  8347. });
  8348. }
  8349. }, {
  8350. key: "_getVisiblePages",
  8351. value: function _getVisiblePages() {
  8352. if (this.isInPresentationMode) {
  8353. return this._getCurrentVisiblePage();
  8354. }
  8355. return _get(_getPrototypeOf(PDFViewer.prototype), "_getVisiblePages", this).call(this);
  8356. }
  8357. }, {
  8358. key: "_updateHelper",
  8359. value: function _updateHelper(visiblePages) {
  8360. if (this.isInPresentationMode) {
  8361. return;
  8362. }
  8363. var currentId = this._currentPageNumber;
  8364. var stillFullyVisible = false;
  8365. var _iteratorNormalCompletion = true;
  8366. var _didIteratorError = false;
  8367. var _iteratorError = undefined;
  8368. try {
  8369. for (var _iterator = visiblePages[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  8370. var page = _step.value;
  8371. if (page.percent < 100) {
  8372. break;
  8373. }
  8374. if (page.id === currentId) {
  8375. stillFullyVisible = true;
  8376. break;
  8377. }
  8378. }
  8379. } catch (err) {
  8380. _didIteratorError = true;
  8381. _iteratorError = err;
  8382. } finally {
  8383. try {
  8384. if (!_iteratorNormalCompletion && _iterator.return != null) {
  8385. _iterator.return();
  8386. }
  8387. } finally {
  8388. if (_didIteratorError) {
  8389. throw _iteratorError;
  8390. }
  8391. }
  8392. }
  8393. if (!stillFullyVisible) {
  8394. currentId = visiblePages[0].id;
  8395. }
  8396. this._setCurrentPageNumber(currentId);
  8397. }
  8398. }, {
  8399. key: "_setDocumentViewerElement",
  8400. get: function get() {
  8401. return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this.viewer);
  8402. }
  8403. }]);
  8404. return PDFViewer;
  8405. }(_base_viewer.BaseViewer);
  8406. exports.PDFViewer = PDFViewer;
  8407. /***/ }),
  8408. /* 29 */
  8409. /***/ (function(module, exports, __webpack_require__) {
  8410. "use strict";
  8411. Object.defineProperty(exports, "__esModule", {
  8412. value: true
  8413. });
  8414. exports.BaseViewer = void 0;
  8415. var _ui_utils = __webpack_require__(6);
  8416. var _pdf_rendering_queue = __webpack_require__(10);
  8417. var _annotation_layer_builder = __webpack_require__(30);
  8418. var _pdfjsLib = __webpack_require__(7);
  8419. var _pdf_page_view = __webpack_require__(31);
  8420. var _pdf_link_service = __webpack_require__(22);
  8421. var _text_layer_builder = __webpack_require__(32);
  8422. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8423. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  8424. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8425. var DEFAULT_CACHE_SIZE = 10;
  8426. function PDFPageViewBuffer(size) {
  8427. var data = [];
  8428. this.push = function (view) {
  8429. var i = data.indexOf(view);
  8430. if (i >= 0) {
  8431. data.splice(i, 1);
  8432. }
  8433. data.push(view);
  8434. if (data.length > size) {
  8435. data.shift().destroy();
  8436. }
  8437. };
  8438. this.resize = function (newSize, pagesToKeep) {
  8439. size = newSize;
  8440. if (pagesToKeep) {
  8441. var pageIdsToKeep = new Set();
  8442. for (var i = 0, iMax = pagesToKeep.length; i < iMax; ++i) {
  8443. pageIdsToKeep.add(pagesToKeep[i].id);
  8444. }
  8445. (0, _ui_utils.moveToEndOfArray)(data, function (page) {
  8446. return pageIdsToKeep.has(page.id);
  8447. });
  8448. }
  8449. while (data.length > size) {
  8450. data.shift().destroy();
  8451. }
  8452. };
  8453. }
  8454. function isSameScale(oldScale, newScale) {
  8455. if (newScale === oldScale) {
  8456. return true;
  8457. }
  8458. if (Math.abs(newScale - oldScale) < 1e-15) {
  8459. return true;
  8460. }
  8461. return false;
  8462. }
  8463. var BaseViewer =
  8464. /*#__PURE__*/
  8465. function () {
  8466. function BaseViewer(options) {
  8467. var _this = this;
  8468. _classCallCheck(this, BaseViewer);
  8469. if (this.constructor === BaseViewer) {
  8470. throw new Error('Cannot initialize BaseViewer.');
  8471. }
  8472. this._name = this.constructor.name;
  8473. this.container = options.container;
  8474. this.viewer = options.viewer || options.container.firstElementChild;
  8475. this.eventBus = options.eventBus || (0, _ui_utils.getGlobalEventBus)();
  8476. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  8477. this.downloadManager = options.downloadManager || null;
  8478. this.findController = options.findController || null;
  8479. this.removePageBorders = options.removePageBorders || false;
  8480. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  8481. this.imageResourcesPath = options.imageResourcesPath || '';
  8482. this.renderInteractiveForms = options.renderInteractiveForms || false;
  8483. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  8484. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  8485. this.enableWebGL = options.enableWebGL || false;
  8486. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  8487. this.maxCanvasPixels = options.maxCanvasPixels;
  8488. this.l10n = options.l10n || _ui_utils.NullL10n;
  8489. this.defaultRenderingQueue = !options.renderingQueue;
  8490. if (this.defaultRenderingQueue) {
  8491. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  8492. this.renderingQueue.setViewer(this);
  8493. } else {
  8494. this.renderingQueue = options.renderingQueue;
  8495. }
  8496. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  8497. this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
  8498. this._resetView();
  8499. if (this.removePageBorders) {
  8500. this.viewer.classList.add('removePageBorders');
  8501. }
  8502. Promise.resolve().then(function () {
  8503. _this.eventBus.dispatch('baseviewerinit', {
  8504. source: _this
  8505. });
  8506. });
  8507. }
  8508. _createClass(BaseViewer, [{
  8509. key: "getPageView",
  8510. value: function getPageView(index) {
  8511. return this._pages[index];
  8512. }
  8513. }, {
  8514. key: "_setCurrentPageNumber",
  8515. value: function _setCurrentPageNumber(val) {
  8516. var resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  8517. if (this._currentPageNumber === val) {
  8518. if (resetCurrentPageView) {
  8519. this._resetCurrentPageView();
  8520. }
  8521. return true;
  8522. }
  8523. if (!(0 < val && val <= this.pagesCount)) {
  8524. return false;
  8525. }
  8526. this._currentPageNumber = val;
  8527. this.eventBus.dispatch('pagechanging', {
  8528. source: this,
  8529. pageNumber: val,
  8530. pageLabel: this._pageLabels && this._pageLabels[val - 1]
  8531. });
  8532. if (resetCurrentPageView) {
  8533. this._resetCurrentPageView();
  8534. }
  8535. return true;
  8536. }
  8537. }, {
  8538. key: "setDocument",
  8539. value: function setDocument(pdfDocument) {
  8540. var _this2 = this;
  8541. if (this.pdfDocument) {
  8542. this._cancelRendering();
  8543. this._resetView();
  8544. if (this.findController) {
  8545. this.findController.setDocument(null);
  8546. }
  8547. }
  8548. this.pdfDocument = pdfDocument;
  8549. if (!pdfDocument) {
  8550. return;
  8551. }
  8552. var pagesCount = pdfDocument.numPages;
  8553. var pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
  8554. this.pagesPromise = pagesCapability.promise;
  8555. pagesCapability.promise.then(function () {
  8556. _this2._pageViewsReady = true;
  8557. _this2.eventBus.dispatch('pagesloaded', {
  8558. source: _this2,
  8559. pagesCount: pagesCount
  8560. });
  8561. });
  8562. var onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  8563. this.onePageRendered = onePageRenderedCapability.promise;
  8564. var bindOnAfterAndBeforeDraw = function bindOnAfterAndBeforeDraw(pageView) {
  8565. pageView.onBeforeDraw = function () {
  8566. _this2._buffer.push(pageView);
  8567. };
  8568. pageView.onAfterDraw = function () {
  8569. if (!onePageRenderedCapability.settled) {
  8570. onePageRenderedCapability.resolve();
  8571. }
  8572. };
  8573. };
  8574. var firstPagePromise = pdfDocument.getPage(1);
  8575. this.firstPagePromise = firstPagePromise;
  8576. firstPagePromise.then(function (pdfPage) {
  8577. var scale = _this2.currentScale;
  8578. var viewport = pdfPage.getViewport({
  8579. scale: scale * _ui_utils.CSS_UNITS
  8580. });
  8581. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  8582. var textLayerFactory = null;
  8583. if (_this2.textLayerMode !== _ui_utils.TextLayerMode.DISABLE) {
  8584. textLayerFactory = _this2;
  8585. }
  8586. var pageView = new _pdf_page_view.PDFPageView({
  8587. container: _this2._setDocumentViewerElement,
  8588. eventBus: _this2.eventBus,
  8589. id: pageNum,
  8590. scale: scale,
  8591. defaultViewport: viewport.clone(),
  8592. renderingQueue: _this2.renderingQueue,
  8593. textLayerFactory: textLayerFactory,
  8594. textLayerMode: _this2.textLayerMode,
  8595. annotationLayerFactory: _this2,
  8596. imageResourcesPath: _this2.imageResourcesPath,
  8597. renderInteractiveForms: _this2.renderInteractiveForms,
  8598. renderer: _this2.renderer,
  8599. enableWebGL: _this2.enableWebGL,
  8600. useOnlyCssZoom: _this2.useOnlyCssZoom,
  8601. maxCanvasPixels: _this2.maxCanvasPixels,
  8602. l10n: _this2.l10n
  8603. });
  8604. bindOnAfterAndBeforeDraw(pageView);
  8605. _this2._pages.push(pageView);
  8606. }
  8607. if (_this2._spreadMode !== _ui_utils.SpreadMode.NONE) {
  8608. _this2._updateSpreadMode();
  8609. }
  8610. onePageRenderedCapability.promise.then(function () {
  8611. if (pdfDocument.loadingParams['disableAutoFetch']) {
  8612. pagesCapability.resolve();
  8613. return;
  8614. }
  8615. var getPagesLeft = pagesCount;
  8616. var _loop = function _loop(_pageNum) {
  8617. pdfDocument.getPage(_pageNum).then(function (pdfPage) {
  8618. var pageView = _this2._pages[_pageNum - 1];
  8619. if (!pageView.pdfPage) {
  8620. pageView.setPdfPage(pdfPage);
  8621. }
  8622. _this2.linkService.cachePageRef(_pageNum, pdfPage.ref);
  8623. if (--getPagesLeft === 0) {
  8624. pagesCapability.resolve();
  8625. }
  8626. }, function (reason) {
  8627. console.error("Unable to get page ".concat(_pageNum, " to initialize viewer"), reason);
  8628. if (--getPagesLeft === 0) {
  8629. pagesCapability.resolve();
  8630. }
  8631. });
  8632. };
  8633. for (var _pageNum = 1; _pageNum <= pagesCount; ++_pageNum) {
  8634. _loop(_pageNum);
  8635. }
  8636. });
  8637. _this2.eventBus.dispatch('pagesinit', {
  8638. source: _this2
  8639. });
  8640. if (_this2.findController) {
  8641. _this2.findController.setDocument(pdfDocument);
  8642. }
  8643. if (_this2.defaultRenderingQueue) {
  8644. _this2.update();
  8645. }
  8646. }).catch(function (reason) {
  8647. console.error('Unable to initialize viewer', reason);
  8648. });
  8649. }
  8650. }, {
  8651. key: "setPageLabels",
  8652. value: function setPageLabels(labels) {
  8653. if (!this.pdfDocument) {
  8654. return;
  8655. }
  8656. if (!labels) {
  8657. this._pageLabels = null;
  8658. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  8659. this._pageLabels = null;
  8660. console.error("".concat(this._name, ".setPageLabels: Invalid page labels."));
  8661. } else {
  8662. this._pageLabels = labels;
  8663. }
  8664. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  8665. var pageView = this._pages[i];
  8666. var label = this._pageLabels && this._pageLabels[i];
  8667. pageView.setPageLabel(label);
  8668. }
  8669. }
  8670. }, {
  8671. key: "_resetView",
  8672. value: function _resetView() {
  8673. this._pages = [];
  8674. this._currentPageNumber = 1;
  8675. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  8676. this._currentScaleValue = null;
  8677. this._pageLabels = null;
  8678. this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  8679. this._location = null;
  8680. this._pagesRotation = 0;
  8681. this._pagesRequests = [];
  8682. this._pageViewsReady = false;
  8683. this._scrollMode = _ui_utils.ScrollMode.VERTICAL;
  8684. this._spreadMode = _ui_utils.SpreadMode.NONE;
  8685. this.viewer.textContent = '';
  8686. this._updateScrollMode();
  8687. }
  8688. }, {
  8689. key: "_scrollUpdate",
  8690. value: function _scrollUpdate() {
  8691. if (this.pagesCount === 0) {
  8692. return;
  8693. }
  8694. this.update();
  8695. }
  8696. }, {
  8697. key: "_scrollIntoView",
  8698. value: function _scrollIntoView(_ref) {
  8699. var pageDiv = _ref.pageDiv,
  8700. _ref$pageSpot = _ref.pageSpot,
  8701. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  8702. _ref$pageNumber = _ref.pageNumber,
  8703. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  8704. (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
  8705. }
  8706. }, {
  8707. key: "_setScaleUpdatePages",
  8708. value: function _setScaleUpdatePages(newScale, newValue) {
  8709. var noScroll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  8710. var preset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  8711. this._currentScaleValue = newValue.toString();
  8712. if (isSameScale(this._currentScale, newScale)) {
  8713. if (preset) {
  8714. this.eventBus.dispatch('scalechanging', {
  8715. source: this,
  8716. scale: newScale,
  8717. presetValue: newValue
  8718. });
  8719. }
  8720. return;
  8721. }
  8722. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  8723. this._pages[i].update(newScale);
  8724. }
  8725. this._currentScale = newScale;
  8726. if (!noScroll) {
  8727. var page = this._currentPageNumber,
  8728. dest;
  8729. if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  8730. page = this._location.pageNumber;
  8731. dest = [null, {
  8732. name: 'XYZ'
  8733. }, this._location.left, this._location.top, null];
  8734. }
  8735. this.scrollPageIntoView({
  8736. pageNumber: page,
  8737. destArray: dest,
  8738. allowNegativeOffset: true
  8739. });
  8740. }
  8741. this.eventBus.dispatch('scalechanging', {
  8742. source: this,
  8743. scale: newScale,
  8744. presetValue: preset ? newValue : undefined
  8745. });
  8746. if (this.defaultRenderingQueue) {
  8747. this.update();
  8748. }
  8749. }
  8750. }, {
  8751. key: "_setScale",
  8752. value: function _setScale(value) {
  8753. var noScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  8754. var scale = parseFloat(value);
  8755. if (scale > 0) {
  8756. this._setScaleUpdatePages(scale, value, noScroll, false);
  8757. } else {
  8758. var currentPage = this._pages[this._currentPageNumber - 1];
  8759. if (!currentPage) {
  8760. return;
  8761. }
  8762. var noPadding = this.isInPresentationMode || this.removePageBorders;
  8763. var hPadding = noPadding ? 0 : _ui_utils.SCROLLBAR_PADDING;
  8764. var vPadding = noPadding ? 0 : _ui_utils.VERTICAL_PADDING;
  8765. if (!noPadding && this._isScrollModeHorizontal) {
  8766. var _ref2 = [vPadding, hPadding];
  8767. hPadding = _ref2[0];
  8768. vPadding = _ref2[1];
  8769. }
  8770. var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale;
  8771. var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  8772. switch (value) {
  8773. case 'page-actual':
  8774. scale = 1;
  8775. break;
  8776. case 'page-width':
  8777. scale = pageWidthScale;
  8778. break;
  8779. case 'page-height':
  8780. scale = pageHeightScale;
  8781. break;
  8782. case 'page-fit':
  8783. scale = Math.min(pageWidthScale, pageHeightScale);
  8784. break;
  8785. case 'auto':
  8786. var horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
  8787. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  8788. break;
  8789. default:
  8790. console.error("".concat(this._name, "._setScale: \"").concat(value, "\" is an unknown zoom value."));
  8791. return;
  8792. }
  8793. this._setScaleUpdatePages(scale, value, noScroll, true);
  8794. }
  8795. }
  8796. }, {
  8797. key: "_resetCurrentPageView",
  8798. value: function _resetCurrentPageView() {
  8799. if (this.isInPresentationMode) {
  8800. this._setScale(this._currentScaleValue, true);
  8801. }
  8802. var pageView = this._pages[this._currentPageNumber - 1];
  8803. this._scrollIntoView({
  8804. pageDiv: pageView.div
  8805. });
  8806. }
  8807. }, {
  8808. key: "scrollPageIntoView",
  8809. value: function scrollPageIntoView(_ref3) {
  8810. var pageNumber = _ref3.pageNumber,
  8811. _ref3$destArray = _ref3.destArray,
  8812. destArray = _ref3$destArray === void 0 ? null : _ref3$destArray,
  8813. _ref3$allowNegativeOf = _ref3.allowNegativeOffset,
  8814. allowNegativeOffset = _ref3$allowNegativeOf === void 0 ? false : _ref3$allowNegativeOf;
  8815. if (!this.pdfDocument) {
  8816. return;
  8817. }
  8818. var pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1];
  8819. if (!pageView) {
  8820. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  8821. return;
  8822. }
  8823. if (this.isInPresentationMode || !destArray) {
  8824. this._setCurrentPageNumber(pageNumber, true);
  8825. return;
  8826. }
  8827. var x = 0,
  8828. y = 0;
  8829. var width = 0,
  8830. height = 0,
  8831. widthScale,
  8832. heightScale;
  8833. var changeOrientation = pageView.rotation % 180 === 0 ? false : true;
  8834. var pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;
  8835. var pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;
  8836. var scale = 0;
  8837. switch (destArray[1].name) {
  8838. case 'XYZ':
  8839. x = destArray[2];
  8840. y = destArray[3];
  8841. scale = destArray[4];
  8842. x = x !== null ? x : 0;
  8843. y = y !== null ? y : pageHeight;
  8844. break;
  8845. case 'Fit':
  8846. case 'FitB':
  8847. scale = 'page-fit';
  8848. break;
  8849. case 'FitH':
  8850. case 'FitBH':
  8851. y = destArray[2];
  8852. scale = 'page-width';
  8853. if (y === null && this._location) {
  8854. x = this._location.left;
  8855. y = this._location.top;
  8856. }
  8857. break;
  8858. case 'FitV':
  8859. case 'FitBV':
  8860. x = destArray[2];
  8861. width = pageWidth;
  8862. height = pageHeight;
  8863. scale = 'page-height';
  8864. break;
  8865. case 'FitR':
  8866. x = destArray[2];
  8867. y = destArray[3];
  8868. width = destArray[4] - x;
  8869. height = destArray[5] - y;
  8870. var hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  8871. var vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  8872. widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;
  8873. heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;
  8874. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  8875. break;
  8876. default:
  8877. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(destArray[1].name, "\" is not a valid destination type."));
  8878. return;
  8879. }
  8880. if (scale && scale !== this._currentScale) {
  8881. this.currentScaleValue = scale;
  8882. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  8883. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  8884. }
  8885. if (scale === 'page-fit' && !destArray[4]) {
  8886. this._scrollIntoView({
  8887. pageDiv: pageView.div,
  8888. pageNumber: pageNumber
  8889. });
  8890. return;
  8891. }
  8892. var boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  8893. var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  8894. var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  8895. if (!allowNegativeOffset) {
  8896. left = Math.max(left, 0);
  8897. top = Math.max(top, 0);
  8898. }
  8899. this._scrollIntoView({
  8900. pageDiv: pageView.div,
  8901. pageSpot: {
  8902. left: left,
  8903. top: top
  8904. },
  8905. pageNumber: pageNumber
  8906. });
  8907. }
  8908. }, {
  8909. key: "_updateLocation",
  8910. value: function _updateLocation(firstPage) {
  8911. var currentScale = this._currentScale;
  8912. var currentScaleValue = this._currentScaleValue;
  8913. var normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  8914. var pageNumber = firstPage.id;
  8915. var pdfOpenParams = '#page=' + pageNumber;
  8916. pdfOpenParams += '&zoom=' + normalizedScaleValue;
  8917. var currentPageView = this._pages[pageNumber - 1];
  8918. var container = this.container;
  8919. var topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  8920. var intLeft = Math.round(topLeft[0]);
  8921. var intTop = Math.round(topLeft[1]);
  8922. pdfOpenParams += ',' + intLeft + ',' + intTop;
  8923. this._location = {
  8924. pageNumber: pageNumber,
  8925. scale: normalizedScaleValue,
  8926. top: intTop,
  8927. left: intLeft,
  8928. rotation: this._pagesRotation,
  8929. pdfOpenParams: pdfOpenParams
  8930. };
  8931. }
  8932. }, {
  8933. key: "_updateHelper",
  8934. value: function _updateHelper(visiblePages) {
  8935. throw new Error('Not implemented: _updateHelper');
  8936. }
  8937. }, {
  8938. key: "update",
  8939. value: function update() {
  8940. var visible = this._getVisiblePages();
  8941. var visiblePages = visible.views,
  8942. numVisiblePages = visiblePages.length;
  8943. if (numVisiblePages === 0) {
  8944. return;
  8945. }
  8946. var newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
  8947. this._buffer.resize(newCacheSize, visiblePages);
  8948. this.renderingQueue.renderHighestPriority(visible);
  8949. this._updateHelper(visiblePages);
  8950. this._updateLocation(visible.first);
  8951. this.eventBus.dispatch('updateviewarea', {
  8952. source: this,
  8953. location: this._location
  8954. });
  8955. }
  8956. }, {
  8957. key: "containsElement",
  8958. value: function containsElement(element) {
  8959. return this.container.contains(element);
  8960. }
  8961. }, {
  8962. key: "focus",
  8963. value: function focus() {
  8964. this.container.focus();
  8965. }
  8966. }, {
  8967. key: "_getCurrentVisiblePage",
  8968. value: function _getCurrentVisiblePage() {
  8969. if (!this.pagesCount) {
  8970. return {
  8971. views: []
  8972. };
  8973. }
  8974. var pageView = this._pages[this._currentPageNumber - 1];
  8975. var element = pageView.div;
  8976. var view = {
  8977. id: pageView.id,
  8978. x: element.offsetLeft + element.clientLeft,
  8979. y: element.offsetTop + element.clientTop,
  8980. view: pageView
  8981. };
  8982. return {
  8983. first: view,
  8984. last: view,
  8985. views: [view]
  8986. };
  8987. }
  8988. }, {
  8989. key: "_getVisiblePages",
  8990. value: function _getVisiblePages() {
  8991. return (0, _ui_utils.getVisibleElements)(this.container, this._pages, true, this._isScrollModeHorizontal);
  8992. }
  8993. }, {
  8994. key: "isPageVisible",
  8995. value: function isPageVisible(pageNumber) {
  8996. if (!this.pdfDocument) {
  8997. return false;
  8998. }
  8999. if (this.pageNumber < 1 || pageNumber > this.pagesCount) {
  9000. console.error("".concat(this._name, ".isPageVisible: \"").concat(pageNumber, "\" is out of bounds."));
  9001. return false;
  9002. }
  9003. return this._getVisiblePages().views.some(function (view) {
  9004. return view.id === pageNumber;
  9005. });
  9006. }
  9007. }, {
  9008. key: "cleanup",
  9009. value: function cleanup() {
  9010. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  9011. if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  9012. this._pages[i].reset();
  9013. }
  9014. }
  9015. }
  9016. }, {
  9017. key: "_cancelRendering",
  9018. value: function _cancelRendering() {
  9019. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  9020. if (this._pages[i]) {
  9021. this._pages[i].cancelRendering();
  9022. }
  9023. }
  9024. }
  9025. }, {
  9026. key: "_ensurePdfPageLoaded",
  9027. value: function _ensurePdfPageLoaded(pageView) {
  9028. var _this3 = this;
  9029. if (pageView.pdfPage) {
  9030. return Promise.resolve(pageView.pdfPage);
  9031. }
  9032. var pageNumber = pageView.id;
  9033. if (this._pagesRequests[pageNumber]) {
  9034. return this._pagesRequests[pageNumber];
  9035. }
  9036. var promise = this.pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  9037. if (!pageView.pdfPage) {
  9038. pageView.setPdfPage(pdfPage);
  9039. }
  9040. _this3._pagesRequests[pageNumber] = null;
  9041. return pdfPage;
  9042. }).catch(function (reason) {
  9043. console.error('Unable to get page for page view', reason);
  9044. _this3._pagesRequests[pageNumber] = null;
  9045. });
  9046. this._pagesRequests[pageNumber] = promise;
  9047. return promise;
  9048. }
  9049. }, {
  9050. key: "forceRendering",
  9051. value: function forceRendering(currentlyVisiblePages) {
  9052. var _this4 = this;
  9053. var visiblePages = currentlyVisiblePages || this._getVisiblePages();
  9054. var scrollAhead = this._isScrollModeHorizontal ? this.scroll.right : this.scroll.down;
  9055. var pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead);
  9056. if (pageView) {
  9057. this._ensurePdfPageLoaded(pageView).then(function () {
  9058. _this4.renderingQueue.renderView(pageView);
  9059. });
  9060. return true;
  9061. }
  9062. return false;
  9063. }
  9064. }, {
  9065. key: "createTextLayerBuilder",
  9066. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  9067. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9068. return new _text_layer_builder.TextLayerBuilder({
  9069. textLayerDiv: textLayerDiv,
  9070. eventBus: this.eventBus,
  9071. pageIndex: pageIndex,
  9072. viewport: viewport,
  9073. findController: this.isInPresentationMode ? null : this.findController,
  9074. enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection
  9075. });
  9076. }
  9077. }, {
  9078. key: "createAnnotationLayerBuilder",
  9079. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  9080. var imageResourcesPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  9081. var renderInteractiveForms = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9082. var l10n = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _ui_utils.NullL10n;
  9083. return new _annotation_layer_builder.AnnotationLayerBuilder({
  9084. pageDiv: pageDiv,
  9085. pdfPage: pdfPage,
  9086. imageResourcesPath: imageResourcesPath,
  9087. renderInteractiveForms: renderInteractiveForms,
  9088. linkService: this.linkService,
  9089. downloadManager: this.downloadManager,
  9090. l10n: l10n
  9091. });
  9092. }
  9093. }, {
  9094. key: "getPagesOverview",
  9095. value: function getPagesOverview() {
  9096. var pagesOverview = this._pages.map(function (pageView) {
  9097. var viewport = pageView.pdfPage.getViewport({
  9098. scale: 1
  9099. });
  9100. return {
  9101. width: viewport.width,
  9102. height: viewport.height,
  9103. rotation: viewport.rotation
  9104. };
  9105. });
  9106. if (!this.enablePrintAutoRotate) {
  9107. return pagesOverview;
  9108. }
  9109. var isFirstPagePortrait = (0, _ui_utils.isPortraitOrientation)(pagesOverview[0]);
  9110. return pagesOverview.map(function (size) {
  9111. if (isFirstPagePortrait === (0, _ui_utils.isPortraitOrientation)(size)) {
  9112. return size;
  9113. }
  9114. return {
  9115. width: size.height,
  9116. height: size.width,
  9117. rotation: (size.rotation + 90) % 360
  9118. };
  9119. });
  9120. }
  9121. }, {
  9122. key: "_updateScrollMode",
  9123. value: function _updateScrollMode() {
  9124. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  9125. var scrollMode = this._scrollMode,
  9126. viewer = this.viewer;
  9127. viewer.classList.toggle('scrollHorizontal', scrollMode === _ui_utils.ScrollMode.HORIZONTAL);
  9128. viewer.classList.toggle('scrollWrapped', scrollMode === _ui_utils.ScrollMode.WRAPPED);
  9129. if (!this.pdfDocument || !pageNumber) {
  9130. return;
  9131. }
  9132. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  9133. this._setScale(this._currentScaleValue, true);
  9134. }
  9135. this._setCurrentPageNumber(pageNumber, true);
  9136. this.update();
  9137. }
  9138. }, {
  9139. key: "_updateSpreadMode",
  9140. value: function _updateSpreadMode() {
  9141. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  9142. if (!this.pdfDocument) {
  9143. return;
  9144. }
  9145. var viewer = this.viewer,
  9146. pages = this._pages;
  9147. viewer.textContent = '';
  9148. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  9149. for (var i = 0, iMax = pages.length; i < iMax; ++i) {
  9150. viewer.appendChild(pages[i].div);
  9151. }
  9152. } else {
  9153. var parity = this._spreadMode - 1;
  9154. var spread = null;
  9155. for (var _i = 0, _iMax = pages.length; _i < _iMax; ++_i) {
  9156. if (spread === null) {
  9157. spread = document.createElement('div');
  9158. spread.className = 'spread';
  9159. viewer.appendChild(spread);
  9160. } else if (_i % 2 === parity) {
  9161. spread = spread.cloneNode(false);
  9162. viewer.appendChild(spread);
  9163. }
  9164. spread.appendChild(pages[_i].div);
  9165. }
  9166. }
  9167. if (!pageNumber) {
  9168. return;
  9169. }
  9170. this._setCurrentPageNumber(pageNumber, true);
  9171. this.update();
  9172. }
  9173. }, {
  9174. key: "pagesCount",
  9175. get: function get() {
  9176. return this._pages.length;
  9177. }
  9178. }, {
  9179. key: "pageViewsReady",
  9180. get: function get() {
  9181. return this._pageViewsReady;
  9182. }
  9183. }, {
  9184. key: "currentPageNumber",
  9185. get: function get() {
  9186. return this._currentPageNumber;
  9187. },
  9188. set: function set(val) {
  9189. if (!Number.isInteger(val)) {
  9190. throw new Error('Invalid page number.');
  9191. }
  9192. if (!this.pdfDocument) {
  9193. return;
  9194. }
  9195. if (!this._setCurrentPageNumber(val, true)) {
  9196. console.error("".concat(this._name, ".currentPageNumber: \"").concat(val, "\" is not a valid page."));
  9197. }
  9198. }
  9199. }, {
  9200. key: "currentPageLabel",
  9201. get: function get() {
  9202. return this._pageLabels && this._pageLabels[this._currentPageNumber - 1];
  9203. },
  9204. set: function set(val) {
  9205. if (!this.pdfDocument) {
  9206. return;
  9207. }
  9208. var page = val | 0;
  9209. if (this._pageLabels) {
  9210. var i = this._pageLabels.indexOf(val);
  9211. if (i >= 0) {
  9212. page = i + 1;
  9213. }
  9214. }
  9215. if (!this._setCurrentPageNumber(page, true)) {
  9216. console.error("".concat(this._name, ".currentPageLabel: \"").concat(val, "\" is not a valid page."));
  9217. }
  9218. }
  9219. }, {
  9220. key: "currentScale",
  9221. get: function get() {
  9222. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
  9223. },
  9224. set: function set(val) {
  9225. if (isNaN(val)) {
  9226. throw new Error('Invalid numeric scale.');
  9227. }
  9228. if (!this.pdfDocument) {
  9229. return;
  9230. }
  9231. this._setScale(val, false);
  9232. }
  9233. }, {
  9234. key: "currentScaleValue",
  9235. get: function get() {
  9236. return this._currentScaleValue;
  9237. },
  9238. set: function set(val) {
  9239. if (!this.pdfDocument) {
  9240. return;
  9241. }
  9242. this._setScale(val, false);
  9243. }
  9244. }, {
  9245. key: "pagesRotation",
  9246. get: function get() {
  9247. return this._pagesRotation;
  9248. },
  9249. set: function set(rotation) {
  9250. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  9251. throw new Error('Invalid pages rotation angle.');
  9252. }
  9253. if (!this.pdfDocument) {
  9254. return;
  9255. }
  9256. if (this._pagesRotation === rotation) {
  9257. return;
  9258. }
  9259. this._pagesRotation = rotation;
  9260. var pageNumber = this._currentPageNumber;
  9261. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  9262. var pageView = this._pages[i];
  9263. pageView.update(pageView.scale, rotation);
  9264. }
  9265. if (this._currentScaleValue) {
  9266. this._setScale(this._currentScaleValue, true);
  9267. }
  9268. this.eventBus.dispatch('rotationchanging', {
  9269. source: this,
  9270. pagesRotation: rotation,
  9271. pageNumber: pageNumber
  9272. });
  9273. if (this.defaultRenderingQueue) {
  9274. this.update();
  9275. }
  9276. }
  9277. }, {
  9278. key: "_setDocumentViewerElement",
  9279. get: function get() {
  9280. throw new Error('Not implemented: _setDocumentViewerElement');
  9281. }
  9282. }, {
  9283. key: "_isScrollModeHorizontal",
  9284. get: function get() {
  9285. return this.isInPresentationMode ? false : this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL;
  9286. }
  9287. }, {
  9288. key: "isInPresentationMode",
  9289. get: function get() {
  9290. return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
  9291. }
  9292. }, {
  9293. key: "isChangingPresentationMode",
  9294. get: function get() {
  9295. return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
  9296. }
  9297. }, {
  9298. key: "isHorizontalScrollbarEnabled",
  9299. get: function get() {
  9300. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  9301. }
  9302. }, {
  9303. key: "isVerticalScrollbarEnabled",
  9304. get: function get() {
  9305. return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight;
  9306. }
  9307. }, {
  9308. key: "hasEqualPageSizes",
  9309. get: function get() {
  9310. var firstPageView = this._pages[0];
  9311. for (var i = 1, ii = this._pages.length; i < ii; ++i) {
  9312. var pageView = this._pages[i];
  9313. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  9314. return false;
  9315. }
  9316. }
  9317. return true;
  9318. }
  9319. }, {
  9320. key: "scrollMode",
  9321. get: function get() {
  9322. return this._scrollMode;
  9323. },
  9324. set: function set(mode) {
  9325. if (this._scrollMode === mode) {
  9326. return;
  9327. }
  9328. if (!(0, _ui_utils.isValidScrollMode)(mode)) {
  9329. throw new Error("Invalid scroll mode: ".concat(mode));
  9330. }
  9331. this._scrollMode = mode;
  9332. this.eventBus.dispatch('scrollmodechanged', {
  9333. source: this,
  9334. mode: mode
  9335. });
  9336. this._updateScrollMode(this._currentPageNumber);
  9337. }
  9338. }, {
  9339. key: "spreadMode",
  9340. get: function get() {
  9341. return this._spreadMode;
  9342. },
  9343. set: function set(mode) {
  9344. if (this._spreadMode === mode) {
  9345. return;
  9346. }
  9347. if (!(0, _ui_utils.isValidSpreadMode)(mode)) {
  9348. throw new Error("Invalid spread mode: ".concat(mode));
  9349. }
  9350. this._spreadMode = mode;
  9351. this.eventBus.dispatch('spreadmodechanged', {
  9352. source: this,
  9353. mode: mode
  9354. });
  9355. this._updateSpreadMode(this._currentPageNumber);
  9356. }
  9357. }]);
  9358. return BaseViewer;
  9359. }();
  9360. exports.BaseViewer = BaseViewer;
  9361. /***/ }),
  9362. /* 30 */
  9363. /***/ (function(module, exports, __webpack_require__) {
  9364. "use strict";
  9365. Object.defineProperty(exports, "__esModule", {
  9366. value: true
  9367. });
  9368. exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = void 0;
  9369. var _pdfjsLib = __webpack_require__(7);
  9370. var _ui_utils = __webpack_require__(6);
  9371. var _pdf_link_service = __webpack_require__(22);
  9372. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9373. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  9374. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9375. var AnnotationLayerBuilder =
  9376. /*#__PURE__*/
  9377. function () {
  9378. function AnnotationLayerBuilder(_ref) {
  9379. var pageDiv = _ref.pageDiv,
  9380. pdfPage = _ref.pdfPage,
  9381. linkService = _ref.linkService,
  9382. downloadManager = _ref.downloadManager,
  9383. _ref$imageResourcesPa = _ref.imageResourcesPath,
  9384. imageResourcesPath = _ref$imageResourcesPa === void 0 ? '' : _ref$imageResourcesPa,
  9385. _ref$renderInteractiv = _ref.renderInteractiveForms,
  9386. renderInteractiveForms = _ref$renderInteractiv === void 0 ? false : _ref$renderInteractiv,
  9387. _ref$l10n = _ref.l10n,
  9388. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  9389. _classCallCheck(this, AnnotationLayerBuilder);
  9390. this.pageDiv = pageDiv;
  9391. this.pdfPage = pdfPage;
  9392. this.linkService = linkService;
  9393. this.downloadManager = downloadManager;
  9394. this.imageResourcesPath = imageResourcesPath;
  9395. this.renderInteractiveForms = renderInteractiveForms;
  9396. this.l10n = l10n;
  9397. this.div = null;
  9398. this._cancelled = false;
  9399. }
  9400. _createClass(AnnotationLayerBuilder, [{
  9401. key: "render",
  9402. value: function render(viewport) {
  9403. var _this = this;
  9404. var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'display';
  9405. this.pdfPage.getAnnotations({
  9406. intent: intent
  9407. }).then(function (annotations) {
  9408. if (_this._cancelled) {
  9409. return;
  9410. }
  9411. var parameters = {
  9412. viewport: viewport.clone({
  9413. dontFlip: true
  9414. }),
  9415. div: _this.div,
  9416. annotations: annotations,
  9417. page: _this.pdfPage,
  9418. imageResourcesPath: _this.imageResourcesPath,
  9419. renderInteractiveForms: _this.renderInteractiveForms,
  9420. linkService: _this.linkService,
  9421. downloadManager: _this.downloadManager
  9422. };
  9423. if (_this.div) {
  9424. _pdfjsLib.AnnotationLayer.update(parameters);
  9425. } else {
  9426. if (annotations.length === 0) {
  9427. return;
  9428. }
  9429. _this.div = document.createElement('div');
  9430. _this.div.className = 'annotationLayer';
  9431. _this.pageDiv.appendChild(_this.div);
  9432. parameters.div = _this.div;
  9433. _pdfjsLib.AnnotationLayer.render(parameters);
  9434. _this.l10n.translate(_this.div);
  9435. }
  9436. });
  9437. }
  9438. }, {
  9439. key: "cancel",
  9440. value: function cancel() {
  9441. this._cancelled = true;
  9442. }
  9443. }, {
  9444. key: "hide",
  9445. value: function hide() {
  9446. if (!this.div) {
  9447. return;
  9448. }
  9449. this.div.setAttribute('hidden', 'true');
  9450. }
  9451. }]);
  9452. return AnnotationLayerBuilder;
  9453. }();
  9454. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  9455. var DefaultAnnotationLayerFactory =
  9456. /*#__PURE__*/
  9457. function () {
  9458. function DefaultAnnotationLayerFactory() {
  9459. _classCallCheck(this, DefaultAnnotationLayerFactory);
  9460. }
  9461. _createClass(DefaultAnnotationLayerFactory, [{
  9462. key: "createAnnotationLayerBuilder",
  9463. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  9464. var imageResourcesPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  9465. var renderInteractiveForms = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9466. var l10n = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _ui_utils.NullL10n;
  9467. return new AnnotationLayerBuilder({
  9468. pageDiv: pageDiv,
  9469. pdfPage: pdfPage,
  9470. imageResourcesPath: imageResourcesPath,
  9471. renderInteractiveForms: renderInteractiveForms,
  9472. linkService: new _pdf_link_service.SimpleLinkService(),
  9473. l10n: l10n
  9474. });
  9475. }
  9476. }]);
  9477. return DefaultAnnotationLayerFactory;
  9478. }();
  9479. exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
  9480. /***/ }),
  9481. /* 31 */
  9482. /***/ (function(module, exports, __webpack_require__) {
  9483. "use strict";
  9484. Object.defineProperty(exports, "__esModule", {
  9485. value: true
  9486. });
  9487. exports.PDFPageView = void 0;
  9488. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  9489. var _ui_utils = __webpack_require__(6);
  9490. var _pdfjsLib = __webpack_require__(7);
  9491. var _pdf_rendering_queue = __webpack_require__(10);
  9492. var _viewer_compatibility = __webpack_require__(13);
  9493. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9494. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  9495. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  9496. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9497. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  9498. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9499. var MAX_CANVAS_PIXELS = _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216;
  9500. var PDFPageView =
  9501. /*#__PURE__*/
  9502. function () {
  9503. function PDFPageView(options) {
  9504. _classCallCheck(this, PDFPageView);
  9505. var container = options.container;
  9506. var defaultViewport = options.defaultViewport;
  9507. this.id = options.id;
  9508. this.renderingId = 'page' + this.id;
  9509. this.pdfPage = null;
  9510. this.pageLabel = null;
  9511. this.rotation = 0;
  9512. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  9513. this.viewport = defaultViewport;
  9514. this.pdfPageRotate = defaultViewport.rotation;
  9515. this.hasRestrictedScaling = false;
  9516. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  9517. this.imageResourcesPath = options.imageResourcesPath || '';
  9518. this.renderInteractiveForms = options.renderInteractiveForms || false;
  9519. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  9520. this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
  9521. this.eventBus = options.eventBus || (0, _ui_utils.getGlobalEventBus)();
  9522. this.renderingQueue = options.renderingQueue;
  9523. this.textLayerFactory = options.textLayerFactory;
  9524. this.annotationLayerFactory = options.annotationLayerFactory;
  9525. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  9526. this.enableWebGL = options.enableWebGL || false;
  9527. this.l10n = options.l10n || _ui_utils.NullL10n;
  9528. this.paintTask = null;
  9529. this.paintedViewportMap = new WeakMap();
  9530. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  9531. this.resume = null;
  9532. this.error = null;
  9533. this.onBeforeDraw = null;
  9534. this.onAfterDraw = null;
  9535. this.annotationLayer = null;
  9536. this.textLayer = null;
  9537. this.zoomLayer = null;
  9538. var div = document.createElement('div');
  9539. div.className = 'page';
  9540. div.style.width = Math.floor(this.viewport.width) + 'px';
  9541. div.style.height = Math.floor(this.viewport.height) + 'px';
  9542. div.setAttribute('data-page-number', this.id);
  9543. this.div = div;
  9544. container.appendChild(div);
  9545. }
  9546. _createClass(PDFPageView, [{
  9547. key: "setPdfPage",
  9548. value: function setPdfPage(pdfPage) {
  9549. this.pdfPage = pdfPage;
  9550. this.pdfPageRotate = pdfPage.rotate;
  9551. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  9552. this.viewport = pdfPage.getViewport({
  9553. scale: this.scale * _ui_utils.CSS_UNITS,
  9554. rotation: totalRotation
  9555. });
  9556. this.stats = pdfPage.stats;
  9557. this.reset();
  9558. }
  9559. }, {
  9560. key: "destroy",
  9561. value: function destroy() {
  9562. this.reset();
  9563. if (this.pdfPage) {
  9564. this.pdfPage.cleanup();
  9565. }
  9566. }
  9567. }, {
  9568. key: "_resetZoomLayer",
  9569. value: function _resetZoomLayer() {
  9570. var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9571. if (!this.zoomLayer) {
  9572. return;
  9573. }
  9574. var zoomLayerCanvas = this.zoomLayer.firstChild;
  9575. this.paintedViewportMap.delete(zoomLayerCanvas);
  9576. zoomLayerCanvas.width = 0;
  9577. zoomLayerCanvas.height = 0;
  9578. if (removeFromDOM) {
  9579. this.zoomLayer.remove();
  9580. }
  9581. this.zoomLayer = null;
  9582. }
  9583. }, {
  9584. key: "reset",
  9585. value: function reset() {
  9586. var keepZoomLayer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9587. var keepAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9588. this.cancelRendering(keepAnnotations);
  9589. var div = this.div;
  9590. div.style.width = Math.floor(this.viewport.width) + 'px';
  9591. div.style.height = Math.floor(this.viewport.height) + 'px';
  9592. var childNodes = div.childNodes;
  9593. var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
  9594. var currentAnnotationNode = keepAnnotations && this.annotationLayer && this.annotationLayer.div || null;
  9595. for (var i = childNodes.length - 1; i >= 0; i--) {
  9596. var node = childNodes[i];
  9597. if (currentZoomLayerNode === node || currentAnnotationNode === node) {
  9598. continue;
  9599. }
  9600. div.removeChild(node);
  9601. }
  9602. div.removeAttribute('data-loaded');
  9603. if (currentAnnotationNode) {
  9604. this.annotationLayer.hide();
  9605. } else if (this.annotationLayer) {
  9606. this.annotationLayer.cancel();
  9607. this.annotationLayer = null;
  9608. }
  9609. if (!currentZoomLayerNode) {
  9610. if (this.canvas) {
  9611. this.paintedViewportMap.delete(this.canvas);
  9612. this.canvas.width = 0;
  9613. this.canvas.height = 0;
  9614. delete this.canvas;
  9615. }
  9616. this._resetZoomLayer();
  9617. }
  9618. if (this.svg) {
  9619. this.paintedViewportMap.delete(this.svg);
  9620. delete this.svg;
  9621. }
  9622. this.loadingIconDiv = document.createElement('div');
  9623. this.loadingIconDiv.className = 'loadingIcon';
  9624. div.appendChild(this.loadingIconDiv);
  9625. }
  9626. }, {
  9627. key: "update",
  9628. value: function update(scale, rotation) {
  9629. this.scale = scale || this.scale;
  9630. if (typeof rotation !== 'undefined') {
  9631. this.rotation = rotation;
  9632. }
  9633. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  9634. this.viewport = this.viewport.clone({
  9635. scale: this.scale * _ui_utils.CSS_UNITS,
  9636. rotation: totalRotation
  9637. });
  9638. if (this.svg) {
  9639. this.cssTransform(this.svg, true);
  9640. this.eventBus.dispatch('pagerendered', {
  9641. source: this,
  9642. pageNumber: this.id,
  9643. cssTransform: true
  9644. });
  9645. return;
  9646. }
  9647. var isScalingRestricted = false;
  9648. if (this.canvas && this.maxCanvasPixels > 0) {
  9649. var outputScale = this.outputScale;
  9650. if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > this.maxCanvasPixels) {
  9651. isScalingRestricted = true;
  9652. }
  9653. }
  9654. if (this.canvas) {
  9655. if (this.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
  9656. this.cssTransform(this.canvas, true);
  9657. this.eventBus.dispatch('pagerendered', {
  9658. source: this,
  9659. pageNumber: this.id,
  9660. cssTransform: true
  9661. });
  9662. return;
  9663. }
  9664. if (!this.zoomLayer && !this.canvas.hasAttribute('hidden')) {
  9665. this.zoomLayer = this.canvas.parentNode;
  9666. this.zoomLayer.style.position = 'absolute';
  9667. }
  9668. }
  9669. if (this.zoomLayer) {
  9670. this.cssTransform(this.zoomLayer.firstChild);
  9671. }
  9672. this.reset(true, true);
  9673. }
  9674. }, {
  9675. key: "cancelRendering",
  9676. value: function cancelRendering() {
  9677. var keepAnnotations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9678. var renderingState = this.renderingState;
  9679. if (this.paintTask) {
  9680. this.paintTask.cancel();
  9681. this.paintTask = null;
  9682. }
  9683. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  9684. this.resume = null;
  9685. if (this.textLayer) {
  9686. this.textLayer.cancel();
  9687. this.textLayer = null;
  9688. }
  9689. if (!keepAnnotations && this.annotationLayer) {
  9690. this.annotationLayer.cancel();
  9691. this.annotationLayer = null;
  9692. }
  9693. if (renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  9694. this.eventBus.dispatch('pagecancelled', {
  9695. source: this,
  9696. pageNumber: this.id,
  9697. renderingState: renderingState
  9698. });
  9699. }
  9700. }
  9701. }, {
  9702. key: "cssTransform",
  9703. value: function cssTransform(target) {
  9704. var redrawAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9705. var width = this.viewport.width;
  9706. var height = this.viewport.height;
  9707. var div = this.div;
  9708. target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + 'px';
  9709. target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + 'px';
  9710. var relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
  9711. var absRotation = Math.abs(relativeRotation);
  9712. var scaleX = 1,
  9713. scaleY = 1;
  9714. if (absRotation === 90 || absRotation === 270) {
  9715. scaleX = height / width;
  9716. scaleY = width / height;
  9717. }
  9718. var cssTransform = 'rotate(' + relativeRotation + 'deg) ' + 'scale(' + scaleX + ',' + scaleY + ')';
  9719. target.style.transform = cssTransform;
  9720. if (this.textLayer) {
  9721. var textLayerViewport = this.textLayer.viewport;
  9722. var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
  9723. var textAbsRotation = Math.abs(textRelativeRotation);
  9724. var scale = width / textLayerViewport.width;
  9725. if (textAbsRotation === 90 || textAbsRotation === 270) {
  9726. scale = width / textLayerViewport.height;
  9727. }
  9728. var textLayerDiv = this.textLayer.textLayerDiv;
  9729. var transX, transY;
  9730. switch (textAbsRotation) {
  9731. case 0:
  9732. transX = transY = 0;
  9733. break;
  9734. case 90:
  9735. transX = 0;
  9736. transY = '-' + textLayerDiv.style.height;
  9737. break;
  9738. case 180:
  9739. transX = '-' + textLayerDiv.style.width;
  9740. transY = '-' + textLayerDiv.style.height;
  9741. break;
  9742. case 270:
  9743. transX = '-' + textLayerDiv.style.width;
  9744. transY = 0;
  9745. break;
  9746. default:
  9747. console.error('Bad rotation value.');
  9748. break;
  9749. }
  9750. textLayerDiv.style.transform = 'rotate(' + textAbsRotation + 'deg) ' + 'scale(' + scale + ', ' + scale + ') ' + 'translate(' + transX + ', ' + transY + ')';
  9751. textLayerDiv.style.transformOrigin = '0% 0%';
  9752. }
  9753. if (redrawAnnotations && this.annotationLayer) {
  9754. this.annotationLayer.render(this.viewport, 'display');
  9755. }
  9756. }
  9757. }, {
  9758. key: "getPagePoint",
  9759. value: function getPagePoint(x, y) {
  9760. return this.viewport.convertToPdfPoint(x, y);
  9761. }
  9762. }, {
  9763. key: "draw",
  9764. value: function draw() {
  9765. var _this = this;
  9766. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  9767. console.error('Must be in new state before drawing');
  9768. this.reset();
  9769. }
  9770. if (!this.pdfPage) {
  9771. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  9772. return Promise.reject(new Error('Page is not loaded'));
  9773. }
  9774. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  9775. var pdfPage = this.pdfPage;
  9776. var div = this.div;
  9777. var canvasWrapper = document.createElement('div');
  9778. canvasWrapper.style.width = div.style.width;
  9779. canvasWrapper.style.height = div.style.height;
  9780. canvasWrapper.classList.add('canvasWrapper');
  9781. if (this.annotationLayer && this.annotationLayer.div) {
  9782. div.insertBefore(canvasWrapper, this.annotationLayer.div);
  9783. } else {
  9784. div.appendChild(canvasWrapper);
  9785. }
  9786. var textLayer = null;
  9787. if (this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && this.textLayerFactory) {
  9788. var textLayerDiv = document.createElement('div');
  9789. textLayerDiv.className = 'textLayer';
  9790. textLayerDiv.style.width = canvasWrapper.style.width;
  9791. textLayerDiv.style.height = canvasWrapper.style.height;
  9792. if (this.annotationLayer && this.annotationLayer.div) {
  9793. div.insertBefore(textLayerDiv, this.annotationLayer.div);
  9794. } else {
  9795. div.appendChild(textLayerDiv);
  9796. }
  9797. textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.textLayerMode === _ui_utils.TextLayerMode.ENABLE_ENHANCE);
  9798. }
  9799. this.textLayer = textLayer;
  9800. var renderContinueCallback = null;
  9801. if (this.renderingQueue) {
  9802. renderContinueCallback = function renderContinueCallback(cont) {
  9803. if (!_this.renderingQueue.isHighestPriority(_this)) {
  9804. _this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  9805. _this.resume = function () {
  9806. _this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  9807. cont();
  9808. };
  9809. return;
  9810. }
  9811. cont();
  9812. };
  9813. }
  9814. var finishPaintTask =
  9815. /*#__PURE__*/
  9816. function () {
  9817. var _ref = _asyncToGenerator(
  9818. /*#__PURE__*/
  9819. _regenerator.default.mark(function _callee(error) {
  9820. return _regenerator.default.wrap(function _callee$(_context) {
  9821. while (1) {
  9822. switch (_context.prev = _context.next) {
  9823. case 0:
  9824. if (paintTask === _this.paintTask) {
  9825. _this.paintTask = null;
  9826. }
  9827. if (!(error instanceof _pdfjsLib.RenderingCancelledException)) {
  9828. _context.next = 4;
  9829. break;
  9830. }
  9831. _this.error = null;
  9832. return _context.abrupt("return");
  9833. case 4:
  9834. _this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  9835. if (_this.loadingIconDiv) {
  9836. div.removeChild(_this.loadingIconDiv);
  9837. delete _this.loadingIconDiv;
  9838. }
  9839. _this._resetZoomLayer(true);
  9840. _this.error = error;
  9841. _this.stats = pdfPage.stats;
  9842. if (_this.onAfterDraw) {
  9843. _this.onAfterDraw();
  9844. }
  9845. _this.eventBus.dispatch('pagerendered', {
  9846. source: _this,
  9847. pageNumber: _this.id,
  9848. cssTransform: false
  9849. });
  9850. if (!error) {
  9851. _context.next = 13;
  9852. break;
  9853. }
  9854. throw error;
  9855. case 13:
  9856. case "end":
  9857. return _context.stop();
  9858. }
  9859. }
  9860. }, _callee, this);
  9861. }));
  9862. return function finishPaintTask(_x) {
  9863. return _ref.apply(this, arguments);
  9864. };
  9865. }();
  9866. var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
  9867. paintTask.onRenderContinue = renderContinueCallback;
  9868. this.paintTask = paintTask;
  9869. var resultPromise = paintTask.promise.then(function () {
  9870. return finishPaintTask(null).then(function () {
  9871. if (textLayer) {
  9872. var readableStream = pdfPage.streamTextContent({
  9873. normalizeWhitespace: true
  9874. });
  9875. textLayer.setTextContentStream(readableStream);
  9876. textLayer.render();
  9877. }
  9878. });
  9879. }, function (reason) {
  9880. return finishPaintTask(reason);
  9881. });
  9882. if (this.annotationLayerFactory) {
  9883. if (!this.annotationLayer) {
  9884. this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this.imageResourcesPath, this.renderInteractiveForms, this.l10n);
  9885. }
  9886. this.annotationLayer.render(this.viewport, 'display');
  9887. }
  9888. div.setAttribute('data-loaded', true);
  9889. if (this.onBeforeDraw) {
  9890. this.onBeforeDraw();
  9891. }
  9892. return resultPromise;
  9893. }
  9894. }, {
  9895. key: "paintOnCanvas",
  9896. value: function paintOnCanvas(canvasWrapper) {
  9897. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  9898. var result = {
  9899. promise: renderCapability.promise,
  9900. onRenderContinue: function onRenderContinue(cont) {
  9901. cont();
  9902. },
  9903. cancel: function cancel() {
  9904. renderTask.cancel();
  9905. }
  9906. };
  9907. var viewport = this.viewport;
  9908. var canvas = document.createElement('canvas');
  9909. canvas.id = this.renderingId;
  9910. canvas.setAttribute('hidden', 'hidden');
  9911. var isCanvasHidden = true;
  9912. var showCanvas = function showCanvas() {
  9913. if (isCanvasHidden) {
  9914. canvas.removeAttribute('hidden');
  9915. isCanvasHidden = false;
  9916. }
  9917. };
  9918. canvasWrapper.appendChild(canvas);
  9919. this.canvas = canvas;
  9920. canvas.mozOpaque = true;
  9921. var ctx = canvas.getContext('2d', {
  9922. alpha: false
  9923. });
  9924. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  9925. this.outputScale = outputScale;
  9926. if (this.useOnlyCssZoom) {
  9927. var actualSizeViewport = viewport.clone({
  9928. scale: _ui_utils.CSS_UNITS
  9929. });
  9930. outputScale.sx *= actualSizeViewport.width / viewport.width;
  9931. outputScale.sy *= actualSizeViewport.height / viewport.height;
  9932. outputScale.scaled = true;
  9933. }
  9934. if (this.maxCanvasPixels > 0) {
  9935. var pixelsInViewport = viewport.width * viewport.height;
  9936. var maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
  9937. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  9938. outputScale.sx = maxScale;
  9939. outputScale.sy = maxScale;
  9940. outputScale.scaled = true;
  9941. this.hasRestrictedScaling = true;
  9942. } else {
  9943. this.hasRestrictedScaling = false;
  9944. }
  9945. }
  9946. var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  9947. var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  9948. canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
  9949. canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
  9950. canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + 'px';
  9951. canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + 'px';
  9952. this.paintedViewportMap.set(canvas, viewport);
  9953. var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
  9954. var renderContext = {
  9955. canvasContext: ctx,
  9956. transform: transform,
  9957. viewport: this.viewport,
  9958. enableWebGL: this.enableWebGL,
  9959. renderInteractiveForms: this.renderInteractiveForms
  9960. };
  9961. var renderTask = this.pdfPage.render(renderContext);
  9962. renderTask.onContinue = function (cont) {
  9963. showCanvas();
  9964. if (result.onRenderContinue) {
  9965. result.onRenderContinue(cont);
  9966. } else {
  9967. cont();
  9968. }
  9969. };
  9970. renderTask.promise.then(function () {
  9971. showCanvas();
  9972. renderCapability.resolve(undefined);
  9973. }, function (error) {
  9974. showCanvas();
  9975. renderCapability.reject(error);
  9976. });
  9977. return result;
  9978. }
  9979. }, {
  9980. key: "paintOnSvg",
  9981. value: function paintOnSvg(wrapper) {
  9982. var _this2 = this;
  9983. var cancelled = false;
  9984. var ensureNotCancelled = function ensureNotCancelled() {
  9985. if (cancelled) {
  9986. throw new _pdfjsLib.RenderingCancelledException('Rendering cancelled, page ' + _this2.id, 'svg');
  9987. }
  9988. };
  9989. var pdfPage = this.pdfPage;
  9990. var actualSizeViewport = this.viewport.clone({
  9991. scale: _ui_utils.CSS_UNITS
  9992. });
  9993. var promise = pdfPage.getOperatorList().then(function (opList) {
  9994. ensureNotCancelled();
  9995. var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
  9996. return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {
  9997. ensureNotCancelled();
  9998. _this2.svg = svg;
  9999. _this2.paintedViewportMap.set(svg, actualSizeViewport);
  10000. svg.style.width = wrapper.style.width;
  10001. svg.style.height = wrapper.style.height;
  10002. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  10003. wrapper.appendChild(svg);
  10004. });
  10005. });
  10006. return {
  10007. promise: promise,
  10008. onRenderContinue: function onRenderContinue(cont) {
  10009. cont();
  10010. },
  10011. cancel: function cancel() {
  10012. cancelled = true;
  10013. }
  10014. };
  10015. }
  10016. }, {
  10017. key: "setPageLabel",
  10018. value: function setPageLabel(label) {
  10019. this.pageLabel = typeof label === 'string' ? label : null;
  10020. if (this.pageLabel !== null) {
  10021. this.div.setAttribute('data-page-label', this.pageLabel);
  10022. } else {
  10023. this.div.removeAttribute('data-page-label');
  10024. }
  10025. }
  10026. }, {
  10027. key: "width",
  10028. get: function get() {
  10029. return this.viewport.width;
  10030. }
  10031. }, {
  10032. key: "height",
  10033. get: function get() {
  10034. return this.viewport.height;
  10035. }
  10036. }]);
  10037. return PDFPageView;
  10038. }();
  10039. exports.PDFPageView = PDFPageView;
  10040. /***/ }),
  10041. /* 32 */
  10042. /***/ (function(module, exports, __webpack_require__) {
  10043. "use strict";
  10044. Object.defineProperty(exports, "__esModule", {
  10045. value: true
  10046. });
  10047. exports.DefaultTextLayerFactory = exports.TextLayerBuilder = void 0;
  10048. var _ui_utils = __webpack_require__(6);
  10049. var _pdfjsLib = __webpack_require__(7);
  10050. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10051. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  10052. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10053. var EXPAND_DIVS_TIMEOUT = 300;
  10054. var TextLayerBuilder =
  10055. /*#__PURE__*/
  10056. function () {
  10057. function TextLayerBuilder(_ref) {
  10058. var textLayerDiv = _ref.textLayerDiv,
  10059. eventBus = _ref.eventBus,
  10060. pageIndex = _ref.pageIndex,
  10061. viewport = _ref.viewport,
  10062. _ref$findController = _ref.findController,
  10063. findController = _ref$findController === void 0 ? null : _ref$findController,
  10064. _ref$enhanceTextSelec = _ref.enhanceTextSelection,
  10065. enhanceTextSelection = _ref$enhanceTextSelec === void 0 ? false : _ref$enhanceTextSelec;
  10066. _classCallCheck(this, TextLayerBuilder);
  10067. this.textLayerDiv = textLayerDiv;
  10068. this.eventBus = eventBus || (0, _ui_utils.getGlobalEventBus)();
  10069. this.textContent = null;
  10070. this.textContentItemsStr = [];
  10071. this.textContentStream = null;
  10072. this.renderingDone = false;
  10073. this.pageIdx = pageIndex;
  10074. this.pageNumber = this.pageIdx + 1;
  10075. this.matches = [];
  10076. this.viewport = viewport;
  10077. this.textDivs = [];
  10078. this.findController = findController;
  10079. this.textLayerRenderTask = null;
  10080. this.enhanceTextSelection = enhanceTextSelection;
  10081. this._boundEvents = Object.create(null);
  10082. this._bindEvents();
  10083. this._bindMouse();
  10084. }
  10085. _createClass(TextLayerBuilder, [{
  10086. key: "_finishRendering",
  10087. value: function _finishRendering() {
  10088. this.renderingDone = true;
  10089. if (!this.enhanceTextSelection) {
  10090. var endOfContent = document.createElement('div');
  10091. endOfContent.className = 'endOfContent';
  10092. this.textLayerDiv.appendChild(endOfContent);
  10093. }
  10094. this.eventBus.dispatch('textlayerrendered', {
  10095. source: this,
  10096. pageNumber: this.pageNumber,
  10097. numTextDivs: this.textDivs.length
  10098. });
  10099. }
  10100. }, {
  10101. key: "render",
  10102. value: function render() {
  10103. var _this = this;
  10104. var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  10105. if (!(this.textContent || this.textContentStream) || this.renderingDone) {
  10106. return;
  10107. }
  10108. this.cancel();
  10109. this.textDivs = [];
  10110. var textLayerFrag = document.createDocumentFragment();
  10111. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  10112. textContent: this.textContent,
  10113. textContentStream: this.textContentStream,
  10114. container: textLayerFrag,
  10115. viewport: this.viewport,
  10116. textDivs: this.textDivs,
  10117. textContentItemsStr: this.textContentItemsStr,
  10118. timeout: timeout,
  10119. enhanceTextSelection: this.enhanceTextSelection
  10120. });
  10121. this.textLayerRenderTask.promise.then(function () {
  10122. _this.textLayerDiv.appendChild(textLayerFrag);
  10123. _this._finishRendering();
  10124. _this._updateMatches();
  10125. }, function (reason) {});
  10126. }
  10127. }, {
  10128. key: "cancel",
  10129. value: function cancel() {
  10130. if (this.textLayerRenderTask) {
  10131. this.textLayerRenderTask.cancel();
  10132. this.textLayerRenderTask = null;
  10133. }
  10134. }
  10135. }, {
  10136. key: "setTextContentStream",
  10137. value: function setTextContentStream(readableStream) {
  10138. this.cancel();
  10139. this.textContentStream = readableStream;
  10140. }
  10141. }, {
  10142. key: "setTextContent",
  10143. value: function setTextContent(textContent) {
  10144. this.cancel();
  10145. this.textContent = textContent;
  10146. }
  10147. }, {
  10148. key: "_convertMatches",
  10149. value: function _convertMatches(matches, matchesLength) {
  10150. if (!matches) {
  10151. return [];
  10152. }
  10153. var findController = this.findController,
  10154. textContentItemsStr = this.textContentItemsStr;
  10155. var i = 0,
  10156. iIndex = 0;
  10157. var end = textContentItemsStr.length - 1;
  10158. var queryLen = findController.state.query.length;
  10159. var result = [];
  10160. for (var m = 0, mm = matches.length; m < mm; m++) {
  10161. var matchIdx = matches[m];
  10162. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  10163. iIndex += textContentItemsStr[i].length;
  10164. i++;
  10165. }
  10166. if (i === textContentItemsStr.length) {
  10167. console.error('Could not find a matching mapping');
  10168. }
  10169. var match = {
  10170. begin: {
  10171. divIdx: i,
  10172. offset: matchIdx - iIndex
  10173. }
  10174. };
  10175. if (matchesLength) {
  10176. matchIdx += matchesLength[m];
  10177. } else {
  10178. matchIdx += queryLen;
  10179. }
  10180. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  10181. iIndex += textContentItemsStr[i].length;
  10182. i++;
  10183. }
  10184. match.end = {
  10185. divIdx: i,
  10186. offset: matchIdx - iIndex
  10187. };
  10188. result.push(match);
  10189. }
  10190. return result;
  10191. }
  10192. }, {
  10193. key: "_renderMatches",
  10194. value: function _renderMatches(matches) {
  10195. if (matches.length === 0) {
  10196. return;
  10197. }
  10198. var findController = this.findController,
  10199. pageIdx = this.pageIdx,
  10200. textContentItemsStr = this.textContentItemsStr,
  10201. textDivs = this.textDivs;
  10202. var isSelectedPage = pageIdx === findController.selected.pageIdx;
  10203. var selectedMatchIdx = findController.selected.matchIdx;
  10204. var highlightAll = findController.state.highlightAll;
  10205. var prevEnd = null;
  10206. var infinity = {
  10207. divIdx: -1,
  10208. offset: undefined
  10209. };
  10210. function beginText(begin, className) {
  10211. var divIdx = begin.divIdx;
  10212. textDivs[divIdx].textContent = '';
  10213. appendTextToDiv(divIdx, 0, begin.offset, className);
  10214. }
  10215. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  10216. var div = textDivs[divIdx];
  10217. var content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  10218. var node = document.createTextNode(content);
  10219. if (className) {
  10220. var span = document.createElement('span');
  10221. span.className = className;
  10222. span.appendChild(node);
  10223. div.appendChild(span);
  10224. return;
  10225. }
  10226. div.appendChild(node);
  10227. }
  10228. var i0 = selectedMatchIdx,
  10229. i1 = i0 + 1;
  10230. if (highlightAll) {
  10231. i0 = 0;
  10232. i1 = matches.length;
  10233. } else if (!isSelectedPage) {
  10234. return;
  10235. }
  10236. for (var i = i0; i < i1; i++) {
  10237. var match = matches[i];
  10238. var begin = match.begin;
  10239. var end = match.end;
  10240. var isSelected = isSelectedPage && i === selectedMatchIdx;
  10241. var highlightSuffix = isSelected ? ' selected' : '';
  10242. if (isSelected) {
  10243. findController.scrollMatchIntoView({
  10244. element: textDivs[begin.divIdx],
  10245. pageIndex: pageIdx,
  10246. matchIndex: selectedMatchIdx
  10247. });
  10248. }
  10249. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  10250. if (prevEnd !== null) {
  10251. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  10252. }
  10253. beginText(begin);
  10254. } else {
  10255. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  10256. }
  10257. if (begin.divIdx === end.divIdx) {
  10258. appendTextToDiv(begin.divIdx, begin.offset, end.offset, 'highlight' + highlightSuffix);
  10259. } else {
  10260. appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, 'highlight begin' + highlightSuffix);
  10261. for (var n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  10262. textDivs[n0].className = 'highlight middle' + highlightSuffix;
  10263. }
  10264. beginText(end, 'highlight end' + highlightSuffix);
  10265. }
  10266. prevEnd = end;
  10267. }
  10268. if (prevEnd) {
  10269. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  10270. }
  10271. }
  10272. }, {
  10273. key: "_updateMatches",
  10274. value: function _updateMatches() {
  10275. if (!this.renderingDone) {
  10276. return;
  10277. }
  10278. var findController = this.findController,
  10279. matches = this.matches,
  10280. pageIdx = this.pageIdx,
  10281. textContentItemsStr = this.textContentItemsStr,
  10282. textDivs = this.textDivs;
  10283. var clearedUntilDivIdx = -1;
  10284. for (var i = 0, ii = matches.length; i < ii; i++) {
  10285. var match = matches[i];
  10286. var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  10287. for (var n = begin, end = match.end.divIdx; n <= end; n++) {
  10288. var div = textDivs[n];
  10289. div.textContent = textContentItemsStr[n];
  10290. div.className = '';
  10291. }
  10292. clearedUntilDivIdx = match.end.divIdx + 1;
  10293. }
  10294. if (!findController || !findController.highlightMatches) {
  10295. return;
  10296. }
  10297. var pageMatches = findController.pageMatches[pageIdx] || null;
  10298. var pageMatchesLength = findController.pageMatchesLength[pageIdx] || null;
  10299. this.matches = this._convertMatches(pageMatches, pageMatchesLength);
  10300. this._renderMatches(this.matches);
  10301. }
  10302. }, {
  10303. key: "_bindEvents",
  10304. value: function _bindEvents() {
  10305. var _this2 = this;
  10306. var eventBus = this.eventBus,
  10307. _boundEvents = this._boundEvents;
  10308. _boundEvents.pageCancelled = function (evt) {
  10309. if (evt.pageNumber !== _this2.pageNumber) {
  10310. return;
  10311. }
  10312. if (_this2.textLayerRenderTask) {
  10313. console.error('TextLayerBuilder._bindEvents: `this.cancel()` should ' + 'have been called when the page was reset, or rendering cancelled.');
  10314. return;
  10315. }
  10316. for (var name in _boundEvents) {
  10317. eventBus.off(name.toLowerCase(), _boundEvents[name]);
  10318. delete _boundEvents[name];
  10319. }
  10320. };
  10321. _boundEvents.updateTextLayerMatches = function (evt) {
  10322. if (evt.pageIndex !== _this2.pageIdx && evt.pageIndex !== -1) {
  10323. return;
  10324. }
  10325. _this2._updateMatches();
  10326. };
  10327. eventBus.on('pagecancelled', _boundEvents.pageCancelled);
  10328. eventBus.on('updatetextlayermatches', _boundEvents.updateTextLayerMatches);
  10329. }
  10330. }, {
  10331. key: "_bindMouse",
  10332. value: function _bindMouse() {
  10333. var _this3 = this;
  10334. var div = this.textLayerDiv;
  10335. var expandDivsTimer = null;
  10336. div.addEventListener('mousedown', function (evt) {
  10337. if (_this3.enhanceTextSelection && _this3.textLayerRenderTask) {
  10338. _this3.textLayerRenderTask.expandTextDivs(true);
  10339. if (expandDivsTimer) {
  10340. clearTimeout(expandDivsTimer);
  10341. expandDivsTimer = null;
  10342. }
  10343. return;
  10344. }
  10345. var end = div.querySelector('.endOfContent');
  10346. if (!end) {
  10347. return;
  10348. }
  10349. var adjustTop = evt.target !== div;
  10350. adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue('-moz-user-select') !== 'none';
  10351. if (adjustTop) {
  10352. var divBounds = div.getBoundingClientRect();
  10353. var r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  10354. end.style.top = (r * 100).toFixed(2) + '%';
  10355. }
  10356. end.classList.add('active');
  10357. });
  10358. div.addEventListener('mouseup', function () {
  10359. if (_this3.enhanceTextSelection && _this3.textLayerRenderTask) {
  10360. expandDivsTimer = setTimeout(function () {
  10361. if (_this3.textLayerRenderTask) {
  10362. _this3.textLayerRenderTask.expandTextDivs(false);
  10363. }
  10364. expandDivsTimer = null;
  10365. }, EXPAND_DIVS_TIMEOUT);
  10366. return;
  10367. }
  10368. var end = div.querySelector('.endOfContent');
  10369. if (!end) {
  10370. return;
  10371. }
  10372. end.style.top = '';
  10373. end.classList.remove('active');
  10374. });
  10375. }
  10376. }]);
  10377. return TextLayerBuilder;
  10378. }();
  10379. exports.TextLayerBuilder = TextLayerBuilder;
  10380. var DefaultTextLayerFactory =
  10381. /*#__PURE__*/
  10382. function () {
  10383. function DefaultTextLayerFactory() {
  10384. _classCallCheck(this, DefaultTextLayerFactory);
  10385. }
  10386. _createClass(DefaultTextLayerFactory, [{
  10387. key: "createTextLayerBuilder",
  10388. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  10389. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  10390. return new TextLayerBuilder({
  10391. textLayerDiv: textLayerDiv,
  10392. pageIndex: pageIndex,
  10393. viewport: viewport,
  10394. enhanceTextSelection: enhanceTextSelection
  10395. });
  10396. }
  10397. }]);
  10398. return DefaultTextLayerFactory;
  10399. }();
  10400. exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
  10401. /***/ }),
  10402. /* 33 */
  10403. /***/ (function(module, exports, __webpack_require__) {
  10404. "use strict";
  10405. Object.defineProperty(exports, "__esModule", {
  10406. value: true
  10407. });
  10408. exports.SecondaryToolbar = void 0;
  10409. var _ui_utils = __webpack_require__(6);
  10410. var _pdf_cursor_tools = __webpack_require__(8);
  10411. var _pdf_single_page_viewer = __webpack_require__(34);
  10412. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10413. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  10414. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10415. var SecondaryToolbar =
  10416. /*#__PURE__*/
  10417. function () {
  10418. function SecondaryToolbar(options, mainContainer, eventBus) {
  10419. var _this = this;
  10420. _classCallCheck(this, SecondaryToolbar);
  10421. this.toolbar = options.toolbar;
  10422. this.toggleButton = options.toggleButton;
  10423. this.toolbarButtonContainer = options.toolbarButtonContainer;
  10424. this.buttons = [{
  10425. element: options.presentationModeButton,
  10426. eventName: 'presentationmode',
  10427. close: true
  10428. }, {
  10429. element: options.openFileButton,
  10430. eventName: 'openfile',
  10431. close: true
  10432. }, {
  10433. element: options.printButton,
  10434. eventName: 'print',
  10435. close: true
  10436. }, {
  10437. element: options.downloadButton,
  10438. eventName: 'download',
  10439. close: true
  10440. }, {
  10441. element: options.viewBookmarkButton,
  10442. eventName: null,
  10443. close: true
  10444. }, {
  10445. element: options.firstPageButton,
  10446. eventName: 'firstpage',
  10447. close: true
  10448. }, {
  10449. element: options.lastPageButton,
  10450. eventName: 'lastpage',
  10451. close: true
  10452. }, {
  10453. element: options.pageRotateCwButton,
  10454. eventName: 'rotatecw',
  10455. close: false
  10456. }, {
  10457. element: options.pageRotateCcwButton,
  10458. eventName: 'rotateccw',
  10459. close: false
  10460. }, {
  10461. element: options.cursorSelectToolButton,
  10462. eventName: 'switchcursortool',
  10463. eventDetails: {
  10464. tool: _pdf_cursor_tools.CursorTool.SELECT
  10465. },
  10466. close: true
  10467. }, {
  10468. element: options.cursorHandToolButton,
  10469. eventName: 'switchcursortool',
  10470. eventDetails: {
  10471. tool: _pdf_cursor_tools.CursorTool.HAND
  10472. },
  10473. close: true
  10474. }, {
  10475. element: options.scrollVerticalButton,
  10476. eventName: 'switchscrollmode',
  10477. eventDetails: {
  10478. mode: _ui_utils.ScrollMode.VERTICAL
  10479. },
  10480. close: true
  10481. }, {
  10482. element: options.scrollHorizontalButton,
  10483. eventName: 'switchscrollmode',
  10484. eventDetails: {
  10485. mode: _ui_utils.ScrollMode.HORIZONTAL
  10486. },
  10487. close: true
  10488. }, {
  10489. element: options.scrollWrappedButton,
  10490. eventName: 'switchscrollmode',
  10491. eventDetails: {
  10492. mode: _ui_utils.ScrollMode.WRAPPED
  10493. },
  10494. close: true
  10495. }, {
  10496. element: options.spreadNoneButton,
  10497. eventName: 'switchspreadmode',
  10498. eventDetails: {
  10499. mode: _ui_utils.SpreadMode.NONE
  10500. },
  10501. close: true
  10502. }, {
  10503. element: options.spreadOddButton,
  10504. eventName: 'switchspreadmode',
  10505. eventDetails: {
  10506. mode: _ui_utils.SpreadMode.ODD
  10507. },
  10508. close: true
  10509. }, {
  10510. element: options.spreadEvenButton,
  10511. eventName: 'switchspreadmode',
  10512. eventDetails: {
  10513. mode: _ui_utils.SpreadMode.EVEN
  10514. },
  10515. close: true
  10516. }, {
  10517. element: options.documentPropertiesButton,
  10518. eventName: 'documentproperties',
  10519. close: true
  10520. }];
  10521. this.items = {
  10522. firstPage: options.firstPageButton,
  10523. lastPage: options.lastPageButton,
  10524. pageRotateCw: options.pageRotateCwButton,
  10525. pageRotateCcw: options.pageRotateCcwButton
  10526. };
  10527. this.mainContainer = mainContainer;
  10528. this.eventBus = eventBus;
  10529. this.opened = false;
  10530. this.containerHeight = null;
  10531. this.previousContainerHeight = null;
  10532. this.reset();
  10533. this._bindClickListeners();
  10534. this._bindCursorToolsListener(options);
  10535. this._bindScrollModeListener(options);
  10536. this._bindSpreadModeListener(options);
  10537. this.eventBus.on('resize', this._setMaxHeight.bind(this));
  10538. this.eventBus.on('baseviewerinit', function (evt) {
  10539. if (evt.source instanceof _pdf_single_page_viewer.PDFSinglePageViewer) {
  10540. _this.toolbarButtonContainer.classList.add('hiddenScrollModeButtons', 'hiddenSpreadModeButtons');
  10541. } else {
  10542. _this.toolbarButtonContainer.classList.remove('hiddenScrollModeButtons', 'hiddenSpreadModeButtons');
  10543. }
  10544. });
  10545. }
  10546. _createClass(SecondaryToolbar, [{
  10547. key: "setPageNumber",
  10548. value: function setPageNumber(pageNumber) {
  10549. this.pageNumber = pageNumber;
  10550. this._updateUIState();
  10551. }
  10552. }, {
  10553. key: "setPagesCount",
  10554. value: function setPagesCount(pagesCount) {
  10555. this.pagesCount = pagesCount;
  10556. this._updateUIState();
  10557. }
  10558. }, {
  10559. key: "reset",
  10560. value: function reset() {
  10561. this.pageNumber = 0;
  10562. this.pagesCount = 0;
  10563. this._updateUIState();
  10564. this.eventBus.dispatch('secondarytoolbarreset', {
  10565. source: this
  10566. });
  10567. }
  10568. }, {
  10569. key: "_updateUIState",
  10570. value: function _updateUIState() {
  10571. this.items.firstPage.disabled = this.pageNumber <= 1;
  10572. this.items.lastPage.disabled = this.pageNumber >= this.pagesCount;
  10573. this.items.pageRotateCw.disabled = this.pagesCount === 0;
  10574. this.items.pageRotateCcw.disabled = this.pagesCount === 0;
  10575. }
  10576. }, {
  10577. key: "_bindClickListeners",
  10578. value: function _bindClickListeners() {
  10579. var _this2 = this;
  10580. this.toggleButton.addEventListener('click', this.toggle.bind(this));
  10581. var _loop = function _loop(button) {
  10582. var _this2$buttons$button = _this2.buttons[button],
  10583. element = _this2$buttons$button.element,
  10584. eventName = _this2$buttons$button.eventName,
  10585. close = _this2$buttons$button.close,
  10586. eventDetails = _this2$buttons$button.eventDetails;
  10587. element.addEventListener('click', function (evt) {
  10588. if (eventName !== null) {
  10589. var details = {
  10590. source: _this2
  10591. };
  10592. for (var property in eventDetails) {
  10593. details[property] = eventDetails[property];
  10594. }
  10595. _this2.eventBus.dispatch(eventName, details);
  10596. }
  10597. if (close) {
  10598. _this2.close();
  10599. }
  10600. });
  10601. };
  10602. for (var button in this.buttons) {
  10603. if (this.buttons.hasOwnProperty(button)) {
  10604. _loop(button);
  10605. }
  10606. }
  10607. }
  10608. }, {
  10609. key: "_bindCursorToolsListener",
  10610. value: function _bindCursorToolsListener(buttons) {
  10611. this.eventBus.on('cursortoolchanged', function (_ref) {
  10612. var tool = _ref.tool;
  10613. buttons.cursorSelectToolButton.classList.toggle('toggled', tool === _pdf_cursor_tools.CursorTool.SELECT);
  10614. buttons.cursorHandToolButton.classList.toggle('toggled', tool === _pdf_cursor_tools.CursorTool.HAND);
  10615. });
  10616. }
  10617. }, {
  10618. key: "_bindScrollModeListener",
  10619. value: function _bindScrollModeListener(buttons) {
  10620. var _this3 = this;
  10621. function scrollModeChanged(_ref2) {
  10622. var mode = _ref2.mode;
  10623. buttons.scrollVerticalButton.classList.toggle('toggled', mode === _ui_utils.ScrollMode.VERTICAL);
  10624. buttons.scrollHorizontalButton.classList.toggle('toggled', mode === _ui_utils.ScrollMode.HORIZONTAL);
  10625. buttons.scrollWrappedButton.classList.toggle('toggled', mode === _ui_utils.ScrollMode.WRAPPED);
  10626. var isScrollModeHorizontal = mode === _ui_utils.ScrollMode.HORIZONTAL;
  10627. buttons.spreadNoneButton.disabled = isScrollModeHorizontal;
  10628. buttons.spreadOddButton.disabled = isScrollModeHorizontal;
  10629. buttons.spreadEvenButton.disabled = isScrollModeHorizontal;
  10630. }
  10631. this.eventBus.on('scrollmodechanged', scrollModeChanged);
  10632. this.eventBus.on('secondarytoolbarreset', function (evt) {
  10633. if (evt.source === _this3) {
  10634. scrollModeChanged({
  10635. mode: _ui_utils.ScrollMode.VERTICAL
  10636. });
  10637. }
  10638. });
  10639. }
  10640. }, {
  10641. key: "_bindSpreadModeListener",
  10642. value: function _bindSpreadModeListener(buttons) {
  10643. var _this4 = this;
  10644. function spreadModeChanged(_ref3) {
  10645. var mode = _ref3.mode;
  10646. buttons.spreadNoneButton.classList.toggle('toggled', mode === _ui_utils.SpreadMode.NONE);
  10647. buttons.spreadOddButton.classList.toggle('toggled', mode === _ui_utils.SpreadMode.ODD);
  10648. buttons.spreadEvenButton.classList.toggle('toggled', mode === _ui_utils.SpreadMode.EVEN);
  10649. }
  10650. this.eventBus.on('spreadmodechanged', spreadModeChanged);
  10651. this.eventBus.on('secondarytoolbarreset', function (evt) {
  10652. if (evt.source === _this4) {
  10653. spreadModeChanged({
  10654. mode: _ui_utils.SpreadMode.NONE
  10655. });
  10656. }
  10657. });
  10658. }
  10659. }, {
  10660. key: "open",
  10661. value: function open() {
  10662. if (this.opened) {
  10663. return;
  10664. }
  10665. this.opened = true;
  10666. this._setMaxHeight();
  10667. this.toggleButton.classList.add('toggled');
  10668. this.toolbar.classList.remove('hidden');
  10669. }
  10670. }, {
  10671. key: "close",
  10672. value: function close() {
  10673. if (!this.opened) {
  10674. return;
  10675. }
  10676. this.opened = false;
  10677. this.toolbar.classList.add('hidden');
  10678. this.toggleButton.classList.remove('toggled');
  10679. }
  10680. }, {
  10681. key: "toggle",
  10682. value: function toggle() {
  10683. if (this.opened) {
  10684. this.close();
  10685. } else {
  10686. this.open();
  10687. }
  10688. }
  10689. }, {
  10690. key: "_setMaxHeight",
  10691. value: function _setMaxHeight() {
  10692. if (!this.opened) {
  10693. return;
  10694. }
  10695. this.containerHeight = this.mainContainer.clientHeight;
  10696. if (this.containerHeight === this.previousContainerHeight) {
  10697. return;
  10698. }
  10699. this.toolbarButtonContainer.setAttribute('style', 'max-height: ' + (this.containerHeight - _ui_utils.SCROLLBAR_PADDING) + 'px;');
  10700. this.previousContainerHeight = this.containerHeight;
  10701. }
  10702. }, {
  10703. key: "isOpen",
  10704. get: function get() {
  10705. return this.opened;
  10706. }
  10707. }]);
  10708. return SecondaryToolbar;
  10709. }();
  10710. exports.SecondaryToolbar = SecondaryToolbar;
  10711. /***/ }),
  10712. /* 34 */
  10713. /***/ (function(module, exports, __webpack_require__) {
  10714. "use strict";
  10715. Object.defineProperty(exports, "__esModule", {
  10716. value: true
  10717. });
  10718. exports.PDFSinglePageViewer = void 0;
  10719. var _base_viewer = __webpack_require__(29);
  10720. var _pdfjsLib = __webpack_require__(7);
  10721. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  10722. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10723. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  10724. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10725. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  10726. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  10727. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  10728. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  10729. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  10730. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  10731. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  10732. var PDFSinglePageViewer =
  10733. /*#__PURE__*/
  10734. function (_BaseViewer) {
  10735. _inherits(PDFSinglePageViewer, _BaseViewer);
  10736. function PDFSinglePageViewer(options) {
  10737. var _this;
  10738. _classCallCheck(this, PDFSinglePageViewer);
  10739. _this = _possibleConstructorReturn(this, _getPrototypeOf(PDFSinglePageViewer).call(this, options));
  10740. _this.eventBus.on('pagesinit', function (evt) {
  10741. _this._ensurePageViewVisible();
  10742. });
  10743. return _this;
  10744. }
  10745. _createClass(PDFSinglePageViewer, [{
  10746. key: "_resetView",
  10747. value: function _resetView() {
  10748. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_resetView", this).call(this);
  10749. this._previousPageNumber = 1;
  10750. this._shadowViewer = document.createDocumentFragment();
  10751. this._updateScrollDown = null;
  10752. }
  10753. }, {
  10754. key: "_ensurePageViewVisible",
  10755. value: function _ensurePageViewVisible() {
  10756. var pageView = this._pages[this._currentPageNumber - 1];
  10757. var previousPageView = this._pages[this._previousPageNumber - 1];
  10758. var viewerNodes = this.viewer.childNodes;
  10759. switch (viewerNodes.length) {
  10760. case 0:
  10761. this.viewer.appendChild(pageView.div);
  10762. break;
  10763. case 1:
  10764. if (viewerNodes[0] !== previousPageView.div) {
  10765. throw new Error('_ensurePageViewVisible: Unexpected previously visible page.');
  10766. }
  10767. if (pageView === previousPageView) {
  10768. break;
  10769. }
  10770. this._shadowViewer.appendChild(previousPageView.div);
  10771. this.viewer.appendChild(pageView.div);
  10772. this.container.scrollTop = 0;
  10773. break;
  10774. default:
  10775. throw new Error('_ensurePageViewVisible: Only one page should be visible at a time.');
  10776. }
  10777. this._previousPageNumber = this._currentPageNumber;
  10778. }
  10779. }, {
  10780. key: "_scrollUpdate",
  10781. value: function _scrollUpdate() {
  10782. if (this._updateScrollDown) {
  10783. this._updateScrollDown();
  10784. }
  10785. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollUpdate", this).call(this);
  10786. }
  10787. }, {
  10788. key: "_scrollIntoView",
  10789. value: function _scrollIntoView(_ref) {
  10790. var _this2 = this;
  10791. var pageDiv = _ref.pageDiv,
  10792. _ref$pageSpot = _ref.pageSpot,
  10793. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  10794. _ref$pageNumber = _ref.pageNumber,
  10795. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  10796. if (pageNumber) {
  10797. this._setCurrentPageNumber(pageNumber);
  10798. }
  10799. var scrolledDown = this._currentPageNumber >= this._previousPageNumber;
  10800. this._ensurePageViewVisible();
  10801. this.update();
  10802. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollIntoView", this).call(this, {
  10803. pageDiv: pageDiv,
  10804. pageSpot: pageSpot,
  10805. pageNumber: pageNumber
  10806. });
  10807. this._updateScrollDown = function () {
  10808. _this2.scroll.down = scrolledDown;
  10809. _this2._updateScrollDown = null;
  10810. };
  10811. }
  10812. }, {
  10813. key: "_getVisiblePages",
  10814. value: function _getVisiblePages() {
  10815. return this._getCurrentVisiblePage();
  10816. }
  10817. }, {
  10818. key: "_updateHelper",
  10819. value: function _updateHelper(visiblePages) {}
  10820. }, {
  10821. key: "_updateScrollMode",
  10822. value: function _updateScrollMode() {}
  10823. }, {
  10824. key: "_updateSpreadMode",
  10825. value: function _updateSpreadMode() {}
  10826. }, {
  10827. key: "_setDocumentViewerElement",
  10828. get: function get() {
  10829. return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this._shadowViewer);
  10830. }
  10831. }, {
  10832. key: "_isScrollModeHorizontal",
  10833. get: function get() {
  10834. return (0, _pdfjsLib.shadow)(this, '_isScrollModeHorizontal', false);
  10835. }
  10836. }]);
  10837. return PDFSinglePageViewer;
  10838. }(_base_viewer.BaseViewer);
  10839. exports.PDFSinglePageViewer = PDFSinglePageViewer;
  10840. /***/ }),
  10841. /* 35 */
  10842. /***/ (function(module, exports, __webpack_require__) {
  10843. "use strict";
  10844. Object.defineProperty(exports, "__esModule", {
  10845. value: true
  10846. });
  10847. exports.Toolbar = void 0;
  10848. var _ui_utils = __webpack_require__(6);
  10849. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10850. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  10851. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10852. var PAGE_NUMBER_LOADING_INDICATOR = 'visiblePageIsLoading';
  10853. var SCALE_SELECT_CONTAINER_PADDING = 8;
  10854. var SCALE_SELECT_PADDING = 22;
  10855. var Toolbar =
  10856. /*#__PURE__*/
  10857. function () {
  10858. function Toolbar(options, eventBus) {
  10859. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  10860. _classCallCheck(this, Toolbar);
  10861. this.toolbar = options.container;
  10862. this.eventBus = eventBus;
  10863. this.l10n = l10n;
  10864. this.items = options;
  10865. this._wasLocalized = false;
  10866. this.reset();
  10867. this._bindListeners();
  10868. }
  10869. _createClass(Toolbar, [{
  10870. key: "setPageNumber",
  10871. value: function setPageNumber(pageNumber, pageLabel) {
  10872. this.pageNumber = pageNumber;
  10873. this.pageLabel = pageLabel;
  10874. this._updateUIState(false);
  10875. }
  10876. }, {
  10877. key: "setPagesCount",
  10878. value: function setPagesCount(pagesCount, hasPageLabels) {
  10879. this.pagesCount = pagesCount;
  10880. this.hasPageLabels = hasPageLabels;
  10881. this._updateUIState(true);
  10882. }
  10883. }, {
  10884. key: "setPageScale",
  10885. value: function setPageScale(pageScaleValue, pageScale) {
  10886. this.pageScaleValue = (pageScaleValue || pageScale).toString();
  10887. this.pageScale = pageScale;
  10888. this._updateUIState(false);
  10889. }
  10890. }, {
  10891. key: "reset",
  10892. value: function reset() {
  10893. this.pageNumber = 0;
  10894. this.pageLabel = null;
  10895. this.hasPageLabels = false;
  10896. this.pagesCount = 0;
  10897. this.pageScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  10898. this.pageScale = _ui_utils.DEFAULT_SCALE;
  10899. this._updateUIState(true);
  10900. }
  10901. }, {
  10902. key: "_bindListeners",
  10903. value: function _bindListeners() {
  10904. var _this = this;
  10905. var eventBus = this.eventBus,
  10906. items = this.items;
  10907. var self = this;
  10908. items.previous.addEventListener('click', function () {
  10909. eventBus.dispatch('previouspage', {
  10910. source: self
  10911. });
  10912. });
  10913. items.next.addEventListener('click', function () {
  10914. eventBus.dispatch('nextpage', {
  10915. source: self
  10916. });
  10917. });
  10918. items.zoomIn.addEventListener('click', function () {
  10919. eventBus.dispatch('zoomin', {
  10920. source: self
  10921. });
  10922. });
  10923. items.zoomOut.addEventListener('click', function () {
  10924. eventBus.dispatch('zoomout', {
  10925. source: self
  10926. });
  10927. });
  10928. items.pageNumber.addEventListener('click', function () {
  10929. this.select();
  10930. });
  10931. items.pageNumber.addEventListener('change', function () {
  10932. eventBus.dispatch('pagenumberchanged', {
  10933. source: self,
  10934. value: this.value
  10935. });
  10936. });
  10937. items.scaleSelect.addEventListener('change', function () {
  10938. if (this.value === 'custom') {
  10939. return;
  10940. }
  10941. eventBus.dispatch('scalechanged', {
  10942. source: self,
  10943. value: this.value
  10944. });
  10945. });
  10946. items.presentationModeButton.addEventListener('click', function () {
  10947. eventBus.dispatch('presentationmode', {
  10948. source: self
  10949. });
  10950. });
  10951. items.openFile.addEventListener('click', function () {
  10952. eventBus.dispatch('openfile', {
  10953. source: self
  10954. });
  10955. });
  10956. items.print.addEventListener('click', function () {
  10957. eventBus.dispatch('print', {
  10958. source: self
  10959. });
  10960. });
  10961. items.download.addEventListener('click', function () {
  10962. eventBus.dispatch('download', {
  10963. source: self
  10964. });
  10965. });
  10966. items.scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler;
  10967. eventBus.on('localized', function () {
  10968. _this._localized();
  10969. });
  10970. }
  10971. }, {
  10972. key: "_localized",
  10973. value: function _localized() {
  10974. this._wasLocalized = true;
  10975. this._adjustScaleWidth();
  10976. this._updateUIState(true);
  10977. }
  10978. }, {
  10979. key: "_updateUIState",
  10980. value: function _updateUIState() {
  10981. var resetNumPages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  10982. if (!this._wasLocalized) {
  10983. return;
  10984. }
  10985. var pageNumber = this.pageNumber,
  10986. pagesCount = this.pagesCount,
  10987. pageScaleValue = this.pageScaleValue,
  10988. pageScale = this.pageScale,
  10989. items = this.items;
  10990. if (resetNumPages) {
  10991. if (this.hasPageLabels) {
  10992. items.pageNumber.type = 'text';
  10993. } else {
  10994. items.pageNumber.type = 'number';
  10995. this.l10n.get('of_pages', {
  10996. pagesCount: pagesCount
  10997. }, 'of {{pagesCount}}').then(function (msg) {
  10998. items.numPages.textContent = msg;
  10999. });
  11000. }
  11001. items.pageNumber.max = pagesCount;
  11002. }
  11003. if (this.hasPageLabels) {
  11004. items.pageNumber.value = this.pageLabel;
  11005. this.l10n.get('page_of_pages', {
  11006. pageNumber: pageNumber,
  11007. pagesCount: pagesCount
  11008. }, '({{pageNumber}} of {{pagesCount}})').then(function (msg) {
  11009. items.numPages.textContent = msg;
  11010. });
  11011. } else {
  11012. items.pageNumber.value = pageNumber;
  11013. }
  11014. items.previous.disabled = pageNumber <= 1;
  11015. items.next.disabled = pageNumber >= pagesCount;
  11016. items.zoomOut.disabled = pageScale <= _ui_utils.MIN_SCALE;
  11017. items.zoomIn.disabled = pageScale >= _ui_utils.MAX_SCALE;
  11018. var customScale = Math.round(pageScale * 10000) / 100;
  11019. this.l10n.get('page_scale_percent', {
  11020. scale: customScale
  11021. }, '{{scale}}%').then(function (msg) {
  11022. var options = items.scaleSelect.options;
  11023. var predefinedValueFound = false;
  11024. for (var i = 0, ii = options.length; i < ii; i++) {
  11025. var option = options[i];
  11026. if (option.value !== pageScaleValue) {
  11027. option.selected = false;
  11028. continue;
  11029. }
  11030. option.selected = true;
  11031. predefinedValueFound = true;
  11032. }
  11033. if (!predefinedValueFound) {
  11034. items.customScaleOption.textContent = msg;
  11035. items.customScaleOption.selected = true;
  11036. }
  11037. });
  11038. }
  11039. }, {
  11040. key: "updateLoadingIndicatorState",
  11041. value: function updateLoadingIndicatorState() {
  11042. var loading = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  11043. var pageNumberInput = this.items.pageNumber;
  11044. pageNumberInput.classList.toggle(PAGE_NUMBER_LOADING_INDICATOR, loading);
  11045. }
  11046. }, {
  11047. key: "_adjustScaleWidth",
  11048. value: function _adjustScaleWidth() {
  11049. var container = this.items.scaleSelectContainer;
  11050. var select = this.items.scaleSelect;
  11051. _ui_utils.animationStarted.then(function () {
  11052. if (container.clientWidth === 0) {
  11053. container.setAttribute('style', 'display: inherit;');
  11054. }
  11055. if (container.clientWidth > 0) {
  11056. select.setAttribute('style', 'min-width: inherit;');
  11057. var width = select.clientWidth + SCALE_SELECT_CONTAINER_PADDING;
  11058. select.setAttribute('style', 'min-width: ' + (width + SCALE_SELECT_PADDING) + 'px;');
  11059. container.setAttribute('style', 'min-width: ' + width + 'px; ' + 'max-width: ' + width + 'px;');
  11060. }
  11061. });
  11062. }
  11063. }]);
  11064. return Toolbar;
  11065. }();
  11066. exports.Toolbar = Toolbar;
  11067. /***/ }),
  11068. /* 36 */
  11069. /***/ (function(module, exports, __webpack_require__) {
  11070. "use strict";
  11071. Object.defineProperty(exports, "__esModule", {
  11072. value: true
  11073. });
  11074. exports.ViewHistory = void 0;
  11075. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  11076. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11077. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  11078. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  11079. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11080. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  11081. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11082. var DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
  11083. var ViewHistory =
  11084. /*#__PURE__*/
  11085. function () {
  11086. function ViewHistory(fingerprint) {
  11087. var _this = this;
  11088. var cacheSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_VIEW_HISTORY_CACHE_SIZE;
  11089. _classCallCheck(this, ViewHistory);
  11090. this.fingerprint = fingerprint;
  11091. this.cacheSize = cacheSize;
  11092. this._initializedPromise = this._readFromStorage().then(function (databaseStr) {
  11093. var database = JSON.parse(databaseStr || '{}');
  11094. if (!('files' in database)) {
  11095. database.files = [];
  11096. } else {
  11097. while (database.files.length >= _this.cacheSize) {
  11098. database.files.shift();
  11099. }
  11100. }
  11101. var index = -1;
  11102. for (var i = 0, length = database.files.length; i < length; i++) {
  11103. var branch = database.files[i];
  11104. if (branch.fingerprint === _this.fingerprint) {
  11105. index = i;
  11106. break;
  11107. }
  11108. }
  11109. if (index === -1) {
  11110. index = database.files.push({
  11111. fingerprint: _this.fingerprint
  11112. }) - 1;
  11113. }
  11114. _this.file = database.files[index];
  11115. _this.database = database;
  11116. });
  11117. }
  11118. _createClass(ViewHistory, [{
  11119. key: "_writeToStorage",
  11120. value: function () {
  11121. var _writeToStorage2 = _asyncToGenerator(
  11122. /*#__PURE__*/
  11123. _regenerator.default.mark(function _callee() {
  11124. var databaseStr;
  11125. return _regenerator.default.wrap(function _callee$(_context) {
  11126. while (1) {
  11127. switch (_context.prev = _context.next) {
  11128. case 0:
  11129. databaseStr = JSON.stringify(this.database);
  11130. localStorage.setItem('pdfjs.history', databaseStr);
  11131. case 2:
  11132. case "end":
  11133. return _context.stop();
  11134. }
  11135. }
  11136. }, _callee, this);
  11137. }));
  11138. function _writeToStorage() {
  11139. return _writeToStorage2.apply(this, arguments);
  11140. }
  11141. return _writeToStorage;
  11142. }()
  11143. }, {
  11144. key: "_readFromStorage",
  11145. value: function () {
  11146. var _readFromStorage2 = _asyncToGenerator(
  11147. /*#__PURE__*/
  11148. _regenerator.default.mark(function _callee2() {
  11149. return _regenerator.default.wrap(function _callee2$(_context2) {
  11150. while (1) {
  11151. switch (_context2.prev = _context2.next) {
  11152. case 0:
  11153. return _context2.abrupt("return", localStorage.getItem('pdfjs.history'));
  11154. case 1:
  11155. case "end":
  11156. return _context2.stop();
  11157. }
  11158. }
  11159. }, _callee2, this);
  11160. }));
  11161. function _readFromStorage() {
  11162. return _readFromStorage2.apply(this, arguments);
  11163. }
  11164. return _readFromStorage;
  11165. }()
  11166. }, {
  11167. key: "set",
  11168. value: function () {
  11169. var _set = _asyncToGenerator(
  11170. /*#__PURE__*/
  11171. _regenerator.default.mark(function _callee3(name, val) {
  11172. return _regenerator.default.wrap(function _callee3$(_context3) {
  11173. while (1) {
  11174. switch (_context3.prev = _context3.next) {
  11175. case 0:
  11176. _context3.next = 2;
  11177. return this._initializedPromise;
  11178. case 2:
  11179. this.file[name] = val;
  11180. return _context3.abrupt("return", this._writeToStorage());
  11181. case 4:
  11182. case "end":
  11183. return _context3.stop();
  11184. }
  11185. }
  11186. }, _callee3, this);
  11187. }));
  11188. function set(_x, _x2) {
  11189. return _set.apply(this, arguments);
  11190. }
  11191. return set;
  11192. }()
  11193. }, {
  11194. key: "setMultiple",
  11195. value: function () {
  11196. var _setMultiple = _asyncToGenerator(
  11197. /*#__PURE__*/
  11198. _regenerator.default.mark(function _callee4(properties) {
  11199. var name;
  11200. return _regenerator.default.wrap(function _callee4$(_context4) {
  11201. while (1) {
  11202. switch (_context4.prev = _context4.next) {
  11203. case 0:
  11204. _context4.next = 2;
  11205. return this._initializedPromise;
  11206. case 2:
  11207. for (name in properties) {
  11208. this.file[name] = properties[name];
  11209. }
  11210. return _context4.abrupt("return", this._writeToStorage());
  11211. case 4:
  11212. case "end":
  11213. return _context4.stop();
  11214. }
  11215. }
  11216. }, _callee4, this);
  11217. }));
  11218. function setMultiple(_x3) {
  11219. return _setMultiple.apply(this, arguments);
  11220. }
  11221. return setMultiple;
  11222. }()
  11223. }, {
  11224. key: "get",
  11225. value: function () {
  11226. var _get = _asyncToGenerator(
  11227. /*#__PURE__*/
  11228. _regenerator.default.mark(function _callee5(name, defaultValue) {
  11229. var val;
  11230. return _regenerator.default.wrap(function _callee5$(_context5) {
  11231. while (1) {
  11232. switch (_context5.prev = _context5.next) {
  11233. case 0:
  11234. _context5.next = 2;
  11235. return this._initializedPromise;
  11236. case 2:
  11237. val = this.file[name];
  11238. return _context5.abrupt("return", val !== undefined ? val : defaultValue);
  11239. case 4:
  11240. case "end":
  11241. return _context5.stop();
  11242. }
  11243. }
  11244. }, _callee5, this);
  11245. }));
  11246. function get(_x4, _x5) {
  11247. return _get.apply(this, arguments);
  11248. }
  11249. return get;
  11250. }()
  11251. }, {
  11252. key: "getMultiple",
  11253. value: function () {
  11254. var _getMultiple = _asyncToGenerator(
  11255. /*#__PURE__*/
  11256. _regenerator.default.mark(function _callee6(properties) {
  11257. var values, name, val;
  11258. return _regenerator.default.wrap(function _callee6$(_context6) {
  11259. while (1) {
  11260. switch (_context6.prev = _context6.next) {
  11261. case 0:
  11262. _context6.next = 2;
  11263. return this._initializedPromise;
  11264. case 2:
  11265. values = Object.create(null);
  11266. for (name in properties) {
  11267. val = this.file[name];
  11268. values[name] = val !== undefined ? val : properties[name];
  11269. }
  11270. return _context6.abrupt("return", values);
  11271. case 5:
  11272. case "end":
  11273. return _context6.stop();
  11274. }
  11275. }
  11276. }, _callee6, this);
  11277. }));
  11278. function getMultiple(_x6) {
  11279. return _getMultiple.apply(this, arguments);
  11280. }
  11281. return getMultiple;
  11282. }()
  11283. }]);
  11284. return ViewHistory;
  11285. }();
  11286. exports.ViewHistory = ViewHistory;
  11287. /***/ }),
  11288. /* 37 */
  11289. /***/ (function(module, exports, __webpack_require__) {
  11290. "use strict";
  11291. Object.defineProperty(exports, "__esModule", {
  11292. value: true
  11293. });
  11294. exports.GenericCom = void 0;
  11295. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  11296. var _app = __webpack_require__(1);
  11297. var _preferences = __webpack_require__(38);
  11298. var _download_manager = __webpack_require__(39);
  11299. var _genericl10n = __webpack_require__(40);
  11300. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11301. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  11302. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  11303. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  11304. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11305. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  11306. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11307. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  11308. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  11309. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  11310. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  11311. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  11312. ;
  11313. var GenericCom = {};
  11314. exports.GenericCom = GenericCom;
  11315. var GenericPreferences =
  11316. /*#__PURE__*/
  11317. function (_BasePreferences) {
  11318. _inherits(GenericPreferences, _BasePreferences);
  11319. function GenericPreferences() {
  11320. _classCallCheck(this, GenericPreferences);
  11321. return _possibleConstructorReturn(this, _getPrototypeOf(GenericPreferences).apply(this, arguments));
  11322. }
  11323. _createClass(GenericPreferences, [{
  11324. key: "_writeToStorage",
  11325. value: function () {
  11326. var _writeToStorage2 = _asyncToGenerator(
  11327. /*#__PURE__*/
  11328. _regenerator.default.mark(function _callee(prefObj) {
  11329. return _regenerator.default.wrap(function _callee$(_context) {
  11330. while (1) {
  11331. switch (_context.prev = _context.next) {
  11332. case 0:
  11333. localStorage.setItem('pdfjs.preferences', JSON.stringify(prefObj));
  11334. case 1:
  11335. case "end":
  11336. return _context.stop();
  11337. }
  11338. }
  11339. }, _callee, this);
  11340. }));
  11341. function _writeToStorage(_x) {
  11342. return _writeToStorage2.apply(this, arguments);
  11343. }
  11344. return _writeToStorage;
  11345. }()
  11346. }, {
  11347. key: "_readFromStorage",
  11348. value: function () {
  11349. var _readFromStorage2 = _asyncToGenerator(
  11350. /*#__PURE__*/
  11351. _regenerator.default.mark(function _callee2(prefObj) {
  11352. return _regenerator.default.wrap(function _callee2$(_context2) {
  11353. while (1) {
  11354. switch (_context2.prev = _context2.next) {
  11355. case 0:
  11356. return _context2.abrupt("return", JSON.parse(localStorage.getItem('pdfjs.preferences')));
  11357. case 1:
  11358. case "end":
  11359. return _context2.stop();
  11360. }
  11361. }
  11362. }, _callee2, this);
  11363. }));
  11364. function _readFromStorage(_x2) {
  11365. return _readFromStorage2.apply(this, arguments);
  11366. }
  11367. return _readFromStorage;
  11368. }()
  11369. }]);
  11370. return GenericPreferences;
  11371. }(_preferences.BasePreferences);
  11372. var GenericExternalServices = Object.create(_app.DefaultExternalServices);
  11373. GenericExternalServices.createDownloadManager = function (options) {
  11374. return new _download_manager.DownloadManager(options);
  11375. };
  11376. GenericExternalServices.createPreferences = function () {
  11377. return new GenericPreferences();
  11378. };
  11379. GenericExternalServices.createL10n = function (_ref) {
  11380. var _ref$locale = _ref.locale,
  11381. locale = _ref$locale === void 0 ? 'en-US' : _ref$locale;
  11382. return new _genericl10n.GenericL10n(locale);
  11383. };
  11384. _app.PDFViewerApplication.externalServices = GenericExternalServices;
  11385. /***/ }),
  11386. /* 38 */
  11387. /***/ (function(module, exports, __webpack_require__) {
  11388. "use strict";
  11389. Object.defineProperty(exports, "__esModule", {
  11390. value: true
  11391. });
  11392. exports.BasePreferences = void 0;
  11393. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  11394. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11395. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  11396. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  11397. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  11398. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11399. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  11400. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11401. var defaultPreferences = null;
  11402. function getDefaultPreferences() {
  11403. if (!defaultPreferences) {
  11404. defaultPreferences = Promise.resolve({
  11405. "viewOnLoad": 0,
  11406. "defaultZoomValue": "",
  11407. "sidebarViewOnLoad": -1,
  11408. "cursorToolOnLoad": 0,
  11409. "enableWebGL": false,
  11410. "eventBusDispatchToDOM": false,
  11411. "pdfBugEnabled": false,
  11412. "disableRange": false,
  11413. "disableStream": false,
  11414. "disableAutoFetch": false,
  11415. "disableFontFace": false,
  11416. "textLayerMode": 1,
  11417. "useOnlyCssZoom": false,
  11418. "externalLinkTarget": 0,
  11419. "renderer": "canvas",
  11420. "renderInteractiveForms": false,
  11421. "enablePrintAutoRotate": false,
  11422. "disablePageLabels": false,
  11423. "historyUpdateUrl": false,
  11424. "scrollModeOnLoad": -1,
  11425. "spreadModeOnLoad": -1
  11426. });
  11427. }
  11428. return defaultPreferences;
  11429. }
  11430. var BasePreferences =
  11431. /*#__PURE__*/
  11432. function () {
  11433. function BasePreferences() {
  11434. var _this = this;
  11435. _classCallCheck(this, BasePreferences);
  11436. if (this.constructor === BasePreferences) {
  11437. throw new Error('Cannot initialize BasePreferences.');
  11438. }
  11439. this.prefs = null;
  11440. this._initializedPromise = getDefaultPreferences().then(function (defaults) {
  11441. Object.defineProperty(_this, 'defaults', {
  11442. value: Object.freeze(defaults),
  11443. writable: false,
  11444. enumerable: true,
  11445. configurable: false
  11446. });
  11447. _this.prefs = Object.assign(Object.create(null), defaults);
  11448. return _this._readFromStorage(defaults);
  11449. }).then(function (prefs) {
  11450. if (!prefs) {
  11451. return;
  11452. }
  11453. for (var name in prefs) {
  11454. var defaultValue = _this.defaults[name],
  11455. prefValue = prefs[name];
  11456. if (defaultValue === undefined || _typeof(prefValue) !== _typeof(defaultValue)) {
  11457. continue;
  11458. }
  11459. _this.prefs[name] = prefValue;
  11460. }
  11461. });
  11462. }
  11463. _createClass(BasePreferences, [{
  11464. key: "_writeToStorage",
  11465. value: function () {
  11466. var _writeToStorage2 = _asyncToGenerator(
  11467. /*#__PURE__*/
  11468. _regenerator.default.mark(function _callee(prefObj) {
  11469. return _regenerator.default.wrap(function _callee$(_context) {
  11470. while (1) {
  11471. switch (_context.prev = _context.next) {
  11472. case 0:
  11473. throw new Error('Not implemented: _writeToStorage');
  11474. case 1:
  11475. case "end":
  11476. return _context.stop();
  11477. }
  11478. }
  11479. }, _callee, this);
  11480. }));
  11481. function _writeToStorage(_x) {
  11482. return _writeToStorage2.apply(this, arguments);
  11483. }
  11484. return _writeToStorage;
  11485. }()
  11486. }, {
  11487. key: "_readFromStorage",
  11488. value: function () {
  11489. var _readFromStorage2 = _asyncToGenerator(
  11490. /*#__PURE__*/
  11491. _regenerator.default.mark(function _callee2(prefObj) {
  11492. return _regenerator.default.wrap(function _callee2$(_context2) {
  11493. while (1) {
  11494. switch (_context2.prev = _context2.next) {
  11495. case 0:
  11496. throw new Error('Not implemented: _readFromStorage');
  11497. case 1:
  11498. case "end":
  11499. return _context2.stop();
  11500. }
  11501. }
  11502. }, _callee2, this);
  11503. }));
  11504. function _readFromStorage(_x2) {
  11505. return _readFromStorage2.apply(this, arguments);
  11506. }
  11507. return _readFromStorage;
  11508. }()
  11509. }, {
  11510. key: "reset",
  11511. value: function () {
  11512. var _reset = _asyncToGenerator(
  11513. /*#__PURE__*/
  11514. _regenerator.default.mark(function _callee3() {
  11515. return _regenerator.default.wrap(function _callee3$(_context3) {
  11516. while (1) {
  11517. switch (_context3.prev = _context3.next) {
  11518. case 0:
  11519. _context3.next = 2;
  11520. return this._initializedPromise;
  11521. case 2:
  11522. this.prefs = Object.assign(Object.create(null), this.defaults);
  11523. return _context3.abrupt("return", this._writeToStorage(this.defaults));
  11524. case 4:
  11525. case "end":
  11526. return _context3.stop();
  11527. }
  11528. }
  11529. }, _callee3, this);
  11530. }));
  11531. function reset() {
  11532. return _reset.apply(this, arguments);
  11533. }
  11534. return reset;
  11535. }()
  11536. }, {
  11537. key: "set",
  11538. value: function () {
  11539. var _set = _asyncToGenerator(
  11540. /*#__PURE__*/
  11541. _regenerator.default.mark(function _callee4(name, value) {
  11542. var defaultValue, valueType, defaultType;
  11543. return _regenerator.default.wrap(function _callee4$(_context4) {
  11544. while (1) {
  11545. switch (_context4.prev = _context4.next) {
  11546. case 0:
  11547. _context4.next = 2;
  11548. return this._initializedPromise;
  11549. case 2:
  11550. defaultValue = this.defaults[name];
  11551. if (!(defaultValue === undefined)) {
  11552. _context4.next = 7;
  11553. break;
  11554. }
  11555. throw new Error("Set preference: \"".concat(name, "\" is undefined."));
  11556. case 7:
  11557. if (!(value === undefined)) {
  11558. _context4.next = 9;
  11559. break;
  11560. }
  11561. throw new Error('Set preference: no value is specified.');
  11562. case 9:
  11563. valueType = _typeof(value);
  11564. defaultType = _typeof(defaultValue);
  11565. if (!(valueType !== defaultType)) {
  11566. _context4.next = 19;
  11567. break;
  11568. }
  11569. if (!(valueType === 'number' && defaultType === 'string')) {
  11570. _context4.next = 16;
  11571. break;
  11572. }
  11573. value = value.toString();
  11574. _context4.next = 17;
  11575. break;
  11576. case 16:
  11577. throw new Error("Set preference: \"".concat(value, "\" is a ").concat(valueType, ", ") + "expected a ".concat(defaultType, "."));
  11578. case 17:
  11579. _context4.next = 21;
  11580. break;
  11581. case 19:
  11582. if (!(valueType === 'number' && !Number.isInteger(value))) {
  11583. _context4.next = 21;
  11584. break;
  11585. }
  11586. throw new Error("Set preference: \"".concat(value, "\" must be an integer."));
  11587. case 21:
  11588. this.prefs[name] = value;
  11589. return _context4.abrupt("return", this._writeToStorage(this.prefs));
  11590. case 23:
  11591. case "end":
  11592. return _context4.stop();
  11593. }
  11594. }
  11595. }, _callee4, this);
  11596. }));
  11597. function set(_x3, _x4) {
  11598. return _set.apply(this, arguments);
  11599. }
  11600. return set;
  11601. }()
  11602. }, {
  11603. key: "get",
  11604. value: function () {
  11605. var _get = _asyncToGenerator(
  11606. /*#__PURE__*/
  11607. _regenerator.default.mark(function _callee5(name) {
  11608. var defaultValue, prefValue;
  11609. return _regenerator.default.wrap(function _callee5$(_context5) {
  11610. while (1) {
  11611. switch (_context5.prev = _context5.next) {
  11612. case 0:
  11613. _context5.next = 2;
  11614. return this._initializedPromise;
  11615. case 2:
  11616. defaultValue = this.defaults[name];
  11617. if (!(defaultValue === undefined)) {
  11618. _context5.next = 7;
  11619. break;
  11620. }
  11621. throw new Error("Get preference: \"".concat(name, "\" is undefined."));
  11622. case 7:
  11623. prefValue = this.prefs[name];
  11624. if (!(prefValue !== undefined)) {
  11625. _context5.next = 10;
  11626. break;
  11627. }
  11628. return _context5.abrupt("return", prefValue);
  11629. case 10:
  11630. return _context5.abrupt("return", defaultValue);
  11631. case 11:
  11632. case "end":
  11633. return _context5.stop();
  11634. }
  11635. }
  11636. }, _callee5, this);
  11637. }));
  11638. function get(_x5) {
  11639. return _get.apply(this, arguments);
  11640. }
  11641. return get;
  11642. }()
  11643. }, {
  11644. key: "getAll",
  11645. value: function () {
  11646. var _getAll = _asyncToGenerator(
  11647. /*#__PURE__*/
  11648. _regenerator.default.mark(function _callee6() {
  11649. return _regenerator.default.wrap(function _callee6$(_context6) {
  11650. while (1) {
  11651. switch (_context6.prev = _context6.next) {
  11652. case 0:
  11653. _context6.next = 2;
  11654. return this._initializedPromise;
  11655. case 2:
  11656. return _context6.abrupt("return", Object.assign(Object.create(null), this.defaults, this.prefs));
  11657. case 3:
  11658. case "end":
  11659. return _context6.stop();
  11660. }
  11661. }
  11662. }, _callee6, this);
  11663. }));
  11664. function getAll() {
  11665. return _getAll.apply(this, arguments);
  11666. }
  11667. return getAll;
  11668. }()
  11669. }]);
  11670. return BasePreferences;
  11671. }();
  11672. exports.BasePreferences = BasePreferences;
  11673. /***/ }),
  11674. /* 39 */
  11675. /***/ (function(module, exports, __webpack_require__) {
  11676. "use strict";
  11677. Object.defineProperty(exports, "__esModule", {
  11678. value: true
  11679. });
  11680. exports.DownloadManager = void 0;
  11681. var _pdfjsLib = __webpack_require__(7);
  11682. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11683. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  11684. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11685. ;
  11686. var DISABLE_CREATE_OBJECT_URL = _pdfjsLib.apiCompatibilityParams.disableCreateObjectURL || false;
  11687. function _download(blobUrl, filename) {
  11688. var a = document.createElement('a');
  11689. if (!a.click) {
  11690. throw new Error('DownloadManager: "a.click()" is not supported.');
  11691. }
  11692. a.href = blobUrl;
  11693. a.target = '_parent';
  11694. if ('download' in a) {
  11695. a.download = filename;
  11696. }
  11697. (document.body || document.documentElement).appendChild(a);
  11698. a.click();
  11699. a.remove();
  11700. }
  11701. var DownloadManager =
  11702. /*#__PURE__*/
  11703. function () {
  11704. function DownloadManager(_ref) {
  11705. var _ref$disableCreateObj = _ref.disableCreateObjectURL,
  11706. disableCreateObjectURL = _ref$disableCreateObj === void 0 ? DISABLE_CREATE_OBJECT_URL : _ref$disableCreateObj;
  11707. _classCallCheck(this, DownloadManager);
  11708. this.disableCreateObjectURL = disableCreateObjectURL;
  11709. }
  11710. _createClass(DownloadManager, [{
  11711. key: "downloadUrl",
  11712. value: function downloadUrl(url, filename) {
  11713. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, 'http://example.com')) {
  11714. return;
  11715. }
  11716. _download(url + '#pdfjs.action=download', filename);
  11717. }
  11718. }, {
  11719. key: "downloadData",
  11720. value: function downloadData(data, filename, contentType) {
  11721. if (navigator.msSaveBlob) {
  11722. return navigator.msSaveBlob(new Blob([data], {
  11723. type: contentType
  11724. }), filename);
  11725. }
  11726. var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, this.disableCreateObjectURL);
  11727. _download(blobUrl, filename);
  11728. }
  11729. }, {
  11730. key: "download",
  11731. value: function download(blob, url, filename) {
  11732. if (navigator.msSaveBlob) {
  11733. if (!navigator.msSaveBlob(blob, filename)) {
  11734. this.downloadUrl(url, filename);
  11735. }
  11736. return;
  11737. }
  11738. if (this.disableCreateObjectURL) {
  11739. this.downloadUrl(url, filename);
  11740. return;
  11741. }
  11742. var blobUrl = _pdfjsLib.URL.createObjectURL(blob);
  11743. _download(blobUrl, filename);
  11744. }
  11745. }]);
  11746. return DownloadManager;
  11747. }();
  11748. exports.DownloadManager = DownloadManager;
  11749. /***/ }),
  11750. /* 40 */
  11751. /***/ (function(module, exports, __webpack_require__) {
  11752. "use strict";
  11753. Object.defineProperty(exports, "__esModule", {
  11754. value: true
  11755. });
  11756. exports.GenericL10n = void 0;
  11757. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  11758. __webpack_require__(41);
  11759. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11760. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  11761. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  11762. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11763. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  11764. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11765. var webL10n = document.webL10n;
  11766. var GenericL10n =
  11767. /*#__PURE__*/
  11768. function () {
  11769. function GenericL10n(lang) {
  11770. _classCallCheck(this, GenericL10n);
  11771. this._lang = lang;
  11772. this._ready = new Promise(function (resolve, reject) {
  11773. webL10n.setLanguage(lang, function () {
  11774. resolve(webL10n);
  11775. });
  11776. });
  11777. }
  11778. _createClass(GenericL10n, [{
  11779. key: "getLanguage",
  11780. value: function () {
  11781. var _getLanguage = _asyncToGenerator(
  11782. /*#__PURE__*/
  11783. _regenerator.default.mark(function _callee() {
  11784. var l10n;
  11785. return _regenerator.default.wrap(function _callee$(_context) {
  11786. while (1) {
  11787. switch (_context.prev = _context.next) {
  11788. case 0:
  11789. _context.next = 2;
  11790. return this._ready;
  11791. case 2:
  11792. l10n = _context.sent;
  11793. return _context.abrupt("return", l10n.getLanguage());
  11794. case 4:
  11795. case "end":
  11796. return _context.stop();
  11797. }
  11798. }
  11799. }, _callee, this);
  11800. }));
  11801. function getLanguage() {
  11802. return _getLanguage.apply(this, arguments);
  11803. }
  11804. return getLanguage;
  11805. }()
  11806. }, {
  11807. key: "getDirection",
  11808. value: function () {
  11809. var _getDirection = _asyncToGenerator(
  11810. /*#__PURE__*/
  11811. _regenerator.default.mark(function _callee2() {
  11812. var l10n;
  11813. return _regenerator.default.wrap(function _callee2$(_context2) {
  11814. while (1) {
  11815. switch (_context2.prev = _context2.next) {
  11816. case 0:
  11817. _context2.next = 2;
  11818. return this._ready;
  11819. case 2:
  11820. l10n = _context2.sent;
  11821. return _context2.abrupt("return", l10n.getDirection());
  11822. case 4:
  11823. case "end":
  11824. return _context2.stop();
  11825. }
  11826. }
  11827. }, _callee2, this);
  11828. }));
  11829. function getDirection() {
  11830. return _getDirection.apply(this, arguments);
  11831. }
  11832. return getDirection;
  11833. }()
  11834. }, {
  11835. key: "get",
  11836. value: function () {
  11837. var _get = _asyncToGenerator(
  11838. /*#__PURE__*/
  11839. _regenerator.default.mark(function _callee3(property, args, fallback) {
  11840. var l10n;
  11841. return _regenerator.default.wrap(function _callee3$(_context3) {
  11842. while (1) {
  11843. switch (_context3.prev = _context3.next) {
  11844. case 0:
  11845. _context3.next = 2;
  11846. return this._ready;
  11847. case 2:
  11848. l10n = _context3.sent;
  11849. return _context3.abrupt("return", l10n.get(property, args, fallback));
  11850. case 4:
  11851. case "end":
  11852. return _context3.stop();
  11853. }
  11854. }
  11855. }, _callee3, this);
  11856. }));
  11857. function get(_x, _x2, _x3) {
  11858. return _get.apply(this, arguments);
  11859. }
  11860. return get;
  11861. }()
  11862. }, {
  11863. key: "translate",
  11864. value: function () {
  11865. var _translate = _asyncToGenerator(
  11866. /*#__PURE__*/
  11867. _regenerator.default.mark(function _callee4(element) {
  11868. var l10n;
  11869. return _regenerator.default.wrap(function _callee4$(_context4) {
  11870. while (1) {
  11871. switch (_context4.prev = _context4.next) {
  11872. case 0:
  11873. _context4.next = 2;
  11874. return this._ready;
  11875. case 2:
  11876. l10n = _context4.sent;
  11877. return _context4.abrupt("return", l10n.translate(element));
  11878. case 4:
  11879. case "end":
  11880. return _context4.stop();
  11881. }
  11882. }
  11883. }, _callee4, this);
  11884. }));
  11885. function translate(_x4) {
  11886. return _translate.apply(this, arguments);
  11887. }
  11888. return translate;
  11889. }()
  11890. }]);
  11891. return GenericL10n;
  11892. }();
  11893. exports.GenericL10n = GenericL10n;
  11894. /***/ }),
  11895. /* 41 */
  11896. /***/ (function(module, exports, __webpack_require__) {
  11897. "use strict";
  11898. document.webL10n = function (window, document, undefined) {
  11899. var gL10nData = {};
  11900. var gTextData = '';
  11901. var gTextProp = 'textContent';
  11902. var gLanguage = '';
  11903. var gMacros = {};
  11904. var gReadyState = 'loading';
  11905. var gAsyncResourceLoading = true;
  11906. function getL10nResourceLinks() {
  11907. return document.querySelectorAll('link[type="application/l10n"]');
  11908. }
  11909. function getL10nDictionary() {
  11910. var script = document.querySelector('script[type="application/l10n"]');
  11911. return script ? JSON.parse(script.innerHTML) : null;
  11912. }
  11913. function getTranslatableChildren(element) {
  11914. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  11915. }
  11916. function getL10nAttributes(element) {
  11917. if (!element) return {};
  11918. var l10nId = element.getAttribute('data-l10n-id');
  11919. var l10nArgs = element.getAttribute('data-l10n-args');
  11920. var args = {};
  11921. if (l10nArgs) {
  11922. try {
  11923. args = JSON.parse(l10nArgs);
  11924. } catch (e) {
  11925. console.warn('could not parse arguments for #' + l10nId);
  11926. }
  11927. }
  11928. return {
  11929. id: l10nId,
  11930. args: args
  11931. };
  11932. }
  11933. function fireL10nReadyEvent(lang) {
  11934. var evtObject = document.createEvent('Event');
  11935. evtObject.initEvent('localized', true, false);
  11936. evtObject.language = lang;
  11937. document.dispatchEvent(evtObject);
  11938. }
  11939. function xhrLoadText(url, onSuccess, onFailure) {
  11940. onSuccess = onSuccess || function _onSuccess(data) {};
  11941. onFailure = onFailure || function _onFailure() {};
  11942. var xhr = new XMLHttpRequest();
  11943. xhr.open('GET', url, gAsyncResourceLoading);
  11944. if (xhr.overrideMimeType) {
  11945. xhr.overrideMimeType('text/plain; charset=utf-8');
  11946. }
  11947. xhr.onreadystatechange = function () {
  11948. if (xhr.readyState == 4) {
  11949. if (xhr.status == 200 || xhr.status === 0) {
  11950. onSuccess(xhr.responseText);
  11951. } else {
  11952. onFailure();
  11953. }
  11954. }
  11955. };
  11956. xhr.onerror = onFailure;
  11957. xhr.ontimeout = onFailure;
  11958. try {
  11959. xhr.send(null);
  11960. } catch (e) {
  11961. onFailure();
  11962. }
  11963. }
  11964. function parseResource(href, lang, successCallback, failureCallback) {
  11965. var baseURL = href.replace(/[^\/]*$/, '') || './';
  11966. function evalString(text) {
  11967. if (text.lastIndexOf('\\') < 0) return text;
  11968. 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, "'");
  11969. }
  11970. function parseProperties(text, parsedPropertiesCallback) {
  11971. var dictionary = {};
  11972. var reBlank = /^\s*|\s*$/;
  11973. var reComment = /^\s*#|^\s*$/;
  11974. var reSection = /^\s*\[(.*)\]\s*$/;
  11975. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  11976. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  11977. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  11978. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  11979. var currentLang = '*';
  11980. var genericLang = lang.split('-', 1)[0];
  11981. var skipLang = false;
  11982. var match = '';
  11983. function nextEntry() {
  11984. while (true) {
  11985. if (!entries.length) {
  11986. parsedRawLinesCallback();
  11987. return;
  11988. }
  11989. var line = entries.shift();
  11990. if (reComment.test(line)) continue;
  11991. if (extendedSyntax) {
  11992. match = reSection.exec(line);
  11993. if (match) {
  11994. currentLang = match[1].toLowerCase();
  11995. skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
  11996. continue;
  11997. } else if (skipLang) {
  11998. continue;
  11999. }
  12000. match = reImport.exec(line);
  12001. if (match) {
  12002. loadImport(baseURL + match[1], nextEntry);
  12003. return;
  12004. }
  12005. }
  12006. var tmp = line.match(reSplit);
  12007. if (tmp && tmp.length == 3) {
  12008. dictionary[tmp[1]] = evalString(tmp[2]);
  12009. }
  12010. }
  12011. }
  12012. nextEntry();
  12013. }
  12014. function loadImport(url, callback) {
  12015. xhrLoadText(url, function (content) {
  12016. parseRawLines(content, false, callback);
  12017. }, function () {
  12018. console.warn(url + ' not found.');
  12019. callback();
  12020. });
  12021. }
  12022. parseRawLines(text, true, function () {
  12023. parsedPropertiesCallback(dictionary);
  12024. });
  12025. }
  12026. xhrLoadText(href, function (response) {
  12027. gTextData += response;
  12028. parseProperties(response, function (data) {
  12029. for (var key in data) {
  12030. var id,
  12031. prop,
  12032. index = key.lastIndexOf('.');
  12033. if (index > 0) {
  12034. id = key.substring(0, index);
  12035. prop = key.substring(index + 1);
  12036. } else {
  12037. id = key;
  12038. prop = gTextProp;
  12039. }
  12040. if (!gL10nData[id]) {
  12041. gL10nData[id] = {};
  12042. }
  12043. gL10nData[id][prop] = data[key];
  12044. }
  12045. if (successCallback) {
  12046. successCallback();
  12047. }
  12048. });
  12049. }, failureCallback);
  12050. }
  12051. function loadLocale(lang, callback) {
  12052. if (lang) {
  12053. lang = lang.toLowerCase();
  12054. }
  12055. callback = callback || function _callback() {};
  12056. clear();
  12057. gLanguage = lang;
  12058. var langLinks = getL10nResourceLinks();
  12059. var langCount = langLinks.length;
  12060. if (langCount === 0) {
  12061. var dict = getL10nDictionary();
  12062. if (dict && dict.locales && dict.default_locale) {
  12063. console.log('using the embedded JSON directory, early way out');
  12064. gL10nData = dict.locales[lang];
  12065. if (!gL10nData) {
  12066. var defaultLocale = dict.default_locale.toLowerCase();
  12067. for (var anyCaseLang in dict.locales) {
  12068. anyCaseLang = anyCaseLang.toLowerCase();
  12069. if (anyCaseLang === lang) {
  12070. gL10nData = dict.locales[lang];
  12071. break;
  12072. } else if (anyCaseLang === defaultLocale) {
  12073. gL10nData = dict.locales[defaultLocale];
  12074. }
  12075. }
  12076. }
  12077. callback();
  12078. } else {
  12079. console.log('no resource to load, early way out');
  12080. }
  12081. fireL10nReadyEvent(lang);
  12082. gReadyState = 'complete';
  12083. return;
  12084. }
  12085. var onResourceLoaded = null;
  12086. var gResourceCount = 0;
  12087. onResourceLoaded = function onResourceLoaded() {
  12088. gResourceCount++;
  12089. if (gResourceCount >= langCount) {
  12090. callback();
  12091. fireL10nReadyEvent(lang);
  12092. gReadyState = 'complete';
  12093. }
  12094. };
  12095. function L10nResourceLink(link) {
  12096. var href = link.href;
  12097. this.load = function (lang, callback) {
  12098. parseResource(href, lang, callback, function () {
  12099. console.warn(href + ' not found.');
  12100. console.warn('"' + lang + '" resource not found');
  12101. gLanguage = '';
  12102. callback();
  12103. });
  12104. };
  12105. }
  12106. for (var i = 0; i < langCount; i++) {
  12107. var resource = new L10nResourceLink(langLinks[i]);
  12108. resource.load(lang, onResourceLoaded);
  12109. }
  12110. }
  12111. function clear() {
  12112. gL10nData = {};
  12113. gTextData = '';
  12114. gLanguage = '';
  12115. }
  12116. function getPluralRules(lang) {
  12117. var locales2rules = {
  12118. 'af': 3,
  12119. 'ak': 4,
  12120. 'am': 4,
  12121. 'ar': 1,
  12122. 'asa': 3,
  12123. 'az': 0,
  12124. 'be': 11,
  12125. 'bem': 3,
  12126. 'bez': 3,
  12127. 'bg': 3,
  12128. 'bh': 4,
  12129. 'bm': 0,
  12130. 'bn': 3,
  12131. 'bo': 0,
  12132. 'br': 20,
  12133. 'brx': 3,
  12134. 'bs': 11,
  12135. 'ca': 3,
  12136. 'cgg': 3,
  12137. 'chr': 3,
  12138. 'cs': 12,
  12139. 'cy': 17,
  12140. 'da': 3,
  12141. 'de': 3,
  12142. 'dv': 3,
  12143. 'dz': 0,
  12144. 'ee': 3,
  12145. 'el': 3,
  12146. 'en': 3,
  12147. 'eo': 3,
  12148. 'es': 3,
  12149. 'et': 3,
  12150. 'eu': 3,
  12151. 'fa': 0,
  12152. 'ff': 5,
  12153. 'fi': 3,
  12154. 'fil': 4,
  12155. 'fo': 3,
  12156. 'fr': 5,
  12157. 'fur': 3,
  12158. 'fy': 3,
  12159. 'ga': 8,
  12160. 'gd': 24,
  12161. 'gl': 3,
  12162. 'gsw': 3,
  12163. 'gu': 3,
  12164. 'guw': 4,
  12165. 'gv': 23,
  12166. 'ha': 3,
  12167. 'haw': 3,
  12168. 'he': 2,
  12169. 'hi': 4,
  12170. 'hr': 11,
  12171. 'hu': 0,
  12172. 'id': 0,
  12173. 'ig': 0,
  12174. 'ii': 0,
  12175. 'is': 3,
  12176. 'it': 3,
  12177. 'iu': 7,
  12178. 'ja': 0,
  12179. 'jmc': 3,
  12180. 'jv': 0,
  12181. 'ka': 0,
  12182. 'kab': 5,
  12183. 'kaj': 3,
  12184. 'kcg': 3,
  12185. 'kde': 0,
  12186. 'kea': 0,
  12187. 'kk': 3,
  12188. 'kl': 3,
  12189. 'km': 0,
  12190. 'kn': 0,
  12191. 'ko': 0,
  12192. 'ksb': 3,
  12193. 'ksh': 21,
  12194. 'ku': 3,
  12195. 'kw': 7,
  12196. 'lag': 18,
  12197. 'lb': 3,
  12198. 'lg': 3,
  12199. 'ln': 4,
  12200. 'lo': 0,
  12201. 'lt': 10,
  12202. 'lv': 6,
  12203. 'mas': 3,
  12204. 'mg': 4,
  12205. 'mk': 16,
  12206. 'ml': 3,
  12207. 'mn': 3,
  12208. 'mo': 9,
  12209. 'mr': 3,
  12210. 'ms': 0,
  12211. 'mt': 15,
  12212. 'my': 0,
  12213. 'nah': 3,
  12214. 'naq': 7,
  12215. 'nb': 3,
  12216. 'nd': 3,
  12217. 'ne': 3,
  12218. 'nl': 3,
  12219. 'nn': 3,
  12220. 'no': 3,
  12221. 'nr': 3,
  12222. 'nso': 4,
  12223. 'ny': 3,
  12224. 'nyn': 3,
  12225. 'om': 3,
  12226. 'or': 3,
  12227. 'pa': 3,
  12228. 'pap': 3,
  12229. 'pl': 13,
  12230. 'ps': 3,
  12231. 'pt': 3,
  12232. 'rm': 3,
  12233. 'ro': 9,
  12234. 'rof': 3,
  12235. 'ru': 11,
  12236. 'rwk': 3,
  12237. 'sah': 0,
  12238. 'saq': 3,
  12239. 'se': 7,
  12240. 'seh': 3,
  12241. 'ses': 0,
  12242. 'sg': 0,
  12243. 'sh': 11,
  12244. 'shi': 19,
  12245. 'sk': 12,
  12246. 'sl': 14,
  12247. 'sma': 7,
  12248. 'smi': 7,
  12249. 'smj': 7,
  12250. 'smn': 7,
  12251. 'sms': 7,
  12252. 'sn': 3,
  12253. 'so': 3,
  12254. 'sq': 3,
  12255. 'sr': 11,
  12256. 'ss': 3,
  12257. 'ssy': 3,
  12258. 'st': 3,
  12259. 'sv': 3,
  12260. 'sw': 3,
  12261. 'syr': 3,
  12262. 'ta': 3,
  12263. 'te': 3,
  12264. 'teo': 3,
  12265. 'th': 0,
  12266. 'ti': 4,
  12267. 'tig': 3,
  12268. 'tk': 3,
  12269. 'tl': 4,
  12270. 'tn': 3,
  12271. 'to': 0,
  12272. 'tr': 0,
  12273. 'ts': 3,
  12274. 'tzm': 22,
  12275. 'uk': 11,
  12276. 'ur': 3,
  12277. 've': 3,
  12278. 'vi': 0,
  12279. 'vun': 3,
  12280. 'wa': 4,
  12281. 'wae': 3,
  12282. 'wo': 0,
  12283. 'xh': 3,
  12284. 'xog': 3,
  12285. 'yo': 0,
  12286. 'zh': 0,
  12287. 'zu': 3
  12288. };
  12289. function isIn(n, list) {
  12290. return list.indexOf(n) !== -1;
  12291. }
  12292. function isBetween(n, start, end) {
  12293. return start <= n && n <= end;
  12294. }
  12295. var pluralRules = {
  12296. '0': function _(n) {
  12297. return 'other';
  12298. },
  12299. '1': function _(n) {
  12300. if (isBetween(n % 100, 3, 10)) return 'few';
  12301. if (n === 0) return 'zero';
  12302. if (isBetween(n % 100, 11, 99)) return 'many';
  12303. if (n == 2) return 'two';
  12304. if (n == 1) return 'one';
  12305. return 'other';
  12306. },
  12307. '2': function _(n) {
  12308. if (n !== 0 && n % 10 === 0) return 'many';
  12309. if (n == 2) return 'two';
  12310. if (n == 1) return 'one';
  12311. return 'other';
  12312. },
  12313. '3': function _(n) {
  12314. if (n == 1) return 'one';
  12315. return 'other';
  12316. },
  12317. '4': function _(n) {
  12318. if (isBetween(n, 0, 1)) return 'one';
  12319. return 'other';
  12320. },
  12321. '5': function _(n) {
  12322. if (isBetween(n, 0, 2) && n != 2) return 'one';
  12323. return 'other';
  12324. },
  12325. '6': function _(n) {
  12326. if (n === 0) return 'zero';
  12327. if (n % 10 == 1 && n % 100 != 11) return 'one';
  12328. return 'other';
  12329. },
  12330. '7': function _(n) {
  12331. if (n == 2) return 'two';
  12332. if (n == 1) return 'one';
  12333. return 'other';
  12334. },
  12335. '8': function _(n) {
  12336. if (isBetween(n, 3, 6)) return 'few';
  12337. if (isBetween(n, 7, 10)) return 'many';
  12338. if (n == 2) return 'two';
  12339. if (n == 1) return 'one';
  12340. return 'other';
  12341. },
  12342. '9': function _(n) {
  12343. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  12344. if (n == 1) return 'one';
  12345. return 'other';
  12346. },
  12347. '10': function _(n) {
  12348. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  12349. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  12350. return 'other';
  12351. },
  12352. '11': function _(n) {
  12353. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  12354. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
  12355. if (n % 10 == 1 && n % 100 != 11) return 'one';
  12356. return 'other';
  12357. },
  12358. '12': function _(n) {
  12359. if (isBetween(n, 2, 4)) return 'few';
  12360. if (n == 1) return 'one';
  12361. return 'other';
  12362. },
  12363. '13': function _(n) {
  12364. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  12365. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
  12366. if (n == 1) return 'one';
  12367. return 'other';
  12368. },
  12369. '14': function _(n) {
  12370. if (isBetween(n % 100, 3, 4)) return 'few';
  12371. if (n % 100 == 2) return 'two';
  12372. if (n % 100 == 1) return 'one';
  12373. return 'other';
  12374. },
  12375. '15': function _(n) {
  12376. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  12377. if (isBetween(n % 100, 11, 19)) return 'many';
  12378. if (n == 1) return 'one';
  12379. return 'other';
  12380. },
  12381. '16': function _(n) {
  12382. if (n % 10 == 1 && n != 11) return 'one';
  12383. return 'other';
  12384. },
  12385. '17': function _(n) {
  12386. if (n == 3) return 'few';
  12387. if (n === 0) return 'zero';
  12388. if (n == 6) return 'many';
  12389. if (n == 2) return 'two';
  12390. if (n == 1) return 'one';
  12391. return 'other';
  12392. },
  12393. '18': function _(n) {
  12394. if (n === 0) return 'zero';
  12395. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  12396. return 'other';
  12397. },
  12398. '19': function _(n) {
  12399. if (isBetween(n, 2, 10)) return 'few';
  12400. if (isBetween(n, 0, 1)) return 'one';
  12401. return 'other';
  12402. },
  12403. '20': function _(n) {
  12404. 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';
  12405. if (n % 1000000 === 0 && n !== 0) return 'many';
  12406. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  12407. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  12408. return 'other';
  12409. },
  12410. '21': function _(n) {
  12411. if (n === 0) return 'zero';
  12412. if (n == 1) return 'one';
  12413. return 'other';
  12414. },
  12415. '22': function _(n) {
  12416. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  12417. return 'other';
  12418. },
  12419. '23': function _(n) {
  12420. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  12421. return 'other';
  12422. },
  12423. '24': function _(n) {
  12424. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  12425. if (isIn(n, [2, 12])) return 'two';
  12426. if (isIn(n, [1, 11])) return 'one';
  12427. return 'other';
  12428. }
  12429. };
  12430. var index = locales2rules[lang.replace(/-.*$/, '')];
  12431. if (!(index in pluralRules)) {
  12432. console.warn('plural form unknown for [' + lang + ']');
  12433. return function () {
  12434. return 'other';
  12435. };
  12436. }
  12437. return pluralRules[index];
  12438. }
  12439. gMacros.plural = function (str, param, key, prop) {
  12440. var n = parseFloat(param);
  12441. if (isNaN(n)) return str;
  12442. if (prop != gTextProp) return str;
  12443. if (!gMacros._pluralRules) {
  12444. gMacros._pluralRules = getPluralRules(gLanguage);
  12445. }
  12446. var index = '[' + gMacros._pluralRules(n) + ']';
  12447. if (n === 0 && key + '[zero]' in gL10nData) {
  12448. str = gL10nData[key + '[zero]'][prop];
  12449. } else if (n == 1 && key + '[one]' in gL10nData) {
  12450. str = gL10nData[key + '[one]'][prop];
  12451. } else if (n == 2 && key + '[two]' in gL10nData) {
  12452. str = gL10nData[key + '[two]'][prop];
  12453. } else if (key + index in gL10nData) {
  12454. str = gL10nData[key + index][prop];
  12455. } else if (key + '[other]' in gL10nData) {
  12456. str = gL10nData[key + '[other]'][prop];
  12457. }
  12458. return str;
  12459. };
  12460. function getL10nData(key, args, fallback) {
  12461. var data = gL10nData[key];
  12462. if (!data) {
  12463. console.warn('#' + key + ' is undefined.');
  12464. if (!fallback) {
  12465. return null;
  12466. }
  12467. data = fallback;
  12468. }
  12469. var rv = {};
  12470. for (var prop in data) {
  12471. var str = data[prop];
  12472. str = substIndexes(str, args, key, prop);
  12473. str = substArguments(str, args, key);
  12474. rv[prop] = str;
  12475. }
  12476. return rv;
  12477. }
  12478. function substIndexes(str, args, key, prop) {
  12479. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  12480. var reMatch = reIndex.exec(str);
  12481. if (!reMatch || !reMatch.length) return str;
  12482. var macroName = reMatch[1];
  12483. var paramName = reMatch[2];
  12484. var param;
  12485. if (args && paramName in args) {
  12486. param = args[paramName];
  12487. } else if (paramName in gL10nData) {
  12488. param = gL10nData[paramName];
  12489. }
  12490. if (macroName in gMacros) {
  12491. var macro = gMacros[macroName];
  12492. str = macro(str, param, key, prop);
  12493. }
  12494. return str;
  12495. }
  12496. function substArguments(str, args, key) {
  12497. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  12498. return str.replace(reArgs, function (matched_text, arg) {
  12499. if (args && arg in args) {
  12500. return args[arg];
  12501. }
  12502. if (arg in gL10nData) {
  12503. return gL10nData[arg];
  12504. }
  12505. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  12506. return matched_text;
  12507. });
  12508. }
  12509. function translateElement(element) {
  12510. var l10n = getL10nAttributes(element);
  12511. if (!l10n.id) return;
  12512. var data = getL10nData(l10n.id, l10n.args);
  12513. if (!data) {
  12514. console.warn('#' + l10n.id + ' is undefined.');
  12515. return;
  12516. }
  12517. if (data[gTextProp]) {
  12518. if (getChildElementCount(element) === 0) {
  12519. element[gTextProp] = data[gTextProp];
  12520. } else {
  12521. var children = element.childNodes;
  12522. var found = false;
  12523. for (var i = 0, l = children.length; i < l; i++) {
  12524. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  12525. if (found) {
  12526. children[i].nodeValue = '';
  12527. } else {
  12528. children[i].nodeValue = data[gTextProp];
  12529. found = true;
  12530. }
  12531. }
  12532. }
  12533. if (!found) {
  12534. var textNode = document.createTextNode(data[gTextProp]);
  12535. element.insertBefore(textNode, element.firstChild);
  12536. }
  12537. }
  12538. delete data[gTextProp];
  12539. }
  12540. for (var k in data) {
  12541. element[k] = data[k];
  12542. }
  12543. }
  12544. function getChildElementCount(element) {
  12545. if (element.children) {
  12546. return element.children.length;
  12547. }
  12548. if (typeof element.childElementCount !== 'undefined') {
  12549. return element.childElementCount;
  12550. }
  12551. var count = 0;
  12552. for (var i = 0; i < element.childNodes.length; i++) {
  12553. count += element.nodeType === 1 ? 1 : 0;
  12554. }
  12555. return count;
  12556. }
  12557. function translateFragment(element) {
  12558. element = element || document.documentElement;
  12559. var children = getTranslatableChildren(element);
  12560. var elementCount = children.length;
  12561. for (var i = 0; i < elementCount; i++) {
  12562. translateElement(children[i]);
  12563. }
  12564. translateElement(element);
  12565. }
  12566. return {
  12567. get: function get(key, args, fallbackString) {
  12568. var index = key.lastIndexOf('.');
  12569. var prop = gTextProp;
  12570. if (index > 0) {
  12571. prop = key.substring(index + 1);
  12572. key = key.substring(0, index);
  12573. }
  12574. var fallback;
  12575. if (fallbackString) {
  12576. fallback = {};
  12577. fallback[prop] = fallbackString;
  12578. }
  12579. var data = getL10nData(key, args, fallback);
  12580. if (data && prop in data) {
  12581. return data[prop];
  12582. }
  12583. return '{{' + key + '}}';
  12584. },
  12585. getData: function getData() {
  12586. return gL10nData;
  12587. },
  12588. getText: function getText() {
  12589. return gTextData;
  12590. },
  12591. getLanguage: function getLanguage() {
  12592. return gLanguage;
  12593. },
  12594. setLanguage: function setLanguage(lang, callback) {
  12595. loadLocale(lang, function () {
  12596. if (callback) callback();
  12597. });
  12598. },
  12599. getDirection: function getDirection() {
  12600. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  12601. var shortCode = gLanguage.split('-', 1)[0];
  12602. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  12603. },
  12604. translate: translateFragment,
  12605. getReadyState: function getReadyState() {
  12606. return gReadyState;
  12607. },
  12608. ready: function ready(callback) {
  12609. if (!callback) {
  12610. return;
  12611. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  12612. window.setTimeout(function () {
  12613. callback();
  12614. });
  12615. } else if (document.addEventListener) {
  12616. document.addEventListener('localized', function once() {
  12617. document.removeEventListener('localized', once);
  12618. callback();
  12619. });
  12620. }
  12621. }
  12622. };
  12623. }(window, document);
  12624. /***/ }),
  12625. /* 42 */
  12626. /***/ (function(module, exports, __webpack_require__) {
  12627. "use strict";
  12628. Object.defineProperty(exports, "__esModule", {
  12629. value: true
  12630. });
  12631. exports.PDFPrintService = PDFPrintService;
  12632. var _ui_utils = __webpack_require__(6);
  12633. var _app = __webpack_require__(1);
  12634. var _pdfjsLib = __webpack_require__(7);
  12635. var activeService = null;
  12636. var overlayManager = null;
  12637. function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size) {
  12638. var scratchCanvas = activeService.scratchCanvas;
  12639. var PRINT_RESOLUTION = 150;
  12640. var PRINT_UNITS = PRINT_RESOLUTION / 72.0;
  12641. scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
  12642. scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
  12643. var width = Math.floor(size.width * _ui_utils.CSS_UNITS) + 'px';
  12644. var height = Math.floor(size.height * _ui_utils.CSS_UNITS) + 'px';
  12645. var ctx = scratchCanvas.getContext('2d');
  12646. ctx.save();
  12647. ctx.fillStyle = 'rgb(255, 255, 255)';
  12648. ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height);
  12649. ctx.restore();
  12650. return pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  12651. var renderContext = {
  12652. canvasContext: ctx,
  12653. transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
  12654. viewport: pdfPage.getViewport({
  12655. scale: 1,
  12656. rotation: size.rotation
  12657. }),
  12658. intent: 'print'
  12659. };
  12660. return pdfPage.render(renderContext).promise;
  12661. }).then(function () {
  12662. return {
  12663. width: width,
  12664. height: height
  12665. };
  12666. });
  12667. }
  12668. function PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
  12669. this.pdfDocument = pdfDocument;
  12670. this.pagesOverview = pagesOverview;
  12671. this.printContainer = printContainer;
  12672. this.l10n = l10n || _ui_utils.NullL10n;
  12673. this.disableCreateObjectURL = pdfDocument.loadingParams['disableCreateObjectURL'];
  12674. this.currentPage = -1;
  12675. this.scratchCanvas = document.createElement('canvas');
  12676. }
  12677. PDFPrintService.prototype = {
  12678. layout: function layout() {
  12679. this.throwIfInactive();
  12680. var body = document.querySelector('body');
  12681. body.setAttribute('data-pdfjsprinting', true);
  12682. var hasEqualPageSizes = this.pagesOverview.every(function (size) {
  12683. return size.width === this.pagesOverview[0].width && size.height === this.pagesOverview[0].height;
  12684. }, this);
  12685. if (!hasEqualPageSizes) {
  12686. console.warn('Not all pages have the same size. The printed ' + 'result may be incorrect!');
  12687. }
  12688. this.pageStyleSheet = document.createElement('style');
  12689. var pageSize = this.pagesOverview[0];
  12690. this.pageStyleSheet.textContent = '@supports ((size:A4) and (size:1pt 1pt)) {' + '@page { size: ' + pageSize.width + 'pt ' + pageSize.height + 'pt;}' + '}';
  12691. body.appendChild(this.pageStyleSheet);
  12692. },
  12693. destroy: function destroy() {
  12694. if (activeService !== this) {
  12695. return;
  12696. }
  12697. this.printContainer.textContent = '';
  12698. if (this.pageStyleSheet) {
  12699. this.pageStyleSheet.remove();
  12700. this.pageStyleSheet = null;
  12701. }
  12702. this.scratchCanvas.width = this.scratchCanvas.height = 0;
  12703. this.scratchCanvas = null;
  12704. activeService = null;
  12705. ensureOverlay().then(function () {
  12706. if (overlayManager.active !== 'printServiceOverlay') {
  12707. return;
  12708. }
  12709. overlayManager.close('printServiceOverlay');
  12710. });
  12711. },
  12712. renderPages: function renderPages() {
  12713. var _this = this;
  12714. var pageCount = this.pagesOverview.length;
  12715. var renderNextPage = function renderNextPage(resolve, reject) {
  12716. _this.throwIfInactive();
  12717. if (++_this.currentPage >= pageCount) {
  12718. renderProgress(pageCount, pageCount, _this.l10n);
  12719. resolve();
  12720. return;
  12721. }
  12722. var index = _this.currentPage;
  12723. renderProgress(index, pageCount, _this.l10n);
  12724. renderPage(_this, _this.pdfDocument, index + 1, _this.pagesOverview[index]).then(_this.useRenderedPage.bind(_this)).then(function () {
  12725. renderNextPage(resolve, reject);
  12726. }, reject);
  12727. };
  12728. return new Promise(renderNextPage);
  12729. },
  12730. useRenderedPage: function useRenderedPage(printItem) {
  12731. this.throwIfInactive();
  12732. var img = document.createElement('img');
  12733. img.style.width = printItem.width;
  12734. img.style.height = printItem.height;
  12735. var scratchCanvas = this.scratchCanvas;
  12736. if ('toBlob' in scratchCanvas && !this.disableCreateObjectURL) {
  12737. scratchCanvas.toBlob(function (blob) {
  12738. img.src = _pdfjsLib.URL.createObjectURL(blob);
  12739. });
  12740. } else {
  12741. img.src = scratchCanvas.toDataURL();
  12742. }
  12743. var wrapper = document.createElement('div');
  12744. wrapper.appendChild(img);
  12745. this.printContainer.appendChild(wrapper);
  12746. return new Promise(function (resolve, reject) {
  12747. img.onload = resolve;
  12748. img.onerror = reject;
  12749. });
  12750. },
  12751. performPrint: function performPrint() {
  12752. var _this2 = this;
  12753. this.throwIfInactive();
  12754. return new Promise(function (resolve) {
  12755. setTimeout(function () {
  12756. if (!_this2.active) {
  12757. resolve();
  12758. return;
  12759. }
  12760. print.call(window);
  12761. setTimeout(resolve, 20);
  12762. }, 0);
  12763. });
  12764. },
  12765. get active() {
  12766. return this === activeService;
  12767. },
  12768. throwIfInactive: function throwIfInactive() {
  12769. if (!this.active) {
  12770. throw new Error('This print request was cancelled or completed.');
  12771. }
  12772. }
  12773. };
  12774. var print = window.print;
  12775. window.print = function print() {
  12776. if (activeService) {
  12777. console.warn('Ignored window.print() because of a pending print job.');
  12778. return;
  12779. }
  12780. ensureOverlay().then(function () {
  12781. if (activeService) {
  12782. overlayManager.open('printServiceOverlay');
  12783. }
  12784. });
  12785. try {
  12786. dispatchEvent('beforeprint');
  12787. } finally {
  12788. if (!activeService) {
  12789. console.error('Expected print service to be initialized.');
  12790. ensureOverlay().then(function () {
  12791. if (overlayManager.active === 'printServiceOverlay') {
  12792. overlayManager.close('printServiceOverlay');
  12793. }
  12794. });
  12795. return;
  12796. }
  12797. var activeServiceOnEntry = activeService;
  12798. activeService.renderPages().then(function () {
  12799. return activeServiceOnEntry.performPrint();
  12800. }).catch(function () {}).then(function () {
  12801. if (activeServiceOnEntry.active) {
  12802. abort();
  12803. }
  12804. });
  12805. }
  12806. };
  12807. function dispatchEvent(eventType) {
  12808. var event = document.createEvent('CustomEvent');
  12809. event.initCustomEvent(eventType, false, false, 'custom');
  12810. window.dispatchEvent(event);
  12811. }
  12812. function abort() {
  12813. if (activeService) {
  12814. activeService.destroy();
  12815. dispatchEvent('afterprint');
  12816. }
  12817. }
  12818. function renderProgress(index, total, l10n) {
  12819. var progressContainer = document.getElementById('printServiceOverlay');
  12820. var progress = Math.round(100 * index / total);
  12821. var progressBar = progressContainer.querySelector('progress');
  12822. var progressPerc = progressContainer.querySelector('.relative-progress');
  12823. progressBar.value = progress;
  12824. l10n.get('print_progress_percent', {
  12825. progress: progress
  12826. }, progress + '%').then(function (msg) {
  12827. progressPerc.textContent = msg;
  12828. });
  12829. }
  12830. var hasAttachEvent = !!document.attachEvent;
  12831. window.addEventListener('keydown', function (event) {
  12832. if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
  12833. window.print();
  12834. if (hasAttachEvent) {
  12835. return;
  12836. }
  12837. event.preventDefault();
  12838. if (event.stopImmediatePropagation) {
  12839. event.stopImmediatePropagation();
  12840. } else {
  12841. event.stopPropagation();
  12842. }
  12843. return;
  12844. }
  12845. }, true);
  12846. if (hasAttachEvent) {
  12847. document.attachEvent('onkeydown', function (event) {
  12848. event = event || window.event;
  12849. if (event.keyCode === 80 && event.ctrlKey) {
  12850. event.keyCode = 0;
  12851. return false;
  12852. }
  12853. });
  12854. }
  12855. if ('onbeforeprint' in window) {
  12856. var stopPropagationIfNeeded = function stopPropagationIfNeeded(event) {
  12857. if (event.detail !== 'custom' && event.stopImmediatePropagation) {
  12858. event.stopImmediatePropagation();
  12859. }
  12860. };
  12861. window.addEventListener('beforeprint', stopPropagationIfNeeded);
  12862. window.addEventListener('afterprint', stopPropagationIfNeeded);
  12863. }
  12864. var overlayPromise;
  12865. function ensureOverlay() {
  12866. if (!overlayPromise) {
  12867. overlayManager = _app.PDFViewerApplication.overlayManager;
  12868. if (!overlayManager) {
  12869. throw new Error('The overlay manager has not yet been initialized.');
  12870. }
  12871. overlayPromise = overlayManager.register('printServiceOverlay', document.getElementById('printServiceOverlay'), abort, true);
  12872. document.getElementById('printCancel').onclick = abort;
  12873. }
  12874. return overlayPromise;
  12875. }
  12876. _app.PDFPrintServiceFactory.instance = {
  12877. supportsPrinting: true,
  12878. createPrintService: function createPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
  12879. if (activeService) {
  12880. throw new Error('The print service is created and active.');
  12881. }
  12882. activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n);
  12883. return activeService;
  12884. }
  12885. };
  12886. /***/ })
  12887. /******/ ]);
  12888. function o2GetCanvasTextWidth(text, font) {
  12889. // re-use canvas object for better performance
  12890. var canvas = o2GetCanvasTextWidth.canvas || (o2GetCanvasTextWidth.canvas = document.createElement("canvas"));
  12891. var context = canvas.getContext("2d");
  12892. context.font = font;
  12893. var metrics = context.measureText(text);
  12894. return metrics.width;
  12895. }
  12896. // 添加水印
  12897. async function addWatermask(url) {
  12898. const existingPdfBytes = await fetch(url, {credentials:'include'}).then(res => res.arrayBuffer())
  12899. // const fontBuffer = await fetch(fontUrl).then(res => res.arrayBuffer())
  12900. // const fontUrl = '../o2_lib/pdfjs/pdf-lib/Alibaba-PuHuiTi-Medium.ttf'
  12901. // const allPromise = [fetch(url, {credentials:'include'}).then(res => res.arrayBuffer()), fetch(fontUrl).then(res => res.arrayBuffer())] // 下载pdf文件 // 下载阿里普惠体
  12902. // const [existingPdfBytes, fontBuffer] = await Promise.all(allPromise)
  12903. // pdf可操作对象
  12904. const pdfDoc = await PDFLib.PDFDocument.load(existingPdfBytes)
  12905. // 读取当前用户 生成水印文字 这里读取的是手机号码, 如果是中文需要添加字体才行,参考15596,15597行
  12906. let mask = ""
  12907. if (layout && layout.session && layout.session.user) {
  12908. mask = layout.session.user.mobile || "O2OA"
  12909. }
  12910. // 加载字体 官方的字体 均不支持中文水印 但可以注入中文字体
  12911. const helveticaFont = await pdfDoc.embedFont(PDFLib.StandardFonts.Helvetica)
  12912. // 注入字体
  12913. // pdfDoc.registerFontkit(fontkit) // 字体注册工具
  12914. // const aliPuHuiTiFont = await pdfDoc.embedFont(fontBuffer) // 注入字体
  12915. const maskWidth = o2GetCanvasTextWidth(mask, '30px Microsoft YaHei')
  12916. // 获取每一页
  12917. const pages = pdfDoc.getPages()
  12918. // 遍历每一页的数据给每一页都添加水印
  12919. pages.forEach(item => {
  12920. // 获取每一页的宽高
  12921. const { width, height } = item.getSize()
  12922. // 对角线
  12923. const diagonal = Math.ceil(Math.sqrt(width*width + height*height))
  12924. let index = 0;
  12925. let fromX;
  12926. // 以对角线的长度来做高度,这样可以保证竖屏和横屏整个屏幕都能布满水印
  12927. for (let positionY = diagonal / 5; positionY <= diagonal; positionY += diagonal / 5) {
  12928. fromX = -width + (index++ % 2) * maskWidth; // 上下两行的X轴起始点不一样,错开显示
  12929. for (let positionX = fromX; positionX < width; positionX += maskWidth * 4) {
  12930. item.drawText(mask, {
  12931. // 出现的 x 轴坐标
  12932. x: positionX,
  12933. // 出现的 y 轴坐标
  12934. y: positionY,
  12935. // 字体大小
  12936. size: 30,
  12937. // 字体
  12938. // font: aliPuHuiTiFont,
  12939. font: helveticaFont,
  12940. // 颜色
  12941. color: PDFLib.rgb(0, 0, 0),
  12942. // 倾斜角度
  12943. rotate: PDFLib.degrees(-45),
  12944. // 透明度
  12945. opacity: 0.2
  12946. })
  12947. }
  12948. }
  12949. })
  12950. // 已经处理好的数据
  12951. const pdfBuffer = await pdfDoc.save()
  12952. // 返回出去
  12953. return pdfBuffer
  12954. }