viewer.js 448 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396
  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 = void 0,
  114. pdfjsWebAppOptions = void 0;
  115. {
  116. pdfjsWebApp = __webpack_require__(1);
  117. pdfjsWebAppOptions = __webpack_require__(12);
  118. }
  119. ;
  120. {
  121. __webpack_require__(38);
  122. }
  123. ;
  124. {
  125. __webpack_require__(43);
  126. }
  127. function getViewerConfiguration() {
  128. return {
  129. appContainer: document.body,
  130. mainContainer: document.getElementById('viewerContainer'),
  131. viewerContainer: document.getElementById('viewer'),
  132. eventBus: null,
  133. toolbar: {
  134. container: document.getElementById('toolbarViewer'),
  135. numPages: document.getElementById('numPages'),
  136. pageNumber: document.getElementById('pageNumber'),
  137. scaleSelectContainer: document.getElementById('scaleSelectContainer'),
  138. scaleSelect: document.getElementById('scaleSelect'),
  139. customScaleOption: document.getElementById('customScaleOption'),
  140. previous: document.getElementById('previous'),
  141. next: document.getElementById('next'),
  142. zoomIn: document.getElementById('zoomIn'),
  143. zoomOut: document.getElementById('zoomOut'),
  144. viewFind: document.getElementById('viewFind'),
  145. openFile: document.getElementById('openFile'),
  146. print: document.getElementById('print'),
  147. presentationModeButton: document.getElementById('presentationMode'),
  148. download: document.getElementById('download'),
  149. viewBookmark: document.getElementById('viewBookmark')
  150. },
  151. secondaryToolbar: {
  152. toolbar: document.getElementById('secondaryToolbar'),
  153. toggleButton: document.getElementById('secondaryToolbarToggle'),
  154. toolbarButtonContainer: document.getElementById('secondaryToolbarButtonContainer'),
  155. presentationModeButton: document.getElementById('secondaryPresentationMode'),
  156. openFileButton: document.getElementById('secondaryOpenFile'),
  157. printButton: document.getElementById('secondaryPrint'),
  158. downloadButton: document.getElementById('secondaryDownload'),
  159. viewBookmarkButton: document.getElementById('secondaryViewBookmark'),
  160. firstPageButton: document.getElementById('firstPage'),
  161. lastPageButton: document.getElementById('lastPage'),
  162. pageRotateCwButton: document.getElementById('pageRotateCw'),
  163. pageRotateCcwButton: document.getElementById('pageRotateCcw'),
  164. cursorSelectToolButton: document.getElementById('cursorSelectTool'),
  165. cursorHandToolButton: document.getElementById('cursorHandTool'),
  166. scrollVerticalButton: document.getElementById('scrollVertical'),
  167. scrollHorizontalButton: document.getElementById('scrollHorizontal'),
  168. scrollWrappedButton: document.getElementById('scrollWrapped'),
  169. spreadNoneButton: document.getElementById('spreadNone'),
  170. spreadOddButton: document.getElementById('spreadOdd'),
  171. spreadEvenButton: document.getElementById('spreadEven'),
  172. documentPropertiesButton: document.getElementById('documentProperties')
  173. },
  174. fullscreen: {
  175. contextFirstPage: document.getElementById('contextFirstPage'),
  176. contextLastPage: document.getElementById('contextLastPage'),
  177. contextPageRotateCw: document.getElementById('contextPageRotateCw'),
  178. contextPageRotateCcw: document.getElementById('contextPageRotateCcw')
  179. },
  180. sidebar: {
  181. outerContainer: document.getElementById('outerContainer'),
  182. viewerContainer: document.getElementById('viewerContainer'),
  183. toggleButton: document.getElementById('sidebarToggle'),
  184. thumbnailButton: document.getElementById('viewThumbnail'),
  185. outlineButton: document.getElementById('viewOutline'),
  186. attachmentsButton: document.getElementById('viewAttachments'),
  187. thumbnailView: document.getElementById('thumbnailView'),
  188. outlineView: document.getElementById('outlineView'),
  189. attachmentsView: document.getElementById('attachmentsView')
  190. },
  191. sidebarResizer: {
  192. outerContainer: document.getElementById('outerContainer'),
  193. resizer: document.getElementById('sidebarResizer')
  194. },
  195. findBar: {
  196. bar: document.getElementById('findbar'),
  197. toggleButton: document.getElementById('viewFind'),
  198. findField: document.getElementById('findInput'),
  199. highlightAllCheckbox: document.getElementById('findHighlightAll'),
  200. caseSensitiveCheckbox: document.getElementById('findMatchCase'),
  201. entireWordCheckbox: document.getElementById('findEntireWord'),
  202. findMsg: document.getElementById('findMsg'),
  203. findResultsCount: document.getElementById('findResultsCount'),
  204. findPreviousButton: document.getElementById('findPrevious'),
  205. findNextButton: document.getElementById('findNext')
  206. },
  207. passwordOverlay: {
  208. overlayName: 'passwordOverlay',
  209. container: document.getElementById('passwordOverlay'),
  210. label: document.getElementById('passwordText'),
  211. input: document.getElementById('password'),
  212. submitButton: document.getElementById('passwordSubmit'),
  213. cancelButton: document.getElementById('passwordCancel')
  214. },
  215. documentProperties: {
  216. overlayName: 'documentPropertiesOverlay',
  217. container: document.getElementById('documentPropertiesOverlay'),
  218. closeButton: document.getElementById('documentPropertiesClose'),
  219. fields: {
  220. 'fileName': document.getElementById('fileNameField'),
  221. 'fileSize': document.getElementById('fileSizeField'),
  222. 'title': document.getElementById('titleField'),
  223. 'author': document.getElementById('authorField'),
  224. 'subject': document.getElementById('subjectField'),
  225. 'keywords': document.getElementById('keywordsField'),
  226. 'creationDate': document.getElementById('creationDateField'),
  227. 'modificationDate': document.getElementById('modificationDateField'),
  228. 'creator': document.getElementById('creatorField'),
  229. 'producer': document.getElementById('producerField'),
  230. 'version': document.getElementById('versionField'),
  231. 'pageCount': document.getElementById('pageCountField'),
  232. 'pageSize': document.getElementById('pageSizeField'),
  233. 'linearized': document.getElementById('linearizedField')
  234. }
  235. },
  236. errorWrapper: {
  237. container: document.getElementById('errorWrapper'),
  238. errorMessage: document.getElementById('errorMessage'),
  239. closeButton: document.getElementById('errorClose'),
  240. errorMoreInfo: document.getElementById('errorMoreInfo'),
  241. moreInfoButton: document.getElementById('errorShowMore'),
  242. lessInfoButton: document.getElementById('errorShowLess')
  243. },
  244. printContainer: document.getElementById('printContainer'),
  245. openFileInputName: 'fileInput',
  246. debuggerScriptPath: './debugger.js'
  247. };
  248. }
  249. function webViewerLoad() {
  250. var config = getViewerConfiguration();
  251. window.PDFViewerApplication = pdfjsWebApp.PDFViewerApplication;
  252. window.PDFViewerApplicationOptions = pdfjsWebAppOptions.AppOptions;
  253. pdfjsWebApp.PDFViewerApplication.run(config);
  254. }
  255. if (document.readyState === 'interactive' || document.readyState === 'complete') {
  256. webViewerLoad();
  257. } else {
  258. document.addEventListener('DOMContentLoaded', webViewerLoad, true);
  259. }
  260. /***/ }),
  261. /* 1 */
  262. /***/ (function(module, exports, __webpack_require__) {
  263. "use strict";
  264. Object.defineProperty(exports, "__esModule", {
  265. value: true
  266. });
  267. exports.PDFPrintServiceFactory = exports.DefaultExternalServices = exports.PDFViewerApplication = undefined;
  268. var _regenerator = __webpack_require__(2);
  269. var _regenerator2 = _interopRequireDefault(_regenerator);
  270. var _slicedToArray = function () { function sliceIterator(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"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  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 _dom_events = __webpack_require__(14);
  278. var _overlay_manager = __webpack_require__(15);
  279. var _password_prompt = __webpack_require__(16);
  280. var _pdf_attachment_viewer = __webpack_require__(17);
  281. var _pdf_document_properties = __webpack_require__(18);
  282. var _pdf_find_bar = __webpack_require__(19);
  283. var _pdf_find_controller = __webpack_require__(20);
  284. var _pdf_history = __webpack_require__(22);
  285. var _pdf_link_service = __webpack_require__(23);
  286. var _pdf_outline_viewer = __webpack_require__(24);
  287. var _pdf_presentation_mode = __webpack_require__(25);
  288. var _pdf_sidebar_resizer = __webpack_require__(26);
  289. var _pdf_thumbnail_viewer = __webpack_require__(27);
  290. var _pdf_viewer = __webpack_require__(29);
  291. var _secondary_toolbar = __webpack_require__(34);
  292. var _toolbar = __webpack_require__(36);
  293. var _view_history = __webpack_require__(37);
  294. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  295. function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
  296. var DEFAULT_SCALE_DELTA = 1.1;
  297. var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
  298. var FORCE_PAGES_LOADED_TIMEOUT = 10000;
  299. var DefaultExternalServices = {
  300. updateFindControlState: function updateFindControlState(data) {},
  301. updateFindMatchesCount: function updateFindMatchesCount(data) {},
  302. initPassiveLoading: function initPassiveLoading(callbacks) {},
  303. fallback: function fallback(data, callback) {},
  304. reportTelemetry: function reportTelemetry(data) {},
  305. createDownloadManager: function createDownloadManager(options) {
  306. throw new Error('Not implemented: createDownloadManager');
  307. },
  308. createPreferences: function createPreferences() {
  309. throw new Error('Not implemented: createPreferences');
  310. },
  311. createL10n: function createL10n(options) {
  312. throw new Error('Not implemented: createL10n');
  313. },
  314. supportsIntegratedFind: false,
  315. supportsDocumentFonts: true,
  316. supportsDocumentColors: true,
  317. supportedMouseWheelZoomModifierKeys: {
  318. ctrlKey: true,
  319. metaKey: true
  320. }
  321. };
  322. var PDFViewerApplication = {
  323. initialBookmark: document.location.hash.substring(1),
  324. initialized: false,
  325. fellback: false,
  326. appConfig: null,
  327. pdfDocument: null,
  328. pdfLoadingTask: null,
  329. printService: null,
  330. pdfViewer: null,
  331. pdfThumbnailViewer: null,
  332. pdfRenderingQueue: null,
  333. pdfPresentationMode: null,
  334. pdfDocumentProperties: null,
  335. pdfLinkService: null,
  336. pdfHistory: null,
  337. pdfSidebar: null,
  338. pdfSidebarResizer: null,
  339. pdfOutlineViewer: null,
  340. pdfAttachmentViewer: null,
  341. pdfCursorTools: null,
  342. store: null,
  343. downloadManager: null,
  344. overlayManager: null,
  345. preferences: null,
  346. toolbar: null,
  347. secondaryToolbar: null,
  348. eventBus: null,
  349. l10n: null,
  350. isInitialViewSet: false,
  351. downloadComplete: false,
  352. isViewerEmbedded: window.parent !== window,
  353. url: '',
  354. baseUrl: '',
  355. externalServices: DefaultExternalServices,
  356. _boundEvents: {},
  357. contentDispositionFilename: null,
  358. initialize: function () {
  359. var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee(appConfig) {
  360. var _this = this;
  361. var appContainer;
  362. return _regenerator2.default.wrap(function _callee$(_context) {
  363. while (1) {
  364. switch (_context.prev = _context.next) {
  365. case 0:
  366. this.preferences = this.externalServices.createPreferences();
  367. this.appConfig = appConfig;
  368. _context.next = 4;
  369. return this._readPreferences();
  370. case 4:
  371. _context.next = 6;
  372. return this._parseHashParameters();
  373. case 6:
  374. _context.next = 8;
  375. return this._initializeL10n();
  376. case 8:
  377. if (this.isViewerEmbedded && _app_options.AppOptions.get('externalLinkTarget') === _pdfjsLib.LinkTarget.NONE) {
  378. _app_options.AppOptions.set('externalLinkTarget', _pdfjsLib.LinkTarget.TOP);
  379. }
  380. _context.next = 11;
  381. return this._initializeViewerComponents();
  382. case 11:
  383. this.bindEvents();
  384. this.bindWindowEvents();
  385. appContainer = appConfig.appContainer || document.documentElement;
  386. this.l10n.translate(appContainer).then(function () {
  387. _this.eventBus.dispatch('localized', { source: _this });
  388. });
  389. this.initialized = true;
  390. case 16:
  391. case 'end':
  392. return _context.stop();
  393. }
  394. }
  395. }, _callee, this);
  396. }));
  397. function initialize(_x) {
  398. return _ref.apply(this, arguments);
  399. }
  400. return initialize;
  401. }(),
  402. _readPreferences: function () {
  403. var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2() {
  404. var OVERRIDES, prefs, name;
  405. return _regenerator2.default.wrap(function _callee2$(_context2) {
  406. while (1) {
  407. switch (_context2.prev = _context2.next) {
  408. case 0:
  409. OVERRIDES = {
  410. disableFontFace: true,
  411. disableRange: true,
  412. disableStream: true,
  413. textLayerMode: _ui_utils.TextLayerMode.DISABLE
  414. };
  415. _context2.prev = 1;
  416. _context2.next = 4;
  417. return this.preferences.getAll();
  418. case 4:
  419. prefs = _context2.sent;
  420. _context2.t0 = _regenerator2.default.keys(prefs);
  421. case 6:
  422. if ((_context2.t1 = _context2.t0()).done) {
  423. _context2.next = 13;
  424. break;
  425. }
  426. name = _context2.t1.value;
  427. if (!(name in OVERRIDES && _app_options.AppOptions.get(name) === OVERRIDES[name])) {
  428. _context2.next = 10;
  429. break;
  430. }
  431. return _context2.abrupt('continue', 6);
  432. case 10:
  433. _app_options.AppOptions.set(name, prefs[name]);
  434. _context2.next = 6;
  435. break;
  436. case 13:
  437. _context2.next = 17;
  438. break;
  439. case 15:
  440. _context2.prev = 15;
  441. _context2.t2 = _context2['catch'](1);
  442. case 17:
  443. case 'end':
  444. return _context2.stop();
  445. }
  446. }
  447. }, _callee2, this, [[1, 15]]);
  448. }));
  449. function _readPreferences() {
  450. return _ref2.apply(this, arguments);
  451. }
  452. return _readPreferences;
  453. }(),
  454. _parseHashParameters: function () {
  455. var _ref3 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee3() {
  456. var waitOn, hash, hashParams, viewer, enabled;
  457. return _regenerator2.default.wrap(function _callee3$(_context3) {
  458. while (1) {
  459. switch (_context3.prev = _context3.next) {
  460. case 0:
  461. if (_app_options.AppOptions.get('pdfBugEnabled')) {
  462. _context3.next = 2;
  463. break;
  464. }
  465. return _context3.abrupt('return');
  466. case 2:
  467. waitOn = [];
  468. hash = document.location.hash.substring(1);
  469. hashParams = (0, _ui_utils.parseQueryString)(hash);
  470. if ('disableworker' in hashParams && hashParams['disableworker'] === 'true') {
  471. waitOn.push(loadFakeWorker());
  472. }
  473. if ('disablerange' in hashParams) {
  474. _app_options.AppOptions.set('disableRange', hashParams['disablerange'] === 'true');
  475. }
  476. if ('disablestream' in hashParams) {
  477. _app_options.AppOptions.set('disableStream', hashParams['disablestream'] === 'true');
  478. }
  479. if ('disableautofetch' in hashParams) {
  480. _app_options.AppOptions.set('disableAutoFetch', hashParams['disableautofetch'] === 'true');
  481. }
  482. if ('disablefontface' in hashParams) {
  483. _app_options.AppOptions.set('disableFontFace', hashParams['disablefontface'] === 'true');
  484. }
  485. if ('disablehistory' in hashParams) {
  486. _app_options.AppOptions.set('disableHistory', hashParams['disablehistory'] === 'true');
  487. }
  488. if ('webgl' in hashParams) {
  489. _app_options.AppOptions.set('enableWebGL', hashParams['webgl'] === 'true');
  490. }
  491. if ('useonlycsszoom' in hashParams) {
  492. _app_options.AppOptions.set('useOnlyCssZoom', hashParams['useonlycsszoom'] === 'true');
  493. }
  494. if ('verbosity' in hashParams) {
  495. _app_options.AppOptions.set('verbosity', hashParams['verbosity'] | 0);
  496. }
  497. if (!('textlayer' in hashParams)) {
  498. _context3.next = 23;
  499. break;
  500. }
  501. _context3.t0 = hashParams['textlayer'];
  502. _context3.next = _context3.t0 === 'off' ? 18 : _context3.t0 === 'visible' ? 20 : _context3.t0 === 'shadow' ? 20 : _context3.t0 === 'hover' ? 20 : 23;
  503. break;
  504. case 18:
  505. _app_options.AppOptions.set('textLayerMode', _ui_utils.TextLayerMode.DISABLE);
  506. return _context3.abrupt('break', 23);
  507. case 20:
  508. viewer = this.appConfig.viewerContainer;
  509. viewer.classList.add('textLayer-' + hashParams['textlayer']);
  510. return _context3.abrupt('break', 23);
  511. case 23:
  512. if ('pdfbug' in hashParams) {
  513. _app_options.AppOptions.set('pdfBug', true);
  514. enabled = hashParams['pdfbug'].split(',');
  515. waitOn.push(loadAndEnablePDFBug(enabled));
  516. }
  517. if ('locale' in hashParams) {
  518. _app_options.AppOptions.set('locale', hashParams['locale']);
  519. }
  520. return _context3.abrupt('return', Promise.all(waitOn).catch(function (reason) {
  521. console.error('_parseHashParameters: "' + reason.message + '".');
  522. }));
  523. case 26:
  524. case 'end':
  525. return _context3.stop();
  526. }
  527. }
  528. }, _callee3, this);
  529. }));
  530. function _parseHashParameters() {
  531. return _ref3.apply(this, arguments);
  532. }
  533. return _parseHashParameters;
  534. }(),
  535. _initializeL10n: function () {
  536. var _ref4 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee4() {
  537. var dir;
  538. return _regenerator2.default.wrap(function _callee4$(_context4) {
  539. while (1) {
  540. switch (_context4.prev = _context4.next) {
  541. case 0:
  542. this.l10n = this.externalServices.createL10n({ locale: _app_options.AppOptions.get('locale') });
  543. _context4.next = 3;
  544. return this.l10n.getDirection();
  545. case 3:
  546. dir = _context4.sent;
  547. document.getElementsByTagName('html')[0].dir = dir;
  548. case 5:
  549. case 'end':
  550. return _context4.stop();
  551. }
  552. }
  553. }, _callee4, this);
  554. }));
  555. function _initializeL10n() {
  556. return _ref4.apply(this, arguments);
  557. }
  558. return _initializeL10n;
  559. }(),
  560. _initializeViewerComponents: function () {
  561. var _ref5 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee5() {
  562. var appConfig, dispatchToDOM, eventBus, pdfRenderingQueue, pdfLinkService, downloadManager, findController, container, viewer, thumbnailContainer, sidebarConfig;
  563. return _regenerator2.default.wrap(function _callee5$(_context5) {
  564. while (1) {
  565. switch (_context5.prev = _context5.next) {
  566. case 0:
  567. appConfig = this.appConfig;
  568. this.overlayManager = new _overlay_manager.OverlayManager();
  569. dispatchToDOM = _app_options.AppOptions.get('eventBusDispatchToDOM');
  570. eventBus = appConfig.eventBus || (0, _dom_events.getGlobalEventBus)(dispatchToDOM);
  571. this.eventBus = eventBus;
  572. pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  573. pdfRenderingQueue.onIdle = this.cleanup.bind(this);
  574. this.pdfRenderingQueue = pdfRenderingQueue;
  575. pdfLinkService = new _pdf_link_service.PDFLinkService({
  576. eventBus: eventBus,
  577. externalLinkTarget: _app_options.AppOptions.get('externalLinkTarget'),
  578. externalLinkRel: _app_options.AppOptions.get('externalLinkRel')
  579. });
  580. this.pdfLinkService = pdfLinkService;
  581. downloadManager = this.externalServices.createDownloadManager({ disableCreateObjectURL: _app_options.AppOptions.get('disableCreateObjectURL') });
  582. this.downloadManager = downloadManager;
  583. findController = new _pdf_find_controller.PDFFindController({
  584. linkService: pdfLinkService,
  585. eventBus: eventBus
  586. });
  587. this.findController = findController;
  588. container = appConfig.mainContainer;
  589. viewer = appConfig.viewerContainer;
  590. this.pdfViewer = new _pdf_viewer.PDFViewer({
  591. container: container,
  592. viewer: viewer,
  593. eventBus: eventBus,
  594. renderingQueue: pdfRenderingQueue,
  595. linkService: pdfLinkService,
  596. downloadManager: downloadManager,
  597. findController: findController,
  598. renderer: _app_options.AppOptions.get('renderer'),
  599. enableWebGL: _app_options.AppOptions.get('enableWebGL'),
  600. l10n: this.l10n,
  601. textLayerMode: _app_options.AppOptions.get('textLayerMode'),
  602. imageResourcesPath: _app_options.AppOptions.get('imageResourcesPath'),
  603. renderInteractiveForms: _app_options.AppOptions.get('renderInteractiveForms'),
  604. enablePrintAutoRotate: _app_options.AppOptions.get('enablePrintAutoRotate'),
  605. useOnlyCssZoom: _app_options.AppOptions.get('useOnlyCssZoom'),
  606. maxCanvasPixels: _app_options.AppOptions.get('maxCanvasPixels')
  607. });
  608. pdfRenderingQueue.setViewer(this.pdfViewer);
  609. pdfLinkService.setViewer(this.pdfViewer);
  610. thumbnailContainer = appConfig.sidebar.thumbnailView;
  611. this.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({
  612. container: thumbnailContainer,
  613. renderingQueue: pdfRenderingQueue,
  614. linkService: pdfLinkService,
  615. l10n: this.l10n
  616. });
  617. pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer);
  618. this.pdfHistory = new _pdf_history.PDFHistory({
  619. linkService: pdfLinkService,
  620. eventBus: eventBus
  621. });
  622. pdfLinkService.setHistory(this.pdfHistory);
  623. this.findBar = new _pdf_find_bar.PDFFindBar(appConfig.findBar, eventBus, this.l10n);
  624. this.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, this.overlayManager, eventBus, this.l10n);
  625. this.pdfCursorTools = new _pdf_cursor_tools.PDFCursorTools({
  626. container: container,
  627. eventBus: eventBus,
  628. cursorToolOnLoad: _app_options.AppOptions.get('cursorToolOnLoad')
  629. });
  630. this.toolbar = new _toolbar.Toolbar(appConfig.toolbar, eventBus, this.l10n);
  631. this.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus);
  632. if (this.supportsFullscreen) {
  633. this.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({
  634. container: container,
  635. viewer: viewer,
  636. pdfViewer: this.pdfViewer,
  637. eventBus: eventBus,
  638. contextMenuItems: appConfig.fullscreen
  639. });
  640. }
  641. this.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, this.overlayManager, this.l10n);
  642. this.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({
  643. container: appConfig.sidebar.outlineView,
  644. eventBus: eventBus,
  645. linkService: pdfLinkService
  646. });
  647. this.pdfAttachmentViewer = new _pdf_attachment_viewer.PDFAttachmentViewer({
  648. container: appConfig.sidebar.attachmentsView,
  649. eventBus: eventBus,
  650. downloadManager: downloadManager
  651. });
  652. sidebarConfig = Object.create(appConfig.sidebar);
  653. sidebarConfig.pdfViewer = this.pdfViewer;
  654. sidebarConfig.pdfThumbnailViewer = this.pdfThumbnailViewer;
  655. this.pdfSidebar = new _pdf_sidebar.PDFSidebar(sidebarConfig, eventBus, this.l10n);
  656. this.pdfSidebar.onToggled = this.forceRendering.bind(this);
  657. this.pdfSidebarResizer = new _pdf_sidebar_resizer.PDFSidebarResizer(appConfig.sidebarResizer, eventBus, this.l10n);
  658. case 39:
  659. case 'end':
  660. return _context5.stop();
  661. }
  662. }
  663. }, _callee5, this);
  664. }));
  665. function _initializeViewerComponents() {
  666. return _ref5.apply(this, arguments);
  667. }
  668. return _initializeViewerComponents;
  669. }(),
  670. run: function run(config) {
  671. this.initialize(config).then(webViewerInitialized);
  672. },
  673. zoomIn: function zoomIn(ticks) {
  674. var newScale = this.pdfViewer.currentScale;
  675. do {
  676. newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2);
  677. newScale = Math.ceil(newScale * 10) / 10;
  678. newScale = Math.min(_ui_utils.MAX_SCALE, newScale);
  679. } while (--ticks > 0 && newScale < _ui_utils.MAX_SCALE);
  680. this.pdfViewer.currentScaleValue = newScale;
  681. },
  682. zoomOut: function zoomOut(ticks) {
  683. var newScale = this.pdfViewer.currentScale;
  684. do {
  685. newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2);
  686. newScale = Math.floor(newScale * 10) / 10;
  687. newScale = Math.max(_ui_utils.MIN_SCALE, newScale);
  688. } while (--ticks > 0 && newScale > _ui_utils.MIN_SCALE);
  689. this.pdfViewer.currentScaleValue = newScale;
  690. },
  691. get pagesCount() {
  692. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  693. },
  694. set page(val) {
  695. this.pdfViewer.currentPageNumber = val;
  696. },
  697. get page() {
  698. return this.pdfViewer.currentPageNumber;
  699. },
  700. get printing() {
  701. return !!this.printService;
  702. },
  703. get supportsPrinting() {
  704. return PDFPrintServiceFactory.instance.supportsPrinting;
  705. },
  706. get supportsFullscreen() {
  707. var support = void 0;
  708. var doc = document.documentElement;
  709. support = !!(doc.requestFullscreen || doc.mozRequestFullScreen || doc.webkitRequestFullScreen || doc.msRequestFullscreen);
  710. if (document.fullscreenEnabled === false || document.mozFullScreenEnabled === false || document.webkitFullscreenEnabled === false || document.msFullscreenEnabled === false) {
  711. support = false;
  712. }
  713. return (0, _pdfjsLib.shadow)(this, 'supportsFullscreen', support);
  714. },
  715. get supportsIntegratedFind() {
  716. return this.externalServices.supportsIntegratedFind;
  717. },
  718. get supportsDocumentFonts() {
  719. return this.externalServices.supportsDocumentFonts;
  720. },
  721. get supportsDocumentColors() {
  722. return this.externalServices.supportsDocumentColors;
  723. },
  724. get loadingBar() {
  725. var bar = new _ui_utils.ProgressBar('#loadingBar');
  726. return (0, _pdfjsLib.shadow)(this, 'loadingBar', bar);
  727. },
  728. get supportedMouseWheelZoomModifierKeys() {
  729. return this.externalServices.supportedMouseWheelZoomModifierKeys;
  730. },
  731. initPassiveLoading: function initPassiveLoading() {
  732. throw new Error('Not implemented: initPassiveLoading');
  733. },
  734. setTitleUsingUrl: function setTitleUsingUrl() {
  735. var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  736. this.url = url;
  737. this.baseUrl = url.split('#')[0];
  738. var title = (0, _ui_utils.getPDFFileNameFromURL)(url, '');
  739. if (!title) {
  740. try {
  741. title = decodeURIComponent((0, _pdfjsLib.getFilenameFromUrl)(url)) || url;
  742. } catch (ex) {
  743. title = url;
  744. }
  745. }
  746. this.setTitle(title);
  747. },
  748. setTitle: function setTitle(title) {
  749. if (this.isViewerEmbedded) {
  750. return;
  751. }
  752. document.title = title;
  753. },
  754. close: function () {
  755. var _ref6 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee6() {
  756. var errorWrapper, promise;
  757. return _regenerator2.default.wrap(function _callee6$(_context6) {
  758. while (1) {
  759. switch (_context6.prev = _context6.next) {
  760. case 0:
  761. errorWrapper = this.appConfig.errorWrapper.container;
  762. errorWrapper.setAttribute('hidden', 'true');
  763. if (this.pdfLoadingTask) {
  764. _context6.next = 4;
  765. break;
  766. }
  767. return _context6.abrupt('return');
  768. case 4:
  769. promise = this.pdfLoadingTask.destroy();
  770. this.pdfLoadingTask = null;
  771. if (this.pdfDocument) {
  772. this.pdfDocument = null;
  773. this.pdfThumbnailViewer.setDocument(null);
  774. this.pdfViewer.setDocument(null);
  775. this.pdfLinkService.setDocument(null);
  776. this.pdfDocumentProperties.setDocument(null);
  777. }
  778. this.store = null;
  779. this.isInitialViewSet = false;
  780. this.downloadComplete = false;
  781. this.url = '';
  782. this.baseUrl = '';
  783. this.contentDispositionFilename = null;
  784. this.pdfSidebar.reset();
  785. this.pdfOutlineViewer.reset();
  786. this.pdfAttachmentViewer.reset();
  787. this.findBar.reset();
  788. this.toolbar.reset();
  789. this.secondaryToolbar.reset();
  790. if (typeof PDFBug !== 'undefined') {
  791. PDFBug.cleanup();
  792. }
  793. return _context6.abrupt('return', promise);
  794. case 21:
  795. case 'end':
  796. return _context6.stop();
  797. }
  798. }
  799. }, _callee6, this);
  800. }));
  801. function close() {
  802. return _ref6.apply(this, arguments);
  803. }
  804. return close;
  805. }(),
  806. open: function () {
  807. var _ref7 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee7(file, args) {
  808. var _this2 = this;
  809. var workerParameters, key, parameters, apiParameters, _key, prop, loadingTask;
  810. return _regenerator2.default.wrap(function _callee7$(_context7) {
  811. while (1) {
  812. switch (_context7.prev = _context7.next) {
  813. case 0:
  814. if (!this.pdfLoadingTask) {
  815. _context7.next = 3;
  816. break;
  817. }
  818. _context7.next = 3;
  819. return this.close();
  820. case 3:
  821. workerParameters = _app_options.AppOptions.getAll('worker');
  822. for (key in workerParameters) {
  823. _pdfjsLib.GlobalWorkerOptions[key] = workerParameters[key];
  824. }
  825. parameters = Object.create(null);
  826. if (typeof file === 'string') {
  827. this.setTitleUsingUrl(file);
  828. parameters.url = file;
  829. } else if (file && 'byteLength' in file) {
  830. parameters.data = file;
  831. } else if (file.url && file.originalUrl) {
  832. this.setTitleUsingUrl(file.originalUrl);
  833. parameters.url = file.url;
  834. }
  835. apiParameters = _app_options.AppOptions.getAll('api');
  836. for (_key in apiParameters) {
  837. parameters[_key] = apiParameters[_key];
  838. }
  839. if (args) {
  840. for (prop in args) {
  841. if (prop === 'length') {
  842. this.pdfDocumentProperties.setFileSize(args[prop]);
  843. }
  844. parameters[prop] = args[prop];
  845. }
  846. }
  847. loadingTask = (0, _pdfjsLib.getDocument)(parameters);
  848. this.pdfLoadingTask = loadingTask;
  849. loadingTask.onPassword = function (updateCallback, reason) {
  850. _this2.passwordPrompt.setUpdateCallback(updateCallback, reason);
  851. _this2.passwordPrompt.open();
  852. };
  853. loadingTask.onProgress = function (_ref8) {
  854. var loaded = _ref8.loaded,
  855. total = _ref8.total;
  856. _this2.progress(loaded / total);
  857. };
  858. loadingTask.onUnsupportedFeature = this.fallback.bind(this);
  859. return _context7.abrupt('return', loadingTask.promise.then(function (pdfDocument) {
  860. _this2.load(pdfDocument);
  861. }, function (exception) {
  862. if (loadingTask !== _this2.pdfLoadingTask) {
  863. return;
  864. }
  865. var message = exception && exception.message;
  866. var loadingErrorMessage = void 0;
  867. if (exception instanceof _pdfjsLib.InvalidPDFException) {
  868. loadingErrorMessage = _this2.l10n.get('invalid_file_error', null, 'Invalid or corrupted PDF file.');
  869. } else if (exception instanceof _pdfjsLib.MissingPDFException) {
  870. loadingErrorMessage = _this2.l10n.get('missing_file_error', null, 'Missing PDF file.');
  871. } else if (exception instanceof _pdfjsLib.UnexpectedResponseException) {
  872. loadingErrorMessage = _this2.l10n.get('unexpected_response_error', null, 'Unexpected server response.');
  873. } else {
  874. loadingErrorMessage = _this2.l10n.get('loading_error', null, 'An error occurred while loading the PDF.');
  875. }
  876. return loadingErrorMessage.then(function (msg) {
  877. _this2.error(msg, { message: message });
  878. throw new Error(msg);
  879. });
  880. }));
  881. case 16:
  882. case 'end':
  883. return _context7.stop();
  884. }
  885. }
  886. }, _callee7, this);
  887. }));
  888. function open(_x3, _x4) {
  889. return _ref7.apply(this, arguments);
  890. }
  891. return open;
  892. }(),
  893. download: function download() {
  894. var _this3 = this;
  895. function downloadByUrl() {
  896. downloadManager.downloadUrl(url, filename);
  897. }
  898. var url = this.baseUrl;
  899. var filename = this.contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(this.url);
  900. var downloadManager = this.downloadManager;
  901. downloadManager.onerror = function (err) {
  902. _this3.error('PDF failed to download: ' + err);
  903. };
  904. if (!this.pdfDocument || !this.downloadComplete) {
  905. downloadByUrl();
  906. return;
  907. }
  908. this.pdfDocument.getData().then(function (data) {
  909. var blob = new Blob([data], { type: 'application/pdf' });
  910. downloadManager.download(blob, url, filename);
  911. }).catch(downloadByUrl);
  912. },
  913. fallback: function fallback(featureId) {},
  914. error: function error(message, moreInfo) {
  915. var moreInfoText = [this.l10n.get('error_version_info', {
  916. version: _pdfjsLib.version || '?',
  917. build: _pdfjsLib.build || '?'
  918. }, 'PDF.js v{{version}} (build: {{build}})')];
  919. if (moreInfo) {
  920. moreInfoText.push(this.l10n.get('error_message', { message: moreInfo.message }, 'Message: {{message}}'));
  921. if (moreInfo.stack) {
  922. moreInfoText.push(this.l10n.get('error_stack', { stack: moreInfo.stack }, 'Stack: {{stack}}'));
  923. } else {
  924. if (moreInfo.filename) {
  925. moreInfoText.push(this.l10n.get('error_file', { file: moreInfo.filename }, 'File: {{file}}'));
  926. }
  927. if (moreInfo.lineNumber) {
  928. moreInfoText.push(this.l10n.get('error_line', { line: moreInfo.lineNumber }, 'Line: {{line}}'));
  929. }
  930. }
  931. }
  932. var errorWrapperConfig = this.appConfig.errorWrapper;
  933. var errorWrapper = errorWrapperConfig.container;
  934. errorWrapper.removeAttribute('hidden');
  935. var errorMessage = errorWrapperConfig.errorMessage;
  936. errorMessage.textContent = message;
  937. var closeButton = errorWrapperConfig.closeButton;
  938. closeButton.onclick = function () {
  939. errorWrapper.setAttribute('hidden', 'true');
  940. };
  941. var errorMoreInfo = errorWrapperConfig.errorMoreInfo;
  942. var moreInfoButton = errorWrapperConfig.moreInfoButton;
  943. var lessInfoButton = errorWrapperConfig.lessInfoButton;
  944. moreInfoButton.onclick = function () {
  945. errorMoreInfo.removeAttribute('hidden');
  946. moreInfoButton.setAttribute('hidden', 'true');
  947. lessInfoButton.removeAttribute('hidden');
  948. errorMoreInfo.style.height = errorMoreInfo.scrollHeight + 'px';
  949. };
  950. lessInfoButton.onclick = function () {
  951. errorMoreInfo.setAttribute('hidden', 'true');
  952. moreInfoButton.removeAttribute('hidden');
  953. lessInfoButton.setAttribute('hidden', 'true');
  954. };
  955. moreInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  956. lessInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  957. closeButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  958. moreInfoButton.removeAttribute('hidden');
  959. lessInfoButton.setAttribute('hidden', 'true');
  960. Promise.all(moreInfoText).then(function (parts) {
  961. errorMoreInfo.value = parts.join('\n');
  962. });
  963. },
  964. progress: function progress(level) {
  965. var _this4 = this;
  966. if (this.downloadComplete) {
  967. return;
  968. }
  969. var percent = Math.round(level * 100);
  970. if (percent > this.loadingBar.percent || isNaN(percent)) {
  971. this.loadingBar.percent = percent;
  972. var disableAutoFetch = this.pdfDocument ? this.pdfDocument.loadingParams['disableAutoFetch'] : _app_options.AppOptions.get('disableAutoFetch');
  973. if (disableAutoFetch && percent) {
  974. if (this.disableAutoFetchLoadingBarTimeout) {
  975. clearTimeout(this.disableAutoFetchLoadingBarTimeout);
  976. this.disableAutoFetchLoadingBarTimeout = null;
  977. }
  978. this.loadingBar.show();
  979. this.disableAutoFetchLoadingBarTimeout = setTimeout(function () {
  980. _this4.loadingBar.hide();
  981. _this4.disableAutoFetchLoadingBarTimeout = null;
  982. }, DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT);
  983. }
  984. }
  985. },
  986. load: function load(pdfDocument) {
  987. var _this5 = this;
  988. this.pdfDocument = pdfDocument;
  989. pdfDocument.getDownloadInfo().then(function () {
  990. _this5.downloadComplete = true;
  991. _this5.loadingBar.hide();
  992. firstPagePromise.then(function () {
  993. _this5.eventBus.dispatch('documentloaded', { source: _this5 });
  994. _this5.eventBus.dispatch('documentload', { source: _this5 });
  995. });
  996. });
  997. var pageModePromise = pdfDocument.getPageMode().catch(function () {});
  998. this.toolbar.setPagesCount(pdfDocument.numPages, false);
  999. this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
  1000. var store = this.store = new _view_history.ViewHistory(pdfDocument.fingerprint);
  1001. var baseDocumentUrl = void 0;
  1002. baseDocumentUrl = null;
  1003. this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
  1004. this.pdfDocumentProperties.setDocument(pdfDocument, this.url);
  1005. var pdfViewer = this.pdfViewer;
  1006. pdfViewer.setDocument(pdfDocument);
  1007. var firstPagePromise = pdfViewer.firstPagePromise;
  1008. var pagesPromise = pdfViewer.pagesPromise;
  1009. var onePageRendered = pdfViewer.onePageRendered;
  1010. var pdfThumbnailViewer = this.pdfThumbnailViewer;
  1011. pdfThumbnailViewer.setDocument(pdfDocument);
  1012. firstPagePromise.then(function (pdfPage) {
  1013. _this5.loadingBar.setWidth(_this5.appConfig.viewerContainer);
  1014. if (!_app_options.AppOptions.get('disableHistory') && !_this5.isViewerEmbedded) {
  1015. var resetHistory = !_app_options.AppOptions.get('showPreviousViewOnLoad');
  1016. _this5.pdfHistory.initialize(pdfDocument.fingerprint, resetHistory);
  1017. if (_this5.pdfHistory.initialBookmark) {
  1018. _this5.initialBookmark = _this5.pdfHistory.initialBookmark;
  1019. _this5.initialRotation = _this5.pdfHistory.initialRotation;
  1020. }
  1021. }
  1022. var storePromise = store.getMultiple({
  1023. page: null,
  1024. zoom: _ui_utils.DEFAULT_SCALE_VALUE,
  1025. scrollLeft: '0',
  1026. scrollTop: '0',
  1027. rotation: null,
  1028. sidebarView: _pdf_sidebar.SidebarView.NONE,
  1029. scrollMode: null,
  1030. spreadMode: null
  1031. }).catch(function () {});
  1032. Promise.all([storePromise, pageModePromise]).then(function () {
  1033. var _ref10 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee8(_ref9) {
  1034. var _ref11 = _slicedToArray(_ref9, 2),
  1035. _ref11$ = _ref11[0],
  1036. values = _ref11$ === undefined ? {} : _ref11$,
  1037. pageMode = _ref11[1];
  1038. var initialBookmark, zoom, hash, rotation, sidebarView, scrollMode, spreadMode;
  1039. return _regenerator2.default.wrap(function _callee8$(_context8) {
  1040. while (1) {
  1041. switch (_context8.prev = _context8.next) {
  1042. case 0:
  1043. initialBookmark = _this5.initialBookmark;
  1044. zoom = _app_options.AppOptions.get('defaultZoomValue');
  1045. hash = zoom ? 'zoom=' + zoom : null;
  1046. rotation = null;
  1047. sidebarView = _app_options.AppOptions.get('sidebarViewOnLoad');
  1048. scrollMode = _app_options.AppOptions.get('scrollModeOnLoad');
  1049. spreadMode = _app_options.AppOptions.get('spreadModeOnLoad');
  1050. if (values.page && _app_options.AppOptions.get('showPreviousViewOnLoad')) {
  1051. hash = 'page=' + values.page + '&zoom=' + (zoom || values.zoom) + ',' + values.scrollLeft + ',' + values.scrollTop;
  1052. rotation = parseInt(values.rotation, 10);
  1053. sidebarView = sidebarView || values.sidebarView | 0;
  1054. scrollMode = scrollMode || values.scrollMode | 0;
  1055. spreadMode = spreadMode || values.spreadMode | 0;
  1056. }
  1057. if (pageMode && !_app_options.AppOptions.get('disablePageMode')) {
  1058. sidebarView = sidebarView || apiPageModeToSidebarView(pageMode);
  1059. }
  1060. _this5.setInitialView(hash, {
  1061. rotation: rotation,
  1062. sidebarView: sidebarView,
  1063. scrollMode: scrollMode,
  1064. spreadMode: spreadMode
  1065. });
  1066. _this5.eventBus.dispatch('documentinit', { source: _this5 });
  1067. if (!_this5.isViewerEmbedded) {
  1068. pdfViewer.focus();
  1069. }
  1070. _context8.next = 14;
  1071. return Promise.race([pagesPromise, new Promise(function (resolve) {
  1072. setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT);
  1073. })]);
  1074. case 14:
  1075. if (!(!initialBookmark && !hash)) {
  1076. _context8.next = 16;
  1077. break;
  1078. }
  1079. return _context8.abrupt('return');
  1080. case 16:
  1081. if (!pdfViewer.hasEqualPageSizes) {
  1082. _context8.next = 18;
  1083. break;
  1084. }
  1085. return _context8.abrupt('return');
  1086. case 18:
  1087. _this5.initialBookmark = initialBookmark;
  1088. pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;
  1089. _this5.setInitialView(hash);
  1090. case 21:
  1091. case 'end':
  1092. return _context8.stop();
  1093. }
  1094. }
  1095. }, _callee8, _this5);
  1096. }));
  1097. return function (_x5) {
  1098. return _ref10.apply(this, arguments);
  1099. };
  1100. }()).then(function () {
  1101. pdfViewer.update();
  1102. });
  1103. });
  1104. pdfDocument.getPageLabels().then(function (labels) {
  1105. if (!labels || _app_options.AppOptions.get('disablePageLabels')) {
  1106. return;
  1107. }
  1108. var i = 0,
  1109. numLabels = labels.length;
  1110. if (numLabels !== _this5.pagesCount) {
  1111. console.error('The number of Page Labels does not match ' + 'the number of pages in the document.');
  1112. return;
  1113. }
  1114. while (i < numLabels && labels[i] === (i + 1).toString()) {
  1115. i++;
  1116. }
  1117. if (i === numLabels) {
  1118. return;
  1119. }
  1120. pdfViewer.setPageLabels(labels);
  1121. pdfThumbnailViewer.setPageLabels(labels);
  1122. _this5.toolbar.setPagesCount(pdfDocument.numPages, true);
  1123. _this5.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  1124. });
  1125. pagesPromise.then(function () {
  1126. if (!_this5.supportsPrinting) {
  1127. return;
  1128. }
  1129. pdfDocument.getJavaScript().then(function (javaScript) {
  1130. if (!javaScript) {
  1131. return;
  1132. }
  1133. javaScript.some(function (js) {
  1134. if (!js) {
  1135. return false;
  1136. }
  1137. console.warn('Warning: JavaScript is not supported');
  1138. _this5.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.javaScript);
  1139. return true;
  1140. });
  1141. var regex = /\bprint\s*\(/;
  1142. for (var i = 0, ii = javaScript.length; i < ii; i++) {
  1143. var js = javaScript[i];
  1144. if (js && regex.test(js)) {
  1145. setTimeout(function () {
  1146. window.print();
  1147. });
  1148. return;
  1149. }
  1150. }
  1151. });
  1152. });
  1153. Promise.all([onePageRendered, _ui_utils.animationStarted]).then(function () {
  1154. pdfDocument.getOutline().then(function (outline) {
  1155. _this5.pdfOutlineViewer.render({ outline: outline });
  1156. });
  1157. pdfDocument.getAttachments().then(function (attachments) {
  1158. _this5.pdfAttachmentViewer.render({ attachments: attachments });
  1159. });
  1160. });
  1161. pdfDocument.getMetadata().then(function (_ref12) {
  1162. var info = _ref12.info,
  1163. metadata = _ref12.metadata,
  1164. contentDispositionFilename = _ref12.contentDispositionFilename;
  1165. _this5.documentInfo = info;
  1166. _this5.metadata = metadata;
  1167. _this5.contentDispositionFilename = contentDispositionFilename;
  1168. console.log('PDF ' + pdfDocument.fingerprint + ' [' + info.PDFFormatVersion + ' ' + (info.Producer || '-').trim() + ' / ' + (info.Creator || '-').trim() + ']' + ' (PDF.js: ' + (_pdfjsLib.version || '-') + (_app_options.AppOptions.get('enableWebGL') ? ' [WebGL]' : '') + ')');
  1169. var pdfTitle = void 0;
  1170. if (metadata && metadata.has('dc:title')) {
  1171. var title = metadata.get('dc:title');
  1172. if (title !== 'Untitled') {
  1173. pdfTitle = title;
  1174. }
  1175. }
  1176. if (!pdfTitle && info && info['Title']) {
  1177. pdfTitle = info['Title'];
  1178. }
  1179. if (pdfTitle) {
  1180. _this5.setTitle(pdfTitle + ' - ' + (contentDispositionFilename || document.title));
  1181. } else if (contentDispositionFilename) {
  1182. _this5.setTitle(contentDispositionFilename);
  1183. }
  1184. if (info.IsAcroFormPresent) {
  1185. console.warn('Warning: AcroForm/XFA is not supported');
  1186. _this5.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms);
  1187. }
  1188. });
  1189. },
  1190. setInitialView: function setInitialView(storedHash) {
  1191. var _this6 = this;
  1192. var _ref13 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  1193. rotation = _ref13.rotation,
  1194. sidebarView = _ref13.sidebarView,
  1195. scrollMode = _ref13.scrollMode,
  1196. spreadMode = _ref13.spreadMode;
  1197. var setRotation = function setRotation(angle) {
  1198. if ((0, _ui_utils.isValidRotation)(angle)) {
  1199. _this6.pdfViewer.pagesRotation = angle;
  1200. }
  1201. };
  1202. var setViewerModes = function setViewerModes(scroll, spread) {
  1203. if (Number.isInteger(scroll)) {
  1204. _this6.pdfViewer.scrollMode = scroll;
  1205. }
  1206. if (Number.isInteger(spread)) {
  1207. _this6.pdfViewer.spreadMode = spread;
  1208. }
  1209. };
  1210. setViewerModes(scrollMode, spreadMode);
  1211. this.isInitialViewSet = true;
  1212. this.pdfSidebar.setInitialView(sidebarView);
  1213. if (this.initialBookmark) {
  1214. setRotation(this.initialRotation);
  1215. delete this.initialRotation;
  1216. this.pdfLinkService.setHash(this.initialBookmark);
  1217. this.initialBookmark = null;
  1218. } else if (storedHash) {
  1219. setRotation(rotation);
  1220. this.pdfLinkService.setHash(storedHash);
  1221. }
  1222. this.toolbar.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel);
  1223. this.secondaryToolbar.setPageNumber(this.pdfViewer.currentPageNumber);
  1224. if (!this.pdfViewer.currentScaleValue) {
  1225. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  1226. }
  1227. },
  1228. cleanup: function cleanup() {
  1229. if (!this.pdfDocument) {
  1230. return;
  1231. }
  1232. this.pdfViewer.cleanup();
  1233. this.pdfThumbnailViewer.cleanup();
  1234. if (this.pdfViewer.renderer !== _ui_utils.RendererType.SVG) {
  1235. this.pdfDocument.cleanup();
  1236. }
  1237. },
  1238. forceRendering: function forceRendering() {
  1239. this.pdfRenderingQueue.printing = this.printing;
  1240. this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar.isThumbnailViewVisible;
  1241. this.pdfRenderingQueue.renderHighestPriority();
  1242. },
  1243. beforePrint: function beforePrint() {
  1244. var _this7 = this;
  1245. if (this.printService) {
  1246. return;
  1247. }
  1248. if (!this.supportsPrinting) {
  1249. this.l10n.get('printing_not_supported', null, 'Warning: Printing is not fully supported by ' + 'this browser.').then(function (printMessage) {
  1250. _this7.error(printMessage);
  1251. });
  1252. return;
  1253. }
  1254. if (!this.pdfViewer.pageViewsReady) {
  1255. this.l10n.get('printing_not_ready', null, 'Warning: The PDF is not fully loaded for printing.').then(function (notReadyMessage) {
  1256. window.alert(notReadyMessage);
  1257. });
  1258. return;
  1259. }
  1260. var pagesOverview = this.pdfViewer.getPagesOverview();
  1261. var printContainer = this.appConfig.printContainer;
  1262. var printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument, pagesOverview, printContainer, this.l10n);
  1263. this.printService = printService;
  1264. this.forceRendering();
  1265. printService.layout();
  1266. },
  1267. afterPrint: function pdfViewSetupAfterPrint() {
  1268. if (this.printService) {
  1269. this.printService.destroy();
  1270. this.printService = null;
  1271. }
  1272. this.forceRendering();
  1273. },
  1274. rotatePages: function rotatePages(delta) {
  1275. if (!this.pdfDocument) {
  1276. return;
  1277. }
  1278. var newRotation = (this.pdfViewer.pagesRotation + 360 + delta) % 360;
  1279. this.pdfViewer.pagesRotation = newRotation;
  1280. },
  1281. requestPresentationMode: function requestPresentationMode() {
  1282. if (!this.pdfPresentationMode) {
  1283. return;
  1284. }
  1285. this.pdfPresentationMode.request();
  1286. },
  1287. bindEvents: function bindEvents() {
  1288. var eventBus = this.eventBus,
  1289. _boundEvents = this._boundEvents;
  1290. _boundEvents.beforePrint = this.beforePrint.bind(this);
  1291. _boundEvents.afterPrint = this.afterPrint.bind(this);
  1292. eventBus.on('resize', webViewerResize);
  1293. eventBus.on('hashchange', webViewerHashchange);
  1294. eventBus.on('beforeprint', _boundEvents.beforePrint);
  1295. eventBus.on('afterprint', _boundEvents.afterPrint);
  1296. eventBus.on('pagerendered', webViewerPageRendered);
  1297. eventBus.on('textlayerrendered', webViewerTextLayerRendered);
  1298. eventBus.on('updateviewarea', webViewerUpdateViewarea);
  1299. eventBus.on('pagechanging', webViewerPageChanging);
  1300. eventBus.on('scalechanging', webViewerScaleChanging);
  1301. eventBus.on('rotationchanging', webViewerRotationChanging);
  1302. eventBus.on('sidebarviewchanged', webViewerSidebarViewChanged);
  1303. eventBus.on('pagemode', webViewerPageMode);
  1304. eventBus.on('namedaction', webViewerNamedAction);
  1305. eventBus.on('presentationmodechanged', webViewerPresentationModeChanged);
  1306. eventBus.on('presentationmode', webViewerPresentationMode);
  1307. eventBus.on('openfile', webViewerOpenFile);
  1308. eventBus.on('print', webViewerPrint);
  1309. eventBus.on('download', webViewerDownload);
  1310. eventBus.on('firstpage', webViewerFirstPage);
  1311. eventBus.on('lastpage', webViewerLastPage);
  1312. eventBus.on('nextpage', webViewerNextPage);
  1313. eventBus.on('previouspage', webViewerPreviousPage);
  1314. eventBus.on('zoomin', webViewerZoomIn);
  1315. eventBus.on('zoomout', webViewerZoomOut);
  1316. eventBus.on('pagenumberchanged', webViewerPageNumberChanged);
  1317. eventBus.on('scalechanged', webViewerScaleChanged);
  1318. eventBus.on('rotatecw', webViewerRotateCw);
  1319. eventBus.on('rotateccw', webViewerRotateCcw);
  1320. eventBus.on('switchscrollmode', webViewerSwitchScrollMode);
  1321. eventBus.on('scrollmodechanged', webViewerScrollModeChanged);
  1322. eventBus.on('switchspreadmode', webViewerSwitchSpreadMode);
  1323. eventBus.on('spreadmodechanged', webViewerSpreadModeChanged);
  1324. eventBus.on('documentproperties', webViewerDocumentProperties);
  1325. eventBus.on('find', webViewerFind);
  1326. eventBus.on('findfromurlhash', webViewerFindFromUrlHash);
  1327. eventBus.on('updatefindmatchescount', webViewerUpdateFindMatchesCount);
  1328. eventBus.on('updatefindcontrolstate', webViewerUpdateFindControlState);
  1329. eventBus.on('fileinputchange', webViewerFileInputChange);
  1330. },
  1331. bindWindowEvents: function bindWindowEvents() {
  1332. var eventBus = this.eventBus,
  1333. _boundEvents = this._boundEvents;
  1334. _boundEvents.windowResize = function () {
  1335. eventBus.dispatch('resize', { source: window });
  1336. };
  1337. _boundEvents.windowHashChange = function () {
  1338. eventBus.dispatch('hashchange', {
  1339. source: window,
  1340. hash: document.location.hash.substring(1)
  1341. });
  1342. };
  1343. _boundEvents.windowBeforePrint = function () {
  1344. eventBus.dispatch('beforeprint', { source: window });
  1345. };
  1346. _boundEvents.windowAfterPrint = function () {
  1347. eventBus.dispatch('afterprint', { source: window });
  1348. };
  1349. window.addEventListener('wheel', webViewerWheel);
  1350. window.addEventListener('click', webViewerClick);
  1351. window.addEventListener('keydown', webViewerKeyDown);
  1352. window.addEventListener('resize', _boundEvents.windowResize);
  1353. window.addEventListener('hashchange', _boundEvents.windowHashChange);
  1354. window.addEventListener('beforeprint', _boundEvents.windowBeforePrint);
  1355. window.addEventListener('afterprint', _boundEvents.windowAfterPrint);
  1356. },
  1357. unbindEvents: function unbindEvents() {
  1358. var eventBus = this.eventBus,
  1359. _boundEvents = this._boundEvents;
  1360. eventBus.off('resize', webViewerResize);
  1361. eventBus.off('hashchange', webViewerHashchange);
  1362. eventBus.off('beforeprint', _boundEvents.beforePrint);
  1363. eventBus.off('afterprint', _boundEvents.afterPrint);
  1364. eventBus.off('pagerendered', webViewerPageRendered);
  1365. eventBus.off('textlayerrendered', webViewerTextLayerRendered);
  1366. eventBus.off('updateviewarea', webViewerUpdateViewarea);
  1367. eventBus.off('pagechanging', webViewerPageChanging);
  1368. eventBus.off('scalechanging', webViewerScaleChanging);
  1369. eventBus.off('rotationchanging', webViewerRotationChanging);
  1370. eventBus.off('sidebarviewchanged', webViewerSidebarViewChanged);
  1371. eventBus.off('pagemode', webViewerPageMode);
  1372. eventBus.off('namedaction', webViewerNamedAction);
  1373. eventBus.off('presentationmodechanged', webViewerPresentationModeChanged);
  1374. eventBus.off('presentationmode', webViewerPresentationMode);
  1375. eventBus.off('openfile', webViewerOpenFile);
  1376. eventBus.off('print', webViewerPrint);
  1377. eventBus.off('download', webViewerDownload);
  1378. eventBus.off('firstpage', webViewerFirstPage);
  1379. eventBus.off('lastpage', webViewerLastPage);
  1380. eventBus.off('nextpage', webViewerNextPage);
  1381. eventBus.off('previouspage', webViewerPreviousPage);
  1382. eventBus.off('zoomin', webViewerZoomIn);
  1383. eventBus.off('zoomout', webViewerZoomOut);
  1384. eventBus.off('pagenumberchanged', webViewerPageNumberChanged);
  1385. eventBus.off('scalechanged', webViewerScaleChanged);
  1386. eventBus.off('rotatecw', webViewerRotateCw);
  1387. eventBus.off('rotateccw', webViewerRotateCcw);
  1388. eventBus.off('switchscrollmode', webViewerSwitchScrollMode);
  1389. eventBus.off('scrollmodechanged', webViewerScrollModeChanged);
  1390. eventBus.off('switchspreadmode', webViewerSwitchSpreadMode);
  1391. eventBus.off('spreadmodechanged', webViewerSpreadModeChanged);
  1392. eventBus.off('documentproperties', webViewerDocumentProperties);
  1393. eventBus.off('find', webViewerFind);
  1394. eventBus.off('findfromurlhash', webViewerFindFromUrlHash);
  1395. eventBus.off('updatefindmatchescount', webViewerUpdateFindMatchesCount);
  1396. eventBus.off('updatefindcontrolstate', webViewerUpdateFindControlState);
  1397. eventBus.off('fileinputchange', webViewerFileInputChange);
  1398. _boundEvents.beforePrint = null;
  1399. _boundEvents.afterPrint = null;
  1400. },
  1401. unbindWindowEvents: function unbindWindowEvents() {
  1402. var _boundEvents = this._boundEvents;
  1403. window.removeEventListener('wheel', webViewerWheel);
  1404. window.removeEventListener('click', webViewerClick);
  1405. window.removeEventListener('keydown', webViewerKeyDown);
  1406. window.removeEventListener('resize', _boundEvents.windowResize);
  1407. window.removeEventListener('hashchange', _boundEvents.windowHashChange);
  1408. window.removeEventListener('beforeprint', _boundEvents.windowBeforePrint);
  1409. window.removeEventListener('afterprint', _boundEvents.windowAfterPrint);
  1410. _boundEvents.windowResize = null;
  1411. _boundEvents.windowHashChange = null;
  1412. _boundEvents.windowBeforePrint = null;
  1413. _boundEvents.windowAfterPrint = null;
  1414. }
  1415. };
  1416. var validateFileURL = void 0;
  1417. {
  1418. var HOSTED_VIEWER_ORIGINS = ['null', 'http://mozilla.github.io', 'https://mozilla.github.io'];
  1419. validateFileURL = function validateFileURL(file) {
  1420. if (file === undefined) {
  1421. return;
  1422. }
  1423. try {
  1424. var viewerOrigin = new _pdfjsLib.URL(window.location.href).origin || 'null';
  1425. if (HOSTED_VIEWER_ORIGINS.includes(viewerOrigin)) {
  1426. return;
  1427. }
  1428. var _ref14 = new _pdfjsLib.URL(file, window.location.href),
  1429. origin = _ref14.origin,
  1430. protocol = _ref14.protocol;
  1431. if (origin !== viewerOrigin && protocol !== 'blob:') {
  1432. throw new Error('file origin does not match viewer\'s');
  1433. }
  1434. } catch (ex) {
  1435. var message = ex && ex.message;
  1436. PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.').then(function (loadingErrorMessage) {
  1437. PDFViewerApplication.error(loadingErrorMessage, { message: message });
  1438. });
  1439. throw ex;
  1440. }
  1441. };
  1442. }
  1443. function loadFakeWorker() {
  1444. if (!_pdfjsLib.GlobalWorkerOptions.workerSrc) {
  1445. _pdfjsLib.GlobalWorkerOptions.workerSrc = _app_options.AppOptions.get('workerSrc');
  1446. }
  1447. return (0, _pdfjsLib.loadScript)(_pdfjsLib.PDFWorker.getWorkerSrc());
  1448. }
  1449. function loadAndEnablePDFBug(enabledTabs) {
  1450. var appConfig = PDFViewerApplication.appConfig;
  1451. return (0, _pdfjsLib.loadScript)(appConfig.debuggerScriptPath).then(function () {
  1452. PDFBug.enable(enabledTabs);
  1453. PDFBug.init({
  1454. OPS: _pdfjsLib.OPS,
  1455. createObjectURL: _pdfjsLib.createObjectURL
  1456. }, appConfig.mainContainer);
  1457. });
  1458. }
  1459. function webViewerInitialized() {
  1460. var appConfig = PDFViewerApplication.appConfig;
  1461. var file = void 0;
  1462. var queryString = document.location.search.substring(1);
  1463. var params = (0, _ui_utils.parseQueryString)(queryString);
  1464. file = 'file' in params ? params.file : _app_options.AppOptions.get('defaultUrl');
  1465. validateFileURL(file);
  1466. var fileInput = document.createElement('input');
  1467. fileInput.id = appConfig.openFileInputName;
  1468. fileInput.className = 'fileInput';
  1469. fileInput.setAttribute('type', 'file');
  1470. fileInput.oncontextmenu = _ui_utils.noContextMenuHandler;
  1471. document.body.appendChild(fileInput);
  1472. if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
  1473. appConfig.toolbar.openFile.setAttribute('hidden', 'true');
  1474. appConfig.secondaryToolbar.openFileButton.setAttribute('hidden', 'true');
  1475. } else {
  1476. fileInput.value = null;
  1477. }
  1478. fileInput.addEventListener('change', function (evt) {
  1479. var files = evt.target.files;
  1480. if (!files || files.length === 0) {
  1481. return;
  1482. }
  1483. PDFViewerApplication.eventBus.dispatch('fileinputchange', {
  1484. source: this,
  1485. fileInput: evt.target
  1486. });
  1487. });
  1488. appConfig.mainContainer.addEventListener('dragover', function (evt) {
  1489. evt.preventDefault();
  1490. evt.dataTransfer.dropEffect = 'move';
  1491. });
  1492. appConfig.mainContainer.addEventListener('drop', function (evt) {
  1493. evt.preventDefault();
  1494. var files = evt.dataTransfer.files;
  1495. if (!files || files.length === 0) {
  1496. return;
  1497. }
  1498. PDFViewerApplication.eventBus.dispatch('fileinputchange', {
  1499. source: this,
  1500. fileInput: evt.dataTransfer
  1501. });
  1502. });
  1503. if (!PDFViewerApplication.supportsPrinting) {
  1504. appConfig.toolbar.print.classList.add('hidden');
  1505. appConfig.secondaryToolbar.printButton.classList.add('hidden');
  1506. }
  1507. if (!PDFViewerApplication.supportsFullscreen) {
  1508. appConfig.toolbar.presentationModeButton.classList.add('hidden');
  1509. appConfig.secondaryToolbar.presentationModeButton.classList.add('hidden');
  1510. }
  1511. if (PDFViewerApplication.supportsIntegratedFind) {
  1512. appConfig.toolbar.viewFind.classList.add('hidden');
  1513. }
  1514. appConfig.mainContainer.addEventListener('transitionend', function (evt) {
  1515. if (evt.target === this) {
  1516. PDFViewerApplication.eventBus.dispatch('resize', { source: this });
  1517. }
  1518. }, true);
  1519. appConfig.sidebar.toggleButton.addEventListener('click', function () {
  1520. PDFViewerApplication.pdfSidebar.toggle();
  1521. });
  1522. try {
  1523. webViewerOpenFileViaURL(file);
  1524. } catch (reason) {
  1525. PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.').then(function (msg) {
  1526. PDFViewerApplication.error(msg, reason);
  1527. });
  1528. }
  1529. }
  1530. var webViewerOpenFileViaURL = void 0;
  1531. {
  1532. webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) {
  1533. if (file && file.lastIndexOf('file:', 0) === 0) {
  1534. PDFViewerApplication.setTitleUsingUrl(file);
  1535. var xhr = new XMLHttpRequest();
  1536. xhr.onload = function () {
  1537. PDFViewerApplication.open(new Uint8Array(xhr.response));
  1538. };
  1539. try {
  1540. xhr.open('GET', file);
  1541. xhr.responseType = 'arraybuffer';
  1542. xhr.send();
  1543. } catch (ex) {
  1544. throw ex;
  1545. }
  1546. return;
  1547. }
  1548. if (file) {
  1549. PDFViewerApplication.open(file);
  1550. }
  1551. };
  1552. }
  1553. function webViewerPageRendered(evt) {
  1554. var pageNumber = evt.pageNumber;
  1555. var pageIndex = pageNumber - 1;
  1556. var pageView = PDFViewerApplication.pdfViewer.getPageView(pageIndex);
  1557. if (pageNumber === PDFViewerApplication.page) {
  1558. PDFViewerApplication.toolbar.updateLoadingIndicatorState(false);
  1559. }
  1560. if (!pageView) {
  1561. return;
  1562. }
  1563. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  1564. var thumbnailView = PDFViewerApplication.pdfThumbnailViewer.getThumbnail(pageIndex);
  1565. thumbnailView.setImage(pageView);
  1566. }
  1567. if (typeof Stats !== 'undefined' && Stats.enabled && pageView.stats) {
  1568. Stats.add(pageNumber, pageView.stats);
  1569. }
  1570. if (pageView.error) {
  1571. PDFViewerApplication.l10n.get('rendering_error', null, 'An error occurred while rendering the page.').then(function (msg) {
  1572. PDFViewerApplication.error(msg, pageView.error);
  1573. });
  1574. }
  1575. }
  1576. function webViewerTextLayerRendered(evt) {}
  1577. function webViewerPageMode(evt) {
  1578. var mode = evt.mode,
  1579. view = void 0;
  1580. switch (mode) {
  1581. case 'thumbs':
  1582. view = _pdf_sidebar.SidebarView.THUMBS;
  1583. break;
  1584. case 'bookmarks':
  1585. case 'outline':
  1586. view = _pdf_sidebar.SidebarView.OUTLINE;
  1587. break;
  1588. case 'attachments':
  1589. view = _pdf_sidebar.SidebarView.ATTACHMENTS;
  1590. break;
  1591. case 'none':
  1592. view = _pdf_sidebar.SidebarView.NONE;
  1593. break;
  1594. default:
  1595. console.error('Invalid "pagemode" hash parameter: ' + mode);
  1596. return;
  1597. }
  1598. PDFViewerApplication.pdfSidebar.switchView(view, true);
  1599. }
  1600. function webViewerNamedAction(evt) {
  1601. var action = evt.action;
  1602. switch (action) {
  1603. case 'GoToPage':
  1604. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  1605. break;
  1606. case 'Find':
  1607. if (!PDFViewerApplication.supportsIntegratedFind) {
  1608. PDFViewerApplication.findBar.toggle();
  1609. }
  1610. break;
  1611. }
  1612. }
  1613. function webViewerPresentationModeChanged(evt) {
  1614. var active = evt.active,
  1615. switchInProgress = evt.switchInProgress;
  1616. PDFViewerApplication.pdfViewer.presentationModeState = switchInProgress ? _ui_utils.PresentationModeState.CHANGING : active ? _ui_utils.PresentationModeState.FULLSCREEN : _ui_utils.PresentationModeState.NORMAL;
  1617. }
  1618. function webViewerSidebarViewChanged(evt) {
  1619. PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = PDFViewerApplication.pdfSidebar.isThumbnailViewVisible;
  1620. var store = PDFViewerApplication.store;
  1621. if (store && PDFViewerApplication.isInitialViewSet) {
  1622. store.set('sidebarView', evt.view).catch(function () {});
  1623. }
  1624. }
  1625. function webViewerUpdateViewarea(evt) {
  1626. var location = evt.location,
  1627. store = PDFViewerApplication.store;
  1628. if (store && PDFViewerApplication.isInitialViewSet) {
  1629. store.setMultiple({
  1630. 'page': location.pageNumber,
  1631. 'zoom': location.scale,
  1632. 'scrollLeft': location.left,
  1633. 'scrollTop': location.top,
  1634. 'rotation': location.rotation
  1635. }).catch(function () {});
  1636. }
  1637. var href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
  1638. PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href;
  1639. PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
  1640. var currentPage = PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page - 1);
  1641. var loading = currentPage.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED;
  1642. PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading);
  1643. }
  1644. function webViewerScrollModeChanged(evt) {
  1645. var store = PDFViewerApplication.store;
  1646. if (store && PDFViewerApplication.isInitialViewSet) {
  1647. store.set('scrollMode', evt.mode).catch(function () {});
  1648. }
  1649. }
  1650. function webViewerSpreadModeChanged(evt) {
  1651. var store = PDFViewerApplication.store;
  1652. if (store && PDFViewerApplication.isInitialViewSet) {
  1653. store.set('spreadMode', evt.mode).catch(function () {});
  1654. }
  1655. }
  1656. function webViewerResize() {
  1657. var pdfDocument = PDFViewerApplication.pdfDocument,
  1658. pdfViewer = PDFViewerApplication.pdfViewer;
  1659. if (!pdfDocument) {
  1660. return;
  1661. }
  1662. var currentScaleValue = pdfViewer.currentScaleValue;
  1663. if (currentScaleValue === 'auto' || currentScaleValue === 'page-fit' || currentScaleValue === 'page-width') {
  1664. pdfViewer.currentScaleValue = currentScaleValue;
  1665. }
  1666. pdfViewer.update();
  1667. }
  1668. function webViewerHashchange(evt) {
  1669. var hash = evt.hash;
  1670. if (!hash) {
  1671. return;
  1672. }
  1673. if (!PDFViewerApplication.isInitialViewSet) {
  1674. PDFViewerApplication.initialBookmark = hash;
  1675. } else if (!PDFViewerApplication.pdfHistory.popStateInProgress) {
  1676. PDFViewerApplication.pdfLinkService.setHash(hash);
  1677. }
  1678. }
  1679. var webViewerFileInputChange = void 0;
  1680. {
  1681. webViewerFileInputChange = function webViewerFileInputChange(evt) {
  1682. if (PDFViewerApplication.pdfViewer && PDFViewerApplication.pdfViewer.isInPresentationMode) {
  1683. return;
  1684. }
  1685. var file = evt.fileInput.files[0];
  1686. if (_pdfjsLib.URL.createObjectURL && !_app_options.AppOptions.get('disableCreateObjectURL')) {
  1687. var _url = _pdfjsLib.URL.createObjectURL(file);
  1688. if (file.name) {
  1689. _url = {
  1690. url: _url,
  1691. originalUrl: file.name
  1692. };
  1693. }
  1694. PDFViewerApplication.open(_url);
  1695. } else {
  1696. PDFViewerApplication.setTitleUsingUrl(file.name);
  1697. var fileReader = new FileReader();
  1698. fileReader.onload = function webViewerChangeFileReaderOnload(evt) {
  1699. var buffer = evt.target.result;
  1700. PDFViewerApplication.open(new Uint8Array(buffer));
  1701. };
  1702. fileReader.readAsArrayBuffer(file);
  1703. }
  1704. var appConfig = PDFViewerApplication.appConfig;
  1705. appConfig.toolbar.viewBookmark.setAttribute('hidden', 'true');
  1706. appConfig.secondaryToolbar.viewBookmarkButton.setAttribute('hidden', 'true');
  1707. appConfig.toolbar.download.setAttribute('hidden', 'true');
  1708. appConfig.secondaryToolbar.downloadButton.setAttribute('hidden', 'true');
  1709. };
  1710. }
  1711. function webViewerPresentationMode() {
  1712. PDFViewerApplication.requestPresentationMode();
  1713. }
  1714. function webViewerOpenFile() {
  1715. var openFileInputName = PDFViewerApplication.appConfig.openFileInputName;
  1716. document.getElementById(openFileInputName).click();
  1717. }
  1718. function webViewerPrint() {
  1719. window.print();
  1720. }
  1721. function webViewerDownload() {
  1722. PDFViewerApplication.download();
  1723. }
  1724. function webViewerFirstPage() {
  1725. if (PDFViewerApplication.pdfDocument) {
  1726. PDFViewerApplication.page = 1;
  1727. }
  1728. }
  1729. function webViewerLastPage() {
  1730. if (PDFViewerApplication.pdfDocument) {
  1731. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  1732. }
  1733. }
  1734. function webViewerNextPage() {
  1735. PDFViewerApplication.page++;
  1736. }
  1737. function webViewerPreviousPage() {
  1738. PDFViewerApplication.page--;
  1739. }
  1740. function webViewerZoomIn() {
  1741. PDFViewerApplication.zoomIn();
  1742. }
  1743. function webViewerZoomOut() {
  1744. PDFViewerApplication.zoomOut();
  1745. }
  1746. function webViewerPageNumberChanged(evt) {
  1747. var pdfViewer = PDFViewerApplication.pdfViewer;
  1748. pdfViewer.currentPageLabel = evt.value;
  1749. if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) {
  1750. PDFViewerApplication.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  1751. }
  1752. }
  1753. function webViewerScaleChanged(evt) {
  1754. PDFViewerApplication.pdfViewer.currentScaleValue = evt.value;
  1755. }
  1756. function webViewerRotateCw() {
  1757. PDFViewerApplication.rotatePages(90);
  1758. }
  1759. function webViewerRotateCcw() {
  1760. PDFViewerApplication.rotatePages(-90);
  1761. }
  1762. function webViewerSwitchScrollMode(evt) {
  1763. PDFViewerApplication.pdfViewer.scrollMode = evt.mode;
  1764. }
  1765. function webViewerSwitchSpreadMode(evt) {
  1766. PDFViewerApplication.pdfViewer.spreadMode = evt.mode;
  1767. }
  1768. function webViewerDocumentProperties() {
  1769. PDFViewerApplication.pdfDocumentProperties.open();
  1770. }
  1771. function webViewerFind(evt) {
  1772. PDFViewerApplication.findController.executeCommand('find' + evt.type, {
  1773. query: evt.query,
  1774. phraseSearch: evt.phraseSearch,
  1775. caseSensitive: evt.caseSensitive,
  1776. entireWord: evt.entireWord,
  1777. highlightAll: evt.highlightAll,
  1778. findPrevious: evt.findPrevious
  1779. });
  1780. }
  1781. function webViewerFindFromUrlHash(evt) {
  1782. PDFViewerApplication.findController.executeCommand('find', {
  1783. query: evt.query,
  1784. phraseSearch: evt.phraseSearch,
  1785. caseSensitive: false,
  1786. entireWord: false,
  1787. highlightAll: true,
  1788. findPrevious: false
  1789. });
  1790. }
  1791. function webViewerUpdateFindMatchesCount(_ref15) {
  1792. var matchesCount = _ref15.matchesCount;
  1793. if (PDFViewerApplication.supportsIntegratedFind) {
  1794. PDFViewerApplication.externalServices.updateFindMatchesCount(matchesCount);
  1795. } else {
  1796. PDFViewerApplication.findBar.updateResultsCount(matchesCount);
  1797. }
  1798. }
  1799. function webViewerUpdateFindControlState(_ref16) {
  1800. var state = _ref16.state,
  1801. previous = _ref16.previous,
  1802. matchesCount = _ref16.matchesCount;
  1803. if (PDFViewerApplication.supportsIntegratedFind) {
  1804. PDFViewerApplication.externalServices.updateFindControlState({
  1805. result: state,
  1806. findPrevious: previous,
  1807. matchesCount: matchesCount
  1808. });
  1809. } else {
  1810. PDFViewerApplication.findBar.updateUIState(state, previous, matchesCount);
  1811. }
  1812. }
  1813. function webViewerScaleChanging(evt) {
  1814. PDFViewerApplication.toolbar.setPageScale(evt.presetValue, evt.scale);
  1815. PDFViewerApplication.pdfViewer.update();
  1816. }
  1817. function webViewerRotationChanging(evt) {
  1818. PDFViewerApplication.pdfThumbnailViewer.pagesRotation = evt.pagesRotation;
  1819. PDFViewerApplication.forceRendering();
  1820. PDFViewerApplication.pdfViewer.currentPageNumber = evt.pageNumber;
  1821. }
  1822. function webViewerPageChanging(evt) {
  1823. var page = evt.pageNumber;
  1824. PDFViewerApplication.toolbar.setPageNumber(page, evt.pageLabel || null);
  1825. PDFViewerApplication.secondaryToolbar.setPageNumber(page);
  1826. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  1827. PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(page);
  1828. }
  1829. if (typeof Stats !== 'undefined' && Stats.enabled) {
  1830. var pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1);
  1831. if (pageView && pageView.stats) {
  1832. Stats.add(page, pageView.stats);
  1833. }
  1834. }
  1835. }
  1836. var zoomDisabled = false,
  1837. zoomDisabledTimeout = void 0;
  1838. function webViewerWheel(evt) {
  1839. var pdfViewer = PDFViewerApplication.pdfViewer;
  1840. if (pdfViewer.isInPresentationMode) {
  1841. return;
  1842. }
  1843. if (evt.ctrlKey || evt.metaKey) {
  1844. var support = PDFViewerApplication.supportedMouseWheelZoomModifierKeys;
  1845. if (evt.ctrlKey && !support.ctrlKey || evt.metaKey && !support.metaKey) {
  1846. return;
  1847. }
  1848. evt.preventDefault();
  1849. if (zoomDisabled) {
  1850. return;
  1851. }
  1852. var previousScale = pdfViewer.currentScale;
  1853. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  1854. var MOUSE_WHEEL_DELTA_PER_PAGE_SCALE = 3.0;
  1855. var ticks = delta * MOUSE_WHEEL_DELTA_PER_PAGE_SCALE;
  1856. if (ticks < 0) {
  1857. PDFViewerApplication.zoomOut(-ticks);
  1858. } else {
  1859. PDFViewerApplication.zoomIn(ticks);
  1860. }
  1861. var currentScale = pdfViewer.currentScale;
  1862. if (previousScale !== currentScale) {
  1863. var scaleCorrectionFactor = currentScale / previousScale - 1;
  1864. var rect = pdfViewer.container.getBoundingClientRect();
  1865. var dx = evt.clientX - rect.left;
  1866. var dy = evt.clientY - rect.top;
  1867. pdfViewer.container.scrollLeft += dx * scaleCorrectionFactor;
  1868. pdfViewer.container.scrollTop += dy * scaleCorrectionFactor;
  1869. }
  1870. } else {
  1871. zoomDisabled = true;
  1872. clearTimeout(zoomDisabledTimeout);
  1873. zoomDisabledTimeout = setTimeout(function () {
  1874. zoomDisabled = false;
  1875. }, 1000);
  1876. }
  1877. }
  1878. function webViewerClick(evt) {
  1879. if (!PDFViewerApplication.secondaryToolbar.isOpen) {
  1880. return;
  1881. }
  1882. var appConfig = PDFViewerApplication.appConfig;
  1883. if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar.container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar.toggleButton) {
  1884. PDFViewerApplication.secondaryToolbar.close();
  1885. }
  1886. }
  1887. function webViewerKeyDown(evt) {
  1888. if (PDFViewerApplication.overlayManager.active) {
  1889. return;
  1890. }
  1891. var handled = false,
  1892. ensureViewerFocused = false;
  1893. var cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0);
  1894. var pdfViewer = PDFViewerApplication.pdfViewer;
  1895. var isViewerInPresentationMode = pdfViewer && pdfViewer.isInPresentationMode;
  1896. if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
  1897. switch (evt.keyCode) {
  1898. case 70:
  1899. if (!PDFViewerApplication.supportsIntegratedFind) {
  1900. PDFViewerApplication.findBar.open();
  1901. handled = true;
  1902. }
  1903. break;
  1904. case 71:
  1905. if (!PDFViewerApplication.supportsIntegratedFind) {
  1906. var findState = PDFViewerApplication.findController.state;
  1907. if (findState) {
  1908. PDFViewerApplication.findController.executeCommand('findagain', {
  1909. query: findState.query,
  1910. phraseSearch: findState.phraseSearch,
  1911. caseSensitive: findState.caseSensitive,
  1912. entireWord: findState.entireWord,
  1913. highlightAll: findState.highlightAll,
  1914. findPrevious: cmd === 5 || cmd === 12
  1915. });
  1916. }
  1917. handled = true;
  1918. }
  1919. break;
  1920. case 61:
  1921. case 107:
  1922. case 187:
  1923. case 171:
  1924. if (!isViewerInPresentationMode) {
  1925. PDFViewerApplication.zoomIn();
  1926. }
  1927. handled = true;
  1928. break;
  1929. case 173:
  1930. case 109:
  1931. case 189:
  1932. if (!isViewerInPresentationMode) {
  1933. PDFViewerApplication.zoomOut();
  1934. }
  1935. handled = true;
  1936. break;
  1937. case 48:
  1938. case 96:
  1939. if (!isViewerInPresentationMode) {
  1940. setTimeout(function () {
  1941. pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  1942. });
  1943. handled = false;
  1944. }
  1945. break;
  1946. case 38:
  1947. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  1948. PDFViewerApplication.page = 1;
  1949. handled = true;
  1950. ensureViewerFocused = true;
  1951. }
  1952. break;
  1953. case 40:
  1954. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  1955. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  1956. handled = true;
  1957. ensureViewerFocused = true;
  1958. }
  1959. break;
  1960. }
  1961. }
  1962. if (cmd === 1 || cmd === 8) {
  1963. switch (evt.keyCode) {
  1964. case 83:
  1965. PDFViewerApplication.download();
  1966. handled = true;
  1967. break;
  1968. }
  1969. }
  1970. if (cmd === 3 || cmd === 10) {
  1971. switch (evt.keyCode) {
  1972. case 80:
  1973. PDFViewerApplication.requestPresentationMode();
  1974. handled = true;
  1975. break;
  1976. case 71:
  1977. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  1978. handled = true;
  1979. break;
  1980. }
  1981. }
  1982. if (handled) {
  1983. if (ensureViewerFocused && !isViewerInPresentationMode) {
  1984. pdfViewer.focus();
  1985. }
  1986. evt.preventDefault();
  1987. return;
  1988. }
  1989. var curElement = document.activeElement || document.querySelector(':focus');
  1990. var curElementTagName = curElement && curElement.tagName.toUpperCase();
  1991. if (curElementTagName === 'INPUT' || curElementTagName === 'TEXTAREA' || curElementTagName === 'SELECT') {
  1992. if (evt.keyCode !== 27) {
  1993. return;
  1994. }
  1995. }
  1996. if (cmd === 0) {
  1997. var turnPage = 0,
  1998. turnOnlyIfPageFit = false;
  1999. switch (evt.keyCode) {
  2000. case 38:
  2001. case 33:
  2002. if (pdfViewer.isVerticalScrollbarEnabled) {
  2003. turnOnlyIfPageFit = true;
  2004. }
  2005. turnPage = -1;
  2006. break;
  2007. case 8:
  2008. if (!isViewerInPresentationMode) {
  2009. turnOnlyIfPageFit = true;
  2010. }
  2011. turnPage = -1;
  2012. break;
  2013. case 37:
  2014. if (pdfViewer.isHorizontalScrollbarEnabled) {
  2015. turnOnlyIfPageFit = true;
  2016. }
  2017. case 75:
  2018. case 80:
  2019. turnPage = -1;
  2020. break;
  2021. case 27:
  2022. if (PDFViewerApplication.secondaryToolbar.isOpen) {
  2023. PDFViewerApplication.secondaryToolbar.close();
  2024. handled = true;
  2025. }
  2026. if (!PDFViewerApplication.supportsIntegratedFind && PDFViewerApplication.findBar.opened) {
  2027. PDFViewerApplication.findBar.close();
  2028. handled = true;
  2029. }
  2030. break;
  2031. case 40:
  2032. case 34:
  2033. if (pdfViewer.isVerticalScrollbarEnabled) {
  2034. turnOnlyIfPageFit = true;
  2035. }
  2036. turnPage = 1;
  2037. break;
  2038. case 13:
  2039. case 32:
  2040. if (!isViewerInPresentationMode) {
  2041. turnOnlyIfPageFit = true;
  2042. }
  2043. turnPage = 1;
  2044. break;
  2045. case 39:
  2046. if (pdfViewer.isHorizontalScrollbarEnabled) {
  2047. turnOnlyIfPageFit = true;
  2048. }
  2049. case 74:
  2050. case 78:
  2051. turnPage = 1;
  2052. break;
  2053. case 36:
  2054. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  2055. PDFViewerApplication.page = 1;
  2056. handled = true;
  2057. ensureViewerFocused = true;
  2058. }
  2059. break;
  2060. case 35:
  2061. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2062. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2063. handled = true;
  2064. ensureViewerFocused = true;
  2065. }
  2066. break;
  2067. case 83:
  2068. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.SELECT);
  2069. break;
  2070. case 72:
  2071. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.HAND);
  2072. break;
  2073. case 82:
  2074. PDFViewerApplication.rotatePages(90);
  2075. break;
  2076. }
  2077. if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === 'page-fit')) {
  2078. if (turnPage > 0) {
  2079. if (PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2080. PDFViewerApplication.page++;
  2081. }
  2082. } else {
  2083. if (PDFViewerApplication.page > 1) {
  2084. PDFViewerApplication.page--;
  2085. }
  2086. }
  2087. handled = true;
  2088. }
  2089. }
  2090. if (cmd === 4) {
  2091. switch (evt.keyCode) {
  2092. case 13:
  2093. case 32:
  2094. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== 'page-fit') {
  2095. break;
  2096. }
  2097. if (PDFViewerApplication.page > 1) {
  2098. PDFViewerApplication.page--;
  2099. }
  2100. handled = true;
  2101. break;
  2102. case 82:
  2103. PDFViewerApplication.rotatePages(-90);
  2104. break;
  2105. }
  2106. }
  2107. if (!handled && !isViewerInPresentationMode) {
  2108. if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !== 'BUTTON') {
  2109. ensureViewerFocused = true;
  2110. }
  2111. }
  2112. if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
  2113. pdfViewer.focus();
  2114. }
  2115. if (handled) {
  2116. evt.preventDefault();
  2117. }
  2118. }
  2119. function apiPageModeToSidebarView(mode) {
  2120. switch (mode) {
  2121. case 'UseNone':
  2122. return _pdf_sidebar.SidebarView.NONE;
  2123. case 'UseThumbs':
  2124. return _pdf_sidebar.SidebarView.THUMBS;
  2125. case 'UseOutlines':
  2126. return _pdf_sidebar.SidebarView.OUTLINE;
  2127. case 'UseAttachments':
  2128. return _pdf_sidebar.SidebarView.ATTACHMENTS;
  2129. case 'UseOC':
  2130. }
  2131. return _pdf_sidebar.SidebarView.NONE;
  2132. }
  2133. var PDFPrintServiceFactory = {
  2134. instance: {
  2135. supportsPrinting: false,
  2136. createPrintService: function createPrintService() {
  2137. throw new Error('Not implemented: createPrintService');
  2138. }
  2139. }
  2140. };
  2141. exports.PDFViewerApplication = PDFViewerApplication;
  2142. exports.DefaultExternalServices = DefaultExternalServices;
  2143. exports.PDFPrintServiceFactory = PDFPrintServiceFactory;
  2144. /***/ }),
  2145. /* 2 */
  2146. /***/ (function(module, exports, __webpack_require__) {
  2147. "use strict";
  2148. module.exports = __webpack_require__(3);
  2149. /***/ }),
  2150. /* 3 */
  2151. /***/ (function(module, exports, __webpack_require__) {
  2152. "use strict";
  2153. var g = function () {
  2154. return this;
  2155. }() || Function("return this")();
  2156. var hadRuntime = g.regeneratorRuntime && Object.getOwnPropertyNames(g).indexOf("regeneratorRuntime") >= 0;
  2157. var oldRuntime = hadRuntime && g.regeneratorRuntime;
  2158. g.regeneratorRuntime = undefined;
  2159. module.exports = __webpack_require__(4);
  2160. if (hadRuntime) {
  2161. g.regeneratorRuntime = oldRuntime;
  2162. } else {
  2163. try {
  2164. delete g.regeneratorRuntime;
  2165. } catch (e) {
  2166. g.regeneratorRuntime = undefined;
  2167. }
  2168. }
  2169. /***/ }),
  2170. /* 4 */
  2171. /***/ (function(module, exports, __webpack_require__) {
  2172. "use strict";
  2173. /* WEBPACK VAR INJECTION */(function(module) {
  2174. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  2175. !function (global) {
  2176. "use strict";
  2177. var Op = Object.prototype;
  2178. var hasOwn = Op.hasOwnProperty;
  2179. var undefined;
  2180. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  2181. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  2182. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  2183. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  2184. var inModule = ( false ? undefined : _typeof(module)) === "object";
  2185. var runtime = global.regeneratorRuntime;
  2186. if (runtime) {
  2187. if (inModule) {
  2188. module.exports = runtime;
  2189. }
  2190. return;
  2191. }
  2192. runtime = global.regeneratorRuntime = inModule ? module.exports : {};
  2193. function wrap(innerFn, outerFn, self, tryLocsList) {
  2194. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  2195. var generator = Object.create(protoGenerator.prototype);
  2196. var context = new Context(tryLocsList || []);
  2197. generator._invoke = makeInvokeMethod(innerFn, self, context);
  2198. return generator;
  2199. }
  2200. runtime.wrap = wrap;
  2201. function tryCatch(fn, obj, arg) {
  2202. try {
  2203. return {
  2204. type: "normal",
  2205. arg: fn.call(obj, arg)
  2206. };
  2207. } catch (err) {
  2208. return {
  2209. type: "throw",
  2210. arg: err
  2211. };
  2212. }
  2213. }
  2214. var GenStateSuspendedStart = "suspendedStart";
  2215. var GenStateSuspendedYield = "suspendedYield";
  2216. var GenStateExecuting = "executing";
  2217. var GenStateCompleted = "completed";
  2218. var ContinueSentinel = {};
  2219. function Generator() {}
  2220. function GeneratorFunction() {}
  2221. function GeneratorFunctionPrototype() {}
  2222. var IteratorPrototype = {};
  2223. IteratorPrototype[iteratorSymbol] = function () {
  2224. return this;
  2225. };
  2226. var getProto = Object.getPrototypeOf;
  2227. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  2228. if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  2229. IteratorPrototype = NativeIteratorPrototype;
  2230. }
  2231. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
  2232. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  2233. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  2234. GeneratorFunctionPrototype[toStringTagSymbol] = GeneratorFunction.displayName = "GeneratorFunction";
  2235. function defineIteratorMethods(prototype) {
  2236. ["next", "throw", "return"].forEach(function (method) {
  2237. prototype[method] = function (arg) {
  2238. return this._invoke(method, arg);
  2239. };
  2240. });
  2241. }
  2242. runtime.isGeneratorFunction = function (genFun) {
  2243. var ctor = typeof genFun === "function" && genFun.constructor;
  2244. return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
  2245. };
  2246. runtime.mark = function (genFun) {
  2247. if (Object.setPrototypeOf) {
  2248. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  2249. } else {
  2250. genFun.__proto__ = GeneratorFunctionPrototype;
  2251. if (!(toStringTagSymbol in genFun)) {
  2252. genFun[toStringTagSymbol] = "GeneratorFunction";
  2253. }
  2254. }
  2255. genFun.prototype = Object.create(Gp);
  2256. return genFun;
  2257. };
  2258. runtime.awrap = function (arg) {
  2259. return { __await: arg };
  2260. };
  2261. function AsyncIterator(generator) {
  2262. function invoke(method, arg, resolve, reject) {
  2263. var record = tryCatch(generator[method], generator, arg);
  2264. if (record.type === "throw") {
  2265. reject(record.arg);
  2266. } else {
  2267. var result = record.arg;
  2268. var value = result.value;
  2269. if (value && (typeof value === "undefined" ? "undefined" : _typeof(value)) === "object" && hasOwn.call(value, "__await")) {
  2270. return Promise.resolve(value.__await).then(function (value) {
  2271. invoke("next", value, resolve, reject);
  2272. }, function (err) {
  2273. invoke("throw", err, resolve, reject);
  2274. });
  2275. }
  2276. return Promise.resolve(value).then(function (unwrapped) {
  2277. result.value = unwrapped;
  2278. resolve(result);
  2279. }, reject);
  2280. }
  2281. }
  2282. var previousPromise;
  2283. function enqueue(method, arg) {
  2284. function callInvokeWithMethodAndArg() {
  2285. return new Promise(function (resolve, reject) {
  2286. invoke(method, arg, resolve, reject);
  2287. });
  2288. }
  2289. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  2290. }
  2291. this._invoke = enqueue;
  2292. }
  2293. defineIteratorMethods(AsyncIterator.prototype);
  2294. AsyncIterator.prototype[asyncIteratorSymbol] = function () {
  2295. return this;
  2296. };
  2297. runtime.AsyncIterator = AsyncIterator;
  2298. runtime.async = function (innerFn, outerFn, self, tryLocsList) {
  2299. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList));
  2300. return runtime.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  2301. return result.done ? result.value : iter.next();
  2302. });
  2303. };
  2304. function makeInvokeMethod(innerFn, self, context) {
  2305. var state = GenStateSuspendedStart;
  2306. return function invoke(method, arg) {
  2307. if (state === GenStateExecuting) {
  2308. throw new Error("Generator is already running");
  2309. }
  2310. if (state === GenStateCompleted) {
  2311. if (method === "throw") {
  2312. throw arg;
  2313. }
  2314. return doneResult();
  2315. }
  2316. context.method = method;
  2317. context.arg = arg;
  2318. while (true) {
  2319. var delegate = context.delegate;
  2320. if (delegate) {
  2321. var delegateResult = maybeInvokeDelegate(delegate, context);
  2322. if (delegateResult) {
  2323. if (delegateResult === ContinueSentinel) continue;
  2324. return delegateResult;
  2325. }
  2326. }
  2327. if (context.method === "next") {
  2328. context.sent = context._sent = context.arg;
  2329. } else if (context.method === "throw") {
  2330. if (state === GenStateSuspendedStart) {
  2331. state = GenStateCompleted;
  2332. throw context.arg;
  2333. }
  2334. context.dispatchException(context.arg);
  2335. } else if (context.method === "return") {
  2336. context.abrupt("return", context.arg);
  2337. }
  2338. state = GenStateExecuting;
  2339. var record = tryCatch(innerFn, self, context);
  2340. if (record.type === "normal") {
  2341. state = context.done ? GenStateCompleted : GenStateSuspendedYield;
  2342. if (record.arg === ContinueSentinel) {
  2343. continue;
  2344. }
  2345. return {
  2346. value: record.arg,
  2347. done: context.done
  2348. };
  2349. } else if (record.type === "throw") {
  2350. state = GenStateCompleted;
  2351. context.method = "throw";
  2352. context.arg = record.arg;
  2353. }
  2354. }
  2355. };
  2356. }
  2357. function maybeInvokeDelegate(delegate, context) {
  2358. var method = delegate.iterator[context.method];
  2359. if (method === undefined) {
  2360. context.delegate = null;
  2361. if (context.method === "throw") {
  2362. if (delegate.iterator.return) {
  2363. context.method = "return";
  2364. context.arg = undefined;
  2365. maybeInvokeDelegate(delegate, context);
  2366. if (context.method === "throw") {
  2367. return ContinueSentinel;
  2368. }
  2369. }
  2370. context.method = "throw";
  2371. context.arg = new TypeError("The iterator does not provide a 'throw' method");
  2372. }
  2373. return ContinueSentinel;
  2374. }
  2375. var record = tryCatch(method, delegate.iterator, context.arg);
  2376. if (record.type === "throw") {
  2377. context.method = "throw";
  2378. context.arg = record.arg;
  2379. context.delegate = null;
  2380. return ContinueSentinel;
  2381. }
  2382. var info = record.arg;
  2383. if (!info) {
  2384. context.method = "throw";
  2385. context.arg = new TypeError("iterator result is not an object");
  2386. context.delegate = null;
  2387. return ContinueSentinel;
  2388. }
  2389. if (info.done) {
  2390. context[delegate.resultName] = info.value;
  2391. context.next = delegate.nextLoc;
  2392. if (context.method !== "return") {
  2393. context.method = "next";
  2394. context.arg = undefined;
  2395. }
  2396. } else {
  2397. return info;
  2398. }
  2399. context.delegate = null;
  2400. return ContinueSentinel;
  2401. }
  2402. defineIteratorMethods(Gp);
  2403. Gp[toStringTagSymbol] = "Generator";
  2404. Gp[iteratorSymbol] = function () {
  2405. return this;
  2406. };
  2407. Gp.toString = function () {
  2408. return "[object Generator]";
  2409. };
  2410. function pushTryEntry(locs) {
  2411. var entry = { tryLoc: locs[0] };
  2412. if (1 in locs) {
  2413. entry.catchLoc = locs[1];
  2414. }
  2415. if (2 in locs) {
  2416. entry.finallyLoc = locs[2];
  2417. entry.afterLoc = locs[3];
  2418. }
  2419. this.tryEntries.push(entry);
  2420. }
  2421. function resetTryEntry(entry) {
  2422. var record = entry.completion || {};
  2423. record.type = "normal";
  2424. delete record.arg;
  2425. entry.completion = record;
  2426. }
  2427. function Context(tryLocsList) {
  2428. this.tryEntries = [{ tryLoc: "root" }];
  2429. tryLocsList.forEach(pushTryEntry, this);
  2430. this.reset(true);
  2431. }
  2432. runtime.keys = function (object) {
  2433. var keys = [];
  2434. for (var key in object) {
  2435. keys.push(key);
  2436. }
  2437. keys.reverse();
  2438. return function next() {
  2439. while (keys.length) {
  2440. var key = keys.pop();
  2441. if (key in object) {
  2442. next.value = key;
  2443. next.done = false;
  2444. return next;
  2445. }
  2446. }
  2447. next.done = true;
  2448. return next;
  2449. };
  2450. };
  2451. function values(iterable) {
  2452. if (iterable) {
  2453. var iteratorMethod = iterable[iteratorSymbol];
  2454. if (iteratorMethod) {
  2455. return iteratorMethod.call(iterable);
  2456. }
  2457. if (typeof iterable.next === "function") {
  2458. return iterable;
  2459. }
  2460. if (!isNaN(iterable.length)) {
  2461. var i = -1,
  2462. next = function next() {
  2463. while (++i < iterable.length) {
  2464. if (hasOwn.call(iterable, i)) {
  2465. next.value = iterable[i];
  2466. next.done = false;
  2467. return next;
  2468. }
  2469. }
  2470. next.value = undefined;
  2471. next.done = true;
  2472. return next;
  2473. };
  2474. return next.next = next;
  2475. }
  2476. }
  2477. return { next: doneResult };
  2478. }
  2479. runtime.values = values;
  2480. function doneResult() {
  2481. return {
  2482. value: undefined,
  2483. done: true
  2484. };
  2485. }
  2486. Context.prototype = {
  2487. constructor: Context,
  2488. reset: function reset(skipTempReset) {
  2489. this.prev = 0;
  2490. this.next = 0;
  2491. this.sent = this._sent = undefined;
  2492. this.done = false;
  2493. this.delegate = null;
  2494. this.method = "next";
  2495. this.arg = undefined;
  2496. this.tryEntries.forEach(resetTryEntry);
  2497. if (!skipTempReset) {
  2498. for (var name in this) {
  2499. if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
  2500. this[name] = undefined;
  2501. }
  2502. }
  2503. }
  2504. },
  2505. stop: function stop() {
  2506. this.done = true;
  2507. var rootEntry = this.tryEntries[0];
  2508. var rootRecord = rootEntry.completion;
  2509. if (rootRecord.type === "throw") {
  2510. throw rootRecord.arg;
  2511. }
  2512. return this.rval;
  2513. },
  2514. dispatchException: function dispatchException(exception) {
  2515. if (this.done) {
  2516. throw exception;
  2517. }
  2518. var context = this;
  2519. function handle(loc, caught) {
  2520. record.type = "throw";
  2521. record.arg = exception;
  2522. context.next = loc;
  2523. if (caught) {
  2524. context.method = "next";
  2525. context.arg = undefined;
  2526. }
  2527. return !!caught;
  2528. }
  2529. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  2530. var entry = this.tryEntries[i];
  2531. var record = entry.completion;
  2532. if (entry.tryLoc === "root") {
  2533. return handle("end");
  2534. }
  2535. if (entry.tryLoc <= this.prev) {
  2536. var hasCatch = hasOwn.call(entry, "catchLoc");
  2537. var hasFinally = hasOwn.call(entry, "finallyLoc");
  2538. if (hasCatch && hasFinally) {
  2539. if (this.prev < entry.catchLoc) {
  2540. return handle(entry.catchLoc, true);
  2541. } else if (this.prev < entry.finallyLoc) {
  2542. return handle(entry.finallyLoc);
  2543. }
  2544. } else if (hasCatch) {
  2545. if (this.prev < entry.catchLoc) {
  2546. return handle(entry.catchLoc, true);
  2547. }
  2548. } else if (hasFinally) {
  2549. if (this.prev < entry.finallyLoc) {
  2550. return handle(entry.finallyLoc);
  2551. }
  2552. } else {
  2553. throw new Error("try statement without catch or finally");
  2554. }
  2555. }
  2556. }
  2557. },
  2558. abrupt: function abrupt(type, arg) {
  2559. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  2560. var entry = this.tryEntries[i];
  2561. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  2562. var finallyEntry = entry;
  2563. break;
  2564. }
  2565. }
  2566. if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
  2567. finallyEntry = null;
  2568. }
  2569. var record = finallyEntry ? finallyEntry.completion : {};
  2570. record.type = type;
  2571. record.arg = arg;
  2572. if (finallyEntry) {
  2573. this.method = "next";
  2574. this.next = finallyEntry.finallyLoc;
  2575. return ContinueSentinel;
  2576. }
  2577. return this.complete(record);
  2578. },
  2579. complete: function complete(record, afterLoc) {
  2580. if (record.type === "throw") {
  2581. throw record.arg;
  2582. }
  2583. if (record.type === "break" || record.type === "continue") {
  2584. this.next = record.arg;
  2585. } else if (record.type === "return") {
  2586. this.rval = this.arg = record.arg;
  2587. this.method = "return";
  2588. this.next = "end";
  2589. } else if (record.type === "normal" && afterLoc) {
  2590. this.next = afterLoc;
  2591. }
  2592. return ContinueSentinel;
  2593. },
  2594. finish: function finish(finallyLoc) {
  2595. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  2596. var entry = this.tryEntries[i];
  2597. if (entry.finallyLoc === finallyLoc) {
  2598. this.complete(entry.completion, entry.afterLoc);
  2599. resetTryEntry(entry);
  2600. return ContinueSentinel;
  2601. }
  2602. }
  2603. },
  2604. "catch": function _catch(tryLoc) {
  2605. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  2606. var entry = this.tryEntries[i];
  2607. if (entry.tryLoc === tryLoc) {
  2608. var record = entry.completion;
  2609. if (record.type === "throw") {
  2610. var thrown = record.arg;
  2611. resetTryEntry(entry);
  2612. }
  2613. return thrown;
  2614. }
  2615. }
  2616. throw new Error("illegal catch attempt");
  2617. },
  2618. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  2619. this.delegate = {
  2620. iterator: values(iterable),
  2621. resultName: resultName,
  2622. nextLoc: nextLoc
  2623. };
  2624. if (this.method === "next") {
  2625. this.arg = undefined;
  2626. }
  2627. return ContinueSentinel;
  2628. }
  2629. };
  2630. }(function () {
  2631. return this;
  2632. }() || Function("return this")());
  2633. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(5)(module)))
  2634. /***/ }),
  2635. /* 5 */
  2636. /***/ (function(module, exports, __webpack_require__) {
  2637. "use strict";
  2638. module.exports = function (module) {
  2639. if (!module.webpackPolyfill) {
  2640. module.deprecate = function () {};
  2641. module.paths = [];
  2642. if (!module.children) module.children = [];
  2643. Object.defineProperty(module, "loaded", {
  2644. enumerable: true,
  2645. get: function get() {
  2646. return module.l;
  2647. }
  2648. });
  2649. Object.defineProperty(module, "id", {
  2650. enumerable: true,
  2651. get: function get() {
  2652. return module.i;
  2653. }
  2654. });
  2655. module.webpackPolyfill = 1;
  2656. }
  2657. return module;
  2658. };
  2659. /***/ }),
  2660. /* 6 */
  2661. /***/ (function(module, exports, __webpack_require__) {
  2662. "use strict";
  2663. Object.defineProperty(exports, "__esModule", {
  2664. value: true
  2665. });
  2666. exports.moveToEndOfArray = exports.waitOnEventOrTimeout = exports.WaitOnType = exports.animationStarted = exports.normalizeWheelEventDelta = exports.binarySearchFirstItem = exports.watchScroll = exports.scrollIntoView = exports.getOutputScale = exports.approximateFraction = exports.getPageSizeInches = exports.roundToDivide = exports.getVisibleElements = exports.backtrackBeforeAllVisibleElements = exports.parseQueryString = exports.noContextMenuHandler = exports.getPDFFileNameFromURL = exports.ProgressBar = exports.EventBus = exports.NullL10n = exports.TextLayerMode = exports.RendererType = exports.PresentationModeState = exports.isPortraitOrientation = exports.isValidRotation = exports.VERTICAL_PADDING = exports.SCROLLBAR_PADDING = exports.MAX_AUTO_SCALE = exports.UNKNOWN_SCALE = exports.MAX_SCALE = exports.MIN_SCALE = exports.DEFAULT_SCALE = exports.DEFAULT_SCALE_VALUE = exports.CSS_UNITS = undefined;
  2667. var _regenerator = __webpack_require__(2);
  2668. var _regenerator2 = _interopRequireDefault(_regenerator);
  2669. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  2670. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  2671. var _slicedToArray = function () { function sliceIterator(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"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  2672. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2673. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2674. function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
  2675. var CSS_UNITS = 96.0 / 72.0;
  2676. var DEFAULT_SCALE_VALUE = 'auto';
  2677. var DEFAULT_SCALE = 1.0;
  2678. var MIN_SCALE = 0.10;
  2679. var MAX_SCALE = 10.0;
  2680. var UNKNOWN_SCALE = 0;
  2681. var MAX_AUTO_SCALE = 1.25;
  2682. var SCROLLBAR_PADDING = 40;
  2683. var VERTICAL_PADDING = 5;
  2684. var PresentationModeState = {
  2685. UNKNOWN: 0,
  2686. NORMAL: 1,
  2687. CHANGING: 2,
  2688. FULLSCREEN: 3
  2689. };
  2690. var RendererType = {
  2691. CANVAS: 'canvas',
  2692. SVG: 'svg'
  2693. };
  2694. var TextLayerMode = {
  2695. DISABLE: 0,
  2696. ENABLE: 1,
  2697. ENABLE_ENHANCE: 2
  2698. };
  2699. function formatL10nValue(text, args) {
  2700. if (!args) {
  2701. return text;
  2702. }
  2703. return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function (all, name) {
  2704. return name in args ? args[name] : '{{' + name + '}}';
  2705. });
  2706. }
  2707. var NullL10n = {
  2708. getLanguage: function () {
  2709. var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee() {
  2710. return _regenerator2.default.wrap(function _callee$(_context) {
  2711. while (1) {
  2712. switch (_context.prev = _context.next) {
  2713. case 0:
  2714. return _context.abrupt('return', 'en-us');
  2715. case 1:
  2716. case 'end':
  2717. return _context.stop();
  2718. }
  2719. }
  2720. }, _callee, this);
  2721. }));
  2722. function getLanguage() {
  2723. return _ref.apply(this, arguments);
  2724. }
  2725. return getLanguage;
  2726. }(),
  2727. getDirection: function () {
  2728. var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2() {
  2729. return _regenerator2.default.wrap(function _callee2$(_context2) {
  2730. while (1) {
  2731. switch (_context2.prev = _context2.next) {
  2732. case 0:
  2733. return _context2.abrupt('return', 'ltr');
  2734. case 1:
  2735. case 'end':
  2736. return _context2.stop();
  2737. }
  2738. }
  2739. }, _callee2, this);
  2740. }));
  2741. function getDirection() {
  2742. return _ref2.apply(this, arguments);
  2743. }
  2744. return getDirection;
  2745. }(),
  2746. get: function () {
  2747. var _ref3 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee3(property, args, fallback) {
  2748. return _regenerator2.default.wrap(function _callee3$(_context3) {
  2749. while (1) {
  2750. switch (_context3.prev = _context3.next) {
  2751. case 0:
  2752. return _context3.abrupt('return', formatL10nValue(fallback, args));
  2753. case 1:
  2754. case 'end':
  2755. return _context3.stop();
  2756. }
  2757. }
  2758. }, _callee3, this);
  2759. }));
  2760. function get(_x, _x2, _x3) {
  2761. return _ref3.apply(this, arguments);
  2762. }
  2763. return get;
  2764. }(),
  2765. translate: function () {
  2766. var _ref4 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee4(element) {
  2767. return _regenerator2.default.wrap(function _callee4$(_context4) {
  2768. while (1) {
  2769. switch (_context4.prev = _context4.next) {
  2770. case 0:
  2771. case 'end':
  2772. return _context4.stop();
  2773. }
  2774. }
  2775. }, _callee4, this);
  2776. }));
  2777. function translate(_x4) {
  2778. return _ref4.apply(this, arguments);
  2779. }
  2780. return translate;
  2781. }()
  2782. };
  2783. function getOutputScale(ctx) {
  2784. var devicePixelRatio = window.devicePixelRatio || 1;
  2785. var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
  2786. var pixelRatio = devicePixelRatio / backingStoreRatio;
  2787. return {
  2788. sx: pixelRatio,
  2789. sy: pixelRatio,
  2790. scaled: pixelRatio !== 1
  2791. };
  2792. }
  2793. function scrollIntoView(element, spot) {
  2794. var skipOverflowHiddenElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  2795. var parent = element.offsetParent;
  2796. if (!parent) {
  2797. console.error('offsetParent is not set -- cannot scroll');
  2798. return;
  2799. }
  2800. var offsetY = element.offsetTop + element.clientTop;
  2801. var offsetX = element.offsetLeft + element.clientLeft;
  2802. while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || skipOverflowHiddenElements && getComputedStyle(parent).overflow === 'hidden') {
  2803. if (parent.dataset._scaleY) {
  2804. offsetY /= parent.dataset._scaleY;
  2805. offsetX /= parent.dataset._scaleX;
  2806. }
  2807. offsetY += parent.offsetTop;
  2808. offsetX += parent.offsetLeft;
  2809. parent = parent.offsetParent;
  2810. if (!parent) {
  2811. return;
  2812. }
  2813. }
  2814. if (spot) {
  2815. if (spot.top !== undefined) {
  2816. offsetY += spot.top;
  2817. }
  2818. if (spot.left !== undefined) {
  2819. offsetX += spot.left;
  2820. parent.scrollLeft = offsetX;
  2821. }
  2822. }
  2823. parent.scrollTop = offsetY;
  2824. }
  2825. function watchScroll(viewAreaElement, callback) {
  2826. var debounceScroll = function debounceScroll(evt) {
  2827. if (rAF) {
  2828. return;
  2829. }
  2830. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  2831. rAF = null;
  2832. var currentX = viewAreaElement.scrollLeft;
  2833. var lastX = state.lastX;
  2834. if (currentX !== lastX) {
  2835. state.right = currentX > lastX;
  2836. }
  2837. state.lastX = currentX;
  2838. var currentY = viewAreaElement.scrollTop;
  2839. var lastY = state.lastY;
  2840. if (currentY !== lastY) {
  2841. state.down = currentY > lastY;
  2842. }
  2843. state.lastY = currentY;
  2844. callback(state);
  2845. });
  2846. };
  2847. var state = {
  2848. right: true,
  2849. down: true,
  2850. lastX: viewAreaElement.scrollLeft,
  2851. lastY: viewAreaElement.scrollTop,
  2852. _eventHandler: debounceScroll
  2853. };
  2854. var rAF = null;
  2855. viewAreaElement.addEventListener('scroll', debounceScroll, true);
  2856. return state;
  2857. }
  2858. function parseQueryString(query) {
  2859. var parts = query.split('&');
  2860. var params = Object.create(null);
  2861. for (var i = 0, ii = parts.length; i < ii; ++i) {
  2862. var param = parts[i].split('=');
  2863. var key = param[0].toLowerCase();
  2864. var value = param.length > 1 ? param[1] : null;
  2865. params[decodeURIComponent(key)] = decodeURIComponent(value);
  2866. }
  2867. return params;
  2868. }
  2869. function binarySearchFirstItem(items, condition) {
  2870. var minIndex = 0;
  2871. var maxIndex = items.length - 1;
  2872. if (items.length === 0 || !condition(items[maxIndex])) {
  2873. return items.length;
  2874. }
  2875. if (condition(items[minIndex])) {
  2876. return minIndex;
  2877. }
  2878. while (minIndex < maxIndex) {
  2879. var currentIndex = minIndex + maxIndex >> 1;
  2880. var currentItem = items[currentIndex];
  2881. if (condition(currentItem)) {
  2882. maxIndex = currentIndex;
  2883. } else {
  2884. minIndex = currentIndex + 1;
  2885. }
  2886. }
  2887. return minIndex;
  2888. }
  2889. function approximateFraction(x) {
  2890. if (Math.floor(x) === x) {
  2891. return [x, 1];
  2892. }
  2893. var xinv = 1 / x;
  2894. var limit = 8;
  2895. if (xinv > limit) {
  2896. return [1, limit];
  2897. } else if (Math.floor(xinv) === xinv) {
  2898. return [1, xinv];
  2899. }
  2900. var x_ = x > 1 ? xinv : x;
  2901. var a = 0,
  2902. b = 1,
  2903. c = 1,
  2904. d = 1;
  2905. while (true) {
  2906. var p = a + c,
  2907. q = b + d;
  2908. if (q > limit) {
  2909. break;
  2910. }
  2911. if (x_ <= p / q) {
  2912. c = p;
  2913. d = q;
  2914. } else {
  2915. a = p;
  2916. b = q;
  2917. }
  2918. }
  2919. var result = void 0;
  2920. if (x_ - a / b < c / d - x_) {
  2921. result = x_ === x ? [a, b] : [b, a];
  2922. } else {
  2923. result = x_ === x ? [c, d] : [d, c];
  2924. }
  2925. return result;
  2926. }
  2927. function roundToDivide(x, div) {
  2928. var r = x % div;
  2929. return r === 0 ? x : Math.round(x - r + div);
  2930. }
  2931. function getPageSizeInches(_ref5) {
  2932. var view = _ref5.view,
  2933. userUnit = _ref5.userUnit,
  2934. rotate = _ref5.rotate;
  2935. var _view = _slicedToArray(view, 4),
  2936. x1 = _view[0],
  2937. y1 = _view[1],
  2938. x2 = _view[2],
  2939. y2 = _view[3];
  2940. var changeOrientation = rotate % 180 !== 0;
  2941. var width = (x2 - x1) / 72 * userUnit;
  2942. var height = (y2 - y1) / 72 * userUnit;
  2943. return {
  2944. width: changeOrientation ? height : width,
  2945. height: changeOrientation ? width : height
  2946. };
  2947. }
  2948. function backtrackBeforeAllVisibleElements(index, views, top) {
  2949. if (index < 2) {
  2950. return index;
  2951. }
  2952. var elt = views[index].div;
  2953. var pageTop = elt.offsetTop + elt.clientTop;
  2954. if (pageTop >= top) {
  2955. elt = views[index - 1].div;
  2956. pageTop = elt.offsetTop + elt.clientTop;
  2957. }
  2958. for (var i = index - 2; i >= 0; --i) {
  2959. elt = views[i].div;
  2960. if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
  2961. break;
  2962. }
  2963. index = i;
  2964. }
  2965. return index;
  2966. }
  2967. function getVisibleElements(scrollEl, views) {
  2968. var sortByVisibility = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  2969. var horizontal = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  2970. var top = scrollEl.scrollTop,
  2971. bottom = top + scrollEl.clientHeight;
  2972. var left = scrollEl.scrollLeft,
  2973. right = left + scrollEl.clientWidth;
  2974. function isElementBottomAfterViewTop(view) {
  2975. var element = view.div;
  2976. var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  2977. return elementBottom > top;
  2978. }
  2979. function isElementRightAfterViewLeft(view) {
  2980. var element = view.div;
  2981. var elementRight = element.offsetLeft + element.clientLeft + element.clientWidth;
  2982. return elementRight > left;
  2983. }
  2984. var visible = [],
  2985. view = void 0,
  2986. element = void 0;
  2987. var currentHeight = void 0,
  2988. viewHeight = void 0,
  2989. viewBottom = void 0,
  2990. hiddenHeight = void 0;
  2991. var currentWidth = void 0,
  2992. viewWidth = void 0,
  2993. viewRight = void 0,
  2994. hiddenWidth = void 0;
  2995. var percentVisible = void 0;
  2996. var firstVisibleElementInd = views.length === 0 ? 0 : binarySearchFirstItem(views, horizontal ? isElementRightAfterViewLeft : isElementBottomAfterViewTop);
  2997. if (views.length > 0 && !horizontal) {
  2998. firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
  2999. }
  3000. var lastEdge = horizontal ? right : -1;
  3001. for (var i = firstVisibleElementInd, ii = views.length; i < ii; i++) {
  3002. view = views[i];
  3003. element = view.div;
  3004. currentWidth = element.offsetLeft + element.clientLeft;
  3005. currentHeight = element.offsetTop + element.clientTop;
  3006. viewWidth = element.clientWidth;
  3007. viewHeight = element.clientHeight;
  3008. viewRight = currentWidth + viewWidth;
  3009. viewBottom = currentHeight + viewHeight;
  3010. if (lastEdge === -1) {
  3011. if (viewBottom >= bottom) {
  3012. lastEdge = viewBottom;
  3013. }
  3014. } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
  3015. break;
  3016. }
  3017. if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) {
  3018. continue;
  3019. }
  3020. hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
  3021. hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
  3022. percentVisible = (viewHeight - hiddenHeight) * (viewWidth - hiddenWidth) * 100 / viewHeight / viewWidth | 0;
  3023. visible.push({
  3024. id: view.id,
  3025. x: currentWidth,
  3026. y: currentHeight,
  3027. view: view,
  3028. percent: percentVisible
  3029. });
  3030. }
  3031. var first = visible[0];
  3032. var last = visible[visible.length - 1];
  3033. if (sortByVisibility) {
  3034. visible.sort(function (a, b) {
  3035. var pc = a.percent - b.percent;
  3036. if (Math.abs(pc) > 0.001) {
  3037. return -pc;
  3038. }
  3039. return a.id - b.id;
  3040. });
  3041. }
  3042. return {
  3043. first: first,
  3044. last: last,
  3045. views: visible
  3046. };
  3047. }
  3048. function noContextMenuHandler(evt) {
  3049. evt.preventDefault();
  3050. }
  3051. function isDataSchema(url) {
  3052. var i = 0,
  3053. ii = url.length;
  3054. while (i < ii && url[i].trim() === '') {
  3055. i++;
  3056. }
  3057. return url.substring(i, i + 5).toLowerCase() === 'data:';
  3058. }
  3059. function getPDFFileNameFromURL(url) {
  3060. var defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'document.pdf';
  3061. if (typeof url !== 'string') {
  3062. return defaultFilename;
  3063. }
  3064. if (isDataSchema(url)) {
  3065. console.warn('getPDFFileNameFromURL: ' + 'ignoring "data:" URL for performance reasons.');
  3066. return defaultFilename;
  3067. }
  3068. var reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
  3069. var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
  3070. var splitURI = reURI.exec(url);
  3071. var suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
  3072. if (suggestedFilename) {
  3073. suggestedFilename = suggestedFilename[0];
  3074. if (suggestedFilename.includes('%')) {
  3075. try {
  3076. suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
  3077. } catch (ex) {}
  3078. }
  3079. }
  3080. return suggestedFilename || defaultFilename;
  3081. }
  3082. function normalizeWheelEventDelta(evt) {
  3083. var delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
  3084. var angle = Math.atan2(evt.deltaY, evt.deltaX);
  3085. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  3086. delta = -delta;
  3087. }
  3088. var MOUSE_DOM_DELTA_PIXEL_MODE = 0;
  3089. var MOUSE_DOM_DELTA_LINE_MODE = 1;
  3090. var MOUSE_PIXELS_PER_LINE = 30;
  3091. var MOUSE_LINES_PER_PAGE = 30;
  3092. if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
  3093. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  3094. } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
  3095. delta /= MOUSE_LINES_PER_PAGE;
  3096. }
  3097. return delta;
  3098. }
  3099. function isValidRotation(angle) {
  3100. return Number.isInteger(angle) && angle % 90 === 0;
  3101. }
  3102. function isPortraitOrientation(size) {
  3103. return size.width <= size.height;
  3104. }
  3105. var WaitOnType = {
  3106. EVENT: 'event',
  3107. TIMEOUT: 'timeout'
  3108. };
  3109. function waitOnEventOrTimeout(_ref6) {
  3110. var target = _ref6.target,
  3111. name = _ref6.name,
  3112. _ref6$delay = _ref6.delay,
  3113. delay = _ref6$delay === undefined ? 0 : _ref6$delay;
  3114. return new Promise(function (resolve, reject) {
  3115. if ((typeof target === 'undefined' ? 'undefined' : _typeof(target)) !== 'object' || !(name && typeof name === 'string') || !(Number.isInteger(delay) && delay >= 0)) {
  3116. throw new Error('waitOnEventOrTimeout - invalid parameters.');
  3117. }
  3118. function handler(type) {
  3119. if (target instanceof EventBus) {
  3120. target.off(name, eventHandler);
  3121. } else {
  3122. target.removeEventListener(name, eventHandler);
  3123. }
  3124. if (timeout) {
  3125. clearTimeout(timeout);
  3126. }
  3127. resolve(type);
  3128. }
  3129. var eventHandler = handler.bind(null, WaitOnType.EVENT);
  3130. if (target instanceof EventBus) {
  3131. target.on(name, eventHandler);
  3132. } else {
  3133. target.addEventListener(name, eventHandler);
  3134. }
  3135. var timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
  3136. var timeout = setTimeout(timeoutHandler, delay);
  3137. });
  3138. }
  3139. var animationStarted = new Promise(function (resolve) {
  3140. window.requestAnimationFrame(resolve);
  3141. });
  3142. var EventBus = function () {
  3143. function EventBus() {
  3144. var _ref7 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  3145. _ref7$dispatchToDOM = _ref7.dispatchToDOM,
  3146. dispatchToDOM = _ref7$dispatchToDOM === undefined ? false : _ref7$dispatchToDOM;
  3147. _classCallCheck(this, EventBus);
  3148. this._listeners = Object.create(null);
  3149. this._dispatchToDOM = dispatchToDOM === true;
  3150. }
  3151. _createClass(EventBus, [{
  3152. key: 'on',
  3153. value: function on(eventName, listener) {
  3154. var eventListeners = this._listeners[eventName];
  3155. if (!eventListeners) {
  3156. eventListeners = [];
  3157. this._listeners[eventName] = eventListeners;
  3158. }
  3159. eventListeners.push(listener);
  3160. }
  3161. }, {
  3162. key: 'off',
  3163. value: function off(eventName, listener) {
  3164. var eventListeners = this._listeners[eventName];
  3165. var i = void 0;
  3166. if (!eventListeners || (i = eventListeners.indexOf(listener)) < 0) {
  3167. return;
  3168. }
  3169. eventListeners.splice(i, 1);
  3170. }
  3171. }, {
  3172. key: 'dispatch',
  3173. value: function dispatch(eventName) {
  3174. var eventListeners = this._listeners[eventName];
  3175. if (!eventListeners || eventListeners.length === 0) {
  3176. if (this._dispatchToDOM) {
  3177. var _args5 = Array.prototype.slice.call(arguments, 1);
  3178. this._dispatchDOMEvent(eventName, _args5);
  3179. }
  3180. return;
  3181. }
  3182. var args = Array.prototype.slice.call(arguments, 1);
  3183. eventListeners.slice(0).forEach(function (listener) {
  3184. listener.apply(null, args);
  3185. });
  3186. if (this._dispatchToDOM) {
  3187. this._dispatchDOMEvent(eventName, args);
  3188. }
  3189. }
  3190. }, {
  3191. key: '_dispatchDOMEvent',
  3192. value: function _dispatchDOMEvent(eventName) {
  3193. var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  3194. if (!this._dispatchToDOM) {
  3195. return;
  3196. }
  3197. var details = Object.create(null);
  3198. if (args && args.length > 0) {
  3199. var obj = args[0];
  3200. for (var key in obj) {
  3201. var value = obj[key];
  3202. if (key === 'source') {
  3203. if (value === window || value === document) {
  3204. return;
  3205. }
  3206. continue;
  3207. }
  3208. details[key] = value;
  3209. }
  3210. }
  3211. var event = document.createEvent('CustomEvent');
  3212. event.initCustomEvent(eventName, true, true, details);
  3213. document.dispatchEvent(event);
  3214. }
  3215. }]);
  3216. return EventBus;
  3217. }();
  3218. function clamp(v, min, max) {
  3219. return Math.min(Math.max(v, min), max);
  3220. }
  3221. var ProgressBar = function () {
  3222. function ProgressBar(id) {
  3223. var _ref8 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  3224. height = _ref8.height,
  3225. width = _ref8.width,
  3226. units = _ref8.units;
  3227. _classCallCheck(this, ProgressBar);
  3228. this.visible = true;
  3229. this.div = document.querySelector(id + ' .progress');
  3230. this.bar = this.div.parentNode;
  3231. this.height = height || 100;
  3232. this.width = width || 100;
  3233. this.units = units || '%';
  3234. this.div.style.height = this.height + this.units;
  3235. this.percent = 0;
  3236. }
  3237. _createClass(ProgressBar, [{
  3238. key: '_updateBar',
  3239. value: function _updateBar() {
  3240. if (this._indeterminate) {
  3241. this.div.classList.add('indeterminate');
  3242. this.div.style.width = this.width + this.units;
  3243. return;
  3244. }
  3245. this.div.classList.remove('indeterminate');
  3246. var progressSize = this.width * this._percent / 100;
  3247. this.div.style.width = progressSize + this.units;
  3248. }
  3249. }, {
  3250. key: 'setWidth',
  3251. value: function setWidth(viewer) {
  3252. if (!viewer) {
  3253. return;
  3254. }
  3255. var container = viewer.parentNode;
  3256. var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  3257. if (scrollbarWidth > 0) {
  3258. this.bar.setAttribute('style', 'width: calc(100% - ' + scrollbarWidth + 'px);');
  3259. }
  3260. }
  3261. }, {
  3262. key: 'hide',
  3263. value: function hide() {
  3264. if (!this.visible) {
  3265. return;
  3266. }
  3267. this.visible = false;
  3268. this.bar.classList.add('hidden');
  3269. document.body.classList.remove('loadingInProgress');
  3270. }
  3271. }, {
  3272. key: 'show',
  3273. value: function show() {
  3274. if (this.visible) {
  3275. return;
  3276. }
  3277. this.visible = true;
  3278. document.body.classList.add('loadingInProgress');
  3279. this.bar.classList.remove('hidden');
  3280. }
  3281. }, {
  3282. key: 'percent',
  3283. get: function get() {
  3284. return this._percent;
  3285. },
  3286. set: function set(val) {
  3287. this._indeterminate = isNaN(val);
  3288. this._percent = clamp(val, 0, 100);
  3289. this._updateBar();
  3290. }
  3291. }]);
  3292. return ProgressBar;
  3293. }();
  3294. function moveToEndOfArray(arr, condition) {
  3295. var moved = [],
  3296. len = arr.length;
  3297. var write = 0;
  3298. for (var read = 0; read < len; ++read) {
  3299. if (condition(arr[read])) {
  3300. moved.push(arr[read]);
  3301. } else {
  3302. arr[write] = arr[read];
  3303. ++write;
  3304. }
  3305. }
  3306. for (var _read = 0; write < len; ++_read, ++write) {
  3307. arr[write] = moved[_read];
  3308. }
  3309. }
  3310. exports.CSS_UNITS = CSS_UNITS;
  3311. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  3312. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  3313. exports.MIN_SCALE = MIN_SCALE;
  3314. exports.MAX_SCALE = MAX_SCALE;
  3315. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  3316. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  3317. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  3318. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  3319. exports.isValidRotation = isValidRotation;
  3320. exports.isPortraitOrientation = isPortraitOrientation;
  3321. exports.PresentationModeState = PresentationModeState;
  3322. exports.RendererType = RendererType;
  3323. exports.TextLayerMode = TextLayerMode;
  3324. exports.NullL10n = NullL10n;
  3325. exports.EventBus = EventBus;
  3326. exports.ProgressBar = ProgressBar;
  3327. exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
  3328. exports.noContextMenuHandler = noContextMenuHandler;
  3329. exports.parseQueryString = parseQueryString;
  3330. exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
  3331. exports.getVisibleElements = getVisibleElements;
  3332. exports.roundToDivide = roundToDivide;
  3333. exports.getPageSizeInches = getPageSizeInches;
  3334. exports.approximateFraction = approximateFraction;
  3335. exports.getOutputScale = getOutputScale;
  3336. exports.scrollIntoView = scrollIntoView;
  3337. exports.watchScroll = watchScroll;
  3338. exports.binarySearchFirstItem = binarySearchFirstItem;
  3339. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  3340. exports.animationStarted = animationStarted;
  3341. exports.WaitOnType = WaitOnType;
  3342. exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
  3343. exports.moveToEndOfArray = moveToEndOfArray;
  3344. /***/ }),
  3345. /* 7 */
  3346. /***/ (function(module, exports, __webpack_require__) {
  3347. "use strict";
  3348. var pdfjsLib = void 0;
  3349. if (typeof window !== 'undefined' && window['pdfjs-dist/build/pdf']) {
  3350. pdfjsLib = window['pdfjs-dist/build/pdf'];
  3351. } else {
  3352. pdfjsLib = require('../build/pdf.js');
  3353. }
  3354. module.exports = pdfjsLib;
  3355. /***/ }),
  3356. /* 8 */
  3357. /***/ (function(module, exports, __webpack_require__) {
  3358. "use strict";
  3359. Object.defineProperty(exports, "__esModule", {
  3360. value: true
  3361. });
  3362. exports.PDFCursorTools = exports.CursorTool = undefined;
  3363. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  3364. var _grab_to_pan = __webpack_require__(9);
  3365. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3366. var CursorTool = {
  3367. SELECT: 0,
  3368. HAND: 1,
  3369. ZOOM: 2
  3370. };
  3371. var PDFCursorTools = function () {
  3372. function PDFCursorTools(_ref) {
  3373. var _this = this;
  3374. var container = _ref.container,
  3375. eventBus = _ref.eventBus,
  3376. _ref$cursorToolOnLoad = _ref.cursorToolOnLoad,
  3377. cursorToolOnLoad = _ref$cursorToolOnLoad === undefined ? CursorTool.SELECT : _ref$cursorToolOnLoad;
  3378. _classCallCheck(this, PDFCursorTools);
  3379. this.container = container;
  3380. this.eventBus = eventBus;
  3381. this.active = CursorTool.SELECT;
  3382. this.activeBeforePresentationMode = null;
  3383. this.handTool = new _grab_to_pan.GrabToPan({ element: this.container });
  3384. this._addEventListeners();
  3385. Promise.resolve().then(function () {
  3386. _this.switchTool(cursorToolOnLoad);
  3387. });
  3388. }
  3389. _createClass(PDFCursorTools, [{
  3390. key: 'switchTool',
  3391. value: function switchTool(tool) {
  3392. var _this2 = this;
  3393. if (this.activeBeforePresentationMode !== null) {
  3394. return;
  3395. }
  3396. if (tool === this.active) {
  3397. return;
  3398. }
  3399. var disableActiveTool = function disableActiveTool() {
  3400. switch (_this2.active) {
  3401. case CursorTool.SELECT:
  3402. break;
  3403. case CursorTool.HAND:
  3404. _this2.handTool.deactivate();
  3405. break;
  3406. case CursorTool.ZOOM:
  3407. }
  3408. };
  3409. switch (tool) {
  3410. case CursorTool.SELECT:
  3411. disableActiveTool();
  3412. break;
  3413. case CursorTool.HAND:
  3414. disableActiveTool();
  3415. this.handTool.activate();
  3416. break;
  3417. case CursorTool.ZOOM:
  3418. default:
  3419. console.error('switchTool: "' + tool + '" is an unsupported value.');
  3420. return;
  3421. }
  3422. this.active = tool;
  3423. this._dispatchEvent();
  3424. }
  3425. }, {
  3426. key: '_dispatchEvent',
  3427. value: function _dispatchEvent() {
  3428. this.eventBus.dispatch('cursortoolchanged', {
  3429. source: this,
  3430. tool: this.active
  3431. });
  3432. }
  3433. }, {
  3434. key: '_addEventListeners',
  3435. value: function _addEventListeners() {
  3436. var _this3 = this;
  3437. this.eventBus.on('switchcursortool', function (evt) {
  3438. _this3.switchTool(evt.tool);
  3439. });
  3440. this.eventBus.on('presentationmodechanged', function (evt) {
  3441. if (evt.switchInProgress) {
  3442. return;
  3443. }
  3444. var previouslyActive = void 0;
  3445. if (evt.active) {
  3446. previouslyActive = _this3.active;
  3447. _this3.switchTool(CursorTool.SELECT);
  3448. _this3.activeBeforePresentationMode = previouslyActive;
  3449. } else {
  3450. previouslyActive = _this3.activeBeforePresentationMode;
  3451. _this3.activeBeforePresentationMode = null;
  3452. _this3.switchTool(previouslyActive);
  3453. }
  3454. });
  3455. }
  3456. }, {
  3457. key: 'activeTool',
  3458. get: function get() {
  3459. return this.active;
  3460. }
  3461. }]);
  3462. return PDFCursorTools;
  3463. }();
  3464. exports.CursorTool = CursorTool;
  3465. exports.PDFCursorTools = PDFCursorTools;
  3466. /***/ }),
  3467. /* 9 */
  3468. /***/ (function(module, exports, __webpack_require__) {
  3469. "use strict";
  3470. Object.defineProperty(exports, "__esModule", {
  3471. value: true
  3472. });
  3473. function GrabToPan(options) {
  3474. this.element = options.element;
  3475. this.document = options.element.ownerDocument;
  3476. if (typeof options.ignoreTarget === 'function') {
  3477. this.ignoreTarget = options.ignoreTarget;
  3478. }
  3479. this.onActiveChanged = options.onActiveChanged;
  3480. this.activate = this.activate.bind(this);
  3481. this.deactivate = this.deactivate.bind(this);
  3482. this.toggle = this.toggle.bind(this);
  3483. this._onmousedown = this._onmousedown.bind(this);
  3484. this._onmousemove = this._onmousemove.bind(this);
  3485. this._endPan = this._endPan.bind(this);
  3486. var overlay = this.overlay = document.createElement('div');
  3487. overlay.className = 'grab-to-pan-grabbing';
  3488. }
  3489. GrabToPan.prototype = {
  3490. CSS_CLASS_GRAB: 'grab-to-pan-grab',
  3491. activate: function GrabToPan_activate() {
  3492. if (!this.active) {
  3493. this.active = true;
  3494. this.element.addEventListener('mousedown', this._onmousedown, true);
  3495. this.element.classList.add(this.CSS_CLASS_GRAB);
  3496. if (this.onActiveChanged) {
  3497. this.onActiveChanged(true);
  3498. }
  3499. }
  3500. },
  3501. deactivate: function GrabToPan_deactivate() {
  3502. if (this.active) {
  3503. this.active = false;
  3504. this.element.removeEventListener('mousedown', this._onmousedown, true);
  3505. this._endPan();
  3506. this.element.classList.remove(this.CSS_CLASS_GRAB);
  3507. if (this.onActiveChanged) {
  3508. this.onActiveChanged(false);
  3509. }
  3510. }
  3511. },
  3512. toggle: function GrabToPan_toggle() {
  3513. if (this.active) {
  3514. this.deactivate();
  3515. } else {
  3516. this.activate();
  3517. }
  3518. },
  3519. ignoreTarget: function GrabToPan_ignoreTarget(node) {
  3520. return node[matchesSelector]('a[href], a[href] *, input, textarea, button, button *, select, option');
  3521. },
  3522. _onmousedown: function GrabToPan__onmousedown(event) {
  3523. if (event.button !== 0 || this.ignoreTarget(event.target)) {
  3524. return;
  3525. }
  3526. if (event.originalTarget) {
  3527. try {
  3528. event.originalTarget.tagName;
  3529. } catch (e) {
  3530. return;
  3531. }
  3532. }
  3533. this.scrollLeftStart = this.element.scrollLeft;
  3534. this.scrollTopStart = this.element.scrollTop;
  3535. this.clientXStart = event.clientX;
  3536. this.clientYStart = event.clientY;
  3537. this.document.addEventListener('mousemove', this._onmousemove, true);
  3538. this.document.addEventListener('mouseup', this._endPan, true);
  3539. this.element.addEventListener('scroll', this._endPan, true);
  3540. event.preventDefault();
  3541. event.stopPropagation();
  3542. var focusedElement = document.activeElement;
  3543. if (focusedElement && !focusedElement.contains(event.target)) {
  3544. focusedElement.blur();
  3545. }
  3546. },
  3547. _onmousemove: function GrabToPan__onmousemove(event) {
  3548. this.element.removeEventListener('scroll', this._endPan, true);
  3549. if (isLeftMouseReleased(event)) {
  3550. this._endPan();
  3551. return;
  3552. }
  3553. var xDiff = event.clientX - this.clientXStart;
  3554. var yDiff = event.clientY - this.clientYStart;
  3555. var scrollTop = this.scrollTopStart - yDiff;
  3556. var scrollLeft = this.scrollLeftStart - xDiff;
  3557. if (this.element.scrollTo) {
  3558. this.element.scrollTo({
  3559. top: scrollTop,
  3560. left: scrollLeft,
  3561. behavior: 'instant'
  3562. });
  3563. } else {
  3564. this.element.scrollTop = scrollTop;
  3565. this.element.scrollLeft = scrollLeft;
  3566. }
  3567. if (!this.overlay.parentNode) {
  3568. document.body.appendChild(this.overlay);
  3569. }
  3570. },
  3571. _endPan: function GrabToPan__endPan() {
  3572. this.element.removeEventListener('scroll', this._endPan, true);
  3573. this.document.removeEventListener('mousemove', this._onmousemove, true);
  3574. this.document.removeEventListener('mouseup', this._endPan, true);
  3575. this.overlay.remove();
  3576. }
  3577. };
  3578. var matchesSelector;
  3579. ['webkitM', 'mozM', 'msM', 'oM', 'm'].some(function (prefix) {
  3580. var name = prefix + 'atches';
  3581. if (name in document.documentElement) {
  3582. matchesSelector = name;
  3583. }
  3584. name += 'Selector';
  3585. if (name in document.documentElement) {
  3586. matchesSelector = name;
  3587. }
  3588. return matchesSelector;
  3589. });
  3590. var isNotIEorIsIE10plus = !document.documentMode || document.documentMode > 9;
  3591. var chrome = window.chrome;
  3592. var isChrome15OrOpera15plus = chrome && (chrome.webstore || chrome.app);
  3593. var isSafari6plus = /Apple/.test(navigator.vendor) && /Version\/([6-9]\d*|[1-5]\d+)/.test(navigator.userAgent);
  3594. function isLeftMouseReleased(event) {
  3595. if ('buttons' in event && isNotIEorIsIE10plus) {
  3596. return !(event.buttons & 1);
  3597. }
  3598. if (isChrome15OrOpera15plus || isSafari6plus) {
  3599. return event.which === 0;
  3600. }
  3601. }
  3602. exports.GrabToPan = GrabToPan;
  3603. /***/ }),
  3604. /* 10 */
  3605. /***/ (function(module, exports, __webpack_require__) {
  3606. "use strict";
  3607. Object.defineProperty(exports, "__esModule", {
  3608. value: true
  3609. });
  3610. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  3611. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3612. var CLEANUP_TIMEOUT = 30000;
  3613. var RenderingStates = {
  3614. INITIAL: 0,
  3615. RUNNING: 1,
  3616. PAUSED: 2,
  3617. FINISHED: 3
  3618. };
  3619. var PDFRenderingQueue = function () {
  3620. function PDFRenderingQueue() {
  3621. _classCallCheck(this, PDFRenderingQueue);
  3622. this.pdfViewer = null;
  3623. this.pdfThumbnailViewer = null;
  3624. this.onIdle = null;
  3625. this.highestPriorityPage = null;
  3626. this.idleTimeout = null;
  3627. this.printing = false;
  3628. this.isThumbnailViewEnabled = false;
  3629. }
  3630. _createClass(PDFRenderingQueue, [{
  3631. key: "setViewer",
  3632. value: function setViewer(pdfViewer) {
  3633. this.pdfViewer = pdfViewer;
  3634. }
  3635. }, {
  3636. key: "setThumbnailViewer",
  3637. value: function setThumbnailViewer(pdfThumbnailViewer) {
  3638. this.pdfThumbnailViewer = pdfThumbnailViewer;
  3639. }
  3640. }, {
  3641. key: "isHighestPriority",
  3642. value: function isHighestPriority(view) {
  3643. return this.highestPriorityPage === view.renderingId;
  3644. }
  3645. }, {
  3646. key: "renderHighestPriority",
  3647. value: function renderHighestPriority(currentlyVisiblePages) {
  3648. if (this.idleTimeout) {
  3649. clearTimeout(this.idleTimeout);
  3650. this.idleTimeout = null;
  3651. }
  3652. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  3653. return;
  3654. }
  3655. if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
  3656. if (this.pdfThumbnailViewer.forceRendering()) {
  3657. return;
  3658. }
  3659. }
  3660. if (this.printing) {
  3661. return;
  3662. }
  3663. if (this.onIdle) {
  3664. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
  3665. }
  3666. }
  3667. }, {
  3668. key: "getHighestPriority",
  3669. value: function getHighestPriority(visible, views, scrolledDown) {
  3670. var visibleViews = visible.views;
  3671. var numVisible = visibleViews.length;
  3672. if (numVisible === 0) {
  3673. return false;
  3674. }
  3675. for (var i = 0; i < numVisible; ++i) {
  3676. var view = visibleViews[i].view;
  3677. if (!this.isViewFinished(view)) {
  3678. return view;
  3679. }
  3680. }
  3681. if (scrolledDown) {
  3682. var nextPageIndex = visible.last.id;
  3683. if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {
  3684. return views[nextPageIndex];
  3685. }
  3686. } else {
  3687. var previousPageIndex = visible.first.id - 2;
  3688. if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) {
  3689. return views[previousPageIndex];
  3690. }
  3691. }
  3692. return null;
  3693. }
  3694. }, {
  3695. key: "isViewFinished",
  3696. value: function isViewFinished(view) {
  3697. return view.renderingState === RenderingStates.FINISHED;
  3698. }
  3699. }, {
  3700. key: "renderView",
  3701. value: function renderView(view) {
  3702. var _this = this;
  3703. switch (view.renderingState) {
  3704. case RenderingStates.FINISHED:
  3705. return false;
  3706. case RenderingStates.PAUSED:
  3707. this.highestPriorityPage = view.renderingId;
  3708. view.resume();
  3709. break;
  3710. case RenderingStates.RUNNING:
  3711. this.highestPriorityPage = view.renderingId;
  3712. break;
  3713. case RenderingStates.INITIAL:
  3714. this.highestPriorityPage = view.renderingId;
  3715. var continueRendering = function continueRendering() {
  3716. _this.renderHighestPriority();
  3717. };
  3718. view.draw().then(continueRendering, continueRendering);
  3719. break;
  3720. }
  3721. return true;
  3722. }
  3723. }]);
  3724. return PDFRenderingQueue;
  3725. }();
  3726. exports.RenderingStates = RenderingStates;
  3727. exports.PDFRenderingQueue = PDFRenderingQueue;
  3728. /***/ }),
  3729. /* 11 */
  3730. /***/ (function(module, exports, __webpack_require__) {
  3731. "use strict";
  3732. Object.defineProperty(exports, "__esModule", {
  3733. value: true
  3734. });
  3735. exports.PDFSidebar = exports.SidebarView = undefined;
  3736. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  3737. var _ui_utils = __webpack_require__(6);
  3738. var _pdf_rendering_queue = __webpack_require__(10);
  3739. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3740. var UI_NOTIFICATION_CLASS = 'pdfSidebarNotification';
  3741. var SidebarView = {
  3742. NONE: 0,
  3743. THUMBS: 1,
  3744. OUTLINE: 2,
  3745. ATTACHMENTS: 3
  3746. };
  3747. var PDFSidebar = function () {
  3748. function PDFSidebar(options, eventBus) {
  3749. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  3750. _classCallCheck(this, PDFSidebar);
  3751. this.isOpen = false;
  3752. this.active = SidebarView.THUMBS;
  3753. this.isInitialViewSet = false;
  3754. this.onToggled = null;
  3755. this.pdfViewer = options.pdfViewer;
  3756. this.pdfThumbnailViewer = options.pdfThumbnailViewer;
  3757. this.outerContainer = options.outerContainer;
  3758. this.viewerContainer = options.viewerContainer;
  3759. this.toggleButton = options.toggleButton;
  3760. this.thumbnailButton = options.thumbnailButton;
  3761. this.outlineButton = options.outlineButton;
  3762. this.attachmentsButton = options.attachmentsButton;
  3763. this.thumbnailView = options.thumbnailView;
  3764. this.outlineView = options.outlineView;
  3765. this.attachmentsView = options.attachmentsView;
  3766. this.disableNotification = options.disableNotification || false;
  3767. this.eventBus = eventBus;
  3768. this.l10n = l10n;
  3769. this._addEventListeners();
  3770. }
  3771. _createClass(PDFSidebar, [{
  3772. key: 'reset',
  3773. value: function reset() {
  3774. this.isInitialViewSet = false;
  3775. this._hideUINotification(null);
  3776. this.switchView(SidebarView.THUMBS);
  3777. this.outlineButton.disabled = false;
  3778. this.attachmentsButton.disabled = false;
  3779. }
  3780. }, {
  3781. key: 'setInitialView',
  3782. value: function setInitialView() {
  3783. var view = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : SidebarView.NONE;
  3784. if (this.isInitialViewSet) {
  3785. return;
  3786. }
  3787. this.isInitialViewSet = true;
  3788. if (this.isOpen && view === SidebarView.NONE) {
  3789. this._dispatchEvent();
  3790. return;
  3791. }
  3792. var isViewPreserved = view === this.visibleView;
  3793. this.switchView(view, true);
  3794. if (isViewPreserved) {
  3795. this._dispatchEvent();
  3796. }
  3797. }
  3798. }, {
  3799. key: 'switchView',
  3800. value: function switchView(view) {
  3801. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  3802. if (view === SidebarView.NONE) {
  3803. this.close();
  3804. return;
  3805. }
  3806. var isViewChanged = view !== this.active;
  3807. var shouldForceRendering = false;
  3808. switch (view) {
  3809. case SidebarView.THUMBS:
  3810. this.thumbnailButton.classList.add('toggled');
  3811. this.outlineButton.classList.remove('toggled');
  3812. this.attachmentsButton.classList.remove('toggled');
  3813. this.thumbnailView.classList.remove('hidden');
  3814. this.outlineView.classList.add('hidden');
  3815. this.attachmentsView.classList.add('hidden');
  3816. if (this.isOpen && isViewChanged) {
  3817. this._updateThumbnailViewer();
  3818. shouldForceRendering = true;
  3819. }
  3820. break;
  3821. case SidebarView.OUTLINE:
  3822. if (this.outlineButton.disabled) {
  3823. return;
  3824. }
  3825. this.thumbnailButton.classList.remove('toggled');
  3826. this.outlineButton.classList.add('toggled');
  3827. this.attachmentsButton.classList.remove('toggled');
  3828. this.thumbnailView.classList.add('hidden');
  3829. this.outlineView.classList.remove('hidden');
  3830. this.attachmentsView.classList.add('hidden');
  3831. break;
  3832. case SidebarView.ATTACHMENTS:
  3833. if (this.attachmentsButton.disabled) {
  3834. return;
  3835. }
  3836. this.thumbnailButton.classList.remove('toggled');
  3837. this.outlineButton.classList.remove('toggled');
  3838. this.attachmentsButton.classList.add('toggled');
  3839. this.thumbnailView.classList.add('hidden');
  3840. this.outlineView.classList.add('hidden');
  3841. this.attachmentsView.classList.remove('hidden');
  3842. break;
  3843. default:
  3844. console.error('PDFSidebar_switchView: "' + view + '" is an unsupported value.');
  3845. return;
  3846. }
  3847. this.active = view | 0;
  3848. if (forceOpen && !this.isOpen) {
  3849. this.open();
  3850. return;
  3851. }
  3852. if (shouldForceRendering) {
  3853. this._forceRendering();
  3854. }
  3855. if (isViewChanged) {
  3856. this._dispatchEvent();
  3857. }
  3858. this._hideUINotification(this.active);
  3859. }
  3860. }, {
  3861. key: 'open',
  3862. value: function open() {
  3863. if (this.isOpen) {
  3864. return;
  3865. }
  3866. this.isOpen = true;
  3867. this.toggleButton.classList.add('toggled');
  3868. this.outerContainer.classList.add('sidebarMoving');
  3869. this.outerContainer.classList.add('sidebarOpen');
  3870. if (this.active === SidebarView.THUMBS) {
  3871. this._updateThumbnailViewer();
  3872. }
  3873. this._forceRendering();
  3874. this._dispatchEvent();
  3875. this._hideUINotification(this.active);
  3876. }
  3877. }, {
  3878. key: 'close',
  3879. value: function close() {
  3880. if (!this.isOpen) {
  3881. return;
  3882. }
  3883. this.isOpen = false;
  3884. this.toggleButton.classList.remove('toggled');
  3885. this.outerContainer.classList.add('sidebarMoving');
  3886. this.outerContainer.classList.remove('sidebarOpen');
  3887. this._forceRendering();
  3888. this._dispatchEvent();
  3889. }
  3890. }, {
  3891. key: 'toggle',
  3892. value: function toggle() {
  3893. if (this.isOpen) {
  3894. this.close();
  3895. } else {
  3896. this.open();
  3897. }
  3898. }
  3899. }, {
  3900. key: '_dispatchEvent',
  3901. value: function _dispatchEvent() {
  3902. this.eventBus.dispatch('sidebarviewchanged', {
  3903. source: this,
  3904. view: this.visibleView
  3905. });
  3906. }
  3907. }, {
  3908. key: '_forceRendering',
  3909. value: function _forceRendering() {
  3910. if (this.onToggled) {
  3911. this.onToggled();
  3912. } else {
  3913. this.pdfViewer.forceRendering();
  3914. this.pdfThumbnailViewer.forceRendering();
  3915. }
  3916. }
  3917. }, {
  3918. key: '_updateThumbnailViewer',
  3919. value: function _updateThumbnailViewer() {
  3920. var pdfViewer = this.pdfViewer,
  3921. pdfThumbnailViewer = this.pdfThumbnailViewer;
  3922. var pagesCount = pdfViewer.pagesCount;
  3923. for (var pageIndex = 0; pageIndex < pagesCount; pageIndex++) {
  3924. var pageView = pdfViewer.getPageView(pageIndex);
  3925. if (pageView && pageView.renderingState === _pdf_rendering_queue.RenderingStates.FINISHED) {
  3926. var thumbnailView = pdfThumbnailViewer.getThumbnail(pageIndex);
  3927. thumbnailView.setImage(pageView);
  3928. }
  3929. }
  3930. pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
  3931. }
  3932. }, {
  3933. key: '_showUINotification',
  3934. value: function _showUINotification(view) {
  3935. var _this = this;
  3936. if (this.disableNotification) {
  3937. return;
  3938. }
  3939. this.l10n.get('toggle_sidebar_notification.title', null, 'Toggle Sidebar (document contains outline/attachments)').then(function (msg) {
  3940. _this.toggleButton.title = msg;
  3941. });
  3942. if (!this.isOpen) {
  3943. this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
  3944. } else if (view === this.active) {
  3945. return;
  3946. }
  3947. switch (view) {
  3948. case SidebarView.OUTLINE:
  3949. this.outlineButton.classList.add(UI_NOTIFICATION_CLASS);
  3950. break;
  3951. case SidebarView.ATTACHMENTS:
  3952. this.attachmentsButton.classList.add(UI_NOTIFICATION_CLASS);
  3953. break;
  3954. }
  3955. }
  3956. }, {
  3957. key: '_hideUINotification',
  3958. value: function _hideUINotification(view) {
  3959. var _this2 = this;
  3960. if (this.disableNotification) {
  3961. return;
  3962. }
  3963. var removeNotification = function removeNotification(view) {
  3964. switch (view) {
  3965. case SidebarView.OUTLINE:
  3966. _this2.outlineButton.classList.remove(UI_NOTIFICATION_CLASS);
  3967. break;
  3968. case SidebarView.ATTACHMENTS:
  3969. _this2.attachmentsButton.classList.remove(UI_NOTIFICATION_CLASS);
  3970. break;
  3971. }
  3972. };
  3973. if (!this.isOpen && view !== null) {
  3974. return;
  3975. }
  3976. this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
  3977. if (view !== null) {
  3978. removeNotification(view);
  3979. return;
  3980. }
  3981. for (view in SidebarView) {
  3982. removeNotification(SidebarView[view]);
  3983. }
  3984. this.l10n.get('toggle_sidebar.title', null, 'Toggle Sidebar').then(function (msg) {
  3985. _this2.toggleButton.title = msg;
  3986. });
  3987. }
  3988. }, {
  3989. key: '_addEventListeners',
  3990. value: function _addEventListeners() {
  3991. var _this3 = this;
  3992. this.viewerContainer.addEventListener('transitionend', function (evt) {
  3993. if (evt.target === _this3.viewerContainer) {
  3994. _this3.outerContainer.classList.remove('sidebarMoving');
  3995. }
  3996. });
  3997. this.thumbnailButton.addEventListener('click', function () {
  3998. _this3.switchView(SidebarView.THUMBS);
  3999. });
  4000. this.outlineButton.addEventListener('click', function () {
  4001. _this3.switchView(SidebarView.OUTLINE);
  4002. });
  4003. this.outlineButton.addEventListener('dblclick', function () {
  4004. _this3.eventBus.dispatch('toggleoutlinetree', { source: _this3 });
  4005. });
  4006. this.attachmentsButton.addEventListener('click', function () {
  4007. _this3.switchView(SidebarView.ATTACHMENTS);
  4008. });
  4009. this.eventBus.on('outlineloaded', function (evt) {
  4010. var outlineCount = evt.outlineCount;
  4011. _this3.outlineButton.disabled = !outlineCount;
  4012. if (outlineCount) {
  4013. _this3._showUINotification(SidebarView.OUTLINE);
  4014. } else if (_this3.active === SidebarView.OUTLINE) {
  4015. _this3.switchView(SidebarView.THUMBS);
  4016. }
  4017. });
  4018. this.eventBus.on('attachmentsloaded', function (evt) {
  4019. if (evt.attachmentsCount) {
  4020. _this3.attachmentsButton.disabled = false;
  4021. _this3._showUINotification(SidebarView.ATTACHMENTS);
  4022. return;
  4023. }
  4024. Promise.resolve().then(function () {
  4025. if (_this3.attachmentsView.hasChildNodes()) {
  4026. return;
  4027. }
  4028. _this3.attachmentsButton.disabled = true;
  4029. if (_this3.active === SidebarView.ATTACHMENTS) {
  4030. _this3.switchView(SidebarView.THUMBS);
  4031. }
  4032. });
  4033. });
  4034. this.eventBus.on('presentationmodechanged', function (evt) {
  4035. if (!evt.active && !evt.switchInProgress && _this3.isThumbnailViewVisible) {
  4036. _this3._updateThumbnailViewer();
  4037. }
  4038. });
  4039. }
  4040. }, {
  4041. key: 'visibleView',
  4042. get: function get() {
  4043. return this.isOpen ? this.active : SidebarView.NONE;
  4044. }
  4045. }, {
  4046. key: 'isThumbnailViewVisible',
  4047. get: function get() {
  4048. return this.isOpen && this.active === SidebarView.THUMBS;
  4049. }
  4050. }, {
  4051. key: 'isOutlineViewVisible',
  4052. get: function get() {
  4053. return this.isOpen && this.active === SidebarView.OUTLINE;
  4054. }
  4055. }, {
  4056. key: 'isAttachmentsViewVisible',
  4057. get: function get() {
  4058. return this.isOpen && this.active === SidebarView.ATTACHMENTS;
  4059. }
  4060. }]);
  4061. return PDFSidebar;
  4062. }();
  4063. exports.SidebarView = SidebarView;
  4064. exports.PDFSidebar = PDFSidebar;
  4065. /***/ }),
  4066. /* 12 */
  4067. /***/ (function(module, exports, __webpack_require__) {
  4068. "use strict";
  4069. Object.defineProperty(exports, "__esModule", {
  4070. value: true
  4071. });
  4072. exports.OptionKind = exports.AppOptions = undefined;
  4073. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  4074. var _pdfjsLib = __webpack_require__(7);
  4075. var _viewer_compatibility = __webpack_require__(13);
  4076. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4077. var OptionKind = {
  4078. VIEWER: 'viewer',
  4079. API: 'api',
  4080. WORKER: 'worker'
  4081. };
  4082. function getQueryString(key){
  4083. var reg = new RegExp("(^|&)"+key+"=([^&]*)(&|$)");
  4084. var result = window.location.search.substr(1).match(reg);
  4085. return result?decodeURIComponent(result[2]):null;
  4086. }
  4087. var pdfType = getQueryString('type');
  4088. var pdfUrl = '缺少文件';
  4089. if (pdfType && pdfType === 'userGuide') { //用户手册
  4090. pdfUrl = '/public/share/userGuide/userGuide.pdf';
  4091. } else if (pdfType && pdfType === 'upgradeGuide') { //升级说明
  4092. pdfUrl = '/public/share/upgradeGuide/upgradeGuide.pdf';
  4093. }
  4094. var defaultOptions = {
  4095. cursorToolOnLoad: {
  4096. value: 0,
  4097. kind: OptionKind.VIEWER
  4098. },
  4099. defaultUrl: {
  4100. value: pdfUrl,
  4101. kind: OptionKind.VIEWER
  4102. },
  4103. defaultZoomValue: {
  4104. value: '',
  4105. kind: OptionKind.VIEWER
  4106. },
  4107. disableHistory: {
  4108. value: false,
  4109. kind: OptionKind.VIEWER
  4110. },
  4111. disablePageLabels: {
  4112. value: false,
  4113. kind: OptionKind.VIEWER
  4114. },
  4115. disablePageMode: {
  4116. value: false,
  4117. kind: OptionKind.VIEWER
  4118. },
  4119. enablePrintAutoRotate: {
  4120. value: false,
  4121. kind: OptionKind.VIEWER
  4122. },
  4123. enableWebGL: {
  4124. value: false,
  4125. kind: OptionKind.VIEWER
  4126. },
  4127. eventBusDispatchToDOM: {
  4128. value: false,
  4129. kind: OptionKind.VIEWER
  4130. },
  4131. externalLinkRel: {
  4132. value: 'noopener noreferrer nofollow',
  4133. kind: OptionKind.VIEWER
  4134. },
  4135. externalLinkTarget: {
  4136. value: 0,
  4137. kind: OptionKind.VIEWER
  4138. },
  4139. imageResourcesPath: {
  4140. value: './images/',
  4141. kind: OptionKind.VIEWER
  4142. },
  4143. maxCanvasPixels: {
  4144. value: _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216,
  4145. kind: OptionKind.VIEWER
  4146. },
  4147. pdfBugEnabled: {
  4148. value: false,
  4149. kind: OptionKind.VIEWER
  4150. },
  4151. renderer: {
  4152. value: 'canvas',
  4153. kind: OptionKind.VIEWER
  4154. },
  4155. renderInteractiveForms: {
  4156. value: false,
  4157. kind: OptionKind.VIEWER
  4158. },
  4159. showPreviousViewOnLoad: {
  4160. value: true,
  4161. kind: OptionKind.VIEWER
  4162. },
  4163. sidebarViewOnLoad: {
  4164. value: 0,
  4165. kind: OptionKind.VIEWER
  4166. },
  4167. scrollModeOnLoad: {
  4168. value: 0,
  4169. kind: OptionKind.VIEWER
  4170. },
  4171. spreadModeOnLoad: {
  4172. value: 0,
  4173. kind: OptionKind.VIEWER
  4174. },
  4175. textLayerMode: {
  4176. value: 1,
  4177. kind: OptionKind.VIEWER
  4178. },
  4179. useOnlyCssZoom: {
  4180. value: false,
  4181. kind: OptionKind.VIEWER
  4182. },
  4183. cMapPacked: {
  4184. value: true,
  4185. kind: OptionKind.API
  4186. },
  4187. cMapUrl: {
  4188. value: '../web/cmaps/',
  4189. kind: OptionKind.API
  4190. },
  4191. disableAutoFetch: {
  4192. value: false,
  4193. kind: OptionKind.API
  4194. },
  4195. disableCreateObjectURL: {
  4196. value: _pdfjsLib.apiCompatibilityParams.disableCreateObjectURL || false,
  4197. kind: OptionKind.API
  4198. },
  4199. disableFontFace: {
  4200. value: false,
  4201. kind: OptionKind.API
  4202. },
  4203. disableRange: {
  4204. value: false,
  4205. kind: OptionKind.API
  4206. },
  4207. disableStream: {
  4208. value: false,
  4209. kind: OptionKind.API
  4210. },
  4211. isEvalSupported: {
  4212. value: true,
  4213. kind: OptionKind.API
  4214. },
  4215. maxImageSize: {
  4216. value: -1,
  4217. kind: OptionKind.API
  4218. },
  4219. pdfBug: {
  4220. value: false,
  4221. kind: OptionKind.API
  4222. },
  4223. postMessageTransfers: {
  4224. value: true,
  4225. kind: OptionKind.API
  4226. },
  4227. verbosity: {
  4228. value: 1,
  4229. kind: OptionKind.API
  4230. },
  4231. workerPort: {
  4232. value: null,
  4233. kind: OptionKind.WORKER
  4234. },
  4235. workerSrc: {
  4236. value: '/lib/pdfjs/pdf.worker.js',
  4237. kind: OptionKind.WORKER
  4238. }
  4239. };
  4240. {
  4241. defaultOptions.locale = {
  4242. value: typeof navigator !== 'undefined' ? navigator.language : 'en-US',
  4243. kind: OptionKind.VIEWER
  4244. };
  4245. }
  4246. var userOptions = Object.create(null);
  4247. var AppOptions = function () {
  4248. function AppOptions() {
  4249. _classCallCheck(this, AppOptions);
  4250. throw new Error('Cannot initialize AppOptions.');
  4251. }
  4252. _createClass(AppOptions, null, [{
  4253. key: 'get',
  4254. value: function get(name) {
  4255. var defaultOption = defaultOptions[name],
  4256. userOption = userOptions[name];
  4257. if (userOption !== undefined) {
  4258. return userOption;
  4259. }
  4260. return defaultOption !== undefined ? defaultOption.value : undefined;
  4261. }
  4262. }, {
  4263. key: 'getAll',
  4264. value: function getAll() {
  4265. var kind = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  4266. var options = Object.create(null);
  4267. for (var name in defaultOptions) {
  4268. var defaultOption = defaultOptions[name],
  4269. userOption = userOptions[name];
  4270. if (kind && defaultOption.kind !== kind) {
  4271. continue;
  4272. }
  4273. options[name] = userOption !== undefined ? userOption : defaultOption.value;
  4274. }
  4275. return options;
  4276. }
  4277. }, {
  4278. key: 'set',
  4279. value: function set(name, value) {
  4280. userOptions[name] = value;
  4281. }
  4282. }, {
  4283. key: 'remove',
  4284. value: function remove(name) {
  4285. delete userOptions[name];
  4286. }
  4287. }]);
  4288. return AppOptions;
  4289. }();
  4290. exports.AppOptions = AppOptions;
  4291. exports.OptionKind = OptionKind;
  4292. /***/ }),
  4293. /* 13 */
  4294. /***/ (function(module, exports, __webpack_require__) {
  4295. "use strict";
  4296. var compatibilityParams = Object.create(null);
  4297. {
  4298. var userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
  4299. var isAndroid = /Android/.test(userAgent);
  4300. var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent);
  4301. (function checkCanvasSizeLimitation() {
  4302. if (isIOS || isAndroid) {
  4303. compatibilityParams.maxCanvasPixels = 5242880;
  4304. }
  4305. })();
  4306. }
  4307. exports.viewerCompatibilityParams = Object.freeze(compatibilityParams);
  4308. /***/ }),
  4309. /* 14 */
  4310. /***/ (function(module, exports, __webpack_require__) {
  4311. "use strict";
  4312. Object.defineProperty(exports, "__esModule", {
  4313. value: true
  4314. });
  4315. exports.getGlobalEventBus = exports.attachDOMEventsToEventBus = undefined;
  4316. var _ui_utils = __webpack_require__(6);
  4317. function attachDOMEventsToEventBus(eventBus) {
  4318. eventBus.on('documentload', function () {
  4319. var event = document.createEvent('CustomEvent');
  4320. event.initCustomEvent('documentload', true, true, {});
  4321. window.dispatchEvent(event);
  4322. });
  4323. eventBus.on('pagerendered', function (evt) {
  4324. var event = document.createEvent('CustomEvent');
  4325. event.initCustomEvent('pagerendered', true, true, {
  4326. pageNumber: evt.pageNumber,
  4327. cssTransform: evt.cssTransform
  4328. });
  4329. evt.source.div.dispatchEvent(event);
  4330. });
  4331. eventBus.on('textlayerrendered', function (evt) {
  4332. var event = document.createEvent('CustomEvent');
  4333. event.initCustomEvent('textlayerrendered', true, true, { pageNumber: evt.pageNumber });
  4334. evt.source.textLayerDiv.dispatchEvent(event);
  4335. });
  4336. eventBus.on('pagechange', function (evt) {
  4337. var event = document.createEvent('UIEvents');
  4338. event.initUIEvent('pagechange', true, true, window, 0);
  4339. event.pageNumber = evt.pageNumber;
  4340. evt.source.container.dispatchEvent(event);
  4341. });
  4342. eventBus.on('pagesinit', function (evt) {
  4343. var event = document.createEvent('CustomEvent');
  4344. event.initCustomEvent('pagesinit', true, true, null);
  4345. evt.source.container.dispatchEvent(event);
  4346. });
  4347. eventBus.on('pagesloaded', function (evt) {
  4348. var event = document.createEvent('CustomEvent');
  4349. event.initCustomEvent('pagesloaded', true, true, { pagesCount: evt.pagesCount });
  4350. evt.source.container.dispatchEvent(event);
  4351. });
  4352. eventBus.on('scalechange', function (evt) {
  4353. var event = document.createEvent('UIEvents');
  4354. event.initUIEvent('scalechange', true, true, window, 0);
  4355. event.scale = evt.scale;
  4356. event.presetValue = evt.presetValue;
  4357. evt.source.container.dispatchEvent(event);
  4358. });
  4359. eventBus.on('updateviewarea', function (evt) {
  4360. var event = document.createEvent('UIEvents');
  4361. event.initUIEvent('updateviewarea', true, true, window, 0);
  4362. event.location = evt.location;
  4363. evt.source.container.dispatchEvent(event);
  4364. });
  4365. eventBus.on('find', function (evt) {
  4366. if (evt.source === window) {
  4367. return;
  4368. }
  4369. var event = document.createEvent('CustomEvent');
  4370. event.initCustomEvent('find' + evt.type, true, true, {
  4371. query: evt.query,
  4372. phraseSearch: evt.phraseSearch,
  4373. caseSensitive: evt.caseSensitive,
  4374. highlightAll: evt.highlightAll,
  4375. findPrevious: evt.findPrevious
  4376. });
  4377. window.dispatchEvent(event);
  4378. });
  4379. eventBus.on('attachmentsloaded', function (evt) {
  4380. var event = document.createEvent('CustomEvent');
  4381. event.initCustomEvent('attachmentsloaded', true, true, { attachmentsCount: evt.attachmentsCount });
  4382. evt.source.container.dispatchEvent(event);
  4383. });
  4384. eventBus.on('sidebarviewchanged', function (evt) {
  4385. var event = document.createEvent('CustomEvent');
  4386. event.initCustomEvent('sidebarviewchanged', true, true, { view: evt.view });
  4387. evt.source.outerContainer.dispatchEvent(event);
  4388. });
  4389. eventBus.on('pagemode', function (evt) {
  4390. var event = document.createEvent('CustomEvent');
  4391. event.initCustomEvent('pagemode', true, true, { mode: evt.mode });
  4392. evt.source.pdfViewer.container.dispatchEvent(event);
  4393. });
  4394. eventBus.on('namedaction', function (evt) {
  4395. var event = document.createEvent('CustomEvent');
  4396. event.initCustomEvent('namedaction', true, true, { action: evt.action });
  4397. evt.source.pdfViewer.container.dispatchEvent(event);
  4398. });
  4399. eventBus.on('presentationmodechanged', function (evt) {
  4400. var event = document.createEvent('CustomEvent');
  4401. event.initCustomEvent('presentationmodechanged', true, true, {
  4402. active: evt.active,
  4403. switchInProgress: evt.switchInProgress
  4404. });
  4405. window.dispatchEvent(event);
  4406. });
  4407. eventBus.on('outlineloaded', function (evt) {
  4408. var event = document.createEvent('CustomEvent');
  4409. event.initCustomEvent('outlineloaded', true, true, { outlineCount: evt.outlineCount });
  4410. evt.source.container.dispatchEvent(event);
  4411. });
  4412. }
  4413. var globalEventBus = null;
  4414. function getGlobalEventBus() {
  4415. var dispatchToDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4416. if (!globalEventBus) {
  4417. globalEventBus = new _ui_utils.EventBus({ dispatchToDOM: dispatchToDOM });
  4418. if (!dispatchToDOM) {
  4419. attachDOMEventsToEventBus(globalEventBus);
  4420. }
  4421. }
  4422. return globalEventBus;
  4423. }
  4424. exports.attachDOMEventsToEventBus = attachDOMEventsToEventBus;
  4425. exports.getGlobalEventBus = getGlobalEventBus;
  4426. /***/ }),
  4427. /* 15 */
  4428. /***/ (function(module, exports, __webpack_require__) {
  4429. "use strict";
  4430. Object.defineProperty(exports, "__esModule", {
  4431. value: true
  4432. });
  4433. exports.OverlayManager = undefined;
  4434. var _regenerator = __webpack_require__(2);
  4435. var _regenerator2 = _interopRequireDefault(_regenerator);
  4436. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  4437. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4438. function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
  4439. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4440. var OverlayManager = function () {
  4441. function OverlayManager() {
  4442. _classCallCheck(this, OverlayManager);
  4443. this._overlays = {};
  4444. this._active = null;
  4445. this._keyDownBound = this._keyDown.bind(this);
  4446. }
  4447. _createClass(OverlayManager, [{
  4448. key: 'register',
  4449. value: function () {
  4450. var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee(name, element) {
  4451. var callerCloseMethod = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4452. var canForceClose = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  4453. var container;
  4454. return _regenerator2.default.wrap(function _callee$(_context) {
  4455. while (1) {
  4456. switch (_context.prev = _context.next) {
  4457. case 0:
  4458. container = void 0;
  4459. if (!(!name || !element || !(container = element.parentNode))) {
  4460. _context.next = 5;
  4461. break;
  4462. }
  4463. throw new Error('Not enough parameters.');
  4464. case 5:
  4465. if (!this._overlays[name]) {
  4466. _context.next = 7;
  4467. break;
  4468. }
  4469. throw new Error('The overlay is already registered.');
  4470. case 7:
  4471. this._overlays[name] = {
  4472. element: element,
  4473. container: container,
  4474. callerCloseMethod: callerCloseMethod,
  4475. canForceClose: canForceClose
  4476. };
  4477. case 8:
  4478. case 'end':
  4479. return _context.stop();
  4480. }
  4481. }
  4482. }, _callee, this);
  4483. }));
  4484. function register(_x3, _x4) {
  4485. return _ref.apply(this, arguments);
  4486. }
  4487. return register;
  4488. }()
  4489. }, {
  4490. key: 'unregister',
  4491. value: function () {
  4492. var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2(name) {
  4493. return _regenerator2.default.wrap(function _callee2$(_context2) {
  4494. while (1) {
  4495. switch (_context2.prev = _context2.next) {
  4496. case 0:
  4497. if (this._overlays[name]) {
  4498. _context2.next = 4;
  4499. break;
  4500. }
  4501. throw new Error('The overlay does not exist.');
  4502. case 4:
  4503. if (!(this._active === name)) {
  4504. _context2.next = 6;
  4505. break;
  4506. }
  4507. throw new Error('The overlay cannot be removed while it is active.');
  4508. case 6:
  4509. delete this._overlays[name];
  4510. case 7:
  4511. case 'end':
  4512. return _context2.stop();
  4513. }
  4514. }
  4515. }, _callee2, this);
  4516. }));
  4517. function unregister(_x5) {
  4518. return _ref2.apply(this, arguments);
  4519. }
  4520. return unregister;
  4521. }()
  4522. }, {
  4523. key: 'open',
  4524. value: function () {
  4525. var _ref3 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee3(name) {
  4526. return _regenerator2.default.wrap(function _callee3$(_context3) {
  4527. while (1) {
  4528. switch (_context3.prev = _context3.next) {
  4529. case 0:
  4530. if (this._overlays[name]) {
  4531. _context3.next = 4;
  4532. break;
  4533. }
  4534. throw new Error('The overlay does not exist.');
  4535. case 4:
  4536. if (!this._active) {
  4537. _context3.next = 14;
  4538. break;
  4539. }
  4540. if (!this._overlays[name].canForceClose) {
  4541. _context3.next = 9;
  4542. break;
  4543. }
  4544. this._closeThroughCaller();
  4545. _context3.next = 14;
  4546. break;
  4547. case 9:
  4548. if (!(this._active === name)) {
  4549. _context3.next = 13;
  4550. break;
  4551. }
  4552. throw new Error('The overlay is already active.');
  4553. case 13:
  4554. throw new Error('Another overlay is currently active.');
  4555. case 14:
  4556. this._active = name;
  4557. this._overlays[this._active].element.classList.remove('hidden');
  4558. this._overlays[this._active].container.classList.remove('hidden');
  4559. window.addEventListener('keydown', this._keyDownBound);
  4560. case 18:
  4561. case 'end':
  4562. return _context3.stop();
  4563. }
  4564. }
  4565. }, _callee3, this);
  4566. }));
  4567. function open(_x6) {
  4568. return _ref3.apply(this, arguments);
  4569. }
  4570. return open;
  4571. }()
  4572. }, {
  4573. key: 'close',
  4574. value: function () {
  4575. var _ref4 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee4(name) {
  4576. return _regenerator2.default.wrap(function _callee4$(_context4) {
  4577. while (1) {
  4578. switch (_context4.prev = _context4.next) {
  4579. case 0:
  4580. if (this._overlays[name]) {
  4581. _context4.next = 4;
  4582. break;
  4583. }
  4584. throw new Error('The overlay does not exist.');
  4585. case 4:
  4586. if (this._active) {
  4587. _context4.next = 8;
  4588. break;
  4589. }
  4590. throw new Error('The overlay is currently not active.');
  4591. case 8:
  4592. if (!(this._active !== name)) {
  4593. _context4.next = 10;
  4594. break;
  4595. }
  4596. throw new Error('Another overlay is currently active.');
  4597. case 10:
  4598. this._overlays[this._active].container.classList.add('hidden');
  4599. this._overlays[this._active].element.classList.add('hidden');
  4600. this._active = null;
  4601. window.removeEventListener('keydown', this._keyDownBound);
  4602. case 14:
  4603. case 'end':
  4604. return _context4.stop();
  4605. }
  4606. }
  4607. }, _callee4, this);
  4608. }));
  4609. function close(_x7) {
  4610. return _ref4.apply(this, arguments);
  4611. }
  4612. return close;
  4613. }()
  4614. }, {
  4615. key: '_keyDown',
  4616. value: function _keyDown(evt) {
  4617. if (this._active && evt.keyCode === 27) {
  4618. this._closeThroughCaller();
  4619. evt.preventDefault();
  4620. }
  4621. }
  4622. }, {
  4623. key: '_closeThroughCaller',
  4624. value: function _closeThroughCaller() {
  4625. if (this._overlays[this._active].callerCloseMethod) {
  4626. this._overlays[this._active].callerCloseMethod();
  4627. }
  4628. if (this._active) {
  4629. this.close(this._active);
  4630. }
  4631. }
  4632. }, {
  4633. key: 'active',
  4634. get: function get() {
  4635. return this._active;
  4636. }
  4637. }]);
  4638. return OverlayManager;
  4639. }();
  4640. exports.OverlayManager = OverlayManager;
  4641. /***/ }),
  4642. /* 16 */
  4643. /***/ (function(module, exports, __webpack_require__) {
  4644. "use strict";
  4645. Object.defineProperty(exports, "__esModule", {
  4646. value: true
  4647. });
  4648. exports.PasswordPrompt = undefined;
  4649. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  4650. var _ui_utils = __webpack_require__(6);
  4651. var _pdfjsLib = __webpack_require__(7);
  4652. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4653. var PasswordPrompt = function () {
  4654. function PasswordPrompt(options, overlayManager) {
  4655. var _this = this;
  4656. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  4657. _classCallCheck(this, PasswordPrompt);
  4658. this.overlayName = options.overlayName;
  4659. this.container = options.container;
  4660. this.label = options.label;
  4661. this.input = options.input;
  4662. this.submitButton = options.submitButton;
  4663. this.cancelButton = options.cancelButton;
  4664. this.overlayManager = overlayManager;
  4665. this.l10n = l10n;
  4666. this.updateCallback = null;
  4667. this.reason = null;
  4668. this.submitButton.addEventListener('click', this.verify.bind(this));
  4669. this.cancelButton.addEventListener('click', this.close.bind(this));
  4670. this.input.addEventListener('keydown', function (e) {
  4671. if (e.keyCode === 13) {
  4672. _this.verify();
  4673. }
  4674. });
  4675. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this), true);
  4676. }
  4677. _createClass(PasswordPrompt, [{
  4678. key: 'open',
  4679. value: function open() {
  4680. var _this2 = this;
  4681. this.overlayManager.open(this.overlayName).then(function () {
  4682. _this2.input.focus();
  4683. var promptString = void 0;
  4684. if (_this2.reason === _pdfjsLib.PasswordResponses.INCORRECT_PASSWORD) {
  4685. promptString = _this2.l10n.get('password_invalid', null, 'Invalid password. Please try again.');
  4686. } else {
  4687. promptString = _this2.l10n.get('password_label', null, 'Enter the password to open this PDF file.');
  4688. }
  4689. promptString.then(function (msg) {
  4690. _this2.label.textContent = msg;
  4691. });
  4692. });
  4693. }
  4694. }, {
  4695. key: 'close',
  4696. value: function close() {
  4697. var _this3 = this;
  4698. this.overlayManager.close(this.overlayName).then(function () {
  4699. _this3.input.value = '';
  4700. });
  4701. }
  4702. }, {
  4703. key: 'verify',
  4704. value: function verify() {
  4705. var password = this.input.value;
  4706. if (password && password.length > 0) {
  4707. this.close();
  4708. return this.updateCallback(password);
  4709. }
  4710. }
  4711. }, {
  4712. key: 'setUpdateCallback',
  4713. value: function setUpdateCallback(updateCallback, reason) {
  4714. this.updateCallback = updateCallback;
  4715. this.reason = reason;
  4716. }
  4717. }]);
  4718. return PasswordPrompt;
  4719. }();
  4720. exports.PasswordPrompt = PasswordPrompt;
  4721. /***/ }),
  4722. /* 17 */
  4723. /***/ (function(module, exports, __webpack_require__) {
  4724. "use strict";
  4725. Object.defineProperty(exports, "__esModule", {
  4726. value: true
  4727. });
  4728. exports.PDFAttachmentViewer = undefined;
  4729. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  4730. var _pdfjsLib = __webpack_require__(7);
  4731. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4732. var PDFAttachmentViewer = function () {
  4733. function PDFAttachmentViewer(_ref) {
  4734. var container = _ref.container,
  4735. eventBus = _ref.eventBus,
  4736. downloadManager = _ref.downloadManager;
  4737. _classCallCheck(this, PDFAttachmentViewer);
  4738. this.container = container;
  4739. this.eventBus = eventBus;
  4740. this.downloadManager = downloadManager;
  4741. this.reset();
  4742. this.eventBus.on('fileattachmentannotation', this._appendAttachment.bind(this));
  4743. }
  4744. _createClass(PDFAttachmentViewer, [{
  4745. key: 'reset',
  4746. value: function reset() {
  4747. var keepRenderedCapability = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4748. this.attachments = null;
  4749. this.container.textContent = '';
  4750. if (!keepRenderedCapability) {
  4751. this._renderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  4752. }
  4753. }
  4754. }, {
  4755. key: '_dispatchEvent',
  4756. value: function _dispatchEvent(attachmentsCount) {
  4757. this._renderedCapability.resolve();
  4758. this.eventBus.dispatch('attachmentsloaded', {
  4759. source: this,
  4760. attachmentsCount: attachmentsCount
  4761. });
  4762. }
  4763. }, {
  4764. key: '_bindPdfLink',
  4765. value: function _bindPdfLink(button, content, filename) {
  4766. if (this.downloadManager.disableCreateObjectURL) {
  4767. throw new Error('bindPdfLink: Unsupported "disableCreateObjectURL" value.');
  4768. }
  4769. var blobUrl = void 0;
  4770. button.onclick = function () {
  4771. if (!blobUrl) {
  4772. blobUrl = (0, _pdfjsLib.createObjectURL)(content, 'application/pdf');
  4773. }
  4774. var viewerUrl = void 0;
  4775. viewerUrl = '?file=' + encodeURIComponent(blobUrl + '#' + filename);
  4776. window.open(viewerUrl);
  4777. return false;
  4778. };
  4779. }
  4780. }, {
  4781. key: '_bindLink',
  4782. value: function _bindLink(button, content, filename) {
  4783. var _this = this;
  4784. button.onclick = function () {
  4785. _this.downloadManager.downloadData(content, filename, '');
  4786. return false;
  4787. };
  4788. }
  4789. }, {
  4790. key: 'render',
  4791. value: function render(_ref2) {
  4792. var attachments = _ref2.attachments,
  4793. _ref2$keepRenderedCap = _ref2.keepRenderedCapability,
  4794. keepRenderedCapability = _ref2$keepRenderedCap === undefined ? false : _ref2$keepRenderedCap;
  4795. var attachmentsCount = 0;
  4796. if (this.attachments) {
  4797. this.reset(keepRenderedCapability === true);
  4798. }
  4799. this.attachments = attachments || null;
  4800. if (!attachments) {
  4801. this._dispatchEvent(attachmentsCount);
  4802. return;
  4803. }
  4804. var names = Object.keys(attachments).sort(function (a, b) {
  4805. return a.toLowerCase().localeCompare(b.toLowerCase());
  4806. });
  4807. attachmentsCount = names.length;
  4808. for (var i = 0; i < attachmentsCount; i++) {
  4809. var item = attachments[names[i]];
  4810. var filename = (0, _pdfjsLib.removeNullCharacters)((0, _pdfjsLib.getFilenameFromUrl)(item.filename));
  4811. var div = document.createElement('div');
  4812. div.className = 'attachmentsItem';
  4813. var button = document.createElement('button');
  4814. button.textContent = filename;
  4815. if (/\.pdf$/i.test(filename) && !this.downloadManager.disableCreateObjectURL) {
  4816. this._bindPdfLink(button, item.content, filename);
  4817. } else {
  4818. this._bindLink(button, item.content, filename);
  4819. }
  4820. div.appendChild(button);
  4821. this.container.appendChild(div);
  4822. }
  4823. this._dispatchEvent(attachmentsCount);
  4824. }
  4825. }, {
  4826. key: '_appendAttachment',
  4827. value: function _appendAttachment(_ref3) {
  4828. var _this2 = this;
  4829. var id = _ref3.id,
  4830. filename = _ref3.filename,
  4831. content = _ref3.content;
  4832. this._renderedCapability.promise.then(function () {
  4833. var attachments = _this2.attachments;
  4834. if (!attachments) {
  4835. attachments = Object.create(null);
  4836. } else {
  4837. for (var name in attachments) {
  4838. if (id === name) {
  4839. return;
  4840. }
  4841. }
  4842. }
  4843. attachments[id] = {
  4844. filename: filename,
  4845. content: content
  4846. };
  4847. _this2.render({
  4848. attachments: attachments,
  4849. keepRenderedCapability: true
  4850. });
  4851. });
  4852. }
  4853. }]);
  4854. return PDFAttachmentViewer;
  4855. }();
  4856. exports.PDFAttachmentViewer = PDFAttachmentViewer;
  4857. /***/ }),
  4858. /* 18 */
  4859. /***/ (function(module, exports, __webpack_require__) {
  4860. "use strict";
  4861. Object.defineProperty(exports, "__esModule", {
  4862. value: true
  4863. });
  4864. exports.PDFDocumentProperties = undefined;
  4865. var _slicedToArray = function () { function sliceIterator(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"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  4866. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  4867. var _ui_utils = __webpack_require__(6);
  4868. var _pdfjsLib = __webpack_require__(7);
  4869. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4870. var DEFAULT_FIELD_CONTENT = '-';
  4871. var NON_METRIC_LOCALES = ['en-us', 'en-lr', 'my'];
  4872. var US_PAGE_NAMES = {
  4873. '8.5x11': 'Letter',
  4874. '8.5x14': 'Legal'
  4875. };
  4876. var METRIC_PAGE_NAMES = {
  4877. '297x420': 'A3',
  4878. '210x297': 'A4'
  4879. };
  4880. function getPageName(size, isPortrait, pageNames) {
  4881. var width = isPortrait ? size.width : size.height;
  4882. var height = isPortrait ? size.height : size.width;
  4883. return pageNames[width + 'x' + height];
  4884. }
  4885. var PDFDocumentProperties = function () {
  4886. function PDFDocumentProperties(_ref, overlayManager, eventBus) {
  4887. var overlayName = _ref.overlayName,
  4888. fields = _ref.fields,
  4889. container = _ref.container,
  4890. closeButton = _ref.closeButton;
  4891. var _this = this;
  4892. var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
  4893. _classCallCheck(this, PDFDocumentProperties);
  4894. this.overlayName = overlayName;
  4895. this.fields = fields;
  4896. this.container = container;
  4897. this.overlayManager = overlayManager;
  4898. this.l10n = l10n;
  4899. this._reset();
  4900. if (closeButton) {
  4901. closeButton.addEventListener('click', this.close.bind(this));
  4902. }
  4903. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this));
  4904. if (eventBus) {
  4905. eventBus.on('pagechanging', function (evt) {
  4906. _this._currentPageNumber = evt.pageNumber;
  4907. });
  4908. eventBus.on('rotationchanging', function (evt) {
  4909. _this._pagesRotation = evt.pagesRotation;
  4910. });
  4911. }
  4912. this._isNonMetricLocale = true;
  4913. l10n.getLanguage().then(function (locale) {
  4914. _this._isNonMetricLocale = NON_METRIC_LOCALES.includes(locale);
  4915. });
  4916. }
  4917. _createClass(PDFDocumentProperties, [{
  4918. key: 'open',
  4919. value: function open() {
  4920. var _this2 = this;
  4921. var freezeFieldData = function freezeFieldData(data) {
  4922. Object.defineProperty(_this2, 'fieldData', {
  4923. value: Object.freeze(data),
  4924. writable: false,
  4925. enumerable: true,
  4926. configurable: true
  4927. });
  4928. };
  4929. Promise.all([this.overlayManager.open(this.overlayName), this._dataAvailableCapability.promise]).then(function () {
  4930. var currentPageNumber = _this2._currentPageNumber;
  4931. var pagesRotation = _this2._pagesRotation;
  4932. if (_this2.fieldData && currentPageNumber === _this2.fieldData['_currentPageNumber'] && pagesRotation === _this2.fieldData['_pagesRotation']) {
  4933. _this2._updateUI();
  4934. return;
  4935. }
  4936. _this2.pdfDocument.getMetadata().then(function (_ref2) {
  4937. var info = _ref2.info,
  4938. metadata = _ref2.metadata,
  4939. contentDispositionFilename = _ref2.contentDispositionFilename;
  4940. 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) {
  4941. return _this2._parsePageSize((0, _ui_utils.getPageSizeInches)(pdfPage), pagesRotation);
  4942. }), _this2._parseLinearization(info.IsLinearized)]);
  4943. }).then(function (_ref3) {
  4944. var _ref4 = _slicedToArray(_ref3, 8),
  4945. info = _ref4[0],
  4946. metadata = _ref4[1],
  4947. fileName = _ref4[2],
  4948. fileSize = _ref4[3],
  4949. creationDate = _ref4[4],
  4950. modDate = _ref4[5],
  4951. pageSize = _ref4[6],
  4952. isLinearized = _ref4[7];
  4953. freezeFieldData({
  4954. 'fileName': fileName,
  4955. 'fileSize': fileSize,
  4956. 'title': info.Title,
  4957. 'author': info.Author,
  4958. 'subject': info.Subject,
  4959. 'keywords': info.Keywords,
  4960. 'creationDate': creationDate,
  4961. 'modificationDate': modDate,
  4962. 'creator': info.Creator,
  4963. 'producer': info.Producer,
  4964. 'version': info.PDFFormatVersion,
  4965. 'pageCount': _this2.pdfDocument.numPages,
  4966. 'pageSize': pageSize,
  4967. 'linearized': isLinearized,
  4968. '_currentPageNumber': currentPageNumber,
  4969. '_pagesRotation': pagesRotation
  4970. });
  4971. _this2._updateUI();
  4972. return _this2.pdfDocument.getDownloadInfo();
  4973. }).then(function (_ref5) {
  4974. var length = _ref5.length;
  4975. _this2.maybeFileSize = length;
  4976. return _this2._parseFileSize(length);
  4977. }).then(function (fileSize) {
  4978. if (fileSize === _this2.fieldData['fileSize']) {
  4979. return;
  4980. }
  4981. var data = Object.assign(Object.create(null), _this2.fieldData);
  4982. data['fileSize'] = fileSize;
  4983. freezeFieldData(data);
  4984. _this2._updateUI();
  4985. });
  4986. });
  4987. }
  4988. }, {
  4989. key: 'close',
  4990. value: function close() {
  4991. this.overlayManager.close(this.overlayName);
  4992. }
  4993. }, {
  4994. key: 'setDocument',
  4995. value: function setDocument(pdfDocument) {
  4996. var url = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  4997. if (this.pdfDocument) {
  4998. this._reset();
  4999. this._updateUI(true);
  5000. }
  5001. if (!pdfDocument) {
  5002. return;
  5003. }
  5004. this.pdfDocument = pdfDocument;
  5005. this.url = url;
  5006. this._dataAvailableCapability.resolve();
  5007. }
  5008. }, {
  5009. key: 'setFileSize',
  5010. value: function setFileSize(fileSize) {
  5011. if (Number.isInteger(fileSize) && fileSize > 0) {
  5012. this.maybeFileSize = fileSize;
  5013. }
  5014. }
  5015. }, {
  5016. key: '_reset',
  5017. value: function _reset() {
  5018. this.pdfDocument = null;
  5019. this.url = null;
  5020. this.maybeFileSize = 0;
  5021. delete this.fieldData;
  5022. this._dataAvailableCapability = (0, _pdfjsLib.createPromiseCapability)();
  5023. this._currentPageNumber = 1;
  5024. this._pagesRotation = 0;
  5025. }
  5026. }, {
  5027. key: '_updateUI',
  5028. value: function _updateUI() {
  5029. var reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5030. if (reset || !this.fieldData) {
  5031. for (var id in this.fields) {
  5032. this.fields[id].textContent = DEFAULT_FIELD_CONTENT;
  5033. }
  5034. return;
  5035. }
  5036. if (this.overlayManager.active !== this.overlayName) {
  5037. return;
  5038. }
  5039. for (var _id in this.fields) {
  5040. var content = this.fieldData[_id];
  5041. this.fields[_id].textContent = content || content === 0 ? content : DEFAULT_FIELD_CONTENT;
  5042. }
  5043. }
  5044. }, {
  5045. key: '_parseFileSize',
  5046. value: function _parseFileSize() {
  5047. var fileSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  5048. var kb = fileSize / 1024;
  5049. if (!kb) {
  5050. return Promise.resolve(undefined);
  5051. } else if (kb < 1024) {
  5052. return this.l10n.get('document_properties_kb', {
  5053. size_kb: (+kb.toPrecision(3)).toLocaleString(),
  5054. size_b: fileSize.toLocaleString()
  5055. }, '{{size_kb}} KB ({{size_b}} bytes)');
  5056. }
  5057. return this.l10n.get('document_properties_mb', {
  5058. size_mb: (+(kb / 1024).toPrecision(3)).toLocaleString(),
  5059. size_b: fileSize.toLocaleString()
  5060. }, '{{size_mb}} MB ({{size_b}} bytes)');
  5061. }
  5062. }, {
  5063. key: '_parsePageSize',
  5064. value: function _parsePageSize(pageSizeInches, pagesRotation) {
  5065. var _this3 = this;
  5066. if (!pageSizeInches) {
  5067. return Promise.resolve(undefined);
  5068. }
  5069. if (pagesRotation % 180 !== 0) {
  5070. pageSizeInches = {
  5071. width: pageSizeInches.height,
  5072. height: pageSizeInches.width
  5073. };
  5074. }
  5075. var isPortrait = (0, _ui_utils.isPortraitOrientation)(pageSizeInches);
  5076. var sizeInches = {
  5077. width: Math.round(pageSizeInches.width * 100) / 100,
  5078. height: Math.round(pageSizeInches.height * 100) / 100
  5079. };
  5080. var sizeMillimeters = {
  5081. width: Math.round(pageSizeInches.width * 25.4 * 10) / 10,
  5082. height: Math.round(pageSizeInches.height * 25.4 * 10) / 10
  5083. };
  5084. var pageName = null;
  5085. var name = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES);
  5086. if (!name && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(sizeMillimeters.height))) {
  5087. var exactMillimeters = {
  5088. width: pageSizeInches.width * 25.4,
  5089. height: pageSizeInches.height * 25.4
  5090. };
  5091. var intMillimeters = {
  5092. width: Math.round(sizeMillimeters.width),
  5093. height: Math.round(sizeMillimeters.height)
  5094. };
  5095. if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) {
  5096. name = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES);
  5097. if (name) {
  5098. sizeInches = {
  5099. width: Math.round(intMillimeters.width / 25.4 * 100) / 100,
  5100. height: Math.round(intMillimeters.height / 25.4 * 100) / 100
  5101. };
  5102. sizeMillimeters = intMillimeters;
  5103. }
  5104. }
  5105. }
  5106. if (name) {
  5107. pageName = this.l10n.get('document_properties_page_size_name_' + name.toLowerCase(), null, name);
  5108. }
  5109. 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) {
  5110. var _ref7 = _slicedToArray(_ref6, 4),
  5111. _ref7$ = _ref7[0],
  5112. width = _ref7$.width,
  5113. height = _ref7$.height,
  5114. unit = _ref7[1],
  5115. name = _ref7[2],
  5116. orientation = _ref7[3];
  5117. return _this3.l10n.get('document_properties_page_size_dimension_' + (name ? 'name_' : '') + 'string', {
  5118. width: width.toLocaleString(),
  5119. height: height.toLocaleString(),
  5120. unit: unit,
  5121. name: name,
  5122. orientation: orientation
  5123. }, '{{width}} × {{height}} {{unit}} (' + (name ? '{{name}}, ' : '') + '{{orientation}})');
  5124. });
  5125. }
  5126. }, {
  5127. key: '_parseDate',
  5128. value: function _parseDate(inputDate) {
  5129. if (!inputDate) {
  5130. return;
  5131. }
  5132. var dateToParse = inputDate;
  5133. if (dateToParse.substring(0, 2) === 'D:') {
  5134. dateToParse = dateToParse.substring(2);
  5135. }
  5136. var year = parseInt(dateToParse.substring(0, 4), 10);
  5137. var month = parseInt(dateToParse.substring(4, 6), 10) - 1;
  5138. var day = parseInt(dateToParse.substring(6, 8), 10);
  5139. var hours = parseInt(dateToParse.substring(8, 10), 10);
  5140. var minutes = parseInt(dateToParse.substring(10, 12), 10);
  5141. var seconds = parseInt(dateToParse.substring(12, 14), 10);
  5142. var utRel = dateToParse.substring(14, 15);
  5143. var offsetHours = parseInt(dateToParse.substring(15, 17), 10);
  5144. var offsetMinutes = parseInt(dateToParse.substring(18, 20), 10);
  5145. if (utRel === '-') {
  5146. hours += offsetHours;
  5147. minutes += offsetMinutes;
  5148. } else if (utRel === '+') {
  5149. hours -= offsetHours;
  5150. minutes -= offsetMinutes;
  5151. }
  5152. var date = new Date(Date.UTC(year, month, day, hours, minutes, seconds));
  5153. var dateString = date.toLocaleDateString();
  5154. var timeString = date.toLocaleTimeString();
  5155. return this.l10n.get('document_properties_date_string', {
  5156. date: dateString,
  5157. time: timeString
  5158. }, '{{date}}, {{time}}');
  5159. }
  5160. }, {
  5161. key: '_parseLinearization',
  5162. value: function _parseLinearization(isLinearized) {
  5163. return this.l10n.get('document_properties_linearized_' + (isLinearized ? 'yes' : 'no'), null, isLinearized ? 'Yes' : 'No');
  5164. }
  5165. }]);
  5166. return PDFDocumentProperties;
  5167. }();
  5168. exports.PDFDocumentProperties = PDFDocumentProperties;
  5169. /***/ }),
  5170. /* 19 */
  5171. /***/ (function(module, exports, __webpack_require__) {
  5172. "use strict";
  5173. Object.defineProperty(exports, "__esModule", {
  5174. value: true
  5175. });
  5176. exports.PDFFindBar = undefined;
  5177. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  5178. var _ui_utils = __webpack_require__(6);
  5179. var _pdf_find_controller = __webpack_require__(20);
  5180. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5181. var MATCHES_COUNT_LIMIT = 1000;
  5182. var PDFFindBar = function () {
  5183. function PDFFindBar(options) {
  5184. var _this = this;
  5185. var eventBus = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (0, _ui_utils.getGlobalEventBus)();
  5186. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  5187. _classCallCheck(this, PDFFindBar);
  5188. this.opened = false;
  5189. this.bar = options.bar || null;
  5190. this.toggleButton = options.toggleButton || null;
  5191. this.findField = options.findField || null;
  5192. this.highlightAll = options.highlightAllCheckbox || null;
  5193. this.caseSensitive = options.caseSensitiveCheckbox || null;
  5194. this.entireWord = options.entireWordCheckbox || null;
  5195. this.findMsg = options.findMsg || null;
  5196. this.findResultsCount = options.findResultsCount || null;
  5197. this.findPreviousButton = options.findPreviousButton || null;
  5198. this.findNextButton = options.findNextButton || null;
  5199. this.eventBus = eventBus;
  5200. this.l10n = l10n;
  5201. this.toggleButton.addEventListener('click', function () {
  5202. _this.toggle();
  5203. });
  5204. this.findField.addEventListener('input', function () {
  5205. _this.dispatchEvent('');
  5206. });
  5207. this.bar.addEventListener('keydown', function (e) {
  5208. switch (e.keyCode) {
  5209. case 13:
  5210. if (e.target === _this.findField) {
  5211. _this.dispatchEvent('again', e.shiftKey);
  5212. }
  5213. break;
  5214. case 27:
  5215. _this.close();
  5216. break;
  5217. }
  5218. });
  5219. this.findPreviousButton.addEventListener('click', function () {
  5220. _this.dispatchEvent('again', true);
  5221. });
  5222. this.findNextButton.addEventListener('click', function () {
  5223. _this.dispatchEvent('again', false);
  5224. });
  5225. this.highlightAll.addEventListener('click', function () {
  5226. _this.dispatchEvent('highlightallchange');
  5227. });
  5228. this.caseSensitive.addEventListener('click', function () {
  5229. _this.dispatchEvent('casesensitivitychange');
  5230. });
  5231. this.entireWord.addEventListener('click', function () {
  5232. _this.dispatchEvent('entirewordchange');
  5233. });
  5234. this.eventBus.on('resize', this._adjustWidth.bind(this));
  5235. }
  5236. _createClass(PDFFindBar, [{
  5237. key: 'reset',
  5238. value: function reset() {
  5239. this.updateUIState();
  5240. }
  5241. }, {
  5242. key: 'dispatchEvent',
  5243. value: function dispatchEvent(type, findPrev) {
  5244. this.eventBus.dispatch('find', {
  5245. source: this,
  5246. type: type,
  5247. query: this.findField.value,
  5248. phraseSearch: true,
  5249. caseSensitive: this.caseSensitive.checked,
  5250. entireWord: this.entireWord.checked,
  5251. highlightAll: this.highlightAll.checked,
  5252. findPrevious: findPrev
  5253. });
  5254. }
  5255. }, {
  5256. key: 'updateUIState',
  5257. value: function updateUIState(state, previous, matchesCount) {
  5258. var _this2 = this;
  5259. var notFound = false;
  5260. var findMsg = '';
  5261. var status = '';
  5262. switch (state) {
  5263. case _pdf_find_controller.FindState.FOUND:
  5264. break;
  5265. case _pdf_find_controller.FindState.PENDING:
  5266. status = 'pending';
  5267. break;
  5268. case _pdf_find_controller.FindState.NOT_FOUND:
  5269. findMsg = this.l10n.get('find_not_found', null, 'Phrase not found');
  5270. notFound = true;
  5271. break;
  5272. case _pdf_find_controller.FindState.WRAPPED:
  5273. if (previous) {
  5274. findMsg = this.l10n.get('find_reached_top', null, 'Reached top of document, continued from bottom');
  5275. } else {
  5276. findMsg = this.l10n.get('find_reached_bottom', null, 'Reached end of document, continued from top');
  5277. }
  5278. break;
  5279. }
  5280. this.findField.classList.toggle('notFound', notFound);
  5281. this.findField.setAttribute('data-status', status);
  5282. Promise.resolve(findMsg).then(function (msg) {
  5283. _this2.findMsg.textContent = msg;
  5284. _this2._adjustWidth();
  5285. });
  5286. this.updateResultsCount(matchesCount);
  5287. }
  5288. }, {
  5289. key: 'updateResultsCount',
  5290. value: function updateResultsCount() {
  5291. var _this3 = this;
  5292. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  5293. _ref$current = _ref.current,
  5294. current = _ref$current === undefined ? 0 : _ref$current,
  5295. _ref$total = _ref.total,
  5296. total = _ref$total === undefined ? 0 : _ref$total;
  5297. if (!this.findResultsCount) {
  5298. return;
  5299. }
  5300. var matchesCountMsg = '',
  5301. limit = MATCHES_COUNT_LIMIT;
  5302. if (total > 0) {
  5303. if (total > limit) {
  5304. matchesCountMsg = this.l10n.get('find_match_count_limit', { limit: limit }, 'More than {{limit}} match' + (limit !== 1 ? 'es' : ''));
  5305. } else {
  5306. matchesCountMsg = this.l10n.get('find_match_count', {
  5307. current: current,
  5308. total: total
  5309. }, '{{current}} of {{total}} match' + (total !== 1 ? 'es' : ''));
  5310. }
  5311. }
  5312. Promise.resolve(matchesCountMsg).then(function (msg) {
  5313. _this3.findResultsCount.textContent = msg;
  5314. _this3.findResultsCount.classList[!total ? 'add' : 'remove']('hidden');
  5315. _this3._adjustWidth();
  5316. });
  5317. }
  5318. }, {
  5319. key: 'open',
  5320. value: function open() {
  5321. if (!this.opened) {
  5322. this.opened = true;
  5323. this.toggleButton.classList.add('toggled');
  5324. this.bar.classList.remove('hidden');
  5325. }
  5326. this.findField.select();
  5327. this.findField.focus();
  5328. this._adjustWidth();
  5329. }
  5330. }, {
  5331. key: 'close',
  5332. value: function close() {
  5333. if (!this.opened) {
  5334. return;
  5335. }
  5336. this.opened = false;
  5337. this.toggleButton.classList.remove('toggled');
  5338. this.bar.classList.add('hidden');
  5339. this.eventBus.dispatch('findbarclose', { source: this });
  5340. }
  5341. }, {
  5342. key: 'toggle',
  5343. value: function toggle() {
  5344. if (this.opened) {
  5345. this.close();
  5346. } else {
  5347. this.open();
  5348. }
  5349. }
  5350. }, {
  5351. key: '_adjustWidth',
  5352. value: function _adjustWidth() {
  5353. if (!this.opened) {
  5354. return;
  5355. }
  5356. this.bar.classList.remove('wrapContainers');
  5357. var findbarHeight = this.bar.clientHeight;
  5358. var inputContainerHeight = this.bar.firstElementChild.clientHeight;
  5359. if (findbarHeight > inputContainerHeight) {
  5360. this.bar.classList.add('wrapContainers');
  5361. }
  5362. }
  5363. }]);
  5364. return PDFFindBar;
  5365. }();
  5366. exports.PDFFindBar = PDFFindBar;
  5367. /***/ }),
  5368. /* 20 */
  5369. /***/ (function(module, exports, __webpack_require__) {
  5370. "use strict";
  5371. Object.defineProperty(exports, "__esModule", {
  5372. value: true
  5373. });
  5374. exports.PDFFindController = exports.FindState = undefined;
  5375. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  5376. var _pdfjsLib = __webpack_require__(7);
  5377. var _pdf_find_utils = __webpack_require__(21);
  5378. var _dom_events = __webpack_require__(14);
  5379. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5380. var FindState = {
  5381. FOUND: 0,
  5382. NOT_FOUND: 1,
  5383. WRAPPED: 2,
  5384. PENDING: 3
  5385. };
  5386. var FIND_TIMEOUT = 250;
  5387. var CHARACTERS_TO_NORMALIZE = {
  5388. '\u2018': '\'',
  5389. '\u2019': '\'',
  5390. '\u201A': '\'',
  5391. '\u201B': '\'',
  5392. '\u201C': '"',
  5393. '\u201D': '"',
  5394. '\u201E': '"',
  5395. '\u201F': '"',
  5396. '\xBC': '1/4',
  5397. '\xBD': '1/2',
  5398. '\xBE': '3/4'
  5399. };
  5400. var PDFFindController = function () {
  5401. function PDFFindController(_ref) {
  5402. var linkService = _ref.linkService,
  5403. _ref$eventBus = _ref.eventBus,
  5404. eventBus = _ref$eventBus === undefined ? (0, _dom_events.getGlobalEventBus)() : _ref$eventBus;
  5405. _classCallCheck(this, PDFFindController);
  5406. this._linkService = linkService;
  5407. this._eventBus = eventBus;
  5408. this._reset();
  5409. eventBus.on('findbarclose', this._onFindBarClose.bind(this));
  5410. var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join('');
  5411. this._normalizationRegex = new RegExp('[' + replace + ']', 'g');
  5412. }
  5413. _createClass(PDFFindController, [{
  5414. key: 'setDocument',
  5415. value: function setDocument(pdfDocument) {
  5416. if (this._pdfDocument) {
  5417. this._reset();
  5418. }
  5419. if (!pdfDocument) {
  5420. return;
  5421. }
  5422. this._pdfDocument = pdfDocument;
  5423. this._firstPageCapability.resolve();
  5424. }
  5425. }, {
  5426. key: 'executeCommand',
  5427. value: function executeCommand(cmd, state) {
  5428. var _this = this;
  5429. var pdfDocument = this._pdfDocument;
  5430. if (this._state === null || cmd !== 'findagain') {
  5431. this._dirtyMatch = true;
  5432. }
  5433. this._state = state;
  5434. this._updateUIState(FindState.PENDING);
  5435. this._firstPageCapability.promise.then(function () {
  5436. if (!_this._pdfDocument || pdfDocument && _this._pdfDocument !== pdfDocument) {
  5437. return;
  5438. }
  5439. _this._extractText();
  5440. if (_this._findTimeout) {
  5441. clearTimeout(_this._findTimeout);
  5442. _this._findTimeout = null;
  5443. }
  5444. if (cmd === 'find') {
  5445. _this._findTimeout = setTimeout(function () {
  5446. _this._nextMatch();
  5447. _this._findTimeout = null;
  5448. }, FIND_TIMEOUT);
  5449. } else {
  5450. _this._nextMatch();
  5451. }
  5452. });
  5453. }
  5454. }, {
  5455. key: '_reset',
  5456. value: function _reset() {
  5457. this._highlightMatches = false;
  5458. this._pdfDocument = null;
  5459. this._pageMatches = [];
  5460. this._pageMatchesLength = null;
  5461. this._state = null;
  5462. this._selected = {
  5463. pageIdx: -1,
  5464. matchIdx: -1
  5465. };
  5466. this._offset = {
  5467. pageIdx: null,
  5468. matchIdx: null
  5469. };
  5470. this._extractTextPromises = [];
  5471. this._pageContents = [];
  5472. this._matchesCountTotal = 0;
  5473. this._pagesToSearch = null;
  5474. this._pendingFindMatches = Object.create(null);
  5475. this._resumePageIdx = null;
  5476. this._dirtyMatch = false;
  5477. clearTimeout(this._findTimeout);
  5478. this._findTimeout = null;
  5479. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  5480. }
  5481. }, {
  5482. key: '_normalize',
  5483. value: function _normalize(text) {
  5484. return text.replace(this._normalizationRegex, function (ch) {
  5485. return CHARACTERS_TO_NORMALIZE[ch];
  5486. });
  5487. }
  5488. }, {
  5489. key: '_prepareMatches',
  5490. value: function _prepareMatches(matchesWithLength, matches, matchesLength) {
  5491. function isSubTerm(matchesWithLength, currentIndex) {
  5492. var currentElem = matchesWithLength[currentIndex];
  5493. var nextElem = matchesWithLength[currentIndex + 1];
  5494. if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {
  5495. currentElem.skipped = true;
  5496. return true;
  5497. }
  5498. for (var i = currentIndex - 1; i >= 0; i--) {
  5499. var prevElem = matchesWithLength[i];
  5500. if (prevElem.skipped) {
  5501. continue;
  5502. }
  5503. if (prevElem.match + prevElem.matchLength < currentElem.match) {
  5504. break;
  5505. }
  5506. if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {
  5507. currentElem.skipped = true;
  5508. return true;
  5509. }
  5510. }
  5511. return false;
  5512. }
  5513. matchesWithLength.sort(function (a, b) {
  5514. return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match;
  5515. });
  5516. for (var i = 0, len = matchesWithLength.length; i < len; i++) {
  5517. if (isSubTerm(matchesWithLength, i)) {
  5518. continue;
  5519. }
  5520. matches.push(matchesWithLength[i].match);
  5521. matchesLength.push(matchesWithLength[i].matchLength);
  5522. }
  5523. }
  5524. }, {
  5525. key: '_isEntireWord',
  5526. value: function _isEntireWord(content, startIdx, length) {
  5527. if (startIdx > 0) {
  5528. var first = content.charCodeAt(startIdx);
  5529. var limit = content.charCodeAt(startIdx - 1);
  5530. if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils.getCharacterType)(limit)) {
  5531. return false;
  5532. }
  5533. }
  5534. var endIdx = startIdx + length - 1;
  5535. if (endIdx < content.length - 1) {
  5536. var last = content.charCodeAt(endIdx);
  5537. var _limit = content.charCodeAt(endIdx + 1);
  5538. if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils.getCharacterType)(_limit)) {
  5539. return false;
  5540. }
  5541. }
  5542. return true;
  5543. }
  5544. }, {
  5545. key: '_calculatePhraseMatch',
  5546. value: function _calculatePhraseMatch(query, pageIndex, pageContent, entireWord) {
  5547. var matches = [];
  5548. var queryLen = query.length;
  5549. var matchIdx = -queryLen;
  5550. while (true) {
  5551. matchIdx = pageContent.indexOf(query, matchIdx + queryLen);
  5552. if (matchIdx === -1) {
  5553. break;
  5554. }
  5555. if (entireWord && !this._isEntireWord(pageContent, matchIdx, queryLen)) {
  5556. continue;
  5557. }
  5558. matches.push(matchIdx);
  5559. }
  5560. this._pageMatches[pageIndex] = matches;
  5561. }
  5562. }, {
  5563. key: '_calculateWordMatch',
  5564. value: function _calculateWordMatch(query, pageIndex, pageContent, entireWord) {
  5565. var matchesWithLength = [];
  5566. var queryArray = query.match(/\S+/g);
  5567. for (var i = 0, len = queryArray.length; i < len; i++) {
  5568. var subquery = queryArray[i];
  5569. var subqueryLen = subquery.length;
  5570. var matchIdx = -subqueryLen;
  5571. while (true) {
  5572. matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen);
  5573. if (matchIdx === -1) {
  5574. break;
  5575. }
  5576. if (entireWord && !this._isEntireWord(pageContent, matchIdx, subqueryLen)) {
  5577. continue;
  5578. }
  5579. matchesWithLength.push({
  5580. match: matchIdx,
  5581. matchLength: subqueryLen,
  5582. skipped: false
  5583. });
  5584. }
  5585. }
  5586. if (!this._pageMatchesLength) {
  5587. this._pageMatchesLength = [];
  5588. }
  5589. this._pageMatchesLength[pageIndex] = [];
  5590. this._pageMatches[pageIndex] = [];
  5591. this._prepareMatches(matchesWithLength, this._pageMatches[pageIndex], this._pageMatchesLength[pageIndex]);
  5592. }
  5593. }, {
  5594. key: '_calculateMatch',
  5595. value: function _calculateMatch(pageIndex) {
  5596. var pageContent = this._normalize(this._pageContents[pageIndex]);
  5597. var query = this._normalize(this._state.query);
  5598. var _state = this._state,
  5599. caseSensitive = _state.caseSensitive,
  5600. entireWord = _state.entireWord,
  5601. phraseSearch = _state.phraseSearch;
  5602. if (query.length === 0) {
  5603. return;
  5604. }
  5605. if (!caseSensitive) {
  5606. pageContent = pageContent.toLowerCase();
  5607. query = query.toLowerCase();
  5608. }
  5609. if (phraseSearch) {
  5610. this._calculatePhraseMatch(query, pageIndex, pageContent, entireWord);
  5611. } else {
  5612. this._calculateWordMatch(query, pageIndex, pageContent, entireWord);
  5613. }
  5614. this._updatePage(pageIndex);
  5615. if (this._resumePageIdx === pageIndex) {
  5616. this._resumePageIdx = null;
  5617. this._nextPageMatch();
  5618. }
  5619. var pageMatchesCount = this._pageMatches[pageIndex].length;
  5620. if (pageMatchesCount > 0) {
  5621. this._matchesCountTotal += pageMatchesCount;
  5622. this._updateUIResultsCount();
  5623. }
  5624. }
  5625. }, {
  5626. key: '_extractText',
  5627. value: function _extractText() {
  5628. var _this2 = this;
  5629. if (this._extractTextPromises.length > 0) {
  5630. return;
  5631. }
  5632. var promise = Promise.resolve();
  5633. var _loop = function _loop(i, ii) {
  5634. var extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
  5635. _this2._extractTextPromises[i] = extractTextCapability.promise;
  5636. promise = promise.then(function () {
  5637. return _this2._pdfDocument.getPage(i + 1).then(function (pdfPage) {
  5638. return pdfPage.getTextContent({ normalizeWhitespace: true });
  5639. }).then(function (textContent) {
  5640. var textItems = textContent.items;
  5641. var strBuf = [];
  5642. for (var j = 0, jj = textItems.length; j < jj; j++) {
  5643. strBuf.push(textItems[j].str);
  5644. }
  5645. _this2._pageContents[i] = strBuf.join('');
  5646. extractTextCapability.resolve(i);
  5647. }, function (reason) {
  5648. console.error('Unable to get text content for page ' + (i + 1), reason);
  5649. _this2._pageContents[i] = '';
  5650. extractTextCapability.resolve(i);
  5651. });
  5652. });
  5653. };
  5654. for (var i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
  5655. _loop(i, ii);
  5656. }
  5657. }
  5658. }, {
  5659. key: '_updatePage',
  5660. value: function _updatePage(index) {
  5661. if (this._selected.pageIdx === index) {
  5662. this._linkService.page = index + 1;
  5663. }
  5664. this._eventBus.dispatch('updatetextlayermatches', {
  5665. source: this,
  5666. pageIndex: index
  5667. });
  5668. }
  5669. }, {
  5670. key: '_nextMatch',
  5671. value: function _nextMatch() {
  5672. var _this3 = this;
  5673. var previous = this._state.findPrevious;
  5674. var currentPageIndex = this._linkService.page - 1;
  5675. var numPages = this._linkService.pagesCount;
  5676. this._highlightMatches = true;
  5677. if (this._dirtyMatch) {
  5678. this._dirtyMatch = false;
  5679. this._selected.pageIdx = this._selected.matchIdx = -1;
  5680. this._offset.pageIdx = currentPageIndex;
  5681. this._offset.matchIdx = null;
  5682. this._resumePageIdx = null;
  5683. this._pageMatches.length = 0;
  5684. this._pageMatchesLength = null;
  5685. this._matchesCountTotal = 0;
  5686. for (var i = 0; i < numPages; i++) {
  5687. this._updatePage(i);
  5688. if (!(i in this._pendingFindMatches)) {
  5689. this._pendingFindMatches[i] = true;
  5690. this._extractTextPromises[i].then(function (pageIdx) {
  5691. delete _this3._pendingFindMatches[pageIdx];
  5692. _this3._calculateMatch(pageIdx);
  5693. });
  5694. }
  5695. }
  5696. }
  5697. if (this._state.query === '') {
  5698. this._updateUIState(FindState.FOUND);
  5699. return;
  5700. }
  5701. if (this._resumePageIdx) {
  5702. return;
  5703. }
  5704. var offset = this._offset;
  5705. this._pagesToSearch = numPages;
  5706. if (offset.matchIdx !== null) {
  5707. var numPageMatches = this._pageMatches[offset.pageIdx].length;
  5708. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  5709. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  5710. this._updateMatch(true);
  5711. return;
  5712. }
  5713. this._advanceOffsetPage(previous);
  5714. }
  5715. this._nextPageMatch();
  5716. }
  5717. }, {
  5718. key: '_matchesReady',
  5719. value: function _matchesReady(matches) {
  5720. var offset = this._offset;
  5721. var numMatches = matches.length;
  5722. var previous = this._state.findPrevious;
  5723. if (numMatches) {
  5724. offset.matchIdx = previous ? numMatches - 1 : 0;
  5725. this._updateMatch(true);
  5726. return true;
  5727. }
  5728. this._advanceOffsetPage(previous);
  5729. if (offset.wrapped) {
  5730. offset.matchIdx = null;
  5731. if (this._pagesToSearch < 0) {
  5732. this._updateMatch(false);
  5733. return true;
  5734. }
  5735. }
  5736. return false;
  5737. }
  5738. }, {
  5739. key: '_nextPageMatch',
  5740. value: function _nextPageMatch() {
  5741. if (this._resumePageIdx !== null) {
  5742. console.error('There can only be one pending page.');
  5743. }
  5744. var matches = null;
  5745. do {
  5746. var pageIdx = this._offset.pageIdx;
  5747. matches = this._pageMatches[pageIdx];
  5748. if (!matches) {
  5749. this._resumePageIdx = pageIdx;
  5750. break;
  5751. }
  5752. } while (!this._matchesReady(matches));
  5753. }
  5754. }, {
  5755. key: '_advanceOffsetPage',
  5756. value: function _advanceOffsetPage(previous) {
  5757. var offset = this._offset;
  5758. var numPages = this._linkService.pagesCount;
  5759. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  5760. offset.matchIdx = null;
  5761. this._pagesToSearch--;
  5762. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  5763. offset.pageIdx = previous ? numPages - 1 : 0;
  5764. offset.wrapped = true;
  5765. }
  5766. }
  5767. }, {
  5768. key: '_updateMatch',
  5769. value: function _updateMatch() {
  5770. var found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5771. var state = FindState.NOT_FOUND;
  5772. var wrapped = this._offset.wrapped;
  5773. this._offset.wrapped = false;
  5774. if (found) {
  5775. var previousPage = this._selected.pageIdx;
  5776. this._selected.pageIdx = this._offset.pageIdx;
  5777. this._selected.matchIdx = this._offset.matchIdx;
  5778. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  5779. if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {
  5780. this._updatePage(previousPage);
  5781. }
  5782. }
  5783. this._updateUIState(state, this._state.findPrevious);
  5784. if (this._selected.pageIdx !== -1) {
  5785. this._updatePage(this._selected.pageIdx);
  5786. }
  5787. }
  5788. }, {
  5789. key: '_onFindBarClose',
  5790. value: function _onFindBarClose(evt) {
  5791. var _this4 = this;
  5792. var pdfDocument = this._pdfDocument;
  5793. this._firstPageCapability.promise.then(function () {
  5794. if (!_this4._pdfDocument || pdfDocument && _this4._pdfDocument !== pdfDocument) {
  5795. return;
  5796. }
  5797. if (_this4._findTimeout) {
  5798. clearTimeout(_this4._findTimeout);
  5799. _this4._findTimeout = null;
  5800. _this4._updateUIState(FindState.FOUND);
  5801. }
  5802. _this4._highlightMatches = false;
  5803. _this4._eventBus.dispatch('updatetextlayermatches', {
  5804. source: _this4,
  5805. pageIndex: -1
  5806. });
  5807. });
  5808. }
  5809. }, {
  5810. key: '_requestMatchesCount',
  5811. value: function _requestMatchesCount() {
  5812. var _selected = this._selected,
  5813. pageIdx = _selected.pageIdx,
  5814. matchIdx = _selected.matchIdx;
  5815. var current = 0,
  5816. total = this._matchesCountTotal;
  5817. if (matchIdx !== -1) {
  5818. for (var i = 0; i < pageIdx; i++) {
  5819. current += this._pageMatches[i] && this._pageMatches[i].length || 0;
  5820. }
  5821. current += matchIdx + 1;
  5822. }
  5823. if (current < 1 || current > total) {
  5824. current = total = 0;
  5825. }
  5826. return {
  5827. current: current,
  5828. total: total
  5829. };
  5830. }
  5831. }, {
  5832. key: '_updateUIResultsCount',
  5833. value: function _updateUIResultsCount() {
  5834. this._eventBus.dispatch('updatefindmatchescount', {
  5835. source: this,
  5836. matchesCount: this._requestMatchesCount()
  5837. });
  5838. }
  5839. }, {
  5840. key: '_updateUIState',
  5841. value: function _updateUIState(state, previous) {
  5842. this._eventBus.dispatch('updatefindcontrolstate', {
  5843. source: this,
  5844. state: state,
  5845. previous: previous,
  5846. matchesCount: this._requestMatchesCount()
  5847. });
  5848. }
  5849. }, {
  5850. key: 'highlightMatches',
  5851. get: function get() {
  5852. return this._highlightMatches;
  5853. }
  5854. }, {
  5855. key: 'pageMatches',
  5856. get: function get() {
  5857. return this._pageMatches;
  5858. }
  5859. }, {
  5860. key: 'pageMatchesLength',
  5861. get: function get() {
  5862. return this._pageMatchesLength;
  5863. }
  5864. }, {
  5865. key: 'selected',
  5866. get: function get() {
  5867. return this._selected;
  5868. }
  5869. }, {
  5870. key: 'state',
  5871. get: function get() {
  5872. return this._state;
  5873. }
  5874. }]);
  5875. return PDFFindController;
  5876. }();
  5877. exports.FindState = FindState;
  5878. exports.PDFFindController = PDFFindController;
  5879. /***/ }),
  5880. /* 21 */
  5881. /***/ (function(module, exports, __webpack_require__) {
  5882. "use strict";
  5883. Object.defineProperty(exports, "__esModule", {
  5884. value: true
  5885. });
  5886. var CharacterType = {
  5887. SPACE: 0,
  5888. ALPHA_LETTER: 1,
  5889. PUNCT: 2,
  5890. HAN_LETTER: 3,
  5891. KATAKANA_LETTER: 4,
  5892. HIRAGANA_LETTER: 5,
  5893. HALFWIDTH_KATAKANA_LETTER: 6,
  5894. THAI_LETTER: 7
  5895. };
  5896. function isAlphabeticalScript(charCode) {
  5897. return charCode < 0x2E80;
  5898. }
  5899. function isAscii(charCode) {
  5900. return (charCode & 0xFF80) === 0;
  5901. }
  5902. function isAsciiAlpha(charCode) {
  5903. return charCode >= 0x61 && charCode <= 0x7A || charCode >= 0x41 && charCode <= 0x5A;
  5904. }
  5905. function isAsciiDigit(charCode) {
  5906. return charCode >= 0x30 && charCode <= 0x39;
  5907. }
  5908. function isAsciiSpace(charCode) {
  5909. return charCode === 0x20 || charCode === 0x09 || charCode === 0x0D || charCode === 0x0A;
  5910. }
  5911. function isHan(charCode) {
  5912. return charCode >= 0x3400 && charCode <= 0x9FFF || charCode >= 0xF900 && charCode <= 0xFAFF;
  5913. }
  5914. function isKatakana(charCode) {
  5915. return charCode >= 0x30A0 && charCode <= 0x30FF;
  5916. }
  5917. function isHiragana(charCode) {
  5918. return charCode >= 0x3040 && charCode <= 0x309F;
  5919. }
  5920. function isHalfwidthKatakana(charCode) {
  5921. return charCode >= 0xFF60 && charCode <= 0xFF9F;
  5922. }
  5923. function isThai(charCode) {
  5924. return (charCode & 0xFF80) === 0x0E00;
  5925. }
  5926. function getCharacterType(charCode) {
  5927. if (isAlphabeticalScript(charCode)) {
  5928. if (isAscii(charCode)) {
  5929. if (isAsciiSpace(charCode)) {
  5930. return CharacterType.SPACE;
  5931. } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5F) {
  5932. return CharacterType.ALPHA_LETTER;
  5933. }
  5934. return CharacterType.PUNCT;
  5935. } else if (isThai(charCode)) {
  5936. return CharacterType.THAI_LETTER;
  5937. } else if (charCode === 0xA0) {
  5938. return CharacterType.SPACE;
  5939. }
  5940. return CharacterType.ALPHA_LETTER;
  5941. }
  5942. if (isHan(charCode)) {
  5943. return CharacterType.HAN_LETTER;
  5944. } else if (isKatakana(charCode)) {
  5945. return CharacterType.KATAKANA_LETTER;
  5946. } else if (isHiragana(charCode)) {
  5947. return CharacterType.HIRAGANA_LETTER;
  5948. } else if (isHalfwidthKatakana(charCode)) {
  5949. return CharacterType.HALFWIDTH_KATAKANA_LETTER;
  5950. }
  5951. return CharacterType.ALPHA_LETTER;
  5952. }
  5953. exports.CharacterType = CharacterType;
  5954. exports.getCharacterType = getCharacterType;
  5955. /***/ }),
  5956. /* 22 */
  5957. /***/ (function(module, exports, __webpack_require__) {
  5958. "use strict";
  5959. Object.defineProperty(exports, "__esModule", {
  5960. value: true
  5961. });
  5962. exports.isDestArraysEqual = exports.isDestHashesEqual = exports.PDFHistory = undefined;
  5963. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  5964. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  5965. var _ui_utils = __webpack_require__(6);
  5966. var _dom_events = __webpack_require__(14);
  5967. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5968. var HASH_CHANGE_TIMEOUT = 1000;
  5969. var POSITION_UPDATED_THRESHOLD = 50;
  5970. var UPDATE_VIEWAREA_TIMEOUT = 1000;
  5971. function getCurrentHash() {
  5972. return document.location.hash;
  5973. }
  5974. function parseCurrentHash(linkService) {
  5975. var hash = unescape(getCurrentHash()).substring(1);
  5976. var params = (0, _ui_utils.parseQueryString)(hash);
  5977. var page = params.page | 0;
  5978. if (!(Number.isInteger(page) && page > 0 && page <= linkService.pagesCount)) {
  5979. page = null;
  5980. }
  5981. return {
  5982. hash: hash,
  5983. page: page,
  5984. rotation: linkService.rotation
  5985. };
  5986. }
  5987. var PDFHistory = function () {
  5988. function PDFHistory(_ref) {
  5989. var _this = this;
  5990. var linkService = _ref.linkService,
  5991. eventBus = _ref.eventBus;
  5992. _classCallCheck(this, PDFHistory);
  5993. this.linkService = linkService;
  5994. this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)();
  5995. this.initialized = false;
  5996. this.initialBookmark = null;
  5997. this.initialRotation = null;
  5998. this._boundEvents = Object.create(null);
  5999. this._isViewerInPresentationMode = false;
  6000. this._isPagesLoaded = false;
  6001. this.eventBus.on('presentationmodechanged', function (evt) {
  6002. _this._isViewerInPresentationMode = evt.active || evt.switchInProgress;
  6003. });
  6004. this.eventBus.on('pagesloaded', function (evt) {
  6005. _this._isPagesLoaded = !!evt.pagesCount;
  6006. });
  6007. }
  6008. _createClass(PDFHistory, [{
  6009. key: 'initialize',
  6010. value: function initialize(fingerprint) {
  6011. var resetHistory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6012. if (!fingerprint || typeof fingerprint !== 'string') {
  6013. console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
  6014. return;
  6015. }
  6016. var reInitialized = this.initialized && this.fingerprint !== fingerprint;
  6017. this.fingerprint = fingerprint;
  6018. if (!this.initialized) {
  6019. this._bindEvents();
  6020. }
  6021. var state = window.history.state;
  6022. this.initialized = true;
  6023. this.initialBookmark = null;
  6024. this.initialRotation = null;
  6025. this._popStateInProgress = false;
  6026. this._blockHashChange = 0;
  6027. this._currentHash = getCurrentHash();
  6028. this._numPositionUpdates = 0;
  6029. this._uid = this._maxUid = 0;
  6030. this._destination = null;
  6031. this._position = null;
  6032. if (!this._isValidState(state) || resetHistory) {
  6033. var _parseCurrentHash = parseCurrentHash(this.linkService),
  6034. hash = _parseCurrentHash.hash,
  6035. page = _parseCurrentHash.page,
  6036. rotation = _parseCurrentHash.rotation;
  6037. if (!hash || reInitialized || resetHistory) {
  6038. this._pushOrReplaceState(null, true);
  6039. return;
  6040. }
  6041. this._pushOrReplaceState({
  6042. hash: hash,
  6043. page: page,
  6044. rotation: rotation
  6045. }, true);
  6046. return;
  6047. }
  6048. var destination = state.destination;
  6049. this._updateInternalState(destination, state.uid, true);
  6050. if (this._uid > this._maxUid) {
  6051. this._maxUid = this._uid;
  6052. }
  6053. if (destination.rotation !== undefined) {
  6054. this.initialRotation = destination.rotation;
  6055. }
  6056. if (destination.dest) {
  6057. this.initialBookmark = JSON.stringify(destination.dest);
  6058. this._destination.page = null;
  6059. } else if (destination.hash) {
  6060. this.initialBookmark = destination.hash;
  6061. } else if (destination.page) {
  6062. this.initialBookmark = 'page=' + destination.page;
  6063. }
  6064. }
  6065. }, {
  6066. key: 'push',
  6067. value: function push(_ref2) {
  6068. var _this2 = this;
  6069. var namedDest = _ref2.namedDest,
  6070. explicitDest = _ref2.explicitDest,
  6071. pageNumber = _ref2.pageNumber;
  6072. if (!this.initialized) {
  6073. return;
  6074. }
  6075. if (namedDest && typeof namedDest !== 'string' || !Array.isArray(explicitDest) || !(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {
  6076. console.error('PDFHistory.push: Invalid parameters.');
  6077. return;
  6078. }
  6079. var hash = namedDest || JSON.stringify(explicitDest);
  6080. if (!hash) {
  6081. return;
  6082. }
  6083. var forceReplace = false;
  6084. if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
  6085. if (this._destination.page) {
  6086. return;
  6087. }
  6088. forceReplace = true;
  6089. }
  6090. if (this._popStateInProgress && !forceReplace) {
  6091. return;
  6092. }
  6093. this._pushOrReplaceState({
  6094. dest: explicitDest,
  6095. hash: hash,
  6096. page: pageNumber,
  6097. rotation: this.linkService.rotation
  6098. }, forceReplace);
  6099. if (!this._popStateInProgress) {
  6100. this._popStateInProgress = true;
  6101. Promise.resolve().then(function () {
  6102. _this2._popStateInProgress = false;
  6103. });
  6104. }
  6105. }
  6106. }, {
  6107. key: 'pushCurrentPosition',
  6108. value: function pushCurrentPosition() {
  6109. if (!this.initialized || this._popStateInProgress) {
  6110. return;
  6111. }
  6112. this._tryPushCurrentPosition();
  6113. }
  6114. }, {
  6115. key: 'back',
  6116. value: function back() {
  6117. if (!this.initialized || this._popStateInProgress) {
  6118. return;
  6119. }
  6120. var state = window.history.state;
  6121. if (this._isValidState(state) && state.uid > 0) {
  6122. window.history.back();
  6123. }
  6124. }
  6125. }, {
  6126. key: 'forward',
  6127. value: function forward() {
  6128. if (!this.initialized || this._popStateInProgress) {
  6129. return;
  6130. }
  6131. var state = window.history.state;
  6132. if (this._isValidState(state) && state.uid < this._maxUid) {
  6133. window.history.forward();
  6134. }
  6135. }
  6136. }, {
  6137. key: '_pushOrReplaceState',
  6138. value: function _pushOrReplaceState(destination) {
  6139. var forceReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6140. var shouldReplace = forceReplace || !this._destination;
  6141. var newState = {
  6142. fingerprint: this.fingerprint,
  6143. uid: shouldReplace ? this._uid : this._uid + 1,
  6144. destination: destination
  6145. };
  6146. this._updateInternalState(destination, newState.uid);
  6147. if (shouldReplace) {
  6148. window.history.replaceState(newState, '');
  6149. } else {
  6150. this._maxUid = this._uid;
  6151. window.history.pushState(newState, '');
  6152. }
  6153. }
  6154. }, {
  6155. key: '_tryPushCurrentPosition',
  6156. value: function _tryPushCurrentPosition() {
  6157. var temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6158. if (!this._position) {
  6159. return;
  6160. }
  6161. var position = this._position;
  6162. if (temporary) {
  6163. position = Object.assign(Object.create(null), this._position);
  6164. position.temporary = true;
  6165. }
  6166. if (!this._destination) {
  6167. this._pushOrReplaceState(position);
  6168. return;
  6169. }
  6170. if (this._destination.temporary) {
  6171. this._pushOrReplaceState(position, true);
  6172. return;
  6173. }
  6174. if (this._destination.hash === position.hash) {
  6175. return;
  6176. }
  6177. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  6178. return;
  6179. }
  6180. var forceReplace = false;
  6181. if (this._destination.page === position.first || this._destination.page === position.page) {
  6182. if (this._destination.dest || !this._destination.first) {
  6183. return;
  6184. }
  6185. forceReplace = true;
  6186. }
  6187. this._pushOrReplaceState(position, forceReplace);
  6188. }
  6189. }, {
  6190. key: '_isValidState',
  6191. value: function _isValidState(state) {
  6192. if (!state) {
  6193. return false;
  6194. }
  6195. if (state.fingerprint !== this.fingerprint) {
  6196. return false;
  6197. }
  6198. if (!Number.isInteger(state.uid) || state.uid < 0) {
  6199. return false;
  6200. }
  6201. if (state.destination === null || _typeof(state.destination) !== 'object') {
  6202. return false;
  6203. }
  6204. return true;
  6205. }
  6206. }, {
  6207. key: '_updateInternalState',
  6208. value: function _updateInternalState(destination, uid) {
  6209. var removeTemporary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  6210. if (this._updateViewareaTimeout) {
  6211. clearTimeout(this._updateViewareaTimeout);
  6212. this._updateViewareaTimeout = null;
  6213. }
  6214. if (removeTemporary && destination && destination.temporary) {
  6215. delete destination.temporary;
  6216. }
  6217. this._destination = destination;
  6218. this._uid = uid;
  6219. this._numPositionUpdates = 0;
  6220. }
  6221. }, {
  6222. key: '_updateViewarea',
  6223. value: function _updateViewarea(_ref3) {
  6224. var _this3 = this;
  6225. var location = _ref3.location;
  6226. if (this._updateViewareaTimeout) {
  6227. clearTimeout(this._updateViewareaTimeout);
  6228. this._updateViewareaTimeout = null;
  6229. }
  6230. this._position = {
  6231. hash: this._isViewerInPresentationMode ? 'page=' + location.pageNumber : location.pdfOpenParams.substring(1),
  6232. page: this.linkService.page,
  6233. first: location.pageNumber,
  6234. rotation: location.rotation
  6235. };
  6236. if (this._popStateInProgress) {
  6237. return;
  6238. }
  6239. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
  6240. this._numPositionUpdates++;
  6241. }
  6242. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  6243. this._updateViewareaTimeout = setTimeout(function () {
  6244. if (!_this3._popStateInProgress) {
  6245. _this3._tryPushCurrentPosition(true);
  6246. }
  6247. _this3._updateViewareaTimeout = null;
  6248. }, UPDATE_VIEWAREA_TIMEOUT);
  6249. }
  6250. }
  6251. }, {
  6252. key: '_popState',
  6253. value: function _popState(_ref4) {
  6254. var _this4 = this;
  6255. var state = _ref4.state;
  6256. var newHash = getCurrentHash(),
  6257. hashChanged = this._currentHash !== newHash;
  6258. this._currentHash = newHash;
  6259. if (!state || false) {
  6260. this._uid++;
  6261. var _parseCurrentHash2 = parseCurrentHash(this.linkService),
  6262. hash = _parseCurrentHash2.hash,
  6263. page = _parseCurrentHash2.page,
  6264. rotation = _parseCurrentHash2.rotation;
  6265. this._pushOrReplaceState({
  6266. hash: hash,
  6267. page: page,
  6268. rotation: rotation
  6269. }, true);
  6270. return;
  6271. }
  6272. if (!this._isValidState(state)) {
  6273. return;
  6274. }
  6275. this._popStateInProgress = true;
  6276. if (hashChanged) {
  6277. this._blockHashChange++;
  6278. (0, _ui_utils.waitOnEventOrTimeout)({
  6279. target: window,
  6280. name: 'hashchange',
  6281. delay: HASH_CHANGE_TIMEOUT
  6282. }).then(function () {
  6283. _this4._blockHashChange--;
  6284. });
  6285. }
  6286. var destination = state.destination;
  6287. this._updateInternalState(destination, state.uid, true);
  6288. if (this._uid > this._maxUid) {
  6289. this._maxUid = this._uid;
  6290. }
  6291. if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
  6292. this.linkService.rotation = destination.rotation;
  6293. }
  6294. if (destination.dest) {
  6295. this.linkService.navigateTo(destination.dest);
  6296. } else if (destination.hash) {
  6297. this.linkService.setHash(destination.hash);
  6298. } else if (destination.page) {
  6299. this.linkService.page = destination.page;
  6300. }
  6301. Promise.resolve().then(function () {
  6302. _this4._popStateInProgress = false;
  6303. });
  6304. }
  6305. }, {
  6306. key: '_bindEvents',
  6307. value: function _bindEvents() {
  6308. var _this5 = this;
  6309. var _boundEvents = this._boundEvents,
  6310. eventBus = this.eventBus;
  6311. _boundEvents.updateViewarea = this._updateViewarea.bind(this);
  6312. _boundEvents.popState = this._popState.bind(this);
  6313. _boundEvents.pageHide = function (evt) {
  6314. if (!_this5._destination || _this5._destination.temporary) {
  6315. _this5._tryPushCurrentPosition();
  6316. }
  6317. };
  6318. eventBus.on('updateviewarea', _boundEvents.updateViewarea);
  6319. window.addEventListener('popstate', _boundEvents.popState);
  6320. window.addEventListener('pagehide', _boundEvents.pageHide);
  6321. }
  6322. }, {
  6323. key: 'popStateInProgress',
  6324. get: function get() {
  6325. return this.initialized && (this._popStateInProgress || this._blockHashChange > 0);
  6326. }
  6327. }]);
  6328. return PDFHistory;
  6329. }();
  6330. function isDestHashesEqual(destHash, pushHash) {
  6331. if (typeof destHash !== 'string' || typeof pushHash !== 'string') {
  6332. return false;
  6333. }
  6334. if (destHash === pushHash) {
  6335. return true;
  6336. }
  6337. var _parseQueryString = (0, _ui_utils.parseQueryString)(destHash),
  6338. nameddest = _parseQueryString.nameddest;
  6339. if (nameddest === pushHash) {
  6340. return true;
  6341. }
  6342. return false;
  6343. }
  6344. function isDestArraysEqual(firstDest, secondDest) {
  6345. function isEntryEqual(first, second) {
  6346. if ((typeof first === 'undefined' ? 'undefined' : _typeof(first)) !== (typeof second === 'undefined' ? 'undefined' : _typeof(second))) {
  6347. return false;
  6348. }
  6349. if (Array.isArray(first) || Array.isArray(second)) {
  6350. return false;
  6351. }
  6352. if (first !== null && (typeof first === 'undefined' ? 'undefined' : _typeof(first)) === 'object' && second !== null) {
  6353. if (Object.keys(first).length !== Object.keys(second).length) {
  6354. return false;
  6355. }
  6356. for (var key in first) {
  6357. if (!isEntryEqual(first[key], second[key])) {
  6358. return false;
  6359. }
  6360. }
  6361. return true;
  6362. }
  6363. return first === second || Number.isNaN(first) && Number.isNaN(second);
  6364. }
  6365. if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
  6366. return false;
  6367. }
  6368. if (firstDest.length !== secondDest.length) {
  6369. return false;
  6370. }
  6371. for (var i = 0, ii = firstDest.length; i < ii; i++) {
  6372. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  6373. return false;
  6374. }
  6375. }
  6376. return true;
  6377. }
  6378. exports.PDFHistory = PDFHistory;
  6379. exports.isDestHashesEqual = isDestHashesEqual;
  6380. exports.isDestArraysEqual = isDestArraysEqual;
  6381. /***/ }),
  6382. /* 23 */
  6383. /***/ (function(module, exports, __webpack_require__) {
  6384. "use strict";
  6385. Object.defineProperty(exports, "__esModule", {
  6386. value: true
  6387. });
  6388. exports.SimpleLinkService = exports.PDFLinkService = undefined;
  6389. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  6390. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  6391. var _dom_events = __webpack_require__(14);
  6392. var _ui_utils = __webpack_require__(6);
  6393. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6394. var PDFLinkService = function () {
  6395. function PDFLinkService() {
  6396. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  6397. eventBus = _ref.eventBus,
  6398. _ref$externalLinkTarg = _ref.externalLinkTarget,
  6399. externalLinkTarget = _ref$externalLinkTarg === undefined ? null : _ref$externalLinkTarg,
  6400. _ref$externalLinkRel = _ref.externalLinkRel,
  6401. externalLinkRel = _ref$externalLinkRel === undefined ? null : _ref$externalLinkRel;
  6402. _classCallCheck(this, PDFLinkService);
  6403. this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)();
  6404. this.externalLinkTarget = externalLinkTarget;
  6405. this.externalLinkRel = externalLinkRel;
  6406. this.baseUrl = null;
  6407. this.pdfDocument = null;
  6408. this.pdfViewer = null;
  6409. this.pdfHistory = null;
  6410. this._pagesRefCache = null;
  6411. }
  6412. _createClass(PDFLinkService, [{
  6413. key: 'setDocument',
  6414. value: function setDocument(pdfDocument) {
  6415. var baseUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  6416. this.baseUrl = baseUrl;
  6417. this.pdfDocument = pdfDocument;
  6418. this._pagesRefCache = Object.create(null);
  6419. }
  6420. }, {
  6421. key: 'setViewer',
  6422. value: function setViewer(pdfViewer) {
  6423. this.pdfViewer = pdfViewer;
  6424. }
  6425. }, {
  6426. key: 'setHistory',
  6427. value: function setHistory(pdfHistory) {
  6428. this.pdfHistory = pdfHistory;
  6429. }
  6430. }, {
  6431. key: 'navigateTo',
  6432. value: function navigateTo(dest) {
  6433. var _this = this;
  6434. var goToDestination = function goToDestination(_ref2) {
  6435. var namedDest = _ref2.namedDest,
  6436. explicitDest = _ref2.explicitDest;
  6437. var destRef = explicitDest[0],
  6438. pageNumber = void 0;
  6439. if (destRef instanceof Object) {
  6440. pageNumber = _this._cachedPageNumber(destRef);
  6441. if (pageNumber === null) {
  6442. _this.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
  6443. _this.cachePageRef(pageIndex + 1, destRef);
  6444. goToDestination({
  6445. namedDest: namedDest,
  6446. explicitDest: explicitDest
  6447. });
  6448. }).catch(function () {
  6449. console.error('PDFLinkService.navigateTo: "' + destRef + '" is not ' + ('a valid page reference, for dest="' + dest + '".'));
  6450. });
  6451. return;
  6452. }
  6453. } else if (Number.isInteger(destRef)) {
  6454. pageNumber = destRef + 1;
  6455. } else {
  6456. console.error('PDFLinkService.navigateTo: "' + destRef + '" is not ' + ('a valid destination reference, for dest="' + dest + '".'));
  6457. return;
  6458. }
  6459. if (!pageNumber || pageNumber < 1 || pageNumber > _this.pagesCount) {
  6460. console.error('PDFLinkService.navigateTo: "' + pageNumber + '" is not ' + ('a valid page number, for dest="' + dest + '".'));
  6461. return;
  6462. }
  6463. if (_this.pdfHistory) {
  6464. _this.pdfHistory.pushCurrentPosition();
  6465. _this.pdfHistory.push({
  6466. namedDest: namedDest,
  6467. explicitDest: explicitDest,
  6468. pageNumber: pageNumber
  6469. });
  6470. }
  6471. _this.pdfViewer.scrollPageIntoView({
  6472. pageNumber: pageNumber,
  6473. destArray: explicitDest
  6474. });
  6475. };
  6476. new Promise(function (resolve, reject) {
  6477. if (typeof dest === 'string') {
  6478. _this.pdfDocument.getDestination(dest).then(function (destArray) {
  6479. resolve({
  6480. namedDest: dest,
  6481. explicitDest: destArray
  6482. });
  6483. });
  6484. return;
  6485. }
  6486. resolve({
  6487. namedDest: '',
  6488. explicitDest: dest
  6489. });
  6490. }).then(function (data) {
  6491. if (!Array.isArray(data.explicitDest)) {
  6492. console.error('PDFLinkService.navigateTo: "' + data.explicitDest + '" is' + (' not a valid destination array, for dest="' + dest + '".'));
  6493. return;
  6494. }
  6495. goToDestination(data);
  6496. });
  6497. }
  6498. }, {
  6499. key: 'getDestinationHash',
  6500. value: function getDestinationHash(dest) {
  6501. if (typeof dest === 'string') {
  6502. return this.getAnchorUrl('#' + escape(dest));
  6503. }
  6504. if (Array.isArray(dest)) {
  6505. var str = JSON.stringify(dest);
  6506. return this.getAnchorUrl('#' + escape(str));
  6507. }
  6508. return this.getAnchorUrl('');
  6509. }
  6510. }, {
  6511. key: 'getAnchorUrl',
  6512. value: function getAnchorUrl(anchor) {
  6513. return (this.baseUrl || '') + anchor;
  6514. }
  6515. }, {
  6516. key: 'setHash',
  6517. value: function setHash(hash) {
  6518. var pageNumber = void 0,
  6519. dest = void 0;
  6520. if (hash.includes('=')) {
  6521. var params = (0, _ui_utils.parseQueryString)(hash);
  6522. if ('search' in params) {
  6523. this.eventBus.dispatch('findfromurlhash', {
  6524. source: this,
  6525. query: params['search'].replace(/"/g, ''),
  6526. phraseSearch: params['phrase'] === 'true'
  6527. });
  6528. }
  6529. if ('nameddest' in params) {
  6530. this.navigateTo(params.nameddest);
  6531. return;
  6532. }
  6533. if ('page' in params) {
  6534. pageNumber = params.page | 0 || 1;
  6535. }
  6536. if ('zoom' in params) {
  6537. var zoomArgs = params.zoom.split(',');
  6538. var zoomArg = zoomArgs[0];
  6539. var zoomArgNumber = parseFloat(zoomArg);
  6540. if (!zoomArg.includes('Fit')) {
  6541. dest = [null, { name: 'XYZ' }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
  6542. } else {
  6543. if (zoomArg === 'Fit' || zoomArg === 'FitB') {
  6544. dest = [null, { name: zoomArg }];
  6545. } else if (zoomArg === 'FitH' || zoomArg === 'FitBH' || zoomArg === 'FitV' || zoomArg === 'FitBV') {
  6546. dest = [null, { name: zoomArg }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  6547. } else if (zoomArg === 'FitR') {
  6548. if (zoomArgs.length !== 5) {
  6549. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
  6550. } else {
  6551. dest = [null, { name: zoomArg }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
  6552. }
  6553. } else {
  6554. console.error('PDFLinkService.setHash: "' + zoomArg + '" is not ' + 'a valid zoom value.');
  6555. }
  6556. }
  6557. }
  6558. if (dest) {
  6559. this.pdfViewer.scrollPageIntoView({
  6560. pageNumber: pageNumber || this.page,
  6561. destArray: dest,
  6562. allowNegativeOffset: true
  6563. });
  6564. } else if (pageNumber) {
  6565. this.page = pageNumber;
  6566. }
  6567. if ('pagemode' in params) {
  6568. this.eventBus.dispatch('pagemode', {
  6569. source: this,
  6570. mode: params.pagemode
  6571. });
  6572. }
  6573. } else {
  6574. dest = unescape(hash);
  6575. try {
  6576. dest = JSON.parse(dest);
  6577. if (!Array.isArray(dest)) {
  6578. dest = dest.toString();
  6579. }
  6580. } catch (ex) {}
  6581. if (typeof dest === 'string' || isValidExplicitDestination(dest)) {
  6582. this.navigateTo(dest);
  6583. return;
  6584. }
  6585. console.error('PDFLinkService.setHash: "' + unescape(hash) + '" is not ' + 'a valid destination.');
  6586. }
  6587. }
  6588. }, {
  6589. key: 'executeNamedAction',
  6590. value: function executeNamedAction(action) {
  6591. switch (action) {
  6592. case 'GoBack':
  6593. if (this.pdfHistory) {
  6594. this.pdfHistory.back();
  6595. }
  6596. break;
  6597. case 'GoForward':
  6598. if (this.pdfHistory) {
  6599. this.pdfHistory.forward();
  6600. }
  6601. break;
  6602. case 'NextPage':
  6603. if (this.page < this.pagesCount) {
  6604. this.page++;
  6605. }
  6606. break;
  6607. case 'PrevPage':
  6608. if (this.page > 1) {
  6609. this.page--;
  6610. }
  6611. break;
  6612. case 'LastPage':
  6613. this.page = this.pagesCount;
  6614. break;
  6615. case 'FirstPage':
  6616. this.page = 1;
  6617. break;
  6618. default:
  6619. break;
  6620. }
  6621. this.eventBus.dispatch('namedaction', {
  6622. source: this,
  6623. action: action
  6624. });
  6625. }
  6626. }, {
  6627. key: 'cachePageRef',
  6628. value: function cachePageRef(pageNum, pageRef) {
  6629. if (!pageRef) {
  6630. return;
  6631. }
  6632. var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
  6633. this._pagesRefCache[refStr] = pageNum;
  6634. }
  6635. }, {
  6636. key: '_cachedPageNumber',
  6637. value: function _cachedPageNumber(pageRef) {
  6638. var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
  6639. return this._pagesRefCache && this._pagesRefCache[refStr] || null;
  6640. }
  6641. }, {
  6642. key: 'pagesCount',
  6643. get: function get() {
  6644. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  6645. }
  6646. }, {
  6647. key: 'page',
  6648. get: function get() {
  6649. return this.pdfViewer.currentPageNumber;
  6650. },
  6651. set: function set(value) {
  6652. this.pdfViewer.currentPageNumber = value;
  6653. }
  6654. }, {
  6655. key: 'rotation',
  6656. get: function get() {
  6657. return this.pdfViewer.pagesRotation;
  6658. },
  6659. set: function set(value) {
  6660. this.pdfViewer.pagesRotation = value;
  6661. }
  6662. }]);
  6663. return PDFLinkService;
  6664. }();
  6665. function isValidExplicitDestination(dest) {
  6666. if (!Array.isArray(dest)) {
  6667. return false;
  6668. }
  6669. var destLength = dest.length,
  6670. allowNull = true;
  6671. if (destLength < 2) {
  6672. return false;
  6673. }
  6674. var page = dest[0];
  6675. if (!((typeof page === 'undefined' ? 'undefined' : _typeof(page)) === 'object' && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
  6676. return false;
  6677. }
  6678. var zoom = dest[1];
  6679. if (!((typeof zoom === 'undefined' ? 'undefined' : _typeof(zoom)) === 'object' && typeof zoom.name === 'string')) {
  6680. return false;
  6681. }
  6682. switch (zoom.name) {
  6683. case 'XYZ':
  6684. if (destLength !== 5) {
  6685. return false;
  6686. }
  6687. break;
  6688. case 'Fit':
  6689. case 'FitB':
  6690. return destLength === 2;
  6691. case 'FitH':
  6692. case 'FitBH':
  6693. case 'FitV':
  6694. case 'FitBV':
  6695. if (destLength !== 3) {
  6696. return false;
  6697. }
  6698. break;
  6699. case 'FitR':
  6700. if (destLength !== 6) {
  6701. return false;
  6702. }
  6703. allowNull = false;
  6704. break;
  6705. default:
  6706. return false;
  6707. }
  6708. for (var i = 2; i < destLength; i++) {
  6709. var param = dest[i];
  6710. if (!(typeof param === 'number' || allowNull && param === null)) {
  6711. return false;
  6712. }
  6713. }
  6714. return true;
  6715. }
  6716. var SimpleLinkService = function () {
  6717. function SimpleLinkService() {
  6718. _classCallCheck(this, SimpleLinkService);
  6719. this.externalLinkTarget = null;
  6720. this.externalLinkRel = null;
  6721. }
  6722. _createClass(SimpleLinkService, [{
  6723. key: 'navigateTo',
  6724. value: function navigateTo(dest) {}
  6725. }, {
  6726. key: 'getDestinationHash',
  6727. value: function getDestinationHash(dest) {
  6728. return '#';
  6729. }
  6730. }, {
  6731. key: 'getAnchorUrl',
  6732. value: function getAnchorUrl(hash) {
  6733. return '#';
  6734. }
  6735. }, {
  6736. key: 'setHash',
  6737. value: function setHash(hash) {}
  6738. }, {
  6739. key: 'executeNamedAction',
  6740. value: function executeNamedAction(action) {}
  6741. }, {
  6742. key: 'cachePageRef',
  6743. value: function cachePageRef(pageNum, pageRef) {}
  6744. }, {
  6745. key: 'pagesCount',
  6746. get: function get() {
  6747. return 0;
  6748. }
  6749. }, {
  6750. key: 'page',
  6751. get: function get() {
  6752. return 0;
  6753. },
  6754. set: function set(value) {}
  6755. }, {
  6756. key: 'rotation',
  6757. get: function get() {
  6758. return 0;
  6759. },
  6760. set: function set(value) {}
  6761. }]);
  6762. return SimpleLinkService;
  6763. }();
  6764. exports.PDFLinkService = PDFLinkService;
  6765. exports.SimpleLinkService = SimpleLinkService;
  6766. /***/ }),
  6767. /* 24 */
  6768. /***/ (function(module, exports, __webpack_require__) {
  6769. "use strict";
  6770. Object.defineProperty(exports, "__esModule", {
  6771. value: true
  6772. });
  6773. exports.PDFOutlineViewer = undefined;
  6774. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  6775. var _pdfjsLib = __webpack_require__(7);
  6776. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6777. var DEFAULT_TITLE = '\u2013';
  6778. var PDFOutlineViewer = function () {
  6779. function PDFOutlineViewer(_ref) {
  6780. var container = _ref.container,
  6781. linkService = _ref.linkService,
  6782. eventBus = _ref.eventBus;
  6783. _classCallCheck(this, PDFOutlineViewer);
  6784. this.container = container;
  6785. this.linkService = linkService;
  6786. this.eventBus = eventBus;
  6787. this.reset();
  6788. eventBus.on('toggleoutlinetree', this.toggleOutlineTree.bind(this));
  6789. }
  6790. _createClass(PDFOutlineViewer, [{
  6791. key: 'reset',
  6792. value: function reset() {
  6793. this.outline = null;
  6794. this.lastToggleIsShow = true;
  6795. this.container.textContent = '';
  6796. this.container.classList.remove('outlineWithDeepNesting');
  6797. }
  6798. }, {
  6799. key: '_dispatchEvent',
  6800. value: function _dispatchEvent(outlineCount) {
  6801. this.eventBus.dispatch('outlineloaded', {
  6802. source: this,
  6803. outlineCount: outlineCount
  6804. });
  6805. }
  6806. }, {
  6807. key: '_bindLink',
  6808. value: function _bindLink(element, _ref2) {
  6809. var url = _ref2.url,
  6810. newWindow = _ref2.newWindow,
  6811. dest = _ref2.dest;
  6812. var linkService = this.linkService;
  6813. if (url) {
  6814. (0, _pdfjsLib.addLinkAttributes)(element, {
  6815. url: url,
  6816. target: newWindow ? _pdfjsLib.LinkTarget.BLANK : linkService.externalLinkTarget,
  6817. rel: linkService.externalLinkRel
  6818. });
  6819. return;
  6820. }
  6821. element.href = linkService.getDestinationHash(dest);
  6822. element.onclick = function () {
  6823. if (dest) {
  6824. linkService.navigateTo(dest);
  6825. }
  6826. return false;
  6827. };
  6828. }
  6829. }, {
  6830. key: '_setStyles',
  6831. value: function _setStyles(element, _ref3) {
  6832. var bold = _ref3.bold,
  6833. italic = _ref3.italic;
  6834. var styleStr = '';
  6835. if (bold) {
  6836. styleStr += 'font-weight: bold;';
  6837. }
  6838. if (italic) {
  6839. styleStr += 'font-style: italic;';
  6840. }
  6841. if (styleStr) {
  6842. element.setAttribute('style', styleStr);
  6843. }
  6844. }
  6845. }, {
  6846. key: '_addToggleButton',
  6847. value: function _addToggleButton(div) {
  6848. var _this = this;
  6849. var toggler = document.createElement('div');
  6850. toggler.className = 'outlineItemToggler';
  6851. toggler.onclick = function (evt) {
  6852. evt.stopPropagation();
  6853. toggler.classList.toggle('outlineItemsHidden');
  6854. if (evt.shiftKey) {
  6855. var shouldShowAll = !toggler.classList.contains('outlineItemsHidden');
  6856. _this._toggleOutlineItem(div, shouldShowAll);
  6857. }
  6858. };
  6859. div.insertBefore(toggler, div.firstChild);
  6860. }
  6861. }, {
  6862. key: '_toggleOutlineItem',
  6863. value: function _toggleOutlineItem(root, show) {
  6864. this.lastToggleIsShow = show;
  6865. var togglers = root.querySelectorAll('.outlineItemToggler');
  6866. for (var i = 0, ii = togglers.length; i < ii; ++i) {
  6867. togglers[i].classList[show ? 'remove' : 'add']('outlineItemsHidden');
  6868. }
  6869. }
  6870. }, {
  6871. key: 'toggleOutlineTree',
  6872. value: function toggleOutlineTree() {
  6873. if (!this.outline) {
  6874. return;
  6875. }
  6876. this._toggleOutlineItem(this.container, !this.lastToggleIsShow);
  6877. }
  6878. }, {
  6879. key: 'render',
  6880. value: function render(_ref4) {
  6881. var outline = _ref4.outline;
  6882. var outlineCount = 0;
  6883. if (this.outline) {
  6884. this.reset();
  6885. }
  6886. this.outline = outline || null;
  6887. if (!outline) {
  6888. this._dispatchEvent(outlineCount);
  6889. return;
  6890. }
  6891. var fragment = document.createDocumentFragment();
  6892. var queue = [{
  6893. parent: fragment,
  6894. items: this.outline
  6895. }];
  6896. var hasAnyNesting = false;
  6897. while (queue.length > 0) {
  6898. var levelData = queue.shift();
  6899. for (var i = 0, len = levelData.items.length; i < len; i++) {
  6900. var item = levelData.items[i];
  6901. var div = document.createElement('div');
  6902. div.className = 'outlineItem';
  6903. var element = document.createElement('a');
  6904. this._bindLink(element, item);
  6905. this._setStyles(element, item);
  6906. element.textContent = (0, _pdfjsLib.removeNullCharacters)(item.title) || DEFAULT_TITLE;
  6907. div.appendChild(element);
  6908. if (item.items.length > 0) {
  6909. hasAnyNesting = true;
  6910. this._addToggleButton(div);
  6911. var itemsDiv = document.createElement('div');
  6912. itemsDiv.className = 'outlineItems';
  6913. div.appendChild(itemsDiv);
  6914. queue.push({
  6915. parent: itemsDiv,
  6916. items: item.items
  6917. });
  6918. }
  6919. levelData.parent.appendChild(div);
  6920. outlineCount++;
  6921. }
  6922. }
  6923. if (hasAnyNesting) {
  6924. this.container.classList.add('outlineWithDeepNesting');
  6925. }
  6926. this.container.appendChild(fragment);
  6927. this._dispatchEvent(outlineCount);
  6928. }
  6929. }]);
  6930. return PDFOutlineViewer;
  6931. }();
  6932. exports.PDFOutlineViewer = PDFOutlineViewer;
  6933. /***/ }),
  6934. /* 25 */
  6935. /***/ (function(module, exports, __webpack_require__) {
  6936. "use strict";
  6937. Object.defineProperty(exports, "__esModule", {
  6938. value: true
  6939. });
  6940. exports.PDFPresentationMode = undefined;
  6941. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  6942. var _ui_utils = __webpack_require__(6);
  6943. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6944. var DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1500;
  6945. var DELAY_BEFORE_HIDING_CONTROLS = 3000;
  6946. var ACTIVE_SELECTOR = 'pdfPresentationMode';
  6947. var CONTROLS_SELECTOR = 'pdfPresentationModeControls';
  6948. var MOUSE_SCROLL_COOLDOWN_TIME = 50;
  6949. var PAGE_SWITCH_THRESHOLD = 0.1;
  6950. var SWIPE_MIN_DISTANCE_THRESHOLD = 50;
  6951. var SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
  6952. var PDFPresentationMode = function () {
  6953. function PDFPresentationMode(_ref) {
  6954. var _this = this;
  6955. var container = _ref.container,
  6956. _ref$viewer = _ref.viewer,
  6957. viewer = _ref$viewer === undefined ? null : _ref$viewer,
  6958. pdfViewer = _ref.pdfViewer,
  6959. eventBus = _ref.eventBus,
  6960. _ref$contextMenuItems = _ref.contextMenuItems,
  6961. contextMenuItems = _ref$contextMenuItems === undefined ? null : _ref$contextMenuItems;
  6962. _classCallCheck(this, PDFPresentationMode);
  6963. this.container = container;
  6964. this.viewer = viewer || container.firstElementChild;
  6965. this.pdfViewer = pdfViewer;
  6966. this.eventBus = eventBus;
  6967. this.active = false;
  6968. this.args = null;
  6969. this.contextMenuOpen = false;
  6970. this.mouseScrollTimeStamp = 0;
  6971. this.mouseScrollDelta = 0;
  6972. this.touchSwipeState = null;
  6973. if (contextMenuItems) {
  6974. contextMenuItems.contextFirstPage.addEventListener('click', function () {
  6975. _this.contextMenuOpen = false;
  6976. _this.eventBus.dispatch('firstpage', { source: _this });
  6977. });
  6978. contextMenuItems.contextLastPage.addEventListener('click', function () {
  6979. _this.contextMenuOpen = false;
  6980. _this.eventBus.dispatch('lastpage', { source: _this });
  6981. });
  6982. contextMenuItems.contextPageRotateCw.addEventListener('click', function () {
  6983. _this.contextMenuOpen = false;
  6984. _this.eventBus.dispatch('rotatecw', { source: _this });
  6985. });
  6986. contextMenuItems.contextPageRotateCcw.addEventListener('click', function () {
  6987. _this.contextMenuOpen = false;
  6988. _this.eventBus.dispatch('rotateccw', { source: _this });
  6989. });
  6990. }
  6991. }
  6992. _createClass(PDFPresentationMode, [{
  6993. key: 'request',
  6994. value: function request() {
  6995. if (this.switchInProgress || this.active || !this.viewer.hasChildNodes()) {
  6996. return false;
  6997. }
  6998. this._addFullscreenChangeListeners();
  6999. this._setSwitchInProgress();
  7000. this._notifyStateChange();
  7001. if (this.container.requestFullscreen) {
  7002. this.container.requestFullscreen();
  7003. } else if (this.container.mozRequestFullScreen) {
  7004. this.container.mozRequestFullScreen();
  7005. } else if (this.container.webkitRequestFullscreen) {
  7006. this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
  7007. } else if (this.container.msRequestFullscreen) {
  7008. this.container.msRequestFullscreen();
  7009. } else {
  7010. return false;
  7011. }
  7012. this.args = {
  7013. page: this.pdfViewer.currentPageNumber,
  7014. previousScale: this.pdfViewer.currentScaleValue
  7015. };
  7016. return true;
  7017. }
  7018. }, {
  7019. key: '_mouseWheel',
  7020. value: function _mouseWheel(evt) {
  7021. if (!this.active) {
  7022. return;
  7023. }
  7024. evt.preventDefault();
  7025. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  7026. var currentTime = new Date().getTime();
  7027. var storedTime = this.mouseScrollTimeStamp;
  7028. if (currentTime > storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {
  7029. return;
  7030. }
  7031. if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) {
  7032. this._resetMouseScrollState();
  7033. }
  7034. this.mouseScrollDelta += delta;
  7035. if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
  7036. var totalDelta = this.mouseScrollDelta;
  7037. this._resetMouseScrollState();
  7038. var success = totalDelta > 0 ? this._goToPreviousPage() : this._goToNextPage();
  7039. if (success) {
  7040. this.mouseScrollTimeStamp = currentTime;
  7041. }
  7042. }
  7043. }
  7044. }, {
  7045. key: '_goToPreviousPage',
  7046. value: function _goToPreviousPage() {
  7047. var page = this.pdfViewer.currentPageNumber;
  7048. if (page <= 1) {
  7049. return false;
  7050. }
  7051. this.pdfViewer.currentPageNumber = page - 1;
  7052. return true;
  7053. }
  7054. }, {
  7055. key: '_goToNextPage',
  7056. value: function _goToNextPage() {
  7057. var page = this.pdfViewer.currentPageNumber;
  7058. if (page >= this.pdfViewer.pagesCount) {
  7059. return false;
  7060. }
  7061. this.pdfViewer.currentPageNumber = page + 1;
  7062. return true;
  7063. }
  7064. }, {
  7065. key: '_notifyStateChange',
  7066. value: function _notifyStateChange() {
  7067. this.eventBus.dispatch('presentationmodechanged', {
  7068. source: this,
  7069. active: this.active,
  7070. switchInProgress: !!this.switchInProgress
  7071. });
  7072. }
  7073. }, {
  7074. key: '_setSwitchInProgress',
  7075. value: function _setSwitchInProgress() {
  7076. var _this2 = this;
  7077. if (this.switchInProgress) {
  7078. clearTimeout(this.switchInProgress);
  7079. }
  7080. this.switchInProgress = setTimeout(function () {
  7081. _this2._removeFullscreenChangeListeners();
  7082. delete _this2.switchInProgress;
  7083. _this2._notifyStateChange();
  7084. }, DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS);
  7085. }
  7086. }, {
  7087. key: '_resetSwitchInProgress',
  7088. value: function _resetSwitchInProgress() {
  7089. if (this.switchInProgress) {
  7090. clearTimeout(this.switchInProgress);
  7091. delete this.switchInProgress;
  7092. }
  7093. }
  7094. }, {
  7095. key: '_enter',
  7096. value: function _enter() {
  7097. var _this3 = this;
  7098. this.active = true;
  7099. this._resetSwitchInProgress();
  7100. this._notifyStateChange();
  7101. this.container.classList.add(ACTIVE_SELECTOR);
  7102. setTimeout(function () {
  7103. _this3.pdfViewer.currentPageNumber = _this3.args.page;
  7104. _this3.pdfViewer.currentScaleValue = 'page-fit';
  7105. }, 0);
  7106. this._addWindowListeners();
  7107. this._showControls();
  7108. this.contextMenuOpen = false;
  7109. this.container.setAttribute('contextmenu', 'viewerContextMenu');
  7110. window.getSelection().removeAllRanges();
  7111. }
  7112. }, {
  7113. key: '_exit',
  7114. value: function _exit() {
  7115. var _this4 = this;
  7116. var page = this.pdfViewer.currentPageNumber;
  7117. this.container.classList.remove(ACTIVE_SELECTOR);
  7118. setTimeout(function () {
  7119. _this4.active = false;
  7120. _this4._removeFullscreenChangeListeners();
  7121. _this4._notifyStateChange();
  7122. _this4.pdfViewer.currentScaleValue = _this4.args.previousScale;
  7123. _this4.pdfViewer.currentPageNumber = page;
  7124. _this4.args = null;
  7125. }, 0);
  7126. this._removeWindowListeners();
  7127. this._hideControls();
  7128. this._resetMouseScrollState();
  7129. this.container.removeAttribute('contextmenu');
  7130. this.contextMenuOpen = false;
  7131. }
  7132. }, {
  7133. key: '_mouseDown',
  7134. value: function _mouseDown(evt) {
  7135. if (this.contextMenuOpen) {
  7136. this.contextMenuOpen = false;
  7137. evt.preventDefault();
  7138. return;
  7139. }
  7140. if (evt.button === 0) {
  7141. var isInternalLink = evt.target.href && evt.target.classList.contains('internalLink');
  7142. if (!isInternalLink) {
  7143. evt.preventDefault();
  7144. if (evt.shiftKey) {
  7145. this._goToPreviousPage();
  7146. } else {
  7147. this._goToNextPage();
  7148. }
  7149. }
  7150. }
  7151. }
  7152. }, {
  7153. key: '_contextMenu',
  7154. value: function _contextMenu() {
  7155. this.contextMenuOpen = true;
  7156. }
  7157. }, {
  7158. key: '_showControls',
  7159. value: function _showControls() {
  7160. var _this5 = this;
  7161. if (this.controlsTimeout) {
  7162. clearTimeout(this.controlsTimeout);
  7163. } else {
  7164. this.container.classList.add(CONTROLS_SELECTOR);
  7165. }
  7166. this.controlsTimeout = setTimeout(function () {
  7167. _this5.container.classList.remove(CONTROLS_SELECTOR);
  7168. delete _this5.controlsTimeout;
  7169. }, DELAY_BEFORE_HIDING_CONTROLS);
  7170. }
  7171. }, {
  7172. key: '_hideControls',
  7173. value: function _hideControls() {
  7174. if (!this.controlsTimeout) {
  7175. return;
  7176. }
  7177. clearTimeout(this.controlsTimeout);
  7178. this.container.classList.remove(CONTROLS_SELECTOR);
  7179. delete this.controlsTimeout;
  7180. }
  7181. }, {
  7182. key: '_resetMouseScrollState',
  7183. value: function _resetMouseScrollState() {
  7184. this.mouseScrollTimeStamp = 0;
  7185. this.mouseScrollDelta = 0;
  7186. }
  7187. }, {
  7188. key: '_touchSwipe',
  7189. value: function _touchSwipe(evt) {
  7190. if (!this.active) {
  7191. return;
  7192. }
  7193. if (evt.touches.length > 1) {
  7194. this.touchSwipeState = null;
  7195. return;
  7196. }
  7197. switch (evt.type) {
  7198. case 'touchstart':
  7199. this.touchSwipeState = {
  7200. startX: evt.touches[0].pageX,
  7201. startY: evt.touches[0].pageY,
  7202. endX: evt.touches[0].pageX,
  7203. endY: evt.touches[0].pageY
  7204. };
  7205. break;
  7206. case 'touchmove':
  7207. if (this.touchSwipeState === null) {
  7208. return;
  7209. }
  7210. this.touchSwipeState.endX = evt.touches[0].pageX;
  7211. this.touchSwipeState.endY = evt.touches[0].pageY;
  7212. evt.preventDefault();
  7213. break;
  7214. case 'touchend':
  7215. if (this.touchSwipeState === null) {
  7216. return;
  7217. }
  7218. var delta = 0;
  7219. var dx = this.touchSwipeState.endX - this.touchSwipeState.startX;
  7220. var dy = this.touchSwipeState.endY - this.touchSwipeState.startY;
  7221. var absAngle = Math.abs(Math.atan2(dy, dx));
  7222. if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <= SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI - SWIPE_ANGLE_THRESHOLD)) {
  7223. delta = dx;
  7224. } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math.abs(absAngle - Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) {
  7225. delta = dy;
  7226. }
  7227. if (delta > 0) {
  7228. this._goToPreviousPage();
  7229. } else if (delta < 0) {
  7230. this._goToNextPage();
  7231. }
  7232. break;
  7233. }
  7234. }
  7235. }, {
  7236. key: '_addWindowListeners',
  7237. value: function _addWindowListeners() {
  7238. this.showControlsBind = this._showControls.bind(this);
  7239. this.mouseDownBind = this._mouseDown.bind(this);
  7240. this.mouseWheelBind = this._mouseWheel.bind(this);
  7241. this.resetMouseScrollStateBind = this._resetMouseScrollState.bind(this);
  7242. this.contextMenuBind = this._contextMenu.bind(this);
  7243. this.touchSwipeBind = this._touchSwipe.bind(this);
  7244. window.addEventListener('mousemove', this.showControlsBind);
  7245. window.addEventListener('mousedown', this.mouseDownBind);
  7246. window.addEventListener('wheel', this.mouseWheelBind);
  7247. window.addEventListener('keydown', this.resetMouseScrollStateBind);
  7248. window.addEventListener('contextmenu', this.contextMenuBind);
  7249. window.addEventListener('touchstart', this.touchSwipeBind);
  7250. window.addEventListener('touchmove', this.touchSwipeBind);
  7251. window.addEventListener('touchend', this.touchSwipeBind);
  7252. }
  7253. }, {
  7254. key: '_removeWindowListeners',
  7255. value: function _removeWindowListeners() {
  7256. window.removeEventListener('mousemove', this.showControlsBind);
  7257. window.removeEventListener('mousedown', this.mouseDownBind);
  7258. window.removeEventListener('wheel', this.mouseWheelBind);
  7259. window.removeEventListener('keydown', this.resetMouseScrollStateBind);
  7260. window.removeEventListener('contextmenu', this.contextMenuBind);
  7261. window.removeEventListener('touchstart', this.touchSwipeBind);
  7262. window.removeEventListener('touchmove', this.touchSwipeBind);
  7263. window.removeEventListener('touchend', this.touchSwipeBind);
  7264. delete this.showControlsBind;
  7265. delete this.mouseDownBind;
  7266. delete this.mouseWheelBind;
  7267. delete this.resetMouseScrollStateBind;
  7268. delete this.contextMenuBind;
  7269. delete this.touchSwipeBind;
  7270. }
  7271. }, {
  7272. key: '_fullscreenChange',
  7273. value: function _fullscreenChange() {
  7274. if (this.isFullscreen) {
  7275. this._enter();
  7276. } else {
  7277. this._exit();
  7278. }
  7279. }
  7280. }, {
  7281. key: '_addFullscreenChangeListeners',
  7282. value: function _addFullscreenChangeListeners() {
  7283. this.fullscreenChangeBind = this._fullscreenChange.bind(this);
  7284. window.addEventListener('fullscreenchange', this.fullscreenChangeBind);
  7285. window.addEventListener('mozfullscreenchange', this.fullscreenChangeBind);
  7286. window.addEventListener('webkitfullscreenchange', this.fullscreenChangeBind);
  7287. window.addEventListener('MSFullscreenChange', this.fullscreenChangeBind);
  7288. }
  7289. }, {
  7290. key: '_removeFullscreenChangeListeners',
  7291. value: function _removeFullscreenChangeListeners() {
  7292. window.removeEventListener('fullscreenchange', this.fullscreenChangeBind);
  7293. window.removeEventListener('mozfullscreenchange', this.fullscreenChangeBind);
  7294. window.removeEventListener('webkitfullscreenchange', this.fullscreenChangeBind);
  7295. window.removeEventListener('MSFullscreenChange', this.fullscreenChangeBind);
  7296. delete this.fullscreenChangeBind;
  7297. }
  7298. }, {
  7299. key: 'isFullscreen',
  7300. get: function get() {
  7301. return !!(document.fullscreenElement || document.mozFullScreen || document.webkitIsFullScreen || document.msFullscreenElement);
  7302. }
  7303. }]);
  7304. return PDFPresentationMode;
  7305. }();
  7306. exports.PDFPresentationMode = PDFPresentationMode;
  7307. /***/ }),
  7308. /* 26 */
  7309. /***/ (function(module, exports, __webpack_require__) {
  7310. "use strict";
  7311. Object.defineProperty(exports, "__esModule", {
  7312. value: true
  7313. });
  7314. exports.PDFSidebarResizer = undefined;
  7315. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  7316. var _ui_utils = __webpack_require__(6);
  7317. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7318. var SIDEBAR_WIDTH_VAR = '--sidebar-width';
  7319. var SIDEBAR_MIN_WIDTH = 200;
  7320. var SIDEBAR_RESIZING_CLASS = 'sidebarResizing';
  7321. var PDFSidebarResizer = function () {
  7322. function PDFSidebarResizer(options, eventBus) {
  7323. var _this = this;
  7324. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  7325. _classCallCheck(this, PDFSidebarResizer);
  7326. this.enabled = false;
  7327. this.isRTL = false;
  7328. this.sidebarOpen = false;
  7329. this.doc = document.documentElement;
  7330. this._width = null;
  7331. this._outerContainerWidth = null;
  7332. this._boundEvents = Object.create(null);
  7333. this.outerContainer = options.outerContainer;
  7334. this.resizer = options.resizer;
  7335. this.eventBus = eventBus;
  7336. this.l10n = l10n;
  7337. if (typeof CSS === 'undefined' || typeof CSS.supports !== 'function' || !CSS.supports(SIDEBAR_WIDTH_VAR, 'calc(-1 * ' + SIDEBAR_MIN_WIDTH + 'px)')) {
  7338. console.warn('PDFSidebarResizer: ' + 'The browser does not support resizing of the sidebar.');
  7339. return;
  7340. }
  7341. this.enabled = true;
  7342. this.resizer.classList.remove('hidden');
  7343. this.l10n.getDirection().then(function (dir) {
  7344. _this.isRTL = dir === 'rtl';
  7345. });
  7346. this._addEventListeners();
  7347. }
  7348. _createClass(PDFSidebarResizer, [{
  7349. key: '_updateWidth',
  7350. value: function _updateWidth() {
  7351. var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  7352. if (!this.enabled) {
  7353. return false;
  7354. }
  7355. var maxWidth = Math.floor(this.outerContainerWidth / 2);
  7356. if (width > maxWidth) {
  7357. width = maxWidth;
  7358. }
  7359. if (width < SIDEBAR_MIN_WIDTH) {
  7360. width = SIDEBAR_MIN_WIDTH;
  7361. }
  7362. if (width === this._width) {
  7363. return false;
  7364. }
  7365. this._width = width;
  7366. this.doc.style.setProperty(SIDEBAR_WIDTH_VAR, width + 'px');
  7367. return true;
  7368. }
  7369. }, {
  7370. key: '_mouseMove',
  7371. value: function _mouseMove(evt) {
  7372. var width = evt.clientX;
  7373. if (this.isRTL) {
  7374. width = this.outerContainerWidth - width;
  7375. }
  7376. this._updateWidth(width);
  7377. }
  7378. }, {
  7379. key: '_mouseUp',
  7380. value: function _mouseUp(evt) {
  7381. this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  7382. this.eventBus.dispatch('resize', { source: this });
  7383. var _boundEvents = this._boundEvents;
  7384. window.removeEventListener('mousemove', _boundEvents.mouseMove);
  7385. window.removeEventListener('mouseup', _boundEvents.mouseUp);
  7386. }
  7387. }, {
  7388. key: '_addEventListeners',
  7389. value: function _addEventListeners() {
  7390. var _this2 = this;
  7391. if (!this.enabled) {
  7392. return;
  7393. }
  7394. var _boundEvents = this._boundEvents;
  7395. _boundEvents.mouseMove = this._mouseMove.bind(this);
  7396. _boundEvents.mouseUp = this._mouseUp.bind(this);
  7397. this.resizer.addEventListener('mousedown', function (evt) {
  7398. if (evt.button !== 0) {
  7399. return;
  7400. }
  7401. _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  7402. window.addEventListener('mousemove', _boundEvents.mouseMove);
  7403. window.addEventListener('mouseup', _boundEvents.mouseUp);
  7404. });
  7405. this.eventBus.on('sidebarviewchanged', function (evt) {
  7406. _this2.sidebarOpen = !!(evt && evt.view);
  7407. });
  7408. this.eventBus.on('resize', function (evt) {
  7409. if (evt && evt.source === window) {
  7410. _this2._outerContainerWidth = null;
  7411. if (_this2._width) {
  7412. if (_this2.sidebarOpen) {
  7413. _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  7414. var updated = _this2._updateWidth(_this2._width);
  7415. Promise.resolve().then(function () {
  7416. _this2.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  7417. if (updated) {
  7418. _this2.eventBus.dispatch('resize', { source: _this2 });
  7419. }
  7420. });
  7421. } else {
  7422. _this2._updateWidth(_this2._width);
  7423. }
  7424. }
  7425. }
  7426. });
  7427. }
  7428. }, {
  7429. key: 'outerContainerWidth',
  7430. get: function get() {
  7431. if (!this._outerContainerWidth) {
  7432. this._outerContainerWidth = this.outerContainer.clientWidth;
  7433. }
  7434. return this._outerContainerWidth;
  7435. }
  7436. }]);
  7437. return PDFSidebarResizer;
  7438. }();
  7439. exports.PDFSidebarResizer = PDFSidebarResizer;
  7440. /***/ }),
  7441. /* 27 */
  7442. /***/ (function(module, exports, __webpack_require__) {
  7443. "use strict";
  7444. Object.defineProperty(exports, "__esModule", {
  7445. value: true
  7446. });
  7447. exports.PDFThumbnailViewer = undefined;
  7448. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  7449. var _ui_utils = __webpack_require__(6);
  7450. var _pdf_thumbnail_view = __webpack_require__(28);
  7451. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7452. var THUMBNAIL_SCROLL_MARGIN = -19;
  7453. var THUMBNAIL_SELECTED_CLASS = 'selected';
  7454. var PDFThumbnailViewer = function () {
  7455. function PDFThumbnailViewer(_ref) {
  7456. var container = _ref.container,
  7457. linkService = _ref.linkService,
  7458. renderingQueue = _ref.renderingQueue,
  7459. _ref$l10n = _ref.l10n,
  7460. l10n = _ref$l10n === undefined ? _ui_utils.NullL10n : _ref$l10n;
  7461. _classCallCheck(this, PDFThumbnailViewer);
  7462. this.container = container;
  7463. this.linkService = linkService;
  7464. this.renderingQueue = renderingQueue;
  7465. this.l10n = l10n;
  7466. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdated.bind(this));
  7467. this._resetView();
  7468. }
  7469. _createClass(PDFThumbnailViewer, [{
  7470. key: '_scrollUpdated',
  7471. value: function _scrollUpdated() {
  7472. this.renderingQueue.renderHighestPriority();
  7473. }
  7474. }, {
  7475. key: 'getThumbnail',
  7476. value: function getThumbnail(index) {
  7477. return this._thumbnails[index];
  7478. }
  7479. }, {
  7480. key: '_getVisibleThumbs',
  7481. value: function _getVisibleThumbs() {
  7482. return (0, _ui_utils.getVisibleElements)(this.container, this._thumbnails);
  7483. }
  7484. }, {
  7485. key: 'scrollThumbnailIntoView',
  7486. value: function scrollThumbnailIntoView(pageNumber) {
  7487. if (!this.pdfDocument) {
  7488. return;
  7489. }
  7490. var thumbnailView = this._thumbnails[pageNumber - 1];
  7491. if (!thumbnailView) {
  7492. console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');
  7493. return;
  7494. }
  7495. if (pageNumber !== this._currentPageNumber) {
  7496. var prevThumbnailView = this._thumbnails[this._currentPageNumber - 1];
  7497. prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS);
  7498. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  7499. }
  7500. var visibleThumbs = this._getVisibleThumbs();
  7501. var numVisibleThumbs = visibleThumbs.views.length;
  7502. if (numVisibleThumbs > 0) {
  7503. var first = visibleThumbs.first.id;
  7504. var last = numVisibleThumbs > 1 ? visibleThumbs.last.id : first;
  7505. var shouldScroll = false;
  7506. if (pageNumber <= first || pageNumber >= last) {
  7507. shouldScroll = true;
  7508. } else {
  7509. visibleThumbs.views.some(function (view) {
  7510. if (view.id !== pageNumber) {
  7511. return false;
  7512. }
  7513. shouldScroll = view.percent < 100;
  7514. return true;
  7515. });
  7516. }
  7517. if (shouldScroll) {
  7518. (0, _ui_utils.scrollIntoView)(thumbnailView.div, { top: THUMBNAIL_SCROLL_MARGIN });
  7519. }
  7520. }
  7521. this._currentPageNumber = pageNumber;
  7522. }
  7523. }, {
  7524. key: 'cleanup',
  7525. value: function cleanup() {
  7526. _pdf_thumbnail_view.PDFThumbnailView.cleanup();
  7527. }
  7528. }, {
  7529. key: '_resetView',
  7530. value: function _resetView() {
  7531. this._thumbnails = [];
  7532. this._currentPageNumber = 1;
  7533. this._pageLabels = null;
  7534. this._pagesRotation = 0;
  7535. this._pagesRequests = [];
  7536. this.container.textContent = '';
  7537. }
  7538. }, {
  7539. key: 'setDocument',
  7540. value: function setDocument(pdfDocument) {
  7541. var _this = this;
  7542. if (this.pdfDocument) {
  7543. this._cancelRendering();
  7544. this._resetView();
  7545. }
  7546. this.pdfDocument = pdfDocument;
  7547. if (!pdfDocument) {
  7548. return;
  7549. }
  7550. pdfDocument.getPage(1).then(function (firstPage) {
  7551. var pagesCount = pdfDocument.numPages;
  7552. var viewport = firstPage.getViewport(1.0);
  7553. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  7554. var thumbnail = new _pdf_thumbnail_view.PDFThumbnailView({
  7555. container: _this.container,
  7556. id: pageNum,
  7557. defaultViewport: viewport.clone(),
  7558. linkService: _this.linkService,
  7559. renderingQueue: _this.renderingQueue,
  7560. disableCanvasToImageConversion: false,
  7561. l10n: _this.l10n
  7562. });
  7563. _this._thumbnails.push(thumbnail);
  7564. }
  7565. var thumbnailView = _this._thumbnails[_this._currentPageNumber - 1];
  7566. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  7567. }).catch(function (reason) {
  7568. console.error('Unable to initialize thumbnail viewer', reason);
  7569. });
  7570. }
  7571. }, {
  7572. key: '_cancelRendering',
  7573. value: function _cancelRendering() {
  7574. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  7575. if (this._thumbnails[i]) {
  7576. this._thumbnails[i].cancelRendering();
  7577. }
  7578. }
  7579. }
  7580. }, {
  7581. key: 'setPageLabels',
  7582. value: function setPageLabels(labels) {
  7583. if (!this.pdfDocument) {
  7584. return;
  7585. }
  7586. if (!labels) {
  7587. this._pageLabels = null;
  7588. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  7589. this._pageLabels = null;
  7590. console.error('PDFThumbnailViewer_setPageLabels: Invalid page labels.');
  7591. } else {
  7592. this._pageLabels = labels;
  7593. }
  7594. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  7595. var label = this._pageLabels && this._pageLabels[i];
  7596. this._thumbnails[i].setPageLabel(label);
  7597. }
  7598. }
  7599. }, {
  7600. key: '_ensurePdfPageLoaded',
  7601. value: function _ensurePdfPageLoaded(thumbView) {
  7602. var _this2 = this;
  7603. if (thumbView.pdfPage) {
  7604. return Promise.resolve(thumbView.pdfPage);
  7605. }
  7606. var pageNumber = thumbView.id;
  7607. if (this._pagesRequests[pageNumber]) {
  7608. return this._pagesRequests[pageNumber];
  7609. }
  7610. var promise = this.pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  7611. thumbView.setPdfPage(pdfPage);
  7612. _this2._pagesRequests[pageNumber] = null;
  7613. return pdfPage;
  7614. }).catch(function (reason) {
  7615. console.error('Unable to get page for thumb view', reason);
  7616. _this2._pagesRequests[pageNumber] = null;
  7617. });
  7618. this._pagesRequests[pageNumber] = promise;
  7619. return promise;
  7620. }
  7621. }, {
  7622. key: 'forceRendering',
  7623. value: function forceRendering() {
  7624. var _this3 = this;
  7625. var visibleThumbs = this._getVisibleThumbs();
  7626. var thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, this.scroll.down);
  7627. if (thumbView) {
  7628. this._ensurePdfPageLoaded(thumbView).then(function () {
  7629. _this3.renderingQueue.renderView(thumbView);
  7630. });
  7631. return true;
  7632. }
  7633. return false;
  7634. }
  7635. }, {
  7636. key: 'pagesRotation',
  7637. get: function get() {
  7638. return this._pagesRotation;
  7639. },
  7640. set: function set(rotation) {
  7641. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  7642. throw new Error('Invalid thumbnails rotation angle.');
  7643. }
  7644. if (!this.pdfDocument) {
  7645. return;
  7646. }
  7647. if (this._pagesRotation === rotation) {
  7648. return;
  7649. }
  7650. this._pagesRotation = rotation;
  7651. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  7652. this._thumbnails[i].update(rotation);
  7653. }
  7654. }
  7655. }]);
  7656. return PDFThumbnailViewer;
  7657. }();
  7658. exports.PDFThumbnailViewer = PDFThumbnailViewer;
  7659. /***/ }),
  7660. /* 28 */
  7661. /***/ (function(module, exports, __webpack_require__) {
  7662. "use strict";
  7663. Object.defineProperty(exports, "__esModule", {
  7664. value: true
  7665. });
  7666. exports.PDFThumbnailView = undefined;
  7667. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  7668. var _pdfjsLib = __webpack_require__(7);
  7669. var _ui_utils = __webpack_require__(6);
  7670. var _pdf_rendering_queue = __webpack_require__(10);
  7671. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7672. var MAX_NUM_SCALING_STEPS = 3;
  7673. var THUMBNAIL_CANVAS_BORDER_WIDTH = 1;
  7674. var THUMBNAIL_WIDTH = 98;
  7675. var TempImageFactory = function TempImageFactoryClosure() {
  7676. var tempCanvasCache = null;
  7677. return {
  7678. getCanvas: function getCanvas(width, height) {
  7679. var tempCanvas = tempCanvasCache;
  7680. if (!tempCanvas) {
  7681. tempCanvas = document.createElement('canvas');
  7682. tempCanvasCache = tempCanvas;
  7683. }
  7684. tempCanvas.width = width;
  7685. tempCanvas.height = height;
  7686. tempCanvas.mozOpaque = true;
  7687. var ctx = tempCanvas.getContext('2d', { alpha: false });
  7688. ctx.save();
  7689. ctx.fillStyle = 'rgb(255, 255, 255)';
  7690. ctx.fillRect(0, 0, width, height);
  7691. ctx.restore();
  7692. return tempCanvas;
  7693. },
  7694. destroyCanvas: function destroyCanvas() {
  7695. var tempCanvas = tempCanvasCache;
  7696. if (tempCanvas) {
  7697. tempCanvas.width = 0;
  7698. tempCanvas.height = 0;
  7699. }
  7700. tempCanvasCache = null;
  7701. }
  7702. };
  7703. }();
  7704. var PDFThumbnailView = function () {
  7705. function PDFThumbnailView(_ref) {
  7706. var container = _ref.container,
  7707. id = _ref.id,
  7708. defaultViewport = _ref.defaultViewport,
  7709. linkService = _ref.linkService,
  7710. renderingQueue = _ref.renderingQueue,
  7711. _ref$disableCanvasToI = _ref.disableCanvasToImageConversion,
  7712. disableCanvasToImageConversion = _ref$disableCanvasToI === undefined ? false : _ref$disableCanvasToI,
  7713. _ref$l10n = _ref.l10n,
  7714. l10n = _ref$l10n === undefined ? _ui_utils.NullL10n : _ref$l10n;
  7715. _classCallCheck(this, PDFThumbnailView);
  7716. this.id = id;
  7717. this.renderingId = 'thumbnail' + id;
  7718. this.pageLabel = null;
  7719. this.pdfPage = null;
  7720. this.rotation = 0;
  7721. this.viewport = defaultViewport;
  7722. this.pdfPageRotate = defaultViewport.rotation;
  7723. this.linkService = linkService;
  7724. this.renderingQueue = renderingQueue;
  7725. this.renderTask = null;
  7726. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  7727. this.resume = null;
  7728. this.disableCanvasToImageConversion = disableCanvasToImageConversion;
  7729. this.pageWidth = this.viewport.width;
  7730. this.pageHeight = this.viewport.height;
  7731. this.pageRatio = this.pageWidth / this.pageHeight;
  7732. this.canvasWidth = THUMBNAIL_WIDTH;
  7733. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  7734. this.scale = this.canvasWidth / this.pageWidth;
  7735. this.l10n = l10n;
  7736. var anchor = document.createElement('a');
  7737. anchor.href = linkService.getAnchorUrl('#page=' + id);
  7738. this.l10n.get('thumb_page_title', { page: id }, 'Page {{page}}').then(function (msg) {
  7739. anchor.title = msg;
  7740. });
  7741. anchor.onclick = function () {
  7742. linkService.page = id;
  7743. return false;
  7744. };
  7745. this.anchor = anchor;
  7746. var div = document.createElement('div');
  7747. div.className = 'thumbnail';
  7748. div.setAttribute('data-page-number', this.id);
  7749. this.div = div;
  7750. var ring = document.createElement('div');
  7751. ring.className = 'thumbnailSelectionRing';
  7752. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  7753. ring.style.width = this.canvasWidth + borderAdjustment + 'px';
  7754. ring.style.height = this.canvasHeight + borderAdjustment + 'px';
  7755. this.ring = ring;
  7756. div.appendChild(ring);
  7757. anchor.appendChild(div);
  7758. container.appendChild(anchor);
  7759. }
  7760. _createClass(PDFThumbnailView, [{
  7761. key: 'setPdfPage',
  7762. value: function setPdfPage(pdfPage) {
  7763. this.pdfPage = pdfPage;
  7764. this.pdfPageRotate = pdfPage.rotate;
  7765. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  7766. this.viewport = pdfPage.getViewport(1, totalRotation);
  7767. this.reset();
  7768. }
  7769. }, {
  7770. key: 'reset',
  7771. value: function reset() {
  7772. this.cancelRendering();
  7773. this.pageWidth = this.viewport.width;
  7774. this.pageHeight = this.viewport.height;
  7775. this.pageRatio = this.pageWidth / this.pageHeight;
  7776. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  7777. this.scale = this.canvasWidth / this.pageWidth;
  7778. this.div.removeAttribute('data-loaded');
  7779. var ring = this.ring;
  7780. var childNodes = ring.childNodes;
  7781. for (var i = childNodes.length - 1; i >= 0; i--) {
  7782. ring.removeChild(childNodes[i]);
  7783. }
  7784. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  7785. ring.style.width = this.canvasWidth + borderAdjustment + 'px';
  7786. ring.style.height = this.canvasHeight + borderAdjustment + 'px';
  7787. if (this.canvas) {
  7788. this.canvas.width = 0;
  7789. this.canvas.height = 0;
  7790. delete this.canvas;
  7791. }
  7792. if (this.image) {
  7793. this.image.removeAttribute('src');
  7794. delete this.image;
  7795. }
  7796. }
  7797. }, {
  7798. key: 'update',
  7799. value: function update(rotation) {
  7800. if (typeof rotation !== 'undefined') {
  7801. this.rotation = rotation;
  7802. }
  7803. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  7804. this.viewport = this.viewport.clone({
  7805. scale: 1,
  7806. rotation: totalRotation
  7807. });
  7808. this.reset();
  7809. }
  7810. }, {
  7811. key: 'cancelRendering',
  7812. value: function cancelRendering() {
  7813. if (this.renderTask) {
  7814. this.renderTask.cancel();
  7815. this.renderTask = null;
  7816. }
  7817. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  7818. this.resume = null;
  7819. }
  7820. }, {
  7821. key: '_getPageDrawContext',
  7822. value: function _getPageDrawContext() {
  7823. var noCtxScale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  7824. var canvas = document.createElement('canvas');
  7825. this.canvas = canvas;
  7826. canvas.mozOpaque = true;
  7827. var ctx = canvas.getContext('2d', { alpha: false });
  7828. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  7829. canvas.width = this.canvasWidth * outputScale.sx | 0;
  7830. canvas.height = this.canvasHeight * outputScale.sy | 0;
  7831. canvas.style.width = this.canvasWidth + 'px';
  7832. canvas.style.height = this.canvasHeight + 'px';
  7833. if (!noCtxScale && outputScale.scaled) {
  7834. ctx.scale(outputScale.sx, outputScale.sy);
  7835. }
  7836. return ctx;
  7837. }
  7838. }, {
  7839. key: '_convertCanvasToImage',
  7840. value: function _convertCanvasToImage() {
  7841. var _this = this;
  7842. if (!this.canvas) {
  7843. return;
  7844. }
  7845. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  7846. return;
  7847. }
  7848. var id = this.renderingId;
  7849. var className = 'thumbnailImage';
  7850. if (this.disableCanvasToImageConversion) {
  7851. this.canvas.id = id;
  7852. this.canvas.className = className;
  7853. this.l10n.get('thumb_page_canvas', { page: this.pageId }, 'Thumbnail of Page {{page}}').then(function (msg) {
  7854. _this.canvas.setAttribute('aria-label', msg);
  7855. });
  7856. this.div.setAttribute('data-loaded', true);
  7857. this.ring.appendChild(this.canvas);
  7858. return;
  7859. }
  7860. var image = document.createElement('img');
  7861. image.id = id;
  7862. image.className = className;
  7863. this.l10n.get('thumb_page_canvas', { page: this.pageId }, 'Thumbnail of Page {{page}}').then(function (msg) {
  7864. image.setAttribute('aria-label', msg);
  7865. });
  7866. image.style.width = this.canvasWidth + 'px';
  7867. image.style.height = this.canvasHeight + 'px';
  7868. image.src = this.canvas.toDataURL();
  7869. this.image = image;
  7870. this.div.setAttribute('data-loaded', true);
  7871. this.ring.appendChild(image);
  7872. this.canvas.width = 0;
  7873. this.canvas.height = 0;
  7874. delete this.canvas;
  7875. }
  7876. }, {
  7877. key: 'draw',
  7878. value: function draw() {
  7879. var _this2 = this;
  7880. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  7881. console.error('Must be in new state before drawing');
  7882. return Promise.resolve(undefined);
  7883. }
  7884. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  7885. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  7886. var finishRenderTask = function finishRenderTask(error) {
  7887. if (renderTask === _this2.renderTask) {
  7888. _this2.renderTask = null;
  7889. }
  7890. if (error instanceof _pdfjsLib.RenderingCancelledException) {
  7891. renderCapability.resolve(undefined);
  7892. return;
  7893. }
  7894. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  7895. _this2._convertCanvasToImage();
  7896. if (!error) {
  7897. renderCapability.resolve(undefined);
  7898. } else {
  7899. renderCapability.reject(error);
  7900. }
  7901. };
  7902. var ctx = this._getPageDrawContext();
  7903. var drawViewport = this.viewport.clone({ scale: this.scale });
  7904. var renderContinueCallback = function renderContinueCallback(cont) {
  7905. if (!_this2.renderingQueue.isHighestPriority(_this2)) {
  7906. _this2.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  7907. _this2.resume = function () {
  7908. _this2.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  7909. cont();
  7910. };
  7911. return;
  7912. }
  7913. cont();
  7914. };
  7915. var renderContext = {
  7916. canvasContext: ctx,
  7917. viewport: drawViewport
  7918. };
  7919. var renderTask = this.renderTask = this.pdfPage.render(renderContext);
  7920. renderTask.onContinue = renderContinueCallback;
  7921. renderTask.promise.then(function () {
  7922. finishRenderTask(null);
  7923. }, function (error) {
  7924. finishRenderTask(error);
  7925. });
  7926. return renderCapability.promise;
  7927. }
  7928. }, {
  7929. key: 'setImage',
  7930. value: function setImage(pageView) {
  7931. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  7932. return;
  7933. }
  7934. var img = pageView.canvas;
  7935. if (!img) {
  7936. return;
  7937. }
  7938. if (!this.pdfPage) {
  7939. this.setPdfPage(pageView.pdfPage);
  7940. }
  7941. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  7942. var ctx = this._getPageDrawContext(true);
  7943. var canvas = ctx.canvas;
  7944. if (img.width <= 2 * canvas.width) {
  7945. ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height);
  7946. this._convertCanvasToImage();
  7947. return;
  7948. }
  7949. var reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
  7950. var reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
  7951. var reducedImage = TempImageFactory.getCanvas(reducedWidth, reducedHeight);
  7952. var reducedImageCtx = reducedImage.getContext('2d');
  7953. while (reducedWidth > img.width || reducedHeight > img.height) {
  7954. reducedWidth >>= 1;
  7955. reducedHeight >>= 1;
  7956. }
  7957. reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0, reducedWidth, reducedHeight);
  7958. while (reducedWidth > 2 * canvas.width) {
  7959. reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, reducedWidth >> 1, reducedHeight >> 1);
  7960. reducedWidth >>= 1;
  7961. reducedHeight >>= 1;
  7962. }
  7963. ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height);
  7964. this._convertCanvasToImage();
  7965. }
  7966. }, {
  7967. key: 'setPageLabel',
  7968. value: function setPageLabel(label) {
  7969. var _this3 = this;
  7970. this.pageLabel = typeof label === 'string' ? label : null;
  7971. this.l10n.get('thumb_page_title', { page: this.pageId }, 'Page {{page}}').then(function (msg) {
  7972. _this3.anchor.title = msg;
  7973. });
  7974. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  7975. return;
  7976. }
  7977. this.l10n.get('thumb_page_canvas', { page: this.pageId }, 'Thumbnail of Page {{page}}').then(function (ariaLabel) {
  7978. if (_this3.image) {
  7979. _this3.image.setAttribute('aria-label', ariaLabel);
  7980. } else if (_this3.disableCanvasToImageConversion && _this3.canvas) {
  7981. _this3.canvas.setAttribute('aria-label', ariaLabel);
  7982. }
  7983. });
  7984. }
  7985. }, {
  7986. key: 'pageId',
  7987. get: function get() {
  7988. return this.pageLabel !== null ? this.pageLabel : this.id;
  7989. }
  7990. }], [{
  7991. key: 'cleanup',
  7992. value: function cleanup() {
  7993. TempImageFactory.destroyCanvas();
  7994. }
  7995. }]);
  7996. return PDFThumbnailView;
  7997. }();
  7998. exports.PDFThumbnailView = PDFThumbnailView;
  7999. /***/ }),
  8000. /* 29 */
  8001. /***/ (function(module, exports, __webpack_require__) {
  8002. "use strict";
  8003. Object.defineProperty(exports, "__esModule", {
  8004. value: true
  8005. });
  8006. exports.PDFViewer = undefined;
  8007. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  8008. var _base_viewer = __webpack_require__(30);
  8009. var _ui_utils = __webpack_require__(6);
  8010. var _pdfjsLib = __webpack_require__(7);
  8011. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8012. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  8013. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  8014. var PDFViewer = function (_BaseViewer) {
  8015. _inherits(PDFViewer, _BaseViewer);
  8016. function PDFViewer() {
  8017. _classCallCheck(this, PDFViewer);
  8018. return _possibleConstructorReturn(this, (PDFViewer.__proto__ || Object.getPrototypeOf(PDFViewer)).apply(this, arguments));
  8019. }
  8020. _createClass(PDFViewer, [{
  8021. key: '_scrollIntoView',
  8022. value: function _scrollIntoView(_ref) {
  8023. var pageDiv = _ref.pageDiv,
  8024. _ref$pageSpot = _ref.pageSpot,
  8025. pageSpot = _ref$pageSpot === undefined ? null : _ref$pageSpot;
  8026. if (!pageSpot && !this.isInPresentationMode) {
  8027. var left = pageDiv.offsetLeft + pageDiv.clientLeft;
  8028. var right = left + pageDiv.clientWidth;
  8029. var _container = this.container,
  8030. scrollLeft = _container.scrollLeft,
  8031. clientWidth = _container.clientWidth;
  8032. if (this._scrollMode === _base_viewer.ScrollMode.HORIZONTAL || left < scrollLeft || right > scrollLeft + clientWidth) {
  8033. pageSpot = {
  8034. left: 0,
  8035. top: 0
  8036. };
  8037. }
  8038. }
  8039. (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
  8040. }
  8041. }, {
  8042. key: '_getVisiblePages',
  8043. value: function _getVisiblePages() {
  8044. if (!this.isInPresentationMode) {
  8045. return (0, _ui_utils.getVisibleElements)(this.container, this._pages, true, this._scrollMode === _base_viewer.ScrollMode.HORIZONTAL);
  8046. }
  8047. var currentPage = this._pages[this._currentPageNumber - 1];
  8048. var visible = [{
  8049. id: currentPage.id,
  8050. view: currentPage
  8051. }];
  8052. return {
  8053. first: currentPage,
  8054. last: currentPage,
  8055. views: visible
  8056. };
  8057. }
  8058. }, {
  8059. key: 'update',
  8060. value: function update() {
  8061. var visible = this._getVisiblePages();
  8062. var visiblePages = visible.views,
  8063. numVisiblePages = visiblePages.length;
  8064. if (numVisiblePages === 0) {
  8065. return;
  8066. }
  8067. this._resizeBuffer(numVisiblePages, visiblePages);
  8068. this.renderingQueue.renderHighestPriority(visible);
  8069. var currentId = this._currentPageNumber;
  8070. var stillFullyVisible = false;
  8071. for (var i = 0; i < numVisiblePages; ++i) {
  8072. var page = visiblePages[i];
  8073. if (page.percent < 100) {
  8074. break;
  8075. }
  8076. if (page.id === currentId) {
  8077. stillFullyVisible = true;
  8078. break;
  8079. }
  8080. }
  8081. if (!stillFullyVisible) {
  8082. currentId = visiblePages[0].id;
  8083. }
  8084. if (!this.isInPresentationMode) {
  8085. this._setCurrentPageNumber(currentId);
  8086. }
  8087. this._updateLocation(visible.first);
  8088. this.eventBus.dispatch('updateviewarea', {
  8089. source: this,
  8090. location: this._location
  8091. });
  8092. }
  8093. }, {
  8094. key: '_setDocumentViewerElement',
  8095. get: function get() {
  8096. return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this.viewer);
  8097. }
  8098. }, {
  8099. key: '_isScrollModeHorizontal',
  8100. get: function get() {
  8101. return this.isInPresentationMode ? false : this._scrollMode === _base_viewer.ScrollMode.HORIZONTAL;
  8102. }
  8103. }]);
  8104. return PDFViewer;
  8105. }(_base_viewer.BaseViewer);
  8106. exports.PDFViewer = PDFViewer;
  8107. /***/ }),
  8108. /* 30 */
  8109. /***/ (function(module, exports, __webpack_require__) {
  8110. "use strict";
  8111. Object.defineProperty(exports, "__esModule", {
  8112. value: true
  8113. });
  8114. exports.SpreadMode = exports.ScrollMode = exports.BaseViewer = undefined;
  8115. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  8116. var _ui_utils = __webpack_require__(6);
  8117. var _pdf_rendering_queue = __webpack_require__(10);
  8118. var _annotation_layer_builder = __webpack_require__(31);
  8119. var _pdfjsLib = __webpack_require__(7);
  8120. var _dom_events = __webpack_require__(14);
  8121. var _pdf_page_view = __webpack_require__(32);
  8122. var _pdf_link_service = __webpack_require__(23);
  8123. var _text_layer_builder = __webpack_require__(33);
  8124. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8125. var DEFAULT_CACHE_SIZE = 10;
  8126. var ScrollMode = {
  8127. VERTICAL: 0,
  8128. HORIZONTAL: 1,
  8129. WRAPPED: 2
  8130. };
  8131. var SpreadMode = {
  8132. NONE: 0,
  8133. ODD: 1,
  8134. EVEN: 2
  8135. };
  8136. function PDFPageViewBuffer(size) {
  8137. var data = [];
  8138. this.push = function (view) {
  8139. var i = data.indexOf(view);
  8140. if (i >= 0) {
  8141. data.splice(i, 1);
  8142. }
  8143. data.push(view);
  8144. if (data.length > size) {
  8145. data.shift().destroy();
  8146. }
  8147. };
  8148. this.resize = function (newSize, pagesToKeep) {
  8149. size = newSize;
  8150. if (pagesToKeep) {
  8151. var pageIdsToKeep = new Set();
  8152. for (var i = 0, iMax = pagesToKeep.length; i < iMax; ++i) {
  8153. pageIdsToKeep.add(pagesToKeep[i].id);
  8154. }
  8155. (0, _ui_utils.moveToEndOfArray)(data, function (page) {
  8156. return pageIdsToKeep.has(page.id);
  8157. });
  8158. }
  8159. while (data.length > size) {
  8160. data.shift().destroy();
  8161. }
  8162. };
  8163. }
  8164. function isSameScale(oldScale, newScale) {
  8165. if (newScale === oldScale) {
  8166. return true;
  8167. }
  8168. if (Math.abs(newScale - oldScale) < 1e-15) {
  8169. return true;
  8170. }
  8171. return false;
  8172. }
  8173. var BaseViewer = function () {
  8174. function BaseViewer(options) {
  8175. var _this = this;
  8176. _classCallCheck(this, BaseViewer);
  8177. if (this.constructor === BaseViewer) {
  8178. throw new Error('Cannot initialize BaseViewer.');
  8179. }
  8180. this._name = this.constructor.name;
  8181. this.container = options.container;
  8182. this.viewer = options.viewer || options.container.firstElementChild;
  8183. this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)();
  8184. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  8185. this.downloadManager = options.downloadManager || null;
  8186. this.findController = options.findController || null;
  8187. this.removePageBorders = options.removePageBorders || false;
  8188. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  8189. this.imageResourcesPath = options.imageResourcesPath || '';
  8190. this.renderInteractiveForms = options.renderInteractiveForms || false;
  8191. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  8192. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  8193. this.enableWebGL = options.enableWebGL || false;
  8194. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  8195. this.maxCanvasPixels = options.maxCanvasPixels;
  8196. this.l10n = options.l10n || _ui_utils.NullL10n;
  8197. this.defaultRenderingQueue = !options.renderingQueue;
  8198. if (this.defaultRenderingQueue) {
  8199. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  8200. this.renderingQueue.setViewer(this);
  8201. } else {
  8202. this.renderingQueue = options.renderingQueue;
  8203. }
  8204. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  8205. this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
  8206. this._resetView();
  8207. if (this.removePageBorders) {
  8208. this.viewer.classList.add('removePageBorders');
  8209. }
  8210. Promise.resolve().then(function () {
  8211. _this.eventBus.dispatch('baseviewerinit', { source: _this });
  8212. });
  8213. }
  8214. _createClass(BaseViewer, [{
  8215. key: 'getPageView',
  8216. value: function getPageView(index) {
  8217. return this._pages[index];
  8218. }
  8219. }, {
  8220. key: '_setCurrentPageNumber',
  8221. value: function _setCurrentPageNumber(val) {
  8222. var resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  8223. if (this._currentPageNumber === val) {
  8224. if (resetCurrentPageView) {
  8225. this._resetCurrentPageView();
  8226. }
  8227. return;
  8228. }
  8229. if (!(0 < val && val <= this.pagesCount)) {
  8230. console.error(this._name + '._setCurrentPageNumber: "' + val + '" is out of bounds.');
  8231. return;
  8232. }
  8233. var arg = {
  8234. source: this,
  8235. pageNumber: val,
  8236. pageLabel: this._pageLabels && this._pageLabels[val - 1]
  8237. };
  8238. this._currentPageNumber = val;
  8239. this.eventBus.dispatch('pagechanging', arg);
  8240. this.eventBus.dispatch('pagechange', arg);
  8241. if (resetCurrentPageView) {
  8242. this._resetCurrentPageView();
  8243. }
  8244. }
  8245. }, {
  8246. key: 'setDocument',
  8247. value: function setDocument(pdfDocument) {
  8248. var _this2 = this;
  8249. if (this.pdfDocument) {
  8250. this._cancelRendering();
  8251. this._resetView();
  8252. if (this.findController) {
  8253. this.findController.setDocument(null);
  8254. }
  8255. }
  8256. this.pdfDocument = pdfDocument;
  8257. if (!pdfDocument) {
  8258. return;
  8259. }
  8260. var pagesCount = pdfDocument.numPages;
  8261. var pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
  8262. this.pagesPromise = pagesCapability.promise;
  8263. pagesCapability.promise.then(function () {
  8264. _this2._pageViewsReady = true;
  8265. _this2.eventBus.dispatch('pagesloaded', {
  8266. source: _this2,
  8267. pagesCount: pagesCount
  8268. });
  8269. });
  8270. var isOnePageRenderedResolved = false;
  8271. var onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  8272. this.onePageRendered = onePageRenderedCapability.promise;
  8273. var bindOnAfterAndBeforeDraw = function bindOnAfterAndBeforeDraw(pageView) {
  8274. pageView.onBeforeDraw = function () {
  8275. _this2._buffer.push(pageView);
  8276. };
  8277. pageView.onAfterDraw = function () {
  8278. if (!isOnePageRenderedResolved) {
  8279. isOnePageRenderedResolved = true;
  8280. onePageRenderedCapability.resolve();
  8281. }
  8282. };
  8283. };
  8284. var firstPagePromise = pdfDocument.getPage(1);
  8285. this.firstPagePromise = firstPagePromise;
  8286. firstPagePromise.then(function (pdfPage) {
  8287. var scale = _this2.currentScale;
  8288. var viewport = pdfPage.getViewport(scale * _ui_utils.CSS_UNITS);
  8289. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  8290. var textLayerFactory = null;
  8291. if (_this2.textLayerMode !== _ui_utils.TextLayerMode.DISABLE) {
  8292. textLayerFactory = _this2;
  8293. }
  8294. var pageView = new _pdf_page_view.PDFPageView({
  8295. container: _this2._setDocumentViewerElement,
  8296. eventBus: _this2.eventBus,
  8297. id: pageNum,
  8298. scale: scale,
  8299. defaultViewport: viewport.clone(),
  8300. renderingQueue: _this2.renderingQueue,
  8301. textLayerFactory: textLayerFactory,
  8302. textLayerMode: _this2.textLayerMode,
  8303. annotationLayerFactory: _this2,
  8304. imageResourcesPath: _this2.imageResourcesPath,
  8305. renderInteractiveForms: _this2.renderInteractiveForms,
  8306. renderer: _this2.renderer,
  8307. enableWebGL: _this2.enableWebGL,
  8308. useOnlyCssZoom: _this2.useOnlyCssZoom,
  8309. maxCanvasPixels: _this2.maxCanvasPixels,
  8310. l10n: _this2.l10n
  8311. });
  8312. bindOnAfterAndBeforeDraw(pageView);
  8313. _this2._pages.push(pageView);
  8314. }
  8315. if (_this2._spreadMode !== SpreadMode.NONE) {
  8316. _this2._updateSpreadMode();
  8317. }
  8318. onePageRenderedCapability.promise.then(function () {
  8319. if (pdfDocument.loadingParams['disableAutoFetch']) {
  8320. pagesCapability.resolve();
  8321. return;
  8322. }
  8323. var getPagesLeft = pagesCount;
  8324. var _loop = function _loop(_pageNum) {
  8325. pdfDocument.getPage(_pageNum).then(function (pdfPage) {
  8326. var pageView = _this2._pages[_pageNum - 1];
  8327. if (!pageView.pdfPage) {
  8328. pageView.setPdfPage(pdfPage);
  8329. }
  8330. _this2.linkService.cachePageRef(_pageNum, pdfPage.ref);
  8331. if (--getPagesLeft === 0) {
  8332. pagesCapability.resolve();
  8333. }
  8334. }, function (reason) {
  8335. console.error('Unable to get page ' + _pageNum + ' to initialize viewer', reason);
  8336. if (--getPagesLeft === 0) {
  8337. pagesCapability.resolve();
  8338. }
  8339. });
  8340. };
  8341. for (var _pageNum = 1; _pageNum <= pagesCount; ++_pageNum) {
  8342. _loop(_pageNum);
  8343. }
  8344. });
  8345. _this2.eventBus.dispatch('pagesinit', { source: _this2 });
  8346. if (_this2.findController) {
  8347. _this2.findController.setDocument(pdfDocument);
  8348. }
  8349. if (_this2.defaultRenderingQueue) {
  8350. _this2.update();
  8351. }
  8352. }).catch(function (reason) {
  8353. console.error('Unable to initialize viewer', reason);
  8354. });
  8355. }
  8356. }, {
  8357. key: 'setPageLabels',
  8358. value: function setPageLabels(labels) {
  8359. if (!this.pdfDocument) {
  8360. return;
  8361. }
  8362. if (!labels) {
  8363. this._pageLabels = null;
  8364. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  8365. this._pageLabels = null;
  8366. console.error(this._name + '.setPageLabels: Invalid page labels.');
  8367. } else {
  8368. this._pageLabels = labels;
  8369. }
  8370. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  8371. var pageView = this._pages[i];
  8372. var label = this._pageLabels && this._pageLabels[i];
  8373. pageView.setPageLabel(label);
  8374. }
  8375. }
  8376. }, {
  8377. key: '_resetView',
  8378. value: function _resetView() {
  8379. this._pages = [];
  8380. this._currentPageNumber = 1;
  8381. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  8382. this._currentScaleValue = null;
  8383. this._pageLabels = null;
  8384. this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  8385. this._location = null;
  8386. this._pagesRotation = 0;
  8387. this._pagesRequests = [];
  8388. this._pageViewsReady = false;
  8389. this._scrollMode = ScrollMode.VERTICAL;
  8390. this._spreadMode = SpreadMode.NONE;
  8391. this.viewer.textContent = '';
  8392. this._updateScrollMode();
  8393. }
  8394. }, {
  8395. key: '_scrollUpdate',
  8396. value: function _scrollUpdate() {
  8397. if (this.pagesCount === 0) {
  8398. return;
  8399. }
  8400. this.update();
  8401. }
  8402. }, {
  8403. key: '_scrollIntoView',
  8404. value: function _scrollIntoView(_ref) {
  8405. var pageDiv = _ref.pageDiv,
  8406. _ref$pageSpot = _ref.pageSpot,
  8407. pageSpot = _ref$pageSpot === undefined ? null : _ref$pageSpot,
  8408. _ref$pageNumber = _ref.pageNumber,
  8409. pageNumber = _ref$pageNumber === undefined ? null : _ref$pageNumber;
  8410. throw new Error('Not implemented: _scrollIntoView');
  8411. }
  8412. }, {
  8413. key: '_setScaleDispatchEvent',
  8414. value: function _setScaleDispatchEvent(newScale, newValue) {
  8415. var preset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  8416. var arg = {
  8417. source: this,
  8418. scale: newScale,
  8419. presetValue: preset ? newValue : undefined
  8420. };
  8421. this.eventBus.dispatch('scalechanging', arg);
  8422. this.eventBus.dispatch('scalechange', arg);
  8423. }
  8424. }, {
  8425. key: '_setScaleUpdatePages',
  8426. value: function _setScaleUpdatePages(newScale, newValue) {
  8427. var noScroll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  8428. var preset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  8429. this._currentScaleValue = newValue.toString();
  8430. if (isSameScale(this._currentScale, newScale)) {
  8431. if (preset) {
  8432. this._setScaleDispatchEvent(newScale, newValue, true);
  8433. }
  8434. return;
  8435. }
  8436. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  8437. this._pages[i].update(newScale);
  8438. }
  8439. this._currentScale = newScale;
  8440. if (!noScroll) {
  8441. var page = this._currentPageNumber,
  8442. dest = void 0;
  8443. if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  8444. page = this._location.pageNumber;
  8445. dest = [null, { name: 'XYZ' }, this._location.left, this._location.top, null];
  8446. }
  8447. this.scrollPageIntoView({
  8448. pageNumber: page,
  8449. destArray: dest,
  8450. allowNegativeOffset: true
  8451. });
  8452. }
  8453. this._setScaleDispatchEvent(newScale, newValue, preset);
  8454. if (this.defaultRenderingQueue) {
  8455. this.update();
  8456. }
  8457. }
  8458. }, {
  8459. key: '_setScale',
  8460. value: function _setScale(value) {
  8461. var noScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  8462. var scale = parseFloat(value);
  8463. if (scale > 0) {
  8464. this._setScaleUpdatePages(scale, value, noScroll, false);
  8465. } else {
  8466. var currentPage = this._pages[this._currentPageNumber - 1];
  8467. if (!currentPage) {
  8468. return;
  8469. }
  8470. var noPadding = this.isInPresentationMode || this.removePageBorders;
  8471. var hPadding = noPadding ? 0 : _ui_utils.SCROLLBAR_PADDING;
  8472. var vPadding = noPadding ? 0 : _ui_utils.VERTICAL_PADDING;
  8473. if (!noPadding && this._isScrollModeHorizontal) {
  8474. var _ref2 = [vPadding, hPadding];
  8475. hPadding = _ref2[0];
  8476. vPadding = _ref2[1];
  8477. }
  8478. var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale;
  8479. var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  8480. switch (value) {
  8481. case 'page-actual':
  8482. scale = 1;
  8483. break;
  8484. case 'page-width':
  8485. scale = pageWidthScale;
  8486. break;
  8487. case 'page-height':
  8488. scale = pageHeightScale;
  8489. break;
  8490. case 'page-fit':
  8491. scale = Math.min(pageWidthScale, pageHeightScale);
  8492. break;
  8493. case 'auto':
  8494. var horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
  8495. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  8496. break;
  8497. default:
  8498. console.error(this._name + '._setScale: "' + value + '" is an unknown zoom value.');
  8499. return;
  8500. }
  8501. this._setScaleUpdatePages(scale, value, noScroll, true);
  8502. }
  8503. }
  8504. }, {
  8505. key: '_resetCurrentPageView',
  8506. value: function _resetCurrentPageView() {
  8507. if (this.isInPresentationMode) {
  8508. this._setScale(this._currentScaleValue, true);
  8509. }
  8510. var pageView = this._pages[this._currentPageNumber - 1];
  8511. this._scrollIntoView({ pageDiv: pageView.div });
  8512. }
  8513. }, {
  8514. key: 'scrollPageIntoView',
  8515. value: function scrollPageIntoView(params) {
  8516. if (!this.pdfDocument) {
  8517. return;
  8518. }
  8519. var pageNumber = params.pageNumber || 0;
  8520. var dest = params.destArray || null;
  8521. var allowNegativeOffset = params.allowNegativeOffset || false;
  8522. if (this.isInPresentationMode || !dest) {
  8523. this._setCurrentPageNumber(pageNumber, true);
  8524. return;
  8525. }
  8526. var pageView = this._pages[pageNumber - 1];
  8527. if (!pageView) {
  8528. console.error(this._name + '.scrollPageIntoView: Invalid "pageNumber" parameter.');
  8529. return;
  8530. }
  8531. var x = 0,
  8532. y = 0;
  8533. var width = 0,
  8534. height = 0,
  8535. widthScale = void 0,
  8536. heightScale = void 0;
  8537. var changeOrientation = pageView.rotation % 180 === 0 ? false : true;
  8538. var pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;
  8539. var pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;
  8540. var scale = 0;
  8541. switch (dest[1].name) {
  8542. case 'XYZ':
  8543. x = dest[2];
  8544. y = dest[3];
  8545. scale = dest[4];
  8546. x = x !== null ? x : 0;
  8547. y = y !== null ? y : pageHeight;
  8548. break;
  8549. case 'Fit':
  8550. case 'FitB':
  8551. scale = 'page-fit';
  8552. break;
  8553. case 'FitH':
  8554. case 'FitBH':
  8555. y = dest[2];
  8556. scale = 'page-width';
  8557. if (y === null && this._location) {
  8558. x = this._location.left;
  8559. y = this._location.top;
  8560. }
  8561. break;
  8562. case 'FitV':
  8563. case 'FitBV':
  8564. x = dest[2];
  8565. width = pageWidth;
  8566. height = pageHeight;
  8567. scale = 'page-height';
  8568. break;
  8569. case 'FitR':
  8570. x = dest[2];
  8571. y = dest[3];
  8572. width = dest[4] - x;
  8573. height = dest[5] - y;
  8574. var hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  8575. var vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  8576. widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;
  8577. heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;
  8578. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  8579. break;
  8580. default:
  8581. console.error(this._name + '.scrollPageIntoView: "' + dest[1].name + '" ' + 'is not a valid destination type.');
  8582. return;
  8583. }
  8584. if (scale && scale !== this._currentScale) {
  8585. this.currentScaleValue = scale;
  8586. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  8587. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  8588. }
  8589. if (scale === 'page-fit' && !dest[4]) {
  8590. this._scrollIntoView({
  8591. pageDiv: pageView.div,
  8592. pageNumber: pageNumber
  8593. });
  8594. return;
  8595. }
  8596. var boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  8597. var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  8598. var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  8599. if (!allowNegativeOffset) {
  8600. left = Math.max(left, 0);
  8601. top = Math.max(top, 0);
  8602. }
  8603. this._scrollIntoView({
  8604. pageDiv: pageView.div,
  8605. pageSpot: {
  8606. left: left,
  8607. top: top
  8608. },
  8609. pageNumber: pageNumber
  8610. });
  8611. }
  8612. }, {
  8613. key: '_resizeBuffer',
  8614. value: function _resizeBuffer(numVisiblePages, visiblePages) {
  8615. var suggestedCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
  8616. this._buffer.resize(suggestedCacheSize, visiblePages);
  8617. }
  8618. }, {
  8619. key: '_updateLocation',
  8620. value: function _updateLocation(firstPage) {
  8621. var currentScale = this._currentScale;
  8622. var currentScaleValue = this._currentScaleValue;
  8623. var normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  8624. var pageNumber = firstPage.id;
  8625. var pdfOpenParams = '#page=' + pageNumber;
  8626. pdfOpenParams += '&zoom=' + normalizedScaleValue;
  8627. var currentPageView = this._pages[pageNumber - 1];
  8628. var container = this.container;
  8629. var topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  8630. var intLeft = Math.round(topLeft[0]);
  8631. var intTop = Math.round(topLeft[1]);
  8632. pdfOpenParams += ',' + intLeft + ',' + intTop;
  8633. this._location = {
  8634. pageNumber: pageNumber,
  8635. scale: normalizedScaleValue,
  8636. top: intTop,
  8637. left: intLeft,
  8638. rotation: this._pagesRotation,
  8639. pdfOpenParams: pdfOpenParams
  8640. };
  8641. }
  8642. }, {
  8643. key: 'update',
  8644. value: function update() {
  8645. throw new Error('Not implemented: update');
  8646. }
  8647. }, {
  8648. key: 'containsElement',
  8649. value: function containsElement(element) {
  8650. return this.container.contains(element);
  8651. }
  8652. }, {
  8653. key: 'focus',
  8654. value: function focus() {
  8655. this.container.focus();
  8656. }
  8657. }, {
  8658. key: '_getVisiblePages',
  8659. value: function _getVisiblePages() {
  8660. throw new Error('Not implemented: _getVisiblePages');
  8661. }
  8662. }, {
  8663. key: 'cleanup',
  8664. value: function cleanup() {
  8665. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  8666. if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  8667. this._pages[i].reset();
  8668. }
  8669. }
  8670. }
  8671. }, {
  8672. key: '_cancelRendering',
  8673. value: function _cancelRendering() {
  8674. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  8675. if (this._pages[i]) {
  8676. this._pages[i].cancelRendering();
  8677. }
  8678. }
  8679. }
  8680. }, {
  8681. key: '_ensurePdfPageLoaded',
  8682. value: function _ensurePdfPageLoaded(pageView) {
  8683. var _this3 = this;
  8684. if (pageView.pdfPage) {
  8685. return Promise.resolve(pageView.pdfPage);
  8686. }
  8687. var pageNumber = pageView.id;
  8688. if (this._pagesRequests[pageNumber]) {
  8689. return this._pagesRequests[pageNumber];
  8690. }
  8691. var promise = this.pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  8692. if (!pageView.pdfPage) {
  8693. pageView.setPdfPage(pdfPage);
  8694. }
  8695. _this3._pagesRequests[pageNumber] = null;
  8696. return pdfPage;
  8697. }).catch(function (reason) {
  8698. console.error('Unable to get page for page view', reason);
  8699. _this3._pagesRequests[pageNumber] = null;
  8700. });
  8701. this._pagesRequests[pageNumber] = promise;
  8702. return promise;
  8703. }
  8704. }, {
  8705. key: 'forceRendering',
  8706. value: function forceRendering(currentlyVisiblePages) {
  8707. var _this4 = this;
  8708. var visiblePages = currentlyVisiblePages || this._getVisiblePages();
  8709. var scrollAhead = this._isScrollModeHorizontal ? this.scroll.right : this.scroll.down;
  8710. var pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead);
  8711. if (pageView) {
  8712. this._ensurePdfPageLoaded(pageView).then(function () {
  8713. _this4.renderingQueue.renderView(pageView);
  8714. });
  8715. return true;
  8716. }
  8717. return false;
  8718. }
  8719. }, {
  8720. key: 'createTextLayerBuilder',
  8721. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  8722. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  8723. return new _text_layer_builder.TextLayerBuilder({
  8724. textLayerDiv: textLayerDiv,
  8725. eventBus: this.eventBus,
  8726. pageIndex: pageIndex,
  8727. viewport: viewport,
  8728. findController: this.isInPresentationMode ? null : this.findController,
  8729. enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection
  8730. });
  8731. }
  8732. }, {
  8733. key: 'createAnnotationLayerBuilder',
  8734. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  8735. var imageResourcesPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  8736. var renderInteractiveForms = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  8737. var l10n = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _ui_utils.NullL10n;
  8738. return new _annotation_layer_builder.AnnotationLayerBuilder({
  8739. pageDiv: pageDiv,
  8740. pdfPage: pdfPage,
  8741. imageResourcesPath: imageResourcesPath,
  8742. renderInteractiveForms: renderInteractiveForms,
  8743. linkService: this.linkService,
  8744. downloadManager: this.downloadManager,
  8745. l10n: l10n
  8746. });
  8747. }
  8748. }, {
  8749. key: 'getPagesOverview',
  8750. value: function getPagesOverview() {
  8751. var pagesOverview = this._pages.map(function (pageView) {
  8752. var viewport = pageView.pdfPage.getViewport(1);
  8753. return {
  8754. width: viewport.width,
  8755. height: viewport.height,
  8756. rotation: viewport.rotation
  8757. };
  8758. });
  8759. if (!this.enablePrintAutoRotate) {
  8760. return pagesOverview;
  8761. }
  8762. var isFirstPagePortrait = (0, _ui_utils.isPortraitOrientation)(pagesOverview[0]);
  8763. return pagesOverview.map(function (size) {
  8764. if (isFirstPagePortrait === (0, _ui_utils.isPortraitOrientation)(size)) {
  8765. return size;
  8766. }
  8767. return {
  8768. width: size.height,
  8769. height: size.width,
  8770. rotation: (size.rotation + 90) % 360
  8771. };
  8772. });
  8773. }
  8774. }, {
  8775. key: '_updateScrollMode',
  8776. value: function _updateScrollMode() {
  8777. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  8778. var scrollMode = this._scrollMode,
  8779. viewer = this.viewer;
  8780. viewer.classList.toggle('scrollHorizontal', scrollMode === ScrollMode.HORIZONTAL);
  8781. viewer.classList.toggle('scrollWrapped', scrollMode === ScrollMode.WRAPPED);
  8782. if (!this.pdfDocument || !pageNumber) {
  8783. return;
  8784. }
  8785. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  8786. this._setScale(this._currentScaleValue, true);
  8787. }
  8788. this.scrollPageIntoView({ pageNumber: pageNumber });
  8789. this.update();
  8790. }
  8791. }, {
  8792. key: '_updateSpreadMode',
  8793. value: function _updateSpreadMode() {
  8794. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  8795. if (!this.pdfDocument) {
  8796. return;
  8797. }
  8798. var viewer = this.viewer,
  8799. pages = this._pages;
  8800. viewer.textContent = '';
  8801. if (this._spreadMode === SpreadMode.NONE) {
  8802. for (var i = 0, iMax = pages.length; i < iMax; ++i) {
  8803. viewer.appendChild(pages[i].div);
  8804. }
  8805. } else {
  8806. var parity = this._spreadMode - 1;
  8807. var spread = null;
  8808. for (var _i = 0, _iMax = pages.length; _i < _iMax; ++_i) {
  8809. if (spread === null) {
  8810. spread = document.createElement('div');
  8811. spread.className = 'spread';
  8812. viewer.appendChild(spread);
  8813. } else if (_i % 2 === parity) {
  8814. spread = spread.cloneNode(false);
  8815. viewer.appendChild(spread);
  8816. }
  8817. spread.appendChild(pages[_i].div);
  8818. }
  8819. }
  8820. if (!pageNumber) {
  8821. return;
  8822. }
  8823. this.scrollPageIntoView({ pageNumber: pageNumber });
  8824. this.update();
  8825. }
  8826. }, {
  8827. key: 'pagesCount',
  8828. get: function get() {
  8829. return this._pages.length;
  8830. }
  8831. }, {
  8832. key: 'pageViewsReady',
  8833. get: function get() {
  8834. return this._pageViewsReady;
  8835. }
  8836. }, {
  8837. key: 'currentPageNumber',
  8838. get: function get() {
  8839. return this._currentPageNumber;
  8840. },
  8841. set: function set(val) {
  8842. if (!Number.isInteger(val)) {
  8843. throw new Error('Invalid page number.');
  8844. }
  8845. if (!this.pdfDocument) {
  8846. return;
  8847. }
  8848. this._setCurrentPageNumber(val, true);
  8849. }
  8850. }, {
  8851. key: 'currentPageLabel',
  8852. get: function get() {
  8853. return this._pageLabels && this._pageLabels[this._currentPageNumber - 1];
  8854. },
  8855. set: function set(val) {
  8856. var pageNumber = val | 0;
  8857. if (this._pageLabels) {
  8858. var i = this._pageLabels.indexOf(val);
  8859. if (i >= 0) {
  8860. pageNumber = i + 1;
  8861. }
  8862. }
  8863. this.currentPageNumber = pageNumber;
  8864. }
  8865. }, {
  8866. key: 'currentScale',
  8867. get: function get() {
  8868. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
  8869. },
  8870. set: function set(val) {
  8871. if (isNaN(val)) {
  8872. throw new Error('Invalid numeric scale');
  8873. }
  8874. if (!this.pdfDocument) {
  8875. return;
  8876. }
  8877. this._setScale(val, false);
  8878. }
  8879. }, {
  8880. key: 'currentScaleValue',
  8881. get: function get() {
  8882. return this._currentScaleValue;
  8883. },
  8884. set: function set(val) {
  8885. if (!this.pdfDocument) {
  8886. return;
  8887. }
  8888. this._setScale(val, false);
  8889. }
  8890. }, {
  8891. key: 'pagesRotation',
  8892. get: function get() {
  8893. return this._pagesRotation;
  8894. },
  8895. set: function set(rotation) {
  8896. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  8897. throw new Error('Invalid pages rotation angle.');
  8898. }
  8899. if (!this.pdfDocument) {
  8900. return;
  8901. }
  8902. if (this._pagesRotation === rotation) {
  8903. return;
  8904. }
  8905. this._pagesRotation = rotation;
  8906. var pageNumber = this._currentPageNumber;
  8907. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  8908. var pageView = this._pages[i];
  8909. pageView.update(pageView.scale, rotation);
  8910. }
  8911. if (this._currentScaleValue) {
  8912. this._setScale(this._currentScaleValue, true);
  8913. }
  8914. this.eventBus.dispatch('rotationchanging', {
  8915. source: this,
  8916. pagesRotation: rotation,
  8917. pageNumber: pageNumber
  8918. });
  8919. if (this.defaultRenderingQueue) {
  8920. this.update();
  8921. }
  8922. }
  8923. }, {
  8924. key: '_setDocumentViewerElement',
  8925. get: function get() {
  8926. throw new Error('Not implemented: _setDocumentViewerElement');
  8927. }
  8928. }, {
  8929. key: '_isScrollModeHorizontal',
  8930. get: function get() {
  8931. throw new Error('Not implemented: _isScrollModeHorizontal');
  8932. }
  8933. }, {
  8934. key: 'isInPresentationMode',
  8935. get: function get() {
  8936. return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
  8937. }
  8938. }, {
  8939. key: 'isChangingPresentationMode',
  8940. get: function get() {
  8941. return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
  8942. }
  8943. }, {
  8944. key: 'isHorizontalScrollbarEnabled',
  8945. get: function get() {
  8946. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  8947. }
  8948. }, {
  8949. key: 'isVerticalScrollbarEnabled',
  8950. get: function get() {
  8951. return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight;
  8952. }
  8953. }, {
  8954. key: 'hasEqualPageSizes',
  8955. get: function get() {
  8956. var firstPageView = this._pages[0];
  8957. for (var i = 1, ii = this._pages.length; i < ii; ++i) {
  8958. var pageView = this._pages[i];
  8959. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  8960. return false;
  8961. }
  8962. }
  8963. return true;
  8964. }
  8965. }, {
  8966. key: 'scrollMode',
  8967. get: function get() {
  8968. return this._scrollMode;
  8969. },
  8970. set: function set(mode) {
  8971. if (this._scrollMode === mode) {
  8972. return;
  8973. }
  8974. if (!Number.isInteger(mode) || !Object.values(ScrollMode).includes(mode)) {
  8975. throw new Error('Invalid scroll mode: ' + mode);
  8976. }
  8977. this._scrollMode = mode;
  8978. this.eventBus.dispatch('scrollmodechanged', {
  8979. source: this,
  8980. mode: mode
  8981. });
  8982. this._updateScrollMode(this._currentPageNumber);
  8983. }
  8984. }, {
  8985. key: 'spreadMode',
  8986. get: function get() {
  8987. return this._spreadMode;
  8988. },
  8989. set: function set(mode) {
  8990. if (this._spreadMode === mode) {
  8991. return;
  8992. }
  8993. if (!Number.isInteger(mode) || !Object.values(SpreadMode).includes(mode)) {
  8994. throw new Error('Invalid spread mode: ' + mode);
  8995. }
  8996. this._spreadMode = mode;
  8997. this.eventBus.dispatch('spreadmodechanged', {
  8998. source: this,
  8999. mode: mode
  9000. });
  9001. this._updateSpreadMode(this._currentPageNumber);
  9002. }
  9003. }]);
  9004. return BaseViewer;
  9005. }();
  9006. exports.BaseViewer = BaseViewer;
  9007. exports.ScrollMode = ScrollMode;
  9008. exports.SpreadMode = SpreadMode;
  9009. /***/ }),
  9010. /* 31 */
  9011. /***/ (function(module, exports, __webpack_require__) {
  9012. "use strict";
  9013. Object.defineProperty(exports, "__esModule", {
  9014. value: true
  9015. });
  9016. exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = undefined;
  9017. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  9018. var _pdfjsLib = __webpack_require__(7);
  9019. var _ui_utils = __webpack_require__(6);
  9020. var _pdf_link_service = __webpack_require__(23);
  9021. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9022. var AnnotationLayerBuilder = function () {
  9023. function AnnotationLayerBuilder(_ref) {
  9024. var pageDiv = _ref.pageDiv,
  9025. pdfPage = _ref.pdfPage,
  9026. linkService = _ref.linkService,
  9027. downloadManager = _ref.downloadManager,
  9028. _ref$imageResourcesPa = _ref.imageResourcesPath,
  9029. imageResourcesPath = _ref$imageResourcesPa === undefined ? '' : _ref$imageResourcesPa,
  9030. _ref$renderInteractiv = _ref.renderInteractiveForms,
  9031. renderInteractiveForms = _ref$renderInteractiv === undefined ? false : _ref$renderInteractiv,
  9032. _ref$l10n = _ref.l10n,
  9033. l10n = _ref$l10n === undefined ? _ui_utils.NullL10n : _ref$l10n;
  9034. _classCallCheck(this, AnnotationLayerBuilder);
  9035. this.pageDiv = pageDiv;
  9036. this.pdfPage = pdfPage;
  9037. this.linkService = linkService;
  9038. this.downloadManager = downloadManager;
  9039. this.imageResourcesPath = imageResourcesPath;
  9040. this.renderInteractiveForms = renderInteractiveForms;
  9041. this.l10n = l10n;
  9042. this.div = null;
  9043. this._cancelled = false;
  9044. }
  9045. _createClass(AnnotationLayerBuilder, [{
  9046. key: 'render',
  9047. value: function render(viewport) {
  9048. var _this = this;
  9049. var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'display';
  9050. this.pdfPage.getAnnotations({ intent: intent }).then(function (annotations) {
  9051. if (_this._cancelled) {
  9052. return;
  9053. }
  9054. var parameters = {
  9055. viewport: viewport.clone({ dontFlip: true }),
  9056. div: _this.div,
  9057. annotations: annotations,
  9058. page: _this.pdfPage,
  9059. imageResourcesPath: _this.imageResourcesPath,
  9060. renderInteractiveForms: _this.renderInteractiveForms,
  9061. linkService: _this.linkService,
  9062. downloadManager: _this.downloadManager
  9063. };
  9064. if (_this.div) {
  9065. _pdfjsLib.AnnotationLayer.update(parameters);
  9066. } else {
  9067. if (annotations.length === 0) {
  9068. return;
  9069. }
  9070. _this.div = document.createElement('div');
  9071. _this.div.className = 'annotationLayer';
  9072. _this.pageDiv.appendChild(_this.div);
  9073. parameters.div = _this.div;
  9074. _pdfjsLib.AnnotationLayer.render(parameters);
  9075. _this.l10n.translate(_this.div);
  9076. }
  9077. });
  9078. }
  9079. }, {
  9080. key: 'cancel',
  9081. value: function cancel() {
  9082. this._cancelled = true;
  9083. }
  9084. }, {
  9085. key: 'hide',
  9086. value: function hide() {
  9087. if (!this.div) {
  9088. return;
  9089. }
  9090. this.div.setAttribute('hidden', 'true');
  9091. }
  9092. }]);
  9093. return AnnotationLayerBuilder;
  9094. }();
  9095. var DefaultAnnotationLayerFactory = function () {
  9096. function DefaultAnnotationLayerFactory() {
  9097. _classCallCheck(this, DefaultAnnotationLayerFactory);
  9098. }
  9099. _createClass(DefaultAnnotationLayerFactory, [{
  9100. key: 'createAnnotationLayerBuilder',
  9101. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  9102. var imageResourcesPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  9103. var renderInteractiveForms = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9104. var l10n = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _ui_utils.NullL10n;
  9105. return new AnnotationLayerBuilder({
  9106. pageDiv: pageDiv,
  9107. pdfPage: pdfPage,
  9108. imageResourcesPath: imageResourcesPath,
  9109. renderInteractiveForms: renderInteractiveForms,
  9110. linkService: new _pdf_link_service.SimpleLinkService(),
  9111. l10n: l10n
  9112. });
  9113. }
  9114. }]);
  9115. return DefaultAnnotationLayerFactory;
  9116. }();
  9117. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  9118. exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
  9119. /***/ }),
  9120. /* 32 */
  9121. /***/ (function(module, exports, __webpack_require__) {
  9122. "use strict";
  9123. Object.defineProperty(exports, "__esModule", {
  9124. value: true
  9125. });
  9126. exports.PDFPageView = undefined;
  9127. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  9128. var _ui_utils = __webpack_require__(6);
  9129. var _pdfjsLib = __webpack_require__(7);
  9130. var _dom_events = __webpack_require__(14);
  9131. var _pdf_rendering_queue = __webpack_require__(10);
  9132. var _viewer_compatibility = __webpack_require__(13);
  9133. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9134. var MAX_CANVAS_PIXELS = _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216;
  9135. var PDFPageView = function () {
  9136. function PDFPageView(options) {
  9137. _classCallCheck(this, PDFPageView);
  9138. var container = options.container;
  9139. var defaultViewport = options.defaultViewport;
  9140. this.id = options.id;
  9141. this.renderingId = 'page' + this.id;
  9142. this.pdfPage = null;
  9143. this.pageLabel = null;
  9144. this.rotation = 0;
  9145. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  9146. this.viewport = defaultViewport;
  9147. this.pdfPageRotate = defaultViewport.rotation;
  9148. this.hasRestrictedScaling = false;
  9149. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  9150. this.imageResourcesPath = options.imageResourcesPath || '';
  9151. this.renderInteractiveForms = options.renderInteractiveForms || false;
  9152. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  9153. this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
  9154. this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)();
  9155. this.renderingQueue = options.renderingQueue;
  9156. this.textLayerFactory = options.textLayerFactory;
  9157. this.annotationLayerFactory = options.annotationLayerFactory;
  9158. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  9159. this.enableWebGL = options.enableWebGL || false;
  9160. this.l10n = options.l10n || _ui_utils.NullL10n;
  9161. this.paintTask = null;
  9162. this.paintedViewportMap = new WeakMap();
  9163. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  9164. this.resume = null;
  9165. this.error = null;
  9166. this.onBeforeDraw = null;
  9167. this.onAfterDraw = null;
  9168. this.annotationLayer = null;
  9169. this.textLayer = null;
  9170. this.zoomLayer = null;
  9171. var div = document.createElement('div');
  9172. div.className = 'page';
  9173. div.style.width = Math.floor(this.viewport.width) + 'px';
  9174. div.style.height = Math.floor(this.viewport.height) + 'px';
  9175. div.setAttribute('data-page-number', this.id);
  9176. this.div = div;
  9177. container.appendChild(div);
  9178. }
  9179. _createClass(PDFPageView, [{
  9180. key: 'setPdfPage',
  9181. value: function setPdfPage(pdfPage) {
  9182. this.pdfPage = pdfPage;
  9183. this.pdfPageRotate = pdfPage.rotate;
  9184. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  9185. this.viewport = pdfPage.getViewport(this.scale * _ui_utils.CSS_UNITS, totalRotation);
  9186. this.stats = pdfPage.stats;
  9187. this.reset();
  9188. }
  9189. }, {
  9190. key: 'destroy',
  9191. value: function destroy() {
  9192. this.reset();
  9193. if (this.pdfPage) {
  9194. this.pdfPage.cleanup();
  9195. }
  9196. }
  9197. }, {
  9198. key: '_resetZoomLayer',
  9199. value: function _resetZoomLayer() {
  9200. var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9201. if (!this.zoomLayer) {
  9202. return;
  9203. }
  9204. var zoomLayerCanvas = this.zoomLayer.firstChild;
  9205. this.paintedViewportMap.delete(zoomLayerCanvas);
  9206. zoomLayerCanvas.width = 0;
  9207. zoomLayerCanvas.height = 0;
  9208. if (removeFromDOM) {
  9209. this.zoomLayer.remove();
  9210. }
  9211. this.zoomLayer = null;
  9212. }
  9213. }, {
  9214. key: 'reset',
  9215. value: function reset() {
  9216. var keepZoomLayer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9217. var keepAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9218. this.cancelRendering(keepAnnotations);
  9219. var div = this.div;
  9220. div.style.width = Math.floor(this.viewport.width) + 'px';
  9221. div.style.height = Math.floor(this.viewport.height) + 'px';
  9222. var childNodes = div.childNodes;
  9223. var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
  9224. var currentAnnotationNode = keepAnnotations && this.annotationLayer && this.annotationLayer.div || null;
  9225. for (var i = childNodes.length - 1; i >= 0; i--) {
  9226. var node = childNodes[i];
  9227. if (currentZoomLayerNode === node || currentAnnotationNode === node) {
  9228. continue;
  9229. }
  9230. div.removeChild(node);
  9231. }
  9232. div.removeAttribute('data-loaded');
  9233. if (currentAnnotationNode) {
  9234. this.annotationLayer.hide();
  9235. } else if (this.annotationLayer) {
  9236. this.annotationLayer.cancel();
  9237. this.annotationLayer = null;
  9238. }
  9239. if (!currentZoomLayerNode) {
  9240. if (this.canvas) {
  9241. this.paintedViewportMap.delete(this.canvas);
  9242. this.canvas.width = 0;
  9243. this.canvas.height = 0;
  9244. delete this.canvas;
  9245. }
  9246. this._resetZoomLayer();
  9247. }
  9248. if (this.svg) {
  9249. this.paintedViewportMap.delete(this.svg);
  9250. delete this.svg;
  9251. }
  9252. this.loadingIconDiv = document.createElement('div');
  9253. this.loadingIconDiv.className = 'loadingIcon';
  9254. div.appendChild(this.loadingIconDiv);
  9255. }
  9256. }, {
  9257. key: 'update',
  9258. value: function update(scale, rotation) {
  9259. this.scale = scale || this.scale;
  9260. if (typeof rotation !== 'undefined') {
  9261. this.rotation = rotation;
  9262. }
  9263. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  9264. this.viewport = this.viewport.clone({
  9265. scale: this.scale * _ui_utils.CSS_UNITS,
  9266. rotation: totalRotation
  9267. });
  9268. if (this.svg) {
  9269. this.cssTransform(this.svg, true);
  9270. this.eventBus.dispatch('pagerendered', {
  9271. source: this,
  9272. pageNumber: this.id,
  9273. cssTransform: true
  9274. });
  9275. return;
  9276. }
  9277. var isScalingRestricted = false;
  9278. if (this.canvas && this.maxCanvasPixels > 0) {
  9279. var outputScale = this.outputScale;
  9280. if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > this.maxCanvasPixels) {
  9281. isScalingRestricted = true;
  9282. }
  9283. }
  9284. if (this.canvas) {
  9285. if (this.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
  9286. this.cssTransform(this.canvas, true);
  9287. this.eventBus.dispatch('pagerendered', {
  9288. source: this,
  9289. pageNumber: this.id,
  9290. cssTransform: true
  9291. });
  9292. return;
  9293. }
  9294. if (!this.zoomLayer && !this.canvas.hasAttribute('hidden')) {
  9295. this.zoomLayer = this.canvas.parentNode;
  9296. this.zoomLayer.style.position = 'absolute';
  9297. }
  9298. }
  9299. if (this.zoomLayer) {
  9300. this.cssTransform(this.zoomLayer.firstChild);
  9301. }
  9302. this.reset(true, true);
  9303. }
  9304. }, {
  9305. key: 'cancelRendering',
  9306. value: function cancelRendering() {
  9307. var keepAnnotations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9308. var renderingState = this.renderingState;
  9309. if (this.paintTask) {
  9310. this.paintTask.cancel();
  9311. this.paintTask = null;
  9312. }
  9313. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  9314. this.resume = null;
  9315. if (this.textLayer) {
  9316. this.textLayer.cancel();
  9317. this.textLayer = null;
  9318. }
  9319. if (!keepAnnotations && this.annotationLayer) {
  9320. this.annotationLayer.cancel();
  9321. this.annotationLayer = null;
  9322. }
  9323. if (renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  9324. this.eventBus.dispatch('pagecancelled', {
  9325. source: this,
  9326. pageNumber: this.id,
  9327. renderingState: renderingState
  9328. });
  9329. }
  9330. }
  9331. }, {
  9332. key: 'cssTransform',
  9333. value: function cssTransform(target) {
  9334. var redrawAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9335. var width = this.viewport.width;
  9336. var height = this.viewport.height;
  9337. var div = this.div;
  9338. target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + 'px';
  9339. target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + 'px';
  9340. var relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
  9341. var absRotation = Math.abs(relativeRotation);
  9342. var scaleX = 1,
  9343. scaleY = 1;
  9344. if (absRotation === 90 || absRotation === 270) {
  9345. scaleX = height / width;
  9346. scaleY = width / height;
  9347. }
  9348. var cssTransform = 'rotate(' + relativeRotation + 'deg) ' + 'scale(' + scaleX + ',' + scaleY + ')';
  9349. target.style.transform = cssTransform;
  9350. if (this.textLayer) {
  9351. var textLayerViewport = this.textLayer.viewport;
  9352. var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
  9353. var textAbsRotation = Math.abs(textRelativeRotation);
  9354. var scale = width / textLayerViewport.width;
  9355. if (textAbsRotation === 90 || textAbsRotation === 270) {
  9356. scale = width / textLayerViewport.height;
  9357. }
  9358. var textLayerDiv = this.textLayer.textLayerDiv;
  9359. var transX = void 0,
  9360. transY = void 0;
  9361. switch (textAbsRotation) {
  9362. case 0:
  9363. transX = transY = 0;
  9364. break;
  9365. case 90:
  9366. transX = 0;
  9367. transY = '-' + textLayerDiv.style.height;
  9368. break;
  9369. case 180:
  9370. transX = '-' + textLayerDiv.style.width;
  9371. transY = '-' + textLayerDiv.style.height;
  9372. break;
  9373. case 270:
  9374. transX = '-' + textLayerDiv.style.width;
  9375. transY = 0;
  9376. break;
  9377. default:
  9378. console.error('Bad rotation value.');
  9379. break;
  9380. }
  9381. textLayerDiv.style.transform = 'rotate(' + textAbsRotation + 'deg) ' + 'scale(' + scale + ', ' + scale + ') ' + 'translate(' + transX + ', ' + transY + ')';
  9382. textLayerDiv.style.transformOrigin = '0% 0%';
  9383. }
  9384. if (redrawAnnotations && this.annotationLayer) {
  9385. this.annotationLayer.render(this.viewport, 'display');
  9386. }
  9387. }
  9388. }, {
  9389. key: 'getPagePoint',
  9390. value: function getPagePoint(x, y) {
  9391. return this.viewport.convertToPdfPoint(x, y);
  9392. }
  9393. }, {
  9394. key: 'draw',
  9395. value: function draw() {
  9396. var _this = this;
  9397. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  9398. console.error('Must be in new state before drawing');
  9399. this.reset();
  9400. }
  9401. if (!this.pdfPage) {
  9402. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  9403. return Promise.reject(new Error('Page is not loaded'));
  9404. }
  9405. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  9406. var pdfPage = this.pdfPage;
  9407. var div = this.div;
  9408. var canvasWrapper = document.createElement('div');
  9409. canvasWrapper.style.width = div.style.width;
  9410. canvasWrapper.style.height = div.style.height;
  9411. canvasWrapper.classList.add('canvasWrapper');
  9412. if (this.annotationLayer && this.annotationLayer.div) {
  9413. div.insertBefore(canvasWrapper, this.annotationLayer.div);
  9414. } else {
  9415. div.appendChild(canvasWrapper);
  9416. }
  9417. var textLayer = null;
  9418. if (this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && this.textLayerFactory) {
  9419. var textLayerDiv = document.createElement('div');
  9420. textLayerDiv.className = 'textLayer';
  9421. textLayerDiv.style.width = canvasWrapper.style.width;
  9422. textLayerDiv.style.height = canvasWrapper.style.height;
  9423. if (this.annotationLayer && this.annotationLayer.div) {
  9424. div.insertBefore(textLayerDiv, this.annotationLayer.div);
  9425. } else {
  9426. div.appendChild(textLayerDiv);
  9427. }
  9428. textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.textLayerMode === _ui_utils.TextLayerMode.ENABLE_ENHANCE);
  9429. }
  9430. this.textLayer = textLayer;
  9431. var renderContinueCallback = null;
  9432. if (this.renderingQueue) {
  9433. renderContinueCallback = function renderContinueCallback(cont) {
  9434. if (!_this.renderingQueue.isHighestPriority(_this)) {
  9435. _this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  9436. _this.resume = function () {
  9437. _this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  9438. cont();
  9439. };
  9440. return;
  9441. }
  9442. cont();
  9443. };
  9444. }
  9445. var finishPaintTask = function finishPaintTask(error) {
  9446. if (paintTask === _this.paintTask) {
  9447. _this.paintTask = null;
  9448. }
  9449. if (error instanceof _pdfjsLib.RenderingCancelledException) {
  9450. _this.error = null;
  9451. return Promise.resolve(undefined);
  9452. }
  9453. _this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  9454. if (_this.loadingIconDiv) {
  9455. div.removeChild(_this.loadingIconDiv);
  9456. delete _this.loadingIconDiv;
  9457. }
  9458. _this._resetZoomLayer(true);
  9459. _this.error = error;
  9460. _this.stats = pdfPage.stats;
  9461. if (_this.onAfterDraw) {
  9462. _this.onAfterDraw();
  9463. }
  9464. _this.eventBus.dispatch('pagerendered', {
  9465. source: _this,
  9466. pageNumber: _this.id,
  9467. cssTransform: false
  9468. });
  9469. if (error) {
  9470. return Promise.reject(error);
  9471. }
  9472. return Promise.resolve(undefined);
  9473. };
  9474. var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
  9475. paintTask.onRenderContinue = renderContinueCallback;
  9476. this.paintTask = paintTask;
  9477. var resultPromise = paintTask.promise.then(function () {
  9478. return finishPaintTask(null).then(function () {
  9479. if (textLayer) {
  9480. var readableStream = pdfPage.streamTextContent({ normalizeWhitespace: true });
  9481. textLayer.setTextContentStream(readableStream);
  9482. textLayer.render();
  9483. }
  9484. });
  9485. }, function (reason) {
  9486. return finishPaintTask(reason);
  9487. });
  9488. if (this.annotationLayerFactory) {
  9489. if (!this.annotationLayer) {
  9490. this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this.imageResourcesPath, this.renderInteractiveForms, this.l10n);
  9491. }
  9492. this.annotationLayer.render(this.viewport, 'display');
  9493. }
  9494. div.setAttribute('data-loaded', true);
  9495. if (this.onBeforeDraw) {
  9496. this.onBeforeDraw();
  9497. }
  9498. return resultPromise;
  9499. }
  9500. }, {
  9501. key: 'paintOnCanvas',
  9502. value: function paintOnCanvas(canvasWrapper) {
  9503. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  9504. var result = {
  9505. promise: renderCapability.promise,
  9506. onRenderContinue: function onRenderContinue(cont) {
  9507. cont();
  9508. },
  9509. cancel: function cancel() {
  9510. renderTask.cancel();
  9511. }
  9512. };
  9513. var viewport = this.viewport;
  9514. var canvas = document.createElement('canvas');
  9515. canvas.id = this.renderingId;
  9516. canvas.setAttribute('hidden', 'hidden');
  9517. var isCanvasHidden = true;
  9518. var showCanvas = function showCanvas() {
  9519. if (isCanvasHidden) {
  9520. canvas.removeAttribute('hidden');
  9521. isCanvasHidden = false;
  9522. }
  9523. };
  9524. canvasWrapper.appendChild(canvas);
  9525. this.canvas = canvas;
  9526. canvas.mozOpaque = true;
  9527. var ctx = canvas.getContext('2d', { alpha: false });
  9528. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  9529. this.outputScale = outputScale;
  9530. if (this.useOnlyCssZoom) {
  9531. var actualSizeViewport = viewport.clone({ scale: _ui_utils.CSS_UNITS });
  9532. outputScale.sx *= actualSizeViewport.width / viewport.width;
  9533. outputScale.sy *= actualSizeViewport.height / viewport.height;
  9534. outputScale.scaled = true;
  9535. }
  9536. if (this.maxCanvasPixels > 0) {
  9537. var pixelsInViewport = viewport.width * viewport.height;
  9538. var maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
  9539. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  9540. outputScale.sx = maxScale;
  9541. outputScale.sy = maxScale;
  9542. outputScale.scaled = true;
  9543. this.hasRestrictedScaling = true;
  9544. } else {
  9545. this.hasRestrictedScaling = false;
  9546. }
  9547. }
  9548. var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  9549. var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  9550. canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
  9551. canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
  9552. canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + 'px';
  9553. canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + 'px';
  9554. this.paintedViewportMap.set(canvas, viewport);
  9555. var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
  9556. var renderContext = {
  9557. canvasContext: ctx,
  9558. transform: transform,
  9559. viewport: this.viewport,
  9560. enableWebGL: this.enableWebGL,
  9561. renderInteractiveForms: this.renderInteractiveForms
  9562. };
  9563. var renderTask = this.pdfPage.render(renderContext);
  9564. renderTask.onContinue = function (cont) {
  9565. showCanvas();
  9566. if (result.onRenderContinue) {
  9567. result.onRenderContinue(cont);
  9568. } else {
  9569. cont();
  9570. }
  9571. };
  9572. renderTask.promise.then(function () {
  9573. showCanvas();
  9574. renderCapability.resolve(undefined);
  9575. }, function (error) {
  9576. showCanvas();
  9577. renderCapability.reject(error);
  9578. });
  9579. return result;
  9580. }
  9581. }, {
  9582. key: 'paintOnSvg',
  9583. value: function paintOnSvg(wrapper) {
  9584. var _this2 = this;
  9585. var cancelled = false;
  9586. var ensureNotCancelled = function ensureNotCancelled() {
  9587. if (cancelled) {
  9588. throw new _pdfjsLib.RenderingCancelledException('Rendering cancelled, page ' + _this2.id, 'svg');
  9589. }
  9590. };
  9591. var pdfPage = this.pdfPage;
  9592. var actualSizeViewport = this.viewport.clone({ scale: _ui_utils.CSS_UNITS });
  9593. var promise = pdfPage.getOperatorList().then(function (opList) {
  9594. ensureNotCancelled();
  9595. var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
  9596. return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {
  9597. ensureNotCancelled();
  9598. _this2.svg = svg;
  9599. _this2.paintedViewportMap.set(svg, actualSizeViewport);
  9600. svg.style.width = wrapper.style.width;
  9601. svg.style.height = wrapper.style.height;
  9602. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  9603. wrapper.appendChild(svg);
  9604. });
  9605. });
  9606. return {
  9607. promise: promise,
  9608. onRenderContinue: function onRenderContinue(cont) {
  9609. cont();
  9610. },
  9611. cancel: function cancel() {
  9612. cancelled = true;
  9613. }
  9614. };
  9615. }
  9616. }, {
  9617. key: 'setPageLabel',
  9618. value: function setPageLabel(label) {
  9619. this.pageLabel = typeof label === 'string' ? label : null;
  9620. if (this.pageLabel !== null) {
  9621. this.div.setAttribute('data-page-label', this.pageLabel);
  9622. } else {
  9623. this.div.removeAttribute('data-page-label');
  9624. }
  9625. }
  9626. }, {
  9627. key: 'width',
  9628. get: function get() {
  9629. return this.viewport.width;
  9630. }
  9631. }, {
  9632. key: 'height',
  9633. get: function get() {
  9634. return this.viewport.height;
  9635. }
  9636. }]);
  9637. return PDFPageView;
  9638. }();
  9639. exports.PDFPageView = PDFPageView;
  9640. /***/ }),
  9641. /* 33 */
  9642. /***/ (function(module, exports, __webpack_require__) {
  9643. "use strict";
  9644. Object.defineProperty(exports, "__esModule", {
  9645. value: true
  9646. });
  9647. exports.DefaultTextLayerFactory = exports.TextLayerBuilder = undefined;
  9648. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  9649. var _dom_events = __webpack_require__(14);
  9650. var _pdfjsLib = __webpack_require__(7);
  9651. var _ui_utils = __webpack_require__(6);
  9652. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9653. var EXPAND_DIVS_TIMEOUT = 300;
  9654. var MATCH_SCROLL_OFFSET_TOP = -50;
  9655. var MATCH_SCROLL_OFFSET_LEFT = -400;
  9656. var TextLayerBuilder = function () {
  9657. function TextLayerBuilder(_ref) {
  9658. var textLayerDiv = _ref.textLayerDiv,
  9659. eventBus = _ref.eventBus,
  9660. pageIndex = _ref.pageIndex,
  9661. viewport = _ref.viewport,
  9662. _ref$findController = _ref.findController,
  9663. findController = _ref$findController === undefined ? null : _ref$findController,
  9664. _ref$enhanceTextSelec = _ref.enhanceTextSelection,
  9665. enhanceTextSelection = _ref$enhanceTextSelec === undefined ? false : _ref$enhanceTextSelec;
  9666. _classCallCheck(this, TextLayerBuilder);
  9667. this.textLayerDiv = textLayerDiv;
  9668. this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)();
  9669. this.textContent = null;
  9670. this.textContentItemsStr = [];
  9671. this.textContentStream = null;
  9672. this.renderingDone = false;
  9673. this.pageIdx = pageIndex;
  9674. this.pageNumber = this.pageIdx + 1;
  9675. this.matches = [];
  9676. this.viewport = viewport;
  9677. this.textDivs = [];
  9678. this.findController = findController;
  9679. this.textLayerRenderTask = null;
  9680. this.enhanceTextSelection = enhanceTextSelection;
  9681. this._boundEvents = Object.create(null);
  9682. this._bindEvents();
  9683. this._bindMouse();
  9684. }
  9685. _createClass(TextLayerBuilder, [{
  9686. key: '_finishRendering',
  9687. value: function _finishRendering() {
  9688. this.renderingDone = true;
  9689. if (!this.enhanceTextSelection) {
  9690. var endOfContent = document.createElement('div');
  9691. endOfContent.className = 'endOfContent';
  9692. this.textLayerDiv.appendChild(endOfContent);
  9693. }
  9694. this.eventBus.dispatch('textlayerrendered', {
  9695. source: this,
  9696. pageNumber: this.pageNumber,
  9697. numTextDivs: this.textDivs.length
  9698. });
  9699. }
  9700. }, {
  9701. key: 'render',
  9702. value: function render() {
  9703. var _this = this;
  9704. var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  9705. if (!(this.textContent || this.textContentStream) || this.renderingDone) {
  9706. return;
  9707. }
  9708. this.cancel();
  9709. this.textDivs = [];
  9710. var textLayerFrag = document.createDocumentFragment();
  9711. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  9712. textContent: this.textContent,
  9713. textContentStream: this.textContentStream,
  9714. container: textLayerFrag,
  9715. viewport: this.viewport,
  9716. textDivs: this.textDivs,
  9717. textContentItemsStr: this.textContentItemsStr,
  9718. timeout: timeout,
  9719. enhanceTextSelection: this.enhanceTextSelection
  9720. });
  9721. this.textLayerRenderTask.promise.then(function () {
  9722. _this.textLayerDiv.appendChild(textLayerFrag);
  9723. _this._finishRendering();
  9724. _this.updateMatches();
  9725. }, function (reason) {});
  9726. }
  9727. }, {
  9728. key: 'cancel',
  9729. value: function cancel() {
  9730. if (this.textLayerRenderTask) {
  9731. this.textLayerRenderTask.cancel();
  9732. this.textLayerRenderTask = null;
  9733. }
  9734. }
  9735. }, {
  9736. key: 'setTextContentStream',
  9737. value: function setTextContentStream(readableStream) {
  9738. this.cancel();
  9739. this.textContentStream = readableStream;
  9740. }
  9741. }, {
  9742. key: 'setTextContent',
  9743. value: function setTextContent(textContent) {
  9744. this.cancel();
  9745. this.textContent = textContent;
  9746. }
  9747. }, {
  9748. key: 'convertMatches',
  9749. value: function convertMatches(matches, matchesLength) {
  9750. var i = 0;
  9751. var iIndex = 0;
  9752. var textContentItemsStr = this.textContentItemsStr;
  9753. var end = textContentItemsStr.length - 1;
  9754. var queryLen = this.findController === null ? 0 : this.findController.state.query.length;
  9755. var ret = [];
  9756. if (!matches) {
  9757. return ret;
  9758. }
  9759. for (var m = 0, len = matches.length; m < len; m++) {
  9760. var matchIdx = matches[m];
  9761. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  9762. iIndex += textContentItemsStr[i].length;
  9763. i++;
  9764. }
  9765. if (i === textContentItemsStr.length) {
  9766. console.error('Could not find a matching mapping');
  9767. }
  9768. var match = {
  9769. begin: {
  9770. divIdx: i,
  9771. offset: matchIdx - iIndex
  9772. }
  9773. };
  9774. if (matchesLength) {
  9775. matchIdx += matchesLength[m];
  9776. } else {
  9777. matchIdx += queryLen;
  9778. }
  9779. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  9780. iIndex += textContentItemsStr[i].length;
  9781. i++;
  9782. }
  9783. match.end = {
  9784. divIdx: i,
  9785. offset: matchIdx - iIndex
  9786. };
  9787. ret.push(match);
  9788. }
  9789. return ret;
  9790. }
  9791. }, {
  9792. key: 'renderMatches',
  9793. value: function renderMatches(matches) {
  9794. if (matches.length === 0) {
  9795. return;
  9796. }
  9797. var textContentItemsStr = this.textContentItemsStr;
  9798. var textDivs = this.textDivs;
  9799. var prevEnd = null;
  9800. var pageIdx = this.pageIdx;
  9801. var isSelectedPage = this.findController === null ? false : pageIdx === this.findController.selected.pageIdx;
  9802. var selectedMatchIdx = this.findController === null ? -1 : this.findController.selected.matchIdx;
  9803. var highlightAll = this.findController === null ? false : this.findController.state.highlightAll;
  9804. var infinity = {
  9805. divIdx: -1,
  9806. offset: undefined
  9807. };
  9808. function beginText(begin, className) {
  9809. var divIdx = begin.divIdx;
  9810. textDivs[divIdx].textContent = '';
  9811. appendTextToDiv(divIdx, 0, begin.offset, className);
  9812. }
  9813. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  9814. var div = textDivs[divIdx];
  9815. var content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  9816. var node = document.createTextNode(content);
  9817. if (className) {
  9818. var span = document.createElement('span');
  9819. span.className = className;
  9820. span.appendChild(node);
  9821. div.appendChild(span);
  9822. return;
  9823. }
  9824. div.appendChild(node);
  9825. }
  9826. var i0 = selectedMatchIdx,
  9827. i1 = i0 + 1;
  9828. if (highlightAll) {
  9829. i0 = 0;
  9830. i1 = matches.length;
  9831. } else if (!isSelectedPage) {
  9832. return;
  9833. }
  9834. for (var i = i0; i < i1; i++) {
  9835. var match = matches[i];
  9836. var begin = match.begin;
  9837. var end = match.end;
  9838. var isSelected = isSelectedPage && i === selectedMatchIdx;
  9839. var highlightSuffix = isSelected ? ' selected' : '';
  9840. if (this.findController) {
  9841. if (this.findController.selected.matchIdx === i && this.findController.selected.pageIdx === pageIdx) {
  9842. var spot = {
  9843. top: MATCH_SCROLL_OFFSET_TOP,
  9844. left: MATCH_SCROLL_OFFSET_LEFT
  9845. };
  9846. (0, _ui_utils.scrollIntoView)(textDivs[begin.divIdx], spot, true);
  9847. }
  9848. }
  9849. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  9850. if (prevEnd !== null) {
  9851. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  9852. }
  9853. beginText(begin);
  9854. } else {
  9855. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  9856. }
  9857. if (begin.divIdx === end.divIdx) {
  9858. appendTextToDiv(begin.divIdx, begin.offset, end.offset, 'highlight' + highlightSuffix);
  9859. } else {
  9860. appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, 'highlight begin' + highlightSuffix);
  9861. for (var n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  9862. textDivs[n0].className = 'highlight middle' + highlightSuffix;
  9863. }
  9864. beginText(end, 'highlight end' + highlightSuffix);
  9865. }
  9866. prevEnd = end;
  9867. }
  9868. if (prevEnd) {
  9869. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  9870. }
  9871. }
  9872. }, {
  9873. key: 'updateMatches',
  9874. value: function updateMatches() {
  9875. if (!this.renderingDone) {
  9876. return;
  9877. }
  9878. var matches = this.matches;
  9879. var textDivs = this.textDivs;
  9880. var textContentItemsStr = this.textContentItemsStr;
  9881. var clearedUntilDivIdx = -1;
  9882. for (var i = 0, len = matches.length; i < len; i++) {
  9883. var match = matches[i];
  9884. var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  9885. for (var n = begin, end = match.end.divIdx; n <= end; n++) {
  9886. var div = textDivs[n];
  9887. div.textContent = textContentItemsStr[n];
  9888. div.className = '';
  9889. }
  9890. clearedUntilDivIdx = match.end.divIdx + 1;
  9891. }
  9892. if (!this.findController || !this.findController.highlightMatches) {
  9893. return;
  9894. }
  9895. var pageMatches = void 0,
  9896. pageMatchesLength = void 0;
  9897. if (this.findController !== null) {
  9898. pageMatches = this.findController.pageMatches[this.pageIdx] || null;
  9899. pageMatchesLength = this.findController.pageMatchesLength ? this.findController.pageMatchesLength[this.pageIdx] || null : null;
  9900. }
  9901. this.matches = this.convertMatches(pageMatches, pageMatchesLength);
  9902. this.renderMatches(this.matches);
  9903. }
  9904. }, {
  9905. key: '_bindEvents',
  9906. value: function _bindEvents() {
  9907. var _this2 = this;
  9908. var eventBus = this.eventBus,
  9909. _boundEvents = this._boundEvents;
  9910. _boundEvents.pageCancelled = function (evt) {
  9911. if (evt.pageNumber !== _this2.pageNumber) {
  9912. return;
  9913. }
  9914. if (_this2.textLayerRenderTask) {
  9915. console.error('TextLayerBuilder._bindEvents: `this.cancel()` should ' + 'have been called when the page was reset, or rendering cancelled.');
  9916. return;
  9917. }
  9918. for (var name in _boundEvents) {
  9919. eventBus.off(name.toLowerCase(), _boundEvents[name]);
  9920. delete _boundEvents[name];
  9921. }
  9922. };
  9923. _boundEvents.updateTextLayerMatches = function (evt) {
  9924. if (evt.pageIndex !== _this2.pageIdx && evt.pageIndex !== -1) {
  9925. return;
  9926. }
  9927. _this2.updateMatches();
  9928. };
  9929. eventBus.on('pagecancelled', _boundEvents.pageCancelled);
  9930. eventBus.on('updatetextlayermatches', _boundEvents.updateTextLayerMatches);
  9931. }
  9932. }, {
  9933. key: '_bindMouse',
  9934. value: function _bindMouse() {
  9935. var _this3 = this;
  9936. var div = this.textLayerDiv;
  9937. var expandDivsTimer = null;
  9938. div.addEventListener('mousedown', function (evt) {
  9939. if (_this3.enhanceTextSelection && _this3.textLayerRenderTask) {
  9940. _this3.textLayerRenderTask.expandTextDivs(true);
  9941. if (expandDivsTimer) {
  9942. clearTimeout(expandDivsTimer);
  9943. expandDivsTimer = null;
  9944. }
  9945. return;
  9946. }
  9947. var end = div.querySelector('.endOfContent');
  9948. if (!end) {
  9949. return;
  9950. }
  9951. var adjustTop = evt.target !== div;
  9952. adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue('-moz-user-select') !== 'none';
  9953. if (adjustTop) {
  9954. var divBounds = div.getBoundingClientRect();
  9955. var r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  9956. end.style.top = (r * 100).toFixed(2) + '%';
  9957. }
  9958. end.classList.add('active');
  9959. });
  9960. div.addEventListener('mouseup', function () {
  9961. if (_this3.enhanceTextSelection && _this3.textLayerRenderTask) {
  9962. expandDivsTimer = setTimeout(function () {
  9963. if (_this3.textLayerRenderTask) {
  9964. _this3.textLayerRenderTask.expandTextDivs(false);
  9965. }
  9966. expandDivsTimer = null;
  9967. }, EXPAND_DIVS_TIMEOUT);
  9968. return;
  9969. }
  9970. var end = div.querySelector('.endOfContent');
  9971. if (!end) {
  9972. return;
  9973. }
  9974. end.style.top = '';
  9975. end.classList.remove('active');
  9976. });
  9977. }
  9978. }]);
  9979. return TextLayerBuilder;
  9980. }();
  9981. var DefaultTextLayerFactory = function () {
  9982. function DefaultTextLayerFactory() {
  9983. _classCallCheck(this, DefaultTextLayerFactory);
  9984. }
  9985. _createClass(DefaultTextLayerFactory, [{
  9986. key: 'createTextLayerBuilder',
  9987. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  9988. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9989. return new TextLayerBuilder({
  9990. textLayerDiv: textLayerDiv,
  9991. pageIndex: pageIndex,
  9992. viewport: viewport,
  9993. enhanceTextSelection: enhanceTextSelection
  9994. });
  9995. }
  9996. }]);
  9997. return DefaultTextLayerFactory;
  9998. }();
  9999. exports.TextLayerBuilder = TextLayerBuilder;
  10000. exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
  10001. /***/ }),
  10002. /* 34 */
  10003. /***/ (function(module, exports, __webpack_require__) {
  10004. "use strict";
  10005. Object.defineProperty(exports, "__esModule", {
  10006. value: true
  10007. });
  10008. exports.SecondaryToolbar = undefined;
  10009. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  10010. var _base_viewer = __webpack_require__(30);
  10011. var _pdf_cursor_tools = __webpack_require__(8);
  10012. var _pdf_single_page_viewer = __webpack_require__(35);
  10013. var _ui_utils = __webpack_require__(6);
  10014. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10015. var SecondaryToolbar = function () {
  10016. function SecondaryToolbar(options, mainContainer, eventBus) {
  10017. var _this = this;
  10018. _classCallCheck(this, SecondaryToolbar);
  10019. this.toolbar = options.toolbar;
  10020. this.toggleButton = options.toggleButton;
  10021. this.toolbarButtonContainer = options.toolbarButtonContainer;
  10022. this.buttons = [{
  10023. element: options.presentationModeButton,
  10024. eventName: 'presentationmode',
  10025. close: true
  10026. }, {
  10027. element: options.openFileButton,
  10028. eventName: 'openfile',
  10029. close: true
  10030. }, {
  10031. element: options.printButton,
  10032. eventName: 'print',
  10033. close: true
  10034. }, {
  10035. element: options.downloadButton,
  10036. eventName: 'download',
  10037. close: true
  10038. }, {
  10039. element: options.viewBookmarkButton,
  10040. eventName: null,
  10041. close: true
  10042. }, {
  10043. element: options.firstPageButton,
  10044. eventName: 'firstpage',
  10045. close: true
  10046. }, {
  10047. element: options.lastPageButton,
  10048. eventName: 'lastpage',
  10049. close: true
  10050. }, {
  10051. element: options.pageRotateCwButton,
  10052. eventName: 'rotatecw',
  10053. close: false
  10054. }, {
  10055. element: options.pageRotateCcwButton,
  10056. eventName: 'rotateccw',
  10057. close: false
  10058. }, {
  10059. element: options.cursorSelectToolButton,
  10060. eventName: 'switchcursortool',
  10061. eventDetails: { tool: _pdf_cursor_tools.CursorTool.SELECT },
  10062. close: true
  10063. }, {
  10064. element: options.cursorHandToolButton,
  10065. eventName: 'switchcursortool',
  10066. eventDetails: { tool: _pdf_cursor_tools.CursorTool.HAND },
  10067. close: true
  10068. }, {
  10069. element: options.scrollVerticalButton,
  10070. eventName: 'switchscrollmode',
  10071. eventDetails: { mode: _base_viewer.ScrollMode.VERTICAL },
  10072. close: true
  10073. }, {
  10074. element: options.scrollHorizontalButton,
  10075. eventName: 'switchscrollmode',
  10076. eventDetails: { mode: _base_viewer.ScrollMode.HORIZONTAL },
  10077. close: true
  10078. }, {
  10079. element: options.scrollWrappedButton,
  10080. eventName: 'switchscrollmode',
  10081. eventDetails: { mode: _base_viewer.ScrollMode.WRAPPED },
  10082. close: true
  10083. }, {
  10084. element: options.spreadNoneButton,
  10085. eventName: 'switchspreadmode',
  10086. eventDetails: { mode: _base_viewer.SpreadMode.NONE },
  10087. close: true
  10088. }, {
  10089. element: options.spreadOddButton,
  10090. eventName: 'switchspreadmode',
  10091. eventDetails: { mode: _base_viewer.SpreadMode.ODD },
  10092. close: true
  10093. }, {
  10094. element: options.spreadEvenButton,
  10095. eventName: 'switchspreadmode',
  10096. eventDetails: { mode: _base_viewer.SpreadMode.EVEN },
  10097. close: true
  10098. }, {
  10099. element: options.documentPropertiesButton,
  10100. eventName: 'documentproperties',
  10101. close: true
  10102. }];
  10103. this.items = {
  10104. firstPage: options.firstPageButton,
  10105. lastPage: options.lastPageButton,
  10106. pageRotateCw: options.pageRotateCwButton,
  10107. pageRotateCcw: options.pageRotateCcwButton
  10108. };
  10109. this.mainContainer = mainContainer;
  10110. this.eventBus = eventBus;
  10111. this.opened = false;
  10112. this.containerHeight = null;
  10113. this.previousContainerHeight = null;
  10114. this.reset();
  10115. this._bindClickListeners();
  10116. this._bindCursorToolsListener(options);
  10117. this._bindScrollModeListener(options);
  10118. this._bindSpreadModeListener(options);
  10119. this.eventBus.on('resize', this._setMaxHeight.bind(this));
  10120. this.eventBus.on('baseviewerinit', function (evt) {
  10121. if (evt.source instanceof _pdf_single_page_viewer.PDFSinglePageViewer) {
  10122. _this.toolbarButtonContainer.classList.add('hiddenScrollModeButtons', 'hiddenSpreadModeButtons');
  10123. } else {
  10124. _this.toolbarButtonContainer.classList.remove('hiddenScrollModeButtons', 'hiddenSpreadModeButtons');
  10125. }
  10126. });
  10127. }
  10128. _createClass(SecondaryToolbar, [{
  10129. key: 'setPageNumber',
  10130. value: function setPageNumber(pageNumber) {
  10131. this.pageNumber = pageNumber;
  10132. this._updateUIState();
  10133. }
  10134. }, {
  10135. key: 'setPagesCount',
  10136. value: function setPagesCount(pagesCount) {
  10137. this.pagesCount = pagesCount;
  10138. this._updateUIState();
  10139. }
  10140. }, {
  10141. key: 'reset',
  10142. value: function reset() {
  10143. this.pageNumber = 0;
  10144. this.pagesCount = 0;
  10145. this._updateUIState();
  10146. this.eventBus.dispatch('secondarytoolbarreset', { source: this });
  10147. }
  10148. }, {
  10149. key: '_updateUIState',
  10150. value: function _updateUIState() {
  10151. this.items.firstPage.disabled = this.pageNumber <= 1;
  10152. this.items.lastPage.disabled = this.pageNumber >= this.pagesCount;
  10153. this.items.pageRotateCw.disabled = this.pagesCount === 0;
  10154. this.items.pageRotateCcw.disabled = this.pagesCount === 0;
  10155. }
  10156. }, {
  10157. key: '_bindClickListeners',
  10158. value: function _bindClickListeners() {
  10159. var _this2 = this;
  10160. this.toggleButton.addEventListener('click', this.toggle.bind(this));
  10161. var _loop = function _loop(button) {
  10162. var _buttons$button = _this2.buttons[button],
  10163. element = _buttons$button.element,
  10164. eventName = _buttons$button.eventName,
  10165. close = _buttons$button.close,
  10166. eventDetails = _buttons$button.eventDetails;
  10167. element.addEventListener('click', function (evt) {
  10168. if (eventName !== null) {
  10169. var details = { source: _this2 };
  10170. for (var property in eventDetails) {
  10171. details[property] = eventDetails[property];
  10172. }
  10173. _this2.eventBus.dispatch(eventName, details);
  10174. }
  10175. if (close) {
  10176. _this2.close();
  10177. }
  10178. });
  10179. };
  10180. for (var button in this.buttons) {
  10181. _loop(button);
  10182. }
  10183. }
  10184. }, {
  10185. key: '_bindCursorToolsListener',
  10186. value: function _bindCursorToolsListener(buttons) {
  10187. this.eventBus.on('cursortoolchanged', function (evt) {
  10188. buttons.cursorSelectToolButton.classList.remove('toggled');
  10189. buttons.cursorHandToolButton.classList.remove('toggled');
  10190. switch (evt.tool) {
  10191. case _pdf_cursor_tools.CursorTool.SELECT:
  10192. buttons.cursorSelectToolButton.classList.add('toggled');
  10193. break;
  10194. case _pdf_cursor_tools.CursorTool.HAND:
  10195. buttons.cursorHandToolButton.classList.add('toggled');
  10196. break;
  10197. }
  10198. });
  10199. }
  10200. }, {
  10201. key: '_bindScrollModeListener',
  10202. value: function _bindScrollModeListener(buttons) {
  10203. var _this3 = this;
  10204. function scrollModeChanged(evt) {
  10205. buttons.scrollVerticalButton.classList.remove('toggled');
  10206. buttons.scrollHorizontalButton.classList.remove('toggled');
  10207. buttons.scrollWrappedButton.classList.remove('toggled');
  10208. switch (evt.mode) {
  10209. case _base_viewer.ScrollMode.VERTICAL:
  10210. buttons.scrollVerticalButton.classList.add('toggled');
  10211. break;
  10212. case _base_viewer.ScrollMode.HORIZONTAL:
  10213. buttons.scrollHorizontalButton.classList.add('toggled');
  10214. break;
  10215. case _base_viewer.ScrollMode.WRAPPED:
  10216. buttons.scrollWrappedButton.classList.add('toggled');
  10217. break;
  10218. }
  10219. var isScrollModeHorizontal = evt.mode === _base_viewer.ScrollMode.HORIZONTAL;
  10220. buttons.spreadNoneButton.disabled = isScrollModeHorizontal;
  10221. buttons.spreadOddButton.disabled = isScrollModeHorizontal;
  10222. buttons.spreadEvenButton.disabled = isScrollModeHorizontal;
  10223. }
  10224. this.eventBus.on('scrollmodechanged', scrollModeChanged);
  10225. this.eventBus.on('secondarytoolbarreset', function (evt) {
  10226. if (evt.source === _this3) {
  10227. scrollModeChanged({ mode: _base_viewer.ScrollMode.VERTICAL });
  10228. }
  10229. });
  10230. }
  10231. }, {
  10232. key: '_bindSpreadModeListener',
  10233. value: function _bindSpreadModeListener(buttons) {
  10234. var _this4 = this;
  10235. function spreadModeChanged(evt) {
  10236. buttons.spreadNoneButton.classList.remove('toggled');
  10237. buttons.spreadOddButton.classList.remove('toggled');
  10238. buttons.spreadEvenButton.classList.remove('toggled');
  10239. switch (evt.mode) {
  10240. case _base_viewer.SpreadMode.NONE:
  10241. buttons.spreadNoneButton.classList.add('toggled');
  10242. break;
  10243. case _base_viewer.SpreadMode.ODD:
  10244. buttons.spreadOddButton.classList.add('toggled');
  10245. break;
  10246. case _base_viewer.SpreadMode.EVEN:
  10247. buttons.spreadEvenButton.classList.add('toggled');
  10248. break;
  10249. }
  10250. }
  10251. this.eventBus.on('spreadmodechanged', spreadModeChanged);
  10252. this.eventBus.on('secondarytoolbarreset', function (evt) {
  10253. if (evt.source === _this4) {
  10254. spreadModeChanged({ mode: _base_viewer.SpreadMode.NONE });
  10255. }
  10256. });
  10257. }
  10258. }, {
  10259. key: 'open',
  10260. value: function open() {
  10261. if (this.opened) {
  10262. return;
  10263. }
  10264. this.opened = true;
  10265. this._setMaxHeight();
  10266. this.toggleButton.classList.add('toggled');
  10267. this.toolbar.classList.remove('hidden');
  10268. }
  10269. }, {
  10270. key: 'close',
  10271. value: function close() {
  10272. if (!this.opened) {
  10273. return;
  10274. }
  10275. this.opened = false;
  10276. this.toolbar.classList.add('hidden');
  10277. this.toggleButton.classList.remove('toggled');
  10278. }
  10279. }, {
  10280. key: 'toggle',
  10281. value: function toggle() {
  10282. if (this.opened) {
  10283. this.close();
  10284. } else {
  10285. this.open();
  10286. }
  10287. }
  10288. }, {
  10289. key: '_setMaxHeight',
  10290. value: function _setMaxHeight() {
  10291. if (!this.opened) {
  10292. return;
  10293. }
  10294. this.containerHeight = this.mainContainer.clientHeight;
  10295. if (this.containerHeight === this.previousContainerHeight) {
  10296. return;
  10297. }
  10298. this.toolbarButtonContainer.setAttribute('style', 'max-height: ' + (this.containerHeight - _ui_utils.SCROLLBAR_PADDING) + 'px;');
  10299. this.previousContainerHeight = this.containerHeight;
  10300. }
  10301. }, {
  10302. key: 'isOpen',
  10303. get: function get() {
  10304. return this.opened;
  10305. }
  10306. }]);
  10307. return SecondaryToolbar;
  10308. }();
  10309. exports.SecondaryToolbar = SecondaryToolbar;
  10310. /***/ }),
  10311. /* 35 */
  10312. /***/ (function(module, exports, __webpack_require__) {
  10313. "use strict";
  10314. Object.defineProperty(exports, "__esModule", {
  10315. value: true
  10316. });
  10317. exports.PDFSinglePageViewer = undefined;
  10318. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  10319. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  10320. var _base_viewer = __webpack_require__(30);
  10321. var _ui_utils = __webpack_require__(6);
  10322. var _pdfjsLib = __webpack_require__(7);
  10323. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10324. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  10325. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  10326. var PDFSinglePageViewer = function (_BaseViewer) {
  10327. _inherits(PDFSinglePageViewer, _BaseViewer);
  10328. function PDFSinglePageViewer(options) {
  10329. _classCallCheck(this, PDFSinglePageViewer);
  10330. var _this = _possibleConstructorReturn(this, (PDFSinglePageViewer.__proto__ || Object.getPrototypeOf(PDFSinglePageViewer)).call(this, options));
  10331. _this.eventBus.on('pagesinit', function (evt) {
  10332. _this._ensurePageViewVisible();
  10333. });
  10334. return _this;
  10335. }
  10336. _createClass(PDFSinglePageViewer, [{
  10337. key: '_resetView',
  10338. value: function _resetView() {
  10339. _get(PDFSinglePageViewer.prototype.__proto__ || Object.getPrototypeOf(PDFSinglePageViewer.prototype), '_resetView', this).call(this);
  10340. this._previousPageNumber = 1;
  10341. this._shadowViewer = document.createDocumentFragment();
  10342. }
  10343. }, {
  10344. key: '_ensurePageViewVisible',
  10345. value: function _ensurePageViewVisible() {
  10346. var pageView = this._pages[this._currentPageNumber - 1];
  10347. var previousPageView = this._pages[this._previousPageNumber - 1];
  10348. var viewerNodes = this.viewer.childNodes;
  10349. switch (viewerNodes.length) {
  10350. case 0:
  10351. this.viewer.appendChild(pageView.div);
  10352. break;
  10353. case 1:
  10354. if (viewerNodes[0] !== previousPageView.div) {
  10355. throw new Error('_ensurePageViewVisible: Unexpected previously visible page.');
  10356. }
  10357. if (pageView === previousPageView) {
  10358. break;
  10359. }
  10360. this._shadowViewer.appendChild(previousPageView.div);
  10361. this.viewer.appendChild(pageView.div);
  10362. this.container.scrollTop = 0;
  10363. break;
  10364. default:
  10365. throw new Error('_ensurePageViewVisible: Only one page should be visible at a time.');
  10366. }
  10367. this._previousPageNumber = this._currentPageNumber;
  10368. }
  10369. }, {
  10370. key: '_scrollUpdate',
  10371. value: function _scrollUpdate() {
  10372. if (this._updateScrollDown) {
  10373. this._updateScrollDown();
  10374. }
  10375. _get(PDFSinglePageViewer.prototype.__proto__ || Object.getPrototypeOf(PDFSinglePageViewer.prototype), '_scrollUpdate', this).call(this);
  10376. }
  10377. }, {
  10378. key: '_scrollIntoView',
  10379. value: function _scrollIntoView(_ref) {
  10380. var _this2 = this;
  10381. var pageDiv = _ref.pageDiv,
  10382. _ref$pageSpot = _ref.pageSpot,
  10383. pageSpot = _ref$pageSpot === undefined ? null : _ref$pageSpot,
  10384. _ref$pageNumber = _ref.pageNumber,
  10385. pageNumber = _ref$pageNumber === undefined ? null : _ref$pageNumber;
  10386. if (pageNumber) {
  10387. this._setCurrentPageNumber(pageNumber);
  10388. }
  10389. var scrolledDown = this._currentPageNumber >= this._previousPageNumber;
  10390. var previousLocation = this._location;
  10391. this._ensurePageViewVisible();
  10392. (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
  10393. this._updateScrollDown = function () {
  10394. _this2.scroll.down = scrolledDown;
  10395. delete _this2._updateScrollDown;
  10396. };
  10397. setTimeout(function () {
  10398. if (_this2._location === previousLocation) {
  10399. if (_this2._updateScrollDown) {
  10400. _this2._updateScrollDown();
  10401. }
  10402. _this2.update();
  10403. }
  10404. }, 0);
  10405. }
  10406. }, {
  10407. key: '_getVisiblePages',
  10408. value: function _getVisiblePages() {
  10409. if (!this.pagesCount) {
  10410. return { views: [] };
  10411. }
  10412. var pageView = this._pages[this._currentPageNumber - 1];
  10413. var element = pageView.div;
  10414. var view = {
  10415. id: pageView.id,
  10416. x: element.offsetLeft + element.clientLeft,
  10417. y: element.offsetTop + element.clientTop,
  10418. view: pageView
  10419. };
  10420. return {
  10421. first: view,
  10422. last: view,
  10423. views: [view]
  10424. };
  10425. }
  10426. }, {
  10427. key: 'update',
  10428. value: function update() {
  10429. var visible = this._getVisiblePages();
  10430. var visiblePages = visible.views,
  10431. numVisiblePages = visiblePages.length;
  10432. if (numVisiblePages === 0) {
  10433. return;
  10434. }
  10435. this._resizeBuffer(numVisiblePages);
  10436. this.renderingQueue.renderHighestPriority(visible);
  10437. this._updateLocation(visible.first);
  10438. this.eventBus.dispatch('updateviewarea', {
  10439. source: this,
  10440. location: this._location
  10441. });
  10442. }
  10443. }, {
  10444. key: '_updateScrollMode',
  10445. value: function _updateScrollMode() {}
  10446. }, {
  10447. key: '_updateSpreadMode',
  10448. value: function _updateSpreadMode() {}
  10449. }, {
  10450. key: '_setDocumentViewerElement',
  10451. get: function get() {
  10452. return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this._shadowViewer);
  10453. }
  10454. }, {
  10455. key: '_isScrollModeHorizontal',
  10456. get: function get() {
  10457. return (0, _pdfjsLib.shadow)(this, '_isScrollModeHorizontal', false);
  10458. }
  10459. }]);
  10460. return PDFSinglePageViewer;
  10461. }(_base_viewer.BaseViewer);
  10462. exports.PDFSinglePageViewer = PDFSinglePageViewer;
  10463. /***/ }),
  10464. /* 36 */
  10465. /***/ (function(module, exports, __webpack_require__) {
  10466. "use strict";
  10467. Object.defineProperty(exports, "__esModule", {
  10468. value: true
  10469. });
  10470. exports.Toolbar = undefined;
  10471. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  10472. var _ui_utils = __webpack_require__(6);
  10473. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10474. var PAGE_NUMBER_LOADING_INDICATOR = 'visiblePageIsLoading';
  10475. var SCALE_SELECT_CONTAINER_PADDING = 8;
  10476. var SCALE_SELECT_PADDING = 22;
  10477. var Toolbar = function () {
  10478. function Toolbar(options, eventBus) {
  10479. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  10480. _classCallCheck(this, Toolbar);
  10481. this.toolbar = options.container;
  10482. this.eventBus = eventBus;
  10483. this.l10n = l10n;
  10484. this.items = options;
  10485. this._wasLocalized = false;
  10486. this.reset();
  10487. this._bindListeners();
  10488. }
  10489. _createClass(Toolbar, [{
  10490. key: 'setPageNumber',
  10491. value: function setPageNumber(pageNumber, pageLabel) {
  10492. this.pageNumber = pageNumber;
  10493. this.pageLabel = pageLabel;
  10494. this._updateUIState(false);
  10495. }
  10496. }, {
  10497. key: 'setPagesCount',
  10498. value: function setPagesCount(pagesCount, hasPageLabels) {
  10499. this.pagesCount = pagesCount;
  10500. this.hasPageLabels = hasPageLabels;
  10501. this._updateUIState(true);
  10502. }
  10503. }, {
  10504. key: 'setPageScale',
  10505. value: function setPageScale(pageScaleValue, pageScale) {
  10506. this.pageScaleValue = (pageScaleValue || pageScale).toString();
  10507. this.pageScale = pageScale;
  10508. this._updateUIState(false);
  10509. }
  10510. }, {
  10511. key: 'reset',
  10512. value: function reset() {
  10513. this.pageNumber = 0;
  10514. this.pageLabel = null;
  10515. this.hasPageLabels = false;
  10516. this.pagesCount = 0;
  10517. this.pageScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  10518. this.pageScale = _ui_utils.DEFAULT_SCALE;
  10519. this._updateUIState(true);
  10520. }
  10521. }, {
  10522. key: '_bindListeners',
  10523. value: function _bindListeners() {
  10524. var _this = this;
  10525. var eventBus = this.eventBus,
  10526. items = this.items;
  10527. var self = this;
  10528. items.previous.addEventListener('click', function () {
  10529. eventBus.dispatch('previouspage', { source: self });
  10530. });
  10531. items.next.addEventListener('click', function () {
  10532. eventBus.dispatch('nextpage', { source: self });
  10533. });
  10534. items.zoomIn.addEventListener('click', function () {
  10535. eventBus.dispatch('zoomin', { source: self });
  10536. });
  10537. items.zoomOut.addEventListener('click', function () {
  10538. eventBus.dispatch('zoomout', { source: self });
  10539. });
  10540. items.pageNumber.addEventListener('click', function () {
  10541. this.select();
  10542. });
  10543. items.pageNumber.addEventListener('change', function () {
  10544. eventBus.dispatch('pagenumberchanged', {
  10545. source: self,
  10546. value: this.value
  10547. });
  10548. });
  10549. items.scaleSelect.addEventListener('change', function () {
  10550. if (this.value === 'custom') {
  10551. return;
  10552. }
  10553. eventBus.dispatch('scalechanged', {
  10554. source: self,
  10555. value: this.value
  10556. });
  10557. });
  10558. items.presentationModeButton.addEventListener('click', function () {
  10559. eventBus.dispatch('presentationmode', { source: self });
  10560. });
  10561. items.openFile.addEventListener('click', function () {
  10562. eventBus.dispatch('openfile', { source: self });
  10563. });
  10564. items.print.addEventListener('click', function () {
  10565. eventBus.dispatch('print', { source: self });
  10566. });
  10567. items.download.addEventListener('click', function () {
  10568. eventBus.dispatch('download', { source: self });
  10569. });
  10570. items.scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler;
  10571. eventBus.on('localized', function () {
  10572. _this._localized();
  10573. });
  10574. }
  10575. }, {
  10576. key: '_localized',
  10577. value: function _localized() {
  10578. this._wasLocalized = true;
  10579. this._adjustScaleWidth();
  10580. this._updateUIState(true);
  10581. }
  10582. }, {
  10583. key: '_updateUIState',
  10584. value: function _updateUIState() {
  10585. var resetNumPages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  10586. if (!this._wasLocalized) {
  10587. return;
  10588. }
  10589. var pageNumber = this.pageNumber,
  10590. pagesCount = this.pagesCount,
  10591. pageScaleValue = this.pageScaleValue,
  10592. pageScale = this.pageScale,
  10593. items = this.items;
  10594. if (resetNumPages) {
  10595. if (this.hasPageLabels) {
  10596. items.pageNumber.type = 'text';
  10597. } else {
  10598. items.pageNumber.type = 'number';
  10599. this.l10n.get('of_pages', { pagesCount: pagesCount }, 'of {{pagesCount}}').then(function (msg) {
  10600. items.numPages.textContent = msg;
  10601. });
  10602. }
  10603. items.pageNumber.max = pagesCount;
  10604. }
  10605. if (this.hasPageLabels) {
  10606. items.pageNumber.value = this.pageLabel;
  10607. this.l10n.get('page_of_pages', {
  10608. pageNumber: pageNumber,
  10609. pagesCount: pagesCount
  10610. }, '({{pageNumber}} of {{pagesCount}})').then(function (msg) {
  10611. items.numPages.textContent = msg;
  10612. });
  10613. } else {
  10614. items.pageNumber.value = pageNumber;
  10615. }
  10616. items.previous.disabled = pageNumber <= 1;
  10617. items.next.disabled = pageNumber >= pagesCount;
  10618. items.zoomOut.disabled = pageScale <= _ui_utils.MIN_SCALE;
  10619. items.zoomIn.disabled = pageScale >= _ui_utils.MAX_SCALE;
  10620. var customScale = Math.round(pageScale * 10000) / 100;
  10621. this.l10n.get('page_scale_percent', { scale: customScale }, '{{scale}}%').then(function (msg) {
  10622. var options = items.scaleSelect.options;
  10623. var predefinedValueFound = false;
  10624. for (var i = 0, ii = options.length; i < ii; i++) {
  10625. var option = options[i];
  10626. if (option.value !== pageScaleValue) {
  10627. option.selected = false;
  10628. continue;
  10629. }
  10630. option.selected = true;
  10631. predefinedValueFound = true;
  10632. }
  10633. if (!predefinedValueFound) {
  10634. items.customScaleOption.textContent = msg;
  10635. items.customScaleOption.selected = true;
  10636. }
  10637. });
  10638. }
  10639. }, {
  10640. key: 'updateLoadingIndicatorState',
  10641. value: function updateLoadingIndicatorState() {
  10642. var loading = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  10643. var pageNumberInput = this.items.pageNumber;
  10644. pageNumberInput.classList.toggle(PAGE_NUMBER_LOADING_INDICATOR, loading);
  10645. }
  10646. }, {
  10647. key: '_adjustScaleWidth',
  10648. value: function _adjustScaleWidth() {
  10649. var container = this.items.scaleSelectContainer;
  10650. var select = this.items.scaleSelect;
  10651. _ui_utils.animationStarted.then(function () {
  10652. if (container.clientWidth === 0) {
  10653. container.setAttribute('style', 'display: inherit;');
  10654. }
  10655. if (container.clientWidth > 0) {
  10656. select.setAttribute('style', 'min-width: inherit;');
  10657. var width = select.clientWidth + SCALE_SELECT_CONTAINER_PADDING;
  10658. select.setAttribute('style', 'min-width: ' + (width + SCALE_SELECT_PADDING) + 'px;');
  10659. container.setAttribute('style', 'min-width: ' + width + 'px; ' + 'max-width: ' + width + 'px;');
  10660. }
  10661. });
  10662. }
  10663. }]);
  10664. return Toolbar;
  10665. }();
  10666. exports.Toolbar = Toolbar;
  10667. /***/ }),
  10668. /* 37 */
  10669. /***/ (function(module, exports, __webpack_require__) {
  10670. "use strict";
  10671. Object.defineProperty(exports, "__esModule", {
  10672. value: true
  10673. });
  10674. exports.ViewHistory = undefined;
  10675. var _regenerator = __webpack_require__(2);
  10676. var _regenerator2 = _interopRequireDefault(_regenerator);
  10677. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  10678. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10679. function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
  10680. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10681. var DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
  10682. var ViewHistory = function () {
  10683. function ViewHistory(fingerprint) {
  10684. var _this = this;
  10685. var cacheSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_VIEW_HISTORY_CACHE_SIZE;
  10686. _classCallCheck(this, ViewHistory);
  10687. this.fingerprint = fingerprint;
  10688. this.cacheSize = cacheSize;
  10689. this._initializedPromise = this._readFromStorage().then(function (databaseStr) {
  10690. var database = JSON.parse(databaseStr || '{}');
  10691. if (!('files' in database)) {
  10692. database.files = [];
  10693. } else {
  10694. while (database.files.length >= _this.cacheSize) {
  10695. database.files.shift();
  10696. }
  10697. }
  10698. var index = -1;
  10699. for (var i = 0, length = database.files.length; i < length; i++) {
  10700. var branch = database.files[i];
  10701. if (branch.fingerprint === _this.fingerprint) {
  10702. index = i;
  10703. break;
  10704. }
  10705. }
  10706. if (index === -1) {
  10707. index = database.files.push({ fingerprint: _this.fingerprint }) - 1;
  10708. }
  10709. _this.file = database.files[index];
  10710. _this.database = database;
  10711. });
  10712. }
  10713. _createClass(ViewHistory, [{
  10714. key: '_writeToStorage',
  10715. value: function () {
  10716. var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee() {
  10717. var databaseStr;
  10718. return _regenerator2.default.wrap(function _callee$(_context) {
  10719. while (1) {
  10720. switch (_context.prev = _context.next) {
  10721. case 0:
  10722. databaseStr = JSON.stringify(this.database);
  10723. localStorage.setItem('pdfjs.history', databaseStr);
  10724. case 2:
  10725. case 'end':
  10726. return _context.stop();
  10727. }
  10728. }
  10729. }, _callee, this);
  10730. }));
  10731. function _writeToStorage() {
  10732. return _ref.apply(this, arguments);
  10733. }
  10734. return _writeToStorage;
  10735. }()
  10736. }, {
  10737. key: '_readFromStorage',
  10738. value: function () {
  10739. var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2() {
  10740. return _regenerator2.default.wrap(function _callee2$(_context2) {
  10741. while (1) {
  10742. switch (_context2.prev = _context2.next) {
  10743. case 0:
  10744. return _context2.abrupt('return', localStorage.getItem('pdfjs.history'));
  10745. case 1:
  10746. case 'end':
  10747. return _context2.stop();
  10748. }
  10749. }
  10750. }, _callee2, this);
  10751. }));
  10752. function _readFromStorage() {
  10753. return _ref2.apply(this, arguments);
  10754. }
  10755. return _readFromStorage;
  10756. }()
  10757. }, {
  10758. key: 'set',
  10759. value: function () {
  10760. var _ref3 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee3(name, val) {
  10761. return _regenerator2.default.wrap(function _callee3$(_context3) {
  10762. while (1) {
  10763. switch (_context3.prev = _context3.next) {
  10764. case 0:
  10765. _context3.next = 2;
  10766. return this._initializedPromise;
  10767. case 2:
  10768. this.file[name] = val;
  10769. return _context3.abrupt('return', this._writeToStorage());
  10770. case 4:
  10771. case 'end':
  10772. return _context3.stop();
  10773. }
  10774. }
  10775. }, _callee3, this);
  10776. }));
  10777. function set(_x2, _x3) {
  10778. return _ref3.apply(this, arguments);
  10779. }
  10780. return set;
  10781. }()
  10782. }, {
  10783. key: 'setMultiple',
  10784. value: function () {
  10785. var _ref4 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee4(properties) {
  10786. var name;
  10787. return _regenerator2.default.wrap(function _callee4$(_context4) {
  10788. while (1) {
  10789. switch (_context4.prev = _context4.next) {
  10790. case 0:
  10791. _context4.next = 2;
  10792. return this._initializedPromise;
  10793. case 2:
  10794. for (name in properties) {
  10795. this.file[name] = properties[name];
  10796. }
  10797. return _context4.abrupt('return', this._writeToStorage());
  10798. case 4:
  10799. case 'end':
  10800. return _context4.stop();
  10801. }
  10802. }
  10803. }, _callee4, this);
  10804. }));
  10805. function setMultiple(_x4) {
  10806. return _ref4.apply(this, arguments);
  10807. }
  10808. return setMultiple;
  10809. }()
  10810. }, {
  10811. key: 'get',
  10812. value: function () {
  10813. var _ref5 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee5(name, defaultValue) {
  10814. var val;
  10815. return _regenerator2.default.wrap(function _callee5$(_context5) {
  10816. while (1) {
  10817. switch (_context5.prev = _context5.next) {
  10818. case 0:
  10819. _context5.next = 2;
  10820. return this._initializedPromise;
  10821. case 2:
  10822. val = this.file[name];
  10823. return _context5.abrupt('return', val !== undefined ? val : defaultValue);
  10824. case 4:
  10825. case 'end':
  10826. return _context5.stop();
  10827. }
  10828. }
  10829. }, _callee5, this);
  10830. }));
  10831. function get(_x5, _x6) {
  10832. return _ref5.apply(this, arguments);
  10833. }
  10834. return get;
  10835. }()
  10836. }, {
  10837. key: 'getMultiple',
  10838. value: function () {
  10839. var _ref6 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee6(properties) {
  10840. var values, name, val;
  10841. return _regenerator2.default.wrap(function _callee6$(_context6) {
  10842. while (1) {
  10843. switch (_context6.prev = _context6.next) {
  10844. case 0:
  10845. _context6.next = 2;
  10846. return this._initializedPromise;
  10847. case 2:
  10848. values = Object.create(null);
  10849. for (name in properties) {
  10850. val = this.file[name];
  10851. values[name] = val !== undefined ? val : properties[name];
  10852. }
  10853. return _context6.abrupt('return', values);
  10854. case 5:
  10855. case 'end':
  10856. return _context6.stop();
  10857. }
  10858. }
  10859. }, _callee6, this);
  10860. }));
  10861. function getMultiple(_x7) {
  10862. return _ref6.apply(this, arguments);
  10863. }
  10864. return getMultiple;
  10865. }()
  10866. }]);
  10867. return ViewHistory;
  10868. }();
  10869. exports.ViewHistory = ViewHistory;
  10870. /***/ }),
  10871. /* 38 */
  10872. /***/ (function(module, exports, __webpack_require__) {
  10873. "use strict";
  10874. Object.defineProperty(exports, "__esModule", {
  10875. value: true
  10876. });
  10877. exports.GenericCom = undefined;
  10878. var _regenerator = __webpack_require__(2);
  10879. var _regenerator2 = _interopRequireDefault(_regenerator);
  10880. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  10881. var _app = __webpack_require__(1);
  10882. var _preferences = __webpack_require__(39);
  10883. var _download_manager = __webpack_require__(40);
  10884. var _genericl10n = __webpack_require__(41);
  10885. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10886. function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
  10887. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10888. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  10889. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  10890. ;
  10891. var GenericCom = {};
  10892. var GenericPreferences = function (_BasePreferences) {
  10893. _inherits(GenericPreferences, _BasePreferences);
  10894. function GenericPreferences() {
  10895. _classCallCheck(this, GenericPreferences);
  10896. return _possibleConstructorReturn(this, (GenericPreferences.__proto__ || Object.getPrototypeOf(GenericPreferences)).apply(this, arguments));
  10897. }
  10898. _createClass(GenericPreferences, [{
  10899. key: '_writeToStorage',
  10900. value: function () {
  10901. var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee(prefObj) {
  10902. return _regenerator2.default.wrap(function _callee$(_context) {
  10903. while (1) {
  10904. switch (_context.prev = _context.next) {
  10905. case 0:
  10906. localStorage.setItem('pdfjs.preferences', JSON.stringify(prefObj));
  10907. case 1:
  10908. case 'end':
  10909. return _context.stop();
  10910. }
  10911. }
  10912. }, _callee, this);
  10913. }));
  10914. function _writeToStorage(_x) {
  10915. return _ref.apply(this, arguments);
  10916. }
  10917. return _writeToStorage;
  10918. }()
  10919. }, {
  10920. key: '_readFromStorage',
  10921. value: function () {
  10922. var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2(prefObj) {
  10923. return _regenerator2.default.wrap(function _callee2$(_context2) {
  10924. while (1) {
  10925. switch (_context2.prev = _context2.next) {
  10926. case 0:
  10927. return _context2.abrupt('return', JSON.parse(localStorage.getItem('pdfjs.preferences')));
  10928. case 1:
  10929. case 'end':
  10930. return _context2.stop();
  10931. }
  10932. }
  10933. }, _callee2, this);
  10934. }));
  10935. function _readFromStorage(_x2) {
  10936. return _ref2.apply(this, arguments);
  10937. }
  10938. return _readFromStorage;
  10939. }()
  10940. }]);
  10941. return GenericPreferences;
  10942. }(_preferences.BasePreferences);
  10943. var GenericExternalServices = Object.create(_app.DefaultExternalServices);
  10944. GenericExternalServices.createDownloadManager = function (options) {
  10945. return new _download_manager.DownloadManager(options);
  10946. };
  10947. GenericExternalServices.createPreferences = function () {
  10948. return new GenericPreferences();
  10949. };
  10950. GenericExternalServices.createL10n = function (_ref3) {
  10951. var _ref3$locale = _ref3.locale,
  10952. locale = _ref3$locale === undefined ? 'en-US' : _ref3$locale;
  10953. return new _genericl10n.GenericL10n(locale);
  10954. };
  10955. _app.PDFViewerApplication.externalServices = GenericExternalServices;
  10956. exports.GenericCom = GenericCom;
  10957. /***/ }),
  10958. /* 39 */
  10959. /***/ (function(module, exports, __webpack_require__) {
  10960. "use strict";
  10961. Object.defineProperty(exports, "__esModule", {
  10962. value: true
  10963. });
  10964. exports.BasePreferences = undefined;
  10965. var _regenerator = __webpack_require__(2);
  10966. var _regenerator2 = _interopRequireDefault(_regenerator);
  10967. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  10968. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  10969. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10970. function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
  10971. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10972. var defaultPreferences = null;
  10973. function getDefaultPreferences() {
  10974. if (!defaultPreferences) {
  10975. defaultPreferences = Promise.resolve({
  10976. "showPreviousViewOnLoad": true,
  10977. "defaultZoomValue": "",
  10978. "sidebarViewOnLoad": 0,
  10979. "cursorToolOnLoad": 0,
  10980. "enableWebGL": false,
  10981. "eventBusDispatchToDOM": false,
  10982. "pdfBugEnabled": false,
  10983. "disableRange": false,
  10984. "disableStream": false,
  10985. "disableAutoFetch": false,
  10986. "disableFontFace": false,
  10987. "textLayerMode": 1,
  10988. "useOnlyCssZoom": false,
  10989. "externalLinkTarget": 0,
  10990. "renderer": "canvas",
  10991. "renderInteractiveForms": false,
  10992. "enablePrintAutoRotate": false,
  10993. "disablePageMode": false,
  10994. "disablePageLabels": false,
  10995. "scrollModeOnLoad": 0,
  10996. "spreadModeOnLoad": 0
  10997. });
  10998. }
  10999. return defaultPreferences;
  11000. }
  11001. var BasePreferences = function () {
  11002. function BasePreferences() {
  11003. var _this = this;
  11004. _classCallCheck(this, BasePreferences);
  11005. if (this.constructor === BasePreferences) {
  11006. throw new Error('Cannot initialize BasePreferences.');
  11007. }
  11008. this.prefs = null;
  11009. this._initializedPromise = getDefaultPreferences().then(function (defaults) {
  11010. Object.defineProperty(_this, 'defaults', {
  11011. value: Object.freeze(defaults),
  11012. writable: false,
  11013. enumerable: true,
  11014. configurable: false
  11015. });
  11016. _this.prefs = Object.assign(Object.create(null), defaults);
  11017. return _this._readFromStorage(defaults);
  11018. }).then(function (prefs) {
  11019. if (!prefs) {
  11020. return;
  11021. }
  11022. for (var name in prefs) {
  11023. var defaultValue = _this.defaults[name],
  11024. prefValue = prefs[name];
  11025. if (defaultValue === undefined || (typeof prefValue === "undefined" ? "undefined" : _typeof(prefValue)) !== (typeof defaultValue === "undefined" ? "undefined" : _typeof(defaultValue))) {
  11026. continue;
  11027. }
  11028. _this.prefs[name] = prefValue;
  11029. }
  11030. });
  11031. }
  11032. _createClass(BasePreferences, [{
  11033. key: "_writeToStorage",
  11034. value: function () {
  11035. var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee(prefObj) {
  11036. return _regenerator2.default.wrap(function _callee$(_context) {
  11037. while (1) {
  11038. switch (_context.prev = _context.next) {
  11039. case 0:
  11040. throw new Error('Not implemented: _writeToStorage');
  11041. case 1:
  11042. case "end":
  11043. return _context.stop();
  11044. }
  11045. }
  11046. }, _callee, this);
  11047. }));
  11048. function _writeToStorage(_x) {
  11049. return _ref.apply(this, arguments);
  11050. }
  11051. return _writeToStorage;
  11052. }()
  11053. }, {
  11054. key: "_readFromStorage",
  11055. value: function () {
  11056. var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2(prefObj) {
  11057. return _regenerator2.default.wrap(function _callee2$(_context2) {
  11058. while (1) {
  11059. switch (_context2.prev = _context2.next) {
  11060. case 0:
  11061. throw new Error('Not implemented: _readFromStorage');
  11062. case 1:
  11063. case "end":
  11064. return _context2.stop();
  11065. }
  11066. }
  11067. }, _callee2, this);
  11068. }));
  11069. function _readFromStorage(_x2) {
  11070. return _ref2.apply(this, arguments);
  11071. }
  11072. return _readFromStorage;
  11073. }()
  11074. }, {
  11075. key: "reset",
  11076. value: function () {
  11077. var _ref3 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee3() {
  11078. return _regenerator2.default.wrap(function _callee3$(_context3) {
  11079. while (1) {
  11080. switch (_context3.prev = _context3.next) {
  11081. case 0:
  11082. _context3.next = 2;
  11083. return this._initializedPromise;
  11084. case 2:
  11085. this.prefs = Object.assign(Object.create(null), this.defaults);
  11086. return _context3.abrupt("return", this._writeToStorage(this.defaults));
  11087. case 4:
  11088. case "end":
  11089. return _context3.stop();
  11090. }
  11091. }
  11092. }, _callee3, this);
  11093. }));
  11094. function reset() {
  11095. return _ref3.apply(this, arguments);
  11096. }
  11097. return reset;
  11098. }()
  11099. }, {
  11100. key: "set",
  11101. value: function () {
  11102. var _ref4 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee4(name, value) {
  11103. var defaultValue, valueType, defaultType;
  11104. return _regenerator2.default.wrap(function _callee4$(_context4) {
  11105. while (1) {
  11106. switch (_context4.prev = _context4.next) {
  11107. case 0:
  11108. _context4.next = 2;
  11109. return this._initializedPromise;
  11110. case 2:
  11111. defaultValue = this.defaults[name];
  11112. if (!(defaultValue === undefined)) {
  11113. _context4.next = 7;
  11114. break;
  11115. }
  11116. throw new Error("Set preference: \"" + name + "\" is undefined.");
  11117. case 7:
  11118. if (!(value === undefined)) {
  11119. _context4.next = 9;
  11120. break;
  11121. }
  11122. throw new Error('Set preference: no value is specified.');
  11123. case 9:
  11124. valueType = typeof value === "undefined" ? "undefined" : _typeof(value);
  11125. defaultType = typeof defaultValue === "undefined" ? "undefined" : _typeof(defaultValue);
  11126. if (!(valueType !== defaultType)) {
  11127. _context4.next = 19;
  11128. break;
  11129. }
  11130. if (!(valueType === 'number' && defaultType === 'string')) {
  11131. _context4.next = 16;
  11132. break;
  11133. }
  11134. value = value.toString();
  11135. _context4.next = 17;
  11136. break;
  11137. case 16:
  11138. throw new Error("Set preference: \"" + value + "\" is a " + valueType + ", " + ("expected a " + defaultType + "."));
  11139. case 17:
  11140. _context4.next = 21;
  11141. break;
  11142. case 19:
  11143. if (!(valueType === 'number' && !Number.isInteger(value))) {
  11144. _context4.next = 21;
  11145. break;
  11146. }
  11147. throw new Error("Set preference: \"" + value + "\" must be an integer.");
  11148. case 21:
  11149. this.prefs[name] = value;
  11150. return _context4.abrupt("return", this._writeToStorage(this.prefs));
  11151. case 23:
  11152. case "end":
  11153. return _context4.stop();
  11154. }
  11155. }
  11156. }, _callee4, this);
  11157. }));
  11158. function set(_x3, _x4) {
  11159. return _ref4.apply(this, arguments);
  11160. }
  11161. return set;
  11162. }()
  11163. }, {
  11164. key: "get",
  11165. value: function () {
  11166. var _ref5 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee5(name) {
  11167. var defaultValue, prefValue;
  11168. return _regenerator2.default.wrap(function _callee5$(_context5) {
  11169. while (1) {
  11170. switch (_context5.prev = _context5.next) {
  11171. case 0:
  11172. _context5.next = 2;
  11173. return this._initializedPromise;
  11174. case 2:
  11175. defaultValue = this.defaults[name];
  11176. if (!(defaultValue === undefined)) {
  11177. _context5.next = 7;
  11178. break;
  11179. }
  11180. throw new Error("Get preference: \"" + name + "\" is undefined.");
  11181. case 7:
  11182. prefValue = this.prefs[name];
  11183. if (!(prefValue !== undefined)) {
  11184. _context5.next = 10;
  11185. break;
  11186. }
  11187. return _context5.abrupt("return", prefValue);
  11188. case 10:
  11189. return _context5.abrupt("return", defaultValue);
  11190. case 11:
  11191. case "end":
  11192. return _context5.stop();
  11193. }
  11194. }
  11195. }, _callee5, this);
  11196. }));
  11197. function get(_x5) {
  11198. return _ref5.apply(this, arguments);
  11199. }
  11200. return get;
  11201. }()
  11202. }, {
  11203. key: "getAll",
  11204. value: function () {
  11205. var _ref6 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee6() {
  11206. return _regenerator2.default.wrap(function _callee6$(_context6) {
  11207. while (1) {
  11208. switch (_context6.prev = _context6.next) {
  11209. case 0:
  11210. _context6.next = 2;
  11211. return this._initializedPromise;
  11212. case 2:
  11213. return _context6.abrupt("return", Object.assign(Object.create(null), this.defaults, this.prefs));
  11214. case 3:
  11215. case "end":
  11216. return _context6.stop();
  11217. }
  11218. }
  11219. }, _callee6, this);
  11220. }));
  11221. function getAll() {
  11222. return _ref6.apply(this, arguments);
  11223. }
  11224. return getAll;
  11225. }()
  11226. }]);
  11227. return BasePreferences;
  11228. }();
  11229. exports.BasePreferences = BasePreferences;
  11230. /***/ }),
  11231. /* 40 */
  11232. /***/ (function(module, exports, __webpack_require__) {
  11233. "use strict";
  11234. Object.defineProperty(exports, "__esModule", {
  11235. value: true
  11236. });
  11237. exports.DownloadManager = undefined;
  11238. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  11239. var _pdfjsLib = __webpack_require__(7);
  11240. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11241. ;
  11242. var DISABLE_CREATE_OBJECT_URL = _pdfjsLib.apiCompatibilityParams.disableCreateObjectURL || false;
  11243. function _download(blobUrl, filename) {
  11244. var a = document.createElement('a');
  11245. if (!a.click) {
  11246. throw new Error('DownloadManager: "a.click()" is not supported.');
  11247. }
  11248. a.href = blobUrl;
  11249. a.target = '_parent';
  11250. if ('download' in a) {
  11251. a.download = filename;
  11252. }
  11253. (document.body || document.documentElement).appendChild(a);
  11254. a.click();
  11255. a.remove();
  11256. }
  11257. var DownloadManager = function () {
  11258. function DownloadManager(_ref) {
  11259. var _ref$disableCreateObj = _ref.disableCreateObjectURL,
  11260. disableCreateObjectURL = _ref$disableCreateObj === undefined ? DISABLE_CREATE_OBJECT_URL : _ref$disableCreateObj;
  11261. _classCallCheck(this, DownloadManager);
  11262. this.disableCreateObjectURL = disableCreateObjectURL;
  11263. }
  11264. _createClass(DownloadManager, [{
  11265. key: 'downloadUrl',
  11266. value: function downloadUrl(url, filename) {
  11267. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, 'http://example.com')) {
  11268. return;
  11269. }
  11270. _download(url + '#pdfjs.action=download', filename);
  11271. }
  11272. }, {
  11273. key: 'downloadData',
  11274. value: function downloadData(data, filename, contentType) {
  11275. if (navigator.msSaveBlob) {
  11276. return navigator.msSaveBlob(new Blob([data], { type: contentType }), filename);
  11277. }
  11278. var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, this.disableCreateObjectURL);
  11279. _download(blobUrl, filename);
  11280. }
  11281. }, {
  11282. key: 'download',
  11283. value: function download(blob, url, filename) {
  11284. if (navigator.msSaveBlob) {
  11285. if (!navigator.msSaveBlob(blob, filename)) {
  11286. this.downloadUrl(url, filename);
  11287. }
  11288. return;
  11289. }
  11290. if (this.disableCreateObjectURL) {
  11291. this.downloadUrl(url, filename);
  11292. return;
  11293. }
  11294. var blobUrl = _pdfjsLib.URL.createObjectURL(blob);
  11295. _download(blobUrl, filename);
  11296. }
  11297. }]);
  11298. return DownloadManager;
  11299. }();
  11300. exports.DownloadManager = DownloadManager;
  11301. /***/ }),
  11302. /* 41 */
  11303. /***/ (function(module, exports, __webpack_require__) {
  11304. "use strict";
  11305. Object.defineProperty(exports, "__esModule", {
  11306. value: true
  11307. });
  11308. exports.GenericL10n = undefined;
  11309. var _regenerator = __webpack_require__(2);
  11310. var _regenerator2 = _interopRequireDefault(_regenerator);
  11311. var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  11312. __webpack_require__(42);
  11313. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11314. function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
  11315. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11316. var webL10n = document.webL10n;
  11317. var GenericL10n = function () {
  11318. function GenericL10n(lang) {
  11319. _classCallCheck(this, GenericL10n);
  11320. this._lang = lang;
  11321. this._ready = new Promise(function (resolve, reject) {
  11322. webL10n.setLanguage(lang, function () {
  11323. resolve(webL10n);
  11324. });
  11325. });
  11326. }
  11327. _createClass(GenericL10n, [{
  11328. key: 'getLanguage',
  11329. value: function () {
  11330. var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee() {
  11331. var l10n;
  11332. return _regenerator2.default.wrap(function _callee$(_context) {
  11333. while (1) {
  11334. switch (_context.prev = _context.next) {
  11335. case 0:
  11336. _context.next = 2;
  11337. return this._ready;
  11338. case 2:
  11339. l10n = _context.sent;
  11340. return _context.abrupt('return', l10n.getLanguage());
  11341. case 4:
  11342. case 'end':
  11343. return _context.stop();
  11344. }
  11345. }
  11346. }, _callee, this);
  11347. }));
  11348. function getLanguage() {
  11349. return _ref.apply(this, arguments);
  11350. }
  11351. return getLanguage;
  11352. }()
  11353. }, {
  11354. key: 'getDirection',
  11355. value: function () {
  11356. var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2() {
  11357. var l10n;
  11358. return _regenerator2.default.wrap(function _callee2$(_context2) {
  11359. while (1) {
  11360. switch (_context2.prev = _context2.next) {
  11361. case 0:
  11362. _context2.next = 2;
  11363. return this._ready;
  11364. case 2:
  11365. l10n = _context2.sent;
  11366. return _context2.abrupt('return', l10n.getDirection());
  11367. case 4:
  11368. case 'end':
  11369. return _context2.stop();
  11370. }
  11371. }
  11372. }, _callee2, this);
  11373. }));
  11374. function getDirection() {
  11375. return _ref2.apply(this, arguments);
  11376. }
  11377. return getDirection;
  11378. }()
  11379. }, {
  11380. key: 'get',
  11381. value: function () {
  11382. var _ref3 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee3(property, args, fallback) {
  11383. var l10n;
  11384. return _regenerator2.default.wrap(function _callee3$(_context3) {
  11385. while (1) {
  11386. switch (_context3.prev = _context3.next) {
  11387. case 0:
  11388. _context3.next = 2;
  11389. return this._ready;
  11390. case 2:
  11391. l10n = _context3.sent;
  11392. return _context3.abrupt('return', l10n.get(property, args, fallback));
  11393. case 4:
  11394. case 'end':
  11395. return _context3.stop();
  11396. }
  11397. }
  11398. }, _callee3, this);
  11399. }));
  11400. function get(_x, _x2, _x3) {
  11401. return _ref3.apply(this, arguments);
  11402. }
  11403. return get;
  11404. }()
  11405. }, {
  11406. key: 'translate',
  11407. value: function () {
  11408. var _ref4 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee4(element) {
  11409. var l10n;
  11410. return _regenerator2.default.wrap(function _callee4$(_context4) {
  11411. while (1) {
  11412. switch (_context4.prev = _context4.next) {
  11413. case 0:
  11414. _context4.next = 2;
  11415. return this._ready;
  11416. case 2:
  11417. l10n = _context4.sent;
  11418. return _context4.abrupt('return', l10n.translate(element));
  11419. case 4:
  11420. case 'end':
  11421. return _context4.stop();
  11422. }
  11423. }
  11424. }, _callee4, this);
  11425. }));
  11426. function translate(_x4) {
  11427. return _ref4.apply(this, arguments);
  11428. }
  11429. return translate;
  11430. }()
  11431. }]);
  11432. return GenericL10n;
  11433. }();
  11434. exports.GenericL10n = GenericL10n;
  11435. /***/ }),
  11436. /* 42 */
  11437. /***/ (function(module, exports, __webpack_require__) {
  11438. "use strict";
  11439. document.webL10n = function (window, document, undefined) {
  11440. var gL10nData = {};
  11441. var gTextData = '';
  11442. var gTextProp = 'textContent';
  11443. var gLanguage = '';
  11444. var gMacros = {};
  11445. var gReadyState = 'loading';
  11446. var gAsyncResourceLoading = true;
  11447. function getL10nResourceLinks() {
  11448. return document.querySelectorAll('link[type="application/l10n"]');
  11449. }
  11450. function getL10nDictionary() {
  11451. var script = document.querySelector('script[type="application/l10n"]');
  11452. return script ? JSON.parse(script.innerHTML) : null;
  11453. }
  11454. function getTranslatableChildren(element) {
  11455. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  11456. }
  11457. function getL10nAttributes(element) {
  11458. if (!element) return {};
  11459. var l10nId = element.getAttribute('data-l10n-id');
  11460. var l10nArgs = element.getAttribute('data-l10n-args');
  11461. var args = {};
  11462. if (l10nArgs) {
  11463. try {
  11464. args = JSON.parse(l10nArgs);
  11465. } catch (e) {
  11466. console.warn('could not parse arguments for #' + l10nId);
  11467. }
  11468. }
  11469. return {
  11470. id: l10nId,
  11471. args: args
  11472. };
  11473. }
  11474. function fireL10nReadyEvent(lang) {
  11475. var evtObject = document.createEvent('Event');
  11476. evtObject.initEvent('localized', true, false);
  11477. evtObject.language = lang;
  11478. document.dispatchEvent(evtObject);
  11479. }
  11480. function xhrLoadText(url, onSuccess, onFailure) {
  11481. onSuccess = onSuccess || function _onSuccess(data) {};
  11482. onFailure = onFailure || function _onFailure() {};
  11483. var xhr = new XMLHttpRequest();
  11484. xhr.open('GET', url, gAsyncResourceLoading);
  11485. if (xhr.overrideMimeType) {
  11486. xhr.overrideMimeType('text/plain; charset=utf-8');
  11487. }
  11488. xhr.onreadystatechange = function () {
  11489. if (xhr.readyState == 4) {
  11490. if (xhr.status == 200 || xhr.status === 0) {
  11491. onSuccess(xhr.responseText);
  11492. } else {
  11493. onFailure();
  11494. }
  11495. }
  11496. };
  11497. xhr.onerror = onFailure;
  11498. xhr.ontimeout = onFailure;
  11499. try {
  11500. xhr.send(null);
  11501. } catch (e) {
  11502. onFailure();
  11503. }
  11504. }
  11505. function parseResource(href, lang, successCallback, failureCallback) {
  11506. var baseURL = href.replace(/[^\/]*$/, '') || './';
  11507. function evalString(text) {
  11508. if (text.lastIndexOf('\\') < 0) return text;
  11509. 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, "'");
  11510. }
  11511. function parseProperties(text, parsedPropertiesCallback) {
  11512. var dictionary = {};
  11513. var reBlank = /^\s*|\s*$/;
  11514. var reComment = /^\s*#|^\s*$/;
  11515. var reSection = /^\s*\[(.*)\]\s*$/;
  11516. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  11517. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  11518. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  11519. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  11520. var currentLang = '*';
  11521. var genericLang = lang.split('-', 1)[0];
  11522. var skipLang = false;
  11523. var match = '';
  11524. function nextEntry() {
  11525. while (true) {
  11526. if (!entries.length) {
  11527. parsedRawLinesCallback();
  11528. return;
  11529. }
  11530. var line = entries.shift();
  11531. if (reComment.test(line)) continue;
  11532. if (extendedSyntax) {
  11533. match = reSection.exec(line);
  11534. if (match) {
  11535. currentLang = match[1].toLowerCase();
  11536. skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
  11537. continue;
  11538. } else if (skipLang) {
  11539. continue;
  11540. }
  11541. match = reImport.exec(line);
  11542. if (match) {
  11543. loadImport(baseURL + match[1], nextEntry);
  11544. return;
  11545. }
  11546. }
  11547. var tmp = line.match(reSplit);
  11548. if (tmp && tmp.length == 3) {
  11549. dictionary[tmp[1]] = evalString(tmp[2]);
  11550. }
  11551. }
  11552. }
  11553. nextEntry();
  11554. }
  11555. function loadImport(url, callback) {
  11556. xhrLoadText(url, function (content) {
  11557. parseRawLines(content, false, callback);
  11558. }, function () {
  11559. console.warn(url + ' not found.');
  11560. callback();
  11561. });
  11562. }
  11563. parseRawLines(text, true, function () {
  11564. parsedPropertiesCallback(dictionary);
  11565. });
  11566. }
  11567. xhrLoadText(href, function (response) {
  11568. gTextData += response;
  11569. parseProperties(response, function (data) {
  11570. for (var key in data) {
  11571. var id,
  11572. prop,
  11573. index = key.lastIndexOf('.');
  11574. if (index > 0) {
  11575. id = key.substring(0, index);
  11576. prop = key.substring(index + 1);
  11577. } else {
  11578. id = key;
  11579. prop = gTextProp;
  11580. }
  11581. if (!gL10nData[id]) {
  11582. gL10nData[id] = {};
  11583. }
  11584. gL10nData[id][prop] = data[key];
  11585. }
  11586. if (successCallback) {
  11587. successCallback();
  11588. }
  11589. });
  11590. }, failureCallback);
  11591. }
  11592. function loadLocale(lang, callback) {
  11593. if (lang) {
  11594. lang = lang.toLowerCase();
  11595. }
  11596. callback = callback || function _callback() {};
  11597. clear();
  11598. gLanguage = lang;
  11599. var langLinks = getL10nResourceLinks();
  11600. var langCount = langLinks.length;
  11601. if (langCount === 0) {
  11602. var dict = getL10nDictionary();
  11603. if (dict && dict.locales && dict.default_locale) {
  11604. console.log('using the embedded JSON directory, early way out');
  11605. gL10nData = dict.locales[lang];
  11606. if (!gL10nData) {
  11607. var defaultLocale = dict.default_locale.toLowerCase();
  11608. for (var anyCaseLang in dict.locales) {
  11609. anyCaseLang = anyCaseLang.toLowerCase();
  11610. if (anyCaseLang === lang) {
  11611. gL10nData = dict.locales[lang];
  11612. break;
  11613. } else if (anyCaseLang === defaultLocale) {
  11614. gL10nData = dict.locales[defaultLocale];
  11615. }
  11616. }
  11617. }
  11618. callback();
  11619. } else {
  11620. console.log('no resource to load, early way out');
  11621. }
  11622. fireL10nReadyEvent(lang);
  11623. gReadyState = 'complete';
  11624. return;
  11625. }
  11626. var onResourceLoaded = null;
  11627. var gResourceCount = 0;
  11628. onResourceLoaded = function onResourceLoaded() {
  11629. gResourceCount++;
  11630. if (gResourceCount >= langCount) {
  11631. callback();
  11632. fireL10nReadyEvent(lang);
  11633. gReadyState = 'complete';
  11634. }
  11635. };
  11636. function L10nResourceLink(link) {
  11637. var href = link.href;
  11638. this.load = function (lang, callback) {
  11639. parseResource(href, lang, callback, function () {
  11640. console.warn(href + ' not found.');
  11641. console.warn('"' + lang + '" resource not found');
  11642. gLanguage = '';
  11643. callback();
  11644. });
  11645. };
  11646. }
  11647. for (var i = 0; i < langCount; i++) {
  11648. var resource = new L10nResourceLink(langLinks[i]);
  11649. resource.load(lang, onResourceLoaded);
  11650. }
  11651. }
  11652. function clear() {
  11653. gL10nData = {};
  11654. gTextData = '';
  11655. gLanguage = '';
  11656. }
  11657. function getPluralRules(lang) {
  11658. var locales2rules = {
  11659. 'af': 3,
  11660. 'ak': 4,
  11661. 'am': 4,
  11662. 'ar': 1,
  11663. 'asa': 3,
  11664. 'az': 0,
  11665. 'be': 11,
  11666. 'bem': 3,
  11667. 'bez': 3,
  11668. 'bg': 3,
  11669. 'bh': 4,
  11670. 'bm': 0,
  11671. 'bn': 3,
  11672. 'bo': 0,
  11673. 'br': 20,
  11674. 'brx': 3,
  11675. 'bs': 11,
  11676. 'ca': 3,
  11677. 'cgg': 3,
  11678. 'chr': 3,
  11679. 'cs': 12,
  11680. 'cy': 17,
  11681. 'da': 3,
  11682. 'de': 3,
  11683. 'dv': 3,
  11684. 'dz': 0,
  11685. 'ee': 3,
  11686. 'el': 3,
  11687. 'en': 3,
  11688. 'eo': 3,
  11689. 'es': 3,
  11690. 'et': 3,
  11691. 'eu': 3,
  11692. 'fa': 0,
  11693. 'ff': 5,
  11694. 'fi': 3,
  11695. 'fil': 4,
  11696. 'fo': 3,
  11697. 'fr': 5,
  11698. 'fur': 3,
  11699. 'fy': 3,
  11700. 'ga': 8,
  11701. 'gd': 24,
  11702. 'gl': 3,
  11703. 'gsw': 3,
  11704. 'gu': 3,
  11705. 'guw': 4,
  11706. 'gv': 23,
  11707. 'ha': 3,
  11708. 'haw': 3,
  11709. 'he': 2,
  11710. 'hi': 4,
  11711. 'hr': 11,
  11712. 'hu': 0,
  11713. 'id': 0,
  11714. 'ig': 0,
  11715. 'ii': 0,
  11716. 'is': 3,
  11717. 'it': 3,
  11718. 'iu': 7,
  11719. 'ja': 0,
  11720. 'jmc': 3,
  11721. 'jv': 0,
  11722. 'ka': 0,
  11723. 'kab': 5,
  11724. 'kaj': 3,
  11725. 'kcg': 3,
  11726. 'kde': 0,
  11727. 'kea': 0,
  11728. 'kk': 3,
  11729. 'kl': 3,
  11730. 'km': 0,
  11731. 'kn': 0,
  11732. 'ko': 0,
  11733. 'ksb': 3,
  11734. 'ksh': 21,
  11735. 'ku': 3,
  11736. 'kw': 7,
  11737. 'lag': 18,
  11738. 'lb': 3,
  11739. 'lg': 3,
  11740. 'ln': 4,
  11741. 'lo': 0,
  11742. 'lt': 10,
  11743. 'lv': 6,
  11744. 'mas': 3,
  11745. 'mg': 4,
  11746. 'mk': 16,
  11747. 'ml': 3,
  11748. 'mn': 3,
  11749. 'mo': 9,
  11750. 'mr': 3,
  11751. 'ms': 0,
  11752. 'mt': 15,
  11753. 'my': 0,
  11754. 'nah': 3,
  11755. 'naq': 7,
  11756. 'nb': 3,
  11757. 'nd': 3,
  11758. 'ne': 3,
  11759. 'nl': 3,
  11760. 'nn': 3,
  11761. 'no': 3,
  11762. 'nr': 3,
  11763. 'nso': 4,
  11764. 'ny': 3,
  11765. 'nyn': 3,
  11766. 'om': 3,
  11767. 'or': 3,
  11768. 'pa': 3,
  11769. 'pap': 3,
  11770. 'pl': 13,
  11771. 'ps': 3,
  11772. 'pt': 3,
  11773. 'rm': 3,
  11774. 'ro': 9,
  11775. 'rof': 3,
  11776. 'ru': 11,
  11777. 'rwk': 3,
  11778. 'sah': 0,
  11779. 'saq': 3,
  11780. 'se': 7,
  11781. 'seh': 3,
  11782. 'ses': 0,
  11783. 'sg': 0,
  11784. 'sh': 11,
  11785. 'shi': 19,
  11786. 'sk': 12,
  11787. 'sl': 14,
  11788. 'sma': 7,
  11789. 'smi': 7,
  11790. 'smj': 7,
  11791. 'smn': 7,
  11792. 'sms': 7,
  11793. 'sn': 3,
  11794. 'so': 3,
  11795. 'sq': 3,
  11796. 'sr': 11,
  11797. 'ss': 3,
  11798. 'ssy': 3,
  11799. 'st': 3,
  11800. 'sv': 3,
  11801. 'sw': 3,
  11802. 'syr': 3,
  11803. 'ta': 3,
  11804. 'te': 3,
  11805. 'teo': 3,
  11806. 'th': 0,
  11807. 'ti': 4,
  11808. 'tig': 3,
  11809. 'tk': 3,
  11810. 'tl': 4,
  11811. 'tn': 3,
  11812. 'to': 0,
  11813. 'tr': 0,
  11814. 'ts': 3,
  11815. 'tzm': 22,
  11816. 'uk': 11,
  11817. 'ur': 3,
  11818. 've': 3,
  11819. 'vi': 0,
  11820. 'vun': 3,
  11821. 'wa': 4,
  11822. 'wae': 3,
  11823. 'wo': 0,
  11824. 'xh': 3,
  11825. 'xog': 3,
  11826. 'yo': 0,
  11827. 'zh': 0,
  11828. 'zu': 3
  11829. };
  11830. function isIn(n, list) {
  11831. return list.indexOf(n) !== -1;
  11832. }
  11833. function isBetween(n, start, end) {
  11834. return start <= n && n <= end;
  11835. }
  11836. var pluralRules = {
  11837. '0': function _(n) {
  11838. return 'other';
  11839. },
  11840. '1': function _(n) {
  11841. if (isBetween(n % 100, 3, 10)) return 'few';
  11842. if (n === 0) return 'zero';
  11843. if (isBetween(n % 100, 11, 99)) return 'many';
  11844. if (n == 2) return 'two';
  11845. if (n == 1) return 'one';
  11846. return 'other';
  11847. },
  11848. '2': function _(n) {
  11849. if (n !== 0 && n % 10 === 0) return 'many';
  11850. if (n == 2) return 'two';
  11851. if (n == 1) return 'one';
  11852. return 'other';
  11853. },
  11854. '3': function _(n) {
  11855. if (n == 1) return 'one';
  11856. return 'other';
  11857. },
  11858. '4': function _(n) {
  11859. if (isBetween(n, 0, 1)) return 'one';
  11860. return 'other';
  11861. },
  11862. '5': function _(n) {
  11863. if (isBetween(n, 0, 2) && n != 2) return 'one';
  11864. return 'other';
  11865. },
  11866. '6': function _(n) {
  11867. if (n === 0) return 'zero';
  11868. if (n % 10 == 1 && n % 100 != 11) return 'one';
  11869. return 'other';
  11870. },
  11871. '7': function _(n) {
  11872. if (n == 2) return 'two';
  11873. if (n == 1) return 'one';
  11874. return 'other';
  11875. },
  11876. '8': function _(n) {
  11877. if (isBetween(n, 3, 6)) return 'few';
  11878. if (isBetween(n, 7, 10)) return 'many';
  11879. if (n == 2) return 'two';
  11880. if (n == 1) return 'one';
  11881. return 'other';
  11882. },
  11883. '9': function _(n) {
  11884. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  11885. if (n == 1) return 'one';
  11886. return 'other';
  11887. },
  11888. '10': function _(n) {
  11889. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  11890. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  11891. return 'other';
  11892. },
  11893. '11': function _(n) {
  11894. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  11895. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
  11896. if (n % 10 == 1 && n % 100 != 11) return 'one';
  11897. return 'other';
  11898. },
  11899. '12': function _(n) {
  11900. if (isBetween(n, 2, 4)) return 'few';
  11901. if (n == 1) return 'one';
  11902. return 'other';
  11903. },
  11904. '13': function _(n) {
  11905. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  11906. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
  11907. if (n == 1) return 'one';
  11908. return 'other';
  11909. },
  11910. '14': function _(n) {
  11911. if (isBetween(n % 100, 3, 4)) return 'few';
  11912. if (n % 100 == 2) return 'two';
  11913. if (n % 100 == 1) return 'one';
  11914. return 'other';
  11915. },
  11916. '15': function _(n) {
  11917. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  11918. if (isBetween(n % 100, 11, 19)) return 'many';
  11919. if (n == 1) return 'one';
  11920. return 'other';
  11921. },
  11922. '16': function _(n) {
  11923. if (n % 10 == 1 && n != 11) return 'one';
  11924. return 'other';
  11925. },
  11926. '17': function _(n) {
  11927. if (n == 3) return 'few';
  11928. if (n === 0) return 'zero';
  11929. if (n == 6) return 'many';
  11930. if (n == 2) return 'two';
  11931. if (n == 1) return 'one';
  11932. return 'other';
  11933. },
  11934. '18': function _(n) {
  11935. if (n === 0) return 'zero';
  11936. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  11937. return 'other';
  11938. },
  11939. '19': function _(n) {
  11940. if (isBetween(n, 2, 10)) return 'few';
  11941. if (isBetween(n, 0, 1)) return 'one';
  11942. return 'other';
  11943. },
  11944. '20': function _(n) {
  11945. 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';
  11946. if (n % 1000000 === 0 && n !== 0) return 'many';
  11947. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  11948. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  11949. return 'other';
  11950. },
  11951. '21': function _(n) {
  11952. if (n === 0) return 'zero';
  11953. if (n == 1) return 'one';
  11954. return 'other';
  11955. },
  11956. '22': function _(n) {
  11957. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  11958. return 'other';
  11959. },
  11960. '23': function _(n) {
  11961. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  11962. return 'other';
  11963. },
  11964. '24': function _(n) {
  11965. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  11966. if (isIn(n, [2, 12])) return 'two';
  11967. if (isIn(n, [1, 11])) return 'one';
  11968. return 'other';
  11969. }
  11970. };
  11971. var index = locales2rules[lang.replace(/-.*$/, '')];
  11972. if (!(index in pluralRules)) {
  11973. console.warn('plural form unknown for [' + lang + ']');
  11974. return function () {
  11975. return 'other';
  11976. };
  11977. }
  11978. return pluralRules[index];
  11979. }
  11980. gMacros.plural = function (str, param, key, prop) {
  11981. var n = parseFloat(param);
  11982. if (isNaN(n)) return str;
  11983. if (prop != gTextProp) return str;
  11984. if (!gMacros._pluralRules) {
  11985. gMacros._pluralRules = getPluralRules(gLanguage);
  11986. }
  11987. var index = '[' + gMacros._pluralRules(n) + ']';
  11988. if (n === 0 && key + '[zero]' in gL10nData) {
  11989. str = gL10nData[key + '[zero]'][prop];
  11990. } else if (n == 1 && key + '[one]' in gL10nData) {
  11991. str = gL10nData[key + '[one]'][prop];
  11992. } else if (n == 2 && key + '[two]' in gL10nData) {
  11993. str = gL10nData[key + '[two]'][prop];
  11994. } else if (key + index in gL10nData) {
  11995. str = gL10nData[key + index][prop];
  11996. } else if (key + '[other]' in gL10nData) {
  11997. str = gL10nData[key + '[other]'][prop];
  11998. }
  11999. return str;
  12000. };
  12001. function getL10nData(key, args, fallback) {
  12002. var data = gL10nData[key];
  12003. if (!data) {
  12004. console.warn('#' + key + ' is undefined.');
  12005. if (!fallback) {
  12006. return null;
  12007. }
  12008. data = fallback;
  12009. }
  12010. var rv = {};
  12011. for (var prop in data) {
  12012. var str = data[prop];
  12013. str = substIndexes(str, args, key, prop);
  12014. str = substArguments(str, args, key);
  12015. rv[prop] = str;
  12016. }
  12017. return rv;
  12018. }
  12019. function substIndexes(str, args, key, prop) {
  12020. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  12021. var reMatch = reIndex.exec(str);
  12022. if (!reMatch || !reMatch.length) return str;
  12023. var macroName = reMatch[1];
  12024. var paramName = reMatch[2];
  12025. var param;
  12026. if (args && paramName in args) {
  12027. param = args[paramName];
  12028. } else if (paramName in gL10nData) {
  12029. param = gL10nData[paramName];
  12030. }
  12031. if (macroName in gMacros) {
  12032. var macro = gMacros[macroName];
  12033. str = macro(str, param, key, prop);
  12034. }
  12035. return str;
  12036. }
  12037. function substArguments(str, args, key) {
  12038. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  12039. return str.replace(reArgs, function (matched_text, arg) {
  12040. if (args && arg in args) {
  12041. return args[arg];
  12042. }
  12043. if (arg in gL10nData) {
  12044. return gL10nData[arg];
  12045. }
  12046. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  12047. return matched_text;
  12048. });
  12049. }
  12050. function translateElement(element) {
  12051. var l10n = getL10nAttributes(element);
  12052. if (!l10n.id) return;
  12053. var data = getL10nData(l10n.id, l10n.args);
  12054. if (!data) {
  12055. console.warn('#' + l10n.id + ' is undefined.');
  12056. return;
  12057. }
  12058. if (data[gTextProp]) {
  12059. if (getChildElementCount(element) === 0) {
  12060. element[gTextProp] = data[gTextProp];
  12061. } else {
  12062. var children = element.childNodes;
  12063. var found = false;
  12064. for (var i = 0, l = children.length; i < l; i++) {
  12065. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  12066. if (found) {
  12067. children[i].nodeValue = '';
  12068. } else {
  12069. children[i].nodeValue = data[gTextProp];
  12070. found = true;
  12071. }
  12072. }
  12073. }
  12074. if (!found) {
  12075. var textNode = document.createTextNode(data[gTextProp]);
  12076. element.insertBefore(textNode, element.firstChild);
  12077. }
  12078. }
  12079. delete data[gTextProp];
  12080. }
  12081. for (var k in data) {
  12082. element[k] = data[k];
  12083. }
  12084. }
  12085. function getChildElementCount(element) {
  12086. if (element.children) {
  12087. return element.children.length;
  12088. }
  12089. if (typeof element.childElementCount !== 'undefined') {
  12090. return element.childElementCount;
  12091. }
  12092. var count = 0;
  12093. for (var i = 0; i < element.childNodes.length; i++) {
  12094. count += element.nodeType === 1 ? 1 : 0;
  12095. }
  12096. return count;
  12097. }
  12098. function translateFragment(element) {
  12099. element = element || document.documentElement;
  12100. var children = getTranslatableChildren(element);
  12101. var elementCount = children.length;
  12102. for (var i = 0; i < elementCount; i++) {
  12103. translateElement(children[i]);
  12104. }
  12105. translateElement(element);
  12106. }
  12107. return {
  12108. get: function get(key, args, fallbackString) {
  12109. var index = key.lastIndexOf('.');
  12110. var prop = gTextProp;
  12111. if (index > 0) {
  12112. prop = key.substring(index + 1);
  12113. key = key.substring(0, index);
  12114. }
  12115. var fallback;
  12116. if (fallbackString) {
  12117. fallback = {};
  12118. fallback[prop] = fallbackString;
  12119. }
  12120. var data = getL10nData(key, args, fallback);
  12121. if (data && prop in data) {
  12122. return data[prop];
  12123. }
  12124. return '{{' + key + '}}';
  12125. },
  12126. getData: function getData() {
  12127. return gL10nData;
  12128. },
  12129. getText: function getText() {
  12130. return gTextData;
  12131. },
  12132. getLanguage: function getLanguage() {
  12133. return gLanguage;
  12134. },
  12135. setLanguage: function setLanguage(lang, callback) {
  12136. loadLocale(lang, function () {
  12137. if (callback) callback();
  12138. });
  12139. },
  12140. getDirection: function getDirection() {
  12141. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  12142. var shortCode = gLanguage.split('-', 1)[0];
  12143. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  12144. },
  12145. translate: translateFragment,
  12146. getReadyState: function getReadyState() {
  12147. return gReadyState;
  12148. },
  12149. ready: function ready(callback) {
  12150. if (!callback) {
  12151. return;
  12152. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  12153. window.setTimeout(function () {
  12154. callback();
  12155. });
  12156. } else if (document.addEventListener) {
  12157. document.addEventListener('localized', function once() {
  12158. document.removeEventListener('localized', once);
  12159. callback();
  12160. });
  12161. }
  12162. }
  12163. };
  12164. }(window, document);
  12165. /***/ }),
  12166. /* 43 */
  12167. /***/ (function(module, exports, __webpack_require__) {
  12168. "use strict";
  12169. Object.defineProperty(exports, "__esModule", {
  12170. value: true
  12171. });
  12172. exports.PDFPrintService = undefined;
  12173. var _ui_utils = __webpack_require__(6);
  12174. var _app = __webpack_require__(1);
  12175. var _pdfjsLib = __webpack_require__(7);
  12176. var activeService = null;
  12177. var overlayManager = null;
  12178. function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size) {
  12179. var scratchCanvas = activeService.scratchCanvas;
  12180. var PRINT_RESOLUTION = 150;
  12181. var PRINT_UNITS = PRINT_RESOLUTION / 72.0;
  12182. scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
  12183. scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
  12184. var width = Math.floor(size.width * _ui_utils.CSS_UNITS) + 'px';
  12185. var height = Math.floor(size.height * _ui_utils.CSS_UNITS) + 'px';
  12186. var ctx = scratchCanvas.getContext('2d');
  12187. ctx.save();
  12188. ctx.fillStyle = 'rgb(255, 255, 255)';
  12189. ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height);
  12190. ctx.restore();
  12191. return pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  12192. var renderContext = {
  12193. canvasContext: ctx,
  12194. transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
  12195. viewport: pdfPage.getViewport(1, size.rotation),
  12196. intent: 'print'
  12197. };
  12198. return pdfPage.render(renderContext).promise;
  12199. }).then(function () {
  12200. return {
  12201. width: width,
  12202. height: height
  12203. };
  12204. });
  12205. }
  12206. function PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
  12207. this.pdfDocument = pdfDocument;
  12208. this.pagesOverview = pagesOverview;
  12209. this.printContainer = printContainer;
  12210. this.l10n = l10n || _ui_utils.NullL10n;
  12211. this.disableCreateObjectURL = pdfDocument.loadingParams['disableCreateObjectURL'];
  12212. this.currentPage = -1;
  12213. this.scratchCanvas = document.createElement('canvas');
  12214. }
  12215. PDFPrintService.prototype = {
  12216. layout: function layout() {
  12217. this.throwIfInactive();
  12218. var body = document.querySelector('body');
  12219. body.setAttribute('data-pdfjsprinting', true);
  12220. var hasEqualPageSizes = this.pagesOverview.every(function (size) {
  12221. return size.width === this.pagesOverview[0].width && size.height === this.pagesOverview[0].height;
  12222. }, this);
  12223. if (!hasEqualPageSizes) {
  12224. console.warn('Not all pages have the same size. The printed ' + 'result may be incorrect!');
  12225. }
  12226. this.pageStyleSheet = document.createElement('style');
  12227. var pageSize = this.pagesOverview[0];
  12228. this.pageStyleSheet.textContent = '@supports ((size:A4) and (size:1pt 1pt)) {' + '@page { size: ' + pageSize.width + 'pt ' + pageSize.height + 'pt;}' + '}';
  12229. body.appendChild(this.pageStyleSheet);
  12230. },
  12231. destroy: function destroy() {
  12232. if (activeService !== this) {
  12233. return;
  12234. }
  12235. this.printContainer.textContent = '';
  12236. if (this.pageStyleSheet) {
  12237. this.pageStyleSheet.remove();
  12238. this.pageStyleSheet = null;
  12239. }
  12240. this.scratchCanvas.width = this.scratchCanvas.height = 0;
  12241. this.scratchCanvas = null;
  12242. activeService = null;
  12243. ensureOverlay().then(function () {
  12244. if (overlayManager.active !== 'printServiceOverlay') {
  12245. return;
  12246. }
  12247. overlayManager.close('printServiceOverlay');
  12248. });
  12249. },
  12250. renderPages: function renderPages() {
  12251. var _this = this;
  12252. var pageCount = this.pagesOverview.length;
  12253. var renderNextPage = function renderNextPage(resolve, reject) {
  12254. _this.throwIfInactive();
  12255. if (++_this.currentPage >= pageCount) {
  12256. renderProgress(pageCount, pageCount, _this.l10n);
  12257. resolve();
  12258. return;
  12259. }
  12260. var index = _this.currentPage;
  12261. renderProgress(index, pageCount, _this.l10n);
  12262. renderPage(_this, _this.pdfDocument, index + 1, _this.pagesOverview[index]).then(_this.useRenderedPage.bind(_this)).then(function () {
  12263. renderNextPage(resolve, reject);
  12264. }, reject);
  12265. };
  12266. return new Promise(renderNextPage);
  12267. },
  12268. useRenderedPage: function useRenderedPage(printItem) {
  12269. this.throwIfInactive();
  12270. var img = document.createElement('img');
  12271. img.style.width = printItem.width;
  12272. img.style.height = printItem.height;
  12273. var scratchCanvas = this.scratchCanvas;
  12274. if ('toBlob' in scratchCanvas && !this.disableCreateObjectURL) {
  12275. scratchCanvas.toBlob(function (blob) {
  12276. img.src = _pdfjsLib.URL.createObjectURL(blob);
  12277. });
  12278. } else {
  12279. img.src = scratchCanvas.toDataURL();
  12280. }
  12281. var wrapper = document.createElement('div');
  12282. wrapper.appendChild(img);
  12283. this.printContainer.appendChild(wrapper);
  12284. return new Promise(function (resolve, reject) {
  12285. img.onload = resolve;
  12286. img.onerror = reject;
  12287. });
  12288. },
  12289. performPrint: function performPrint() {
  12290. var _this2 = this;
  12291. this.throwIfInactive();
  12292. return new Promise(function (resolve) {
  12293. setTimeout(function () {
  12294. if (!_this2.active) {
  12295. resolve();
  12296. return;
  12297. }
  12298. print.call(window);
  12299. setTimeout(resolve, 20);
  12300. }, 0);
  12301. });
  12302. },
  12303. get active() {
  12304. return this === activeService;
  12305. },
  12306. throwIfInactive: function throwIfInactive() {
  12307. if (!this.active) {
  12308. throw new Error('This print request was cancelled or completed.');
  12309. }
  12310. }
  12311. };
  12312. var print = window.print;
  12313. window.print = function print() {
  12314. if (activeService) {
  12315. console.warn('Ignored window.print() because of a pending print job.');
  12316. return;
  12317. }
  12318. ensureOverlay().then(function () {
  12319. if (activeService) {
  12320. overlayManager.open('printServiceOverlay');
  12321. }
  12322. });
  12323. try {
  12324. dispatchEvent('beforeprint');
  12325. } finally {
  12326. if (!activeService) {
  12327. console.error('Expected print service to be initialized.');
  12328. ensureOverlay().then(function () {
  12329. if (overlayManager.active === 'printServiceOverlay') {
  12330. overlayManager.close('printServiceOverlay');
  12331. }
  12332. });
  12333. return;
  12334. }
  12335. var activeServiceOnEntry = activeService;
  12336. activeService.renderPages().then(function () {
  12337. return activeServiceOnEntry.performPrint();
  12338. }).catch(function () {}).then(function () {
  12339. if (activeServiceOnEntry.active) {
  12340. abort();
  12341. }
  12342. });
  12343. }
  12344. };
  12345. function dispatchEvent(eventType) {
  12346. var event = document.createEvent('CustomEvent');
  12347. event.initCustomEvent(eventType, false, false, 'custom');
  12348. window.dispatchEvent(event);
  12349. }
  12350. function abort() {
  12351. if (activeService) {
  12352. activeService.destroy();
  12353. dispatchEvent('afterprint');
  12354. }
  12355. }
  12356. function renderProgress(index, total, l10n) {
  12357. var progressContainer = document.getElementById('printServiceOverlay');
  12358. var progress = Math.round(100 * index / total);
  12359. var progressBar = progressContainer.querySelector('progress');
  12360. var progressPerc = progressContainer.querySelector('.relative-progress');
  12361. progressBar.value = progress;
  12362. l10n.get('print_progress_percent', { progress: progress }, progress + '%').then(function (msg) {
  12363. progressPerc.textContent = msg;
  12364. });
  12365. }
  12366. var hasAttachEvent = !!document.attachEvent;
  12367. window.addEventListener('keydown', function (event) {
  12368. if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
  12369. window.print();
  12370. if (hasAttachEvent) {
  12371. return;
  12372. }
  12373. event.preventDefault();
  12374. if (event.stopImmediatePropagation) {
  12375. event.stopImmediatePropagation();
  12376. } else {
  12377. event.stopPropagation();
  12378. }
  12379. return;
  12380. }
  12381. }, true);
  12382. if (hasAttachEvent) {
  12383. document.attachEvent('onkeydown', function (event) {
  12384. event = event || window.event;
  12385. if (event.keyCode === 80 && event.ctrlKey) {
  12386. event.keyCode = 0;
  12387. return false;
  12388. }
  12389. });
  12390. }
  12391. if ('onbeforeprint' in window) {
  12392. var stopPropagationIfNeeded = function stopPropagationIfNeeded(event) {
  12393. if (event.detail !== 'custom' && event.stopImmediatePropagation) {
  12394. event.stopImmediatePropagation();
  12395. }
  12396. };
  12397. window.addEventListener('beforeprint', stopPropagationIfNeeded);
  12398. window.addEventListener('afterprint', stopPropagationIfNeeded);
  12399. }
  12400. var overlayPromise = void 0;
  12401. function ensureOverlay() {
  12402. if (!overlayPromise) {
  12403. overlayManager = _app.PDFViewerApplication.overlayManager;
  12404. if (!overlayManager) {
  12405. throw new Error('The overlay manager has not yet been initialized.');
  12406. }
  12407. overlayPromise = overlayManager.register('printServiceOverlay', document.getElementById('printServiceOverlay'), abort, true);
  12408. document.getElementById('printCancel').onclick = abort;
  12409. }
  12410. return overlayPromise;
  12411. }
  12412. _app.PDFPrintServiceFactory.instance = {
  12413. supportsPrinting: true,
  12414. createPrintService: function createPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
  12415. if (activeService) {
  12416. throw new Error('The print service is created and active.');
  12417. }
  12418. activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n);
  12419. return activeService;
  12420. }
  12421. };
  12422. exports.PDFPrintService = PDFPrintService;
  12423. /***/ })
  12424. /******/ ]);
  12425. //# sourceMappingURL=viewer.js.map