pdf_viewer.js 207 KB

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