pdf_viewer.js 316 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2021 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 /******/ (() => { // webpackBootstrap
  33. /******/ "use strict";
  34. /******/ var __webpack_modules__ = ([
  35. /* 0 */,
  36. /* 1 */
  37. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  38. Object.defineProperty(exports, "__esModule", ({
  39. value: true
  40. }));
  41. exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = void 0;
  42. var _pdfjsLib = __w_pdfjs_require__(2);
  43. var _l10n_utils = __w_pdfjs_require__(3);
  44. var _pdf_link_service = __w_pdfjs_require__(6);
  45. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  46. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  47. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  48. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  49. function _iterableToArrayLimit(arr, i) { var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]); if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  50. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  51. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  52. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  53. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  54. var AnnotationLayerBuilder = /*#__PURE__*/function () {
  55. function AnnotationLayerBuilder(_ref) {
  56. var pageDiv = _ref.pageDiv,
  57. pdfPage = _ref.pdfPage,
  58. linkService = _ref.linkService,
  59. downloadManager = _ref.downloadManager,
  60. _ref$annotationStorag = _ref.annotationStorage,
  61. annotationStorage = _ref$annotationStorag === void 0 ? null : _ref$annotationStorag,
  62. _ref$imageResourcesPa = _ref.imageResourcesPath,
  63. imageResourcesPath = _ref$imageResourcesPa === void 0 ? "" : _ref$imageResourcesPa,
  64. _ref$renderInteractiv = _ref.renderInteractiveForms,
  65. renderInteractiveForms = _ref$renderInteractiv === void 0 ? true : _ref$renderInteractiv,
  66. _ref$l10n = _ref.l10n,
  67. l10n = _ref$l10n === void 0 ? _l10n_utils.NullL10n : _ref$l10n,
  68. _ref$enableScripting = _ref.enableScripting,
  69. enableScripting = _ref$enableScripting === void 0 ? false : _ref$enableScripting,
  70. _ref$hasJSActionsProm = _ref.hasJSActionsPromise,
  71. hasJSActionsPromise = _ref$hasJSActionsProm === void 0 ? null : _ref$hasJSActionsProm,
  72. _ref$mouseState = _ref.mouseState,
  73. mouseState = _ref$mouseState === void 0 ? null : _ref$mouseState;
  74. _classCallCheck(this, AnnotationLayerBuilder);
  75. this.pageDiv = pageDiv;
  76. this.pdfPage = pdfPage;
  77. this.linkService = linkService;
  78. this.downloadManager = downloadManager;
  79. this.imageResourcesPath = imageResourcesPath;
  80. this.renderInteractiveForms = renderInteractiveForms;
  81. this.l10n = l10n;
  82. this.annotationStorage = annotationStorage;
  83. this.enableScripting = enableScripting;
  84. this._hasJSActionsPromise = hasJSActionsPromise;
  85. this._mouseState = mouseState;
  86. this.div = null;
  87. this._cancelled = false;
  88. }
  89. _createClass(AnnotationLayerBuilder, [{
  90. key: "render",
  91. value: function render(viewport) {
  92. var _this = this;
  93. var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "display";
  94. return Promise.all([this.pdfPage.getAnnotations({
  95. intent: intent
  96. }), this._hasJSActionsPromise]).then(function (_ref2) {
  97. var _ref3 = _slicedToArray(_ref2, 2),
  98. annotations = _ref3[0],
  99. _ref3$ = _ref3[1],
  100. hasJSActions = _ref3$ === void 0 ? false : _ref3$;
  101. if (_this._cancelled) {
  102. return;
  103. }
  104. if (annotations.length === 0) {
  105. return;
  106. }
  107. var parameters = {
  108. viewport: viewport.clone({
  109. dontFlip: true
  110. }),
  111. div: _this.div,
  112. annotations: annotations,
  113. page: _this.pdfPage,
  114. imageResourcesPath: _this.imageResourcesPath,
  115. renderInteractiveForms: _this.renderInteractiveForms,
  116. linkService: _this.linkService,
  117. downloadManager: _this.downloadManager,
  118. annotationStorage: _this.annotationStorage,
  119. enableScripting: _this.enableScripting,
  120. hasJSActions: hasJSActions,
  121. mouseState: _this._mouseState
  122. };
  123. if (_this.div) {
  124. _pdfjsLib.AnnotationLayer.update(parameters);
  125. } else {
  126. _this.div = document.createElement("div");
  127. _this.div.className = "annotationLayer";
  128. _this.pageDiv.appendChild(_this.div);
  129. parameters.div = _this.div;
  130. _pdfjsLib.AnnotationLayer.render(parameters);
  131. _this.l10n.translate(_this.div);
  132. }
  133. });
  134. }
  135. }, {
  136. key: "cancel",
  137. value: function cancel() {
  138. this._cancelled = true;
  139. }
  140. }, {
  141. key: "hide",
  142. value: function hide() {
  143. if (!this.div) {
  144. return;
  145. }
  146. this.div.hidden = true;
  147. }
  148. }]);
  149. return AnnotationLayerBuilder;
  150. }();
  151. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  152. var DefaultAnnotationLayerFactory = /*#__PURE__*/function () {
  153. function DefaultAnnotationLayerFactory() {
  154. _classCallCheck(this, DefaultAnnotationLayerFactory);
  155. }
  156. _createClass(DefaultAnnotationLayerFactory, [{
  157. key: "createAnnotationLayerBuilder",
  158. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  159. var annotationStorage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  160. var imageResourcesPath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "";
  161. var renderInteractiveForms = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
  162. var l10n = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : _l10n_utils.NullL10n;
  163. var enableScripting = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
  164. var hasJSActionsPromise = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
  165. var mouseState = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
  166. return new AnnotationLayerBuilder({
  167. pageDiv: pageDiv,
  168. pdfPage: pdfPage,
  169. imageResourcesPath: imageResourcesPath,
  170. renderInteractiveForms: renderInteractiveForms,
  171. linkService: new _pdf_link_service.SimpleLinkService(),
  172. l10n: l10n,
  173. annotationStorage: annotationStorage,
  174. enableScripting: enableScripting,
  175. hasJSActionsPromise: hasJSActionsPromise,
  176. mouseState: mouseState
  177. });
  178. }
  179. }]);
  180. return DefaultAnnotationLayerFactory;
  181. }();
  182. exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
  183. /***/ }),
  184. /* 2 */
  185. /***/ ((module) => {
  186. var pdfjsLib;
  187. if (typeof window !== "undefined" && window["pdfjs-dist/build/pdf"]) {
  188. pdfjsLib = window["pdfjs-dist/build/pdf"];
  189. } else {
  190. pdfjsLib = require("../build/pdf.js");
  191. }
  192. module.exports = pdfjsLib;
  193. /***/ }),
  194. /* 3 */
  195. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  196. Object.defineProperty(exports, "__esModule", ({
  197. value: true
  198. }));
  199. exports.getL10nFallback = getL10nFallback;
  200. exports.NullL10n = void 0;
  201. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(4));
  202. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  203. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  204. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  205. var DEFAULT_L10N_STRINGS = {
  206. of_pages: "of {{pagesCount}}",
  207. page_of_pages: "({{pageNumber}} of {{pagesCount}})",
  208. document_properties_kb: "{{size_kb}} KB ({{size_b}} bytes)",
  209. document_properties_mb: "{{size_mb}} MB ({{size_b}} bytes)",
  210. document_properties_date_string: "{{date}}, {{time}}",
  211. document_properties_page_size_unit_inches: "in",
  212. document_properties_page_size_unit_millimeters: "mm",
  213. document_properties_page_size_orientation_portrait: "portrait",
  214. document_properties_page_size_orientation_landscape: "landscape",
  215. document_properties_page_size_name_a3: "A3",
  216. document_properties_page_size_name_a4: "A4",
  217. document_properties_page_size_name_letter: "Letter",
  218. document_properties_page_size_name_legal: "Legal",
  219. document_properties_page_size_dimension_string: "{{width}} × {{height}} {{unit}} ({{orientation}})",
  220. document_properties_page_size_dimension_name_string: "{{width}} × {{height}} {{unit}} ({{name}}, {{orientation}})",
  221. document_properties_linearized_yes: "Yes",
  222. document_properties_linearized_no: "No",
  223. print_progress_percent: "{{progress}}%",
  224. "toggle_sidebar.title": "Toggle Sidebar",
  225. "toggle_sidebar_notification2.title": "Toggle Sidebar (document contains outline/attachments/layers)",
  226. additional_layers: "Additional Layers",
  227. page_landmark: "Page {{page}}",
  228. thumb_page_title: "Page {{page}}",
  229. thumb_page_canvas: "Thumbnail of Page {{page}}",
  230. find_reached_top: "Reached top of document, continued from bottom",
  231. find_reached_bottom: "Reached end of document, continued from top",
  232. "find_match_count[one]": "{{current}} of {{total}} match",
  233. "find_match_count[other]": "{{current}} of {{total}} matches",
  234. "find_match_count_limit[one]": "More than {{limit}} match",
  235. "find_match_count_limit[other]": "More than {{limit}} matches",
  236. find_not_found: "Phrase not found",
  237. error_version_info: "PDF.js v{{version}} (build: {{build}})",
  238. error_message: "Message: {{message}}",
  239. error_stack: "Stack: {{stack}}",
  240. error_file: "File: {{file}}",
  241. error_line: "Line: {{line}}",
  242. rendering_error: "An error occurred while rendering the page.",
  243. page_scale_width: "Page Width",
  244. page_scale_fit: "Page Fit",
  245. page_scale_auto: "Automatic Zoom",
  246. page_scale_actual: "Actual Size",
  247. page_scale_percent: "{{scale}}%",
  248. loading: "Loading…",
  249. loading_error: "An error occurred while loading the PDF.",
  250. invalid_file_error: "Invalid or corrupted PDF file.",
  251. missing_file_error: "Missing PDF file.",
  252. unexpected_response_error: "Unexpected server response.",
  253. printing_not_supported: "Warning: Printing is not fully supported by this browser.",
  254. printing_not_ready: "Warning: The PDF is not fully loaded for printing.",
  255. web_fonts_disabled: "Web fonts are disabled: unable to use embedded PDF fonts."
  256. };
  257. function getL10nFallback(key, args) {
  258. switch (key) {
  259. case "find_match_count":
  260. key = "find_match_count[".concat(args.total === 1 ? "one" : "other", "]");
  261. break;
  262. case "find_match_count_limit":
  263. key = "find_match_count_limit[".concat(args.limit === 1 ? "one" : "other", "]");
  264. break;
  265. }
  266. return DEFAULT_L10N_STRINGS[key] || "";
  267. }
  268. function formatL10nValue(text, args) {
  269. if (!args) {
  270. return text;
  271. }
  272. return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function (all, name) {
  273. return name in args ? args[name] : "{{" + name + "}}";
  274. });
  275. }
  276. var NullL10n = {
  277. getLanguage: function getLanguage() {
  278. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  279. return _regenerator["default"].wrap(function _callee$(_context) {
  280. while (1) {
  281. switch (_context.prev = _context.next) {
  282. case 0:
  283. return _context.abrupt("return", "en-us");
  284. case 1:
  285. case "end":
  286. return _context.stop();
  287. }
  288. }
  289. }, _callee);
  290. }))();
  291. },
  292. getDirection: function getDirection() {
  293. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  294. return _regenerator["default"].wrap(function _callee2$(_context2) {
  295. while (1) {
  296. switch (_context2.prev = _context2.next) {
  297. case 0:
  298. return _context2.abrupt("return", "ltr");
  299. case 1:
  300. case "end":
  301. return _context2.stop();
  302. }
  303. }
  304. }, _callee2);
  305. }))();
  306. },
  307. get: function get(key) {
  308. var _arguments = arguments;
  309. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  310. var args, fallback;
  311. return _regenerator["default"].wrap(function _callee3$(_context3) {
  312. while (1) {
  313. switch (_context3.prev = _context3.next) {
  314. case 0:
  315. args = _arguments.length > 1 && _arguments[1] !== undefined ? _arguments[1] : null;
  316. fallback = _arguments.length > 2 && _arguments[2] !== undefined ? _arguments[2] : getL10nFallback(key, args);
  317. return _context3.abrupt("return", formatL10nValue(fallback, args));
  318. case 3:
  319. case "end":
  320. return _context3.stop();
  321. }
  322. }
  323. }, _callee3);
  324. }))();
  325. },
  326. translate: function translate(element) {
  327. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
  328. return _regenerator["default"].wrap(function _callee4$(_context4) {
  329. while (1) {
  330. switch (_context4.prev = _context4.next) {
  331. case 0:
  332. case "end":
  333. return _context4.stop();
  334. }
  335. }
  336. }, _callee4);
  337. }))();
  338. }
  339. };
  340. exports.NullL10n = NullL10n;
  341. /***/ }),
  342. /* 4 */
  343. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  344. module.exports = __w_pdfjs_require__(5);
  345. /***/ }),
  346. /* 5 */
  347. /***/ ((module, __unused_webpack_exports, __w_pdfjs_require__) => {
  348. /* module decorator */ module = __w_pdfjs_require__.nmd(module);
  349. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  350. var runtime = function (exports) {
  351. "use strict";
  352. var Op = Object.prototype;
  353. var hasOwn = Op.hasOwnProperty;
  354. var undefined;
  355. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  356. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  357. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  358. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  359. function define(obj, key, value) {
  360. Object.defineProperty(obj, key, {
  361. value: value,
  362. enumerable: true,
  363. configurable: true,
  364. writable: true
  365. });
  366. return obj[key];
  367. }
  368. try {
  369. define({}, "");
  370. } catch (err) {
  371. define = function define(obj, key, value) {
  372. return obj[key] = value;
  373. };
  374. }
  375. function wrap(innerFn, outerFn, self, tryLocsList) {
  376. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  377. var generator = Object.create(protoGenerator.prototype);
  378. var context = new Context(tryLocsList || []);
  379. generator._invoke = makeInvokeMethod(innerFn, self, context);
  380. return generator;
  381. }
  382. exports.wrap = wrap;
  383. function tryCatch(fn, obj, arg) {
  384. try {
  385. return {
  386. type: "normal",
  387. arg: fn.call(obj, arg)
  388. };
  389. } catch (err) {
  390. return {
  391. type: "throw",
  392. arg: err
  393. };
  394. }
  395. }
  396. var GenStateSuspendedStart = "suspendedStart";
  397. var GenStateSuspendedYield = "suspendedYield";
  398. var GenStateExecuting = "executing";
  399. var GenStateCompleted = "completed";
  400. var ContinueSentinel = {};
  401. function Generator() {}
  402. function GeneratorFunction() {}
  403. function GeneratorFunctionPrototype() {}
  404. var IteratorPrototype = {};
  405. IteratorPrototype[iteratorSymbol] = function () {
  406. return this;
  407. };
  408. var getProto = Object.getPrototypeOf;
  409. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  410. if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  411. IteratorPrototype = NativeIteratorPrototype;
  412. }
  413. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
  414. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  415. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  416. GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
  417. function defineIteratorMethods(prototype) {
  418. ["next", "throw", "return"].forEach(function (method) {
  419. define(prototype, method, function (arg) {
  420. return this._invoke(method, arg);
  421. });
  422. });
  423. }
  424. exports.isGeneratorFunction = function (genFun) {
  425. var ctor = typeof genFun === "function" && genFun.constructor;
  426. return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
  427. };
  428. exports.mark = function (genFun) {
  429. if (Object.setPrototypeOf) {
  430. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  431. } else {
  432. genFun.__proto__ = GeneratorFunctionPrototype;
  433. define(genFun, toStringTagSymbol, "GeneratorFunction");
  434. }
  435. genFun.prototype = Object.create(Gp);
  436. return genFun;
  437. };
  438. exports.awrap = function (arg) {
  439. return {
  440. __await: arg
  441. };
  442. };
  443. function AsyncIterator(generator, PromiseImpl) {
  444. function invoke(method, arg, resolve, reject) {
  445. var record = tryCatch(generator[method], generator, arg);
  446. if (record.type === "throw") {
  447. reject(record.arg);
  448. } else {
  449. var result = record.arg;
  450. var value = result.value;
  451. if (value && _typeof(value) === "object" && hasOwn.call(value, "__await")) {
  452. return PromiseImpl.resolve(value.__await).then(function (value) {
  453. invoke("next", value, resolve, reject);
  454. }, function (err) {
  455. invoke("throw", err, resolve, reject);
  456. });
  457. }
  458. return PromiseImpl.resolve(value).then(function (unwrapped) {
  459. result.value = unwrapped;
  460. resolve(result);
  461. }, function (error) {
  462. return invoke("throw", error, resolve, reject);
  463. });
  464. }
  465. }
  466. var previousPromise;
  467. function enqueue(method, arg) {
  468. function callInvokeWithMethodAndArg() {
  469. return new PromiseImpl(function (resolve, reject) {
  470. invoke(method, arg, resolve, reject);
  471. });
  472. }
  473. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  474. }
  475. this._invoke = enqueue;
  476. }
  477. defineIteratorMethods(AsyncIterator.prototype);
  478. AsyncIterator.prototype[asyncIteratorSymbol] = function () {
  479. return this;
  480. };
  481. exports.AsyncIterator = AsyncIterator;
  482. exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  483. if (PromiseImpl === void 0) PromiseImpl = Promise;
  484. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  485. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  486. return result.done ? result.value : iter.next();
  487. });
  488. };
  489. function makeInvokeMethod(innerFn, self, context) {
  490. var state = GenStateSuspendedStart;
  491. return function invoke(method, arg) {
  492. if (state === GenStateExecuting) {
  493. throw new Error("Generator is already running");
  494. }
  495. if (state === GenStateCompleted) {
  496. if (method === "throw") {
  497. throw arg;
  498. }
  499. return doneResult();
  500. }
  501. context.method = method;
  502. context.arg = arg;
  503. while (true) {
  504. var delegate = context.delegate;
  505. if (delegate) {
  506. var delegateResult = maybeInvokeDelegate(delegate, context);
  507. if (delegateResult) {
  508. if (delegateResult === ContinueSentinel) continue;
  509. return delegateResult;
  510. }
  511. }
  512. if (context.method === "next") {
  513. context.sent = context._sent = context.arg;
  514. } else if (context.method === "throw") {
  515. if (state === GenStateSuspendedStart) {
  516. state = GenStateCompleted;
  517. throw context.arg;
  518. }
  519. context.dispatchException(context.arg);
  520. } else if (context.method === "return") {
  521. context.abrupt("return", context.arg);
  522. }
  523. state = GenStateExecuting;
  524. var record = tryCatch(innerFn, self, context);
  525. if (record.type === "normal") {
  526. state = context.done ? GenStateCompleted : GenStateSuspendedYield;
  527. if (record.arg === ContinueSentinel) {
  528. continue;
  529. }
  530. return {
  531. value: record.arg,
  532. done: context.done
  533. };
  534. } else if (record.type === "throw") {
  535. state = GenStateCompleted;
  536. context.method = "throw";
  537. context.arg = record.arg;
  538. }
  539. }
  540. };
  541. }
  542. function maybeInvokeDelegate(delegate, context) {
  543. var method = delegate.iterator[context.method];
  544. if (method === undefined) {
  545. context.delegate = null;
  546. if (context.method === "throw") {
  547. if (delegate.iterator["return"]) {
  548. context.method = "return";
  549. context.arg = undefined;
  550. maybeInvokeDelegate(delegate, context);
  551. if (context.method === "throw") {
  552. return ContinueSentinel;
  553. }
  554. }
  555. context.method = "throw";
  556. context.arg = new TypeError("The iterator does not provide a 'throw' method");
  557. }
  558. return ContinueSentinel;
  559. }
  560. var record = tryCatch(method, delegate.iterator, context.arg);
  561. if (record.type === "throw") {
  562. context.method = "throw";
  563. context.arg = record.arg;
  564. context.delegate = null;
  565. return ContinueSentinel;
  566. }
  567. var info = record.arg;
  568. if (!info) {
  569. context.method = "throw";
  570. context.arg = new TypeError("iterator result is not an object");
  571. context.delegate = null;
  572. return ContinueSentinel;
  573. }
  574. if (info.done) {
  575. context[delegate.resultName] = info.value;
  576. context.next = delegate.nextLoc;
  577. if (context.method !== "return") {
  578. context.method = "next";
  579. context.arg = undefined;
  580. }
  581. } else {
  582. return info;
  583. }
  584. context.delegate = null;
  585. return ContinueSentinel;
  586. }
  587. defineIteratorMethods(Gp);
  588. define(Gp, toStringTagSymbol, "Generator");
  589. Gp[iteratorSymbol] = function () {
  590. return this;
  591. };
  592. Gp.toString = function () {
  593. return "[object Generator]";
  594. };
  595. function pushTryEntry(locs) {
  596. var entry = {
  597. tryLoc: locs[0]
  598. };
  599. if (1 in locs) {
  600. entry.catchLoc = locs[1];
  601. }
  602. if (2 in locs) {
  603. entry.finallyLoc = locs[2];
  604. entry.afterLoc = locs[3];
  605. }
  606. this.tryEntries.push(entry);
  607. }
  608. function resetTryEntry(entry) {
  609. var record = entry.completion || {};
  610. record.type = "normal";
  611. delete record.arg;
  612. entry.completion = record;
  613. }
  614. function Context(tryLocsList) {
  615. this.tryEntries = [{
  616. tryLoc: "root"
  617. }];
  618. tryLocsList.forEach(pushTryEntry, this);
  619. this.reset(true);
  620. }
  621. exports.keys = function (object) {
  622. var keys = [];
  623. for (var key in object) {
  624. keys.push(key);
  625. }
  626. keys.reverse();
  627. return function next() {
  628. while (keys.length) {
  629. var key = keys.pop();
  630. if (key in object) {
  631. next.value = key;
  632. next.done = false;
  633. return next;
  634. }
  635. }
  636. next.done = true;
  637. return next;
  638. };
  639. };
  640. function values(iterable) {
  641. if (iterable) {
  642. var iteratorMethod = iterable[iteratorSymbol];
  643. if (iteratorMethod) {
  644. return iteratorMethod.call(iterable);
  645. }
  646. if (typeof iterable.next === "function") {
  647. return iterable;
  648. }
  649. if (!isNaN(iterable.length)) {
  650. var i = -1,
  651. next = function next() {
  652. while (++i < iterable.length) {
  653. if (hasOwn.call(iterable, i)) {
  654. next.value = iterable[i];
  655. next.done = false;
  656. return next;
  657. }
  658. }
  659. next.value = undefined;
  660. next.done = true;
  661. return next;
  662. };
  663. return next.next = next;
  664. }
  665. }
  666. return {
  667. next: doneResult
  668. };
  669. }
  670. exports.values = values;
  671. function doneResult() {
  672. return {
  673. value: undefined,
  674. done: true
  675. };
  676. }
  677. Context.prototype = {
  678. constructor: Context,
  679. reset: function reset(skipTempReset) {
  680. this.prev = 0;
  681. this.next = 0;
  682. this.sent = this._sent = undefined;
  683. this.done = false;
  684. this.delegate = null;
  685. this.method = "next";
  686. this.arg = undefined;
  687. this.tryEntries.forEach(resetTryEntry);
  688. if (!skipTempReset) {
  689. for (var name in this) {
  690. if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
  691. this[name] = undefined;
  692. }
  693. }
  694. }
  695. },
  696. stop: function stop() {
  697. this.done = true;
  698. var rootEntry = this.tryEntries[0];
  699. var rootRecord = rootEntry.completion;
  700. if (rootRecord.type === "throw") {
  701. throw rootRecord.arg;
  702. }
  703. return this.rval;
  704. },
  705. dispatchException: function dispatchException(exception) {
  706. if (this.done) {
  707. throw exception;
  708. }
  709. var context = this;
  710. function handle(loc, caught) {
  711. record.type = "throw";
  712. record.arg = exception;
  713. context.next = loc;
  714. if (caught) {
  715. context.method = "next";
  716. context.arg = undefined;
  717. }
  718. return !!caught;
  719. }
  720. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  721. var entry = this.tryEntries[i];
  722. var record = entry.completion;
  723. if (entry.tryLoc === "root") {
  724. return handle("end");
  725. }
  726. if (entry.tryLoc <= this.prev) {
  727. var hasCatch = hasOwn.call(entry, "catchLoc");
  728. var hasFinally = hasOwn.call(entry, "finallyLoc");
  729. if (hasCatch && hasFinally) {
  730. if (this.prev < entry.catchLoc) {
  731. return handle(entry.catchLoc, true);
  732. } else if (this.prev < entry.finallyLoc) {
  733. return handle(entry.finallyLoc);
  734. }
  735. } else if (hasCatch) {
  736. if (this.prev < entry.catchLoc) {
  737. return handle(entry.catchLoc, true);
  738. }
  739. } else if (hasFinally) {
  740. if (this.prev < entry.finallyLoc) {
  741. return handle(entry.finallyLoc);
  742. }
  743. } else {
  744. throw new Error("try statement without catch or finally");
  745. }
  746. }
  747. }
  748. },
  749. abrupt: function abrupt(type, arg) {
  750. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  751. var entry = this.tryEntries[i];
  752. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  753. var finallyEntry = entry;
  754. break;
  755. }
  756. }
  757. if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
  758. finallyEntry = null;
  759. }
  760. var record = finallyEntry ? finallyEntry.completion : {};
  761. record.type = type;
  762. record.arg = arg;
  763. if (finallyEntry) {
  764. this.method = "next";
  765. this.next = finallyEntry.finallyLoc;
  766. return ContinueSentinel;
  767. }
  768. return this.complete(record);
  769. },
  770. complete: function complete(record, afterLoc) {
  771. if (record.type === "throw") {
  772. throw record.arg;
  773. }
  774. if (record.type === "break" || record.type === "continue") {
  775. this.next = record.arg;
  776. } else if (record.type === "return") {
  777. this.rval = this.arg = record.arg;
  778. this.method = "return";
  779. this.next = "end";
  780. } else if (record.type === "normal" && afterLoc) {
  781. this.next = afterLoc;
  782. }
  783. return ContinueSentinel;
  784. },
  785. finish: function finish(finallyLoc) {
  786. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  787. var entry = this.tryEntries[i];
  788. if (entry.finallyLoc === finallyLoc) {
  789. this.complete(entry.completion, entry.afterLoc);
  790. resetTryEntry(entry);
  791. return ContinueSentinel;
  792. }
  793. }
  794. },
  795. "catch": function _catch(tryLoc) {
  796. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  797. var entry = this.tryEntries[i];
  798. if (entry.tryLoc === tryLoc) {
  799. var record = entry.completion;
  800. if (record.type === "throw") {
  801. var thrown = record.arg;
  802. resetTryEntry(entry);
  803. }
  804. return thrown;
  805. }
  806. }
  807. throw new Error("illegal catch attempt");
  808. },
  809. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  810. this.delegate = {
  811. iterator: values(iterable),
  812. resultName: resultName,
  813. nextLoc: nextLoc
  814. };
  815. if (this.method === "next") {
  816. this.arg = undefined;
  817. }
  818. return ContinueSentinel;
  819. }
  820. };
  821. return exports;
  822. }(( false ? 0 : _typeof(module)) === "object" ? module.exports : {});
  823. try {
  824. regeneratorRuntime = runtime;
  825. } catch (accidentalStrictMode) {
  826. Function("r", "regeneratorRuntime = r")(runtime);
  827. }
  828. /***/ }),
  829. /* 6 */
  830. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  831. Object.defineProperty(exports, "__esModule", ({
  832. value: true
  833. }));
  834. exports.SimpleLinkService = exports.PDFLinkService = void 0;
  835. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(4));
  836. var _ui_utils = __w_pdfjs_require__(7);
  837. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  838. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  839. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  840. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  841. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  842. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  843. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  844. var PDFLinkService = /*#__PURE__*/function () {
  845. function PDFLinkService() {
  846. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  847. eventBus = _ref.eventBus,
  848. _ref$externalLinkTarg = _ref.externalLinkTarget,
  849. externalLinkTarget = _ref$externalLinkTarg === void 0 ? null : _ref$externalLinkTarg,
  850. _ref$externalLinkRel = _ref.externalLinkRel,
  851. externalLinkRel = _ref$externalLinkRel === void 0 ? null : _ref$externalLinkRel,
  852. _ref$externalLinkEnab = _ref.externalLinkEnabled,
  853. externalLinkEnabled = _ref$externalLinkEnab === void 0 ? true : _ref$externalLinkEnab,
  854. _ref$ignoreDestinatio = _ref.ignoreDestinationZoom,
  855. ignoreDestinationZoom = _ref$ignoreDestinatio === void 0 ? false : _ref$ignoreDestinatio;
  856. _classCallCheck(this, PDFLinkService);
  857. this.eventBus = eventBus;
  858. this.externalLinkTarget = externalLinkTarget;
  859. this.externalLinkRel = externalLinkRel;
  860. this.externalLinkEnabled = externalLinkEnabled;
  861. this._ignoreDestinationZoom = ignoreDestinationZoom;
  862. this.baseUrl = null;
  863. this.pdfDocument = null;
  864. this.pdfViewer = null;
  865. this.pdfHistory = null;
  866. this._pagesRefCache = null;
  867. }
  868. _createClass(PDFLinkService, [{
  869. key: "setDocument",
  870. value: function setDocument(pdfDocument) {
  871. var baseUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  872. this.baseUrl = baseUrl;
  873. this.pdfDocument = pdfDocument;
  874. this._pagesRefCache = Object.create(null);
  875. }
  876. }, {
  877. key: "setViewer",
  878. value: function setViewer(pdfViewer) {
  879. this.pdfViewer = pdfViewer;
  880. }
  881. }, {
  882. key: "setHistory",
  883. value: function setHistory(pdfHistory) {
  884. this.pdfHistory = pdfHistory;
  885. }
  886. }, {
  887. key: "pagesCount",
  888. get: function get() {
  889. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  890. }
  891. }, {
  892. key: "page",
  893. get: function get() {
  894. return this.pdfViewer.currentPageNumber;
  895. },
  896. set: function set(value) {
  897. this.pdfViewer.currentPageNumber = value;
  898. }
  899. }, {
  900. key: "rotation",
  901. get: function get() {
  902. return this.pdfViewer.pagesRotation;
  903. },
  904. set: function set(value) {
  905. this.pdfViewer.pagesRotation = value;
  906. }
  907. }, {
  908. key: "_goToDestinationHelper",
  909. value: function _goToDestinationHelper(rawDest) {
  910. var _this = this;
  911. var namedDest = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  912. var explicitDest = arguments.length > 2 ? arguments[2] : undefined;
  913. var destRef = explicitDest[0];
  914. var pageNumber;
  915. if (destRef instanceof Object) {
  916. pageNumber = this._cachedPageNumber(destRef);
  917. if (pageNumber === null) {
  918. this.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
  919. _this.cachePageRef(pageIndex + 1, destRef);
  920. _this._goToDestinationHelper(rawDest, namedDest, explicitDest);
  921. })["catch"](function () {
  922. console.error("PDFLinkService._goToDestinationHelper: \"".concat(destRef, "\" is not ") + "a valid page reference, for dest=\"".concat(rawDest, "\"."));
  923. });
  924. return;
  925. }
  926. } else if (Number.isInteger(destRef)) {
  927. pageNumber = destRef + 1;
  928. } else {
  929. console.error("PDFLinkService._goToDestinationHelper: \"".concat(destRef, "\" is not ") + "a valid destination reference, for dest=\"".concat(rawDest, "\"."));
  930. return;
  931. }
  932. if (!pageNumber || pageNumber < 1 || pageNumber > this.pagesCount) {
  933. console.error("PDFLinkService._goToDestinationHelper: \"".concat(pageNumber, "\" is not ") + "a valid page number, for dest=\"".concat(rawDest, "\"."));
  934. return;
  935. }
  936. if (this.pdfHistory) {
  937. this.pdfHistory.pushCurrentPosition();
  938. this.pdfHistory.push({
  939. namedDest: namedDest,
  940. explicitDest: explicitDest,
  941. pageNumber: pageNumber
  942. });
  943. }
  944. this.pdfViewer.scrollPageIntoView({
  945. pageNumber: pageNumber,
  946. destArray: explicitDest,
  947. ignoreDestinationZoom: this._ignoreDestinationZoom
  948. });
  949. }
  950. }, {
  951. key: "goToDestination",
  952. value: function () {
  953. var _goToDestination = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(dest) {
  954. var namedDest, explicitDest;
  955. return _regenerator["default"].wrap(function _callee$(_context) {
  956. while (1) {
  957. switch (_context.prev = _context.next) {
  958. case 0:
  959. if (this.pdfDocument) {
  960. _context.next = 2;
  961. break;
  962. }
  963. return _context.abrupt("return");
  964. case 2:
  965. if (!(typeof dest === "string")) {
  966. _context.next = 9;
  967. break;
  968. }
  969. namedDest = dest;
  970. _context.next = 6;
  971. return this.pdfDocument.getDestination(dest);
  972. case 6:
  973. explicitDest = _context.sent;
  974. _context.next = 13;
  975. break;
  976. case 9:
  977. namedDest = null;
  978. _context.next = 12;
  979. return dest;
  980. case 12:
  981. explicitDest = _context.sent;
  982. case 13:
  983. if (Array.isArray(explicitDest)) {
  984. _context.next = 16;
  985. break;
  986. }
  987. console.error("PDFLinkService.goToDestination: \"".concat(explicitDest, "\" is not ") + "a valid destination array, for dest=\"".concat(dest, "\"."));
  988. return _context.abrupt("return");
  989. case 16:
  990. this._goToDestinationHelper(dest, namedDest, explicitDest);
  991. case 17:
  992. case "end":
  993. return _context.stop();
  994. }
  995. }
  996. }, _callee, this);
  997. }));
  998. function goToDestination(_x) {
  999. return _goToDestination.apply(this, arguments);
  1000. }
  1001. return goToDestination;
  1002. }()
  1003. }, {
  1004. key: "goToPage",
  1005. value: function goToPage(val) {
  1006. if (!this.pdfDocument) {
  1007. return;
  1008. }
  1009. var pageNumber = typeof val === "string" && this.pdfViewer.pageLabelToPageNumber(val) || val | 0;
  1010. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
  1011. console.error("PDFLinkService.goToPage: \"".concat(val, "\" is not a valid page."));
  1012. return;
  1013. }
  1014. if (this.pdfHistory) {
  1015. this.pdfHistory.pushCurrentPosition();
  1016. this.pdfHistory.pushPage(pageNumber);
  1017. }
  1018. this.pdfViewer.scrollPageIntoView({
  1019. pageNumber: pageNumber
  1020. });
  1021. }
  1022. }, {
  1023. key: "getDestinationHash",
  1024. value: function getDestinationHash(dest) {
  1025. if (typeof dest === "string") {
  1026. if (dest.length > 0) {
  1027. return this.getAnchorUrl("#" + escape(dest));
  1028. }
  1029. } else if (Array.isArray(dest)) {
  1030. var str = JSON.stringify(dest);
  1031. if (str.length > 0) {
  1032. return this.getAnchorUrl("#" + escape(str));
  1033. }
  1034. }
  1035. return this.getAnchorUrl("");
  1036. }
  1037. }, {
  1038. key: "getAnchorUrl",
  1039. value: function getAnchorUrl(anchor) {
  1040. return (this.baseUrl || "") + anchor;
  1041. }
  1042. }, {
  1043. key: "setHash",
  1044. value: function setHash(hash) {
  1045. if (!this.pdfDocument) {
  1046. return;
  1047. }
  1048. var pageNumber, dest;
  1049. if (hash.includes("=")) {
  1050. var params = (0, _ui_utils.parseQueryString)(hash);
  1051. if ("search" in params) {
  1052. this.eventBus.dispatch("findfromurlhash", {
  1053. source: this,
  1054. query: params.search.replace(/"/g, ""),
  1055. phraseSearch: params.phrase === "true"
  1056. });
  1057. }
  1058. if ("page" in params) {
  1059. pageNumber = params.page | 0 || 1;
  1060. }
  1061. if ("zoom" in params) {
  1062. var zoomArgs = params.zoom.split(",");
  1063. var zoomArg = zoomArgs[0];
  1064. var zoomArgNumber = parseFloat(zoomArg);
  1065. if (!zoomArg.includes("Fit")) {
  1066. dest = [null, {
  1067. name: "XYZ"
  1068. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
  1069. } else {
  1070. if (zoomArg === "Fit" || zoomArg === "FitB") {
  1071. dest = [null, {
  1072. name: zoomArg
  1073. }];
  1074. } else if (zoomArg === "FitH" || zoomArg === "FitBH" || zoomArg === "FitV" || zoomArg === "FitBV") {
  1075. dest = [null, {
  1076. name: zoomArg
  1077. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  1078. } else if (zoomArg === "FitR") {
  1079. if (zoomArgs.length !== 5) {
  1080. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
  1081. } else {
  1082. dest = [null, {
  1083. name: zoomArg
  1084. }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
  1085. }
  1086. } else {
  1087. console.error("PDFLinkService.setHash: \"".concat(zoomArg, "\" is not ") + "a valid zoom value.");
  1088. }
  1089. }
  1090. }
  1091. if (dest) {
  1092. this.pdfViewer.scrollPageIntoView({
  1093. pageNumber: pageNumber || this.page,
  1094. destArray: dest,
  1095. allowNegativeOffset: true
  1096. });
  1097. } else if (pageNumber) {
  1098. this.page = pageNumber;
  1099. }
  1100. if ("pagemode" in params) {
  1101. this.eventBus.dispatch("pagemode", {
  1102. source: this,
  1103. mode: params.pagemode
  1104. });
  1105. }
  1106. if ("nameddest" in params) {
  1107. this.goToDestination(params.nameddest);
  1108. }
  1109. } else {
  1110. dest = unescape(hash);
  1111. try {
  1112. dest = JSON.parse(dest);
  1113. if (!Array.isArray(dest)) {
  1114. dest = dest.toString();
  1115. }
  1116. } catch (ex) {}
  1117. if (typeof dest === "string" || isValidExplicitDestination(dest)) {
  1118. this.goToDestination(dest);
  1119. return;
  1120. }
  1121. console.error("PDFLinkService.setHash: \"".concat(unescape(hash), "\" is not ") + "a valid destination.");
  1122. }
  1123. }
  1124. }, {
  1125. key: "executeNamedAction",
  1126. value: function executeNamedAction(action) {
  1127. switch (action) {
  1128. case "GoBack":
  1129. if (this.pdfHistory) {
  1130. this.pdfHistory.back();
  1131. }
  1132. break;
  1133. case "GoForward":
  1134. if (this.pdfHistory) {
  1135. this.pdfHistory.forward();
  1136. }
  1137. break;
  1138. case "NextPage":
  1139. this.pdfViewer.nextPage();
  1140. break;
  1141. case "PrevPage":
  1142. this.pdfViewer.previousPage();
  1143. break;
  1144. case "LastPage":
  1145. this.page = this.pagesCount;
  1146. break;
  1147. case "FirstPage":
  1148. this.page = 1;
  1149. break;
  1150. default:
  1151. break;
  1152. }
  1153. this.eventBus.dispatch("namedaction", {
  1154. source: this,
  1155. action: action
  1156. });
  1157. }
  1158. }, {
  1159. key: "cachePageRef",
  1160. value: function cachePageRef(pageNum, pageRef) {
  1161. if (!pageRef) {
  1162. return;
  1163. }
  1164. var refStr = pageRef.gen === 0 ? "".concat(pageRef.num, "R") : "".concat(pageRef.num, "R").concat(pageRef.gen);
  1165. this._pagesRefCache[refStr] = pageNum;
  1166. }
  1167. }, {
  1168. key: "_cachedPageNumber",
  1169. value: function _cachedPageNumber(pageRef) {
  1170. var _this$_pagesRefCache;
  1171. var refStr = pageRef.gen === 0 ? "".concat(pageRef.num, "R") : "".concat(pageRef.num, "R").concat(pageRef.gen);
  1172. return ((_this$_pagesRefCache = this._pagesRefCache) === null || _this$_pagesRefCache === void 0 ? void 0 : _this$_pagesRefCache[refStr]) || null;
  1173. }
  1174. }, {
  1175. key: "isPageVisible",
  1176. value: function isPageVisible(pageNumber) {
  1177. return this.pdfViewer.isPageVisible(pageNumber);
  1178. }
  1179. }, {
  1180. key: "isPageCached",
  1181. value: function isPageCached(pageNumber) {
  1182. return this.pdfViewer.isPageCached(pageNumber);
  1183. }
  1184. }]);
  1185. return PDFLinkService;
  1186. }();
  1187. exports.PDFLinkService = PDFLinkService;
  1188. function isValidExplicitDestination(dest) {
  1189. if (!Array.isArray(dest)) {
  1190. return false;
  1191. }
  1192. var destLength = dest.length;
  1193. if (destLength < 2) {
  1194. return false;
  1195. }
  1196. var page = dest[0];
  1197. if (!(_typeof(page) === "object" && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
  1198. return false;
  1199. }
  1200. var zoom = dest[1];
  1201. if (!(_typeof(zoom) === "object" && typeof zoom.name === "string")) {
  1202. return false;
  1203. }
  1204. var allowNull = true;
  1205. switch (zoom.name) {
  1206. case "XYZ":
  1207. if (destLength !== 5) {
  1208. return false;
  1209. }
  1210. break;
  1211. case "Fit":
  1212. case "FitB":
  1213. return destLength === 2;
  1214. case "FitH":
  1215. case "FitBH":
  1216. case "FitV":
  1217. case "FitBV":
  1218. if (destLength !== 3) {
  1219. return false;
  1220. }
  1221. break;
  1222. case "FitR":
  1223. if (destLength !== 6) {
  1224. return false;
  1225. }
  1226. allowNull = false;
  1227. break;
  1228. default:
  1229. return false;
  1230. }
  1231. for (var i = 2; i < destLength; i++) {
  1232. var param = dest[i];
  1233. if (!(typeof param === "number" || allowNull && param === null)) {
  1234. return false;
  1235. }
  1236. }
  1237. return true;
  1238. }
  1239. var SimpleLinkService = /*#__PURE__*/function () {
  1240. function SimpleLinkService() {
  1241. _classCallCheck(this, SimpleLinkService);
  1242. this.externalLinkTarget = null;
  1243. this.externalLinkRel = null;
  1244. this.externalLinkEnabled = true;
  1245. this._ignoreDestinationZoom = false;
  1246. }
  1247. _createClass(SimpleLinkService, [{
  1248. key: "pagesCount",
  1249. get: function get() {
  1250. return 0;
  1251. }
  1252. }, {
  1253. key: "page",
  1254. get: function get() {
  1255. return 0;
  1256. },
  1257. set: function set(value) {}
  1258. }, {
  1259. key: "rotation",
  1260. get: function get() {
  1261. return 0;
  1262. },
  1263. set: function set(value) {}
  1264. }, {
  1265. key: "goToDestination",
  1266. value: function () {
  1267. var _goToDestination2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(dest) {
  1268. return _regenerator["default"].wrap(function _callee2$(_context2) {
  1269. while (1) {
  1270. switch (_context2.prev = _context2.next) {
  1271. case 0:
  1272. case "end":
  1273. return _context2.stop();
  1274. }
  1275. }
  1276. }, _callee2);
  1277. }));
  1278. function goToDestination(_x2) {
  1279. return _goToDestination2.apply(this, arguments);
  1280. }
  1281. return goToDestination;
  1282. }()
  1283. }, {
  1284. key: "goToPage",
  1285. value: function goToPage(val) {}
  1286. }, {
  1287. key: "getDestinationHash",
  1288. value: function getDestinationHash(dest) {
  1289. return "#";
  1290. }
  1291. }, {
  1292. key: "getAnchorUrl",
  1293. value: function getAnchorUrl(hash) {
  1294. return "#";
  1295. }
  1296. }, {
  1297. key: "setHash",
  1298. value: function setHash(hash) {}
  1299. }, {
  1300. key: "executeNamedAction",
  1301. value: function executeNamedAction(action) {}
  1302. }, {
  1303. key: "cachePageRef",
  1304. value: function cachePageRef(pageNum, pageRef) {}
  1305. }, {
  1306. key: "isPageVisible",
  1307. value: function isPageVisible(pageNumber) {
  1308. return true;
  1309. }
  1310. }, {
  1311. key: "isPageCached",
  1312. value: function isPageCached(pageNumber) {
  1313. return true;
  1314. }
  1315. }]);
  1316. return SimpleLinkService;
  1317. }();
  1318. exports.SimpleLinkService = SimpleLinkService;
  1319. /***/ }),
  1320. /* 7 */
  1321. /***/ ((__unused_webpack_module, exports) => {
  1322. Object.defineProperty(exports, "__esModule", ({
  1323. value: true
  1324. }));
  1325. exports.apiPageLayoutToSpreadMode = apiPageLayoutToSpreadMode;
  1326. exports.apiPageModeToSidebarView = apiPageModeToSidebarView;
  1327. exports.approximateFraction = approximateFraction;
  1328. exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
  1329. exports.binarySearchFirstItem = binarySearchFirstItem;
  1330. exports.getActiveOrFocusedElement = getActiveOrFocusedElement;
  1331. exports.getOutputScale = getOutputScale;
  1332. exports.getPageSizeInches = getPageSizeInches;
  1333. exports.getVisibleElements = getVisibleElements;
  1334. exports.isPortraitOrientation = isPortraitOrientation;
  1335. exports.isValidRotation = isValidRotation;
  1336. exports.isValidScrollMode = isValidScrollMode;
  1337. exports.isValidSpreadMode = isValidSpreadMode;
  1338. exports.moveToEndOfArray = moveToEndOfArray;
  1339. exports.noContextMenuHandler = noContextMenuHandler;
  1340. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  1341. exports.normalizeWheelEventDirection = normalizeWheelEventDirection;
  1342. exports.parseQueryString = parseQueryString;
  1343. exports.roundToDivide = roundToDivide;
  1344. exports.scrollIntoView = scrollIntoView;
  1345. exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
  1346. exports.watchScroll = watchScroll;
  1347. exports.WaitOnType = exports.VERTICAL_PADDING = exports.UNKNOWN_SCALE = exports.TextLayerMode = exports.SpreadMode = exports.SidebarView = exports.ScrollMode = exports.SCROLLBAR_PADDING = exports.RendererType = exports.ProgressBar = exports.PresentationModeState = exports.MIN_SCALE = exports.MAX_SCALE = exports.MAX_AUTO_SCALE = exports.EventBus = exports.DEFAULT_SCALE_VALUE = exports.DEFAULT_SCALE = exports.CSS_UNITS = exports.AutoPrintRegExp = exports.animationStarted = void 0;
  1348. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  1349. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1350. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  1351. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  1352. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  1353. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  1354. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  1355. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  1356. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  1357. function _iterableToArrayLimit(arr, i) { var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]); if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  1358. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  1359. var CSS_UNITS = 96.0 / 72.0;
  1360. exports.CSS_UNITS = CSS_UNITS;
  1361. var DEFAULT_SCALE_VALUE = "auto";
  1362. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  1363. var DEFAULT_SCALE = 1.0;
  1364. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  1365. var MIN_SCALE = 0.1;
  1366. exports.MIN_SCALE = MIN_SCALE;
  1367. var MAX_SCALE = 10.0;
  1368. exports.MAX_SCALE = MAX_SCALE;
  1369. var UNKNOWN_SCALE = 0;
  1370. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  1371. var MAX_AUTO_SCALE = 1.25;
  1372. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  1373. var SCROLLBAR_PADDING = 40;
  1374. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  1375. var VERTICAL_PADDING = 5;
  1376. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  1377. var LOADINGBAR_END_OFFSET_VAR = "--loadingBar-end-offset";
  1378. var PresentationModeState = {
  1379. UNKNOWN: 0,
  1380. NORMAL: 1,
  1381. CHANGING: 2,
  1382. FULLSCREEN: 3
  1383. };
  1384. exports.PresentationModeState = PresentationModeState;
  1385. var SidebarView = {
  1386. UNKNOWN: -1,
  1387. NONE: 0,
  1388. THUMBS: 1,
  1389. OUTLINE: 2,
  1390. ATTACHMENTS: 3,
  1391. LAYERS: 4
  1392. };
  1393. exports.SidebarView = SidebarView;
  1394. var RendererType = {
  1395. CANVAS: "canvas",
  1396. SVG: "svg"
  1397. };
  1398. exports.RendererType = RendererType;
  1399. var TextLayerMode = {
  1400. DISABLE: 0,
  1401. ENABLE: 1,
  1402. ENABLE_ENHANCE: 2
  1403. };
  1404. exports.TextLayerMode = TextLayerMode;
  1405. var ScrollMode = {
  1406. UNKNOWN: -1,
  1407. VERTICAL: 0,
  1408. HORIZONTAL: 1,
  1409. WRAPPED: 2
  1410. };
  1411. exports.ScrollMode = ScrollMode;
  1412. var SpreadMode = {
  1413. UNKNOWN: -1,
  1414. NONE: 0,
  1415. ODD: 1,
  1416. EVEN: 2
  1417. };
  1418. exports.SpreadMode = SpreadMode;
  1419. var AutoPrintRegExp = /\bprint\s*\(/;
  1420. exports.AutoPrintRegExp = AutoPrintRegExp;
  1421. function getOutputScale(ctx) {
  1422. var devicePixelRatio = window.devicePixelRatio || 1;
  1423. var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
  1424. var pixelRatio = devicePixelRatio / backingStoreRatio;
  1425. return {
  1426. sx: pixelRatio,
  1427. sy: pixelRatio,
  1428. scaled: pixelRatio !== 1
  1429. };
  1430. }
  1431. function scrollIntoView(element, spot) {
  1432. var skipOverflowHiddenElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  1433. var parent = element.offsetParent;
  1434. if (!parent) {
  1435. console.error("offsetParent is not set -- cannot scroll");
  1436. return;
  1437. }
  1438. var offsetY = element.offsetTop + element.clientTop;
  1439. var offsetX = element.offsetLeft + element.clientLeft;
  1440. while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || skipOverflowHiddenElements && getComputedStyle(parent).overflow === "hidden") {
  1441. if (parent.dataset._scaleY) {
  1442. offsetY /= parent.dataset._scaleY;
  1443. offsetX /= parent.dataset._scaleX;
  1444. }
  1445. offsetY += parent.offsetTop;
  1446. offsetX += parent.offsetLeft;
  1447. parent = parent.offsetParent;
  1448. if (!parent) {
  1449. return;
  1450. }
  1451. }
  1452. if (spot) {
  1453. if (spot.top !== undefined) {
  1454. offsetY += spot.top;
  1455. }
  1456. if (spot.left !== undefined) {
  1457. offsetX += spot.left;
  1458. parent.scrollLeft = offsetX;
  1459. }
  1460. }
  1461. parent.scrollTop = offsetY;
  1462. }
  1463. function watchScroll(viewAreaElement, callback) {
  1464. var debounceScroll = function debounceScroll(evt) {
  1465. if (rAF) {
  1466. return;
  1467. }
  1468. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  1469. rAF = null;
  1470. var currentX = viewAreaElement.scrollLeft;
  1471. var lastX = state.lastX;
  1472. if (currentX !== lastX) {
  1473. state.right = currentX > lastX;
  1474. }
  1475. state.lastX = currentX;
  1476. var currentY = viewAreaElement.scrollTop;
  1477. var lastY = state.lastY;
  1478. if (currentY !== lastY) {
  1479. state.down = currentY > lastY;
  1480. }
  1481. state.lastY = currentY;
  1482. callback(state);
  1483. });
  1484. };
  1485. var state = {
  1486. right: true,
  1487. down: true,
  1488. lastX: viewAreaElement.scrollLeft,
  1489. lastY: viewAreaElement.scrollTop,
  1490. _eventHandler: debounceScroll
  1491. };
  1492. var rAF = null;
  1493. viewAreaElement.addEventListener("scroll", debounceScroll, true);
  1494. return state;
  1495. }
  1496. function parseQueryString(query) {
  1497. var parts = query.split("&");
  1498. var params = Object.create(null);
  1499. for (var i = 0, ii = parts.length; i < ii; ++i) {
  1500. var param = parts[i].split("=");
  1501. var key = param[0].toLowerCase();
  1502. var value = param.length > 1 ? param[1] : null;
  1503. params[decodeURIComponent(key)] = decodeURIComponent(value);
  1504. }
  1505. return params;
  1506. }
  1507. function binarySearchFirstItem(items, condition) {
  1508. var minIndex = 0;
  1509. var maxIndex = items.length - 1;
  1510. if (maxIndex < 0 || !condition(items[maxIndex])) {
  1511. return items.length;
  1512. }
  1513. if (condition(items[minIndex])) {
  1514. return minIndex;
  1515. }
  1516. while (minIndex < maxIndex) {
  1517. var currentIndex = minIndex + maxIndex >> 1;
  1518. var currentItem = items[currentIndex];
  1519. if (condition(currentItem)) {
  1520. maxIndex = currentIndex;
  1521. } else {
  1522. minIndex = currentIndex + 1;
  1523. }
  1524. }
  1525. return minIndex;
  1526. }
  1527. function approximateFraction(x) {
  1528. if (Math.floor(x) === x) {
  1529. return [x, 1];
  1530. }
  1531. var xinv = 1 / x;
  1532. var limit = 8;
  1533. if (xinv > limit) {
  1534. return [1, limit];
  1535. } else if (Math.floor(xinv) === xinv) {
  1536. return [1, xinv];
  1537. }
  1538. var x_ = x > 1 ? xinv : x;
  1539. var a = 0,
  1540. b = 1,
  1541. c = 1,
  1542. d = 1;
  1543. while (true) {
  1544. var p = a + c,
  1545. q = b + d;
  1546. if (q > limit) {
  1547. break;
  1548. }
  1549. if (x_ <= p / q) {
  1550. c = p;
  1551. d = q;
  1552. } else {
  1553. a = p;
  1554. b = q;
  1555. }
  1556. }
  1557. var result;
  1558. if (x_ - a / b < c / d - x_) {
  1559. result = x_ === x ? [a, b] : [b, a];
  1560. } else {
  1561. result = x_ === x ? [c, d] : [d, c];
  1562. }
  1563. return result;
  1564. }
  1565. function roundToDivide(x, div) {
  1566. var r = x % div;
  1567. return r === 0 ? x : Math.round(x - r + div);
  1568. }
  1569. function getPageSizeInches(_ref) {
  1570. var view = _ref.view,
  1571. userUnit = _ref.userUnit,
  1572. rotate = _ref.rotate;
  1573. var _view = _slicedToArray(view, 4),
  1574. x1 = _view[0],
  1575. y1 = _view[1],
  1576. x2 = _view[2],
  1577. y2 = _view[3];
  1578. var changeOrientation = rotate % 180 !== 0;
  1579. var width = (x2 - x1) / 72 * userUnit;
  1580. var height = (y2 - y1) / 72 * userUnit;
  1581. return {
  1582. width: changeOrientation ? height : width,
  1583. height: changeOrientation ? width : height
  1584. };
  1585. }
  1586. function backtrackBeforeAllVisibleElements(index, views, top) {
  1587. if (index < 2) {
  1588. return index;
  1589. }
  1590. var elt = views[index].div;
  1591. var pageTop = elt.offsetTop + elt.clientTop;
  1592. if (pageTop >= top) {
  1593. elt = views[index - 1].div;
  1594. pageTop = elt.offsetTop + elt.clientTop;
  1595. }
  1596. for (var i = index - 2; i >= 0; --i) {
  1597. elt = views[i].div;
  1598. if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
  1599. break;
  1600. }
  1601. index = i;
  1602. }
  1603. return index;
  1604. }
  1605. function getVisibleElements(_ref2) {
  1606. var scrollEl = _ref2.scrollEl,
  1607. views = _ref2.views,
  1608. _ref2$sortByVisibilit = _ref2.sortByVisibility,
  1609. sortByVisibility = _ref2$sortByVisibilit === void 0 ? false : _ref2$sortByVisibilit,
  1610. _ref2$horizontal = _ref2.horizontal,
  1611. horizontal = _ref2$horizontal === void 0 ? false : _ref2$horizontal,
  1612. _ref2$rtl = _ref2.rtl,
  1613. rtl = _ref2$rtl === void 0 ? false : _ref2$rtl;
  1614. var top = scrollEl.scrollTop,
  1615. bottom = top + scrollEl.clientHeight;
  1616. var left = scrollEl.scrollLeft,
  1617. right = left + scrollEl.clientWidth;
  1618. function isElementBottomAfterViewTop(view) {
  1619. var element = view.div;
  1620. var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  1621. return elementBottom > top;
  1622. }
  1623. function isElementNextAfterViewHorizontally(view) {
  1624. var element = view.div;
  1625. var elementLeft = element.offsetLeft + element.clientLeft;
  1626. var elementRight = elementLeft + element.clientWidth;
  1627. return rtl ? elementLeft < right : elementRight > left;
  1628. }
  1629. var visible = [],
  1630. numViews = views.length;
  1631. var firstVisibleElementInd = binarySearchFirstItem(views, horizontal ? isElementNextAfterViewHorizontally : isElementBottomAfterViewTop);
  1632. if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
  1633. firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
  1634. }
  1635. var lastEdge = horizontal ? right : -1;
  1636. for (var i = firstVisibleElementInd; i < numViews; i++) {
  1637. var view = views[i],
  1638. element = view.div;
  1639. var currentWidth = element.offsetLeft + element.clientLeft;
  1640. var currentHeight = element.offsetTop + element.clientTop;
  1641. var viewWidth = element.clientWidth,
  1642. viewHeight = element.clientHeight;
  1643. var viewRight = currentWidth + viewWidth;
  1644. var viewBottom = currentHeight + viewHeight;
  1645. if (lastEdge === -1) {
  1646. if (viewBottom >= bottom) {
  1647. lastEdge = viewBottom;
  1648. }
  1649. } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
  1650. break;
  1651. }
  1652. if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) {
  1653. continue;
  1654. }
  1655. var hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
  1656. var hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
  1657. var fractionHeight = (viewHeight - hiddenHeight) / viewHeight,
  1658. fractionWidth = (viewWidth - hiddenWidth) / viewWidth;
  1659. var percent = fractionHeight * fractionWidth * 100 | 0;
  1660. visible.push({
  1661. id: view.id,
  1662. x: currentWidth,
  1663. y: currentHeight,
  1664. view: view,
  1665. percent: percent,
  1666. widthPercent: fractionWidth * 100 | 0
  1667. });
  1668. }
  1669. var first = visible[0],
  1670. last = visible[visible.length - 1];
  1671. if (sortByVisibility) {
  1672. visible.sort(function (a, b) {
  1673. var pc = a.percent - b.percent;
  1674. if (Math.abs(pc) > 0.001) {
  1675. return -pc;
  1676. }
  1677. return a.id - b.id;
  1678. });
  1679. }
  1680. return {
  1681. first: first,
  1682. last: last,
  1683. views: visible
  1684. };
  1685. }
  1686. function noContextMenuHandler(evt) {
  1687. evt.preventDefault();
  1688. }
  1689. function normalizeWheelEventDirection(evt) {
  1690. var delta = Math.hypot(evt.deltaX, evt.deltaY);
  1691. var angle = Math.atan2(evt.deltaY, evt.deltaX);
  1692. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  1693. delta = -delta;
  1694. }
  1695. return delta;
  1696. }
  1697. function normalizeWheelEventDelta(evt) {
  1698. var delta = normalizeWheelEventDirection(evt);
  1699. var MOUSE_DOM_DELTA_PIXEL_MODE = 0;
  1700. var MOUSE_DOM_DELTA_LINE_MODE = 1;
  1701. var MOUSE_PIXELS_PER_LINE = 30;
  1702. var MOUSE_LINES_PER_PAGE = 30;
  1703. if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
  1704. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  1705. } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
  1706. delta /= MOUSE_LINES_PER_PAGE;
  1707. }
  1708. return delta;
  1709. }
  1710. function isValidRotation(angle) {
  1711. return Number.isInteger(angle) && angle % 90 === 0;
  1712. }
  1713. function isValidScrollMode(mode) {
  1714. return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN;
  1715. }
  1716. function isValidSpreadMode(mode) {
  1717. return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN;
  1718. }
  1719. function isPortraitOrientation(size) {
  1720. return size.width <= size.height;
  1721. }
  1722. var WaitOnType = {
  1723. EVENT: "event",
  1724. TIMEOUT: "timeout"
  1725. };
  1726. exports.WaitOnType = WaitOnType;
  1727. function waitOnEventOrTimeout(_ref3) {
  1728. var target = _ref3.target,
  1729. name = _ref3.name,
  1730. _ref3$delay = _ref3.delay,
  1731. delay = _ref3$delay === void 0 ? 0 : _ref3$delay;
  1732. return new Promise(function (resolve, reject) {
  1733. if (_typeof(target) !== "object" || !(name && typeof name === "string") || !(Number.isInteger(delay) && delay >= 0)) {
  1734. throw new Error("waitOnEventOrTimeout - invalid parameters.");
  1735. }
  1736. function handler(type) {
  1737. if (target instanceof EventBus) {
  1738. target._off(name, eventHandler);
  1739. } else {
  1740. target.removeEventListener(name, eventHandler);
  1741. }
  1742. if (timeout) {
  1743. clearTimeout(timeout);
  1744. }
  1745. resolve(type);
  1746. }
  1747. var eventHandler = handler.bind(null, WaitOnType.EVENT);
  1748. if (target instanceof EventBus) {
  1749. target._on(name, eventHandler);
  1750. } else {
  1751. target.addEventListener(name, eventHandler);
  1752. }
  1753. var timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
  1754. var timeout = setTimeout(timeoutHandler, delay);
  1755. });
  1756. }
  1757. var animationStarted = new Promise(function (resolve) {
  1758. window.requestAnimationFrame(resolve);
  1759. });
  1760. exports.animationStarted = animationStarted;
  1761. function dispatchDOMEvent(eventName) {
  1762. var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  1763. throw new Error("Not implemented: dispatchDOMEvent");
  1764. }
  1765. var EventBus = /*#__PURE__*/function () {
  1766. function EventBus(options) {
  1767. _classCallCheck(this, EventBus);
  1768. this._listeners = Object.create(null);
  1769. }
  1770. _createClass(EventBus, [{
  1771. key: "on",
  1772. value: function on(eventName, listener) {
  1773. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  1774. this._on(eventName, listener, {
  1775. external: true,
  1776. once: options === null || options === void 0 ? void 0 : options.once
  1777. });
  1778. }
  1779. }, {
  1780. key: "off",
  1781. value: function off(eventName, listener) {
  1782. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  1783. this._off(eventName, listener, {
  1784. external: true,
  1785. once: options === null || options === void 0 ? void 0 : options.once
  1786. });
  1787. }
  1788. }, {
  1789. key: "dispatch",
  1790. value: function dispatch(eventName) {
  1791. var eventListeners = this._listeners[eventName];
  1792. if (!eventListeners || eventListeners.length === 0) {
  1793. return;
  1794. }
  1795. var args = Array.prototype.slice.call(arguments, 1);
  1796. var externalListeners;
  1797. var _iterator = _createForOfIteratorHelper(eventListeners.slice(0)),
  1798. _step;
  1799. try {
  1800. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  1801. var _step$value = _step.value,
  1802. _listener = _step$value.listener,
  1803. external = _step$value.external,
  1804. once = _step$value.once;
  1805. if (once) {
  1806. this._off(eventName, _listener);
  1807. }
  1808. if (external) {
  1809. (externalListeners || (externalListeners = [])).push(_listener);
  1810. continue;
  1811. }
  1812. _listener.apply(null, args);
  1813. }
  1814. } catch (err) {
  1815. _iterator.e(err);
  1816. } finally {
  1817. _iterator.f();
  1818. }
  1819. if (externalListeners) {
  1820. var _iterator2 = _createForOfIteratorHelper(externalListeners),
  1821. _step2;
  1822. try {
  1823. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  1824. var listener = _step2.value;
  1825. listener.apply(null, args);
  1826. }
  1827. } catch (err) {
  1828. _iterator2.e(err);
  1829. } finally {
  1830. _iterator2.f();
  1831. }
  1832. externalListeners = null;
  1833. }
  1834. }
  1835. }, {
  1836. key: "_on",
  1837. value: function _on(eventName, listener) {
  1838. var _this$_listeners;
  1839. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  1840. var eventListeners = (_this$_listeners = this._listeners)[eventName] || (_this$_listeners[eventName] = []);
  1841. eventListeners.push({
  1842. listener: listener,
  1843. external: (options === null || options === void 0 ? void 0 : options.external) === true,
  1844. once: (options === null || options === void 0 ? void 0 : options.once) === true
  1845. });
  1846. }
  1847. }, {
  1848. key: "_off",
  1849. value: function _off(eventName, listener) {
  1850. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  1851. var eventListeners = this._listeners[eventName];
  1852. if (!eventListeners) {
  1853. return;
  1854. }
  1855. for (var i = 0, ii = eventListeners.length; i < ii; i++) {
  1856. if (eventListeners[i].listener === listener) {
  1857. eventListeners.splice(i, 1);
  1858. return;
  1859. }
  1860. }
  1861. }
  1862. }]);
  1863. return EventBus;
  1864. }();
  1865. exports.EventBus = EventBus;
  1866. function clamp(v, min, max) {
  1867. return Math.min(Math.max(v, min), max);
  1868. }
  1869. var ProgressBar = /*#__PURE__*/function () {
  1870. function ProgressBar(id) {
  1871. var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  1872. height = _ref4.height,
  1873. width = _ref4.width,
  1874. units = _ref4.units;
  1875. _classCallCheck(this, ProgressBar);
  1876. this.visible = true;
  1877. this.div = document.querySelector(id + " .progress");
  1878. this.bar = this.div.parentNode;
  1879. this.height = height || 100;
  1880. this.width = width || 100;
  1881. this.units = units || "%";
  1882. this.div.style.height = this.height + this.units;
  1883. this.percent = 0;
  1884. }
  1885. _createClass(ProgressBar, [{
  1886. key: "_updateBar",
  1887. value: function _updateBar() {
  1888. if (this._indeterminate) {
  1889. this.div.classList.add("indeterminate");
  1890. this.div.style.width = this.width + this.units;
  1891. return;
  1892. }
  1893. this.div.classList.remove("indeterminate");
  1894. var progressSize = this.width * this._percent / 100;
  1895. this.div.style.width = progressSize + this.units;
  1896. }
  1897. }, {
  1898. key: "percent",
  1899. get: function get() {
  1900. return this._percent;
  1901. },
  1902. set: function set(val) {
  1903. this._indeterminate = isNaN(val);
  1904. this._percent = clamp(val, 0, 100);
  1905. this._updateBar();
  1906. }
  1907. }, {
  1908. key: "setWidth",
  1909. value: function setWidth(viewer) {
  1910. if (!viewer) {
  1911. return;
  1912. }
  1913. var container = viewer.parentNode;
  1914. var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  1915. if (scrollbarWidth > 0) {
  1916. var doc = document.documentElement;
  1917. doc.style.setProperty(LOADINGBAR_END_OFFSET_VAR, "".concat(scrollbarWidth, "px"));
  1918. }
  1919. }
  1920. }, {
  1921. key: "hide",
  1922. value: function hide() {
  1923. if (!this.visible) {
  1924. return;
  1925. }
  1926. this.visible = false;
  1927. this.bar.classList.add("hidden");
  1928. }
  1929. }, {
  1930. key: "show",
  1931. value: function show() {
  1932. if (this.visible) {
  1933. return;
  1934. }
  1935. this.visible = true;
  1936. this.bar.classList.remove("hidden");
  1937. }
  1938. }]);
  1939. return ProgressBar;
  1940. }();
  1941. exports.ProgressBar = ProgressBar;
  1942. function moveToEndOfArray(arr, condition) {
  1943. var moved = [],
  1944. len = arr.length;
  1945. var write = 0;
  1946. for (var read = 0; read < len; ++read) {
  1947. if (condition(arr[read])) {
  1948. moved.push(arr[read]);
  1949. } else {
  1950. arr[write] = arr[read];
  1951. ++write;
  1952. }
  1953. }
  1954. for (var _read = 0; write < len; ++_read, ++write) {
  1955. arr[write] = moved[_read];
  1956. }
  1957. }
  1958. function getActiveOrFocusedElement() {
  1959. var curRoot = document;
  1960. var curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
  1961. while ((_curActiveOrFocused = curActiveOrFocused) !== null && _curActiveOrFocused !== void 0 && _curActiveOrFocused.shadowRoot) {
  1962. var _curActiveOrFocused;
  1963. curRoot = curActiveOrFocused.shadowRoot;
  1964. curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
  1965. }
  1966. return curActiveOrFocused;
  1967. }
  1968. function apiPageLayoutToSpreadMode(layout) {
  1969. switch (layout) {
  1970. case "SinglePage":
  1971. case "OneColumn":
  1972. return SpreadMode.NONE;
  1973. case "TwoColumnLeft":
  1974. case "TwoPageLeft":
  1975. return SpreadMode.ODD;
  1976. case "TwoColumnRight":
  1977. case "TwoPageRight":
  1978. return SpreadMode.EVEN;
  1979. }
  1980. return SpreadMode.NONE;
  1981. }
  1982. function apiPageModeToSidebarView(mode) {
  1983. switch (mode) {
  1984. case "UseNone":
  1985. return SidebarView.NONE;
  1986. case "UseThumbs":
  1987. return SidebarView.THUMBS;
  1988. case "UseOutlines":
  1989. return SidebarView.OUTLINE;
  1990. case "UseAttachments":
  1991. return SidebarView.ATTACHMENTS;
  1992. case "UseOC":
  1993. return SidebarView.LAYERS;
  1994. }
  1995. return SidebarView.NONE;
  1996. }
  1997. /***/ }),
  1998. /* 8 */
  1999. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  2000. Object.defineProperty(exports, "__esModule", ({
  2001. value: true
  2002. }));
  2003. exports.TextLayerBuilder = exports.DefaultTextLayerFactory = void 0;
  2004. var _pdfjsLib = __w_pdfjs_require__(2);
  2005. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2006. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  2007. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2008. var EXPAND_DIVS_TIMEOUT = 300;
  2009. var TextLayerBuilder = /*#__PURE__*/function () {
  2010. function TextLayerBuilder(_ref) {
  2011. var textLayerDiv = _ref.textLayerDiv,
  2012. eventBus = _ref.eventBus,
  2013. pageIndex = _ref.pageIndex,
  2014. viewport = _ref.viewport,
  2015. _ref$findController = _ref.findController,
  2016. findController = _ref$findController === void 0 ? null : _ref$findController,
  2017. _ref$enhanceTextSelec = _ref.enhanceTextSelection,
  2018. enhanceTextSelection = _ref$enhanceTextSelec === void 0 ? false : _ref$enhanceTextSelec;
  2019. _classCallCheck(this, TextLayerBuilder);
  2020. this.textLayerDiv = textLayerDiv;
  2021. this.eventBus = eventBus;
  2022. this.textContent = null;
  2023. this.textContentItemsStr = [];
  2024. this.textContentStream = null;
  2025. this.renderingDone = false;
  2026. this.pageIdx = pageIndex;
  2027. this.pageNumber = this.pageIdx + 1;
  2028. this.matches = [];
  2029. this.viewport = viewport;
  2030. this.textDivs = [];
  2031. this.findController = findController;
  2032. this.textLayerRenderTask = null;
  2033. this.enhanceTextSelection = enhanceTextSelection;
  2034. this._onUpdateTextLayerMatches = null;
  2035. this._bindMouse();
  2036. }
  2037. _createClass(TextLayerBuilder, [{
  2038. key: "_finishRendering",
  2039. value: function _finishRendering() {
  2040. this.renderingDone = true;
  2041. if (!this.enhanceTextSelection) {
  2042. var endOfContent = document.createElement("div");
  2043. endOfContent.className = "endOfContent";
  2044. this.textLayerDiv.appendChild(endOfContent);
  2045. }
  2046. this.eventBus.dispatch("textlayerrendered", {
  2047. source: this,
  2048. pageNumber: this.pageNumber,
  2049. numTextDivs: this.textDivs.length
  2050. });
  2051. }
  2052. }, {
  2053. key: "render",
  2054. value: function render() {
  2055. var _this = this;
  2056. var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  2057. if (!(this.textContent || this.textContentStream) || this.renderingDone) {
  2058. return;
  2059. }
  2060. this.cancel();
  2061. this.textDivs = [];
  2062. var textLayerFrag = document.createDocumentFragment();
  2063. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  2064. textContent: this.textContent,
  2065. textContentStream: this.textContentStream,
  2066. container: textLayerFrag,
  2067. viewport: this.viewport,
  2068. textDivs: this.textDivs,
  2069. textContentItemsStr: this.textContentItemsStr,
  2070. timeout: timeout,
  2071. enhanceTextSelection: this.enhanceTextSelection
  2072. });
  2073. this.textLayerRenderTask.promise.then(function () {
  2074. _this.textLayerDiv.appendChild(textLayerFrag);
  2075. _this._finishRendering();
  2076. _this._updateMatches();
  2077. }, function (reason) {});
  2078. if (!this._onUpdateTextLayerMatches) {
  2079. this._onUpdateTextLayerMatches = function (evt) {
  2080. if (evt.pageIndex === _this.pageIdx || evt.pageIndex === -1) {
  2081. _this._updateMatches();
  2082. }
  2083. };
  2084. this.eventBus._on("updatetextlayermatches", this._onUpdateTextLayerMatches);
  2085. }
  2086. }
  2087. }, {
  2088. key: "cancel",
  2089. value: function cancel() {
  2090. if (this.textLayerRenderTask) {
  2091. this.textLayerRenderTask.cancel();
  2092. this.textLayerRenderTask = null;
  2093. }
  2094. if (this._onUpdateTextLayerMatches) {
  2095. this.eventBus._off("updatetextlayermatches", this._onUpdateTextLayerMatches);
  2096. this._onUpdateTextLayerMatches = null;
  2097. }
  2098. }
  2099. }, {
  2100. key: "setTextContentStream",
  2101. value: function setTextContentStream(readableStream) {
  2102. this.cancel();
  2103. this.textContentStream = readableStream;
  2104. }
  2105. }, {
  2106. key: "setTextContent",
  2107. value: function setTextContent(textContent) {
  2108. this.cancel();
  2109. this.textContent = textContent;
  2110. }
  2111. }, {
  2112. key: "_convertMatches",
  2113. value: function _convertMatches(matches, matchesLength) {
  2114. if (!matches) {
  2115. return [];
  2116. }
  2117. var textContentItemsStr = this.textContentItemsStr;
  2118. var i = 0,
  2119. iIndex = 0;
  2120. var end = textContentItemsStr.length - 1;
  2121. var result = [];
  2122. for (var m = 0, mm = matches.length; m < mm; m++) {
  2123. var matchIdx = matches[m];
  2124. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  2125. iIndex += textContentItemsStr[i].length;
  2126. i++;
  2127. }
  2128. if (i === textContentItemsStr.length) {
  2129. console.error("Could not find a matching mapping");
  2130. }
  2131. var match = {
  2132. begin: {
  2133. divIdx: i,
  2134. offset: matchIdx - iIndex
  2135. }
  2136. };
  2137. matchIdx += matchesLength[m];
  2138. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  2139. iIndex += textContentItemsStr[i].length;
  2140. i++;
  2141. }
  2142. match.end = {
  2143. divIdx: i,
  2144. offset: matchIdx - iIndex
  2145. };
  2146. result.push(match);
  2147. }
  2148. return result;
  2149. }
  2150. }, {
  2151. key: "_renderMatches",
  2152. value: function _renderMatches(matches) {
  2153. if (matches.length === 0) {
  2154. return;
  2155. }
  2156. var findController = this.findController,
  2157. pageIdx = this.pageIdx,
  2158. textContentItemsStr = this.textContentItemsStr,
  2159. textDivs = this.textDivs;
  2160. var isSelectedPage = pageIdx === findController.selected.pageIdx;
  2161. var selectedMatchIdx = findController.selected.matchIdx;
  2162. var highlightAll = findController.state.highlightAll;
  2163. var prevEnd = null;
  2164. var infinity = {
  2165. divIdx: -1,
  2166. offset: undefined
  2167. };
  2168. function beginText(begin, className) {
  2169. var divIdx = begin.divIdx;
  2170. textDivs[divIdx].textContent = "";
  2171. appendTextToDiv(divIdx, 0, begin.offset, className);
  2172. }
  2173. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  2174. var div = textDivs[divIdx];
  2175. var content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  2176. var node = document.createTextNode(content);
  2177. if (className) {
  2178. var span = document.createElement("span");
  2179. span.className = className;
  2180. span.appendChild(node);
  2181. div.appendChild(span);
  2182. return;
  2183. }
  2184. div.appendChild(node);
  2185. }
  2186. var i0 = selectedMatchIdx,
  2187. i1 = i0 + 1;
  2188. if (highlightAll) {
  2189. i0 = 0;
  2190. i1 = matches.length;
  2191. } else if (!isSelectedPage) {
  2192. return;
  2193. }
  2194. for (var i = i0; i < i1; i++) {
  2195. var match = matches[i];
  2196. var begin = match.begin;
  2197. var end = match.end;
  2198. var isSelected = isSelectedPage && i === selectedMatchIdx;
  2199. var highlightSuffix = isSelected ? " selected" : "";
  2200. if (isSelected) {
  2201. findController.scrollMatchIntoView({
  2202. element: textDivs[begin.divIdx],
  2203. pageIndex: pageIdx,
  2204. matchIndex: selectedMatchIdx
  2205. });
  2206. }
  2207. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  2208. if (prevEnd !== null) {
  2209. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  2210. }
  2211. beginText(begin);
  2212. } else {
  2213. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  2214. }
  2215. if (begin.divIdx === end.divIdx) {
  2216. appendTextToDiv(begin.divIdx, begin.offset, end.offset, "highlight" + highlightSuffix);
  2217. } else {
  2218. appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, "highlight begin" + highlightSuffix);
  2219. for (var n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  2220. textDivs[n0].className = "highlight middle" + highlightSuffix;
  2221. }
  2222. beginText(end, "highlight end" + highlightSuffix);
  2223. }
  2224. prevEnd = end;
  2225. }
  2226. if (prevEnd) {
  2227. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  2228. }
  2229. }
  2230. }, {
  2231. key: "_updateMatches",
  2232. value: function _updateMatches() {
  2233. if (!this.renderingDone) {
  2234. return;
  2235. }
  2236. var findController = this.findController,
  2237. matches = this.matches,
  2238. pageIdx = this.pageIdx,
  2239. textContentItemsStr = this.textContentItemsStr,
  2240. textDivs = this.textDivs;
  2241. var clearedUntilDivIdx = -1;
  2242. for (var i = 0, ii = matches.length; i < ii; i++) {
  2243. var match = matches[i];
  2244. var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  2245. for (var n = begin, end = match.end.divIdx; n <= end; n++) {
  2246. var div = textDivs[n];
  2247. div.textContent = textContentItemsStr[n];
  2248. div.className = "";
  2249. }
  2250. clearedUntilDivIdx = match.end.divIdx + 1;
  2251. }
  2252. if (!(findController !== null && findController !== void 0 && findController.highlightMatches)) {
  2253. return;
  2254. }
  2255. var pageMatches = findController.pageMatches[pageIdx] || null;
  2256. var pageMatchesLength = findController.pageMatchesLength[pageIdx] || null;
  2257. this.matches = this._convertMatches(pageMatches, pageMatchesLength);
  2258. this._renderMatches(this.matches);
  2259. }
  2260. }, {
  2261. key: "_bindMouse",
  2262. value: function _bindMouse() {
  2263. var _this2 = this;
  2264. var div = this.textLayerDiv;
  2265. var expandDivsTimer = null;
  2266. div.addEventListener("mousedown", function (evt) {
  2267. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  2268. _this2.textLayerRenderTask.expandTextDivs(true);
  2269. if (expandDivsTimer) {
  2270. clearTimeout(expandDivsTimer);
  2271. expandDivsTimer = null;
  2272. }
  2273. return;
  2274. }
  2275. var end = div.querySelector(".endOfContent");
  2276. if (!end) {
  2277. return;
  2278. }
  2279. var adjustTop = evt.target !== div;
  2280. adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue("-moz-user-select") !== "none";
  2281. if (adjustTop) {
  2282. var divBounds = div.getBoundingClientRect();
  2283. var r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  2284. end.style.top = (r * 100).toFixed(2) + "%";
  2285. }
  2286. end.classList.add("active");
  2287. });
  2288. div.addEventListener("mouseup", function () {
  2289. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  2290. expandDivsTimer = setTimeout(function () {
  2291. if (_this2.textLayerRenderTask) {
  2292. _this2.textLayerRenderTask.expandTextDivs(false);
  2293. }
  2294. expandDivsTimer = null;
  2295. }, EXPAND_DIVS_TIMEOUT);
  2296. return;
  2297. }
  2298. var end = div.querySelector(".endOfContent");
  2299. if (!end) {
  2300. return;
  2301. }
  2302. end.style.top = "";
  2303. end.classList.remove("active");
  2304. });
  2305. }
  2306. }]);
  2307. return TextLayerBuilder;
  2308. }();
  2309. exports.TextLayerBuilder = TextLayerBuilder;
  2310. var DefaultTextLayerFactory = /*#__PURE__*/function () {
  2311. function DefaultTextLayerFactory() {
  2312. _classCallCheck(this, DefaultTextLayerFactory);
  2313. }
  2314. _createClass(DefaultTextLayerFactory, [{
  2315. key: "createTextLayerBuilder",
  2316. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  2317. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  2318. var eventBus = arguments.length > 4 ? arguments[4] : undefined;
  2319. return new TextLayerBuilder({
  2320. textLayerDiv: textLayerDiv,
  2321. pageIndex: pageIndex,
  2322. viewport: viewport,
  2323. enhanceTextSelection: enhanceTextSelection,
  2324. eventBus: eventBus
  2325. });
  2326. }
  2327. }]);
  2328. return DefaultTextLayerFactory;
  2329. }();
  2330. exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
  2331. /***/ }),
  2332. /* 9 */
  2333. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  2334. Object.defineProperty(exports, "__esModule", ({
  2335. value: true
  2336. }));
  2337. exports.DownloadManager = void 0;
  2338. var _pdfjsLib = __w_pdfjs_require__(2);
  2339. var _viewer_compatibility = __w_pdfjs_require__(10);
  2340. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2341. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  2342. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2343. ;
  2344. function _download(blobUrl, filename) {
  2345. var a = document.createElement("a");
  2346. if (!a.click) {
  2347. throw new Error('DownloadManager: "a.click()" is not supported.');
  2348. }
  2349. a.href = blobUrl;
  2350. a.target = "_parent";
  2351. if ("download" in a) {
  2352. a.download = filename;
  2353. }
  2354. (document.body || document.documentElement).appendChild(a);
  2355. a.click();
  2356. a.remove();
  2357. }
  2358. var DownloadManager = /*#__PURE__*/function () {
  2359. function DownloadManager() {
  2360. _classCallCheck(this, DownloadManager);
  2361. this._openBlobUrls = new WeakMap();
  2362. }
  2363. _createClass(DownloadManager, [{
  2364. key: "downloadUrl",
  2365. value: function downloadUrl(url, filename) {
  2366. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, "http://example.com")) {
  2367. return;
  2368. }
  2369. _download(url + "#pdfjs.action=download", filename);
  2370. }
  2371. }, {
  2372. key: "downloadData",
  2373. value: function downloadData(data, filename, contentType) {
  2374. var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, _viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL);
  2375. _download(blobUrl, filename);
  2376. }
  2377. }, {
  2378. key: "openOrDownloadData",
  2379. value: function openOrDownloadData(element, data, filename) {
  2380. var isPdfData = (0, _pdfjsLib.isPdfFile)(filename);
  2381. var contentType = isPdfData ? "application/pdf" : "";
  2382. if (isPdfData && !_viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL) {
  2383. var blobUrl = this._openBlobUrls.get(element);
  2384. if (!blobUrl) {
  2385. blobUrl = URL.createObjectURL(new Blob([data], {
  2386. type: contentType
  2387. }));
  2388. this._openBlobUrls.set(element, blobUrl);
  2389. }
  2390. var viewerUrl;
  2391. viewerUrl = "?file=" + encodeURIComponent(blobUrl + "#" + filename);
  2392. try {
  2393. window.open(viewerUrl);
  2394. return true;
  2395. } catch (ex) {
  2396. console.error("openOrDownloadData: ".concat(ex));
  2397. URL.revokeObjectURL(blobUrl);
  2398. this._openBlobUrls["delete"](element);
  2399. }
  2400. }
  2401. this.downloadData(data, filename, contentType);
  2402. return false;
  2403. }
  2404. }, {
  2405. key: "download",
  2406. value: function download(blob, url, filename) {
  2407. var sourceEventType = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "download";
  2408. if (_viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL) {
  2409. this.downloadUrl(url, filename);
  2410. return;
  2411. }
  2412. var blobUrl = URL.createObjectURL(blob);
  2413. _download(blobUrl, filename);
  2414. }
  2415. }]);
  2416. return DownloadManager;
  2417. }();
  2418. exports.DownloadManager = DownloadManager;
  2419. /***/ }),
  2420. /* 10 */
  2421. /***/ ((__unused_webpack_module, exports) => {
  2422. Object.defineProperty(exports, "__esModule", ({
  2423. value: true
  2424. }));
  2425. exports.viewerCompatibilityParams = void 0;
  2426. var compatibilityParams = Object.create(null);
  2427. {
  2428. var userAgent = typeof navigator !== "undefined" && navigator.userAgent || "";
  2429. var platform = typeof navigator !== "undefined" && navigator.platform || "";
  2430. var maxTouchPoints = typeof navigator !== "undefined" && navigator.maxTouchPoints || 1;
  2431. var isAndroid = /Android/.test(userAgent);
  2432. var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" && maxTouchPoints > 1;
  2433. var isIOSChrome = /CriOS/.test(userAgent);
  2434. (function checkOnBlobSupport() {
  2435. if (isIOSChrome) {
  2436. compatibilityParams.disableCreateObjectURL = true;
  2437. }
  2438. })();
  2439. (function checkCanvasSizeLimitation() {
  2440. if (isIOS || isAndroid) {
  2441. compatibilityParams.maxCanvasPixels = 5242880;
  2442. }
  2443. })();
  2444. }
  2445. var viewerCompatibilityParams = Object.freeze(compatibilityParams);
  2446. exports.viewerCompatibilityParams = viewerCompatibilityParams;
  2447. /***/ }),
  2448. /* 11 */
  2449. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  2450. Object.defineProperty(exports, "__esModule", ({
  2451. value: true
  2452. }));
  2453. exports.GenericL10n = void 0;
  2454. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(4));
  2455. __w_pdfjs_require__(12);
  2456. var _l10n_utils = __w_pdfjs_require__(3);
  2457. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  2458. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  2459. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  2460. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2461. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  2462. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2463. var webL10n = document.webL10n;
  2464. var GenericL10n = /*#__PURE__*/function () {
  2465. function GenericL10n(lang) {
  2466. _classCallCheck(this, GenericL10n);
  2467. this._lang = lang;
  2468. this._ready = new Promise(function (resolve, reject) {
  2469. webL10n.setLanguage(lang, function () {
  2470. resolve(webL10n);
  2471. });
  2472. });
  2473. }
  2474. _createClass(GenericL10n, [{
  2475. key: "getLanguage",
  2476. value: function () {
  2477. var _getLanguage = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  2478. var l10n;
  2479. return _regenerator["default"].wrap(function _callee$(_context) {
  2480. while (1) {
  2481. switch (_context.prev = _context.next) {
  2482. case 0:
  2483. _context.next = 2;
  2484. return this._ready;
  2485. case 2:
  2486. l10n = _context.sent;
  2487. return _context.abrupt("return", l10n.getLanguage());
  2488. case 4:
  2489. case "end":
  2490. return _context.stop();
  2491. }
  2492. }
  2493. }, _callee, this);
  2494. }));
  2495. function getLanguage() {
  2496. return _getLanguage.apply(this, arguments);
  2497. }
  2498. return getLanguage;
  2499. }()
  2500. }, {
  2501. key: "getDirection",
  2502. value: function () {
  2503. var _getDirection = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  2504. var l10n;
  2505. return _regenerator["default"].wrap(function _callee2$(_context2) {
  2506. while (1) {
  2507. switch (_context2.prev = _context2.next) {
  2508. case 0:
  2509. _context2.next = 2;
  2510. return this._ready;
  2511. case 2:
  2512. l10n = _context2.sent;
  2513. return _context2.abrupt("return", l10n.getDirection());
  2514. case 4:
  2515. case "end":
  2516. return _context2.stop();
  2517. }
  2518. }
  2519. }, _callee2, this);
  2520. }));
  2521. function getDirection() {
  2522. return _getDirection.apply(this, arguments);
  2523. }
  2524. return getDirection;
  2525. }()
  2526. }, {
  2527. key: "get",
  2528. value: function () {
  2529. var _get = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(key) {
  2530. var args,
  2531. fallback,
  2532. l10n,
  2533. _args3 = arguments;
  2534. return _regenerator["default"].wrap(function _callee3$(_context3) {
  2535. while (1) {
  2536. switch (_context3.prev = _context3.next) {
  2537. case 0:
  2538. args = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : null;
  2539. fallback = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : (0, _l10n_utils.getL10nFallback)(key, args);
  2540. _context3.next = 4;
  2541. return this._ready;
  2542. case 4:
  2543. l10n = _context3.sent;
  2544. return _context3.abrupt("return", l10n.get(key, args, fallback));
  2545. case 6:
  2546. case "end":
  2547. return _context3.stop();
  2548. }
  2549. }
  2550. }, _callee3, this);
  2551. }));
  2552. function get(_x) {
  2553. return _get.apply(this, arguments);
  2554. }
  2555. return get;
  2556. }()
  2557. }, {
  2558. key: "translate",
  2559. value: function () {
  2560. var _translate = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(element) {
  2561. var l10n;
  2562. return _regenerator["default"].wrap(function _callee4$(_context4) {
  2563. while (1) {
  2564. switch (_context4.prev = _context4.next) {
  2565. case 0:
  2566. _context4.next = 2;
  2567. return this._ready;
  2568. case 2:
  2569. l10n = _context4.sent;
  2570. return _context4.abrupt("return", l10n.translate(element));
  2571. case 4:
  2572. case "end":
  2573. return _context4.stop();
  2574. }
  2575. }
  2576. }, _callee4, this);
  2577. }));
  2578. function translate(_x2) {
  2579. return _translate.apply(this, arguments);
  2580. }
  2581. return translate;
  2582. }()
  2583. }]);
  2584. return GenericL10n;
  2585. }();
  2586. exports.GenericL10n = GenericL10n;
  2587. /***/ }),
  2588. /* 12 */
  2589. /***/ (() => {
  2590. document.webL10n = function (window, document, undefined) {
  2591. var gL10nData = {};
  2592. var gTextData = '';
  2593. var gTextProp = 'textContent';
  2594. var gLanguage = '';
  2595. var gMacros = {};
  2596. var gReadyState = 'loading';
  2597. var gAsyncResourceLoading = true;
  2598. function getL10nResourceLinks() {
  2599. return document.querySelectorAll('link[type="application/l10n"]');
  2600. }
  2601. function getL10nDictionary() {
  2602. var script = document.querySelector('script[type="application/l10n"]');
  2603. return script ? JSON.parse(script.innerHTML) : null;
  2604. }
  2605. function getTranslatableChildren(element) {
  2606. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  2607. }
  2608. function getL10nAttributes(element) {
  2609. if (!element) return {};
  2610. var l10nId = element.getAttribute('data-l10n-id');
  2611. var l10nArgs = element.getAttribute('data-l10n-args');
  2612. var args = {};
  2613. if (l10nArgs) {
  2614. try {
  2615. args = JSON.parse(l10nArgs);
  2616. } catch (e) {
  2617. console.warn('could not parse arguments for #' + l10nId);
  2618. }
  2619. }
  2620. return {
  2621. id: l10nId,
  2622. args: args
  2623. };
  2624. }
  2625. function xhrLoadText(url, onSuccess, onFailure) {
  2626. onSuccess = onSuccess || function _onSuccess(data) {};
  2627. onFailure = onFailure || function _onFailure() {};
  2628. var xhr = new XMLHttpRequest();
  2629. xhr.open('GET', url, gAsyncResourceLoading);
  2630. if (xhr.overrideMimeType) {
  2631. xhr.overrideMimeType('text/plain; charset=utf-8');
  2632. }
  2633. xhr.onreadystatechange = function () {
  2634. if (xhr.readyState == 4) {
  2635. if (xhr.status == 200 || xhr.status === 0) {
  2636. onSuccess(xhr.responseText);
  2637. } else {
  2638. onFailure();
  2639. }
  2640. }
  2641. };
  2642. xhr.onerror = onFailure;
  2643. xhr.ontimeout = onFailure;
  2644. try {
  2645. xhr.send(null);
  2646. } catch (e) {
  2647. onFailure();
  2648. }
  2649. }
  2650. function parseResource(href, lang, successCallback, failureCallback) {
  2651. var baseURL = href.replace(/[^\/]*$/, '') || './';
  2652. function evalString(text) {
  2653. if (text.lastIndexOf('\\') < 0) return text;
  2654. 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, "'");
  2655. }
  2656. function parseProperties(text, parsedPropertiesCallback) {
  2657. var dictionary = {};
  2658. var reBlank = /^\s*|\s*$/;
  2659. var reComment = /^\s*#|^\s*$/;
  2660. var reSection = /^\s*\[(.*)\]\s*$/;
  2661. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  2662. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  2663. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  2664. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  2665. var currentLang = '*';
  2666. var genericLang = lang.split('-', 1)[0];
  2667. var skipLang = false;
  2668. var match = '';
  2669. function nextEntry() {
  2670. while (true) {
  2671. if (!entries.length) {
  2672. parsedRawLinesCallback();
  2673. return;
  2674. }
  2675. var line = entries.shift();
  2676. if (reComment.test(line)) continue;
  2677. if (extendedSyntax) {
  2678. match = reSection.exec(line);
  2679. if (match) {
  2680. currentLang = match[1].toLowerCase();
  2681. skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
  2682. continue;
  2683. } else if (skipLang) {
  2684. continue;
  2685. }
  2686. match = reImport.exec(line);
  2687. if (match) {
  2688. loadImport(baseURL + match[1], nextEntry);
  2689. return;
  2690. }
  2691. }
  2692. var tmp = line.match(reSplit);
  2693. if (tmp && tmp.length == 3) {
  2694. dictionary[tmp[1]] = evalString(tmp[2]);
  2695. }
  2696. }
  2697. }
  2698. nextEntry();
  2699. }
  2700. function loadImport(url, callback) {
  2701. xhrLoadText(url, function (content) {
  2702. parseRawLines(content, false, callback);
  2703. }, function () {
  2704. console.warn(url + ' not found.');
  2705. callback();
  2706. });
  2707. }
  2708. parseRawLines(text, true, function () {
  2709. parsedPropertiesCallback(dictionary);
  2710. });
  2711. }
  2712. xhrLoadText(href, function (response) {
  2713. gTextData += response;
  2714. parseProperties(response, function (data) {
  2715. for (var key in data) {
  2716. var id,
  2717. prop,
  2718. index = key.lastIndexOf('.');
  2719. if (index > 0) {
  2720. id = key.substring(0, index);
  2721. prop = key.substring(index + 1);
  2722. } else {
  2723. id = key;
  2724. prop = gTextProp;
  2725. }
  2726. if (!gL10nData[id]) {
  2727. gL10nData[id] = {};
  2728. }
  2729. gL10nData[id][prop] = data[key];
  2730. }
  2731. if (successCallback) {
  2732. successCallback();
  2733. }
  2734. });
  2735. }, failureCallback);
  2736. }
  2737. function loadLocale(lang, callback) {
  2738. if (lang) {
  2739. lang = lang.toLowerCase();
  2740. }
  2741. callback = callback || function _callback() {};
  2742. clear();
  2743. gLanguage = lang;
  2744. var langLinks = getL10nResourceLinks();
  2745. var langCount = langLinks.length;
  2746. if (langCount === 0) {
  2747. var dict = getL10nDictionary();
  2748. if (dict && dict.locales && dict.default_locale) {
  2749. console.log('using the embedded JSON directory, early way out');
  2750. gL10nData = dict.locales[lang];
  2751. if (!gL10nData) {
  2752. var defaultLocale = dict.default_locale.toLowerCase();
  2753. for (var anyCaseLang in dict.locales) {
  2754. anyCaseLang = anyCaseLang.toLowerCase();
  2755. if (anyCaseLang === lang) {
  2756. gL10nData = dict.locales[lang];
  2757. break;
  2758. } else if (anyCaseLang === defaultLocale) {
  2759. gL10nData = dict.locales[defaultLocale];
  2760. }
  2761. }
  2762. }
  2763. callback();
  2764. } else {
  2765. console.log('no resource to load, early way out');
  2766. }
  2767. gReadyState = 'complete';
  2768. return;
  2769. }
  2770. var onResourceLoaded = null;
  2771. var gResourceCount = 0;
  2772. onResourceLoaded = function onResourceLoaded() {
  2773. gResourceCount++;
  2774. if (gResourceCount >= langCount) {
  2775. callback();
  2776. gReadyState = 'complete';
  2777. }
  2778. };
  2779. function L10nResourceLink(link) {
  2780. var href = link.href;
  2781. this.load = function (lang, callback) {
  2782. parseResource(href, lang, callback, function () {
  2783. console.warn(href + ' not found.');
  2784. console.warn('"' + lang + '" resource not found');
  2785. gLanguage = '';
  2786. callback();
  2787. });
  2788. };
  2789. }
  2790. for (var i = 0; i < langCount; i++) {
  2791. var resource = new L10nResourceLink(langLinks[i]);
  2792. resource.load(lang, onResourceLoaded);
  2793. }
  2794. }
  2795. function clear() {
  2796. gL10nData = {};
  2797. gTextData = '';
  2798. gLanguage = '';
  2799. }
  2800. function getPluralRules(lang) {
  2801. var locales2rules = {
  2802. 'af': 3,
  2803. 'ak': 4,
  2804. 'am': 4,
  2805. 'ar': 1,
  2806. 'asa': 3,
  2807. 'az': 0,
  2808. 'be': 11,
  2809. 'bem': 3,
  2810. 'bez': 3,
  2811. 'bg': 3,
  2812. 'bh': 4,
  2813. 'bm': 0,
  2814. 'bn': 3,
  2815. 'bo': 0,
  2816. 'br': 20,
  2817. 'brx': 3,
  2818. 'bs': 11,
  2819. 'ca': 3,
  2820. 'cgg': 3,
  2821. 'chr': 3,
  2822. 'cs': 12,
  2823. 'cy': 17,
  2824. 'da': 3,
  2825. 'de': 3,
  2826. 'dv': 3,
  2827. 'dz': 0,
  2828. 'ee': 3,
  2829. 'el': 3,
  2830. 'en': 3,
  2831. 'eo': 3,
  2832. 'es': 3,
  2833. 'et': 3,
  2834. 'eu': 3,
  2835. 'fa': 0,
  2836. 'ff': 5,
  2837. 'fi': 3,
  2838. 'fil': 4,
  2839. 'fo': 3,
  2840. 'fr': 5,
  2841. 'fur': 3,
  2842. 'fy': 3,
  2843. 'ga': 8,
  2844. 'gd': 24,
  2845. 'gl': 3,
  2846. 'gsw': 3,
  2847. 'gu': 3,
  2848. 'guw': 4,
  2849. 'gv': 23,
  2850. 'ha': 3,
  2851. 'haw': 3,
  2852. 'he': 2,
  2853. 'hi': 4,
  2854. 'hr': 11,
  2855. 'hu': 0,
  2856. 'id': 0,
  2857. 'ig': 0,
  2858. 'ii': 0,
  2859. 'is': 3,
  2860. 'it': 3,
  2861. 'iu': 7,
  2862. 'ja': 0,
  2863. 'jmc': 3,
  2864. 'jv': 0,
  2865. 'ka': 0,
  2866. 'kab': 5,
  2867. 'kaj': 3,
  2868. 'kcg': 3,
  2869. 'kde': 0,
  2870. 'kea': 0,
  2871. 'kk': 3,
  2872. 'kl': 3,
  2873. 'km': 0,
  2874. 'kn': 0,
  2875. 'ko': 0,
  2876. 'ksb': 3,
  2877. 'ksh': 21,
  2878. 'ku': 3,
  2879. 'kw': 7,
  2880. 'lag': 18,
  2881. 'lb': 3,
  2882. 'lg': 3,
  2883. 'ln': 4,
  2884. 'lo': 0,
  2885. 'lt': 10,
  2886. 'lv': 6,
  2887. 'mas': 3,
  2888. 'mg': 4,
  2889. 'mk': 16,
  2890. 'ml': 3,
  2891. 'mn': 3,
  2892. 'mo': 9,
  2893. 'mr': 3,
  2894. 'ms': 0,
  2895. 'mt': 15,
  2896. 'my': 0,
  2897. 'nah': 3,
  2898. 'naq': 7,
  2899. 'nb': 3,
  2900. 'nd': 3,
  2901. 'ne': 3,
  2902. 'nl': 3,
  2903. 'nn': 3,
  2904. 'no': 3,
  2905. 'nr': 3,
  2906. 'nso': 4,
  2907. 'ny': 3,
  2908. 'nyn': 3,
  2909. 'om': 3,
  2910. 'or': 3,
  2911. 'pa': 3,
  2912. 'pap': 3,
  2913. 'pl': 13,
  2914. 'ps': 3,
  2915. 'pt': 3,
  2916. 'rm': 3,
  2917. 'ro': 9,
  2918. 'rof': 3,
  2919. 'ru': 11,
  2920. 'rwk': 3,
  2921. 'sah': 0,
  2922. 'saq': 3,
  2923. 'se': 7,
  2924. 'seh': 3,
  2925. 'ses': 0,
  2926. 'sg': 0,
  2927. 'sh': 11,
  2928. 'shi': 19,
  2929. 'sk': 12,
  2930. 'sl': 14,
  2931. 'sma': 7,
  2932. 'smi': 7,
  2933. 'smj': 7,
  2934. 'smn': 7,
  2935. 'sms': 7,
  2936. 'sn': 3,
  2937. 'so': 3,
  2938. 'sq': 3,
  2939. 'sr': 11,
  2940. 'ss': 3,
  2941. 'ssy': 3,
  2942. 'st': 3,
  2943. 'sv': 3,
  2944. 'sw': 3,
  2945. 'syr': 3,
  2946. 'ta': 3,
  2947. 'te': 3,
  2948. 'teo': 3,
  2949. 'th': 0,
  2950. 'ti': 4,
  2951. 'tig': 3,
  2952. 'tk': 3,
  2953. 'tl': 4,
  2954. 'tn': 3,
  2955. 'to': 0,
  2956. 'tr': 0,
  2957. 'ts': 3,
  2958. 'tzm': 22,
  2959. 'uk': 11,
  2960. 'ur': 3,
  2961. 've': 3,
  2962. 'vi': 0,
  2963. 'vun': 3,
  2964. 'wa': 4,
  2965. 'wae': 3,
  2966. 'wo': 0,
  2967. 'xh': 3,
  2968. 'xog': 3,
  2969. 'yo': 0,
  2970. 'zh': 0,
  2971. 'zu': 3
  2972. };
  2973. function isIn(n, list) {
  2974. return list.indexOf(n) !== -1;
  2975. }
  2976. function isBetween(n, start, end) {
  2977. return start <= n && n <= end;
  2978. }
  2979. var pluralRules = {
  2980. '0': function _(n) {
  2981. return 'other';
  2982. },
  2983. '1': function _(n) {
  2984. if (isBetween(n % 100, 3, 10)) return 'few';
  2985. if (n === 0) return 'zero';
  2986. if (isBetween(n % 100, 11, 99)) return 'many';
  2987. if (n == 2) return 'two';
  2988. if (n == 1) return 'one';
  2989. return 'other';
  2990. },
  2991. '2': function _(n) {
  2992. if (n !== 0 && n % 10 === 0) return 'many';
  2993. if (n == 2) return 'two';
  2994. if (n == 1) return 'one';
  2995. return 'other';
  2996. },
  2997. '3': function _(n) {
  2998. if (n == 1) return 'one';
  2999. return 'other';
  3000. },
  3001. '4': function _(n) {
  3002. if (isBetween(n, 0, 1)) return 'one';
  3003. return 'other';
  3004. },
  3005. '5': function _(n) {
  3006. if (isBetween(n, 0, 2) && n != 2) return 'one';
  3007. return 'other';
  3008. },
  3009. '6': function _(n) {
  3010. if (n === 0) return 'zero';
  3011. if (n % 10 == 1 && n % 100 != 11) return 'one';
  3012. return 'other';
  3013. },
  3014. '7': function _(n) {
  3015. if (n == 2) return 'two';
  3016. if (n == 1) return 'one';
  3017. return 'other';
  3018. },
  3019. '8': function _(n) {
  3020. if (isBetween(n, 3, 6)) return 'few';
  3021. if (isBetween(n, 7, 10)) return 'many';
  3022. if (n == 2) return 'two';
  3023. if (n == 1) return 'one';
  3024. return 'other';
  3025. },
  3026. '9': function _(n) {
  3027. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  3028. if (n == 1) return 'one';
  3029. return 'other';
  3030. },
  3031. '10': function _(n) {
  3032. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  3033. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  3034. return 'other';
  3035. },
  3036. '11': function _(n) {
  3037. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  3038. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
  3039. if (n % 10 == 1 && n % 100 != 11) return 'one';
  3040. return 'other';
  3041. },
  3042. '12': function _(n) {
  3043. if (isBetween(n, 2, 4)) return 'few';
  3044. if (n == 1) return 'one';
  3045. return 'other';
  3046. },
  3047. '13': function _(n) {
  3048. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  3049. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
  3050. if (n == 1) return 'one';
  3051. return 'other';
  3052. },
  3053. '14': function _(n) {
  3054. if (isBetween(n % 100, 3, 4)) return 'few';
  3055. if (n % 100 == 2) return 'two';
  3056. if (n % 100 == 1) return 'one';
  3057. return 'other';
  3058. },
  3059. '15': function _(n) {
  3060. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  3061. if (isBetween(n % 100, 11, 19)) return 'many';
  3062. if (n == 1) return 'one';
  3063. return 'other';
  3064. },
  3065. '16': function _(n) {
  3066. if (n % 10 == 1 && n != 11) return 'one';
  3067. return 'other';
  3068. },
  3069. '17': function _(n) {
  3070. if (n == 3) return 'few';
  3071. if (n === 0) return 'zero';
  3072. if (n == 6) return 'many';
  3073. if (n == 2) return 'two';
  3074. if (n == 1) return 'one';
  3075. return 'other';
  3076. },
  3077. '18': function _(n) {
  3078. if (n === 0) return 'zero';
  3079. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  3080. return 'other';
  3081. },
  3082. '19': function _(n) {
  3083. if (isBetween(n, 2, 10)) return 'few';
  3084. if (isBetween(n, 0, 1)) return 'one';
  3085. return 'other';
  3086. },
  3087. '20': function _(n) {
  3088. 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';
  3089. if (n % 1000000 === 0 && n !== 0) return 'many';
  3090. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  3091. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  3092. return 'other';
  3093. },
  3094. '21': function _(n) {
  3095. if (n === 0) return 'zero';
  3096. if (n == 1) return 'one';
  3097. return 'other';
  3098. },
  3099. '22': function _(n) {
  3100. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  3101. return 'other';
  3102. },
  3103. '23': function _(n) {
  3104. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  3105. return 'other';
  3106. },
  3107. '24': function _(n) {
  3108. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  3109. if (isIn(n, [2, 12])) return 'two';
  3110. if (isIn(n, [1, 11])) return 'one';
  3111. return 'other';
  3112. }
  3113. };
  3114. var index = locales2rules[lang.replace(/-.*$/, '')];
  3115. if (!(index in pluralRules)) {
  3116. console.warn('plural form unknown for [' + lang + ']');
  3117. return function () {
  3118. return 'other';
  3119. };
  3120. }
  3121. return pluralRules[index];
  3122. }
  3123. gMacros.plural = function (str, param, key, prop) {
  3124. var n = parseFloat(param);
  3125. if (isNaN(n)) return str;
  3126. if (prop != gTextProp) return str;
  3127. if (!gMacros._pluralRules) {
  3128. gMacros._pluralRules = getPluralRules(gLanguage);
  3129. }
  3130. var index = '[' + gMacros._pluralRules(n) + ']';
  3131. if (n === 0 && key + '[zero]' in gL10nData) {
  3132. str = gL10nData[key + '[zero]'][prop];
  3133. } else if (n == 1 && key + '[one]' in gL10nData) {
  3134. str = gL10nData[key + '[one]'][prop];
  3135. } else if (n == 2 && key + '[two]' in gL10nData) {
  3136. str = gL10nData[key + '[two]'][prop];
  3137. } else if (key + index in gL10nData) {
  3138. str = gL10nData[key + index][prop];
  3139. } else if (key + '[other]' in gL10nData) {
  3140. str = gL10nData[key + '[other]'][prop];
  3141. }
  3142. return str;
  3143. };
  3144. function getL10nData(key, args, fallback) {
  3145. var data = gL10nData[key];
  3146. if (!data) {
  3147. console.warn('#' + key + ' is undefined.');
  3148. if (!fallback) {
  3149. return null;
  3150. }
  3151. data = fallback;
  3152. }
  3153. var rv = {};
  3154. for (var prop in data) {
  3155. var str = data[prop];
  3156. str = substIndexes(str, args, key, prop);
  3157. str = substArguments(str, args, key);
  3158. rv[prop] = str;
  3159. }
  3160. return rv;
  3161. }
  3162. function substIndexes(str, args, key, prop) {
  3163. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  3164. var reMatch = reIndex.exec(str);
  3165. if (!reMatch || !reMatch.length) return str;
  3166. var macroName = reMatch[1];
  3167. var paramName = reMatch[2];
  3168. var param;
  3169. if (args && paramName in args) {
  3170. param = args[paramName];
  3171. } else if (paramName in gL10nData) {
  3172. param = gL10nData[paramName];
  3173. }
  3174. if (macroName in gMacros) {
  3175. var macro = gMacros[macroName];
  3176. str = macro(str, param, key, prop);
  3177. }
  3178. return str;
  3179. }
  3180. function substArguments(str, args, key) {
  3181. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  3182. return str.replace(reArgs, function (matched_text, arg) {
  3183. if (args && arg in args) {
  3184. return args[arg];
  3185. }
  3186. if (arg in gL10nData) {
  3187. return gL10nData[arg];
  3188. }
  3189. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  3190. return matched_text;
  3191. });
  3192. }
  3193. function translateElement(element) {
  3194. var l10n = getL10nAttributes(element);
  3195. if (!l10n.id) return;
  3196. var data = getL10nData(l10n.id, l10n.args);
  3197. if (!data) {
  3198. console.warn('#' + l10n.id + ' is undefined.');
  3199. return;
  3200. }
  3201. if (data[gTextProp]) {
  3202. if (getChildElementCount(element) === 0) {
  3203. element[gTextProp] = data[gTextProp];
  3204. } else {
  3205. var children = element.childNodes;
  3206. var found = false;
  3207. for (var i = 0, l = children.length; i < l; i++) {
  3208. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  3209. if (found) {
  3210. children[i].nodeValue = '';
  3211. } else {
  3212. children[i].nodeValue = data[gTextProp];
  3213. found = true;
  3214. }
  3215. }
  3216. }
  3217. if (!found) {
  3218. var textNode = document.createTextNode(data[gTextProp]);
  3219. element.insertBefore(textNode, element.firstChild);
  3220. }
  3221. }
  3222. delete data[gTextProp];
  3223. }
  3224. for (var k in data) {
  3225. element[k] = data[k];
  3226. }
  3227. }
  3228. function getChildElementCount(element) {
  3229. if (element.children) {
  3230. return element.children.length;
  3231. }
  3232. if (typeof element.childElementCount !== 'undefined') {
  3233. return element.childElementCount;
  3234. }
  3235. var count = 0;
  3236. for (var i = 0; i < element.childNodes.length; i++) {
  3237. count += element.nodeType === 1 ? 1 : 0;
  3238. }
  3239. return count;
  3240. }
  3241. function translateFragment(element) {
  3242. element = element || document.documentElement;
  3243. var children = getTranslatableChildren(element);
  3244. var elementCount = children.length;
  3245. for (var i = 0; i < elementCount; i++) {
  3246. translateElement(children[i]);
  3247. }
  3248. translateElement(element);
  3249. }
  3250. return {
  3251. get: function get(key, args, fallbackString) {
  3252. var index = key.lastIndexOf('.');
  3253. var prop = gTextProp;
  3254. if (index > 0) {
  3255. prop = key.substring(index + 1);
  3256. key = key.substring(0, index);
  3257. }
  3258. var fallback;
  3259. if (fallbackString) {
  3260. fallback = {};
  3261. fallback[prop] = fallbackString;
  3262. }
  3263. var data = getL10nData(key, args, fallback);
  3264. if (data && prop in data) {
  3265. return data[prop];
  3266. }
  3267. return '{{' + key + '}}';
  3268. },
  3269. getData: function getData() {
  3270. return gL10nData;
  3271. },
  3272. getText: function getText() {
  3273. return gTextData;
  3274. },
  3275. getLanguage: function getLanguage() {
  3276. return gLanguage;
  3277. },
  3278. setLanguage: function setLanguage(lang, callback) {
  3279. loadLocale(lang, function () {
  3280. if (callback) callback();
  3281. });
  3282. },
  3283. getDirection: function getDirection() {
  3284. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  3285. var shortCode = gLanguage.split('-', 1)[0];
  3286. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  3287. },
  3288. translate: translateFragment,
  3289. getReadyState: function getReadyState() {
  3290. return gReadyState;
  3291. },
  3292. ready: function ready(callback) {
  3293. if (!callback) {
  3294. return;
  3295. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  3296. window.setTimeout(function () {
  3297. callback();
  3298. });
  3299. } else if (document.addEventListener) {
  3300. document.addEventListener('localized', function once() {
  3301. document.removeEventListener('localized', once);
  3302. callback();
  3303. });
  3304. }
  3305. }
  3306. };
  3307. }(window, document);
  3308. /***/ }),
  3309. /* 13 */
  3310. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  3311. Object.defineProperty(exports, "__esModule", ({
  3312. value: true
  3313. }));
  3314. exports.PDFFindController = exports.FindState = void 0;
  3315. var _pdfjsLib = __w_pdfjs_require__(2);
  3316. var _pdf_find_utils = __w_pdfjs_require__(14);
  3317. var _ui_utils = __w_pdfjs_require__(7);
  3318. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3319. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  3320. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3321. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  3322. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  3323. function _iterableToArrayLimit(arr, i) { var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]); if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  3324. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  3325. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  3326. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  3327. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  3328. var FindState = {
  3329. FOUND: 0,
  3330. NOT_FOUND: 1,
  3331. WRAPPED: 2,
  3332. PENDING: 3
  3333. };
  3334. exports.FindState = FindState;
  3335. var FIND_TIMEOUT = 250;
  3336. var MATCH_SCROLL_OFFSET_TOP = -50;
  3337. var MATCH_SCROLL_OFFSET_LEFT = -400;
  3338. var CHARACTERS_TO_NORMALIZE = {
  3339. "\u2018": "'",
  3340. "\u2019": "'",
  3341. "\u201A": "'",
  3342. "\u201B": "'",
  3343. "\u201C": '"',
  3344. "\u201D": '"',
  3345. "\u201E": '"',
  3346. "\u201F": '"',
  3347. "\xBC": "1/4",
  3348. "\xBD": "1/2",
  3349. "\xBE": "3/4"
  3350. };
  3351. var normalizationRegex = null;
  3352. function normalize(text) {
  3353. if (!normalizationRegex) {
  3354. var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join("");
  3355. normalizationRegex = new RegExp("[".concat(replace, "]"), "g");
  3356. }
  3357. var diffs = null;
  3358. var normalizedText = text.replace(normalizationRegex, function (ch, index) {
  3359. var normalizedCh = CHARACTERS_TO_NORMALIZE[ch],
  3360. diff = normalizedCh.length - ch.length;
  3361. if (diff !== 0) {
  3362. (diffs || (diffs = [])).push([index, diff]);
  3363. }
  3364. return normalizedCh;
  3365. });
  3366. return [normalizedText, diffs];
  3367. }
  3368. function getOriginalIndex(matchIndex) {
  3369. var diffs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  3370. if (!diffs) {
  3371. return matchIndex;
  3372. }
  3373. var totalDiff = 0;
  3374. var _iterator = _createForOfIteratorHelper(diffs),
  3375. _step;
  3376. try {
  3377. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  3378. var _step$value = _slicedToArray(_step.value, 2),
  3379. index = _step$value[0],
  3380. diff = _step$value[1];
  3381. var currentIndex = index + totalDiff;
  3382. if (currentIndex >= matchIndex) {
  3383. break;
  3384. }
  3385. if (currentIndex + diff > matchIndex) {
  3386. totalDiff += matchIndex - currentIndex;
  3387. break;
  3388. }
  3389. totalDiff += diff;
  3390. }
  3391. } catch (err) {
  3392. _iterator.e(err);
  3393. } finally {
  3394. _iterator.f();
  3395. }
  3396. return matchIndex - totalDiff;
  3397. }
  3398. var PDFFindController = /*#__PURE__*/function () {
  3399. function PDFFindController(_ref) {
  3400. var linkService = _ref.linkService,
  3401. eventBus = _ref.eventBus;
  3402. _classCallCheck(this, PDFFindController);
  3403. this._linkService = linkService;
  3404. this._eventBus = eventBus;
  3405. this._reset();
  3406. eventBus._on("findbarclose", this._onFindBarClose.bind(this));
  3407. }
  3408. _createClass(PDFFindController, [{
  3409. key: "highlightMatches",
  3410. get: function get() {
  3411. return this._highlightMatches;
  3412. }
  3413. }, {
  3414. key: "pageMatches",
  3415. get: function get() {
  3416. return this._pageMatches;
  3417. }
  3418. }, {
  3419. key: "pageMatchesLength",
  3420. get: function get() {
  3421. return this._pageMatchesLength;
  3422. }
  3423. }, {
  3424. key: "selected",
  3425. get: function get() {
  3426. return this._selected;
  3427. }
  3428. }, {
  3429. key: "state",
  3430. get: function get() {
  3431. return this._state;
  3432. }
  3433. }, {
  3434. key: "setDocument",
  3435. value: function setDocument(pdfDocument) {
  3436. if (this._pdfDocument) {
  3437. this._reset();
  3438. }
  3439. if (!pdfDocument) {
  3440. return;
  3441. }
  3442. this._pdfDocument = pdfDocument;
  3443. this._firstPageCapability.resolve();
  3444. }
  3445. }, {
  3446. key: "executeCommand",
  3447. value: function executeCommand(cmd, state) {
  3448. var _this = this;
  3449. if (!state) {
  3450. return;
  3451. }
  3452. var pdfDocument = this._pdfDocument;
  3453. if (this._state === null || this._shouldDirtyMatch(cmd, state)) {
  3454. this._dirtyMatch = true;
  3455. }
  3456. this._state = state;
  3457. if (cmd !== "findhighlightallchange") {
  3458. this._updateUIState(FindState.PENDING);
  3459. }
  3460. this._firstPageCapability.promise.then(function () {
  3461. if (!_this._pdfDocument || pdfDocument && _this._pdfDocument !== pdfDocument) {
  3462. return;
  3463. }
  3464. _this._extractText();
  3465. var findbarClosed = !_this._highlightMatches;
  3466. var pendingTimeout = !!_this._findTimeout;
  3467. if (_this._findTimeout) {
  3468. clearTimeout(_this._findTimeout);
  3469. _this._findTimeout = null;
  3470. }
  3471. if (cmd === "find") {
  3472. _this._findTimeout = setTimeout(function () {
  3473. _this._nextMatch();
  3474. _this._findTimeout = null;
  3475. }, FIND_TIMEOUT);
  3476. } else if (_this._dirtyMatch) {
  3477. _this._nextMatch();
  3478. } else if (cmd === "findagain") {
  3479. _this._nextMatch();
  3480. if (findbarClosed && _this._state.highlightAll) {
  3481. _this._updateAllPages();
  3482. }
  3483. } else if (cmd === "findhighlightallchange") {
  3484. if (pendingTimeout) {
  3485. _this._nextMatch();
  3486. } else {
  3487. _this._highlightMatches = true;
  3488. }
  3489. _this._updateAllPages();
  3490. } else {
  3491. _this._nextMatch();
  3492. }
  3493. });
  3494. }
  3495. }, {
  3496. key: "scrollMatchIntoView",
  3497. value: function scrollMatchIntoView(_ref2) {
  3498. var _ref2$element = _ref2.element,
  3499. element = _ref2$element === void 0 ? null : _ref2$element,
  3500. _ref2$pageIndex = _ref2.pageIndex,
  3501. pageIndex = _ref2$pageIndex === void 0 ? -1 : _ref2$pageIndex,
  3502. _ref2$matchIndex = _ref2.matchIndex,
  3503. matchIndex = _ref2$matchIndex === void 0 ? -1 : _ref2$matchIndex;
  3504. if (!this._scrollMatches || !element) {
  3505. return;
  3506. } else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) {
  3507. return;
  3508. } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) {
  3509. return;
  3510. }
  3511. this._scrollMatches = false;
  3512. var spot = {
  3513. top: MATCH_SCROLL_OFFSET_TOP,
  3514. left: MATCH_SCROLL_OFFSET_LEFT
  3515. };
  3516. (0, _ui_utils.scrollIntoView)(element, spot, true);
  3517. }
  3518. }, {
  3519. key: "_reset",
  3520. value: function _reset() {
  3521. this._highlightMatches = false;
  3522. this._scrollMatches = false;
  3523. this._pdfDocument = null;
  3524. this._pageMatches = [];
  3525. this._pageMatchesLength = [];
  3526. this._state = null;
  3527. this._selected = {
  3528. pageIdx: -1,
  3529. matchIdx: -1
  3530. };
  3531. this._offset = {
  3532. pageIdx: null,
  3533. matchIdx: null,
  3534. wrapped: false
  3535. };
  3536. this._extractTextPromises = [];
  3537. this._pageContents = [];
  3538. this._pageDiffs = [];
  3539. this._matchesCountTotal = 0;
  3540. this._pagesToSearch = null;
  3541. this._pendingFindMatches = new Set();
  3542. this._resumePageIdx = null;
  3543. this._dirtyMatch = false;
  3544. clearTimeout(this._findTimeout);
  3545. this._findTimeout = null;
  3546. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  3547. }
  3548. }, {
  3549. key: "_query",
  3550. get: function get() {
  3551. if (this._state.query !== this._rawQuery) {
  3552. this._rawQuery = this._state.query;
  3553. var _normalize = normalize(this._state.query);
  3554. var _normalize2 = _slicedToArray(_normalize, 1);
  3555. this._normalizedQuery = _normalize2[0];
  3556. }
  3557. return this._normalizedQuery;
  3558. }
  3559. }, {
  3560. key: "_shouldDirtyMatch",
  3561. value: function _shouldDirtyMatch(cmd, state) {
  3562. if (state.query !== this._state.query) {
  3563. return true;
  3564. }
  3565. switch (cmd) {
  3566. case "findagain":
  3567. var pageNumber = this._selected.pageIdx + 1;
  3568. var linkService = this._linkService;
  3569. if (pageNumber >= 1 && pageNumber <= linkService.pagesCount && pageNumber !== linkService.page && !linkService.isPageVisible(pageNumber)) {
  3570. return true;
  3571. }
  3572. return false;
  3573. case "findhighlightallchange":
  3574. return false;
  3575. }
  3576. return true;
  3577. }
  3578. }, {
  3579. key: "_prepareMatches",
  3580. value: function _prepareMatches(matchesWithLength, matches, matchesLength) {
  3581. function isSubTerm(currentIndex) {
  3582. var currentElem = matchesWithLength[currentIndex];
  3583. var nextElem = matchesWithLength[currentIndex + 1];
  3584. if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {
  3585. currentElem.skipped = true;
  3586. return true;
  3587. }
  3588. for (var i = currentIndex - 1; i >= 0; i--) {
  3589. var prevElem = matchesWithLength[i];
  3590. if (prevElem.skipped) {
  3591. continue;
  3592. }
  3593. if (prevElem.match + prevElem.matchLength < currentElem.match) {
  3594. break;
  3595. }
  3596. if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {
  3597. currentElem.skipped = true;
  3598. return true;
  3599. }
  3600. }
  3601. return false;
  3602. }
  3603. matchesWithLength.sort(function (a, b) {
  3604. return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match;
  3605. });
  3606. for (var i = 0, len = matchesWithLength.length; i < len; i++) {
  3607. if (isSubTerm(i)) {
  3608. continue;
  3609. }
  3610. matches.push(matchesWithLength[i].match);
  3611. matchesLength.push(matchesWithLength[i].matchLength);
  3612. }
  3613. }
  3614. }, {
  3615. key: "_isEntireWord",
  3616. value: function _isEntireWord(content, startIdx, length) {
  3617. if (startIdx > 0) {
  3618. var first = content.charCodeAt(startIdx);
  3619. var limit = content.charCodeAt(startIdx - 1);
  3620. if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils.getCharacterType)(limit)) {
  3621. return false;
  3622. }
  3623. }
  3624. var endIdx = startIdx + length - 1;
  3625. if (endIdx < content.length - 1) {
  3626. var last = content.charCodeAt(endIdx);
  3627. var _limit = content.charCodeAt(endIdx + 1);
  3628. if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils.getCharacterType)(_limit)) {
  3629. return false;
  3630. }
  3631. }
  3632. return true;
  3633. }
  3634. }, {
  3635. key: "_calculatePhraseMatch",
  3636. value: function _calculatePhraseMatch(query, pageIndex, pageContent, pageDiffs, entireWord) {
  3637. var matches = [],
  3638. matchesLength = [];
  3639. var queryLen = query.length;
  3640. var matchIdx = -queryLen;
  3641. while (true) {
  3642. matchIdx = pageContent.indexOf(query, matchIdx + queryLen);
  3643. if (matchIdx === -1) {
  3644. break;
  3645. }
  3646. if (entireWord && !this._isEntireWord(pageContent, matchIdx, queryLen)) {
  3647. continue;
  3648. }
  3649. var originalMatchIdx = getOriginalIndex(matchIdx, pageDiffs),
  3650. matchEnd = matchIdx + queryLen - 1,
  3651. originalQueryLen = getOriginalIndex(matchEnd, pageDiffs) - originalMatchIdx + 1;
  3652. matches.push(originalMatchIdx);
  3653. matchesLength.push(originalQueryLen);
  3654. }
  3655. this._pageMatches[pageIndex] = matches;
  3656. this._pageMatchesLength[pageIndex] = matchesLength;
  3657. }
  3658. }, {
  3659. key: "_calculateWordMatch",
  3660. value: function _calculateWordMatch(query, pageIndex, pageContent, pageDiffs, entireWord) {
  3661. var matchesWithLength = [];
  3662. var queryArray = query.match(/\S+/g);
  3663. for (var i = 0, len = queryArray.length; i < len; i++) {
  3664. var subquery = queryArray[i];
  3665. var subqueryLen = subquery.length;
  3666. var matchIdx = -subqueryLen;
  3667. while (true) {
  3668. matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen);
  3669. if (matchIdx === -1) {
  3670. break;
  3671. }
  3672. if (entireWord && !this._isEntireWord(pageContent, matchIdx, subqueryLen)) {
  3673. continue;
  3674. }
  3675. var originalMatchIdx = getOriginalIndex(matchIdx, pageDiffs),
  3676. matchEnd = matchIdx + subqueryLen - 1,
  3677. originalQueryLen = getOriginalIndex(matchEnd, pageDiffs) - originalMatchIdx + 1;
  3678. matchesWithLength.push({
  3679. match: originalMatchIdx,
  3680. matchLength: originalQueryLen,
  3681. skipped: false
  3682. });
  3683. }
  3684. }
  3685. this._pageMatchesLength[pageIndex] = [];
  3686. this._pageMatches[pageIndex] = [];
  3687. this._prepareMatches(matchesWithLength, this._pageMatches[pageIndex], this._pageMatchesLength[pageIndex]);
  3688. }
  3689. }, {
  3690. key: "_calculateMatch",
  3691. value: function _calculateMatch(pageIndex) {
  3692. var pageContent = this._pageContents[pageIndex];
  3693. var pageDiffs = this._pageDiffs[pageIndex];
  3694. var query = this._query;
  3695. var _this$_state = this._state,
  3696. caseSensitive = _this$_state.caseSensitive,
  3697. entireWord = _this$_state.entireWord,
  3698. phraseSearch = _this$_state.phraseSearch;
  3699. if (query.length === 0) {
  3700. return;
  3701. }
  3702. if (!caseSensitive) {
  3703. pageContent = pageContent.toLowerCase();
  3704. query = query.toLowerCase();
  3705. }
  3706. if (phraseSearch) {
  3707. this._calculatePhraseMatch(query, pageIndex, pageContent, pageDiffs, entireWord);
  3708. } else {
  3709. this._calculateWordMatch(query, pageIndex, pageContent, pageDiffs, entireWord);
  3710. }
  3711. if (this._state.highlightAll) {
  3712. this._updatePage(pageIndex);
  3713. }
  3714. if (this._resumePageIdx === pageIndex) {
  3715. this._resumePageIdx = null;
  3716. this._nextPageMatch();
  3717. }
  3718. var pageMatchesCount = this._pageMatches[pageIndex].length;
  3719. if (pageMatchesCount > 0) {
  3720. this._matchesCountTotal += pageMatchesCount;
  3721. this._updateUIResultsCount();
  3722. }
  3723. }
  3724. }, {
  3725. key: "_extractText",
  3726. value: function _extractText() {
  3727. var _this2 = this;
  3728. if (this._extractTextPromises.length > 0) {
  3729. return;
  3730. }
  3731. var promise = Promise.resolve();
  3732. var _loop = function _loop(i, ii) {
  3733. var extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
  3734. _this2._extractTextPromises[i] = extractTextCapability.promise;
  3735. promise = promise.then(function () {
  3736. return _this2._pdfDocument.getPage(i + 1).then(function (pdfPage) {
  3737. return pdfPage.getTextContent({
  3738. normalizeWhitespace: true
  3739. });
  3740. }).then(function (textContent) {
  3741. var textItems = textContent.items;
  3742. var strBuf = [];
  3743. for (var j = 0, jj = textItems.length; j < jj; j++) {
  3744. strBuf.push(textItems[j].str);
  3745. }
  3746. var _normalize3 = normalize(strBuf.join(""));
  3747. var _normalize4 = _slicedToArray(_normalize3, 2);
  3748. _this2._pageContents[i] = _normalize4[0];
  3749. _this2._pageDiffs[i] = _normalize4[1];
  3750. extractTextCapability.resolve(i);
  3751. }, function (reason) {
  3752. console.error("Unable to get text content for page ".concat(i + 1), reason);
  3753. _this2._pageContents[i] = "";
  3754. _this2._pageDiffs[i] = null;
  3755. extractTextCapability.resolve(i);
  3756. });
  3757. });
  3758. };
  3759. for (var i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
  3760. _loop(i, ii);
  3761. }
  3762. }
  3763. }, {
  3764. key: "_updatePage",
  3765. value: function _updatePage(index) {
  3766. if (this._scrollMatches && this._selected.pageIdx === index) {
  3767. this._linkService.page = index + 1;
  3768. }
  3769. this._eventBus.dispatch("updatetextlayermatches", {
  3770. source: this,
  3771. pageIndex: index
  3772. });
  3773. }
  3774. }, {
  3775. key: "_updateAllPages",
  3776. value: function _updateAllPages() {
  3777. this._eventBus.dispatch("updatetextlayermatches", {
  3778. source: this,
  3779. pageIndex: -1
  3780. });
  3781. }
  3782. }, {
  3783. key: "_nextMatch",
  3784. value: function _nextMatch() {
  3785. var _this3 = this;
  3786. var previous = this._state.findPrevious;
  3787. var currentPageIndex = this._linkService.page - 1;
  3788. var numPages = this._linkService.pagesCount;
  3789. this._highlightMatches = true;
  3790. if (this._dirtyMatch) {
  3791. this._dirtyMatch = false;
  3792. this._selected.pageIdx = this._selected.matchIdx = -1;
  3793. this._offset.pageIdx = currentPageIndex;
  3794. this._offset.matchIdx = null;
  3795. this._offset.wrapped = false;
  3796. this._resumePageIdx = null;
  3797. this._pageMatches.length = 0;
  3798. this._pageMatchesLength.length = 0;
  3799. this._matchesCountTotal = 0;
  3800. this._updateAllPages();
  3801. for (var i = 0; i < numPages; i++) {
  3802. if (this._pendingFindMatches.has(i)) {
  3803. continue;
  3804. }
  3805. this._pendingFindMatches.add(i);
  3806. this._extractTextPromises[i].then(function (pageIdx) {
  3807. _this3._pendingFindMatches["delete"](pageIdx);
  3808. _this3._calculateMatch(pageIdx);
  3809. });
  3810. }
  3811. }
  3812. if (this._query === "") {
  3813. this._updateUIState(FindState.FOUND);
  3814. return;
  3815. }
  3816. if (this._resumePageIdx) {
  3817. return;
  3818. }
  3819. var offset = this._offset;
  3820. this._pagesToSearch = numPages;
  3821. if (offset.matchIdx !== null) {
  3822. var numPageMatches = this._pageMatches[offset.pageIdx].length;
  3823. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  3824. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  3825. this._updateMatch(true);
  3826. return;
  3827. }
  3828. this._advanceOffsetPage(previous);
  3829. }
  3830. this._nextPageMatch();
  3831. }
  3832. }, {
  3833. key: "_matchesReady",
  3834. value: function _matchesReady(matches) {
  3835. var offset = this._offset;
  3836. var numMatches = matches.length;
  3837. var previous = this._state.findPrevious;
  3838. if (numMatches) {
  3839. offset.matchIdx = previous ? numMatches - 1 : 0;
  3840. this._updateMatch(true);
  3841. return true;
  3842. }
  3843. this._advanceOffsetPage(previous);
  3844. if (offset.wrapped) {
  3845. offset.matchIdx = null;
  3846. if (this._pagesToSearch < 0) {
  3847. this._updateMatch(false);
  3848. return true;
  3849. }
  3850. }
  3851. return false;
  3852. }
  3853. }, {
  3854. key: "_nextPageMatch",
  3855. value: function _nextPageMatch() {
  3856. if (this._resumePageIdx !== null) {
  3857. console.error("There can only be one pending page.");
  3858. }
  3859. var matches = null;
  3860. do {
  3861. var pageIdx = this._offset.pageIdx;
  3862. matches = this._pageMatches[pageIdx];
  3863. if (!matches) {
  3864. this._resumePageIdx = pageIdx;
  3865. break;
  3866. }
  3867. } while (!this._matchesReady(matches));
  3868. }
  3869. }, {
  3870. key: "_advanceOffsetPage",
  3871. value: function _advanceOffsetPage(previous) {
  3872. var offset = this._offset;
  3873. var numPages = this._linkService.pagesCount;
  3874. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  3875. offset.matchIdx = null;
  3876. this._pagesToSearch--;
  3877. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  3878. offset.pageIdx = previous ? numPages - 1 : 0;
  3879. offset.wrapped = true;
  3880. }
  3881. }
  3882. }, {
  3883. key: "_updateMatch",
  3884. value: function _updateMatch() {
  3885. var found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  3886. var state = FindState.NOT_FOUND;
  3887. var wrapped = this._offset.wrapped;
  3888. this._offset.wrapped = false;
  3889. if (found) {
  3890. var previousPage = this._selected.pageIdx;
  3891. this._selected.pageIdx = this._offset.pageIdx;
  3892. this._selected.matchIdx = this._offset.matchIdx;
  3893. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  3894. if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {
  3895. this._updatePage(previousPage);
  3896. }
  3897. }
  3898. this._updateUIState(state, this._state.findPrevious);
  3899. if (this._selected.pageIdx !== -1) {
  3900. this._scrollMatches = true;
  3901. this._updatePage(this._selected.pageIdx);
  3902. }
  3903. }
  3904. }, {
  3905. key: "_onFindBarClose",
  3906. value: function _onFindBarClose(evt) {
  3907. var _this4 = this;
  3908. var pdfDocument = this._pdfDocument;
  3909. this._firstPageCapability.promise.then(function () {
  3910. if (!_this4._pdfDocument || pdfDocument && _this4._pdfDocument !== pdfDocument) {
  3911. return;
  3912. }
  3913. if (_this4._findTimeout) {
  3914. clearTimeout(_this4._findTimeout);
  3915. _this4._findTimeout = null;
  3916. }
  3917. if (_this4._resumePageIdx) {
  3918. _this4._resumePageIdx = null;
  3919. _this4._dirtyMatch = true;
  3920. }
  3921. _this4._updateUIState(FindState.FOUND);
  3922. _this4._highlightMatches = false;
  3923. _this4._updateAllPages();
  3924. });
  3925. }
  3926. }, {
  3927. key: "_requestMatchesCount",
  3928. value: function _requestMatchesCount() {
  3929. var _this$_selected = this._selected,
  3930. pageIdx = _this$_selected.pageIdx,
  3931. matchIdx = _this$_selected.matchIdx;
  3932. var current = 0,
  3933. total = this._matchesCountTotal;
  3934. if (matchIdx !== -1) {
  3935. for (var i = 0; i < pageIdx; i++) {
  3936. var _this$_pageMatches$i;
  3937. current += ((_this$_pageMatches$i = this._pageMatches[i]) === null || _this$_pageMatches$i === void 0 ? void 0 : _this$_pageMatches$i.length) || 0;
  3938. }
  3939. current += matchIdx + 1;
  3940. }
  3941. if (current < 1 || current > total) {
  3942. current = total = 0;
  3943. }
  3944. return {
  3945. current: current,
  3946. total: total
  3947. };
  3948. }
  3949. }, {
  3950. key: "_updateUIResultsCount",
  3951. value: function _updateUIResultsCount() {
  3952. this._eventBus.dispatch("updatefindmatchescount", {
  3953. source: this,
  3954. matchesCount: this._requestMatchesCount()
  3955. });
  3956. }
  3957. }, {
  3958. key: "_updateUIState",
  3959. value: function _updateUIState(state, previous) {
  3960. var _this$_state$query, _this$_state2;
  3961. this._eventBus.dispatch("updatefindcontrolstate", {
  3962. source: this,
  3963. state: state,
  3964. previous: previous,
  3965. matchesCount: this._requestMatchesCount(),
  3966. rawQuery: (_this$_state$query = (_this$_state2 = this._state) === null || _this$_state2 === void 0 ? void 0 : _this$_state2.query) !== null && _this$_state$query !== void 0 ? _this$_state$query : null
  3967. });
  3968. }
  3969. }]);
  3970. return PDFFindController;
  3971. }();
  3972. exports.PDFFindController = PDFFindController;
  3973. /***/ }),
  3974. /* 14 */
  3975. /***/ ((__unused_webpack_module, exports) => {
  3976. Object.defineProperty(exports, "__esModule", ({
  3977. value: true
  3978. }));
  3979. exports.getCharacterType = getCharacterType;
  3980. exports.CharacterType = void 0;
  3981. var CharacterType = {
  3982. SPACE: 0,
  3983. ALPHA_LETTER: 1,
  3984. PUNCT: 2,
  3985. HAN_LETTER: 3,
  3986. KATAKANA_LETTER: 4,
  3987. HIRAGANA_LETTER: 5,
  3988. HALFWIDTH_KATAKANA_LETTER: 6,
  3989. THAI_LETTER: 7
  3990. };
  3991. exports.CharacterType = CharacterType;
  3992. function isAlphabeticalScript(charCode) {
  3993. return charCode < 0x2e80;
  3994. }
  3995. function isAscii(charCode) {
  3996. return (charCode & 0xff80) === 0;
  3997. }
  3998. function isAsciiAlpha(charCode) {
  3999. return charCode >= 0x61 && charCode <= 0x7a || charCode >= 0x41 && charCode <= 0x5a;
  4000. }
  4001. function isAsciiDigit(charCode) {
  4002. return charCode >= 0x30 && charCode <= 0x39;
  4003. }
  4004. function isAsciiSpace(charCode) {
  4005. return charCode === 0x20 || charCode === 0x09 || charCode === 0x0d || charCode === 0x0a;
  4006. }
  4007. function isHan(charCode) {
  4008. return charCode >= 0x3400 && charCode <= 0x9fff || charCode >= 0xf900 && charCode <= 0xfaff;
  4009. }
  4010. function isKatakana(charCode) {
  4011. return charCode >= 0x30a0 && charCode <= 0x30ff;
  4012. }
  4013. function isHiragana(charCode) {
  4014. return charCode >= 0x3040 && charCode <= 0x309f;
  4015. }
  4016. function isHalfwidthKatakana(charCode) {
  4017. return charCode >= 0xff60 && charCode <= 0xff9f;
  4018. }
  4019. function isThai(charCode) {
  4020. return (charCode & 0xff80) === 0x0e00;
  4021. }
  4022. function getCharacterType(charCode) {
  4023. if (isAlphabeticalScript(charCode)) {
  4024. if (isAscii(charCode)) {
  4025. if (isAsciiSpace(charCode)) {
  4026. return CharacterType.SPACE;
  4027. } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5f) {
  4028. return CharacterType.ALPHA_LETTER;
  4029. }
  4030. return CharacterType.PUNCT;
  4031. } else if (isThai(charCode)) {
  4032. return CharacterType.THAI_LETTER;
  4033. } else if (charCode === 0xa0) {
  4034. return CharacterType.SPACE;
  4035. }
  4036. return CharacterType.ALPHA_LETTER;
  4037. }
  4038. if (isHan(charCode)) {
  4039. return CharacterType.HAN_LETTER;
  4040. } else if (isKatakana(charCode)) {
  4041. return CharacterType.KATAKANA_LETTER;
  4042. } else if (isHiragana(charCode)) {
  4043. return CharacterType.HIRAGANA_LETTER;
  4044. } else if (isHalfwidthKatakana(charCode)) {
  4045. return CharacterType.HALFWIDTH_KATAKANA_LETTER;
  4046. }
  4047. return CharacterType.ALPHA_LETTER;
  4048. }
  4049. /***/ }),
  4050. /* 15 */
  4051. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  4052. Object.defineProperty(exports, "__esModule", ({
  4053. value: true
  4054. }));
  4055. exports.isDestArraysEqual = isDestArraysEqual;
  4056. exports.isDestHashesEqual = isDestHashesEqual;
  4057. exports.PDFHistory = void 0;
  4058. var _ui_utils = __w_pdfjs_require__(7);
  4059. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  4060. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  4061. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  4062. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  4063. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  4064. function _iterableToArrayLimit(arr, i) { var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]); if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  4065. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  4066. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4067. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  4068. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4069. var HASH_CHANGE_TIMEOUT = 1000;
  4070. var POSITION_UPDATED_THRESHOLD = 50;
  4071. var UPDATE_VIEWAREA_TIMEOUT = 1000;
  4072. function getCurrentHash() {
  4073. return document.location.hash;
  4074. }
  4075. var PDFHistory = /*#__PURE__*/function () {
  4076. function PDFHistory(_ref) {
  4077. var _this = this;
  4078. var linkService = _ref.linkService,
  4079. eventBus = _ref.eventBus;
  4080. _classCallCheck(this, PDFHistory);
  4081. this.linkService = linkService;
  4082. this.eventBus = eventBus;
  4083. this._initialized = false;
  4084. this._fingerprint = "";
  4085. this.reset();
  4086. this._boundEvents = null;
  4087. this._isViewerInPresentationMode = false;
  4088. this.eventBus._on("presentationmodechanged", function (evt) {
  4089. _this._isViewerInPresentationMode = evt.state !== _ui_utils.PresentationModeState.NORMAL;
  4090. });
  4091. this.eventBus._on("pagesinit", function () {
  4092. _this._isPagesLoaded = false;
  4093. _this.eventBus._on("pagesloaded", function (evt) {
  4094. _this._isPagesLoaded = !!evt.pagesCount;
  4095. }, {
  4096. once: true
  4097. });
  4098. });
  4099. }
  4100. _createClass(PDFHistory, [{
  4101. key: "initialize",
  4102. value: function initialize(_ref2) {
  4103. var fingerprint = _ref2.fingerprint,
  4104. _ref2$resetHistory = _ref2.resetHistory,
  4105. resetHistory = _ref2$resetHistory === void 0 ? false : _ref2$resetHistory,
  4106. _ref2$updateUrl = _ref2.updateUrl,
  4107. updateUrl = _ref2$updateUrl === void 0 ? false : _ref2$updateUrl;
  4108. if (!fingerprint || typeof fingerprint !== "string") {
  4109. console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
  4110. return;
  4111. }
  4112. if (this._initialized) {
  4113. this.reset();
  4114. }
  4115. var reInitialized = this._fingerprint !== "" && this._fingerprint !== fingerprint;
  4116. this._fingerprint = fingerprint;
  4117. this._updateUrl = updateUrl === true;
  4118. this._initialized = true;
  4119. this._bindEvents();
  4120. var state = window.history.state;
  4121. this._popStateInProgress = false;
  4122. this._blockHashChange = 0;
  4123. this._currentHash = getCurrentHash();
  4124. this._numPositionUpdates = 0;
  4125. this._uid = this._maxUid = 0;
  4126. this._destination = null;
  4127. this._position = null;
  4128. if (!this._isValidState(state, true) || resetHistory) {
  4129. var _this$_parseCurrentHa = this._parseCurrentHash(true),
  4130. hash = _this$_parseCurrentHa.hash,
  4131. page = _this$_parseCurrentHa.page,
  4132. rotation = _this$_parseCurrentHa.rotation;
  4133. if (!hash || reInitialized || resetHistory) {
  4134. this._pushOrReplaceState(null, true);
  4135. return;
  4136. }
  4137. this._pushOrReplaceState({
  4138. hash: hash,
  4139. page: page,
  4140. rotation: rotation
  4141. }, true);
  4142. return;
  4143. }
  4144. var destination = state.destination;
  4145. this._updateInternalState(destination, state.uid, true);
  4146. if (destination.rotation !== undefined) {
  4147. this._initialRotation = destination.rotation;
  4148. }
  4149. if (destination.dest) {
  4150. this._initialBookmark = JSON.stringify(destination.dest);
  4151. this._destination.page = null;
  4152. } else if (destination.hash) {
  4153. this._initialBookmark = destination.hash;
  4154. } else if (destination.page) {
  4155. this._initialBookmark = "page=".concat(destination.page);
  4156. }
  4157. }
  4158. }, {
  4159. key: "reset",
  4160. value: function reset() {
  4161. if (this._initialized) {
  4162. this._pageHide();
  4163. this._initialized = false;
  4164. this._unbindEvents();
  4165. }
  4166. if (this._updateViewareaTimeout) {
  4167. clearTimeout(this._updateViewareaTimeout);
  4168. this._updateViewareaTimeout = null;
  4169. }
  4170. this._initialBookmark = null;
  4171. this._initialRotation = null;
  4172. }
  4173. }, {
  4174. key: "push",
  4175. value: function push(_ref3) {
  4176. var _this2 = this;
  4177. var _ref3$namedDest = _ref3.namedDest,
  4178. namedDest = _ref3$namedDest === void 0 ? null : _ref3$namedDest,
  4179. explicitDest = _ref3.explicitDest,
  4180. pageNumber = _ref3.pageNumber;
  4181. if (!this._initialized) {
  4182. return;
  4183. }
  4184. if (namedDest && typeof namedDest !== "string") {
  4185. console.error("PDFHistory.push: " + "\"".concat(namedDest, "\" is not a valid namedDest parameter."));
  4186. return;
  4187. } else if (!Array.isArray(explicitDest)) {
  4188. console.error("PDFHistory.push: " + "\"".concat(explicitDest, "\" is not a valid explicitDest parameter."));
  4189. return;
  4190. } else if (!this._isValidPage(pageNumber)) {
  4191. if (pageNumber !== null || this._destination) {
  4192. console.error("PDFHistory.push: " + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  4193. return;
  4194. }
  4195. }
  4196. var hash = namedDest || JSON.stringify(explicitDest);
  4197. if (!hash) {
  4198. return;
  4199. }
  4200. var forceReplace = false;
  4201. if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
  4202. if (this._destination.page) {
  4203. return;
  4204. }
  4205. forceReplace = true;
  4206. }
  4207. if (this._popStateInProgress && !forceReplace) {
  4208. return;
  4209. }
  4210. this._pushOrReplaceState({
  4211. dest: explicitDest,
  4212. hash: hash,
  4213. page: pageNumber,
  4214. rotation: this.linkService.rotation
  4215. }, forceReplace);
  4216. if (!this._popStateInProgress) {
  4217. this._popStateInProgress = true;
  4218. Promise.resolve().then(function () {
  4219. _this2._popStateInProgress = false;
  4220. });
  4221. }
  4222. }
  4223. }, {
  4224. key: "pushPage",
  4225. value: function pushPage(pageNumber) {
  4226. var _this$_destination,
  4227. _this3 = this;
  4228. if (!this._initialized) {
  4229. return;
  4230. }
  4231. if (!this._isValidPage(pageNumber)) {
  4232. console.error("PDFHistory.pushPage: \"".concat(pageNumber, "\" is not a valid page number."));
  4233. return;
  4234. }
  4235. if (((_this$_destination = this._destination) === null || _this$_destination === void 0 ? void 0 : _this$_destination.page) === pageNumber) {
  4236. return;
  4237. }
  4238. if (this._popStateInProgress) {
  4239. return;
  4240. }
  4241. this._pushOrReplaceState({
  4242. dest: null,
  4243. hash: "page=".concat(pageNumber),
  4244. page: pageNumber,
  4245. rotation: this.linkService.rotation
  4246. });
  4247. if (!this._popStateInProgress) {
  4248. this._popStateInProgress = true;
  4249. Promise.resolve().then(function () {
  4250. _this3._popStateInProgress = false;
  4251. });
  4252. }
  4253. }
  4254. }, {
  4255. key: "pushCurrentPosition",
  4256. value: function pushCurrentPosition() {
  4257. if (!this._initialized || this._popStateInProgress) {
  4258. return;
  4259. }
  4260. this._tryPushCurrentPosition();
  4261. }
  4262. }, {
  4263. key: "back",
  4264. value: function back() {
  4265. if (!this._initialized || this._popStateInProgress) {
  4266. return;
  4267. }
  4268. var state = window.history.state;
  4269. if (this._isValidState(state) && state.uid > 0) {
  4270. window.history.back();
  4271. }
  4272. }
  4273. }, {
  4274. key: "forward",
  4275. value: function forward() {
  4276. if (!this._initialized || this._popStateInProgress) {
  4277. return;
  4278. }
  4279. var state = window.history.state;
  4280. if (this._isValidState(state) && state.uid < this._maxUid) {
  4281. window.history.forward();
  4282. }
  4283. }
  4284. }, {
  4285. key: "popStateInProgress",
  4286. get: function get() {
  4287. return this._initialized && (this._popStateInProgress || this._blockHashChange > 0);
  4288. }
  4289. }, {
  4290. key: "initialBookmark",
  4291. get: function get() {
  4292. return this._initialized ? this._initialBookmark : null;
  4293. }
  4294. }, {
  4295. key: "initialRotation",
  4296. get: function get() {
  4297. return this._initialized ? this._initialRotation : null;
  4298. }
  4299. }, {
  4300. key: "_pushOrReplaceState",
  4301. value: function _pushOrReplaceState(destination) {
  4302. var forceReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4303. var shouldReplace = forceReplace || !this._destination;
  4304. var newState = {
  4305. fingerprint: this._fingerprint,
  4306. uid: shouldReplace ? this._uid : this._uid + 1,
  4307. destination: destination
  4308. };
  4309. this._updateInternalState(destination, newState.uid);
  4310. var newUrl;
  4311. if (this._updateUrl && destination !== null && destination !== void 0 && destination.hash) {
  4312. var baseUrl = document.location.href.split("#")[0];
  4313. if (!baseUrl.startsWith("file://")) {
  4314. newUrl = "".concat(baseUrl, "#").concat(destination.hash);
  4315. }
  4316. }
  4317. if (shouldReplace) {
  4318. window.history.replaceState(newState, "", newUrl);
  4319. } else {
  4320. window.history.pushState(newState, "", newUrl);
  4321. }
  4322. }
  4323. }, {
  4324. key: "_tryPushCurrentPosition",
  4325. value: function _tryPushCurrentPosition() {
  4326. var temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4327. if (!this._position) {
  4328. return;
  4329. }
  4330. var position = this._position;
  4331. if (temporary) {
  4332. position = Object.assign(Object.create(null), this._position);
  4333. position.temporary = true;
  4334. }
  4335. if (!this._destination) {
  4336. this._pushOrReplaceState(position);
  4337. return;
  4338. }
  4339. if (this._destination.temporary) {
  4340. this._pushOrReplaceState(position, true);
  4341. return;
  4342. }
  4343. if (this._destination.hash === position.hash) {
  4344. return;
  4345. }
  4346. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  4347. return;
  4348. }
  4349. var forceReplace = false;
  4350. if (this._destination.page >= position.first && this._destination.page <= position.page) {
  4351. if (this._destination.dest !== undefined || !this._destination.first) {
  4352. return;
  4353. }
  4354. forceReplace = true;
  4355. }
  4356. this._pushOrReplaceState(position, forceReplace);
  4357. }
  4358. }, {
  4359. key: "_isValidPage",
  4360. value: function _isValidPage(val) {
  4361. return Number.isInteger(val) && val > 0 && val <= this.linkService.pagesCount;
  4362. }
  4363. }, {
  4364. key: "_isValidState",
  4365. value: function _isValidState(state) {
  4366. var checkReload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4367. if (!state) {
  4368. return false;
  4369. }
  4370. if (state.fingerprint !== this._fingerprint) {
  4371. if (checkReload) {
  4372. if (typeof state.fingerprint !== "string" || state.fingerprint.length !== this._fingerprint.length) {
  4373. return false;
  4374. }
  4375. var _performance$getEntri = performance.getEntriesByType("navigation"),
  4376. _performance$getEntri2 = _slicedToArray(_performance$getEntri, 1),
  4377. perfEntry = _performance$getEntri2[0];
  4378. if ((perfEntry === null || perfEntry === void 0 ? void 0 : perfEntry.type) !== "reload") {
  4379. return false;
  4380. }
  4381. } else {
  4382. return false;
  4383. }
  4384. }
  4385. if (!Number.isInteger(state.uid) || state.uid < 0) {
  4386. return false;
  4387. }
  4388. if (state.destination === null || _typeof(state.destination) !== "object") {
  4389. return false;
  4390. }
  4391. return true;
  4392. }
  4393. }, {
  4394. key: "_updateInternalState",
  4395. value: function _updateInternalState(destination, uid) {
  4396. var removeTemporary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  4397. if (this._updateViewareaTimeout) {
  4398. clearTimeout(this._updateViewareaTimeout);
  4399. this._updateViewareaTimeout = null;
  4400. }
  4401. if (removeTemporary && destination !== null && destination !== void 0 && destination.temporary) {
  4402. delete destination.temporary;
  4403. }
  4404. this._destination = destination;
  4405. this._uid = uid;
  4406. this._maxUid = Math.max(this._maxUid, uid);
  4407. this._numPositionUpdates = 0;
  4408. }
  4409. }, {
  4410. key: "_parseCurrentHash",
  4411. value: function _parseCurrentHash() {
  4412. var checkNameddest = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4413. var hash = unescape(getCurrentHash()).substring(1);
  4414. var params = (0, _ui_utils.parseQueryString)(hash);
  4415. var nameddest = params.nameddest || "";
  4416. var page = params.page | 0;
  4417. if (!this._isValidPage(page) || checkNameddest && nameddest.length > 0) {
  4418. page = null;
  4419. }
  4420. return {
  4421. hash: hash,
  4422. page: page,
  4423. rotation: this.linkService.rotation
  4424. };
  4425. }
  4426. }, {
  4427. key: "_updateViewarea",
  4428. value: function _updateViewarea(_ref4) {
  4429. var _this4 = this;
  4430. var location = _ref4.location;
  4431. if (this._updateViewareaTimeout) {
  4432. clearTimeout(this._updateViewareaTimeout);
  4433. this._updateViewareaTimeout = null;
  4434. }
  4435. this._position = {
  4436. hash: this._isViewerInPresentationMode ? "page=".concat(location.pageNumber) : location.pdfOpenParams.substring(1),
  4437. page: this.linkService.page,
  4438. first: location.pageNumber,
  4439. rotation: location.rotation
  4440. };
  4441. if (this._popStateInProgress) {
  4442. return;
  4443. }
  4444. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
  4445. this._numPositionUpdates++;
  4446. }
  4447. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  4448. this._updateViewareaTimeout = setTimeout(function () {
  4449. if (!_this4._popStateInProgress) {
  4450. _this4._tryPushCurrentPosition(true);
  4451. }
  4452. _this4._updateViewareaTimeout = null;
  4453. }, UPDATE_VIEWAREA_TIMEOUT);
  4454. }
  4455. }
  4456. }, {
  4457. key: "_popState",
  4458. value: function _popState(_ref5) {
  4459. var _this5 = this;
  4460. var state = _ref5.state;
  4461. var newHash = getCurrentHash(),
  4462. hashChanged = this._currentHash !== newHash;
  4463. this._currentHash = newHash;
  4464. if (!state) {
  4465. this._uid++;
  4466. var _this$_parseCurrentHa2 = this._parseCurrentHash(),
  4467. hash = _this$_parseCurrentHa2.hash,
  4468. page = _this$_parseCurrentHa2.page,
  4469. rotation = _this$_parseCurrentHa2.rotation;
  4470. this._pushOrReplaceState({
  4471. hash: hash,
  4472. page: page,
  4473. rotation: rotation
  4474. }, true);
  4475. return;
  4476. }
  4477. if (!this._isValidState(state)) {
  4478. return;
  4479. }
  4480. this._popStateInProgress = true;
  4481. if (hashChanged) {
  4482. this._blockHashChange++;
  4483. (0, _ui_utils.waitOnEventOrTimeout)({
  4484. target: window,
  4485. name: "hashchange",
  4486. delay: HASH_CHANGE_TIMEOUT
  4487. }).then(function () {
  4488. _this5._blockHashChange--;
  4489. });
  4490. }
  4491. var destination = state.destination;
  4492. this._updateInternalState(destination, state.uid, true);
  4493. if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
  4494. this.linkService.rotation = destination.rotation;
  4495. }
  4496. if (destination.dest) {
  4497. this.linkService.goToDestination(destination.dest);
  4498. } else if (destination.hash) {
  4499. this.linkService.setHash(destination.hash);
  4500. } else if (destination.page) {
  4501. this.linkService.page = destination.page;
  4502. }
  4503. Promise.resolve().then(function () {
  4504. _this5._popStateInProgress = false;
  4505. });
  4506. }
  4507. }, {
  4508. key: "_pageHide",
  4509. value: function _pageHide() {
  4510. if (!this._destination || this._destination.temporary) {
  4511. this._tryPushCurrentPosition();
  4512. }
  4513. }
  4514. }, {
  4515. key: "_bindEvents",
  4516. value: function _bindEvents() {
  4517. if (this._boundEvents) {
  4518. return;
  4519. }
  4520. this._boundEvents = {
  4521. updateViewarea: this._updateViewarea.bind(this),
  4522. popState: this._popState.bind(this),
  4523. pageHide: this._pageHide.bind(this)
  4524. };
  4525. this.eventBus._on("updateviewarea", this._boundEvents.updateViewarea);
  4526. window.addEventListener("popstate", this._boundEvents.popState);
  4527. window.addEventListener("pagehide", this._boundEvents.pageHide);
  4528. }
  4529. }, {
  4530. key: "_unbindEvents",
  4531. value: function _unbindEvents() {
  4532. if (!this._boundEvents) {
  4533. return;
  4534. }
  4535. this.eventBus._off("updateviewarea", this._boundEvents.updateViewarea);
  4536. window.removeEventListener("popstate", this._boundEvents.popState);
  4537. window.removeEventListener("pagehide", this._boundEvents.pageHide);
  4538. this._boundEvents = null;
  4539. }
  4540. }]);
  4541. return PDFHistory;
  4542. }();
  4543. exports.PDFHistory = PDFHistory;
  4544. function isDestHashesEqual(destHash, pushHash) {
  4545. if (typeof destHash !== "string" || typeof pushHash !== "string") {
  4546. return false;
  4547. }
  4548. if (destHash === pushHash) {
  4549. return true;
  4550. }
  4551. var _parseQueryString = (0, _ui_utils.parseQueryString)(destHash),
  4552. nameddest = _parseQueryString.nameddest;
  4553. if (nameddest === pushHash) {
  4554. return true;
  4555. }
  4556. return false;
  4557. }
  4558. function isDestArraysEqual(firstDest, secondDest) {
  4559. function isEntryEqual(first, second) {
  4560. if (_typeof(first) !== _typeof(second)) {
  4561. return false;
  4562. }
  4563. if (Array.isArray(first) || Array.isArray(second)) {
  4564. return false;
  4565. }
  4566. if (first !== null && _typeof(first) === "object" && second !== null) {
  4567. if (Object.keys(first).length !== Object.keys(second).length) {
  4568. return false;
  4569. }
  4570. for (var key in first) {
  4571. if (!isEntryEqual(first[key], second[key])) {
  4572. return false;
  4573. }
  4574. }
  4575. return true;
  4576. }
  4577. return first === second || Number.isNaN(first) && Number.isNaN(second);
  4578. }
  4579. if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
  4580. return false;
  4581. }
  4582. if (firstDest.length !== secondDest.length) {
  4583. return false;
  4584. }
  4585. for (var i = 0, ii = firstDest.length; i < ii; i++) {
  4586. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  4587. return false;
  4588. }
  4589. }
  4590. return true;
  4591. }
  4592. /***/ }),
  4593. /* 16 */
  4594. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  4595. Object.defineProperty(exports, "__esModule", ({
  4596. value: true
  4597. }));
  4598. exports.PDFPageView = void 0;
  4599. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(4));
  4600. var _ui_utils = __w_pdfjs_require__(7);
  4601. var _pdfjsLib = __w_pdfjs_require__(2);
  4602. var _l10n_utils = __w_pdfjs_require__(3);
  4603. var _pdf_rendering_queue = __w_pdfjs_require__(17);
  4604. var _viewer_compatibility = __w_pdfjs_require__(10);
  4605. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  4606. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  4607. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  4608. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4609. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  4610. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4611. var MAX_CANVAS_PIXELS = _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216;
  4612. var PDFPageView = /*#__PURE__*/function () {
  4613. function PDFPageView(options) {
  4614. _classCallCheck(this, PDFPageView);
  4615. var container = options.container;
  4616. var defaultViewport = options.defaultViewport;
  4617. this.id = options.id;
  4618. this.renderingId = "page" + this.id;
  4619. this.pdfPage = null;
  4620. this.pageLabel = null;
  4621. this.rotation = 0;
  4622. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  4623. this.viewport = defaultViewport;
  4624. this.pdfPageRotate = defaultViewport.rotation;
  4625. this._optionalContentConfigPromise = options.optionalContentConfigPromise || null;
  4626. this.hasRestrictedScaling = false;
  4627. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  4628. this.imageResourcesPath = options.imageResourcesPath || "";
  4629. this.renderInteractiveForms = options.renderInteractiveForms !== false;
  4630. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  4631. this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
  4632. this.eventBus = options.eventBus;
  4633. this.renderingQueue = options.renderingQueue;
  4634. this.textLayerFactory = options.textLayerFactory;
  4635. this.annotationLayerFactory = options.annotationLayerFactory;
  4636. this.xfaLayerFactory = options.xfaLayerFactory;
  4637. this.structTreeLayerFactory = options.structTreeLayerFactory;
  4638. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  4639. this.l10n = options.l10n || _l10n_utils.NullL10n;
  4640. this.paintTask = null;
  4641. this.paintedViewportMap = new WeakMap();
  4642. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  4643. this.resume = null;
  4644. this._renderError = null;
  4645. this.annotationLayer = null;
  4646. this.textLayer = null;
  4647. this.zoomLayer = null;
  4648. this.xfaLayer = null;
  4649. this.structTreeLayer = null;
  4650. var div = document.createElement("div");
  4651. div.className = "page";
  4652. div.style.width = Math.floor(this.viewport.width) + "px";
  4653. div.style.height = Math.floor(this.viewport.height) + "px";
  4654. div.setAttribute("data-page-number", this.id);
  4655. div.setAttribute("role", "region");
  4656. this.l10n.get("page_landmark", {
  4657. page: this.id
  4658. }).then(function (msg) {
  4659. div.setAttribute("aria-label", msg);
  4660. });
  4661. this.div = div;
  4662. container.appendChild(div);
  4663. }
  4664. _createClass(PDFPageView, [{
  4665. key: "setPdfPage",
  4666. value: function setPdfPage(pdfPage) {
  4667. this.pdfPage = pdfPage;
  4668. this.pdfPageRotate = pdfPage.rotate;
  4669. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  4670. this.viewport = pdfPage.getViewport({
  4671. scale: this.scale * _ui_utils.CSS_UNITS,
  4672. rotation: totalRotation
  4673. });
  4674. this.reset();
  4675. }
  4676. }, {
  4677. key: "destroy",
  4678. value: function destroy() {
  4679. this.reset();
  4680. if (this.pdfPage) {
  4681. this.pdfPage.cleanup();
  4682. }
  4683. }
  4684. }, {
  4685. key: "_renderAnnotationLayer",
  4686. value: function () {
  4687. var _renderAnnotationLayer2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  4688. var error;
  4689. return _regenerator["default"].wrap(function _callee$(_context) {
  4690. while (1) {
  4691. switch (_context.prev = _context.next) {
  4692. case 0:
  4693. error = null;
  4694. _context.prev = 1;
  4695. _context.next = 4;
  4696. return this.annotationLayer.render(this.viewport, "display");
  4697. case 4:
  4698. _context.next = 9;
  4699. break;
  4700. case 6:
  4701. _context.prev = 6;
  4702. _context.t0 = _context["catch"](1);
  4703. error = _context.t0;
  4704. case 9:
  4705. _context.prev = 9;
  4706. this.eventBus.dispatch("annotationlayerrendered", {
  4707. source: this,
  4708. pageNumber: this.id,
  4709. error: error
  4710. });
  4711. return _context.finish(9);
  4712. case 12:
  4713. case "end":
  4714. return _context.stop();
  4715. }
  4716. }
  4717. }, _callee, this, [[1, 6, 9, 12]]);
  4718. }));
  4719. function _renderAnnotationLayer() {
  4720. return _renderAnnotationLayer2.apply(this, arguments);
  4721. }
  4722. return _renderAnnotationLayer;
  4723. }()
  4724. }, {
  4725. key: "_renderXfaLayer",
  4726. value: function () {
  4727. var _renderXfaLayer2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  4728. var error;
  4729. return _regenerator["default"].wrap(function _callee2$(_context2) {
  4730. while (1) {
  4731. switch (_context2.prev = _context2.next) {
  4732. case 0:
  4733. error = null;
  4734. _context2.prev = 1;
  4735. _context2.next = 4;
  4736. return this.xfaLayer.render(this.viewport, "display");
  4737. case 4:
  4738. _context2.next = 9;
  4739. break;
  4740. case 6:
  4741. _context2.prev = 6;
  4742. _context2.t0 = _context2["catch"](1);
  4743. error = _context2.t0;
  4744. case 9:
  4745. _context2.prev = 9;
  4746. this.eventBus.dispatch("xfalayerrendered", {
  4747. source: this,
  4748. pageNumber: this.id,
  4749. error: error
  4750. });
  4751. return _context2.finish(9);
  4752. case 12:
  4753. case "end":
  4754. return _context2.stop();
  4755. }
  4756. }
  4757. }, _callee2, this, [[1, 6, 9, 12]]);
  4758. }));
  4759. function _renderXfaLayer() {
  4760. return _renderXfaLayer2.apply(this, arguments);
  4761. }
  4762. return _renderXfaLayer;
  4763. }()
  4764. }, {
  4765. key: "_resetZoomLayer",
  4766. value: function _resetZoomLayer() {
  4767. var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4768. if (!this.zoomLayer) {
  4769. return;
  4770. }
  4771. var zoomLayerCanvas = this.zoomLayer.firstChild;
  4772. this.paintedViewportMap["delete"](zoomLayerCanvas);
  4773. zoomLayerCanvas.width = 0;
  4774. zoomLayerCanvas.height = 0;
  4775. if (removeFromDOM) {
  4776. this.zoomLayer.remove();
  4777. }
  4778. this.zoomLayer = null;
  4779. }
  4780. }, {
  4781. key: "reset",
  4782. value: function reset() {
  4783. var _this$annotationLayer,
  4784. _this$xfaLayer,
  4785. _this = this;
  4786. var keepZoomLayer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4787. var keepAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4788. this.cancelRendering(keepAnnotations);
  4789. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  4790. var div = this.div;
  4791. div.style.width = Math.floor(this.viewport.width) + "px";
  4792. div.style.height = Math.floor(this.viewport.height) + "px";
  4793. var childNodes = div.childNodes;
  4794. var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
  4795. var currentAnnotationNode = keepAnnotations && ((_this$annotationLayer = this.annotationLayer) === null || _this$annotationLayer === void 0 ? void 0 : _this$annotationLayer.div) || null;
  4796. var currentXfaLayerNode = ((_this$xfaLayer = this.xfaLayer) === null || _this$xfaLayer === void 0 ? void 0 : _this$xfaLayer.div) || null;
  4797. for (var i = childNodes.length - 1; i >= 0; i--) {
  4798. var node = childNodes[i];
  4799. if (currentZoomLayerNode === node || currentAnnotationNode === node || currentXfaLayerNode === node) {
  4800. continue;
  4801. }
  4802. div.removeChild(node);
  4803. }
  4804. div.removeAttribute("data-loaded");
  4805. if (currentAnnotationNode) {
  4806. this.annotationLayer.hide();
  4807. } else if (this.annotationLayer) {
  4808. this.annotationLayer.cancel();
  4809. this.annotationLayer = null;
  4810. }
  4811. if (!currentZoomLayerNode) {
  4812. if (this.canvas) {
  4813. this.paintedViewportMap["delete"](this.canvas);
  4814. this.canvas.width = 0;
  4815. this.canvas.height = 0;
  4816. delete this.canvas;
  4817. }
  4818. this._resetZoomLayer();
  4819. }
  4820. if (this.svg) {
  4821. this.paintedViewportMap["delete"](this.svg);
  4822. delete this.svg;
  4823. }
  4824. this.loadingIconDiv = document.createElement("div");
  4825. this.loadingIconDiv.className = "loadingIcon";
  4826. this.loadingIconDiv.setAttribute("role", "img");
  4827. this.l10n.get("loading").then(function (msg) {
  4828. var _this$loadingIconDiv;
  4829. (_this$loadingIconDiv = _this.loadingIconDiv) === null || _this$loadingIconDiv === void 0 ? void 0 : _this$loadingIconDiv.setAttribute("aria-label", msg);
  4830. });
  4831. div.appendChild(this.loadingIconDiv);
  4832. }
  4833. }, {
  4834. key: "update",
  4835. value: function update(scale, rotation) {
  4836. var optionalContentConfigPromise = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4837. this.scale = scale || this.scale;
  4838. if (typeof rotation !== "undefined") {
  4839. this.rotation = rotation;
  4840. }
  4841. if (optionalContentConfigPromise instanceof Promise) {
  4842. this._optionalContentConfigPromise = optionalContentConfigPromise;
  4843. }
  4844. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  4845. this.viewport = this.viewport.clone({
  4846. scale: this.scale * _ui_utils.CSS_UNITS,
  4847. rotation: totalRotation
  4848. });
  4849. if (this.svg) {
  4850. this.cssTransform(this.svg, true);
  4851. this.eventBus.dispatch("pagerendered", {
  4852. source: this,
  4853. pageNumber: this.id,
  4854. cssTransform: true,
  4855. timestamp: performance.now(),
  4856. error: this._renderError
  4857. });
  4858. return;
  4859. }
  4860. var isScalingRestricted = false;
  4861. if (this.canvas && this.maxCanvasPixels > 0) {
  4862. var outputScale = this.outputScale;
  4863. if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > this.maxCanvasPixels) {
  4864. isScalingRestricted = true;
  4865. }
  4866. }
  4867. if (this.canvas) {
  4868. if (this.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
  4869. this.cssTransform(this.canvas, true);
  4870. this.eventBus.dispatch("pagerendered", {
  4871. source: this,
  4872. pageNumber: this.id,
  4873. cssTransform: true,
  4874. timestamp: performance.now(),
  4875. error: this._renderError
  4876. });
  4877. return;
  4878. }
  4879. if (!this.zoomLayer && !this.canvas.hidden) {
  4880. this.zoomLayer = this.canvas.parentNode;
  4881. this.zoomLayer.style.position = "absolute";
  4882. }
  4883. }
  4884. if (this.zoomLayer) {
  4885. this.cssTransform(this.zoomLayer.firstChild);
  4886. }
  4887. this.reset(true, true);
  4888. }
  4889. }, {
  4890. key: "cancelRendering",
  4891. value: function cancelRendering() {
  4892. var keepAnnotations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4893. if (this.paintTask) {
  4894. this.paintTask.cancel();
  4895. this.paintTask = null;
  4896. }
  4897. this.resume = null;
  4898. if (this.textLayer) {
  4899. this.textLayer.cancel();
  4900. this.textLayer = null;
  4901. }
  4902. if (!keepAnnotations && this.annotationLayer) {
  4903. this.annotationLayer.cancel();
  4904. this.annotationLayer = null;
  4905. }
  4906. if (this._onTextLayerRendered) {
  4907. this.eventBus._off("textlayerrendered", this._onTextLayerRendered);
  4908. this._onTextLayerRendered = null;
  4909. }
  4910. }
  4911. }, {
  4912. key: "cssTransform",
  4913. value: function cssTransform(target) {
  4914. var redrawAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4915. var width = this.viewport.width;
  4916. var height = this.viewport.height;
  4917. var div = this.div;
  4918. target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + "px";
  4919. target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + "px";
  4920. var relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
  4921. var absRotation = Math.abs(relativeRotation);
  4922. var scaleX = 1,
  4923. scaleY = 1;
  4924. if (absRotation === 90 || absRotation === 270) {
  4925. scaleX = height / width;
  4926. scaleY = width / height;
  4927. }
  4928. target.style.transform = "rotate(".concat(relativeRotation, "deg) scale(").concat(scaleX, ", ").concat(scaleY, ")");
  4929. if (this.textLayer) {
  4930. var textLayerViewport = this.textLayer.viewport;
  4931. var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
  4932. var textAbsRotation = Math.abs(textRelativeRotation);
  4933. var scale = width / textLayerViewport.width;
  4934. if (textAbsRotation === 90 || textAbsRotation === 270) {
  4935. scale = width / textLayerViewport.height;
  4936. }
  4937. var textLayerDiv = this.textLayer.textLayerDiv;
  4938. var transX, transY;
  4939. switch (textAbsRotation) {
  4940. case 0:
  4941. transX = transY = 0;
  4942. break;
  4943. case 90:
  4944. transX = 0;
  4945. transY = "-" + textLayerDiv.style.height;
  4946. break;
  4947. case 180:
  4948. transX = "-" + textLayerDiv.style.width;
  4949. transY = "-" + textLayerDiv.style.height;
  4950. break;
  4951. case 270:
  4952. transX = "-" + textLayerDiv.style.width;
  4953. transY = 0;
  4954. break;
  4955. default:
  4956. console.error("Bad rotation value.");
  4957. break;
  4958. }
  4959. textLayerDiv.style.transform = "rotate(".concat(textAbsRotation, "deg) ") + "scale(".concat(scale, ") ") + "translate(".concat(transX, ", ").concat(transY, ")");
  4960. textLayerDiv.style.transformOrigin = "0% 0%";
  4961. }
  4962. if (redrawAnnotations && this.annotationLayer) {
  4963. this._renderAnnotationLayer();
  4964. }
  4965. if (this.xfaLayer) {
  4966. this._renderXfaLayer();
  4967. }
  4968. }
  4969. }, {
  4970. key: "width",
  4971. get: function get() {
  4972. return this.viewport.width;
  4973. }
  4974. }, {
  4975. key: "height",
  4976. get: function get() {
  4977. return this.viewport.height;
  4978. }
  4979. }, {
  4980. key: "getPagePoint",
  4981. value: function getPagePoint(x, y) {
  4982. return this.viewport.convertToPdfPoint(x, y);
  4983. }
  4984. }, {
  4985. key: "draw",
  4986. value: function draw() {
  4987. var _this$annotationLayer2,
  4988. _this2 = this;
  4989. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  4990. console.error("Must be in new state before drawing");
  4991. this.reset();
  4992. }
  4993. var div = this.div,
  4994. pdfPage = this.pdfPage;
  4995. if (!pdfPage) {
  4996. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  4997. if (this.loadingIconDiv) {
  4998. div.removeChild(this.loadingIconDiv);
  4999. delete this.loadingIconDiv;
  5000. }
  5001. return Promise.reject(new Error("pdfPage is not loaded"));
  5002. }
  5003. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  5004. var canvasWrapper = document.createElement("div");
  5005. canvasWrapper.style.width = div.style.width;
  5006. canvasWrapper.style.height = div.style.height;
  5007. canvasWrapper.classList.add("canvasWrapper");
  5008. if ((_this$annotationLayer2 = this.annotationLayer) !== null && _this$annotationLayer2 !== void 0 && _this$annotationLayer2.div) {
  5009. div.insertBefore(canvasWrapper, this.annotationLayer.div);
  5010. } else {
  5011. div.appendChild(canvasWrapper);
  5012. }
  5013. var textLayer = null;
  5014. if (this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && this.textLayerFactory) {
  5015. var _this$annotationLayer3;
  5016. var textLayerDiv = document.createElement("div");
  5017. textLayerDiv.className = "textLayer";
  5018. textLayerDiv.style.width = canvasWrapper.style.width;
  5019. textLayerDiv.style.height = canvasWrapper.style.height;
  5020. if ((_this$annotationLayer3 = this.annotationLayer) !== null && _this$annotationLayer3 !== void 0 && _this$annotationLayer3.div) {
  5021. div.insertBefore(textLayerDiv, this.annotationLayer.div);
  5022. } else {
  5023. div.appendChild(textLayerDiv);
  5024. }
  5025. textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.textLayerMode === _ui_utils.TextLayerMode.ENABLE_ENHANCE, this.eventBus);
  5026. }
  5027. this.textLayer = textLayer;
  5028. var renderContinueCallback = null;
  5029. if (this.renderingQueue) {
  5030. renderContinueCallback = function renderContinueCallback(cont) {
  5031. if (!_this2.renderingQueue.isHighestPriority(_this2)) {
  5032. _this2.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  5033. _this2.resume = function () {
  5034. _this2.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  5035. cont();
  5036. };
  5037. return;
  5038. }
  5039. cont();
  5040. };
  5041. }
  5042. var finishPaintTask = /*#__PURE__*/function () {
  5043. var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  5044. var error,
  5045. _args3 = arguments;
  5046. return _regenerator["default"].wrap(function _callee3$(_context3) {
  5047. while (1) {
  5048. switch (_context3.prev = _context3.next) {
  5049. case 0:
  5050. error = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : null;
  5051. if (paintTask === _this2.paintTask) {
  5052. _this2.paintTask = null;
  5053. }
  5054. if (!(error instanceof _pdfjsLib.RenderingCancelledException)) {
  5055. _context3.next = 5;
  5056. break;
  5057. }
  5058. _this2._renderError = null;
  5059. return _context3.abrupt("return");
  5060. case 5:
  5061. _this2._renderError = error;
  5062. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  5063. if (_this2.loadingIconDiv) {
  5064. div.removeChild(_this2.loadingIconDiv);
  5065. delete _this2.loadingIconDiv;
  5066. }
  5067. _this2._resetZoomLayer(true);
  5068. _this2.eventBus.dispatch("pagerendered", {
  5069. source: _this2,
  5070. pageNumber: _this2.id,
  5071. cssTransform: false,
  5072. timestamp: performance.now(),
  5073. error: _this2._renderError
  5074. });
  5075. if (!error) {
  5076. _context3.next = 12;
  5077. break;
  5078. }
  5079. throw error;
  5080. case 12:
  5081. case "end":
  5082. return _context3.stop();
  5083. }
  5084. }
  5085. }, _callee3);
  5086. }));
  5087. return function finishPaintTask() {
  5088. return _ref.apply(this, arguments);
  5089. };
  5090. }();
  5091. var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
  5092. paintTask.onRenderContinue = renderContinueCallback;
  5093. this.paintTask = paintTask;
  5094. var resultPromise = paintTask.promise.then(function () {
  5095. return finishPaintTask(null).then(function () {
  5096. if (textLayer) {
  5097. var readableStream = pdfPage.streamTextContent({
  5098. normalizeWhitespace: true,
  5099. includeMarkedContent: true
  5100. });
  5101. textLayer.setTextContentStream(readableStream);
  5102. textLayer.render();
  5103. }
  5104. });
  5105. }, function (reason) {
  5106. return finishPaintTask(reason);
  5107. });
  5108. if (this.annotationLayerFactory) {
  5109. if (!this.annotationLayer) {
  5110. this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, null, this.imageResourcesPath, this.renderInteractiveForms, this.l10n, null, null, null);
  5111. }
  5112. this._renderAnnotationLayer();
  5113. }
  5114. if (this.xfaLayerFactory) {
  5115. if (!this.xfaLayer) {
  5116. this.xfaLayer = this.xfaLayerFactory.createXfaLayerBuilder(div, pdfPage, null);
  5117. }
  5118. this._renderXfaLayer();
  5119. }
  5120. if (this.structTreeLayerFactory && this.textLayer && this.canvas) {
  5121. this._onTextLayerRendered = function (event) {
  5122. if (event.pageNumber !== _this2.id) {
  5123. return;
  5124. }
  5125. _this2.eventBus._off("textlayerrendered", _this2._onTextLayerRendered);
  5126. _this2._onTextLayerRendered = null;
  5127. if (!_this2.canvas) {
  5128. return;
  5129. }
  5130. _this2.pdfPage.getStructTree().then(function (tree) {
  5131. if (!tree) {
  5132. return;
  5133. }
  5134. if (!_this2.canvas) {
  5135. return;
  5136. }
  5137. var treeDom = _this2.structTreeLayer.render(tree);
  5138. treeDom.classList.add("structTree");
  5139. _this2.canvas.appendChild(treeDom);
  5140. });
  5141. };
  5142. this.eventBus._on("textlayerrendered", this._onTextLayerRendered);
  5143. this.structTreeLayer = this.structTreeLayerFactory.createStructTreeLayerBuilder(pdfPage);
  5144. }
  5145. div.setAttribute("data-loaded", true);
  5146. this.eventBus.dispatch("pagerender", {
  5147. source: this,
  5148. pageNumber: this.id
  5149. });
  5150. return resultPromise;
  5151. }
  5152. }, {
  5153. key: "paintOnCanvas",
  5154. value: function paintOnCanvas(canvasWrapper) {
  5155. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  5156. var result = {
  5157. promise: renderCapability.promise,
  5158. onRenderContinue: function onRenderContinue(cont) {
  5159. cont();
  5160. },
  5161. cancel: function cancel() {
  5162. renderTask.cancel();
  5163. }
  5164. };
  5165. var viewport = this.viewport;
  5166. var canvas = document.createElement("canvas");
  5167. canvas.hidden = true;
  5168. var isCanvasHidden = true;
  5169. var showCanvas = function showCanvas() {
  5170. if (isCanvasHidden) {
  5171. canvas.hidden = false;
  5172. isCanvasHidden = false;
  5173. }
  5174. };
  5175. canvasWrapper.appendChild(canvas);
  5176. this.canvas = canvas;
  5177. canvas.mozOpaque = true;
  5178. var ctx = canvas.getContext("2d", {
  5179. alpha: false
  5180. });
  5181. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  5182. this.outputScale = outputScale;
  5183. if (this.useOnlyCssZoom) {
  5184. var actualSizeViewport = viewport.clone({
  5185. scale: _ui_utils.CSS_UNITS
  5186. });
  5187. outputScale.sx *= actualSizeViewport.width / viewport.width;
  5188. outputScale.sy *= actualSizeViewport.height / viewport.height;
  5189. outputScale.scaled = true;
  5190. }
  5191. if (this.maxCanvasPixels > 0) {
  5192. var pixelsInViewport = viewport.width * viewport.height;
  5193. var maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
  5194. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  5195. outputScale.sx = maxScale;
  5196. outputScale.sy = maxScale;
  5197. outputScale.scaled = true;
  5198. this.hasRestrictedScaling = true;
  5199. } else {
  5200. this.hasRestrictedScaling = false;
  5201. }
  5202. }
  5203. var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  5204. var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  5205. canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
  5206. canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
  5207. canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + "px";
  5208. canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + "px";
  5209. this.paintedViewportMap.set(canvas, viewport);
  5210. var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
  5211. var renderContext = {
  5212. canvasContext: ctx,
  5213. transform: transform,
  5214. viewport: this.viewport,
  5215. renderInteractiveForms: this.renderInteractiveForms,
  5216. optionalContentConfigPromise: this._optionalContentConfigPromise
  5217. };
  5218. var renderTask = this.pdfPage.render(renderContext);
  5219. renderTask.onContinue = function (cont) {
  5220. showCanvas();
  5221. if (result.onRenderContinue) {
  5222. result.onRenderContinue(cont);
  5223. } else {
  5224. cont();
  5225. }
  5226. };
  5227. renderTask.promise.then(function () {
  5228. showCanvas();
  5229. renderCapability.resolve(undefined);
  5230. }, function (error) {
  5231. showCanvas();
  5232. renderCapability.reject(error);
  5233. });
  5234. return result;
  5235. }
  5236. }, {
  5237. key: "paintOnSvg",
  5238. value: function paintOnSvg(wrapper) {
  5239. var _this3 = this;
  5240. var cancelled = false;
  5241. var ensureNotCancelled = function ensureNotCancelled() {
  5242. if (cancelled) {
  5243. throw new _pdfjsLib.RenderingCancelledException("Rendering cancelled, page ".concat(_this3.id), "svg");
  5244. }
  5245. };
  5246. var pdfPage = this.pdfPage;
  5247. var actualSizeViewport = this.viewport.clone({
  5248. scale: _ui_utils.CSS_UNITS
  5249. });
  5250. var promise = pdfPage.getOperatorList().then(function (opList) {
  5251. ensureNotCancelled();
  5252. var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs, _viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL);
  5253. return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {
  5254. ensureNotCancelled();
  5255. _this3.svg = svg;
  5256. _this3.paintedViewportMap.set(svg, actualSizeViewport);
  5257. svg.style.width = wrapper.style.width;
  5258. svg.style.height = wrapper.style.height;
  5259. _this3.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  5260. wrapper.appendChild(svg);
  5261. });
  5262. });
  5263. return {
  5264. promise: promise,
  5265. onRenderContinue: function onRenderContinue(cont) {
  5266. cont();
  5267. },
  5268. cancel: function cancel() {
  5269. cancelled = true;
  5270. }
  5271. };
  5272. }
  5273. }, {
  5274. key: "setPageLabel",
  5275. value: function setPageLabel(label) {
  5276. this.pageLabel = typeof label === "string" ? label : null;
  5277. if (this.pageLabel !== null) {
  5278. this.div.setAttribute("data-page-label", this.pageLabel);
  5279. } else {
  5280. this.div.removeAttribute("data-page-label");
  5281. }
  5282. }
  5283. }]);
  5284. return PDFPageView;
  5285. }();
  5286. exports.PDFPageView = PDFPageView;
  5287. /***/ }),
  5288. /* 17 */
  5289. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  5290. Object.defineProperty(exports, "__esModule", ({
  5291. value: true
  5292. }));
  5293. exports.RenderingStates = exports.PDFRenderingQueue = void 0;
  5294. var _pdfjsLib = __w_pdfjs_require__(2);
  5295. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5296. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  5297. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5298. var CLEANUP_TIMEOUT = 30000;
  5299. var RenderingStates = {
  5300. INITIAL: 0,
  5301. RUNNING: 1,
  5302. PAUSED: 2,
  5303. FINISHED: 3
  5304. };
  5305. exports.RenderingStates = RenderingStates;
  5306. var PDFRenderingQueue = /*#__PURE__*/function () {
  5307. function PDFRenderingQueue() {
  5308. _classCallCheck(this, PDFRenderingQueue);
  5309. this.pdfViewer = null;
  5310. this.pdfThumbnailViewer = null;
  5311. this.onIdle = null;
  5312. this.highestPriorityPage = null;
  5313. this.idleTimeout = null;
  5314. this.printing = false;
  5315. this.isThumbnailViewEnabled = false;
  5316. }
  5317. _createClass(PDFRenderingQueue, [{
  5318. key: "setViewer",
  5319. value: function setViewer(pdfViewer) {
  5320. this.pdfViewer = pdfViewer;
  5321. }
  5322. }, {
  5323. key: "setThumbnailViewer",
  5324. value: function setThumbnailViewer(pdfThumbnailViewer) {
  5325. this.pdfThumbnailViewer = pdfThumbnailViewer;
  5326. }
  5327. }, {
  5328. key: "isHighestPriority",
  5329. value: function isHighestPriority(view) {
  5330. return this.highestPriorityPage === view.renderingId;
  5331. }
  5332. }, {
  5333. key: "renderHighestPriority",
  5334. value: function renderHighestPriority(currentlyVisiblePages) {
  5335. if (this.idleTimeout) {
  5336. clearTimeout(this.idleTimeout);
  5337. this.idleTimeout = null;
  5338. }
  5339. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  5340. return;
  5341. }
  5342. if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
  5343. if (this.pdfThumbnailViewer.forceRendering()) {
  5344. return;
  5345. }
  5346. }
  5347. if (this.printing) {
  5348. return;
  5349. }
  5350. if (this.onIdle) {
  5351. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
  5352. }
  5353. }
  5354. }, {
  5355. key: "getHighestPriority",
  5356. value: function getHighestPriority(visible, views, scrolledDown) {
  5357. var visibleViews = visible.views;
  5358. var numVisible = visibleViews.length;
  5359. if (numVisible === 0) {
  5360. return null;
  5361. }
  5362. for (var i = 0; i < numVisible; ++i) {
  5363. var view = visibleViews[i].view;
  5364. if (!this.isViewFinished(view)) {
  5365. return view;
  5366. }
  5367. }
  5368. if (scrolledDown) {
  5369. var nextPageIndex = visible.last.id;
  5370. if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {
  5371. return views[nextPageIndex];
  5372. }
  5373. } else {
  5374. var previousPageIndex = visible.first.id - 2;
  5375. if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) {
  5376. return views[previousPageIndex];
  5377. }
  5378. }
  5379. return null;
  5380. }
  5381. }, {
  5382. key: "isViewFinished",
  5383. value: function isViewFinished(view) {
  5384. return view.renderingState === RenderingStates.FINISHED;
  5385. }
  5386. }, {
  5387. key: "renderView",
  5388. value: function renderView(view) {
  5389. var _this = this;
  5390. switch (view.renderingState) {
  5391. case RenderingStates.FINISHED:
  5392. return false;
  5393. case RenderingStates.PAUSED:
  5394. this.highestPriorityPage = view.renderingId;
  5395. view.resume();
  5396. break;
  5397. case RenderingStates.RUNNING:
  5398. this.highestPriorityPage = view.renderingId;
  5399. break;
  5400. case RenderingStates.INITIAL:
  5401. this.highestPriorityPage = view.renderingId;
  5402. view.draw()["finally"](function () {
  5403. _this.renderHighestPriority();
  5404. })["catch"](function (reason) {
  5405. if (reason instanceof _pdfjsLib.RenderingCancelledException) {
  5406. return;
  5407. }
  5408. console.error("renderView: \"".concat(reason, "\""));
  5409. });
  5410. break;
  5411. }
  5412. return true;
  5413. }
  5414. }]);
  5415. return PDFRenderingQueue;
  5416. }();
  5417. exports.PDFRenderingQueue = PDFRenderingQueue;
  5418. /***/ }),
  5419. /* 18 */
  5420. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  5421. Object.defineProperty(exports, "__esModule", ({
  5422. value: true
  5423. }));
  5424. exports.PDFScriptingManager = void 0;
  5425. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(4));
  5426. var _pdfjsLib = __w_pdfjs_require__(2);
  5427. var _ui_utils = __w_pdfjs_require__(7);
  5428. var _pdf_rendering_queue = __w_pdfjs_require__(17);
  5429. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5430. function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
  5431. function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  5432. function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
  5433. function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
  5434. function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
  5435. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
  5436. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  5437. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  5438. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  5439. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  5440. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  5441. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  5442. function _iterableToArrayLimit(arr, i) { var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]); if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  5443. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  5444. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  5445. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  5446. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5447. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  5448. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5449. var PDFScriptingManager = /*#__PURE__*/function () {
  5450. function PDFScriptingManager(_ref) {
  5451. var _this = this;
  5452. var eventBus = _ref.eventBus,
  5453. _ref$sandboxBundleSrc = _ref.sandboxBundleSrc,
  5454. sandboxBundleSrc = _ref$sandboxBundleSrc === void 0 ? null : _ref$sandboxBundleSrc,
  5455. _ref$scriptingFactory = _ref.scriptingFactory,
  5456. scriptingFactory = _ref$scriptingFactory === void 0 ? null : _ref$scriptingFactory,
  5457. _ref$docPropertiesLoo = _ref.docPropertiesLookup,
  5458. docPropertiesLookup = _ref$docPropertiesLoo === void 0 ? null : _ref$docPropertiesLoo;
  5459. _classCallCheck(this, PDFScriptingManager);
  5460. this._pdfDocument = null;
  5461. this._pdfViewer = null;
  5462. this._closeCapability = null;
  5463. this._destroyCapability = null;
  5464. this._scripting = null;
  5465. this._mouseState = Object.create(null);
  5466. this._pageEventsReady = false;
  5467. this._ready = false;
  5468. this._eventBus = eventBus;
  5469. this._sandboxBundleSrc = sandboxBundleSrc;
  5470. this._scriptingFactory = scriptingFactory;
  5471. this._docPropertiesLookup = docPropertiesLookup;
  5472. if (!this._scriptingFactory) {
  5473. window.addEventListener("updatefromsandbox", function (event) {
  5474. _this._eventBus.dispatch("updatefromsandbox", {
  5475. source: window,
  5476. detail: event.detail
  5477. });
  5478. });
  5479. }
  5480. }
  5481. _createClass(PDFScriptingManager, [{
  5482. key: "setViewer",
  5483. value: function setViewer(pdfViewer) {
  5484. this._pdfViewer = pdfViewer;
  5485. }
  5486. }, {
  5487. key: "setDocument",
  5488. value: function () {
  5489. var _setDocument = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(pdfDocument) {
  5490. var _this2 = this,
  5491. _this$_scripting;
  5492. var _yield$Promise$all, _yield$Promise$all2, objects, calculationOrder, docActions, _iterator, _step, _step$value, name, listener, _iterator2, _step2, _step2$value, _name, _listener, docProperties;
  5493. return _regenerator["default"].wrap(function _callee2$(_context2) {
  5494. while (1) {
  5495. switch (_context2.prev = _context2.next) {
  5496. case 0:
  5497. if (!this._pdfDocument) {
  5498. _context2.next = 3;
  5499. break;
  5500. }
  5501. _context2.next = 3;
  5502. return this._destroyScripting();
  5503. case 3:
  5504. this._pdfDocument = pdfDocument;
  5505. if (pdfDocument) {
  5506. _context2.next = 6;
  5507. break;
  5508. }
  5509. return _context2.abrupt("return");
  5510. case 6:
  5511. _context2.next = 8;
  5512. return Promise.all([pdfDocument.getFieldObjects(), pdfDocument.getCalculationOrderIds(), pdfDocument.getJSActions()]);
  5513. case 8:
  5514. _yield$Promise$all = _context2.sent;
  5515. _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 3);
  5516. objects = _yield$Promise$all2[0];
  5517. calculationOrder = _yield$Promise$all2[1];
  5518. docActions = _yield$Promise$all2[2];
  5519. if (!(!objects && !docActions)) {
  5520. _context2.next = 17;
  5521. break;
  5522. }
  5523. _context2.next = 16;
  5524. return this._destroyScripting();
  5525. case 16:
  5526. return _context2.abrupt("return");
  5527. case 17:
  5528. if (!(pdfDocument !== this._pdfDocument)) {
  5529. _context2.next = 19;
  5530. break;
  5531. }
  5532. return _context2.abrupt("return");
  5533. case 19:
  5534. this._scripting = this._createScripting();
  5535. this._internalEvents.set("updatefromsandbox", function (event) {
  5536. if ((event === null || event === void 0 ? void 0 : event.source) !== window) {
  5537. return;
  5538. }
  5539. _this2._updateFromSandbox(event.detail);
  5540. });
  5541. this._internalEvents.set("dispatcheventinsandbox", function (event) {
  5542. var _this2$_scripting;
  5543. (_this2$_scripting = _this2._scripting) === null || _this2$_scripting === void 0 ? void 0 : _this2$_scripting.dispatchEventInSandbox(event.detail);
  5544. });
  5545. this._internalEvents.set("pagechanging", function (_ref2) {
  5546. var pageNumber = _ref2.pageNumber,
  5547. previous = _ref2.previous;
  5548. if (pageNumber === previous) {
  5549. return;
  5550. }
  5551. _this2._dispatchPageClose(previous);
  5552. _this2._dispatchPageOpen(pageNumber);
  5553. });
  5554. this._internalEvents.set("pagerendered", function (_ref3) {
  5555. var pageNumber = _ref3.pageNumber;
  5556. if (!_this2._pageOpenPending.has(pageNumber)) {
  5557. return;
  5558. }
  5559. if (pageNumber !== _this2._pdfViewer.currentPageNumber) {
  5560. return;
  5561. }
  5562. _this2._dispatchPageOpen(pageNumber);
  5563. });
  5564. this._internalEvents.set("pagesdestroy", /*#__PURE__*/function () {
  5565. var _ref4 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(event) {
  5566. var _this2$_scripting2, _this2$_closeCapabili;
  5567. return _regenerator["default"].wrap(function _callee$(_context) {
  5568. while (1) {
  5569. switch (_context.prev = _context.next) {
  5570. case 0:
  5571. _context.next = 2;
  5572. return _this2._dispatchPageClose(_this2._pdfViewer.currentPageNumber);
  5573. case 2:
  5574. _context.next = 4;
  5575. return (_this2$_scripting2 = _this2._scripting) === null || _this2$_scripting2 === void 0 ? void 0 : _this2$_scripting2.dispatchEventInSandbox({
  5576. id: "doc",
  5577. name: "WillClose"
  5578. });
  5579. case 4:
  5580. (_this2$_closeCapabili = _this2._closeCapability) === null || _this2$_closeCapabili === void 0 ? void 0 : _this2$_closeCapabili.resolve();
  5581. case 5:
  5582. case "end":
  5583. return _context.stop();
  5584. }
  5585. }
  5586. }, _callee);
  5587. }));
  5588. return function (_x2) {
  5589. return _ref4.apply(this, arguments);
  5590. };
  5591. }());
  5592. this._domEvents.set("mousedown", function (event) {
  5593. _this2._mouseState.isDown = true;
  5594. });
  5595. this._domEvents.set("mouseup", function (event) {
  5596. _this2._mouseState.isDown = false;
  5597. });
  5598. _iterator = _createForOfIteratorHelper(this._internalEvents);
  5599. try {
  5600. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  5601. _step$value = _slicedToArray(_step.value, 2), name = _step$value[0], listener = _step$value[1];
  5602. this._eventBus._on(name, listener);
  5603. }
  5604. } catch (err) {
  5605. _iterator.e(err);
  5606. } finally {
  5607. _iterator.f();
  5608. }
  5609. _iterator2 = _createForOfIteratorHelper(this._domEvents);
  5610. try {
  5611. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  5612. _step2$value = _slicedToArray(_step2.value, 2), _name = _step2$value[0], _listener = _step2$value[1];
  5613. window.addEventListener(_name, _listener);
  5614. }
  5615. } catch (err) {
  5616. _iterator2.e(err);
  5617. } finally {
  5618. _iterator2.f();
  5619. }
  5620. _context2.prev = 31;
  5621. _context2.next = 34;
  5622. return this._getDocProperties();
  5623. case 34:
  5624. docProperties = _context2.sent;
  5625. if (!(pdfDocument !== this._pdfDocument)) {
  5626. _context2.next = 37;
  5627. break;
  5628. }
  5629. return _context2.abrupt("return");
  5630. case 37:
  5631. _context2.next = 39;
  5632. return this._scripting.createSandbox({
  5633. objects: objects,
  5634. calculationOrder: calculationOrder,
  5635. appInfo: {
  5636. platform: navigator.platform,
  5637. language: navigator.language
  5638. },
  5639. docInfo: _objectSpread(_objectSpread({}, docProperties), {}, {
  5640. actions: docActions
  5641. })
  5642. });
  5643. case 39:
  5644. this._eventBus.dispatch("sandboxcreated", {
  5645. source: this
  5646. });
  5647. _context2.next = 48;
  5648. break;
  5649. case 42:
  5650. _context2.prev = 42;
  5651. _context2.t0 = _context2["catch"](31);
  5652. console.error("PDFScriptingManager.setDocument: \"".concat(_context2.t0 === null || _context2.t0 === void 0 ? void 0 : _context2.t0.message, "\"."));
  5653. _context2.next = 47;
  5654. return this._destroyScripting();
  5655. case 47:
  5656. return _context2.abrupt("return");
  5657. case 48:
  5658. _context2.next = 50;
  5659. return (_this$_scripting = this._scripting) === null || _this$_scripting === void 0 ? void 0 : _this$_scripting.dispatchEventInSandbox({
  5660. id: "doc",
  5661. name: "Open"
  5662. });
  5663. case 50:
  5664. _context2.next = 52;
  5665. return this._dispatchPageOpen(this._pdfViewer.currentPageNumber, true);
  5666. case 52:
  5667. Promise.resolve().then(function () {
  5668. if (pdfDocument === _this2._pdfDocument) {
  5669. _this2._ready = true;
  5670. }
  5671. });
  5672. case 53:
  5673. case "end":
  5674. return _context2.stop();
  5675. }
  5676. }
  5677. }, _callee2, this, [[31, 42]]);
  5678. }));
  5679. function setDocument(_x) {
  5680. return _setDocument.apply(this, arguments);
  5681. }
  5682. return setDocument;
  5683. }()
  5684. }, {
  5685. key: "dispatchWillSave",
  5686. value: function () {
  5687. var _dispatchWillSave = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(detail) {
  5688. var _this$_scripting2;
  5689. return _regenerator["default"].wrap(function _callee3$(_context3) {
  5690. while (1) {
  5691. switch (_context3.prev = _context3.next) {
  5692. case 0:
  5693. return _context3.abrupt("return", (_this$_scripting2 = this._scripting) === null || _this$_scripting2 === void 0 ? void 0 : _this$_scripting2.dispatchEventInSandbox({
  5694. id: "doc",
  5695. name: "WillSave"
  5696. }));
  5697. case 1:
  5698. case "end":
  5699. return _context3.stop();
  5700. }
  5701. }
  5702. }, _callee3, this);
  5703. }));
  5704. function dispatchWillSave(_x3) {
  5705. return _dispatchWillSave.apply(this, arguments);
  5706. }
  5707. return dispatchWillSave;
  5708. }()
  5709. }, {
  5710. key: "dispatchDidSave",
  5711. value: function () {
  5712. var _dispatchDidSave = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(detail) {
  5713. var _this$_scripting3;
  5714. return _regenerator["default"].wrap(function _callee4$(_context4) {
  5715. while (1) {
  5716. switch (_context4.prev = _context4.next) {
  5717. case 0:
  5718. return _context4.abrupt("return", (_this$_scripting3 = this._scripting) === null || _this$_scripting3 === void 0 ? void 0 : _this$_scripting3.dispatchEventInSandbox({
  5719. id: "doc",
  5720. name: "DidSave"
  5721. }));
  5722. case 1:
  5723. case "end":
  5724. return _context4.stop();
  5725. }
  5726. }
  5727. }, _callee4, this);
  5728. }));
  5729. function dispatchDidSave(_x4) {
  5730. return _dispatchDidSave.apply(this, arguments);
  5731. }
  5732. return dispatchDidSave;
  5733. }()
  5734. }, {
  5735. key: "dispatchWillPrint",
  5736. value: function () {
  5737. var _dispatchWillPrint = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5(detail) {
  5738. var _this$_scripting4;
  5739. return _regenerator["default"].wrap(function _callee5$(_context5) {
  5740. while (1) {
  5741. switch (_context5.prev = _context5.next) {
  5742. case 0:
  5743. return _context5.abrupt("return", (_this$_scripting4 = this._scripting) === null || _this$_scripting4 === void 0 ? void 0 : _this$_scripting4.dispatchEventInSandbox({
  5744. id: "doc",
  5745. name: "WillPrint"
  5746. }));
  5747. case 1:
  5748. case "end":
  5749. return _context5.stop();
  5750. }
  5751. }
  5752. }, _callee5, this);
  5753. }));
  5754. function dispatchWillPrint(_x5) {
  5755. return _dispatchWillPrint.apply(this, arguments);
  5756. }
  5757. return dispatchWillPrint;
  5758. }()
  5759. }, {
  5760. key: "dispatchDidPrint",
  5761. value: function () {
  5762. var _dispatchDidPrint = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6(detail) {
  5763. var _this$_scripting5;
  5764. return _regenerator["default"].wrap(function _callee6$(_context6) {
  5765. while (1) {
  5766. switch (_context6.prev = _context6.next) {
  5767. case 0:
  5768. return _context6.abrupt("return", (_this$_scripting5 = this._scripting) === null || _this$_scripting5 === void 0 ? void 0 : _this$_scripting5.dispatchEventInSandbox({
  5769. id: "doc",
  5770. name: "DidPrint"
  5771. }));
  5772. case 1:
  5773. case "end":
  5774. return _context6.stop();
  5775. }
  5776. }
  5777. }, _callee6, this);
  5778. }));
  5779. function dispatchDidPrint(_x6) {
  5780. return _dispatchDidPrint.apply(this, arguments);
  5781. }
  5782. return dispatchDidPrint;
  5783. }()
  5784. }, {
  5785. key: "mouseState",
  5786. get: function get() {
  5787. return this._mouseState;
  5788. }
  5789. }, {
  5790. key: "destroyPromise",
  5791. get: function get() {
  5792. var _this$_destroyCapabil;
  5793. return ((_this$_destroyCapabil = this._destroyCapability) === null || _this$_destroyCapabil === void 0 ? void 0 : _this$_destroyCapabil.promise) || null;
  5794. }
  5795. }, {
  5796. key: "ready",
  5797. get: function get() {
  5798. return this._ready;
  5799. }
  5800. }, {
  5801. key: "_internalEvents",
  5802. get: function get() {
  5803. return (0, _pdfjsLib.shadow)(this, "_internalEvents", new Map());
  5804. }
  5805. }, {
  5806. key: "_domEvents",
  5807. get: function get() {
  5808. return (0, _pdfjsLib.shadow)(this, "_domEvents", new Map());
  5809. }
  5810. }, {
  5811. key: "_pageOpenPending",
  5812. get: function get() {
  5813. return (0, _pdfjsLib.shadow)(this, "_pageOpenPending", new Set());
  5814. }
  5815. }, {
  5816. key: "_visitedPages",
  5817. get: function get() {
  5818. return (0, _pdfjsLib.shadow)(this, "_visitedPages", new Map());
  5819. }
  5820. }, {
  5821. key: "_updateFromSandbox",
  5822. value: function () {
  5823. var _updateFromSandbox2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee7(detail) {
  5824. var isInPresentationMode, id, siblings, command, value, ids, _iterator3, _step3, elementId, element, _this$_pdfDocument;
  5825. return _regenerator["default"].wrap(function _callee7$(_context7) {
  5826. while (1) {
  5827. switch (_context7.prev = _context7.next) {
  5828. case 0:
  5829. isInPresentationMode = this._pdfViewer.isInPresentationMode || this._pdfViewer.isChangingPresentationMode;
  5830. id = detail.id, siblings = detail.siblings, command = detail.command, value = detail.value;
  5831. if (id) {
  5832. _context7.next = 25;
  5833. break;
  5834. }
  5835. _context7.t0 = command;
  5836. _context7.next = _context7.t0 === "clear" ? 6 : _context7.t0 === "error" ? 8 : _context7.t0 === "layout" ? 10 : _context7.t0 === "page-num" ? 12 : _context7.t0 === "print" ? 14 : _context7.t0 === "println" ? 18 : _context7.t0 === "zoom" ? 20 : 24;
  5837. break;
  5838. case 6:
  5839. console.clear();
  5840. return _context7.abrupt("break", 24);
  5841. case 8:
  5842. console.error(value);
  5843. return _context7.abrupt("break", 24);
  5844. case 10:
  5845. this._pdfViewer.spreadMode = (0, _ui_utils.apiPageLayoutToSpreadMode)(value);
  5846. return _context7.abrupt("break", 24);
  5847. case 12:
  5848. this._pdfViewer.currentPageNumber = value + 1;
  5849. return _context7.abrupt("break", 24);
  5850. case 14:
  5851. _context7.next = 16;
  5852. return this._pdfViewer.pagesPromise;
  5853. case 16:
  5854. this._eventBus.dispatch("print", {
  5855. source: this
  5856. });
  5857. return _context7.abrupt("break", 24);
  5858. case 18:
  5859. console.log(value);
  5860. return _context7.abrupt("break", 24);
  5861. case 20:
  5862. if (!isInPresentationMode) {
  5863. _context7.next = 22;
  5864. break;
  5865. }
  5866. return _context7.abrupt("return");
  5867. case 22:
  5868. this._pdfViewer.currentScaleValue = value;
  5869. return _context7.abrupt("break", 24);
  5870. case 24:
  5871. return _context7.abrupt("return");
  5872. case 25:
  5873. if (!isInPresentationMode) {
  5874. _context7.next = 28;
  5875. break;
  5876. }
  5877. if (!detail.focus) {
  5878. _context7.next = 28;
  5879. break;
  5880. }
  5881. return _context7.abrupt("return");
  5882. case 28:
  5883. delete detail.id;
  5884. delete detail.siblings;
  5885. ids = siblings ? [id].concat(_toConsumableArray(siblings)) : [id];
  5886. _iterator3 = _createForOfIteratorHelper(ids);
  5887. try {
  5888. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  5889. elementId = _step3.value;
  5890. element = document.getElementById(elementId);
  5891. if (element) {
  5892. element.dispatchEvent(new CustomEvent("updatefromsandbox", {
  5893. detail: detail
  5894. }));
  5895. } else {
  5896. (_this$_pdfDocument = this._pdfDocument) === null || _this$_pdfDocument === void 0 ? void 0 : _this$_pdfDocument.annotationStorage.setValue(elementId, detail);
  5897. }
  5898. }
  5899. } catch (err) {
  5900. _iterator3.e(err);
  5901. } finally {
  5902. _iterator3.f();
  5903. }
  5904. case 33:
  5905. case "end":
  5906. return _context7.stop();
  5907. }
  5908. }
  5909. }, _callee7, this);
  5910. }));
  5911. function _updateFromSandbox(_x7) {
  5912. return _updateFromSandbox2.apply(this, arguments);
  5913. }
  5914. return _updateFromSandbox;
  5915. }()
  5916. }, {
  5917. key: "_dispatchPageOpen",
  5918. value: function () {
  5919. var _dispatchPageOpen2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee9(pageNumber) {
  5920. var _this3 = this;
  5921. var initialize,
  5922. pdfDocument,
  5923. visitedPages,
  5924. pageView,
  5925. actionsPromise,
  5926. _args9 = arguments;
  5927. return _regenerator["default"].wrap(function _callee9$(_context9) {
  5928. while (1) {
  5929. switch (_context9.prev = _context9.next) {
  5930. case 0:
  5931. initialize = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : false;
  5932. pdfDocument = this._pdfDocument, visitedPages = this._visitedPages;
  5933. if (initialize) {
  5934. this._closeCapability = (0, _pdfjsLib.createPromiseCapability)();
  5935. this._pageEventsReady = true;
  5936. }
  5937. if (this._pageEventsReady) {
  5938. _context9.next = 5;
  5939. break;
  5940. }
  5941. return _context9.abrupt("return");
  5942. case 5:
  5943. pageView = this._pdfViewer.getPageView(pageNumber - 1);
  5944. if (!((pageView === null || pageView === void 0 ? void 0 : pageView.renderingState) !== _pdf_rendering_queue.RenderingStates.FINISHED)) {
  5945. _context9.next = 9;
  5946. break;
  5947. }
  5948. this._pageOpenPending.add(pageNumber);
  5949. return _context9.abrupt("return");
  5950. case 9:
  5951. this._pageOpenPending["delete"](pageNumber);
  5952. actionsPromise = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee8() {
  5953. var _pageView$pdfPage, _this3$_scripting;
  5954. var actions;
  5955. return _regenerator["default"].wrap(function _callee8$(_context8) {
  5956. while (1) {
  5957. switch (_context8.prev = _context8.next) {
  5958. case 0:
  5959. _context8.next = 2;
  5960. return !visitedPages.has(pageNumber) ? (_pageView$pdfPage = pageView.pdfPage) === null || _pageView$pdfPage === void 0 ? void 0 : _pageView$pdfPage.getJSActions() : null;
  5961. case 2:
  5962. actions = _context8.sent;
  5963. if (!(pdfDocument !== _this3._pdfDocument)) {
  5964. _context8.next = 5;
  5965. break;
  5966. }
  5967. return _context8.abrupt("return");
  5968. case 5:
  5969. _context8.next = 7;
  5970. return (_this3$_scripting = _this3._scripting) === null || _this3$_scripting === void 0 ? void 0 : _this3$_scripting.dispatchEventInSandbox({
  5971. id: "page",
  5972. name: "PageOpen",
  5973. pageNumber: pageNumber,
  5974. actions: actions
  5975. });
  5976. case 7:
  5977. case "end":
  5978. return _context8.stop();
  5979. }
  5980. }
  5981. }, _callee8);
  5982. }))();
  5983. visitedPages.set(pageNumber, actionsPromise);
  5984. case 12:
  5985. case "end":
  5986. return _context9.stop();
  5987. }
  5988. }
  5989. }, _callee9, this);
  5990. }));
  5991. function _dispatchPageOpen(_x8) {
  5992. return _dispatchPageOpen2.apply(this, arguments);
  5993. }
  5994. return _dispatchPageOpen;
  5995. }()
  5996. }, {
  5997. key: "_dispatchPageClose",
  5998. value: function () {
  5999. var _dispatchPageClose2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee10(pageNumber) {
  6000. var _this$_scripting6;
  6001. var pdfDocument, visitedPages, actionsPromise;
  6002. return _regenerator["default"].wrap(function _callee10$(_context10) {
  6003. while (1) {
  6004. switch (_context10.prev = _context10.next) {
  6005. case 0:
  6006. pdfDocument = this._pdfDocument, visitedPages = this._visitedPages;
  6007. if (this._pageEventsReady) {
  6008. _context10.next = 3;
  6009. break;
  6010. }
  6011. return _context10.abrupt("return");
  6012. case 3:
  6013. if (!this._pageOpenPending.has(pageNumber)) {
  6014. _context10.next = 5;
  6015. break;
  6016. }
  6017. return _context10.abrupt("return");
  6018. case 5:
  6019. actionsPromise = visitedPages.get(pageNumber);
  6020. if (actionsPromise) {
  6021. _context10.next = 8;
  6022. break;
  6023. }
  6024. return _context10.abrupt("return");
  6025. case 8:
  6026. visitedPages.set(pageNumber, null);
  6027. _context10.next = 11;
  6028. return actionsPromise;
  6029. case 11:
  6030. if (!(pdfDocument !== this._pdfDocument)) {
  6031. _context10.next = 13;
  6032. break;
  6033. }
  6034. return _context10.abrupt("return");
  6035. case 13:
  6036. _context10.next = 15;
  6037. return (_this$_scripting6 = this._scripting) === null || _this$_scripting6 === void 0 ? void 0 : _this$_scripting6.dispatchEventInSandbox({
  6038. id: "page",
  6039. name: "PageClose",
  6040. pageNumber: pageNumber
  6041. });
  6042. case 15:
  6043. case "end":
  6044. return _context10.stop();
  6045. }
  6046. }
  6047. }, _callee10, this);
  6048. }));
  6049. function _dispatchPageClose(_x9) {
  6050. return _dispatchPageClose2.apply(this, arguments);
  6051. }
  6052. return _dispatchPageClose;
  6053. }()
  6054. }, {
  6055. key: "_getDocProperties",
  6056. value: function () {
  6057. var _getDocProperties2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee11() {
  6058. var _require, docPropertiesLookup;
  6059. return _regenerator["default"].wrap(function _callee11$(_context11) {
  6060. while (1) {
  6061. switch (_context11.prev = _context11.next) {
  6062. case 0:
  6063. if (!this._docPropertiesLookup) {
  6064. _context11.next = 2;
  6065. break;
  6066. }
  6067. return _context11.abrupt("return", this._docPropertiesLookup(this._pdfDocument));
  6068. case 2:
  6069. _require = __w_pdfjs_require__(19), docPropertiesLookup = _require.docPropertiesLookup;
  6070. return _context11.abrupt("return", docPropertiesLookup(this._pdfDocument));
  6071. case 4:
  6072. case "end":
  6073. return _context11.stop();
  6074. }
  6075. }
  6076. }, _callee11, this);
  6077. }));
  6078. function _getDocProperties() {
  6079. return _getDocProperties2.apply(this, arguments);
  6080. }
  6081. return _getDocProperties;
  6082. }()
  6083. }, {
  6084. key: "_createScripting",
  6085. value: function _createScripting() {
  6086. this._destroyCapability = (0, _pdfjsLib.createPromiseCapability)();
  6087. if (this._scripting) {
  6088. throw new Error("_createScripting: Scripting already exists.");
  6089. }
  6090. if (this._scriptingFactory) {
  6091. return this._scriptingFactory.createScripting({
  6092. sandboxBundleSrc: this._sandboxBundleSrc
  6093. });
  6094. }
  6095. var _require2 = __w_pdfjs_require__(19),
  6096. GenericScripting = _require2.GenericScripting;
  6097. return new GenericScripting(this._sandboxBundleSrc);
  6098. }
  6099. }, {
  6100. key: "_destroyScripting",
  6101. value: function () {
  6102. var _destroyScripting2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee12() {
  6103. var _this$_destroyCapabil3;
  6104. var _this$_destroyCapabil2, _iterator4, _step4, _step4$value, name, listener, _iterator5, _step5, _step5$value, _name2, _listener2;
  6105. return _regenerator["default"].wrap(function _callee12$(_context12) {
  6106. while (1) {
  6107. switch (_context12.prev = _context12.next) {
  6108. case 0:
  6109. if (this._scripting) {
  6110. _context12.next = 4;
  6111. break;
  6112. }
  6113. this._pdfDocument = null;
  6114. (_this$_destroyCapabil2 = this._destroyCapability) === null || _this$_destroyCapabil2 === void 0 ? void 0 : _this$_destroyCapabil2.resolve();
  6115. return _context12.abrupt("return");
  6116. case 4:
  6117. if (!this._closeCapability) {
  6118. _context12.next = 8;
  6119. break;
  6120. }
  6121. _context12.next = 7;
  6122. return Promise.race([this._closeCapability.promise, new Promise(function (resolve) {
  6123. setTimeout(resolve, 1000);
  6124. })])["catch"](function (reason) {});
  6125. case 7:
  6126. this._closeCapability = null;
  6127. case 8:
  6128. this._pdfDocument = null;
  6129. _context12.prev = 9;
  6130. _context12.next = 12;
  6131. return this._scripting.destroySandbox();
  6132. case 12:
  6133. _context12.next = 16;
  6134. break;
  6135. case 14:
  6136. _context12.prev = 14;
  6137. _context12.t0 = _context12["catch"](9);
  6138. case 16:
  6139. _iterator4 = _createForOfIteratorHelper(this._internalEvents);
  6140. try {
  6141. for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
  6142. _step4$value = _slicedToArray(_step4.value, 2), name = _step4$value[0], listener = _step4$value[1];
  6143. this._eventBus._off(name, listener);
  6144. }
  6145. } catch (err) {
  6146. _iterator4.e(err);
  6147. } finally {
  6148. _iterator4.f();
  6149. }
  6150. this._internalEvents.clear();
  6151. _iterator5 = _createForOfIteratorHelper(this._domEvents);
  6152. try {
  6153. for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
  6154. _step5$value = _slicedToArray(_step5.value, 2), _name2 = _step5$value[0], _listener2 = _step5$value[1];
  6155. window.removeEventListener(_name2, _listener2);
  6156. }
  6157. } catch (err) {
  6158. _iterator5.e(err);
  6159. } finally {
  6160. _iterator5.f();
  6161. }
  6162. this._domEvents.clear();
  6163. this._pageOpenPending.clear();
  6164. this._visitedPages.clear();
  6165. this._scripting = null;
  6166. delete this._mouseState.isDown;
  6167. this._pageEventsReady = false;
  6168. this._ready = false;
  6169. (_this$_destroyCapabil3 = this._destroyCapability) === null || _this$_destroyCapabil3 === void 0 ? void 0 : _this$_destroyCapabil3.resolve();
  6170. case 29:
  6171. case "end":
  6172. return _context12.stop();
  6173. }
  6174. }
  6175. }, _callee12, this, [[9, 14]]);
  6176. }));
  6177. function _destroyScripting() {
  6178. return _destroyScripting2.apply(this, arguments);
  6179. }
  6180. return _destroyScripting;
  6181. }()
  6182. }]);
  6183. return PDFScriptingManager;
  6184. }();
  6185. exports.PDFScriptingManager = PDFScriptingManager;
  6186. /***/ }),
  6187. /* 19 */
  6188. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  6189. Object.defineProperty(exports, "__esModule", ({
  6190. value: true
  6191. }));
  6192. exports.docPropertiesLookup = docPropertiesLookup;
  6193. exports.GenericScripting = void 0;
  6194. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(4));
  6195. var _pdfjsLib = __w_pdfjs_require__(2);
  6196. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  6197. function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
  6198. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
  6199. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  6200. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6201. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  6202. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6203. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  6204. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  6205. function docPropertiesLookup(_x) {
  6206. return _docPropertiesLookup.apply(this, arguments);
  6207. }
  6208. function _docPropertiesLookup() {
  6209. _docPropertiesLookup = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(pdfDocument) {
  6210. var url, baseUrl, _yield$pdfDocument$ge, info, metadata, contentDispositionFilename, contentLength, _yield$pdfDocument$ge2, length;
  6211. return _regenerator["default"].wrap(function _callee4$(_context4) {
  6212. while (1) {
  6213. switch (_context4.prev = _context4.next) {
  6214. case 0:
  6215. url = "", baseUrl = url.split("#")[0];
  6216. _context4.next = 3;
  6217. return pdfDocument.getMetadata();
  6218. case 3:
  6219. _yield$pdfDocument$ge = _context4.sent;
  6220. info = _yield$pdfDocument$ge.info;
  6221. metadata = _yield$pdfDocument$ge.metadata;
  6222. contentDispositionFilename = _yield$pdfDocument$ge.contentDispositionFilename;
  6223. contentLength = _yield$pdfDocument$ge.contentLength;
  6224. if (contentLength) {
  6225. _context4.next = 14;
  6226. break;
  6227. }
  6228. _context4.next = 11;
  6229. return pdfDocument.getDownloadInfo();
  6230. case 11:
  6231. _yield$pdfDocument$ge2 = _context4.sent;
  6232. length = _yield$pdfDocument$ge2.length;
  6233. contentLength = length;
  6234. case 14:
  6235. return _context4.abrupt("return", _objectSpread(_objectSpread({}, info), {}, {
  6236. baseURL: baseUrl,
  6237. filesize: contentLength,
  6238. filename: contentDispositionFilename || (0, _pdfjsLib.getPdfFilenameFromUrl)(url),
  6239. metadata: metadata === null || metadata === void 0 ? void 0 : metadata.getRaw(),
  6240. authors: metadata === null || metadata === void 0 ? void 0 : metadata.get("dc:creator"),
  6241. numPages: pdfDocument.numPages,
  6242. URL: url
  6243. }));
  6244. case 15:
  6245. case "end":
  6246. return _context4.stop();
  6247. }
  6248. }
  6249. }, _callee4);
  6250. }));
  6251. return _docPropertiesLookup.apply(this, arguments);
  6252. }
  6253. var GenericScripting = /*#__PURE__*/function () {
  6254. function GenericScripting(sandboxBundleSrc) {
  6255. _classCallCheck(this, GenericScripting);
  6256. this._ready = (0, _pdfjsLib.loadScript)(sandboxBundleSrc, true).then(function () {
  6257. return window.pdfjsSandbox.QuickJSSandbox();
  6258. });
  6259. }
  6260. _createClass(GenericScripting, [{
  6261. key: "createSandbox",
  6262. value: function () {
  6263. var _createSandbox = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(data) {
  6264. var sandbox;
  6265. return _regenerator["default"].wrap(function _callee$(_context) {
  6266. while (1) {
  6267. switch (_context.prev = _context.next) {
  6268. case 0:
  6269. _context.next = 2;
  6270. return this._ready;
  6271. case 2:
  6272. sandbox = _context.sent;
  6273. sandbox.create(data);
  6274. case 4:
  6275. case "end":
  6276. return _context.stop();
  6277. }
  6278. }
  6279. }, _callee, this);
  6280. }));
  6281. function createSandbox(_x2) {
  6282. return _createSandbox.apply(this, arguments);
  6283. }
  6284. return createSandbox;
  6285. }()
  6286. }, {
  6287. key: "dispatchEventInSandbox",
  6288. value: function () {
  6289. var _dispatchEventInSandbox = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(event) {
  6290. var sandbox;
  6291. return _regenerator["default"].wrap(function _callee2$(_context2) {
  6292. while (1) {
  6293. switch (_context2.prev = _context2.next) {
  6294. case 0:
  6295. _context2.next = 2;
  6296. return this._ready;
  6297. case 2:
  6298. sandbox = _context2.sent;
  6299. sandbox.dispatchEvent(event);
  6300. case 4:
  6301. case "end":
  6302. return _context2.stop();
  6303. }
  6304. }
  6305. }, _callee2, this);
  6306. }));
  6307. function dispatchEventInSandbox(_x3) {
  6308. return _dispatchEventInSandbox.apply(this, arguments);
  6309. }
  6310. return dispatchEventInSandbox;
  6311. }()
  6312. }, {
  6313. key: "destroySandbox",
  6314. value: function () {
  6315. var _destroySandbox = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  6316. var sandbox;
  6317. return _regenerator["default"].wrap(function _callee3$(_context3) {
  6318. while (1) {
  6319. switch (_context3.prev = _context3.next) {
  6320. case 0:
  6321. _context3.next = 2;
  6322. return this._ready;
  6323. case 2:
  6324. sandbox = _context3.sent;
  6325. sandbox.nukeSandbox();
  6326. case 4:
  6327. case "end":
  6328. return _context3.stop();
  6329. }
  6330. }
  6331. }, _callee3, this);
  6332. }));
  6333. function destroySandbox() {
  6334. return _destroySandbox.apply(this, arguments);
  6335. }
  6336. return destroySandbox;
  6337. }()
  6338. }]);
  6339. return GenericScripting;
  6340. }();
  6341. exports.GenericScripting = GenericScripting;
  6342. /***/ }),
  6343. /* 20 */
  6344. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  6345. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  6346. Object.defineProperty(exports, "__esModule", ({
  6347. value: true
  6348. }));
  6349. exports.PDFSinglePageViewer = void 0;
  6350. var _base_viewer = __w_pdfjs_require__(21);
  6351. var _pdfjsLib = __w_pdfjs_require__(2);
  6352. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6353. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  6354. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6355. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  6356. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  6357. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  6358. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  6359. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  6360. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  6361. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  6362. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  6363. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  6364. var PDFSinglePageViewer = /*#__PURE__*/function (_BaseViewer) {
  6365. _inherits(PDFSinglePageViewer, _BaseViewer);
  6366. var _super = _createSuper(PDFSinglePageViewer);
  6367. function PDFSinglePageViewer(options) {
  6368. var _this;
  6369. _classCallCheck(this, PDFSinglePageViewer);
  6370. _this = _super.call(this, options);
  6371. _this.eventBus._on("pagesinit", function (evt) {
  6372. _this._ensurePageViewVisible();
  6373. });
  6374. return _this;
  6375. }
  6376. _createClass(PDFSinglePageViewer, [{
  6377. key: "_viewerElement",
  6378. get: function get() {
  6379. return (0, _pdfjsLib.shadow)(this, "_viewerElement", this._shadowViewer);
  6380. }
  6381. }, {
  6382. key: "_pageWidthScaleFactor",
  6383. get: function get() {
  6384. return 1;
  6385. }
  6386. }, {
  6387. key: "_resetView",
  6388. value: function _resetView() {
  6389. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_resetView", this).call(this);
  6390. this._previousPageNumber = 1;
  6391. this._shadowViewer = document.createDocumentFragment();
  6392. this._updateScrollDown = null;
  6393. }
  6394. }, {
  6395. key: "_ensurePageViewVisible",
  6396. value: function _ensurePageViewVisible() {
  6397. var pageView = this._pages[this._currentPageNumber - 1];
  6398. var previousPageView = this._pages[this._previousPageNumber - 1];
  6399. var viewerNodes = this.viewer.childNodes;
  6400. switch (viewerNodes.length) {
  6401. case 0:
  6402. this.viewer.appendChild(pageView.div);
  6403. break;
  6404. case 1:
  6405. if (viewerNodes[0] !== previousPageView.div) {
  6406. throw new Error("_ensurePageViewVisible: Unexpected previously visible page.");
  6407. }
  6408. if (pageView === previousPageView) {
  6409. break;
  6410. }
  6411. this._shadowViewer.appendChild(previousPageView.div);
  6412. this.viewer.appendChild(pageView.div);
  6413. this.container.scrollTop = 0;
  6414. break;
  6415. default:
  6416. throw new Error("_ensurePageViewVisible: Only one page should be visible at a time.");
  6417. }
  6418. this._previousPageNumber = this._currentPageNumber;
  6419. }
  6420. }, {
  6421. key: "_scrollUpdate",
  6422. value: function _scrollUpdate() {
  6423. if (this._updateScrollDown) {
  6424. this._updateScrollDown();
  6425. }
  6426. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollUpdate", this).call(this);
  6427. }
  6428. }, {
  6429. key: "_scrollIntoView",
  6430. value: function _scrollIntoView(_ref) {
  6431. var _this2 = this;
  6432. var pageDiv = _ref.pageDiv,
  6433. _ref$pageSpot = _ref.pageSpot,
  6434. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  6435. _ref$pageNumber = _ref.pageNumber,
  6436. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  6437. if (pageNumber) {
  6438. this._setCurrentPageNumber(pageNumber);
  6439. }
  6440. var scrolledDown = this._currentPageNumber >= this._previousPageNumber;
  6441. this._ensurePageViewVisible();
  6442. this.update();
  6443. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollIntoView", this).call(this, {
  6444. pageDiv: pageDiv,
  6445. pageSpot: pageSpot,
  6446. pageNumber: pageNumber
  6447. });
  6448. this._updateScrollDown = function () {
  6449. _this2.scroll.down = scrolledDown;
  6450. _this2._updateScrollDown = null;
  6451. };
  6452. }
  6453. }, {
  6454. key: "_getVisiblePages",
  6455. value: function _getVisiblePages() {
  6456. return this._getCurrentVisiblePage();
  6457. }
  6458. }, {
  6459. key: "_updateHelper",
  6460. value: function _updateHelper(visiblePages) {}
  6461. }, {
  6462. key: "_isScrollModeHorizontal",
  6463. get: function get() {
  6464. return (0, _pdfjsLib.shadow)(this, "_isScrollModeHorizontal", false);
  6465. }
  6466. }, {
  6467. key: "_updateScrollMode",
  6468. value: function _updateScrollMode() {}
  6469. }, {
  6470. key: "_updateSpreadMode",
  6471. value: function _updateSpreadMode() {}
  6472. }, {
  6473. key: "_getPageAdvance",
  6474. value: function _getPageAdvance() {
  6475. return 1;
  6476. }
  6477. }]);
  6478. return PDFSinglePageViewer;
  6479. }(_base_viewer.BaseViewer);
  6480. exports.PDFSinglePageViewer = PDFSinglePageViewer;
  6481. /***/ }),
  6482. /* 21 */
  6483. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  6484. Object.defineProperty(exports, "__esModule", ({
  6485. value: true
  6486. }));
  6487. exports.BaseViewer = void 0;
  6488. var _pdfjsLib = __w_pdfjs_require__(2);
  6489. var _ui_utils = __w_pdfjs_require__(7);
  6490. var _pdf_rendering_queue = __w_pdfjs_require__(17);
  6491. var _annotation_layer_builder = __w_pdfjs_require__(1);
  6492. var _l10n_utils = __w_pdfjs_require__(3);
  6493. var _pdf_page_view = __w_pdfjs_require__(16);
  6494. var _pdf_link_service = __w_pdfjs_require__(6);
  6495. var _struct_tree_layer_builder = __w_pdfjs_require__(22);
  6496. var _text_layer_builder = __w_pdfjs_require__(8);
  6497. var _xfa_layer_builder = __w_pdfjs_require__(23);
  6498. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  6499. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  6500. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  6501. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6502. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  6503. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6504. var DEFAULT_CACHE_SIZE = 10;
  6505. function PDFPageViewBuffer(size) {
  6506. var data = [];
  6507. this.push = function (view) {
  6508. var i = data.indexOf(view);
  6509. if (i >= 0) {
  6510. data.splice(i, 1);
  6511. }
  6512. data.push(view);
  6513. if (data.length > size) {
  6514. data.shift().destroy();
  6515. }
  6516. };
  6517. this.resize = function (newSize, pagesToKeep) {
  6518. size = newSize;
  6519. if (pagesToKeep) {
  6520. var pageIdsToKeep = new Set();
  6521. for (var i = 0, iMax = pagesToKeep.length; i < iMax; ++i) {
  6522. pageIdsToKeep.add(pagesToKeep[i].id);
  6523. }
  6524. (0, _ui_utils.moveToEndOfArray)(data, function (page) {
  6525. return pageIdsToKeep.has(page.id);
  6526. });
  6527. }
  6528. while (data.length > size) {
  6529. data.shift().destroy();
  6530. }
  6531. };
  6532. this.has = function (view) {
  6533. return data.includes(view);
  6534. };
  6535. }
  6536. function isSameScale(oldScale, newScale) {
  6537. if (newScale === oldScale) {
  6538. return true;
  6539. }
  6540. if (Math.abs(newScale - oldScale) < 1e-15) {
  6541. return true;
  6542. }
  6543. return false;
  6544. }
  6545. var BaseViewer = /*#__PURE__*/function () {
  6546. function BaseViewer(options) {
  6547. var _this$container,
  6548. _this$viewer,
  6549. _this = this;
  6550. _classCallCheck(this, BaseViewer);
  6551. if (this.constructor === BaseViewer) {
  6552. throw new Error("Cannot initialize BaseViewer.");
  6553. }
  6554. var viewerVersion = '2.9.359';
  6555. if (_pdfjsLib.version !== viewerVersion) {
  6556. throw new Error("The API version \"".concat(_pdfjsLib.version, "\" does not match the Viewer version \"").concat(viewerVersion, "\"."));
  6557. }
  6558. this._name = this.constructor.name;
  6559. this.container = options.container;
  6560. this.viewer = options.viewer || options.container.firstElementChild;
  6561. if (!(((_this$container = this.container) === null || _this$container === void 0 ? void 0 : _this$container.tagName.toUpperCase()) === "DIV" && ((_this$viewer = this.viewer) === null || _this$viewer === void 0 ? void 0 : _this$viewer.tagName.toUpperCase()) === "DIV")) {
  6562. throw new Error("Invalid `container` and/or `viewer` option.");
  6563. }
  6564. if (this.container.offsetParent && getComputedStyle(this.container).position !== "absolute") {
  6565. throw new Error("The `container` must be absolutely positioned.");
  6566. }
  6567. this.eventBus = options.eventBus;
  6568. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  6569. this.downloadManager = options.downloadManager || null;
  6570. this.findController = options.findController || null;
  6571. this._scriptingManager = options.scriptingManager || null;
  6572. this.removePageBorders = options.removePageBorders || false;
  6573. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  6574. this.imageResourcesPath = options.imageResourcesPath || "";
  6575. this.renderInteractiveForms = options.renderInteractiveForms !== false;
  6576. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  6577. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  6578. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  6579. this.maxCanvasPixels = options.maxCanvasPixels;
  6580. this.l10n = options.l10n || _l10n_utils.NullL10n;
  6581. this.enableScripting = options.enableScripting === true && !!this._scriptingManager;
  6582. this.defaultRenderingQueue = !options.renderingQueue;
  6583. if (this.defaultRenderingQueue) {
  6584. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  6585. this.renderingQueue.setViewer(this);
  6586. } else {
  6587. this.renderingQueue = options.renderingQueue;
  6588. }
  6589. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  6590. this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
  6591. this._onBeforeDraw = this._onAfterDraw = null;
  6592. this._resetView();
  6593. if (this.removePageBorders) {
  6594. this.viewer.classList.add("removePageBorders");
  6595. }
  6596. Promise.resolve().then(function () {
  6597. _this.eventBus.dispatch("baseviewerinit", {
  6598. source: _this
  6599. });
  6600. });
  6601. }
  6602. _createClass(BaseViewer, [{
  6603. key: "pagesCount",
  6604. get: function get() {
  6605. return this._pages.length;
  6606. }
  6607. }, {
  6608. key: "getPageView",
  6609. value: function getPageView(index) {
  6610. return this._pages[index];
  6611. }
  6612. }, {
  6613. key: "pageViewsReady",
  6614. get: function get() {
  6615. if (!this._pagesCapability.settled) {
  6616. return false;
  6617. }
  6618. return this._pages.every(function (pageView) {
  6619. return pageView === null || pageView === void 0 ? void 0 : pageView.pdfPage;
  6620. });
  6621. }
  6622. }, {
  6623. key: "currentPageNumber",
  6624. get: function get() {
  6625. return this._currentPageNumber;
  6626. },
  6627. set: function set(val) {
  6628. if (!Number.isInteger(val)) {
  6629. throw new Error("Invalid page number.");
  6630. }
  6631. if (!this.pdfDocument) {
  6632. return;
  6633. }
  6634. if (!this._setCurrentPageNumber(val, true)) {
  6635. console.error("".concat(this._name, ".currentPageNumber: \"").concat(val, "\" is not a valid page."));
  6636. }
  6637. }
  6638. }, {
  6639. key: "_setCurrentPageNumber",
  6640. value: function _setCurrentPageNumber(val) {
  6641. var _this$_pageLabels, _this$_pageLabels2;
  6642. var resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6643. if (this._currentPageNumber === val) {
  6644. if (resetCurrentPageView) {
  6645. this._resetCurrentPageView();
  6646. }
  6647. return true;
  6648. }
  6649. if (!(0 < val && val <= this.pagesCount)) {
  6650. return false;
  6651. }
  6652. var previous = this._currentPageNumber;
  6653. this._currentPageNumber = val;
  6654. this.eventBus.dispatch("pagechanging", {
  6655. source: this,
  6656. pageNumber: val,
  6657. pageLabel: (_this$_pageLabels = (_this$_pageLabels2 = this._pageLabels) === null || _this$_pageLabels2 === void 0 ? void 0 : _this$_pageLabels2[val - 1]) !== null && _this$_pageLabels !== void 0 ? _this$_pageLabels : null,
  6658. previous: previous
  6659. });
  6660. if (resetCurrentPageView) {
  6661. this._resetCurrentPageView();
  6662. }
  6663. return true;
  6664. }
  6665. }, {
  6666. key: "currentPageLabel",
  6667. get: function get() {
  6668. var _this$_pageLabels3, _this$_pageLabels4;
  6669. return (_this$_pageLabels3 = (_this$_pageLabels4 = this._pageLabels) === null || _this$_pageLabels4 === void 0 ? void 0 : _this$_pageLabels4[this._currentPageNumber - 1]) !== null && _this$_pageLabels3 !== void 0 ? _this$_pageLabels3 : null;
  6670. },
  6671. set: function set(val) {
  6672. if (!this.pdfDocument) {
  6673. return;
  6674. }
  6675. var page = val | 0;
  6676. if (this._pageLabels) {
  6677. var i = this._pageLabels.indexOf(val);
  6678. if (i >= 0) {
  6679. page = i + 1;
  6680. }
  6681. }
  6682. if (!this._setCurrentPageNumber(page, true)) {
  6683. console.error("".concat(this._name, ".currentPageLabel: \"").concat(val, "\" is not a valid page."));
  6684. }
  6685. }
  6686. }, {
  6687. key: "currentScale",
  6688. get: function get() {
  6689. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
  6690. },
  6691. set: function set(val) {
  6692. if (isNaN(val)) {
  6693. throw new Error("Invalid numeric scale.");
  6694. }
  6695. if (!this.pdfDocument) {
  6696. return;
  6697. }
  6698. this._setScale(val, false);
  6699. }
  6700. }, {
  6701. key: "currentScaleValue",
  6702. get: function get() {
  6703. return this._currentScaleValue;
  6704. },
  6705. set: function set(val) {
  6706. if (!this.pdfDocument) {
  6707. return;
  6708. }
  6709. this._setScale(val, false);
  6710. }
  6711. }, {
  6712. key: "pagesRotation",
  6713. get: function get() {
  6714. return this._pagesRotation;
  6715. },
  6716. set: function set(rotation) {
  6717. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  6718. throw new Error("Invalid pages rotation angle.");
  6719. }
  6720. if (!this.pdfDocument) {
  6721. return;
  6722. }
  6723. rotation %= 360;
  6724. if (rotation < 0) {
  6725. rotation += 360;
  6726. }
  6727. if (this._pagesRotation === rotation) {
  6728. return;
  6729. }
  6730. this._pagesRotation = rotation;
  6731. var pageNumber = this._currentPageNumber;
  6732. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  6733. var pageView = this._pages[i];
  6734. pageView.update(pageView.scale, rotation);
  6735. }
  6736. if (this._currentScaleValue) {
  6737. this._setScale(this._currentScaleValue, true);
  6738. }
  6739. this.eventBus.dispatch("rotationchanging", {
  6740. source: this,
  6741. pagesRotation: rotation,
  6742. pageNumber: pageNumber
  6743. });
  6744. if (this.defaultRenderingQueue) {
  6745. this.update();
  6746. }
  6747. }
  6748. }, {
  6749. key: "firstPagePromise",
  6750. get: function get() {
  6751. return this.pdfDocument ? this._firstPageCapability.promise : null;
  6752. }
  6753. }, {
  6754. key: "onePageRendered",
  6755. get: function get() {
  6756. return this.pdfDocument ? this._onePageRenderedCapability.promise : null;
  6757. }
  6758. }, {
  6759. key: "pagesPromise",
  6760. get: function get() {
  6761. return this.pdfDocument ? this._pagesCapability.promise : null;
  6762. }
  6763. }, {
  6764. key: "_viewerElement",
  6765. get: function get() {
  6766. throw new Error("Not implemented: _viewerElement");
  6767. }
  6768. }, {
  6769. key: "_onePageRenderedOrForceFetch",
  6770. value: function _onePageRenderedOrForceFetch() {
  6771. if (!this.container.offsetParent || this._getVisiblePages().views.length === 0) {
  6772. return Promise.resolve();
  6773. }
  6774. return this._onePageRenderedCapability.promise;
  6775. }
  6776. }, {
  6777. key: "setDocument",
  6778. value: function setDocument(pdfDocument) {
  6779. var _this2 = this;
  6780. if (this.pdfDocument) {
  6781. this.eventBus.dispatch("pagesdestroy", {
  6782. source: this
  6783. });
  6784. this._cancelRendering();
  6785. this._resetView();
  6786. if (this.findController) {
  6787. this.findController.setDocument(null);
  6788. }
  6789. if (this._scriptingManager) {
  6790. this._scriptingManager.setDocument(null);
  6791. }
  6792. }
  6793. this.pdfDocument = pdfDocument;
  6794. if (!pdfDocument) {
  6795. return;
  6796. }
  6797. var isPureXfa = pdfDocument.isPureXfa;
  6798. var pagesCount = pdfDocument.numPages;
  6799. var firstPagePromise = pdfDocument.getPage(1);
  6800. var optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
  6801. this._pagesCapability.promise.then(function () {
  6802. _this2.eventBus.dispatch("pagesloaded", {
  6803. source: _this2,
  6804. pagesCount: pagesCount
  6805. });
  6806. });
  6807. this._onBeforeDraw = function (evt) {
  6808. var pageView = _this2._pages[evt.pageNumber - 1];
  6809. if (!pageView) {
  6810. return;
  6811. }
  6812. _this2._buffer.push(pageView);
  6813. };
  6814. this.eventBus._on("pagerender", this._onBeforeDraw);
  6815. this._onAfterDraw = function (evt) {
  6816. if (evt.cssTransform || _this2._onePageRenderedCapability.settled) {
  6817. return;
  6818. }
  6819. _this2._onePageRenderedCapability.resolve();
  6820. _this2.eventBus._off("pagerendered", _this2._onAfterDraw);
  6821. _this2._onAfterDraw = null;
  6822. };
  6823. this.eventBus._on("pagerendered", this._onAfterDraw);
  6824. firstPagePromise.then(function (firstPdfPage) {
  6825. _this2._firstPageCapability.resolve(firstPdfPage);
  6826. _this2._optionalContentConfigPromise = optionalContentConfigPromise;
  6827. var scale = _this2.currentScale;
  6828. var viewport = firstPdfPage.getViewport({
  6829. scale: scale * _ui_utils.CSS_UNITS
  6830. });
  6831. var textLayerFactory = _this2.textLayerMode !== _ui_utils.TextLayerMode.DISABLE ? _this2 : null;
  6832. var xfaLayerFactory = isPureXfa ? _this2 : null;
  6833. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  6834. var pageView = new _pdf_page_view.PDFPageView({
  6835. container: _this2._viewerElement,
  6836. eventBus: _this2.eventBus,
  6837. id: pageNum,
  6838. scale: scale,
  6839. defaultViewport: viewport.clone(),
  6840. optionalContentConfigPromise: optionalContentConfigPromise,
  6841. renderingQueue: _this2.renderingQueue,
  6842. textLayerFactory: textLayerFactory,
  6843. textLayerMode: _this2.textLayerMode,
  6844. annotationLayerFactory: _this2,
  6845. xfaLayerFactory: xfaLayerFactory,
  6846. structTreeLayerFactory: _this2,
  6847. imageResourcesPath: _this2.imageResourcesPath,
  6848. renderInteractiveForms: _this2.renderInteractiveForms,
  6849. renderer: _this2.renderer,
  6850. useOnlyCssZoom: _this2.useOnlyCssZoom,
  6851. maxCanvasPixels: _this2.maxCanvasPixels,
  6852. l10n: _this2.l10n
  6853. });
  6854. _this2._pages.push(pageView);
  6855. }
  6856. var firstPageView = _this2._pages[0];
  6857. if (firstPageView) {
  6858. firstPageView.setPdfPage(firstPdfPage);
  6859. _this2.linkService.cachePageRef(1, firstPdfPage.ref);
  6860. }
  6861. if (_this2._spreadMode !== _ui_utils.SpreadMode.NONE) {
  6862. _this2._updateSpreadMode();
  6863. }
  6864. _this2._onePageRenderedOrForceFetch().then(function () {
  6865. if (_this2.findController) {
  6866. _this2.findController.setDocument(pdfDocument);
  6867. }
  6868. if (_this2.enableScripting) {
  6869. _this2._scriptingManager.setDocument(pdfDocument);
  6870. }
  6871. if (pdfDocument.loadingParams.disableAutoFetch || pagesCount > 7500) {
  6872. _this2._pagesCapability.resolve();
  6873. return;
  6874. }
  6875. var getPagesLeft = pagesCount - 1;
  6876. if (getPagesLeft <= 0) {
  6877. _this2._pagesCapability.resolve();
  6878. return;
  6879. }
  6880. var _loop = function _loop(_pageNum) {
  6881. pdfDocument.getPage(_pageNum).then(function (pdfPage) {
  6882. var pageView = _this2._pages[_pageNum - 1];
  6883. if (!pageView.pdfPage) {
  6884. pageView.setPdfPage(pdfPage);
  6885. }
  6886. _this2.linkService.cachePageRef(_pageNum, pdfPage.ref);
  6887. if (--getPagesLeft === 0) {
  6888. _this2._pagesCapability.resolve();
  6889. }
  6890. }, function (reason) {
  6891. console.error("Unable to get page ".concat(_pageNum, " to initialize viewer"), reason);
  6892. if (--getPagesLeft === 0) {
  6893. _this2._pagesCapability.resolve();
  6894. }
  6895. });
  6896. };
  6897. for (var _pageNum = 2; _pageNum <= pagesCount; ++_pageNum) {
  6898. _loop(_pageNum);
  6899. }
  6900. });
  6901. _this2.eventBus.dispatch("pagesinit", {
  6902. source: _this2
  6903. });
  6904. if (_this2.defaultRenderingQueue) {
  6905. _this2.update();
  6906. }
  6907. })["catch"](function (reason) {
  6908. console.error("Unable to initialize viewer", reason);
  6909. });
  6910. }
  6911. }, {
  6912. key: "setPageLabels",
  6913. value: function setPageLabels(labels) {
  6914. if (!this.pdfDocument) {
  6915. return;
  6916. }
  6917. if (!labels) {
  6918. this._pageLabels = null;
  6919. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  6920. this._pageLabels = null;
  6921. console.error("".concat(this._name, ".setPageLabels: Invalid page labels."));
  6922. } else {
  6923. this._pageLabels = labels;
  6924. }
  6925. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  6926. var _this$_pageLabels$i, _this$_pageLabels5;
  6927. this._pages[i].setPageLabel((_this$_pageLabels$i = (_this$_pageLabels5 = this._pageLabels) === null || _this$_pageLabels5 === void 0 ? void 0 : _this$_pageLabels5[i]) !== null && _this$_pageLabels$i !== void 0 ? _this$_pageLabels$i : null);
  6928. }
  6929. }
  6930. }, {
  6931. key: "_resetView",
  6932. value: function _resetView() {
  6933. this._pages = [];
  6934. this._currentPageNumber = 1;
  6935. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  6936. this._currentScaleValue = null;
  6937. this._pageLabels = null;
  6938. this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  6939. this._location = null;
  6940. this._pagesRotation = 0;
  6941. this._optionalContentConfigPromise = null;
  6942. this._pagesRequests = new WeakMap();
  6943. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  6944. this._onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  6945. this._pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
  6946. this._scrollMode = _ui_utils.ScrollMode.VERTICAL;
  6947. this._spreadMode = _ui_utils.SpreadMode.NONE;
  6948. if (this._onBeforeDraw) {
  6949. this.eventBus._off("pagerender", this._onBeforeDraw);
  6950. this._onBeforeDraw = null;
  6951. }
  6952. if (this._onAfterDraw) {
  6953. this.eventBus._off("pagerendered", this._onAfterDraw);
  6954. this._onAfterDraw = null;
  6955. }
  6956. this.viewer.textContent = "";
  6957. this._updateScrollMode();
  6958. }
  6959. }, {
  6960. key: "_scrollUpdate",
  6961. value: function _scrollUpdate() {
  6962. if (this.pagesCount === 0) {
  6963. return;
  6964. }
  6965. this.update();
  6966. }
  6967. }, {
  6968. key: "_scrollIntoView",
  6969. value: function _scrollIntoView(_ref) {
  6970. var pageDiv = _ref.pageDiv,
  6971. _ref$pageSpot = _ref.pageSpot,
  6972. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  6973. _ref$pageNumber = _ref.pageNumber,
  6974. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  6975. (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
  6976. }
  6977. }, {
  6978. key: "_setScaleUpdatePages",
  6979. value: function _setScaleUpdatePages(newScale, newValue) {
  6980. var noScroll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  6981. var preset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  6982. this._currentScaleValue = newValue.toString();
  6983. if (isSameScale(this._currentScale, newScale)) {
  6984. if (preset) {
  6985. this.eventBus.dispatch("scalechanging", {
  6986. source: this,
  6987. scale: newScale,
  6988. presetValue: newValue
  6989. });
  6990. }
  6991. return;
  6992. }
  6993. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  6994. this._pages[i].update(newScale);
  6995. }
  6996. this._currentScale = newScale;
  6997. if (!noScroll) {
  6998. var page = this._currentPageNumber,
  6999. dest;
  7000. if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  7001. page = this._location.pageNumber;
  7002. dest = [null, {
  7003. name: "XYZ"
  7004. }, this._location.left, this._location.top, null];
  7005. }
  7006. this.scrollPageIntoView({
  7007. pageNumber: page,
  7008. destArray: dest,
  7009. allowNegativeOffset: true
  7010. });
  7011. }
  7012. this.eventBus.dispatch("scalechanging", {
  7013. source: this,
  7014. scale: newScale,
  7015. presetValue: preset ? newValue : undefined
  7016. });
  7017. if (this.defaultRenderingQueue) {
  7018. this.update();
  7019. }
  7020. }
  7021. }, {
  7022. key: "_pageWidthScaleFactor",
  7023. get: function get() {
  7024. if (this._spreadMode !== _ui_utils.SpreadMode.NONE && this._scrollMode !== _ui_utils.ScrollMode.HORIZONTAL && !this.isInPresentationMode) {
  7025. return 2;
  7026. }
  7027. return 1;
  7028. }
  7029. }, {
  7030. key: "_setScale",
  7031. value: function _setScale(value) {
  7032. var noScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7033. var scale = parseFloat(value);
  7034. if (scale > 0) {
  7035. this._setScaleUpdatePages(scale, value, noScroll, false);
  7036. } else {
  7037. var currentPage = this._pages[this._currentPageNumber - 1];
  7038. if (!currentPage) {
  7039. return;
  7040. }
  7041. var noPadding = this.isInPresentationMode || this.removePageBorders;
  7042. var hPadding = noPadding ? 0 : _ui_utils.SCROLLBAR_PADDING;
  7043. var vPadding = noPadding ? 0 : _ui_utils.VERTICAL_PADDING;
  7044. if (!noPadding && this._isScrollModeHorizontal) {
  7045. var _ref2 = [vPadding, hPadding];
  7046. hPadding = _ref2[0];
  7047. vPadding = _ref2[1];
  7048. }
  7049. var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale / this._pageWidthScaleFactor;
  7050. var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  7051. switch (value) {
  7052. case "page-actual":
  7053. scale = 1;
  7054. break;
  7055. case "page-width":
  7056. scale = pageWidthScale;
  7057. break;
  7058. case "page-height":
  7059. scale = pageHeightScale;
  7060. break;
  7061. case "page-fit":
  7062. scale = Math.min(pageWidthScale, pageHeightScale);
  7063. break;
  7064. case "auto":
  7065. var horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
  7066. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  7067. break;
  7068. default:
  7069. console.error("".concat(this._name, "._setScale: \"").concat(value, "\" is an unknown zoom value."));
  7070. return;
  7071. }
  7072. this._setScaleUpdatePages(scale, value, noScroll, true);
  7073. }
  7074. }
  7075. }, {
  7076. key: "_resetCurrentPageView",
  7077. value: function _resetCurrentPageView() {
  7078. if (this.isInPresentationMode) {
  7079. this._setScale(this._currentScaleValue, true);
  7080. }
  7081. var pageView = this._pages[this._currentPageNumber - 1];
  7082. this._scrollIntoView({
  7083. pageDiv: pageView.div
  7084. });
  7085. }
  7086. }, {
  7087. key: "pageLabelToPageNumber",
  7088. value: function pageLabelToPageNumber(label) {
  7089. if (!this._pageLabels) {
  7090. return null;
  7091. }
  7092. var i = this._pageLabels.indexOf(label);
  7093. if (i < 0) {
  7094. return null;
  7095. }
  7096. return i + 1;
  7097. }
  7098. }, {
  7099. key: "scrollPageIntoView",
  7100. value: function scrollPageIntoView(_ref3) {
  7101. var pageNumber = _ref3.pageNumber,
  7102. _ref3$destArray = _ref3.destArray,
  7103. destArray = _ref3$destArray === void 0 ? null : _ref3$destArray,
  7104. _ref3$allowNegativeOf = _ref3.allowNegativeOffset,
  7105. allowNegativeOffset = _ref3$allowNegativeOf === void 0 ? false : _ref3$allowNegativeOf,
  7106. _ref3$ignoreDestinati = _ref3.ignoreDestinationZoom,
  7107. ignoreDestinationZoom = _ref3$ignoreDestinati === void 0 ? false : _ref3$ignoreDestinati;
  7108. if (!this.pdfDocument) {
  7109. return;
  7110. }
  7111. var pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1];
  7112. if (!pageView) {
  7113. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  7114. return;
  7115. }
  7116. if (this.isInPresentationMode || !destArray) {
  7117. this._setCurrentPageNumber(pageNumber, true);
  7118. return;
  7119. }
  7120. var x = 0,
  7121. y = 0;
  7122. var width = 0,
  7123. height = 0,
  7124. widthScale,
  7125. heightScale;
  7126. var changeOrientation = pageView.rotation % 180 !== 0;
  7127. var pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;
  7128. var pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;
  7129. var scale = 0;
  7130. switch (destArray[1].name) {
  7131. case "XYZ":
  7132. x = destArray[2];
  7133. y = destArray[3];
  7134. scale = destArray[4];
  7135. x = x !== null ? x : 0;
  7136. y = y !== null ? y : pageHeight;
  7137. break;
  7138. case "Fit":
  7139. case "FitB":
  7140. scale = "page-fit";
  7141. break;
  7142. case "FitH":
  7143. case "FitBH":
  7144. y = destArray[2];
  7145. scale = "page-width";
  7146. if (y === null && this._location) {
  7147. x = this._location.left;
  7148. y = this._location.top;
  7149. } else if (typeof y !== "number") {
  7150. y = pageHeight;
  7151. }
  7152. break;
  7153. case "FitV":
  7154. case "FitBV":
  7155. x = destArray[2];
  7156. width = pageWidth;
  7157. height = pageHeight;
  7158. scale = "page-height";
  7159. break;
  7160. case "FitR":
  7161. x = destArray[2];
  7162. y = destArray[3];
  7163. width = destArray[4] - x;
  7164. height = destArray[5] - y;
  7165. var hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  7166. var vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  7167. widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;
  7168. heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;
  7169. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  7170. break;
  7171. default:
  7172. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(destArray[1].name, "\" is not a valid destination type."));
  7173. return;
  7174. }
  7175. if (!ignoreDestinationZoom) {
  7176. if (scale && scale !== this._currentScale) {
  7177. this.currentScaleValue = scale;
  7178. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  7179. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  7180. }
  7181. }
  7182. if (scale === "page-fit" && !destArray[4]) {
  7183. this._scrollIntoView({
  7184. pageDiv: pageView.div,
  7185. pageNumber: pageNumber
  7186. });
  7187. return;
  7188. }
  7189. var boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  7190. var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  7191. var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  7192. if (!allowNegativeOffset) {
  7193. left = Math.max(left, 0);
  7194. top = Math.max(top, 0);
  7195. }
  7196. this._scrollIntoView({
  7197. pageDiv: pageView.div,
  7198. pageSpot: {
  7199. left: left,
  7200. top: top
  7201. },
  7202. pageNumber: pageNumber
  7203. });
  7204. }
  7205. }, {
  7206. key: "_updateLocation",
  7207. value: function _updateLocation(firstPage) {
  7208. var currentScale = this._currentScale;
  7209. var currentScaleValue = this._currentScaleValue;
  7210. var normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  7211. var pageNumber = firstPage.id;
  7212. var pdfOpenParams = "#page=" + pageNumber;
  7213. pdfOpenParams += "&zoom=" + normalizedScaleValue;
  7214. var currentPageView = this._pages[pageNumber - 1];
  7215. var container = this.container;
  7216. var topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  7217. var intLeft = Math.round(topLeft[0]);
  7218. var intTop = Math.round(topLeft[1]);
  7219. pdfOpenParams += "," + intLeft + "," + intTop;
  7220. this._location = {
  7221. pageNumber: pageNumber,
  7222. scale: normalizedScaleValue,
  7223. top: intTop,
  7224. left: intLeft,
  7225. rotation: this._pagesRotation,
  7226. pdfOpenParams: pdfOpenParams
  7227. };
  7228. }
  7229. }, {
  7230. key: "_updateHelper",
  7231. value: function _updateHelper(visiblePages) {
  7232. throw new Error("Not implemented: _updateHelper");
  7233. }
  7234. }, {
  7235. key: "update",
  7236. value: function update() {
  7237. var visible = this._getVisiblePages();
  7238. var visiblePages = visible.views,
  7239. numVisiblePages = visiblePages.length;
  7240. if (numVisiblePages === 0) {
  7241. return;
  7242. }
  7243. var newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
  7244. this._buffer.resize(newCacheSize, visiblePages);
  7245. this.renderingQueue.renderHighestPriority(visible);
  7246. this._updateHelper(visiblePages);
  7247. this._updateLocation(visible.first);
  7248. this.eventBus.dispatch("updateviewarea", {
  7249. source: this,
  7250. location: this._location
  7251. });
  7252. }
  7253. }, {
  7254. key: "containsElement",
  7255. value: function containsElement(element) {
  7256. return this.container.contains(element);
  7257. }
  7258. }, {
  7259. key: "focus",
  7260. value: function focus() {
  7261. this.container.focus();
  7262. }
  7263. }, {
  7264. key: "_isScrollModeHorizontal",
  7265. get: function get() {
  7266. return this.isInPresentationMode ? false : this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL;
  7267. }
  7268. }, {
  7269. key: "_isContainerRtl",
  7270. get: function get() {
  7271. return getComputedStyle(this.container).direction === "rtl";
  7272. }
  7273. }, {
  7274. key: "isInPresentationMode",
  7275. get: function get() {
  7276. return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
  7277. }
  7278. }, {
  7279. key: "isChangingPresentationMode",
  7280. get: function get() {
  7281. return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
  7282. }
  7283. }, {
  7284. key: "isHorizontalScrollbarEnabled",
  7285. get: function get() {
  7286. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  7287. }
  7288. }, {
  7289. key: "isVerticalScrollbarEnabled",
  7290. get: function get() {
  7291. return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight;
  7292. }
  7293. }, {
  7294. key: "_getCurrentVisiblePage",
  7295. value: function _getCurrentVisiblePage() {
  7296. if (!this.pagesCount) {
  7297. return {
  7298. views: []
  7299. };
  7300. }
  7301. var pageView = this._pages[this._currentPageNumber - 1];
  7302. var element = pageView.div;
  7303. var view = {
  7304. id: pageView.id,
  7305. x: element.offsetLeft + element.clientLeft,
  7306. y: element.offsetTop + element.clientTop,
  7307. view: pageView
  7308. };
  7309. return {
  7310. first: view,
  7311. last: view,
  7312. views: [view]
  7313. };
  7314. }
  7315. }, {
  7316. key: "_getVisiblePages",
  7317. value: function _getVisiblePages() {
  7318. return (0, _ui_utils.getVisibleElements)({
  7319. scrollEl: this.container,
  7320. views: this._pages,
  7321. sortByVisibility: true,
  7322. horizontal: this._isScrollModeHorizontal,
  7323. rtl: this._isScrollModeHorizontal && this._isContainerRtl
  7324. });
  7325. }
  7326. }, {
  7327. key: "isPageVisible",
  7328. value: function isPageVisible(pageNumber) {
  7329. if (!this.pdfDocument) {
  7330. return false;
  7331. }
  7332. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
  7333. console.error("".concat(this._name, ".isPageVisible: \"").concat(pageNumber, "\" is not a valid page."));
  7334. return false;
  7335. }
  7336. return this._getVisiblePages().views.some(function (view) {
  7337. return view.id === pageNumber;
  7338. });
  7339. }
  7340. }, {
  7341. key: "isPageCached",
  7342. value: function isPageCached(pageNumber) {
  7343. if (!this.pdfDocument || !this._buffer) {
  7344. return false;
  7345. }
  7346. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
  7347. console.error("".concat(this._name, ".isPageCached: \"").concat(pageNumber, "\" is not a valid page."));
  7348. return false;
  7349. }
  7350. var pageView = this._pages[pageNumber - 1];
  7351. if (!pageView) {
  7352. return false;
  7353. }
  7354. return this._buffer.has(pageView);
  7355. }
  7356. }, {
  7357. key: "cleanup",
  7358. value: function cleanup() {
  7359. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  7360. if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  7361. this._pages[i].reset();
  7362. }
  7363. }
  7364. }
  7365. }, {
  7366. key: "_cancelRendering",
  7367. value: function _cancelRendering() {
  7368. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  7369. if (this._pages[i]) {
  7370. this._pages[i].cancelRendering();
  7371. }
  7372. }
  7373. }
  7374. }, {
  7375. key: "_ensurePdfPageLoaded",
  7376. value: function _ensurePdfPageLoaded(pageView) {
  7377. var _this3 = this;
  7378. if (pageView.pdfPage) {
  7379. return Promise.resolve(pageView.pdfPage);
  7380. }
  7381. if (this._pagesRequests.has(pageView)) {
  7382. return this._pagesRequests.get(pageView);
  7383. }
  7384. var promise = this.pdfDocument.getPage(pageView.id).then(function (pdfPage) {
  7385. if (!pageView.pdfPage) {
  7386. pageView.setPdfPage(pdfPage);
  7387. }
  7388. _this3._pagesRequests["delete"](pageView);
  7389. return pdfPage;
  7390. })["catch"](function (reason) {
  7391. console.error("Unable to get page for page view", reason);
  7392. _this3._pagesRequests["delete"](pageView);
  7393. });
  7394. this._pagesRequests.set(pageView, promise);
  7395. return promise;
  7396. }
  7397. }, {
  7398. key: "forceRendering",
  7399. value: function forceRendering(currentlyVisiblePages) {
  7400. var _this4 = this;
  7401. var visiblePages = currentlyVisiblePages || this._getVisiblePages();
  7402. var scrollAhead = this._isScrollModeHorizontal ? this.scroll.right : this.scroll.down;
  7403. var pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead);
  7404. if (pageView) {
  7405. this._ensurePdfPageLoaded(pageView).then(function () {
  7406. _this4.renderingQueue.renderView(pageView);
  7407. });
  7408. return true;
  7409. }
  7410. return false;
  7411. }
  7412. }, {
  7413. key: "createTextLayerBuilder",
  7414. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  7415. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  7416. var eventBus = arguments.length > 4 ? arguments[4] : undefined;
  7417. return new _text_layer_builder.TextLayerBuilder({
  7418. textLayerDiv: textLayerDiv,
  7419. eventBus: eventBus,
  7420. pageIndex: pageIndex,
  7421. viewport: viewport,
  7422. findController: this.isInPresentationMode ? null : this.findController,
  7423. enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection
  7424. });
  7425. }
  7426. }, {
  7427. key: "createAnnotationLayerBuilder",
  7428. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  7429. var _this$pdfDocument, _this$pdfDocument2, _this$_scriptingManag;
  7430. var annotationStorage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  7431. var imageResourcesPath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "";
  7432. var renderInteractiveForms = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  7433. var l10n = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : _l10n_utils.NullL10n;
  7434. var enableScripting = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
  7435. var hasJSActionsPromise = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
  7436. var mouseState = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
  7437. return new _annotation_layer_builder.AnnotationLayerBuilder({
  7438. pageDiv: pageDiv,
  7439. pdfPage: pdfPage,
  7440. annotationStorage: annotationStorage || ((_this$pdfDocument = this.pdfDocument) === null || _this$pdfDocument === void 0 ? void 0 : _this$pdfDocument.annotationStorage),
  7441. imageResourcesPath: imageResourcesPath,
  7442. renderInteractiveForms: renderInteractiveForms,
  7443. linkService: this.linkService,
  7444. downloadManager: this.downloadManager,
  7445. l10n: l10n,
  7446. enableScripting: enableScripting !== null && enableScripting !== void 0 ? enableScripting : this.enableScripting,
  7447. hasJSActionsPromise: hasJSActionsPromise || ((_this$pdfDocument2 = this.pdfDocument) === null || _this$pdfDocument2 === void 0 ? void 0 : _this$pdfDocument2.hasJSActions()),
  7448. mouseState: mouseState || ((_this$_scriptingManag = this._scriptingManager) === null || _this$_scriptingManag === void 0 ? void 0 : _this$_scriptingManag.mouseState)
  7449. });
  7450. }
  7451. }, {
  7452. key: "createXfaLayerBuilder",
  7453. value: function createXfaLayerBuilder(pageDiv, pdfPage) {
  7454. var _this$pdfDocument3;
  7455. var annotationStorage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  7456. return new _xfa_layer_builder.XfaLayerBuilder({
  7457. pageDiv: pageDiv,
  7458. pdfPage: pdfPage,
  7459. annotationStorage: annotationStorage || ((_this$pdfDocument3 = this.pdfDocument) === null || _this$pdfDocument3 === void 0 ? void 0 : _this$pdfDocument3.annotationStorage)
  7460. });
  7461. }
  7462. }, {
  7463. key: "createStructTreeLayerBuilder",
  7464. value: function createStructTreeLayerBuilder(pdfPage) {
  7465. return new _struct_tree_layer_builder.StructTreeLayerBuilder({
  7466. pdfPage: pdfPage
  7467. });
  7468. }
  7469. }, {
  7470. key: "hasEqualPageSizes",
  7471. get: function get() {
  7472. var firstPageView = this._pages[0];
  7473. for (var i = 1, ii = this._pages.length; i < ii; ++i) {
  7474. var pageView = this._pages[i];
  7475. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  7476. return false;
  7477. }
  7478. }
  7479. return true;
  7480. }
  7481. }, {
  7482. key: "getPagesOverview",
  7483. value: function getPagesOverview() {
  7484. var _this5 = this;
  7485. return this._pages.map(function (pageView) {
  7486. var viewport = pageView.pdfPage.getViewport({
  7487. scale: 1
  7488. });
  7489. if (!_this5.enablePrintAutoRotate || (0, _ui_utils.isPortraitOrientation)(viewport)) {
  7490. return {
  7491. width: viewport.width,
  7492. height: viewport.height,
  7493. rotation: viewport.rotation
  7494. };
  7495. }
  7496. return {
  7497. width: viewport.height,
  7498. height: viewport.width,
  7499. rotation: (viewport.rotation - 90) % 360
  7500. };
  7501. });
  7502. }
  7503. }, {
  7504. key: "optionalContentConfigPromise",
  7505. get: function get() {
  7506. if (!this.pdfDocument) {
  7507. return Promise.resolve(null);
  7508. }
  7509. if (!this._optionalContentConfigPromise) {
  7510. return this.pdfDocument.getOptionalContentConfig();
  7511. }
  7512. return this._optionalContentConfigPromise;
  7513. },
  7514. set: function set(promise) {
  7515. if (!(promise instanceof Promise)) {
  7516. throw new Error("Invalid optionalContentConfigPromise: ".concat(promise));
  7517. }
  7518. if (!this.pdfDocument) {
  7519. return;
  7520. }
  7521. if (!this._optionalContentConfigPromise) {
  7522. return;
  7523. }
  7524. this._optionalContentConfigPromise = promise;
  7525. var _iterator = _createForOfIteratorHelper(this._pages),
  7526. _step;
  7527. try {
  7528. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  7529. var pageView = _step.value;
  7530. pageView.update(pageView.scale, pageView.rotation, promise);
  7531. }
  7532. } catch (err) {
  7533. _iterator.e(err);
  7534. } finally {
  7535. _iterator.f();
  7536. }
  7537. this.update();
  7538. this.eventBus.dispatch("optionalcontentconfigchanged", {
  7539. source: this,
  7540. promise: promise
  7541. });
  7542. }
  7543. }, {
  7544. key: "scrollMode",
  7545. get: function get() {
  7546. return this._scrollMode;
  7547. },
  7548. set: function set(mode) {
  7549. if (this._scrollMode === mode) {
  7550. return;
  7551. }
  7552. if (!(0, _ui_utils.isValidScrollMode)(mode)) {
  7553. throw new Error("Invalid scroll mode: ".concat(mode));
  7554. }
  7555. this._scrollMode = mode;
  7556. this.eventBus.dispatch("scrollmodechanged", {
  7557. source: this,
  7558. mode: mode
  7559. });
  7560. this._updateScrollMode(this._currentPageNumber);
  7561. }
  7562. }, {
  7563. key: "_updateScrollMode",
  7564. value: function _updateScrollMode() {
  7565. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  7566. var scrollMode = this._scrollMode,
  7567. viewer = this.viewer;
  7568. viewer.classList.toggle("scrollHorizontal", scrollMode === _ui_utils.ScrollMode.HORIZONTAL);
  7569. viewer.classList.toggle("scrollWrapped", scrollMode === _ui_utils.ScrollMode.WRAPPED);
  7570. if (!this.pdfDocument || !pageNumber) {
  7571. return;
  7572. }
  7573. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  7574. this._setScale(this._currentScaleValue, true);
  7575. }
  7576. this._setCurrentPageNumber(pageNumber, true);
  7577. this.update();
  7578. }
  7579. }, {
  7580. key: "spreadMode",
  7581. get: function get() {
  7582. return this._spreadMode;
  7583. },
  7584. set: function set(mode) {
  7585. if (this._spreadMode === mode) {
  7586. return;
  7587. }
  7588. if (!(0, _ui_utils.isValidSpreadMode)(mode)) {
  7589. throw new Error("Invalid spread mode: ".concat(mode));
  7590. }
  7591. this._spreadMode = mode;
  7592. this.eventBus.dispatch("spreadmodechanged", {
  7593. source: this,
  7594. mode: mode
  7595. });
  7596. this._updateSpreadMode(this._currentPageNumber);
  7597. }
  7598. }, {
  7599. key: "_updateSpreadMode",
  7600. value: function _updateSpreadMode() {
  7601. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  7602. if (!this.pdfDocument) {
  7603. return;
  7604. }
  7605. var viewer = this.viewer,
  7606. pages = this._pages;
  7607. viewer.textContent = "";
  7608. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  7609. for (var i = 0, iMax = pages.length; i < iMax; ++i) {
  7610. viewer.appendChild(pages[i].div);
  7611. }
  7612. } else {
  7613. var parity = this._spreadMode - 1;
  7614. var spread = null;
  7615. for (var _i = 0, _iMax = pages.length; _i < _iMax; ++_i) {
  7616. if (spread === null) {
  7617. spread = document.createElement("div");
  7618. spread.className = "spread";
  7619. viewer.appendChild(spread);
  7620. } else if (_i % 2 === parity) {
  7621. spread = spread.cloneNode(false);
  7622. viewer.appendChild(spread);
  7623. }
  7624. spread.appendChild(pages[_i].div);
  7625. }
  7626. }
  7627. if (!pageNumber) {
  7628. return;
  7629. }
  7630. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  7631. this._setScale(this._currentScaleValue, true);
  7632. }
  7633. this._setCurrentPageNumber(pageNumber, true);
  7634. this.update();
  7635. }
  7636. }, {
  7637. key: "_getPageAdvance",
  7638. value: function _getPageAdvance(currentPageNumber) {
  7639. var previous = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7640. if (this.isInPresentationMode) {
  7641. return 1;
  7642. }
  7643. switch (this._scrollMode) {
  7644. case _ui_utils.ScrollMode.WRAPPED:
  7645. {
  7646. var _this$_getVisiblePage = this._getVisiblePages(),
  7647. views = _this$_getVisiblePage.views,
  7648. pageLayout = new Map();
  7649. var _iterator2 = _createForOfIteratorHelper(views),
  7650. _step2;
  7651. try {
  7652. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  7653. var _step2$value = _step2.value,
  7654. id = _step2$value.id,
  7655. y = _step2$value.y,
  7656. percent = _step2$value.percent,
  7657. widthPercent = _step2$value.widthPercent;
  7658. if (percent === 0 || widthPercent < 100) {
  7659. continue;
  7660. }
  7661. var yArray = pageLayout.get(y);
  7662. if (!yArray) {
  7663. pageLayout.set(y, yArray || (yArray = []));
  7664. }
  7665. yArray.push(id);
  7666. }
  7667. } catch (err) {
  7668. _iterator2.e(err);
  7669. } finally {
  7670. _iterator2.f();
  7671. }
  7672. var _iterator3 = _createForOfIteratorHelper(pageLayout.values()),
  7673. _step3;
  7674. try {
  7675. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  7676. var _yArray = _step3.value;
  7677. var currentIndex = _yArray.indexOf(currentPageNumber);
  7678. if (currentIndex === -1) {
  7679. continue;
  7680. }
  7681. var numPages = _yArray.length;
  7682. if (numPages === 1) {
  7683. break;
  7684. }
  7685. if (previous) {
  7686. for (var i = currentIndex - 1, ii = 0; i >= ii; i--) {
  7687. var currentId = _yArray[i],
  7688. expectedId = _yArray[i + 1] - 1;
  7689. if (currentId < expectedId) {
  7690. return currentPageNumber - expectedId;
  7691. }
  7692. }
  7693. } else {
  7694. for (var _i2 = currentIndex + 1, _ii = numPages; _i2 < _ii; _i2++) {
  7695. var _currentId = _yArray[_i2],
  7696. _expectedId = _yArray[_i2 - 1] + 1;
  7697. if (_currentId > _expectedId) {
  7698. return _expectedId - currentPageNumber;
  7699. }
  7700. }
  7701. }
  7702. if (previous) {
  7703. var firstId = _yArray[0];
  7704. if (firstId < currentPageNumber) {
  7705. return currentPageNumber - firstId + 1;
  7706. }
  7707. } else {
  7708. var lastId = _yArray[numPages - 1];
  7709. if (lastId > currentPageNumber) {
  7710. return lastId - currentPageNumber + 1;
  7711. }
  7712. }
  7713. break;
  7714. }
  7715. } catch (err) {
  7716. _iterator3.e(err);
  7717. } finally {
  7718. _iterator3.f();
  7719. }
  7720. break;
  7721. }
  7722. case _ui_utils.ScrollMode.HORIZONTAL:
  7723. {
  7724. break;
  7725. }
  7726. case _ui_utils.ScrollMode.VERTICAL:
  7727. {
  7728. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  7729. break;
  7730. }
  7731. var parity = this._spreadMode - 1;
  7732. if (previous && currentPageNumber % 2 !== parity) {
  7733. break;
  7734. } else if (!previous && currentPageNumber % 2 === parity) {
  7735. break;
  7736. }
  7737. var _this$_getVisiblePage2 = this._getVisiblePages(),
  7738. _views = _this$_getVisiblePage2.views,
  7739. _expectedId2 = previous ? currentPageNumber - 1 : currentPageNumber + 1;
  7740. var _iterator4 = _createForOfIteratorHelper(_views),
  7741. _step4;
  7742. try {
  7743. for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
  7744. var _step4$value = _step4.value,
  7745. _id = _step4$value.id,
  7746. _percent = _step4$value.percent,
  7747. _widthPercent = _step4$value.widthPercent;
  7748. if (_id !== _expectedId2) {
  7749. continue;
  7750. }
  7751. if (_percent > 0 && _widthPercent === 100) {
  7752. return 2;
  7753. }
  7754. break;
  7755. }
  7756. } catch (err) {
  7757. _iterator4.e(err);
  7758. } finally {
  7759. _iterator4.f();
  7760. }
  7761. break;
  7762. }
  7763. }
  7764. return 1;
  7765. }
  7766. }, {
  7767. key: "nextPage",
  7768. value: function nextPage() {
  7769. var currentPageNumber = this._currentPageNumber,
  7770. pagesCount = this.pagesCount;
  7771. if (currentPageNumber >= pagesCount) {
  7772. return false;
  7773. }
  7774. var advance = this._getPageAdvance(currentPageNumber, false) || 1;
  7775. this.currentPageNumber = Math.min(currentPageNumber + advance, pagesCount);
  7776. return true;
  7777. }
  7778. }, {
  7779. key: "previousPage",
  7780. value: function previousPage() {
  7781. var currentPageNumber = this._currentPageNumber;
  7782. if (currentPageNumber <= 1) {
  7783. return false;
  7784. }
  7785. var advance = this._getPageAdvance(currentPageNumber, true) || 1;
  7786. this.currentPageNumber = Math.max(currentPageNumber - advance, 1);
  7787. return true;
  7788. }
  7789. }]);
  7790. return BaseViewer;
  7791. }();
  7792. exports.BaseViewer = BaseViewer;
  7793. /***/ }),
  7794. /* 22 */
  7795. /***/ ((__unused_webpack_module, exports) => {
  7796. Object.defineProperty(exports, "__esModule", ({
  7797. value: true
  7798. }));
  7799. exports.StructTreeLayerBuilder = exports.DefaultStructTreeLayerFactory = void 0;
  7800. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  7801. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  7802. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  7803. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7804. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  7805. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7806. var PDF_ROLE_TO_HTML_ROLE = {
  7807. Document: null,
  7808. DocumentFragment: null,
  7809. Part: "group",
  7810. Sect: "group",
  7811. Div: "group",
  7812. Aside: "note",
  7813. NonStruct: "none",
  7814. P: null,
  7815. H: "heading",
  7816. Title: null,
  7817. FENote: "note",
  7818. Sub: "group",
  7819. Lbl: null,
  7820. Span: null,
  7821. Em: null,
  7822. Strong: null,
  7823. Link: "link",
  7824. Annot: "note",
  7825. Form: "form",
  7826. Ruby: null,
  7827. RB: null,
  7828. RT: null,
  7829. RP: null,
  7830. Warichu: null,
  7831. WT: null,
  7832. WP: null,
  7833. L: "list",
  7834. LI: "listitem",
  7835. LBody: null,
  7836. Table: "table",
  7837. TR: "row",
  7838. TH: "columnheader",
  7839. TD: "cell",
  7840. THead: "columnheader",
  7841. TBody: null,
  7842. TFoot: null,
  7843. Caption: null,
  7844. Figure: "figure",
  7845. Formula: null,
  7846. Artifact: null
  7847. };
  7848. var HEADING_PATTERN = /^H(\d+)$/;
  7849. var StructTreeLayerBuilder = /*#__PURE__*/function () {
  7850. function StructTreeLayerBuilder(_ref) {
  7851. var pdfPage = _ref.pdfPage;
  7852. _classCallCheck(this, StructTreeLayerBuilder);
  7853. this.pdfPage = pdfPage;
  7854. }
  7855. _createClass(StructTreeLayerBuilder, [{
  7856. key: "render",
  7857. value: function render(structTree) {
  7858. return this._walk(structTree);
  7859. }
  7860. }, {
  7861. key: "_setAttributes",
  7862. value: function _setAttributes(structElement, htmlElement) {
  7863. if (structElement.alt !== undefined) {
  7864. htmlElement.setAttribute("aria-label", structElement.alt);
  7865. }
  7866. if (structElement.id !== undefined) {
  7867. htmlElement.setAttribute("aria-owns", structElement.id);
  7868. }
  7869. }
  7870. }, {
  7871. key: "_walk",
  7872. value: function _walk(node) {
  7873. if (!node) {
  7874. return null;
  7875. }
  7876. var element = document.createElement("span");
  7877. if ("role" in node) {
  7878. var role = node.role;
  7879. var match = role.match(HEADING_PATTERN);
  7880. if (match) {
  7881. element.setAttribute("role", "heading");
  7882. element.setAttribute("aria-level", match[1]);
  7883. } else if (PDF_ROLE_TO_HTML_ROLE[role]) {
  7884. element.setAttribute("role", PDF_ROLE_TO_HTML_ROLE[role]);
  7885. }
  7886. }
  7887. this._setAttributes(node, element);
  7888. if (node.children) {
  7889. if (node.children.length === 1 && "id" in node.children[0]) {
  7890. this._setAttributes(node.children[0], element);
  7891. } else {
  7892. var _iterator = _createForOfIteratorHelper(node.children),
  7893. _step;
  7894. try {
  7895. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  7896. var kid = _step.value;
  7897. element.appendChild(this._walk(kid));
  7898. }
  7899. } catch (err) {
  7900. _iterator.e(err);
  7901. } finally {
  7902. _iterator.f();
  7903. }
  7904. }
  7905. }
  7906. return element;
  7907. }
  7908. }]);
  7909. return StructTreeLayerBuilder;
  7910. }();
  7911. exports.StructTreeLayerBuilder = StructTreeLayerBuilder;
  7912. var DefaultStructTreeLayerFactory = /*#__PURE__*/function () {
  7913. function DefaultStructTreeLayerFactory() {
  7914. _classCallCheck(this, DefaultStructTreeLayerFactory);
  7915. }
  7916. _createClass(DefaultStructTreeLayerFactory, [{
  7917. key: "createStructTreeLayerBuilder",
  7918. value: function createStructTreeLayerBuilder(pdfPage) {
  7919. return new StructTreeLayerBuilder({
  7920. pdfPage: pdfPage
  7921. });
  7922. }
  7923. }]);
  7924. return DefaultStructTreeLayerFactory;
  7925. }();
  7926. exports.DefaultStructTreeLayerFactory = DefaultStructTreeLayerFactory;
  7927. /***/ }),
  7928. /* 23 */
  7929. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  7930. Object.defineProperty(exports, "__esModule", ({
  7931. value: true
  7932. }));
  7933. exports.XfaLayerBuilder = exports.DefaultXfaLayerFactory = void 0;
  7934. var _pdfjsLib = __w_pdfjs_require__(2);
  7935. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7936. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  7937. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7938. var XfaLayerBuilder = /*#__PURE__*/function () {
  7939. function XfaLayerBuilder(_ref) {
  7940. var pageDiv = _ref.pageDiv,
  7941. pdfPage = _ref.pdfPage,
  7942. annotationStorage = _ref.annotationStorage;
  7943. _classCallCheck(this, XfaLayerBuilder);
  7944. this.pageDiv = pageDiv;
  7945. this.pdfPage = pdfPage;
  7946. this.annotationStorage = annotationStorage;
  7947. this.div = null;
  7948. this._cancelled = false;
  7949. }
  7950. _createClass(XfaLayerBuilder, [{
  7951. key: "render",
  7952. value: function render(viewport) {
  7953. var _this = this;
  7954. var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "display";
  7955. return this.pdfPage.getXfa().then(function (xfa) {
  7956. if (_this._cancelled) {
  7957. return;
  7958. }
  7959. var parameters = {
  7960. viewport: viewport.clone({
  7961. dontFlip: true
  7962. }),
  7963. div: _this.div,
  7964. xfa: xfa,
  7965. page: _this.pdfPage,
  7966. annotationStorage: _this.annotationStorage
  7967. };
  7968. if (_this.div) {
  7969. _pdfjsLib.XfaLayer.update(parameters);
  7970. } else {
  7971. _this.div = document.createElement("div");
  7972. _this.pageDiv.appendChild(_this.div);
  7973. parameters.div = _this.div;
  7974. _pdfjsLib.XfaLayer.render(parameters);
  7975. }
  7976. })["catch"](function (error) {
  7977. console.error(error);
  7978. });
  7979. }
  7980. }, {
  7981. key: "cancel",
  7982. value: function cancel() {
  7983. this._cancelled = true;
  7984. }
  7985. }, {
  7986. key: "hide",
  7987. value: function hide() {
  7988. if (!this.div) {
  7989. return;
  7990. }
  7991. this.div.hidden = true;
  7992. }
  7993. }]);
  7994. return XfaLayerBuilder;
  7995. }();
  7996. exports.XfaLayerBuilder = XfaLayerBuilder;
  7997. var DefaultXfaLayerFactory = /*#__PURE__*/function () {
  7998. function DefaultXfaLayerFactory() {
  7999. _classCallCheck(this, DefaultXfaLayerFactory);
  8000. }
  8001. _createClass(DefaultXfaLayerFactory, [{
  8002. key: "createXfaLayerBuilder",
  8003. value: function createXfaLayerBuilder(pageDiv, pdfPage) {
  8004. var annotationStorage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  8005. return new XfaLayerBuilder({
  8006. pageDiv: pageDiv,
  8007. pdfPage: pdfPage,
  8008. annotationStorage: annotationStorage
  8009. });
  8010. }
  8011. }]);
  8012. return DefaultXfaLayerFactory;
  8013. }();
  8014. exports.DefaultXfaLayerFactory = DefaultXfaLayerFactory;
  8015. /***/ }),
  8016. /* 24 */
  8017. /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
  8018. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  8019. Object.defineProperty(exports, "__esModule", ({
  8020. value: true
  8021. }));
  8022. exports.PDFViewer = void 0;
  8023. var _ui_utils = __w_pdfjs_require__(7);
  8024. var _base_viewer = __w_pdfjs_require__(21);
  8025. var _pdfjsLib = __w_pdfjs_require__(2);
  8026. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  8027. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  8028. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  8029. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8030. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  8031. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8032. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  8033. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  8034. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  8035. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  8036. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  8037. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  8038. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  8039. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  8040. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  8041. var PDFViewer = /*#__PURE__*/function (_BaseViewer) {
  8042. _inherits(PDFViewer, _BaseViewer);
  8043. var _super = _createSuper(PDFViewer);
  8044. function PDFViewer() {
  8045. _classCallCheck(this, PDFViewer);
  8046. return _super.apply(this, arguments);
  8047. }
  8048. _createClass(PDFViewer, [{
  8049. key: "_viewerElement",
  8050. get: function get() {
  8051. return (0, _pdfjsLib.shadow)(this, "_viewerElement", this.viewer);
  8052. }
  8053. }, {
  8054. key: "_scrollIntoView",
  8055. value: function _scrollIntoView(_ref) {
  8056. var pageDiv = _ref.pageDiv,
  8057. _ref$pageSpot = _ref.pageSpot,
  8058. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  8059. _ref$pageNumber = _ref.pageNumber,
  8060. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  8061. if (!pageSpot && !this.isInPresentationMode) {
  8062. var left = pageDiv.offsetLeft + pageDiv.clientLeft;
  8063. var right = left + pageDiv.clientWidth;
  8064. var _this$container = this.container,
  8065. scrollLeft = _this$container.scrollLeft,
  8066. clientWidth = _this$container.clientWidth;
  8067. if (this._isScrollModeHorizontal || left < scrollLeft || right > scrollLeft + clientWidth) {
  8068. pageSpot = {
  8069. left: 0,
  8070. top: 0
  8071. };
  8072. }
  8073. }
  8074. _get(_getPrototypeOf(PDFViewer.prototype), "_scrollIntoView", this).call(this, {
  8075. pageDiv: pageDiv,
  8076. pageSpot: pageSpot,
  8077. pageNumber: pageNumber
  8078. });
  8079. }
  8080. }, {
  8081. key: "_getVisiblePages",
  8082. value: function _getVisiblePages() {
  8083. if (this.isInPresentationMode) {
  8084. return this._getCurrentVisiblePage();
  8085. }
  8086. return _get(_getPrototypeOf(PDFViewer.prototype), "_getVisiblePages", this).call(this);
  8087. }
  8088. }, {
  8089. key: "_updateHelper",
  8090. value: function _updateHelper(visiblePages) {
  8091. if (this.isInPresentationMode) {
  8092. return;
  8093. }
  8094. var currentId = this._currentPageNumber;
  8095. var stillFullyVisible = false;
  8096. var _iterator = _createForOfIteratorHelper(visiblePages),
  8097. _step;
  8098. try {
  8099. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  8100. var page = _step.value;
  8101. if (page.percent < 100) {
  8102. break;
  8103. }
  8104. if (page.id === currentId && this._scrollMode === _ui_utils.ScrollMode.VERTICAL && this._spreadMode === _ui_utils.SpreadMode.NONE) {
  8105. stillFullyVisible = true;
  8106. break;
  8107. }
  8108. }
  8109. } catch (err) {
  8110. _iterator.e(err);
  8111. } finally {
  8112. _iterator.f();
  8113. }
  8114. if (!stillFullyVisible) {
  8115. currentId = visiblePages[0].id;
  8116. }
  8117. this._setCurrentPageNumber(currentId);
  8118. }
  8119. }]);
  8120. return PDFViewer;
  8121. }(_base_viewer.BaseViewer);
  8122. exports.PDFViewer = PDFViewer;
  8123. /***/ })
  8124. /******/ ]);
  8125. /************************************************************************/
  8126. /******/ // The module cache
  8127. /******/ var __webpack_module_cache__ = {};
  8128. /******/
  8129. /******/ // The require function
  8130. /******/ function __w_pdfjs_require__(moduleId) {
  8131. /******/ // Check if module is in cache
  8132. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  8133. /******/ if (cachedModule !== undefined) {
  8134. /******/ return cachedModule.exports;
  8135. /******/ }
  8136. /******/ // Create a new module (and put it into the cache)
  8137. /******/ var module = __webpack_module_cache__[moduleId] = {
  8138. /******/ id: moduleId,
  8139. /******/ loaded: false,
  8140. /******/ exports: {}
  8141. /******/ };
  8142. /******/
  8143. /******/ // Execute the module function
  8144. /******/ __webpack_modules__[moduleId](module, module.exports, __w_pdfjs_require__);
  8145. /******/
  8146. /******/ // Flag the module as loaded
  8147. /******/ module.loaded = true;
  8148. /******/
  8149. /******/ // Return the exports of the module
  8150. /******/ return module.exports;
  8151. /******/ }
  8152. /******/
  8153. /************************************************************************/
  8154. /******/ /* webpack/runtime/node module decorator */
  8155. /******/ (() => {
  8156. /******/ __w_pdfjs_require__.nmd = (module) => {
  8157. /******/ module.paths = [];
  8158. /******/ if (!module.children) module.children = [];
  8159. /******/ return module;
  8160. /******/ };
  8161. /******/ })();
  8162. /******/
  8163. /************************************************************************/
  8164. var __webpack_exports__ = {};
  8165. // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
  8166. (() => {
  8167. var exports = __webpack_exports__;
  8168. Object.defineProperty(exports, "__esModule", ({
  8169. value: true
  8170. }));
  8171. Object.defineProperty(exports, "AnnotationLayerBuilder", ({
  8172. enumerable: true,
  8173. get: function get() {
  8174. return _annotation_layer_builder.AnnotationLayerBuilder;
  8175. }
  8176. }));
  8177. Object.defineProperty(exports, "DefaultAnnotationLayerFactory", ({
  8178. enumerable: true,
  8179. get: function get() {
  8180. return _annotation_layer_builder.DefaultAnnotationLayerFactory;
  8181. }
  8182. }));
  8183. Object.defineProperty(exports, "DefaultTextLayerFactory", ({
  8184. enumerable: true,
  8185. get: function get() {
  8186. return _text_layer_builder.DefaultTextLayerFactory;
  8187. }
  8188. }));
  8189. Object.defineProperty(exports, "TextLayerBuilder", ({
  8190. enumerable: true,
  8191. get: function get() {
  8192. return _text_layer_builder.TextLayerBuilder;
  8193. }
  8194. }));
  8195. Object.defineProperty(exports, "EventBus", ({
  8196. enumerable: true,
  8197. get: function get() {
  8198. return _ui_utils.EventBus;
  8199. }
  8200. }));
  8201. Object.defineProperty(exports, "ProgressBar", ({
  8202. enumerable: true,
  8203. get: function get() {
  8204. return _ui_utils.ProgressBar;
  8205. }
  8206. }));
  8207. Object.defineProperty(exports, "PDFLinkService", ({
  8208. enumerable: true,
  8209. get: function get() {
  8210. return _pdf_link_service.PDFLinkService;
  8211. }
  8212. }));
  8213. Object.defineProperty(exports, "SimpleLinkService", ({
  8214. enumerable: true,
  8215. get: function get() {
  8216. return _pdf_link_service.SimpleLinkService;
  8217. }
  8218. }));
  8219. Object.defineProperty(exports, "DownloadManager", ({
  8220. enumerable: true,
  8221. get: function get() {
  8222. return _download_manager.DownloadManager;
  8223. }
  8224. }));
  8225. Object.defineProperty(exports, "GenericL10n", ({
  8226. enumerable: true,
  8227. get: function get() {
  8228. return _genericl10n.GenericL10n;
  8229. }
  8230. }));
  8231. Object.defineProperty(exports, "NullL10n", ({
  8232. enumerable: true,
  8233. get: function get() {
  8234. return _l10n_utils.NullL10n;
  8235. }
  8236. }));
  8237. Object.defineProperty(exports, "PDFFindController", ({
  8238. enumerable: true,
  8239. get: function get() {
  8240. return _pdf_find_controller.PDFFindController;
  8241. }
  8242. }));
  8243. Object.defineProperty(exports, "PDFHistory", ({
  8244. enumerable: true,
  8245. get: function get() {
  8246. return _pdf_history.PDFHistory;
  8247. }
  8248. }));
  8249. Object.defineProperty(exports, "PDFPageView", ({
  8250. enumerable: true,
  8251. get: function get() {
  8252. return _pdf_page_view.PDFPageView;
  8253. }
  8254. }));
  8255. Object.defineProperty(exports, "PDFScriptingManager", ({
  8256. enumerable: true,
  8257. get: function get() {
  8258. return _pdf_scripting_manager.PDFScriptingManager;
  8259. }
  8260. }));
  8261. Object.defineProperty(exports, "PDFSinglePageViewer", ({
  8262. enumerable: true,
  8263. get: function get() {
  8264. return _pdf_single_page_viewer.PDFSinglePageViewer;
  8265. }
  8266. }));
  8267. Object.defineProperty(exports, "PDFViewer", ({
  8268. enumerable: true,
  8269. get: function get() {
  8270. return _pdf_viewer.PDFViewer;
  8271. }
  8272. }));
  8273. var _annotation_layer_builder = __w_pdfjs_require__(1);
  8274. var _text_layer_builder = __w_pdfjs_require__(8);
  8275. var _ui_utils = __w_pdfjs_require__(7);
  8276. var _pdf_link_service = __w_pdfjs_require__(6);
  8277. var _download_manager = __w_pdfjs_require__(9);
  8278. var _genericl10n = __w_pdfjs_require__(11);
  8279. var _l10n_utils = __w_pdfjs_require__(3);
  8280. var _pdf_find_controller = __w_pdfjs_require__(13);
  8281. var _pdf_history = __w_pdfjs_require__(15);
  8282. var _pdf_page_view = __w_pdfjs_require__(16);
  8283. var _pdf_scripting_manager = __w_pdfjs_require__(18);
  8284. var _pdf_single_page_viewer = __w_pdfjs_require__(20);
  8285. var _pdf_viewer = __w_pdfjs_require__(24);
  8286. var pdfjsVersion = '2.9.359';
  8287. var pdfjsBuild = 'e667c8cbc';
  8288. })();
  8289. /******/ return __webpack_exports__;
  8290. /******/ })()
  8291. ;
  8292. });
  8293. //# sourceMappingURL=pdf_viewer.js.map