pdf_viewer.js 208 KB

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