pdf_viewer.js 208 KB

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