2
0

pdf_viewer.js 231 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2020 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * Javascript code in this page
  21. */
  22. (function webpackUniversalModuleDefinition(root, factory) {
  23. if(typeof exports === 'object' && typeof module === 'object')
  24. module.exports = factory();
  25. else if(typeof define === 'function' && define.amd)
  26. define("pdfjs-dist/web/pdf_viewer", [], factory);
  27. else if(typeof exports === 'object')
  28. exports["pdfjs-dist/web/pdf_viewer"] = factory();
  29. else
  30. root["pdfjs-dist/web/pdf_viewer"] = root.pdfjsViewer = factory();
  31. })(this, function() {
  32. return /******/ (function(modules) { // webpackBootstrap
  33. /******/ // The module cache
  34. /******/ var installedModules = {};
  35. /******/
  36. /******/ // The require function
  37. /******/ function __w_pdfjs_require__(moduleId) {
  38. /******/
  39. /******/ // Check if module is in cache
  40. /******/ if(installedModules[moduleId]) {
  41. /******/ return installedModules[moduleId].exports;
  42. /******/ }
  43. /******/ // Create a new module (and put it into the cache)
  44. /******/ var module = installedModules[moduleId] = {
  45. /******/ i: moduleId,
  46. /******/ l: false,
  47. /******/ exports: {}
  48. /******/ };
  49. /******/
  50. /******/ // Execute the module function
  51. /******/ modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);
  52. /******/
  53. /******/ // Flag the module as loaded
  54. /******/ module.l = true;
  55. /******/
  56. /******/ // Return the exports of the module
  57. /******/ return module.exports;
  58. /******/ }
  59. /******/
  60. /******/
  61. /******/ // expose the modules object (__webpack_modules__)
  62. /******/ __w_pdfjs_require__.m = modules;
  63. /******/
  64. /******/ // expose the module cache
  65. /******/ __w_pdfjs_require__.c = installedModules;
  66. /******/
  67. /******/ // define getter function for harmony exports
  68. /******/ __w_pdfjs_require__.d = function(exports, name, getter) {
  69. /******/ if(!__w_pdfjs_require__.o(exports, name)) {
  70. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  71. /******/ }
  72. /******/ };
  73. /******/
  74. /******/ // define __esModule on exports
  75. /******/ __w_pdfjs_require__.r = function(exports) {
  76. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  77. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  78. /******/ }
  79. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  80. /******/ };
  81. /******/
  82. /******/ // create a fake namespace object
  83. /******/ // mode & 1: value is a module id, require it
  84. /******/ // mode & 2: merge all properties of value into the ns
  85. /******/ // mode & 4: return value when already ns object
  86. /******/ // mode & 8|1: behave like require
  87. /******/ __w_pdfjs_require__.t = function(value, mode) {
  88. /******/ if(mode & 1) value = __w_pdfjs_require__(value);
  89. /******/ if(mode & 8) return value;
  90. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  91. /******/ var ns = Object.create(null);
  92. /******/ __w_pdfjs_require__.r(ns);
  93. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  94. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __w_pdfjs_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  95. /******/ return ns;
  96. /******/ };
  97. /******/
  98. /******/ // getDefaultExport function for compatibility with non-harmony modules
  99. /******/ __w_pdfjs_require__.n = function(module) {
  100. /******/ var getter = module && module.__esModule ?
  101. /******/ function getDefault() { return module['default']; } :
  102. /******/ function getModuleExports() { return module; };
  103. /******/ __w_pdfjs_require__.d(getter, 'a', getter);
  104. /******/ return getter;
  105. /******/ };
  106. /******/
  107. /******/ // Object.prototype.hasOwnProperty.call
  108. /******/ __w_pdfjs_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  109. /******/
  110. /******/ // __webpack_public_path__
  111. /******/ __w_pdfjs_require__.p = "";
  112. /******/
  113. /******/
  114. /******/ // Load entry module and return exports
  115. /******/ return __w_pdfjs_require__(__w_pdfjs_require__.s = 0);
  116. /******/ })
  117. /************************************************************************/
  118. /******/ ([
  119. /* 0 */
  120. /***/ (function(module, exports, __w_pdfjs_require__) {
  121. "use strict";
  122. Object.defineProperty(exports, "__esModule", {
  123. value: true
  124. });
  125. Object.defineProperty(exports, "AnnotationLayerBuilder", {
  126. enumerable: true,
  127. get: function get() {
  128. return _annotation_layer_builder.AnnotationLayerBuilder;
  129. }
  130. });
  131. Object.defineProperty(exports, "DefaultAnnotationLayerFactory", {
  132. enumerable: true,
  133. get: function get() {
  134. return _annotation_layer_builder.DefaultAnnotationLayerFactory;
  135. }
  136. });
  137. Object.defineProperty(exports, "DefaultTextLayerFactory", {
  138. enumerable: true,
  139. get: function get() {
  140. return _text_layer_builder.DefaultTextLayerFactory;
  141. }
  142. });
  143. Object.defineProperty(exports, "TextLayerBuilder", {
  144. enumerable: true,
  145. get: function get() {
  146. return _text_layer_builder.TextLayerBuilder;
  147. }
  148. });
  149. Object.defineProperty(exports, "EventBus", {
  150. enumerable: true,
  151. get: function get() {
  152. return _ui_utils.EventBus;
  153. }
  154. });
  155. Object.defineProperty(exports, "NullL10n", {
  156. enumerable: true,
  157. get: function get() {
  158. return _ui_utils.NullL10n;
  159. }
  160. });
  161. Object.defineProperty(exports, "ProgressBar", {
  162. enumerable: true,
  163. get: function get() {
  164. return _ui_utils.ProgressBar;
  165. }
  166. });
  167. Object.defineProperty(exports, "PDFLinkService", {
  168. enumerable: true,
  169. get: function get() {
  170. return _pdf_link_service.PDFLinkService;
  171. }
  172. });
  173. Object.defineProperty(exports, "SimpleLinkService", {
  174. enumerable: true,
  175. get: function get() {
  176. return _pdf_link_service.SimpleLinkService;
  177. }
  178. });
  179. Object.defineProperty(exports, "DownloadManager", {
  180. enumerable: true,
  181. get: function get() {
  182. return _download_manager.DownloadManager;
  183. }
  184. });
  185. Object.defineProperty(exports, "GenericL10n", {
  186. enumerable: true,
  187. get: function get() {
  188. return _genericl10n.GenericL10n;
  189. }
  190. });
  191. Object.defineProperty(exports, "PDFFindController", {
  192. enumerable: true,
  193. get: function get() {
  194. return _pdf_find_controller.PDFFindController;
  195. }
  196. });
  197. Object.defineProperty(exports, "PDFHistory", {
  198. enumerable: true,
  199. get: function get() {
  200. return _pdf_history.PDFHistory;
  201. }
  202. });
  203. Object.defineProperty(exports, "PDFPageView", {
  204. enumerable: true,
  205. get: function get() {
  206. return _pdf_page_view.PDFPageView;
  207. }
  208. });
  209. Object.defineProperty(exports, "PDFSinglePageViewer", {
  210. enumerable: true,
  211. get: function get() {
  212. return _pdf_single_page_viewer.PDFSinglePageViewer;
  213. }
  214. });
  215. Object.defineProperty(exports, "PDFViewer", {
  216. enumerable: true,
  217. get: function get() {
  218. return _pdf_viewer.PDFViewer;
  219. }
  220. });
  221. var _annotation_layer_builder = __w_pdfjs_require__(1);
  222. var _text_layer_builder = __w_pdfjs_require__(8);
  223. var _ui_utils = __w_pdfjs_require__(3);
  224. var _pdf_link_service = __w_pdfjs_require__(7);
  225. var _download_manager = __w_pdfjs_require__(9);
  226. var _genericl10n = __w_pdfjs_require__(11);
  227. var _pdf_find_controller = __w_pdfjs_require__(13);
  228. var _pdf_history = __w_pdfjs_require__(15);
  229. var _pdf_page_view = __w_pdfjs_require__(16);
  230. var _pdf_single_page_viewer = __w_pdfjs_require__(18);
  231. var _pdf_viewer = __w_pdfjs_require__(20);
  232. var pdfjsVersion = '2.6.347';
  233. var pdfjsBuild = '3be9c65f';
  234. /***/ }),
  235. /* 1 */
  236. /***/ (function(module, exports, __w_pdfjs_require__) {
  237. "use strict";
  238. Object.defineProperty(exports, "__esModule", {
  239. value: true
  240. });
  241. exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = void 0;
  242. var _pdfjsLib = __w_pdfjs_require__(2);
  243. var _ui_utils = __w_pdfjs_require__(3);
  244. var _pdf_link_service = __w_pdfjs_require__(7);
  245. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  246. 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); } }
  247. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  248. var AnnotationLayerBuilder = /*#__PURE__*/function () {
  249. function AnnotationLayerBuilder(_ref) {
  250. var pageDiv = _ref.pageDiv,
  251. pdfPage = _ref.pdfPage,
  252. linkService = _ref.linkService,
  253. downloadManager = _ref.downloadManager,
  254. _ref$annotationStorag = _ref.annotationStorage,
  255. annotationStorage = _ref$annotationStorag === void 0 ? null : _ref$annotationStorag,
  256. _ref$imageResourcesPa = _ref.imageResourcesPath,
  257. imageResourcesPath = _ref$imageResourcesPa === void 0 ? "" : _ref$imageResourcesPa,
  258. _ref$renderInteractiv = _ref.renderInteractiveForms,
  259. renderInteractiveForms = _ref$renderInteractiv === void 0 ? true : _ref$renderInteractiv,
  260. _ref$l10n = _ref.l10n,
  261. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  262. _classCallCheck(this, AnnotationLayerBuilder);
  263. this.pageDiv = pageDiv;
  264. this.pdfPage = pdfPage;
  265. this.linkService = linkService;
  266. this.downloadManager = downloadManager;
  267. this.imageResourcesPath = imageResourcesPath;
  268. this.renderInteractiveForms = renderInteractiveForms;
  269. this.l10n = l10n;
  270. this.annotationStorage = annotationStorage;
  271. this.div = null;
  272. this._cancelled = false;
  273. }
  274. _createClass(AnnotationLayerBuilder, [{
  275. key: "render",
  276. value: function render(viewport) {
  277. var _this = this;
  278. var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "display";
  279. return this.pdfPage.getAnnotations({
  280. intent: intent
  281. }).then(function (annotations) {
  282. if (_this._cancelled) {
  283. return;
  284. }
  285. if (annotations.length === 0) {
  286. return;
  287. }
  288. var parameters = {
  289. viewport: viewport.clone({
  290. dontFlip: true
  291. }),
  292. div: _this.div,
  293. annotations: annotations,
  294. page: _this.pdfPage,
  295. imageResourcesPath: _this.imageResourcesPath,
  296. renderInteractiveForms: _this.renderInteractiveForms,
  297. linkService: _this.linkService,
  298. downloadManager: _this.downloadManager,
  299. annotationStorage: _this.annotationStorage
  300. };
  301. if (_this.div) {
  302. _pdfjsLib.AnnotationLayer.update(parameters);
  303. } else {
  304. _this.div = document.createElement("div");
  305. _this.div.className = "annotationLayer";
  306. _this.pageDiv.appendChild(_this.div);
  307. parameters.div = _this.div;
  308. _pdfjsLib.AnnotationLayer.render(parameters);
  309. _this.l10n.translate(_this.div);
  310. }
  311. });
  312. }
  313. }, {
  314. key: "cancel",
  315. value: function cancel() {
  316. this._cancelled = true;
  317. }
  318. }, {
  319. key: "hide",
  320. value: function hide() {
  321. if (!this.div) {
  322. return;
  323. }
  324. this.div.setAttribute("hidden", "true");
  325. }
  326. }]);
  327. return AnnotationLayerBuilder;
  328. }();
  329. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  330. var DefaultAnnotationLayerFactory = /*#__PURE__*/function () {
  331. function DefaultAnnotationLayerFactory() {
  332. _classCallCheck(this, DefaultAnnotationLayerFactory);
  333. }
  334. _createClass(DefaultAnnotationLayerFactory, [{
  335. key: "createAnnotationLayerBuilder",
  336. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  337. var annotationStorage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  338. var imageResourcesPath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "";
  339. var renderInteractiveForms = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
  340. var l10n = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : _ui_utils.NullL10n;
  341. return new AnnotationLayerBuilder({
  342. pageDiv: pageDiv,
  343. pdfPage: pdfPage,
  344. imageResourcesPath: imageResourcesPath,
  345. renderInteractiveForms: renderInteractiveForms,
  346. linkService: new _pdf_link_service.SimpleLinkService(),
  347. l10n: l10n,
  348. annotationStorage: annotationStorage
  349. });
  350. }
  351. }]);
  352. return DefaultAnnotationLayerFactory;
  353. }();
  354. exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
  355. /***/ }),
  356. /* 2 */
  357. /***/ (function(module, exports, __w_pdfjs_require__) {
  358. "use strict";
  359. var pdfjsLib;
  360. if (typeof window !== "undefined" && window["pdfjs-dist/build/pdf"]) {
  361. pdfjsLib = window["pdfjs-dist/build/pdf"];
  362. } else {
  363. pdfjsLib = require("../build/pdf.js");
  364. }
  365. module.exports = pdfjsLib;
  366. /***/ }),
  367. /* 3 */
  368. /***/ (function(module, exports, __w_pdfjs_require__) {
  369. "use strict";
  370. Object.defineProperty(exports, "__esModule", {
  371. value: true
  372. });
  373. exports.isValidRotation = isValidRotation;
  374. exports.isValidScrollMode = isValidScrollMode;
  375. exports.isValidSpreadMode = isValidSpreadMode;
  376. exports.isPortraitOrientation = isPortraitOrientation;
  377. exports.clamp = clamp;
  378. exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
  379. exports.noContextMenuHandler = noContextMenuHandler;
  380. exports.parseQueryString = parseQueryString;
  381. exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
  382. exports.getVisibleElements = getVisibleElements;
  383. exports.roundToDivide = roundToDivide;
  384. exports.getPageSizeInches = getPageSizeInches;
  385. exports.approximateFraction = approximateFraction;
  386. exports.getOutputScale = getOutputScale;
  387. exports.scrollIntoView = scrollIntoView;
  388. exports.watchScroll = watchScroll;
  389. exports.binarySearchFirstItem = binarySearchFirstItem;
  390. exports.normalizeWheelEventDirection = normalizeWheelEventDirection;
  391. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  392. exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
  393. exports.moveToEndOfArray = moveToEndOfArray;
  394. exports.WaitOnType = exports.animationStarted = exports.ProgressBar = exports.EventBus = exports.NullL10n = exports.SpreadMode = exports.ScrollMode = exports.TextLayerMode = exports.RendererType = exports.PresentationModeState = exports.VERTICAL_PADDING = exports.SCROLLBAR_PADDING = exports.MAX_AUTO_SCALE = exports.UNKNOWN_SCALE = exports.MAX_SCALE = exports.MIN_SCALE = exports.DEFAULT_SCALE = exports.DEFAULT_SCALE_VALUE = exports.CSS_UNITS = exports.AutoPrintRegExp = void 0;
  395. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(4));
  396. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  397. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  398. 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); } }
  399. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  400. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  401. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  402. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  403. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  404. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  405. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  406. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  407. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  408. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  409. var CSS_UNITS = 96.0 / 72.0;
  410. exports.CSS_UNITS = CSS_UNITS;
  411. var DEFAULT_SCALE_VALUE = "auto";
  412. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  413. var DEFAULT_SCALE = 1.0;
  414. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  415. var MIN_SCALE = 0.1;
  416. exports.MIN_SCALE = MIN_SCALE;
  417. var MAX_SCALE = 10.0;
  418. exports.MAX_SCALE = MAX_SCALE;
  419. var UNKNOWN_SCALE = 0;
  420. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  421. var MAX_AUTO_SCALE = 1.25;
  422. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  423. var SCROLLBAR_PADDING = 40;
  424. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  425. var VERTICAL_PADDING = 5;
  426. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  427. var PresentationModeState = {
  428. UNKNOWN: 0,
  429. NORMAL: 1,
  430. CHANGING: 2,
  431. FULLSCREEN: 3
  432. };
  433. exports.PresentationModeState = PresentationModeState;
  434. var RendererType = {
  435. CANVAS: "canvas",
  436. SVG: "svg"
  437. };
  438. exports.RendererType = RendererType;
  439. var TextLayerMode = {
  440. DISABLE: 0,
  441. ENABLE: 1,
  442. ENABLE_ENHANCE: 2
  443. };
  444. exports.TextLayerMode = TextLayerMode;
  445. var ScrollMode = {
  446. UNKNOWN: -1,
  447. VERTICAL: 0,
  448. HORIZONTAL: 1,
  449. WRAPPED: 2
  450. };
  451. exports.ScrollMode = ScrollMode;
  452. var SpreadMode = {
  453. UNKNOWN: -1,
  454. NONE: 0,
  455. ODD: 1,
  456. EVEN: 2
  457. };
  458. exports.SpreadMode = SpreadMode;
  459. var AutoPrintRegExp = /\bprint\s*\(/;
  460. exports.AutoPrintRegExp = AutoPrintRegExp;
  461. function formatL10nValue(text, args) {
  462. if (!args) {
  463. return text;
  464. }
  465. return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function (all, name) {
  466. return name in args ? args[name] : "{{" + name + "}}";
  467. });
  468. }
  469. var NullL10n = {
  470. getLanguage: function getLanguage() {
  471. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  472. return _regenerator["default"].wrap(function _callee$(_context) {
  473. while (1) {
  474. switch (_context.prev = _context.next) {
  475. case 0:
  476. return _context.abrupt("return", "en-us");
  477. case 1:
  478. case "end":
  479. return _context.stop();
  480. }
  481. }
  482. }, _callee);
  483. }))();
  484. },
  485. getDirection: function getDirection() {
  486. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  487. return _regenerator["default"].wrap(function _callee2$(_context2) {
  488. while (1) {
  489. switch (_context2.prev = _context2.next) {
  490. case 0:
  491. return _context2.abrupt("return", "ltr");
  492. case 1:
  493. case "end":
  494. return _context2.stop();
  495. }
  496. }
  497. }, _callee2);
  498. }))();
  499. },
  500. get: function get(property, args, fallback) {
  501. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  502. return _regenerator["default"].wrap(function _callee3$(_context3) {
  503. while (1) {
  504. switch (_context3.prev = _context3.next) {
  505. case 0:
  506. return _context3.abrupt("return", formatL10nValue(fallback, args));
  507. case 1:
  508. case "end":
  509. return _context3.stop();
  510. }
  511. }
  512. }, _callee3);
  513. }))();
  514. },
  515. translate: function translate(element) {
  516. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
  517. return _regenerator["default"].wrap(function _callee4$(_context4) {
  518. while (1) {
  519. switch (_context4.prev = _context4.next) {
  520. case 0:
  521. case "end":
  522. return _context4.stop();
  523. }
  524. }
  525. }, _callee4);
  526. }))();
  527. }
  528. };
  529. exports.NullL10n = NullL10n;
  530. function getOutputScale(ctx) {
  531. var devicePixelRatio = window.devicePixelRatio || 1;
  532. var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
  533. var pixelRatio = devicePixelRatio / backingStoreRatio;
  534. return {
  535. sx: pixelRatio,
  536. sy: pixelRatio,
  537. scaled: pixelRatio !== 1
  538. };
  539. }
  540. function scrollIntoView(element, spot) {
  541. var skipOverflowHiddenElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  542. var parent = element.offsetParent;
  543. if (!parent) {
  544. console.error("offsetParent is not set -- cannot scroll");
  545. return;
  546. }
  547. var offsetY = element.offsetTop + element.clientTop;
  548. var offsetX = element.offsetLeft + element.clientLeft;
  549. while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || skipOverflowHiddenElements && getComputedStyle(parent).overflow === "hidden") {
  550. if (parent.dataset._scaleY) {
  551. offsetY /= parent.dataset._scaleY;
  552. offsetX /= parent.dataset._scaleX;
  553. }
  554. offsetY += parent.offsetTop;
  555. offsetX += parent.offsetLeft;
  556. parent = parent.offsetParent;
  557. if (!parent) {
  558. return;
  559. }
  560. }
  561. if (spot) {
  562. if (spot.top !== undefined) {
  563. offsetY += spot.top;
  564. }
  565. if (spot.left !== undefined) {
  566. offsetX += spot.left;
  567. parent.scrollLeft = offsetX;
  568. }
  569. }
  570. parent.scrollTop = offsetY;
  571. }
  572. function watchScroll(viewAreaElement, callback) {
  573. var debounceScroll = function debounceScroll(evt) {
  574. if (rAF) {
  575. return;
  576. }
  577. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  578. rAF = null;
  579. var currentX = viewAreaElement.scrollLeft;
  580. var lastX = state.lastX;
  581. if (currentX !== lastX) {
  582. state.right = currentX > lastX;
  583. }
  584. state.lastX = currentX;
  585. var currentY = viewAreaElement.scrollTop;
  586. var lastY = state.lastY;
  587. if (currentY !== lastY) {
  588. state.down = currentY > lastY;
  589. }
  590. state.lastY = currentY;
  591. callback(state);
  592. });
  593. };
  594. var state = {
  595. right: true,
  596. down: true,
  597. lastX: viewAreaElement.scrollLeft,
  598. lastY: viewAreaElement.scrollTop,
  599. _eventHandler: debounceScroll
  600. };
  601. var rAF = null;
  602. viewAreaElement.addEventListener("scroll", debounceScroll, true);
  603. return state;
  604. }
  605. function parseQueryString(query) {
  606. var parts = query.split("&");
  607. var params = Object.create(null);
  608. for (var i = 0, ii = parts.length; i < ii; ++i) {
  609. var param = parts[i].split("=");
  610. var key = param[0].toLowerCase();
  611. var value = param.length > 1 ? param[1] : null;
  612. params[decodeURIComponent(key)] = decodeURIComponent(value);
  613. }
  614. return params;
  615. }
  616. function binarySearchFirstItem(items, condition) {
  617. var minIndex = 0;
  618. var maxIndex = items.length - 1;
  619. if (maxIndex < 0 || !condition(items[maxIndex])) {
  620. return items.length;
  621. }
  622. if (condition(items[minIndex])) {
  623. return minIndex;
  624. }
  625. while (minIndex < maxIndex) {
  626. var currentIndex = minIndex + maxIndex >> 1;
  627. var currentItem = items[currentIndex];
  628. if (condition(currentItem)) {
  629. maxIndex = currentIndex;
  630. } else {
  631. minIndex = currentIndex + 1;
  632. }
  633. }
  634. return minIndex;
  635. }
  636. function approximateFraction(x) {
  637. if (Math.floor(x) === x) {
  638. return [x, 1];
  639. }
  640. var xinv = 1 / x;
  641. var limit = 8;
  642. if (xinv > limit) {
  643. return [1, limit];
  644. } else if (Math.floor(xinv) === xinv) {
  645. return [1, xinv];
  646. }
  647. var x_ = x > 1 ? xinv : x;
  648. var a = 0,
  649. b = 1,
  650. c = 1,
  651. d = 1;
  652. while (true) {
  653. var p = a + c,
  654. q = b + d;
  655. if (q > limit) {
  656. break;
  657. }
  658. if (x_ <= p / q) {
  659. c = p;
  660. d = q;
  661. } else {
  662. a = p;
  663. b = q;
  664. }
  665. }
  666. var result;
  667. if (x_ - a / b < c / d - x_) {
  668. result = x_ === x ? [a, b] : [b, a];
  669. } else {
  670. result = x_ === x ? [c, d] : [d, c];
  671. }
  672. return result;
  673. }
  674. function roundToDivide(x, div) {
  675. var r = x % div;
  676. return r === 0 ? x : Math.round(x - r + div);
  677. }
  678. function getPageSizeInches(_ref) {
  679. var view = _ref.view,
  680. userUnit = _ref.userUnit,
  681. rotate = _ref.rotate;
  682. var _view = _slicedToArray(view, 4),
  683. x1 = _view[0],
  684. y1 = _view[1],
  685. x2 = _view[2],
  686. y2 = _view[3];
  687. var changeOrientation = rotate % 180 !== 0;
  688. var width = (x2 - x1) / 72 * userUnit;
  689. var height = (y2 - y1) / 72 * userUnit;
  690. return {
  691. width: changeOrientation ? height : width,
  692. height: changeOrientation ? width : height
  693. };
  694. }
  695. function backtrackBeforeAllVisibleElements(index, views, top) {
  696. if (index < 2) {
  697. return index;
  698. }
  699. var elt = views[index].div;
  700. var pageTop = elt.offsetTop + elt.clientTop;
  701. if (pageTop >= top) {
  702. elt = views[index - 1].div;
  703. pageTop = elt.offsetTop + elt.clientTop;
  704. }
  705. for (var i = index - 2; i >= 0; --i) {
  706. elt = views[i].div;
  707. if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
  708. break;
  709. }
  710. index = i;
  711. }
  712. return index;
  713. }
  714. function getVisibleElements(scrollEl, views) {
  715. var sortByVisibility = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  716. var horizontal = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  717. var top = scrollEl.scrollTop,
  718. bottom = top + scrollEl.clientHeight;
  719. var left = scrollEl.scrollLeft,
  720. right = left + scrollEl.clientWidth;
  721. function isElementBottomAfterViewTop(view) {
  722. var element = view.div;
  723. var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  724. return elementBottom > top;
  725. }
  726. function isElementRightAfterViewLeft(view) {
  727. var element = view.div;
  728. var elementRight = element.offsetLeft + element.clientLeft + element.clientWidth;
  729. return elementRight > left;
  730. }
  731. var visible = [],
  732. numViews = views.length;
  733. var firstVisibleElementInd = numViews === 0 ? 0 : binarySearchFirstItem(views, horizontal ? isElementRightAfterViewLeft : isElementBottomAfterViewTop);
  734. if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
  735. firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
  736. }
  737. var lastEdge = horizontal ? right : -1;
  738. for (var i = firstVisibleElementInd; i < numViews; i++) {
  739. var view = views[i],
  740. element = view.div;
  741. var currentWidth = element.offsetLeft + element.clientLeft;
  742. var currentHeight = element.offsetTop + element.clientTop;
  743. var viewWidth = element.clientWidth,
  744. viewHeight = element.clientHeight;
  745. var viewRight = currentWidth + viewWidth;
  746. var viewBottom = currentHeight + viewHeight;
  747. if (lastEdge === -1) {
  748. if (viewBottom >= bottom) {
  749. lastEdge = viewBottom;
  750. }
  751. } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
  752. break;
  753. }
  754. if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) {
  755. continue;
  756. }
  757. var hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
  758. var hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
  759. var percent = (viewHeight - hiddenHeight) * (viewWidth - hiddenWidth) * 100 / viewHeight / viewWidth | 0;
  760. visible.push({
  761. id: view.id,
  762. x: currentWidth,
  763. y: currentHeight,
  764. view: view,
  765. percent: percent
  766. });
  767. }
  768. var first = visible[0],
  769. last = visible[visible.length - 1];
  770. if (sortByVisibility) {
  771. visible.sort(function (a, b) {
  772. var pc = a.percent - b.percent;
  773. if (Math.abs(pc) > 0.001) {
  774. return -pc;
  775. }
  776. return a.id - b.id;
  777. });
  778. }
  779. return {
  780. first: first,
  781. last: last,
  782. views: visible
  783. };
  784. }
  785. function noContextMenuHandler(evt) {
  786. evt.preventDefault();
  787. }
  788. function isDataSchema(url) {
  789. var i = 0;
  790. var ii = url.length;
  791. while (i < ii && url[i].trim() === "") {
  792. i++;
  793. }
  794. return url.substring(i, i + 5).toLowerCase() === "data:";
  795. }
  796. function getPDFFileNameFromURL(url) {
  797. var defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "document.pdf";
  798. if (typeof url !== "string") {
  799. return defaultFilename;
  800. }
  801. if (isDataSchema(url)) {
  802. console.warn("getPDFFileNameFromURL: " + 'ignoring "data:" URL for performance reasons.');
  803. return defaultFilename;
  804. }
  805. var reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
  806. var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
  807. var splitURI = reURI.exec(url);
  808. var suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
  809. if (suggestedFilename) {
  810. suggestedFilename = suggestedFilename[0];
  811. if (suggestedFilename.includes("%")) {
  812. try {
  813. suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
  814. } catch (ex) {}
  815. }
  816. }
  817. return suggestedFilename || defaultFilename;
  818. }
  819. function normalizeWheelEventDirection(evt) {
  820. var delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
  821. var angle = Math.atan2(evt.deltaY, evt.deltaX);
  822. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  823. delta = -delta;
  824. }
  825. return delta;
  826. }
  827. function normalizeWheelEventDelta(evt) {
  828. var delta = normalizeWheelEventDirection(evt);
  829. var MOUSE_DOM_DELTA_PIXEL_MODE = 0;
  830. var MOUSE_DOM_DELTA_LINE_MODE = 1;
  831. var MOUSE_PIXELS_PER_LINE = 30;
  832. var MOUSE_LINES_PER_PAGE = 30;
  833. if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
  834. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  835. } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
  836. delta /= MOUSE_LINES_PER_PAGE;
  837. }
  838. return delta;
  839. }
  840. function isValidRotation(angle) {
  841. return Number.isInteger(angle) && angle % 90 === 0;
  842. }
  843. function isValidScrollMode(mode) {
  844. return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN;
  845. }
  846. function isValidSpreadMode(mode) {
  847. return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN;
  848. }
  849. function isPortraitOrientation(size) {
  850. return size.width <= size.height;
  851. }
  852. var WaitOnType = {
  853. EVENT: "event",
  854. TIMEOUT: "timeout"
  855. };
  856. exports.WaitOnType = WaitOnType;
  857. function waitOnEventOrTimeout(_ref2) {
  858. var target = _ref2.target,
  859. name = _ref2.name,
  860. _ref2$delay = _ref2.delay,
  861. delay = _ref2$delay === void 0 ? 0 : _ref2$delay;
  862. return new Promise(function (resolve, reject) {
  863. if (_typeof(target) !== "object" || !(name && typeof name === "string") || !(Number.isInteger(delay) && delay >= 0)) {
  864. throw new Error("waitOnEventOrTimeout - invalid parameters.");
  865. }
  866. function handler(type) {
  867. if (target instanceof EventBus) {
  868. target._off(name, eventHandler);
  869. } else {
  870. target.removeEventListener(name, eventHandler);
  871. }
  872. if (timeout) {
  873. clearTimeout(timeout);
  874. }
  875. resolve(type);
  876. }
  877. var eventHandler = handler.bind(null, WaitOnType.EVENT);
  878. if (target instanceof EventBus) {
  879. target._on(name, eventHandler);
  880. } else {
  881. target.addEventListener(name, eventHandler);
  882. }
  883. var timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
  884. var timeout = setTimeout(timeoutHandler, delay);
  885. });
  886. }
  887. var animationStarted = new Promise(function (resolve) {
  888. window.requestAnimationFrame(resolve);
  889. });
  890. exports.animationStarted = animationStarted;
  891. function dispatchDOMEvent(eventName) {
  892. var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  893. throw new Error("Not implemented: dispatchDOMEvent");
  894. }
  895. var EventBus = /*#__PURE__*/function () {
  896. function EventBus(options) {
  897. _classCallCheck(this, EventBus);
  898. this._listeners = Object.create(null);
  899. }
  900. _createClass(EventBus, [{
  901. key: "on",
  902. value: function on(eventName, listener) {
  903. this._on(eventName, listener, {
  904. external: true
  905. });
  906. }
  907. }, {
  908. key: "off",
  909. value: function off(eventName, listener) {
  910. this._off(eventName, listener, {
  911. external: true
  912. });
  913. }
  914. }, {
  915. key: "dispatch",
  916. value: function dispatch(eventName) {
  917. var eventListeners = this._listeners[eventName];
  918. if (!eventListeners || eventListeners.length === 0) {
  919. return;
  920. }
  921. var args = Array.prototype.slice.call(arguments, 1);
  922. var externalListeners;
  923. eventListeners.slice(0).forEach(function (_ref3) {
  924. var listener = _ref3.listener,
  925. external = _ref3.external;
  926. if (external) {
  927. if (!externalListeners) {
  928. externalListeners = [];
  929. }
  930. externalListeners.push(listener);
  931. return;
  932. }
  933. listener.apply(null, args);
  934. });
  935. if (externalListeners) {
  936. externalListeners.forEach(function (listener) {
  937. listener.apply(null, args);
  938. });
  939. externalListeners = null;
  940. }
  941. }
  942. }, {
  943. key: "_on",
  944. value: function _on(eventName, listener) {
  945. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  946. var eventListeners = this._listeners[eventName];
  947. if (!eventListeners) {
  948. this._listeners[eventName] = eventListeners = [];
  949. }
  950. eventListeners.push({
  951. listener: listener,
  952. external: (options && options.external) === true
  953. });
  954. }
  955. }, {
  956. key: "_off",
  957. value: function _off(eventName, listener) {
  958. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  959. var eventListeners = this._listeners[eventName];
  960. if (!eventListeners) {
  961. return;
  962. }
  963. for (var i = 0, ii = eventListeners.length; i < ii; i++) {
  964. if (eventListeners[i].listener === listener) {
  965. eventListeners.splice(i, 1);
  966. return;
  967. }
  968. }
  969. }
  970. }]);
  971. return EventBus;
  972. }();
  973. exports.EventBus = EventBus;
  974. function clamp(v, min, max) {
  975. return Math.min(Math.max(v, min), max);
  976. }
  977. var ProgressBar = /*#__PURE__*/function () {
  978. function ProgressBar(id) {
  979. var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  980. height = _ref4.height,
  981. width = _ref4.width,
  982. units = _ref4.units;
  983. _classCallCheck(this, ProgressBar);
  984. this.visible = true;
  985. this.div = document.querySelector(id + " .progress");
  986. this.bar = this.div.parentNode;
  987. this.height = height || 100;
  988. this.width = width || 100;
  989. this.units = units || "%";
  990. this.div.style.height = this.height + this.units;
  991. this.percent = 0;
  992. }
  993. _createClass(ProgressBar, [{
  994. key: "_updateBar",
  995. value: function _updateBar() {
  996. if (this._indeterminate) {
  997. this.div.classList.add("indeterminate");
  998. this.div.style.width = this.width + this.units;
  999. return;
  1000. }
  1001. this.div.classList.remove("indeterminate");
  1002. var progressSize = this.width * this._percent / 100;
  1003. this.div.style.width = progressSize + this.units;
  1004. }
  1005. }, {
  1006. key: "setWidth",
  1007. value: function setWidth(viewer) {
  1008. if (!viewer) {
  1009. return;
  1010. }
  1011. var container = viewer.parentNode;
  1012. var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  1013. if (scrollbarWidth > 0) {
  1014. this.bar.style.width = "calc(100% - ".concat(scrollbarWidth, "px)");
  1015. }
  1016. }
  1017. }, {
  1018. key: "hide",
  1019. value: function hide() {
  1020. if (!this.visible) {
  1021. return;
  1022. }
  1023. this.visible = false;
  1024. this.bar.classList.add("hidden");
  1025. document.body.classList.remove("loadingInProgress");
  1026. }
  1027. }, {
  1028. key: "show",
  1029. value: function show() {
  1030. if (this.visible) {
  1031. return;
  1032. }
  1033. this.visible = true;
  1034. document.body.classList.add("loadingInProgress");
  1035. this.bar.classList.remove("hidden");
  1036. }
  1037. }, {
  1038. key: "percent",
  1039. get: function get() {
  1040. return this._percent;
  1041. },
  1042. set: function set(val) {
  1043. this._indeterminate = isNaN(val);
  1044. this._percent = clamp(val, 0, 100);
  1045. this._updateBar();
  1046. }
  1047. }]);
  1048. return ProgressBar;
  1049. }();
  1050. exports.ProgressBar = ProgressBar;
  1051. function moveToEndOfArray(arr, condition) {
  1052. var moved = [],
  1053. len = arr.length;
  1054. var write = 0;
  1055. for (var read = 0; read < len; ++read) {
  1056. if (condition(arr[read])) {
  1057. moved.push(arr[read]);
  1058. } else {
  1059. arr[write] = arr[read];
  1060. ++write;
  1061. }
  1062. }
  1063. for (var _read = 0; write < len; ++_read, ++write) {
  1064. arr[write] = moved[_read];
  1065. }
  1066. }
  1067. /***/ }),
  1068. /* 4 */
  1069. /***/ (function(module, exports, __w_pdfjs_require__) {
  1070. "use strict";
  1071. module.exports = __w_pdfjs_require__(5);
  1072. /***/ }),
  1073. /* 5 */
  1074. /***/ (function(module, exports, __w_pdfjs_require__) {
  1075. "use strict";
  1076. /* WEBPACK VAR INJECTION */(function(module) {
  1077. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  1078. var runtime = function (exports) {
  1079. "use strict";
  1080. var Op = Object.prototype;
  1081. var hasOwn = Op.hasOwnProperty;
  1082. var undefined;
  1083. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  1084. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  1085. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  1086. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  1087. function define(obj, key, value) {
  1088. Object.defineProperty(obj, key, {
  1089. value: value,
  1090. enumerable: true,
  1091. configurable: true,
  1092. writable: true
  1093. });
  1094. return obj[key];
  1095. }
  1096. try {
  1097. define({}, "");
  1098. } catch (err) {
  1099. define = function define(obj, key, value) {
  1100. return obj[key] = value;
  1101. };
  1102. }
  1103. function wrap(innerFn, outerFn, self, tryLocsList) {
  1104. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  1105. var generator = Object.create(protoGenerator.prototype);
  1106. var context = new Context(tryLocsList || []);
  1107. generator._invoke = makeInvokeMethod(innerFn, self, context);
  1108. return generator;
  1109. }
  1110. exports.wrap = wrap;
  1111. function tryCatch(fn, obj, arg) {
  1112. try {
  1113. return {
  1114. type: "normal",
  1115. arg: fn.call(obj, arg)
  1116. };
  1117. } catch (err) {
  1118. return {
  1119. type: "throw",
  1120. arg: err
  1121. };
  1122. }
  1123. }
  1124. var GenStateSuspendedStart = "suspendedStart";
  1125. var GenStateSuspendedYield = "suspendedYield";
  1126. var GenStateExecuting = "executing";
  1127. var GenStateCompleted = "completed";
  1128. var ContinueSentinel = {};
  1129. function Generator() {}
  1130. function GeneratorFunction() {}
  1131. function GeneratorFunctionPrototype() {}
  1132. var IteratorPrototype = {};
  1133. IteratorPrototype[iteratorSymbol] = function () {
  1134. return this;
  1135. };
  1136. var getProto = Object.getPrototypeOf;
  1137. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  1138. if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  1139. IteratorPrototype = NativeIteratorPrototype;
  1140. }
  1141. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
  1142. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  1143. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  1144. GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
  1145. function defineIteratorMethods(prototype) {
  1146. ["next", "throw", "return"].forEach(function (method) {
  1147. define(prototype, method, function (arg) {
  1148. return this._invoke(method, arg);
  1149. });
  1150. });
  1151. }
  1152. exports.isGeneratorFunction = function (genFun) {
  1153. var ctor = typeof genFun === "function" && genFun.constructor;
  1154. return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
  1155. };
  1156. exports.mark = function (genFun) {
  1157. if (Object.setPrototypeOf) {
  1158. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  1159. } else {
  1160. genFun.__proto__ = GeneratorFunctionPrototype;
  1161. define(genFun, toStringTagSymbol, "GeneratorFunction");
  1162. }
  1163. genFun.prototype = Object.create(Gp);
  1164. return genFun;
  1165. };
  1166. exports.awrap = function (arg) {
  1167. return {
  1168. __await: arg
  1169. };
  1170. };
  1171. function AsyncIterator(generator, PromiseImpl) {
  1172. function invoke(method, arg, resolve, reject) {
  1173. var record = tryCatch(generator[method], generator, arg);
  1174. if (record.type === "throw") {
  1175. reject(record.arg);
  1176. } else {
  1177. var result = record.arg;
  1178. var value = result.value;
  1179. if (value && _typeof(value) === "object" && hasOwn.call(value, "__await")) {
  1180. return PromiseImpl.resolve(value.__await).then(function (value) {
  1181. invoke("next", value, resolve, reject);
  1182. }, function (err) {
  1183. invoke("throw", err, resolve, reject);
  1184. });
  1185. }
  1186. return PromiseImpl.resolve(value).then(function (unwrapped) {
  1187. result.value = unwrapped;
  1188. resolve(result);
  1189. }, function (error) {
  1190. return invoke("throw", error, resolve, reject);
  1191. });
  1192. }
  1193. }
  1194. var previousPromise;
  1195. function enqueue(method, arg) {
  1196. function callInvokeWithMethodAndArg() {
  1197. return new PromiseImpl(function (resolve, reject) {
  1198. invoke(method, arg, resolve, reject);
  1199. });
  1200. }
  1201. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  1202. }
  1203. this._invoke = enqueue;
  1204. }
  1205. defineIteratorMethods(AsyncIterator.prototype);
  1206. AsyncIterator.prototype[asyncIteratorSymbol] = function () {
  1207. return this;
  1208. };
  1209. exports.AsyncIterator = AsyncIterator;
  1210. exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  1211. if (PromiseImpl === void 0) PromiseImpl = Promise;
  1212. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  1213. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  1214. return result.done ? result.value : iter.next();
  1215. });
  1216. };
  1217. function makeInvokeMethod(innerFn, self, context) {
  1218. var state = GenStateSuspendedStart;
  1219. return function invoke(method, arg) {
  1220. if (state === GenStateExecuting) {
  1221. throw new Error("Generator is already running");
  1222. }
  1223. if (state === GenStateCompleted) {
  1224. if (method === "throw") {
  1225. throw arg;
  1226. }
  1227. return doneResult();
  1228. }
  1229. context.method = method;
  1230. context.arg = arg;
  1231. while (true) {
  1232. var delegate = context.delegate;
  1233. if (delegate) {
  1234. var delegateResult = maybeInvokeDelegate(delegate, context);
  1235. if (delegateResult) {
  1236. if (delegateResult === ContinueSentinel) continue;
  1237. return delegateResult;
  1238. }
  1239. }
  1240. if (context.method === "next") {
  1241. context.sent = context._sent = context.arg;
  1242. } else if (context.method === "throw") {
  1243. if (state === GenStateSuspendedStart) {
  1244. state = GenStateCompleted;
  1245. throw context.arg;
  1246. }
  1247. context.dispatchException(context.arg);
  1248. } else if (context.method === "return") {
  1249. context.abrupt("return", context.arg);
  1250. }
  1251. state = GenStateExecuting;
  1252. var record = tryCatch(innerFn, self, context);
  1253. if (record.type === "normal") {
  1254. state = context.done ? GenStateCompleted : GenStateSuspendedYield;
  1255. if (record.arg === ContinueSentinel) {
  1256. continue;
  1257. }
  1258. return {
  1259. value: record.arg,
  1260. done: context.done
  1261. };
  1262. } else if (record.type === "throw") {
  1263. state = GenStateCompleted;
  1264. context.method = "throw";
  1265. context.arg = record.arg;
  1266. }
  1267. }
  1268. };
  1269. }
  1270. function maybeInvokeDelegate(delegate, context) {
  1271. var method = delegate.iterator[context.method];
  1272. if (method === undefined) {
  1273. context.delegate = null;
  1274. if (context.method === "throw") {
  1275. if (delegate.iterator["return"]) {
  1276. context.method = "return";
  1277. context.arg = undefined;
  1278. maybeInvokeDelegate(delegate, context);
  1279. if (context.method === "throw") {
  1280. return ContinueSentinel;
  1281. }
  1282. }
  1283. context.method = "throw";
  1284. context.arg = new TypeError("The iterator does not provide a 'throw' method");
  1285. }
  1286. return ContinueSentinel;
  1287. }
  1288. var record = tryCatch(method, delegate.iterator, context.arg);
  1289. if (record.type === "throw") {
  1290. context.method = "throw";
  1291. context.arg = record.arg;
  1292. context.delegate = null;
  1293. return ContinueSentinel;
  1294. }
  1295. var info = record.arg;
  1296. if (!info) {
  1297. context.method = "throw";
  1298. context.arg = new TypeError("iterator result is not an object");
  1299. context.delegate = null;
  1300. return ContinueSentinel;
  1301. }
  1302. if (info.done) {
  1303. context[delegate.resultName] = info.value;
  1304. context.next = delegate.nextLoc;
  1305. if (context.method !== "return") {
  1306. context.method = "next";
  1307. context.arg = undefined;
  1308. }
  1309. } else {
  1310. return info;
  1311. }
  1312. context.delegate = null;
  1313. return ContinueSentinel;
  1314. }
  1315. defineIteratorMethods(Gp);
  1316. define(Gp, toStringTagSymbol, "Generator");
  1317. Gp[iteratorSymbol] = function () {
  1318. return this;
  1319. };
  1320. Gp.toString = function () {
  1321. return "[object Generator]";
  1322. };
  1323. function pushTryEntry(locs) {
  1324. var entry = {
  1325. tryLoc: locs[0]
  1326. };
  1327. if (1 in locs) {
  1328. entry.catchLoc = locs[1];
  1329. }
  1330. if (2 in locs) {
  1331. entry.finallyLoc = locs[2];
  1332. entry.afterLoc = locs[3];
  1333. }
  1334. this.tryEntries.push(entry);
  1335. }
  1336. function resetTryEntry(entry) {
  1337. var record = entry.completion || {};
  1338. record.type = "normal";
  1339. delete record.arg;
  1340. entry.completion = record;
  1341. }
  1342. function Context(tryLocsList) {
  1343. this.tryEntries = [{
  1344. tryLoc: "root"
  1345. }];
  1346. tryLocsList.forEach(pushTryEntry, this);
  1347. this.reset(true);
  1348. }
  1349. exports.keys = function (object) {
  1350. var keys = [];
  1351. for (var key in object) {
  1352. keys.push(key);
  1353. }
  1354. keys.reverse();
  1355. return function next() {
  1356. while (keys.length) {
  1357. var key = keys.pop();
  1358. if (key in object) {
  1359. next.value = key;
  1360. next.done = false;
  1361. return next;
  1362. }
  1363. }
  1364. next.done = true;
  1365. return next;
  1366. };
  1367. };
  1368. function values(iterable) {
  1369. if (iterable) {
  1370. var iteratorMethod = iterable[iteratorSymbol];
  1371. if (iteratorMethod) {
  1372. return iteratorMethod.call(iterable);
  1373. }
  1374. if (typeof iterable.next === "function") {
  1375. return iterable;
  1376. }
  1377. if (!isNaN(iterable.length)) {
  1378. var i = -1,
  1379. next = function next() {
  1380. while (++i < iterable.length) {
  1381. if (hasOwn.call(iterable, i)) {
  1382. next.value = iterable[i];
  1383. next.done = false;
  1384. return next;
  1385. }
  1386. }
  1387. next.value = undefined;
  1388. next.done = true;
  1389. return next;
  1390. };
  1391. return next.next = next;
  1392. }
  1393. }
  1394. return {
  1395. next: doneResult
  1396. };
  1397. }
  1398. exports.values = values;
  1399. function doneResult() {
  1400. return {
  1401. value: undefined,
  1402. done: true
  1403. };
  1404. }
  1405. Context.prototype = {
  1406. constructor: Context,
  1407. reset: function reset(skipTempReset) {
  1408. this.prev = 0;
  1409. this.next = 0;
  1410. this.sent = this._sent = undefined;
  1411. this.done = false;
  1412. this.delegate = null;
  1413. this.method = "next";
  1414. this.arg = undefined;
  1415. this.tryEntries.forEach(resetTryEntry);
  1416. if (!skipTempReset) {
  1417. for (var name in this) {
  1418. if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
  1419. this[name] = undefined;
  1420. }
  1421. }
  1422. }
  1423. },
  1424. stop: function stop() {
  1425. this.done = true;
  1426. var rootEntry = this.tryEntries[0];
  1427. var rootRecord = rootEntry.completion;
  1428. if (rootRecord.type === "throw") {
  1429. throw rootRecord.arg;
  1430. }
  1431. return this.rval;
  1432. },
  1433. dispatchException: function dispatchException(exception) {
  1434. if (this.done) {
  1435. throw exception;
  1436. }
  1437. var context = this;
  1438. function handle(loc, caught) {
  1439. record.type = "throw";
  1440. record.arg = exception;
  1441. context.next = loc;
  1442. if (caught) {
  1443. context.method = "next";
  1444. context.arg = undefined;
  1445. }
  1446. return !!caught;
  1447. }
  1448. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  1449. var entry = this.tryEntries[i];
  1450. var record = entry.completion;
  1451. if (entry.tryLoc === "root") {
  1452. return handle("end");
  1453. }
  1454. if (entry.tryLoc <= this.prev) {
  1455. var hasCatch = hasOwn.call(entry, "catchLoc");
  1456. var hasFinally = hasOwn.call(entry, "finallyLoc");
  1457. if (hasCatch && hasFinally) {
  1458. if (this.prev < entry.catchLoc) {
  1459. return handle(entry.catchLoc, true);
  1460. } else if (this.prev < entry.finallyLoc) {
  1461. return handle(entry.finallyLoc);
  1462. }
  1463. } else if (hasCatch) {
  1464. if (this.prev < entry.catchLoc) {
  1465. return handle(entry.catchLoc, true);
  1466. }
  1467. } else if (hasFinally) {
  1468. if (this.prev < entry.finallyLoc) {
  1469. return handle(entry.finallyLoc);
  1470. }
  1471. } else {
  1472. throw new Error("try statement without catch or finally");
  1473. }
  1474. }
  1475. }
  1476. },
  1477. abrupt: function abrupt(type, arg) {
  1478. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  1479. var entry = this.tryEntries[i];
  1480. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  1481. var finallyEntry = entry;
  1482. break;
  1483. }
  1484. }
  1485. if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
  1486. finallyEntry = null;
  1487. }
  1488. var record = finallyEntry ? finallyEntry.completion : {};
  1489. record.type = type;
  1490. record.arg = arg;
  1491. if (finallyEntry) {
  1492. this.method = "next";
  1493. this.next = finallyEntry.finallyLoc;
  1494. return ContinueSentinel;
  1495. }
  1496. return this.complete(record);
  1497. },
  1498. complete: function complete(record, afterLoc) {
  1499. if (record.type === "throw") {
  1500. throw record.arg;
  1501. }
  1502. if (record.type === "break" || record.type === "continue") {
  1503. this.next = record.arg;
  1504. } else if (record.type === "return") {
  1505. this.rval = this.arg = record.arg;
  1506. this.method = "return";
  1507. this.next = "end";
  1508. } else if (record.type === "normal" && afterLoc) {
  1509. this.next = afterLoc;
  1510. }
  1511. return ContinueSentinel;
  1512. },
  1513. finish: function finish(finallyLoc) {
  1514. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  1515. var entry = this.tryEntries[i];
  1516. if (entry.finallyLoc === finallyLoc) {
  1517. this.complete(entry.completion, entry.afterLoc);
  1518. resetTryEntry(entry);
  1519. return ContinueSentinel;
  1520. }
  1521. }
  1522. },
  1523. "catch": function _catch(tryLoc) {
  1524. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  1525. var entry = this.tryEntries[i];
  1526. if (entry.tryLoc === tryLoc) {
  1527. var record = entry.completion;
  1528. if (record.type === "throw") {
  1529. var thrown = record.arg;
  1530. resetTryEntry(entry);
  1531. }
  1532. return thrown;
  1533. }
  1534. }
  1535. throw new Error("illegal catch attempt");
  1536. },
  1537. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  1538. this.delegate = {
  1539. iterator: values(iterable),
  1540. resultName: resultName,
  1541. nextLoc: nextLoc
  1542. };
  1543. if (this.method === "next") {
  1544. this.arg = undefined;
  1545. }
  1546. return ContinueSentinel;
  1547. }
  1548. };
  1549. return exports;
  1550. }(( false ? undefined : _typeof(module)) === "object" ? module.exports : {});
  1551. try {
  1552. regeneratorRuntime = runtime;
  1553. } catch (accidentalStrictMode) {
  1554. Function("r", "regeneratorRuntime = r")(runtime);
  1555. }
  1556. /* WEBPACK VAR INJECTION */}.call(this, __w_pdfjs_require__(6)(module)))
  1557. /***/ }),
  1558. /* 6 */
  1559. /***/ (function(module, exports, __w_pdfjs_require__) {
  1560. "use strict";
  1561. module.exports = function (module) {
  1562. if (!module.webpackPolyfill) {
  1563. module.deprecate = function () {};
  1564. module.paths = [];
  1565. if (!module.children) module.children = [];
  1566. Object.defineProperty(module, "loaded", {
  1567. enumerable: true,
  1568. get: function get() {
  1569. return module.l;
  1570. }
  1571. });
  1572. Object.defineProperty(module, "id", {
  1573. enumerable: true,
  1574. get: function get() {
  1575. return module.i;
  1576. }
  1577. });
  1578. module.webpackPolyfill = 1;
  1579. }
  1580. return module;
  1581. };
  1582. /***/ }),
  1583. /* 7 */
  1584. /***/ (function(module, exports, __w_pdfjs_require__) {
  1585. "use strict";
  1586. Object.defineProperty(exports, "__esModule", {
  1587. value: true
  1588. });
  1589. exports.SimpleLinkService = exports.PDFLinkService = void 0;
  1590. var _ui_utils = __w_pdfjs_require__(3);
  1591. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  1592. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1593. 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); } }
  1594. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  1595. var PDFLinkService = /*#__PURE__*/function () {
  1596. function PDFLinkService() {
  1597. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  1598. eventBus = _ref.eventBus,
  1599. _ref$externalLinkTarg = _ref.externalLinkTarget,
  1600. externalLinkTarget = _ref$externalLinkTarg === void 0 ? null : _ref$externalLinkTarg,
  1601. _ref$externalLinkRel = _ref.externalLinkRel,
  1602. externalLinkRel = _ref$externalLinkRel === void 0 ? null : _ref$externalLinkRel,
  1603. _ref$externalLinkEnab = _ref.externalLinkEnabled,
  1604. externalLinkEnabled = _ref$externalLinkEnab === void 0 ? true : _ref$externalLinkEnab,
  1605. _ref$ignoreDestinatio = _ref.ignoreDestinationZoom,
  1606. ignoreDestinationZoom = _ref$ignoreDestinatio === void 0 ? false : _ref$ignoreDestinatio;
  1607. _classCallCheck(this, PDFLinkService);
  1608. this.eventBus = eventBus;
  1609. this.externalLinkTarget = externalLinkTarget;
  1610. this.externalLinkRel = externalLinkRel;
  1611. this.externalLinkEnabled = externalLinkEnabled;
  1612. this._ignoreDestinationZoom = ignoreDestinationZoom;
  1613. this.baseUrl = null;
  1614. this.pdfDocument = null;
  1615. this.pdfViewer = null;
  1616. this.pdfHistory = null;
  1617. this._pagesRefCache = null;
  1618. }
  1619. _createClass(PDFLinkService, [{
  1620. key: "setDocument",
  1621. value: function setDocument(pdfDocument) {
  1622. var baseUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  1623. this.baseUrl = baseUrl;
  1624. this.pdfDocument = pdfDocument;
  1625. this._pagesRefCache = Object.create(null);
  1626. }
  1627. }, {
  1628. key: "setViewer",
  1629. value: function setViewer(pdfViewer) {
  1630. this.pdfViewer = pdfViewer;
  1631. }
  1632. }, {
  1633. key: "setHistory",
  1634. value: function setHistory(pdfHistory) {
  1635. this.pdfHistory = pdfHistory;
  1636. }
  1637. }, {
  1638. key: "navigateTo",
  1639. value: function navigateTo(dest) {
  1640. var _this = this;
  1641. var goToDestination = function goToDestination(_ref2) {
  1642. var namedDest = _ref2.namedDest,
  1643. explicitDest = _ref2.explicitDest;
  1644. var destRef = explicitDest[0];
  1645. var pageNumber;
  1646. if (destRef instanceof Object) {
  1647. pageNumber = _this._cachedPageNumber(destRef);
  1648. if (pageNumber === null) {
  1649. _this.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
  1650. _this.cachePageRef(pageIndex + 1, destRef);
  1651. goToDestination({
  1652. namedDest: namedDest,
  1653. explicitDest: explicitDest
  1654. });
  1655. })["catch"](function () {
  1656. console.error("PDFLinkService.navigateTo: \"".concat(destRef, "\" is not ") + "a valid page reference, for dest=\"".concat(dest, "\"."));
  1657. });
  1658. return;
  1659. }
  1660. } else if (Number.isInteger(destRef)) {
  1661. pageNumber = destRef + 1;
  1662. } else {
  1663. console.error("PDFLinkService.navigateTo: \"".concat(destRef, "\" is not ") + "a valid destination reference, for dest=\"".concat(dest, "\"."));
  1664. return;
  1665. }
  1666. if (!pageNumber || pageNumber < 1 || pageNumber > _this.pagesCount) {
  1667. console.error("PDFLinkService.navigateTo: \"".concat(pageNumber, "\" is not ") + "a valid page number, for dest=\"".concat(dest, "\"."));
  1668. return;
  1669. }
  1670. if (_this.pdfHistory) {
  1671. _this.pdfHistory.pushCurrentPosition();
  1672. _this.pdfHistory.push({
  1673. namedDest: namedDest,
  1674. explicitDest: explicitDest,
  1675. pageNumber: pageNumber
  1676. });
  1677. }
  1678. _this.pdfViewer.scrollPageIntoView({
  1679. pageNumber: pageNumber,
  1680. destArray: explicitDest,
  1681. ignoreDestinationZoom: _this._ignoreDestinationZoom
  1682. });
  1683. };
  1684. new Promise(function (resolve, reject) {
  1685. if (typeof dest === "string") {
  1686. _this.pdfDocument.getDestination(dest).then(function (destArray) {
  1687. resolve({
  1688. namedDest: dest,
  1689. explicitDest: destArray
  1690. });
  1691. });
  1692. return;
  1693. }
  1694. resolve({
  1695. namedDest: "",
  1696. explicitDest: dest
  1697. });
  1698. }).then(function (data) {
  1699. if (!Array.isArray(data.explicitDest)) {
  1700. console.error("PDFLinkService.navigateTo: \"".concat(data.explicitDest, "\" is") + " not a valid destination array, for dest=\"".concat(dest, "\"."));
  1701. return;
  1702. }
  1703. goToDestination(data);
  1704. });
  1705. }
  1706. }, {
  1707. key: "getDestinationHash",
  1708. value: function getDestinationHash(dest) {
  1709. if (typeof dest === "string") {
  1710. return this.getAnchorUrl("#" + escape(dest));
  1711. }
  1712. if (Array.isArray(dest)) {
  1713. var str = JSON.stringify(dest);
  1714. return this.getAnchorUrl("#" + escape(str));
  1715. }
  1716. return this.getAnchorUrl("");
  1717. }
  1718. }, {
  1719. key: "getAnchorUrl",
  1720. value: function getAnchorUrl(anchor) {
  1721. return (this.baseUrl || "") + anchor;
  1722. }
  1723. }, {
  1724. key: "setHash",
  1725. value: function setHash(hash) {
  1726. var pageNumber, dest;
  1727. if (hash.includes("=")) {
  1728. var params = (0, _ui_utils.parseQueryString)(hash);
  1729. if ("search" in params) {
  1730. this.eventBus.dispatch("findfromurlhash", {
  1731. source: this,
  1732. query: params.search.replace(/"/g, ""),
  1733. phraseSearch: params.phrase === "true"
  1734. });
  1735. }
  1736. if ("page" in params) {
  1737. pageNumber = params.page | 0 || 1;
  1738. }
  1739. if ("zoom" in params) {
  1740. var zoomArgs = params.zoom.split(",");
  1741. var zoomArg = zoomArgs[0];
  1742. var zoomArgNumber = parseFloat(zoomArg);
  1743. if (!zoomArg.includes("Fit")) {
  1744. dest = [null, {
  1745. name: "XYZ"
  1746. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
  1747. } else {
  1748. if (zoomArg === "Fit" || zoomArg === "FitB") {
  1749. dest = [null, {
  1750. name: zoomArg
  1751. }];
  1752. } else if (zoomArg === "FitH" || zoomArg === "FitBH" || zoomArg === "FitV" || zoomArg === "FitBV") {
  1753. dest = [null, {
  1754. name: zoomArg
  1755. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  1756. } else if (zoomArg === "FitR") {
  1757. if (zoomArgs.length !== 5) {
  1758. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
  1759. } else {
  1760. dest = [null, {
  1761. name: zoomArg
  1762. }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
  1763. }
  1764. } else {
  1765. console.error("PDFLinkService.setHash: \"".concat(zoomArg, "\" is not ") + "a valid zoom value.");
  1766. }
  1767. }
  1768. }
  1769. if (dest) {
  1770. this.pdfViewer.scrollPageIntoView({
  1771. pageNumber: pageNumber || this.page,
  1772. destArray: dest,
  1773. allowNegativeOffset: true
  1774. });
  1775. } else if (pageNumber) {
  1776. this.page = pageNumber;
  1777. }
  1778. if ("pagemode" in params) {
  1779. this.eventBus.dispatch("pagemode", {
  1780. source: this,
  1781. mode: params.pagemode
  1782. });
  1783. }
  1784. if ("nameddest" in params) {
  1785. this.navigateTo(params.nameddest);
  1786. }
  1787. } else {
  1788. dest = unescape(hash);
  1789. try {
  1790. dest = JSON.parse(dest);
  1791. if (!Array.isArray(dest)) {
  1792. dest = dest.toString();
  1793. }
  1794. } catch (ex) {}
  1795. if (typeof dest === "string" || isValidExplicitDestination(dest)) {
  1796. this.navigateTo(dest);
  1797. return;
  1798. }
  1799. console.error("PDFLinkService.setHash: \"".concat(unescape(hash), "\" is not ") + "a valid destination.");
  1800. }
  1801. }
  1802. }, {
  1803. key: "executeNamedAction",
  1804. value: function executeNamedAction(action) {
  1805. switch (action) {
  1806. case "GoBack":
  1807. if (this.pdfHistory) {
  1808. this.pdfHistory.back();
  1809. }
  1810. break;
  1811. case "GoForward":
  1812. if (this.pdfHistory) {
  1813. this.pdfHistory.forward();
  1814. }
  1815. break;
  1816. case "NextPage":
  1817. if (this.page < this.pagesCount) {
  1818. this.page++;
  1819. }
  1820. break;
  1821. case "PrevPage":
  1822. if (this.page > 1) {
  1823. this.page--;
  1824. }
  1825. break;
  1826. case "LastPage":
  1827. this.page = this.pagesCount;
  1828. break;
  1829. case "FirstPage":
  1830. this.page = 1;
  1831. break;
  1832. default:
  1833. break;
  1834. }
  1835. this.eventBus.dispatch("namedaction", {
  1836. source: this,
  1837. action: action
  1838. });
  1839. }
  1840. }, {
  1841. key: "cachePageRef",
  1842. value: function cachePageRef(pageNum, pageRef) {
  1843. if (!pageRef) {
  1844. return;
  1845. }
  1846. var refStr = pageRef.gen === 0 ? "".concat(pageRef.num, "R") : "".concat(pageRef.num, "R").concat(pageRef.gen);
  1847. this._pagesRefCache[refStr] = pageNum;
  1848. }
  1849. }, {
  1850. key: "_cachedPageNumber",
  1851. value: function _cachedPageNumber(pageRef) {
  1852. var refStr = pageRef.gen === 0 ? "".concat(pageRef.num, "R") : "".concat(pageRef.num, "R").concat(pageRef.gen);
  1853. return this._pagesRefCache && this._pagesRefCache[refStr] || null;
  1854. }
  1855. }, {
  1856. key: "isPageVisible",
  1857. value: function isPageVisible(pageNumber) {
  1858. return this.pdfViewer.isPageVisible(pageNumber);
  1859. }
  1860. }, {
  1861. key: "pagesCount",
  1862. get: function get() {
  1863. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  1864. }
  1865. }, {
  1866. key: "page",
  1867. get: function get() {
  1868. return this.pdfViewer.currentPageNumber;
  1869. },
  1870. set: function set(value) {
  1871. this.pdfViewer.currentPageNumber = value;
  1872. }
  1873. }, {
  1874. key: "rotation",
  1875. get: function get() {
  1876. return this.pdfViewer.pagesRotation;
  1877. },
  1878. set: function set(value) {
  1879. this.pdfViewer.pagesRotation = value;
  1880. }
  1881. }]);
  1882. return PDFLinkService;
  1883. }();
  1884. exports.PDFLinkService = PDFLinkService;
  1885. function isValidExplicitDestination(dest) {
  1886. if (!Array.isArray(dest)) {
  1887. return false;
  1888. }
  1889. var destLength = dest.length;
  1890. if (destLength < 2) {
  1891. return false;
  1892. }
  1893. var page = dest[0];
  1894. if (!(_typeof(page) === "object" && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
  1895. return false;
  1896. }
  1897. var zoom = dest[1];
  1898. if (!(_typeof(zoom) === "object" && typeof zoom.name === "string")) {
  1899. return false;
  1900. }
  1901. var allowNull = true;
  1902. switch (zoom.name) {
  1903. case "XYZ":
  1904. if (destLength !== 5) {
  1905. return false;
  1906. }
  1907. break;
  1908. case "Fit":
  1909. case "FitB":
  1910. return destLength === 2;
  1911. case "FitH":
  1912. case "FitBH":
  1913. case "FitV":
  1914. case "FitBV":
  1915. if (destLength !== 3) {
  1916. return false;
  1917. }
  1918. break;
  1919. case "FitR":
  1920. if (destLength !== 6) {
  1921. return false;
  1922. }
  1923. allowNull = false;
  1924. break;
  1925. default:
  1926. return false;
  1927. }
  1928. for (var i = 2; i < destLength; i++) {
  1929. var param = dest[i];
  1930. if (!(typeof param === "number" || allowNull && param === null)) {
  1931. return false;
  1932. }
  1933. }
  1934. return true;
  1935. }
  1936. var SimpleLinkService = /*#__PURE__*/function () {
  1937. function SimpleLinkService() {
  1938. _classCallCheck(this, SimpleLinkService);
  1939. this.externalLinkTarget = null;
  1940. this.externalLinkRel = null;
  1941. this.externalLinkEnabled = true;
  1942. this._ignoreDestinationZoom = false;
  1943. }
  1944. _createClass(SimpleLinkService, [{
  1945. key: "navigateTo",
  1946. value: function navigateTo(dest) {}
  1947. }, {
  1948. key: "getDestinationHash",
  1949. value: function getDestinationHash(dest) {
  1950. return "#";
  1951. }
  1952. }, {
  1953. key: "getAnchorUrl",
  1954. value: function getAnchorUrl(hash) {
  1955. return "#";
  1956. }
  1957. }, {
  1958. key: "setHash",
  1959. value: function setHash(hash) {}
  1960. }, {
  1961. key: "executeNamedAction",
  1962. value: function executeNamedAction(action) {}
  1963. }, {
  1964. key: "cachePageRef",
  1965. value: function cachePageRef(pageNum, pageRef) {}
  1966. }, {
  1967. key: "isPageVisible",
  1968. value: function isPageVisible(pageNumber) {
  1969. return true;
  1970. }
  1971. }, {
  1972. key: "pagesCount",
  1973. get: function get() {
  1974. return 0;
  1975. }
  1976. }, {
  1977. key: "page",
  1978. get: function get() {
  1979. return 0;
  1980. },
  1981. set: function set(value) {}
  1982. }, {
  1983. key: "rotation",
  1984. get: function get() {
  1985. return 0;
  1986. },
  1987. set: function set(value) {}
  1988. }]);
  1989. return SimpleLinkService;
  1990. }();
  1991. exports.SimpleLinkService = SimpleLinkService;
  1992. /***/ }),
  1993. /* 8 */
  1994. /***/ (function(module, exports, __w_pdfjs_require__) {
  1995. "use strict";
  1996. Object.defineProperty(exports, "__esModule", {
  1997. value: true
  1998. });
  1999. exports.DefaultTextLayerFactory = exports.TextLayerBuilder = void 0;
  2000. var _pdfjsLib = __w_pdfjs_require__(2);
  2001. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2002. 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); } }
  2003. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2004. var EXPAND_DIVS_TIMEOUT = 300;
  2005. var TextLayerBuilder = /*#__PURE__*/function () {
  2006. function TextLayerBuilder(_ref) {
  2007. var textLayerDiv = _ref.textLayerDiv,
  2008. eventBus = _ref.eventBus,
  2009. pageIndex = _ref.pageIndex,
  2010. viewport = _ref.viewport,
  2011. _ref$findController = _ref.findController,
  2012. findController = _ref$findController === void 0 ? null : _ref$findController,
  2013. _ref$enhanceTextSelec = _ref.enhanceTextSelection,
  2014. enhanceTextSelection = _ref$enhanceTextSelec === void 0 ? false : _ref$enhanceTextSelec;
  2015. _classCallCheck(this, TextLayerBuilder);
  2016. this.textLayerDiv = textLayerDiv;
  2017. this.eventBus = eventBus;
  2018. this.textContent = null;
  2019. this.textContentItemsStr = [];
  2020. this.textContentStream = null;
  2021. this.renderingDone = false;
  2022. this.pageIdx = pageIndex;
  2023. this.pageNumber = this.pageIdx + 1;
  2024. this.matches = [];
  2025. this.viewport = viewport;
  2026. this.textDivs = [];
  2027. this.findController = findController;
  2028. this.textLayerRenderTask = null;
  2029. this.enhanceTextSelection = enhanceTextSelection;
  2030. this._onUpdateTextLayerMatches = null;
  2031. this._bindMouse();
  2032. }
  2033. _createClass(TextLayerBuilder, [{
  2034. key: "_finishRendering",
  2035. value: function _finishRendering() {
  2036. this.renderingDone = true;
  2037. if (!this.enhanceTextSelection) {
  2038. var endOfContent = document.createElement("div");
  2039. endOfContent.className = "endOfContent";
  2040. this.textLayerDiv.appendChild(endOfContent);
  2041. }
  2042. this.eventBus.dispatch("textlayerrendered", {
  2043. source: this,
  2044. pageNumber: this.pageNumber,
  2045. numTextDivs: this.textDivs.length
  2046. });
  2047. }
  2048. }, {
  2049. key: "render",
  2050. value: function render() {
  2051. var _this = this;
  2052. var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  2053. if (!(this.textContent || this.textContentStream) || this.renderingDone) {
  2054. return;
  2055. }
  2056. this.cancel();
  2057. this.textDivs = [];
  2058. var textLayerFrag = document.createDocumentFragment();
  2059. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  2060. textContent: this.textContent,
  2061. textContentStream: this.textContentStream,
  2062. container: textLayerFrag,
  2063. viewport: this.viewport,
  2064. textDivs: this.textDivs,
  2065. textContentItemsStr: this.textContentItemsStr,
  2066. timeout: timeout,
  2067. enhanceTextSelection: this.enhanceTextSelection
  2068. });
  2069. this.textLayerRenderTask.promise.then(function () {
  2070. _this.textLayerDiv.appendChild(textLayerFrag);
  2071. _this._finishRendering();
  2072. _this._updateMatches();
  2073. }, function (reason) {});
  2074. if (!this._onUpdateTextLayerMatches) {
  2075. this._onUpdateTextLayerMatches = function (evt) {
  2076. if (evt.pageIndex === _this.pageIdx || evt.pageIndex === -1) {
  2077. _this._updateMatches();
  2078. }
  2079. };
  2080. this.eventBus._on("updatetextlayermatches", this._onUpdateTextLayerMatches);
  2081. }
  2082. }
  2083. }, {
  2084. key: "cancel",
  2085. value: function cancel() {
  2086. if (this.textLayerRenderTask) {
  2087. this.textLayerRenderTask.cancel();
  2088. this.textLayerRenderTask = null;
  2089. }
  2090. if (this._onUpdateTextLayerMatches) {
  2091. this.eventBus._off("updatetextlayermatches", this._onUpdateTextLayerMatches);
  2092. this._onUpdateTextLayerMatches = null;
  2093. }
  2094. }
  2095. }, {
  2096. key: "setTextContentStream",
  2097. value: function setTextContentStream(readableStream) {
  2098. this.cancel();
  2099. this.textContentStream = readableStream;
  2100. }
  2101. }, {
  2102. key: "setTextContent",
  2103. value: function setTextContent(textContent) {
  2104. this.cancel();
  2105. this.textContent = textContent;
  2106. }
  2107. }, {
  2108. key: "_convertMatches",
  2109. value: function _convertMatches(matches, matchesLength) {
  2110. if (!matches) {
  2111. return [];
  2112. }
  2113. var findController = this.findController,
  2114. textContentItemsStr = this.textContentItemsStr;
  2115. var i = 0,
  2116. iIndex = 0;
  2117. var end = textContentItemsStr.length - 1;
  2118. var queryLen = findController.state.query.length;
  2119. var result = [];
  2120. for (var m = 0, mm = matches.length; m < mm; m++) {
  2121. var matchIdx = matches[m];
  2122. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  2123. iIndex += textContentItemsStr[i].length;
  2124. i++;
  2125. }
  2126. if (i === textContentItemsStr.length) {
  2127. console.error("Could not find a matching mapping");
  2128. }
  2129. var match = {
  2130. begin: {
  2131. divIdx: i,
  2132. offset: matchIdx - iIndex
  2133. }
  2134. };
  2135. if (matchesLength) {
  2136. matchIdx += matchesLength[m];
  2137. } else {
  2138. matchIdx += queryLen;
  2139. }
  2140. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  2141. iIndex += textContentItemsStr[i].length;
  2142. i++;
  2143. }
  2144. match.end = {
  2145. divIdx: i,
  2146. offset: matchIdx - iIndex
  2147. };
  2148. result.push(match);
  2149. }
  2150. return result;
  2151. }
  2152. }, {
  2153. key: "_renderMatches",
  2154. value: function _renderMatches(matches) {
  2155. if (matches.length === 0) {
  2156. return;
  2157. }
  2158. var findController = this.findController,
  2159. pageIdx = this.pageIdx,
  2160. textContentItemsStr = this.textContentItemsStr,
  2161. textDivs = this.textDivs;
  2162. var isSelectedPage = pageIdx === findController.selected.pageIdx;
  2163. var selectedMatchIdx = findController.selected.matchIdx;
  2164. var highlightAll = findController.state.highlightAll;
  2165. var prevEnd = null;
  2166. var infinity = {
  2167. divIdx: -1,
  2168. offset: undefined
  2169. };
  2170. function beginText(begin, className) {
  2171. var divIdx = begin.divIdx;
  2172. textDivs[divIdx].textContent = "";
  2173. appendTextToDiv(divIdx, 0, begin.offset, className);
  2174. }
  2175. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  2176. var div = textDivs[divIdx];
  2177. var content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  2178. var node = document.createTextNode(content);
  2179. if (className) {
  2180. var span = document.createElement("span");
  2181. span.className = className;
  2182. span.appendChild(node);
  2183. div.appendChild(span);
  2184. return;
  2185. }
  2186. div.appendChild(node);
  2187. }
  2188. var i0 = selectedMatchIdx,
  2189. i1 = i0 + 1;
  2190. if (highlightAll) {
  2191. i0 = 0;
  2192. i1 = matches.length;
  2193. } else if (!isSelectedPage) {
  2194. return;
  2195. }
  2196. for (var i = i0; i < i1; i++) {
  2197. var match = matches[i];
  2198. var begin = match.begin;
  2199. var end = match.end;
  2200. var isSelected = isSelectedPage && i === selectedMatchIdx;
  2201. var highlightSuffix = isSelected ? " selected" : "";
  2202. if (isSelected) {
  2203. findController.scrollMatchIntoView({
  2204. element: textDivs[begin.divIdx],
  2205. pageIndex: pageIdx,
  2206. matchIndex: selectedMatchIdx
  2207. });
  2208. }
  2209. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  2210. if (prevEnd !== null) {
  2211. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  2212. }
  2213. beginText(begin);
  2214. } else {
  2215. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  2216. }
  2217. if (begin.divIdx === end.divIdx) {
  2218. appendTextToDiv(begin.divIdx, begin.offset, end.offset, "highlight" + highlightSuffix);
  2219. } else {
  2220. appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, "highlight begin" + highlightSuffix);
  2221. for (var n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  2222. textDivs[n0].className = "highlight middle" + highlightSuffix;
  2223. }
  2224. beginText(end, "highlight end" + highlightSuffix);
  2225. }
  2226. prevEnd = end;
  2227. }
  2228. if (prevEnd) {
  2229. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  2230. }
  2231. }
  2232. }, {
  2233. key: "_updateMatches",
  2234. value: function _updateMatches() {
  2235. if (!this.renderingDone) {
  2236. return;
  2237. }
  2238. var findController = this.findController,
  2239. matches = this.matches,
  2240. pageIdx = this.pageIdx,
  2241. textContentItemsStr = this.textContentItemsStr,
  2242. textDivs = this.textDivs;
  2243. var clearedUntilDivIdx = -1;
  2244. for (var i = 0, ii = matches.length; i < ii; i++) {
  2245. var match = matches[i];
  2246. var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  2247. for (var n = begin, end = match.end.divIdx; n <= end; n++) {
  2248. var div = textDivs[n];
  2249. div.textContent = textContentItemsStr[n];
  2250. div.className = "";
  2251. }
  2252. clearedUntilDivIdx = match.end.divIdx + 1;
  2253. }
  2254. if (!findController || !findController.highlightMatches) {
  2255. return;
  2256. }
  2257. var pageMatches = findController.pageMatches[pageIdx] || null;
  2258. var pageMatchesLength = findController.pageMatchesLength[pageIdx] || null;
  2259. this.matches = this._convertMatches(pageMatches, pageMatchesLength);
  2260. this._renderMatches(this.matches);
  2261. }
  2262. }, {
  2263. key: "_bindMouse",
  2264. value: function _bindMouse() {
  2265. var _this2 = this;
  2266. var div = this.textLayerDiv;
  2267. var expandDivsTimer = null;
  2268. div.addEventListener("mousedown", function (evt) {
  2269. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  2270. _this2.textLayerRenderTask.expandTextDivs(true);
  2271. if (expandDivsTimer) {
  2272. clearTimeout(expandDivsTimer);
  2273. expandDivsTimer = null;
  2274. }
  2275. return;
  2276. }
  2277. var end = div.querySelector(".endOfContent");
  2278. if (!end) {
  2279. return;
  2280. }
  2281. var adjustTop = evt.target !== div;
  2282. adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue("-moz-user-select") !== "none";
  2283. if (adjustTop) {
  2284. var divBounds = div.getBoundingClientRect();
  2285. var r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  2286. end.style.top = (r * 100).toFixed(2) + "%";
  2287. }
  2288. end.classList.add("active");
  2289. });
  2290. div.addEventListener("mouseup", function () {
  2291. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  2292. expandDivsTimer = setTimeout(function () {
  2293. if (_this2.textLayerRenderTask) {
  2294. _this2.textLayerRenderTask.expandTextDivs(false);
  2295. }
  2296. expandDivsTimer = null;
  2297. }, EXPAND_DIVS_TIMEOUT);
  2298. return;
  2299. }
  2300. var end = div.querySelector(".endOfContent");
  2301. if (!end) {
  2302. return;
  2303. }
  2304. end.style.top = "";
  2305. end.classList.remove("active");
  2306. });
  2307. }
  2308. }]);
  2309. return TextLayerBuilder;
  2310. }();
  2311. exports.TextLayerBuilder = TextLayerBuilder;
  2312. var DefaultTextLayerFactory = /*#__PURE__*/function () {
  2313. function DefaultTextLayerFactory() {
  2314. _classCallCheck(this, DefaultTextLayerFactory);
  2315. }
  2316. _createClass(DefaultTextLayerFactory, [{
  2317. key: "createTextLayerBuilder",
  2318. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  2319. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  2320. var eventBus = arguments.length > 4 ? arguments[4] : undefined;
  2321. return new TextLayerBuilder({
  2322. textLayerDiv: textLayerDiv,
  2323. pageIndex: pageIndex,
  2324. viewport: viewport,
  2325. enhanceTextSelection: enhanceTextSelection,
  2326. eventBus: eventBus
  2327. });
  2328. }
  2329. }]);
  2330. return DefaultTextLayerFactory;
  2331. }();
  2332. exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
  2333. /***/ }),
  2334. /* 9 */
  2335. /***/ (function(module, exports, __w_pdfjs_require__) {
  2336. "use strict";
  2337. Object.defineProperty(exports, "__esModule", {
  2338. value: true
  2339. });
  2340. exports.DownloadManager = void 0;
  2341. var _pdfjsLib = __w_pdfjs_require__(2);
  2342. var _viewer_compatibility = __w_pdfjs_require__(10);
  2343. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2344. 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); } }
  2345. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2346. ;
  2347. function _download(blobUrl, filename) {
  2348. var a = document.createElement("a");
  2349. if (!a.click) {
  2350. throw new Error('DownloadManager: "a.click()" is not supported.');
  2351. }
  2352. a.href = blobUrl;
  2353. a.target = "_parent";
  2354. if ("download" in a) {
  2355. a.download = filename;
  2356. }
  2357. (document.body || document.documentElement).appendChild(a);
  2358. a.click();
  2359. a.remove();
  2360. }
  2361. var DownloadManager = /*#__PURE__*/function () {
  2362. function DownloadManager() {
  2363. _classCallCheck(this, DownloadManager);
  2364. }
  2365. _createClass(DownloadManager, [{
  2366. key: "downloadUrl",
  2367. value: function downloadUrl(url, filename) {
  2368. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, "http://example.com")) {
  2369. return;
  2370. }
  2371. _download(url + "#pdfjs.action=download", filename);
  2372. }
  2373. }, {
  2374. key: "downloadData",
  2375. value: function downloadData(data, filename, contentType) {
  2376. if (navigator.msSaveBlob) {
  2377. navigator.msSaveBlob(new Blob([data], {
  2378. type: contentType
  2379. }), filename);
  2380. return;
  2381. }
  2382. var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, _viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL);
  2383. _download(blobUrl, filename);
  2384. }
  2385. }, {
  2386. key: "download",
  2387. value: function download(blob, url, filename) {
  2388. var sourceEventType = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "download";
  2389. if (navigator.msSaveBlob) {
  2390. if (!navigator.msSaveBlob(blob, filename)) {
  2391. this.downloadUrl(url, filename);
  2392. }
  2393. return;
  2394. }
  2395. if (_viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL) {
  2396. this.downloadUrl(url, filename);
  2397. return;
  2398. }
  2399. var blobUrl = URL.createObjectURL(blob);
  2400. _download(blobUrl, filename);
  2401. }
  2402. }]);
  2403. return DownloadManager;
  2404. }();
  2405. exports.DownloadManager = DownloadManager;
  2406. /***/ }),
  2407. /* 10 */
  2408. /***/ (function(module, exports, __w_pdfjs_require__) {
  2409. "use strict";
  2410. Object.defineProperty(exports, "__esModule", {
  2411. value: true
  2412. });
  2413. exports.viewerCompatibilityParams = void 0;
  2414. var compatibilityParams = Object.create(null);
  2415. {
  2416. var userAgent = typeof navigator !== "undefined" && navigator.userAgent || "";
  2417. var platform = typeof navigator !== "undefined" && navigator.platform || "";
  2418. var maxTouchPoints = typeof navigator !== "undefined" && navigator.maxTouchPoints || 1;
  2419. var isAndroid = /Android/.test(userAgent);
  2420. var isIE = /Trident/.test(userAgent);
  2421. var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" && maxTouchPoints > 1;
  2422. var isIOSChrome = /CriOS/.test(userAgent);
  2423. (function checkOnBlobSupport() {
  2424. if (isIE || isIOSChrome) {
  2425. compatibilityParams.disableCreateObjectURL = true;
  2426. }
  2427. })();
  2428. (function checkCanvasSizeLimitation() {
  2429. if (isIOS || isAndroid) {
  2430. compatibilityParams.maxCanvasPixels = 5242880;
  2431. }
  2432. })();
  2433. }
  2434. var viewerCompatibilityParams = Object.freeze(compatibilityParams);
  2435. exports.viewerCompatibilityParams = viewerCompatibilityParams;
  2436. /***/ }),
  2437. /* 11 */
  2438. /***/ (function(module, exports, __w_pdfjs_require__) {
  2439. "use strict";
  2440. Object.defineProperty(exports, "__esModule", {
  2441. value: true
  2442. });
  2443. exports.GenericL10n = void 0;
  2444. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(4));
  2445. __w_pdfjs_require__(12);
  2446. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  2447. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  2448. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  2449. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2450. 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); } }
  2451. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2452. var webL10n = document.webL10n;
  2453. var GenericL10n = /*#__PURE__*/function () {
  2454. function GenericL10n(lang) {
  2455. _classCallCheck(this, GenericL10n);
  2456. this._lang = lang;
  2457. this._ready = new Promise(function (resolve, reject) {
  2458. webL10n.setLanguage(lang, function () {
  2459. resolve(webL10n);
  2460. });
  2461. });
  2462. }
  2463. _createClass(GenericL10n, [{
  2464. key: "getLanguage",
  2465. value: function () {
  2466. var _getLanguage = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  2467. var l10n;
  2468. return _regenerator["default"].wrap(function _callee$(_context) {
  2469. while (1) {
  2470. switch (_context.prev = _context.next) {
  2471. case 0:
  2472. _context.next = 2;
  2473. return this._ready;
  2474. case 2:
  2475. l10n = _context.sent;
  2476. return _context.abrupt("return", l10n.getLanguage());
  2477. case 4:
  2478. case "end":
  2479. return _context.stop();
  2480. }
  2481. }
  2482. }, _callee, this);
  2483. }));
  2484. function getLanguage() {
  2485. return _getLanguage.apply(this, arguments);
  2486. }
  2487. return getLanguage;
  2488. }()
  2489. }, {
  2490. key: "getDirection",
  2491. value: function () {
  2492. var _getDirection = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  2493. var l10n;
  2494. return _regenerator["default"].wrap(function _callee2$(_context2) {
  2495. while (1) {
  2496. switch (_context2.prev = _context2.next) {
  2497. case 0:
  2498. _context2.next = 2;
  2499. return this._ready;
  2500. case 2:
  2501. l10n = _context2.sent;
  2502. return _context2.abrupt("return", l10n.getDirection());
  2503. case 4:
  2504. case "end":
  2505. return _context2.stop();
  2506. }
  2507. }
  2508. }, _callee2, this);
  2509. }));
  2510. function getDirection() {
  2511. return _getDirection.apply(this, arguments);
  2512. }
  2513. return getDirection;
  2514. }()
  2515. }, {
  2516. key: "get",
  2517. value: function () {
  2518. var _get = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(property, args, fallback) {
  2519. var l10n;
  2520. return _regenerator["default"].wrap(function _callee3$(_context3) {
  2521. while (1) {
  2522. switch (_context3.prev = _context3.next) {
  2523. case 0:
  2524. _context3.next = 2;
  2525. return this._ready;
  2526. case 2:
  2527. l10n = _context3.sent;
  2528. return _context3.abrupt("return", l10n.get(property, args, fallback));
  2529. case 4:
  2530. case "end":
  2531. return _context3.stop();
  2532. }
  2533. }
  2534. }, _callee3, this);
  2535. }));
  2536. function get(_x, _x2, _x3) {
  2537. return _get.apply(this, arguments);
  2538. }
  2539. return get;
  2540. }()
  2541. }, {
  2542. key: "translate",
  2543. value: function () {
  2544. var _translate = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(element) {
  2545. var l10n;
  2546. return _regenerator["default"].wrap(function _callee4$(_context4) {
  2547. while (1) {
  2548. switch (_context4.prev = _context4.next) {
  2549. case 0:
  2550. _context4.next = 2;
  2551. return this._ready;
  2552. case 2:
  2553. l10n = _context4.sent;
  2554. return _context4.abrupt("return", l10n.translate(element));
  2555. case 4:
  2556. case "end":
  2557. return _context4.stop();
  2558. }
  2559. }
  2560. }, _callee4, this);
  2561. }));
  2562. function translate(_x4) {
  2563. return _translate.apply(this, arguments);
  2564. }
  2565. return translate;
  2566. }()
  2567. }]);
  2568. return GenericL10n;
  2569. }();
  2570. exports.GenericL10n = GenericL10n;
  2571. /***/ }),
  2572. /* 12 */
  2573. /***/ (function(module, exports, __w_pdfjs_require__) {
  2574. "use strict";
  2575. document.webL10n = function (window, document, undefined) {
  2576. var gL10nData = {};
  2577. var gTextData = '';
  2578. var gTextProp = 'textContent';
  2579. var gLanguage = '';
  2580. var gMacros = {};
  2581. var gReadyState = 'loading';
  2582. var gAsyncResourceLoading = true;
  2583. function getL10nResourceLinks() {
  2584. return document.querySelectorAll('link[type="application/l10n"]');
  2585. }
  2586. function getL10nDictionary() {
  2587. var script = document.querySelector('script[type="application/l10n"]');
  2588. return script ? JSON.parse(script.innerHTML) : null;
  2589. }
  2590. function getTranslatableChildren(element) {
  2591. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  2592. }
  2593. function getL10nAttributes(element) {
  2594. if (!element) return {};
  2595. var l10nId = element.getAttribute('data-l10n-id');
  2596. var l10nArgs = element.getAttribute('data-l10n-args');
  2597. var args = {};
  2598. if (l10nArgs) {
  2599. try {
  2600. args = JSON.parse(l10nArgs);
  2601. } catch (e) {
  2602. console.warn('could not parse arguments for #' + l10nId);
  2603. }
  2604. }
  2605. return {
  2606. id: l10nId,
  2607. args: args
  2608. };
  2609. }
  2610. function xhrLoadText(url, onSuccess, onFailure) {
  2611. onSuccess = onSuccess || function _onSuccess(data) {};
  2612. onFailure = onFailure || function _onFailure() {};
  2613. var xhr = new XMLHttpRequest();
  2614. xhr.open('GET', url, gAsyncResourceLoading);
  2615. if (xhr.overrideMimeType) {
  2616. xhr.overrideMimeType('text/plain; charset=utf-8');
  2617. }
  2618. xhr.onreadystatechange = function () {
  2619. if (xhr.readyState == 4) {
  2620. if (xhr.status == 200 || xhr.status === 0) {
  2621. onSuccess(xhr.responseText);
  2622. } else {
  2623. onFailure();
  2624. }
  2625. }
  2626. };
  2627. xhr.onerror = onFailure;
  2628. xhr.ontimeout = onFailure;
  2629. try {
  2630. xhr.send(null);
  2631. } catch (e) {
  2632. onFailure();
  2633. }
  2634. }
  2635. function parseResource(href, lang, successCallback, failureCallback) {
  2636. var baseURL = href.replace(/[^\/]*$/, '') || './';
  2637. function evalString(text) {
  2638. if (text.lastIndexOf('\\') < 0) return text;
  2639. 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, "'");
  2640. }
  2641. function parseProperties(text, parsedPropertiesCallback) {
  2642. var dictionary = {};
  2643. var reBlank = /^\s*|\s*$/;
  2644. var reComment = /^\s*#|^\s*$/;
  2645. var reSection = /^\s*\[(.*)\]\s*$/;
  2646. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  2647. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  2648. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  2649. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  2650. var currentLang = '*';
  2651. var genericLang = lang.split('-', 1)[0];
  2652. var skipLang = false;
  2653. var match = '';
  2654. function nextEntry() {
  2655. while (true) {
  2656. if (!entries.length) {
  2657. parsedRawLinesCallback();
  2658. return;
  2659. }
  2660. var line = entries.shift();
  2661. if (reComment.test(line)) continue;
  2662. if (extendedSyntax) {
  2663. match = reSection.exec(line);
  2664. if (match) {
  2665. currentLang = match[1].toLowerCase();
  2666. skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
  2667. continue;
  2668. } else if (skipLang) {
  2669. continue;
  2670. }
  2671. match = reImport.exec(line);
  2672. if (match) {
  2673. loadImport(baseURL + match[1], nextEntry);
  2674. return;
  2675. }
  2676. }
  2677. var tmp = line.match(reSplit);
  2678. if (tmp && tmp.length == 3) {
  2679. dictionary[tmp[1]] = evalString(tmp[2]);
  2680. }
  2681. }
  2682. }
  2683. nextEntry();
  2684. }
  2685. function loadImport(url, callback) {
  2686. xhrLoadText(url, function (content) {
  2687. parseRawLines(content, false, callback);
  2688. }, function () {
  2689. console.warn(url + ' not found.');
  2690. callback();
  2691. });
  2692. }
  2693. parseRawLines(text, true, function () {
  2694. parsedPropertiesCallback(dictionary);
  2695. });
  2696. }
  2697. xhrLoadText(href, function (response) {
  2698. gTextData += response;
  2699. parseProperties(response, function (data) {
  2700. for (var key in data) {
  2701. var id,
  2702. prop,
  2703. index = key.lastIndexOf('.');
  2704. if (index > 0) {
  2705. id = key.substring(0, index);
  2706. prop = key.substring(index + 1);
  2707. } else {
  2708. id = key;
  2709. prop = gTextProp;
  2710. }
  2711. if (!gL10nData[id]) {
  2712. gL10nData[id] = {};
  2713. }
  2714. gL10nData[id][prop] = data[key];
  2715. }
  2716. if (successCallback) {
  2717. successCallback();
  2718. }
  2719. });
  2720. }, failureCallback);
  2721. }
  2722. function loadLocale(lang, callback) {
  2723. if (lang) {
  2724. lang = lang.toLowerCase();
  2725. }
  2726. callback = callback || function _callback() {};
  2727. clear();
  2728. gLanguage = lang;
  2729. var langLinks = getL10nResourceLinks();
  2730. var langCount = langLinks.length;
  2731. if (langCount === 0) {
  2732. var dict = getL10nDictionary();
  2733. if (dict && dict.locales && dict.default_locale) {
  2734. console.log('using the embedded JSON directory, early way out');
  2735. gL10nData = dict.locales[lang];
  2736. if (!gL10nData) {
  2737. var defaultLocale = dict.default_locale.toLowerCase();
  2738. for (var anyCaseLang in dict.locales) {
  2739. anyCaseLang = anyCaseLang.toLowerCase();
  2740. if (anyCaseLang === lang) {
  2741. gL10nData = dict.locales[lang];
  2742. break;
  2743. } else if (anyCaseLang === defaultLocale) {
  2744. gL10nData = dict.locales[defaultLocale];
  2745. }
  2746. }
  2747. }
  2748. callback();
  2749. } else {
  2750. console.log('no resource to load, early way out');
  2751. }
  2752. gReadyState = 'complete';
  2753. return;
  2754. }
  2755. var onResourceLoaded = null;
  2756. var gResourceCount = 0;
  2757. onResourceLoaded = function onResourceLoaded() {
  2758. gResourceCount++;
  2759. if (gResourceCount >= langCount) {
  2760. callback();
  2761. gReadyState = 'complete';
  2762. }
  2763. };
  2764. function L10nResourceLink(link) {
  2765. var href = link.href;
  2766. this.load = function (lang, callback) {
  2767. parseResource(href, lang, callback, function () {
  2768. console.warn(href + ' not found.');
  2769. console.warn('"' + lang + '" resource not found');
  2770. gLanguage = '';
  2771. callback();
  2772. });
  2773. };
  2774. }
  2775. for (var i = 0; i < langCount; i++) {
  2776. var resource = new L10nResourceLink(langLinks[i]);
  2777. resource.load(lang, onResourceLoaded);
  2778. }
  2779. }
  2780. function clear() {
  2781. gL10nData = {};
  2782. gTextData = '';
  2783. gLanguage = '';
  2784. }
  2785. function getPluralRules(lang) {
  2786. var locales2rules = {
  2787. 'af': 3,
  2788. 'ak': 4,
  2789. 'am': 4,
  2790. 'ar': 1,
  2791. 'asa': 3,
  2792. 'az': 0,
  2793. 'be': 11,
  2794. 'bem': 3,
  2795. 'bez': 3,
  2796. 'bg': 3,
  2797. 'bh': 4,
  2798. 'bm': 0,
  2799. 'bn': 3,
  2800. 'bo': 0,
  2801. 'br': 20,
  2802. 'brx': 3,
  2803. 'bs': 11,
  2804. 'ca': 3,
  2805. 'cgg': 3,
  2806. 'chr': 3,
  2807. 'cs': 12,
  2808. 'cy': 17,
  2809. 'da': 3,
  2810. 'de': 3,
  2811. 'dv': 3,
  2812. 'dz': 0,
  2813. 'ee': 3,
  2814. 'el': 3,
  2815. 'en': 3,
  2816. 'eo': 3,
  2817. 'es': 3,
  2818. 'et': 3,
  2819. 'eu': 3,
  2820. 'fa': 0,
  2821. 'ff': 5,
  2822. 'fi': 3,
  2823. 'fil': 4,
  2824. 'fo': 3,
  2825. 'fr': 5,
  2826. 'fur': 3,
  2827. 'fy': 3,
  2828. 'ga': 8,
  2829. 'gd': 24,
  2830. 'gl': 3,
  2831. 'gsw': 3,
  2832. 'gu': 3,
  2833. 'guw': 4,
  2834. 'gv': 23,
  2835. 'ha': 3,
  2836. 'haw': 3,
  2837. 'he': 2,
  2838. 'hi': 4,
  2839. 'hr': 11,
  2840. 'hu': 0,
  2841. 'id': 0,
  2842. 'ig': 0,
  2843. 'ii': 0,
  2844. 'is': 3,
  2845. 'it': 3,
  2846. 'iu': 7,
  2847. 'ja': 0,
  2848. 'jmc': 3,
  2849. 'jv': 0,
  2850. 'ka': 0,
  2851. 'kab': 5,
  2852. 'kaj': 3,
  2853. 'kcg': 3,
  2854. 'kde': 0,
  2855. 'kea': 0,
  2856. 'kk': 3,
  2857. 'kl': 3,
  2858. 'km': 0,
  2859. 'kn': 0,
  2860. 'ko': 0,
  2861. 'ksb': 3,
  2862. 'ksh': 21,
  2863. 'ku': 3,
  2864. 'kw': 7,
  2865. 'lag': 18,
  2866. 'lb': 3,
  2867. 'lg': 3,
  2868. 'ln': 4,
  2869. 'lo': 0,
  2870. 'lt': 10,
  2871. 'lv': 6,
  2872. 'mas': 3,
  2873. 'mg': 4,
  2874. 'mk': 16,
  2875. 'ml': 3,
  2876. 'mn': 3,
  2877. 'mo': 9,
  2878. 'mr': 3,
  2879. 'ms': 0,
  2880. 'mt': 15,
  2881. 'my': 0,
  2882. 'nah': 3,
  2883. 'naq': 7,
  2884. 'nb': 3,
  2885. 'nd': 3,
  2886. 'ne': 3,
  2887. 'nl': 3,
  2888. 'nn': 3,
  2889. 'no': 3,
  2890. 'nr': 3,
  2891. 'nso': 4,
  2892. 'ny': 3,
  2893. 'nyn': 3,
  2894. 'om': 3,
  2895. 'or': 3,
  2896. 'pa': 3,
  2897. 'pap': 3,
  2898. 'pl': 13,
  2899. 'ps': 3,
  2900. 'pt': 3,
  2901. 'rm': 3,
  2902. 'ro': 9,
  2903. 'rof': 3,
  2904. 'ru': 11,
  2905. 'rwk': 3,
  2906. 'sah': 0,
  2907. 'saq': 3,
  2908. 'se': 7,
  2909. 'seh': 3,
  2910. 'ses': 0,
  2911. 'sg': 0,
  2912. 'sh': 11,
  2913. 'shi': 19,
  2914. 'sk': 12,
  2915. 'sl': 14,
  2916. 'sma': 7,
  2917. 'smi': 7,
  2918. 'smj': 7,
  2919. 'smn': 7,
  2920. 'sms': 7,
  2921. 'sn': 3,
  2922. 'so': 3,
  2923. 'sq': 3,
  2924. 'sr': 11,
  2925. 'ss': 3,
  2926. 'ssy': 3,
  2927. 'st': 3,
  2928. 'sv': 3,
  2929. 'sw': 3,
  2930. 'syr': 3,
  2931. 'ta': 3,
  2932. 'te': 3,
  2933. 'teo': 3,
  2934. 'th': 0,
  2935. 'ti': 4,
  2936. 'tig': 3,
  2937. 'tk': 3,
  2938. 'tl': 4,
  2939. 'tn': 3,
  2940. 'to': 0,
  2941. 'tr': 0,
  2942. 'ts': 3,
  2943. 'tzm': 22,
  2944. 'uk': 11,
  2945. 'ur': 3,
  2946. 've': 3,
  2947. 'vi': 0,
  2948. 'vun': 3,
  2949. 'wa': 4,
  2950. 'wae': 3,
  2951. 'wo': 0,
  2952. 'xh': 3,
  2953. 'xog': 3,
  2954. 'yo': 0,
  2955. 'zh': 0,
  2956. 'zu': 3
  2957. };
  2958. function isIn(n, list) {
  2959. return list.indexOf(n) !== -1;
  2960. }
  2961. function isBetween(n, start, end) {
  2962. return start <= n && n <= end;
  2963. }
  2964. var pluralRules = {
  2965. '0': function _(n) {
  2966. return 'other';
  2967. },
  2968. '1': function _(n) {
  2969. if (isBetween(n % 100, 3, 10)) return 'few';
  2970. if (n === 0) return 'zero';
  2971. if (isBetween(n % 100, 11, 99)) return 'many';
  2972. if (n == 2) return 'two';
  2973. if (n == 1) return 'one';
  2974. return 'other';
  2975. },
  2976. '2': function _(n) {
  2977. if (n !== 0 && n % 10 === 0) return 'many';
  2978. if (n == 2) return 'two';
  2979. if (n == 1) return 'one';
  2980. return 'other';
  2981. },
  2982. '3': function _(n) {
  2983. if (n == 1) return 'one';
  2984. return 'other';
  2985. },
  2986. '4': function _(n) {
  2987. if (isBetween(n, 0, 1)) return 'one';
  2988. return 'other';
  2989. },
  2990. '5': function _(n) {
  2991. if (isBetween(n, 0, 2) && n != 2) return 'one';
  2992. return 'other';
  2993. },
  2994. '6': function _(n) {
  2995. if (n === 0) return 'zero';
  2996. if (n % 10 == 1 && n % 100 != 11) return 'one';
  2997. return 'other';
  2998. },
  2999. '7': function _(n) {
  3000. if (n == 2) return 'two';
  3001. if (n == 1) return 'one';
  3002. return 'other';
  3003. },
  3004. '8': function _(n) {
  3005. if (isBetween(n, 3, 6)) return 'few';
  3006. if (isBetween(n, 7, 10)) return 'many';
  3007. if (n == 2) return 'two';
  3008. if (n == 1) return 'one';
  3009. return 'other';
  3010. },
  3011. '9': function _(n) {
  3012. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  3013. if (n == 1) return 'one';
  3014. return 'other';
  3015. },
  3016. '10': function _(n) {
  3017. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  3018. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  3019. return 'other';
  3020. },
  3021. '11': function _(n) {
  3022. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  3023. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
  3024. if (n % 10 == 1 && n % 100 != 11) return 'one';
  3025. return 'other';
  3026. },
  3027. '12': function _(n) {
  3028. if (isBetween(n, 2, 4)) return 'few';
  3029. if (n == 1) return 'one';
  3030. return 'other';
  3031. },
  3032. '13': function _(n) {
  3033. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  3034. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
  3035. if (n == 1) return 'one';
  3036. return 'other';
  3037. },
  3038. '14': function _(n) {
  3039. if (isBetween(n % 100, 3, 4)) return 'few';
  3040. if (n % 100 == 2) return 'two';
  3041. if (n % 100 == 1) return 'one';
  3042. return 'other';
  3043. },
  3044. '15': function _(n) {
  3045. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  3046. if (isBetween(n % 100, 11, 19)) return 'many';
  3047. if (n == 1) return 'one';
  3048. return 'other';
  3049. },
  3050. '16': function _(n) {
  3051. if (n % 10 == 1 && n != 11) return 'one';
  3052. return 'other';
  3053. },
  3054. '17': function _(n) {
  3055. if (n == 3) return 'few';
  3056. if (n === 0) return 'zero';
  3057. if (n == 6) return 'many';
  3058. if (n == 2) return 'two';
  3059. if (n == 1) return 'one';
  3060. return 'other';
  3061. },
  3062. '18': function _(n) {
  3063. if (n === 0) return 'zero';
  3064. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  3065. return 'other';
  3066. },
  3067. '19': function _(n) {
  3068. if (isBetween(n, 2, 10)) return 'few';
  3069. if (isBetween(n, 0, 1)) return 'one';
  3070. return 'other';
  3071. },
  3072. '20': function _(n) {
  3073. 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';
  3074. if (n % 1000000 === 0 && n !== 0) return 'many';
  3075. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  3076. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  3077. return 'other';
  3078. },
  3079. '21': function _(n) {
  3080. if (n === 0) return 'zero';
  3081. if (n == 1) return 'one';
  3082. return 'other';
  3083. },
  3084. '22': function _(n) {
  3085. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  3086. return 'other';
  3087. },
  3088. '23': function _(n) {
  3089. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  3090. return 'other';
  3091. },
  3092. '24': function _(n) {
  3093. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  3094. if (isIn(n, [2, 12])) return 'two';
  3095. if (isIn(n, [1, 11])) return 'one';
  3096. return 'other';
  3097. }
  3098. };
  3099. var index = locales2rules[lang.replace(/-.*$/, '')];
  3100. if (!(index in pluralRules)) {
  3101. console.warn('plural form unknown for [' + lang + ']');
  3102. return function () {
  3103. return 'other';
  3104. };
  3105. }
  3106. return pluralRules[index];
  3107. }
  3108. gMacros.plural = function (str, param, key, prop) {
  3109. var n = parseFloat(param);
  3110. if (isNaN(n)) return str;
  3111. if (prop != gTextProp) return str;
  3112. if (!gMacros._pluralRules) {
  3113. gMacros._pluralRules = getPluralRules(gLanguage);
  3114. }
  3115. var index = '[' + gMacros._pluralRules(n) + ']';
  3116. if (n === 0 && key + '[zero]' in gL10nData) {
  3117. str = gL10nData[key + '[zero]'][prop];
  3118. } else if (n == 1 && key + '[one]' in gL10nData) {
  3119. str = gL10nData[key + '[one]'][prop];
  3120. } else if (n == 2 && key + '[two]' in gL10nData) {
  3121. str = gL10nData[key + '[two]'][prop];
  3122. } else if (key + index in gL10nData) {
  3123. str = gL10nData[key + index][prop];
  3124. } else if (key + '[other]' in gL10nData) {
  3125. str = gL10nData[key + '[other]'][prop];
  3126. }
  3127. return str;
  3128. };
  3129. function getL10nData(key, args, fallback) {
  3130. var data = gL10nData[key];
  3131. if (!data) {
  3132. console.warn('#' + key + ' is undefined.');
  3133. if (!fallback) {
  3134. return null;
  3135. }
  3136. data = fallback;
  3137. }
  3138. var rv = {};
  3139. for (var prop in data) {
  3140. var str = data[prop];
  3141. str = substIndexes(str, args, key, prop);
  3142. str = substArguments(str, args, key);
  3143. rv[prop] = str;
  3144. }
  3145. return rv;
  3146. }
  3147. function substIndexes(str, args, key, prop) {
  3148. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  3149. var reMatch = reIndex.exec(str);
  3150. if (!reMatch || !reMatch.length) return str;
  3151. var macroName = reMatch[1];
  3152. var paramName = reMatch[2];
  3153. var param;
  3154. if (args && paramName in args) {
  3155. param = args[paramName];
  3156. } else if (paramName in gL10nData) {
  3157. param = gL10nData[paramName];
  3158. }
  3159. if (macroName in gMacros) {
  3160. var macro = gMacros[macroName];
  3161. str = macro(str, param, key, prop);
  3162. }
  3163. return str;
  3164. }
  3165. function substArguments(str, args, key) {
  3166. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  3167. return str.replace(reArgs, function (matched_text, arg) {
  3168. if (args && arg in args) {
  3169. return args[arg];
  3170. }
  3171. if (arg in gL10nData) {
  3172. return gL10nData[arg];
  3173. }
  3174. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  3175. return matched_text;
  3176. });
  3177. }
  3178. function translateElement(element) {
  3179. var l10n = getL10nAttributes(element);
  3180. if (!l10n.id) return;
  3181. var data = getL10nData(l10n.id, l10n.args);
  3182. if (!data) {
  3183. console.warn('#' + l10n.id + ' is undefined.');
  3184. return;
  3185. }
  3186. if (data[gTextProp]) {
  3187. if (getChildElementCount(element) === 0) {
  3188. element[gTextProp] = data[gTextProp];
  3189. } else {
  3190. var children = element.childNodes;
  3191. var found = false;
  3192. for (var i = 0, l = children.length; i < l; i++) {
  3193. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  3194. if (found) {
  3195. children[i].nodeValue = '';
  3196. } else {
  3197. children[i].nodeValue = data[gTextProp];
  3198. found = true;
  3199. }
  3200. }
  3201. }
  3202. if (!found) {
  3203. var textNode = document.createTextNode(data[gTextProp]);
  3204. element.insertBefore(textNode, element.firstChild);
  3205. }
  3206. }
  3207. delete data[gTextProp];
  3208. }
  3209. for (var k in data) {
  3210. element[k] = data[k];
  3211. }
  3212. }
  3213. function getChildElementCount(element) {
  3214. if (element.children) {
  3215. return element.children.length;
  3216. }
  3217. if (typeof element.childElementCount !== 'undefined') {
  3218. return element.childElementCount;
  3219. }
  3220. var count = 0;
  3221. for (var i = 0; i < element.childNodes.length; i++) {
  3222. count += element.nodeType === 1 ? 1 : 0;
  3223. }
  3224. return count;
  3225. }
  3226. function translateFragment(element) {
  3227. element = element || document.documentElement;
  3228. var children = getTranslatableChildren(element);
  3229. var elementCount = children.length;
  3230. for (var i = 0; i < elementCount; i++) {
  3231. translateElement(children[i]);
  3232. }
  3233. translateElement(element);
  3234. }
  3235. return {
  3236. get: function get(key, args, fallbackString) {
  3237. var index = key.lastIndexOf('.');
  3238. var prop = gTextProp;
  3239. if (index > 0) {
  3240. prop = key.substring(index + 1);
  3241. key = key.substring(0, index);
  3242. }
  3243. var fallback;
  3244. if (fallbackString) {
  3245. fallback = {};
  3246. fallback[prop] = fallbackString;
  3247. }
  3248. var data = getL10nData(key, args, fallback);
  3249. if (data && prop in data) {
  3250. return data[prop];
  3251. }
  3252. return '{{' + key + '}}';
  3253. },
  3254. getData: function getData() {
  3255. return gL10nData;
  3256. },
  3257. getText: function getText() {
  3258. return gTextData;
  3259. },
  3260. getLanguage: function getLanguage() {
  3261. return gLanguage;
  3262. },
  3263. setLanguage: function setLanguage(lang, callback) {
  3264. loadLocale(lang, function () {
  3265. if (callback) callback();
  3266. });
  3267. },
  3268. getDirection: function getDirection() {
  3269. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  3270. var shortCode = gLanguage.split('-', 1)[0];
  3271. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  3272. },
  3273. translate: translateFragment,
  3274. getReadyState: function getReadyState() {
  3275. return gReadyState;
  3276. },
  3277. ready: function ready(callback) {
  3278. if (!callback) {
  3279. return;
  3280. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  3281. window.setTimeout(function () {
  3282. callback();
  3283. });
  3284. } else if (document.addEventListener) {
  3285. document.addEventListener('localized', function once() {
  3286. document.removeEventListener('localized', once);
  3287. callback();
  3288. });
  3289. }
  3290. }
  3291. };
  3292. }(window, document);
  3293. /***/ }),
  3294. /* 13 */
  3295. /***/ (function(module, exports, __w_pdfjs_require__) {
  3296. "use strict";
  3297. Object.defineProperty(exports, "__esModule", {
  3298. value: true
  3299. });
  3300. exports.PDFFindController = exports.FindState = void 0;
  3301. var _pdfjsLib = __w_pdfjs_require__(2);
  3302. var _pdf_find_utils = __w_pdfjs_require__(14);
  3303. var _ui_utils = __w_pdfjs_require__(3);
  3304. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3305. 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); } }
  3306. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3307. var FindState = {
  3308. FOUND: 0,
  3309. NOT_FOUND: 1,
  3310. WRAPPED: 2,
  3311. PENDING: 3
  3312. };
  3313. exports.FindState = FindState;
  3314. var FIND_TIMEOUT = 250;
  3315. var MATCH_SCROLL_OFFSET_TOP = -50;
  3316. var MATCH_SCROLL_OFFSET_LEFT = -400;
  3317. var CHARACTERS_TO_NORMALIZE = {
  3318. "\u2018": "'",
  3319. "\u2019": "'",
  3320. "\u201A": "'",
  3321. "\u201B": "'",
  3322. "\u201C": '"',
  3323. "\u201D": '"',
  3324. "\u201E": '"',
  3325. "\u201F": '"',
  3326. "\xBC": "1/4",
  3327. "\xBD": "1/2",
  3328. "\xBE": "3/4"
  3329. };
  3330. var normalizationRegex = null;
  3331. function normalize(text) {
  3332. if (!normalizationRegex) {
  3333. var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join("");
  3334. normalizationRegex = new RegExp("[".concat(replace, "]"), "g");
  3335. }
  3336. return text.replace(normalizationRegex, function (ch) {
  3337. return CHARACTERS_TO_NORMALIZE[ch];
  3338. });
  3339. }
  3340. var PDFFindController = /*#__PURE__*/function () {
  3341. function PDFFindController(_ref) {
  3342. var linkService = _ref.linkService,
  3343. eventBus = _ref.eventBus;
  3344. _classCallCheck(this, PDFFindController);
  3345. this._linkService = linkService;
  3346. this._eventBus = eventBus;
  3347. this._reset();
  3348. eventBus._on("findbarclose", this._onFindBarClose.bind(this));
  3349. }
  3350. _createClass(PDFFindController, [{
  3351. key: "setDocument",
  3352. value: function setDocument(pdfDocument) {
  3353. if (this._pdfDocument) {
  3354. this._reset();
  3355. }
  3356. if (!pdfDocument) {
  3357. return;
  3358. }
  3359. this._pdfDocument = pdfDocument;
  3360. this._firstPageCapability.resolve();
  3361. }
  3362. }, {
  3363. key: "executeCommand",
  3364. value: function executeCommand(cmd, state) {
  3365. var _this = this;
  3366. if (!state) {
  3367. return;
  3368. }
  3369. var pdfDocument = this._pdfDocument;
  3370. if (this._state === null || this._shouldDirtyMatch(cmd, state)) {
  3371. this._dirtyMatch = true;
  3372. }
  3373. this._state = state;
  3374. if (cmd !== "findhighlightallchange") {
  3375. this._updateUIState(FindState.PENDING);
  3376. }
  3377. this._firstPageCapability.promise.then(function () {
  3378. if (!_this._pdfDocument || pdfDocument && _this._pdfDocument !== pdfDocument) {
  3379. return;
  3380. }
  3381. _this._extractText();
  3382. var findbarClosed = !_this._highlightMatches;
  3383. var pendingTimeout = !!_this._findTimeout;
  3384. if (_this._findTimeout) {
  3385. clearTimeout(_this._findTimeout);
  3386. _this._findTimeout = null;
  3387. }
  3388. if (cmd === "find") {
  3389. _this._findTimeout = setTimeout(function () {
  3390. _this._nextMatch();
  3391. _this._findTimeout = null;
  3392. }, FIND_TIMEOUT);
  3393. } else if (_this._dirtyMatch) {
  3394. _this._nextMatch();
  3395. } else if (cmd === "findagain") {
  3396. _this._nextMatch();
  3397. if (findbarClosed && _this._state.highlightAll) {
  3398. _this._updateAllPages();
  3399. }
  3400. } else if (cmd === "findhighlightallchange") {
  3401. if (pendingTimeout) {
  3402. _this._nextMatch();
  3403. } else {
  3404. _this._highlightMatches = true;
  3405. }
  3406. _this._updateAllPages();
  3407. } else {
  3408. _this._nextMatch();
  3409. }
  3410. });
  3411. }
  3412. }, {
  3413. key: "scrollMatchIntoView",
  3414. value: function scrollMatchIntoView(_ref2) {
  3415. var _ref2$element = _ref2.element,
  3416. element = _ref2$element === void 0 ? null : _ref2$element,
  3417. _ref2$pageIndex = _ref2.pageIndex,
  3418. pageIndex = _ref2$pageIndex === void 0 ? -1 : _ref2$pageIndex,
  3419. _ref2$matchIndex = _ref2.matchIndex,
  3420. matchIndex = _ref2$matchIndex === void 0 ? -1 : _ref2$matchIndex;
  3421. if (!this._scrollMatches || !element) {
  3422. return;
  3423. } else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) {
  3424. return;
  3425. } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) {
  3426. return;
  3427. }
  3428. this._scrollMatches = false;
  3429. var spot = {
  3430. top: MATCH_SCROLL_OFFSET_TOP,
  3431. left: MATCH_SCROLL_OFFSET_LEFT
  3432. };
  3433. (0, _ui_utils.scrollIntoView)(element, spot, true);
  3434. }
  3435. }, {
  3436. key: "_reset",
  3437. value: function _reset() {
  3438. this._highlightMatches = false;
  3439. this._scrollMatches = false;
  3440. this._pdfDocument = null;
  3441. this._pageMatches = [];
  3442. this._pageMatchesLength = [];
  3443. this._state = null;
  3444. this._selected = {
  3445. pageIdx: -1,
  3446. matchIdx: -1
  3447. };
  3448. this._offset = {
  3449. pageIdx: null,
  3450. matchIdx: null,
  3451. wrapped: false
  3452. };
  3453. this._extractTextPromises = [];
  3454. this._pageContents = [];
  3455. this._matchesCountTotal = 0;
  3456. this._pagesToSearch = null;
  3457. this._pendingFindMatches = Object.create(null);
  3458. this._resumePageIdx = null;
  3459. this._dirtyMatch = false;
  3460. clearTimeout(this._findTimeout);
  3461. this._findTimeout = null;
  3462. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  3463. }
  3464. }, {
  3465. key: "_shouldDirtyMatch",
  3466. value: function _shouldDirtyMatch(cmd, state) {
  3467. if (state.query !== this._state.query) {
  3468. return true;
  3469. }
  3470. switch (cmd) {
  3471. case "findagain":
  3472. var pageNumber = this._selected.pageIdx + 1;
  3473. var linkService = this._linkService;
  3474. if (pageNumber >= 1 && pageNumber <= linkService.pagesCount && pageNumber !== linkService.page && !linkService.isPageVisible(pageNumber)) {
  3475. return true;
  3476. }
  3477. return false;
  3478. case "findhighlightallchange":
  3479. return false;
  3480. }
  3481. return true;
  3482. }
  3483. }, {
  3484. key: "_prepareMatches",
  3485. value: function _prepareMatches(matchesWithLength, matches, matchesLength) {
  3486. function isSubTerm(currentIndex) {
  3487. var currentElem = matchesWithLength[currentIndex];
  3488. var nextElem = matchesWithLength[currentIndex + 1];
  3489. if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {
  3490. currentElem.skipped = true;
  3491. return true;
  3492. }
  3493. for (var i = currentIndex - 1; i >= 0; i--) {
  3494. var prevElem = matchesWithLength[i];
  3495. if (prevElem.skipped) {
  3496. continue;
  3497. }
  3498. if (prevElem.match + prevElem.matchLength < currentElem.match) {
  3499. break;
  3500. }
  3501. if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {
  3502. currentElem.skipped = true;
  3503. return true;
  3504. }
  3505. }
  3506. return false;
  3507. }
  3508. matchesWithLength.sort(function (a, b) {
  3509. return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match;
  3510. });
  3511. for (var i = 0, len = matchesWithLength.length; i < len; i++) {
  3512. if (isSubTerm(i)) {
  3513. continue;
  3514. }
  3515. matches.push(matchesWithLength[i].match);
  3516. matchesLength.push(matchesWithLength[i].matchLength);
  3517. }
  3518. }
  3519. }, {
  3520. key: "_isEntireWord",
  3521. value: function _isEntireWord(content, startIdx, length) {
  3522. if (startIdx > 0) {
  3523. var first = content.charCodeAt(startIdx);
  3524. var limit = content.charCodeAt(startIdx - 1);
  3525. if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils.getCharacterType)(limit)) {
  3526. return false;
  3527. }
  3528. }
  3529. var endIdx = startIdx + length - 1;
  3530. if (endIdx < content.length - 1) {
  3531. var last = content.charCodeAt(endIdx);
  3532. var _limit = content.charCodeAt(endIdx + 1);
  3533. if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils.getCharacterType)(_limit)) {
  3534. return false;
  3535. }
  3536. }
  3537. return true;
  3538. }
  3539. }, {
  3540. key: "_calculatePhraseMatch",
  3541. value: function _calculatePhraseMatch(query, pageIndex, pageContent, entireWord) {
  3542. var matches = [];
  3543. var queryLen = query.length;
  3544. var matchIdx = -queryLen;
  3545. while (true) {
  3546. matchIdx = pageContent.indexOf(query, matchIdx + queryLen);
  3547. if (matchIdx === -1) {
  3548. break;
  3549. }
  3550. if (entireWord && !this._isEntireWord(pageContent, matchIdx, queryLen)) {
  3551. continue;
  3552. }
  3553. matches.push(matchIdx);
  3554. }
  3555. this._pageMatches[pageIndex] = matches;
  3556. }
  3557. }, {
  3558. key: "_calculateWordMatch",
  3559. value: function _calculateWordMatch(query, pageIndex, pageContent, entireWord) {
  3560. var matchesWithLength = [];
  3561. var queryArray = query.match(/\S+/g);
  3562. for (var i = 0, len = queryArray.length; i < len; i++) {
  3563. var subquery = queryArray[i];
  3564. var subqueryLen = subquery.length;
  3565. var matchIdx = -subqueryLen;
  3566. while (true) {
  3567. matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen);
  3568. if (matchIdx === -1) {
  3569. break;
  3570. }
  3571. if (entireWord && !this._isEntireWord(pageContent, matchIdx, subqueryLen)) {
  3572. continue;
  3573. }
  3574. matchesWithLength.push({
  3575. match: matchIdx,
  3576. matchLength: subqueryLen,
  3577. skipped: false
  3578. });
  3579. }
  3580. }
  3581. this._pageMatchesLength[pageIndex] = [];
  3582. this._pageMatches[pageIndex] = [];
  3583. this._prepareMatches(matchesWithLength, this._pageMatches[pageIndex], this._pageMatchesLength[pageIndex]);
  3584. }
  3585. }, {
  3586. key: "_calculateMatch",
  3587. value: function _calculateMatch(pageIndex) {
  3588. var pageContent = this._pageContents[pageIndex];
  3589. var query = this._query;
  3590. var _this$_state = this._state,
  3591. caseSensitive = _this$_state.caseSensitive,
  3592. entireWord = _this$_state.entireWord,
  3593. phraseSearch = _this$_state.phraseSearch;
  3594. if (query.length === 0) {
  3595. return;
  3596. }
  3597. if (!caseSensitive) {
  3598. pageContent = pageContent.toLowerCase();
  3599. query = query.toLowerCase();
  3600. }
  3601. if (phraseSearch) {
  3602. this._calculatePhraseMatch(query, pageIndex, pageContent, entireWord);
  3603. } else {
  3604. this._calculateWordMatch(query, pageIndex, pageContent, entireWord);
  3605. }
  3606. if (this._state.highlightAll) {
  3607. this._updatePage(pageIndex);
  3608. }
  3609. if (this._resumePageIdx === pageIndex) {
  3610. this._resumePageIdx = null;
  3611. this._nextPageMatch();
  3612. }
  3613. var pageMatchesCount = this._pageMatches[pageIndex].length;
  3614. if (pageMatchesCount > 0) {
  3615. this._matchesCountTotal += pageMatchesCount;
  3616. this._updateUIResultsCount();
  3617. }
  3618. }
  3619. }, {
  3620. key: "_extractText",
  3621. value: function _extractText() {
  3622. var _this2 = this;
  3623. if (this._extractTextPromises.length > 0) {
  3624. return;
  3625. }
  3626. var promise = Promise.resolve();
  3627. var _loop = function _loop(i, ii) {
  3628. var extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
  3629. _this2._extractTextPromises[i] = extractTextCapability.promise;
  3630. promise = promise.then(function () {
  3631. return _this2._pdfDocument.getPage(i + 1).then(function (pdfPage) {
  3632. return pdfPage.getTextContent({
  3633. normalizeWhitespace: true
  3634. });
  3635. }).then(function (textContent) {
  3636. var textItems = textContent.items;
  3637. var strBuf = [];
  3638. for (var j = 0, jj = textItems.length; j < jj; j++) {
  3639. strBuf.push(textItems[j].str);
  3640. }
  3641. _this2._pageContents[i] = normalize(strBuf.join(""));
  3642. extractTextCapability.resolve(i);
  3643. }, function (reason) {
  3644. console.error("Unable to get text content for page ".concat(i + 1), reason);
  3645. _this2._pageContents[i] = "";
  3646. extractTextCapability.resolve(i);
  3647. });
  3648. });
  3649. };
  3650. for (var i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
  3651. _loop(i, ii);
  3652. }
  3653. }
  3654. }, {
  3655. key: "_updatePage",
  3656. value: function _updatePage(index) {
  3657. if (this._scrollMatches && this._selected.pageIdx === index) {
  3658. this._linkService.page = index + 1;
  3659. }
  3660. this._eventBus.dispatch("updatetextlayermatches", {
  3661. source: this,
  3662. pageIndex: index
  3663. });
  3664. }
  3665. }, {
  3666. key: "_updateAllPages",
  3667. value: function _updateAllPages() {
  3668. this._eventBus.dispatch("updatetextlayermatches", {
  3669. source: this,
  3670. pageIndex: -1
  3671. });
  3672. }
  3673. }, {
  3674. key: "_nextMatch",
  3675. value: function _nextMatch() {
  3676. var _this3 = this;
  3677. var previous = this._state.findPrevious;
  3678. var currentPageIndex = this._linkService.page - 1;
  3679. var numPages = this._linkService.pagesCount;
  3680. this._highlightMatches = true;
  3681. if (this._dirtyMatch) {
  3682. this._dirtyMatch = false;
  3683. this._selected.pageIdx = this._selected.matchIdx = -1;
  3684. this._offset.pageIdx = currentPageIndex;
  3685. this._offset.matchIdx = null;
  3686. this._offset.wrapped = false;
  3687. this._resumePageIdx = null;
  3688. this._pageMatches.length = 0;
  3689. this._pageMatchesLength.length = 0;
  3690. this._matchesCountTotal = 0;
  3691. this._updateAllPages();
  3692. for (var i = 0; i < numPages; i++) {
  3693. if (this._pendingFindMatches[i] === true) {
  3694. continue;
  3695. }
  3696. this._pendingFindMatches[i] = true;
  3697. this._extractTextPromises[i].then(function (pageIdx) {
  3698. delete _this3._pendingFindMatches[pageIdx];
  3699. _this3._calculateMatch(pageIdx);
  3700. });
  3701. }
  3702. }
  3703. if (this._query === "") {
  3704. this._updateUIState(FindState.FOUND);
  3705. return;
  3706. }
  3707. if (this._resumePageIdx) {
  3708. return;
  3709. }
  3710. var offset = this._offset;
  3711. this._pagesToSearch = numPages;
  3712. if (offset.matchIdx !== null) {
  3713. var numPageMatches = this._pageMatches[offset.pageIdx].length;
  3714. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  3715. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  3716. this._updateMatch(true);
  3717. return;
  3718. }
  3719. this._advanceOffsetPage(previous);
  3720. }
  3721. this._nextPageMatch();
  3722. }
  3723. }, {
  3724. key: "_matchesReady",
  3725. value: function _matchesReady(matches) {
  3726. var offset = this._offset;
  3727. var numMatches = matches.length;
  3728. var previous = this._state.findPrevious;
  3729. if (numMatches) {
  3730. offset.matchIdx = previous ? numMatches - 1 : 0;
  3731. this._updateMatch(true);
  3732. return true;
  3733. }
  3734. this._advanceOffsetPage(previous);
  3735. if (offset.wrapped) {
  3736. offset.matchIdx = null;
  3737. if (this._pagesToSearch < 0) {
  3738. this._updateMatch(false);
  3739. return true;
  3740. }
  3741. }
  3742. return false;
  3743. }
  3744. }, {
  3745. key: "_nextPageMatch",
  3746. value: function _nextPageMatch() {
  3747. if (this._resumePageIdx !== null) {
  3748. console.error("There can only be one pending page.");
  3749. }
  3750. var matches = null;
  3751. do {
  3752. var pageIdx = this._offset.pageIdx;
  3753. matches = this._pageMatches[pageIdx];
  3754. if (!matches) {
  3755. this._resumePageIdx = pageIdx;
  3756. break;
  3757. }
  3758. } while (!this._matchesReady(matches));
  3759. }
  3760. }, {
  3761. key: "_advanceOffsetPage",
  3762. value: function _advanceOffsetPage(previous) {
  3763. var offset = this._offset;
  3764. var numPages = this._linkService.pagesCount;
  3765. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  3766. offset.matchIdx = null;
  3767. this._pagesToSearch--;
  3768. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  3769. offset.pageIdx = previous ? numPages - 1 : 0;
  3770. offset.wrapped = true;
  3771. }
  3772. }
  3773. }, {
  3774. key: "_updateMatch",
  3775. value: function _updateMatch() {
  3776. var found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  3777. var state = FindState.NOT_FOUND;
  3778. var wrapped = this._offset.wrapped;
  3779. this._offset.wrapped = false;
  3780. if (found) {
  3781. var previousPage = this._selected.pageIdx;
  3782. this._selected.pageIdx = this._offset.pageIdx;
  3783. this._selected.matchIdx = this._offset.matchIdx;
  3784. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  3785. if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {
  3786. this._updatePage(previousPage);
  3787. }
  3788. }
  3789. this._updateUIState(state, this._state.findPrevious);
  3790. if (this._selected.pageIdx !== -1) {
  3791. this._scrollMatches = true;
  3792. this._updatePage(this._selected.pageIdx);
  3793. }
  3794. }
  3795. }, {
  3796. key: "_onFindBarClose",
  3797. value: function _onFindBarClose(evt) {
  3798. var _this4 = this;
  3799. var pdfDocument = this._pdfDocument;
  3800. this._firstPageCapability.promise.then(function () {
  3801. if (!_this4._pdfDocument || pdfDocument && _this4._pdfDocument !== pdfDocument) {
  3802. return;
  3803. }
  3804. if (_this4._findTimeout) {
  3805. clearTimeout(_this4._findTimeout);
  3806. _this4._findTimeout = null;
  3807. }
  3808. if (_this4._resumePageIdx) {
  3809. _this4._resumePageIdx = null;
  3810. _this4._dirtyMatch = true;
  3811. }
  3812. _this4._updateUIState(FindState.FOUND);
  3813. _this4._highlightMatches = false;
  3814. _this4._updateAllPages();
  3815. });
  3816. }
  3817. }, {
  3818. key: "_requestMatchesCount",
  3819. value: function _requestMatchesCount() {
  3820. var _this$_selected = this._selected,
  3821. pageIdx = _this$_selected.pageIdx,
  3822. matchIdx = _this$_selected.matchIdx;
  3823. var current = 0,
  3824. total = this._matchesCountTotal;
  3825. if (matchIdx !== -1) {
  3826. for (var i = 0; i < pageIdx; i++) {
  3827. current += this._pageMatches[i] && this._pageMatches[i].length || 0;
  3828. }
  3829. current += matchIdx + 1;
  3830. }
  3831. if (current < 1 || current > total) {
  3832. current = total = 0;
  3833. }
  3834. return {
  3835. current: current,
  3836. total: total
  3837. };
  3838. }
  3839. }, {
  3840. key: "_updateUIResultsCount",
  3841. value: function _updateUIResultsCount() {
  3842. this._eventBus.dispatch("updatefindmatchescount", {
  3843. source: this,
  3844. matchesCount: this._requestMatchesCount()
  3845. });
  3846. }
  3847. }, {
  3848. key: "_updateUIState",
  3849. value: function _updateUIState(state, previous) {
  3850. this._eventBus.dispatch("updatefindcontrolstate", {
  3851. source: this,
  3852. state: state,
  3853. previous: previous,
  3854. matchesCount: this._requestMatchesCount(),
  3855. rawQuery: this._state ? this._state.query : null
  3856. });
  3857. }
  3858. }, {
  3859. key: "highlightMatches",
  3860. get: function get() {
  3861. return this._highlightMatches;
  3862. }
  3863. }, {
  3864. key: "pageMatches",
  3865. get: function get() {
  3866. return this._pageMatches;
  3867. }
  3868. }, {
  3869. key: "pageMatchesLength",
  3870. get: function get() {
  3871. return this._pageMatchesLength;
  3872. }
  3873. }, {
  3874. key: "selected",
  3875. get: function get() {
  3876. return this._selected;
  3877. }
  3878. }, {
  3879. key: "state",
  3880. get: function get() {
  3881. return this._state;
  3882. }
  3883. }, {
  3884. key: "_query",
  3885. get: function get() {
  3886. if (this._state.query !== this._rawQuery) {
  3887. this._rawQuery = this._state.query;
  3888. this._normalizedQuery = normalize(this._state.query);
  3889. }
  3890. return this._normalizedQuery;
  3891. }
  3892. }]);
  3893. return PDFFindController;
  3894. }();
  3895. exports.PDFFindController = PDFFindController;
  3896. /***/ }),
  3897. /* 14 */
  3898. /***/ (function(module, exports, __w_pdfjs_require__) {
  3899. "use strict";
  3900. Object.defineProperty(exports, "__esModule", {
  3901. value: true
  3902. });
  3903. exports.getCharacterType = getCharacterType;
  3904. exports.CharacterType = void 0;
  3905. var CharacterType = {
  3906. SPACE: 0,
  3907. ALPHA_LETTER: 1,
  3908. PUNCT: 2,
  3909. HAN_LETTER: 3,
  3910. KATAKANA_LETTER: 4,
  3911. HIRAGANA_LETTER: 5,
  3912. HALFWIDTH_KATAKANA_LETTER: 6,
  3913. THAI_LETTER: 7
  3914. };
  3915. exports.CharacterType = CharacterType;
  3916. function isAlphabeticalScript(charCode) {
  3917. return charCode < 0x2e80;
  3918. }
  3919. function isAscii(charCode) {
  3920. return (charCode & 0xff80) === 0;
  3921. }
  3922. function isAsciiAlpha(charCode) {
  3923. return charCode >= 0x61 && charCode <= 0x7a || charCode >= 0x41 && charCode <= 0x5a;
  3924. }
  3925. function isAsciiDigit(charCode) {
  3926. return charCode >= 0x30 && charCode <= 0x39;
  3927. }
  3928. function isAsciiSpace(charCode) {
  3929. return charCode === 0x20 || charCode === 0x09 || charCode === 0x0d || charCode === 0x0a;
  3930. }
  3931. function isHan(charCode) {
  3932. return charCode >= 0x3400 && charCode <= 0x9fff || charCode >= 0xf900 && charCode <= 0xfaff;
  3933. }
  3934. function isKatakana(charCode) {
  3935. return charCode >= 0x30a0 && charCode <= 0x30ff;
  3936. }
  3937. function isHiragana(charCode) {
  3938. return charCode >= 0x3040 && charCode <= 0x309f;
  3939. }
  3940. function isHalfwidthKatakana(charCode) {
  3941. return charCode >= 0xff60 && charCode <= 0xff9f;
  3942. }
  3943. function isThai(charCode) {
  3944. return (charCode & 0xff80) === 0x0e00;
  3945. }
  3946. function getCharacterType(charCode) {
  3947. if (isAlphabeticalScript(charCode)) {
  3948. if (isAscii(charCode)) {
  3949. if (isAsciiSpace(charCode)) {
  3950. return CharacterType.SPACE;
  3951. } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5f) {
  3952. return CharacterType.ALPHA_LETTER;
  3953. }
  3954. return CharacterType.PUNCT;
  3955. } else if (isThai(charCode)) {
  3956. return CharacterType.THAI_LETTER;
  3957. } else if (charCode === 0xa0) {
  3958. return CharacterType.SPACE;
  3959. }
  3960. return CharacterType.ALPHA_LETTER;
  3961. }
  3962. if (isHan(charCode)) {
  3963. return CharacterType.HAN_LETTER;
  3964. } else if (isKatakana(charCode)) {
  3965. return CharacterType.KATAKANA_LETTER;
  3966. } else if (isHiragana(charCode)) {
  3967. return CharacterType.HIRAGANA_LETTER;
  3968. } else if (isHalfwidthKatakana(charCode)) {
  3969. return CharacterType.HALFWIDTH_KATAKANA_LETTER;
  3970. }
  3971. return CharacterType.ALPHA_LETTER;
  3972. }
  3973. /***/ }),
  3974. /* 15 */
  3975. /***/ (function(module, exports, __w_pdfjs_require__) {
  3976. "use strict";
  3977. Object.defineProperty(exports, "__esModule", {
  3978. value: true
  3979. });
  3980. exports.isDestHashesEqual = isDestHashesEqual;
  3981. exports.isDestArraysEqual = isDestArraysEqual;
  3982. exports.PDFHistory = void 0;
  3983. var _ui_utils = __w_pdfjs_require__(3);
  3984. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  3985. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  3986. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  3987. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  3988. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  3989. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  3990. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  3991. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3992. 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); } }
  3993. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3994. var HASH_CHANGE_TIMEOUT = 1000;
  3995. var POSITION_UPDATED_THRESHOLD = 50;
  3996. var UPDATE_VIEWAREA_TIMEOUT = 1000;
  3997. function getCurrentHash() {
  3998. return document.location.hash;
  3999. }
  4000. var PDFHistory = /*#__PURE__*/function () {
  4001. function PDFHistory(_ref) {
  4002. var _this = this;
  4003. var linkService = _ref.linkService,
  4004. eventBus = _ref.eventBus;
  4005. _classCallCheck(this, PDFHistory);
  4006. this.linkService = linkService;
  4007. this.eventBus = eventBus;
  4008. this._initialized = false;
  4009. this._fingerprint = "";
  4010. this.reset();
  4011. this._boundEvents = null;
  4012. this._isViewerInPresentationMode = false;
  4013. this.eventBus._on("presentationmodechanged", function (evt) {
  4014. _this._isViewerInPresentationMode = evt.active || evt.switchInProgress;
  4015. });
  4016. this.eventBus._on("pagesinit", function () {
  4017. _this._isPagesLoaded = false;
  4018. var onPagesLoaded = function onPagesLoaded(evt) {
  4019. _this.eventBus._off("pagesloaded", onPagesLoaded);
  4020. _this._isPagesLoaded = !!evt.pagesCount;
  4021. };
  4022. _this.eventBus._on("pagesloaded", onPagesLoaded);
  4023. });
  4024. }
  4025. _createClass(PDFHistory, [{
  4026. key: "initialize",
  4027. value: function initialize(_ref2) {
  4028. var fingerprint = _ref2.fingerprint,
  4029. _ref2$resetHistory = _ref2.resetHistory,
  4030. resetHistory = _ref2$resetHistory === void 0 ? false : _ref2$resetHistory,
  4031. _ref2$updateUrl = _ref2.updateUrl,
  4032. updateUrl = _ref2$updateUrl === void 0 ? false : _ref2$updateUrl;
  4033. if (!fingerprint || typeof fingerprint !== "string") {
  4034. console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
  4035. return;
  4036. }
  4037. if (this._initialized) {
  4038. this.reset();
  4039. }
  4040. var reInitialized = this._fingerprint !== "" && this._fingerprint !== fingerprint;
  4041. this._fingerprint = fingerprint;
  4042. this._updateUrl = updateUrl === true;
  4043. this._initialized = true;
  4044. this._bindEvents();
  4045. var state = window.history.state;
  4046. this._popStateInProgress = false;
  4047. this._blockHashChange = 0;
  4048. this._currentHash = getCurrentHash();
  4049. this._numPositionUpdates = 0;
  4050. this._uid = this._maxUid = 0;
  4051. this._destination = null;
  4052. this._position = null;
  4053. if (!this._isValidState(state, true) || resetHistory) {
  4054. var _this$_parseCurrentHa = this._parseCurrentHash(true),
  4055. hash = _this$_parseCurrentHa.hash,
  4056. page = _this$_parseCurrentHa.page,
  4057. rotation = _this$_parseCurrentHa.rotation;
  4058. if (!hash || reInitialized || resetHistory) {
  4059. this._pushOrReplaceState(null, true);
  4060. return;
  4061. }
  4062. this._pushOrReplaceState({
  4063. hash: hash,
  4064. page: page,
  4065. rotation: rotation
  4066. }, true);
  4067. return;
  4068. }
  4069. var destination = state.destination;
  4070. this._updateInternalState(destination, state.uid, true);
  4071. if (this._uid > this._maxUid) {
  4072. this._maxUid = this._uid;
  4073. }
  4074. if (destination.rotation !== undefined) {
  4075. this._initialRotation = destination.rotation;
  4076. }
  4077. if (destination.dest) {
  4078. this._initialBookmark = JSON.stringify(destination.dest);
  4079. this._destination.page = null;
  4080. } else if (destination.hash) {
  4081. this._initialBookmark = destination.hash;
  4082. } else if (destination.page) {
  4083. this._initialBookmark = "page=".concat(destination.page);
  4084. }
  4085. }
  4086. }, {
  4087. key: "reset",
  4088. value: function reset() {
  4089. if (this._initialized) {
  4090. this._pageHide();
  4091. this._initialized = false;
  4092. this._unbindEvents();
  4093. }
  4094. if (this._updateViewareaTimeout) {
  4095. clearTimeout(this._updateViewareaTimeout);
  4096. this._updateViewareaTimeout = null;
  4097. }
  4098. this._initialBookmark = null;
  4099. this._initialRotation = null;
  4100. }
  4101. }, {
  4102. key: "push",
  4103. value: function push(_ref3) {
  4104. var _this2 = this;
  4105. var _ref3$namedDest = _ref3.namedDest,
  4106. namedDest = _ref3$namedDest === void 0 ? null : _ref3$namedDest,
  4107. explicitDest = _ref3.explicitDest,
  4108. pageNumber = _ref3.pageNumber;
  4109. if (!this._initialized) {
  4110. return;
  4111. }
  4112. if (namedDest && typeof namedDest !== "string") {
  4113. console.error("PDFHistory.push: " + "\"".concat(namedDest, "\" is not a valid namedDest parameter."));
  4114. return;
  4115. } else if (!Array.isArray(explicitDest)) {
  4116. console.error("PDFHistory.push: " + "\"".concat(explicitDest, "\" is not a valid explicitDest parameter."));
  4117. return;
  4118. } else if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {
  4119. if (pageNumber !== null || this._destination) {
  4120. console.error("PDFHistory.push: " + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  4121. return;
  4122. }
  4123. }
  4124. var hash = namedDest || JSON.stringify(explicitDest);
  4125. if (!hash) {
  4126. return;
  4127. }
  4128. var forceReplace = false;
  4129. if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
  4130. if (this._destination.page) {
  4131. return;
  4132. }
  4133. forceReplace = true;
  4134. }
  4135. if (this._popStateInProgress && !forceReplace) {
  4136. return;
  4137. }
  4138. this._pushOrReplaceState({
  4139. dest: explicitDest,
  4140. hash: hash,
  4141. page: pageNumber,
  4142. rotation: this.linkService.rotation
  4143. }, forceReplace);
  4144. if (!this._popStateInProgress) {
  4145. this._popStateInProgress = true;
  4146. Promise.resolve().then(function () {
  4147. _this2._popStateInProgress = false;
  4148. });
  4149. }
  4150. }
  4151. }, {
  4152. key: "pushCurrentPosition",
  4153. value: function pushCurrentPosition() {
  4154. if (!this._initialized || this._popStateInProgress) {
  4155. return;
  4156. }
  4157. this._tryPushCurrentPosition();
  4158. }
  4159. }, {
  4160. key: "back",
  4161. value: function back() {
  4162. if (!this._initialized || this._popStateInProgress) {
  4163. return;
  4164. }
  4165. var state = window.history.state;
  4166. if (this._isValidState(state) && state.uid > 0) {
  4167. window.history.back();
  4168. }
  4169. }
  4170. }, {
  4171. key: "forward",
  4172. value: function forward() {
  4173. if (!this._initialized || this._popStateInProgress) {
  4174. return;
  4175. }
  4176. var state = window.history.state;
  4177. if (this._isValidState(state) && state.uid < this._maxUid) {
  4178. window.history.forward();
  4179. }
  4180. }
  4181. }, {
  4182. key: "_pushOrReplaceState",
  4183. value: function _pushOrReplaceState(destination) {
  4184. var forceReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4185. var shouldReplace = forceReplace || !this._destination;
  4186. var newState = {
  4187. fingerprint: this._fingerprint,
  4188. uid: shouldReplace ? this._uid : this._uid + 1,
  4189. destination: destination
  4190. };
  4191. this._updateInternalState(destination, newState.uid);
  4192. var newUrl;
  4193. if (this._updateUrl && destination && destination.hash) {
  4194. var baseUrl = document.location.href.split("#")[0];
  4195. if (!baseUrl.startsWith("file://")) {
  4196. newUrl = "".concat(baseUrl, "#").concat(destination.hash);
  4197. }
  4198. }
  4199. if (shouldReplace) {
  4200. window.history.replaceState(newState, "", newUrl);
  4201. } else {
  4202. this._maxUid = this._uid;
  4203. window.history.pushState(newState, "", newUrl);
  4204. }
  4205. }
  4206. }, {
  4207. key: "_tryPushCurrentPosition",
  4208. value: function _tryPushCurrentPosition() {
  4209. var temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4210. if (!this._position) {
  4211. return;
  4212. }
  4213. var position = this._position;
  4214. if (temporary) {
  4215. position = Object.assign(Object.create(null), this._position);
  4216. position.temporary = true;
  4217. }
  4218. if (!this._destination) {
  4219. this._pushOrReplaceState(position);
  4220. return;
  4221. }
  4222. if (this._destination.temporary) {
  4223. this._pushOrReplaceState(position, true);
  4224. return;
  4225. }
  4226. if (this._destination.hash === position.hash) {
  4227. return;
  4228. }
  4229. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  4230. return;
  4231. }
  4232. var forceReplace = false;
  4233. if (this._destination.page >= position.first && this._destination.page <= position.page) {
  4234. if (this._destination.dest || !this._destination.first) {
  4235. return;
  4236. }
  4237. forceReplace = true;
  4238. }
  4239. this._pushOrReplaceState(position, forceReplace);
  4240. }
  4241. }, {
  4242. key: "_isValidState",
  4243. value: function _isValidState(state) {
  4244. var checkReload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4245. if (!state) {
  4246. return false;
  4247. }
  4248. if (state.fingerprint !== this._fingerprint) {
  4249. if (checkReload) {
  4250. if (typeof state.fingerprint !== "string" || state.fingerprint.length !== this._fingerprint.length) {
  4251. return false;
  4252. }
  4253. var _performance$getEntri = performance.getEntriesByType("navigation"),
  4254. _performance$getEntri2 = _slicedToArray(_performance$getEntri, 1),
  4255. perfEntry = _performance$getEntri2[0];
  4256. if (!perfEntry || perfEntry.type !== "reload") {
  4257. return false;
  4258. }
  4259. } else {
  4260. return false;
  4261. }
  4262. }
  4263. if (!Number.isInteger(state.uid) || state.uid < 0) {
  4264. return false;
  4265. }
  4266. if (state.destination === null || _typeof(state.destination) !== "object") {
  4267. return false;
  4268. }
  4269. return true;
  4270. }
  4271. }, {
  4272. key: "_updateInternalState",
  4273. value: function _updateInternalState(destination, uid) {
  4274. var removeTemporary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  4275. if (this._updateViewareaTimeout) {
  4276. clearTimeout(this._updateViewareaTimeout);
  4277. this._updateViewareaTimeout = null;
  4278. }
  4279. if (removeTemporary && destination && destination.temporary) {
  4280. delete destination.temporary;
  4281. }
  4282. this._destination = destination;
  4283. this._uid = uid;
  4284. this._numPositionUpdates = 0;
  4285. }
  4286. }, {
  4287. key: "_parseCurrentHash",
  4288. value: function _parseCurrentHash() {
  4289. var checkNameddest = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4290. var hash = unescape(getCurrentHash()).substring(1);
  4291. var params = (0, _ui_utils.parseQueryString)(hash);
  4292. var nameddest = params.nameddest || "";
  4293. var page = params.page | 0;
  4294. if (!(Number.isInteger(page) && page > 0 && page <= this.linkService.pagesCount) || checkNameddest && nameddest.length > 0) {
  4295. page = null;
  4296. }
  4297. return {
  4298. hash: hash,
  4299. page: page,
  4300. rotation: this.linkService.rotation
  4301. };
  4302. }
  4303. }, {
  4304. key: "_updateViewarea",
  4305. value: function _updateViewarea(_ref4) {
  4306. var _this3 = this;
  4307. var location = _ref4.location;
  4308. if (this._updateViewareaTimeout) {
  4309. clearTimeout(this._updateViewareaTimeout);
  4310. this._updateViewareaTimeout = null;
  4311. }
  4312. this._position = {
  4313. hash: this._isViewerInPresentationMode ? "page=".concat(location.pageNumber) : location.pdfOpenParams.substring(1),
  4314. page: this.linkService.page,
  4315. first: location.pageNumber,
  4316. rotation: location.rotation
  4317. };
  4318. if (this._popStateInProgress) {
  4319. return;
  4320. }
  4321. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
  4322. this._numPositionUpdates++;
  4323. }
  4324. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  4325. this._updateViewareaTimeout = setTimeout(function () {
  4326. if (!_this3._popStateInProgress) {
  4327. _this3._tryPushCurrentPosition(true);
  4328. }
  4329. _this3._updateViewareaTimeout = null;
  4330. }, UPDATE_VIEWAREA_TIMEOUT);
  4331. }
  4332. }
  4333. }, {
  4334. key: "_popState",
  4335. value: function _popState(_ref5) {
  4336. var _this4 = this;
  4337. var state = _ref5.state;
  4338. var newHash = getCurrentHash(),
  4339. hashChanged = this._currentHash !== newHash;
  4340. this._currentHash = newHash;
  4341. if (!state) {
  4342. this._uid++;
  4343. var _this$_parseCurrentHa2 = this._parseCurrentHash(),
  4344. hash = _this$_parseCurrentHa2.hash,
  4345. page = _this$_parseCurrentHa2.page,
  4346. rotation = _this$_parseCurrentHa2.rotation;
  4347. this._pushOrReplaceState({
  4348. hash: hash,
  4349. page: page,
  4350. rotation: rotation
  4351. }, true);
  4352. return;
  4353. }
  4354. if (!this._isValidState(state)) {
  4355. return;
  4356. }
  4357. this._popStateInProgress = true;
  4358. if (hashChanged) {
  4359. this._blockHashChange++;
  4360. (0, _ui_utils.waitOnEventOrTimeout)({
  4361. target: window,
  4362. name: "hashchange",
  4363. delay: HASH_CHANGE_TIMEOUT
  4364. }).then(function () {
  4365. _this4._blockHashChange--;
  4366. });
  4367. }
  4368. var destination = state.destination;
  4369. this._updateInternalState(destination, state.uid, true);
  4370. if (this._uid > this._maxUid) {
  4371. this._maxUid = this._uid;
  4372. }
  4373. if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
  4374. this.linkService.rotation = destination.rotation;
  4375. }
  4376. if (destination.dest) {
  4377. this.linkService.navigateTo(destination.dest);
  4378. } else if (destination.hash) {
  4379. this.linkService.setHash(destination.hash);
  4380. } else if (destination.page) {
  4381. this.linkService.page = destination.page;
  4382. }
  4383. Promise.resolve().then(function () {
  4384. _this4._popStateInProgress = false;
  4385. });
  4386. }
  4387. }, {
  4388. key: "_pageHide",
  4389. value: function _pageHide() {
  4390. if (!this._destination || this._destination.temporary) {
  4391. this._tryPushCurrentPosition();
  4392. }
  4393. }
  4394. }, {
  4395. key: "_bindEvents",
  4396. value: function _bindEvents() {
  4397. if (this._boundEvents) {
  4398. return;
  4399. }
  4400. this._boundEvents = {
  4401. updateViewarea: this._updateViewarea.bind(this),
  4402. popState: this._popState.bind(this),
  4403. pageHide: this._pageHide.bind(this)
  4404. };
  4405. this.eventBus._on("updateviewarea", this._boundEvents.updateViewarea);
  4406. window.addEventListener("popstate", this._boundEvents.popState);
  4407. window.addEventListener("pagehide", this._boundEvents.pageHide);
  4408. }
  4409. }, {
  4410. key: "_unbindEvents",
  4411. value: function _unbindEvents() {
  4412. if (!this._boundEvents) {
  4413. return;
  4414. }
  4415. this.eventBus._off("updateviewarea", this._boundEvents.updateViewarea);
  4416. window.removeEventListener("popstate", this._boundEvents.popState);
  4417. window.removeEventListener("pagehide", this._boundEvents.pageHide);
  4418. this._boundEvents = null;
  4419. }
  4420. }, {
  4421. key: "popStateInProgress",
  4422. get: function get() {
  4423. return this._initialized && (this._popStateInProgress || this._blockHashChange > 0);
  4424. }
  4425. }, {
  4426. key: "initialBookmark",
  4427. get: function get() {
  4428. return this._initialized ? this._initialBookmark : null;
  4429. }
  4430. }, {
  4431. key: "initialRotation",
  4432. get: function get() {
  4433. return this._initialized ? this._initialRotation : null;
  4434. }
  4435. }]);
  4436. return PDFHistory;
  4437. }();
  4438. exports.PDFHistory = PDFHistory;
  4439. function isDestHashesEqual(destHash, pushHash) {
  4440. if (typeof destHash !== "string" || typeof pushHash !== "string") {
  4441. return false;
  4442. }
  4443. if (destHash === pushHash) {
  4444. return true;
  4445. }
  4446. var _parseQueryString = (0, _ui_utils.parseQueryString)(destHash),
  4447. nameddest = _parseQueryString.nameddest;
  4448. if (nameddest === pushHash) {
  4449. return true;
  4450. }
  4451. return false;
  4452. }
  4453. function isDestArraysEqual(firstDest, secondDest) {
  4454. function isEntryEqual(first, second) {
  4455. if (_typeof(first) !== _typeof(second)) {
  4456. return false;
  4457. }
  4458. if (Array.isArray(first) || Array.isArray(second)) {
  4459. return false;
  4460. }
  4461. if (first !== null && _typeof(first) === "object" && second !== null) {
  4462. if (Object.keys(first).length !== Object.keys(second).length) {
  4463. return false;
  4464. }
  4465. for (var key in first) {
  4466. if (!isEntryEqual(first[key], second[key])) {
  4467. return false;
  4468. }
  4469. }
  4470. return true;
  4471. }
  4472. return first === second || Number.isNaN(first) && Number.isNaN(second);
  4473. }
  4474. if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
  4475. return false;
  4476. }
  4477. if (firstDest.length !== secondDest.length) {
  4478. return false;
  4479. }
  4480. for (var i = 0, ii = firstDest.length; i < ii; i++) {
  4481. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  4482. return false;
  4483. }
  4484. }
  4485. return true;
  4486. }
  4487. /***/ }),
  4488. /* 16 */
  4489. /***/ (function(module, exports, __w_pdfjs_require__) {
  4490. "use strict";
  4491. Object.defineProperty(exports, "__esModule", {
  4492. value: true
  4493. });
  4494. exports.PDFPageView = void 0;
  4495. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(4));
  4496. var _ui_utils = __w_pdfjs_require__(3);
  4497. var _pdfjsLib = __w_pdfjs_require__(2);
  4498. var _pdf_rendering_queue = __w_pdfjs_require__(17);
  4499. var _viewer_compatibility = __w_pdfjs_require__(10);
  4500. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  4501. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  4502. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  4503. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4504. 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); } }
  4505. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4506. var MAX_CANVAS_PIXELS = _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216;
  4507. var PDFPageView = /*#__PURE__*/function () {
  4508. function PDFPageView(options) {
  4509. _classCallCheck(this, PDFPageView);
  4510. var container = options.container;
  4511. var defaultViewport = options.defaultViewport;
  4512. this.id = options.id;
  4513. this.renderingId = "page" + this.id;
  4514. this.pdfPage = null;
  4515. this.pageLabel = null;
  4516. this.rotation = 0;
  4517. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  4518. this.viewport = defaultViewport;
  4519. this.pdfPageRotate = defaultViewport.rotation;
  4520. this._annotationStorage = options.annotationStorage || null;
  4521. this._optionalContentConfigPromise = options.optionalContentConfigPromise || null;
  4522. this.hasRestrictedScaling = false;
  4523. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  4524. this.imageResourcesPath = options.imageResourcesPath || "";
  4525. this.renderInteractiveForms = typeof options.renderInteractiveForms === "boolean" ? options.renderInteractiveForms : true;
  4526. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  4527. this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
  4528. this.eventBus = options.eventBus;
  4529. this.renderingQueue = options.renderingQueue;
  4530. this.textLayerFactory = options.textLayerFactory;
  4531. this.annotationLayerFactory = options.annotationLayerFactory;
  4532. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  4533. this.enableWebGL = options.enableWebGL || false;
  4534. this.l10n = options.l10n || _ui_utils.NullL10n;
  4535. this.paintTask = null;
  4536. this.paintedViewportMap = new WeakMap();
  4537. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  4538. this.resume = null;
  4539. this.error = null;
  4540. this.annotationLayer = null;
  4541. this.textLayer = null;
  4542. this.zoomLayer = null;
  4543. var div = document.createElement("div");
  4544. div.className = "page";
  4545. div.style.width = Math.floor(this.viewport.width) + "px";
  4546. div.style.height = Math.floor(this.viewport.height) + "px";
  4547. div.setAttribute("data-page-number", this.id);
  4548. this.div = div;
  4549. container.appendChild(div);
  4550. }
  4551. _createClass(PDFPageView, [{
  4552. key: "setPdfPage",
  4553. value: function setPdfPage(pdfPage) {
  4554. this.pdfPage = pdfPage;
  4555. this.pdfPageRotate = pdfPage.rotate;
  4556. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  4557. this.viewport = pdfPage.getViewport({
  4558. scale: this.scale * _ui_utils.CSS_UNITS,
  4559. rotation: totalRotation
  4560. });
  4561. this.stats = pdfPage.stats;
  4562. this.reset();
  4563. }
  4564. }, {
  4565. key: "destroy",
  4566. value: function destroy() {
  4567. this.reset();
  4568. if (this.pdfPage) {
  4569. this.pdfPage.cleanup();
  4570. }
  4571. }
  4572. }, {
  4573. key: "_renderAnnotationLayer",
  4574. value: function () {
  4575. var _renderAnnotationLayer2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  4576. var error;
  4577. return _regenerator["default"].wrap(function _callee$(_context) {
  4578. while (1) {
  4579. switch (_context.prev = _context.next) {
  4580. case 0:
  4581. error = null;
  4582. _context.prev = 1;
  4583. _context.next = 4;
  4584. return this.annotationLayer.render(this.viewport, "display");
  4585. case 4:
  4586. _context.next = 9;
  4587. break;
  4588. case 6:
  4589. _context.prev = 6;
  4590. _context.t0 = _context["catch"](1);
  4591. error = _context.t0;
  4592. case 9:
  4593. _context.prev = 9;
  4594. this.eventBus.dispatch("annotationlayerrendered", {
  4595. source: this,
  4596. pageNumber: this.id,
  4597. error: error
  4598. });
  4599. return _context.finish(9);
  4600. case 12:
  4601. case "end":
  4602. return _context.stop();
  4603. }
  4604. }
  4605. }, _callee, this, [[1, 6, 9, 12]]);
  4606. }));
  4607. function _renderAnnotationLayer() {
  4608. return _renderAnnotationLayer2.apply(this, arguments);
  4609. }
  4610. return _renderAnnotationLayer;
  4611. }()
  4612. }, {
  4613. key: "_resetZoomLayer",
  4614. value: function _resetZoomLayer() {
  4615. var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4616. if (!this.zoomLayer) {
  4617. return;
  4618. }
  4619. var zoomLayerCanvas = this.zoomLayer.firstChild;
  4620. this.paintedViewportMap["delete"](zoomLayerCanvas);
  4621. zoomLayerCanvas.width = 0;
  4622. zoomLayerCanvas.height = 0;
  4623. if (removeFromDOM) {
  4624. this.zoomLayer.remove();
  4625. }
  4626. this.zoomLayer = null;
  4627. }
  4628. }, {
  4629. key: "reset",
  4630. value: function reset() {
  4631. var keepZoomLayer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4632. var keepAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4633. this.cancelRendering(keepAnnotations);
  4634. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  4635. var div = this.div;
  4636. div.style.width = Math.floor(this.viewport.width) + "px";
  4637. div.style.height = Math.floor(this.viewport.height) + "px";
  4638. var childNodes = div.childNodes;
  4639. var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
  4640. var currentAnnotationNode = keepAnnotations && this.annotationLayer && this.annotationLayer.div || null;
  4641. for (var i = childNodes.length - 1; i >= 0; i--) {
  4642. var node = childNodes[i];
  4643. if (currentZoomLayerNode === node || currentAnnotationNode === node) {
  4644. continue;
  4645. }
  4646. div.removeChild(node);
  4647. }
  4648. div.removeAttribute("data-loaded");
  4649. if (currentAnnotationNode) {
  4650. this.annotationLayer.hide();
  4651. } else if (this.annotationLayer) {
  4652. this.annotationLayer.cancel();
  4653. this.annotationLayer = null;
  4654. }
  4655. if (!currentZoomLayerNode) {
  4656. if (this.canvas) {
  4657. this.paintedViewportMap["delete"](this.canvas);
  4658. this.canvas.width = 0;
  4659. this.canvas.height = 0;
  4660. delete this.canvas;
  4661. }
  4662. this._resetZoomLayer();
  4663. }
  4664. if (this.svg) {
  4665. this.paintedViewportMap["delete"](this.svg);
  4666. delete this.svg;
  4667. }
  4668. this.loadingIconDiv = document.createElement("div");
  4669. this.loadingIconDiv.className = "loadingIcon";
  4670. div.appendChild(this.loadingIconDiv);
  4671. }
  4672. }, {
  4673. key: "update",
  4674. value: function update(scale, rotation) {
  4675. var optionalContentConfigPromise = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4676. this.scale = scale || this.scale;
  4677. if (typeof rotation !== "undefined") {
  4678. this.rotation = rotation;
  4679. }
  4680. if (optionalContentConfigPromise instanceof Promise) {
  4681. this._optionalContentConfigPromise = optionalContentConfigPromise;
  4682. }
  4683. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  4684. this.viewport = this.viewport.clone({
  4685. scale: this.scale * _ui_utils.CSS_UNITS,
  4686. rotation: totalRotation
  4687. });
  4688. if (this.svg) {
  4689. this.cssTransform(this.svg, true);
  4690. this.eventBus.dispatch("pagerendered", {
  4691. source: this,
  4692. pageNumber: this.id,
  4693. cssTransform: true,
  4694. timestamp: performance.now()
  4695. });
  4696. return;
  4697. }
  4698. var isScalingRestricted = false;
  4699. if (this.canvas && this.maxCanvasPixels > 0) {
  4700. var outputScale = this.outputScale;
  4701. if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > this.maxCanvasPixels) {
  4702. isScalingRestricted = true;
  4703. }
  4704. }
  4705. if (this.canvas) {
  4706. if (this.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
  4707. this.cssTransform(this.canvas, true);
  4708. this.eventBus.dispatch("pagerendered", {
  4709. source: this,
  4710. pageNumber: this.id,
  4711. cssTransform: true,
  4712. timestamp: performance.now()
  4713. });
  4714. return;
  4715. }
  4716. if (!this.zoomLayer && !this.canvas.hasAttribute("hidden")) {
  4717. this.zoomLayer = this.canvas.parentNode;
  4718. this.zoomLayer.style.position = "absolute";
  4719. }
  4720. }
  4721. if (this.zoomLayer) {
  4722. this.cssTransform(this.zoomLayer.firstChild);
  4723. }
  4724. this.reset(true, true);
  4725. }
  4726. }, {
  4727. key: "cancelRendering",
  4728. value: function cancelRendering() {
  4729. var keepAnnotations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4730. if (this.paintTask) {
  4731. this.paintTask.cancel();
  4732. this.paintTask = null;
  4733. }
  4734. this.resume = null;
  4735. if (this.textLayer) {
  4736. this.textLayer.cancel();
  4737. this.textLayer = null;
  4738. }
  4739. if (!keepAnnotations && this.annotationLayer) {
  4740. this.annotationLayer.cancel();
  4741. this.annotationLayer = null;
  4742. }
  4743. }
  4744. }, {
  4745. key: "cssTransform",
  4746. value: function cssTransform(target) {
  4747. var redrawAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4748. var width = this.viewport.width;
  4749. var height = this.viewport.height;
  4750. var div = this.div;
  4751. target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + "px";
  4752. target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + "px";
  4753. var relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
  4754. var absRotation = Math.abs(relativeRotation);
  4755. var scaleX = 1,
  4756. scaleY = 1;
  4757. if (absRotation === 90 || absRotation === 270) {
  4758. scaleX = height / width;
  4759. scaleY = width / height;
  4760. }
  4761. var cssTransform = "rotate(" + relativeRotation + "deg) " + "scale(" + scaleX + "," + scaleY + ")";
  4762. target.style.transform = cssTransform;
  4763. if (this.textLayer) {
  4764. var textLayerViewport = this.textLayer.viewport;
  4765. var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
  4766. var textAbsRotation = Math.abs(textRelativeRotation);
  4767. var scale = width / textLayerViewport.width;
  4768. if (textAbsRotation === 90 || textAbsRotation === 270) {
  4769. scale = width / textLayerViewport.height;
  4770. }
  4771. var textLayerDiv = this.textLayer.textLayerDiv;
  4772. var transX, transY;
  4773. switch (textAbsRotation) {
  4774. case 0:
  4775. transX = transY = 0;
  4776. break;
  4777. case 90:
  4778. transX = 0;
  4779. transY = "-" + textLayerDiv.style.height;
  4780. break;
  4781. case 180:
  4782. transX = "-" + textLayerDiv.style.width;
  4783. transY = "-" + textLayerDiv.style.height;
  4784. break;
  4785. case 270:
  4786. transX = "-" + textLayerDiv.style.width;
  4787. transY = 0;
  4788. break;
  4789. default:
  4790. console.error("Bad rotation value.");
  4791. break;
  4792. }
  4793. textLayerDiv.style.transform = "rotate(" + textAbsRotation + "deg) " + "scale(" + scale + ", " + scale + ") " + "translate(" + transX + ", " + transY + ")";
  4794. textLayerDiv.style.transformOrigin = "0% 0%";
  4795. }
  4796. if (redrawAnnotations && this.annotationLayer) {
  4797. this._renderAnnotationLayer();
  4798. }
  4799. }
  4800. }, {
  4801. key: "getPagePoint",
  4802. value: function getPagePoint(x, y) {
  4803. return this.viewport.convertToPdfPoint(x, y);
  4804. }
  4805. }, {
  4806. key: "draw",
  4807. value: function draw() {
  4808. var _this = this;
  4809. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  4810. console.error("Must be in new state before drawing");
  4811. this.reset();
  4812. }
  4813. var div = this.div,
  4814. pdfPage = this.pdfPage;
  4815. if (!pdfPage) {
  4816. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  4817. if (this.loadingIconDiv) {
  4818. div.removeChild(this.loadingIconDiv);
  4819. delete this.loadingIconDiv;
  4820. }
  4821. return Promise.reject(new Error("pdfPage is not loaded"));
  4822. }
  4823. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  4824. var canvasWrapper = document.createElement("div");
  4825. canvasWrapper.style.width = div.style.width;
  4826. canvasWrapper.style.height = div.style.height;
  4827. canvasWrapper.classList.add("canvasWrapper");
  4828. if (this.annotationLayer && this.annotationLayer.div) {
  4829. div.insertBefore(canvasWrapper, this.annotationLayer.div);
  4830. } else {
  4831. div.appendChild(canvasWrapper);
  4832. }
  4833. var textLayer = null;
  4834. if (this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && this.textLayerFactory) {
  4835. var textLayerDiv = document.createElement("div");
  4836. textLayerDiv.className = "textLayer";
  4837. textLayerDiv.style.width = canvasWrapper.style.width;
  4838. textLayerDiv.style.height = canvasWrapper.style.height;
  4839. if (this.annotationLayer && this.annotationLayer.div) {
  4840. div.insertBefore(textLayerDiv, this.annotationLayer.div);
  4841. } else {
  4842. div.appendChild(textLayerDiv);
  4843. }
  4844. textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.textLayerMode === _ui_utils.TextLayerMode.ENABLE_ENHANCE, this.eventBus);
  4845. }
  4846. this.textLayer = textLayer;
  4847. var renderContinueCallback = null;
  4848. if (this.renderingQueue) {
  4849. renderContinueCallback = function renderContinueCallback(cont) {
  4850. if (!_this.renderingQueue.isHighestPriority(_this)) {
  4851. _this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  4852. _this.resume = function () {
  4853. _this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  4854. cont();
  4855. };
  4856. return;
  4857. }
  4858. cont();
  4859. };
  4860. }
  4861. var finishPaintTask = /*#__PURE__*/function () {
  4862. var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(error) {
  4863. return _regenerator["default"].wrap(function _callee2$(_context2) {
  4864. while (1) {
  4865. switch (_context2.prev = _context2.next) {
  4866. case 0:
  4867. if (paintTask === _this.paintTask) {
  4868. _this.paintTask = null;
  4869. }
  4870. if (!(error instanceof _pdfjsLib.RenderingCancelledException)) {
  4871. _context2.next = 4;
  4872. break;
  4873. }
  4874. _this.error = null;
  4875. return _context2.abrupt("return");
  4876. case 4:
  4877. _this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  4878. if (_this.loadingIconDiv) {
  4879. div.removeChild(_this.loadingIconDiv);
  4880. delete _this.loadingIconDiv;
  4881. }
  4882. _this._resetZoomLayer(true);
  4883. _this.error = error;
  4884. _this.stats = pdfPage.stats;
  4885. _this.eventBus.dispatch("pagerendered", {
  4886. source: _this,
  4887. pageNumber: _this.id,
  4888. cssTransform: false,
  4889. timestamp: performance.now()
  4890. });
  4891. if (!error) {
  4892. _context2.next = 12;
  4893. break;
  4894. }
  4895. throw error;
  4896. case 12:
  4897. case "end":
  4898. return _context2.stop();
  4899. }
  4900. }
  4901. }, _callee2);
  4902. }));
  4903. return function finishPaintTask(_x) {
  4904. return _ref.apply(this, arguments);
  4905. };
  4906. }();
  4907. var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
  4908. paintTask.onRenderContinue = renderContinueCallback;
  4909. this.paintTask = paintTask;
  4910. var resultPromise = paintTask.promise.then(function () {
  4911. return finishPaintTask(null).then(function () {
  4912. if (textLayer) {
  4913. var readableStream = pdfPage.streamTextContent({
  4914. normalizeWhitespace: true
  4915. });
  4916. textLayer.setTextContentStream(readableStream);
  4917. textLayer.render();
  4918. }
  4919. });
  4920. }, function (reason) {
  4921. return finishPaintTask(reason);
  4922. });
  4923. if (this.annotationLayerFactory) {
  4924. if (!this.annotationLayer) {
  4925. this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this._annotationStorage, this.imageResourcesPath, this.renderInteractiveForms, this.l10n);
  4926. }
  4927. this._renderAnnotationLayer();
  4928. }
  4929. div.setAttribute("data-loaded", true);
  4930. this.eventBus.dispatch("pagerender", {
  4931. source: this,
  4932. pageNumber: this.id
  4933. });
  4934. return resultPromise;
  4935. }
  4936. }, {
  4937. key: "paintOnCanvas",
  4938. value: function paintOnCanvas(canvasWrapper) {
  4939. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  4940. var result = {
  4941. promise: renderCapability.promise,
  4942. onRenderContinue: function onRenderContinue(cont) {
  4943. cont();
  4944. },
  4945. cancel: function cancel() {
  4946. renderTask.cancel();
  4947. }
  4948. };
  4949. var viewport = this.viewport;
  4950. var canvas = document.createElement("canvas");
  4951. this.l10n.get("page_canvas", {
  4952. page: this.id
  4953. }, "Page {{page}}").then(function (msg) {
  4954. canvas.setAttribute("aria-label", msg);
  4955. });
  4956. canvas.setAttribute("hidden", "hidden");
  4957. var isCanvasHidden = true;
  4958. var showCanvas = function showCanvas() {
  4959. if (isCanvasHidden) {
  4960. canvas.removeAttribute("hidden");
  4961. isCanvasHidden = false;
  4962. }
  4963. };
  4964. canvasWrapper.appendChild(canvas);
  4965. this.canvas = canvas;
  4966. canvas.mozOpaque = true;
  4967. var ctx = canvas.getContext("2d", {
  4968. alpha: false
  4969. });
  4970. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  4971. this.outputScale = outputScale;
  4972. if (this.useOnlyCssZoom) {
  4973. var actualSizeViewport = viewport.clone({
  4974. scale: _ui_utils.CSS_UNITS
  4975. });
  4976. outputScale.sx *= actualSizeViewport.width / viewport.width;
  4977. outputScale.sy *= actualSizeViewport.height / viewport.height;
  4978. outputScale.scaled = true;
  4979. }
  4980. if (this.maxCanvasPixels > 0) {
  4981. var pixelsInViewport = viewport.width * viewport.height;
  4982. var maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
  4983. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  4984. outputScale.sx = maxScale;
  4985. outputScale.sy = maxScale;
  4986. outputScale.scaled = true;
  4987. this.hasRestrictedScaling = true;
  4988. } else {
  4989. this.hasRestrictedScaling = false;
  4990. }
  4991. }
  4992. var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  4993. var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  4994. canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
  4995. canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
  4996. canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + "px";
  4997. canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + "px";
  4998. this.paintedViewportMap.set(canvas, viewport);
  4999. var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
  5000. var renderContext = {
  5001. canvasContext: ctx,
  5002. transform: transform,
  5003. viewport: this.viewport,
  5004. enableWebGL: this.enableWebGL,
  5005. renderInteractiveForms: this.renderInteractiveForms,
  5006. optionalContentConfigPromise: this._optionalContentConfigPromise
  5007. };
  5008. var renderTask = this.pdfPage.render(renderContext);
  5009. renderTask.onContinue = function (cont) {
  5010. showCanvas();
  5011. if (result.onRenderContinue) {
  5012. result.onRenderContinue(cont);
  5013. } else {
  5014. cont();
  5015. }
  5016. };
  5017. renderTask.promise.then(function () {
  5018. showCanvas();
  5019. renderCapability.resolve(undefined);
  5020. }, function (error) {
  5021. showCanvas();
  5022. renderCapability.reject(error);
  5023. });
  5024. return result;
  5025. }
  5026. }, {
  5027. key: "paintOnSvg",
  5028. value: function paintOnSvg(wrapper) {
  5029. var _this2 = this;
  5030. var cancelled = false;
  5031. var ensureNotCancelled = function ensureNotCancelled() {
  5032. if (cancelled) {
  5033. throw new _pdfjsLib.RenderingCancelledException("Rendering cancelled, page ".concat(_this2.id), "svg");
  5034. }
  5035. };
  5036. var pdfPage = this.pdfPage;
  5037. var actualSizeViewport = this.viewport.clone({
  5038. scale: _ui_utils.CSS_UNITS
  5039. });
  5040. var promise = pdfPage.getOperatorList().then(function (opList) {
  5041. ensureNotCancelled();
  5042. var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
  5043. return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {
  5044. ensureNotCancelled();
  5045. _this2.svg = svg;
  5046. _this2.paintedViewportMap.set(svg, actualSizeViewport);
  5047. svg.style.width = wrapper.style.width;
  5048. svg.style.height = wrapper.style.height;
  5049. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  5050. wrapper.appendChild(svg);
  5051. });
  5052. });
  5053. return {
  5054. promise: promise,
  5055. onRenderContinue: function onRenderContinue(cont) {
  5056. cont();
  5057. },
  5058. cancel: function cancel() {
  5059. cancelled = true;
  5060. }
  5061. };
  5062. }
  5063. }, {
  5064. key: "setPageLabel",
  5065. value: function setPageLabel(label) {
  5066. this.pageLabel = typeof label === "string" ? label : null;
  5067. if (this.pageLabel !== null) {
  5068. this.div.setAttribute("data-page-label", this.pageLabel);
  5069. } else {
  5070. this.div.removeAttribute("data-page-label");
  5071. }
  5072. }
  5073. }, {
  5074. key: "width",
  5075. get: function get() {
  5076. return this.viewport.width;
  5077. }
  5078. }, {
  5079. key: "height",
  5080. get: function get() {
  5081. return this.viewport.height;
  5082. }
  5083. }]);
  5084. return PDFPageView;
  5085. }();
  5086. exports.PDFPageView = PDFPageView;
  5087. /***/ }),
  5088. /* 17 */
  5089. /***/ (function(module, exports, __w_pdfjs_require__) {
  5090. "use strict";
  5091. Object.defineProperty(exports, "__esModule", {
  5092. value: true
  5093. });
  5094. exports.PDFRenderingQueue = exports.RenderingStates = void 0;
  5095. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5096. 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); } }
  5097. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5098. var CLEANUP_TIMEOUT = 30000;
  5099. var RenderingStates = {
  5100. INITIAL: 0,
  5101. RUNNING: 1,
  5102. PAUSED: 2,
  5103. FINISHED: 3
  5104. };
  5105. exports.RenderingStates = RenderingStates;
  5106. var PDFRenderingQueue = /*#__PURE__*/function () {
  5107. function PDFRenderingQueue() {
  5108. _classCallCheck(this, PDFRenderingQueue);
  5109. this.pdfViewer = null;
  5110. this.pdfThumbnailViewer = null;
  5111. this.onIdle = null;
  5112. this.highestPriorityPage = null;
  5113. this.idleTimeout = null;
  5114. this.printing = false;
  5115. this.isThumbnailViewEnabled = false;
  5116. }
  5117. _createClass(PDFRenderingQueue, [{
  5118. key: "setViewer",
  5119. value: function setViewer(pdfViewer) {
  5120. this.pdfViewer = pdfViewer;
  5121. }
  5122. }, {
  5123. key: "setThumbnailViewer",
  5124. value: function setThumbnailViewer(pdfThumbnailViewer) {
  5125. this.pdfThumbnailViewer = pdfThumbnailViewer;
  5126. }
  5127. }, {
  5128. key: "isHighestPriority",
  5129. value: function isHighestPriority(view) {
  5130. return this.highestPriorityPage === view.renderingId;
  5131. }
  5132. }, {
  5133. key: "renderHighestPriority",
  5134. value: function renderHighestPriority(currentlyVisiblePages) {
  5135. if (this.idleTimeout) {
  5136. clearTimeout(this.idleTimeout);
  5137. this.idleTimeout = null;
  5138. }
  5139. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  5140. return;
  5141. }
  5142. if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
  5143. if (this.pdfThumbnailViewer.forceRendering()) {
  5144. return;
  5145. }
  5146. }
  5147. if (this.printing) {
  5148. return;
  5149. }
  5150. if (this.onIdle) {
  5151. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
  5152. }
  5153. }
  5154. }, {
  5155. key: "getHighestPriority",
  5156. value: function getHighestPriority(visible, views, scrolledDown) {
  5157. var visibleViews = visible.views;
  5158. var numVisible = visibleViews.length;
  5159. if (numVisible === 0) {
  5160. return null;
  5161. }
  5162. for (var i = 0; i < numVisible; ++i) {
  5163. var view = visibleViews[i].view;
  5164. if (!this.isViewFinished(view)) {
  5165. return view;
  5166. }
  5167. }
  5168. if (scrolledDown) {
  5169. var nextPageIndex = visible.last.id;
  5170. if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {
  5171. return views[nextPageIndex];
  5172. }
  5173. } else {
  5174. var previousPageIndex = visible.first.id - 2;
  5175. if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) {
  5176. return views[previousPageIndex];
  5177. }
  5178. }
  5179. return null;
  5180. }
  5181. }, {
  5182. key: "isViewFinished",
  5183. value: function isViewFinished(view) {
  5184. return view.renderingState === RenderingStates.FINISHED;
  5185. }
  5186. }, {
  5187. key: "renderView",
  5188. value: function renderView(view) {
  5189. var _this = this;
  5190. switch (view.renderingState) {
  5191. case RenderingStates.FINISHED:
  5192. return false;
  5193. case RenderingStates.PAUSED:
  5194. this.highestPriorityPage = view.renderingId;
  5195. view.resume();
  5196. break;
  5197. case RenderingStates.RUNNING:
  5198. this.highestPriorityPage = view.renderingId;
  5199. break;
  5200. case RenderingStates.INITIAL:
  5201. this.highestPriorityPage = view.renderingId;
  5202. view.draw()["finally"](function () {
  5203. _this.renderHighestPriority();
  5204. })["catch"](function (reason) {
  5205. console.error("renderView: \"".concat(reason, "\""));
  5206. });
  5207. break;
  5208. }
  5209. return true;
  5210. }
  5211. }]);
  5212. return PDFRenderingQueue;
  5213. }();
  5214. exports.PDFRenderingQueue = PDFRenderingQueue;
  5215. /***/ }),
  5216. /* 18 */
  5217. /***/ (function(module, exports, __w_pdfjs_require__) {
  5218. "use strict";
  5219. Object.defineProperty(exports, "__esModule", {
  5220. value: true
  5221. });
  5222. exports.PDFSinglePageViewer = void 0;
  5223. var _base_viewer = __w_pdfjs_require__(19);
  5224. var _pdfjsLib = __w_pdfjs_require__(2);
  5225. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  5226. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5227. 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); } }
  5228. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5229. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  5230. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  5231. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  5232. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  5233. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  5234. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  5235. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  5236. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  5237. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  5238. var PDFSinglePageViewer = /*#__PURE__*/function (_BaseViewer) {
  5239. _inherits(PDFSinglePageViewer, _BaseViewer);
  5240. var _super = _createSuper(PDFSinglePageViewer);
  5241. function PDFSinglePageViewer(options) {
  5242. var _this;
  5243. _classCallCheck(this, PDFSinglePageViewer);
  5244. _this = _super.call(this, options);
  5245. _this.eventBus._on("pagesinit", function (evt) {
  5246. _this._ensurePageViewVisible();
  5247. });
  5248. return _this;
  5249. }
  5250. _createClass(PDFSinglePageViewer, [{
  5251. key: "_resetView",
  5252. value: function _resetView() {
  5253. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_resetView", this).call(this);
  5254. this._previousPageNumber = 1;
  5255. this._shadowViewer = document.createDocumentFragment();
  5256. this._updateScrollDown = null;
  5257. }
  5258. }, {
  5259. key: "_ensurePageViewVisible",
  5260. value: function _ensurePageViewVisible() {
  5261. var pageView = this._pages[this._currentPageNumber - 1];
  5262. var previousPageView = this._pages[this._previousPageNumber - 1];
  5263. var viewerNodes = this.viewer.childNodes;
  5264. switch (viewerNodes.length) {
  5265. case 0:
  5266. this.viewer.appendChild(pageView.div);
  5267. break;
  5268. case 1:
  5269. if (viewerNodes[0] !== previousPageView.div) {
  5270. throw new Error("_ensurePageViewVisible: Unexpected previously visible page.");
  5271. }
  5272. if (pageView === previousPageView) {
  5273. break;
  5274. }
  5275. this._shadowViewer.appendChild(previousPageView.div);
  5276. this.viewer.appendChild(pageView.div);
  5277. this.container.scrollTop = 0;
  5278. break;
  5279. default:
  5280. throw new Error("_ensurePageViewVisible: Only one page should be visible at a time.");
  5281. }
  5282. this._previousPageNumber = this._currentPageNumber;
  5283. }
  5284. }, {
  5285. key: "_scrollUpdate",
  5286. value: function _scrollUpdate() {
  5287. if (this._updateScrollDown) {
  5288. this._updateScrollDown();
  5289. }
  5290. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollUpdate", this).call(this);
  5291. }
  5292. }, {
  5293. key: "_scrollIntoView",
  5294. value: function _scrollIntoView(_ref) {
  5295. var _this2 = this;
  5296. var pageDiv = _ref.pageDiv,
  5297. _ref$pageSpot = _ref.pageSpot,
  5298. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  5299. _ref$pageNumber = _ref.pageNumber,
  5300. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  5301. if (pageNumber) {
  5302. this._setCurrentPageNumber(pageNumber);
  5303. }
  5304. var scrolledDown = this._currentPageNumber >= this._previousPageNumber;
  5305. this._ensurePageViewVisible();
  5306. this.update();
  5307. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollIntoView", this).call(this, {
  5308. pageDiv: pageDiv,
  5309. pageSpot: pageSpot,
  5310. pageNumber: pageNumber
  5311. });
  5312. this._updateScrollDown = function () {
  5313. _this2.scroll.down = scrolledDown;
  5314. _this2._updateScrollDown = null;
  5315. };
  5316. }
  5317. }, {
  5318. key: "_getVisiblePages",
  5319. value: function _getVisiblePages() {
  5320. return this._getCurrentVisiblePage();
  5321. }
  5322. }, {
  5323. key: "_updateHelper",
  5324. value: function _updateHelper(visiblePages) {}
  5325. }, {
  5326. key: "_updateScrollMode",
  5327. value: function _updateScrollMode() {}
  5328. }, {
  5329. key: "_updateSpreadMode",
  5330. value: function _updateSpreadMode() {}
  5331. }, {
  5332. key: "_viewerElement",
  5333. get: function get() {
  5334. return (0, _pdfjsLib.shadow)(this, "_viewerElement", this._shadowViewer);
  5335. }
  5336. }, {
  5337. key: "_isScrollModeHorizontal",
  5338. get: function get() {
  5339. return (0, _pdfjsLib.shadow)(this, "_isScrollModeHorizontal", false);
  5340. }
  5341. }]);
  5342. return PDFSinglePageViewer;
  5343. }(_base_viewer.BaseViewer);
  5344. exports.PDFSinglePageViewer = PDFSinglePageViewer;
  5345. /***/ }),
  5346. /* 19 */
  5347. /***/ (function(module, exports, __w_pdfjs_require__) {
  5348. "use strict";
  5349. Object.defineProperty(exports, "__esModule", {
  5350. value: true
  5351. });
  5352. exports.BaseViewer = void 0;
  5353. var _ui_utils = __w_pdfjs_require__(3);
  5354. var _pdf_rendering_queue = __w_pdfjs_require__(17);
  5355. var _annotation_layer_builder = __w_pdfjs_require__(1);
  5356. var _pdfjsLib = __w_pdfjs_require__(2);
  5357. var _pdf_page_view = __w_pdfjs_require__(16);
  5358. var _pdf_link_service = __w_pdfjs_require__(7);
  5359. var _text_layer_builder = __w_pdfjs_require__(8);
  5360. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  5361. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  5362. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  5363. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5364. 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); } }
  5365. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5366. var DEFAULT_CACHE_SIZE = 10;
  5367. function PDFPageViewBuffer(size) {
  5368. var data = [];
  5369. this.push = function (view) {
  5370. var i = data.indexOf(view);
  5371. if (i >= 0) {
  5372. data.splice(i, 1);
  5373. }
  5374. data.push(view);
  5375. if (data.length > size) {
  5376. data.shift().destroy();
  5377. }
  5378. };
  5379. this.resize = function (newSize, pagesToKeep) {
  5380. size = newSize;
  5381. if (pagesToKeep) {
  5382. var pageIdsToKeep = new Set();
  5383. for (var i = 0, iMax = pagesToKeep.length; i < iMax; ++i) {
  5384. pageIdsToKeep.add(pagesToKeep[i].id);
  5385. }
  5386. (0, _ui_utils.moveToEndOfArray)(data, function (page) {
  5387. return pageIdsToKeep.has(page.id);
  5388. });
  5389. }
  5390. while (data.length > size) {
  5391. data.shift().destroy();
  5392. }
  5393. };
  5394. }
  5395. function isSameScale(oldScale, newScale) {
  5396. if (newScale === oldScale) {
  5397. return true;
  5398. }
  5399. if (Math.abs(newScale - oldScale) < 1e-15) {
  5400. return true;
  5401. }
  5402. return false;
  5403. }
  5404. var BaseViewer = /*#__PURE__*/function () {
  5405. function BaseViewer(options) {
  5406. var _this = this;
  5407. _classCallCheck(this, BaseViewer);
  5408. if (this.constructor === BaseViewer) {
  5409. throw new Error("Cannot initialize BaseViewer.");
  5410. }
  5411. this._name = this.constructor.name;
  5412. this.container = options.container;
  5413. this.viewer = options.viewer || options.container.firstElementChild;
  5414. if (!(this.container instanceof HTMLDivElement && this.viewer instanceof HTMLDivElement)) {
  5415. throw new Error("Invalid `container` and/or `viewer` option.");
  5416. }
  5417. this.eventBus = options.eventBus;
  5418. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  5419. this.downloadManager = options.downloadManager || null;
  5420. this.findController = options.findController || null;
  5421. this.removePageBorders = options.removePageBorders || false;
  5422. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  5423. this.imageResourcesPath = options.imageResourcesPath || "";
  5424. this.renderInteractiveForms = typeof options.renderInteractiveForms === "boolean" ? options.renderInteractiveForms : true;
  5425. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  5426. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  5427. this.enableWebGL = options.enableWebGL || false;
  5428. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  5429. this.maxCanvasPixels = options.maxCanvasPixels;
  5430. this.l10n = options.l10n || _ui_utils.NullL10n;
  5431. this.defaultRenderingQueue = !options.renderingQueue;
  5432. if (this.defaultRenderingQueue) {
  5433. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  5434. this.renderingQueue.setViewer(this);
  5435. } else {
  5436. this.renderingQueue = options.renderingQueue;
  5437. }
  5438. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  5439. this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
  5440. this._onBeforeDraw = this._onAfterDraw = null;
  5441. this._resetView();
  5442. if (this.removePageBorders) {
  5443. this.viewer.classList.add("removePageBorders");
  5444. }
  5445. Promise.resolve().then(function () {
  5446. _this.eventBus.dispatch("baseviewerinit", {
  5447. source: _this
  5448. });
  5449. });
  5450. }
  5451. _createClass(BaseViewer, [{
  5452. key: "getPageView",
  5453. value: function getPageView(index) {
  5454. return this._pages[index];
  5455. }
  5456. }, {
  5457. key: "_setCurrentPageNumber",
  5458. value: function _setCurrentPageNumber(val) {
  5459. var resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  5460. if (this._currentPageNumber === val) {
  5461. if (resetCurrentPageView) {
  5462. this._resetCurrentPageView();
  5463. }
  5464. return true;
  5465. }
  5466. if (!(0 < val && val <= this.pagesCount)) {
  5467. return false;
  5468. }
  5469. this._currentPageNumber = val;
  5470. this.eventBus.dispatch("pagechanging", {
  5471. source: this,
  5472. pageNumber: val,
  5473. pageLabel: this._pageLabels && this._pageLabels[val - 1]
  5474. });
  5475. if (resetCurrentPageView) {
  5476. this._resetCurrentPageView();
  5477. }
  5478. return true;
  5479. }
  5480. }, {
  5481. key: "_onePageRenderedOrForceFetch",
  5482. value: function _onePageRenderedOrForceFetch() {
  5483. if (!this.container.offsetParent || this._getVisiblePages().views.length === 0) {
  5484. return Promise.resolve();
  5485. }
  5486. return this._onePageRenderedCapability.promise;
  5487. }
  5488. }, {
  5489. key: "setDocument",
  5490. value: function setDocument(pdfDocument) {
  5491. var _this2 = this;
  5492. if (this.pdfDocument) {
  5493. this._cancelRendering();
  5494. this._resetView();
  5495. if (this.findController) {
  5496. this.findController.setDocument(null);
  5497. }
  5498. }
  5499. this.pdfDocument = pdfDocument;
  5500. if (!pdfDocument) {
  5501. return;
  5502. }
  5503. var pagesCount = pdfDocument.numPages;
  5504. var firstPagePromise = pdfDocument.getPage(1);
  5505. var annotationStorage = pdfDocument.annotationStorage;
  5506. var optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
  5507. this._pagesCapability.promise.then(function () {
  5508. _this2.eventBus.dispatch("pagesloaded", {
  5509. source: _this2,
  5510. pagesCount: pagesCount
  5511. });
  5512. });
  5513. this._onBeforeDraw = function (evt) {
  5514. var pageView = _this2._pages[evt.pageNumber - 1];
  5515. if (!pageView) {
  5516. return;
  5517. }
  5518. _this2._buffer.push(pageView);
  5519. };
  5520. this.eventBus._on("pagerender", this._onBeforeDraw);
  5521. this._onAfterDraw = function (evt) {
  5522. if (evt.cssTransform || _this2._onePageRenderedCapability.settled) {
  5523. return;
  5524. }
  5525. _this2._onePageRenderedCapability.resolve();
  5526. _this2.eventBus._off("pagerendered", _this2._onAfterDraw);
  5527. _this2._onAfterDraw = null;
  5528. };
  5529. this.eventBus._on("pagerendered", this._onAfterDraw);
  5530. firstPagePromise.then(function (firstPdfPage) {
  5531. _this2._firstPageCapability.resolve(firstPdfPage);
  5532. _this2._optionalContentConfigPromise = optionalContentConfigPromise;
  5533. var scale = _this2.currentScale;
  5534. var viewport = firstPdfPage.getViewport({
  5535. scale: scale * _ui_utils.CSS_UNITS
  5536. });
  5537. var textLayerFactory = _this2.textLayerMode !== _ui_utils.TextLayerMode.DISABLE ? _this2 : null;
  5538. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  5539. var pageView = new _pdf_page_view.PDFPageView({
  5540. container: _this2._viewerElement,
  5541. eventBus: _this2.eventBus,
  5542. id: pageNum,
  5543. scale: scale,
  5544. defaultViewport: viewport.clone(),
  5545. annotationStorage: annotationStorage,
  5546. optionalContentConfigPromise: optionalContentConfigPromise,
  5547. renderingQueue: _this2.renderingQueue,
  5548. textLayerFactory: textLayerFactory,
  5549. textLayerMode: _this2.textLayerMode,
  5550. annotationLayerFactory: _this2,
  5551. imageResourcesPath: _this2.imageResourcesPath,
  5552. renderInteractiveForms: _this2.renderInteractiveForms,
  5553. renderer: _this2.renderer,
  5554. enableWebGL: _this2.enableWebGL,
  5555. useOnlyCssZoom: _this2.useOnlyCssZoom,
  5556. maxCanvasPixels: _this2.maxCanvasPixels,
  5557. l10n: _this2.l10n
  5558. });
  5559. _this2._pages.push(pageView);
  5560. }
  5561. var firstPageView = _this2._pages[0];
  5562. if (firstPageView) {
  5563. firstPageView.setPdfPage(firstPdfPage);
  5564. _this2.linkService.cachePageRef(1, firstPdfPage.ref);
  5565. }
  5566. if (_this2._spreadMode !== _ui_utils.SpreadMode.NONE) {
  5567. _this2._updateSpreadMode();
  5568. }
  5569. _this2._onePageRenderedOrForceFetch().then(function () {
  5570. if (_this2.findController) {
  5571. _this2.findController.setDocument(pdfDocument);
  5572. }
  5573. if (pdfDocument.loadingParams.disableAutoFetch || pagesCount > 7500) {
  5574. _this2._pagesCapability.resolve();
  5575. return;
  5576. }
  5577. var getPagesLeft = pagesCount - 1;
  5578. if (getPagesLeft <= 0) {
  5579. _this2._pagesCapability.resolve();
  5580. return;
  5581. }
  5582. var _loop = function _loop(_pageNum) {
  5583. pdfDocument.getPage(_pageNum).then(function (pdfPage) {
  5584. var pageView = _this2._pages[_pageNum - 1];
  5585. if (!pageView.pdfPage) {
  5586. pageView.setPdfPage(pdfPage);
  5587. }
  5588. _this2.linkService.cachePageRef(_pageNum, pdfPage.ref);
  5589. if (--getPagesLeft === 0) {
  5590. _this2._pagesCapability.resolve();
  5591. }
  5592. }, function (reason) {
  5593. console.error("Unable to get page ".concat(_pageNum, " to initialize viewer"), reason);
  5594. if (--getPagesLeft === 0) {
  5595. _this2._pagesCapability.resolve();
  5596. }
  5597. });
  5598. };
  5599. for (var _pageNum = 2; _pageNum <= pagesCount; ++_pageNum) {
  5600. _loop(_pageNum);
  5601. }
  5602. });
  5603. _this2.eventBus.dispatch("pagesinit", {
  5604. source: _this2
  5605. });
  5606. if (_this2.defaultRenderingQueue) {
  5607. _this2.update();
  5608. }
  5609. })["catch"](function (reason) {
  5610. console.error("Unable to initialize viewer", reason);
  5611. });
  5612. }
  5613. }, {
  5614. key: "setPageLabels",
  5615. value: function setPageLabels(labels) {
  5616. if (!this.pdfDocument) {
  5617. return;
  5618. }
  5619. if (!labels) {
  5620. this._pageLabels = null;
  5621. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  5622. this._pageLabels = null;
  5623. console.error("".concat(this._name, ".setPageLabels: Invalid page labels."));
  5624. } else {
  5625. this._pageLabels = labels;
  5626. }
  5627. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  5628. var pageView = this._pages[i];
  5629. var label = this._pageLabels && this._pageLabels[i];
  5630. pageView.setPageLabel(label);
  5631. }
  5632. }
  5633. }, {
  5634. key: "_resetView",
  5635. value: function _resetView() {
  5636. this._pages = [];
  5637. this._currentPageNumber = 1;
  5638. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  5639. this._currentScaleValue = null;
  5640. this._pageLabels = null;
  5641. this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  5642. this._location = null;
  5643. this._pagesRotation = 0;
  5644. this._optionalContentConfigPromise = null;
  5645. this._pagesRequests = new WeakMap();
  5646. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  5647. this._onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  5648. this._pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
  5649. this._scrollMode = _ui_utils.ScrollMode.VERTICAL;
  5650. this._spreadMode = _ui_utils.SpreadMode.NONE;
  5651. if (this._onBeforeDraw) {
  5652. this.eventBus._off("pagerender", this._onBeforeDraw);
  5653. this._onBeforeDraw = null;
  5654. }
  5655. if (this._onAfterDraw) {
  5656. this.eventBus._off("pagerendered", this._onAfterDraw);
  5657. this._onAfterDraw = null;
  5658. }
  5659. this.viewer.textContent = "";
  5660. this._updateScrollMode();
  5661. }
  5662. }, {
  5663. key: "_scrollUpdate",
  5664. value: function _scrollUpdate() {
  5665. if (this.pagesCount === 0) {
  5666. return;
  5667. }
  5668. this.update();
  5669. }
  5670. }, {
  5671. key: "_scrollIntoView",
  5672. value: function _scrollIntoView(_ref) {
  5673. var pageDiv = _ref.pageDiv,
  5674. _ref$pageSpot = _ref.pageSpot,
  5675. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  5676. _ref$pageNumber = _ref.pageNumber,
  5677. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  5678. (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
  5679. }
  5680. }, {
  5681. key: "_setScaleUpdatePages",
  5682. value: function _setScaleUpdatePages(newScale, newValue) {
  5683. var noScroll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  5684. var preset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  5685. this._currentScaleValue = newValue.toString();
  5686. if (isSameScale(this._currentScale, newScale)) {
  5687. if (preset) {
  5688. this.eventBus.dispatch("scalechanging", {
  5689. source: this,
  5690. scale: newScale,
  5691. presetValue: newValue
  5692. });
  5693. }
  5694. return;
  5695. }
  5696. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  5697. this._pages[i].update(newScale);
  5698. }
  5699. this._currentScale = newScale;
  5700. if (!noScroll) {
  5701. var page = this._currentPageNumber,
  5702. dest;
  5703. if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  5704. page = this._location.pageNumber;
  5705. dest = [null, {
  5706. name: "XYZ"
  5707. }, this._location.left, this._location.top, null];
  5708. }
  5709. this.scrollPageIntoView({
  5710. pageNumber: page,
  5711. destArray: dest,
  5712. allowNegativeOffset: true
  5713. });
  5714. }
  5715. this.eventBus.dispatch("scalechanging", {
  5716. source: this,
  5717. scale: newScale,
  5718. presetValue: preset ? newValue : undefined
  5719. });
  5720. if (this.defaultRenderingQueue) {
  5721. this.update();
  5722. }
  5723. }
  5724. }, {
  5725. key: "_setScale",
  5726. value: function _setScale(value) {
  5727. var noScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  5728. var scale = parseFloat(value);
  5729. if (scale > 0) {
  5730. this._setScaleUpdatePages(scale, value, noScroll, false);
  5731. } else {
  5732. var currentPage = this._pages[this._currentPageNumber - 1];
  5733. if (!currentPage) {
  5734. return;
  5735. }
  5736. var noPadding = this.isInPresentationMode || this.removePageBorders;
  5737. var hPadding = noPadding ? 0 : _ui_utils.SCROLLBAR_PADDING;
  5738. var vPadding = noPadding ? 0 : _ui_utils.VERTICAL_PADDING;
  5739. if (!noPadding && this._isScrollModeHorizontal) {
  5740. var _ref2 = [vPadding, hPadding];
  5741. hPadding = _ref2[0];
  5742. vPadding = _ref2[1];
  5743. }
  5744. var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale;
  5745. var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  5746. switch (value) {
  5747. case "page-actual":
  5748. scale = 1;
  5749. break;
  5750. case "page-width":
  5751. scale = pageWidthScale;
  5752. break;
  5753. case "page-height":
  5754. scale = pageHeightScale;
  5755. break;
  5756. case "page-fit":
  5757. scale = Math.min(pageWidthScale, pageHeightScale);
  5758. break;
  5759. case "auto":
  5760. var horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
  5761. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  5762. break;
  5763. default:
  5764. console.error("".concat(this._name, "._setScale: \"").concat(value, "\" is an unknown zoom value."));
  5765. return;
  5766. }
  5767. this._setScaleUpdatePages(scale, value, noScroll, true);
  5768. }
  5769. }
  5770. }, {
  5771. key: "_resetCurrentPageView",
  5772. value: function _resetCurrentPageView() {
  5773. if (this.isInPresentationMode) {
  5774. this._setScale(this._currentScaleValue, true);
  5775. }
  5776. var pageView = this._pages[this._currentPageNumber - 1];
  5777. this._scrollIntoView({
  5778. pageDiv: pageView.div
  5779. });
  5780. }
  5781. }, {
  5782. key: "scrollPageIntoView",
  5783. value: function scrollPageIntoView(_ref3) {
  5784. var pageNumber = _ref3.pageNumber,
  5785. _ref3$destArray = _ref3.destArray,
  5786. destArray = _ref3$destArray === void 0 ? null : _ref3$destArray,
  5787. _ref3$allowNegativeOf = _ref3.allowNegativeOffset,
  5788. allowNegativeOffset = _ref3$allowNegativeOf === void 0 ? false : _ref3$allowNegativeOf,
  5789. _ref3$ignoreDestinati = _ref3.ignoreDestinationZoom,
  5790. ignoreDestinationZoom = _ref3$ignoreDestinati === void 0 ? false : _ref3$ignoreDestinati;
  5791. if (!this.pdfDocument) {
  5792. return;
  5793. }
  5794. var pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1];
  5795. if (!pageView) {
  5796. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  5797. return;
  5798. }
  5799. if (this.isInPresentationMode || !destArray) {
  5800. this._setCurrentPageNumber(pageNumber, true);
  5801. return;
  5802. }
  5803. var x = 0,
  5804. y = 0;
  5805. var width = 0,
  5806. height = 0,
  5807. widthScale,
  5808. heightScale;
  5809. var changeOrientation = pageView.rotation % 180 !== 0;
  5810. var pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;
  5811. var pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;
  5812. var scale = 0;
  5813. switch (destArray[1].name) {
  5814. case "XYZ":
  5815. x = destArray[2];
  5816. y = destArray[3];
  5817. scale = destArray[4];
  5818. x = x !== null ? x : 0;
  5819. y = y !== null ? y : pageHeight;
  5820. break;
  5821. case "Fit":
  5822. case "FitB":
  5823. scale = "page-fit";
  5824. break;
  5825. case "FitH":
  5826. case "FitBH":
  5827. y = destArray[2];
  5828. scale = "page-width";
  5829. if (y === null && this._location) {
  5830. x = this._location.left;
  5831. y = this._location.top;
  5832. }
  5833. break;
  5834. case "FitV":
  5835. case "FitBV":
  5836. x = destArray[2];
  5837. width = pageWidth;
  5838. height = pageHeight;
  5839. scale = "page-height";
  5840. break;
  5841. case "FitR":
  5842. x = destArray[2];
  5843. y = destArray[3];
  5844. width = destArray[4] - x;
  5845. height = destArray[5] - y;
  5846. var hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  5847. var vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  5848. widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;
  5849. heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;
  5850. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  5851. break;
  5852. default:
  5853. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(destArray[1].name, "\" is not a valid destination type."));
  5854. return;
  5855. }
  5856. if (!ignoreDestinationZoom) {
  5857. if (scale && scale !== this._currentScale) {
  5858. this.currentScaleValue = scale;
  5859. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  5860. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  5861. }
  5862. }
  5863. if (scale === "page-fit" && !destArray[4]) {
  5864. this._scrollIntoView({
  5865. pageDiv: pageView.div,
  5866. pageNumber: pageNumber
  5867. });
  5868. return;
  5869. }
  5870. var boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  5871. var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  5872. var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  5873. if (!allowNegativeOffset) {
  5874. left = Math.max(left, 0);
  5875. top = Math.max(top, 0);
  5876. }
  5877. this._scrollIntoView({
  5878. pageDiv: pageView.div,
  5879. pageSpot: {
  5880. left: left,
  5881. top: top
  5882. },
  5883. pageNumber: pageNumber
  5884. });
  5885. }
  5886. }, {
  5887. key: "_updateLocation",
  5888. value: function _updateLocation(firstPage) {
  5889. var currentScale = this._currentScale;
  5890. var currentScaleValue = this._currentScaleValue;
  5891. var normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  5892. var pageNumber = firstPage.id;
  5893. var pdfOpenParams = "#page=" + pageNumber;
  5894. pdfOpenParams += "&zoom=" + normalizedScaleValue;
  5895. var currentPageView = this._pages[pageNumber - 1];
  5896. var container = this.container;
  5897. var topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  5898. var intLeft = Math.round(topLeft[0]);
  5899. var intTop = Math.round(topLeft[1]);
  5900. pdfOpenParams += "," + intLeft + "," + intTop;
  5901. this._location = {
  5902. pageNumber: pageNumber,
  5903. scale: normalizedScaleValue,
  5904. top: intTop,
  5905. left: intLeft,
  5906. rotation: this._pagesRotation,
  5907. pdfOpenParams: pdfOpenParams
  5908. };
  5909. }
  5910. }, {
  5911. key: "_updateHelper",
  5912. value: function _updateHelper(visiblePages) {
  5913. throw new Error("Not implemented: _updateHelper");
  5914. }
  5915. }, {
  5916. key: "update",
  5917. value: function update() {
  5918. var visible = this._getVisiblePages();
  5919. var visiblePages = visible.views,
  5920. numVisiblePages = visiblePages.length;
  5921. if (numVisiblePages === 0) {
  5922. return;
  5923. }
  5924. var newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
  5925. this._buffer.resize(newCacheSize, visiblePages);
  5926. this.renderingQueue.renderHighestPriority(visible);
  5927. this._updateHelper(visiblePages);
  5928. this._updateLocation(visible.first);
  5929. this.eventBus.dispatch("updateviewarea", {
  5930. source: this,
  5931. location: this._location
  5932. });
  5933. }
  5934. }, {
  5935. key: "containsElement",
  5936. value: function containsElement(element) {
  5937. return this.container.contains(element);
  5938. }
  5939. }, {
  5940. key: "focus",
  5941. value: function focus() {
  5942. this.container.focus();
  5943. }
  5944. }, {
  5945. key: "_getCurrentVisiblePage",
  5946. value: function _getCurrentVisiblePage() {
  5947. if (!this.pagesCount) {
  5948. return {
  5949. views: []
  5950. };
  5951. }
  5952. var pageView = this._pages[this._currentPageNumber - 1];
  5953. var element = pageView.div;
  5954. var view = {
  5955. id: pageView.id,
  5956. x: element.offsetLeft + element.clientLeft,
  5957. y: element.offsetTop + element.clientTop,
  5958. view: pageView
  5959. };
  5960. return {
  5961. first: view,
  5962. last: view,
  5963. views: [view]
  5964. };
  5965. }
  5966. }, {
  5967. key: "_getVisiblePages",
  5968. value: function _getVisiblePages() {
  5969. return (0, _ui_utils.getVisibleElements)(this.container, this._pages, true, this._isScrollModeHorizontal);
  5970. }
  5971. }, {
  5972. key: "isPageVisible",
  5973. value: function isPageVisible(pageNumber) {
  5974. if (!this.pdfDocument) {
  5975. return false;
  5976. }
  5977. if (pageNumber < 1 || pageNumber > this.pagesCount) {
  5978. console.error("".concat(this._name, ".isPageVisible: \"").concat(pageNumber, "\" is out of bounds."));
  5979. return false;
  5980. }
  5981. return this._getVisiblePages().views.some(function (view) {
  5982. return view.id === pageNumber;
  5983. });
  5984. }
  5985. }, {
  5986. key: "cleanup",
  5987. value: function cleanup() {
  5988. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  5989. if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  5990. this._pages[i].reset();
  5991. }
  5992. }
  5993. }
  5994. }, {
  5995. key: "_cancelRendering",
  5996. value: function _cancelRendering() {
  5997. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  5998. if (this._pages[i]) {
  5999. this._pages[i].cancelRendering();
  6000. }
  6001. }
  6002. }
  6003. }, {
  6004. key: "_ensurePdfPageLoaded",
  6005. value: function _ensurePdfPageLoaded(pageView) {
  6006. var _this3 = this;
  6007. if (pageView.pdfPage) {
  6008. return Promise.resolve(pageView.pdfPage);
  6009. }
  6010. if (this._pagesRequests.has(pageView)) {
  6011. return this._pagesRequests.get(pageView);
  6012. }
  6013. var promise = this.pdfDocument.getPage(pageView.id).then(function (pdfPage) {
  6014. if (!pageView.pdfPage) {
  6015. pageView.setPdfPage(pdfPage);
  6016. }
  6017. _this3._pagesRequests["delete"](pageView);
  6018. return pdfPage;
  6019. })["catch"](function (reason) {
  6020. console.error("Unable to get page for page view", reason);
  6021. _this3._pagesRequests["delete"](pageView);
  6022. });
  6023. this._pagesRequests.set(pageView, promise);
  6024. return promise;
  6025. }
  6026. }, {
  6027. key: "forceRendering",
  6028. value: function forceRendering(currentlyVisiblePages) {
  6029. var _this4 = this;
  6030. var visiblePages = currentlyVisiblePages || this._getVisiblePages();
  6031. var scrollAhead = this._isScrollModeHorizontal ? this.scroll.right : this.scroll.down;
  6032. var pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead);
  6033. if (pageView) {
  6034. this._ensurePdfPageLoaded(pageView).then(function () {
  6035. _this4.renderingQueue.renderView(pageView);
  6036. });
  6037. return true;
  6038. }
  6039. return false;
  6040. }
  6041. }, {
  6042. key: "createTextLayerBuilder",
  6043. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  6044. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  6045. var eventBus = arguments.length > 4 ? arguments[4] : undefined;
  6046. return new _text_layer_builder.TextLayerBuilder({
  6047. textLayerDiv: textLayerDiv,
  6048. eventBus: eventBus,
  6049. pageIndex: pageIndex,
  6050. viewport: viewport,
  6051. findController: this.isInPresentationMode ? null : this.findController,
  6052. enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection
  6053. });
  6054. }
  6055. }, {
  6056. key: "createAnnotationLayerBuilder",
  6057. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  6058. var annotationStorage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  6059. var imageResourcesPath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "";
  6060. var renderInteractiveForms = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  6061. var l10n = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : _ui_utils.NullL10n;
  6062. return new _annotation_layer_builder.AnnotationLayerBuilder({
  6063. pageDiv: pageDiv,
  6064. pdfPage: pdfPage,
  6065. annotationStorage: annotationStorage,
  6066. imageResourcesPath: imageResourcesPath,
  6067. renderInteractiveForms: renderInteractiveForms,
  6068. linkService: this.linkService,
  6069. downloadManager: this.downloadManager,
  6070. l10n: l10n
  6071. });
  6072. }
  6073. }, {
  6074. key: "getPagesOverview",
  6075. value: function getPagesOverview() {
  6076. var pagesOverview = this._pages.map(function (pageView) {
  6077. var viewport = pageView.pdfPage.getViewport({
  6078. scale: 1
  6079. });
  6080. return {
  6081. width: viewport.width,
  6082. height: viewport.height,
  6083. rotation: viewport.rotation
  6084. };
  6085. });
  6086. if (!this.enablePrintAutoRotate) {
  6087. return pagesOverview;
  6088. }
  6089. return pagesOverview.map(function (size) {
  6090. if ((0, _ui_utils.isPortraitOrientation)(size)) {
  6091. return size;
  6092. }
  6093. return {
  6094. width: size.height,
  6095. height: size.width,
  6096. rotation: (size.rotation + 90) % 360
  6097. };
  6098. });
  6099. }
  6100. }, {
  6101. key: "_updateScrollMode",
  6102. value: function _updateScrollMode() {
  6103. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  6104. var scrollMode = this._scrollMode,
  6105. viewer = this.viewer;
  6106. viewer.classList.toggle("scrollHorizontal", scrollMode === _ui_utils.ScrollMode.HORIZONTAL);
  6107. viewer.classList.toggle("scrollWrapped", scrollMode === _ui_utils.ScrollMode.WRAPPED);
  6108. if (!this.pdfDocument || !pageNumber) {
  6109. return;
  6110. }
  6111. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  6112. this._setScale(this._currentScaleValue, true);
  6113. }
  6114. this._setCurrentPageNumber(pageNumber, true);
  6115. this.update();
  6116. }
  6117. }, {
  6118. key: "_updateSpreadMode",
  6119. value: function _updateSpreadMode() {
  6120. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  6121. if (!this.pdfDocument) {
  6122. return;
  6123. }
  6124. var viewer = this.viewer,
  6125. pages = this._pages;
  6126. viewer.textContent = "";
  6127. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  6128. for (var i = 0, iMax = pages.length; i < iMax; ++i) {
  6129. viewer.appendChild(pages[i].div);
  6130. }
  6131. } else {
  6132. var parity = this._spreadMode - 1;
  6133. var spread = null;
  6134. for (var _i = 0, _iMax = pages.length; _i < _iMax; ++_i) {
  6135. if (spread === null) {
  6136. spread = document.createElement("div");
  6137. spread.className = "spread";
  6138. viewer.appendChild(spread);
  6139. } else if (_i % 2 === parity) {
  6140. spread = spread.cloneNode(false);
  6141. viewer.appendChild(spread);
  6142. }
  6143. spread.appendChild(pages[_i].div);
  6144. }
  6145. }
  6146. if (!pageNumber) {
  6147. return;
  6148. }
  6149. this._setCurrentPageNumber(pageNumber, true);
  6150. this.update();
  6151. }
  6152. }, {
  6153. key: "pagesCount",
  6154. get: function get() {
  6155. return this._pages.length;
  6156. }
  6157. }, {
  6158. key: "pageViewsReady",
  6159. get: function get() {
  6160. if (!this._pagesCapability.settled) {
  6161. return false;
  6162. }
  6163. return this._pages.every(function (pageView) {
  6164. return pageView && pageView.pdfPage;
  6165. });
  6166. }
  6167. }, {
  6168. key: "currentPageNumber",
  6169. get: function get() {
  6170. return this._currentPageNumber;
  6171. },
  6172. set: function set(val) {
  6173. if (!Number.isInteger(val)) {
  6174. throw new Error("Invalid page number.");
  6175. }
  6176. if (!this.pdfDocument) {
  6177. return;
  6178. }
  6179. if (!this._setCurrentPageNumber(val, true)) {
  6180. console.error("".concat(this._name, ".currentPageNumber: \"").concat(val, "\" is not a valid page."));
  6181. }
  6182. }
  6183. }, {
  6184. key: "currentPageLabel",
  6185. get: function get() {
  6186. return this._pageLabels && this._pageLabels[this._currentPageNumber - 1];
  6187. },
  6188. set: function set(val) {
  6189. if (!this.pdfDocument) {
  6190. return;
  6191. }
  6192. var page = val | 0;
  6193. if (this._pageLabels) {
  6194. var i = this._pageLabels.indexOf(val);
  6195. if (i >= 0) {
  6196. page = i + 1;
  6197. }
  6198. }
  6199. if (!this._setCurrentPageNumber(page, true)) {
  6200. console.error("".concat(this._name, ".currentPageLabel: \"").concat(val, "\" is not a valid page."));
  6201. }
  6202. }
  6203. }, {
  6204. key: "currentScale",
  6205. get: function get() {
  6206. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
  6207. },
  6208. set: function set(val) {
  6209. if (isNaN(val)) {
  6210. throw new Error("Invalid numeric scale.");
  6211. }
  6212. if (!this.pdfDocument) {
  6213. return;
  6214. }
  6215. this._setScale(val, false);
  6216. }
  6217. }, {
  6218. key: "currentScaleValue",
  6219. get: function get() {
  6220. return this._currentScaleValue;
  6221. },
  6222. set: function set(val) {
  6223. if (!this.pdfDocument) {
  6224. return;
  6225. }
  6226. this._setScale(val, false);
  6227. }
  6228. }, {
  6229. key: "pagesRotation",
  6230. get: function get() {
  6231. return this._pagesRotation;
  6232. },
  6233. set: function set(rotation) {
  6234. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  6235. throw new Error("Invalid pages rotation angle.");
  6236. }
  6237. if (!this.pdfDocument) {
  6238. return;
  6239. }
  6240. if (this._pagesRotation === rotation) {
  6241. return;
  6242. }
  6243. this._pagesRotation = rotation;
  6244. var pageNumber = this._currentPageNumber;
  6245. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  6246. var pageView = this._pages[i];
  6247. pageView.update(pageView.scale, rotation);
  6248. }
  6249. if (this._currentScaleValue) {
  6250. this._setScale(this._currentScaleValue, true);
  6251. }
  6252. this.eventBus.dispatch("rotationchanging", {
  6253. source: this,
  6254. pagesRotation: rotation,
  6255. pageNumber: pageNumber
  6256. });
  6257. if (this.defaultRenderingQueue) {
  6258. this.update();
  6259. }
  6260. }
  6261. }, {
  6262. key: "firstPagePromise",
  6263. get: function get() {
  6264. return this.pdfDocument ? this._firstPageCapability.promise : null;
  6265. }
  6266. }, {
  6267. key: "onePageRendered",
  6268. get: function get() {
  6269. return this.pdfDocument ? this._onePageRenderedCapability.promise : null;
  6270. }
  6271. }, {
  6272. key: "pagesPromise",
  6273. get: function get() {
  6274. return this.pdfDocument ? this._pagesCapability.promise : null;
  6275. }
  6276. }, {
  6277. key: "_viewerElement",
  6278. get: function get() {
  6279. throw new Error("Not implemented: _viewerElement");
  6280. }
  6281. }, {
  6282. key: "_isScrollModeHorizontal",
  6283. get: function get() {
  6284. return this.isInPresentationMode ? false : this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL;
  6285. }
  6286. }, {
  6287. key: "isInPresentationMode",
  6288. get: function get() {
  6289. return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
  6290. }
  6291. }, {
  6292. key: "isChangingPresentationMode",
  6293. get: function get() {
  6294. return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
  6295. }
  6296. }, {
  6297. key: "isHorizontalScrollbarEnabled",
  6298. get: function get() {
  6299. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  6300. }
  6301. }, {
  6302. key: "isVerticalScrollbarEnabled",
  6303. get: function get() {
  6304. return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight;
  6305. }
  6306. }, {
  6307. key: "hasEqualPageSizes",
  6308. get: function get() {
  6309. var firstPageView = this._pages[0];
  6310. for (var i = 1, ii = this._pages.length; i < ii; ++i) {
  6311. var pageView = this._pages[i];
  6312. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  6313. return false;
  6314. }
  6315. }
  6316. return true;
  6317. }
  6318. }, {
  6319. key: "optionalContentConfigPromise",
  6320. get: function get() {
  6321. if (!this.pdfDocument) {
  6322. return Promise.resolve(null);
  6323. }
  6324. if (!this._optionalContentConfigPromise) {
  6325. return this.pdfDocument.getOptionalContentConfig();
  6326. }
  6327. return this._optionalContentConfigPromise;
  6328. },
  6329. set: function set(promise) {
  6330. if (!(promise instanceof Promise)) {
  6331. throw new Error("Invalid optionalContentConfigPromise: ".concat(promise));
  6332. }
  6333. if (!this.pdfDocument) {
  6334. return;
  6335. }
  6336. if (!this._optionalContentConfigPromise) {
  6337. return;
  6338. }
  6339. this._optionalContentConfigPromise = promise;
  6340. var _iterator = _createForOfIteratorHelper(this._pages),
  6341. _step;
  6342. try {
  6343. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  6344. var pageView = _step.value;
  6345. pageView.update(pageView.scale, pageView.rotation, promise);
  6346. }
  6347. } catch (err) {
  6348. _iterator.e(err);
  6349. } finally {
  6350. _iterator.f();
  6351. }
  6352. this.update();
  6353. this.eventBus.dispatch("optionalcontentconfigchanged", {
  6354. source: this,
  6355. promise: promise
  6356. });
  6357. }
  6358. }, {
  6359. key: "scrollMode",
  6360. get: function get() {
  6361. return this._scrollMode;
  6362. },
  6363. set: function set(mode) {
  6364. if (this._scrollMode === mode) {
  6365. return;
  6366. }
  6367. if (!(0, _ui_utils.isValidScrollMode)(mode)) {
  6368. throw new Error("Invalid scroll mode: ".concat(mode));
  6369. }
  6370. this._scrollMode = mode;
  6371. this.eventBus.dispatch("scrollmodechanged", {
  6372. source: this,
  6373. mode: mode
  6374. });
  6375. this._updateScrollMode(this._currentPageNumber);
  6376. }
  6377. }, {
  6378. key: "spreadMode",
  6379. get: function get() {
  6380. return this._spreadMode;
  6381. },
  6382. set: function set(mode) {
  6383. if (this._spreadMode === mode) {
  6384. return;
  6385. }
  6386. if (!(0, _ui_utils.isValidSpreadMode)(mode)) {
  6387. throw new Error("Invalid spread mode: ".concat(mode));
  6388. }
  6389. this._spreadMode = mode;
  6390. this.eventBus.dispatch("spreadmodechanged", {
  6391. source: this,
  6392. mode: mode
  6393. });
  6394. this._updateSpreadMode(this._currentPageNumber);
  6395. }
  6396. }]);
  6397. return BaseViewer;
  6398. }();
  6399. exports.BaseViewer = BaseViewer;
  6400. /***/ }),
  6401. /* 20 */
  6402. /***/ (function(module, exports, __w_pdfjs_require__) {
  6403. "use strict";
  6404. Object.defineProperty(exports, "__esModule", {
  6405. value: true
  6406. });
  6407. exports.PDFViewer = void 0;
  6408. var _base_viewer = __w_pdfjs_require__(19);
  6409. var _pdfjsLib = __w_pdfjs_require__(2);
  6410. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  6411. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  6412. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  6413. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  6414. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6415. 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); } }
  6416. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6417. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  6418. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  6419. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  6420. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  6421. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  6422. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  6423. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  6424. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  6425. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  6426. var PDFViewer = /*#__PURE__*/function (_BaseViewer) {
  6427. _inherits(PDFViewer, _BaseViewer);
  6428. var _super = _createSuper(PDFViewer);
  6429. function PDFViewer() {
  6430. _classCallCheck(this, PDFViewer);
  6431. return _super.apply(this, arguments);
  6432. }
  6433. _createClass(PDFViewer, [{
  6434. key: "_scrollIntoView",
  6435. value: function _scrollIntoView(_ref) {
  6436. var pageDiv = _ref.pageDiv,
  6437. _ref$pageSpot = _ref.pageSpot,
  6438. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  6439. _ref$pageNumber = _ref.pageNumber,
  6440. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  6441. if (!pageSpot && !this.isInPresentationMode) {
  6442. var left = pageDiv.offsetLeft + pageDiv.clientLeft;
  6443. var right = left + pageDiv.clientWidth;
  6444. var _this$container = this.container,
  6445. scrollLeft = _this$container.scrollLeft,
  6446. clientWidth = _this$container.clientWidth;
  6447. if (this._isScrollModeHorizontal || left < scrollLeft || right > scrollLeft + clientWidth) {
  6448. pageSpot = {
  6449. left: 0,
  6450. top: 0
  6451. };
  6452. }
  6453. }
  6454. _get(_getPrototypeOf(PDFViewer.prototype), "_scrollIntoView", this).call(this, {
  6455. pageDiv: pageDiv,
  6456. pageSpot: pageSpot,
  6457. pageNumber: pageNumber
  6458. });
  6459. }
  6460. }, {
  6461. key: "_getVisiblePages",
  6462. value: function _getVisiblePages() {
  6463. if (this.isInPresentationMode) {
  6464. return this._getCurrentVisiblePage();
  6465. }
  6466. return _get(_getPrototypeOf(PDFViewer.prototype), "_getVisiblePages", this).call(this);
  6467. }
  6468. }, {
  6469. key: "_updateHelper",
  6470. value: function _updateHelper(visiblePages) {
  6471. if (this.isInPresentationMode) {
  6472. return;
  6473. }
  6474. var currentId = this._currentPageNumber;
  6475. var stillFullyVisible = false;
  6476. var _iterator = _createForOfIteratorHelper(visiblePages),
  6477. _step;
  6478. try {
  6479. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  6480. var page = _step.value;
  6481. if (page.percent < 100) {
  6482. break;
  6483. }
  6484. if (page.id === currentId) {
  6485. stillFullyVisible = true;
  6486. break;
  6487. }
  6488. }
  6489. } catch (err) {
  6490. _iterator.e(err);
  6491. } finally {
  6492. _iterator.f();
  6493. }
  6494. if (!stillFullyVisible) {
  6495. currentId = visiblePages[0].id;
  6496. }
  6497. this._setCurrentPageNumber(currentId);
  6498. }
  6499. }, {
  6500. key: "_viewerElement",
  6501. get: function get() {
  6502. return (0, _pdfjsLib.shadow)(this, "_viewerElement", this.viewer);
  6503. }
  6504. }]);
  6505. return PDFViewer;
  6506. }(_base_viewer.BaseViewer);
  6507. exports.PDFViewer = PDFViewer;
  6508. /***/ })
  6509. /******/ ]);
  6510. });
  6511. //# sourceMappingURL=pdf_viewer.js.map