2
0

pdf_viewer.js 264 KB

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