2
0

pdf_viewer.js 201 KB

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