viewer.js 447 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384
  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. var defaultOptions = {
  4083. cursorToolOnLoad: {
  4084. value: 0,
  4085. kind: OptionKind.VIEWER
  4086. },
  4087. defaultUrl: {
  4088. value: file,
  4089. kind: OptionKind.VIEWER
  4090. },
  4091. defaultZoomValue: {
  4092. value: '',
  4093. kind: OptionKind.VIEWER
  4094. },
  4095. disableHistory: {
  4096. value: false,
  4097. kind: OptionKind.VIEWER
  4098. },
  4099. disablePageLabels: {
  4100. value: false,
  4101. kind: OptionKind.VIEWER
  4102. },
  4103. disablePageMode: {
  4104. value: false,
  4105. kind: OptionKind.VIEWER
  4106. },
  4107. enablePrintAutoRotate: {
  4108. value: false,
  4109. kind: OptionKind.VIEWER
  4110. },
  4111. enableWebGL: {
  4112. value: false,
  4113. kind: OptionKind.VIEWER
  4114. },
  4115. eventBusDispatchToDOM: {
  4116. value: false,
  4117. kind: OptionKind.VIEWER
  4118. },
  4119. externalLinkRel: {
  4120. value: 'noopener noreferrer nofollow',
  4121. kind: OptionKind.VIEWER
  4122. },
  4123. externalLinkTarget: {
  4124. value: 0,
  4125. kind: OptionKind.VIEWER
  4126. },
  4127. imageResourcesPath: {
  4128. value: './images/',
  4129. kind: OptionKind.VIEWER
  4130. },
  4131. maxCanvasPixels: {
  4132. value: _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216,
  4133. kind: OptionKind.VIEWER
  4134. },
  4135. pdfBugEnabled: {
  4136. value: false,
  4137. kind: OptionKind.VIEWER
  4138. },
  4139. renderer: {
  4140. value: 'canvas',
  4141. kind: OptionKind.VIEWER
  4142. },
  4143. renderInteractiveForms: {
  4144. value: false,
  4145. kind: OptionKind.VIEWER
  4146. },
  4147. showPreviousViewOnLoad: {
  4148. value: true,
  4149. kind: OptionKind.VIEWER
  4150. },
  4151. sidebarViewOnLoad: {
  4152. value: 0,
  4153. kind: OptionKind.VIEWER
  4154. },
  4155. scrollModeOnLoad: {
  4156. value: 0,
  4157. kind: OptionKind.VIEWER
  4158. },
  4159. spreadModeOnLoad: {
  4160. value: 0,
  4161. kind: OptionKind.VIEWER
  4162. },
  4163. textLayerMode: {
  4164. value: 1,
  4165. kind: OptionKind.VIEWER
  4166. },
  4167. useOnlyCssZoom: {
  4168. value: false,
  4169. kind: OptionKind.VIEWER
  4170. },
  4171. cMapPacked: {
  4172. value: true,
  4173. kind: OptionKind.API
  4174. },
  4175. cMapUrl: {
  4176. value: '../web/cmaps/',
  4177. kind: OptionKind.API
  4178. },
  4179. disableAutoFetch: {
  4180. value: false,
  4181. kind: OptionKind.API
  4182. },
  4183. disableCreateObjectURL: {
  4184. value: _pdfjsLib.apiCompatibilityParams.disableCreateObjectURL || false,
  4185. kind: OptionKind.API
  4186. },
  4187. disableFontFace: {
  4188. value: false,
  4189. kind: OptionKind.API
  4190. },
  4191. disableRange: {
  4192. value: false,
  4193. kind: OptionKind.API
  4194. },
  4195. disableStream: {
  4196. value: false,
  4197. kind: OptionKind.API
  4198. },
  4199. isEvalSupported: {
  4200. value: true,
  4201. kind: OptionKind.API
  4202. },
  4203. maxImageSize: {
  4204. value: -1,
  4205. kind: OptionKind.API
  4206. },
  4207. pdfBug: {
  4208. value: false,
  4209. kind: OptionKind.API
  4210. },
  4211. postMessageTransfers: {
  4212. value: true,
  4213. kind: OptionKind.API
  4214. },
  4215. verbosity: {
  4216. value: 1,
  4217. kind: OptionKind.API
  4218. },
  4219. workerPort: {
  4220. value: null,
  4221. kind: OptionKind.WORKER
  4222. },
  4223. workerSrc: {
  4224. value: workerSrc,
  4225. kind: OptionKind.WORKER
  4226. }
  4227. };
  4228. {
  4229. defaultOptions.locale = {
  4230. value: typeof navigator !== 'undefined' ? navigator.language : 'en-US',
  4231. kind: OptionKind.VIEWER
  4232. };
  4233. }
  4234. var userOptions = Object.create(null);
  4235. var AppOptions = function () {
  4236. function AppOptions() {
  4237. _classCallCheck(this, AppOptions);
  4238. throw new Error('Cannot initialize AppOptions.');
  4239. }
  4240. _createClass(AppOptions, null, [{
  4241. key: 'get',
  4242. value: function get(name) {
  4243. var defaultOption = defaultOptions[name],
  4244. userOption = userOptions[name];
  4245. if (userOption !== undefined) {
  4246. return userOption;
  4247. }
  4248. return defaultOption !== undefined ? defaultOption.value : undefined;
  4249. }
  4250. }, {
  4251. key: 'getAll',
  4252. value: function getAll() {
  4253. var kind = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  4254. var options = Object.create(null);
  4255. for (var name in defaultOptions) {
  4256. var defaultOption = defaultOptions[name],
  4257. userOption = userOptions[name];
  4258. if (kind && defaultOption.kind !== kind) {
  4259. continue;
  4260. }
  4261. options[name] = userOption !== undefined ? userOption : defaultOption.value;
  4262. }
  4263. return options;
  4264. }
  4265. }, {
  4266. key: 'set',
  4267. value: function set(name, value) {
  4268. userOptions[name] = value;
  4269. }
  4270. }, {
  4271. key: 'remove',
  4272. value: function remove(name) {
  4273. delete userOptions[name];
  4274. }
  4275. }]);
  4276. return AppOptions;
  4277. }();
  4278. exports.AppOptions = AppOptions;
  4279. exports.OptionKind = OptionKind;
  4280. /***/ }),
  4281. /* 13 */
  4282. /***/ (function(module, exports, __webpack_require__) {
  4283. "use strict";
  4284. var compatibilityParams = Object.create(null);
  4285. {
  4286. var userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
  4287. var isAndroid = /Android/.test(userAgent);
  4288. var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent);
  4289. (function checkCanvasSizeLimitation() {
  4290. if (isIOS || isAndroid) {
  4291. compatibilityParams.maxCanvasPixels = 5242880;
  4292. }
  4293. })();
  4294. }
  4295. exports.viewerCompatibilityParams = Object.freeze(compatibilityParams);
  4296. /***/ }),
  4297. /* 14 */
  4298. /***/ (function(module, exports, __webpack_require__) {
  4299. "use strict";
  4300. Object.defineProperty(exports, "__esModule", {
  4301. value: true
  4302. });
  4303. exports.getGlobalEventBus = exports.attachDOMEventsToEventBus = undefined;
  4304. var _ui_utils = __webpack_require__(6);
  4305. function attachDOMEventsToEventBus(eventBus) {
  4306. eventBus.on('documentload', function () {
  4307. var event = document.createEvent('CustomEvent');
  4308. event.initCustomEvent('documentload', true, true, {});
  4309. window.dispatchEvent(event);
  4310. });
  4311. eventBus.on('pagerendered', function (evt) {
  4312. var event = document.createEvent('CustomEvent');
  4313. event.initCustomEvent('pagerendered', true, true, {
  4314. pageNumber: evt.pageNumber,
  4315. cssTransform: evt.cssTransform
  4316. });
  4317. evt.source.div.dispatchEvent(event);
  4318. });
  4319. eventBus.on('textlayerrendered', function (evt) {
  4320. var event = document.createEvent('CustomEvent');
  4321. event.initCustomEvent('textlayerrendered', true, true, { pageNumber: evt.pageNumber });
  4322. evt.source.textLayerDiv.dispatchEvent(event);
  4323. });
  4324. eventBus.on('pagechange', function (evt) {
  4325. var event = document.createEvent('UIEvents');
  4326. event.initUIEvent('pagechange', true, true, window, 0);
  4327. event.pageNumber = evt.pageNumber;
  4328. evt.source.container.dispatchEvent(event);
  4329. });
  4330. eventBus.on('pagesinit', function (evt) {
  4331. var event = document.createEvent('CustomEvent');
  4332. event.initCustomEvent('pagesinit', true, true, null);
  4333. evt.source.container.dispatchEvent(event);
  4334. });
  4335. eventBus.on('pagesloaded', function (evt) {
  4336. var event = document.createEvent('CustomEvent');
  4337. event.initCustomEvent('pagesloaded', true, true, { pagesCount: evt.pagesCount });
  4338. evt.source.container.dispatchEvent(event);
  4339. });
  4340. eventBus.on('scalechange', function (evt) {
  4341. var event = document.createEvent('UIEvents');
  4342. event.initUIEvent('scalechange', true, true, window, 0);
  4343. event.scale = evt.scale;
  4344. event.presetValue = evt.presetValue;
  4345. evt.source.container.dispatchEvent(event);
  4346. });
  4347. eventBus.on('updateviewarea', function (evt) {
  4348. var event = document.createEvent('UIEvents');
  4349. event.initUIEvent('updateviewarea', true, true, window, 0);
  4350. event.location = evt.location;
  4351. evt.source.container.dispatchEvent(event);
  4352. });
  4353. eventBus.on('find', function (evt) {
  4354. if (evt.source === window) {
  4355. return;
  4356. }
  4357. var event = document.createEvent('CustomEvent');
  4358. event.initCustomEvent('find' + evt.type, true, true, {
  4359. query: evt.query,
  4360. phraseSearch: evt.phraseSearch,
  4361. caseSensitive: evt.caseSensitive,
  4362. highlightAll: evt.highlightAll,
  4363. findPrevious: evt.findPrevious
  4364. });
  4365. window.dispatchEvent(event);
  4366. });
  4367. eventBus.on('attachmentsloaded', function (evt) {
  4368. var event = document.createEvent('CustomEvent');
  4369. event.initCustomEvent('attachmentsloaded', true, true, { attachmentsCount: evt.attachmentsCount });
  4370. evt.source.container.dispatchEvent(event);
  4371. });
  4372. eventBus.on('sidebarviewchanged', function (evt) {
  4373. var event = document.createEvent('CustomEvent');
  4374. event.initCustomEvent('sidebarviewchanged', true, true, { view: evt.view });
  4375. evt.source.outerContainer.dispatchEvent(event);
  4376. });
  4377. eventBus.on('pagemode', function (evt) {
  4378. var event = document.createEvent('CustomEvent');
  4379. event.initCustomEvent('pagemode', true, true, { mode: evt.mode });
  4380. evt.source.pdfViewer.container.dispatchEvent(event);
  4381. });
  4382. eventBus.on('namedaction', function (evt) {
  4383. var event = document.createEvent('CustomEvent');
  4384. event.initCustomEvent('namedaction', true, true, { action: evt.action });
  4385. evt.source.pdfViewer.container.dispatchEvent(event);
  4386. });
  4387. eventBus.on('presentationmodechanged', function (evt) {
  4388. var event = document.createEvent('CustomEvent');
  4389. event.initCustomEvent('presentationmodechanged', true, true, {
  4390. active: evt.active,
  4391. switchInProgress: evt.switchInProgress
  4392. });
  4393. window.dispatchEvent(event);
  4394. });
  4395. eventBus.on('outlineloaded', function (evt) {
  4396. var event = document.createEvent('CustomEvent');
  4397. event.initCustomEvent('outlineloaded', true, true, { outlineCount: evt.outlineCount });
  4398. evt.source.container.dispatchEvent(event);
  4399. });
  4400. }
  4401. var globalEventBus = null;
  4402. function getGlobalEventBus() {
  4403. var dispatchToDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4404. if (!globalEventBus) {
  4405. globalEventBus = new _ui_utils.EventBus({ dispatchToDOM: dispatchToDOM });
  4406. if (!dispatchToDOM) {
  4407. attachDOMEventsToEventBus(globalEventBus);
  4408. }
  4409. }
  4410. return globalEventBus;
  4411. }
  4412. exports.attachDOMEventsToEventBus = attachDOMEventsToEventBus;
  4413. exports.getGlobalEventBus = getGlobalEventBus;
  4414. /***/ }),
  4415. /* 15 */
  4416. /***/ (function(module, exports, __webpack_require__) {
  4417. "use strict";
  4418. Object.defineProperty(exports, "__esModule", {
  4419. value: true
  4420. });
  4421. exports.OverlayManager = undefined;
  4422. var _regenerator = __webpack_require__(2);
  4423. var _regenerator2 = _interopRequireDefault(_regenerator);
  4424. 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; }; }();
  4425. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4426. 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"); }); }; }
  4427. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4428. var OverlayManager = function () {
  4429. function OverlayManager() {
  4430. _classCallCheck(this, OverlayManager);
  4431. this._overlays = {};
  4432. this._active = null;
  4433. this._keyDownBound = this._keyDown.bind(this);
  4434. }
  4435. _createClass(OverlayManager, [{
  4436. key: 'register',
  4437. value: function () {
  4438. var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee(name, element) {
  4439. var callerCloseMethod = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4440. var canForceClose = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  4441. var container;
  4442. return _regenerator2.default.wrap(function _callee$(_context) {
  4443. while (1) {
  4444. switch (_context.prev = _context.next) {
  4445. case 0:
  4446. container = void 0;
  4447. if (!(!name || !element || !(container = element.parentNode))) {
  4448. _context.next = 5;
  4449. break;
  4450. }
  4451. throw new Error('Not enough parameters.');
  4452. case 5:
  4453. if (!this._overlays[name]) {
  4454. _context.next = 7;
  4455. break;
  4456. }
  4457. throw new Error('The overlay is already registered.');
  4458. case 7:
  4459. this._overlays[name] = {
  4460. element: element,
  4461. container: container,
  4462. callerCloseMethod: callerCloseMethod,
  4463. canForceClose: canForceClose
  4464. };
  4465. case 8:
  4466. case 'end':
  4467. return _context.stop();
  4468. }
  4469. }
  4470. }, _callee, this);
  4471. }));
  4472. function register(_x3, _x4) {
  4473. return _ref.apply(this, arguments);
  4474. }
  4475. return register;
  4476. }()
  4477. }, {
  4478. key: 'unregister',
  4479. value: function () {
  4480. var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2(name) {
  4481. return _regenerator2.default.wrap(function _callee2$(_context2) {
  4482. while (1) {
  4483. switch (_context2.prev = _context2.next) {
  4484. case 0:
  4485. if (this._overlays[name]) {
  4486. _context2.next = 4;
  4487. break;
  4488. }
  4489. throw new Error('The overlay does not exist.');
  4490. case 4:
  4491. if (!(this._active === name)) {
  4492. _context2.next = 6;
  4493. break;
  4494. }
  4495. throw new Error('The overlay cannot be removed while it is active.');
  4496. case 6:
  4497. delete this._overlays[name];
  4498. case 7:
  4499. case 'end':
  4500. return _context2.stop();
  4501. }
  4502. }
  4503. }, _callee2, this);
  4504. }));
  4505. function unregister(_x5) {
  4506. return _ref2.apply(this, arguments);
  4507. }
  4508. return unregister;
  4509. }()
  4510. }, {
  4511. key: 'open',
  4512. value: function () {
  4513. var _ref3 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee3(name) {
  4514. return _regenerator2.default.wrap(function _callee3$(_context3) {
  4515. while (1) {
  4516. switch (_context3.prev = _context3.next) {
  4517. case 0:
  4518. if (this._overlays[name]) {
  4519. _context3.next = 4;
  4520. break;
  4521. }
  4522. throw new Error('The overlay does not exist.');
  4523. case 4:
  4524. if (!this._active) {
  4525. _context3.next = 14;
  4526. break;
  4527. }
  4528. if (!this._overlays[name].canForceClose) {
  4529. _context3.next = 9;
  4530. break;
  4531. }
  4532. this._closeThroughCaller();
  4533. _context3.next = 14;
  4534. break;
  4535. case 9:
  4536. if (!(this._active === name)) {
  4537. _context3.next = 13;
  4538. break;
  4539. }
  4540. throw new Error('The overlay is already active.');
  4541. case 13:
  4542. throw new Error('Another overlay is currently active.');
  4543. case 14:
  4544. this._active = name;
  4545. this._overlays[this._active].element.classList.remove('hidden');
  4546. this._overlays[this._active].container.classList.remove('hidden');
  4547. window.addEventListener('keydown', this._keyDownBound);
  4548. case 18:
  4549. case 'end':
  4550. return _context3.stop();
  4551. }
  4552. }
  4553. }, _callee3, this);
  4554. }));
  4555. function open(_x6) {
  4556. return _ref3.apply(this, arguments);
  4557. }
  4558. return open;
  4559. }()
  4560. }, {
  4561. key: 'close',
  4562. value: function () {
  4563. var _ref4 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee4(name) {
  4564. return _regenerator2.default.wrap(function _callee4$(_context4) {
  4565. while (1) {
  4566. switch (_context4.prev = _context4.next) {
  4567. case 0:
  4568. if (this._overlays[name]) {
  4569. _context4.next = 4;
  4570. break;
  4571. }
  4572. throw new Error('The overlay does not exist.');
  4573. case 4:
  4574. if (this._active) {
  4575. _context4.next = 8;
  4576. break;
  4577. }
  4578. throw new Error('The overlay is currently not active.');
  4579. case 8:
  4580. if (!(this._active !== name)) {
  4581. _context4.next = 10;
  4582. break;
  4583. }
  4584. throw new Error('Another overlay is currently active.');
  4585. case 10:
  4586. this._overlays[this._active].container.classList.add('hidden');
  4587. this._overlays[this._active].element.classList.add('hidden');
  4588. this._active = null;
  4589. window.removeEventListener('keydown', this._keyDownBound);
  4590. case 14:
  4591. case 'end':
  4592. return _context4.stop();
  4593. }
  4594. }
  4595. }, _callee4, this);
  4596. }));
  4597. function close(_x7) {
  4598. return _ref4.apply(this, arguments);
  4599. }
  4600. return close;
  4601. }()
  4602. }, {
  4603. key: '_keyDown',
  4604. value: function _keyDown(evt) {
  4605. if (this._active && evt.keyCode === 27) {
  4606. this._closeThroughCaller();
  4607. evt.preventDefault();
  4608. }
  4609. }
  4610. }, {
  4611. key: '_closeThroughCaller',
  4612. value: function _closeThroughCaller() {
  4613. if (this._overlays[this._active].callerCloseMethod) {
  4614. this._overlays[this._active].callerCloseMethod();
  4615. }
  4616. if (this._active) {
  4617. this.close(this._active);
  4618. }
  4619. }
  4620. }, {
  4621. key: 'active',
  4622. get: function get() {
  4623. return this._active;
  4624. }
  4625. }]);
  4626. return OverlayManager;
  4627. }();
  4628. exports.OverlayManager = OverlayManager;
  4629. /***/ }),
  4630. /* 16 */
  4631. /***/ (function(module, exports, __webpack_require__) {
  4632. "use strict";
  4633. Object.defineProperty(exports, "__esModule", {
  4634. value: true
  4635. });
  4636. exports.PasswordPrompt = undefined;
  4637. 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; }; }();
  4638. var _ui_utils = __webpack_require__(6);
  4639. var _pdfjsLib = __webpack_require__(7);
  4640. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4641. var PasswordPrompt = function () {
  4642. function PasswordPrompt(options, overlayManager) {
  4643. var _this = this;
  4644. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  4645. _classCallCheck(this, PasswordPrompt);
  4646. this.overlayName = options.overlayName;
  4647. this.container = options.container;
  4648. this.label = options.label;
  4649. this.input = options.input;
  4650. this.submitButton = options.submitButton;
  4651. this.cancelButton = options.cancelButton;
  4652. this.overlayManager = overlayManager;
  4653. this.l10n = l10n;
  4654. this.updateCallback = null;
  4655. this.reason = null;
  4656. this.submitButton.addEventListener('click', this.verify.bind(this));
  4657. this.cancelButton.addEventListener('click', this.close.bind(this));
  4658. this.input.addEventListener('keydown', function (e) {
  4659. if (e.keyCode === 13) {
  4660. _this.verify();
  4661. }
  4662. });
  4663. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this), true);
  4664. }
  4665. _createClass(PasswordPrompt, [{
  4666. key: 'open',
  4667. value: function open() {
  4668. var _this2 = this;
  4669. this.overlayManager.open(this.overlayName).then(function () {
  4670. _this2.input.focus();
  4671. var promptString = void 0;
  4672. if (_this2.reason === _pdfjsLib.PasswordResponses.INCORRECT_PASSWORD) {
  4673. promptString = _this2.l10n.get('password_invalid', null, 'Invalid password. Please try again.');
  4674. } else {
  4675. promptString = _this2.l10n.get('password_label', null, 'Enter the password to open this PDF file.');
  4676. }
  4677. promptString.then(function (msg) {
  4678. _this2.label.textContent = msg;
  4679. });
  4680. });
  4681. }
  4682. }, {
  4683. key: 'close',
  4684. value: function close() {
  4685. var _this3 = this;
  4686. this.overlayManager.close(this.overlayName).then(function () {
  4687. _this3.input.value = '';
  4688. });
  4689. }
  4690. }, {
  4691. key: 'verify',
  4692. value: function verify() {
  4693. var password = this.input.value;
  4694. if (password && password.length > 0) {
  4695. this.close();
  4696. return this.updateCallback(password);
  4697. }
  4698. }
  4699. }, {
  4700. key: 'setUpdateCallback',
  4701. value: function setUpdateCallback(updateCallback, reason) {
  4702. this.updateCallback = updateCallback;
  4703. this.reason = reason;
  4704. }
  4705. }]);
  4706. return PasswordPrompt;
  4707. }();
  4708. exports.PasswordPrompt = PasswordPrompt;
  4709. /***/ }),
  4710. /* 17 */
  4711. /***/ (function(module, exports, __webpack_require__) {
  4712. "use strict";
  4713. Object.defineProperty(exports, "__esModule", {
  4714. value: true
  4715. });
  4716. exports.PDFAttachmentViewer = undefined;
  4717. 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; }; }();
  4718. var _pdfjsLib = __webpack_require__(7);
  4719. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4720. var PDFAttachmentViewer = function () {
  4721. function PDFAttachmentViewer(_ref) {
  4722. var container = _ref.container,
  4723. eventBus = _ref.eventBus,
  4724. downloadManager = _ref.downloadManager;
  4725. _classCallCheck(this, PDFAttachmentViewer);
  4726. this.container = container;
  4727. this.eventBus = eventBus;
  4728. this.downloadManager = downloadManager;
  4729. this.reset();
  4730. this.eventBus.on('fileattachmentannotation', this._appendAttachment.bind(this));
  4731. }
  4732. _createClass(PDFAttachmentViewer, [{
  4733. key: 'reset',
  4734. value: function reset() {
  4735. var keepRenderedCapability = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4736. this.attachments = null;
  4737. this.container.textContent = '';
  4738. if (!keepRenderedCapability) {
  4739. this._renderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  4740. }
  4741. }
  4742. }, {
  4743. key: '_dispatchEvent',
  4744. value: function _dispatchEvent(attachmentsCount) {
  4745. this._renderedCapability.resolve();
  4746. this.eventBus.dispatch('attachmentsloaded', {
  4747. source: this,
  4748. attachmentsCount: attachmentsCount
  4749. });
  4750. }
  4751. }, {
  4752. key: '_bindPdfLink',
  4753. value: function _bindPdfLink(button, content, filename) {
  4754. if (this.downloadManager.disableCreateObjectURL) {
  4755. throw new Error('bindPdfLink: Unsupported "disableCreateObjectURL" value.');
  4756. }
  4757. var blobUrl = void 0;
  4758. button.onclick = function () {
  4759. if (!blobUrl) {
  4760. blobUrl = (0, _pdfjsLib.createObjectURL)(content, 'application/pdf');
  4761. }
  4762. var viewerUrl = void 0;
  4763. viewerUrl = '?file=' + encodeURIComponent(blobUrl + '#' + filename);
  4764. window.open(viewerUrl);
  4765. return false;
  4766. };
  4767. }
  4768. }, {
  4769. key: '_bindLink',
  4770. value: function _bindLink(button, content, filename) {
  4771. var _this = this;
  4772. button.onclick = function () {
  4773. _this.downloadManager.downloadData(content, filename, '');
  4774. return false;
  4775. };
  4776. }
  4777. }, {
  4778. key: 'render',
  4779. value: function render(_ref2) {
  4780. var attachments = _ref2.attachments,
  4781. _ref2$keepRenderedCap = _ref2.keepRenderedCapability,
  4782. keepRenderedCapability = _ref2$keepRenderedCap === undefined ? false : _ref2$keepRenderedCap;
  4783. var attachmentsCount = 0;
  4784. if (this.attachments) {
  4785. this.reset(keepRenderedCapability === true);
  4786. }
  4787. this.attachments = attachments || null;
  4788. if (!attachments) {
  4789. this._dispatchEvent(attachmentsCount);
  4790. return;
  4791. }
  4792. var names = Object.keys(attachments).sort(function (a, b) {
  4793. return a.toLowerCase().localeCompare(b.toLowerCase());
  4794. });
  4795. attachmentsCount = names.length;
  4796. for (var i = 0; i < attachmentsCount; i++) {
  4797. var item = attachments[names[i]];
  4798. var filename = (0, _pdfjsLib.removeNullCharacters)((0, _pdfjsLib.getFilenameFromUrl)(item.filename));
  4799. var div = document.createElement('div');
  4800. div.className = 'attachmentsItem';
  4801. var button = document.createElement('button');
  4802. button.textContent = filename;
  4803. if (/\.pdf$/i.test(filename) && !this.downloadManager.disableCreateObjectURL) {
  4804. this._bindPdfLink(button, item.content, filename);
  4805. } else {
  4806. this._bindLink(button, item.content, filename);
  4807. }
  4808. div.appendChild(button);
  4809. this.container.appendChild(div);
  4810. }
  4811. this._dispatchEvent(attachmentsCount);
  4812. }
  4813. }, {
  4814. key: '_appendAttachment',
  4815. value: function _appendAttachment(_ref3) {
  4816. var _this2 = this;
  4817. var id = _ref3.id,
  4818. filename = _ref3.filename,
  4819. content = _ref3.content;
  4820. this._renderedCapability.promise.then(function () {
  4821. var attachments = _this2.attachments;
  4822. if (!attachments) {
  4823. attachments = Object.create(null);
  4824. } else {
  4825. for (var name in attachments) {
  4826. if (id === name) {
  4827. return;
  4828. }
  4829. }
  4830. }
  4831. attachments[id] = {
  4832. filename: filename,
  4833. content: content
  4834. };
  4835. _this2.render({
  4836. attachments: attachments,
  4837. keepRenderedCapability: true
  4838. });
  4839. });
  4840. }
  4841. }]);
  4842. return PDFAttachmentViewer;
  4843. }();
  4844. exports.PDFAttachmentViewer = PDFAttachmentViewer;
  4845. /***/ }),
  4846. /* 18 */
  4847. /***/ (function(module, exports, __webpack_require__) {
  4848. "use strict";
  4849. Object.defineProperty(exports, "__esModule", {
  4850. value: true
  4851. });
  4852. exports.PDFDocumentProperties = undefined;
  4853. 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"); } }; }();
  4854. 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; }; }();
  4855. var _ui_utils = __webpack_require__(6);
  4856. var _pdfjsLib = __webpack_require__(7);
  4857. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4858. var DEFAULT_FIELD_CONTENT = '-';
  4859. var NON_METRIC_LOCALES = ['en-us', 'en-lr', 'my'];
  4860. var US_PAGE_NAMES = {
  4861. '8.5x11': 'Letter',
  4862. '8.5x14': 'Legal'
  4863. };
  4864. var METRIC_PAGE_NAMES = {
  4865. '297x420': 'A3',
  4866. '210x297': 'A4'
  4867. };
  4868. function getPageName(size, isPortrait, pageNames) {
  4869. var width = isPortrait ? size.width : size.height;
  4870. var height = isPortrait ? size.height : size.width;
  4871. return pageNames[width + 'x' + height];
  4872. }
  4873. var PDFDocumentProperties = function () {
  4874. function PDFDocumentProperties(_ref, overlayManager, eventBus) {
  4875. var overlayName = _ref.overlayName,
  4876. fields = _ref.fields,
  4877. container = _ref.container,
  4878. closeButton = _ref.closeButton;
  4879. var _this = this;
  4880. var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
  4881. _classCallCheck(this, PDFDocumentProperties);
  4882. this.overlayName = overlayName;
  4883. this.fields = fields;
  4884. this.container = container;
  4885. this.overlayManager = overlayManager;
  4886. this.l10n = l10n;
  4887. this._reset();
  4888. if (closeButton) {
  4889. closeButton.addEventListener('click', this.close.bind(this));
  4890. }
  4891. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this));
  4892. if (eventBus) {
  4893. eventBus.on('pagechanging', function (evt) {
  4894. _this._currentPageNumber = evt.pageNumber;
  4895. });
  4896. eventBus.on('rotationchanging', function (evt) {
  4897. _this._pagesRotation = evt.pagesRotation;
  4898. });
  4899. }
  4900. this._isNonMetricLocale = true;
  4901. l10n.getLanguage().then(function (locale) {
  4902. _this._isNonMetricLocale = NON_METRIC_LOCALES.includes(locale);
  4903. });
  4904. }
  4905. _createClass(PDFDocumentProperties, [{
  4906. key: 'open',
  4907. value: function open() {
  4908. var _this2 = this;
  4909. var freezeFieldData = function freezeFieldData(data) {
  4910. Object.defineProperty(_this2, 'fieldData', {
  4911. value: Object.freeze(data),
  4912. writable: false,
  4913. enumerable: true,
  4914. configurable: true
  4915. });
  4916. };
  4917. Promise.all([this.overlayManager.open(this.overlayName), this._dataAvailableCapability.promise]).then(function () {
  4918. var currentPageNumber = _this2._currentPageNumber;
  4919. var pagesRotation = _this2._pagesRotation;
  4920. if (_this2.fieldData && currentPageNumber === _this2.fieldData['_currentPageNumber'] && pagesRotation === _this2.fieldData['_pagesRotation']) {
  4921. _this2._updateUI();
  4922. return;
  4923. }
  4924. _this2.pdfDocument.getMetadata().then(function (_ref2) {
  4925. var info = _ref2.info,
  4926. metadata = _ref2.metadata,
  4927. contentDispositionFilename = _ref2.contentDispositionFilename;
  4928. 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) {
  4929. return _this2._parsePageSize((0, _ui_utils.getPageSizeInches)(pdfPage), pagesRotation);
  4930. }), _this2._parseLinearization(info.IsLinearized)]);
  4931. }).then(function (_ref3) {
  4932. var _ref4 = _slicedToArray(_ref3, 8),
  4933. info = _ref4[0],
  4934. metadata = _ref4[1],
  4935. fileName = _ref4[2],
  4936. fileSize = _ref4[3],
  4937. creationDate = _ref4[4],
  4938. modDate = _ref4[5],
  4939. pageSize = _ref4[6],
  4940. isLinearized = _ref4[7];
  4941. freezeFieldData({
  4942. 'fileName': fileName,
  4943. 'fileSize': fileSize,
  4944. 'title': info.Title,
  4945. 'author': info.Author,
  4946. 'subject': info.Subject,
  4947. 'keywords': info.Keywords,
  4948. 'creationDate': creationDate,
  4949. 'modificationDate': modDate,
  4950. 'creator': info.Creator,
  4951. 'producer': info.Producer,
  4952. 'version': info.PDFFormatVersion,
  4953. 'pageCount': _this2.pdfDocument.numPages,
  4954. 'pageSize': pageSize,
  4955. 'linearized': isLinearized,
  4956. '_currentPageNumber': currentPageNumber,
  4957. '_pagesRotation': pagesRotation
  4958. });
  4959. _this2._updateUI();
  4960. return _this2.pdfDocument.getDownloadInfo();
  4961. }).then(function (_ref5) {
  4962. var length = _ref5.length;
  4963. _this2.maybeFileSize = length;
  4964. return _this2._parseFileSize(length);
  4965. }).then(function (fileSize) {
  4966. if (fileSize === _this2.fieldData['fileSize']) {
  4967. return;
  4968. }
  4969. var data = Object.assign(Object.create(null), _this2.fieldData);
  4970. data['fileSize'] = fileSize;
  4971. freezeFieldData(data);
  4972. _this2._updateUI();
  4973. });
  4974. });
  4975. }
  4976. }, {
  4977. key: 'close',
  4978. value: function close() {
  4979. this.overlayManager.close(this.overlayName);
  4980. }
  4981. }, {
  4982. key: 'setDocument',
  4983. value: function setDocument(pdfDocument) {
  4984. var url = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  4985. if (this.pdfDocument) {
  4986. this._reset();
  4987. this._updateUI(true);
  4988. }
  4989. if (!pdfDocument) {
  4990. return;
  4991. }
  4992. this.pdfDocument = pdfDocument;
  4993. this.url = url;
  4994. this._dataAvailableCapability.resolve();
  4995. }
  4996. }, {
  4997. key: 'setFileSize',
  4998. value: function setFileSize(fileSize) {
  4999. if (Number.isInteger(fileSize) && fileSize > 0) {
  5000. this.maybeFileSize = fileSize;
  5001. }
  5002. }
  5003. }, {
  5004. key: '_reset',
  5005. value: function _reset() {
  5006. this.pdfDocument = null;
  5007. this.url = null;
  5008. this.maybeFileSize = 0;
  5009. delete this.fieldData;
  5010. this._dataAvailableCapability = (0, _pdfjsLib.createPromiseCapability)();
  5011. this._currentPageNumber = 1;
  5012. this._pagesRotation = 0;
  5013. }
  5014. }, {
  5015. key: '_updateUI',
  5016. value: function _updateUI() {
  5017. var reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5018. if (reset || !this.fieldData) {
  5019. for (var id in this.fields) {
  5020. this.fields[id].textContent = DEFAULT_FIELD_CONTENT;
  5021. }
  5022. return;
  5023. }
  5024. if (this.overlayManager.active !== this.overlayName) {
  5025. return;
  5026. }
  5027. for (var _id in this.fields) {
  5028. var content = this.fieldData[_id];
  5029. this.fields[_id].textContent = content || content === 0 ? content : DEFAULT_FIELD_CONTENT;
  5030. }
  5031. }
  5032. }, {
  5033. key: '_parseFileSize',
  5034. value: function _parseFileSize() {
  5035. var fileSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  5036. var kb = fileSize / 1024;
  5037. if (!kb) {
  5038. return Promise.resolve(undefined);
  5039. } else if (kb < 1024) {
  5040. return this.l10n.get('document_properties_kb', {
  5041. size_kb: (+kb.toPrecision(3)).toLocaleString(),
  5042. size_b: fileSize.toLocaleString()
  5043. }, '{{size_kb}} KB ({{size_b}} bytes)');
  5044. }
  5045. return this.l10n.get('document_properties_mb', {
  5046. size_mb: (+(kb / 1024).toPrecision(3)).toLocaleString(),
  5047. size_b: fileSize.toLocaleString()
  5048. }, '{{size_mb}} MB ({{size_b}} bytes)');
  5049. }
  5050. }, {
  5051. key: '_parsePageSize',
  5052. value: function _parsePageSize(pageSizeInches, pagesRotation) {
  5053. var _this3 = this;
  5054. if (!pageSizeInches) {
  5055. return Promise.resolve(undefined);
  5056. }
  5057. if (pagesRotation % 180 !== 0) {
  5058. pageSizeInches = {
  5059. width: pageSizeInches.height,
  5060. height: pageSizeInches.width
  5061. };
  5062. }
  5063. var isPortrait = (0, _ui_utils.isPortraitOrientation)(pageSizeInches);
  5064. var sizeInches = {
  5065. width: Math.round(pageSizeInches.width * 100) / 100,
  5066. height: Math.round(pageSizeInches.height * 100) / 100
  5067. };
  5068. var sizeMillimeters = {
  5069. width: Math.round(pageSizeInches.width * 25.4 * 10) / 10,
  5070. height: Math.round(pageSizeInches.height * 25.4 * 10) / 10
  5071. };
  5072. var pageName = null;
  5073. var name = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES);
  5074. if (!name && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(sizeMillimeters.height))) {
  5075. var exactMillimeters = {
  5076. width: pageSizeInches.width * 25.4,
  5077. height: pageSizeInches.height * 25.4
  5078. };
  5079. var intMillimeters = {
  5080. width: Math.round(sizeMillimeters.width),
  5081. height: Math.round(sizeMillimeters.height)
  5082. };
  5083. if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) {
  5084. name = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES);
  5085. if (name) {
  5086. sizeInches = {
  5087. width: Math.round(intMillimeters.width / 25.4 * 100) / 100,
  5088. height: Math.round(intMillimeters.height / 25.4 * 100) / 100
  5089. };
  5090. sizeMillimeters = intMillimeters;
  5091. }
  5092. }
  5093. }
  5094. if (name) {
  5095. pageName = this.l10n.get('document_properties_page_size_name_' + name.toLowerCase(), null, name);
  5096. }
  5097. 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) {
  5098. var _ref7 = _slicedToArray(_ref6, 4),
  5099. _ref7$ = _ref7[0],
  5100. width = _ref7$.width,
  5101. height = _ref7$.height,
  5102. unit = _ref7[1],
  5103. name = _ref7[2],
  5104. orientation = _ref7[3];
  5105. return _this3.l10n.get('document_properties_page_size_dimension_' + (name ? 'name_' : '') + 'string', {
  5106. width: width.toLocaleString(),
  5107. height: height.toLocaleString(),
  5108. unit: unit,
  5109. name: name,
  5110. orientation: orientation
  5111. }, '{{width}} × {{height}} {{unit}} (' + (name ? '{{name}}, ' : '') + '{{orientation}})');
  5112. });
  5113. }
  5114. }, {
  5115. key: '_parseDate',
  5116. value: function _parseDate(inputDate) {
  5117. if (!inputDate) {
  5118. return;
  5119. }
  5120. var dateToParse = inputDate;
  5121. if (dateToParse.substring(0, 2) === 'D:') {
  5122. dateToParse = dateToParse.substring(2);
  5123. }
  5124. var year = parseInt(dateToParse.substring(0, 4), 10);
  5125. var month = parseInt(dateToParse.substring(4, 6), 10) - 1;
  5126. var day = parseInt(dateToParse.substring(6, 8), 10);
  5127. var hours = parseInt(dateToParse.substring(8, 10), 10);
  5128. var minutes = parseInt(dateToParse.substring(10, 12), 10);
  5129. var seconds = parseInt(dateToParse.substring(12, 14), 10);
  5130. var utRel = dateToParse.substring(14, 15);
  5131. var offsetHours = parseInt(dateToParse.substring(15, 17), 10);
  5132. var offsetMinutes = parseInt(dateToParse.substring(18, 20), 10);
  5133. if (utRel === '-') {
  5134. hours += offsetHours;
  5135. minutes += offsetMinutes;
  5136. } else if (utRel === '+') {
  5137. hours -= offsetHours;
  5138. minutes -= offsetMinutes;
  5139. }
  5140. var date = new Date(Date.UTC(year, month, day, hours, minutes, seconds));
  5141. var dateString = date.toLocaleDateString();
  5142. var timeString = date.toLocaleTimeString();
  5143. return this.l10n.get('document_properties_date_string', {
  5144. date: dateString,
  5145. time: timeString
  5146. }, '{{date}}, {{time}}');
  5147. }
  5148. }, {
  5149. key: '_parseLinearization',
  5150. value: function _parseLinearization(isLinearized) {
  5151. return this.l10n.get('document_properties_linearized_' + (isLinearized ? 'yes' : 'no'), null, isLinearized ? 'Yes' : 'No');
  5152. }
  5153. }]);
  5154. return PDFDocumentProperties;
  5155. }();
  5156. exports.PDFDocumentProperties = PDFDocumentProperties;
  5157. /***/ }),
  5158. /* 19 */
  5159. /***/ (function(module, exports, __webpack_require__) {
  5160. "use strict";
  5161. Object.defineProperty(exports, "__esModule", {
  5162. value: true
  5163. });
  5164. exports.PDFFindBar = undefined;
  5165. 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; }; }();
  5166. var _ui_utils = __webpack_require__(6);
  5167. var _pdf_find_controller = __webpack_require__(20);
  5168. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5169. var MATCHES_COUNT_LIMIT = 1000;
  5170. var PDFFindBar = function () {
  5171. function PDFFindBar(options) {
  5172. var _this = this;
  5173. var eventBus = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (0, _ui_utils.getGlobalEventBus)();
  5174. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  5175. _classCallCheck(this, PDFFindBar);
  5176. this.opened = false;
  5177. this.bar = options.bar || null;
  5178. this.toggleButton = options.toggleButton || null;
  5179. this.findField = options.findField || null;
  5180. this.highlightAll = options.highlightAllCheckbox || null;
  5181. this.caseSensitive = options.caseSensitiveCheckbox || null;
  5182. this.entireWord = options.entireWordCheckbox || null;
  5183. this.findMsg = options.findMsg || null;
  5184. this.findResultsCount = options.findResultsCount || null;
  5185. this.findPreviousButton = options.findPreviousButton || null;
  5186. this.findNextButton = options.findNextButton || null;
  5187. this.eventBus = eventBus;
  5188. this.l10n = l10n;
  5189. this.toggleButton.addEventListener('click', function () {
  5190. _this.toggle();
  5191. });
  5192. this.findField.addEventListener('input', function () {
  5193. _this.dispatchEvent('');
  5194. });
  5195. this.bar.addEventListener('keydown', function (e) {
  5196. switch (e.keyCode) {
  5197. case 13:
  5198. if (e.target === _this.findField) {
  5199. _this.dispatchEvent('again', e.shiftKey);
  5200. }
  5201. break;
  5202. case 27:
  5203. _this.close();
  5204. break;
  5205. }
  5206. });
  5207. this.findPreviousButton.addEventListener('click', function () {
  5208. _this.dispatchEvent('again', true);
  5209. });
  5210. this.findNextButton.addEventListener('click', function () {
  5211. _this.dispatchEvent('again', false);
  5212. });
  5213. this.highlightAll.addEventListener('click', function () {
  5214. _this.dispatchEvent('highlightallchange');
  5215. });
  5216. this.caseSensitive.addEventListener('click', function () {
  5217. _this.dispatchEvent('casesensitivitychange');
  5218. });
  5219. this.entireWord.addEventListener('click', function () {
  5220. _this.dispatchEvent('entirewordchange');
  5221. });
  5222. this.eventBus.on('resize', this._adjustWidth.bind(this));
  5223. }
  5224. _createClass(PDFFindBar, [{
  5225. key: 'reset',
  5226. value: function reset() {
  5227. this.updateUIState();
  5228. }
  5229. }, {
  5230. key: 'dispatchEvent',
  5231. value: function dispatchEvent(type, findPrev) {
  5232. this.eventBus.dispatch('find', {
  5233. source: this,
  5234. type: type,
  5235. query: this.findField.value,
  5236. phraseSearch: true,
  5237. caseSensitive: this.caseSensitive.checked,
  5238. entireWord: this.entireWord.checked,
  5239. highlightAll: this.highlightAll.checked,
  5240. findPrevious: findPrev
  5241. });
  5242. }
  5243. }, {
  5244. key: 'updateUIState',
  5245. value: function updateUIState(state, previous, matchesCount) {
  5246. var _this2 = this;
  5247. var notFound = false;
  5248. var findMsg = '';
  5249. var status = '';
  5250. switch (state) {
  5251. case _pdf_find_controller.FindState.FOUND:
  5252. break;
  5253. case _pdf_find_controller.FindState.PENDING:
  5254. status = 'pending';
  5255. break;
  5256. case _pdf_find_controller.FindState.NOT_FOUND:
  5257. findMsg = this.l10n.get('find_not_found', null, 'Phrase not found');
  5258. notFound = true;
  5259. break;
  5260. case _pdf_find_controller.FindState.WRAPPED:
  5261. if (previous) {
  5262. findMsg = this.l10n.get('find_reached_top', null, 'Reached top of document, continued from bottom');
  5263. } else {
  5264. findMsg = this.l10n.get('find_reached_bottom', null, 'Reached end of document, continued from top');
  5265. }
  5266. break;
  5267. }
  5268. this.findField.classList.toggle('notFound', notFound);
  5269. this.findField.setAttribute('data-status', status);
  5270. Promise.resolve(findMsg).then(function (msg) {
  5271. _this2.findMsg.textContent = msg;
  5272. _this2._adjustWidth();
  5273. });
  5274. this.updateResultsCount(matchesCount);
  5275. }
  5276. }, {
  5277. key: 'updateResultsCount',
  5278. value: function updateResultsCount() {
  5279. var _this3 = this;
  5280. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  5281. _ref$current = _ref.current,
  5282. current = _ref$current === undefined ? 0 : _ref$current,
  5283. _ref$total = _ref.total,
  5284. total = _ref$total === undefined ? 0 : _ref$total;
  5285. if (!this.findResultsCount) {
  5286. return;
  5287. }
  5288. var matchesCountMsg = '',
  5289. limit = MATCHES_COUNT_LIMIT;
  5290. if (total > 0) {
  5291. if (total > limit) {
  5292. matchesCountMsg = this.l10n.get('find_match_count_limit', { limit: limit }, 'More than {{limit}} match' + (limit !== 1 ? 'es' : ''));
  5293. } else {
  5294. matchesCountMsg = this.l10n.get('find_match_count', {
  5295. current: current,
  5296. total: total
  5297. }, '{{current}} of {{total}} match' + (total !== 1 ? 'es' : ''));
  5298. }
  5299. }
  5300. Promise.resolve(matchesCountMsg).then(function (msg) {
  5301. _this3.findResultsCount.textContent = msg;
  5302. _this3.findResultsCount.classList[!total ? 'add' : 'remove']('hidden');
  5303. _this3._adjustWidth();
  5304. });
  5305. }
  5306. }, {
  5307. key: 'open',
  5308. value: function open() {
  5309. if (!this.opened) {
  5310. this.opened = true;
  5311. this.toggleButton.classList.add('toggled');
  5312. this.bar.classList.remove('hidden');
  5313. }
  5314. this.findField.select();
  5315. this.findField.focus();
  5316. this._adjustWidth();
  5317. }
  5318. }, {
  5319. key: 'close',
  5320. value: function close() {
  5321. if (!this.opened) {
  5322. return;
  5323. }
  5324. this.opened = false;
  5325. this.toggleButton.classList.remove('toggled');
  5326. this.bar.classList.add('hidden');
  5327. this.eventBus.dispatch('findbarclose', { source: this });
  5328. }
  5329. }, {
  5330. key: 'toggle',
  5331. value: function toggle() {
  5332. if (this.opened) {
  5333. this.close();
  5334. } else {
  5335. this.open();
  5336. }
  5337. }
  5338. }, {
  5339. key: '_adjustWidth',
  5340. value: function _adjustWidth() {
  5341. if (!this.opened) {
  5342. return;
  5343. }
  5344. this.bar.classList.remove('wrapContainers');
  5345. var findbarHeight = this.bar.clientHeight;
  5346. var inputContainerHeight = this.bar.firstElementChild.clientHeight;
  5347. if (findbarHeight > inputContainerHeight) {
  5348. this.bar.classList.add('wrapContainers');
  5349. }
  5350. }
  5351. }]);
  5352. return PDFFindBar;
  5353. }();
  5354. exports.PDFFindBar = PDFFindBar;
  5355. /***/ }),
  5356. /* 20 */
  5357. /***/ (function(module, exports, __webpack_require__) {
  5358. "use strict";
  5359. Object.defineProperty(exports, "__esModule", {
  5360. value: true
  5361. });
  5362. exports.PDFFindController = exports.FindState = undefined;
  5363. 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; }; }();
  5364. var _pdfjsLib = __webpack_require__(7);
  5365. var _pdf_find_utils = __webpack_require__(21);
  5366. var _dom_events = __webpack_require__(14);
  5367. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5368. var FindState = {
  5369. FOUND: 0,
  5370. NOT_FOUND: 1,
  5371. WRAPPED: 2,
  5372. PENDING: 3
  5373. };
  5374. var FIND_TIMEOUT = 250;
  5375. var CHARACTERS_TO_NORMALIZE = {
  5376. '\u2018': '\'',
  5377. '\u2019': '\'',
  5378. '\u201A': '\'',
  5379. '\u201B': '\'',
  5380. '\u201C': '"',
  5381. '\u201D': '"',
  5382. '\u201E': '"',
  5383. '\u201F': '"',
  5384. '\xBC': '1/4',
  5385. '\xBD': '1/2',
  5386. '\xBE': '3/4'
  5387. };
  5388. var PDFFindController = function () {
  5389. function PDFFindController(_ref) {
  5390. var linkService = _ref.linkService,
  5391. _ref$eventBus = _ref.eventBus,
  5392. eventBus = _ref$eventBus === undefined ? (0, _dom_events.getGlobalEventBus)() : _ref$eventBus;
  5393. _classCallCheck(this, PDFFindController);
  5394. this._linkService = linkService;
  5395. this._eventBus = eventBus;
  5396. this._reset();
  5397. eventBus.on('findbarclose', this._onFindBarClose.bind(this));
  5398. var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join('');
  5399. this._normalizationRegex = new RegExp('[' + replace + ']', 'g');
  5400. }
  5401. _createClass(PDFFindController, [{
  5402. key: 'setDocument',
  5403. value: function setDocument(pdfDocument) {
  5404. if (this._pdfDocument) {
  5405. this._reset();
  5406. }
  5407. if (!pdfDocument) {
  5408. return;
  5409. }
  5410. this._pdfDocument = pdfDocument;
  5411. this._firstPageCapability.resolve();
  5412. }
  5413. }, {
  5414. key: 'executeCommand',
  5415. value: function executeCommand(cmd, state) {
  5416. var _this = this;
  5417. var pdfDocument = this._pdfDocument;
  5418. if (this._state === null || cmd !== 'findagain') {
  5419. this._dirtyMatch = true;
  5420. }
  5421. this._state = state;
  5422. this._updateUIState(FindState.PENDING);
  5423. this._firstPageCapability.promise.then(function () {
  5424. if (!_this._pdfDocument || pdfDocument && _this._pdfDocument !== pdfDocument) {
  5425. return;
  5426. }
  5427. _this._extractText();
  5428. if (_this._findTimeout) {
  5429. clearTimeout(_this._findTimeout);
  5430. _this._findTimeout = null;
  5431. }
  5432. if (cmd === 'find') {
  5433. _this._findTimeout = setTimeout(function () {
  5434. _this._nextMatch();
  5435. _this._findTimeout = null;
  5436. }, FIND_TIMEOUT);
  5437. } else {
  5438. _this._nextMatch();
  5439. }
  5440. });
  5441. }
  5442. }, {
  5443. key: '_reset',
  5444. value: function _reset() {
  5445. this._highlightMatches = false;
  5446. this._pdfDocument = null;
  5447. this._pageMatches = [];
  5448. this._pageMatchesLength = null;
  5449. this._state = null;
  5450. this._selected = {
  5451. pageIdx: -1,
  5452. matchIdx: -1
  5453. };
  5454. this._offset = {
  5455. pageIdx: null,
  5456. matchIdx: null
  5457. };
  5458. this._extractTextPromises = [];
  5459. this._pageContents = [];
  5460. this._matchesCountTotal = 0;
  5461. this._pagesToSearch = null;
  5462. this._pendingFindMatches = Object.create(null);
  5463. this._resumePageIdx = null;
  5464. this._dirtyMatch = false;
  5465. clearTimeout(this._findTimeout);
  5466. this._findTimeout = null;
  5467. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  5468. }
  5469. }, {
  5470. key: '_normalize',
  5471. value: function _normalize(text) {
  5472. return text.replace(this._normalizationRegex, function (ch) {
  5473. return CHARACTERS_TO_NORMALIZE[ch];
  5474. });
  5475. }
  5476. }, {
  5477. key: '_prepareMatches',
  5478. value: function _prepareMatches(matchesWithLength, matches, matchesLength) {
  5479. function isSubTerm(matchesWithLength, currentIndex) {
  5480. var currentElem = matchesWithLength[currentIndex];
  5481. var nextElem = matchesWithLength[currentIndex + 1];
  5482. if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {
  5483. currentElem.skipped = true;
  5484. return true;
  5485. }
  5486. for (var i = currentIndex - 1; i >= 0; i--) {
  5487. var prevElem = matchesWithLength[i];
  5488. if (prevElem.skipped) {
  5489. continue;
  5490. }
  5491. if (prevElem.match + prevElem.matchLength < currentElem.match) {
  5492. break;
  5493. }
  5494. if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {
  5495. currentElem.skipped = true;
  5496. return true;
  5497. }
  5498. }
  5499. return false;
  5500. }
  5501. matchesWithLength.sort(function (a, b) {
  5502. return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match;
  5503. });
  5504. for (var i = 0, len = matchesWithLength.length; i < len; i++) {
  5505. if (isSubTerm(matchesWithLength, i)) {
  5506. continue;
  5507. }
  5508. matches.push(matchesWithLength[i].match);
  5509. matchesLength.push(matchesWithLength[i].matchLength);
  5510. }
  5511. }
  5512. }, {
  5513. key: '_isEntireWord',
  5514. value: function _isEntireWord(content, startIdx, length) {
  5515. if (startIdx > 0) {
  5516. var first = content.charCodeAt(startIdx);
  5517. var limit = content.charCodeAt(startIdx - 1);
  5518. if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils.getCharacterType)(limit)) {
  5519. return false;
  5520. }
  5521. }
  5522. var endIdx = startIdx + length - 1;
  5523. if (endIdx < content.length - 1) {
  5524. var last = content.charCodeAt(endIdx);
  5525. var _limit = content.charCodeAt(endIdx + 1);
  5526. if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils.getCharacterType)(_limit)) {
  5527. return false;
  5528. }
  5529. }
  5530. return true;
  5531. }
  5532. }, {
  5533. key: '_calculatePhraseMatch',
  5534. value: function _calculatePhraseMatch(query, pageIndex, pageContent, entireWord) {
  5535. var matches = [];
  5536. var queryLen = query.length;
  5537. var matchIdx = -queryLen;
  5538. while (true) {
  5539. matchIdx = pageContent.indexOf(query, matchIdx + queryLen);
  5540. if (matchIdx === -1) {
  5541. break;
  5542. }
  5543. if (entireWord && !this._isEntireWord(pageContent, matchIdx, queryLen)) {
  5544. continue;
  5545. }
  5546. matches.push(matchIdx);
  5547. }
  5548. this._pageMatches[pageIndex] = matches;
  5549. }
  5550. }, {
  5551. key: '_calculateWordMatch',
  5552. value: function _calculateWordMatch(query, pageIndex, pageContent, entireWord) {
  5553. var matchesWithLength = [];
  5554. var queryArray = query.match(/\S+/g);
  5555. for (var i = 0, len = queryArray.length; i < len; i++) {
  5556. var subquery = queryArray[i];
  5557. var subqueryLen = subquery.length;
  5558. var matchIdx = -subqueryLen;
  5559. while (true) {
  5560. matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen);
  5561. if (matchIdx === -1) {
  5562. break;
  5563. }
  5564. if (entireWord && !this._isEntireWord(pageContent, matchIdx, subqueryLen)) {
  5565. continue;
  5566. }
  5567. matchesWithLength.push({
  5568. match: matchIdx,
  5569. matchLength: subqueryLen,
  5570. skipped: false
  5571. });
  5572. }
  5573. }
  5574. if (!this._pageMatchesLength) {
  5575. this._pageMatchesLength = [];
  5576. }
  5577. this._pageMatchesLength[pageIndex] = [];
  5578. this._pageMatches[pageIndex] = [];
  5579. this._prepareMatches(matchesWithLength, this._pageMatches[pageIndex], this._pageMatchesLength[pageIndex]);
  5580. }
  5581. }, {
  5582. key: '_calculateMatch',
  5583. value: function _calculateMatch(pageIndex) {
  5584. var pageContent = this._normalize(this._pageContents[pageIndex]);
  5585. var query = this._normalize(this._state.query);
  5586. var _state = this._state,
  5587. caseSensitive = _state.caseSensitive,
  5588. entireWord = _state.entireWord,
  5589. phraseSearch = _state.phraseSearch;
  5590. if (query.length === 0) {
  5591. return;
  5592. }
  5593. if (!caseSensitive) {
  5594. pageContent = pageContent.toLowerCase();
  5595. query = query.toLowerCase();
  5596. }
  5597. if (phraseSearch) {
  5598. this._calculatePhraseMatch(query, pageIndex, pageContent, entireWord);
  5599. } else {
  5600. this._calculateWordMatch(query, pageIndex, pageContent, entireWord);
  5601. }
  5602. this._updatePage(pageIndex);
  5603. if (this._resumePageIdx === pageIndex) {
  5604. this._resumePageIdx = null;
  5605. this._nextPageMatch();
  5606. }
  5607. var pageMatchesCount = this._pageMatches[pageIndex].length;
  5608. if (pageMatchesCount > 0) {
  5609. this._matchesCountTotal += pageMatchesCount;
  5610. this._updateUIResultsCount();
  5611. }
  5612. }
  5613. }, {
  5614. key: '_extractText',
  5615. value: function _extractText() {
  5616. var _this2 = this;
  5617. if (this._extractTextPromises.length > 0) {
  5618. return;
  5619. }
  5620. var promise = Promise.resolve();
  5621. var _loop = function _loop(i, ii) {
  5622. var extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
  5623. _this2._extractTextPromises[i] = extractTextCapability.promise;
  5624. promise = promise.then(function () {
  5625. return _this2._pdfDocument.getPage(i + 1).then(function (pdfPage) {
  5626. return pdfPage.getTextContent({ normalizeWhitespace: true });
  5627. }).then(function (textContent) {
  5628. var textItems = textContent.items;
  5629. var strBuf = [];
  5630. for (var j = 0, jj = textItems.length; j < jj; j++) {
  5631. strBuf.push(textItems[j].str);
  5632. }
  5633. _this2._pageContents[i] = strBuf.join('');
  5634. extractTextCapability.resolve(i);
  5635. }, function (reason) {
  5636. console.error('Unable to get text content for page ' + (i + 1), reason);
  5637. _this2._pageContents[i] = '';
  5638. extractTextCapability.resolve(i);
  5639. });
  5640. });
  5641. };
  5642. for (var i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
  5643. _loop(i, ii);
  5644. }
  5645. }
  5646. }, {
  5647. key: '_updatePage',
  5648. value: function _updatePage(index) {
  5649. if (this._selected.pageIdx === index) {
  5650. this._linkService.page = index + 1;
  5651. }
  5652. this._eventBus.dispatch('updatetextlayermatches', {
  5653. source: this,
  5654. pageIndex: index
  5655. });
  5656. }
  5657. }, {
  5658. key: '_nextMatch',
  5659. value: function _nextMatch() {
  5660. var _this3 = this;
  5661. var previous = this._state.findPrevious;
  5662. var currentPageIndex = this._linkService.page - 1;
  5663. var numPages = this._linkService.pagesCount;
  5664. this._highlightMatches = true;
  5665. if (this._dirtyMatch) {
  5666. this._dirtyMatch = false;
  5667. this._selected.pageIdx = this._selected.matchIdx = -1;
  5668. this._offset.pageIdx = currentPageIndex;
  5669. this._offset.matchIdx = null;
  5670. this._resumePageIdx = null;
  5671. this._pageMatches.length = 0;
  5672. this._pageMatchesLength = null;
  5673. this._matchesCountTotal = 0;
  5674. for (var i = 0; i < numPages; i++) {
  5675. this._updatePage(i);
  5676. if (!(i in this._pendingFindMatches)) {
  5677. this._pendingFindMatches[i] = true;
  5678. this._extractTextPromises[i].then(function (pageIdx) {
  5679. delete _this3._pendingFindMatches[pageIdx];
  5680. _this3._calculateMatch(pageIdx);
  5681. });
  5682. }
  5683. }
  5684. }
  5685. if (this._state.query === '') {
  5686. this._updateUIState(FindState.FOUND);
  5687. return;
  5688. }
  5689. if (this._resumePageIdx) {
  5690. return;
  5691. }
  5692. var offset = this._offset;
  5693. this._pagesToSearch = numPages;
  5694. if (offset.matchIdx !== null) {
  5695. var numPageMatches = this._pageMatches[offset.pageIdx].length;
  5696. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  5697. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  5698. this._updateMatch(true);
  5699. return;
  5700. }
  5701. this._advanceOffsetPage(previous);
  5702. }
  5703. this._nextPageMatch();
  5704. }
  5705. }, {
  5706. key: '_matchesReady',
  5707. value: function _matchesReady(matches) {
  5708. var offset = this._offset;
  5709. var numMatches = matches.length;
  5710. var previous = this._state.findPrevious;
  5711. if (numMatches) {
  5712. offset.matchIdx = previous ? numMatches - 1 : 0;
  5713. this._updateMatch(true);
  5714. return true;
  5715. }
  5716. this._advanceOffsetPage(previous);
  5717. if (offset.wrapped) {
  5718. offset.matchIdx = null;
  5719. if (this._pagesToSearch < 0) {
  5720. this._updateMatch(false);
  5721. return true;
  5722. }
  5723. }
  5724. return false;
  5725. }
  5726. }, {
  5727. key: '_nextPageMatch',
  5728. value: function _nextPageMatch() {
  5729. if (this._resumePageIdx !== null) {
  5730. console.error('There can only be one pending page.');
  5731. }
  5732. var matches = null;
  5733. do {
  5734. var pageIdx = this._offset.pageIdx;
  5735. matches = this._pageMatches[pageIdx];
  5736. if (!matches) {
  5737. this._resumePageIdx = pageIdx;
  5738. break;
  5739. }
  5740. } while (!this._matchesReady(matches));
  5741. }
  5742. }, {
  5743. key: '_advanceOffsetPage',
  5744. value: function _advanceOffsetPage(previous) {
  5745. var offset = this._offset;
  5746. var numPages = this._linkService.pagesCount;
  5747. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  5748. offset.matchIdx = null;
  5749. this._pagesToSearch--;
  5750. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  5751. offset.pageIdx = previous ? numPages - 1 : 0;
  5752. offset.wrapped = true;
  5753. }
  5754. }
  5755. }, {
  5756. key: '_updateMatch',
  5757. value: function _updateMatch() {
  5758. var found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5759. var state = FindState.NOT_FOUND;
  5760. var wrapped = this._offset.wrapped;
  5761. this._offset.wrapped = false;
  5762. if (found) {
  5763. var previousPage = this._selected.pageIdx;
  5764. this._selected.pageIdx = this._offset.pageIdx;
  5765. this._selected.matchIdx = this._offset.matchIdx;
  5766. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  5767. if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {
  5768. this._updatePage(previousPage);
  5769. }
  5770. }
  5771. this._updateUIState(state, this._state.findPrevious);
  5772. if (this._selected.pageIdx !== -1) {
  5773. this._updatePage(this._selected.pageIdx);
  5774. }
  5775. }
  5776. }, {
  5777. key: '_onFindBarClose',
  5778. value: function _onFindBarClose(evt) {
  5779. var _this4 = this;
  5780. var pdfDocument = this._pdfDocument;
  5781. this._firstPageCapability.promise.then(function () {
  5782. if (!_this4._pdfDocument || pdfDocument && _this4._pdfDocument !== pdfDocument) {
  5783. return;
  5784. }
  5785. if (_this4._findTimeout) {
  5786. clearTimeout(_this4._findTimeout);
  5787. _this4._findTimeout = null;
  5788. _this4._updateUIState(FindState.FOUND);
  5789. }
  5790. _this4._highlightMatches = false;
  5791. _this4._eventBus.dispatch('updatetextlayermatches', {
  5792. source: _this4,
  5793. pageIndex: -1
  5794. });
  5795. });
  5796. }
  5797. }, {
  5798. key: '_requestMatchesCount',
  5799. value: function _requestMatchesCount() {
  5800. var _selected = this._selected,
  5801. pageIdx = _selected.pageIdx,
  5802. matchIdx = _selected.matchIdx;
  5803. var current = 0,
  5804. total = this._matchesCountTotal;
  5805. if (matchIdx !== -1) {
  5806. for (var i = 0; i < pageIdx; i++) {
  5807. current += this._pageMatches[i] && this._pageMatches[i].length || 0;
  5808. }
  5809. current += matchIdx + 1;
  5810. }
  5811. if (current < 1 || current > total) {
  5812. current = total = 0;
  5813. }
  5814. return {
  5815. current: current,
  5816. total: total
  5817. };
  5818. }
  5819. }, {
  5820. key: '_updateUIResultsCount',
  5821. value: function _updateUIResultsCount() {
  5822. this._eventBus.dispatch('updatefindmatchescount', {
  5823. source: this,
  5824. matchesCount: this._requestMatchesCount()
  5825. });
  5826. }
  5827. }, {
  5828. key: '_updateUIState',
  5829. value: function _updateUIState(state, previous) {
  5830. this._eventBus.dispatch('updatefindcontrolstate', {
  5831. source: this,
  5832. state: state,
  5833. previous: previous,
  5834. matchesCount: this._requestMatchesCount()
  5835. });
  5836. }
  5837. }, {
  5838. key: 'highlightMatches',
  5839. get: function get() {
  5840. return this._highlightMatches;
  5841. }
  5842. }, {
  5843. key: 'pageMatches',
  5844. get: function get() {
  5845. return this._pageMatches;
  5846. }
  5847. }, {
  5848. key: 'pageMatchesLength',
  5849. get: function get() {
  5850. return this._pageMatchesLength;
  5851. }
  5852. }, {
  5853. key: 'selected',
  5854. get: function get() {
  5855. return this._selected;
  5856. }
  5857. }, {
  5858. key: 'state',
  5859. get: function get() {
  5860. return this._state;
  5861. }
  5862. }]);
  5863. return PDFFindController;
  5864. }();
  5865. exports.FindState = FindState;
  5866. exports.PDFFindController = PDFFindController;
  5867. /***/ }),
  5868. /* 21 */
  5869. /***/ (function(module, exports, __webpack_require__) {
  5870. "use strict";
  5871. Object.defineProperty(exports, "__esModule", {
  5872. value: true
  5873. });
  5874. var CharacterType = {
  5875. SPACE: 0,
  5876. ALPHA_LETTER: 1,
  5877. PUNCT: 2,
  5878. HAN_LETTER: 3,
  5879. KATAKANA_LETTER: 4,
  5880. HIRAGANA_LETTER: 5,
  5881. HALFWIDTH_KATAKANA_LETTER: 6,
  5882. THAI_LETTER: 7
  5883. };
  5884. function isAlphabeticalScript(charCode) {
  5885. return charCode < 0x2E80;
  5886. }
  5887. function isAscii(charCode) {
  5888. return (charCode & 0xFF80) === 0;
  5889. }
  5890. function isAsciiAlpha(charCode) {
  5891. return charCode >= 0x61 && charCode <= 0x7A || charCode >= 0x41 && charCode <= 0x5A;
  5892. }
  5893. function isAsciiDigit(charCode) {
  5894. return charCode >= 0x30 && charCode <= 0x39;
  5895. }
  5896. function isAsciiSpace(charCode) {
  5897. return charCode === 0x20 || charCode === 0x09 || charCode === 0x0D || charCode === 0x0A;
  5898. }
  5899. function isHan(charCode) {
  5900. return charCode >= 0x3400 && charCode <= 0x9FFF || charCode >= 0xF900 && charCode <= 0xFAFF;
  5901. }
  5902. function isKatakana(charCode) {
  5903. return charCode >= 0x30A0 && charCode <= 0x30FF;
  5904. }
  5905. function isHiragana(charCode) {
  5906. return charCode >= 0x3040 && charCode <= 0x309F;
  5907. }
  5908. function isHalfwidthKatakana(charCode) {
  5909. return charCode >= 0xFF60 && charCode <= 0xFF9F;
  5910. }
  5911. function isThai(charCode) {
  5912. return (charCode & 0xFF80) === 0x0E00;
  5913. }
  5914. function getCharacterType(charCode) {
  5915. if (isAlphabeticalScript(charCode)) {
  5916. if (isAscii(charCode)) {
  5917. if (isAsciiSpace(charCode)) {
  5918. return CharacterType.SPACE;
  5919. } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5F) {
  5920. return CharacterType.ALPHA_LETTER;
  5921. }
  5922. return CharacterType.PUNCT;
  5923. } else if (isThai(charCode)) {
  5924. return CharacterType.THAI_LETTER;
  5925. } else if (charCode === 0xA0) {
  5926. return CharacterType.SPACE;
  5927. }
  5928. return CharacterType.ALPHA_LETTER;
  5929. }
  5930. if (isHan(charCode)) {
  5931. return CharacterType.HAN_LETTER;
  5932. } else if (isKatakana(charCode)) {
  5933. return CharacterType.KATAKANA_LETTER;
  5934. } else if (isHiragana(charCode)) {
  5935. return CharacterType.HIRAGANA_LETTER;
  5936. } else if (isHalfwidthKatakana(charCode)) {
  5937. return CharacterType.HALFWIDTH_KATAKANA_LETTER;
  5938. }
  5939. return CharacterType.ALPHA_LETTER;
  5940. }
  5941. exports.CharacterType = CharacterType;
  5942. exports.getCharacterType = getCharacterType;
  5943. /***/ }),
  5944. /* 22 */
  5945. /***/ (function(module, exports, __webpack_require__) {
  5946. "use strict";
  5947. Object.defineProperty(exports, "__esModule", {
  5948. value: true
  5949. });
  5950. exports.isDestArraysEqual = exports.isDestHashesEqual = exports.PDFHistory = undefined;
  5951. 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; };
  5952. 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; }; }();
  5953. var _ui_utils = __webpack_require__(6);
  5954. var _dom_events = __webpack_require__(14);
  5955. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5956. var HASH_CHANGE_TIMEOUT = 1000;
  5957. var POSITION_UPDATED_THRESHOLD = 50;
  5958. var UPDATE_VIEWAREA_TIMEOUT = 1000;
  5959. function getCurrentHash() {
  5960. return document.location.hash;
  5961. }
  5962. function parseCurrentHash(linkService) {
  5963. var hash = unescape(getCurrentHash()).substring(1);
  5964. var params = (0, _ui_utils.parseQueryString)(hash);
  5965. var page = params.page | 0;
  5966. if (!(Number.isInteger(page) && page > 0 && page <= linkService.pagesCount)) {
  5967. page = null;
  5968. }
  5969. return {
  5970. hash: hash,
  5971. page: page,
  5972. rotation: linkService.rotation
  5973. };
  5974. }
  5975. var PDFHistory = function () {
  5976. function PDFHistory(_ref) {
  5977. var _this = this;
  5978. var linkService = _ref.linkService,
  5979. eventBus = _ref.eventBus;
  5980. _classCallCheck(this, PDFHistory);
  5981. this.linkService = linkService;
  5982. this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)();
  5983. this.initialized = false;
  5984. this.initialBookmark = null;
  5985. this.initialRotation = null;
  5986. this._boundEvents = Object.create(null);
  5987. this._isViewerInPresentationMode = false;
  5988. this._isPagesLoaded = false;
  5989. this.eventBus.on('presentationmodechanged', function (evt) {
  5990. _this._isViewerInPresentationMode = evt.active || evt.switchInProgress;
  5991. });
  5992. this.eventBus.on('pagesloaded', function (evt) {
  5993. _this._isPagesLoaded = !!evt.pagesCount;
  5994. });
  5995. }
  5996. _createClass(PDFHistory, [{
  5997. key: 'initialize',
  5998. value: function initialize(fingerprint) {
  5999. var resetHistory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6000. if (!fingerprint || typeof fingerprint !== 'string') {
  6001. console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
  6002. return;
  6003. }
  6004. var reInitialized = this.initialized && this.fingerprint !== fingerprint;
  6005. this.fingerprint = fingerprint;
  6006. if (!this.initialized) {
  6007. this._bindEvents();
  6008. }
  6009. var state = window.history.state;
  6010. this.initialized = true;
  6011. this.initialBookmark = null;
  6012. this.initialRotation = null;
  6013. this._popStateInProgress = false;
  6014. this._blockHashChange = 0;
  6015. this._currentHash = getCurrentHash();
  6016. this._numPositionUpdates = 0;
  6017. this._uid = this._maxUid = 0;
  6018. this._destination = null;
  6019. this._position = null;
  6020. if (!this._isValidState(state) || resetHistory) {
  6021. var _parseCurrentHash = parseCurrentHash(this.linkService),
  6022. hash = _parseCurrentHash.hash,
  6023. page = _parseCurrentHash.page,
  6024. rotation = _parseCurrentHash.rotation;
  6025. if (!hash || reInitialized || resetHistory) {
  6026. this._pushOrReplaceState(null, true);
  6027. return;
  6028. }
  6029. this._pushOrReplaceState({
  6030. hash: hash,
  6031. page: page,
  6032. rotation: rotation
  6033. }, true);
  6034. return;
  6035. }
  6036. var destination = state.destination;
  6037. this._updateInternalState(destination, state.uid, true);
  6038. if (this._uid > this._maxUid) {
  6039. this._maxUid = this._uid;
  6040. }
  6041. if (destination.rotation !== undefined) {
  6042. this.initialRotation = destination.rotation;
  6043. }
  6044. if (destination.dest) {
  6045. this.initialBookmark = JSON.stringify(destination.dest);
  6046. this._destination.page = null;
  6047. } else if (destination.hash) {
  6048. this.initialBookmark = destination.hash;
  6049. } else if (destination.page) {
  6050. this.initialBookmark = 'page=' + destination.page;
  6051. }
  6052. }
  6053. }, {
  6054. key: 'push',
  6055. value: function push(_ref2) {
  6056. var _this2 = this;
  6057. var namedDest = _ref2.namedDest,
  6058. explicitDest = _ref2.explicitDest,
  6059. pageNumber = _ref2.pageNumber;
  6060. if (!this.initialized) {
  6061. return;
  6062. }
  6063. if (namedDest && typeof namedDest !== 'string' || !Array.isArray(explicitDest) || !(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {
  6064. console.error('PDFHistory.push: Invalid parameters.');
  6065. return;
  6066. }
  6067. var hash = namedDest || JSON.stringify(explicitDest);
  6068. if (!hash) {
  6069. return;
  6070. }
  6071. var forceReplace = false;
  6072. if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
  6073. if (this._destination.page) {
  6074. return;
  6075. }
  6076. forceReplace = true;
  6077. }
  6078. if (this._popStateInProgress && !forceReplace) {
  6079. return;
  6080. }
  6081. this._pushOrReplaceState({
  6082. dest: explicitDest,
  6083. hash: hash,
  6084. page: pageNumber,
  6085. rotation: this.linkService.rotation
  6086. }, forceReplace);
  6087. if (!this._popStateInProgress) {
  6088. this._popStateInProgress = true;
  6089. Promise.resolve().then(function () {
  6090. _this2._popStateInProgress = false;
  6091. });
  6092. }
  6093. }
  6094. }, {
  6095. key: 'pushCurrentPosition',
  6096. value: function pushCurrentPosition() {
  6097. if (!this.initialized || this._popStateInProgress) {
  6098. return;
  6099. }
  6100. this._tryPushCurrentPosition();
  6101. }
  6102. }, {
  6103. key: 'back',
  6104. value: function back() {
  6105. if (!this.initialized || this._popStateInProgress) {
  6106. return;
  6107. }
  6108. var state = window.history.state;
  6109. if (this._isValidState(state) && state.uid > 0) {
  6110. window.history.back();
  6111. }
  6112. }
  6113. }, {
  6114. key: 'forward',
  6115. value: function forward() {
  6116. if (!this.initialized || this._popStateInProgress) {
  6117. return;
  6118. }
  6119. var state = window.history.state;
  6120. if (this._isValidState(state) && state.uid < this._maxUid) {
  6121. window.history.forward();
  6122. }
  6123. }
  6124. }, {
  6125. key: '_pushOrReplaceState',
  6126. value: function _pushOrReplaceState(destination) {
  6127. var forceReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6128. var shouldReplace = forceReplace || !this._destination;
  6129. var newState = {
  6130. fingerprint: this.fingerprint,
  6131. uid: shouldReplace ? this._uid : this._uid + 1,
  6132. destination: destination
  6133. };
  6134. this._updateInternalState(destination, newState.uid);
  6135. if (shouldReplace) {
  6136. window.history.replaceState(newState, '');
  6137. } else {
  6138. this._maxUid = this._uid;
  6139. window.history.pushState(newState, '');
  6140. }
  6141. }
  6142. }, {
  6143. key: '_tryPushCurrentPosition',
  6144. value: function _tryPushCurrentPosition() {
  6145. var temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6146. if (!this._position) {
  6147. return;
  6148. }
  6149. var position = this._position;
  6150. if (temporary) {
  6151. position = Object.assign(Object.create(null), this._position);
  6152. position.temporary = true;
  6153. }
  6154. if (!this._destination) {
  6155. this._pushOrReplaceState(position);
  6156. return;
  6157. }
  6158. if (this._destination.temporary) {
  6159. this._pushOrReplaceState(position, true);
  6160. return;
  6161. }
  6162. if (this._destination.hash === position.hash) {
  6163. return;
  6164. }
  6165. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  6166. return;
  6167. }
  6168. var forceReplace = false;
  6169. if (this._destination.page === position.first || this._destination.page === position.page) {
  6170. if (this._destination.dest || !this._destination.first) {
  6171. return;
  6172. }
  6173. forceReplace = true;
  6174. }
  6175. this._pushOrReplaceState(position, forceReplace);
  6176. }
  6177. }, {
  6178. key: '_isValidState',
  6179. value: function _isValidState(state) {
  6180. if (!state) {
  6181. return false;
  6182. }
  6183. if (state.fingerprint !== this.fingerprint) {
  6184. return false;
  6185. }
  6186. if (!Number.isInteger(state.uid) || state.uid < 0) {
  6187. return false;
  6188. }
  6189. if (state.destination === null || _typeof(state.destination) !== 'object') {
  6190. return false;
  6191. }
  6192. return true;
  6193. }
  6194. }, {
  6195. key: '_updateInternalState',
  6196. value: function _updateInternalState(destination, uid) {
  6197. var removeTemporary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  6198. if (this._updateViewareaTimeout) {
  6199. clearTimeout(this._updateViewareaTimeout);
  6200. this._updateViewareaTimeout = null;
  6201. }
  6202. if (removeTemporary && destination && destination.temporary) {
  6203. delete destination.temporary;
  6204. }
  6205. this._destination = destination;
  6206. this._uid = uid;
  6207. this._numPositionUpdates = 0;
  6208. }
  6209. }, {
  6210. key: '_updateViewarea',
  6211. value: function _updateViewarea(_ref3) {
  6212. var _this3 = this;
  6213. var location = _ref3.location;
  6214. if (this._updateViewareaTimeout) {
  6215. clearTimeout(this._updateViewareaTimeout);
  6216. this._updateViewareaTimeout = null;
  6217. }
  6218. this._position = {
  6219. hash: this._isViewerInPresentationMode ? 'page=' + location.pageNumber : location.pdfOpenParams.substring(1),
  6220. page: this.linkService.page,
  6221. first: location.pageNumber,
  6222. rotation: location.rotation
  6223. };
  6224. if (this._popStateInProgress) {
  6225. return;
  6226. }
  6227. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
  6228. this._numPositionUpdates++;
  6229. }
  6230. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  6231. this._updateViewareaTimeout = setTimeout(function () {
  6232. if (!_this3._popStateInProgress) {
  6233. _this3._tryPushCurrentPosition(true);
  6234. }
  6235. _this3._updateViewareaTimeout = null;
  6236. }, UPDATE_VIEWAREA_TIMEOUT);
  6237. }
  6238. }
  6239. }, {
  6240. key: '_popState',
  6241. value: function _popState(_ref4) {
  6242. var _this4 = this;
  6243. var state = _ref4.state;
  6244. var newHash = getCurrentHash(),
  6245. hashChanged = this._currentHash !== newHash;
  6246. this._currentHash = newHash;
  6247. if (!state || false) {
  6248. this._uid++;
  6249. var _parseCurrentHash2 = parseCurrentHash(this.linkService),
  6250. hash = _parseCurrentHash2.hash,
  6251. page = _parseCurrentHash2.page,
  6252. rotation = _parseCurrentHash2.rotation;
  6253. this._pushOrReplaceState({
  6254. hash: hash,
  6255. page: page,
  6256. rotation: rotation
  6257. }, true);
  6258. return;
  6259. }
  6260. if (!this._isValidState(state)) {
  6261. return;
  6262. }
  6263. this._popStateInProgress = true;
  6264. if (hashChanged) {
  6265. this._blockHashChange++;
  6266. (0, _ui_utils.waitOnEventOrTimeout)({
  6267. target: window,
  6268. name: 'hashchange',
  6269. delay: HASH_CHANGE_TIMEOUT
  6270. }).then(function () {
  6271. _this4._blockHashChange--;
  6272. });
  6273. }
  6274. var destination = state.destination;
  6275. this._updateInternalState(destination, state.uid, true);
  6276. if (this._uid > this._maxUid) {
  6277. this._maxUid = this._uid;
  6278. }
  6279. if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
  6280. this.linkService.rotation = destination.rotation;
  6281. }
  6282. if (destination.dest) {
  6283. this.linkService.navigateTo(destination.dest);
  6284. } else if (destination.hash) {
  6285. this.linkService.setHash(destination.hash);
  6286. } else if (destination.page) {
  6287. this.linkService.page = destination.page;
  6288. }
  6289. Promise.resolve().then(function () {
  6290. _this4._popStateInProgress = false;
  6291. });
  6292. }
  6293. }, {
  6294. key: '_bindEvents',
  6295. value: function _bindEvents() {
  6296. var _this5 = this;
  6297. var _boundEvents = this._boundEvents,
  6298. eventBus = this.eventBus;
  6299. _boundEvents.updateViewarea = this._updateViewarea.bind(this);
  6300. _boundEvents.popState = this._popState.bind(this);
  6301. _boundEvents.pageHide = function (evt) {
  6302. if (!_this5._destination || _this5._destination.temporary) {
  6303. _this5._tryPushCurrentPosition();
  6304. }
  6305. };
  6306. eventBus.on('updateviewarea', _boundEvents.updateViewarea);
  6307. window.addEventListener('popstate', _boundEvents.popState);
  6308. window.addEventListener('pagehide', _boundEvents.pageHide);
  6309. }
  6310. }, {
  6311. key: 'popStateInProgress',
  6312. get: function get() {
  6313. return this.initialized && (this._popStateInProgress || this._blockHashChange > 0);
  6314. }
  6315. }]);
  6316. return PDFHistory;
  6317. }();
  6318. function isDestHashesEqual(destHash, pushHash) {
  6319. if (typeof destHash !== 'string' || typeof pushHash !== 'string') {
  6320. return false;
  6321. }
  6322. if (destHash === pushHash) {
  6323. return true;
  6324. }
  6325. var _parseQueryString = (0, _ui_utils.parseQueryString)(destHash),
  6326. nameddest = _parseQueryString.nameddest;
  6327. if (nameddest === pushHash) {
  6328. return true;
  6329. }
  6330. return false;
  6331. }
  6332. function isDestArraysEqual(firstDest, secondDest) {
  6333. function isEntryEqual(first, second) {
  6334. if ((typeof first === 'undefined' ? 'undefined' : _typeof(first)) !== (typeof second === 'undefined' ? 'undefined' : _typeof(second))) {
  6335. return false;
  6336. }
  6337. if (Array.isArray(first) || Array.isArray(second)) {
  6338. return false;
  6339. }
  6340. if (first !== null && (typeof first === 'undefined' ? 'undefined' : _typeof(first)) === 'object' && second !== null) {
  6341. if (Object.keys(first).length !== Object.keys(second).length) {
  6342. return false;
  6343. }
  6344. for (var key in first) {
  6345. if (!isEntryEqual(first[key], second[key])) {
  6346. return false;
  6347. }
  6348. }
  6349. return true;
  6350. }
  6351. return first === second || Number.isNaN(first) && Number.isNaN(second);
  6352. }
  6353. if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
  6354. return false;
  6355. }
  6356. if (firstDest.length !== secondDest.length) {
  6357. return false;
  6358. }
  6359. for (var i = 0, ii = firstDest.length; i < ii; i++) {
  6360. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  6361. return false;
  6362. }
  6363. }
  6364. return true;
  6365. }
  6366. exports.PDFHistory = PDFHistory;
  6367. exports.isDestHashesEqual = isDestHashesEqual;
  6368. exports.isDestArraysEqual = isDestArraysEqual;
  6369. /***/ }),
  6370. /* 23 */
  6371. /***/ (function(module, exports, __webpack_require__) {
  6372. "use strict";
  6373. Object.defineProperty(exports, "__esModule", {
  6374. value: true
  6375. });
  6376. exports.SimpleLinkService = exports.PDFLinkService = undefined;
  6377. 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; };
  6378. 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; }; }();
  6379. var _dom_events = __webpack_require__(14);
  6380. var _ui_utils = __webpack_require__(6);
  6381. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6382. var PDFLinkService = function () {
  6383. function PDFLinkService() {
  6384. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  6385. eventBus = _ref.eventBus,
  6386. _ref$externalLinkTarg = _ref.externalLinkTarget,
  6387. externalLinkTarget = _ref$externalLinkTarg === undefined ? null : _ref$externalLinkTarg,
  6388. _ref$externalLinkRel = _ref.externalLinkRel,
  6389. externalLinkRel = _ref$externalLinkRel === undefined ? null : _ref$externalLinkRel;
  6390. _classCallCheck(this, PDFLinkService);
  6391. this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)();
  6392. this.externalLinkTarget = externalLinkTarget;
  6393. this.externalLinkRel = externalLinkRel;
  6394. this.baseUrl = null;
  6395. this.pdfDocument = null;
  6396. this.pdfViewer = null;
  6397. this.pdfHistory = null;
  6398. this._pagesRefCache = null;
  6399. }
  6400. _createClass(PDFLinkService, [{
  6401. key: 'setDocument',
  6402. value: function setDocument(pdfDocument) {
  6403. var baseUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  6404. this.baseUrl = baseUrl;
  6405. this.pdfDocument = pdfDocument;
  6406. this._pagesRefCache = Object.create(null);
  6407. }
  6408. }, {
  6409. key: 'setViewer',
  6410. value: function setViewer(pdfViewer) {
  6411. this.pdfViewer = pdfViewer;
  6412. }
  6413. }, {
  6414. key: 'setHistory',
  6415. value: function setHistory(pdfHistory) {
  6416. this.pdfHistory = pdfHistory;
  6417. }
  6418. }, {
  6419. key: 'navigateTo',
  6420. value: function navigateTo(dest) {
  6421. var _this = this;
  6422. var goToDestination = function goToDestination(_ref2) {
  6423. var namedDest = _ref2.namedDest,
  6424. explicitDest = _ref2.explicitDest;
  6425. var destRef = explicitDest[0],
  6426. pageNumber = void 0;
  6427. if (destRef instanceof Object) {
  6428. pageNumber = _this._cachedPageNumber(destRef);
  6429. if (pageNumber === null) {
  6430. _this.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
  6431. _this.cachePageRef(pageIndex + 1, destRef);
  6432. goToDestination({
  6433. namedDest: namedDest,
  6434. explicitDest: explicitDest
  6435. });
  6436. }).catch(function () {
  6437. console.error('PDFLinkService.navigateTo: "' + destRef + '" is not ' + ('a valid page reference, for dest="' + dest + '".'));
  6438. });
  6439. return;
  6440. }
  6441. } else if (Number.isInteger(destRef)) {
  6442. pageNumber = destRef + 1;
  6443. } else {
  6444. console.error('PDFLinkService.navigateTo: "' + destRef + '" is not ' + ('a valid destination reference, for dest="' + dest + '".'));
  6445. return;
  6446. }
  6447. if (!pageNumber || pageNumber < 1 || pageNumber > _this.pagesCount) {
  6448. console.error('PDFLinkService.navigateTo: "' + pageNumber + '" is not ' + ('a valid page number, for dest="' + dest + '".'));
  6449. return;
  6450. }
  6451. if (_this.pdfHistory) {
  6452. _this.pdfHistory.pushCurrentPosition();
  6453. _this.pdfHistory.push({
  6454. namedDest: namedDest,
  6455. explicitDest: explicitDest,
  6456. pageNumber: pageNumber
  6457. });
  6458. }
  6459. _this.pdfViewer.scrollPageIntoView({
  6460. pageNumber: pageNumber,
  6461. destArray: explicitDest
  6462. });
  6463. };
  6464. new Promise(function (resolve, reject) {
  6465. if (typeof dest === 'string') {
  6466. _this.pdfDocument.getDestination(dest).then(function (destArray) {
  6467. resolve({
  6468. namedDest: dest,
  6469. explicitDest: destArray
  6470. });
  6471. });
  6472. return;
  6473. }
  6474. resolve({
  6475. namedDest: '',
  6476. explicitDest: dest
  6477. });
  6478. }).then(function (data) {
  6479. if (!Array.isArray(data.explicitDest)) {
  6480. console.error('PDFLinkService.navigateTo: "' + data.explicitDest + '" is' + (' not a valid destination array, for dest="' + dest + '".'));
  6481. return;
  6482. }
  6483. goToDestination(data);
  6484. });
  6485. }
  6486. }, {
  6487. key: 'getDestinationHash',
  6488. value: function getDestinationHash(dest) {
  6489. if (typeof dest === 'string') {
  6490. return this.getAnchorUrl('#' + escape(dest));
  6491. }
  6492. if (Array.isArray(dest)) {
  6493. var str = JSON.stringify(dest);
  6494. return this.getAnchorUrl('#' + escape(str));
  6495. }
  6496. return this.getAnchorUrl('');
  6497. }
  6498. }, {
  6499. key: 'getAnchorUrl',
  6500. value: function getAnchorUrl(anchor) {
  6501. return (this.baseUrl || '') + anchor;
  6502. }
  6503. }, {
  6504. key: 'setHash',
  6505. value: function setHash(hash) {
  6506. var pageNumber = void 0,
  6507. dest = void 0;
  6508. if (hash.includes('=')) {
  6509. var params = (0, _ui_utils.parseQueryString)(hash);
  6510. if ('search' in params) {
  6511. this.eventBus.dispatch('findfromurlhash', {
  6512. source: this,
  6513. query: params['search'].replace(/"/g, ''),
  6514. phraseSearch: params['phrase'] === 'true'
  6515. });
  6516. }
  6517. if ('nameddest' in params) {
  6518. this.navigateTo(params.nameddest);
  6519. return;
  6520. }
  6521. if ('page' in params) {
  6522. pageNumber = params.page | 0 || 1;
  6523. }
  6524. if ('zoom' in params) {
  6525. var zoomArgs = params.zoom.split(',');
  6526. var zoomArg = zoomArgs[0];
  6527. var zoomArgNumber = parseFloat(zoomArg);
  6528. if (!zoomArg.includes('Fit')) {
  6529. dest = [null, { name: 'XYZ' }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
  6530. } else {
  6531. if (zoomArg === 'Fit' || zoomArg === 'FitB') {
  6532. dest = [null, { name: zoomArg }];
  6533. } else if (zoomArg === 'FitH' || zoomArg === 'FitBH' || zoomArg === 'FitV' || zoomArg === 'FitBV') {
  6534. dest = [null, { name: zoomArg }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  6535. } else if (zoomArg === 'FitR') {
  6536. if (zoomArgs.length !== 5) {
  6537. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
  6538. } else {
  6539. dest = [null, { name: zoomArg }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
  6540. }
  6541. } else {
  6542. console.error('PDFLinkService.setHash: "' + zoomArg + '" is not ' + 'a valid zoom value.');
  6543. }
  6544. }
  6545. }
  6546. if (dest) {
  6547. this.pdfViewer.scrollPageIntoView({
  6548. pageNumber: pageNumber || this.page,
  6549. destArray: dest,
  6550. allowNegativeOffset: true
  6551. });
  6552. } else if (pageNumber) {
  6553. this.page = pageNumber;
  6554. }
  6555. if ('pagemode' in params) {
  6556. this.eventBus.dispatch('pagemode', {
  6557. source: this,
  6558. mode: params.pagemode
  6559. });
  6560. }
  6561. } else {
  6562. dest = unescape(hash);
  6563. try {
  6564. dest = JSON.parse(dest);
  6565. if (!Array.isArray(dest)) {
  6566. dest = dest.toString();
  6567. }
  6568. } catch (ex) {}
  6569. if (typeof dest === 'string' || isValidExplicitDestination(dest)) {
  6570. this.navigateTo(dest);
  6571. return;
  6572. }
  6573. console.error('PDFLinkService.setHash: "' + unescape(hash) + '" is not ' + 'a valid destination.');
  6574. }
  6575. }
  6576. }, {
  6577. key: 'executeNamedAction',
  6578. value: function executeNamedAction(action) {
  6579. switch (action) {
  6580. case 'GoBack':
  6581. if (this.pdfHistory) {
  6582. this.pdfHistory.back();
  6583. }
  6584. break;
  6585. case 'GoForward':
  6586. if (this.pdfHistory) {
  6587. this.pdfHistory.forward();
  6588. }
  6589. break;
  6590. case 'NextPage':
  6591. if (this.page < this.pagesCount) {
  6592. this.page++;
  6593. }
  6594. break;
  6595. case 'PrevPage':
  6596. if (this.page > 1) {
  6597. this.page--;
  6598. }
  6599. break;
  6600. case 'LastPage':
  6601. this.page = this.pagesCount;
  6602. break;
  6603. case 'FirstPage':
  6604. this.page = 1;
  6605. break;
  6606. default:
  6607. break;
  6608. }
  6609. this.eventBus.dispatch('namedaction', {
  6610. source: this,
  6611. action: action
  6612. });
  6613. }
  6614. }, {
  6615. key: 'cachePageRef',
  6616. value: function cachePageRef(pageNum, pageRef) {
  6617. if (!pageRef) {
  6618. return;
  6619. }
  6620. var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
  6621. this._pagesRefCache[refStr] = pageNum;
  6622. }
  6623. }, {
  6624. key: '_cachedPageNumber',
  6625. value: function _cachedPageNumber(pageRef) {
  6626. var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
  6627. return this._pagesRefCache && this._pagesRefCache[refStr] || null;
  6628. }
  6629. }, {
  6630. key: 'pagesCount',
  6631. get: function get() {
  6632. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  6633. }
  6634. }, {
  6635. key: 'page',
  6636. get: function get() {
  6637. return this.pdfViewer.currentPageNumber;
  6638. },
  6639. set: function set(value) {
  6640. this.pdfViewer.currentPageNumber = value;
  6641. }
  6642. }, {
  6643. key: 'rotation',
  6644. get: function get() {
  6645. return this.pdfViewer.pagesRotation;
  6646. },
  6647. set: function set(value) {
  6648. this.pdfViewer.pagesRotation = value;
  6649. }
  6650. }]);
  6651. return PDFLinkService;
  6652. }();
  6653. function isValidExplicitDestination(dest) {
  6654. if (!Array.isArray(dest)) {
  6655. return false;
  6656. }
  6657. var destLength = dest.length,
  6658. allowNull = true;
  6659. if (destLength < 2) {
  6660. return false;
  6661. }
  6662. var page = dest[0];
  6663. if (!((typeof page === 'undefined' ? 'undefined' : _typeof(page)) === 'object' && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
  6664. return false;
  6665. }
  6666. var zoom = dest[1];
  6667. if (!((typeof zoom === 'undefined' ? 'undefined' : _typeof(zoom)) === 'object' && typeof zoom.name === 'string')) {
  6668. return false;
  6669. }
  6670. switch (zoom.name) {
  6671. case 'XYZ':
  6672. if (destLength !== 5) {
  6673. return false;
  6674. }
  6675. break;
  6676. case 'Fit':
  6677. case 'FitB':
  6678. return destLength === 2;
  6679. case 'FitH':
  6680. case 'FitBH':
  6681. case 'FitV':
  6682. case 'FitBV':
  6683. if (destLength !== 3) {
  6684. return false;
  6685. }
  6686. break;
  6687. case 'FitR':
  6688. if (destLength !== 6) {
  6689. return false;
  6690. }
  6691. allowNull = false;
  6692. break;
  6693. default:
  6694. return false;
  6695. }
  6696. for (var i = 2; i < destLength; i++) {
  6697. var param = dest[i];
  6698. if (!(typeof param === 'number' || allowNull && param === null)) {
  6699. return false;
  6700. }
  6701. }
  6702. return true;
  6703. }
  6704. var SimpleLinkService = function () {
  6705. function SimpleLinkService() {
  6706. _classCallCheck(this, SimpleLinkService);
  6707. this.externalLinkTarget = null;
  6708. this.externalLinkRel = null;
  6709. }
  6710. _createClass(SimpleLinkService, [{
  6711. key: 'navigateTo',
  6712. value: function navigateTo(dest) {}
  6713. }, {
  6714. key: 'getDestinationHash',
  6715. value: function getDestinationHash(dest) {
  6716. return '#';
  6717. }
  6718. }, {
  6719. key: 'getAnchorUrl',
  6720. value: function getAnchorUrl(hash) {
  6721. return '#';
  6722. }
  6723. }, {
  6724. key: 'setHash',
  6725. value: function setHash(hash) {}
  6726. }, {
  6727. key: 'executeNamedAction',
  6728. value: function executeNamedAction(action) {}
  6729. }, {
  6730. key: 'cachePageRef',
  6731. value: function cachePageRef(pageNum, pageRef) {}
  6732. }, {
  6733. key: 'pagesCount',
  6734. get: function get() {
  6735. return 0;
  6736. }
  6737. }, {
  6738. key: 'page',
  6739. get: function get() {
  6740. return 0;
  6741. },
  6742. set: function set(value) {}
  6743. }, {
  6744. key: 'rotation',
  6745. get: function get() {
  6746. return 0;
  6747. },
  6748. set: function set(value) {}
  6749. }]);
  6750. return SimpleLinkService;
  6751. }();
  6752. exports.PDFLinkService = PDFLinkService;
  6753. exports.SimpleLinkService = SimpleLinkService;
  6754. /***/ }),
  6755. /* 24 */
  6756. /***/ (function(module, exports, __webpack_require__) {
  6757. "use strict";
  6758. Object.defineProperty(exports, "__esModule", {
  6759. value: true
  6760. });
  6761. exports.PDFOutlineViewer = undefined;
  6762. 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; }; }();
  6763. var _pdfjsLib = __webpack_require__(7);
  6764. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6765. var DEFAULT_TITLE = '\u2013';
  6766. var PDFOutlineViewer = function () {
  6767. function PDFOutlineViewer(_ref) {
  6768. var container = _ref.container,
  6769. linkService = _ref.linkService,
  6770. eventBus = _ref.eventBus;
  6771. _classCallCheck(this, PDFOutlineViewer);
  6772. this.container = container;
  6773. this.linkService = linkService;
  6774. this.eventBus = eventBus;
  6775. this.reset();
  6776. eventBus.on('toggleoutlinetree', this.toggleOutlineTree.bind(this));
  6777. }
  6778. _createClass(PDFOutlineViewer, [{
  6779. key: 'reset',
  6780. value: function reset() {
  6781. this.outline = null;
  6782. this.lastToggleIsShow = true;
  6783. this.container.textContent = '';
  6784. this.container.classList.remove('outlineWithDeepNesting');
  6785. }
  6786. }, {
  6787. key: '_dispatchEvent',
  6788. value: function _dispatchEvent(outlineCount) {
  6789. this.eventBus.dispatch('outlineloaded', {
  6790. source: this,
  6791. outlineCount: outlineCount
  6792. });
  6793. }
  6794. }, {
  6795. key: '_bindLink',
  6796. value: function _bindLink(element, _ref2) {
  6797. var url = _ref2.url,
  6798. newWindow = _ref2.newWindow,
  6799. dest = _ref2.dest;
  6800. var linkService = this.linkService;
  6801. if (url) {
  6802. (0, _pdfjsLib.addLinkAttributes)(element, {
  6803. url: url,
  6804. target: newWindow ? _pdfjsLib.LinkTarget.BLANK : linkService.externalLinkTarget,
  6805. rel: linkService.externalLinkRel
  6806. });
  6807. return;
  6808. }
  6809. element.href = linkService.getDestinationHash(dest);
  6810. element.onclick = function () {
  6811. if (dest) {
  6812. linkService.navigateTo(dest);
  6813. }
  6814. return false;
  6815. };
  6816. }
  6817. }, {
  6818. key: '_setStyles',
  6819. value: function _setStyles(element, _ref3) {
  6820. var bold = _ref3.bold,
  6821. italic = _ref3.italic;
  6822. var styleStr = '';
  6823. if (bold) {
  6824. styleStr += 'font-weight: bold;';
  6825. }
  6826. if (italic) {
  6827. styleStr += 'font-style: italic;';
  6828. }
  6829. if (styleStr) {
  6830. element.setAttribute('style', styleStr);
  6831. }
  6832. }
  6833. }, {
  6834. key: '_addToggleButton',
  6835. value: function _addToggleButton(div) {
  6836. var _this = this;
  6837. var toggler = document.createElement('div');
  6838. toggler.className = 'outlineItemToggler';
  6839. toggler.onclick = function (evt) {
  6840. evt.stopPropagation();
  6841. toggler.classList.toggle('outlineItemsHidden');
  6842. if (evt.shiftKey) {
  6843. var shouldShowAll = !toggler.classList.contains('outlineItemsHidden');
  6844. _this._toggleOutlineItem(div, shouldShowAll);
  6845. }
  6846. };
  6847. div.insertBefore(toggler, div.firstChild);
  6848. }
  6849. }, {
  6850. key: '_toggleOutlineItem',
  6851. value: function _toggleOutlineItem(root, show) {
  6852. this.lastToggleIsShow = show;
  6853. var togglers = root.querySelectorAll('.outlineItemToggler');
  6854. for (var i = 0, ii = togglers.length; i < ii; ++i) {
  6855. togglers[i].classList[show ? 'remove' : 'add']('outlineItemsHidden');
  6856. }
  6857. }
  6858. }, {
  6859. key: 'toggleOutlineTree',
  6860. value: function toggleOutlineTree() {
  6861. if (!this.outline) {
  6862. return;
  6863. }
  6864. this._toggleOutlineItem(this.container, !this.lastToggleIsShow);
  6865. }
  6866. }, {
  6867. key: 'render',
  6868. value: function render(_ref4) {
  6869. var outline = _ref4.outline;
  6870. var outlineCount = 0;
  6871. if (this.outline) {
  6872. this.reset();
  6873. }
  6874. this.outline = outline || null;
  6875. if (!outline) {
  6876. this._dispatchEvent(outlineCount);
  6877. return;
  6878. }
  6879. var fragment = document.createDocumentFragment();
  6880. var queue = [{
  6881. parent: fragment,
  6882. items: this.outline
  6883. }];
  6884. var hasAnyNesting = false;
  6885. while (queue.length > 0) {
  6886. var levelData = queue.shift();
  6887. for (var i = 0, len = levelData.items.length; i < len; i++) {
  6888. var item = levelData.items[i];
  6889. var div = document.createElement('div');
  6890. div.className = 'outlineItem';
  6891. var element = document.createElement('a');
  6892. this._bindLink(element, item);
  6893. this._setStyles(element, item);
  6894. element.textContent = (0, _pdfjsLib.removeNullCharacters)(item.title) || DEFAULT_TITLE;
  6895. div.appendChild(element);
  6896. if (item.items.length > 0) {
  6897. hasAnyNesting = true;
  6898. this._addToggleButton(div);
  6899. var itemsDiv = document.createElement('div');
  6900. itemsDiv.className = 'outlineItems';
  6901. div.appendChild(itemsDiv);
  6902. queue.push({
  6903. parent: itemsDiv,
  6904. items: item.items
  6905. });
  6906. }
  6907. levelData.parent.appendChild(div);
  6908. outlineCount++;
  6909. }
  6910. }
  6911. if (hasAnyNesting) {
  6912. this.container.classList.add('outlineWithDeepNesting');
  6913. }
  6914. this.container.appendChild(fragment);
  6915. this._dispatchEvent(outlineCount);
  6916. }
  6917. }]);
  6918. return PDFOutlineViewer;
  6919. }();
  6920. exports.PDFOutlineViewer = PDFOutlineViewer;
  6921. /***/ }),
  6922. /* 25 */
  6923. /***/ (function(module, exports, __webpack_require__) {
  6924. "use strict";
  6925. Object.defineProperty(exports, "__esModule", {
  6926. value: true
  6927. });
  6928. exports.PDFPresentationMode = undefined;
  6929. 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; }; }();
  6930. var _ui_utils = __webpack_require__(6);
  6931. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6932. var DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1500;
  6933. var DELAY_BEFORE_HIDING_CONTROLS = 3000;
  6934. var ACTIVE_SELECTOR = 'pdfPresentationMode';
  6935. var CONTROLS_SELECTOR = 'pdfPresentationModeControls';
  6936. var MOUSE_SCROLL_COOLDOWN_TIME = 50;
  6937. var PAGE_SWITCH_THRESHOLD = 0.1;
  6938. var SWIPE_MIN_DISTANCE_THRESHOLD = 50;
  6939. var SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
  6940. var PDFPresentationMode = function () {
  6941. function PDFPresentationMode(_ref) {
  6942. var _this = this;
  6943. var container = _ref.container,
  6944. _ref$viewer = _ref.viewer,
  6945. viewer = _ref$viewer === undefined ? null : _ref$viewer,
  6946. pdfViewer = _ref.pdfViewer,
  6947. eventBus = _ref.eventBus,
  6948. _ref$contextMenuItems = _ref.contextMenuItems,
  6949. contextMenuItems = _ref$contextMenuItems === undefined ? null : _ref$contextMenuItems;
  6950. _classCallCheck(this, PDFPresentationMode);
  6951. this.container = container;
  6952. this.viewer = viewer || container.firstElementChild;
  6953. this.pdfViewer = pdfViewer;
  6954. this.eventBus = eventBus;
  6955. this.active = false;
  6956. this.args = null;
  6957. this.contextMenuOpen = false;
  6958. this.mouseScrollTimeStamp = 0;
  6959. this.mouseScrollDelta = 0;
  6960. this.touchSwipeState = null;
  6961. if (contextMenuItems) {
  6962. contextMenuItems.contextFirstPage.addEventListener('click', function () {
  6963. _this.contextMenuOpen = false;
  6964. _this.eventBus.dispatch('firstpage', { source: _this });
  6965. });
  6966. contextMenuItems.contextLastPage.addEventListener('click', function () {
  6967. _this.contextMenuOpen = false;
  6968. _this.eventBus.dispatch('lastpage', { source: _this });
  6969. });
  6970. contextMenuItems.contextPageRotateCw.addEventListener('click', function () {
  6971. _this.contextMenuOpen = false;
  6972. _this.eventBus.dispatch('rotatecw', { source: _this });
  6973. });
  6974. contextMenuItems.contextPageRotateCcw.addEventListener('click', function () {
  6975. _this.contextMenuOpen = false;
  6976. _this.eventBus.dispatch('rotateccw', { source: _this });
  6977. });
  6978. }
  6979. }
  6980. _createClass(PDFPresentationMode, [{
  6981. key: 'request',
  6982. value: function request() {
  6983. if (this.switchInProgress || this.active || !this.viewer.hasChildNodes()) {
  6984. return false;
  6985. }
  6986. this._addFullscreenChangeListeners();
  6987. this._setSwitchInProgress();
  6988. this._notifyStateChange();
  6989. if (this.container.requestFullscreen) {
  6990. this.container.requestFullscreen();
  6991. } else if (this.container.mozRequestFullScreen) {
  6992. this.container.mozRequestFullScreen();
  6993. } else if (this.container.webkitRequestFullscreen) {
  6994. this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
  6995. } else if (this.container.msRequestFullscreen) {
  6996. this.container.msRequestFullscreen();
  6997. } else {
  6998. return false;
  6999. }
  7000. this.args = {
  7001. page: this.pdfViewer.currentPageNumber,
  7002. previousScale: this.pdfViewer.currentScaleValue
  7003. };
  7004. return true;
  7005. }
  7006. }, {
  7007. key: '_mouseWheel',
  7008. value: function _mouseWheel(evt) {
  7009. if (!this.active) {
  7010. return;
  7011. }
  7012. evt.preventDefault();
  7013. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  7014. var currentTime = new Date().getTime();
  7015. var storedTime = this.mouseScrollTimeStamp;
  7016. if (currentTime > storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {
  7017. return;
  7018. }
  7019. if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) {
  7020. this._resetMouseScrollState();
  7021. }
  7022. this.mouseScrollDelta += delta;
  7023. if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
  7024. var totalDelta = this.mouseScrollDelta;
  7025. this._resetMouseScrollState();
  7026. var success = totalDelta > 0 ? this._goToPreviousPage() : this._goToNextPage();
  7027. if (success) {
  7028. this.mouseScrollTimeStamp = currentTime;
  7029. }
  7030. }
  7031. }
  7032. }, {
  7033. key: '_goToPreviousPage',
  7034. value: function _goToPreviousPage() {
  7035. var page = this.pdfViewer.currentPageNumber;
  7036. if (page <= 1) {
  7037. return false;
  7038. }
  7039. this.pdfViewer.currentPageNumber = page - 1;
  7040. return true;
  7041. }
  7042. }, {
  7043. key: '_goToNextPage',
  7044. value: function _goToNextPage() {
  7045. var page = this.pdfViewer.currentPageNumber;
  7046. if (page >= this.pdfViewer.pagesCount) {
  7047. return false;
  7048. }
  7049. this.pdfViewer.currentPageNumber = page + 1;
  7050. return true;
  7051. }
  7052. }, {
  7053. key: '_notifyStateChange',
  7054. value: function _notifyStateChange() {
  7055. this.eventBus.dispatch('presentationmodechanged', {
  7056. source: this,
  7057. active: this.active,
  7058. switchInProgress: !!this.switchInProgress
  7059. });
  7060. }
  7061. }, {
  7062. key: '_setSwitchInProgress',
  7063. value: function _setSwitchInProgress() {
  7064. var _this2 = this;
  7065. if (this.switchInProgress) {
  7066. clearTimeout(this.switchInProgress);
  7067. }
  7068. this.switchInProgress = setTimeout(function () {
  7069. _this2._removeFullscreenChangeListeners();
  7070. delete _this2.switchInProgress;
  7071. _this2._notifyStateChange();
  7072. }, DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS);
  7073. }
  7074. }, {
  7075. key: '_resetSwitchInProgress',
  7076. value: function _resetSwitchInProgress() {
  7077. if (this.switchInProgress) {
  7078. clearTimeout(this.switchInProgress);
  7079. delete this.switchInProgress;
  7080. }
  7081. }
  7082. }, {
  7083. key: '_enter',
  7084. value: function _enter() {
  7085. var _this3 = this;
  7086. this.active = true;
  7087. this._resetSwitchInProgress();
  7088. this._notifyStateChange();
  7089. this.container.classList.add(ACTIVE_SELECTOR);
  7090. setTimeout(function () {
  7091. _this3.pdfViewer.currentPageNumber = _this3.args.page;
  7092. _this3.pdfViewer.currentScaleValue = 'page-fit';
  7093. }, 0);
  7094. this._addWindowListeners();
  7095. this._showControls();
  7096. this.contextMenuOpen = false;
  7097. this.container.setAttribute('contextmenu', 'viewerContextMenu');
  7098. window.getSelection().removeAllRanges();
  7099. }
  7100. }, {
  7101. key: '_exit',
  7102. value: function _exit() {
  7103. var _this4 = this;
  7104. var page = this.pdfViewer.currentPageNumber;
  7105. this.container.classList.remove(ACTIVE_SELECTOR);
  7106. setTimeout(function () {
  7107. _this4.active = false;
  7108. _this4._removeFullscreenChangeListeners();
  7109. _this4._notifyStateChange();
  7110. _this4.pdfViewer.currentScaleValue = _this4.args.previousScale;
  7111. _this4.pdfViewer.currentPageNumber = page;
  7112. _this4.args = null;
  7113. }, 0);
  7114. this._removeWindowListeners();
  7115. this._hideControls();
  7116. this._resetMouseScrollState();
  7117. this.container.removeAttribute('contextmenu');
  7118. this.contextMenuOpen = false;
  7119. }
  7120. }, {
  7121. key: '_mouseDown',
  7122. value: function _mouseDown(evt) {
  7123. if (this.contextMenuOpen) {
  7124. this.contextMenuOpen = false;
  7125. evt.preventDefault();
  7126. return;
  7127. }
  7128. if (evt.button === 0) {
  7129. var isInternalLink = evt.target.href && evt.target.classList.contains('internalLink');
  7130. if (!isInternalLink) {
  7131. evt.preventDefault();
  7132. if (evt.shiftKey) {
  7133. this._goToPreviousPage();
  7134. } else {
  7135. this._goToNextPage();
  7136. }
  7137. }
  7138. }
  7139. }
  7140. }, {
  7141. key: '_contextMenu',
  7142. value: function _contextMenu() {
  7143. this.contextMenuOpen = true;
  7144. }
  7145. }, {
  7146. key: '_showControls',
  7147. value: function _showControls() {
  7148. var _this5 = this;
  7149. if (this.controlsTimeout) {
  7150. clearTimeout(this.controlsTimeout);
  7151. } else {
  7152. this.container.classList.add(CONTROLS_SELECTOR);
  7153. }
  7154. this.controlsTimeout = setTimeout(function () {
  7155. _this5.container.classList.remove(CONTROLS_SELECTOR);
  7156. delete _this5.controlsTimeout;
  7157. }, DELAY_BEFORE_HIDING_CONTROLS);
  7158. }
  7159. }, {
  7160. key: '_hideControls',
  7161. value: function _hideControls() {
  7162. if (!this.controlsTimeout) {
  7163. return;
  7164. }
  7165. clearTimeout(this.controlsTimeout);
  7166. this.container.classList.remove(CONTROLS_SELECTOR);
  7167. delete this.controlsTimeout;
  7168. }
  7169. }, {
  7170. key: '_resetMouseScrollState',
  7171. value: function _resetMouseScrollState() {
  7172. this.mouseScrollTimeStamp = 0;
  7173. this.mouseScrollDelta = 0;
  7174. }
  7175. }, {
  7176. key: '_touchSwipe',
  7177. value: function _touchSwipe(evt) {
  7178. if (!this.active) {
  7179. return;
  7180. }
  7181. if (evt.touches.length > 1) {
  7182. this.touchSwipeState = null;
  7183. return;
  7184. }
  7185. switch (evt.type) {
  7186. case 'touchstart':
  7187. this.touchSwipeState = {
  7188. startX: evt.touches[0].pageX,
  7189. startY: evt.touches[0].pageY,
  7190. endX: evt.touches[0].pageX,
  7191. endY: evt.touches[0].pageY
  7192. };
  7193. break;
  7194. case 'touchmove':
  7195. if (this.touchSwipeState === null) {
  7196. return;
  7197. }
  7198. this.touchSwipeState.endX = evt.touches[0].pageX;
  7199. this.touchSwipeState.endY = evt.touches[0].pageY;
  7200. evt.preventDefault();
  7201. break;
  7202. case 'touchend':
  7203. if (this.touchSwipeState === null) {
  7204. return;
  7205. }
  7206. var delta = 0;
  7207. var dx = this.touchSwipeState.endX - this.touchSwipeState.startX;
  7208. var dy = this.touchSwipeState.endY - this.touchSwipeState.startY;
  7209. var absAngle = Math.abs(Math.atan2(dy, dx));
  7210. if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <= SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI - SWIPE_ANGLE_THRESHOLD)) {
  7211. delta = dx;
  7212. } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math.abs(absAngle - Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) {
  7213. delta = dy;
  7214. }
  7215. if (delta > 0) {
  7216. this._goToPreviousPage();
  7217. } else if (delta < 0) {
  7218. this._goToNextPage();
  7219. }
  7220. break;
  7221. }
  7222. }
  7223. }, {
  7224. key: '_addWindowListeners',
  7225. value: function _addWindowListeners() {
  7226. this.showControlsBind = this._showControls.bind(this);
  7227. this.mouseDownBind = this._mouseDown.bind(this);
  7228. this.mouseWheelBind = this._mouseWheel.bind(this);
  7229. this.resetMouseScrollStateBind = this._resetMouseScrollState.bind(this);
  7230. this.contextMenuBind = this._contextMenu.bind(this);
  7231. this.touchSwipeBind = this._touchSwipe.bind(this);
  7232. window.addEventListener('mousemove', this.showControlsBind);
  7233. window.addEventListener('mousedown', this.mouseDownBind);
  7234. window.addEventListener('wheel', this.mouseWheelBind);
  7235. window.addEventListener('keydown', this.resetMouseScrollStateBind);
  7236. window.addEventListener('contextmenu', this.contextMenuBind);
  7237. window.addEventListener('touchstart', this.touchSwipeBind);
  7238. window.addEventListener('touchmove', this.touchSwipeBind);
  7239. window.addEventListener('touchend', this.touchSwipeBind);
  7240. }
  7241. }, {
  7242. key: '_removeWindowListeners',
  7243. value: function _removeWindowListeners() {
  7244. window.removeEventListener('mousemove', this.showControlsBind);
  7245. window.removeEventListener('mousedown', this.mouseDownBind);
  7246. window.removeEventListener('wheel', this.mouseWheelBind);
  7247. window.removeEventListener('keydown', this.resetMouseScrollStateBind);
  7248. window.removeEventListener('contextmenu', this.contextMenuBind);
  7249. window.removeEventListener('touchstart', this.touchSwipeBind);
  7250. window.removeEventListener('touchmove', this.touchSwipeBind);
  7251. window.removeEventListener('touchend', this.touchSwipeBind);
  7252. delete this.showControlsBind;
  7253. delete this.mouseDownBind;
  7254. delete this.mouseWheelBind;
  7255. delete this.resetMouseScrollStateBind;
  7256. delete this.contextMenuBind;
  7257. delete this.touchSwipeBind;
  7258. }
  7259. }, {
  7260. key: '_fullscreenChange',
  7261. value: function _fullscreenChange() {
  7262. if (this.isFullscreen) {
  7263. this._enter();
  7264. } else {
  7265. this._exit();
  7266. }
  7267. }
  7268. }, {
  7269. key: '_addFullscreenChangeListeners',
  7270. value: function _addFullscreenChangeListeners() {
  7271. this.fullscreenChangeBind = this._fullscreenChange.bind(this);
  7272. window.addEventListener('fullscreenchange', this.fullscreenChangeBind);
  7273. window.addEventListener('mozfullscreenchange', this.fullscreenChangeBind);
  7274. window.addEventListener('webkitfullscreenchange', this.fullscreenChangeBind);
  7275. window.addEventListener('MSFullscreenChange', this.fullscreenChangeBind);
  7276. }
  7277. }, {
  7278. key: '_removeFullscreenChangeListeners',
  7279. value: function _removeFullscreenChangeListeners() {
  7280. window.removeEventListener('fullscreenchange', this.fullscreenChangeBind);
  7281. window.removeEventListener('mozfullscreenchange', this.fullscreenChangeBind);
  7282. window.removeEventListener('webkitfullscreenchange', this.fullscreenChangeBind);
  7283. window.removeEventListener('MSFullscreenChange', this.fullscreenChangeBind);
  7284. delete this.fullscreenChangeBind;
  7285. }
  7286. }, {
  7287. key: 'isFullscreen',
  7288. get: function get() {
  7289. return !!(document.fullscreenElement || document.mozFullScreen || document.webkitIsFullScreen || document.msFullscreenElement);
  7290. }
  7291. }]);
  7292. return PDFPresentationMode;
  7293. }();
  7294. exports.PDFPresentationMode = PDFPresentationMode;
  7295. /***/ }),
  7296. /* 26 */
  7297. /***/ (function(module, exports, __webpack_require__) {
  7298. "use strict";
  7299. Object.defineProperty(exports, "__esModule", {
  7300. value: true
  7301. });
  7302. exports.PDFSidebarResizer = undefined;
  7303. 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; }; }();
  7304. var _ui_utils = __webpack_require__(6);
  7305. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7306. var SIDEBAR_WIDTH_VAR = '--sidebar-width';
  7307. var SIDEBAR_MIN_WIDTH = 200;
  7308. var SIDEBAR_RESIZING_CLASS = 'sidebarResizing';
  7309. var PDFSidebarResizer = function () {
  7310. function PDFSidebarResizer(options, eventBus) {
  7311. var _this = this;
  7312. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  7313. _classCallCheck(this, PDFSidebarResizer);
  7314. this.enabled = false;
  7315. this.isRTL = false;
  7316. this.sidebarOpen = false;
  7317. this.doc = document.documentElement;
  7318. this._width = null;
  7319. this._outerContainerWidth = null;
  7320. this._boundEvents = Object.create(null);
  7321. this.outerContainer = options.outerContainer;
  7322. this.resizer = options.resizer;
  7323. this.eventBus = eventBus;
  7324. this.l10n = l10n;
  7325. if (typeof CSS === 'undefined' || typeof CSS.supports !== 'function' || !CSS.supports(SIDEBAR_WIDTH_VAR, 'calc(-1 * ' + SIDEBAR_MIN_WIDTH + 'px)')) {
  7326. console.warn('PDFSidebarResizer: ' + 'The browser does not support resizing of the sidebar.');
  7327. return;
  7328. }
  7329. this.enabled = true;
  7330. this.resizer.classList.remove('hidden');
  7331. this.l10n.getDirection().then(function (dir) {
  7332. _this.isRTL = dir === 'rtl';
  7333. });
  7334. this._addEventListeners();
  7335. }
  7336. _createClass(PDFSidebarResizer, [{
  7337. key: '_updateWidth',
  7338. value: function _updateWidth() {
  7339. var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  7340. if (!this.enabled) {
  7341. return false;
  7342. }
  7343. var maxWidth = Math.floor(this.outerContainerWidth / 2);
  7344. if (width > maxWidth) {
  7345. width = maxWidth;
  7346. }
  7347. if (width < SIDEBAR_MIN_WIDTH) {
  7348. width = SIDEBAR_MIN_WIDTH;
  7349. }
  7350. if (width === this._width) {
  7351. return false;
  7352. }
  7353. this._width = width;
  7354. this.doc.style.setProperty(SIDEBAR_WIDTH_VAR, width + 'px');
  7355. return true;
  7356. }
  7357. }, {
  7358. key: '_mouseMove',
  7359. value: function _mouseMove(evt) {
  7360. var width = evt.clientX;
  7361. if (this.isRTL) {
  7362. width = this.outerContainerWidth - width;
  7363. }
  7364. this._updateWidth(width);
  7365. }
  7366. }, {
  7367. key: '_mouseUp',
  7368. value: function _mouseUp(evt) {
  7369. this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  7370. this.eventBus.dispatch('resize', { source: this });
  7371. var _boundEvents = this._boundEvents;
  7372. window.removeEventListener('mousemove', _boundEvents.mouseMove);
  7373. window.removeEventListener('mouseup', _boundEvents.mouseUp);
  7374. }
  7375. }, {
  7376. key: '_addEventListeners',
  7377. value: function _addEventListeners() {
  7378. var _this2 = this;
  7379. if (!this.enabled) {
  7380. return;
  7381. }
  7382. var _boundEvents = this._boundEvents;
  7383. _boundEvents.mouseMove = this._mouseMove.bind(this);
  7384. _boundEvents.mouseUp = this._mouseUp.bind(this);
  7385. this.resizer.addEventListener('mousedown', function (evt) {
  7386. if (evt.button !== 0) {
  7387. return;
  7388. }
  7389. _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  7390. window.addEventListener('mousemove', _boundEvents.mouseMove);
  7391. window.addEventListener('mouseup', _boundEvents.mouseUp);
  7392. });
  7393. this.eventBus.on('sidebarviewchanged', function (evt) {
  7394. _this2.sidebarOpen = !!(evt && evt.view);
  7395. });
  7396. this.eventBus.on('resize', function (evt) {
  7397. if (evt && evt.source === window) {
  7398. _this2._outerContainerWidth = null;
  7399. if (_this2._width) {
  7400. if (_this2.sidebarOpen) {
  7401. _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  7402. var updated = _this2._updateWidth(_this2._width);
  7403. Promise.resolve().then(function () {
  7404. _this2.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  7405. if (updated) {
  7406. _this2.eventBus.dispatch('resize', { source: _this2 });
  7407. }
  7408. });
  7409. } else {
  7410. _this2._updateWidth(_this2._width);
  7411. }
  7412. }
  7413. }
  7414. });
  7415. }
  7416. }, {
  7417. key: 'outerContainerWidth',
  7418. get: function get() {
  7419. if (!this._outerContainerWidth) {
  7420. this._outerContainerWidth = this.outerContainer.clientWidth;
  7421. }
  7422. return this._outerContainerWidth;
  7423. }
  7424. }]);
  7425. return PDFSidebarResizer;
  7426. }();
  7427. exports.PDFSidebarResizer = PDFSidebarResizer;
  7428. /***/ }),
  7429. /* 27 */
  7430. /***/ (function(module, exports, __webpack_require__) {
  7431. "use strict";
  7432. Object.defineProperty(exports, "__esModule", {
  7433. value: true
  7434. });
  7435. exports.PDFThumbnailViewer = undefined;
  7436. 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; }; }();
  7437. var _ui_utils = __webpack_require__(6);
  7438. var _pdf_thumbnail_view = __webpack_require__(28);
  7439. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7440. var THUMBNAIL_SCROLL_MARGIN = -19;
  7441. var THUMBNAIL_SELECTED_CLASS = 'selected';
  7442. var PDFThumbnailViewer = function () {
  7443. function PDFThumbnailViewer(_ref) {
  7444. var container = _ref.container,
  7445. linkService = _ref.linkService,
  7446. renderingQueue = _ref.renderingQueue,
  7447. _ref$l10n = _ref.l10n,
  7448. l10n = _ref$l10n === undefined ? _ui_utils.NullL10n : _ref$l10n;
  7449. _classCallCheck(this, PDFThumbnailViewer);
  7450. this.container = container;
  7451. this.linkService = linkService;
  7452. this.renderingQueue = renderingQueue;
  7453. this.l10n = l10n;
  7454. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdated.bind(this));
  7455. this._resetView();
  7456. }
  7457. _createClass(PDFThumbnailViewer, [{
  7458. key: '_scrollUpdated',
  7459. value: function _scrollUpdated() {
  7460. this.renderingQueue.renderHighestPriority();
  7461. }
  7462. }, {
  7463. key: 'getThumbnail',
  7464. value: function getThumbnail(index) {
  7465. return this._thumbnails[index];
  7466. }
  7467. }, {
  7468. key: '_getVisibleThumbs',
  7469. value: function _getVisibleThumbs() {
  7470. return (0, _ui_utils.getVisibleElements)(this.container, this._thumbnails);
  7471. }
  7472. }, {
  7473. key: 'scrollThumbnailIntoView',
  7474. value: function scrollThumbnailIntoView(pageNumber) {
  7475. if (!this.pdfDocument) {
  7476. return;
  7477. }
  7478. var thumbnailView = this._thumbnails[pageNumber - 1];
  7479. if (!thumbnailView) {
  7480. console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');
  7481. return;
  7482. }
  7483. if (pageNumber !== this._currentPageNumber) {
  7484. var prevThumbnailView = this._thumbnails[this._currentPageNumber - 1];
  7485. prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS);
  7486. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  7487. }
  7488. var visibleThumbs = this._getVisibleThumbs();
  7489. var numVisibleThumbs = visibleThumbs.views.length;
  7490. if (numVisibleThumbs > 0) {
  7491. var first = visibleThumbs.first.id;
  7492. var last = numVisibleThumbs > 1 ? visibleThumbs.last.id : first;
  7493. var shouldScroll = false;
  7494. if (pageNumber <= first || pageNumber >= last) {
  7495. shouldScroll = true;
  7496. } else {
  7497. visibleThumbs.views.some(function (view) {
  7498. if (view.id !== pageNumber) {
  7499. return false;
  7500. }
  7501. shouldScroll = view.percent < 100;
  7502. return true;
  7503. });
  7504. }
  7505. if (shouldScroll) {
  7506. (0, _ui_utils.scrollIntoView)(thumbnailView.div, { top: THUMBNAIL_SCROLL_MARGIN });
  7507. }
  7508. }
  7509. this._currentPageNumber = pageNumber;
  7510. }
  7511. }, {
  7512. key: 'cleanup',
  7513. value: function cleanup() {
  7514. _pdf_thumbnail_view.PDFThumbnailView.cleanup();
  7515. }
  7516. }, {
  7517. key: '_resetView',
  7518. value: function _resetView() {
  7519. this._thumbnails = [];
  7520. this._currentPageNumber = 1;
  7521. this._pageLabels = null;
  7522. this._pagesRotation = 0;
  7523. this._pagesRequests = [];
  7524. this.container.textContent = '';
  7525. }
  7526. }, {
  7527. key: 'setDocument',
  7528. value: function setDocument(pdfDocument) {
  7529. var _this = this;
  7530. if (this.pdfDocument) {
  7531. this._cancelRendering();
  7532. this._resetView();
  7533. }
  7534. this.pdfDocument = pdfDocument;
  7535. if (!pdfDocument) {
  7536. return;
  7537. }
  7538. pdfDocument.getPage(1).then(function (firstPage) {
  7539. var pagesCount = pdfDocument.numPages;
  7540. var viewport = firstPage.getViewport(1.0);
  7541. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  7542. var thumbnail = new _pdf_thumbnail_view.PDFThumbnailView({
  7543. container: _this.container,
  7544. id: pageNum,
  7545. defaultViewport: viewport.clone(),
  7546. linkService: _this.linkService,
  7547. renderingQueue: _this.renderingQueue,
  7548. disableCanvasToImageConversion: false,
  7549. l10n: _this.l10n
  7550. });
  7551. _this._thumbnails.push(thumbnail);
  7552. }
  7553. var thumbnailView = _this._thumbnails[_this._currentPageNumber - 1];
  7554. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  7555. }).catch(function (reason) {
  7556. console.error('Unable to initialize thumbnail viewer', reason);
  7557. });
  7558. }
  7559. }, {
  7560. key: '_cancelRendering',
  7561. value: function _cancelRendering() {
  7562. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  7563. if (this._thumbnails[i]) {
  7564. this._thumbnails[i].cancelRendering();
  7565. }
  7566. }
  7567. }
  7568. }, {
  7569. key: 'setPageLabels',
  7570. value: function setPageLabels(labels) {
  7571. if (!this.pdfDocument) {
  7572. return;
  7573. }
  7574. if (!labels) {
  7575. this._pageLabels = null;
  7576. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  7577. this._pageLabels = null;
  7578. console.error('PDFThumbnailViewer_setPageLabels: Invalid page labels.');
  7579. } else {
  7580. this._pageLabels = labels;
  7581. }
  7582. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  7583. var label = this._pageLabels && this._pageLabels[i];
  7584. this._thumbnails[i].setPageLabel(label);
  7585. }
  7586. }
  7587. }, {
  7588. key: '_ensurePdfPageLoaded',
  7589. value: function _ensurePdfPageLoaded(thumbView) {
  7590. var _this2 = this;
  7591. if (thumbView.pdfPage) {
  7592. return Promise.resolve(thumbView.pdfPage);
  7593. }
  7594. var pageNumber = thumbView.id;
  7595. if (this._pagesRequests[pageNumber]) {
  7596. return this._pagesRequests[pageNumber];
  7597. }
  7598. var promise = this.pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  7599. thumbView.setPdfPage(pdfPage);
  7600. _this2._pagesRequests[pageNumber] = null;
  7601. return pdfPage;
  7602. }).catch(function (reason) {
  7603. console.error('Unable to get page for thumb view', reason);
  7604. _this2._pagesRequests[pageNumber] = null;
  7605. });
  7606. this._pagesRequests[pageNumber] = promise;
  7607. return promise;
  7608. }
  7609. }, {
  7610. key: 'forceRendering',
  7611. value: function forceRendering() {
  7612. var _this3 = this;
  7613. var visibleThumbs = this._getVisibleThumbs();
  7614. var thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, this.scroll.down);
  7615. if (thumbView) {
  7616. this._ensurePdfPageLoaded(thumbView).then(function () {
  7617. _this3.renderingQueue.renderView(thumbView);
  7618. });
  7619. return true;
  7620. }
  7621. return false;
  7622. }
  7623. }, {
  7624. key: 'pagesRotation',
  7625. get: function get() {
  7626. return this._pagesRotation;
  7627. },
  7628. set: function set(rotation) {
  7629. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  7630. throw new Error('Invalid thumbnails rotation angle.');
  7631. }
  7632. if (!this.pdfDocument) {
  7633. return;
  7634. }
  7635. if (this._pagesRotation === rotation) {
  7636. return;
  7637. }
  7638. this._pagesRotation = rotation;
  7639. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  7640. this._thumbnails[i].update(rotation);
  7641. }
  7642. }
  7643. }]);
  7644. return PDFThumbnailViewer;
  7645. }();
  7646. exports.PDFThumbnailViewer = PDFThumbnailViewer;
  7647. /***/ }),
  7648. /* 28 */
  7649. /***/ (function(module, exports, __webpack_require__) {
  7650. "use strict";
  7651. Object.defineProperty(exports, "__esModule", {
  7652. value: true
  7653. });
  7654. exports.PDFThumbnailView = undefined;
  7655. 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; }; }();
  7656. var _pdfjsLib = __webpack_require__(7);
  7657. var _ui_utils = __webpack_require__(6);
  7658. var _pdf_rendering_queue = __webpack_require__(10);
  7659. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7660. var MAX_NUM_SCALING_STEPS = 3;
  7661. var THUMBNAIL_CANVAS_BORDER_WIDTH = 1;
  7662. var THUMBNAIL_WIDTH = 98;
  7663. var TempImageFactory = function TempImageFactoryClosure() {
  7664. var tempCanvasCache = null;
  7665. return {
  7666. getCanvas: function getCanvas(width, height) {
  7667. var tempCanvas = tempCanvasCache;
  7668. if (!tempCanvas) {
  7669. tempCanvas = document.createElement('canvas');
  7670. tempCanvasCache = tempCanvas;
  7671. }
  7672. tempCanvas.width = width;
  7673. tempCanvas.height = height;
  7674. tempCanvas.mozOpaque = true;
  7675. var ctx = tempCanvas.getContext('2d', { alpha: false });
  7676. ctx.save();
  7677. ctx.fillStyle = 'rgb(255, 255, 255)';
  7678. ctx.fillRect(0, 0, width, height);
  7679. ctx.restore();
  7680. return tempCanvas;
  7681. },
  7682. destroyCanvas: function destroyCanvas() {
  7683. var tempCanvas = tempCanvasCache;
  7684. if (tempCanvas) {
  7685. tempCanvas.width = 0;
  7686. tempCanvas.height = 0;
  7687. }
  7688. tempCanvasCache = null;
  7689. }
  7690. };
  7691. }();
  7692. var PDFThumbnailView = function () {
  7693. function PDFThumbnailView(_ref) {
  7694. var container = _ref.container,
  7695. id = _ref.id,
  7696. defaultViewport = _ref.defaultViewport,
  7697. linkService = _ref.linkService,
  7698. renderingQueue = _ref.renderingQueue,
  7699. _ref$disableCanvasToI = _ref.disableCanvasToImageConversion,
  7700. disableCanvasToImageConversion = _ref$disableCanvasToI === undefined ? false : _ref$disableCanvasToI,
  7701. _ref$l10n = _ref.l10n,
  7702. l10n = _ref$l10n === undefined ? _ui_utils.NullL10n : _ref$l10n;
  7703. _classCallCheck(this, PDFThumbnailView);
  7704. this.id = id;
  7705. this.renderingId = 'thumbnail' + id;
  7706. this.pageLabel = null;
  7707. this.pdfPage = null;
  7708. this.rotation = 0;
  7709. this.viewport = defaultViewport;
  7710. this.pdfPageRotate = defaultViewport.rotation;
  7711. this.linkService = linkService;
  7712. this.renderingQueue = renderingQueue;
  7713. this.renderTask = null;
  7714. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  7715. this.resume = null;
  7716. this.disableCanvasToImageConversion = disableCanvasToImageConversion;
  7717. this.pageWidth = this.viewport.width;
  7718. this.pageHeight = this.viewport.height;
  7719. this.pageRatio = this.pageWidth / this.pageHeight;
  7720. this.canvasWidth = THUMBNAIL_WIDTH;
  7721. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  7722. this.scale = this.canvasWidth / this.pageWidth;
  7723. this.l10n = l10n;
  7724. var anchor = document.createElement('a');
  7725. anchor.href = linkService.getAnchorUrl('#page=' + id);
  7726. this.l10n.get('thumb_page_title', { page: id }, 'Page {{page}}').then(function (msg) {
  7727. anchor.title = msg;
  7728. });
  7729. anchor.onclick = function () {
  7730. linkService.page = id;
  7731. return false;
  7732. };
  7733. this.anchor = anchor;
  7734. var div = document.createElement('div');
  7735. div.className = 'thumbnail';
  7736. div.setAttribute('data-page-number', this.id);
  7737. this.div = div;
  7738. var ring = document.createElement('div');
  7739. ring.className = 'thumbnailSelectionRing';
  7740. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  7741. ring.style.width = this.canvasWidth + borderAdjustment + 'px';
  7742. ring.style.height = this.canvasHeight + borderAdjustment + 'px';
  7743. this.ring = ring;
  7744. div.appendChild(ring);
  7745. anchor.appendChild(div);
  7746. container.appendChild(anchor);
  7747. }
  7748. _createClass(PDFThumbnailView, [{
  7749. key: 'setPdfPage',
  7750. value: function setPdfPage(pdfPage) {
  7751. this.pdfPage = pdfPage;
  7752. this.pdfPageRotate = pdfPage.rotate;
  7753. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  7754. this.viewport = pdfPage.getViewport(1, totalRotation);
  7755. this.reset();
  7756. }
  7757. }, {
  7758. key: 'reset',
  7759. value: function reset() {
  7760. this.cancelRendering();
  7761. this.pageWidth = this.viewport.width;
  7762. this.pageHeight = this.viewport.height;
  7763. this.pageRatio = this.pageWidth / this.pageHeight;
  7764. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  7765. this.scale = this.canvasWidth / this.pageWidth;
  7766. this.div.removeAttribute('data-loaded');
  7767. var ring = this.ring;
  7768. var childNodes = ring.childNodes;
  7769. for (var i = childNodes.length - 1; i >= 0; i--) {
  7770. ring.removeChild(childNodes[i]);
  7771. }
  7772. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  7773. ring.style.width = this.canvasWidth + borderAdjustment + 'px';
  7774. ring.style.height = this.canvasHeight + borderAdjustment + 'px';
  7775. if (this.canvas) {
  7776. this.canvas.width = 0;
  7777. this.canvas.height = 0;
  7778. delete this.canvas;
  7779. }
  7780. if (this.image) {
  7781. this.image.removeAttribute('src');
  7782. delete this.image;
  7783. }
  7784. }
  7785. }, {
  7786. key: 'update',
  7787. value: function update(rotation) {
  7788. if (typeof rotation !== 'undefined') {
  7789. this.rotation = rotation;
  7790. }
  7791. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  7792. this.viewport = this.viewport.clone({
  7793. scale: 1,
  7794. rotation: totalRotation
  7795. });
  7796. this.reset();
  7797. }
  7798. }, {
  7799. key: 'cancelRendering',
  7800. value: function cancelRendering() {
  7801. if (this.renderTask) {
  7802. this.renderTask.cancel();
  7803. this.renderTask = null;
  7804. }
  7805. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  7806. this.resume = null;
  7807. }
  7808. }, {
  7809. key: '_getPageDrawContext',
  7810. value: function _getPageDrawContext() {
  7811. var noCtxScale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  7812. var canvas = document.createElement('canvas');
  7813. this.canvas = canvas;
  7814. canvas.mozOpaque = true;
  7815. var ctx = canvas.getContext('2d', { alpha: false });
  7816. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  7817. canvas.width = this.canvasWidth * outputScale.sx | 0;
  7818. canvas.height = this.canvasHeight * outputScale.sy | 0;
  7819. canvas.style.width = this.canvasWidth + 'px';
  7820. canvas.style.height = this.canvasHeight + 'px';
  7821. if (!noCtxScale && outputScale.scaled) {
  7822. ctx.scale(outputScale.sx, outputScale.sy);
  7823. }
  7824. return ctx;
  7825. }
  7826. }, {
  7827. key: '_convertCanvasToImage',
  7828. value: function _convertCanvasToImage() {
  7829. var _this = this;
  7830. if (!this.canvas) {
  7831. return;
  7832. }
  7833. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  7834. return;
  7835. }
  7836. var id = this.renderingId;
  7837. var className = 'thumbnailImage';
  7838. if (this.disableCanvasToImageConversion) {
  7839. this.canvas.id = id;
  7840. this.canvas.className = className;
  7841. this.l10n.get('thumb_page_canvas', { page: this.pageId }, 'Thumbnail of Page {{page}}').then(function (msg) {
  7842. _this.canvas.setAttribute('aria-label', msg);
  7843. });
  7844. this.div.setAttribute('data-loaded', true);
  7845. this.ring.appendChild(this.canvas);
  7846. return;
  7847. }
  7848. var image = document.createElement('img');
  7849. image.id = id;
  7850. image.className = className;
  7851. this.l10n.get('thumb_page_canvas', { page: this.pageId }, 'Thumbnail of Page {{page}}').then(function (msg) {
  7852. image.setAttribute('aria-label', msg);
  7853. });
  7854. image.style.width = this.canvasWidth + 'px';
  7855. image.style.height = this.canvasHeight + 'px';
  7856. image.src = this.canvas.toDataURL();
  7857. this.image = image;
  7858. this.div.setAttribute('data-loaded', true);
  7859. this.ring.appendChild(image);
  7860. this.canvas.width = 0;
  7861. this.canvas.height = 0;
  7862. delete this.canvas;
  7863. }
  7864. }, {
  7865. key: 'draw',
  7866. value: function draw() {
  7867. var _this2 = this;
  7868. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  7869. console.error('Must be in new state before drawing');
  7870. return Promise.resolve(undefined);
  7871. }
  7872. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  7873. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  7874. var finishRenderTask = function finishRenderTask(error) {
  7875. if (renderTask === _this2.renderTask) {
  7876. _this2.renderTask = null;
  7877. }
  7878. if (error instanceof _pdfjsLib.RenderingCancelledException) {
  7879. renderCapability.resolve(undefined);
  7880. return;
  7881. }
  7882. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  7883. _this2._convertCanvasToImage();
  7884. if (!error) {
  7885. renderCapability.resolve(undefined);
  7886. } else {
  7887. renderCapability.reject(error);
  7888. }
  7889. };
  7890. var ctx = this._getPageDrawContext();
  7891. var drawViewport = this.viewport.clone({ scale: this.scale });
  7892. var renderContinueCallback = function renderContinueCallback(cont) {
  7893. if (!_this2.renderingQueue.isHighestPriority(_this2)) {
  7894. _this2.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  7895. _this2.resume = function () {
  7896. _this2.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  7897. cont();
  7898. };
  7899. return;
  7900. }
  7901. cont();
  7902. };
  7903. var renderContext = {
  7904. canvasContext: ctx,
  7905. viewport: drawViewport
  7906. };
  7907. var renderTask = this.renderTask = this.pdfPage.render(renderContext);
  7908. renderTask.onContinue = renderContinueCallback;
  7909. renderTask.promise.then(function () {
  7910. finishRenderTask(null);
  7911. }, function (error) {
  7912. finishRenderTask(error);
  7913. });
  7914. return renderCapability.promise;
  7915. }
  7916. }, {
  7917. key: 'setImage',
  7918. value: function setImage(pageView) {
  7919. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  7920. return;
  7921. }
  7922. var img = pageView.canvas;
  7923. if (!img) {
  7924. return;
  7925. }
  7926. if (!this.pdfPage) {
  7927. this.setPdfPage(pageView.pdfPage);
  7928. }
  7929. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  7930. var ctx = this._getPageDrawContext(true);
  7931. var canvas = ctx.canvas;
  7932. if (img.width <= 2 * canvas.width) {
  7933. ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height);
  7934. this._convertCanvasToImage();
  7935. return;
  7936. }
  7937. var reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
  7938. var reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
  7939. var reducedImage = TempImageFactory.getCanvas(reducedWidth, reducedHeight);
  7940. var reducedImageCtx = reducedImage.getContext('2d');
  7941. while (reducedWidth > img.width || reducedHeight > img.height) {
  7942. reducedWidth >>= 1;
  7943. reducedHeight >>= 1;
  7944. }
  7945. reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0, reducedWidth, reducedHeight);
  7946. while (reducedWidth > 2 * canvas.width) {
  7947. reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, reducedWidth >> 1, reducedHeight >> 1);
  7948. reducedWidth >>= 1;
  7949. reducedHeight >>= 1;
  7950. }
  7951. ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height);
  7952. this._convertCanvasToImage();
  7953. }
  7954. }, {
  7955. key: 'setPageLabel',
  7956. value: function setPageLabel(label) {
  7957. var _this3 = this;
  7958. this.pageLabel = typeof label === 'string' ? label : null;
  7959. this.l10n.get('thumb_page_title', { page: this.pageId }, 'Page {{page}}').then(function (msg) {
  7960. _this3.anchor.title = msg;
  7961. });
  7962. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  7963. return;
  7964. }
  7965. this.l10n.get('thumb_page_canvas', { page: this.pageId }, 'Thumbnail of Page {{page}}').then(function (ariaLabel) {
  7966. if (_this3.image) {
  7967. _this3.image.setAttribute('aria-label', ariaLabel);
  7968. } else if (_this3.disableCanvasToImageConversion && _this3.canvas) {
  7969. _this3.canvas.setAttribute('aria-label', ariaLabel);
  7970. }
  7971. });
  7972. }
  7973. }, {
  7974. key: 'pageId',
  7975. get: function get() {
  7976. return this.pageLabel !== null ? this.pageLabel : this.id;
  7977. }
  7978. }], [{
  7979. key: 'cleanup',
  7980. value: function cleanup() {
  7981. TempImageFactory.destroyCanvas();
  7982. }
  7983. }]);
  7984. return PDFThumbnailView;
  7985. }();
  7986. exports.PDFThumbnailView = PDFThumbnailView;
  7987. /***/ }),
  7988. /* 29 */
  7989. /***/ (function(module, exports, __webpack_require__) {
  7990. "use strict";
  7991. Object.defineProperty(exports, "__esModule", {
  7992. value: true
  7993. });
  7994. exports.PDFViewer = undefined;
  7995. 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; }; }();
  7996. var _base_viewer = __webpack_require__(30);
  7997. var _ui_utils = __webpack_require__(6);
  7998. var _pdfjsLib = __webpack_require__(7);
  7999. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8000. 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; }
  8001. 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; }
  8002. var PDFViewer = function (_BaseViewer) {
  8003. _inherits(PDFViewer, _BaseViewer);
  8004. function PDFViewer() {
  8005. _classCallCheck(this, PDFViewer);
  8006. return _possibleConstructorReturn(this, (PDFViewer.__proto__ || Object.getPrototypeOf(PDFViewer)).apply(this, arguments));
  8007. }
  8008. _createClass(PDFViewer, [{
  8009. key: '_scrollIntoView',
  8010. value: function _scrollIntoView(_ref) {
  8011. var pageDiv = _ref.pageDiv,
  8012. _ref$pageSpot = _ref.pageSpot,
  8013. pageSpot = _ref$pageSpot === undefined ? null : _ref$pageSpot;
  8014. if (!pageSpot && !this.isInPresentationMode) {
  8015. var left = pageDiv.offsetLeft + pageDiv.clientLeft;
  8016. var right = left + pageDiv.clientWidth;
  8017. var _container = this.container,
  8018. scrollLeft = _container.scrollLeft,
  8019. clientWidth = _container.clientWidth;
  8020. if (this._scrollMode === _base_viewer.ScrollMode.HORIZONTAL || left < scrollLeft || right > scrollLeft + clientWidth) {
  8021. pageSpot = {
  8022. left: 0,
  8023. top: 0
  8024. };
  8025. }
  8026. }
  8027. (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
  8028. }
  8029. }, {
  8030. key: '_getVisiblePages',
  8031. value: function _getVisiblePages() {
  8032. if (!this.isInPresentationMode) {
  8033. return (0, _ui_utils.getVisibleElements)(this.container, this._pages, true, this._scrollMode === _base_viewer.ScrollMode.HORIZONTAL);
  8034. }
  8035. var currentPage = this._pages[this._currentPageNumber - 1];
  8036. var visible = [{
  8037. id: currentPage.id,
  8038. view: currentPage
  8039. }];
  8040. return {
  8041. first: currentPage,
  8042. last: currentPage,
  8043. views: visible
  8044. };
  8045. }
  8046. }, {
  8047. key: 'update',
  8048. value: function update() {
  8049. var visible = this._getVisiblePages();
  8050. var visiblePages = visible.views,
  8051. numVisiblePages = visiblePages.length;
  8052. if (numVisiblePages === 0) {
  8053. return;
  8054. }
  8055. this._resizeBuffer(numVisiblePages, visiblePages);
  8056. this.renderingQueue.renderHighestPriority(visible);
  8057. var currentId = this._currentPageNumber;
  8058. var stillFullyVisible = false;
  8059. for (var i = 0; i < numVisiblePages; ++i) {
  8060. var page = visiblePages[i];
  8061. if (page.percent < 100) {
  8062. break;
  8063. }
  8064. if (page.id === currentId) {
  8065. stillFullyVisible = true;
  8066. break;
  8067. }
  8068. }
  8069. if (!stillFullyVisible) {
  8070. currentId = visiblePages[0].id;
  8071. }
  8072. if (!this.isInPresentationMode) {
  8073. this._setCurrentPageNumber(currentId);
  8074. }
  8075. this._updateLocation(visible.first);
  8076. this.eventBus.dispatch('updateviewarea', {
  8077. source: this,
  8078. location: this._location
  8079. });
  8080. }
  8081. }, {
  8082. key: '_setDocumentViewerElement',
  8083. get: function get() {
  8084. return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this.viewer);
  8085. }
  8086. }, {
  8087. key: '_isScrollModeHorizontal',
  8088. get: function get() {
  8089. return this.isInPresentationMode ? false : this._scrollMode === _base_viewer.ScrollMode.HORIZONTAL;
  8090. }
  8091. }]);
  8092. return PDFViewer;
  8093. }(_base_viewer.BaseViewer);
  8094. exports.PDFViewer = PDFViewer;
  8095. /***/ }),
  8096. /* 30 */
  8097. /***/ (function(module, exports, __webpack_require__) {
  8098. "use strict";
  8099. Object.defineProperty(exports, "__esModule", {
  8100. value: true
  8101. });
  8102. exports.SpreadMode = exports.ScrollMode = exports.BaseViewer = undefined;
  8103. 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; }; }();
  8104. var _ui_utils = __webpack_require__(6);
  8105. var _pdf_rendering_queue = __webpack_require__(10);
  8106. var _annotation_layer_builder = __webpack_require__(31);
  8107. var _pdfjsLib = __webpack_require__(7);
  8108. var _dom_events = __webpack_require__(14);
  8109. var _pdf_page_view = __webpack_require__(32);
  8110. var _pdf_link_service = __webpack_require__(23);
  8111. var _text_layer_builder = __webpack_require__(33);
  8112. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8113. var DEFAULT_CACHE_SIZE = 10;
  8114. var ScrollMode = {
  8115. VERTICAL: 0,
  8116. HORIZONTAL: 1,
  8117. WRAPPED: 2
  8118. };
  8119. var SpreadMode = {
  8120. NONE: 0,
  8121. ODD: 1,
  8122. EVEN: 2
  8123. };
  8124. function PDFPageViewBuffer(size) {
  8125. var data = [];
  8126. this.push = function (view) {
  8127. var i = data.indexOf(view);
  8128. if (i >= 0) {
  8129. data.splice(i, 1);
  8130. }
  8131. data.push(view);
  8132. if (data.length > size) {
  8133. data.shift().destroy();
  8134. }
  8135. };
  8136. this.resize = function (newSize, pagesToKeep) {
  8137. size = newSize;
  8138. if (pagesToKeep) {
  8139. var pageIdsToKeep = new Set();
  8140. for (var i = 0, iMax = pagesToKeep.length; i < iMax; ++i) {
  8141. pageIdsToKeep.add(pagesToKeep[i].id);
  8142. }
  8143. (0, _ui_utils.moveToEndOfArray)(data, function (page) {
  8144. return pageIdsToKeep.has(page.id);
  8145. });
  8146. }
  8147. while (data.length > size) {
  8148. data.shift().destroy();
  8149. }
  8150. };
  8151. }
  8152. function isSameScale(oldScale, newScale) {
  8153. if (newScale === oldScale) {
  8154. return true;
  8155. }
  8156. if (Math.abs(newScale - oldScale) < 1e-15) {
  8157. return true;
  8158. }
  8159. return false;
  8160. }
  8161. var BaseViewer = function () {
  8162. function BaseViewer(options) {
  8163. var _this = this;
  8164. _classCallCheck(this, BaseViewer);
  8165. if (this.constructor === BaseViewer) {
  8166. throw new Error('Cannot initialize BaseViewer.');
  8167. }
  8168. this._name = this.constructor.name;
  8169. this.container = options.container;
  8170. this.viewer = options.viewer || options.container.firstElementChild;
  8171. this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)();
  8172. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  8173. this.downloadManager = options.downloadManager || null;
  8174. this.findController = options.findController || null;
  8175. this.removePageBorders = options.removePageBorders || false;
  8176. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  8177. this.imageResourcesPath = options.imageResourcesPath || '';
  8178. this.renderInteractiveForms = options.renderInteractiveForms || false;
  8179. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  8180. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  8181. this.enableWebGL = options.enableWebGL || false;
  8182. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  8183. this.maxCanvasPixels = options.maxCanvasPixels;
  8184. this.l10n = options.l10n || _ui_utils.NullL10n;
  8185. this.defaultRenderingQueue = !options.renderingQueue;
  8186. if (this.defaultRenderingQueue) {
  8187. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  8188. this.renderingQueue.setViewer(this);
  8189. } else {
  8190. this.renderingQueue = options.renderingQueue;
  8191. }
  8192. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  8193. this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
  8194. this._resetView();
  8195. if (this.removePageBorders) {
  8196. this.viewer.classList.add('removePageBorders');
  8197. }
  8198. Promise.resolve().then(function () {
  8199. _this.eventBus.dispatch('baseviewerinit', { source: _this });
  8200. });
  8201. }
  8202. _createClass(BaseViewer, [{
  8203. key: 'getPageView',
  8204. value: function getPageView(index) {
  8205. return this._pages[index];
  8206. }
  8207. }, {
  8208. key: '_setCurrentPageNumber',
  8209. value: function _setCurrentPageNumber(val) {
  8210. var resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  8211. if (this._currentPageNumber === val) {
  8212. if (resetCurrentPageView) {
  8213. this._resetCurrentPageView();
  8214. }
  8215. return;
  8216. }
  8217. if (!(0 < val && val <= this.pagesCount)) {
  8218. console.error(this._name + '._setCurrentPageNumber: "' + val + '" is out of bounds.');
  8219. return;
  8220. }
  8221. var arg = {
  8222. source: this,
  8223. pageNumber: val,
  8224. pageLabel: this._pageLabels && this._pageLabels[val - 1]
  8225. };
  8226. this._currentPageNumber = val;
  8227. this.eventBus.dispatch('pagechanging', arg);
  8228. this.eventBus.dispatch('pagechange', arg);
  8229. if (resetCurrentPageView) {
  8230. this._resetCurrentPageView();
  8231. }
  8232. }
  8233. }, {
  8234. key: 'setDocument',
  8235. value: function setDocument(pdfDocument) {
  8236. var _this2 = this;
  8237. if (this.pdfDocument) {
  8238. this._cancelRendering();
  8239. this._resetView();
  8240. if (this.findController) {
  8241. this.findController.setDocument(null);
  8242. }
  8243. }
  8244. this.pdfDocument = pdfDocument;
  8245. if (!pdfDocument) {
  8246. return;
  8247. }
  8248. var pagesCount = pdfDocument.numPages;
  8249. var pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
  8250. this.pagesPromise = pagesCapability.promise;
  8251. pagesCapability.promise.then(function () {
  8252. _this2._pageViewsReady = true;
  8253. _this2.eventBus.dispatch('pagesloaded', {
  8254. source: _this2,
  8255. pagesCount: pagesCount
  8256. });
  8257. });
  8258. var isOnePageRenderedResolved = false;
  8259. var onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  8260. this.onePageRendered = onePageRenderedCapability.promise;
  8261. var bindOnAfterAndBeforeDraw = function bindOnAfterAndBeforeDraw(pageView) {
  8262. pageView.onBeforeDraw = function () {
  8263. _this2._buffer.push(pageView);
  8264. };
  8265. pageView.onAfterDraw = function () {
  8266. if (!isOnePageRenderedResolved) {
  8267. isOnePageRenderedResolved = true;
  8268. onePageRenderedCapability.resolve();
  8269. }
  8270. };
  8271. };
  8272. var firstPagePromise = pdfDocument.getPage(1);
  8273. this.firstPagePromise = firstPagePromise;
  8274. firstPagePromise.then(function (pdfPage) {
  8275. var scale = _this2.currentScale;
  8276. var viewport = pdfPage.getViewport(scale * _ui_utils.CSS_UNITS);
  8277. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  8278. var textLayerFactory = null;
  8279. if (_this2.textLayerMode !== _ui_utils.TextLayerMode.DISABLE) {
  8280. textLayerFactory = _this2;
  8281. }
  8282. var pageView = new _pdf_page_view.PDFPageView({
  8283. container: _this2._setDocumentViewerElement,
  8284. eventBus: _this2.eventBus,
  8285. id: pageNum,
  8286. scale: scale,
  8287. defaultViewport: viewport.clone(),
  8288. renderingQueue: _this2.renderingQueue,
  8289. textLayerFactory: textLayerFactory,
  8290. textLayerMode: _this2.textLayerMode,
  8291. annotationLayerFactory: _this2,
  8292. imageResourcesPath: _this2.imageResourcesPath,
  8293. renderInteractiveForms: _this2.renderInteractiveForms,
  8294. renderer: _this2.renderer,
  8295. enableWebGL: _this2.enableWebGL,
  8296. useOnlyCssZoom: _this2.useOnlyCssZoom,
  8297. maxCanvasPixels: _this2.maxCanvasPixels,
  8298. l10n: _this2.l10n
  8299. });
  8300. bindOnAfterAndBeforeDraw(pageView);
  8301. _this2._pages.push(pageView);
  8302. }
  8303. if (_this2._spreadMode !== SpreadMode.NONE) {
  8304. _this2._updateSpreadMode();
  8305. }
  8306. onePageRenderedCapability.promise.then(function () {
  8307. if (pdfDocument.loadingParams['disableAutoFetch']) {
  8308. pagesCapability.resolve();
  8309. return;
  8310. }
  8311. var getPagesLeft = pagesCount;
  8312. var _loop = function _loop(_pageNum) {
  8313. pdfDocument.getPage(_pageNum).then(function (pdfPage) {
  8314. var pageView = _this2._pages[_pageNum - 1];
  8315. if (!pageView.pdfPage) {
  8316. pageView.setPdfPage(pdfPage);
  8317. }
  8318. _this2.linkService.cachePageRef(_pageNum, pdfPage.ref);
  8319. if (--getPagesLeft === 0) {
  8320. pagesCapability.resolve();
  8321. }
  8322. }, function (reason) {
  8323. console.error('Unable to get page ' + _pageNum + ' to initialize viewer', reason);
  8324. if (--getPagesLeft === 0) {
  8325. pagesCapability.resolve();
  8326. }
  8327. });
  8328. };
  8329. for (var _pageNum = 1; _pageNum <= pagesCount; ++_pageNum) {
  8330. _loop(_pageNum);
  8331. }
  8332. });
  8333. _this2.eventBus.dispatch('pagesinit', { source: _this2 });
  8334. if (_this2.findController) {
  8335. _this2.findController.setDocument(pdfDocument);
  8336. }
  8337. if (_this2.defaultRenderingQueue) {
  8338. _this2.update();
  8339. }
  8340. }).catch(function (reason) {
  8341. console.error('Unable to initialize viewer', reason);
  8342. });
  8343. }
  8344. }, {
  8345. key: 'setPageLabels',
  8346. value: function setPageLabels(labels) {
  8347. if (!this.pdfDocument) {
  8348. return;
  8349. }
  8350. if (!labels) {
  8351. this._pageLabels = null;
  8352. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  8353. this._pageLabels = null;
  8354. console.error(this._name + '.setPageLabels: Invalid page labels.');
  8355. } else {
  8356. this._pageLabels = labels;
  8357. }
  8358. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  8359. var pageView = this._pages[i];
  8360. var label = this._pageLabels && this._pageLabels[i];
  8361. pageView.setPageLabel(label);
  8362. }
  8363. }
  8364. }, {
  8365. key: '_resetView',
  8366. value: function _resetView() {
  8367. this._pages = [];
  8368. this._currentPageNumber = 1;
  8369. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  8370. this._currentScaleValue = null;
  8371. this._pageLabels = null;
  8372. this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  8373. this._location = null;
  8374. this._pagesRotation = 0;
  8375. this._pagesRequests = [];
  8376. this._pageViewsReady = false;
  8377. this._scrollMode = ScrollMode.VERTICAL;
  8378. this._spreadMode = SpreadMode.NONE;
  8379. this.viewer.textContent = '';
  8380. this._updateScrollMode();
  8381. }
  8382. }, {
  8383. key: '_scrollUpdate',
  8384. value: function _scrollUpdate() {
  8385. if (this.pagesCount === 0) {
  8386. return;
  8387. }
  8388. this.update();
  8389. }
  8390. }, {
  8391. key: '_scrollIntoView',
  8392. value: function _scrollIntoView(_ref) {
  8393. var pageDiv = _ref.pageDiv,
  8394. _ref$pageSpot = _ref.pageSpot,
  8395. pageSpot = _ref$pageSpot === undefined ? null : _ref$pageSpot,
  8396. _ref$pageNumber = _ref.pageNumber,
  8397. pageNumber = _ref$pageNumber === undefined ? null : _ref$pageNumber;
  8398. throw new Error('Not implemented: _scrollIntoView');
  8399. }
  8400. }, {
  8401. key: '_setScaleDispatchEvent',
  8402. value: function _setScaleDispatchEvent(newScale, newValue) {
  8403. var preset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  8404. var arg = {
  8405. source: this,
  8406. scale: newScale,
  8407. presetValue: preset ? newValue : undefined
  8408. };
  8409. this.eventBus.dispatch('scalechanging', arg);
  8410. this.eventBus.dispatch('scalechange', arg);
  8411. }
  8412. }, {
  8413. key: '_setScaleUpdatePages',
  8414. value: function _setScaleUpdatePages(newScale, newValue) {
  8415. var noScroll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  8416. var preset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  8417. this._currentScaleValue = newValue.toString();
  8418. if (isSameScale(this._currentScale, newScale)) {
  8419. if (preset) {
  8420. this._setScaleDispatchEvent(newScale, newValue, true);
  8421. }
  8422. return;
  8423. }
  8424. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  8425. this._pages[i].update(newScale);
  8426. }
  8427. this._currentScale = newScale;
  8428. if (!noScroll) {
  8429. var page = this._currentPageNumber,
  8430. dest = void 0;
  8431. if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  8432. page = this._location.pageNumber;
  8433. dest = [null, { name: 'XYZ' }, this._location.left, this._location.top, null];
  8434. }
  8435. this.scrollPageIntoView({
  8436. pageNumber: page,
  8437. destArray: dest,
  8438. allowNegativeOffset: true
  8439. });
  8440. }
  8441. this._setScaleDispatchEvent(newScale, newValue, preset);
  8442. if (this.defaultRenderingQueue) {
  8443. this.update();
  8444. }
  8445. }
  8446. }, {
  8447. key: '_setScale',
  8448. value: function _setScale(value) {
  8449. var noScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  8450. var scale = parseFloat(value);
  8451. if (scale > 0) {
  8452. this._setScaleUpdatePages(scale, value, noScroll, false);
  8453. } else {
  8454. var currentPage = this._pages[this._currentPageNumber - 1];
  8455. if (!currentPage) {
  8456. return;
  8457. }
  8458. var noPadding = this.isInPresentationMode || this.removePageBorders;
  8459. var hPadding = noPadding ? 0 : _ui_utils.SCROLLBAR_PADDING;
  8460. var vPadding = noPadding ? 0 : _ui_utils.VERTICAL_PADDING;
  8461. if (!noPadding && this._isScrollModeHorizontal) {
  8462. var _ref2 = [vPadding, hPadding];
  8463. hPadding = _ref2[0];
  8464. vPadding = _ref2[1];
  8465. }
  8466. var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale;
  8467. var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  8468. switch (value) {
  8469. case 'page-actual':
  8470. scale = 1;
  8471. break;
  8472. case 'page-width':
  8473. scale = pageWidthScale;
  8474. break;
  8475. case 'page-height':
  8476. scale = pageHeightScale;
  8477. break;
  8478. case 'page-fit':
  8479. scale = Math.min(pageWidthScale, pageHeightScale);
  8480. break;
  8481. case 'auto':
  8482. var horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
  8483. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  8484. break;
  8485. default:
  8486. console.error(this._name + '._setScale: "' + value + '" is an unknown zoom value.');
  8487. return;
  8488. }
  8489. this._setScaleUpdatePages(scale, value, noScroll, true);
  8490. }
  8491. }
  8492. }, {
  8493. key: '_resetCurrentPageView',
  8494. value: function _resetCurrentPageView() {
  8495. if (this.isInPresentationMode) {
  8496. this._setScale(this._currentScaleValue, true);
  8497. }
  8498. var pageView = this._pages[this._currentPageNumber - 1];
  8499. this._scrollIntoView({ pageDiv: pageView.div });
  8500. }
  8501. }, {
  8502. key: 'scrollPageIntoView',
  8503. value: function scrollPageIntoView(params) {
  8504. if (!this.pdfDocument) {
  8505. return;
  8506. }
  8507. var pageNumber = params.pageNumber || 0;
  8508. var dest = params.destArray || null;
  8509. var allowNegativeOffset = params.allowNegativeOffset || false;
  8510. if (this.isInPresentationMode || !dest) {
  8511. this._setCurrentPageNumber(pageNumber, true);
  8512. return;
  8513. }
  8514. var pageView = this._pages[pageNumber - 1];
  8515. if (!pageView) {
  8516. console.error(this._name + '.scrollPageIntoView: Invalid "pageNumber" parameter.');
  8517. return;
  8518. }
  8519. var x = 0,
  8520. y = 0;
  8521. var width = 0,
  8522. height = 0,
  8523. widthScale = void 0,
  8524. heightScale = void 0;
  8525. var changeOrientation = pageView.rotation % 180 === 0 ? false : true;
  8526. var pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;
  8527. var pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;
  8528. var scale = 0;
  8529. switch (dest[1].name) {
  8530. case 'XYZ':
  8531. x = dest[2];
  8532. y = dest[3];
  8533. scale = dest[4];
  8534. x = x !== null ? x : 0;
  8535. y = y !== null ? y : pageHeight;
  8536. break;
  8537. case 'Fit':
  8538. case 'FitB':
  8539. scale = 'page-fit';
  8540. break;
  8541. case 'FitH':
  8542. case 'FitBH':
  8543. y = dest[2];
  8544. scale = 'page-width';
  8545. if (y === null && this._location) {
  8546. x = this._location.left;
  8547. y = this._location.top;
  8548. }
  8549. break;
  8550. case 'FitV':
  8551. case 'FitBV':
  8552. x = dest[2];
  8553. width = pageWidth;
  8554. height = pageHeight;
  8555. scale = 'page-height';
  8556. break;
  8557. case 'FitR':
  8558. x = dest[2];
  8559. y = dest[3];
  8560. width = dest[4] - x;
  8561. height = dest[5] - y;
  8562. var hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  8563. var vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  8564. widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;
  8565. heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;
  8566. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  8567. break;
  8568. default:
  8569. console.error(this._name + '.scrollPageIntoView: "' + dest[1].name + '" ' + 'is not a valid destination type.');
  8570. return;
  8571. }
  8572. if (scale && scale !== this._currentScale) {
  8573. this.currentScaleValue = scale;
  8574. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  8575. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  8576. }
  8577. if (scale === 'page-fit' && !dest[4]) {
  8578. this._scrollIntoView({
  8579. pageDiv: pageView.div,
  8580. pageNumber: pageNumber
  8581. });
  8582. return;
  8583. }
  8584. var boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  8585. var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  8586. var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  8587. if (!allowNegativeOffset) {
  8588. left = Math.max(left, 0);
  8589. top = Math.max(top, 0);
  8590. }
  8591. this._scrollIntoView({
  8592. pageDiv: pageView.div,
  8593. pageSpot: {
  8594. left: left,
  8595. top: top
  8596. },
  8597. pageNumber: pageNumber
  8598. });
  8599. }
  8600. }, {
  8601. key: '_resizeBuffer',
  8602. value: function _resizeBuffer(numVisiblePages, visiblePages) {
  8603. var suggestedCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
  8604. this._buffer.resize(suggestedCacheSize, visiblePages);
  8605. }
  8606. }, {
  8607. key: '_updateLocation',
  8608. value: function _updateLocation(firstPage) {
  8609. var currentScale = this._currentScale;
  8610. var currentScaleValue = this._currentScaleValue;
  8611. var normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  8612. var pageNumber = firstPage.id;
  8613. var pdfOpenParams = '#page=' + pageNumber;
  8614. pdfOpenParams += '&zoom=' + normalizedScaleValue;
  8615. var currentPageView = this._pages[pageNumber - 1];
  8616. var container = this.container;
  8617. var topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  8618. var intLeft = Math.round(topLeft[0]);
  8619. var intTop = Math.round(topLeft[1]);
  8620. pdfOpenParams += ',' + intLeft + ',' + intTop;
  8621. this._location = {
  8622. pageNumber: pageNumber,
  8623. scale: normalizedScaleValue,
  8624. top: intTop,
  8625. left: intLeft,
  8626. rotation: this._pagesRotation,
  8627. pdfOpenParams: pdfOpenParams
  8628. };
  8629. }
  8630. }, {
  8631. key: 'update',
  8632. value: function update() {
  8633. throw new Error('Not implemented: update');
  8634. }
  8635. }, {
  8636. key: 'containsElement',
  8637. value: function containsElement(element) {
  8638. return this.container.contains(element);
  8639. }
  8640. }, {
  8641. key: 'focus',
  8642. value: function focus() {
  8643. this.container.focus();
  8644. }
  8645. }, {
  8646. key: '_getVisiblePages',
  8647. value: function _getVisiblePages() {
  8648. throw new Error('Not implemented: _getVisiblePages');
  8649. }
  8650. }, {
  8651. key: 'cleanup',
  8652. value: function cleanup() {
  8653. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  8654. if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  8655. this._pages[i].reset();
  8656. }
  8657. }
  8658. }
  8659. }, {
  8660. key: '_cancelRendering',
  8661. value: function _cancelRendering() {
  8662. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  8663. if (this._pages[i]) {
  8664. this._pages[i].cancelRendering();
  8665. }
  8666. }
  8667. }
  8668. }, {
  8669. key: '_ensurePdfPageLoaded',
  8670. value: function _ensurePdfPageLoaded(pageView) {
  8671. var _this3 = this;
  8672. if (pageView.pdfPage) {
  8673. return Promise.resolve(pageView.pdfPage);
  8674. }
  8675. var pageNumber = pageView.id;
  8676. if (this._pagesRequests[pageNumber]) {
  8677. return this._pagesRequests[pageNumber];
  8678. }
  8679. var promise = this.pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  8680. if (!pageView.pdfPage) {
  8681. pageView.setPdfPage(pdfPage);
  8682. }
  8683. _this3._pagesRequests[pageNumber] = null;
  8684. return pdfPage;
  8685. }).catch(function (reason) {
  8686. console.error('Unable to get page for page view', reason);
  8687. _this3._pagesRequests[pageNumber] = null;
  8688. });
  8689. this._pagesRequests[pageNumber] = promise;
  8690. return promise;
  8691. }
  8692. }, {
  8693. key: 'forceRendering',
  8694. value: function forceRendering(currentlyVisiblePages) {
  8695. var _this4 = this;
  8696. var visiblePages = currentlyVisiblePages || this._getVisiblePages();
  8697. var scrollAhead = this._isScrollModeHorizontal ? this.scroll.right : this.scroll.down;
  8698. var pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead);
  8699. if (pageView) {
  8700. this._ensurePdfPageLoaded(pageView).then(function () {
  8701. _this4.renderingQueue.renderView(pageView);
  8702. });
  8703. return true;
  8704. }
  8705. return false;
  8706. }
  8707. }, {
  8708. key: 'createTextLayerBuilder',
  8709. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  8710. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  8711. return new _text_layer_builder.TextLayerBuilder({
  8712. textLayerDiv: textLayerDiv,
  8713. eventBus: this.eventBus,
  8714. pageIndex: pageIndex,
  8715. viewport: viewport,
  8716. findController: this.isInPresentationMode ? null : this.findController,
  8717. enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection
  8718. });
  8719. }
  8720. }, {
  8721. key: 'createAnnotationLayerBuilder',
  8722. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  8723. var imageResourcesPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  8724. var renderInteractiveForms = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  8725. var l10n = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _ui_utils.NullL10n;
  8726. return new _annotation_layer_builder.AnnotationLayerBuilder({
  8727. pageDiv: pageDiv,
  8728. pdfPage: pdfPage,
  8729. imageResourcesPath: imageResourcesPath,
  8730. renderInteractiveForms: renderInteractiveForms,
  8731. linkService: this.linkService,
  8732. downloadManager: this.downloadManager,
  8733. l10n: l10n
  8734. });
  8735. }
  8736. }, {
  8737. key: 'getPagesOverview',
  8738. value: function getPagesOverview() {
  8739. var pagesOverview = this._pages.map(function (pageView) {
  8740. var viewport = pageView.pdfPage.getViewport(1);
  8741. return {
  8742. width: viewport.width,
  8743. height: viewport.height,
  8744. rotation: viewport.rotation
  8745. };
  8746. });
  8747. if (!this.enablePrintAutoRotate) {
  8748. return pagesOverview;
  8749. }
  8750. var isFirstPagePortrait = (0, _ui_utils.isPortraitOrientation)(pagesOverview[0]);
  8751. return pagesOverview.map(function (size) {
  8752. if (isFirstPagePortrait === (0, _ui_utils.isPortraitOrientation)(size)) {
  8753. return size;
  8754. }
  8755. return {
  8756. width: size.height,
  8757. height: size.width,
  8758. rotation: (size.rotation + 90) % 360
  8759. };
  8760. });
  8761. }
  8762. }, {
  8763. key: '_updateScrollMode',
  8764. value: function _updateScrollMode() {
  8765. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  8766. var scrollMode = this._scrollMode,
  8767. viewer = this.viewer;
  8768. viewer.classList.toggle('scrollHorizontal', scrollMode === ScrollMode.HORIZONTAL);
  8769. viewer.classList.toggle('scrollWrapped', scrollMode === ScrollMode.WRAPPED);
  8770. if (!this.pdfDocument || !pageNumber) {
  8771. return;
  8772. }
  8773. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  8774. this._setScale(this._currentScaleValue, true);
  8775. }
  8776. this.scrollPageIntoView({ pageNumber: pageNumber });
  8777. this.update();
  8778. }
  8779. }, {
  8780. key: '_updateSpreadMode',
  8781. value: function _updateSpreadMode() {
  8782. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  8783. if (!this.pdfDocument) {
  8784. return;
  8785. }
  8786. var viewer = this.viewer,
  8787. pages = this._pages;
  8788. viewer.textContent = '';
  8789. if (this._spreadMode === SpreadMode.NONE) {
  8790. for (var i = 0, iMax = pages.length; i < iMax; ++i) {
  8791. viewer.appendChild(pages[i].div);
  8792. }
  8793. } else {
  8794. var parity = this._spreadMode - 1;
  8795. var spread = null;
  8796. for (var _i = 0, _iMax = pages.length; _i < _iMax; ++_i) {
  8797. if (spread === null) {
  8798. spread = document.createElement('div');
  8799. spread.className = 'spread';
  8800. viewer.appendChild(spread);
  8801. } else if (_i % 2 === parity) {
  8802. spread = spread.cloneNode(false);
  8803. viewer.appendChild(spread);
  8804. }
  8805. spread.appendChild(pages[_i].div);
  8806. }
  8807. }
  8808. if (!pageNumber) {
  8809. return;
  8810. }
  8811. this.scrollPageIntoView({ pageNumber: pageNumber });
  8812. this.update();
  8813. }
  8814. }, {
  8815. key: 'pagesCount',
  8816. get: function get() {
  8817. return this._pages.length;
  8818. }
  8819. }, {
  8820. key: 'pageViewsReady',
  8821. get: function get() {
  8822. return this._pageViewsReady;
  8823. }
  8824. }, {
  8825. key: 'currentPageNumber',
  8826. get: function get() {
  8827. return this._currentPageNumber;
  8828. },
  8829. set: function set(val) {
  8830. if (!Number.isInteger(val)) {
  8831. throw new Error('Invalid page number.');
  8832. }
  8833. if (!this.pdfDocument) {
  8834. return;
  8835. }
  8836. this._setCurrentPageNumber(val, true);
  8837. }
  8838. }, {
  8839. key: 'currentPageLabel',
  8840. get: function get() {
  8841. return this._pageLabels && this._pageLabels[this._currentPageNumber - 1];
  8842. },
  8843. set: function set(val) {
  8844. var pageNumber = val | 0;
  8845. if (this._pageLabels) {
  8846. var i = this._pageLabels.indexOf(val);
  8847. if (i >= 0) {
  8848. pageNumber = i + 1;
  8849. }
  8850. }
  8851. this.currentPageNumber = pageNumber;
  8852. }
  8853. }, {
  8854. key: 'currentScale',
  8855. get: function get() {
  8856. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
  8857. },
  8858. set: function set(val) {
  8859. if (isNaN(val)) {
  8860. throw new Error('Invalid numeric scale');
  8861. }
  8862. if (!this.pdfDocument) {
  8863. return;
  8864. }
  8865. this._setScale(val, false);
  8866. }
  8867. }, {
  8868. key: 'currentScaleValue',
  8869. get: function get() {
  8870. return this._currentScaleValue;
  8871. },
  8872. set: function set(val) {
  8873. if (!this.pdfDocument) {
  8874. return;
  8875. }
  8876. this._setScale(val, false);
  8877. }
  8878. }, {
  8879. key: 'pagesRotation',
  8880. get: function get() {
  8881. return this._pagesRotation;
  8882. },
  8883. set: function set(rotation) {
  8884. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  8885. throw new Error('Invalid pages rotation angle.');
  8886. }
  8887. if (!this.pdfDocument) {
  8888. return;
  8889. }
  8890. if (this._pagesRotation === rotation) {
  8891. return;
  8892. }
  8893. this._pagesRotation = rotation;
  8894. var pageNumber = this._currentPageNumber;
  8895. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  8896. var pageView = this._pages[i];
  8897. pageView.update(pageView.scale, rotation);
  8898. }
  8899. if (this._currentScaleValue) {
  8900. this._setScale(this._currentScaleValue, true);
  8901. }
  8902. this.eventBus.dispatch('rotationchanging', {
  8903. source: this,
  8904. pagesRotation: rotation,
  8905. pageNumber: pageNumber
  8906. });
  8907. if (this.defaultRenderingQueue) {
  8908. this.update();
  8909. }
  8910. }
  8911. }, {
  8912. key: '_setDocumentViewerElement',
  8913. get: function get() {
  8914. throw new Error('Not implemented: _setDocumentViewerElement');
  8915. }
  8916. }, {
  8917. key: '_isScrollModeHorizontal',
  8918. get: function get() {
  8919. throw new Error('Not implemented: _isScrollModeHorizontal');
  8920. }
  8921. }, {
  8922. key: 'isInPresentationMode',
  8923. get: function get() {
  8924. return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
  8925. }
  8926. }, {
  8927. key: 'isChangingPresentationMode',
  8928. get: function get() {
  8929. return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
  8930. }
  8931. }, {
  8932. key: 'isHorizontalScrollbarEnabled',
  8933. get: function get() {
  8934. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  8935. }
  8936. }, {
  8937. key: 'isVerticalScrollbarEnabled',
  8938. get: function get() {
  8939. return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight;
  8940. }
  8941. }, {
  8942. key: 'hasEqualPageSizes',
  8943. get: function get() {
  8944. var firstPageView = this._pages[0];
  8945. for (var i = 1, ii = this._pages.length; i < ii; ++i) {
  8946. var pageView = this._pages[i];
  8947. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  8948. return false;
  8949. }
  8950. }
  8951. return true;
  8952. }
  8953. }, {
  8954. key: 'scrollMode',
  8955. get: function get() {
  8956. return this._scrollMode;
  8957. },
  8958. set: function set(mode) {
  8959. if (this._scrollMode === mode) {
  8960. return;
  8961. }
  8962. if (!Number.isInteger(mode) || !Object.values(ScrollMode).includes(mode)) {
  8963. throw new Error('Invalid scroll mode: ' + mode);
  8964. }
  8965. this._scrollMode = mode;
  8966. this.eventBus.dispatch('scrollmodechanged', {
  8967. source: this,
  8968. mode: mode
  8969. });
  8970. this._updateScrollMode(this._currentPageNumber);
  8971. }
  8972. }, {
  8973. key: 'spreadMode',
  8974. get: function get() {
  8975. return this._spreadMode;
  8976. },
  8977. set: function set(mode) {
  8978. if (this._spreadMode === mode) {
  8979. return;
  8980. }
  8981. if (!Number.isInteger(mode) || !Object.values(SpreadMode).includes(mode)) {
  8982. throw new Error('Invalid spread mode: ' + mode);
  8983. }
  8984. this._spreadMode = mode;
  8985. this.eventBus.dispatch('spreadmodechanged', {
  8986. source: this,
  8987. mode: mode
  8988. });
  8989. this._updateSpreadMode(this._currentPageNumber);
  8990. }
  8991. }]);
  8992. return BaseViewer;
  8993. }();
  8994. exports.BaseViewer = BaseViewer;
  8995. exports.ScrollMode = ScrollMode;
  8996. exports.SpreadMode = SpreadMode;
  8997. /***/ }),
  8998. /* 31 */
  8999. /***/ (function(module, exports, __webpack_require__) {
  9000. "use strict";
  9001. Object.defineProperty(exports, "__esModule", {
  9002. value: true
  9003. });
  9004. exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = undefined;
  9005. 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; }; }();
  9006. var _pdfjsLib = __webpack_require__(7);
  9007. var _ui_utils = __webpack_require__(6);
  9008. var _pdf_link_service = __webpack_require__(23);
  9009. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9010. var AnnotationLayerBuilder = function () {
  9011. function AnnotationLayerBuilder(_ref) {
  9012. var pageDiv = _ref.pageDiv,
  9013. pdfPage = _ref.pdfPage,
  9014. linkService = _ref.linkService,
  9015. downloadManager = _ref.downloadManager,
  9016. _ref$imageResourcesPa = _ref.imageResourcesPath,
  9017. imageResourcesPath = _ref$imageResourcesPa === undefined ? '' : _ref$imageResourcesPa,
  9018. _ref$renderInteractiv = _ref.renderInteractiveForms,
  9019. renderInteractiveForms = _ref$renderInteractiv === undefined ? false : _ref$renderInteractiv,
  9020. _ref$l10n = _ref.l10n,
  9021. l10n = _ref$l10n === undefined ? _ui_utils.NullL10n : _ref$l10n;
  9022. _classCallCheck(this, AnnotationLayerBuilder);
  9023. this.pageDiv = pageDiv;
  9024. this.pdfPage = pdfPage;
  9025. this.linkService = linkService;
  9026. this.downloadManager = downloadManager;
  9027. this.imageResourcesPath = imageResourcesPath;
  9028. this.renderInteractiveForms = renderInteractiveForms;
  9029. this.l10n = l10n;
  9030. this.div = null;
  9031. this._cancelled = false;
  9032. }
  9033. _createClass(AnnotationLayerBuilder, [{
  9034. key: 'render',
  9035. value: function render(viewport) {
  9036. var _this = this;
  9037. var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'display';
  9038. this.pdfPage.getAnnotations({ intent: intent }).then(function (annotations) {
  9039. if (_this._cancelled) {
  9040. return;
  9041. }
  9042. var parameters = {
  9043. viewport: viewport.clone({ dontFlip: true }),
  9044. div: _this.div,
  9045. annotations: annotations,
  9046. page: _this.pdfPage,
  9047. imageResourcesPath: _this.imageResourcesPath,
  9048. renderInteractiveForms: _this.renderInteractiveForms,
  9049. linkService: _this.linkService,
  9050. downloadManager: _this.downloadManager
  9051. };
  9052. if (_this.div) {
  9053. _pdfjsLib.AnnotationLayer.update(parameters);
  9054. } else {
  9055. if (annotations.length === 0) {
  9056. return;
  9057. }
  9058. _this.div = document.createElement('div');
  9059. _this.div.className = 'annotationLayer';
  9060. _this.pageDiv.appendChild(_this.div);
  9061. parameters.div = _this.div;
  9062. _pdfjsLib.AnnotationLayer.render(parameters);
  9063. _this.l10n.translate(_this.div);
  9064. }
  9065. });
  9066. }
  9067. }, {
  9068. key: 'cancel',
  9069. value: function cancel() {
  9070. this._cancelled = true;
  9071. }
  9072. }, {
  9073. key: 'hide',
  9074. value: function hide() {
  9075. if (!this.div) {
  9076. return;
  9077. }
  9078. this.div.setAttribute('hidden', 'true');
  9079. }
  9080. }]);
  9081. return AnnotationLayerBuilder;
  9082. }();
  9083. var DefaultAnnotationLayerFactory = function () {
  9084. function DefaultAnnotationLayerFactory() {
  9085. _classCallCheck(this, DefaultAnnotationLayerFactory);
  9086. }
  9087. _createClass(DefaultAnnotationLayerFactory, [{
  9088. key: 'createAnnotationLayerBuilder',
  9089. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  9090. var imageResourcesPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  9091. var renderInteractiveForms = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9092. var l10n = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _ui_utils.NullL10n;
  9093. return new AnnotationLayerBuilder({
  9094. pageDiv: pageDiv,
  9095. pdfPage: pdfPage,
  9096. imageResourcesPath: imageResourcesPath,
  9097. renderInteractiveForms: renderInteractiveForms,
  9098. linkService: new _pdf_link_service.SimpleLinkService(),
  9099. l10n: l10n
  9100. });
  9101. }
  9102. }]);
  9103. return DefaultAnnotationLayerFactory;
  9104. }();
  9105. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  9106. exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
  9107. /***/ }),
  9108. /* 32 */
  9109. /***/ (function(module, exports, __webpack_require__) {
  9110. "use strict";
  9111. Object.defineProperty(exports, "__esModule", {
  9112. value: true
  9113. });
  9114. exports.PDFPageView = undefined;
  9115. 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; }; }();
  9116. var _ui_utils = __webpack_require__(6);
  9117. var _pdfjsLib = __webpack_require__(7);
  9118. var _dom_events = __webpack_require__(14);
  9119. var _pdf_rendering_queue = __webpack_require__(10);
  9120. var _viewer_compatibility = __webpack_require__(13);
  9121. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9122. var MAX_CANVAS_PIXELS = _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216;
  9123. var PDFPageView = function () {
  9124. function PDFPageView(options) {
  9125. _classCallCheck(this, PDFPageView);
  9126. var container = options.container;
  9127. var defaultViewport = options.defaultViewport;
  9128. this.id = options.id;
  9129. this.renderingId = 'page' + this.id;
  9130. this.pdfPage = null;
  9131. this.pageLabel = null;
  9132. this.rotation = 0;
  9133. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  9134. this.viewport = defaultViewport;
  9135. this.pdfPageRotate = defaultViewport.rotation;
  9136. this.hasRestrictedScaling = false;
  9137. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  9138. this.imageResourcesPath = options.imageResourcesPath || '';
  9139. this.renderInteractiveForms = options.renderInteractiveForms || false;
  9140. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  9141. this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
  9142. this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)();
  9143. this.renderingQueue = options.renderingQueue;
  9144. this.textLayerFactory = options.textLayerFactory;
  9145. this.annotationLayerFactory = options.annotationLayerFactory;
  9146. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  9147. this.enableWebGL = options.enableWebGL || false;
  9148. this.l10n = options.l10n || _ui_utils.NullL10n;
  9149. this.paintTask = null;
  9150. this.paintedViewportMap = new WeakMap();
  9151. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  9152. this.resume = null;
  9153. this.error = null;
  9154. this.onBeforeDraw = null;
  9155. this.onAfterDraw = null;
  9156. this.annotationLayer = null;
  9157. this.textLayer = null;
  9158. this.zoomLayer = null;
  9159. var div = document.createElement('div');
  9160. div.className = 'page';
  9161. div.style.width = Math.floor(this.viewport.width) + 'px';
  9162. div.style.height = Math.floor(this.viewport.height) + 'px';
  9163. div.setAttribute('data-page-number', this.id);
  9164. this.div = div;
  9165. container.appendChild(div);
  9166. }
  9167. _createClass(PDFPageView, [{
  9168. key: 'setPdfPage',
  9169. value: function setPdfPage(pdfPage) {
  9170. this.pdfPage = pdfPage;
  9171. this.pdfPageRotate = pdfPage.rotate;
  9172. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  9173. this.viewport = pdfPage.getViewport(this.scale * _ui_utils.CSS_UNITS, totalRotation);
  9174. this.stats = pdfPage.stats;
  9175. this.reset();
  9176. }
  9177. }, {
  9178. key: 'destroy',
  9179. value: function destroy() {
  9180. this.reset();
  9181. if (this.pdfPage) {
  9182. this.pdfPage.cleanup();
  9183. }
  9184. }
  9185. }, {
  9186. key: '_resetZoomLayer',
  9187. value: function _resetZoomLayer() {
  9188. var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9189. if (!this.zoomLayer) {
  9190. return;
  9191. }
  9192. var zoomLayerCanvas = this.zoomLayer.firstChild;
  9193. this.paintedViewportMap.delete(zoomLayerCanvas);
  9194. zoomLayerCanvas.width = 0;
  9195. zoomLayerCanvas.height = 0;
  9196. if (removeFromDOM) {
  9197. this.zoomLayer.remove();
  9198. }
  9199. this.zoomLayer = null;
  9200. }
  9201. }, {
  9202. key: 'reset',
  9203. value: function reset() {
  9204. var keepZoomLayer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9205. var keepAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9206. this.cancelRendering(keepAnnotations);
  9207. var div = this.div;
  9208. div.style.width = Math.floor(this.viewport.width) + 'px';
  9209. div.style.height = Math.floor(this.viewport.height) + 'px';
  9210. var childNodes = div.childNodes;
  9211. var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
  9212. var currentAnnotationNode = keepAnnotations && this.annotationLayer && this.annotationLayer.div || null;
  9213. for (var i = childNodes.length - 1; i >= 0; i--) {
  9214. var node = childNodes[i];
  9215. if (currentZoomLayerNode === node || currentAnnotationNode === node) {
  9216. continue;
  9217. }
  9218. div.removeChild(node);
  9219. }
  9220. div.removeAttribute('data-loaded');
  9221. if (currentAnnotationNode) {
  9222. this.annotationLayer.hide();
  9223. } else if (this.annotationLayer) {
  9224. this.annotationLayer.cancel();
  9225. this.annotationLayer = null;
  9226. }
  9227. if (!currentZoomLayerNode) {
  9228. if (this.canvas) {
  9229. this.paintedViewportMap.delete(this.canvas);
  9230. this.canvas.width = 0;
  9231. this.canvas.height = 0;
  9232. delete this.canvas;
  9233. }
  9234. this._resetZoomLayer();
  9235. }
  9236. if (this.svg) {
  9237. this.paintedViewportMap.delete(this.svg);
  9238. delete this.svg;
  9239. }
  9240. this.loadingIconDiv = document.createElement('div');
  9241. this.loadingIconDiv.className = 'loadingIcon';
  9242. div.appendChild(this.loadingIconDiv);
  9243. }
  9244. }, {
  9245. key: 'update',
  9246. value: function update(scale, rotation) {
  9247. this.scale = scale || this.scale;
  9248. if (typeof rotation !== 'undefined') {
  9249. this.rotation = rotation;
  9250. }
  9251. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  9252. this.viewport = this.viewport.clone({
  9253. scale: this.scale * _ui_utils.CSS_UNITS,
  9254. rotation: totalRotation
  9255. });
  9256. if (this.svg) {
  9257. this.cssTransform(this.svg, true);
  9258. this.eventBus.dispatch('pagerendered', {
  9259. source: this,
  9260. pageNumber: this.id,
  9261. cssTransform: true
  9262. });
  9263. return;
  9264. }
  9265. var isScalingRestricted = false;
  9266. if (this.canvas && this.maxCanvasPixels > 0) {
  9267. var outputScale = this.outputScale;
  9268. if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > this.maxCanvasPixels) {
  9269. isScalingRestricted = true;
  9270. }
  9271. }
  9272. if (this.canvas) {
  9273. if (this.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
  9274. this.cssTransform(this.canvas, true);
  9275. this.eventBus.dispatch('pagerendered', {
  9276. source: this,
  9277. pageNumber: this.id,
  9278. cssTransform: true
  9279. });
  9280. return;
  9281. }
  9282. if (!this.zoomLayer && !this.canvas.hasAttribute('hidden')) {
  9283. this.zoomLayer = this.canvas.parentNode;
  9284. this.zoomLayer.style.position = 'absolute';
  9285. }
  9286. }
  9287. if (this.zoomLayer) {
  9288. this.cssTransform(this.zoomLayer.firstChild);
  9289. }
  9290. this.reset(true, true);
  9291. }
  9292. }, {
  9293. key: 'cancelRendering',
  9294. value: function cancelRendering() {
  9295. var keepAnnotations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9296. var renderingState = this.renderingState;
  9297. if (this.paintTask) {
  9298. this.paintTask.cancel();
  9299. this.paintTask = null;
  9300. }
  9301. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  9302. this.resume = null;
  9303. if (this.textLayer) {
  9304. this.textLayer.cancel();
  9305. this.textLayer = null;
  9306. }
  9307. if (!keepAnnotations && this.annotationLayer) {
  9308. this.annotationLayer.cancel();
  9309. this.annotationLayer = null;
  9310. }
  9311. if (renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  9312. this.eventBus.dispatch('pagecancelled', {
  9313. source: this,
  9314. pageNumber: this.id,
  9315. renderingState: renderingState
  9316. });
  9317. }
  9318. }
  9319. }, {
  9320. key: 'cssTransform',
  9321. value: function cssTransform(target) {
  9322. var redrawAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9323. var width = this.viewport.width;
  9324. var height = this.viewport.height;
  9325. var div = this.div;
  9326. target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + 'px';
  9327. target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + 'px';
  9328. var relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
  9329. var absRotation = Math.abs(relativeRotation);
  9330. var scaleX = 1,
  9331. scaleY = 1;
  9332. if (absRotation === 90 || absRotation === 270) {
  9333. scaleX = height / width;
  9334. scaleY = width / height;
  9335. }
  9336. var cssTransform = 'rotate(' + relativeRotation + 'deg) ' + 'scale(' + scaleX + ',' + scaleY + ')';
  9337. target.style.transform = cssTransform;
  9338. if (this.textLayer) {
  9339. var textLayerViewport = this.textLayer.viewport;
  9340. var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
  9341. var textAbsRotation = Math.abs(textRelativeRotation);
  9342. var scale = width / textLayerViewport.width;
  9343. if (textAbsRotation === 90 || textAbsRotation === 270) {
  9344. scale = width / textLayerViewport.height;
  9345. }
  9346. var textLayerDiv = this.textLayer.textLayerDiv;
  9347. var transX = void 0,
  9348. transY = void 0;
  9349. switch (textAbsRotation) {
  9350. case 0:
  9351. transX = transY = 0;
  9352. break;
  9353. case 90:
  9354. transX = 0;
  9355. transY = '-' + textLayerDiv.style.height;
  9356. break;
  9357. case 180:
  9358. transX = '-' + textLayerDiv.style.width;
  9359. transY = '-' + textLayerDiv.style.height;
  9360. break;
  9361. case 270:
  9362. transX = '-' + textLayerDiv.style.width;
  9363. transY = 0;
  9364. break;
  9365. default:
  9366. console.error('Bad rotation value.');
  9367. break;
  9368. }
  9369. textLayerDiv.style.transform = 'rotate(' + textAbsRotation + 'deg) ' + 'scale(' + scale + ', ' + scale + ') ' + 'translate(' + transX + ', ' + transY + ')';
  9370. textLayerDiv.style.transformOrigin = '0% 0%';
  9371. }
  9372. if (redrawAnnotations && this.annotationLayer) {
  9373. this.annotationLayer.render(this.viewport, 'display');
  9374. }
  9375. }
  9376. }, {
  9377. key: 'getPagePoint',
  9378. value: function getPagePoint(x, y) {
  9379. return this.viewport.convertToPdfPoint(x, y);
  9380. }
  9381. }, {
  9382. key: 'draw',
  9383. value: function draw() {
  9384. var _this = this;
  9385. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  9386. console.error('Must be in new state before drawing');
  9387. this.reset();
  9388. }
  9389. if (!this.pdfPage) {
  9390. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  9391. return Promise.reject(new Error('Page is not loaded'));
  9392. }
  9393. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  9394. var pdfPage = this.pdfPage;
  9395. var div = this.div;
  9396. var canvasWrapper = document.createElement('div');
  9397. canvasWrapper.style.width = div.style.width;
  9398. canvasWrapper.style.height = div.style.height;
  9399. canvasWrapper.classList.add('canvasWrapper');
  9400. if (this.annotationLayer && this.annotationLayer.div) {
  9401. div.insertBefore(canvasWrapper, this.annotationLayer.div);
  9402. } else {
  9403. div.appendChild(canvasWrapper);
  9404. }
  9405. var textLayer = null;
  9406. if (this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && this.textLayerFactory) {
  9407. var textLayerDiv = document.createElement('div');
  9408. textLayerDiv.className = 'textLayer';
  9409. textLayerDiv.style.width = canvasWrapper.style.width;
  9410. textLayerDiv.style.height = canvasWrapper.style.height;
  9411. if (this.annotationLayer && this.annotationLayer.div) {
  9412. div.insertBefore(textLayerDiv, this.annotationLayer.div);
  9413. } else {
  9414. div.appendChild(textLayerDiv);
  9415. }
  9416. textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.textLayerMode === _ui_utils.TextLayerMode.ENABLE_ENHANCE);
  9417. }
  9418. this.textLayer = textLayer;
  9419. var renderContinueCallback = null;
  9420. if (this.renderingQueue) {
  9421. renderContinueCallback = function renderContinueCallback(cont) {
  9422. if (!_this.renderingQueue.isHighestPriority(_this)) {
  9423. _this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  9424. _this.resume = function () {
  9425. _this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  9426. cont();
  9427. };
  9428. return;
  9429. }
  9430. cont();
  9431. };
  9432. }
  9433. var finishPaintTask = function finishPaintTask(error) {
  9434. if (paintTask === _this.paintTask) {
  9435. _this.paintTask = null;
  9436. }
  9437. if (error instanceof _pdfjsLib.RenderingCancelledException) {
  9438. _this.error = null;
  9439. return Promise.resolve(undefined);
  9440. }
  9441. _this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  9442. if (_this.loadingIconDiv) {
  9443. div.removeChild(_this.loadingIconDiv);
  9444. delete _this.loadingIconDiv;
  9445. }
  9446. _this._resetZoomLayer(true);
  9447. _this.error = error;
  9448. _this.stats = pdfPage.stats;
  9449. if (_this.onAfterDraw) {
  9450. _this.onAfterDraw();
  9451. }
  9452. _this.eventBus.dispatch('pagerendered', {
  9453. source: _this,
  9454. pageNumber: _this.id,
  9455. cssTransform: false
  9456. });
  9457. if (error) {
  9458. return Promise.reject(error);
  9459. }
  9460. return Promise.resolve(undefined);
  9461. };
  9462. var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
  9463. paintTask.onRenderContinue = renderContinueCallback;
  9464. this.paintTask = paintTask;
  9465. var resultPromise = paintTask.promise.then(function () {
  9466. return finishPaintTask(null).then(function () {
  9467. if (textLayer) {
  9468. var readableStream = pdfPage.streamTextContent({ normalizeWhitespace: true });
  9469. textLayer.setTextContentStream(readableStream);
  9470. textLayer.render();
  9471. }
  9472. });
  9473. }, function (reason) {
  9474. return finishPaintTask(reason);
  9475. });
  9476. if (this.annotationLayerFactory) {
  9477. if (!this.annotationLayer) {
  9478. this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this.imageResourcesPath, this.renderInteractiveForms, this.l10n);
  9479. }
  9480. this.annotationLayer.render(this.viewport, 'display');
  9481. }
  9482. div.setAttribute('data-loaded', true);
  9483. if (this.onBeforeDraw) {
  9484. this.onBeforeDraw();
  9485. }
  9486. return resultPromise;
  9487. }
  9488. }, {
  9489. key: 'paintOnCanvas',
  9490. value: function paintOnCanvas(canvasWrapper) {
  9491. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  9492. var result = {
  9493. promise: renderCapability.promise,
  9494. onRenderContinue: function onRenderContinue(cont) {
  9495. cont();
  9496. },
  9497. cancel: function cancel() {
  9498. renderTask.cancel();
  9499. }
  9500. };
  9501. var viewport = this.viewport;
  9502. var canvas = document.createElement('canvas');
  9503. canvas.id = this.renderingId;
  9504. canvas.setAttribute('hidden', 'hidden');
  9505. var isCanvasHidden = true;
  9506. var showCanvas = function showCanvas() {
  9507. if (isCanvasHidden) {
  9508. canvas.removeAttribute('hidden');
  9509. isCanvasHidden = false;
  9510. }
  9511. };
  9512. canvasWrapper.appendChild(canvas);
  9513. this.canvas = canvas;
  9514. canvas.mozOpaque = true;
  9515. var ctx = canvas.getContext('2d', { alpha: false });
  9516. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  9517. this.outputScale = outputScale;
  9518. if (this.useOnlyCssZoom) {
  9519. var actualSizeViewport = viewport.clone({ scale: _ui_utils.CSS_UNITS });
  9520. outputScale.sx *= actualSizeViewport.width / viewport.width;
  9521. outputScale.sy *= actualSizeViewport.height / viewport.height;
  9522. outputScale.scaled = true;
  9523. }
  9524. if (this.maxCanvasPixels > 0) {
  9525. var pixelsInViewport = viewport.width * viewport.height;
  9526. var maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
  9527. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  9528. outputScale.sx = maxScale;
  9529. outputScale.sy = maxScale;
  9530. outputScale.scaled = true;
  9531. this.hasRestrictedScaling = true;
  9532. } else {
  9533. this.hasRestrictedScaling = false;
  9534. }
  9535. }
  9536. var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  9537. var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  9538. canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
  9539. canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
  9540. canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + 'px';
  9541. canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + 'px';
  9542. this.paintedViewportMap.set(canvas, viewport);
  9543. var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
  9544. var renderContext = {
  9545. canvasContext: ctx,
  9546. transform: transform,
  9547. viewport: this.viewport,
  9548. enableWebGL: this.enableWebGL,
  9549. renderInteractiveForms: this.renderInteractiveForms
  9550. };
  9551. var renderTask = this.pdfPage.render(renderContext);
  9552. renderTask.onContinue = function (cont) {
  9553. showCanvas();
  9554. if (result.onRenderContinue) {
  9555. result.onRenderContinue(cont);
  9556. } else {
  9557. cont();
  9558. }
  9559. };
  9560. renderTask.promise.then(function () {
  9561. showCanvas();
  9562. renderCapability.resolve(undefined);
  9563. }, function (error) {
  9564. showCanvas();
  9565. renderCapability.reject(error);
  9566. });
  9567. return result;
  9568. }
  9569. }, {
  9570. key: 'paintOnSvg',
  9571. value: function paintOnSvg(wrapper) {
  9572. var _this2 = this;
  9573. var cancelled = false;
  9574. var ensureNotCancelled = function ensureNotCancelled() {
  9575. if (cancelled) {
  9576. throw new _pdfjsLib.RenderingCancelledException('Rendering cancelled, page ' + _this2.id, 'svg');
  9577. }
  9578. };
  9579. var pdfPage = this.pdfPage;
  9580. var actualSizeViewport = this.viewport.clone({ scale: _ui_utils.CSS_UNITS });
  9581. var promise = pdfPage.getOperatorList().then(function (opList) {
  9582. ensureNotCancelled();
  9583. var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
  9584. return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {
  9585. ensureNotCancelled();
  9586. _this2.svg = svg;
  9587. _this2.paintedViewportMap.set(svg, actualSizeViewport);
  9588. svg.style.width = wrapper.style.width;
  9589. svg.style.height = wrapper.style.height;
  9590. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  9591. wrapper.appendChild(svg);
  9592. });
  9593. });
  9594. return {
  9595. promise: promise,
  9596. onRenderContinue: function onRenderContinue(cont) {
  9597. cont();
  9598. },
  9599. cancel: function cancel() {
  9600. cancelled = true;
  9601. }
  9602. };
  9603. }
  9604. }, {
  9605. key: 'setPageLabel',
  9606. value: function setPageLabel(label) {
  9607. this.pageLabel = typeof label === 'string' ? label : null;
  9608. if (this.pageLabel !== null) {
  9609. this.div.setAttribute('data-page-label', this.pageLabel);
  9610. } else {
  9611. this.div.removeAttribute('data-page-label');
  9612. }
  9613. }
  9614. }, {
  9615. key: 'width',
  9616. get: function get() {
  9617. return this.viewport.width;
  9618. }
  9619. }, {
  9620. key: 'height',
  9621. get: function get() {
  9622. return this.viewport.height;
  9623. }
  9624. }]);
  9625. return PDFPageView;
  9626. }();
  9627. exports.PDFPageView = PDFPageView;
  9628. /***/ }),
  9629. /* 33 */
  9630. /***/ (function(module, exports, __webpack_require__) {
  9631. "use strict";
  9632. Object.defineProperty(exports, "__esModule", {
  9633. value: true
  9634. });
  9635. exports.DefaultTextLayerFactory = exports.TextLayerBuilder = undefined;
  9636. 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; }; }();
  9637. var _dom_events = __webpack_require__(14);
  9638. var _pdfjsLib = __webpack_require__(7);
  9639. var _ui_utils = __webpack_require__(6);
  9640. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9641. var EXPAND_DIVS_TIMEOUT = 300;
  9642. var MATCH_SCROLL_OFFSET_TOP = -50;
  9643. var MATCH_SCROLL_OFFSET_LEFT = -400;
  9644. var TextLayerBuilder = function () {
  9645. function TextLayerBuilder(_ref) {
  9646. var textLayerDiv = _ref.textLayerDiv,
  9647. eventBus = _ref.eventBus,
  9648. pageIndex = _ref.pageIndex,
  9649. viewport = _ref.viewport,
  9650. _ref$findController = _ref.findController,
  9651. findController = _ref$findController === undefined ? null : _ref$findController,
  9652. _ref$enhanceTextSelec = _ref.enhanceTextSelection,
  9653. enhanceTextSelection = _ref$enhanceTextSelec === undefined ? false : _ref$enhanceTextSelec;
  9654. _classCallCheck(this, TextLayerBuilder);
  9655. this.textLayerDiv = textLayerDiv;
  9656. this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)();
  9657. this.textContent = null;
  9658. this.textContentItemsStr = [];
  9659. this.textContentStream = null;
  9660. this.renderingDone = false;
  9661. this.pageIdx = pageIndex;
  9662. this.pageNumber = this.pageIdx + 1;
  9663. this.matches = [];
  9664. this.viewport = viewport;
  9665. this.textDivs = [];
  9666. this.findController = findController;
  9667. this.textLayerRenderTask = null;
  9668. this.enhanceTextSelection = enhanceTextSelection;
  9669. this._boundEvents = Object.create(null);
  9670. this._bindEvents();
  9671. this._bindMouse();
  9672. }
  9673. _createClass(TextLayerBuilder, [{
  9674. key: '_finishRendering',
  9675. value: function _finishRendering() {
  9676. this.renderingDone = true;
  9677. if (!this.enhanceTextSelection) {
  9678. var endOfContent = document.createElement('div');
  9679. endOfContent.className = 'endOfContent';
  9680. this.textLayerDiv.appendChild(endOfContent);
  9681. }
  9682. this.eventBus.dispatch('textlayerrendered', {
  9683. source: this,
  9684. pageNumber: this.pageNumber,
  9685. numTextDivs: this.textDivs.length
  9686. });
  9687. }
  9688. }, {
  9689. key: 'render',
  9690. value: function render() {
  9691. var _this = this;
  9692. var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  9693. if (!(this.textContent || this.textContentStream) || this.renderingDone) {
  9694. return;
  9695. }
  9696. this.cancel();
  9697. this.textDivs = [];
  9698. var textLayerFrag = document.createDocumentFragment();
  9699. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  9700. textContent: this.textContent,
  9701. textContentStream: this.textContentStream,
  9702. container: textLayerFrag,
  9703. viewport: this.viewport,
  9704. textDivs: this.textDivs,
  9705. textContentItemsStr: this.textContentItemsStr,
  9706. timeout: timeout,
  9707. enhanceTextSelection: this.enhanceTextSelection
  9708. });
  9709. this.textLayerRenderTask.promise.then(function () {
  9710. _this.textLayerDiv.appendChild(textLayerFrag);
  9711. _this._finishRendering();
  9712. _this.updateMatches();
  9713. }, function (reason) {});
  9714. }
  9715. }, {
  9716. key: 'cancel',
  9717. value: function cancel() {
  9718. if (this.textLayerRenderTask) {
  9719. this.textLayerRenderTask.cancel();
  9720. this.textLayerRenderTask = null;
  9721. }
  9722. }
  9723. }, {
  9724. key: 'setTextContentStream',
  9725. value: function setTextContentStream(readableStream) {
  9726. this.cancel();
  9727. this.textContentStream = readableStream;
  9728. }
  9729. }, {
  9730. key: 'setTextContent',
  9731. value: function setTextContent(textContent) {
  9732. this.cancel();
  9733. this.textContent = textContent;
  9734. }
  9735. }, {
  9736. key: 'convertMatches',
  9737. value: function convertMatches(matches, matchesLength) {
  9738. var i = 0;
  9739. var iIndex = 0;
  9740. var textContentItemsStr = this.textContentItemsStr;
  9741. var end = textContentItemsStr.length - 1;
  9742. var queryLen = this.findController === null ? 0 : this.findController.state.query.length;
  9743. var ret = [];
  9744. if (!matches) {
  9745. return ret;
  9746. }
  9747. for (var m = 0, len = matches.length; m < len; m++) {
  9748. var matchIdx = matches[m];
  9749. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  9750. iIndex += textContentItemsStr[i].length;
  9751. i++;
  9752. }
  9753. if (i === textContentItemsStr.length) {
  9754. console.error('Could not find a matching mapping');
  9755. }
  9756. var match = {
  9757. begin: {
  9758. divIdx: i,
  9759. offset: matchIdx - iIndex
  9760. }
  9761. };
  9762. if (matchesLength) {
  9763. matchIdx += matchesLength[m];
  9764. } else {
  9765. matchIdx += queryLen;
  9766. }
  9767. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  9768. iIndex += textContentItemsStr[i].length;
  9769. i++;
  9770. }
  9771. match.end = {
  9772. divIdx: i,
  9773. offset: matchIdx - iIndex
  9774. };
  9775. ret.push(match);
  9776. }
  9777. return ret;
  9778. }
  9779. }, {
  9780. key: 'renderMatches',
  9781. value: function renderMatches(matches) {
  9782. if (matches.length === 0) {
  9783. return;
  9784. }
  9785. var textContentItemsStr = this.textContentItemsStr;
  9786. var textDivs = this.textDivs;
  9787. var prevEnd = null;
  9788. var pageIdx = this.pageIdx;
  9789. var isSelectedPage = this.findController === null ? false : pageIdx === this.findController.selected.pageIdx;
  9790. var selectedMatchIdx = this.findController === null ? -1 : this.findController.selected.matchIdx;
  9791. var highlightAll = this.findController === null ? false : this.findController.state.highlightAll;
  9792. var infinity = {
  9793. divIdx: -1,
  9794. offset: undefined
  9795. };
  9796. function beginText(begin, className) {
  9797. var divIdx = begin.divIdx;
  9798. textDivs[divIdx].textContent = '';
  9799. appendTextToDiv(divIdx, 0, begin.offset, className);
  9800. }
  9801. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  9802. var div = textDivs[divIdx];
  9803. var content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  9804. var node = document.createTextNode(content);
  9805. if (className) {
  9806. var span = document.createElement('span');
  9807. span.className = className;
  9808. span.appendChild(node);
  9809. div.appendChild(span);
  9810. return;
  9811. }
  9812. div.appendChild(node);
  9813. }
  9814. var i0 = selectedMatchIdx,
  9815. i1 = i0 + 1;
  9816. if (highlightAll) {
  9817. i0 = 0;
  9818. i1 = matches.length;
  9819. } else if (!isSelectedPage) {
  9820. return;
  9821. }
  9822. for (var i = i0; i < i1; i++) {
  9823. var match = matches[i];
  9824. var begin = match.begin;
  9825. var end = match.end;
  9826. var isSelected = isSelectedPage && i === selectedMatchIdx;
  9827. var highlightSuffix = isSelected ? ' selected' : '';
  9828. if (this.findController) {
  9829. if (this.findController.selected.matchIdx === i && this.findController.selected.pageIdx === pageIdx) {
  9830. var spot = {
  9831. top: MATCH_SCROLL_OFFSET_TOP,
  9832. left: MATCH_SCROLL_OFFSET_LEFT
  9833. };
  9834. (0, _ui_utils.scrollIntoView)(textDivs[begin.divIdx], spot, true);
  9835. }
  9836. }
  9837. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  9838. if (prevEnd !== null) {
  9839. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  9840. }
  9841. beginText(begin);
  9842. } else {
  9843. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  9844. }
  9845. if (begin.divIdx === end.divIdx) {
  9846. appendTextToDiv(begin.divIdx, begin.offset, end.offset, 'highlight' + highlightSuffix);
  9847. } else {
  9848. appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, 'highlight begin' + highlightSuffix);
  9849. for (var n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  9850. textDivs[n0].className = 'highlight middle' + highlightSuffix;
  9851. }
  9852. beginText(end, 'highlight end' + highlightSuffix);
  9853. }
  9854. prevEnd = end;
  9855. }
  9856. if (prevEnd) {
  9857. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  9858. }
  9859. }
  9860. }, {
  9861. key: 'updateMatches',
  9862. value: function updateMatches() {
  9863. if (!this.renderingDone) {
  9864. return;
  9865. }
  9866. var matches = this.matches;
  9867. var textDivs = this.textDivs;
  9868. var textContentItemsStr = this.textContentItemsStr;
  9869. var clearedUntilDivIdx = -1;
  9870. for (var i = 0, len = matches.length; i < len; i++) {
  9871. var match = matches[i];
  9872. var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  9873. for (var n = begin, end = match.end.divIdx; n <= end; n++) {
  9874. var div = textDivs[n];
  9875. div.textContent = textContentItemsStr[n];
  9876. div.className = '';
  9877. }
  9878. clearedUntilDivIdx = match.end.divIdx + 1;
  9879. }
  9880. if (!this.findController || !this.findController.highlightMatches) {
  9881. return;
  9882. }
  9883. var pageMatches = void 0,
  9884. pageMatchesLength = void 0;
  9885. if (this.findController !== null) {
  9886. pageMatches = this.findController.pageMatches[this.pageIdx] || null;
  9887. pageMatchesLength = this.findController.pageMatchesLength ? this.findController.pageMatchesLength[this.pageIdx] || null : null;
  9888. }
  9889. this.matches = this.convertMatches(pageMatches, pageMatchesLength);
  9890. this.renderMatches(this.matches);
  9891. }
  9892. }, {
  9893. key: '_bindEvents',
  9894. value: function _bindEvents() {
  9895. var _this2 = this;
  9896. var eventBus = this.eventBus,
  9897. _boundEvents = this._boundEvents;
  9898. _boundEvents.pageCancelled = function (evt) {
  9899. if (evt.pageNumber !== _this2.pageNumber) {
  9900. return;
  9901. }
  9902. if (_this2.textLayerRenderTask) {
  9903. console.error('TextLayerBuilder._bindEvents: `this.cancel()` should ' + 'have been called when the page was reset, or rendering cancelled.');
  9904. return;
  9905. }
  9906. for (var name in _boundEvents) {
  9907. eventBus.off(name.toLowerCase(), _boundEvents[name]);
  9908. delete _boundEvents[name];
  9909. }
  9910. };
  9911. _boundEvents.updateTextLayerMatches = function (evt) {
  9912. if (evt.pageIndex !== _this2.pageIdx && evt.pageIndex !== -1) {
  9913. return;
  9914. }
  9915. _this2.updateMatches();
  9916. };
  9917. eventBus.on('pagecancelled', _boundEvents.pageCancelled);
  9918. eventBus.on('updatetextlayermatches', _boundEvents.updateTextLayerMatches);
  9919. }
  9920. }, {
  9921. key: '_bindMouse',
  9922. value: function _bindMouse() {
  9923. var _this3 = this;
  9924. var div = this.textLayerDiv;
  9925. var expandDivsTimer = null;
  9926. div.addEventListener('mousedown', function (evt) {
  9927. if (_this3.enhanceTextSelection && _this3.textLayerRenderTask) {
  9928. _this3.textLayerRenderTask.expandTextDivs(true);
  9929. if (expandDivsTimer) {
  9930. clearTimeout(expandDivsTimer);
  9931. expandDivsTimer = null;
  9932. }
  9933. return;
  9934. }
  9935. var end = div.querySelector('.endOfContent');
  9936. if (!end) {
  9937. return;
  9938. }
  9939. var adjustTop = evt.target !== div;
  9940. adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue('-moz-user-select') !== 'none';
  9941. if (adjustTop) {
  9942. var divBounds = div.getBoundingClientRect();
  9943. var r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  9944. end.style.top = (r * 100).toFixed(2) + '%';
  9945. }
  9946. end.classList.add('active');
  9947. });
  9948. div.addEventListener('mouseup', function () {
  9949. if (_this3.enhanceTextSelection && _this3.textLayerRenderTask) {
  9950. expandDivsTimer = setTimeout(function () {
  9951. if (_this3.textLayerRenderTask) {
  9952. _this3.textLayerRenderTask.expandTextDivs(false);
  9953. }
  9954. expandDivsTimer = null;
  9955. }, EXPAND_DIVS_TIMEOUT);
  9956. return;
  9957. }
  9958. var end = div.querySelector('.endOfContent');
  9959. if (!end) {
  9960. return;
  9961. }
  9962. end.style.top = '';
  9963. end.classList.remove('active');
  9964. });
  9965. }
  9966. }]);
  9967. return TextLayerBuilder;
  9968. }();
  9969. var DefaultTextLayerFactory = function () {
  9970. function DefaultTextLayerFactory() {
  9971. _classCallCheck(this, DefaultTextLayerFactory);
  9972. }
  9973. _createClass(DefaultTextLayerFactory, [{
  9974. key: 'createTextLayerBuilder',
  9975. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  9976. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9977. return new TextLayerBuilder({
  9978. textLayerDiv: textLayerDiv,
  9979. pageIndex: pageIndex,
  9980. viewport: viewport,
  9981. enhanceTextSelection: enhanceTextSelection
  9982. });
  9983. }
  9984. }]);
  9985. return DefaultTextLayerFactory;
  9986. }();
  9987. exports.TextLayerBuilder = TextLayerBuilder;
  9988. exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
  9989. /***/ }),
  9990. /* 34 */
  9991. /***/ (function(module, exports, __webpack_require__) {
  9992. "use strict";
  9993. Object.defineProperty(exports, "__esModule", {
  9994. value: true
  9995. });
  9996. exports.SecondaryToolbar = undefined;
  9997. 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; }; }();
  9998. var _base_viewer = __webpack_require__(30);
  9999. var _pdf_cursor_tools = __webpack_require__(8);
  10000. var _pdf_single_page_viewer = __webpack_require__(35);
  10001. var _ui_utils = __webpack_require__(6);
  10002. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10003. var SecondaryToolbar = function () {
  10004. function SecondaryToolbar(options, mainContainer, eventBus) {
  10005. var _this = this;
  10006. _classCallCheck(this, SecondaryToolbar);
  10007. this.toolbar = options.toolbar;
  10008. this.toggleButton = options.toggleButton;
  10009. this.toolbarButtonContainer = options.toolbarButtonContainer;
  10010. this.buttons = [{
  10011. element: options.presentationModeButton,
  10012. eventName: 'presentationmode',
  10013. close: true
  10014. }, {
  10015. element: options.openFileButton,
  10016. eventName: 'openfile',
  10017. close: true
  10018. }, {
  10019. element: options.printButton,
  10020. eventName: 'print',
  10021. close: true
  10022. }, {
  10023. element: options.downloadButton,
  10024. eventName: 'download',
  10025. close: true
  10026. }, {
  10027. element: options.viewBookmarkButton,
  10028. eventName: null,
  10029. close: true
  10030. }, {
  10031. element: options.firstPageButton,
  10032. eventName: 'firstpage',
  10033. close: true
  10034. }, {
  10035. element: options.lastPageButton,
  10036. eventName: 'lastpage',
  10037. close: true
  10038. }, {
  10039. element: options.pageRotateCwButton,
  10040. eventName: 'rotatecw',
  10041. close: false
  10042. }, {
  10043. element: options.pageRotateCcwButton,
  10044. eventName: 'rotateccw',
  10045. close: false
  10046. }, {
  10047. element: options.cursorSelectToolButton,
  10048. eventName: 'switchcursortool',
  10049. eventDetails: { tool: _pdf_cursor_tools.CursorTool.SELECT },
  10050. close: true
  10051. }, {
  10052. element: options.cursorHandToolButton,
  10053. eventName: 'switchcursortool',
  10054. eventDetails: { tool: _pdf_cursor_tools.CursorTool.HAND },
  10055. close: true
  10056. }, {
  10057. element: options.scrollVerticalButton,
  10058. eventName: 'switchscrollmode',
  10059. eventDetails: { mode: _base_viewer.ScrollMode.VERTICAL },
  10060. close: true
  10061. }, {
  10062. element: options.scrollHorizontalButton,
  10063. eventName: 'switchscrollmode',
  10064. eventDetails: { mode: _base_viewer.ScrollMode.HORIZONTAL },
  10065. close: true
  10066. }, {
  10067. element: options.scrollWrappedButton,
  10068. eventName: 'switchscrollmode',
  10069. eventDetails: { mode: _base_viewer.ScrollMode.WRAPPED },
  10070. close: true
  10071. }, {
  10072. element: options.spreadNoneButton,
  10073. eventName: 'switchspreadmode',
  10074. eventDetails: { mode: _base_viewer.SpreadMode.NONE },
  10075. close: true
  10076. }, {
  10077. element: options.spreadOddButton,
  10078. eventName: 'switchspreadmode',
  10079. eventDetails: { mode: _base_viewer.SpreadMode.ODD },
  10080. close: true
  10081. }, {
  10082. element: options.spreadEvenButton,
  10083. eventName: 'switchspreadmode',
  10084. eventDetails: { mode: _base_viewer.SpreadMode.EVEN },
  10085. close: true
  10086. }, {
  10087. element: options.documentPropertiesButton,
  10088. eventName: 'documentproperties',
  10089. close: true
  10090. }];
  10091. this.items = {
  10092. firstPage: options.firstPageButton,
  10093. lastPage: options.lastPageButton,
  10094. pageRotateCw: options.pageRotateCwButton,
  10095. pageRotateCcw: options.pageRotateCcwButton
  10096. };
  10097. this.mainContainer = mainContainer;
  10098. this.eventBus = eventBus;
  10099. this.opened = false;
  10100. this.containerHeight = null;
  10101. this.previousContainerHeight = null;
  10102. this.reset();
  10103. this._bindClickListeners();
  10104. this._bindCursorToolsListener(options);
  10105. this._bindScrollModeListener(options);
  10106. this._bindSpreadModeListener(options);
  10107. this.eventBus.on('resize', this._setMaxHeight.bind(this));
  10108. this.eventBus.on('baseviewerinit', function (evt) {
  10109. if (evt.source instanceof _pdf_single_page_viewer.PDFSinglePageViewer) {
  10110. _this.toolbarButtonContainer.classList.add('hiddenScrollModeButtons', 'hiddenSpreadModeButtons');
  10111. } else {
  10112. _this.toolbarButtonContainer.classList.remove('hiddenScrollModeButtons', 'hiddenSpreadModeButtons');
  10113. }
  10114. });
  10115. }
  10116. _createClass(SecondaryToolbar, [{
  10117. key: 'setPageNumber',
  10118. value: function setPageNumber(pageNumber) {
  10119. this.pageNumber = pageNumber;
  10120. this._updateUIState();
  10121. }
  10122. }, {
  10123. key: 'setPagesCount',
  10124. value: function setPagesCount(pagesCount) {
  10125. this.pagesCount = pagesCount;
  10126. this._updateUIState();
  10127. }
  10128. }, {
  10129. key: 'reset',
  10130. value: function reset() {
  10131. this.pageNumber = 0;
  10132. this.pagesCount = 0;
  10133. this._updateUIState();
  10134. this.eventBus.dispatch('secondarytoolbarreset', { source: this });
  10135. }
  10136. }, {
  10137. key: '_updateUIState',
  10138. value: function _updateUIState() {
  10139. this.items.firstPage.disabled = this.pageNumber <= 1;
  10140. this.items.lastPage.disabled = this.pageNumber >= this.pagesCount;
  10141. this.items.pageRotateCw.disabled = this.pagesCount === 0;
  10142. this.items.pageRotateCcw.disabled = this.pagesCount === 0;
  10143. }
  10144. }, {
  10145. key: '_bindClickListeners',
  10146. value: function _bindClickListeners() {
  10147. var _this2 = this;
  10148. this.toggleButton.addEventListener('click', this.toggle.bind(this));
  10149. var _loop = function _loop(button) {
  10150. var _buttons$button = _this2.buttons[button],
  10151. element = _buttons$button.element,
  10152. eventName = _buttons$button.eventName,
  10153. close = _buttons$button.close,
  10154. eventDetails = _buttons$button.eventDetails;
  10155. element.addEventListener('click', function (evt) {
  10156. if (eventName !== null) {
  10157. var details = { source: _this2 };
  10158. for (var property in eventDetails) {
  10159. details[property] = eventDetails[property];
  10160. }
  10161. _this2.eventBus.dispatch(eventName, details);
  10162. }
  10163. if (close) {
  10164. _this2.close();
  10165. }
  10166. });
  10167. };
  10168. for (var button in this.buttons) {
  10169. _loop(button);
  10170. }
  10171. }
  10172. }, {
  10173. key: '_bindCursorToolsListener',
  10174. value: function _bindCursorToolsListener(buttons) {
  10175. this.eventBus.on('cursortoolchanged', function (evt) {
  10176. buttons.cursorSelectToolButton.classList.remove('toggled');
  10177. buttons.cursorHandToolButton.classList.remove('toggled');
  10178. switch (evt.tool) {
  10179. case _pdf_cursor_tools.CursorTool.SELECT:
  10180. buttons.cursorSelectToolButton.classList.add('toggled');
  10181. break;
  10182. case _pdf_cursor_tools.CursorTool.HAND:
  10183. buttons.cursorHandToolButton.classList.add('toggled');
  10184. break;
  10185. }
  10186. });
  10187. }
  10188. }, {
  10189. key: '_bindScrollModeListener',
  10190. value: function _bindScrollModeListener(buttons) {
  10191. var _this3 = this;
  10192. function scrollModeChanged(evt) {
  10193. buttons.scrollVerticalButton.classList.remove('toggled');
  10194. buttons.scrollHorizontalButton.classList.remove('toggled');
  10195. buttons.scrollWrappedButton.classList.remove('toggled');
  10196. switch (evt.mode) {
  10197. case _base_viewer.ScrollMode.VERTICAL:
  10198. buttons.scrollVerticalButton.classList.add('toggled');
  10199. break;
  10200. case _base_viewer.ScrollMode.HORIZONTAL:
  10201. buttons.scrollHorizontalButton.classList.add('toggled');
  10202. break;
  10203. case _base_viewer.ScrollMode.WRAPPED:
  10204. buttons.scrollWrappedButton.classList.add('toggled');
  10205. break;
  10206. }
  10207. var isScrollModeHorizontal = evt.mode === _base_viewer.ScrollMode.HORIZONTAL;
  10208. buttons.spreadNoneButton.disabled = isScrollModeHorizontal;
  10209. buttons.spreadOddButton.disabled = isScrollModeHorizontal;
  10210. buttons.spreadEvenButton.disabled = isScrollModeHorizontal;
  10211. }
  10212. this.eventBus.on('scrollmodechanged', scrollModeChanged);
  10213. this.eventBus.on('secondarytoolbarreset', function (evt) {
  10214. if (evt.source === _this3) {
  10215. scrollModeChanged({ mode: _base_viewer.ScrollMode.VERTICAL });
  10216. }
  10217. });
  10218. }
  10219. }, {
  10220. key: '_bindSpreadModeListener',
  10221. value: function _bindSpreadModeListener(buttons) {
  10222. var _this4 = this;
  10223. function spreadModeChanged(evt) {
  10224. buttons.spreadNoneButton.classList.remove('toggled');
  10225. buttons.spreadOddButton.classList.remove('toggled');
  10226. buttons.spreadEvenButton.classList.remove('toggled');
  10227. switch (evt.mode) {
  10228. case _base_viewer.SpreadMode.NONE:
  10229. buttons.spreadNoneButton.classList.add('toggled');
  10230. break;
  10231. case _base_viewer.SpreadMode.ODD:
  10232. buttons.spreadOddButton.classList.add('toggled');
  10233. break;
  10234. case _base_viewer.SpreadMode.EVEN:
  10235. buttons.spreadEvenButton.classList.add('toggled');
  10236. break;
  10237. }
  10238. }
  10239. this.eventBus.on('spreadmodechanged', spreadModeChanged);
  10240. this.eventBus.on('secondarytoolbarreset', function (evt) {
  10241. if (evt.source === _this4) {
  10242. spreadModeChanged({ mode: _base_viewer.SpreadMode.NONE });
  10243. }
  10244. });
  10245. }
  10246. }, {
  10247. key: 'open',
  10248. value: function open() {
  10249. if (this.opened) {
  10250. return;
  10251. }
  10252. this.opened = true;
  10253. this._setMaxHeight();
  10254. this.toggleButton.classList.add('toggled');
  10255. this.toolbar.classList.remove('hidden');
  10256. }
  10257. }, {
  10258. key: 'close',
  10259. value: function close() {
  10260. if (!this.opened) {
  10261. return;
  10262. }
  10263. this.opened = false;
  10264. this.toolbar.classList.add('hidden');
  10265. this.toggleButton.classList.remove('toggled');
  10266. }
  10267. }, {
  10268. key: 'toggle',
  10269. value: function toggle() {
  10270. if (this.opened) {
  10271. this.close();
  10272. } else {
  10273. this.open();
  10274. }
  10275. }
  10276. }, {
  10277. key: '_setMaxHeight',
  10278. value: function _setMaxHeight() {
  10279. if (!this.opened) {
  10280. return;
  10281. }
  10282. this.containerHeight = this.mainContainer.clientHeight;
  10283. if (this.containerHeight === this.previousContainerHeight) {
  10284. return;
  10285. }
  10286. this.toolbarButtonContainer.setAttribute('style', 'max-height: ' + (this.containerHeight - _ui_utils.SCROLLBAR_PADDING) + 'px;');
  10287. this.previousContainerHeight = this.containerHeight;
  10288. }
  10289. }, {
  10290. key: 'isOpen',
  10291. get: function get() {
  10292. return this.opened;
  10293. }
  10294. }]);
  10295. return SecondaryToolbar;
  10296. }();
  10297. exports.SecondaryToolbar = SecondaryToolbar;
  10298. /***/ }),
  10299. /* 35 */
  10300. /***/ (function(module, exports, __webpack_require__) {
  10301. "use strict";
  10302. Object.defineProperty(exports, "__esModule", {
  10303. value: true
  10304. });
  10305. exports.PDFSinglePageViewer = undefined;
  10306. 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; }; }();
  10307. 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); } };
  10308. var _base_viewer = __webpack_require__(30);
  10309. var _ui_utils = __webpack_require__(6);
  10310. var _pdfjsLib = __webpack_require__(7);
  10311. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10312. 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; }
  10313. 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; }
  10314. var PDFSinglePageViewer = function (_BaseViewer) {
  10315. _inherits(PDFSinglePageViewer, _BaseViewer);
  10316. function PDFSinglePageViewer(options) {
  10317. _classCallCheck(this, PDFSinglePageViewer);
  10318. var _this = _possibleConstructorReturn(this, (PDFSinglePageViewer.__proto__ || Object.getPrototypeOf(PDFSinglePageViewer)).call(this, options));
  10319. _this.eventBus.on('pagesinit', function (evt) {
  10320. _this._ensurePageViewVisible();
  10321. });
  10322. return _this;
  10323. }
  10324. _createClass(PDFSinglePageViewer, [{
  10325. key: '_resetView',
  10326. value: function _resetView() {
  10327. _get(PDFSinglePageViewer.prototype.__proto__ || Object.getPrototypeOf(PDFSinglePageViewer.prototype), '_resetView', this).call(this);
  10328. this._previousPageNumber = 1;
  10329. this._shadowViewer = document.createDocumentFragment();
  10330. }
  10331. }, {
  10332. key: '_ensurePageViewVisible',
  10333. value: function _ensurePageViewVisible() {
  10334. var pageView = this._pages[this._currentPageNumber - 1];
  10335. var previousPageView = this._pages[this._previousPageNumber - 1];
  10336. var viewerNodes = this.viewer.childNodes;
  10337. switch (viewerNodes.length) {
  10338. case 0:
  10339. this.viewer.appendChild(pageView.div);
  10340. break;
  10341. case 1:
  10342. if (viewerNodes[0] !== previousPageView.div) {
  10343. throw new Error('_ensurePageViewVisible: Unexpected previously visible page.');
  10344. }
  10345. if (pageView === previousPageView) {
  10346. break;
  10347. }
  10348. this._shadowViewer.appendChild(previousPageView.div);
  10349. this.viewer.appendChild(pageView.div);
  10350. this.container.scrollTop = 0;
  10351. break;
  10352. default:
  10353. throw new Error('_ensurePageViewVisible: Only one page should be visible at a time.');
  10354. }
  10355. this._previousPageNumber = this._currentPageNumber;
  10356. }
  10357. }, {
  10358. key: '_scrollUpdate',
  10359. value: function _scrollUpdate() {
  10360. if (this._updateScrollDown) {
  10361. this._updateScrollDown();
  10362. }
  10363. _get(PDFSinglePageViewer.prototype.__proto__ || Object.getPrototypeOf(PDFSinglePageViewer.prototype), '_scrollUpdate', this).call(this);
  10364. }
  10365. }, {
  10366. key: '_scrollIntoView',
  10367. value: function _scrollIntoView(_ref) {
  10368. var _this2 = this;
  10369. var pageDiv = _ref.pageDiv,
  10370. _ref$pageSpot = _ref.pageSpot,
  10371. pageSpot = _ref$pageSpot === undefined ? null : _ref$pageSpot,
  10372. _ref$pageNumber = _ref.pageNumber,
  10373. pageNumber = _ref$pageNumber === undefined ? null : _ref$pageNumber;
  10374. if (pageNumber) {
  10375. this._setCurrentPageNumber(pageNumber);
  10376. }
  10377. var scrolledDown = this._currentPageNumber >= this._previousPageNumber;
  10378. var previousLocation = this._location;
  10379. this._ensurePageViewVisible();
  10380. (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
  10381. this._updateScrollDown = function () {
  10382. _this2.scroll.down = scrolledDown;
  10383. delete _this2._updateScrollDown;
  10384. };
  10385. setTimeout(function () {
  10386. if (_this2._location === previousLocation) {
  10387. if (_this2._updateScrollDown) {
  10388. _this2._updateScrollDown();
  10389. }
  10390. _this2.update();
  10391. }
  10392. }, 0);
  10393. }
  10394. }, {
  10395. key: '_getVisiblePages',
  10396. value: function _getVisiblePages() {
  10397. if (!this.pagesCount) {
  10398. return { views: [] };
  10399. }
  10400. var pageView = this._pages[this._currentPageNumber - 1];
  10401. var element = pageView.div;
  10402. var view = {
  10403. id: pageView.id,
  10404. x: element.offsetLeft + element.clientLeft,
  10405. y: element.offsetTop + element.clientTop,
  10406. view: pageView
  10407. };
  10408. return {
  10409. first: view,
  10410. last: view,
  10411. views: [view]
  10412. };
  10413. }
  10414. }, {
  10415. key: 'update',
  10416. value: function update() {
  10417. var visible = this._getVisiblePages();
  10418. var visiblePages = visible.views,
  10419. numVisiblePages = visiblePages.length;
  10420. if (numVisiblePages === 0) {
  10421. return;
  10422. }
  10423. this._resizeBuffer(numVisiblePages);
  10424. this.renderingQueue.renderHighestPriority(visible);
  10425. this._updateLocation(visible.first);
  10426. this.eventBus.dispatch('updateviewarea', {
  10427. source: this,
  10428. location: this._location
  10429. });
  10430. }
  10431. }, {
  10432. key: '_updateScrollMode',
  10433. value: function _updateScrollMode() {}
  10434. }, {
  10435. key: '_updateSpreadMode',
  10436. value: function _updateSpreadMode() {}
  10437. }, {
  10438. key: '_setDocumentViewerElement',
  10439. get: function get() {
  10440. return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this._shadowViewer);
  10441. }
  10442. }, {
  10443. key: '_isScrollModeHorizontal',
  10444. get: function get() {
  10445. return (0, _pdfjsLib.shadow)(this, '_isScrollModeHorizontal', false);
  10446. }
  10447. }]);
  10448. return PDFSinglePageViewer;
  10449. }(_base_viewer.BaseViewer);
  10450. exports.PDFSinglePageViewer = PDFSinglePageViewer;
  10451. /***/ }),
  10452. /* 36 */
  10453. /***/ (function(module, exports, __webpack_require__) {
  10454. "use strict";
  10455. Object.defineProperty(exports, "__esModule", {
  10456. value: true
  10457. });
  10458. exports.Toolbar = undefined;
  10459. 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; }; }();
  10460. var _ui_utils = __webpack_require__(6);
  10461. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10462. var PAGE_NUMBER_LOADING_INDICATOR = 'visiblePageIsLoading';
  10463. var SCALE_SELECT_CONTAINER_PADDING = 8;
  10464. var SCALE_SELECT_PADDING = 22;
  10465. var Toolbar = function () {
  10466. function Toolbar(options, eventBus) {
  10467. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  10468. _classCallCheck(this, Toolbar);
  10469. this.toolbar = options.container;
  10470. this.eventBus = eventBus;
  10471. this.l10n = l10n;
  10472. this.items = options;
  10473. this._wasLocalized = false;
  10474. this.reset();
  10475. this._bindListeners();
  10476. }
  10477. _createClass(Toolbar, [{
  10478. key: 'setPageNumber',
  10479. value: function setPageNumber(pageNumber, pageLabel) {
  10480. this.pageNumber = pageNumber;
  10481. this.pageLabel = pageLabel;
  10482. this._updateUIState(false);
  10483. }
  10484. }, {
  10485. key: 'setPagesCount',
  10486. value: function setPagesCount(pagesCount, hasPageLabels) {
  10487. this.pagesCount = pagesCount;
  10488. this.hasPageLabels = hasPageLabels;
  10489. this._updateUIState(true);
  10490. }
  10491. }, {
  10492. key: 'setPageScale',
  10493. value: function setPageScale(pageScaleValue, pageScale) {
  10494. this.pageScaleValue = (pageScaleValue || pageScale).toString();
  10495. this.pageScale = pageScale;
  10496. this._updateUIState(false);
  10497. }
  10498. }, {
  10499. key: 'reset',
  10500. value: function reset() {
  10501. this.pageNumber = 0;
  10502. this.pageLabel = null;
  10503. this.hasPageLabels = false;
  10504. this.pagesCount = 0;
  10505. this.pageScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  10506. this.pageScale = _ui_utils.DEFAULT_SCALE;
  10507. this._updateUIState(true);
  10508. }
  10509. }, {
  10510. key: '_bindListeners',
  10511. value: function _bindListeners() {
  10512. var _this = this;
  10513. var eventBus = this.eventBus,
  10514. items = this.items;
  10515. var self = this;
  10516. items.previous.addEventListener('click', function () {
  10517. eventBus.dispatch('previouspage', { source: self });
  10518. });
  10519. items.next.addEventListener('click', function () {
  10520. eventBus.dispatch('nextpage', { source: self });
  10521. });
  10522. items.zoomIn.addEventListener('click', function () {
  10523. eventBus.dispatch('zoomin', { source: self });
  10524. });
  10525. items.zoomOut.addEventListener('click', function () {
  10526. eventBus.dispatch('zoomout', { source: self });
  10527. });
  10528. items.pageNumber.addEventListener('click', function () {
  10529. this.select();
  10530. });
  10531. items.pageNumber.addEventListener('change', function () {
  10532. eventBus.dispatch('pagenumberchanged', {
  10533. source: self,
  10534. value: this.value
  10535. });
  10536. });
  10537. items.scaleSelect.addEventListener('change', function () {
  10538. if (this.value === 'custom') {
  10539. return;
  10540. }
  10541. eventBus.dispatch('scalechanged', {
  10542. source: self,
  10543. value: this.value
  10544. });
  10545. });
  10546. items.presentationModeButton.addEventListener('click', function () {
  10547. eventBus.dispatch('presentationmode', { source: self });
  10548. });
  10549. items.openFile.addEventListener('click', function () {
  10550. eventBus.dispatch('openfile', { source: self });
  10551. });
  10552. items.print.addEventListener('click', function () {
  10553. eventBus.dispatch('print', { source: self });
  10554. });
  10555. items.download.addEventListener('click', function () {
  10556. eventBus.dispatch('download', { source: self });
  10557. });
  10558. items.scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler;
  10559. eventBus.on('localized', function () {
  10560. _this._localized();
  10561. });
  10562. }
  10563. }, {
  10564. key: '_localized',
  10565. value: function _localized() {
  10566. this._wasLocalized = true;
  10567. this._adjustScaleWidth();
  10568. this._updateUIState(true);
  10569. }
  10570. }, {
  10571. key: '_updateUIState',
  10572. value: function _updateUIState() {
  10573. var resetNumPages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  10574. if (!this._wasLocalized) {
  10575. return;
  10576. }
  10577. var pageNumber = this.pageNumber,
  10578. pagesCount = this.pagesCount,
  10579. pageScaleValue = this.pageScaleValue,
  10580. pageScale = this.pageScale,
  10581. items = this.items;
  10582. if (resetNumPages) {
  10583. if (this.hasPageLabels) {
  10584. items.pageNumber.type = 'text';
  10585. } else {
  10586. items.pageNumber.type = 'number';
  10587. this.l10n.get('of_pages', { pagesCount: pagesCount }, 'of {{pagesCount}}').then(function (msg) {
  10588. items.numPages.textContent = msg;
  10589. });
  10590. }
  10591. items.pageNumber.max = pagesCount;
  10592. }
  10593. if (this.hasPageLabels) {
  10594. items.pageNumber.value = this.pageLabel;
  10595. this.l10n.get('page_of_pages', {
  10596. pageNumber: pageNumber,
  10597. pagesCount: pagesCount
  10598. }, '({{pageNumber}} of {{pagesCount}})').then(function (msg) {
  10599. items.numPages.textContent = msg;
  10600. });
  10601. } else {
  10602. items.pageNumber.value = pageNumber;
  10603. }
  10604. items.previous.disabled = pageNumber <= 1;
  10605. items.next.disabled = pageNumber >= pagesCount;
  10606. items.zoomOut.disabled = pageScale <= _ui_utils.MIN_SCALE;
  10607. items.zoomIn.disabled = pageScale >= _ui_utils.MAX_SCALE;
  10608. var customScale = Math.round(pageScale * 10000) / 100;
  10609. this.l10n.get('page_scale_percent', { scale: customScale }, '{{scale}}%').then(function (msg) {
  10610. var options = items.scaleSelect.options;
  10611. var predefinedValueFound = false;
  10612. for (var i = 0, ii = options.length; i < ii; i++) {
  10613. var option = options[i];
  10614. if (option.value !== pageScaleValue) {
  10615. option.selected = false;
  10616. continue;
  10617. }
  10618. option.selected = true;
  10619. predefinedValueFound = true;
  10620. }
  10621. if (!predefinedValueFound) {
  10622. items.customScaleOption.textContent = msg;
  10623. items.customScaleOption.selected = true;
  10624. }
  10625. });
  10626. }
  10627. }, {
  10628. key: 'updateLoadingIndicatorState',
  10629. value: function updateLoadingIndicatorState() {
  10630. var loading = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  10631. var pageNumberInput = this.items.pageNumber;
  10632. pageNumberInput.classList.toggle(PAGE_NUMBER_LOADING_INDICATOR, loading);
  10633. }
  10634. }, {
  10635. key: '_adjustScaleWidth',
  10636. value: function _adjustScaleWidth() {
  10637. var container = this.items.scaleSelectContainer;
  10638. var select = this.items.scaleSelect;
  10639. _ui_utils.animationStarted.then(function () {
  10640. if (container.clientWidth === 0) {
  10641. container.setAttribute('style', 'display: inherit;');
  10642. }
  10643. if (container.clientWidth > 0) {
  10644. select.setAttribute('style', 'min-width: inherit;');
  10645. var width = select.clientWidth + SCALE_SELECT_CONTAINER_PADDING;
  10646. select.setAttribute('style', 'min-width: ' + (width + SCALE_SELECT_PADDING) + 'px;');
  10647. container.setAttribute('style', 'min-width: ' + width + 'px; ' + 'max-width: ' + width + 'px;');
  10648. }
  10649. });
  10650. }
  10651. }]);
  10652. return Toolbar;
  10653. }();
  10654. exports.Toolbar = Toolbar;
  10655. /***/ }),
  10656. /* 37 */
  10657. /***/ (function(module, exports, __webpack_require__) {
  10658. "use strict";
  10659. Object.defineProperty(exports, "__esModule", {
  10660. value: true
  10661. });
  10662. exports.ViewHistory = undefined;
  10663. var _regenerator = __webpack_require__(2);
  10664. var _regenerator2 = _interopRequireDefault(_regenerator);
  10665. 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; }; }();
  10666. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10667. 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"); }); }; }
  10668. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10669. var DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
  10670. var ViewHistory = function () {
  10671. function ViewHistory(fingerprint) {
  10672. var _this = this;
  10673. var cacheSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_VIEW_HISTORY_CACHE_SIZE;
  10674. _classCallCheck(this, ViewHistory);
  10675. this.fingerprint = fingerprint;
  10676. this.cacheSize = cacheSize;
  10677. this._initializedPromise = this._readFromStorage().then(function (databaseStr) {
  10678. var database = JSON.parse(databaseStr || '{}');
  10679. if (!('files' in database)) {
  10680. database.files = [];
  10681. } else {
  10682. while (database.files.length >= _this.cacheSize) {
  10683. database.files.shift();
  10684. }
  10685. }
  10686. var index = -1;
  10687. for (var i = 0, length = database.files.length; i < length; i++) {
  10688. var branch = database.files[i];
  10689. if (branch.fingerprint === _this.fingerprint) {
  10690. index = i;
  10691. break;
  10692. }
  10693. }
  10694. if (index === -1) {
  10695. index = database.files.push({ fingerprint: _this.fingerprint }) - 1;
  10696. }
  10697. _this.file = database.files[index];
  10698. _this.database = database;
  10699. });
  10700. }
  10701. _createClass(ViewHistory, [{
  10702. key: '_writeToStorage',
  10703. value: function () {
  10704. var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee() {
  10705. var databaseStr;
  10706. return _regenerator2.default.wrap(function _callee$(_context) {
  10707. while (1) {
  10708. switch (_context.prev = _context.next) {
  10709. case 0:
  10710. databaseStr = JSON.stringify(this.database);
  10711. localStorage.setItem('pdfjs.history', databaseStr);
  10712. case 2:
  10713. case 'end':
  10714. return _context.stop();
  10715. }
  10716. }
  10717. }, _callee, this);
  10718. }));
  10719. function _writeToStorage() {
  10720. return _ref.apply(this, arguments);
  10721. }
  10722. return _writeToStorage;
  10723. }()
  10724. }, {
  10725. key: '_readFromStorage',
  10726. value: function () {
  10727. var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2() {
  10728. return _regenerator2.default.wrap(function _callee2$(_context2) {
  10729. while (1) {
  10730. switch (_context2.prev = _context2.next) {
  10731. case 0:
  10732. return _context2.abrupt('return', localStorage.getItem('pdfjs.history'));
  10733. case 1:
  10734. case 'end':
  10735. return _context2.stop();
  10736. }
  10737. }
  10738. }, _callee2, this);
  10739. }));
  10740. function _readFromStorage() {
  10741. return _ref2.apply(this, arguments);
  10742. }
  10743. return _readFromStorage;
  10744. }()
  10745. }, {
  10746. key: 'set',
  10747. value: function () {
  10748. var _ref3 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee3(name, val) {
  10749. return _regenerator2.default.wrap(function _callee3$(_context3) {
  10750. while (1) {
  10751. switch (_context3.prev = _context3.next) {
  10752. case 0:
  10753. _context3.next = 2;
  10754. return this._initializedPromise;
  10755. case 2:
  10756. this.file[name] = val;
  10757. return _context3.abrupt('return', this._writeToStorage());
  10758. case 4:
  10759. case 'end':
  10760. return _context3.stop();
  10761. }
  10762. }
  10763. }, _callee3, this);
  10764. }));
  10765. function set(_x2, _x3) {
  10766. return _ref3.apply(this, arguments);
  10767. }
  10768. return set;
  10769. }()
  10770. }, {
  10771. key: 'setMultiple',
  10772. value: function () {
  10773. var _ref4 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee4(properties) {
  10774. var name;
  10775. return _regenerator2.default.wrap(function _callee4$(_context4) {
  10776. while (1) {
  10777. switch (_context4.prev = _context4.next) {
  10778. case 0:
  10779. _context4.next = 2;
  10780. return this._initializedPromise;
  10781. case 2:
  10782. for (name in properties) {
  10783. this.file[name] = properties[name];
  10784. }
  10785. return _context4.abrupt('return', this._writeToStorage());
  10786. case 4:
  10787. case 'end':
  10788. return _context4.stop();
  10789. }
  10790. }
  10791. }, _callee4, this);
  10792. }));
  10793. function setMultiple(_x4) {
  10794. return _ref4.apply(this, arguments);
  10795. }
  10796. return setMultiple;
  10797. }()
  10798. }, {
  10799. key: 'get',
  10800. value: function () {
  10801. var _ref5 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee5(name, defaultValue) {
  10802. var val;
  10803. return _regenerator2.default.wrap(function _callee5$(_context5) {
  10804. while (1) {
  10805. switch (_context5.prev = _context5.next) {
  10806. case 0:
  10807. _context5.next = 2;
  10808. return this._initializedPromise;
  10809. case 2:
  10810. val = this.file[name];
  10811. return _context5.abrupt('return', val !== undefined ? val : defaultValue);
  10812. case 4:
  10813. case 'end':
  10814. return _context5.stop();
  10815. }
  10816. }
  10817. }, _callee5, this);
  10818. }));
  10819. function get(_x5, _x6) {
  10820. return _ref5.apply(this, arguments);
  10821. }
  10822. return get;
  10823. }()
  10824. }, {
  10825. key: 'getMultiple',
  10826. value: function () {
  10827. var _ref6 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee6(properties) {
  10828. var values, name, val;
  10829. return _regenerator2.default.wrap(function _callee6$(_context6) {
  10830. while (1) {
  10831. switch (_context6.prev = _context6.next) {
  10832. case 0:
  10833. _context6.next = 2;
  10834. return this._initializedPromise;
  10835. case 2:
  10836. values = Object.create(null);
  10837. for (name in properties) {
  10838. val = this.file[name];
  10839. values[name] = val !== undefined ? val : properties[name];
  10840. }
  10841. return _context6.abrupt('return', values);
  10842. case 5:
  10843. case 'end':
  10844. return _context6.stop();
  10845. }
  10846. }
  10847. }, _callee6, this);
  10848. }));
  10849. function getMultiple(_x7) {
  10850. return _ref6.apply(this, arguments);
  10851. }
  10852. return getMultiple;
  10853. }()
  10854. }]);
  10855. return ViewHistory;
  10856. }();
  10857. exports.ViewHistory = ViewHistory;
  10858. /***/ }),
  10859. /* 38 */
  10860. /***/ (function(module, exports, __webpack_require__) {
  10861. "use strict";
  10862. Object.defineProperty(exports, "__esModule", {
  10863. value: true
  10864. });
  10865. exports.GenericCom = undefined;
  10866. var _regenerator = __webpack_require__(2);
  10867. var _regenerator2 = _interopRequireDefault(_regenerator);
  10868. 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; }; }();
  10869. var _app = __webpack_require__(1);
  10870. var _preferences = __webpack_require__(39);
  10871. var _download_manager = __webpack_require__(40);
  10872. var _genericl10n = __webpack_require__(41);
  10873. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10874. 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"); }); }; }
  10875. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10876. 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; }
  10877. 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; }
  10878. ;
  10879. var GenericCom = {};
  10880. var GenericPreferences = function (_BasePreferences) {
  10881. _inherits(GenericPreferences, _BasePreferences);
  10882. function GenericPreferences() {
  10883. _classCallCheck(this, GenericPreferences);
  10884. return _possibleConstructorReturn(this, (GenericPreferences.__proto__ || Object.getPrototypeOf(GenericPreferences)).apply(this, arguments));
  10885. }
  10886. _createClass(GenericPreferences, [{
  10887. key: '_writeToStorage',
  10888. value: function () {
  10889. var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee(prefObj) {
  10890. return _regenerator2.default.wrap(function _callee$(_context) {
  10891. while (1) {
  10892. switch (_context.prev = _context.next) {
  10893. case 0:
  10894. localStorage.setItem('pdfjs.preferences', JSON.stringify(prefObj));
  10895. case 1:
  10896. case 'end':
  10897. return _context.stop();
  10898. }
  10899. }
  10900. }, _callee, this);
  10901. }));
  10902. function _writeToStorage(_x) {
  10903. return _ref.apply(this, arguments);
  10904. }
  10905. return _writeToStorage;
  10906. }()
  10907. }, {
  10908. key: '_readFromStorage',
  10909. value: function () {
  10910. var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2(prefObj) {
  10911. return _regenerator2.default.wrap(function _callee2$(_context2) {
  10912. while (1) {
  10913. switch (_context2.prev = _context2.next) {
  10914. case 0:
  10915. return _context2.abrupt('return', JSON.parse(localStorage.getItem('pdfjs.preferences')));
  10916. case 1:
  10917. case 'end':
  10918. return _context2.stop();
  10919. }
  10920. }
  10921. }, _callee2, this);
  10922. }));
  10923. function _readFromStorage(_x2) {
  10924. return _ref2.apply(this, arguments);
  10925. }
  10926. return _readFromStorage;
  10927. }()
  10928. }]);
  10929. return GenericPreferences;
  10930. }(_preferences.BasePreferences);
  10931. var GenericExternalServices = Object.create(_app.DefaultExternalServices);
  10932. GenericExternalServices.createDownloadManager = function (options) {
  10933. return new _download_manager.DownloadManager(options);
  10934. };
  10935. GenericExternalServices.createPreferences = function () {
  10936. return new GenericPreferences();
  10937. };
  10938. GenericExternalServices.createL10n = function (_ref3) {
  10939. var _ref3$locale = _ref3.locale,
  10940. locale = _ref3$locale === undefined ? 'en-US' : _ref3$locale;
  10941. return new _genericl10n.GenericL10n(locale);
  10942. };
  10943. _app.PDFViewerApplication.externalServices = GenericExternalServices;
  10944. exports.GenericCom = GenericCom;
  10945. /***/ }),
  10946. /* 39 */
  10947. /***/ (function(module, exports, __webpack_require__) {
  10948. "use strict";
  10949. Object.defineProperty(exports, "__esModule", {
  10950. value: true
  10951. });
  10952. exports.BasePreferences = undefined;
  10953. var _regenerator = __webpack_require__(2);
  10954. var _regenerator2 = _interopRequireDefault(_regenerator);
  10955. 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; };
  10956. 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; }; }();
  10957. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10958. 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"); }); }; }
  10959. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10960. var defaultPreferences = null;
  10961. function getDefaultPreferences() {
  10962. if (!defaultPreferences) {
  10963. defaultPreferences = Promise.resolve({
  10964. "showPreviousViewOnLoad": true,
  10965. "defaultZoomValue": "",
  10966. "sidebarViewOnLoad": 0,
  10967. "cursorToolOnLoad": 0,
  10968. "enableWebGL": false,
  10969. "eventBusDispatchToDOM": false,
  10970. "pdfBugEnabled": false,
  10971. "disableRange": false,
  10972. "disableStream": false,
  10973. "disableAutoFetch": false,
  10974. "disableFontFace": false,
  10975. "textLayerMode": 1,
  10976. "useOnlyCssZoom": false,
  10977. "externalLinkTarget": 0,
  10978. "renderer": "canvas",
  10979. "renderInteractiveForms": false,
  10980. "enablePrintAutoRotate": false,
  10981. "disablePageMode": false,
  10982. "disablePageLabels": false,
  10983. "scrollModeOnLoad": 0,
  10984. "spreadModeOnLoad": 0
  10985. });
  10986. }
  10987. return defaultPreferences;
  10988. }
  10989. var BasePreferences = function () {
  10990. function BasePreferences() {
  10991. var _this = this;
  10992. _classCallCheck(this, BasePreferences);
  10993. if (this.constructor === BasePreferences) {
  10994. throw new Error('Cannot initialize BasePreferences.');
  10995. }
  10996. this.prefs = null;
  10997. this._initializedPromise = getDefaultPreferences().then(function (defaults) {
  10998. Object.defineProperty(_this, 'defaults', {
  10999. value: Object.freeze(defaults),
  11000. writable: false,
  11001. enumerable: true,
  11002. configurable: false
  11003. });
  11004. _this.prefs = Object.assign(Object.create(null), defaults);
  11005. return _this._readFromStorage(defaults);
  11006. }).then(function (prefs) {
  11007. if (!prefs) {
  11008. return;
  11009. }
  11010. for (var name in prefs) {
  11011. var defaultValue = _this.defaults[name],
  11012. prefValue = prefs[name];
  11013. if (defaultValue === undefined || (typeof prefValue === "undefined" ? "undefined" : _typeof(prefValue)) !== (typeof defaultValue === "undefined" ? "undefined" : _typeof(defaultValue))) {
  11014. continue;
  11015. }
  11016. _this.prefs[name] = prefValue;
  11017. }
  11018. });
  11019. }
  11020. _createClass(BasePreferences, [{
  11021. key: "_writeToStorage",
  11022. value: function () {
  11023. var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee(prefObj) {
  11024. return _regenerator2.default.wrap(function _callee$(_context) {
  11025. while (1) {
  11026. switch (_context.prev = _context.next) {
  11027. case 0:
  11028. throw new Error('Not implemented: _writeToStorage');
  11029. case 1:
  11030. case "end":
  11031. return _context.stop();
  11032. }
  11033. }
  11034. }, _callee, this);
  11035. }));
  11036. function _writeToStorage(_x) {
  11037. return _ref.apply(this, arguments);
  11038. }
  11039. return _writeToStorage;
  11040. }()
  11041. }, {
  11042. key: "_readFromStorage",
  11043. value: function () {
  11044. var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2(prefObj) {
  11045. return _regenerator2.default.wrap(function _callee2$(_context2) {
  11046. while (1) {
  11047. switch (_context2.prev = _context2.next) {
  11048. case 0:
  11049. throw new Error('Not implemented: _readFromStorage');
  11050. case 1:
  11051. case "end":
  11052. return _context2.stop();
  11053. }
  11054. }
  11055. }, _callee2, this);
  11056. }));
  11057. function _readFromStorage(_x2) {
  11058. return _ref2.apply(this, arguments);
  11059. }
  11060. return _readFromStorage;
  11061. }()
  11062. }, {
  11063. key: "reset",
  11064. value: function () {
  11065. var _ref3 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee3() {
  11066. return _regenerator2.default.wrap(function _callee3$(_context3) {
  11067. while (1) {
  11068. switch (_context3.prev = _context3.next) {
  11069. case 0:
  11070. _context3.next = 2;
  11071. return this._initializedPromise;
  11072. case 2:
  11073. this.prefs = Object.assign(Object.create(null), this.defaults);
  11074. return _context3.abrupt("return", this._writeToStorage(this.defaults));
  11075. case 4:
  11076. case "end":
  11077. return _context3.stop();
  11078. }
  11079. }
  11080. }, _callee3, this);
  11081. }));
  11082. function reset() {
  11083. return _ref3.apply(this, arguments);
  11084. }
  11085. return reset;
  11086. }()
  11087. }, {
  11088. key: "set",
  11089. value: function () {
  11090. var _ref4 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee4(name, value) {
  11091. var defaultValue, valueType, defaultType;
  11092. return _regenerator2.default.wrap(function _callee4$(_context4) {
  11093. while (1) {
  11094. switch (_context4.prev = _context4.next) {
  11095. case 0:
  11096. _context4.next = 2;
  11097. return this._initializedPromise;
  11098. case 2:
  11099. defaultValue = this.defaults[name];
  11100. if (!(defaultValue === undefined)) {
  11101. _context4.next = 7;
  11102. break;
  11103. }
  11104. throw new Error("Set preference: \"" + name + "\" is undefined.");
  11105. case 7:
  11106. if (!(value === undefined)) {
  11107. _context4.next = 9;
  11108. break;
  11109. }
  11110. throw new Error('Set preference: no value is specified.');
  11111. case 9:
  11112. valueType = typeof value === "undefined" ? "undefined" : _typeof(value);
  11113. defaultType = typeof defaultValue === "undefined" ? "undefined" : _typeof(defaultValue);
  11114. if (!(valueType !== defaultType)) {
  11115. _context4.next = 19;
  11116. break;
  11117. }
  11118. if (!(valueType === 'number' && defaultType === 'string')) {
  11119. _context4.next = 16;
  11120. break;
  11121. }
  11122. value = value.toString();
  11123. _context4.next = 17;
  11124. break;
  11125. case 16:
  11126. throw new Error("Set preference: \"" + value + "\" is a " + valueType + ", " + ("expected a " + defaultType + "."));
  11127. case 17:
  11128. _context4.next = 21;
  11129. break;
  11130. case 19:
  11131. if (!(valueType === 'number' && !Number.isInteger(value))) {
  11132. _context4.next = 21;
  11133. break;
  11134. }
  11135. throw new Error("Set preference: \"" + value + "\" must be an integer.");
  11136. case 21:
  11137. this.prefs[name] = value;
  11138. return _context4.abrupt("return", this._writeToStorage(this.prefs));
  11139. case 23:
  11140. case "end":
  11141. return _context4.stop();
  11142. }
  11143. }
  11144. }, _callee4, this);
  11145. }));
  11146. function set(_x3, _x4) {
  11147. return _ref4.apply(this, arguments);
  11148. }
  11149. return set;
  11150. }()
  11151. }, {
  11152. key: "get",
  11153. value: function () {
  11154. var _ref5 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee5(name) {
  11155. var defaultValue, prefValue;
  11156. return _regenerator2.default.wrap(function _callee5$(_context5) {
  11157. while (1) {
  11158. switch (_context5.prev = _context5.next) {
  11159. case 0:
  11160. _context5.next = 2;
  11161. return this._initializedPromise;
  11162. case 2:
  11163. defaultValue = this.defaults[name];
  11164. if (!(defaultValue === undefined)) {
  11165. _context5.next = 7;
  11166. break;
  11167. }
  11168. throw new Error("Get preference: \"" + name + "\" is undefined.");
  11169. case 7:
  11170. prefValue = this.prefs[name];
  11171. if (!(prefValue !== undefined)) {
  11172. _context5.next = 10;
  11173. break;
  11174. }
  11175. return _context5.abrupt("return", prefValue);
  11176. case 10:
  11177. return _context5.abrupt("return", defaultValue);
  11178. case 11:
  11179. case "end":
  11180. return _context5.stop();
  11181. }
  11182. }
  11183. }, _callee5, this);
  11184. }));
  11185. function get(_x5) {
  11186. return _ref5.apply(this, arguments);
  11187. }
  11188. return get;
  11189. }()
  11190. }, {
  11191. key: "getAll",
  11192. value: function () {
  11193. var _ref6 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee6() {
  11194. return _regenerator2.default.wrap(function _callee6$(_context6) {
  11195. while (1) {
  11196. switch (_context6.prev = _context6.next) {
  11197. case 0:
  11198. _context6.next = 2;
  11199. return this._initializedPromise;
  11200. case 2:
  11201. return _context6.abrupt("return", Object.assign(Object.create(null), this.defaults, this.prefs));
  11202. case 3:
  11203. case "end":
  11204. return _context6.stop();
  11205. }
  11206. }
  11207. }, _callee6, this);
  11208. }));
  11209. function getAll() {
  11210. return _ref6.apply(this, arguments);
  11211. }
  11212. return getAll;
  11213. }()
  11214. }]);
  11215. return BasePreferences;
  11216. }();
  11217. exports.BasePreferences = BasePreferences;
  11218. /***/ }),
  11219. /* 40 */
  11220. /***/ (function(module, exports, __webpack_require__) {
  11221. "use strict";
  11222. Object.defineProperty(exports, "__esModule", {
  11223. value: true
  11224. });
  11225. exports.DownloadManager = undefined;
  11226. 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; }; }();
  11227. var _pdfjsLib = __webpack_require__(7);
  11228. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11229. ;
  11230. var DISABLE_CREATE_OBJECT_URL = _pdfjsLib.apiCompatibilityParams.disableCreateObjectURL || false;
  11231. function _download(blobUrl, filename) {
  11232. var a = document.createElement('a');
  11233. if (!a.click) {
  11234. throw new Error('DownloadManager: "a.click()" is not supported.');
  11235. }
  11236. a.href = blobUrl;
  11237. a.target = '_parent';
  11238. if ('download' in a) {
  11239. a.download = filename;
  11240. }
  11241. (document.body || document.documentElement).appendChild(a);
  11242. a.click();
  11243. a.remove();
  11244. }
  11245. var DownloadManager = function () {
  11246. function DownloadManager(_ref) {
  11247. var _ref$disableCreateObj = _ref.disableCreateObjectURL,
  11248. disableCreateObjectURL = _ref$disableCreateObj === undefined ? DISABLE_CREATE_OBJECT_URL : _ref$disableCreateObj;
  11249. _classCallCheck(this, DownloadManager);
  11250. this.disableCreateObjectURL = disableCreateObjectURL;
  11251. }
  11252. _createClass(DownloadManager, [{
  11253. key: 'downloadUrl',
  11254. value: function downloadUrl(url, filename) {
  11255. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, 'http://example.com')) {
  11256. return;
  11257. }
  11258. _download(url + '#pdfjs.action=download', filename);
  11259. }
  11260. }, {
  11261. key: 'downloadData',
  11262. value: function downloadData(data, filename, contentType) {
  11263. if (navigator.msSaveBlob) {
  11264. return navigator.msSaveBlob(new Blob([data], { type: contentType }), filename);
  11265. }
  11266. var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, this.disableCreateObjectURL);
  11267. _download(blobUrl, filename);
  11268. }
  11269. }, {
  11270. key: 'download',
  11271. value: function download(blob, url, filename) {
  11272. if (navigator.msSaveBlob) {
  11273. if (!navigator.msSaveBlob(blob, filename)) {
  11274. this.downloadUrl(url, filename);
  11275. }
  11276. return;
  11277. }
  11278. if (this.disableCreateObjectURL) {
  11279. this.downloadUrl(url, filename);
  11280. return;
  11281. }
  11282. var blobUrl = _pdfjsLib.URL.createObjectURL(blob);
  11283. _download(blobUrl, filename);
  11284. }
  11285. }]);
  11286. return DownloadManager;
  11287. }();
  11288. exports.DownloadManager = DownloadManager;
  11289. /***/ }),
  11290. /* 41 */
  11291. /***/ (function(module, exports, __webpack_require__) {
  11292. "use strict";
  11293. Object.defineProperty(exports, "__esModule", {
  11294. value: true
  11295. });
  11296. exports.GenericL10n = undefined;
  11297. var _regenerator = __webpack_require__(2);
  11298. var _regenerator2 = _interopRequireDefault(_regenerator);
  11299. 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; }; }();
  11300. __webpack_require__(42);
  11301. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11302. 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"); }); }; }
  11303. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11304. var webL10n = document.webL10n;
  11305. var GenericL10n = function () {
  11306. function GenericL10n(lang) {
  11307. _classCallCheck(this, GenericL10n);
  11308. this._lang = lang;
  11309. this._ready = new Promise(function (resolve, reject) {
  11310. webL10n.setLanguage(lang, function () {
  11311. resolve(webL10n);
  11312. });
  11313. });
  11314. }
  11315. _createClass(GenericL10n, [{
  11316. key: 'getLanguage',
  11317. value: function () {
  11318. var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee() {
  11319. var l10n;
  11320. return _regenerator2.default.wrap(function _callee$(_context) {
  11321. while (1) {
  11322. switch (_context.prev = _context.next) {
  11323. case 0:
  11324. _context.next = 2;
  11325. return this._ready;
  11326. case 2:
  11327. l10n = _context.sent;
  11328. return _context.abrupt('return', l10n.getLanguage());
  11329. case 4:
  11330. case 'end':
  11331. return _context.stop();
  11332. }
  11333. }
  11334. }, _callee, this);
  11335. }));
  11336. function getLanguage() {
  11337. return _ref.apply(this, arguments);
  11338. }
  11339. return getLanguage;
  11340. }()
  11341. }, {
  11342. key: 'getDirection',
  11343. value: function () {
  11344. var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2() {
  11345. var l10n;
  11346. return _regenerator2.default.wrap(function _callee2$(_context2) {
  11347. while (1) {
  11348. switch (_context2.prev = _context2.next) {
  11349. case 0:
  11350. _context2.next = 2;
  11351. return this._ready;
  11352. case 2:
  11353. l10n = _context2.sent;
  11354. return _context2.abrupt('return', l10n.getDirection());
  11355. case 4:
  11356. case 'end':
  11357. return _context2.stop();
  11358. }
  11359. }
  11360. }, _callee2, this);
  11361. }));
  11362. function getDirection() {
  11363. return _ref2.apply(this, arguments);
  11364. }
  11365. return getDirection;
  11366. }()
  11367. }, {
  11368. key: 'get',
  11369. value: function () {
  11370. var _ref3 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee3(property, args, fallback) {
  11371. var l10n;
  11372. return _regenerator2.default.wrap(function _callee3$(_context3) {
  11373. while (1) {
  11374. switch (_context3.prev = _context3.next) {
  11375. case 0:
  11376. _context3.next = 2;
  11377. return this._ready;
  11378. case 2:
  11379. l10n = _context3.sent;
  11380. return _context3.abrupt('return', l10n.get(property, args, fallback));
  11381. case 4:
  11382. case 'end':
  11383. return _context3.stop();
  11384. }
  11385. }
  11386. }, _callee3, this);
  11387. }));
  11388. function get(_x, _x2, _x3) {
  11389. return _ref3.apply(this, arguments);
  11390. }
  11391. return get;
  11392. }()
  11393. }, {
  11394. key: 'translate',
  11395. value: function () {
  11396. var _ref4 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee4(element) {
  11397. var l10n;
  11398. return _regenerator2.default.wrap(function _callee4$(_context4) {
  11399. while (1) {
  11400. switch (_context4.prev = _context4.next) {
  11401. case 0:
  11402. _context4.next = 2;
  11403. return this._ready;
  11404. case 2:
  11405. l10n = _context4.sent;
  11406. return _context4.abrupt('return', l10n.translate(element));
  11407. case 4:
  11408. case 'end':
  11409. return _context4.stop();
  11410. }
  11411. }
  11412. }, _callee4, this);
  11413. }));
  11414. function translate(_x4) {
  11415. return _ref4.apply(this, arguments);
  11416. }
  11417. return translate;
  11418. }()
  11419. }]);
  11420. return GenericL10n;
  11421. }();
  11422. exports.GenericL10n = GenericL10n;
  11423. /***/ }),
  11424. /* 42 */
  11425. /***/ (function(module, exports, __webpack_require__) {
  11426. "use strict";
  11427. document.webL10n = function (window, document, undefined) {
  11428. var gL10nData = {};
  11429. var gTextData = '';
  11430. var gTextProp = 'textContent';
  11431. var gLanguage = '';
  11432. var gMacros = {};
  11433. var gReadyState = 'loading';
  11434. var gAsyncResourceLoading = true;
  11435. function getL10nResourceLinks() {
  11436. return document.querySelectorAll('link[type="application/l10n"]');
  11437. }
  11438. function getL10nDictionary() {
  11439. var script = document.querySelector('script[type="application/l10n"]');
  11440. return script ? JSON.parse(script.innerHTML) : null;
  11441. }
  11442. function getTranslatableChildren(element) {
  11443. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  11444. }
  11445. function getL10nAttributes(element) {
  11446. if (!element) return {};
  11447. var l10nId = element.getAttribute('data-l10n-id');
  11448. var l10nArgs = element.getAttribute('data-l10n-args');
  11449. var args = {};
  11450. if (l10nArgs) {
  11451. try {
  11452. args = JSON.parse(l10nArgs);
  11453. } catch (e) {
  11454. console.warn('could not parse arguments for #' + l10nId);
  11455. }
  11456. }
  11457. return {
  11458. id: l10nId,
  11459. args: args
  11460. };
  11461. }
  11462. function fireL10nReadyEvent(lang) {
  11463. var evtObject = document.createEvent('Event');
  11464. evtObject.initEvent('localized', true, false);
  11465. evtObject.language = lang;
  11466. document.dispatchEvent(evtObject);
  11467. }
  11468. function xhrLoadText(url, onSuccess, onFailure) {
  11469. onSuccess = onSuccess || function _onSuccess(data) {};
  11470. onFailure = onFailure || function _onFailure() {};
  11471. var xhr = new XMLHttpRequest();
  11472. xhr.open('GET', url, gAsyncResourceLoading);
  11473. if (xhr.overrideMimeType) {
  11474. xhr.overrideMimeType('text/plain; charset=utf-8');
  11475. }
  11476. xhr.onreadystatechange = function () {
  11477. if (xhr.readyState == 4) {
  11478. if (xhr.status == 200 || xhr.status === 0) {
  11479. onSuccess(xhr.responseText);
  11480. } else {
  11481. onFailure();
  11482. }
  11483. }
  11484. };
  11485. xhr.onerror = onFailure;
  11486. xhr.ontimeout = onFailure;
  11487. try {
  11488. xhr.send(null);
  11489. } catch (e) {
  11490. onFailure();
  11491. }
  11492. }
  11493. function parseResource(href, lang, successCallback, failureCallback) {
  11494. var baseURL = href.replace(/[^\/]*$/, '') || './';
  11495. function evalString(text) {
  11496. if (text.lastIndexOf('\\') < 0) return text;
  11497. 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, "'");
  11498. }
  11499. function parseProperties(text, parsedPropertiesCallback) {
  11500. var dictionary = {};
  11501. var reBlank = /^\s*|\s*$/;
  11502. var reComment = /^\s*#|^\s*$/;
  11503. var reSection = /^\s*\[(.*)\]\s*$/;
  11504. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  11505. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  11506. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  11507. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  11508. var currentLang = '*';
  11509. var genericLang = lang.split('-', 1)[0];
  11510. var skipLang = false;
  11511. var match = '';
  11512. function nextEntry() {
  11513. while (true) {
  11514. if (!entries.length) {
  11515. parsedRawLinesCallback();
  11516. return;
  11517. }
  11518. var line = entries.shift();
  11519. if (reComment.test(line)) continue;
  11520. if (extendedSyntax) {
  11521. match = reSection.exec(line);
  11522. if (match) {
  11523. currentLang = match[1].toLowerCase();
  11524. skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
  11525. continue;
  11526. } else if (skipLang) {
  11527. continue;
  11528. }
  11529. match = reImport.exec(line);
  11530. if (match) {
  11531. loadImport(baseURL + match[1], nextEntry);
  11532. return;
  11533. }
  11534. }
  11535. var tmp = line.match(reSplit);
  11536. if (tmp && tmp.length == 3) {
  11537. dictionary[tmp[1]] = evalString(tmp[2]);
  11538. }
  11539. }
  11540. }
  11541. nextEntry();
  11542. }
  11543. function loadImport(url, callback) {
  11544. xhrLoadText(url, function (content) {
  11545. parseRawLines(content, false, callback);
  11546. }, function () {
  11547. console.warn(url + ' not found.');
  11548. callback();
  11549. });
  11550. }
  11551. parseRawLines(text, true, function () {
  11552. parsedPropertiesCallback(dictionary);
  11553. });
  11554. }
  11555. xhrLoadText(href, function (response) {
  11556. gTextData += response;
  11557. parseProperties(response, function (data) {
  11558. for (var key in data) {
  11559. var id,
  11560. prop,
  11561. index = key.lastIndexOf('.');
  11562. if (index > 0) {
  11563. id = key.substring(0, index);
  11564. prop = key.substring(index + 1);
  11565. } else {
  11566. id = key;
  11567. prop = gTextProp;
  11568. }
  11569. if (!gL10nData[id]) {
  11570. gL10nData[id] = {};
  11571. }
  11572. gL10nData[id][prop] = data[key];
  11573. }
  11574. if (successCallback) {
  11575. successCallback();
  11576. }
  11577. });
  11578. }, failureCallback);
  11579. }
  11580. function loadLocale(lang, callback) {
  11581. if (lang) {
  11582. lang = lang.toLowerCase();
  11583. }
  11584. callback = callback || function _callback() {};
  11585. clear();
  11586. gLanguage = lang;
  11587. var langLinks = getL10nResourceLinks();
  11588. var langCount = langLinks.length;
  11589. if (langCount === 0) {
  11590. var dict = getL10nDictionary();
  11591. if (dict && dict.locales && dict.default_locale) {
  11592. console.log('using the embedded JSON directory, early way out');
  11593. gL10nData = dict.locales[lang];
  11594. if (!gL10nData) {
  11595. var defaultLocale = dict.default_locale.toLowerCase();
  11596. for (var anyCaseLang in dict.locales) {
  11597. anyCaseLang = anyCaseLang.toLowerCase();
  11598. if (anyCaseLang === lang) {
  11599. gL10nData = dict.locales[lang];
  11600. break;
  11601. } else if (anyCaseLang === defaultLocale) {
  11602. gL10nData = dict.locales[defaultLocale];
  11603. }
  11604. }
  11605. }
  11606. callback();
  11607. } else {
  11608. console.log('no resource to load, early way out');
  11609. }
  11610. fireL10nReadyEvent(lang);
  11611. gReadyState = 'complete';
  11612. return;
  11613. }
  11614. var onResourceLoaded = null;
  11615. var gResourceCount = 0;
  11616. onResourceLoaded = function onResourceLoaded() {
  11617. gResourceCount++;
  11618. if (gResourceCount >= langCount) {
  11619. callback();
  11620. fireL10nReadyEvent(lang);
  11621. gReadyState = 'complete';
  11622. }
  11623. };
  11624. function L10nResourceLink(link) {
  11625. var href = link.href;
  11626. this.load = function (lang, callback) {
  11627. parseResource(href, lang, callback, function () {
  11628. console.warn(href + ' not found.');
  11629. console.warn('"' + lang + '" resource not found');
  11630. gLanguage = '';
  11631. callback();
  11632. });
  11633. };
  11634. }
  11635. for (var i = 0; i < langCount; i++) {
  11636. var resource = new L10nResourceLink(langLinks[i]);
  11637. resource.load(lang, onResourceLoaded);
  11638. }
  11639. }
  11640. function clear() {
  11641. gL10nData = {};
  11642. gTextData = '';
  11643. gLanguage = '';
  11644. }
  11645. function getPluralRules(lang) {
  11646. var locales2rules = {
  11647. 'af': 3,
  11648. 'ak': 4,
  11649. 'am': 4,
  11650. 'ar': 1,
  11651. 'asa': 3,
  11652. 'az': 0,
  11653. 'be': 11,
  11654. 'bem': 3,
  11655. 'bez': 3,
  11656. 'bg': 3,
  11657. 'bh': 4,
  11658. 'bm': 0,
  11659. 'bn': 3,
  11660. 'bo': 0,
  11661. 'br': 20,
  11662. 'brx': 3,
  11663. 'bs': 11,
  11664. 'ca': 3,
  11665. 'cgg': 3,
  11666. 'chr': 3,
  11667. 'cs': 12,
  11668. 'cy': 17,
  11669. 'da': 3,
  11670. 'de': 3,
  11671. 'dv': 3,
  11672. 'dz': 0,
  11673. 'ee': 3,
  11674. 'el': 3,
  11675. 'en': 3,
  11676. 'eo': 3,
  11677. 'es': 3,
  11678. 'et': 3,
  11679. 'eu': 3,
  11680. 'fa': 0,
  11681. 'ff': 5,
  11682. 'fi': 3,
  11683. 'fil': 4,
  11684. 'fo': 3,
  11685. 'fr': 5,
  11686. 'fur': 3,
  11687. 'fy': 3,
  11688. 'ga': 8,
  11689. 'gd': 24,
  11690. 'gl': 3,
  11691. 'gsw': 3,
  11692. 'gu': 3,
  11693. 'guw': 4,
  11694. 'gv': 23,
  11695. 'ha': 3,
  11696. 'haw': 3,
  11697. 'he': 2,
  11698. 'hi': 4,
  11699. 'hr': 11,
  11700. 'hu': 0,
  11701. 'id': 0,
  11702. 'ig': 0,
  11703. 'ii': 0,
  11704. 'is': 3,
  11705. 'it': 3,
  11706. 'iu': 7,
  11707. 'ja': 0,
  11708. 'jmc': 3,
  11709. 'jv': 0,
  11710. 'ka': 0,
  11711. 'kab': 5,
  11712. 'kaj': 3,
  11713. 'kcg': 3,
  11714. 'kde': 0,
  11715. 'kea': 0,
  11716. 'kk': 3,
  11717. 'kl': 3,
  11718. 'km': 0,
  11719. 'kn': 0,
  11720. 'ko': 0,
  11721. 'ksb': 3,
  11722. 'ksh': 21,
  11723. 'ku': 3,
  11724. 'kw': 7,
  11725. 'lag': 18,
  11726. 'lb': 3,
  11727. 'lg': 3,
  11728. 'ln': 4,
  11729. 'lo': 0,
  11730. 'lt': 10,
  11731. 'lv': 6,
  11732. 'mas': 3,
  11733. 'mg': 4,
  11734. 'mk': 16,
  11735. 'ml': 3,
  11736. 'mn': 3,
  11737. 'mo': 9,
  11738. 'mr': 3,
  11739. 'ms': 0,
  11740. 'mt': 15,
  11741. 'my': 0,
  11742. 'nah': 3,
  11743. 'naq': 7,
  11744. 'nb': 3,
  11745. 'nd': 3,
  11746. 'ne': 3,
  11747. 'nl': 3,
  11748. 'nn': 3,
  11749. 'no': 3,
  11750. 'nr': 3,
  11751. 'nso': 4,
  11752. 'ny': 3,
  11753. 'nyn': 3,
  11754. 'om': 3,
  11755. 'or': 3,
  11756. 'pa': 3,
  11757. 'pap': 3,
  11758. 'pl': 13,
  11759. 'ps': 3,
  11760. 'pt': 3,
  11761. 'rm': 3,
  11762. 'ro': 9,
  11763. 'rof': 3,
  11764. 'ru': 11,
  11765. 'rwk': 3,
  11766. 'sah': 0,
  11767. 'saq': 3,
  11768. 'se': 7,
  11769. 'seh': 3,
  11770. 'ses': 0,
  11771. 'sg': 0,
  11772. 'sh': 11,
  11773. 'shi': 19,
  11774. 'sk': 12,
  11775. 'sl': 14,
  11776. 'sma': 7,
  11777. 'smi': 7,
  11778. 'smj': 7,
  11779. 'smn': 7,
  11780. 'sms': 7,
  11781. 'sn': 3,
  11782. 'so': 3,
  11783. 'sq': 3,
  11784. 'sr': 11,
  11785. 'ss': 3,
  11786. 'ssy': 3,
  11787. 'st': 3,
  11788. 'sv': 3,
  11789. 'sw': 3,
  11790. 'syr': 3,
  11791. 'ta': 3,
  11792. 'te': 3,
  11793. 'teo': 3,
  11794. 'th': 0,
  11795. 'ti': 4,
  11796. 'tig': 3,
  11797. 'tk': 3,
  11798. 'tl': 4,
  11799. 'tn': 3,
  11800. 'to': 0,
  11801. 'tr': 0,
  11802. 'ts': 3,
  11803. 'tzm': 22,
  11804. 'uk': 11,
  11805. 'ur': 3,
  11806. 've': 3,
  11807. 'vi': 0,
  11808. 'vun': 3,
  11809. 'wa': 4,
  11810. 'wae': 3,
  11811. 'wo': 0,
  11812. 'xh': 3,
  11813. 'xog': 3,
  11814. 'yo': 0,
  11815. 'zh': 0,
  11816. 'zu': 3
  11817. };
  11818. function isIn(n, list) {
  11819. return list.indexOf(n) !== -1;
  11820. }
  11821. function isBetween(n, start, end) {
  11822. return start <= n && n <= end;
  11823. }
  11824. var pluralRules = {
  11825. '0': function _(n) {
  11826. return 'other';
  11827. },
  11828. '1': function _(n) {
  11829. if (isBetween(n % 100, 3, 10)) return 'few';
  11830. if (n === 0) return 'zero';
  11831. if (isBetween(n % 100, 11, 99)) return 'many';
  11832. if (n == 2) return 'two';
  11833. if (n == 1) return 'one';
  11834. return 'other';
  11835. },
  11836. '2': function _(n) {
  11837. if (n !== 0 && n % 10 === 0) return 'many';
  11838. if (n == 2) return 'two';
  11839. if (n == 1) return 'one';
  11840. return 'other';
  11841. },
  11842. '3': function _(n) {
  11843. if (n == 1) return 'one';
  11844. return 'other';
  11845. },
  11846. '4': function _(n) {
  11847. if (isBetween(n, 0, 1)) return 'one';
  11848. return 'other';
  11849. },
  11850. '5': function _(n) {
  11851. if (isBetween(n, 0, 2) && n != 2) return 'one';
  11852. return 'other';
  11853. },
  11854. '6': function _(n) {
  11855. if (n === 0) return 'zero';
  11856. if (n % 10 == 1 && n % 100 != 11) return 'one';
  11857. return 'other';
  11858. },
  11859. '7': function _(n) {
  11860. if (n == 2) return 'two';
  11861. if (n == 1) return 'one';
  11862. return 'other';
  11863. },
  11864. '8': function _(n) {
  11865. if (isBetween(n, 3, 6)) return 'few';
  11866. if (isBetween(n, 7, 10)) return 'many';
  11867. if (n == 2) return 'two';
  11868. if (n == 1) return 'one';
  11869. return 'other';
  11870. },
  11871. '9': function _(n) {
  11872. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  11873. if (n == 1) return 'one';
  11874. return 'other';
  11875. },
  11876. '10': function _(n) {
  11877. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  11878. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  11879. return 'other';
  11880. },
  11881. '11': function _(n) {
  11882. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  11883. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
  11884. if (n % 10 == 1 && n % 100 != 11) return 'one';
  11885. return 'other';
  11886. },
  11887. '12': function _(n) {
  11888. if (isBetween(n, 2, 4)) return 'few';
  11889. if (n == 1) return 'one';
  11890. return 'other';
  11891. },
  11892. '13': function _(n) {
  11893. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  11894. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
  11895. if (n == 1) return 'one';
  11896. return 'other';
  11897. },
  11898. '14': function _(n) {
  11899. if (isBetween(n % 100, 3, 4)) return 'few';
  11900. if (n % 100 == 2) return 'two';
  11901. if (n % 100 == 1) return 'one';
  11902. return 'other';
  11903. },
  11904. '15': function _(n) {
  11905. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  11906. if (isBetween(n % 100, 11, 19)) return 'many';
  11907. if (n == 1) return 'one';
  11908. return 'other';
  11909. },
  11910. '16': function _(n) {
  11911. if (n % 10 == 1 && n != 11) return 'one';
  11912. return 'other';
  11913. },
  11914. '17': function _(n) {
  11915. if (n == 3) return 'few';
  11916. if (n === 0) return 'zero';
  11917. if (n == 6) return 'many';
  11918. if (n == 2) return 'two';
  11919. if (n == 1) return 'one';
  11920. return 'other';
  11921. },
  11922. '18': function _(n) {
  11923. if (n === 0) return 'zero';
  11924. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  11925. return 'other';
  11926. },
  11927. '19': function _(n) {
  11928. if (isBetween(n, 2, 10)) return 'few';
  11929. if (isBetween(n, 0, 1)) return 'one';
  11930. return 'other';
  11931. },
  11932. '20': function _(n) {
  11933. 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';
  11934. if (n % 1000000 === 0 && n !== 0) return 'many';
  11935. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  11936. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  11937. return 'other';
  11938. },
  11939. '21': function _(n) {
  11940. if (n === 0) return 'zero';
  11941. if (n == 1) return 'one';
  11942. return 'other';
  11943. },
  11944. '22': function _(n) {
  11945. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  11946. return 'other';
  11947. },
  11948. '23': function _(n) {
  11949. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  11950. return 'other';
  11951. },
  11952. '24': function _(n) {
  11953. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  11954. if (isIn(n, [2, 12])) return 'two';
  11955. if (isIn(n, [1, 11])) return 'one';
  11956. return 'other';
  11957. }
  11958. };
  11959. var index = locales2rules[lang.replace(/-.*$/, '')];
  11960. if (!(index in pluralRules)) {
  11961. console.warn('plural form unknown for [' + lang + ']');
  11962. return function () {
  11963. return 'other';
  11964. };
  11965. }
  11966. return pluralRules[index];
  11967. }
  11968. gMacros.plural = function (str, param, key, prop) {
  11969. var n = parseFloat(param);
  11970. if (isNaN(n)) return str;
  11971. if (prop != gTextProp) return str;
  11972. if (!gMacros._pluralRules) {
  11973. gMacros._pluralRules = getPluralRules(gLanguage);
  11974. }
  11975. var index = '[' + gMacros._pluralRules(n) + ']';
  11976. if (n === 0 && key + '[zero]' in gL10nData) {
  11977. str = gL10nData[key + '[zero]'][prop];
  11978. } else if (n == 1 && key + '[one]' in gL10nData) {
  11979. str = gL10nData[key + '[one]'][prop];
  11980. } else if (n == 2 && key + '[two]' in gL10nData) {
  11981. str = gL10nData[key + '[two]'][prop];
  11982. } else if (key + index in gL10nData) {
  11983. str = gL10nData[key + index][prop];
  11984. } else if (key + '[other]' in gL10nData) {
  11985. str = gL10nData[key + '[other]'][prop];
  11986. }
  11987. return str;
  11988. };
  11989. function getL10nData(key, args, fallback) {
  11990. var data = gL10nData[key];
  11991. if (!data) {
  11992. console.warn('#' + key + ' is undefined.');
  11993. if (!fallback) {
  11994. return null;
  11995. }
  11996. data = fallback;
  11997. }
  11998. var rv = {};
  11999. for (var prop in data) {
  12000. var str = data[prop];
  12001. str = substIndexes(str, args, key, prop);
  12002. str = substArguments(str, args, key);
  12003. rv[prop] = str;
  12004. }
  12005. return rv;
  12006. }
  12007. function substIndexes(str, args, key, prop) {
  12008. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  12009. var reMatch = reIndex.exec(str);
  12010. if (!reMatch || !reMatch.length) return str;
  12011. var macroName = reMatch[1];
  12012. var paramName = reMatch[2];
  12013. var param;
  12014. if (args && paramName in args) {
  12015. param = args[paramName];
  12016. } else if (paramName in gL10nData) {
  12017. param = gL10nData[paramName];
  12018. }
  12019. if (macroName in gMacros) {
  12020. var macro = gMacros[macroName];
  12021. str = macro(str, param, key, prop);
  12022. }
  12023. return str;
  12024. }
  12025. function substArguments(str, args, key) {
  12026. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  12027. return str.replace(reArgs, function (matched_text, arg) {
  12028. if (args && arg in args) {
  12029. return args[arg];
  12030. }
  12031. if (arg in gL10nData) {
  12032. return gL10nData[arg];
  12033. }
  12034. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  12035. return matched_text;
  12036. });
  12037. }
  12038. function translateElement(element) {
  12039. var l10n = getL10nAttributes(element);
  12040. if (!l10n.id) return;
  12041. var data = getL10nData(l10n.id, l10n.args);
  12042. if (!data) {
  12043. console.warn('#' + l10n.id + ' is undefined.');
  12044. return;
  12045. }
  12046. if (data[gTextProp]) {
  12047. if (getChildElementCount(element) === 0) {
  12048. element[gTextProp] = data[gTextProp];
  12049. } else {
  12050. var children = element.childNodes;
  12051. var found = false;
  12052. for (var i = 0, l = children.length; i < l; i++) {
  12053. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  12054. if (found) {
  12055. children[i].nodeValue = '';
  12056. } else {
  12057. children[i].nodeValue = data[gTextProp];
  12058. found = true;
  12059. }
  12060. }
  12061. }
  12062. if (!found) {
  12063. var textNode = document.createTextNode(data[gTextProp]);
  12064. element.insertBefore(textNode, element.firstChild);
  12065. }
  12066. }
  12067. delete data[gTextProp];
  12068. }
  12069. for (var k in data) {
  12070. element[k] = data[k];
  12071. }
  12072. }
  12073. function getChildElementCount(element) {
  12074. if (element.children) {
  12075. return element.children.length;
  12076. }
  12077. if (typeof element.childElementCount !== 'undefined') {
  12078. return element.childElementCount;
  12079. }
  12080. var count = 0;
  12081. for (var i = 0; i < element.childNodes.length; i++) {
  12082. count += element.nodeType === 1 ? 1 : 0;
  12083. }
  12084. return count;
  12085. }
  12086. function translateFragment(element) {
  12087. element = element || document.documentElement;
  12088. var children = getTranslatableChildren(element);
  12089. var elementCount = children.length;
  12090. for (var i = 0; i < elementCount; i++) {
  12091. translateElement(children[i]);
  12092. }
  12093. translateElement(element);
  12094. }
  12095. return {
  12096. get: function get(key, args, fallbackString) {
  12097. var index = key.lastIndexOf('.');
  12098. var prop = gTextProp;
  12099. if (index > 0) {
  12100. prop = key.substring(index + 1);
  12101. key = key.substring(0, index);
  12102. }
  12103. var fallback;
  12104. if (fallbackString) {
  12105. fallback = {};
  12106. fallback[prop] = fallbackString;
  12107. }
  12108. var data = getL10nData(key, args, fallback);
  12109. if (data && prop in data) {
  12110. return data[prop];
  12111. }
  12112. return '{{' + key + '}}';
  12113. },
  12114. getData: function getData() {
  12115. return gL10nData;
  12116. },
  12117. getText: function getText() {
  12118. return gTextData;
  12119. },
  12120. getLanguage: function getLanguage() {
  12121. return gLanguage;
  12122. },
  12123. setLanguage: function setLanguage(lang, callback) {
  12124. loadLocale(lang, function () {
  12125. if (callback) callback();
  12126. });
  12127. },
  12128. getDirection: function getDirection() {
  12129. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  12130. var shortCode = gLanguage.split('-', 1)[0];
  12131. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  12132. },
  12133. translate: translateFragment,
  12134. getReadyState: function getReadyState() {
  12135. return gReadyState;
  12136. },
  12137. ready: function ready(callback) {
  12138. if (!callback) {
  12139. return;
  12140. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  12141. window.setTimeout(function () {
  12142. callback();
  12143. });
  12144. } else if (document.addEventListener) {
  12145. document.addEventListener('localized', function once() {
  12146. document.removeEventListener('localized', once);
  12147. callback();
  12148. });
  12149. }
  12150. }
  12151. };
  12152. }(window, document);
  12153. /***/ }),
  12154. /* 43 */
  12155. /***/ (function(module, exports, __webpack_require__) {
  12156. "use strict";
  12157. Object.defineProperty(exports, "__esModule", {
  12158. value: true
  12159. });
  12160. exports.PDFPrintService = undefined;
  12161. var _ui_utils = __webpack_require__(6);
  12162. var _app = __webpack_require__(1);
  12163. var _pdfjsLib = __webpack_require__(7);
  12164. var activeService = null;
  12165. var overlayManager = null;
  12166. function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size) {
  12167. var scratchCanvas = activeService.scratchCanvas;
  12168. var PRINT_RESOLUTION = 150;
  12169. var PRINT_UNITS = PRINT_RESOLUTION / 72.0;
  12170. scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
  12171. scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
  12172. var width = Math.floor(size.width * _ui_utils.CSS_UNITS) + 'px';
  12173. var height = Math.floor(size.height * _ui_utils.CSS_UNITS) + 'px';
  12174. var ctx = scratchCanvas.getContext('2d');
  12175. ctx.save();
  12176. ctx.fillStyle = 'rgb(255, 255, 255)';
  12177. ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height);
  12178. ctx.restore();
  12179. return pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  12180. var renderContext = {
  12181. canvasContext: ctx,
  12182. transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
  12183. viewport: pdfPage.getViewport(1, size.rotation),
  12184. intent: 'print'
  12185. };
  12186. return pdfPage.render(renderContext).promise;
  12187. }).then(function () {
  12188. return {
  12189. width: width,
  12190. height: height
  12191. };
  12192. });
  12193. }
  12194. function PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
  12195. this.pdfDocument = pdfDocument;
  12196. this.pagesOverview = pagesOverview;
  12197. this.printContainer = printContainer;
  12198. this.l10n = l10n || _ui_utils.NullL10n;
  12199. this.disableCreateObjectURL = pdfDocument.loadingParams['disableCreateObjectURL'];
  12200. this.currentPage = -1;
  12201. this.scratchCanvas = document.createElement('canvas');
  12202. }
  12203. PDFPrintService.prototype = {
  12204. layout: function layout() {
  12205. this.throwIfInactive();
  12206. var body = document.querySelector('body');
  12207. body.setAttribute('data-pdfjsprinting', true);
  12208. var hasEqualPageSizes = this.pagesOverview.every(function (size) {
  12209. return size.width === this.pagesOverview[0].width && size.height === this.pagesOverview[0].height;
  12210. }, this);
  12211. if (!hasEqualPageSizes) {
  12212. console.warn('Not all pages have the same size. The printed ' + 'result may be incorrect!');
  12213. }
  12214. this.pageStyleSheet = document.createElement('style');
  12215. var pageSize = this.pagesOverview[0];
  12216. this.pageStyleSheet.textContent = '@supports ((size:A4) and (size:1pt 1pt)) {' + '@page { size: ' + pageSize.width + 'pt ' + pageSize.height + 'pt;}' + '}';
  12217. body.appendChild(this.pageStyleSheet);
  12218. },
  12219. destroy: function destroy() {
  12220. if (activeService !== this) {
  12221. return;
  12222. }
  12223. this.printContainer.textContent = '';
  12224. if (this.pageStyleSheet) {
  12225. this.pageStyleSheet.remove();
  12226. this.pageStyleSheet = null;
  12227. }
  12228. this.scratchCanvas.width = this.scratchCanvas.height = 0;
  12229. this.scratchCanvas = null;
  12230. activeService = null;
  12231. ensureOverlay().then(function () {
  12232. if (overlayManager.active !== 'printServiceOverlay') {
  12233. return;
  12234. }
  12235. overlayManager.close('printServiceOverlay');
  12236. });
  12237. },
  12238. renderPages: function renderPages() {
  12239. var _this = this;
  12240. var pageCount = this.pagesOverview.length;
  12241. var renderNextPage = function renderNextPage(resolve, reject) {
  12242. _this.throwIfInactive();
  12243. if (++_this.currentPage >= pageCount) {
  12244. renderProgress(pageCount, pageCount, _this.l10n);
  12245. resolve();
  12246. return;
  12247. }
  12248. var index = _this.currentPage;
  12249. renderProgress(index, pageCount, _this.l10n);
  12250. renderPage(_this, _this.pdfDocument, index + 1, _this.pagesOverview[index]).then(_this.useRenderedPage.bind(_this)).then(function () {
  12251. renderNextPage(resolve, reject);
  12252. }, reject);
  12253. };
  12254. return new Promise(renderNextPage);
  12255. },
  12256. useRenderedPage: function useRenderedPage(printItem) {
  12257. this.throwIfInactive();
  12258. var img = document.createElement('img');
  12259. img.style.width = printItem.width;
  12260. img.style.height = printItem.height;
  12261. var scratchCanvas = this.scratchCanvas;
  12262. if ('toBlob' in scratchCanvas && !this.disableCreateObjectURL) {
  12263. scratchCanvas.toBlob(function (blob) {
  12264. img.src = _pdfjsLib.URL.createObjectURL(blob);
  12265. });
  12266. } else {
  12267. img.src = scratchCanvas.toDataURL();
  12268. }
  12269. var wrapper = document.createElement('div');
  12270. wrapper.appendChild(img);
  12271. this.printContainer.appendChild(wrapper);
  12272. return new Promise(function (resolve, reject) {
  12273. img.onload = resolve;
  12274. img.onerror = reject;
  12275. });
  12276. },
  12277. performPrint: function performPrint() {
  12278. var _this2 = this;
  12279. this.throwIfInactive();
  12280. return new Promise(function (resolve) {
  12281. setTimeout(function () {
  12282. if (!_this2.active) {
  12283. resolve();
  12284. return;
  12285. }
  12286. print.call(window);
  12287. setTimeout(resolve, 20);
  12288. }, 0);
  12289. });
  12290. },
  12291. get active() {
  12292. return this === activeService;
  12293. },
  12294. throwIfInactive: function throwIfInactive() {
  12295. if (!this.active) {
  12296. throw new Error('This print request was cancelled or completed.');
  12297. }
  12298. }
  12299. };
  12300. var print = window.print;
  12301. window.print = function print() {
  12302. if (activeService) {
  12303. console.warn('Ignored window.print() because of a pending print job.');
  12304. return;
  12305. }
  12306. ensureOverlay().then(function () {
  12307. if (activeService) {
  12308. overlayManager.open('printServiceOverlay');
  12309. }
  12310. });
  12311. try {
  12312. dispatchEvent('beforeprint');
  12313. } finally {
  12314. if (!activeService) {
  12315. console.error('Expected print service to be initialized.');
  12316. ensureOverlay().then(function () {
  12317. if (overlayManager.active === 'printServiceOverlay') {
  12318. overlayManager.close('printServiceOverlay');
  12319. }
  12320. });
  12321. return;
  12322. }
  12323. var activeServiceOnEntry = activeService;
  12324. activeService.renderPages().then(function () {
  12325. return activeServiceOnEntry.performPrint();
  12326. }).catch(function () {}).then(function () {
  12327. if (activeServiceOnEntry.active) {
  12328. abort();
  12329. }
  12330. });
  12331. }
  12332. };
  12333. function dispatchEvent(eventType) {
  12334. var event = document.createEvent('CustomEvent');
  12335. event.initCustomEvent(eventType, false, false, 'custom');
  12336. window.dispatchEvent(event);
  12337. }
  12338. function abort() {
  12339. if (activeService) {
  12340. activeService.destroy();
  12341. dispatchEvent('afterprint');
  12342. }
  12343. }
  12344. function renderProgress(index, total, l10n) {
  12345. var progressContainer = document.getElementById('printServiceOverlay');
  12346. var progress = Math.round(100 * index / total);
  12347. var progressBar = progressContainer.querySelector('progress');
  12348. var progressPerc = progressContainer.querySelector('.relative-progress');
  12349. progressBar.value = progress;
  12350. l10n.get('print_progress_percent', { progress: progress }, progress + '%').then(function (msg) {
  12351. progressPerc.textContent = msg;
  12352. });
  12353. }
  12354. var hasAttachEvent = !!document.attachEvent;
  12355. window.addEventListener('keydown', function (event) {
  12356. if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
  12357. window.print();
  12358. if (hasAttachEvent) {
  12359. return;
  12360. }
  12361. event.preventDefault();
  12362. if (event.stopImmediatePropagation) {
  12363. event.stopImmediatePropagation();
  12364. } else {
  12365. event.stopPropagation();
  12366. }
  12367. return;
  12368. }
  12369. }, true);
  12370. if (hasAttachEvent) {
  12371. document.attachEvent('onkeydown', function (event) {
  12372. event = event || window.event;
  12373. if (event.keyCode === 80 && event.ctrlKey) {
  12374. event.keyCode = 0;
  12375. return false;
  12376. }
  12377. });
  12378. }
  12379. if ('onbeforeprint' in window) {
  12380. var stopPropagationIfNeeded = function stopPropagationIfNeeded(event) {
  12381. if (event.detail !== 'custom' && event.stopImmediatePropagation) {
  12382. event.stopImmediatePropagation();
  12383. }
  12384. };
  12385. window.addEventListener('beforeprint', stopPropagationIfNeeded);
  12386. window.addEventListener('afterprint', stopPropagationIfNeeded);
  12387. }
  12388. var overlayPromise = void 0;
  12389. function ensureOverlay() {
  12390. if (!overlayPromise) {
  12391. overlayManager = _app.PDFViewerApplication.overlayManager;
  12392. if (!overlayManager) {
  12393. throw new Error('The overlay manager has not yet been initialized.');
  12394. }
  12395. overlayPromise = overlayManager.register('printServiceOverlay', document.getElementById('printServiceOverlay'), abort, true);
  12396. document.getElementById('printCancel').onclick = abort;
  12397. }
  12398. return overlayPromise;
  12399. }
  12400. _app.PDFPrintServiceFactory.instance = {
  12401. supportsPrinting: true,
  12402. createPrintService: function createPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
  12403. if (activeService) {
  12404. throw new Error('The print service is created and active.');
  12405. }
  12406. activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n);
  12407. return activeService;
  12408. }
  12409. };
  12410. exports.PDFPrintService = PDFPrintService;
  12411. /***/ })
  12412. /******/ ]);
  12413. //# sourceMappingURL=viewer.js.map