pdf_viewer.js 157 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440
  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 () {
  128. return _annotation_layer_builder.AnnotationLayerBuilder;
  129. }
  130. });
  131. Object.defineProperty(exports, "DefaultAnnotationLayerFactory", {
  132. enumerable: true,
  133. get: function () {
  134. return _annotation_layer_builder.DefaultAnnotationLayerFactory;
  135. }
  136. });
  137. Object.defineProperty(exports, "DefaultTextLayerFactory", {
  138. enumerable: true,
  139. get: function () {
  140. return _text_layer_builder.DefaultTextLayerFactory;
  141. }
  142. });
  143. Object.defineProperty(exports, "TextLayerBuilder", {
  144. enumerable: true,
  145. get: function () {
  146. return _text_layer_builder.TextLayerBuilder;
  147. }
  148. });
  149. Object.defineProperty(exports, "EventBus", {
  150. enumerable: true,
  151. get: function () {
  152. return _ui_utils.EventBus;
  153. }
  154. });
  155. Object.defineProperty(exports, "NullL10n", {
  156. enumerable: true,
  157. get: function () {
  158. return _ui_utils.NullL10n;
  159. }
  160. });
  161. Object.defineProperty(exports, "ProgressBar", {
  162. enumerable: true,
  163. get: function () {
  164. return _ui_utils.ProgressBar;
  165. }
  166. });
  167. Object.defineProperty(exports, "PDFLinkService", {
  168. enumerable: true,
  169. get: function () {
  170. return _pdf_link_service.PDFLinkService;
  171. }
  172. });
  173. Object.defineProperty(exports, "SimpleLinkService", {
  174. enumerable: true,
  175. get: function () {
  176. return _pdf_link_service.SimpleLinkService;
  177. }
  178. });
  179. Object.defineProperty(exports, "DownloadManager", {
  180. enumerable: true,
  181. get: function () {
  182. return _download_manager.DownloadManager;
  183. }
  184. });
  185. Object.defineProperty(exports, "GenericL10n", {
  186. enumerable: true,
  187. get: function () {
  188. return _genericl10n.GenericL10n;
  189. }
  190. });
  191. Object.defineProperty(exports, "PDFFindController", {
  192. enumerable: true,
  193. get: function () {
  194. return _pdf_find_controller.PDFFindController;
  195. }
  196. });
  197. Object.defineProperty(exports, "PDFHistory", {
  198. enumerable: true,
  199. get: function () {
  200. return _pdf_history.PDFHistory;
  201. }
  202. });
  203. Object.defineProperty(exports, "PDFPageView", {
  204. enumerable: true,
  205. get: function () {
  206. return _pdf_page_view.PDFPageView;
  207. }
  208. });
  209. Object.defineProperty(exports, "PDFSinglePageViewer", {
  210. enumerable: true,
  211. get: function () {
  212. return _pdf_single_page_viewer.PDFSinglePageViewer;
  213. }
  214. });
  215. Object.defineProperty(exports, "PDFViewer", {
  216. enumerable: true,
  217. get: function () {
  218. return _pdf_viewer.PDFViewer;
  219. }
  220. });
  221. var _annotation_layer_builder = __w_pdfjs_require__(1);
  222. var _text_layer_builder = __w_pdfjs_require__(5);
  223. var _ui_utils = __w_pdfjs_require__(3);
  224. var _pdf_link_service = __w_pdfjs_require__(4);
  225. var _download_manager = __w_pdfjs_require__(6);
  226. var _genericl10n = __w_pdfjs_require__(8);
  227. var _pdf_find_controller = __w_pdfjs_require__(10);
  228. var _pdf_history = __w_pdfjs_require__(12);
  229. var _pdf_page_view = __w_pdfjs_require__(13);
  230. var _pdf_single_page_viewer = __w_pdfjs_require__(15);
  231. var _pdf_viewer = __w_pdfjs_require__(17);
  232. const pdfjsVersion = '2.6.347';
  233. const 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__(4);
  245. class AnnotationLayerBuilder {
  246. constructor({
  247. pageDiv,
  248. pdfPage,
  249. linkService,
  250. downloadManager,
  251. annotationStorage = null,
  252. imageResourcesPath = "",
  253. renderInteractiveForms = true,
  254. l10n = _ui_utils.NullL10n
  255. }) {
  256. this.pageDiv = pageDiv;
  257. this.pdfPage = pdfPage;
  258. this.linkService = linkService;
  259. this.downloadManager = downloadManager;
  260. this.imageResourcesPath = imageResourcesPath;
  261. this.renderInteractiveForms = renderInteractiveForms;
  262. this.l10n = l10n;
  263. this.annotationStorage = annotationStorage;
  264. this.div = null;
  265. this._cancelled = false;
  266. }
  267. render(viewport, intent = "display") {
  268. return this.pdfPage.getAnnotations({
  269. intent
  270. }).then(annotations => {
  271. if (this._cancelled) {
  272. return;
  273. }
  274. if (annotations.length === 0) {
  275. return;
  276. }
  277. const parameters = {
  278. viewport: viewport.clone({
  279. dontFlip: true
  280. }),
  281. div: this.div,
  282. annotations,
  283. page: this.pdfPage,
  284. imageResourcesPath: this.imageResourcesPath,
  285. renderInteractiveForms: this.renderInteractiveForms,
  286. linkService: this.linkService,
  287. downloadManager: this.downloadManager,
  288. annotationStorage: this.annotationStorage
  289. };
  290. if (this.div) {
  291. _pdfjsLib.AnnotationLayer.update(parameters);
  292. } else {
  293. this.div = document.createElement("div");
  294. this.div.className = "annotationLayer";
  295. this.pageDiv.appendChild(this.div);
  296. parameters.div = this.div;
  297. _pdfjsLib.AnnotationLayer.render(parameters);
  298. this.l10n.translate(this.div);
  299. }
  300. });
  301. }
  302. cancel() {
  303. this._cancelled = true;
  304. }
  305. hide() {
  306. if (!this.div) {
  307. return;
  308. }
  309. this.div.setAttribute("hidden", "true");
  310. }
  311. }
  312. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  313. class DefaultAnnotationLayerFactory {
  314. createAnnotationLayerBuilder(pageDiv, pdfPage, annotationStorage = null, imageResourcesPath = "", renderInteractiveForms = true, l10n = _ui_utils.NullL10n) {
  315. return new AnnotationLayerBuilder({
  316. pageDiv,
  317. pdfPage,
  318. imageResourcesPath,
  319. renderInteractiveForms,
  320. linkService: new _pdf_link_service.SimpleLinkService(),
  321. l10n,
  322. annotationStorage
  323. });
  324. }
  325. }
  326. exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
  327. /***/ }),
  328. /* 2 */
  329. /***/ (function(module, exports, __w_pdfjs_require__) {
  330. "use strict";
  331. let pdfjsLib;
  332. if (typeof window !== "undefined" && window["pdfjs-dist/build/pdf"]) {
  333. pdfjsLib = window["pdfjs-dist/build/pdf"];
  334. } else {
  335. pdfjsLib = require("../build/pdf.js");
  336. }
  337. module.exports = pdfjsLib;
  338. /***/ }),
  339. /* 3 */
  340. /***/ (function(module, exports, __w_pdfjs_require__) {
  341. "use strict";
  342. Object.defineProperty(exports, "__esModule", {
  343. value: true
  344. });
  345. exports.isValidRotation = isValidRotation;
  346. exports.isValidScrollMode = isValidScrollMode;
  347. exports.isValidSpreadMode = isValidSpreadMode;
  348. exports.isPortraitOrientation = isPortraitOrientation;
  349. exports.clamp = clamp;
  350. exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
  351. exports.noContextMenuHandler = noContextMenuHandler;
  352. exports.parseQueryString = parseQueryString;
  353. exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
  354. exports.getVisibleElements = getVisibleElements;
  355. exports.roundToDivide = roundToDivide;
  356. exports.getPageSizeInches = getPageSizeInches;
  357. exports.approximateFraction = approximateFraction;
  358. exports.getOutputScale = getOutputScale;
  359. exports.scrollIntoView = scrollIntoView;
  360. exports.watchScroll = watchScroll;
  361. exports.binarySearchFirstItem = binarySearchFirstItem;
  362. exports.normalizeWheelEventDirection = normalizeWheelEventDirection;
  363. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  364. exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
  365. exports.moveToEndOfArray = moveToEndOfArray;
  366. 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;
  367. const CSS_UNITS = 96.0 / 72.0;
  368. exports.CSS_UNITS = CSS_UNITS;
  369. const DEFAULT_SCALE_VALUE = "auto";
  370. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  371. const DEFAULT_SCALE = 1.0;
  372. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  373. const MIN_SCALE = 0.1;
  374. exports.MIN_SCALE = MIN_SCALE;
  375. const MAX_SCALE = 10.0;
  376. exports.MAX_SCALE = MAX_SCALE;
  377. const UNKNOWN_SCALE = 0;
  378. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  379. const MAX_AUTO_SCALE = 1.25;
  380. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  381. const SCROLLBAR_PADDING = 40;
  382. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  383. const VERTICAL_PADDING = 5;
  384. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  385. const PresentationModeState = {
  386. UNKNOWN: 0,
  387. NORMAL: 1,
  388. CHANGING: 2,
  389. FULLSCREEN: 3
  390. };
  391. exports.PresentationModeState = PresentationModeState;
  392. const RendererType = {
  393. CANVAS: "canvas",
  394. SVG: "svg"
  395. };
  396. exports.RendererType = RendererType;
  397. const TextLayerMode = {
  398. DISABLE: 0,
  399. ENABLE: 1,
  400. ENABLE_ENHANCE: 2
  401. };
  402. exports.TextLayerMode = TextLayerMode;
  403. const ScrollMode = {
  404. UNKNOWN: -1,
  405. VERTICAL: 0,
  406. HORIZONTAL: 1,
  407. WRAPPED: 2
  408. };
  409. exports.ScrollMode = ScrollMode;
  410. const SpreadMode = {
  411. UNKNOWN: -1,
  412. NONE: 0,
  413. ODD: 1,
  414. EVEN: 2
  415. };
  416. exports.SpreadMode = SpreadMode;
  417. const AutoPrintRegExp = /\bprint\s*\(/;
  418. exports.AutoPrintRegExp = AutoPrintRegExp;
  419. function formatL10nValue(text, args) {
  420. if (!args) {
  421. return text;
  422. }
  423. return text.replace(/\{\{\s*(\w+)\s*\}\}/g, (all, name) => {
  424. return name in args ? args[name] : "{{" + name + "}}";
  425. });
  426. }
  427. const NullL10n = {
  428. async getLanguage() {
  429. return "en-us";
  430. },
  431. async getDirection() {
  432. return "ltr";
  433. },
  434. async get(property, args, fallback) {
  435. return formatL10nValue(fallback, args);
  436. },
  437. async translate(element) {}
  438. };
  439. exports.NullL10n = NullL10n;
  440. function getOutputScale(ctx) {
  441. const devicePixelRatio = window.devicePixelRatio || 1;
  442. const backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
  443. const pixelRatio = devicePixelRatio / backingStoreRatio;
  444. return {
  445. sx: pixelRatio,
  446. sy: pixelRatio,
  447. scaled: pixelRatio !== 1
  448. };
  449. }
  450. function scrollIntoView(element, spot, skipOverflowHiddenElements = false) {
  451. let parent = element.offsetParent;
  452. if (!parent) {
  453. console.error("offsetParent is not set -- cannot scroll");
  454. return;
  455. }
  456. let offsetY = element.offsetTop + element.clientTop;
  457. let offsetX = element.offsetLeft + element.clientLeft;
  458. while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || skipOverflowHiddenElements && getComputedStyle(parent).overflow === "hidden") {
  459. if (parent.dataset._scaleY) {
  460. offsetY /= parent.dataset._scaleY;
  461. offsetX /= parent.dataset._scaleX;
  462. }
  463. offsetY += parent.offsetTop;
  464. offsetX += parent.offsetLeft;
  465. parent = parent.offsetParent;
  466. if (!parent) {
  467. return;
  468. }
  469. }
  470. if (spot) {
  471. if (spot.top !== undefined) {
  472. offsetY += spot.top;
  473. }
  474. if (spot.left !== undefined) {
  475. offsetX += spot.left;
  476. parent.scrollLeft = offsetX;
  477. }
  478. }
  479. parent.scrollTop = offsetY;
  480. }
  481. function watchScroll(viewAreaElement, callback) {
  482. const debounceScroll = function (evt) {
  483. if (rAF) {
  484. return;
  485. }
  486. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  487. rAF = null;
  488. const currentX = viewAreaElement.scrollLeft;
  489. const lastX = state.lastX;
  490. if (currentX !== lastX) {
  491. state.right = currentX > lastX;
  492. }
  493. state.lastX = currentX;
  494. const currentY = viewAreaElement.scrollTop;
  495. const lastY = state.lastY;
  496. if (currentY !== lastY) {
  497. state.down = currentY > lastY;
  498. }
  499. state.lastY = currentY;
  500. callback(state);
  501. });
  502. };
  503. const state = {
  504. right: true,
  505. down: true,
  506. lastX: viewAreaElement.scrollLeft,
  507. lastY: viewAreaElement.scrollTop,
  508. _eventHandler: debounceScroll
  509. };
  510. let rAF = null;
  511. viewAreaElement.addEventListener("scroll", debounceScroll, true);
  512. return state;
  513. }
  514. function parseQueryString(query) {
  515. const parts = query.split("&");
  516. const params = Object.create(null);
  517. for (let i = 0, ii = parts.length; i < ii; ++i) {
  518. const param = parts[i].split("=");
  519. const key = param[0].toLowerCase();
  520. const value = param.length > 1 ? param[1] : null;
  521. params[decodeURIComponent(key)] = decodeURIComponent(value);
  522. }
  523. return params;
  524. }
  525. function binarySearchFirstItem(items, condition) {
  526. let minIndex = 0;
  527. let maxIndex = items.length - 1;
  528. if (maxIndex < 0 || !condition(items[maxIndex])) {
  529. return items.length;
  530. }
  531. if (condition(items[minIndex])) {
  532. return minIndex;
  533. }
  534. while (minIndex < maxIndex) {
  535. const currentIndex = minIndex + maxIndex >> 1;
  536. const currentItem = items[currentIndex];
  537. if (condition(currentItem)) {
  538. maxIndex = currentIndex;
  539. } else {
  540. minIndex = currentIndex + 1;
  541. }
  542. }
  543. return minIndex;
  544. }
  545. function approximateFraction(x) {
  546. if (Math.floor(x) === x) {
  547. return [x, 1];
  548. }
  549. const xinv = 1 / x;
  550. const limit = 8;
  551. if (xinv > limit) {
  552. return [1, limit];
  553. } else if (Math.floor(xinv) === xinv) {
  554. return [1, xinv];
  555. }
  556. const x_ = x > 1 ? xinv : x;
  557. let a = 0,
  558. b = 1,
  559. c = 1,
  560. d = 1;
  561. while (true) {
  562. const p = a + c,
  563. q = b + d;
  564. if (q > limit) {
  565. break;
  566. }
  567. if (x_ <= p / q) {
  568. c = p;
  569. d = q;
  570. } else {
  571. a = p;
  572. b = q;
  573. }
  574. }
  575. let result;
  576. if (x_ - a / b < c / d - x_) {
  577. result = x_ === x ? [a, b] : [b, a];
  578. } else {
  579. result = x_ === x ? [c, d] : [d, c];
  580. }
  581. return result;
  582. }
  583. function roundToDivide(x, div) {
  584. const r = x % div;
  585. return r === 0 ? x : Math.round(x - r + div);
  586. }
  587. function getPageSizeInches({
  588. view,
  589. userUnit,
  590. rotate
  591. }) {
  592. const [x1, y1, x2, y2] = view;
  593. const changeOrientation = rotate % 180 !== 0;
  594. const width = (x2 - x1) / 72 * userUnit;
  595. const height = (y2 - y1) / 72 * userUnit;
  596. return {
  597. width: changeOrientation ? height : width,
  598. height: changeOrientation ? width : height
  599. };
  600. }
  601. function backtrackBeforeAllVisibleElements(index, views, top) {
  602. if (index < 2) {
  603. return index;
  604. }
  605. let elt = views[index].div;
  606. let pageTop = elt.offsetTop + elt.clientTop;
  607. if (pageTop >= top) {
  608. elt = views[index - 1].div;
  609. pageTop = elt.offsetTop + elt.clientTop;
  610. }
  611. for (let i = index - 2; i >= 0; --i) {
  612. elt = views[i].div;
  613. if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
  614. break;
  615. }
  616. index = i;
  617. }
  618. return index;
  619. }
  620. function getVisibleElements(scrollEl, views, sortByVisibility = false, horizontal = false) {
  621. const top = scrollEl.scrollTop,
  622. bottom = top + scrollEl.clientHeight;
  623. const left = scrollEl.scrollLeft,
  624. right = left + scrollEl.clientWidth;
  625. function isElementBottomAfterViewTop(view) {
  626. const element = view.div;
  627. const elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  628. return elementBottom > top;
  629. }
  630. function isElementRightAfterViewLeft(view) {
  631. const element = view.div;
  632. const elementRight = element.offsetLeft + element.clientLeft + element.clientWidth;
  633. return elementRight > left;
  634. }
  635. const visible = [],
  636. numViews = views.length;
  637. let firstVisibleElementInd = numViews === 0 ? 0 : binarySearchFirstItem(views, horizontal ? isElementRightAfterViewLeft : isElementBottomAfterViewTop);
  638. if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
  639. firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
  640. }
  641. let lastEdge = horizontal ? right : -1;
  642. for (let i = firstVisibleElementInd; i < numViews; i++) {
  643. const view = views[i],
  644. element = view.div;
  645. const currentWidth = element.offsetLeft + element.clientLeft;
  646. const currentHeight = element.offsetTop + element.clientTop;
  647. const viewWidth = element.clientWidth,
  648. viewHeight = element.clientHeight;
  649. const viewRight = currentWidth + viewWidth;
  650. const viewBottom = currentHeight + viewHeight;
  651. if (lastEdge === -1) {
  652. if (viewBottom >= bottom) {
  653. lastEdge = viewBottom;
  654. }
  655. } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
  656. break;
  657. }
  658. if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) {
  659. continue;
  660. }
  661. const hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
  662. const hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
  663. const percent = (viewHeight - hiddenHeight) * (viewWidth - hiddenWidth) * 100 / viewHeight / viewWidth | 0;
  664. visible.push({
  665. id: view.id,
  666. x: currentWidth,
  667. y: currentHeight,
  668. view,
  669. percent
  670. });
  671. }
  672. const first = visible[0],
  673. last = visible[visible.length - 1];
  674. if (sortByVisibility) {
  675. visible.sort(function (a, b) {
  676. const pc = a.percent - b.percent;
  677. if (Math.abs(pc) > 0.001) {
  678. return -pc;
  679. }
  680. return a.id - b.id;
  681. });
  682. }
  683. return {
  684. first,
  685. last,
  686. views: visible
  687. };
  688. }
  689. function noContextMenuHandler(evt) {
  690. evt.preventDefault();
  691. }
  692. function isDataSchema(url) {
  693. let i = 0;
  694. const ii = url.length;
  695. while (i < ii && url[i].trim() === "") {
  696. i++;
  697. }
  698. return url.substring(i, i + 5).toLowerCase() === "data:";
  699. }
  700. function getPDFFileNameFromURL(url, defaultFilename = "document.pdf") {
  701. if (typeof url !== "string") {
  702. return defaultFilename;
  703. }
  704. if (isDataSchema(url)) {
  705. console.warn("getPDFFileNameFromURL: " + 'ignoring "data:" URL for performance reasons.');
  706. return defaultFilename;
  707. }
  708. const reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
  709. const reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
  710. const splitURI = reURI.exec(url);
  711. let suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
  712. if (suggestedFilename) {
  713. suggestedFilename = suggestedFilename[0];
  714. if (suggestedFilename.includes("%")) {
  715. try {
  716. suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
  717. } catch (ex) {}
  718. }
  719. }
  720. return suggestedFilename || defaultFilename;
  721. }
  722. function normalizeWheelEventDirection(evt) {
  723. let delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
  724. const angle = Math.atan2(evt.deltaY, evt.deltaX);
  725. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  726. delta = -delta;
  727. }
  728. return delta;
  729. }
  730. function normalizeWheelEventDelta(evt) {
  731. let delta = normalizeWheelEventDirection(evt);
  732. const MOUSE_DOM_DELTA_PIXEL_MODE = 0;
  733. const MOUSE_DOM_DELTA_LINE_MODE = 1;
  734. const MOUSE_PIXELS_PER_LINE = 30;
  735. const MOUSE_LINES_PER_PAGE = 30;
  736. if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
  737. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  738. } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
  739. delta /= MOUSE_LINES_PER_PAGE;
  740. }
  741. return delta;
  742. }
  743. function isValidRotation(angle) {
  744. return Number.isInteger(angle) && angle % 90 === 0;
  745. }
  746. function isValidScrollMode(mode) {
  747. return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN;
  748. }
  749. function isValidSpreadMode(mode) {
  750. return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN;
  751. }
  752. function isPortraitOrientation(size) {
  753. return size.width <= size.height;
  754. }
  755. const WaitOnType = {
  756. EVENT: "event",
  757. TIMEOUT: "timeout"
  758. };
  759. exports.WaitOnType = WaitOnType;
  760. function waitOnEventOrTimeout({
  761. target,
  762. name,
  763. delay = 0
  764. }) {
  765. return new Promise(function (resolve, reject) {
  766. if (typeof target !== "object" || !(name && typeof name === "string") || !(Number.isInteger(delay) && delay >= 0)) {
  767. throw new Error("waitOnEventOrTimeout - invalid parameters.");
  768. }
  769. function handler(type) {
  770. if (target instanceof EventBus) {
  771. target._off(name, eventHandler);
  772. } else {
  773. target.removeEventListener(name, eventHandler);
  774. }
  775. if (timeout) {
  776. clearTimeout(timeout);
  777. }
  778. resolve(type);
  779. }
  780. const eventHandler = handler.bind(null, WaitOnType.EVENT);
  781. if (target instanceof EventBus) {
  782. target._on(name, eventHandler);
  783. } else {
  784. target.addEventListener(name, eventHandler);
  785. }
  786. const timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
  787. const timeout = setTimeout(timeoutHandler, delay);
  788. });
  789. }
  790. const animationStarted = new Promise(function (resolve) {
  791. window.requestAnimationFrame(resolve);
  792. });
  793. exports.animationStarted = animationStarted;
  794. function dispatchDOMEvent(eventName, args = null) {
  795. throw new Error("Not implemented: dispatchDOMEvent");
  796. }
  797. class EventBus {
  798. constructor(options) {
  799. this._listeners = Object.create(null);
  800. }
  801. on(eventName, listener) {
  802. this._on(eventName, listener, {
  803. external: true
  804. });
  805. }
  806. off(eventName, listener) {
  807. this._off(eventName, listener, {
  808. external: true
  809. });
  810. }
  811. dispatch(eventName) {
  812. const eventListeners = this._listeners[eventName];
  813. if (!eventListeners || eventListeners.length === 0) {
  814. return;
  815. }
  816. const args = Array.prototype.slice.call(arguments, 1);
  817. let externalListeners;
  818. eventListeners.slice(0).forEach(function ({
  819. listener,
  820. external
  821. }) {
  822. if (external) {
  823. if (!externalListeners) {
  824. externalListeners = [];
  825. }
  826. externalListeners.push(listener);
  827. return;
  828. }
  829. listener.apply(null, args);
  830. });
  831. if (externalListeners) {
  832. externalListeners.forEach(function (listener) {
  833. listener.apply(null, args);
  834. });
  835. externalListeners = null;
  836. }
  837. }
  838. _on(eventName, listener, options = null) {
  839. let eventListeners = this._listeners[eventName];
  840. if (!eventListeners) {
  841. this._listeners[eventName] = eventListeners = [];
  842. }
  843. eventListeners.push({
  844. listener,
  845. external: (options && options.external) === true
  846. });
  847. }
  848. _off(eventName, listener, options = null) {
  849. const eventListeners = this._listeners[eventName];
  850. if (!eventListeners) {
  851. return;
  852. }
  853. for (let i = 0, ii = eventListeners.length; i < ii; i++) {
  854. if (eventListeners[i].listener === listener) {
  855. eventListeners.splice(i, 1);
  856. return;
  857. }
  858. }
  859. }
  860. }
  861. exports.EventBus = EventBus;
  862. function clamp(v, min, max) {
  863. return Math.min(Math.max(v, min), max);
  864. }
  865. class ProgressBar {
  866. constructor(id, {
  867. height,
  868. width,
  869. units
  870. } = {}) {
  871. this.visible = true;
  872. this.div = document.querySelector(id + " .progress");
  873. this.bar = this.div.parentNode;
  874. this.height = height || 100;
  875. this.width = width || 100;
  876. this.units = units || "%";
  877. this.div.style.height = this.height + this.units;
  878. this.percent = 0;
  879. }
  880. _updateBar() {
  881. if (this._indeterminate) {
  882. this.div.classList.add("indeterminate");
  883. this.div.style.width = this.width + this.units;
  884. return;
  885. }
  886. this.div.classList.remove("indeterminate");
  887. const progressSize = this.width * this._percent / 100;
  888. this.div.style.width = progressSize + this.units;
  889. }
  890. get percent() {
  891. return this._percent;
  892. }
  893. set percent(val) {
  894. this._indeterminate = isNaN(val);
  895. this._percent = clamp(val, 0, 100);
  896. this._updateBar();
  897. }
  898. setWidth(viewer) {
  899. if (!viewer) {
  900. return;
  901. }
  902. const container = viewer.parentNode;
  903. const scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  904. if (scrollbarWidth > 0) {
  905. this.bar.style.width = `calc(100% - ${scrollbarWidth}px)`;
  906. }
  907. }
  908. hide() {
  909. if (!this.visible) {
  910. return;
  911. }
  912. this.visible = false;
  913. this.bar.classList.add("hidden");
  914. document.body.classList.remove("loadingInProgress");
  915. }
  916. show() {
  917. if (this.visible) {
  918. return;
  919. }
  920. this.visible = true;
  921. document.body.classList.add("loadingInProgress");
  922. this.bar.classList.remove("hidden");
  923. }
  924. }
  925. exports.ProgressBar = ProgressBar;
  926. function moveToEndOfArray(arr, condition) {
  927. const moved = [],
  928. len = arr.length;
  929. let write = 0;
  930. for (let read = 0; read < len; ++read) {
  931. if (condition(arr[read])) {
  932. moved.push(arr[read]);
  933. } else {
  934. arr[write] = arr[read];
  935. ++write;
  936. }
  937. }
  938. for (let read = 0; write < len; ++read, ++write) {
  939. arr[write] = moved[read];
  940. }
  941. }
  942. /***/ }),
  943. /* 4 */
  944. /***/ (function(module, exports, __w_pdfjs_require__) {
  945. "use strict";
  946. Object.defineProperty(exports, "__esModule", {
  947. value: true
  948. });
  949. exports.SimpleLinkService = exports.PDFLinkService = void 0;
  950. var _ui_utils = __w_pdfjs_require__(3);
  951. class PDFLinkService {
  952. constructor({
  953. eventBus,
  954. externalLinkTarget = null,
  955. externalLinkRel = null,
  956. externalLinkEnabled = true,
  957. ignoreDestinationZoom = false
  958. } = {}) {
  959. this.eventBus = eventBus;
  960. this.externalLinkTarget = externalLinkTarget;
  961. this.externalLinkRel = externalLinkRel;
  962. this.externalLinkEnabled = externalLinkEnabled;
  963. this._ignoreDestinationZoom = ignoreDestinationZoom;
  964. this.baseUrl = null;
  965. this.pdfDocument = null;
  966. this.pdfViewer = null;
  967. this.pdfHistory = null;
  968. this._pagesRefCache = null;
  969. }
  970. setDocument(pdfDocument, baseUrl = null) {
  971. this.baseUrl = baseUrl;
  972. this.pdfDocument = pdfDocument;
  973. this._pagesRefCache = Object.create(null);
  974. }
  975. setViewer(pdfViewer) {
  976. this.pdfViewer = pdfViewer;
  977. }
  978. setHistory(pdfHistory) {
  979. this.pdfHistory = pdfHistory;
  980. }
  981. get pagesCount() {
  982. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  983. }
  984. get page() {
  985. return this.pdfViewer.currentPageNumber;
  986. }
  987. set page(value) {
  988. this.pdfViewer.currentPageNumber = value;
  989. }
  990. get rotation() {
  991. return this.pdfViewer.pagesRotation;
  992. }
  993. set rotation(value) {
  994. this.pdfViewer.pagesRotation = value;
  995. }
  996. navigateTo(dest) {
  997. const goToDestination = ({
  998. namedDest,
  999. explicitDest
  1000. }) => {
  1001. const destRef = explicitDest[0];
  1002. let pageNumber;
  1003. if (destRef instanceof Object) {
  1004. pageNumber = this._cachedPageNumber(destRef);
  1005. if (pageNumber === null) {
  1006. this.pdfDocument.getPageIndex(destRef).then(pageIndex => {
  1007. this.cachePageRef(pageIndex + 1, destRef);
  1008. goToDestination({
  1009. namedDest,
  1010. explicitDest
  1011. });
  1012. }).catch(() => {
  1013. console.error(`PDFLinkService.navigateTo: "${destRef}" is not ` + `a valid page reference, for dest="${dest}".`);
  1014. });
  1015. return;
  1016. }
  1017. } else if (Number.isInteger(destRef)) {
  1018. pageNumber = destRef + 1;
  1019. } else {
  1020. console.error(`PDFLinkService.navigateTo: "${destRef}" is not ` + `a valid destination reference, for dest="${dest}".`);
  1021. return;
  1022. }
  1023. if (!pageNumber || pageNumber < 1 || pageNumber > this.pagesCount) {
  1024. console.error(`PDFLinkService.navigateTo: "${pageNumber}" is not ` + `a valid page number, for dest="${dest}".`);
  1025. return;
  1026. }
  1027. if (this.pdfHistory) {
  1028. this.pdfHistory.pushCurrentPosition();
  1029. this.pdfHistory.push({
  1030. namedDest,
  1031. explicitDest,
  1032. pageNumber
  1033. });
  1034. }
  1035. this.pdfViewer.scrollPageIntoView({
  1036. pageNumber,
  1037. destArray: explicitDest,
  1038. ignoreDestinationZoom: this._ignoreDestinationZoom
  1039. });
  1040. };
  1041. new Promise((resolve, reject) => {
  1042. if (typeof dest === "string") {
  1043. this.pdfDocument.getDestination(dest).then(destArray => {
  1044. resolve({
  1045. namedDest: dest,
  1046. explicitDest: destArray
  1047. });
  1048. });
  1049. return;
  1050. }
  1051. resolve({
  1052. namedDest: "",
  1053. explicitDest: dest
  1054. });
  1055. }).then(data => {
  1056. if (!Array.isArray(data.explicitDest)) {
  1057. console.error(`PDFLinkService.navigateTo: "${data.explicitDest}" is` + ` not a valid destination array, for dest="${dest}".`);
  1058. return;
  1059. }
  1060. goToDestination(data);
  1061. });
  1062. }
  1063. getDestinationHash(dest) {
  1064. if (typeof dest === "string") {
  1065. return this.getAnchorUrl("#" + escape(dest));
  1066. }
  1067. if (Array.isArray(dest)) {
  1068. const str = JSON.stringify(dest);
  1069. return this.getAnchorUrl("#" + escape(str));
  1070. }
  1071. return this.getAnchorUrl("");
  1072. }
  1073. getAnchorUrl(anchor) {
  1074. return (this.baseUrl || "") + anchor;
  1075. }
  1076. setHash(hash) {
  1077. let pageNumber, dest;
  1078. if (hash.includes("=")) {
  1079. const params = (0, _ui_utils.parseQueryString)(hash);
  1080. if ("search" in params) {
  1081. this.eventBus.dispatch("findfromurlhash", {
  1082. source: this,
  1083. query: params.search.replace(/"/g, ""),
  1084. phraseSearch: params.phrase === "true"
  1085. });
  1086. }
  1087. if ("page" in params) {
  1088. pageNumber = params.page | 0 || 1;
  1089. }
  1090. if ("zoom" in params) {
  1091. const zoomArgs = params.zoom.split(",");
  1092. const zoomArg = zoomArgs[0];
  1093. const zoomArgNumber = parseFloat(zoomArg);
  1094. if (!zoomArg.includes("Fit")) {
  1095. dest = [null, {
  1096. name: "XYZ"
  1097. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
  1098. } else {
  1099. if (zoomArg === "Fit" || zoomArg === "FitB") {
  1100. dest = [null, {
  1101. name: zoomArg
  1102. }];
  1103. } else if (zoomArg === "FitH" || zoomArg === "FitBH" || zoomArg === "FitV" || zoomArg === "FitBV") {
  1104. dest = [null, {
  1105. name: zoomArg
  1106. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  1107. } else if (zoomArg === "FitR") {
  1108. if (zoomArgs.length !== 5) {
  1109. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
  1110. } else {
  1111. dest = [null, {
  1112. name: zoomArg
  1113. }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
  1114. }
  1115. } else {
  1116. console.error(`PDFLinkService.setHash: "${zoomArg}" is not ` + "a valid zoom value.");
  1117. }
  1118. }
  1119. }
  1120. if (dest) {
  1121. this.pdfViewer.scrollPageIntoView({
  1122. pageNumber: pageNumber || this.page,
  1123. destArray: dest,
  1124. allowNegativeOffset: true
  1125. });
  1126. } else if (pageNumber) {
  1127. this.page = pageNumber;
  1128. }
  1129. if ("pagemode" in params) {
  1130. this.eventBus.dispatch("pagemode", {
  1131. source: this,
  1132. mode: params.pagemode
  1133. });
  1134. }
  1135. if ("nameddest" in params) {
  1136. this.navigateTo(params.nameddest);
  1137. }
  1138. } else {
  1139. dest = unescape(hash);
  1140. try {
  1141. dest = JSON.parse(dest);
  1142. if (!Array.isArray(dest)) {
  1143. dest = dest.toString();
  1144. }
  1145. } catch (ex) {}
  1146. if (typeof dest === "string" || isValidExplicitDestination(dest)) {
  1147. this.navigateTo(dest);
  1148. return;
  1149. }
  1150. console.error(`PDFLinkService.setHash: "${unescape(hash)}" is not ` + "a valid destination.");
  1151. }
  1152. }
  1153. executeNamedAction(action) {
  1154. switch (action) {
  1155. case "GoBack":
  1156. if (this.pdfHistory) {
  1157. this.pdfHistory.back();
  1158. }
  1159. break;
  1160. case "GoForward":
  1161. if (this.pdfHistory) {
  1162. this.pdfHistory.forward();
  1163. }
  1164. break;
  1165. case "NextPage":
  1166. if (this.page < this.pagesCount) {
  1167. this.page++;
  1168. }
  1169. break;
  1170. case "PrevPage":
  1171. if (this.page > 1) {
  1172. this.page--;
  1173. }
  1174. break;
  1175. case "LastPage":
  1176. this.page = this.pagesCount;
  1177. break;
  1178. case "FirstPage":
  1179. this.page = 1;
  1180. break;
  1181. default:
  1182. break;
  1183. }
  1184. this.eventBus.dispatch("namedaction", {
  1185. source: this,
  1186. action
  1187. });
  1188. }
  1189. cachePageRef(pageNum, pageRef) {
  1190. if (!pageRef) {
  1191. return;
  1192. }
  1193. const refStr = pageRef.gen === 0 ? `${pageRef.num}R` : `${pageRef.num}R${pageRef.gen}`;
  1194. this._pagesRefCache[refStr] = pageNum;
  1195. }
  1196. _cachedPageNumber(pageRef) {
  1197. const refStr = pageRef.gen === 0 ? `${pageRef.num}R` : `${pageRef.num}R${pageRef.gen}`;
  1198. return this._pagesRefCache && this._pagesRefCache[refStr] || null;
  1199. }
  1200. isPageVisible(pageNumber) {
  1201. return this.pdfViewer.isPageVisible(pageNumber);
  1202. }
  1203. }
  1204. exports.PDFLinkService = PDFLinkService;
  1205. function isValidExplicitDestination(dest) {
  1206. if (!Array.isArray(dest)) {
  1207. return false;
  1208. }
  1209. const destLength = dest.length;
  1210. if (destLength < 2) {
  1211. return false;
  1212. }
  1213. const page = dest[0];
  1214. if (!(typeof page === "object" && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
  1215. return false;
  1216. }
  1217. const zoom = dest[1];
  1218. if (!(typeof zoom === "object" && typeof zoom.name === "string")) {
  1219. return false;
  1220. }
  1221. let allowNull = true;
  1222. switch (zoom.name) {
  1223. case "XYZ":
  1224. if (destLength !== 5) {
  1225. return false;
  1226. }
  1227. break;
  1228. case "Fit":
  1229. case "FitB":
  1230. return destLength === 2;
  1231. case "FitH":
  1232. case "FitBH":
  1233. case "FitV":
  1234. case "FitBV":
  1235. if (destLength !== 3) {
  1236. return false;
  1237. }
  1238. break;
  1239. case "FitR":
  1240. if (destLength !== 6) {
  1241. return false;
  1242. }
  1243. allowNull = false;
  1244. break;
  1245. default:
  1246. return false;
  1247. }
  1248. for (let i = 2; i < destLength; i++) {
  1249. const param = dest[i];
  1250. if (!(typeof param === "number" || allowNull && param === null)) {
  1251. return false;
  1252. }
  1253. }
  1254. return true;
  1255. }
  1256. class SimpleLinkService {
  1257. constructor() {
  1258. this.externalLinkTarget = null;
  1259. this.externalLinkRel = null;
  1260. this.externalLinkEnabled = true;
  1261. this._ignoreDestinationZoom = false;
  1262. }
  1263. get pagesCount() {
  1264. return 0;
  1265. }
  1266. get page() {
  1267. return 0;
  1268. }
  1269. set page(value) {}
  1270. get rotation() {
  1271. return 0;
  1272. }
  1273. set rotation(value) {}
  1274. navigateTo(dest) {}
  1275. getDestinationHash(dest) {
  1276. return "#";
  1277. }
  1278. getAnchorUrl(hash) {
  1279. return "#";
  1280. }
  1281. setHash(hash) {}
  1282. executeNamedAction(action) {}
  1283. cachePageRef(pageNum, pageRef) {}
  1284. isPageVisible(pageNumber) {
  1285. return true;
  1286. }
  1287. }
  1288. exports.SimpleLinkService = SimpleLinkService;
  1289. /***/ }),
  1290. /* 5 */
  1291. /***/ (function(module, exports, __w_pdfjs_require__) {
  1292. "use strict";
  1293. Object.defineProperty(exports, "__esModule", {
  1294. value: true
  1295. });
  1296. exports.DefaultTextLayerFactory = exports.TextLayerBuilder = void 0;
  1297. var _pdfjsLib = __w_pdfjs_require__(2);
  1298. const EXPAND_DIVS_TIMEOUT = 300;
  1299. class TextLayerBuilder {
  1300. constructor({
  1301. textLayerDiv,
  1302. eventBus,
  1303. pageIndex,
  1304. viewport,
  1305. findController = null,
  1306. enhanceTextSelection = false
  1307. }) {
  1308. this.textLayerDiv = textLayerDiv;
  1309. this.eventBus = eventBus;
  1310. this.textContent = null;
  1311. this.textContentItemsStr = [];
  1312. this.textContentStream = null;
  1313. this.renderingDone = false;
  1314. this.pageIdx = pageIndex;
  1315. this.pageNumber = this.pageIdx + 1;
  1316. this.matches = [];
  1317. this.viewport = viewport;
  1318. this.textDivs = [];
  1319. this.findController = findController;
  1320. this.textLayerRenderTask = null;
  1321. this.enhanceTextSelection = enhanceTextSelection;
  1322. this._onUpdateTextLayerMatches = null;
  1323. this._bindMouse();
  1324. }
  1325. _finishRendering() {
  1326. this.renderingDone = true;
  1327. if (!this.enhanceTextSelection) {
  1328. const endOfContent = document.createElement("div");
  1329. endOfContent.className = "endOfContent";
  1330. this.textLayerDiv.appendChild(endOfContent);
  1331. }
  1332. this.eventBus.dispatch("textlayerrendered", {
  1333. source: this,
  1334. pageNumber: this.pageNumber,
  1335. numTextDivs: this.textDivs.length
  1336. });
  1337. }
  1338. render(timeout = 0) {
  1339. if (!(this.textContent || this.textContentStream) || this.renderingDone) {
  1340. return;
  1341. }
  1342. this.cancel();
  1343. this.textDivs = [];
  1344. const textLayerFrag = document.createDocumentFragment();
  1345. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  1346. textContent: this.textContent,
  1347. textContentStream: this.textContentStream,
  1348. container: textLayerFrag,
  1349. viewport: this.viewport,
  1350. textDivs: this.textDivs,
  1351. textContentItemsStr: this.textContentItemsStr,
  1352. timeout,
  1353. enhanceTextSelection: this.enhanceTextSelection
  1354. });
  1355. this.textLayerRenderTask.promise.then(() => {
  1356. this.textLayerDiv.appendChild(textLayerFrag);
  1357. this._finishRendering();
  1358. this._updateMatches();
  1359. }, function (reason) {});
  1360. if (!this._onUpdateTextLayerMatches) {
  1361. this._onUpdateTextLayerMatches = evt => {
  1362. if (evt.pageIndex === this.pageIdx || evt.pageIndex === -1) {
  1363. this._updateMatches();
  1364. }
  1365. };
  1366. this.eventBus._on("updatetextlayermatches", this._onUpdateTextLayerMatches);
  1367. }
  1368. }
  1369. cancel() {
  1370. if (this.textLayerRenderTask) {
  1371. this.textLayerRenderTask.cancel();
  1372. this.textLayerRenderTask = null;
  1373. }
  1374. if (this._onUpdateTextLayerMatches) {
  1375. this.eventBus._off("updatetextlayermatches", this._onUpdateTextLayerMatches);
  1376. this._onUpdateTextLayerMatches = null;
  1377. }
  1378. }
  1379. setTextContentStream(readableStream) {
  1380. this.cancel();
  1381. this.textContentStream = readableStream;
  1382. }
  1383. setTextContent(textContent) {
  1384. this.cancel();
  1385. this.textContent = textContent;
  1386. }
  1387. _convertMatches(matches, matchesLength) {
  1388. if (!matches) {
  1389. return [];
  1390. }
  1391. const {
  1392. findController,
  1393. textContentItemsStr
  1394. } = this;
  1395. let i = 0,
  1396. iIndex = 0;
  1397. const end = textContentItemsStr.length - 1;
  1398. const queryLen = findController.state.query.length;
  1399. const result = [];
  1400. for (let m = 0, mm = matches.length; m < mm; m++) {
  1401. let matchIdx = matches[m];
  1402. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  1403. iIndex += textContentItemsStr[i].length;
  1404. i++;
  1405. }
  1406. if (i === textContentItemsStr.length) {
  1407. console.error("Could not find a matching mapping");
  1408. }
  1409. const match = {
  1410. begin: {
  1411. divIdx: i,
  1412. offset: matchIdx - iIndex
  1413. }
  1414. };
  1415. if (matchesLength) {
  1416. matchIdx += matchesLength[m];
  1417. } else {
  1418. matchIdx += queryLen;
  1419. }
  1420. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  1421. iIndex += textContentItemsStr[i].length;
  1422. i++;
  1423. }
  1424. match.end = {
  1425. divIdx: i,
  1426. offset: matchIdx - iIndex
  1427. };
  1428. result.push(match);
  1429. }
  1430. return result;
  1431. }
  1432. _renderMatches(matches) {
  1433. if (matches.length === 0) {
  1434. return;
  1435. }
  1436. const {
  1437. findController,
  1438. pageIdx,
  1439. textContentItemsStr,
  1440. textDivs
  1441. } = this;
  1442. const isSelectedPage = pageIdx === findController.selected.pageIdx;
  1443. const selectedMatchIdx = findController.selected.matchIdx;
  1444. const highlightAll = findController.state.highlightAll;
  1445. let prevEnd = null;
  1446. const infinity = {
  1447. divIdx: -1,
  1448. offset: undefined
  1449. };
  1450. function beginText(begin, className) {
  1451. const divIdx = begin.divIdx;
  1452. textDivs[divIdx].textContent = "";
  1453. appendTextToDiv(divIdx, 0, begin.offset, className);
  1454. }
  1455. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  1456. const div = textDivs[divIdx];
  1457. const content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  1458. const node = document.createTextNode(content);
  1459. if (className) {
  1460. const span = document.createElement("span");
  1461. span.className = className;
  1462. span.appendChild(node);
  1463. div.appendChild(span);
  1464. return;
  1465. }
  1466. div.appendChild(node);
  1467. }
  1468. let i0 = selectedMatchIdx,
  1469. i1 = i0 + 1;
  1470. if (highlightAll) {
  1471. i0 = 0;
  1472. i1 = matches.length;
  1473. } else if (!isSelectedPage) {
  1474. return;
  1475. }
  1476. for (let i = i0; i < i1; i++) {
  1477. const match = matches[i];
  1478. const begin = match.begin;
  1479. const end = match.end;
  1480. const isSelected = isSelectedPage && i === selectedMatchIdx;
  1481. const highlightSuffix = isSelected ? " selected" : "";
  1482. if (isSelected) {
  1483. findController.scrollMatchIntoView({
  1484. element: textDivs[begin.divIdx],
  1485. pageIndex: pageIdx,
  1486. matchIndex: selectedMatchIdx
  1487. });
  1488. }
  1489. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  1490. if (prevEnd !== null) {
  1491. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  1492. }
  1493. beginText(begin);
  1494. } else {
  1495. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  1496. }
  1497. if (begin.divIdx === end.divIdx) {
  1498. appendTextToDiv(begin.divIdx, begin.offset, end.offset, "highlight" + highlightSuffix);
  1499. } else {
  1500. appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, "highlight begin" + highlightSuffix);
  1501. for (let n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  1502. textDivs[n0].className = "highlight middle" + highlightSuffix;
  1503. }
  1504. beginText(end, "highlight end" + highlightSuffix);
  1505. }
  1506. prevEnd = end;
  1507. }
  1508. if (prevEnd) {
  1509. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  1510. }
  1511. }
  1512. _updateMatches() {
  1513. if (!this.renderingDone) {
  1514. return;
  1515. }
  1516. const {
  1517. findController,
  1518. matches,
  1519. pageIdx,
  1520. textContentItemsStr,
  1521. textDivs
  1522. } = this;
  1523. let clearedUntilDivIdx = -1;
  1524. for (let i = 0, ii = matches.length; i < ii; i++) {
  1525. const match = matches[i];
  1526. const begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  1527. for (let n = begin, end = match.end.divIdx; n <= end; n++) {
  1528. const div = textDivs[n];
  1529. div.textContent = textContentItemsStr[n];
  1530. div.className = "";
  1531. }
  1532. clearedUntilDivIdx = match.end.divIdx + 1;
  1533. }
  1534. if (!findController || !findController.highlightMatches) {
  1535. return;
  1536. }
  1537. const pageMatches = findController.pageMatches[pageIdx] || null;
  1538. const pageMatchesLength = findController.pageMatchesLength[pageIdx] || null;
  1539. this.matches = this._convertMatches(pageMatches, pageMatchesLength);
  1540. this._renderMatches(this.matches);
  1541. }
  1542. _bindMouse() {
  1543. const div = this.textLayerDiv;
  1544. let expandDivsTimer = null;
  1545. div.addEventListener("mousedown", evt => {
  1546. if (this.enhanceTextSelection && this.textLayerRenderTask) {
  1547. this.textLayerRenderTask.expandTextDivs(true);
  1548. if (expandDivsTimer) {
  1549. clearTimeout(expandDivsTimer);
  1550. expandDivsTimer = null;
  1551. }
  1552. return;
  1553. }
  1554. const end = div.querySelector(".endOfContent");
  1555. if (!end) {
  1556. return;
  1557. }
  1558. let adjustTop = evt.target !== div;
  1559. adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue("-moz-user-select") !== "none";
  1560. if (adjustTop) {
  1561. const divBounds = div.getBoundingClientRect();
  1562. const r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  1563. end.style.top = (r * 100).toFixed(2) + "%";
  1564. }
  1565. end.classList.add("active");
  1566. });
  1567. div.addEventListener("mouseup", () => {
  1568. if (this.enhanceTextSelection && this.textLayerRenderTask) {
  1569. expandDivsTimer = setTimeout(() => {
  1570. if (this.textLayerRenderTask) {
  1571. this.textLayerRenderTask.expandTextDivs(false);
  1572. }
  1573. expandDivsTimer = null;
  1574. }, EXPAND_DIVS_TIMEOUT);
  1575. return;
  1576. }
  1577. const end = div.querySelector(".endOfContent");
  1578. if (!end) {
  1579. return;
  1580. }
  1581. end.style.top = "";
  1582. end.classList.remove("active");
  1583. });
  1584. }
  1585. }
  1586. exports.TextLayerBuilder = TextLayerBuilder;
  1587. class DefaultTextLayerFactory {
  1588. createTextLayerBuilder(textLayerDiv, pageIndex, viewport, enhanceTextSelection = false, eventBus) {
  1589. return new TextLayerBuilder({
  1590. textLayerDiv,
  1591. pageIndex,
  1592. viewport,
  1593. enhanceTextSelection,
  1594. eventBus
  1595. });
  1596. }
  1597. }
  1598. exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
  1599. /***/ }),
  1600. /* 6 */
  1601. /***/ (function(module, exports, __w_pdfjs_require__) {
  1602. "use strict";
  1603. Object.defineProperty(exports, "__esModule", {
  1604. value: true
  1605. });
  1606. exports.DownloadManager = void 0;
  1607. var _pdfjsLib = __w_pdfjs_require__(2);
  1608. var _viewer_compatibility = __w_pdfjs_require__(7);
  1609. ;
  1610. function download(blobUrl, filename) {
  1611. const a = document.createElement("a");
  1612. if (!a.click) {
  1613. throw new Error('DownloadManager: "a.click()" is not supported.');
  1614. }
  1615. a.href = blobUrl;
  1616. a.target = "_parent";
  1617. if ("download" in a) {
  1618. a.download = filename;
  1619. }
  1620. (document.body || document.documentElement).appendChild(a);
  1621. a.click();
  1622. a.remove();
  1623. }
  1624. class DownloadManager {
  1625. downloadUrl(url, filename) {
  1626. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, "http://example.com")) {
  1627. return;
  1628. }
  1629. download(url + "#pdfjs.action=download", filename);
  1630. }
  1631. downloadData(data, filename, contentType) {
  1632. if (navigator.msSaveBlob) {
  1633. navigator.msSaveBlob(new Blob([data], {
  1634. type: contentType
  1635. }), filename);
  1636. return;
  1637. }
  1638. const blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, _viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL);
  1639. download(blobUrl, filename);
  1640. }
  1641. download(blob, url, filename, sourceEventType = "download") {
  1642. if (navigator.msSaveBlob) {
  1643. if (!navigator.msSaveBlob(blob, filename)) {
  1644. this.downloadUrl(url, filename);
  1645. }
  1646. return;
  1647. }
  1648. if (_viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL) {
  1649. this.downloadUrl(url, filename);
  1650. return;
  1651. }
  1652. const blobUrl = URL.createObjectURL(blob);
  1653. download(blobUrl, filename);
  1654. }
  1655. }
  1656. exports.DownloadManager = DownloadManager;
  1657. /***/ }),
  1658. /* 7 */
  1659. /***/ (function(module, exports, __w_pdfjs_require__) {
  1660. "use strict";
  1661. Object.defineProperty(exports, "__esModule", {
  1662. value: true
  1663. });
  1664. exports.viewerCompatibilityParams = void 0;
  1665. const compatibilityParams = Object.create(null);
  1666. {
  1667. const userAgent = typeof navigator !== "undefined" && navigator.userAgent || "";
  1668. const platform = typeof navigator !== "undefined" && navigator.platform || "";
  1669. const maxTouchPoints = typeof navigator !== "undefined" && navigator.maxTouchPoints || 1;
  1670. const isAndroid = /Android/.test(userAgent);
  1671. const isIE = /Trident/.test(userAgent);
  1672. const isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" && maxTouchPoints > 1;
  1673. const isIOSChrome = /CriOS/.test(userAgent);
  1674. (function checkOnBlobSupport() {
  1675. if (isIE || isIOSChrome) {
  1676. compatibilityParams.disableCreateObjectURL = true;
  1677. }
  1678. })();
  1679. (function checkCanvasSizeLimitation() {
  1680. if (isIOS || isAndroid) {
  1681. compatibilityParams.maxCanvasPixels = 5242880;
  1682. }
  1683. })();
  1684. }
  1685. const viewerCompatibilityParams = Object.freeze(compatibilityParams);
  1686. exports.viewerCompatibilityParams = viewerCompatibilityParams;
  1687. /***/ }),
  1688. /* 8 */
  1689. /***/ (function(module, exports, __w_pdfjs_require__) {
  1690. "use strict";
  1691. Object.defineProperty(exports, "__esModule", {
  1692. value: true
  1693. });
  1694. exports.GenericL10n = void 0;
  1695. __w_pdfjs_require__(9);
  1696. const webL10n = document.webL10n;
  1697. class GenericL10n {
  1698. constructor(lang) {
  1699. this._lang = lang;
  1700. this._ready = new Promise((resolve, reject) => {
  1701. webL10n.setLanguage(lang, () => {
  1702. resolve(webL10n);
  1703. });
  1704. });
  1705. }
  1706. async getLanguage() {
  1707. const l10n = await this._ready;
  1708. return l10n.getLanguage();
  1709. }
  1710. async getDirection() {
  1711. const l10n = await this._ready;
  1712. return l10n.getDirection();
  1713. }
  1714. async get(property, args, fallback) {
  1715. const l10n = await this._ready;
  1716. return l10n.get(property, args, fallback);
  1717. }
  1718. async translate(element) {
  1719. const l10n = await this._ready;
  1720. return l10n.translate(element);
  1721. }
  1722. }
  1723. exports.GenericL10n = GenericL10n;
  1724. /***/ }),
  1725. /* 9 */
  1726. /***/ (function(module, exports, __w_pdfjs_require__) {
  1727. "use strict";
  1728. document.webL10n = function (window, document, undefined) {
  1729. var gL10nData = {};
  1730. var gTextData = '';
  1731. var gTextProp = 'textContent';
  1732. var gLanguage = '';
  1733. var gMacros = {};
  1734. var gReadyState = 'loading';
  1735. var gAsyncResourceLoading = true;
  1736. function getL10nResourceLinks() {
  1737. return document.querySelectorAll('link[type="application/l10n"]');
  1738. }
  1739. function getL10nDictionary() {
  1740. var script = document.querySelector('script[type="application/l10n"]');
  1741. return script ? JSON.parse(script.innerHTML) : null;
  1742. }
  1743. function getTranslatableChildren(element) {
  1744. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  1745. }
  1746. function getL10nAttributes(element) {
  1747. if (!element) return {};
  1748. var l10nId = element.getAttribute('data-l10n-id');
  1749. var l10nArgs = element.getAttribute('data-l10n-args');
  1750. var args = {};
  1751. if (l10nArgs) {
  1752. try {
  1753. args = JSON.parse(l10nArgs);
  1754. } catch (e) {
  1755. console.warn('could not parse arguments for #' + l10nId);
  1756. }
  1757. }
  1758. return {
  1759. id: l10nId,
  1760. args: args
  1761. };
  1762. }
  1763. function xhrLoadText(url, onSuccess, onFailure) {
  1764. onSuccess = onSuccess || function _onSuccess(data) {};
  1765. onFailure = onFailure || function _onFailure() {};
  1766. var xhr = new XMLHttpRequest();
  1767. xhr.open('GET', url, gAsyncResourceLoading);
  1768. if (xhr.overrideMimeType) {
  1769. xhr.overrideMimeType('text/plain; charset=utf-8');
  1770. }
  1771. xhr.onreadystatechange = function () {
  1772. if (xhr.readyState == 4) {
  1773. if (xhr.status == 200 || xhr.status === 0) {
  1774. onSuccess(xhr.responseText);
  1775. } else {
  1776. onFailure();
  1777. }
  1778. }
  1779. };
  1780. xhr.onerror = onFailure;
  1781. xhr.ontimeout = onFailure;
  1782. try {
  1783. xhr.send(null);
  1784. } catch (e) {
  1785. onFailure();
  1786. }
  1787. }
  1788. function parseResource(href, lang, successCallback, failureCallback) {
  1789. var baseURL = href.replace(/[^\/]*$/, '') || './';
  1790. function evalString(text) {
  1791. if (text.lastIndexOf('\\') < 0) return text;
  1792. 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, "'");
  1793. }
  1794. function parseProperties(text, parsedPropertiesCallback) {
  1795. var dictionary = {};
  1796. var reBlank = /^\s*|\s*$/;
  1797. var reComment = /^\s*#|^\s*$/;
  1798. var reSection = /^\s*\[(.*)\]\s*$/;
  1799. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  1800. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  1801. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  1802. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  1803. var currentLang = '*';
  1804. var genericLang = lang.split('-', 1)[0];
  1805. var skipLang = false;
  1806. var match = '';
  1807. function nextEntry() {
  1808. while (true) {
  1809. if (!entries.length) {
  1810. parsedRawLinesCallback();
  1811. return;
  1812. }
  1813. var line = entries.shift();
  1814. if (reComment.test(line)) continue;
  1815. if (extendedSyntax) {
  1816. match = reSection.exec(line);
  1817. if (match) {
  1818. currentLang = match[1].toLowerCase();
  1819. skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
  1820. continue;
  1821. } else if (skipLang) {
  1822. continue;
  1823. }
  1824. match = reImport.exec(line);
  1825. if (match) {
  1826. loadImport(baseURL + match[1], nextEntry);
  1827. return;
  1828. }
  1829. }
  1830. var tmp = line.match(reSplit);
  1831. if (tmp && tmp.length == 3) {
  1832. dictionary[tmp[1]] = evalString(tmp[2]);
  1833. }
  1834. }
  1835. }
  1836. nextEntry();
  1837. }
  1838. function loadImport(url, callback) {
  1839. xhrLoadText(url, function (content) {
  1840. parseRawLines(content, false, callback);
  1841. }, function () {
  1842. console.warn(url + ' not found.');
  1843. callback();
  1844. });
  1845. }
  1846. parseRawLines(text, true, function () {
  1847. parsedPropertiesCallback(dictionary);
  1848. });
  1849. }
  1850. xhrLoadText(href, function (response) {
  1851. gTextData += response;
  1852. parseProperties(response, function (data) {
  1853. for (var key in data) {
  1854. var id,
  1855. prop,
  1856. index = key.lastIndexOf('.');
  1857. if (index > 0) {
  1858. id = key.substring(0, index);
  1859. prop = key.substring(index + 1);
  1860. } else {
  1861. id = key;
  1862. prop = gTextProp;
  1863. }
  1864. if (!gL10nData[id]) {
  1865. gL10nData[id] = {};
  1866. }
  1867. gL10nData[id][prop] = data[key];
  1868. }
  1869. if (successCallback) {
  1870. successCallback();
  1871. }
  1872. });
  1873. }, failureCallback);
  1874. }
  1875. function loadLocale(lang, callback) {
  1876. if (lang) {
  1877. lang = lang.toLowerCase();
  1878. }
  1879. callback = callback || function _callback() {};
  1880. clear();
  1881. gLanguage = lang;
  1882. var langLinks = getL10nResourceLinks();
  1883. var langCount = langLinks.length;
  1884. if (langCount === 0) {
  1885. var dict = getL10nDictionary();
  1886. if (dict && dict.locales && dict.default_locale) {
  1887. console.log('using the embedded JSON directory, early way out');
  1888. gL10nData = dict.locales[lang];
  1889. if (!gL10nData) {
  1890. var defaultLocale = dict.default_locale.toLowerCase();
  1891. for (var anyCaseLang in dict.locales) {
  1892. anyCaseLang = anyCaseLang.toLowerCase();
  1893. if (anyCaseLang === lang) {
  1894. gL10nData = dict.locales[lang];
  1895. break;
  1896. } else if (anyCaseLang === defaultLocale) {
  1897. gL10nData = dict.locales[defaultLocale];
  1898. }
  1899. }
  1900. }
  1901. callback();
  1902. } else {
  1903. console.log('no resource to load, early way out');
  1904. }
  1905. gReadyState = 'complete';
  1906. return;
  1907. }
  1908. var onResourceLoaded = null;
  1909. var gResourceCount = 0;
  1910. onResourceLoaded = function () {
  1911. gResourceCount++;
  1912. if (gResourceCount >= langCount) {
  1913. callback();
  1914. gReadyState = 'complete';
  1915. }
  1916. };
  1917. function L10nResourceLink(link) {
  1918. var href = link.href;
  1919. this.load = function (lang, callback) {
  1920. parseResource(href, lang, callback, function () {
  1921. console.warn(href + ' not found.');
  1922. console.warn('"' + lang + '" resource not found');
  1923. gLanguage = '';
  1924. callback();
  1925. });
  1926. };
  1927. }
  1928. for (var i = 0; i < langCount; i++) {
  1929. var resource = new L10nResourceLink(langLinks[i]);
  1930. resource.load(lang, onResourceLoaded);
  1931. }
  1932. }
  1933. function clear() {
  1934. gL10nData = {};
  1935. gTextData = '';
  1936. gLanguage = '';
  1937. }
  1938. function getPluralRules(lang) {
  1939. var locales2rules = {
  1940. 'af': 3,
  1941. 'ak': 4,
  1942. 'am': 4,
  1943. 'ar': 1,
  1944. 'asa': 3,
  1945. 'az': 0,
  1946. 'be': 11,
  1947. 'bem': 3,
  1948. 'bez': 3,
  1949. 'bg': 3,
  1950. 'bh': 4,
  1951. 'bm': 0,
  1952. 'bn': 3,
  1953. 'bo': 0,
  1954. 'br': 20,
  1955. 'brx': 3,
  1956. 'bs': 11,
  1957. 'ca': 3,
  1958. 'cgg': 3,
  1959. 'chr': 3,
  1960. 'cs': 12,
  1961. 'cy': 17,
  1962. 'da': 3,
  1963. 'de': 3,
  1964. 'dv': 3,
  1965. 'dz': 0,
  1966. 'ee': 3,
  1967. 'el': 3,
  1968. 'en': 3,
  1969. 'eo': 3,
  1970. 'es': 3,
  1971. 'et': 3,
  1972. 'eu': 3,
  1973. 'fa': 0,
  1974. 'ff': 5,
  1975. 'fi': 3,
  1976. 'fil': 4,
  1977. 'fo': 3,
  1978. 'fr': 5,
  1979. 'fur': 3,
  1980. 'fy': 3,
  1981. 'ga': 8,
  1982. 'gd': 24,
  1983. 'gl': 3,
  1984. 'gsw': 3,
  1985. 'gu': 3,
  1986. 'guw': 4,
  1987. 'gv': 23,
  1988. 'ha': 3,
  1989. 'haw': 3,
  1990. 'he': 2,
  1991. 'hi': 4,
  1992. 'hr': 11,
  1993. 'hu': 0,
  1994. 'id': 0,
  1995. 'ig': 0,
  1996. 'ii': 0,
  1997. 'is': 3,
  1998. 'it': 3,
  1999. 'iu': 7,
  2000. 'ja': 0,
  2001. 'jmc': 3,
  2002. 'jv': 0,
  2003. 'ka': 0,
  2004. 'kab': 5,
  2005. 'kaj': 3,
  2006. 'kcg': 3,
  2007. 'kde': 0,
  2008. 'kea': 0,
  2009. 'kk': 3,
  2010. 'kl': 3,
  2011. 'km': 0,
  2012. 'kn': 0,
  2013. 'ko': 0,
  2014. 'ksb': 3,
  2015. 'ksh': 21,
  2016. 'ku': 3,
  2017. 'kw': 7,
  2018. 'lag': 18,
  2019. 'lb': 3,
  2020. 'lg': 3,
  2021. 'ln': 4,
  2022. 'lo': 0,
  2023. 'lt': 10,
  2024. 'lv': 6,
  2025. 'mas': 3,
  2026. 'mg': 4,
  2027. 'mk': 16,
  2028. 'ml': 3,
  2029. 'mn': 3,
  2030. 'mo': 9,
  2031. 'mr': 3,
  2032. 'ms': 0,
  2033. 'mt': 15,
  2034. 'my': 0,
  2035. 'nah': 3,
  2036. 'naq': 7,
  2037. 'nb': 3,
  2038. 'nd': 3,
  2039. 'ne': 3,
  2040. 'nl': 3,
  2041. 'nn': 3,
  2042. 'no': 3,
  2043. 'nr': 3,
  2044. 'nso': 4,
  2045. 'ny': 3,
  2046. 'nyn': 3,
  2047. 'om': 3,
  2048. 'or': 3,
  2049. 'pa': 3,
  2050. 'pap': 3,
  2051. 'pl': 13,
  2052. 'ps': 3,
  2053. 'pt': 3,
  2054. 'rm': 3,
  2055. 'ro': 9,
  2056. 'rof': 3,
  2057. 'ru': 11,
  2058. 'rwk': 3,
  2059. 'sah': 0,
  2060. 'saq': 3,
  2061. 'se': 7,
  2062. 'seh': 3,
  2063. 'ses': 0,
  2064. 'sg': 0,
  2065. 'sh': 11,
  2066. 'shi': 19,
  2067. 'sk': 12,
  2068. 'sl': 14,
  2069. 'sma': 7,
  2070. 'smi': 7,
  2071. 'smj': 7,
  2072. 'smn': 7,
  2073. 'sms': 7,
  2074. 'sn': 3,
  2075. 'so': 3,
  2076. 'sq': 3,
  2077. 'sr': 11,
  2078. 'ss': 3,
  2079. 'ssy': 3,
  2080. 'st': 3,
  2081. 'sv': 3,
  2082. 'sw': 3,
  2083. 'syr': 3,
  2084. 'ta': 3,
  2085. 'te': 3,
  2086. 'teo': 3,
  2087. 'th': 0,
  2088. 'ti': 4,
  2089. 'tig': 3,
  2090. 'tk': 3,
  2091. 'tl': 4,
  2092. 'tn': 3,
  2093. 'to': 0,
  2094. 'tr': 0,
  2095. 'ts': 3,
  2096. 'tzm': 22,
  2097. 'uk': 11,
  2098. 'ur': 3,
  2099. 've': 3,
  2100. 'vi': 0,
  2101. 'vun': 3,
  2102. 'wa': 4,
  2103. 'wae': 3,
  2104. 'wo': 0,
  2105. 'xh': 3,
  2106. 'xog': 3,
  2107. 'yo': 0,
  2108. 'zh': 0,
  2109. 'zu': 3
  2110. };
  2111. function isIn(n, list) {
  2112. return list.indexOf(n) !== -1;
  2113. }
  2114. function isBetween(n, start, end) {
  2115. return start <= n && n <= end;
  2116. }
  2117. var pluralRules = {
  2118. '0': function (n) {
  2119. return 'other';
  2120. },
  2121. '1': function (n) {
  2122. if (isBetween(n % 100, 3, 10)) return 'few';
  2123. if (n === 0) return 'zero';
  2124. if (isBetween(n % 100, 11, 99)) return 'many';
  2125. if (n == 2) return 'two';
  2126. if (n == 1) return 'one';
  2127. return 'other';
  2128. },
  2129. '2': function (n) {
  2130. if (n !== 0 && n % 10 === 0) return 'many';
  2131. if (n == 2) return 'two';
  2132. if (n == 1) return 'one';
  2133. return 'other';
  2134. },
  2135. '3': function (n) {
  2136. if (n == 1) return 'one';
  2137. return 'other';
  2138. },
  2139. '4': function (n) {
  2140. if (isBetween(n, 0, 1)) return 'one';
  2141. return 'other';
  2142. },
  2143. '5': function (n) {
  2144. if (isBetween(n, 0, 2) && n != 2) return 'one';
  2145. return 'other';
  2146. },
  2147. '6': function (n) {
  2148. if (n === 0) return 'zero';
  2149. if (n % 10 == 1 && n % 100 != 11) return 'one';
  2150. return 'other';
  2151. },
  2152. '7': function (n) {
  2153. if (n == 2) return 'two';
  2154. if (n == 1) return 'one';
  2155. return 'other';
  2156. },
  2157. '8': function (n) {
  2158. if (isBetween(n, 3, 6)) return 'few';
  2159. if (isBetween(n, 7, 10)) return 'many';
  2160. if (n == 2) return 'two';
  2161. if (n == 1) return 'one';
  2162. return 'other';
  2163. },
  2164. '9': function (n) {
  2165. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  2166. if (n == 1) return 'one';
  2167. return 'other';
  2168. },
  2169. '10': function (n) {
  2170. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  2171. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  2172. return 'other';
  2173. },
  2174. '11': function (n) {
  2175. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  2176. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
  2177. if (n % 10 == 1 && n % 100 != 11) return 'one';
  2178. return 'other';
  2179. },
  2180. '12': function (n) {
  2181. if (isBetween(n, 2, 4)) return 'few';
  2182. if (n == 1) return 'one';
  2183. return 'other';
  2184. },
  2185. '13': function (n) {
  2186. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  2187. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
  2188. if (n == 1) return 'one';
  2189. return 'other';
  2190. },
  2191. '14': function (n) {
  2192. if (isBetween(n % 100, 3, 4)) return 'few';
  2193. if (n % 100 == 2) return 'two';
  2194. if (n % 100 == 1) return 'one';
  2195. return 'other';
  2196. },
  2197. '15': function (n) {
  2198. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  2199. if (isBetween(n % 100, 11, 19)) return 'many';
  2200. if (n == 1) return 'one';
  2201. return 'other';
  2202. },
  2203. '16': function (n) {
  2204. if (n % 10 == 1 && n != 11) return 'one';
  2205. return 'other';
  2206. },
  2207. '17': function (n) {
  2208. if (n == 3) return 'few';
  2209. if (n === 0) return 'zero';
  2210. if (n == 6) return 'many';
  2211. if (n == 2) return 'two';
  2212. if (n == 1) return 'one';
  2213. return 'other';
  2214. },
  2215. '18': function (n) {
  2216. if (n === 0) return 'zero';
  2217. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  2218. return 'other';
  2219. },
  2220. '19': function (n) {
  2221. if (isBetween(n, 2, 10)) return 'few';
  2222. if (isBetween(n, 0, 1)) return 'one';
  2223. return 'other';
  2224. },
  2225. '20': function (n) {
  2226. 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';
  2227. if (n % 1000000 === 0 && n !== 0) return 'many';
  2228. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  2229. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  2230. return 'other';
  2231. },
  2232. '21': function (n) {
  2233. if (n === 0) return 'zero';
  2234. if (n == 1) return 'one';
  2235. return 'other';
  2236. },
  2237. '22': function (n) {
  2238. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  2239. return 'other';
  2240. },
  2241. '23': function (n) {
  2242. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  2243. return 'other';
  2244. },
  2245. '24': function (n) {
  2246. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  2247. if (isIn(n, [2, 12])) return 'two';
  2248. if (isIn(n, [1, 11])) return 'one';
  2249. return 'other';
  2250. }
  2251. };
  2252. var index = locales2rules[lang.replace(/-.*$/, '')];
  2253. if (!(index in pluralRules)) {
  2254. console.warn('plural form unknown for [' + lang + ']');
  2255. return function () {
  2256. return 'other';
  2257. };
  2258. }
  2259. return pluralRules[index];
  2260. }
  2261. gMacros.plural = function (str, param, key, prop) {
  2262. var n = parseFloat(param);
  2263. if (isNaN(n)) return str;
  2264. if (prop != gTextProp) return str;
  2265. if (!gMacros._pluralRules) {
  2266. gMacros._pluralRules = getPluralRules(gLanguage);
  2267. }
  2268. var index = '[' + gMacros._pluralRules(n) + ']';
  2269. if (n === 0 && key + '[zero]' in gL10nData) {
  2270. str = gL10nData[key + '[zero]'][prop];
  2271. } else if (n == 1 && key + '[one]' in gL10nData) {
  2272. str = gL10nData[key + '[one]'][prop];
  2273. } else if (n == 2 && key + '[two]' in gL10nData) {
  2274. str = gL10nData[key + '[two]'][prop];
  2275. } else if (key + index in gL10nData) {
  2276. str = gL10nData[key + index][prop];
  2277. } else if (key + '[other]' in gL10nData) {
  2278. str = gL10nData[key + '[other]'][prop];
  2279. }
  2280. return str;
  2281. };
  2282. function getL10nData(key, args, fallback) {
  2283. var data = gL10nData[key];
  2284. if (!data) {
  2285. console.warn('#' + key + ' is undefined.');
  2286. if (!fallback) {
  2287. return null;
  2288. }
  2289. data = fallback;
  2290. }
  2291. var rv = {};
  2292. for (var prop in data) {
  2293. var str = data[prop];
  2294. str = substIndexes(str, args, key, prop);
  2295. str = substArguments(str, args, key);
  2296. rv[prop] = str;
  2297. }
  2298. return rv;
  2299. }
  2300. function substIndexes(str, args, key, prop) {
  2301. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  2302. var reMatch = reIndex.exec(str);
  2303. if (!reMatch || !reMatch.length) return str;
  2304. var macroName = reMatch[1];
  2305. var paramName = reMatch[2];
  2306. var param;
  2307. if (args && paramName in args) {
  2308. param = args[paramName];
  2309. } else if (paramName in gL10nData) {
  2310. param = gL10nData[paramName];
  2311. }
  2312. if (macroName in gMacros) {
  2313. var macro = gMacros[macroName];
  2314. str = macro(str, param, key, prop);
  2315. }
  2316. return str;
  2317. }
  2318. function substArguments(str, args, key) {
  2319. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  2320. return str.replace(reArgs, function (matched_text, arg) {
  2321. if (args && arg in args) {
  2322. return args[arg];
  2323. }
  2324. if (arg in gL10nData) {
  2325. return gL10nData[arg];
  2326. }
  2327. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  2328. return matched_text;
  2329. });
  2330. }
  2331. function translateElement(element) {
  2332. var l10n = getL10nAttributes(element);
  2333. if (!l10n.id) return;
  2334. var data = getL10nData(l10n.id, l10n.args);
  2335. if (!data) {
  2336. console.warn('#' + l10n.id + ' is undefined.');
  2337. return;
  2338. }
  2339. if (data[gTextProp]) {
  2340. if (getChildElementCount(element) === 0) {
  2341. element[gTextProp] = data[gTextProp];
  2342. } else {
  2343. var children = element.childNodes;
  2344. var found = false;
  2345. for (var i = 0, l = children.length; i < l; i++) {
  2346. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  2347. if (found) {
  2348. children[i].nodeValue = '';
  2349. } else {
  2350. children[i].nodeValue = data[gTextProp];
  2351. found = true;
  2352. }
  2353. }
  2354. }
  2355. if (!found) {
  2356. var textNode = document.createTextNode(data[gTextProp]);
  2357. element.insertBefore(textNode, element.firstChild);
  2358. }
  2359. }
  2360. delete data[gTextProp];
  2361. }
  2362. for (var k in data) {
  2363. element[k] = data[k];
  2364. }
  2365. }
  2366. function getChildElementCount(element) {
  2367. if (element.children) {
  2368. return element.children.length;
  2369. }
  2370. if (typeof element.childElementCount !== 'undefined') {
  2371. return element.childElementCount;
  2372. }
  2373. var count = 0;
  2374. for (var i = 0; i < element.childNodes.length; i++) {
  2375. count += element.nodeType === 1 ? 1 : 0;
  2376. }
  2377. return count;
  2378. }
  2379. function translateFragment(element) {
  2380. element = element || document.documentElement;
  2381. var children = getTranslatableChildren(element);
  2382. var elementCount = children.length;
  2383. for (var i = 0; i < elementCount; i++) {
  2384. translateElement(children[i]);
  2385. }
  2386. translateElement(element);
  2387. }
  2388. return {
  2389. get: function (key, args, fallbackString) {
  2390. var index = key.lastIndexOf('.');
  2391. var prop = gTextProp;
  2392. if (index > 0) {
  2393. prop = key.substring(index + 1);
  2394. key = key.substring(0, index);
  2395. }
  2396. var fallback;
  2397. if (fallbackString) {
  2398. fallback = {};
  2399. fallback[prop] = fallbackString;
  2400. }
  2401. var data = getL10nData(key, args, fallback);
  2402. if (data && prop in data) {
  2403. return data[prop];
  2404. }
  2405. return '{{' + key + '}}';
  2406. },
  2407. getData: function () {
  2408. return gL10nData;
  2409. },
  2410. getText: function () {
  2411. return gTextData;
  2412. },
  2413. getLanguage: function () {
  2414. return gLanguage;
  2415. },
  2416. setLanguage: function (lang, callback) {
  2417. loadLocale(lang, function () {
  2418. if (callback) callback();
  2419. });
  2420. },
  2421. getDirection: function () {
  2422. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  2423. var shortCode = gLanguage.split('-', 1)[0];
  2424. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  2425. },
  2426. translate: translateFragment,
  2427. getReadyState: function () {
  2428. return gReadyState;
  2429. },
  2430. ready: function (callback) {
  2431. if (!callback) {
  2432. return;
  2433. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  2434. window.setTimeout(function () {
  2435. callback();
  2436. });
  2437. } else if (document.addEventListener) {
  2438. document.addEventListener('localized', function once() {
  2439. document.removeEventListener('localized', once);
  2440. callback();
  2441. });
  2442. }
  2443. }
  2444. };
  2445. }(window, document);
  2446. /***/ }),
  2447. /* 10 */
  2448. /***/ (function(module, exports, __w_pdfjs_require__) {
  2449. "use strict";
  2450. Object.defineProperty(exports, "__esModule", {
  2451. value: true
  2452. });
  2453. exports.PDFFindController = exports.FindState = void 0;
  2454. var _pdfjsLib = __w_pdfjs_require__(2);
  2455. var _pdf_find_utils = __w_pdfjs_require__(11);
  2456. var _ui_utils = __w_pdfjs_require__(3);
  2457. const FindState = {
  2458. FOUND: 0,
  2459. NOT_FOUND: 1,
  2460. WRAPPED: 2,
  2461. PENDING: 3
  2462. };
  2463. exports.FindState = FindState;
  2464. const FIND_TIMEOUT = 250;
  2465. const MATCH_SCROLL_OFFSET_TOP = -50;
  2466. const MATCH_SCROLL_OFFSET_LEFT = -400;
  2467. const CHARACTERS_TO_NORMALIZE = {
  2468. "\u2018": "'",
  2469. "\u2019": "'",
  2470. "\u201A": "'",
  2471. "\u201B": "'",
  2472. "\u201C": '"',
  2473. "\u201D": '"',
  2474. "\u201E": '"',
  2475. "\u201F": '"',
  2476. "\u00BC": "1/4",
  2477. "\u00BD": "1/2",
  2478. "\u00BE": "3/4"
  2479. };
  2480. let normalizationRegex = null;
  2481. function normalize(text) {
  2482. if (!normalizationRegex) {
  2483. const replace = Object.keys(CHARACTERS_TO_NORMALIZE).join("");
  2484. normalizationRegex = new RegExp(`[${replace}]`, "g");
  2485. }
  2486. return text.replace(normalizationRegex, function (ch) {
  2487. return CHARACTERS_TO_NORMALIZE[ch];
  2488. });
  2489. }
  2490. class PDFFindController {
  2491. constructor({
  2492. linkService,
  2493. eventBus
  2494. }) {
  2495. this._linkService = linkService;
  2496. this._eventBus = eventBus;
  2497. this._reset();
  2498. eventBus._on("findbarclose", this._onFindBarClose.bind(this));
  2499. }
  2500. get highlightMatches() {
  2501. return this._highlightMatches;
  2502. }
  2503. get pageMatches() {
  2504. return this._pageMatches;
  2505. }
  2506. get pageMatchesLength() {
  2507. return this._pageMatchesLength;
  2508. }
  2509. get selected() {
  2510. return this._selected;
  2511. }
  2512. get state() {
  2513. return this._state;
  2514. }
  2515. setDocument(pdfDocument) {
  2516. if (this._pdfDocument) {
  2517. this._reset();
  2518. }
  2519. if (!pdfDocument) {
  2520. return;
  2521. }
  2522. this._pdfDocument = pdfDocument;
  2523. this._firstPageCapability.resolve();
  2524. }
  2525. executeCommand(cmd, state) {
  2526. if (!state) {
  2527. return;
  2528. }
  2529. const pdfDocument = this._pdfDocument;
  2530. if (this._state === null || this._shouldDirtyMatch(cmd, state)) {
  2531. this._dirtyMatch = true;
  2532. }
  2533. this._state = state;
  2534. if (cmd !== "findhighlightallchange") {
  2535. this._updateUIState(FindState.PENDING);
  2536. }
  2537. this._firstPageCapability.promise.then(() => {
  2538. if (!this._pdfDocument || pdfDocument && this._pdfDocument !== pdfDocument) {
  2539. return;
  2540. }
  2541. this._extractText();
  2542. const findbarClosed = !this._highlightMatches;
  2543. const pendingTimeout = !!this._findTimeout;
  2544. if (this._findTimeout) {
  2545. clearTimeout(this._findTimeout);
  2546. this._findTimeout = null;
  2547. }
  2548. if (cmd === "find") {
  2549. this._findTimeout = setTimeout(() => {
  2550. this._nextMatch();
  2551. this._findTimeout = null;
  2552. }, FIND_TIMEOUT);
  2553. } else if (this._dirtyMatch) {
  2554. this._nextMatch();
  2555. } else if (cmd === "findagain") {
  2556. this._nextMatch();
  2557. if (findbarClosed && this._state.highlightAll) {
  2558. this._updateAllPages();
  2559. }
  2560. } else if (cmd === "findhighlightallchange") {
  2561. if (pendingTimeout) {
  2562. this._nextMatch();
  2563. } else {
  2564. this._highlightMatches = true;
  2565. }
  2566. this._updateAllPages();
  2567. } else {
  2568. this._nextMatch();
  2569. }
  2570. });
  2571. }
  2572. scrollMatchIntoView({
  2573. element = null,
  2574. pageIndex = -1,
  2575. matchIndex = -1
  2576. }) {
  2577. if (!this._scrollMatches || !element) {
  2578. return;
  2579. } else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) {
  2580. return;
  2581. } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) {
  2582. return;
  2583. }
  2584. this._scrollMatches = false;
  2585. const spot = {
  2586. top: MATCH_SCROLL_OFFSET_TOP,
  2587. left: MATCH_SCROLL_OFFSET_LEFT
  2588. };
  2589. (0, _ui_utils.scrollIntoView)(element, spot, true);
  2590. }
  2591. _reset() {
  2592. this._highlightMatches = false;
  2593. this._scrollMatches = false;
  2594. this._pdfDocument = null;
  2595. this._pageMatches = [];
  2596. this._pageMatchesLength = [];
  2597. this._state = null;
  2598. this._selected = {
  2599. pageIdx: -1,
  2600. matchIdx: -1
  2601. };
  2602. this._offset = {
  2603. pageIdx: null,
  2604. matchIdx: null,
  2605. wrapped: false
  2606. };
  2607. this._extractTextPromises = [];
  2608. this._pageContents = [];
  2609. this._matchesCountTotal = 0;
  2610. this._pagesToSearch = null;
  2611. this._pendingFindMatches = Object.create(null);
  2612. this._resumePageIdx = null;
  2613. this._dirtyMatch = false;
  2614. clearTimeout(this._findTimeout);
  2615. this._findTimeout = null;
  2616. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  2617. }
  2618. get _query() {
  2619. if (this._state.query !== this._rawQuery) {
  2620. this._rawQuery = this._state.query;
  2621. this._normalizedQuery = normalize(this._state.query);
  2622. }
  2623. return this._normalizedQuery;
  2624. }
  2625. _shouldDirtyMatch(cmd, state) {
  2626. if (state.query !== this._state.query) {
  2627. return true;
  2628. }
  2629. switch (cmd) {
  2630. case "findagain":
  2631. const pageNumber = this._selected.pageIdx + 1;
  2632. const linkService = this._linkService;
  2633. if (pageNumber >= 1 && pageNumber <= linkService.pagesCount && pageNumber !== linkService.page && !linkService.isPageVisible(pageNumber)) {
  2634. return true;
  2635. }
  2636. return false;
  2637. case "findhighlightallchange":
  2638. return false;
  2639. }
  2640. return true;
  2641. }
  2642. _prepareMatches(matchesWithLength, matches, matchesLength) {
  2643. function isSubTerm(currentIndex) {
  2644. const currentElem = matchesWithLength[currentIndex];
  2645. const nextElem = matchesWithLength[currentIndex + 1];
  2646. if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {
  2647. currentElem.skipped = true;
  2648. return true;
  2649. }
  2650. for (let i = currentIndex - 1; i >= 0; i--) {
  2651. const prevElem = matchesWithLength[i];
  2652. if (prevElem.skipped) {
  2653. continue;
  2654. }
  2655. if (prevElem.match + prevElem.matchLength < currentElem.match) {
  2656. break;
  2657. }
  2658. if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {
  2659. currentElem.skipped = true;
  2660. return true;
  2661. }
  2662. }
  2663. return false;
  2664. }
  2665. matchesWithLength.sort(function (a, b) {
  2666. return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match;
  2667. });
  2668. for (let i = 0, len = matchesWithLength.length; i < len; i++) {
  2669. if (isSubTerm(i)) {
  2670. continue;
  2671. }
  2672. matches.push(matchesWithLength[i].match);
  2673. matchesLength.push(matchesWithLength[i].matchLength);
  2674. }
  2675. }
  2676. _isEntireWord(content, startIdx, length) {
  2677. if (startIdx > 0) {
  2678. const first = content.charCodeAt(startIdx);
  2679. const limit = content.charCodeAt(startIdx - 1);
  2680. if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils.getCharacterType)(limit)) {
  2681. return false;
  2682. }
  2683. }
  2684. const endIdx = startIdx + length - 1;
  2685. if (endIdx < content.length - 1) {
  2686. const last = content.charCodeAt(endIdx);
  2687. const limit = content.charCodeAt(endIdx + 1);
  2688. if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils.getCharacterType)(limit)) {
  2689. return false;
  2690. }
  2691. }
  2692. return true;
  2693. }
  2694. _calculatePhraseMatch(query, pageIndex, pageContent, entireWord) {
  2695. const matches = [];
  2696. const queryLen = query.length;
  2697. let matchIdx = -queryLen;
  2698. while (true) {
  2699. matchIdx = pageContent.indexOf(query, matchIdx + queryLen);
  2700. if (matchIdx === -1) {
  2701. break;
  2702. }
  2703. if (entireWord && !this._isEntireWord(pageContent, matchIdx, queryLen)) {
  2704. continue;
  2705. }
  2706. matches.push(matchIdx);
  2707. }
  2708. this._pageMatches[pageIndex] = matches;
  2709. }
  2710. _calculateWordMatch(query, pageIndex, pageContent, entireWord) {
  2711. const matchesWithLength = [];
  2712. const queryArray = query.match(/\S+/g);
  2713. for (let i = 0, len = queryArray.length; i < len; i++) {
  2714. const subquery = queryArray[i];
  2715. const subqueryLen = subquery.length;
  2716. let matchIdx = -subqueryLen;
  2717. while (true) {
  2718. matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen);
  2719. if (matchIdx === -1) {
  2720. break;
  2721. }
  2722. if (entireWord && !this._isEntireWord(pageContent, matchIdx, subqueryLen)) {
  2723. continue;
  2724. }
  2725. matchesWithLength.push({
  2726. match: matchIdx,
  2727. matchLength: subqueryLen,
  2728. skipped: false
  2729. });
  2730. }
  2731. }
  2732. this._pageMatchesLength[pageIndex] = [];
  2733. this._pageMatches[pageIndex] = [];
  2734. this._prepareMatches(matchesWithLength, this._pageMatches[pageIndex], this._pageMatchesLength[pageIndex]);
  2735. }
  2736. _calculateMatch(pageIndex) {
  2737. let pageContent = this._pageContents[pageIndex];
  2738. let query = this._query;
  2739. const {
  2740. caseSensitive,
  2741. entireWord,
  2742. phraseSearch
  2743. } = this._state;
  2744. if (query.length === 0) {
  2745. return;
  2746. }
  2747. if (!caseSensitive) {
  2748. pageContent = pageContent.toLowerCase();
  2749. query = query.toLowerCase();
  2750. }
  2751. if (phraseSearch) {
  2752. this._calculatePhraseMatch(query, pageIndex, pageContent, entireWord);
  2753. } else {
  2754. this._calculateWordMatch(query, pageIndex, pageContent, entireWord);
  2755. }
  2756. if (this._state.highlightAll) {
  2757. this._updatePage(pageIndex);
  2758. }
  2759. if (this._resumePageIdx === pageIndex) {
  2760. this._resumePageIdx = null;
  2761. this._nextPageMatch();
  2762. }
  2763. const pageMatchesCount = this._pageMatches[pageIndex].length;
  2764. if (pageMatchesCount > 0) {
  2765. this._matchesCountTotal += pageMatchesCount;
  2766. this._updateUIResultsCount();
  2767. }
  2768. }
  2769. _extractText() {
  2770. if (this._extractTextPromises.length > 0) {
  2771. return;
  2772. }
  2773. let promise = Promise.resolve();
  2774. for (let i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
  2775. const extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
  2776. this._extractTextPromises[i] = extractTextCapability.promise;
  2777. promise = promise.then(() => {
  2778. return this._pdfDocument.getPage(i + 1).then(pdfPage => {
  2779. return pdfPage.getTextContent({
  2780. normalizeWhitespace: true
  2781. });
  2782. }).then(textContent => {
  2783. const textItems = textContent.items;
  2784. const strBuf = [];
  2785. for (let j = 0, jj = textItems.length; j < jj; j++) {
  2786. strBuf.push(textItems[j].str);
  2787. }
  2788. this._pageContents[i] = normalize(strBuf.join(""));
  2789. extractTextCapability.resolve(i);
  2790. }, reason => {
  2791. console.error(`Unable to get text content for page ${i + 1}`, reason);
  2792. this._pageContents[i] = "";
  2793. extractTextCapability.resolve(i);
  2794. });
  2795. });
  2796. }
  2797. }
  2798. _updatePage(index) {
  2799. if (this._scrollMatches && this._selected.pageIdx === index) {
  2800. this._linkService.page = index + 1;
  2801. }
  2802. this._eventBus.dispatch("updatetextlayermatches", {
  2803. source: this,
  2804. pageIndex: index
  2805. });
  2806. }
  2807. _updateAllPages() {
  2808. this._eventBus.dispatch("updatetextlayermatches", {
  2809. source: this,
  2810. pageIndex: -1
  2811. });
  2812. }
  2813. _nextMatch() {
  2814. const previous = this._state.findPrevious;
  2815. const currentPageIndex = this._linkService.page - 1;
  2816. const numPages = this._linkService.pagesCount;
  2817. this._highlightMatches = true;
  2818. if (this._dirtyMatch) {
  2819. this._dirtyMatch = false;
  2820. this._selected.pageIdx = this._selected.matchIdx = -1;
  2821. this._offset.pageIdx = currentPageIndex;
  2822. this._offset.matchIdx = null;
  2823. this._offset.wrapped = false;
  2824. this._resumePageIdx = null;
  2825. this._pageMatches.length = 0;
  2826. this._pageMatchesLength.length = 0;
  2827. this._matchesCountTotal = 0;
  2828. this._updateAllPages();
  2829. for (let i = 0; i < numPages; i++) {
  2830. if (this._pendingFindMatches[i] === true) {
  2831. continue;
  2832. }
  2833. this._pendingFindMatches[i] = true;
  2834. this._extractTextPromises[i].then(pageIdx => {
  2835. delete this._pendingFindMatches[pageIdx];
  2836. this._calculateMatch(pageIdx);
  2837. });
  2838. }
  2839. }
  2840. if (this._query === "") {
  2841. this._updateUIState(FindState.FOUND);
  2842. return;
  2843. }
  2844. if (this._resumePageIdx) {
  2845. return;
  2846. }
  2847. const offset = this._offset;
  2848. this._pagesToSearch = numPages;
  2849. if (offset.matchIdx !== null) {
  2850. const numPageMatches = this._pageMatches[offset.pageIdx].length;
  2851. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  2852. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  2853. this._updateMatch(true);
  2854. return;
  2855. }
  2856. this._advanceOffsetPage(previous);
  2857. }
  2858. this._nextPageMatch();
  2859. }
  2860. _matchesReady(matches) {
  2861. const offset = this._offset;
  2862. const numMatches = matches.length;
  2863. const previous = this._state.findPrevious;
  2864. if (numMatches) {
  2865. offset.matchIdx = previous ? numMatches - 1 : 0;
  2866. this._updateMatch(true);
  2867. return true;
  2868. }
  2869. this._advanceOffsetPage(previous);
  2870. if (offset.wrapped) {
  2871. offset.matchIdx = null;
  2872. if (this._pagesToSearch < 0) {
  2873. this._updateMatch(false);
  2874. return true;
  2875. }
  2876. }
  2877. return false;
  2878. }
  2879. _nextPageMatch() {
  2880. if (this._resumePageIdx !== null) {
  2881. console.error("There can only be one pending page.");
  2882. }
  2883. let matches = null;
  2884. do {
  2885. const pageIdx = this._offset.pageIdx;
  2886. matches = this._pageMatches[pageIdx];
  2887. if (!matches) {
  2888. this._resumePageIdx = pageIdx;
  2889. break;
  2890. }
  2891. } while (!this._matchesReady(matches));
  2892. }
  2893. _advanceOffsetPage(previous) {
  2894. const offset = this._offset;
  2895. const numPages = this._linkService.pagesCount;
  2896. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  2897. offset.matchIdx = null;
  2898. this._pagesToSearch--;
  2899. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  2900. offset.pageIdx = previous ? numPages - 1 : 0;
  2901. offset.wrapped = true;
  2902. }
  2903. }
  2904. _updateMatch(found = false) {
  2905. let state = FindState.NOT_FOUND;
  2906. const wrapped = this._offset.wrapped;
  2907. this._offset.wrapped = false;
  2908. if (found) {
  2909. const previousPage = this._selected.pageIdx;
  2910. this._selected.pageIdx = this._offset.pageIdx;
  2911. this._selected.matchIdx = this._offset.matchIdx;
  2912. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  2913. if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {
  2914. this._updatePage(previousPage);
  2915. }
  2916. }
  2917. this._updateUIState(state, this._state.findPrevious);
  2918. if (this._selected.pageIdx !== -1) {
  2919. this._scrollMatches = true;
  2920. this._updatePage(this._selected.pageIdx);
  2921. }
  2922. }
  2923. _onFindBarClose(evt) {
  2924. const pdfDocument = this._pdfDocument;
  2925. this._firstPageCapability.promise.then(() => {
  2926. if (!this._pdfDocument || pdfDocument && this._pdfDocument !== pdfDocument) {
  2927. return;
  2928. }
  2929. if (this._findTimeout) {
  2930. clearTimeout(this._findTimeout);
  2931. this._findTimeout = null;
  2932. }
  2933. if (this._resumePageIdx) {
  2934. this._resumePageIdx = null;
  2935. this._dirtyMatch = true;
  2936. }
  2937. this._updateUIState(FindState.FOUND);
  2938. this._highlightMatches = false;
  2939. this._updateAllPages();
  2940. });
  2941. }
  2942. _requestMatchesCount() {
  2943. const {
  2944. pageIdx,
  2945. matchIdx
  2946. } = this._selected;
  2947. let current = 0,
  2948. total = this._matchesCountTotal;
  2949. if (matchIdx !== -1) {
  2950. for (let i = 0; i < pageIdx; i++) {
  2951. current += this._pageMatches[i] && this._pageMatches[i].length || 0;
  2952. }
  2953. current += matchIdx + 1;
  2954. }
  2955. if (current < 1 || current > total) {
  2956. current = total = 0;
  2957. }
  2958. return {
  2959. current,
  2960. total
  2961. };
  2962. }
  2963. _updateUIResultsCount() {
  2964. this._eventBus.dispatch("updatefindmatchescount", {
  2965. source: this,
  2966. matchesCount: this._requestMatchesCount()
  2967. });
  2968. }
  2969. _updateUIState(state, previous) {
  2970. this._eventBus.dispatch("updatefindcontrolstate", {
  2971. source: this,
  2972. state,
  2973. previous,
  2974. matchesCount: this._requestMatchesCount(),
  2975. rawQuery: this._state ? this._state.query : null
  2976. });
  2977. }
  2978. }
  2979. exports.PDFFindController = PDFFindController;
  2980. /***/ }),
  2981. /* 11 */
  2982. /***/ (function(module, exports, __w_pdfjs_require__) {
  2983. "use strict";
  2984. Object.defineProperty(exports, "__esModule", {
  2985. value: true
  2986. });
  2987. exports.getCharacterType = getCharacterType;
  2988. exports.CharacterType = void 0;
  2989. const CharacterType = {
  2990. SPACE: 0,
  2991. ALPHA_LETTER: 1,
  2992. PUNCT: 2,
  2993. HAN_LETTER: 3,
  2994. KATAKANA_LETTER: 4,
  2995. HIRAGANA_LETTER: 5,
  2996. HALFWIDTH_KATAKANA_LETTER: 6,
  2997. THAI_LETTER: 7
  2998. };
  2999. exports.CharacterType = CharacterType;
  3000. function isAlphabeticalScript(charCode) {
  3001. return charCode < 0x2e80;
  3002. }
  3003. function isAscii(charCode) {
  3004. return (charCode & 0xff80) === 0;
  3005. }
  3006. function isAsciiAlpha(charCode) {
  3007. return charCode >= 0x61 && charCode <= 0x7a || charCode >= 0x41 && charCode <= 0x5a;
  3008. }
  3009. function isAsciiDigit(charCode) {
  3010. return charCode >= 0x30 && charCode <= 0x39;
  3011. }
  3012. function isAsciiSpace(charCode) {
  3013. return charCode === 0x20 || charCode === 0x09 || charCode === 0x0d || charCode === 0x0a;
  3014. }
  3015. function isHan(charCode) {
  3016. return charCode >= 0x3400 && charCode <= 0x9fff || charCode >= 0xf900 && charCode <= 0xfaff;
  3017. }
  3018. function isKatakana(charCode) {
  3019. return charCode >= 0x30a0 && charCode <= 0x30ff;
  3020. }
  3021. function isHiragana(charCode) {
  3022. return charCode >= 0x3040 && charCode <= 0x309f;
  3023. }
  3024. function isHalfwidthKatakana(charCode) {
  3025. return charCode >= 0xff60 && charCode <= 0xff9f;
  3026. }
  3027. function isThai(charCode) {
  3028. return (charCode & 0xff80) === 0x0e00;
  3029. }
  3030. function getCharacterType(charCode) {
  3031. if (isAlphabeticalScript(charCode)) {
  3032. if (isAscii(charCode)) {
  3033. if (isAsciiSpace(charCode)) {
  3034. return CharacterType.SPACE;
  3035. } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5f) {
  3036. return CharacterType.ALPHA_LETTER;
  3037. }
  3038. return CharacterType.PUNCT;
  3039. } else if (isThai(charCode)) {
  3040. return CharacterType.THAI_LETTER;
  3041. } else if (charCode === 0xa0) {
  3042. return CharacterType.SPACE;
  3043. }
  3044. return CharacterType.ALPHA_LETTER;
  3045. }
  3046. if (isHan(charCode)) {
  3047. return CharacterType.HAN_LETTER;
  3048. } else if (isKatakana(charCode)) {
  3049. return CharacterType.KATAKANA_LETTER;
  3050. } else if (isHiragana(charCode)) {
  3051. return CharacterType.HIRAGANA_LETTER;
  3052. } else if (isHalfwidthKatakana(charCode)) {
  3053. return CharacterType.HALFWIDTH_KATAKANA_LETTER;
  3054. }
  3055. return CharacterType.ALPHA_LETTER;
  3056. }
  3057. /***/ }),
  3058. /* 12 */
  3059. /***/ (function(module, exports, __w_pdfjs_require__) {
  3060. "use strict";
  3061. Object.defineProperty(exports, "__esModule", {
  3062. value: true
  3063. });
  3064. exports.isDestHashesEqual = isDestHashesEqual;
  3065. exports.isDestArraysEqual = isDestArraysEqual;
  3066. exports.PDFHistory = void 0;
  3067. var _ui_utils = __w_pdfjs_require__(3);
  3068. const HASH_CHANGE_TIMEOUT = 1000;
  3069. const POSITION_UPDATED_THRESHOLD = 50;
  3070. const UPDATE_VIEWAREA_TIMEOUT = 1000;
  3071. function getCurrentHash() {
  3072. return document.location.hash;
  3073. }
  3074. class PDFHistory {
  3075. constructor({
  3076. linkService,
  3077. eventBus
  3078. }) {
  3079. this.linkService = linkService;
  3080. this.eventBus = eventBus;
  3081. this._initialized = false;
  3082. this._fingerprint = "";
  3083. this.reset();
  3084. this._boundEvents = null;
  3085. this._isViewerInPresentationMode = false;
  3086. this.eventBus._on("presentationmodechanged", evt => {
  3087. this._isViewerInPresentationMode = evt.active || evt.switchInProgress;
  3088. });
  3089. this.eventBus._on("pagesinit", () => {
  3090. this._isPagesLoaded = false;
  3091. const onPagesLoaded = evt => {
  3092. this.eventBus._off("pagesloaded", onPagesLoaded);
  3093. this._isPagesLoaded = !!evt.pagesCount;
  3094. };
  3095. this.eventBus._on("pagesloaded", onPagesLoaded);
  3096. });
  3097. }
  3098. initialize({
  3099. fingerprint,
  3100. resetHistory = false,
  3101. updateUrl = false
  3102. }) {
  3103. if (!fingerprint || typeof fingerprint !== "string") {
  3104. console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
  3105. return;
  3106. }
  3107. if (this._initialized) {
  3108. this.reset();
  3109. }
  3110. const reInitialized = this._fingerprint !== "" && this._fingerprint !== fingerprint;
  3111. this._fingerprint = fingerprint;
  3112. this._updateUrl = updateUrl === true;
  3113. this._initialized = true;
  3114. this._bindEvents();
  3115. const state = window.history.state;
  3116. this._popStateInProgress = false;
  3117. this._blockHashChange = 0;
  3118. this._currentHash = getCurrentHash();
  3119. this._numPositionUpdates = 0;
  3120. this._uid = this._maxUid = 0;
  3121. this._destination = null;
  3122. this._position = null;
  3123. if (!this._isValidState(state, true) || resetHistory) {
  3124. const {
  3125. hash,
  3126. page,
  3127. rotation
  3128. } = this._parseCurrentHash(true);
  3129. if (!hash || reInitialized || resetHistory) {
  3130. this._pushOrReplaceState(null, true);
  3131. return;
  3132. }
  3133. this._pushOrReplaceState({
  3134. hash,
  3135. page,
  3136. rotation
  3137. }, true);
  3138. return;
  3139. }
  3140. const destination = state.destination;
  3141. this._updateInternalState(destination, state.uid, true);
  3142. if (this._uid > this._maxUid) {
  3143. this._maxUid = this._uid;
  3144. }
  3145. if (destination.rotation !== undefined) {
  3146. this._initialRotation = destination.rotation;
  3147. }
  3148. if (destination.dest) {
  3149. this._initialBookmark = JSON.stringify(destination.dest);
  3150. this._destination.page = null;
  3151. } else if (destination.hash) {
  3152. this._initialBookmark = destination.hash;
  3153. } else if (destination.page) {
  3154. this._initialBookmark = `page=${destination.page}`;
  3155. }
  3156. }
  3157. reset() {
  3158. if (this._initialized) {
  3159. this._pageHide();
  3160. this._initialized = false;
  3161. this._unbindEvents();
  3162. }
  3163. if (this._updateViewareaTimeout) {
  3164. clearTimeout(this._updateViewareaTimeout);
  3165. this._updateViewareaTimeout = null;
  3166. }
  3167. this._initialBookmark = null;
  3168. this._initialRotation = null;
  3169. }
  3170. push({
  3171. namedDest = null,
  3172. explicitDest,
  3173. pageNumber
  3174. }) {
  3175. if (!this._initialized) {
  3176. return;
  3177. }
  3178. if (namedDest && typeof namedDest !== "string") {
  3179. console.error("PDFHistory.push: " + `"${namedDest}" is not a valid namedDest parameter.`);
  3180. return;
  3181. } else if (!Array.isArray(explicitDest)) {
  3182. console.error("PDFHistory.push: " + `"${explicitDest}" is not a valid explicitDest parameter.`);
  3183. return;
  3184. } else if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {
  3185. if (pageNumber !== null || this._destination) {
  3186. console.error("PDFHistory.push: " + `"${pageNumber}" is not a valid pageNumber parameter.`);
  3187. return;
  3188. }
  3189. }
  3190. const hash = namedDest || JSON.stringify(explicitDest);
  3191. if (!hash) {
  3192. return;
  3193. }
  3194. let forceReplace = false;
  3195. if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
  3196. if (this._destination.page) {
  3197. return;
  3198. }
  3199. forceReplace = true;
  3200. }
  3201. if (this._popStateInProgress && !forceReplace) {
  3202. return;
  3203. }
  3204. this._pushOrReplaceState({
  3205. dest: explicitDest,
  3206. hash,
  3207. page: pageNumber,
  3208. rotation: this.linkService.rotation
  3209. }, forceReplace);
  3210. if (!this._popStateInProgress) {
  3211. this._popStateInProgress = true;
  3212. Promise.resolve().then(() => {
  3213. this._popStateInProgress = false;
  3214. });
  3215. }
  3216. }
  3217. pushCurrentPosition() {
  3218. if (!this._initialized || this._popStateInProgress) {
  3219. return;
  3220. }
  3221. this._tryPushCurrentPosition();
  3222. }
  3223. back() {
  3224. if (!this._initialized || this._popStateInProgress) {
  3225. return;
  3226. }
  3227. const state = window.history.state;
  3228. if (this._isValidState(state) && state.uid > 0) {
  3229. window.history.back();
  3230. }
  3231. }
  3232. forward() {
  3233. if (!this._initialized || this._popStateInProgress) {
  3234. return;
  3235. }
  3236. const state = window.history.state;
  3237. if (this._isValidState(state) && state.uid < this._maxUid) {
  3238. window.history.forward();
  3239. }
  3240. }
  3241. get popStateInProgress() {
  3242. return this._initialized && (this._popStateInProgress || this._blockHashChange > 0);
  3243. }
  3244. get initialBookmark() {
  3245. return this._initialized ? this._initialBookmark : null;
  3246. }
  3247. get initialRotation() {
  3248. return this._initialized ? this._initialRotation : null;
  3249. }
  3250. _pushOrReplaceState(destination, forceReplace = false) {
  3251. const shouldReplace = forceReplace || !this._destination;
  3252. const newState = {
  3253. fingerprint: this._fingerprint,
  3254. uid: shouldReplace ? this._uid : this._uid + 1,
  3255. destination
  3256. };
  3257. this._updateInternalState(destination, newState.uid);
  3258. let newUrl;
  3259. if (this._updateUrl && destination && destination.hash) {
  3260. const baseUrl = document.location.href.split("#")[0];
  3261. if (!baseUrl.startsWith("file://")) {
  3262. newUrl = `${baseUrl}#${destination.hash}`;
  3263. }
  3264. }
  3265. if (shouldReplace) {
  3266. window.history.replaceState(newState, "", newUrl);
  3267. } else {
  3268. this._maxUid = this._uid;
  3269. window.history.pushState(newState, "", newUrl);
  3270. }
  3271. }
  3272. _tryPushCurrentPosition(temporary = false) {
  3273. if (!this._position) {
  3274. return;
  3275. }
  3276. let position = this._position;
  3277. if (temporary) {
  3278. position = Object.assign(Object.create(null), this._position);
  3279. position.temporary = true;
  3280. }
  3281. if (!this._destination) {
  3282. this._pushOrReplaceState(position);
  3283. return;
  3284. }
  3285. if (this._destination.temporary) {
  3286. this._pushOrReplaceState(position, true);
  3287. return;
  3288. }
  3289. if (this._destination.hash === position.hash) {
  3290. return;
  3291. }
  3292. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  3293. return;
  3294. }
  3295. let forceReplace = false;
  3296. if (this._destination.page >= position.first && this._destination.page <= position.page) {
  3297. if (this._destination.dest || !this._destination.first) {
  3298. return;
  3299. }
  3300. forceReplace = true;
  3301. }
  3302. this._pushOrReplaceState(position, forceReplace);
  3303. }
  3304. _isValidState(state, checkReload = false) {
  3305. if (!state) {
  3306. return false;
  3307. }
  3308. if (state.fingerprint !== this._fingerprint) {
  3309. if (checkReload) {
  3310. if (typeof state.fingerprint !== "string" || state.fingerprint.length !== this._fingerprint.length) {
  3311. return false;
  3312. }
  3313. const [perfEntry] = performance.getEntriesByType("navigation");
  3314. if (!perfEntry || perfEntry.type !== "reload") {
  3315. return false;
  3316. }
  3317. } else {
  3318. return false;
  3319. }
  3320. }
  3321. if (!Number.isInteger(state.uid) || state.uid < 0) {
  3322. return false;
  3323. }
  3324. if (state.destination === null || typeof state.destination !== "object") {
  3325. return false;
  3326. }
  3327. return true;
  3328. }
  3329. _updateInternalState(destination, uid, removeTemporary = false) {
  3330. if (this._updateViewareaTimeout) {
  3331. clearTimeout(this._updateViewareaTimeout);
  3332. this._updateViewareaTimeout = null;
  3333. }
  3334. if (removeTemporary && destination && destination.temporary) {
  3335. delete destination.temporary;
  3336. }
  3337. this._destination = destination;
  3338. this._uid = uid;
  3339. this._numPositionUpdates = 0;
  3340. }
  3341. _parseCurrentHash(checkNameddest = false) {
  3342. const hash = unescape(getCurrentHash()).substring(1);
  3343. const params = (0, _ui_utils.parseQueryString)(hash);
  3344. const nameddest = params.nameddest || "";
  3345. let page = params.page | 0;
  3346. if (!(Number.isInteger(page) && page > 0 && page <= this.linkService.pagesCount) || checkNameddest && nameddest.length > 0) {
  3347. page = null;
  3348. }
  3349. return {
  3350. hash,
  3351. page,
  3352. rotation: this.linkService.rotation
  3353. };
  3354. }
  3355. _updateViewarea({
  3356. location
  3357. }) {
  3358. if (this._updateViewareaTimeout) {
  3359. clearTimeout(this._updateViewareaTimeout);
  3360. this._updateViewareaTimeout = null;
  3361. }
  3362. this._position = {
  3363. hash: this._isViewerInPresentationMode ? `page=${location.pageNumber}` : location.pdfOpenParams.substring(1),
  3364. page: this.linkService.page,
  3365. first: location.pageNumber,
  3366. rotation: location.rotation
  3367. };
  3368. if (this._popStateInProgress) {
  3369. return;
  3370. }
  3371. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
  3372. this._numPositionUpdates++;
  3373. }
  3374. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  3375. this._updateViewareaTimeout = setTimeout(() => {
  3376. if (!this._popStateInProgress) {
  3377. this._tryPushCurrentPosition(true);
  3378. }
  3379. this._updateViewareaTimeout = null;
  3380. }, UPDATE_VIEWAREA_TIMEOUT);
  3381. }
  3382. }
  3383. _popState({
  3384. state
  3385. }) {
  3386. const newHash = getCurrentHash(),
  3387. hashChanged = this._currentHash !== newHash;
  3388. this._currentHash = newHash;
  3389. if (!state) {
  3390. this._uid++;
  3391. const {
  3392. hash,
  3393. page,
  3394. rotation
  3395. } = this._parseCurrentHash();
  3396. this._pushOrReplaceState({
  3397. hash,
  3398. page,
  3399. rotation
  3400. }, true);
  3401. return;
  3402. }
  3403. if (!this._isValidState(state)) {
  3404. return;
  3405. }
  3406. this._popStateInProgress = true;
  3407. if (hashChanged) {
  3408. this._blockHashChange++;
  3409. (0, _ui_utils.waitOnEventOrTimeout)({
  3410. target: window,
  3411. name: "hashchange",
  3412. delay: HASH_CHANGE_TIMEOUT
  3413. }).then(() => {
  3414. this._blockHashChange--;
  3415. });
  3416. }
  3417. const destination = state.destination;
  3418. this._updateInternalState(destination, state.uid, true);
  3419. if (this._uid > this._maxUid) {
  3420. this._maxUid = this._uid;
  3421. }
  3422. if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
  3423. this.linkService.rotation = destination.rotation;
  3424. }
  3425. if (destination.dest) {
  3426. this.linkService.navigateTo(destination.dest);
  3427. } else if (destination.hash) {
  3428. this.linkService.setHash(destination.hash);
  3429. } else if (destination.page) {
  3430. this.linkService.page = destination.page;
  3431. }
  3432. Promise.resolve().then(() => {
  3433. this._popStateInProgress = false;
  3434. });
  3435. }
  3436. _pageHide() {
  3437. if (!this._destination || this._destination.temporary) {
  3438. this._tryPushCurrentPosition();
  3439. }
  3440. }
  3441. _bindEvents() {
  3442. if (this._boundEvents) {
  3443. return;
  3444. }
  3445. this._boundEvents = {
  3446. updateViewarea: this._updateViewarea.bind(this),
  3447. popState: this._popState.bind(this),
  3448. pageHide: this._pageHide.bind(this)
  3449. };
  3450. this.eventBus._on("updateviewarea", this._boundEvents.updateViewarea);
  3451. window.addEventListener("popstate", this._boundEvents.popState);
  3452. window.addEventListener("pagehide", this._boundEvents.pageHide);
  3453. }
  3454. _unbindEvents() {
  3455. if (!this._boundEvents) {
  3456. return;
  3457. }
  3458. this.eventBus._off("updateviewarea", this._boundEvents.updateViewarea);
  3459. window.removeEventListener("popstate", this._boundEvents.popState);
  3460. window.removeEventListener("pagehide", this._boundEvents.pageHide);
  3461. this._boundEvents = null;
  3462. }
  3463. }
  3464. exports.PDFHistory = PDFHistory;
  3465. function isDestHashesEqual(destHash, pushHash) {
  3466. if (typeof destHash !== "string" || typeof pushHash !== "string") {
  3467. return false;
  3468. }
  3469. if (destHash === pushHash) {
  3470. return true;
  3471. }
  3472. const {
  3473. nameddest
  3474. } = (0, _ui_utils.parseQueryString)(destHash);
  3475. if (nameddest === pushHash) {
  3476. return true;
  3477. }
  3478. return false;
  3479. }
  3480. function isDestArraysEqual(firstDest, secondDest) {
  3481. function isEntryEqual(first, second) {
  3482. if (typeof first !== typeof second) {
  3483. return false;
  3484. }
  3485. if (Array.isArray(first) || Array.isArray(second)) {
  3486. return false;
  3487. }
  3488. if (first !== null && typeof first === "object" && second !== null) {
  3489. if (Object.keys(first).length !== Object.keys(second).length) {
  3490. return false;
  3491. }
  3492. for (const key in first) {
  3493. if (!isEntryEqual(first[key], second[key])) {
  3494. return false;
  3495. }
  3496. }
  3497. return true;
  3498. }
  3499. return first === second || Number.isNaN(first) && Number.isNaN(second);
  3500. }
  3501. if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
  3502. return false;
  3503. }
  3504. if (firstDest.length !== secondDest.length) {
  3505. return false;
  3506. }
  3507. for (let i = 0, ii = firstDest.length; i < ii; i++) {
  3508. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  3509. return false;
  3510. }
  3511. }
  3512. return true;
  3513. }
  3514. /***/ }),
  3515. /* 13 */
  3516. /***/ (function(module, exports, __w_pdfjs_require__) {
  3517. "use strict";
  3518. Object.defineProperty(exports, "__esModule", {
  3519. value: true
  3520. });
  3521. exports.PDFPageView = void 0;
  3522. var _ui_utils = __w_pdfjs_require__(3);
  3523. var _pdfjsLib = __w_pdfjs_require__(2);
  3524. var _pdf_rendering_queue = __w_pdfjs_require__(14);
  3525. var _viewer_compatibility = __w_pdfjs_require__(7);
  3526. const MAX_CANVAS_PIXELS = _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216;
  3527. class PDFPageView {
  3528. constructor(options) {
  3529. const container = options.container;
  3530. const defaultViewport = options.defaultViewport;
  3531. this.id = options.id;
  3532. this.renderingId = "page" + this.id;
  3533. this.pdfPage = null;
  3534. this.pageLabel = null;
  3535. this.rotation = 0;
  3536. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  3537. this.viewport = defaultViewport;
  3538. this.pdfPageRotate = defaultViewport.rotation;
  3539. this._annotationStorage = options.annotationStorage || null;
  3540. this._optionalContentConfigPromise = options.optionalContentConfigPromise || null;
  3541. this.hasRestrictedScaling = false;
  3542. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  3543. this.imageResourcesPath = options.imageResourcesPath || "";
  3544. this.renderInteractiveForms = typeof options.renderInteractiveForms === "boolean" ? options.renderInteractiveForms : true;
  3545. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  3546. this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
  3547. this.eventBus = options.eventBus;
  3548. this.renderingQueue = options.renderingQueue;
  3549. this.textLayerFactory = options.textLayerFactory;
  3550. this.annotationLayerFactory = options.annotationLayerFactory;
  3551. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  3552. this.enableWebGL = options.enableWebGL || false;
  3553. this.l10n = options.l10n || _ui_utils.NullL10n;
  3554. this.paintTask = null;
  3555. this.paintedViewportMap = new WeakMap();
  3556. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  3557. this.resume = null;
  3558. this.error = null;
  3559. this.annotationLayer = null;
  3560. this.textLayer = null;
  3561. this.zoomLayer = null;
  3562. const div = document.createElement("div");
  3563. div.className = "page";
  3564. div.style.width = Math.floor(this.viewport.width) + "px";
  3565. div.style.height = Math.floor(this.viewport.height) + "px";
  3566. div.setAttribute("data-page-number", this.id);
  3567. this.div = div;
  3568. container.appendChild(div);
  3569. }
  3570. setPdfPage(pdfPage) {
  3571. this.pdfPage = pdfPage;
  3572. this.pdfPageRotate = pdfPage.rotate;
  3573. const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  3574. this.viewport = pdfPage.getViewport({
  3575. scale: this.scale * _ui_utils.CSS_UNITS,
  3576. rotation: totalRotation
  3577. });
  3578. this.stats = pdfPage.stats;
  3579. this.reset();
  3580. }
  3581. destroy() {
  3582. this.reset();
  3583. if (this.pdfPage) {
  3584. this.pdfPage.cleanup();
  3585. }
  3586. }
  3587. async _renderAnnotationLayer() {
  3588. let error = null;
  3589. try {
  3590. await this.annotationLayer.render(this.viewport, "display");
  3591. } catch (ex) {
  3592. error = ex;
  3593. } finally {
  3594. this.eventBus.dispatch("annotationlayerrendered", {
  3595. source: this,
  3596. pageNumber: this.id,
  3597. error
  3598. });
  3599. }
  3600. }
  3601. _resetZoomLayer(removeFromDOM = false) {
  3602. if (!this.zoomLayer) {
  3603. return;
  3604. }
  3605. const zoomLayerCanvas = this.zoomLayer.firstChild;
  3606. this.paintedViewportMap.delete(zoomLayerCanvas);
  3607. zoomLayerCanvas.width = 0;
  3608. zoomLayerCanvas.height = 0;
  3609. if (removeFromDOM) {
  3610. this.zoomLayer.remove();
  3611. }
  3612. this.zoomLayer = null;
  3613. }
  3614. reset(keepZoomLayer = false, keepAnnotations = false) {
  3615. this.cancelRendering(keepAnnotations);
  3616. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  3617. const div = this.div;
  3618. div.style.width = Math.floor(this.viewport.width) + "px";
  3619. div.style.height = Math.floor(this.viewport.height) + "px";
  3620. const childNodes = div.childNodes;
  3621. const currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
  3622. const currentAnnotationNode = keepAnnotations && this.annotationLayer && this.annotationLayer.div || null;
  3623. for (let i = childNodes.length - 1; i >= 0; i--) {
  3624. const node = childNodes[i];
  3625. if (currentZoomLayerNode === node || currentAnnotationNode === node) {
  3626. continue;
  3627. }
  3628. div.removeChild(node);
  3629. }
  3630. div.removeAttribute("data-loaded");
  3631. if (currentAnnotationNode) {
  3632. this.annotationLayer.hide();
  3633. } else if (this.annotationLayer) {
  3634. this.annotationLayer.cancel();
  3635. this.annotationLayer = null;
  3636. }
  3637. if (!currentZoomLayerNode) {
  3638. if (this.canvas) {
  3639. this.paintedViewportMap.delete(this.canvas);
  3640. this.canvas.width = 0;
  3641. this.canvas.height = 0;
  3642. delete this.canvas;
  3643. }
  3644. this._resetZoomLayer();
  3645. }
  3646. if (this.svg) {
  3647. this.paintedViewportMap.delete(this.svg);
  3648. delete this.svg;
  3649. }
  3650. this.loadingIconDiv = document.createElement("div");
  3651. this.loadingIconDiv.className = "loadingIcon";
  3652. div.appendChild(this.loadingIconDiv);
  3653. }
  3654. update(scale, rotation, optionalContentConfigPromise = null) {
  3655. this.scale = scale || this.scale;
  3656. if (typeof rotation !== "undefined") {
  3657. this.rotation = rotation;
  3658. }
  3659. if (optionalContentConfigPromise instanceof Promise) {
  3660. this._optionalContentConfigPromise = optionalContentConfigPromise;
  3661. }
  3662. const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  3663. this.viewport = this.viewport.clone({
  3664. scale: this.scale * _ui_utils.CSS_UNITS,
  3665. rotation: totalRotation
  3666. });
  3667. if (this.svg) {
  3668. this.cssTransform(this.svg, true);
  3669. this.eventBus.dispatch("pagerendered", {
  3670. source: this,
  3671. pageNumber: this.id,
  3672. cssTransform: true,
  3673. timestamp: performance.now()
  3674. });
  3675. return;
  3676. }
  3677. let isScalingRestricted = false;
  3678. if (this.canvas && this.maxCanvasPixels > 0) {
  3679. const outputScale = this.outputScale;
  3680. if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > this.maxCanvasPixels) {
  3681. isScalingRestricted = true;
  3682. }
  3683. }
  3684. if (this.canvas) {
  3685. if (this.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
  3686. this.cssTransform(this.canvas, true);
  3687. this.eventBus.dispatch("pagerendered", {
  3688. source: this,
  3689. pageNumber: this.id,
  3690. cssTransform: true,
  3691. timestamp: performance.now()
  3692. });
  3693. return;
  3694. }
  3695. if (!this.zoomLayer && !this.canvas.hasAttribute("hidden")) {
  3696. this.zoomLayer = this.canvas.parentNode;
  3697. this.zoomLayer.style.position = "absolute";
  3698. }
  3699. }
  3700. if (this.zoomLayer) {
  3701. this.cssTransform(this.zoomLayer.firstChild);
  3702. }
  3703. this.reset(true, true);
  3704. }
  3705. cancelRendering(keepAnnotations = false) {
  3706. if (this.paintTask) {
  3707. this.paintTask.cancel();
  3708. this.paintTask = null;
  3709. }
  3710. this.resume = null;
  3711. if (this.textLayer) {
  3712. this.textLayer.cancel();
  3713. this.textLayer = null;
  3714. }
  3715. if (!keepAnnotations && this.annotationLayer) {
  3716. this.annotationLayer.cancel();
  3717. this.annotationLayer = null;
  3718. }
  3719. }
  3720. cssTransform(target, redrawAnnotations = false) {
  3721. const width = this.viewport.width;
  3722. const height = this.viewport.height;
  3723. const div = this.div;
  3724. target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + "px";
  3725. target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + "px";
  3726. const relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
  3727. const absRotation = Math.abs(relativeRotation);
  3728. let scaleX = 1,
  3729. scaleY = 1;
  3730. if (absRotation === 90 || absRotation === 270) {
  3731. scaleX = height / width;
  3732. scaleY = width / height;
  3733. }
  3734. const cssTransform = "rotate(" + relativeRotation + "deg) " + "scale(" + scaleX + "," + scaleY + ")";
  3735. target.style.transform = cssTransform;
  3736. if (this.textLayer) {
  3737. const textLayerViewport = this.textLayer.viewport;
  3738. const textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
  3739. const textAbsRotation = Math.abs(textRelativeRotation);
  3740. let scale = width / textLayerViewport.width;
  3741. if (textAbsRotation === 90 || textAbsRotation === 270) {
  3742. scale = width / textLayerViewport.height;
  3743. }
  3744. const textLayerDiv = this.textLayer.textLayerDiv;
  3745. let transX, transY;
  3746. switch (textAbsRotation) {
  3747. case 0:
  3748. transX = transY = 0;
  3749. break;
  3750. case 90:
  3751. transX = 0;
  3752. transY = "-" + textLayerDiv.style.height;
  3753. break;
  3754. case 180:
  3755. transX = "-" + textLayerDiv.style.width;
  3756. transY = "-" + textLayerDiv.style.height;
  3757. break;
  3758. case 270:
  3759. transX = "-" + textLayerDiv.style.width;
  3760. transY = 0;
  3761. break;
  3762. default:
  3763. console.error("Bad rotation value.");
  3764. break;
  3765. }
  3766. textLayerDiv.style.transform = "rotate(" + textAbsRotation + "deg) " + "scale(" + scale + ", " + scale + ") " + "translate(" + transX + ", " + transY + ")";
  3767. textLayerDiv.style.transformOrigin = "0% 0%";
  3768. }
  3769. if (redrawAnnotations && this.annotationLayer) {
  3770. this._renderAnnotationLayer();
  3771. }
  3772. }
  3773. get width() {
  3774. return this.viewport.width;
  3775. }
  3776. get height() {
  3777. return this.viewport.height;
  3778. }
  3779. getPagePoint(x, y) {
  3780. return this.viewport.convertToPdfPoint(x, y);
  3781. }
  3782. draw() {
  3783. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  3784. console.error("Must be in new state before drawing");
  3785. this.reset();
  3786. }
  3787. const {
  3788. div,
  3789. pdfPage
  3790. } = this;
  3791. if (!pdfPage) {
  3792. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  3793. if (this.loadingIconDiv) {
  3794. div.removeChild(this.loadingIconDiv);
  3795. delete this.loadingIconDiv;
  3796. }
  3797. return Promise.reject(new Error("pdfPage is not loaded"));
  3798. }
  3799. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  3800. const canvasWrapper = document.createElement("div");
  3801. canvasWrapper.style.width = div.style.width;
  3802. canvasWrapper.style.height = div.style.height;
  3803. canvasWrapper.classList.add("canvasWrapper");
  3804. if (this.annotationLayer && this.annotationLayer.div) {
  3805. div.insertBefore(canvasWrapper, this.annotationLayer.div);
  3806. } else {
  3807. div.appendChild(canvasWrapper);
  3808. }
  3809. let textLayer = null;
  3810. if (this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && this.textLayerFactory) {
  3811. const textLayerDiv = document.createElement("div");
  3812. textLayerDiv.className = "textLayer";
  3813. textLayerDiv.style.width = canvasWrapper.style.width;
  3814. textLayerDiv.style.height = canvasWrapper.style.height;
  3815. if (this.annotationLayer && this.annotationLayer.div) {
  3816. div.insertBefore(textLayerDiv, this.annotationLayer.div);
  3817. } else {
  3818. div.appendChild(textLayerDiv);
  3819. }
  3820. textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.textLayerMode === _ui_utils.TextLayerMode.ENABLE_ENHANCE, this.eventBus);
  3821. }
  3822. this.textLayer = textLayer;
  3823. let renderContinueCallback = null;
  3824. if (this.renderingQueue) {
  3825. renderContinueCallback = cont => {
  3826. if (!this.renderingQueue.isHighestPriority(this)) {
  3827. this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  3828. this.resume = () => {
  3829. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  3830. cont();
  3831. };
  3832. return;
  3833. }
  3834. cont();
  3835. };
  3836. }
  3837. const finishPaintTask = async error => {
  3838. if (paintTask === this.paintTask) {
  3839. this.paintTask = null;
  3840. }
  3841. if (error instanceof _pdfjsLib.RenderingCancelledException) {
  3842. this.error = null;
  3843. return;
  3844. }
  3845. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  3846. if (this.loadingIconDiv) {
  3847. div.removeChild(this.loadingIconDiv);
  3848. delete this.loadingIconDiv;
  3849. }
  3850. this._resetZoomLayer(true);
  3851. this.error = error;
  3852. this.stats = pdfPage.stats;
  3853. this.eventBus.dispatch("pagerendered", {
  3854. source: this,
  3855. pageNumber: this.id,
  3856. cssTransform: false,
  3857. timestamp: performance.now()
  3858. });
  3859. if (error) {
  3860. throw error;
  3861. }
  3862. };
  3863. const paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
  3864. paintTask.onRenderContinue = renderContinueCallback;
  3865. this.paintTask = paintTask;
  3866. const resultPromise = paintTask.promise.then(function () {
  3867. return finishPaintTask(null).then(function () {
  3868. if (textLayer) {
  3869. const readableStream = pdfPage.streamTextContent({
  3870. normalizeWhitespace: true
  3871. });
  3872. textLayer.setTextContentStream(readableStream);
  3873. textLayer.render();
  3874. }
  3875. });
  3876. }, function (reason) {
  3877. return finishPaintTask(reason);
  3878. });
  3879. if (this.annotationLayerFactory) {
  3880. if (!this.annotationLayer) {
  3881. this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this._annotationStorage, this.imageResourcesPath, this.renderInteractiveForms, this.l10n);
  3882. }
  3883. this._renderAnnotationLayer();
  3884. }
  3885. div.setAttribute("data-loaded", true);
  3886. this.eventBus.dispatch("pagerender", {
  3887. source: this,
  3888. pageNumber: this.id
  3889. });
  3890. return resultPromise;
  3891. }
  3892. paintOnCanvas(canvasWrapper) {
  3893. const renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  3894. const result = {
  3895. promise: renderCapability.promise,
  3896. onRenderContinue(cont) {
  3897. cont();
  3898. },
  3899. cancel() {
  3900. renderTask.cancel();
  3901. }
  3902. };
  3903. const viewport = this.viewport;
  3904. const canvas = document.createElement("canvas");
  3905. this.l10n.get("page_canvas", {
  3906. page: this.id
  3907. }, "Page {{page}}").then(msg => {
  3908. canvas.setAttribute("aria-label", msg);
  3909. });
  3910. canvas.setAttribute("hidden", "hidden");
  3911. let isCanvasHidden = true;
  3912. const showCanvas = function () {
  3913. if (isCanvasHidden) {
  3914. canvas.removeAttribute("hidden");
  3915. isCanvasHidden = false;
  3916. }
  3917. };
  3918. canvasWrapper.appendChild(canvas);
  3919. this.canvas = canvas;
  3920. canvas.mozOpaque = true;
  3921. const ctx = canvas.getContext("2d", {
  3922. alpha: false
  3923. });
  3924. const outputScale = (0, _ui_utils.getOutputScale)(ctx);
  3925. this.outputScale = outputScale;
  3926. if (this.useOnlyCssZoom) {
  3927. const actualSizeViewport = viewport.clone({
  3928. scale: _ui_utils.CSS_UNITS
  3929. });
  3930. outputScale.sx *= actualSizeViewport.width / viewport.width;
  3931. outputScale.sy *= actualSizeViewport.height / viewport.height;
  3932. outputScale.scaled = true;
  3933. }
  3934. if (this.maxCanvasPixels > 0) {
  3935. const pixelsInViewport = viewport.width * viewport.height;
  3936. const maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
  3937. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  3938. outputScale.sx = maxScale;
  3939. outputScale.sy = maxScale;
  3940. outputScale.scaled = true;
  3941. this.hasRestrictedScaling = true;
  3942. } else {
  3943. this.hasRestrictedScaling = false;
  3944. }
  3945. }
  3946. const sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  3947. const sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  3948. canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
  3949. canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
  3950. canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + "px";
  3951. canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + "px";
  3952. this.paintedViewportMap.set(canvas, viewport);
  3953. const transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
  3954. const renderContext = {
  3955. canvasContext: ctx,
  3956. transform,
  3957. viewport: this.viewport,
  3958. enableWebGL: this.enableWebGL,
  3959. renderInteractiveForms: this.renderInteractiveForms,
  3960. optionalContentConfigPromise: this._optionalContentConfigPromise
  3961. };
  3962. const renderTask = this.pdfPage.render(renderContext);
  3963. renderTask.onContinue = function (cont) {
  3964. showCanvas();
  3965. if (result.onRenderContinue) {
  3966. result.onRenderContinue(cont);
  3967. } else {
  3968. cont();
  3969. }
  3970. };
  3971. renderTask.promise.then(function () {
  3972. showCanvas();
  3973. renderCapability.resolve(undefined);
  3974. }, function (error) {
  3975. showCanvas();
  3976. renderCapability.reject(error);
  3977. });
  3978. return result;
  3979. }
  3980. paintOnSvg(wrapper) {
  3981. let cancelled = false;
  3982. const ensureNotCancelled = () => {
  3983. if (cancelled) {
  3984. throw new _pdfjsLib.RenderingCancelledException(`Rendering cancelled, page ${this.id}`, "svg");
  3985. }
  3986. };
  3987. const pdfPage = this.pdfPage;
  3988. const actualSizeViewport = this.viewport.clone({
  3989. scale: _ui_utils.CSS_UNITS
  3990. });
  3991. const promise = pdfPage.getOperatorList().then(opList => {
  3992. ensureNotCancelled();
  3993. const svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
  3994. return svgGfx.getSVG(opList, actualSizeViewport).then(svg => {
  3995. ensureNotCancelled();
  3996. this.svg = svg;
  3997. this.paintedViewportMap.set(svg, actualSizeViewport);
  3998. svg.style.width = wrapper.style.width;
  3999. svg.style.height = wrapper.style.height;
  4000. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  4001. wrapper.appendChild(svg);
  4002. });
  4003. });
  4004. return {
  4005. promise,
  4006. onRenderContinue(cont) {
  4007. cont();
  4008. },
  4009. cancel() {
  4010. cancelled = true;
  4011. }
  4012. };
  4013. }
  4014. setPageLabel(label) {
  4015. this.pageLabel = typeof label === "string" ? label : null;
  4016. if (this.pageLabel !== null) {
  4017. this.div.setAttribute("data-page-label", this.pageLabel);
  4018. } else {
  4019. this.div.removeAttribute("data-page-label");
  4020. }
  4021. }
  4022. }
  4023. exports.PDFPageView = PDFPageView;
  4024. /***/ }),
  4025. /* 14 */
  4026. /***/ (function(module, exports, __w_pdfjs_require__) {
  4027. "use strict";
  4028. Object.defineProperty(exports, "__esModule", {
  4029. value: true
  4030. });
  4031. exports.PDFRenderingQueue = exports.RenderingStates = void 0;
  4032. const CLEANUP_TIMEOUT = 30000;
  4033. const RenderingStates = {
  4034. INITIAL: 0,
  4035. RUNNING: 1,
  4036. PAUSED: 2,
  4037. FINISHED: 3
  4038. };
  4039. exports.RenderingStates = RenderingStates;
  4040. class PDFRenderingQueue {
  4041. constructor() {
  4042. this.pdfViewer = null;
  4043. this.pdfThumbnailViewer = null;
  4044. this.onIdle = null;
  4045. this.highestPriorityPage = null;
  4046. this.idleTimeout = null;
  4047. this.printing = false;
  4048. this.isThumbnailViewEnabled = false;
  4049. }
  4050. setViewer(pdfViewer) {
  4051. this.pdfViewer = pdfViewer;
  4052. }
  4053. setThumbnailViewer(pdfThumbnailViewer) {
  4054. this.pdfThumbnailViewer = pdfThumbnailViewer;
  4055. }
  4056. isHighestPriority(view) {
  4057. return this.highestPriorityPage === view.renderingId;
  4058. }
  4059. renderHighestPriority(currentlyVisiblePages) {
  4060. if (this.idleTimeout) {
  4061. clearTimeout(this.idleTimeout);
  4062. this.idleTimeout = null;
  4063. }
  4064. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  4065. return;
  4066. }
  4067. if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
  4068. if (this.pdfThumbnailViewer.forceRendering()) {
  4069. return;
  4070. }
  4071. }
  4072. if (this.printing) {
  4073. return;
  4074. }
  4075. if (this.onIdle) {
  4076. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
  4077. }
  4078. }
  4079. getHighestPriority(visible, views, scrolledDown) {
  4080. const visibleViews = visible.views;
  4081. const numVisible = visibleViews.length;
  4082. if (numVisible === 0) {
  4083. return null;
  4084. }
  4085. for (let i = 0; i < numVisible; ++i) {
  4086. const view = visibleViews[i].view;
  4087. if (!this.isViewFinished(view)) {
  4088. return view;
  4089. }
  4090. }
  4091. if (scrolledDown) {
  4092. const nextPageIndex = visible.last.id;
  4093. if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {
  4094. return views[nextPageIndex];
  4095. }
  4096. } else {
  4097. const previousPageIndex = visible.first.id - 2;
  4098. if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) {
  4099. return views[previousPageIndex];
  4100. }
  4101. }
  4102. return null;
  4103. }
  4104. isViewFinished(view) {
  4105. return view.renderingState === RenderingStates.FINISHED;
  4106. }
  4107. renderView(view) {
  4108. switch (view.renderingState) {
  4109. case RenderingStates.FINISHED:
  4110. return false;
  4111. case RenderingStates.PAUSED:
  4112. this.highestPriorityPage = view.renderingId;
  4113. view.resume();
  4114. break;
  4115. case RenderingStates.RUNNING:
  4116. this.highestPriorityPage = view.renderingId;
  4117. break;
  4118. case RenderingStates.INITIAL:
  4119. this.highestPriorityPage = view.renderingId;
  4120. view.draw().finally(() => {
  4121. this.renderHighestPriority();
  4122. }).catch(reason => {
  4123. console.error(`renderView: "${reason}"`);
  4124. });
  4125. break;
  4126. }
  4127. return true;
  4128. }
  4129. }
  4130. exports.PDFRenderingQueue = PDFRenderingQueue;
  4131. /***/ }),
  4132. /* 15 */
  4133. /***/ (function(module, exports, __w_pdfjs_require__) {
  4134. "use strict";
  4135. Object.defineProperty(exports, "__esModule", {
  4136. value: true
  4137. });
  4138. exports.PDFSinglePageViewer = void 0;
  4139. var _base_viewer = __w_pdfjs_require__(16);
  4140. var _pdfjsLib = __w_pdfjs_require__(2);
  4141. class PDFSinglePageViewer extends _base_viewer.BaseViewer {
  4142. constructor(options) {
  4143. super(options);
  4144. this.eventBus._on("pagesinit", evt => {
  4145. this._ensurePageViewVisible();
  4146. });
  4147. }
  4148. get _viewerElement() {
  4149. return (0, _pdfjsLib.shadow)(this, "_viewerElement", this._shadowViewer);
  4150. }
  4151. _resetView() {
  4152. super._resetView();
  4153. this._previousPageNumber = 1;
  4154. this._shadowViewer = document.createDocumentFragment();
  4155. this._updateScrollDown = null;
  4156. }
  4157. _ensurePageViewVisible() {
  4158. const pageView = this._pages[this._currentPageNumber - 1];
  4159. const previousPageView = this._pages[this._previousPageNumber - 1];
  4160. const viewerNodes = this.viewer.childNodes;
  4161. switch (viewerNodes.length) {
  4162. case 0:
  4163. this.viewer.appendChild(pageView.div);
  4164. break;
  4165. case 1:
  4166. if (viewerNodes[0] !== previousPageView.div) {
  4167. throw new Error("_ensurePageViewVisible: Unexpected previously visible page.");
  4168. }
  4169. if (pageView === previousPageView) {
  4170. break;
  4171. }
  4172. this._shadowViewer.appendChild(previousPageView.div);
  4173. this.viewer.appendChild(pageView.div);
  4174. this.container.scrollTop = 0;
  4175. break;
  4176. default:
  4177. throw new Error("_ensurePageViewVisible: Only one page should be visible at a time.");
  4178. }
  4179. this._previousPageNumber = this._currentPageNumber;
  4180. }
  4181. _scrollUpdate() {
  4182. if (this._updateScrollDown) {
  4183. this._updateScrollDown();
  4184. }
  4185. super._scrollUpdate();
  4186. }
  4187. _scrollIntoView({
  4188. pageDiv,
  4189. pageSpot = null,
  4190. pageNumber = null
  4191. }) {
  4192. if (pageNumber) {
  4193. this._setCurrentPageNumber(pageNumber);
  4194. }
  4195. const scrolledDown = this._currentPageNumber >= this._previousPageNumber;
  4196. this._ensurePageViewVisible();
  4197. this.update();
  4198. super._scrollIntoView({
  4199. pageDiv,
  4200. pageSpot,
  4201. pageNumber
  4202. });
  4203. this._updateScrollDown = () => {
  4204. this.scroll.down = scrolledDown;
  4205. this._updateScrollDown = null;
  4206. };
  4207. }
  4208. _getVisiblePages() {
  4209. return this._getCurrentVisiblePage();
  4210. }
  4211. _updateHelper(visiblePages) {}
  4212. get _isScrollModeHorizontal() {
  4213. return (0, _pdfjsLib.shadow)(this, "_isScrollModeHorizontal", false);
  4214. }
  4215. _updateScrollMode() {}
  4216. _updateSpreadMode() {}
  4217. }
  4218. exports.PDFSinglePageViewer = PDFSinglePageViewer;
  4219. /***/ }),
  4220. /* 16 */
  4221. /***/ (function(module, exports, __w_pdfjs_require__) {
  4222. "use strict";
  4223. Object.defineProperty(exports, "__esModule", {
  4224. value: true
  4225. });
  4226. exports.BaseViewer = void 0;
  4227. var _ui_utils = __w_pdfjs_require__(3);
  4228. var _pdf_rendering_queue = __w_pdfjs_require__(14);
  4229. var _annotation_layer_builder = __w_pdfjs_require__(1);
  4230. var _pdfjsLib = __w_pdfjs_require__(2);
  4231. var _pdf_page_view = __w_pdfjs_require__(13);
  4232. var _pdf_link_service = __w_pdfjs_require__(4);
  4233. var _text_layer_builder = __w_pdfjs_require__(5);
  4234. const DEFAULT_CACHE_SIZE = 10;
  4235. function PDFPageViewBuffer(size) {
  4236. const data = [];
  4237. this.push = function (view) {
  4238. const i = data.indexOf(view);
  4239. if (i >= 0) {
  4240. data.splice(i, 1);
  4241. }
  4242. data.push(view);
  4243. if (data.length > size) {
  4244. data.shift().destroy();
  4245. }
  4246. };
  4247. this.resize = function (newSize, pagesToKeep) {
  4248. size = newSize;
  4249. if (pagesToKeep) {
  4250. const pageIdsToKeep = new Set();
  4251. for (let i = 0, iMax = pagesToKeep.length; i < iMax; ++i) {
  4252. pageIdsToKeep.add(pagesToKeep[i].id);
  4253. }
  4254. (0, _ui_utils.moveToEndOfArray)(data, function (page) {
  4255. return pageIdsToKeep.has(page.id);
  4256. });
  4257. }
  4258. while (data.length > size) {
  4259. data.shift().destroy();
  4260. }
  4261. };
  4262. }
  4263. function isSameScale(oldScale, newScale) {
  4264. if (newScale === oldScale) {
  4265. return true;
  4266. }
  4267. if (Math.abs(newScale - oldScale) < 1e-15) {
  4268. return true;
  4269. }
  4270. return false;
  4271. }
  4272. class BaseViewer {
  4273. constructor(options) {
  4274. if (this.constructor === BaseViewer) {
  4275. throw new Error("Cannot initialize BaseViewer.");
  4276. }
  4277. this._name = this.constructor.name;
  4278. this.container = options.container;
  4279. this.viewer = options.viewer || options.container.firstElementChild;
  4280. if (!(this.container instanceof HTMLDivElement && this.viewer instanceof HTMLDivElement)) {
  4281. throw new Error("Invalid `container` and/or `viewer` option.");
  4282. }
  4283. this.eventBus = options.eventBus;
  4284. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  4285. this.downloadManager = options.downloadManager || null;
  4286. this.findController = options.findController || null;
  4287. this.removePageBorders = options.removePageBorders || false;
  4288. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  4289. this.imageResourcesPath = options.imageResourcesPath || "";
  4290. this.renderInteractiveForms = typeof options.renderInteractiveForms === "boolean" ? options.renderInteractiveForms : true;
  4291. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  4292. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  4293. this.enableWebGL = options.enableWebGL || false;
  4294. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  4295. this.maxCanvasPixels = options.maxCanvasPixels;
  4296. this.l10n = options.l10n || _ui_utils.NullL10n;
  4297. this.defaultRenderingQueue = !options.renderingQueue;
  4298. if (this.defaultRenderingQueue) {
  4299. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  4300. this.renderingQueue.setViewer(this);
  4301. } else {
  4302. this.renderingQueue = options.renderingQueue;
  4303. }
  4304. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  4305. this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
  4306. this._onBeforeDraw = this._onAfterDraw = null;
  4307. this._resetView();
  4308. if (this.removePageBorders) {
  4309. this.viewer.classList.add("removePageBorders");
  4310. }
  4311. Promise.resolve().then(() => {
  4312. this.eventBus.dispatch("baseviewerinit", {
  4313. source: this
  4314. });
  4315. });
  4316. }
  4317. get pagesCount() {
  4318. return this._pages.length;
  4319. }
  4320. getPageView(index) {
  4321. return this._pages[index];
  4322. }
  4323. get pageViewsReady() {
  4324. if (!this._pagesCapability.settled) {
  4325. return false;
  4326. }
  4327. return this._pages.every(function (pageView) {
  4328. return pageView && pageView.pdfPage;
  4329. });
  4330. }
  4331. get currentPageNumber() {
  4332. return this._currentPageNumber;
  4333. }
  4334. set currentPageNumber(val) {
  4335. if (!Number.isInteger(val)) {
  4336. throw new Error("Invalid page number.");
  4337. }
  4338. if (!this.pdfDocument) {
  4339. return;
  4340. }
  4341. if (!this._setCurrentPageNumber(val, true)) {
  4342. console.error(`${this._name}.currentPageNumber: "${val}" is not a valid page.`);
  4343. }
  4344. }
  4345. _setCurrentPageNumber(val, resetCurrentPageView = false) {
  4346. if (this._currentPageNumber === val) {
  4347. if (resetCurrentPageView) {
  4348. this._resetCurrentPageView();
  4349. }
  4350. return true;
  4351. }
  4352. if (!(0 < val && val <= this.pagesCount)) {
  4353. return false;
  4354. }
  4355. this._currentPageNumber = val;
  4356. this.eventBus.dispatch("pagechanging", {
  4357. source: this,
  4358. pageNumber: val,
  4359. pageLabel: this._pageLabels && this._pageLabels[val - 1]
  4360. });
  4361. if (resetCurrentPageView) {
  4362. this._resetCurrentPageView();
  4363. }
  4364. return true;
  4365. }
  4366. get currentPageLabel() {
  4367. return this._pageLabels && this._pageLabels[this._currentPageNumber - 1];
  4368. }
  4369. set currentPageLabel(val) {
  4370. if (!this.pdfDocument) {
  4371. return;
  4372. }
  4373. let page = val | 0;
  4374. if (this._pageLabels) {
  4375. const i = this._pageLabels.indexOf(val);
  4376. if (i >= 0) {
  4377. page = i + 1;
  4378. }
  4379. }
  4380. if (!this._setCurrentPageNumber(page, true)) {
  4381. console.error(`${this._name}.currentPageLabel: "${val}" is not a valid page.`);
  4382. }
  4383. }
  4384. get currentScale() {
  4385. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
  4386. }
  4387. set currentScale(val) {
  4388. if (isNaN(val)) {
  4389. throw new Error("Invalid numeric scale.");
  4390. }
  4391. if (!this.pdfDocument) {
  4392. return;
  4393. }
  4394. this._setScale(val, false);
  4395. }
  4396. get currentScaleValue() {
  4397. return this._currentScaleValue;
  4398. }
  4399. set currentScaleValue(val) {
  4400. if (!this.pdfDocument) {
  4401. return;
  4402. }
  4403. this._setScale(val, false);
  4404. }
  4405. get pagesRotation() {
  4406. return this._pagesRotation;
  4407. }
  4408. set pagesRotation(rotation) {
  4409. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  4410. throw new Error("Invalid pages rotation angle.");
  4411. }
  4412. if (!this.pdfDocument) {
  4413. return;
  4414. }
  4415. if (this._pagesRotation === rotation) {
  4416. return;
  4417. }
  4418. this._pagesRotation = rotation;
  4419. const pageNumber = this._currentPageNumber;
  4420. for (let i = 0, ii = this._pages.length; i < ii; i++) {
  4421. const pageView = this._pages[i];
  4422. pageView.update(pageView.scale, rotation);
  4423. }
  4424. if (this._currentScaleValue) {
  4425. this._setScale(this._currentScaleValue, true);
  4426. }
  4427. this.eventBus.dispatch("rotationchanging", {
  4428. source: this,
  4429. pagesRotation: rotation,
  4430. pageNumber
  4431. });
  4432. if (this.defaultRenderingQueue) {
  4433. this.update();
  4434. }
  4435. }
  4436. get firstPagePromise() {
  4437. return this.pdfDocument ? this._firstPageCapability.promise : null;
  4438. }
  4439. get onePageRendered() {
  4440. return this.pdfDocument ? this._onePageRenderedCapability.promise : null;
  4441. }
  4442. get pagesPromise() {
  4443. return this.pdfDocument ? this._pagesCapability.promise : null;
  4444. }
  4445. get _viewerElement() {
  4446. throw new Error("Not implemented: _viewerElement");
  4447. }
  4448. _onePageRenderedOrForceFetch() {
  4449. if (!this.container.offsetParent || this._getVisiblePages().views.length === 0) {
  4450. return Promise.resolve();
  4451. }
  4452. return this._onePageRenderedCapability.promise;
  4453. }
  4454. setDocument(pdfDocument) {
  4455. if (this.pdfDocument) {
  4456. this._cancelRendering();
  4457. this._resetView();
  4458. if (this.findController) {
  4459. this.findController.setDocument(null);
  4460. }
  4461. }
  4462. this.pdfDocument = pdfDocument;
  4463. if (!pdfDocument) {
  4464. return;
  4465. }
  4466. const pagesCount = pdfDocument.numPages;
  4467. const firstPagePromise = pdfDocument.getPage(1);
  4468. const annotationStorage = pdfDocument.annotationStorage;
  4469. const optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
  4470. this._pagesCapability.promise.then(() => {
  4471. this.eventBus.dispatch("pagesloaded", {
  4472. source: this,
  4473. pagesCount
  4474. });
  4475. });
  4476. this._onBeforeDraw = evt => {
  4477. const pageView = this._pages[evt.pageNumber - 1];
  4478. if (!pageView) {
  4479. return;
  4480. }
  4481. this._buffer.push(pageView);
  4482. };
  4483. this.eventBus._on("pagerender", this._onBeforeDraw);
  4484. this._onAfterDraw = evt => {
  4485. if (evt.cssTransform || this._onePageRenderedCapability.settled) {
  4486. return;
  4487. }
  4488. this._onePageRenderedCapability.resolve();
  4489. this.eventBus._off("pagerendered", this._onAfterDraw);
  4490. this._onAfterDraw = null;
  4491. };
  4492. this.eventBus._on("pagerendered", this._onAfterDraw);
  4493. firstPagePromise.then(firstPdfPage => {
  4494. this._firstPageCapability.resolve(firstPdfPage);
  4495. this._optionalContentConfigPromise = optionalContentConfigPromise;
  4496. const scale = this.currentScale;
  4497. const viewport = firstPdfPage.getViewport({
  4498. scale: scale * _ui_utils.CSS_UNITS
  4499. });
  4500. const textLayerFactory = this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE ? this : null;
  4501. for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  4502. const pageView = new _pdf_page_view.PDFPageView({
  4503. container: this._viewerElement,
  4504. eventBus: this.eventBus,
  4505. id: pageNum,
  4506. scale,
  4507. defaultViewport: viewport.clone(),
  4508. annotationStorage,
  4509. optionalContentConfigPromise,
  4510. renderingQueue: this.renderingQueue,
  4511. textLayerFactory,
  4512. textLayerMode: this.textLayerMode,
  4513. annotationLayerFactory: this,
  4514. imageResourcesPath: this.imageResourcesPath,
  4515. renderInteractiveForms: this.renderInteractiveForms,
  4516. renderer: this.renderer,
  4517. enableWebGL: this.enableWebGL,
  4518. useOnlyCssZoom: this.useOnlyCssZoom,
  4519. maxCanvasPixels: this.maxCanvasPixels,
  4520. l10n: this.l10n
  4521. });
  4522. this._pages.push(pageView);
  4523. }
  4524. const firstPageView = this._pages[0];
  4525. if (firstPageView) {
  4526. firstPageView.setPdfPage(firstPdfPage);
  4527. this.linkService.cachePageRef(1, firstPdfPage.ref);
  4528. }
  4529. if (this._spreadMode !== _ui_utils.SpreadMode.NONE) {
  4530. this._updateSpreadMode();
  4531. }
  4532. this._onePageRenderedOrForceFetch().then(() => {
  4533. if (this.findController) {
  4534. this.findController.setDocument(pdfDocument);
  4535. }
  4536. if (pdfDocument.loadingParams.disableAutoFetch || pagesCount > 7500) {
  4537. this._pagesCapability.resolve();
  4538. return;
  4539. }
  4540. let getPagesLeft = pagesCount - 1;
  4541. if (getPagesLeft <= 0) {
  4542. this._pagesCapability.resolve();
  4543. return;
  4544. }
  4545. for (let pageNum = 2; pageNum <= pagesCount; ++pageNum) {
  4546. pdfDocument.getPage(pageNum).then(pdfPage => {
  4547. const pageView = this._pages[pageNum - 1];
  4548. if (!pageView.pdfPage) {
  4549. pageView.setPdfPage(pdfPage);
  4550. }
  4551. this.linkService.cachePageRef(pageNum, pdfPage.ref);
  4552. if (--getPagesLeft === 0) {
  4553. this._pagesCapability.resolve();
  4554. }
  4555. }, reason => {
  4556. console.error(`Unable to get page ${pageNum} to initialize viewer`, reason);
  4557. if (--getPagesLeft === 0) {
  4558. this._pagesCapability.resolve();
  4559. }
  4560. });
  4561. }
  4562. });
  4563. this.eventBus.dispatch("pagesinit", {
  4564. source: this
  4565. });
  4566. if (this.defaultRenderingQueue) {
  4567. this.update();
  4568. }
  4569. }).catch(reason => {
  4570. console.error("Unable to initialize viewer", reason);
  4571. });
  4572. }
  4573. setPageLabels(labels) {
  4574. if (!this.pdfDocument) {
  4575. return;
  4576. }
  4577. if (!labels) {
  4578. this._pageLabels = null;
  4579. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  4580. this._pageLabels = null;
  4581. console.error(`${this._name}.setPageLabels: Invalid page labels.`);
  4582. } else {
  4583. this._pageLabels = labels;
  4584. }
  4585. for (let i = 0, ii = this._pages.length; i < ii; i++) {
  4586. const pageView = this._pages[i];
  4587. const label = this._pageLabels && this._pageLabels[i];
  4588. pageView.setPageLabel(label);
  4589. }
  4590. }
  4591. _resetView() {
  4592. this._pages = [];
  4593. this._currentPageNumber = 1;
  4594. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  4595. this._currentScaleValue = null;
  4596. this._pageLabels = null;
  4597. this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  4598. this._location = null;
  4599. this._pagesRotation = 0;
  4600. this._optionalContentConfigPromise = null;
  4601. this._pagesRequests = new WeakMap();
  4602. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  4603. this._onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  4604. this._pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
  4605. this._scrollMode = _ui_utils.ScrollMode.VERTICAL;
  4606. this._spreadMode = _ui_utils.SpreadMode.NONE;
  4607. if (this._onBeforeDraw) {
  4608. this.eventBus._off("pagerender", this._onBeforeDraw);
  4609. this._onBeforeDraw = null;
  4610. }
  4611. if (this._onAfterDraw) {
  4612. this.eventBus._off("pagerendered", this._onAfterDraw);
  4613. this._onAfterDraw = null;
  4614. }
  4615. this.viewer.textContent = "";
  4616. this._updateScrollMode();
  4617. }
  4618. _scrollUpdate() {
  4619. if (this.pagesCount === 0) {
  4620. return;
  4621. }
  4622. this.update();
  4623. }
  4624. _scrollIntoView({
  4625. pageDiv,
  4626. pageSpot = null,
  4627. pageNumber = null
  4628. }) {
  4629. (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
  4630. }
  4631. _setScaleUpdatePages(newScale, newValue, noScroll = false, preset = false) {
  4632. this._currentScaleValue = newValue.toString();
  4633. if (isSameScale(this._currentScale, newScale)) {
  4634. if (preset) {
  4635. this.eventBus.dispatch("scalechanging", {
  4636. source: this,
  4637. scale: newScale,
  4638. presetValue: newValue
  4639. });
  4640. }
  4641. return;
  4642. }
  4643. for (let i = 0, ii = this._pages.length; i < ii; i++) {
  4644. this._pages[i].update(newScale);
  4645. }
  4646. this._currentScale = newScale;
  4647. if (!noScroll) {
  4648. let page = this._currentPageNumber,
  4649. dest;
  4650. if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  4651. page = this._location.pageNumber;
  4652. dest = [null, {
  4653. name: "XYZ"
  4654. }, this._location.left, this._location.top, null];
  4655. }
  4656. this.scrollPageIntoView({
  4657. pageNumber: page,
  4658. destArray: dest,
  4659. allowNegativeOffset: true
  4660. });
  4661. }
  4662. this.eventBus.dispatch("scalechanging", {
  4663. source: this,
  4664. scale: newScale,
  4665. presetValue: preset ? newValue : undefined
  4666. });
  4667. if (this.defaultRenderingQueue) {
  4668. this.update();
  4669. }
  4670. }
  4671. _setScale(value, noScroll = false) {
  4672. let scale = parseFloat(value);
  4673. if (scale > 0) {
  4674. this._setScaleUpdatePages(scale, value, noScroll, false);
  4675. } else {
  4676. const currentPage = this._pages[this._currentPageNumber - 1];
  4677. if (!currentPage) {
  4678. return;
  4679. }
  4680. const noPadding = this.isInPresentationMode || this.removePageBorders;
  4681. let hPadding = noPadding ? 0 : _ui_utils.SCROLLBAR_PADDING;
  4682. let vPadding = noPadding ? 0 : _ui_utils.VERTICAL_PADDING;
  4683. if (!noPadding && this._isScrollModeHorizontal) {
  4684. [hPadding, vPadding] = [vPadding, hPadding];
  4685. }
  4686. const pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale;
  4687. const pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  4688. switch (value) {
  4689. case "page-actual":
  4690. scale = 1;
  4691. break;
  4692. case "page-width":
  4693. scale = pageWidthScale;
  4694. break;
  4695. case "page-height":
  4696. scale = pageHeightScale;
  4697. break;
  4698. case "page-fit":
  4699. scale = Math.min(pageWidthScale, pageHeightScale);
  4700. break;
  4701. case "auto":
  4702. const horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
  4703. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  4704. break;
  4705. default:
  4706. console.error(`${this._name}._setScale: "${value}" is an unknown zoom value.`);
  4707. return;
  4708. }
  4709. this._setScaleUpdatePages(scale, value, noScroll, true);
  4710. }
  4711. }
  4712. _resetCurrentPageView() {
  4713. if (this.isInPresentationMode) {
  4714. this._setScale(this._currentScaleValue, true);
  4715. }
  4716. const pageView = this._pages[this._currentPageNumber - 1];
  4717. this._scrollIntoView({
  4718. pageDiv: pageView.div
  4719. });
  4720. }
  4721. scrollPageIntoView({
  4722. pageNumber,
  4723. destArray = null,
  4724. allowNegativeOffset = false,
  4725. ignoreDestinationZoom = false
  4726. }) {
  4727. if (!this.pdfDocument) {
  4728. return;
  4729. }
  4730. const pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1];
  4731. if (!pageView) {
  4732. console.error(`${this._name}.scrollPageIntoView: ` + `"${pageNumber}" is not a valid pageNumber parameter.`);
  4733. return;
  4734. }
  4735. if (this.isInPresentationMode || !destArray) {
  4736. this._setCurrentPageNumber(pageNumber, true);
  4737. return;
  4738. }
  4739. let x = 0,
  4740. y = 0;
  4741. let width = 0,
  4742. height = 0,
  4743. widthScale,
  4744. heightScale;
  4745. const changeOrientation = pageView.rotation % 180 !== 0;
  4746. const pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;
  4747. const pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;
  4748. let scale = 0;
  4749. switch (destArray[1].name) {
  4750. case "XYZ":
  4751. x = destArray[2];
  4752. y = destArray[3];
  4753. scale = destArray[4];
  4754. x = x !== null ? x : 0;
  4755. y = y !== null ? y : pageHeight;
  4756. break;
  4757. case "Fit":
  4758. case "FitB":
  4759. scale = "page-fit";
  4760. break;
  4761. case "FitH":
  4762. case "FitBH":
  4763. y = destArray[2];
  4764. scale = "page-width";
  4765. if (y === null && this._location) {
  4766. x = this._location.left;
  4767. y = this._location.top;
  4768. }
  4769. break;
  4770. case "FitV":
  4771. case "FitBV":
  4772. x = destArray[2];
  4773. width = pageWidth;
  4774. height = pageHeight;
  4775. scale = "page-height";
  4776. break;
  4777. case "FitR":
  4778. x = destArray[2];
  4779. y = destArray[3];
  4780. width = destArray[4] - x;
  4781. height = destArray[5] - y;
  4782. const hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  4783. const vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  4784. widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;
  4785. heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;
  4786. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  4787. break;
  4788. default:
  4789. console.error(`${this._name}.scrollPageIntoView: ` + `"${destArray[1].name}" is not a valid destination type.`);
  4790. return;
  4791. }
  4792. if (!ignoreDestinationZoom) {
  4793. if (scale && scale !== this._currentScale) {
  4794. this.currentScaleValue = scale;
  4795. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  4796. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  4797. }
  4798. }
  4799. if (scale === "page-fit" && !destArray[4]) {
  4800. this._scrollIntoView({
  4801. pageDiv: pageView.div,
  4802. pageNumber
  4803. });
  4804. return;
  4805. }
  4806. const boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  4807. let left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  4808. let top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  4809. if (!allowNegativeOffset) {
  4810. left = Math.max(left, 0);
  4811. top = Math.max(top, 0);
  4812. }
  4813. this._scrollIntoView({
  4814. pageDiv: pageView.div,
  4815. pageSpot: {
  4816. left,
  4817. top
  4818. },
  4819. pageNumber
  4820. });
  4821. }
  4822. _updateLocation(firstPage) {
  4823. const currentScale = this._currentScale;
  4824. const currentScaleValue = this._currentScaleValue;
  4825. const normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  4826. const pageNumber = firstPage.id;
  4827. let pdfOpenParams = "#page=" + pageNumber;
  4828. pdfOpenParams += "&zoom=" + normalizedScaleValue;
  4829. const currentPageView = this._pages[pageNumber - 1];
  4830. const container = this.container;
  4831. const topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  4832. const intLeft = Math.round(topLeft[0]);
  4833. const intTop = Math.round(topLeft[1]);
  4834. pdfOpenParams += "," + intLeft + "," + intTop;
  4835. this._location = {
  4836. pageNumber,
  4837. scale: normalizedScaleValue,
  4838. top: intTop,
  4839. left: intLeft,
  4840. rotation: this._pagesRotation,
  4841. pdfOpenParams
  4842. };
  4843. }
  4844. _updateHelper(visiblePages) {
  4845. throw new Error("Not implemented: _updateHelper");
  4846. }
  4847. update() {
  4848. const visible = this._getVisiblePages();
  4849. const visiblePages = visible.views,
  4850. numVisiblePages = visiblePages.length;
  4851. if (numVisiblePages === 0) {
  4852. return;
  4853. }
  4854. const newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
  4855. this._buffer.resize(newCacheSize, visiblePages);
  4856. this.renderingQueue.renderHighestPriority(visible);
  4857. this._updateHelper(visiblePages);
  4858. this._updateLocation(visible.first);
  4859. this.eventBus.dispatch("updateviewarea", {
  4860. source: this,
  4861. location: this._location
  4862. });
  4863. }
  4864. containsElement(element) {
  4865. return this.container.contains(element);
  4866. }
  4867. focus() {
  4868. this.container.focus();
  4869. }
  4870. get _isScrollModeHorizontal() {
  4871. return this.isInPresentationMode ? false : this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL;
  4872. }
  4873. get isInPresentationMode() {
  4874. return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
  4875. }
  4876. get isChangingPresentationMode() {
  4877. return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
  4878. }
  4879. get isHorizontalScrollbarEnabled() {
  4880. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  4881. }
  4882. get isVerticalScrollbarEnabled() {
  4883. return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight;
  4884. }
  4885. _getCurrentVisiblePage() {
  4886. if (!this.pagesCount) {
  4887. return {
  4888. views: []
  4889. };
  4890. }
  4891. const pageView = this._pages[this._currentPageNumber - 1];
  4892. const element = pageView.div;
  4893. const view = {
  4894. id: pageView.id,
  4895. x: element.offsetLeft + element.clientLeft,
  4896. y: element.offsetTop + element.clientTop,
  4897. view: pageView
  4898. };
  4899. return {
  4900. first: view,
  4901. last: view,
  4902. views: [view]
  4903. };
  4904. }
  4905. _getVisiblePages() {
  4906. return (0, _ui_utils.getVisibleElements)(this.container, this._pages, true, this._isScrollModeHorizontal);
  4907. }
  4908. isPageVisible(pageNumber) {
  4909. if (!this.pdfDocument) {
  4910. return false;
  4911. }
  4912. if (pageNumber < 1 || pageNumber > this.pagesCount) {
  4913. console.error(`${this._name}.isPageVisible: "${pageNumber}" is out of bounds.`);
  4914. return false;
  4915. }
  4916. return this._getVisiblePages().views.some(function (view) {
  4917. return view.id === pageNumber;
  4918. });
  4919. }
  4920. cleanup() {
  4921. for (let i = 0, ii = this._pages.length; i < ii; i++) {
  4922. if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  4923. this._pages[i].reset();
  4924. }
  4925. }
  4926. }
  4927. _cancelRendering() {
  4928. for (let i = 0, ii = this._pages.length; i < ii; i++) {
  4929. if (this._pages[i]) {
  4930. this._pages[i].cancelRendering();
  4931. }
  4932. }
  4933. }
  4934. _ensurePdfPageLoaded(pageView) {
  4935. if (pageView.pdfPage) {
  4936. return Promise.resolve(pageView.pdfPage);
  4937. }
  4938. if (this._pagesRequests.has(pageView)) {
  4939. return this._pagesRequests.get(pageView);
  4940. }
  4941. const promise = this.pdfDocument.getPage(pageView.id).then(pdfPage => {
  4942. if (!pageView.pdfPage) {
  4943. pageView.setPdfPage(pdfPage);
  4944. }
  4945. this._pagesRequests.delete(pageView);
  4946. return pdfPage;
  4947. }).catch(reason => {
  4948. console.error("Unable to get page for page view", reason);
  4949. this._pagesRequests.delete(pageView);
  4950. });
  4951. this._pagesRequests.set(pageView, promise);
  4952. return promise;
  4953. }
  4954. forceRendering(currentlyVisiblePages) {
  4955. const visiblePages = currentlyVisiblePages || this._getVisiblePages();
  4956. const scrollAhead = this._isScrollModeHorizontal ? this.scroll.right : this.scroll.down;
  4957. const pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead);
  4958. if (pageView) {
  4959. this._ensurePdfPageLoaded(pageView).then(() => {
  4960. this.renderingQueue.renderView(pageView);
  4961. });
  4962. return true;
  4963. }
  4964. return false;
  4965. }
  4966. createTextLayerBuilder(textLayerDiv, pageIndex, viewport, enhanceTextSelection = false, eventBus) {
  4967. return new _text_layer_builder.TextLayerBuilder({
  4968. textLayerDiv,
  4969. eventBus,
  4970. pageIndex,
  4971. viewport,
  4972. findController: this.isInPresentationMode ? null : this.findController,
  4973. enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection
  4974. });
  4975. }
  4976. createAnnotationLayerBuilder(pageDiv, pdfPage, annotationStorage = null, imageResourcesPath = "", renderInteractiveForms = false, l10n = _ui_utils.NullL10n) {
  4977. return new _annotation_layer_builder.AnnotationLayerBuilder({
  4978. pageDiv,
  4979. pdfPage,
  4980. annotationStorage,
  4981. imageResourcesPath,
  4982. renderInteractiveForms,
  4983. linkService: this.linkService,
  4984. downloadManager: this.downloadManager,
  4985. l10n
  4986. });
  4987. }
  4988. get hasEqualPageSizes() {
  4989. const firstPageView = this._pages[0];
  4990. for (let i = 1, ii = this._pages.length; i < ii; ++i) {
  4991. const pageView = this._pages[i];
  4992. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  4993. return false;
  4994. }
  4995. }
  4996. return true;
  4997. }
  4998. getPagesOverview() {
  4999. const pagesOverview = this._pages.map(function (pageView) {
  5000. const viewport = pageView.pdfPage.getViewport({
  5001. scale: 1
  5002. });
  5003. return {
  5004. width: viewport.width,
  5005. height: viewport.height,
  5006. rotation: viewport.rotation
  5007. };
  5008. });
  5009. if (!this.enablePrintAutoRotate) {
  5010. return pagesOverview;
  5011. }
  5012. return pagesOverview.map(function (size) {
  5013. if ((0, _ui_utils.isPortraitOrientation)(size)) {
  5014. return size;
  5015. }
  5016. return {
  5017. width: size.height,
  5018. height: size.width,
  5019. rotation: (size.rotation + 90) % 360
  5020. };
  5021. });
  5022. }
  5023. get optionalContentConfigPromise() {
  5024. if (!this.pdfDocument) {
  5025. return Promise.resolve(null);
  5026. }
  5027. if (!this._optionalContentConfigPromise) {
  5028. return this.pdfDocument.getOptionalContentConfig();
  5029. }
  5030. return this._optionalContentConfigPromise;
  5031. }
  5032. set optionalContentConfigPromise(promise) {
  5033. if (!(promise instanceof Promise)) {
  5034. throw new Error(`Invalid optionalContentConfigPromise: ${promise}`);
  5035. }
  5036. if (!this.pdfDocument) {
  5037. return;
  5038. }
  5039. if (!this._optionalContentConfigPromise) {
  5040. return;
  5041. }
  5042. this._optionalContentConfigPromise = promise;
  5043. for (const pageView of this._pages) {
  5044. pageView.update(pageView.scale, pageView.rotation, promise);
  5045. }
  5046. this.update();
  5047. this.eventBus.dispatch("optionalcontentconfigchanged", {
  5048. source: this,
  5049. promise
  5050. });
  5051. }
  5052. get scrollMode() {
  5053. return this._scrollMode;
  5054. }
  5055. set scrollMode(mode) {
  5056. if (this._scrollMode === mode) {
  5057. return;
  5058. }
  5059. if (!(0, _ui_utils.isValidScrollMode)(mode)) {
  5060. throw new Error(`Invalid scroll mode: ${mode}`);
  5061. }
  5062. this._scrollMode = mode;
  5063. this.eventBus.dispatch("scrollmodechanged", {
  5064. source: this,
  5065. mode
  5066. });
  5067. this._updateScrollMode(this._currentPageNumber);
  5068. }
  5069. _updateScrollMode(pageNumber = null) {
  5070. const scrollMode = this._scrollMode,
  5071. viewer = this.viewer;
  5072. viewer.classList.toggle("scrollHorizontal", scrollMode === _ui_utils.ScrollMode.HORIZONTAL);
  5073. viewer.classList.toggle("scrollWrapped", scrollMode === _ui_utils.ScrollMode.WRAPPED);
  5074. if (!this.pdfDocument || !pageNumber) {
  5075. return;
  5076. }
  5077. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  5078. this._setScale(this._currentScaleValue, true);
  5079. }
  5080. this._setCurrentPageNumber(pageNumber, true);
  5081. this.update();
  5082. }
  5083. get spreadMode() {
  5084. return this._spreadMode;
  5085. }
  5086. set spreadMode(mode) {
  5087. if (this._spreadMode === mode) {
  5088. return;
  5089. }
  5090. if (!(0, _ui_utils.isValidSpreadMode)(mode)) {
  5091. throw new Error(`Invalid spread mode: ${mode}`);
  5092. }
  5093. this._spreadMode = mode;
  5094. this.eventBus.dispatch("spreadmodechanged", {
  5095. source: this,
  5096. mode
  5097. });
  5098. this._updateSpreadMode(this._currentPageNumber);
  5099. }
  5100. _updateSpreadMode(pageNumber = null) {
  5101. if (!this.pdfDocument) {
  5102. return;
  5103. }
  5104. const viewer = this.viewer,
  5105. pages = this._pages;
  5106. viewer.textContent = "";
  5107. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  5108. for (let i = 0, iMax = pages.length; i < iMax; ++i) {
  5109. viewer.appendChild(pages[i].div);
  5110. }
  5111. } else {
  5112. const parity = this._spreadMode - 1;
  5113. let spread = null;
  5114. for (let i = 0, iMax = pages.length; i < iMax; ++i) {
  5115. if (spread === null) {
  5116. spread = document.createElement("div");
  5117. spread.className = "spread";
  5118. viewer.appendChild(spread);
  5119. } else if (i % 2 === parity) {
  5120. spread = spread.cloneNode(false);
  5121. viewer.appendChild(spread);
  5122. }
  5123. spread.appendChild(pages[i].div);
  5124. }
  5125. }
  5126. if (!pageNumber) {
  5127. return;
  5128. }
  5129. this._setCurrentPageNumber(pageNumber, true);
  5130. this.update();
  5131. }
  5132. }
  5133. exports.BaseViewer = BaseViewer;
  5134. /***/ }),
  5135. /* 17 */
  5136. /***/ (function(module, exports, __w_pdfjs_require__) {
  5137. "use strict";
  5138. Object.defineProperty(exports, "__esModule", {
  5139. value: true
  5140. });
  5141. exports.PDFViewer = void 0;
  5142. var _base_viewer = __w_pdfjs_require__(16);
  5143. var _pdfjsLib = __w_pdfjs_require__(2);
  5144. class PDFViewer extends _base_viewer.BaseViewer {
  5145. get _viewerElement() {
  5146. return (0, _pdfjsLib.shadow)(this, "_viewerElement", this.viewer);
  5147. }
  5148. _scrollIntoView({
  5149. pageDiv,
  5150. pageSpot = null,
  5151. pageNumber = null
  5152. }) {
  5153. if (!pageSpot && !this.isInPresentationMode) {
  5154. const left = pageDiv.offsetLeft + pageDiv.clientLeft;
  5155. const right = left + pageDiv.clientWidth;
  5156. const {
  5157. scrollLeft,
  5158. clientWidth
  5159. } = this.container;
  5160. if (this._isScrollModeHorizontal || left < scrollLeft || right > scrollLeft + clientWidth) {
  5161. pageSpot = {
  5162. left: 0,
  5163. top: 0
  5164. };
  5165. }
  5166. }
  5167. super._scrollIntoView({
  5168. pageDiv,
  5169. pageSpot,
  5170. pageNumber
  5171. });
  5172. }
  5173. _getVisiblePages() {
  5174. if (this.isInPresentationMode) {
  5175. return this._getCurrentVisiblePage();
  5176. }
  5177. return super._getVisiblePages();
  5178. }
  5179. _updateHelper(visiblePages) {
  5180. if (this.isInPresentationMode) {
  5181. return;
  5182. }
  5183. let currentId = this._currentPageNumber;
  5184. let stillFullyVisible = false;
  5185. for (const page of visiblePages) {
  5186. if (page.percent < 100) {
  5187. break;
  5188. }
  5189. if (page.id === currentId) {
  5190. stillFullyVisible = true;
  5191. break;
  5192. }
  5193. }
  5194. if (!stillFullyVisible) {
  5195. currentId = visiblePages[0].id;
  5196. }
  5197. this._setCurrentPageNumber(currentId);
  5198. }
  5199. }
  5200. exports.PDFViewer = PDFViewer;
  5201. /***/ })
  5202. /******/ ]);
  5203. });
  5204. //# sourceMappingURL=pdf_viewer.js.map