2
0

pdf_viewer.js 258 KB

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