pdf_viewer.js 225 KB

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