viewer.js 624 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * JavaScript code in this page
  4. *
  5. * Copyright 2023 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. /******/ (() => { // webpackBootstrap
  23. /******/ "use strict";
  24. /******/ var __webpack_modules__ = ([
  25. /* 0 */,
  26. /* 1 */
  27. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  28. Object.defineProperty(exports, "__esModule", ({
  29. value: true
  30. }));
  31. exports.GenericCom = void 0;
  32. var _app = __webpack_require__(2);
  33. var _preferences = __webpack_require__(43);
  34. var _download_manager = __webpack_require__(44);
  35. var _genericl10n = __webpack_require__(45);
  36. var _generic_scripting = __webpack_require__(47);
  37. ;
  38. const GenericCom = {};
  39. exports.GenericCom = GenericCom;
  40. class GenericPreferences extends _preferences.BasePreferences {
  41. async _writeToStorage(prefObj) {
  42. localStorage.setItem("pdfjs.preferences", JSON.stringify(prefObj));
  43. }
  44. async _readFromStorage(prefObj) {
  45. return JSON.parse(localStorage.getItem("pdfjs.preferences"));
  46. }
  47. }
  48. class GenericExternalServices extends _app.DefaultExternalServices {
  49. static createDownloadManager() {
  50. return new _download_manager.DownloadManager();
  51. }
  52. static createPreferences() {
  53. return new GenericPreferences();
  54. }
  55. static createL10n(_ref) {
  56. let {
  57. locale = "en-US"
  58. } = _ref;
  59. return new _genericl10n.GenericL10n(locale);
  60. }
  61. static createScripting(_ref2) {
  62. let {
  63. sandboxBundleSrc
  64. } = _ref2;
  65. return new _generic_scripting.GenericScripting(sandboxBundleSrc);
  66. }
  67. }
  68. _app.PDFViewerApplication.externalServices = GenericExternalServices;
  69. /***/
  70. }),
  71. /* 2 */
  72. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  73. Object.defineProperty(exports, "__esModule", ({
  74. value: true
  75. }));
  76. exports.PDFViewerApplication = exports.PDFPrintServiceFactory = exports.DefaultExternalServices = void 0;
  77. var _ui_utils = __webpack_require__(3);
  78. var _pdfjsLib = __webpack_require__(4);
  79. var _app_options = __webpack_require__(5);
  80. var _event_utils = __webpack_require__(6);
  81. var _pdf_link_service = __webpack_require__(7);
  82. var _webAnnotation_editor_params = __webpack_require__(8);
  83. var _overlay_manager = __webpack_require__(9);
  84. var _password_prompt = __webpack_require__(11);
  85. var _webPdf_attachment_viewer = __webpack_require__(12);
  86. var _webPdf_cursor_tools = __webpack_require__(14);
  87. var _webPdf_document_properties = __webpack_require__(16);
  88. var _webPdf_find_bar = __webpack_require__(17);
  89. var _pdf_find_controller = __webpack_require__(18);
  90. var _pdf_history = __webpack_require__(20);
  91. var _webPdf_layer_viewer = __webpack_require__(21);
  92. var _webPdf_outline_viewer = __webpack_require__(22);
  93. var _webPdf_presentation_mode = __webpack_require__(23);
  94. var _pdf_rendering_queue = __webpack_require__(24);
  95. var _pdf_scripting_manager = __webpack_require__(25);
  96. var _webPdf_sidebar = __webpack_require__(26);
  97. var _webPdf_sidebar_resizer = __webpack_require__(27);
  98. var _webPdf_thumbnail_viewer = __webpack_require__(28);
  99. var _pdf_viewer = __webpack_require__(30);
  100. var _webSecondary_toolbar = __webpack_require__(40);
  101. var _webToolbar = __webpack_require__(41);
  102. var _view_history = __webpack_require__(42);
  103. const FORCE_PAGES_LOADED_TIMEOUT = 10000;
  104. const WHEEL_ZOOM_DISABLED_TIMEOUT = 1000;
  105. const ViewOnLoad = {
  106. UNKNOWN: -1,
  107. PREVIOUS: 0,
  108. INITIAL: 1
  109. };
  110. const ViewerCssTheme = {
  111. AUTOMATIC: 0,
  112. LIGHT: 1,
  113. DARK: 2
  114. };
  115. class DefaultExternalServices {
  116. constructor() {
  117. throw new Error("Cannot initialize DefaultExternalServices.");
  118. }
  119. static updateFindControlState(data) { }
  120. static updateFindMatchesCount(data) { }
  121. static initPassiveLoading(callbacks) { }
  122. static reportTelemetry(data) { }
  123. static createDownloadManager() {
  124. throw new Error("Not implemented: createDownloadManager");
  125. }
  126. static createPreferences() {
  127. throw new Error("Not implemented: createPreferences");
  128. }
  129. static createL10n(options) {
  130. throw new Error("Not implemented: createL10n");
  131. }
  132. static createScripting(options) {
  133. throw new Error("Not implemented: createScripting");
  134. }
  135. static get supportsPinchToZoom() {
  136. return (0, _pdfjsLib.shadow)(this, "supportsPinchToZoom", true);
  137. }
  138. static get supportsIntegratedFind() {
  139. return (0, _pdfjsLib.shadow)(this, "supportsIntegratedFind", false);
  140. }
  141. static get supportsDocumentFonts() {
  142. return (0, _pdfjsLib.shadow)(this, "supportsDocumentFonts", true);
  143. }
  144. static get supportedMouseWheelZoomModifierKeys() {
  145. return (0, _pdfjsLib.shadow)(this, "supportedMouseWheelZoomModifierKeys", {
  146. ctrlKey: true,
  147. metaKey: true
  148. });
  149. }
  150. static get isInAutomation() {
  151. return (0, _pdfjsLib.shadow)(this, "isInAutomation", false);
  152. }
  153. static updateEditorStates(data) {
  154. throw new Error("Not implemented: updateEditorStates");
  155. }
  156. }
  157. exports.DefaultExternalServices = DefaultExternalServices;
  158. const PDFViewerApplication = {
  159. initialBookmark: document.location.hash.substring(1),
  160. _initializedCapability: (0, _pdfjsLib.createPromiseCapability)(),
  161. appConfig: null,
  162. pdfDocument: null,
  163. pdfLoadingTask: null,
  164. printService: null,
  165. pdfViewer: null,
  166. pdfThumbnailViewer: null,
  167. pdfRenderingQueue: null,
  168. pdfPresentationMode: null,
  169. pdfDocumentProperties: null,
  170. pdfLinkService: null,
  171. pdfHistory: null,
  172. pdfSidebar: null,
  173. pdfSidebarResizer: null,
  174. pdfOutlineViewer: null,
  175. pdfAttachmentViewer: null,
  176. pdfLayerViewer: null,
  177. pdfCursorTools: null,
  178. pdfScriptingManager: null,
  179. store: null,
  180. downloadManager: null,
  181. overlayManager: null,
  182. preferences: null,
  183. toolbar: null,
  184. secondaryToolbar: null,
  185. eventBus: null,
  186. l10n: null,
  187. annotationEditorParams: null,
  188. isInitialViewSet: false,
  189. downloadComplete: false,
  190. isViewerEmbedded: window.parent !== window,
  191. url: "",
  192. baseUrl: "",
  193. _downloadUrl: "",
  194. externalServices: DefaultExternalServices,
  195. _boundEvents: Object.create(null),
  196. documentInfo: null,
  197. metadata: null,
  198. _contentDispositionFilename: null,
  199. _contentLength: null,
  200. _saveInProgress: false,
  201. _wheelUnusedTicks: 0,
  202. _wheelUnusedFactor: 1,
  203. _touchUnusedTicks: 0,
  204. _touchUnusedFactor: 1,
  205. _PDFBug: null,
  206. _hasAnnotationEditors: false,
  207. _title: document.title,
  208. _printAnnotationStoragePromise: null,
  209. _touchInfo: null,
  210. _isCtrlKeyDown: false,
  211. async initialize(appConfig) {
  212. this.preferences = this.externalServices.createPreferences();
  213. this.appConfig = appConfig;
  214. await this._initializeOptions();
  215. this._forceCssTheme();
  216. await this._initializeL10n();
  217. if (this.isViewerEmbedded && _app_options.AppOptions.get("externalLinkTarget") === _pdf_link_service.LinkTarget.NONE) {
  218. _app_options.AppOptions.set("externalLinkTarget", _pdf_link_service.LinkTarget.TOP);
  219. }
  220. await this._initializeViewerComponents();
  221. this.bindEvents();
  222. this.bindWindowEvents();
  223. const appContainer = appConfig.appContainer || document.documentElement;
  224. this.l10n.translate(appContainer).then(() => {
  225. this.eventBus.dispatch("localized", {
  226. source: this
  227. });
  228. });
  229. this._initializedCapability.resolve();
  230. },
  231. async _initializeOptions() {
  232. if (_app_options.AppOptions.get("disablePreferences")) {
  233. if (_app_options.AppOptions.get("pdfBugEnabled")) {
  234. await this._parseHashParams();
  235. }
  236. return;
  237. }
  238. if (_app_options.AppOptions._hasUserOptions()) {
  239. console.warn("_initializeOptions: The Preferences may override manually set AppOptions; " + 'please use the "disablePreferences"-option in order to prevent that.');
  240. }
  241. try {
  242. _app_options.AppOptions.setAll(await this.preferences.getAll());
  243. } catch (reason) {
  244. console.error(`_initializeOptions: "${reason.message}".`);
  245. }
  246. if (_app_options.AppOptions.get("pdfBugEnabled")) {
  247. await this._parseHashParams();
  248. }
  249. },
  250. async _parseHashParams() {
  251. const hash = document.location.hash.substring(1);
  252. if (!hash) {
  253. return;
  254. }
  255. const {
  256. mainContainer,
  257. viewerContainer
  258. } = this.appConfig,
  259. params = (0, _ui_utils.parseQueryString)(hash);
  260. if (params.get("disableworker") === "true") {
  261. try {
  262. await loadFakeWorker();
  263. } catch (ex) {
  264. console.error(`_parseHashParams: "${ex.message}".`);
  265. }
  266. }
  267. if (params.has("disablerange")) {
  268. _app_options.AppOptions.set("disableRange", params.get("disablerange") === "true");
  269. }
  270. if (params.has("disablestream")) {
  271. _app_options.AppOptions.set("disableStream", params.get("disablestream") === "true");
  272. }
  273. if (params.has("disableautofetch")) {
  274. _app_options.AppOptions.set("disableAutoFetch", params.get("disableautofetch") === "true");
  275. }
  276. if (params.has("disablefontface")) {
  277. _app_options.AppOptions.set("disableFontFace", params.get("disablefontface") === "true");
  278. }
  279. if (params.has("disablehistory")) {
  280. _app_options.AppOptions.set("disableHistory", params.get("disablehistory") === "true");
  281. }
  282. if (params.has("verbosity")) {
  283. _app_options.AppOptions.set("verbosity", params.get("verbosity") | 0);
  284. }
  285. if (params.has("textlayer")) {
  286. switch (params.get("textlayer")) {
  287. case "off":
  288. _app_options.AppOptions.set("textLayerMode", _ui_utils.TextLayerMode.DISABLE);
  289. break;
  290. case "visible":
  291. case "shadow":
  292. case "hover":
  293. viewerContainer.classList.add(`textLayer-${params.get("textlayer")}`);
  294. try {
  295. await loadPDFBug(this);
  296. this._PDFBug.loadCSS();
  297. } catch (ex) {
  298. console.error(`_parseHashParams: "${ex.message}".`);
  299. }
  300. break;
  301. }
  302. }
  303. if (params.has("pdfbug")) {
  304. _app_options.AppOptions.set("pdfBug", true);
  305. _app_options.AppOptions.set("fontExtraProperties", true);
  306. const enabled = params.get("pdfbug").split(",");
  307. try {
  308. await loadPDFBug(this);
  309. this._PDFBug.init({
  310. OPS: _pdfjsLib.OPS
  311. }, mainContainer, enabled);
  312. } catch (ex) {
  313. console.error(`_parseHashParams: "${ex.message}".`);
  314. }
  315. }
  316. if (params.has("locale")) {
  317. _app_options.AppOptions.set("locale", params.get("locale"));
  318. }
  319. },
  320. async _initializeL10n() {
  321. this.l10n = this.externalServices.createL10n({
  322. locale: _app_options.AppOptions.get("locale")
  323. });
  324. const dir = await this.l10n.getDirection();
  325. document.getElementsByTagName("html")[0].dir = dir;
  326. },
  327. _forceCssTheme() {
  328. const cssTheme = _app_options.AppOptions.get("viewerCssTheme");
  329. if (cssTheme === ViewerCssTheme.AUTOMATIC || !Object.values(ViewerCssTheme).includes(cssTheme)) {
  330. return;
  331. }
  332. try {
  333. const styleSheet = document.styleSheets[0];
  334. const cssRules = (styleSheet === null || styleSheet === void 0 ? void 0 : styleSheet.cssRules) || [];
  335. for (let i = 0, ii = cssRules.length; i < ii; i++) {
  336. var _rule$media;
  337. const rule = cssRules[i];
  338. if (rule instanceof CSSMediaRule && ((_rule$media = rule.media) === null || _rule$media === void 0 ? void 0 : _rule$media[0]) === "(prefers-color-scheme: dark)") {
  339. if (cssTheme === ViewerCssTheme.LIGHT) {
  340. styleSheet.deleteRule(i);
  341. return;
  342. }
  343. const darkRules = /^@media \(prefers-color-scheme: dark\) {\n\s*([\w\s-.,:;/\\{}()]+)\n}$/.exec(rule.cssText);
  344. if (darkRules !== null && darkRules !== void 0 && darkRules[1]) {
  345. styleSheet.deleteRule(i);
  346. styleSheet.insertRule(darkRules[1], i);
  347. }
  348. return;
  349. }
  350. }
  351. } catch (reason) {
  352. console.error(`_forceCssTheme: "${reason === null || reason === void 0 ? void 0 : reason.message}".`);
  353. }
  354. },
  355. async _initializeViewerComponents() {
  356. var _appConfig$sidebar, _appConfig$secondaryT, _appConfig$secondaryT2, _appConfig$sidebar2, _appConfig$sidebar3, _appConfig$sidebar4;
  357. const {
  358. appConfig,
  359. externalServices
  360. } = this;
  361. const eventBus = externalServices.isInAutomation ? new _event_utils.AutomationEventBus() : new _event_utils.EventBus();
  362. this.eventBus = eventBus;
  363. this.overlayManager = new _overlay_manager.OverlayManager();
  364. const pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  365. pdfRenderingQueue.onIdle = this._cleanup.bind(this);
  366. this.pdfRenderingQueue = pdfRenderingQueue;
  367. const pdfLinkService = new _pdf_link_service.PDFLinkService({
  368. eventBus,
  369. externalLinkTarget: _app_options.AppOptions.get("externalLinkTarget"),
  370. externalLinkRel: _app_options.AppOptions.get("externalLinkRel"),
  371. ignoreDestinationZoom: _app_options.AppOptions.get("ignoreDestinationZoom")
  372. });
  373. this.pdfLinkService = pdfLinkService;
  374. const downloadManager = externalServices.createDownloadManager();
  375. this.downloadManager = downloadManager;
  376. const findController = new _pdf_find_controller.PDFFindController({
  377. linkService: pdfLinkService,
  378. eventBus,
  379. updateMatchesCountOnProgress: true
  380. });
  381. this.findController = findController;
  382. const pdfScriptingManager = new _pdf_scripting_manager.PDFScriptingManager({
  383. eventBus,
  384. sandboxBundleSrc: _app_options.AppOptions.get("sandboxBundleSrc"),
  385. scriptingFactory: externalServices,
  386. docPropertiesLookup: this._scriptingDocProperties.bind(this)
  387. });
  388. this.pdfScriptingManager = pdfScriptingManager;
  389. const container = appConfig.mainContainer,
  390. viewer = appConfig.viewerContainer;
  391. const annotationEditorMode = _app_options.AppOptions.get("annotationEditorMode");
  392. const pageColors = _app_options.AppOptions.get("forcePageColors") || window.matchMedia("(forced-colors: active)").matches ? {
  393. background: _app_options.AppOptions.get("pageColorsBackground"),
  394. foreground: _app_options.AppOptions.get("pageColorsForeground")
  395. } : null;
  396. this.pdfViewer = new _pdf_viewer.PDFViewer({
  397. container,
  398. viewer,
  399. eventBus,
  400. renderingQueue: pdfRenderingQueue,
  401. linkService: pdfLinkService,
  402. downloadManager,
  403. findController,
  404. scriptingManager: _app_options.AppOptions.get("enableScripting") && pdfScriptingManager,
  405. renderer: _app_options.AppOptions.get("renderer"),
  406. l10n: this.l10n,
  407. textLayerMode: _app_options.AppOptions.get("textLayerMode"),
  408. annotationMode: _app_options.AppOptions.get("annotationMode"),
  409. annotationEditorMode,
  410. imageResourcesPath: _app_options.AppOptions.get("imageResourcesPath"),
  411. enablePrintAutoRotate: _app_options.AppOptions.get("enablePrintAutoRotate"),
  412. useOnlyCssZoom: _app_options.AppOptions.get("useOnlyCssZoom"),
  413. isOffscreenCanvasSupported: _app_options.AppOptions.get("isOffscreenCanvasSupported"),
  414. maxCanvasPixels: _app_options.AppOptions.get("maxCanvasPixels"),
  415. enablePermissions: _app_options.AppOptions.get("enablePermissions"),
  416. pageColors
  417. });
  418. pdfRenderingQueue.setViewer(this.pdfViewer);
  419. pdfLinkService.setViewer(this.pdfViewer);
  420. pdfScriptingManager.setViewer(this.pdfViewer);
  421. if ((_appConfig$sidebar = appConfig.sidebar) !== null && _appConfig$sidebar !== void 0 && _appConfig$sidebar.thumbnailView) {
  422. this.pdfThumbnailViewer = new _webPdf_thumbnail_viewer.PDFThumbnailViewer({
  423. container: appConfig.sidebar.thumbnailView,
  424. renderingQueue: pdfRenderingQueue,
  425. linkService: pdfLinkService,
  426. l10n: this.l10n,
  427. pageColors
  428. });
  429. pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer);
  430. }
  431. if (!this.isViewerEmbedded && !_app_options.AppOptions.get("disableHistory")) {
  432. this.pdfHistory = new _pdf_history.PDFHistory({
  433. linkService: pdfLinkService,
  434. eventBus
  435. });
  436. pdfLinkService.setHistory(this.pdfHistory);
  437. }
  438. if (!this.supportsIntegratedFind && appConfig.findBar) {
  439. this.findBar = new _webPdf_find_bar.PDFFindBar(appConfig.findBar, eventBus, this.l10n);
  440. }
  441. if (appConfig.annotationEditorParams) {
  442. if (annotationEditorMode !== _pdfjsLib.AnnotationEditorType.DISABLE) {
  443. this.annotationEditorParams = new _webAnnotation_editor_params.AnnotationEditorParams(appConfig.annotationEditorParams, eventBus);
  444. } else {
  445. for (const id of ["editorModeButtons", "editorModeSeparator"]) {
  446. var _document$getElementB;
  447. (_document$getElementB = document.getElementById(id)) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.classList.add("hidden");
  448. }
  449. }
  450. }
  451. if (appConfig.documentProperties) {
  452. this.pdfDocumentProperties = new _webPdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, this.overlayManager, eventBus, this.l10n, () => {
  453. return this._docFilename;
  454. });
  455. }
  456. if ((_appConfig$secondaryT = appConfig.secondaryToolbar) !== null && _appConfig$secondaryT !== void 0 && _appConfig$secondaryT.cursorHandToolButton) {
  457. this.pdfCursorTools = new _webPdf_cursor_tools.PDFCursorTools({
  458. container,
  459. eventBus,
  460. cursorToolOnLoad: _app_options.AppOptions.get("cursorToolOnLoad")
  461. });
  462. }
  463. if (appConfig.toolbar) {
  464. this.toolbar = new _webToolbar.Toolbar(appConfig.toolbar, eventBus, this.l10n);
  465. }
  466. if (appConfig.secondaryToolbar) {
  467. this.secondaryToolbar = new _webSecondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, eventBus, this.externalServices);
  468. }
  469. if (this.supportsFullscreen && (_appConfig$secondaryT2 = appConfig.secondaryToolbar) !== null && _appConfig$secondaryT2 !== void 0 && _appConfig$secondaryT2.presentationModeButton) {
  470. this.pdfPresentationMode = new _webPdf_presentation_mode.PDFPresentationMode({
  471. container,
  472. pdfViewer: this.pdfViewer,
  473. eventBus
  474. });
  475. }
  476. if (appConfig.passwordOverlay) {
  477. this.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, this.overlayManager, this.l10n, this.isViewerEmbedded);
  478. }
  479. if ((_appConfig$sidebar2 = appConfig.sidebar) !== null && _appConfig$sidebar2 !== void 0 && _appConfig$sidebar2.outlineView) {
  480. this.pdfOutlineViewer = new _webPdf_outline_viewer.PDFOutlineViewer({
  481. container: appConfig.sidebar.outlineView,
  482. eventBus,
  483. linkService: pdfLinkService,
  484. downloadManager
  485. });
  486. }
  487. if ((_appConfig$sidebar3 = appConfig.sidebar) !== null && _appConfig$sidebar3 !== void 0 && _appConfig$sidebar3.attachmentsView) {
  488. this.pdfAttachmentViewer = new _webPdf_attachment_viewer.PDFAttachmentViewer({
  489. container: appConfig.sidebar.attachmentsView,
  490. eventBus,
  491. downloadManager
  492. });
  493. }
  494. if ((_appConfig$sidebar4 = appConfig.sidebar) !== null && _appConfig$sidebar4 !== void 0 && _appConfig$sidebar4.layersView) {
  495. this.pdfLayerViewer = new _webPdf_layer_viewer.PDFLayerViewer({
  496. container: appConfig.sidebar.layersView,
  497. eventBus,
  498. l10n: this.l10n
  499. });
  500. }
  501. if (appConfig.sidebar) {
  502. this.pdfSidebar = new _webPdf_sidebar.PDFSidebar({
  503. elements: appConfig.sidebar,
  504. pdfViewer: this.pdfViewer,
  505. pdfThumbnailViewer: this.pdfThumbnailViewer,
  506. eventBus,
  507. l10n: this.l10n
  508. });
  509. this.pdfSidebar.onToggled = this.forceRendering.bind(this);
  510. this.pdfSidebarResizer = new _webPdf_sidebar_resizer.PDFSidebarResizer(appConfig.sidebarResizer, eventBus, this.l10n);
  511. }
  512. },
  513. run(config) {
  514. this.initialize(config).then(webViewerInitialized);
  515. },
  516. get initialized() {
  517. return this._initializedCapability.settled;
  518. },
  519. get initializedPromise() {
  520. return this._initializedCapability.promise;
  521. },
  522. zoomIn(steps, scaleFactor) {
  523. if (this.pdfViewer.isInPresentationMode) {
  524. return;
  525. }
  526. this.pdfViewer.increaseScale({
  527. drawingDelay: _app_options.AppOptions.get("defaultZoomDelay"),
  528. steps,
  529. scaleFactor
  530. });
  531. },
  532. zoomOut(steps, scaleFactor) {
  533. if (this.pdfViewer.isInPresentationMode) {
  534. return;
  535. }
  536. this.pdfViewer.decreaseScale({
  537. drawingDelay: _app_options.AppOptions.get("defaultZoomDelay"),
  538. steps,
  539. scaleFactor
  540. });
  541. },
  542. zoomReset() {
  543. if (this.pdfViewer.isInPresentationMode) {
  544. return;
  545. }
  546. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  547. },
  548. get pagesCount() {
  549. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  550. },
  551. get page() {
  552. return this.pdfViewer.currentPageNumber;
  553. },
  554. set page(val) {
  555. this.pdfViewer.currentPageNumber = val;
  556. },
  557. get supportsPrinting() {
  558. return PDFPrintServiceFactory.instance.supportsPrinting;
  559. },
  560. get supportsFullscreen() {
  561. return (0, _pdfjsLib.shadow)(this, "supportsFullscreen", document.fullscreenEnabled);
  562. },
  563. get supportsPinchToZoom() {
  564. return this.externalServices.supportsPinchToZoom;
  565. },
  566. get supportsIntegratedFind() {
  567. return this.externalServices.supportsIntegratedFind;
  568. },
  569. get supportsDocumentFonts() {
  570. return this.externalServices.supportsDocumentFonts;
  571. },
  572. get loadingBar() {
  573. const barElement = document.getElementById("loadingBar");
  574. const bar = barElement ? new _ui_utils.ProgressBar(barElement) : null;
  575. return (0, _pdfjsLib.shadow)(this, "loadingBar", bar);
  576. },
  577. get supportedMouseWheelZoomModifierKeys() {
  578. return this.externalServices.supportedMouseWheelZoomModifierKeys;
  579. },
  580. initPassiveLoading() {
  581. throw new Error("Not implemented: initPassiveLoading");
  582. },
  583. setTitleUsingUrl() {
  584. let url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
  585. let downloadUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  586. this.url = url;
  587. this.baseUrl = url.split("#")[0];
  588. if (downloadUrl) {
  589. this._downloadUrl = downloadUrl === url ? this.baseUrl : downloadUrl.split("#")[0];
  590. }
  591. if ((0, _pdfjsLib.isDataScheme)(url)) {
  592. this._hideViewBookmark();
  593. }
  594. let title = (0, _pdfjsLib.getPdfFilenameFromUrl)(url, "");
  595. if (!title) {
  596. try {
  597. title = decodeURIComponent((0, _pdfjsLib.getFilenameFromUrl)(url)) || url;
  598. } catch (ex) {
  599. title = url;
  600. }
  601. }
  602. this.setTitle(title);
  603. },
  604. setTitle() {
  605. let title = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this._title;
  606. this._title = title;
  607. if (this.isViewerEmbedded) {
  608. return;
  609. }
  610. const editorIndicator = this._hasAnnotationEditors && !this.pdfRenderingQueue.printing;
  611. document.title = `${editorIndicator ? "* " : ""}${title}`;
  612. },
  613. get _docFilename() {
  614. return this._contentDispositionFilename || (0, _pdfjsLib.getPdfFilenameFromUrl)(this.url);
  615. },
  616. _hideViewBookmark() {
  617. const {
  618. secondaryToolbar
  619. } = this.appConfig;
  620. secondaryToolbar === null || secondaryToolbar === void 0 ? void 0 : secondaryToolbar.viewBookmarkButton.classList.add("hidden");
  621. if (secondaryToolbar !== null && secondaryToolbar !== void 0 && secondaryToolbar.presentationModeButton.classList.contains("hidden")) {
  622. var _document$getElementB2;
  623. (_document$getElementB2 = document.getElementById("viewBookmarkSeparator")) === null || _document$getElementB2 === void 0 ? void 0 : _document$getElementB2.classList.add("hidden");
  624. }
  625. },
  626. async close() {
  627. var _this$pdfDocument, _this$pdfSidebar, _this$pdfOutlineViewe, _this$pdfAttachmentVi, _this$pdfLayerViewer, _this$pdfHistory, _this$findBar, _this$toolbar, _this$secondaryToolba, _this$_PDFBug;
  628. this._unblockDocumentLoadEvent();
  629. this._hideViewBookmark();
  630. if (!this.pdfLoadingTask) {
  631. return;
  632. }
  633. if (((_this$pdfDocument = this.pdfDocument) === null || _this$pdfDocument === void 0 ? void 0 : _this$pdfDocument.annotationStorage.size) > 0 && this._annotationStorageModified) {
  634. try {
  635. await this.save();
  636. } catch (reason) { }
  637. }
  638. const promises = [];
  639. promises.push(this.pdfLoadingTask.destroy());
  640. this.pdfLoadingTask = null;
  641. if (this.pdfDocument) {
  642. var _this$pdfThumbnailVie, _this$pdfDocumentProp;
  643. this.pdfDocument = null;
  644. (_this$pdfThumbnailVie = this.pdfThumbnailViewer) === null || _this$pdfThumbnailVie === void 0 ? void 0 : _this$pdfThumbnailVie.setDocument(null);
  645. this.pdfViewer.setDocument(null);
  646. this.pdfLinkService.setDocument(null);
  647. (_this$pdfDocumentProp = this.pdfDocumentProperties) === null || _this$pdfDocumentProp === void 0 ? void 0 : _this$pdfDocumentProp.setDocument(null);
  648. }
  649. this.pdfLinkService.externalLinkEnabled = true;
  650. this.store = null;
  651. this.isInitialViewSet = false;
  652. this.downloadComplete = false;
  653. this.url = "";
  654. this.baseUrl = "";
  655. this._downloadUrl = "";
  656. this.documentInfo = null;
  657. this.metadata = null;
  658. this._contentDispositionFilename = null;
  659. this._contentLength = null;
  660. this._saveInProgress = false;
  661. this._hasAnnotationEditors = false;
  662. promises.push(this.pdfScriptingManager.destroyPromise);
  663. this.setTitle();
  664. (_this$pdfSidebar = this.pdfSidebar) === null || _this$pdfSidebar === void 0 ? void 0 : _this$pdfSidebar.reset();
  665. (_this$pdfOutlineViewe = this.pdfOutlineViewer) === null || _this$pdfOutlineViewe === void 0 ? void 0 : _this$pdfOutlineViewe.reset();
  666. (_this$pdfAttachmentVi = this.pdfAttachmentViewer) === null || _this$pdfAttachmentVi === void 0 ? void 0 : _this$pdfAttachmentVi.reset();
  667. (_this$pdfLayerViewer = this.pdfLayerViewer) === null || _this$pdfLayerViewer === void 0 ? void 0 : _this$pdfLayerViewer.reset();
  668. (_this$pdfHistory = this.pdfHistory) === null || _this$pdfHistory === void 0 ? void 0 : _this$pdfHistory.reset();
  669. (_this$findBar = this.findBar) === null || _this$findBar === void 0 ? void 0 : _this$findBar.reset();
  670. (_this$toolbar = this.toolbar) === null || _this$toolbar === void 0 ? void 0 : _this$toolbar.reset();
  671. (_this$secondaryToolba = this.secondaryToolbar) === null || _this$secondaryToolba === void 0 ? void 0 : _this$secondaryToolba.reset();
  672. (_this$_PDFBug = this._PDFBug) === null || _this$_PDFBug === void 0 ? void 0 : _this$_PDFBug.cleanup();
  673. await Promise.all(promises);
  674. },
  675. async open(args) {
  676. var _args;
  677. let deprecatedArgs = false;
  678. if (typeof args === "string") {
  679. args = {
  680. url: args
  681. };
  682. deprecatedArgs = true;
  683. } else if ((_args = args) !== null && _args !== void 0 && _args.byteLength) {
  684. args = {
  685. data: args
  686. };
  687. deprecatedArgs = true;
  688. }
  689. if (deprecatedArgs) {
  690. console.error("The `PDFViewerApplication.open` signature was updated, please use an object instead.");
  691. }
  692. if (this.pdfLoadingTask) {
  693. await this.close();
  694. }
  695. const workerParams = _app_options.AppOptions.getAll(_app_options.OptionKind.WORKER);
  696. Object.assign(_pdfjsLib.GlobalWorkerOptions, workerParams);
  697. if (args.url) {
  698. this.setTitleUsingUrl(args.originalUrl || args.url, args.url);
  699. }
  700. const apiParams = _app_options.AppOptions.getAll(_app_options.OptionKind.API);
  701. const params = {
  702. ...apiParams,
  703. ...args
  704. };
  705. const loadingTask = (0, _pdfjsLib.getDocument)(params);
  706. this.pdfLoadingTask = loadingTask;
  707. loadingTask.onPassword = (updateCallback, reason) => {
  708. if (this.isViewerEmbedded) {
  709. this._unblockDocumentLoadEvent();
  710. }
  711. this.pdfLinkService.externalLinkEnabled = false;
  712. this.passwordPrompt.setUpdateCallback(updateCallback, reason);
  713. this.passwordPrompt.open();
  714. };
  715. loadingTask.onProgress = _ref => {
  716. let {
  717. loaded,
  718. total
  719. } = _ref;
  720. this.progress(loaded / total);
  721. };
  722. return loadingTask.promise.then(pdfDocument => {
  723. this.load(pdfDocument);
  724. }, reason => {
  725. if (loadingTask !== this.pdfLoadingTask) {
  726. return undefined;
  727. }
  728. let key = "loading_error";
  729. if (reason instanceof _pdfjsLib.InvalidPDFException) {
  730. key = "invalid_file_error";
  731. } else if (reason instanceof _pdfjsLib.MissingPDFException) {
  732. key = "missing_file_error";
  733. } else if (reason instanceof _pdfjsLib.UnexpectedResponseException) {
  734. key = "unexpected_response_error";
  735. }
  736. return this.l10n.get(key).then(msg => {
  737. this._documentError(msg, {
  738. message: reason === null || reason === void 0 ? void 0 : reason.message
  739. });
  740. throw reason;
  741. });
  742. });
  743. },
  744. _ensureDownloadComplete() {
  745. if (this.pdfDocument && this.downloadComplete) {
  746. return;
  747. }
  748. throw new Error("PDF document not downloaded.");
  749. },
  750. async download() {
  751. const url = this._downloadUrl,
  752. filename = this._docFilename;
  753. try {
  754. this._ensureDownloadComplete();
  755. const data = await this.pdfDocument.getData();
  756. const blob = new Blob([data], {
  757. type: "application/pdf"
  758. });
  759. await this.downloadManager.download(blob, url, filename);
  760. } catch (reason) {
  761. await this.downloadManager.downloadUrl(url, filename);
  762. }
  763. },
  764. async save() {
  765. if (this._saveInProgress) {
  766. return;
  767. }
  768. this._saveInProgress = true;
  769. await this.pdfScriptingManager.dispatchWillSave();
  770. const url = this._downloadUrl,
  771. filename = this._docFilename;
  772. try {
  773. this._ensureDownloadComplete();
  774. const data = await this.pdfDocument.saveDocument();
  775. const blob = new Blob([data], {
  776. type: "application/pdf"
  777. });
  778. await this.downloadManager.download(blob, url, filename);
  779. } catch (reason) {
  780. console.error(`Error when saving the document: ${reason.message}`);
  781. await this.download();
  782. } finally {
  783. await this.pdfScriptingManager.dispatchDidSave();
  784. this._saveInProgress = false;
  785. }
  786. if (this._hasAnnotationEditors) {
  787. this.externalServices.reportTelemetry({
  788. type: "editing",
  789. data: {
  790. type: "save"
  791. }
  792. });
  793. }
  794. },
  795. downloadOrSave() {
  796. var _this$pdfDocument2;
  797. if (((_this$pdfDocument2 = this.pdfDocument) === null || _this$pdfDocument2 === void 0 ? void 0 : _this$pdfDocument2.annotationStorage.size) > 0) {
  798. this.save();
  799. } else {
  800. this.download();
  801. }
  802. },
  803. _documentError(message) {
  804. let moreInfo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  805. this._unblockDocumentLoadEvent();
  806. this._otherError(message, moreInfo);
  807. this.eventBus.dispatch("documenterror", {
  808. source: this,
  809. message,
  810. reason: (moreInfo === null || moreInfo === void 0 ? void 0 : moreInfo.message) ?? null
  811. });
  812. },
  813. _otherError(message) {
  814. let moreInfo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  815. const moreInfoText = [`PDF.js v${_pdfjsLib.version || "?"} (build: ${_pdfjsLib.build || "?"})`];
  816. if (moreInfo) {
  817. moreInfoText.push(`Message: ${moreInfo.message}`);
  818. if (moreInfo.stack) {
  819. moreInfoText.push(`Stack: ${moreInfo.stack}`);
  820. } else {
  821. if (moreInfo.filename) {
  822. moreInfoText.push(`File: ${moreInfo.filename}`);
  823. }
  824. if (moreInfo.lineNumber) {
  825. moreInfoText.push(`Line: ${moreInfo.lineNumber}`);
  826. }
  827. }
  828. }
  829. console.error(`${message}\n\n${moreInfoText.join("\n")}`);
  830. },
  831. progress(level) {
  832. var _this$pdfDocument3;
  833. if (!this.loadingBar || this.downloadComplete) {
  834. return;
  835. }
  836. const percent = Math.round(level * 100);
  837. if (percent <= this.loadingBar.percent) {
  838. return;
  839. }
  840. this.loadingBar.percent = percent;
  841. if (((_this$pdfDocument3 = this.pdfDocument) === null || _this$pdfDocument3 === void 0 ? void 0 : _this$pdfDocument3.loadingParams.disableAutoFetch) ?? _app_options.AppOptions.get("disableAutoFetch")) {
  842. this.loadingBar.setDisableAutoFetch();
  843. }
  844. },
  845. load(pdfDocument) {
  846. var _this$toolbar2, _this$secondaryToolba2, _this$pdfDocumentProp2, _this$pdfThumbnailVie2;
  847. this.pdfDocument = pdfDocument;
  848. pdfDocument.getDownloadInfo().then(_ref2 => {
  849. var _this$loadingBar;
  850. let {
  851. length
  852. } = _ref2;
  853. this._contentLength = length;
  854. this.downloadComplete = true;
  855. (_this$loadingBar = this.loadingBar) === null || _this$loadingBar === void 0 ? void 0 : _this$loadingBar.hide();
  856. firstPagePromise.then(() => {
  857. this.eventBus.dispatch("documentloaded", {
  858. source: this
  859. });
  860. });
  861. });
  862. const pageLayoutPromise = pdfDocument.getPageLayout().catch(function () { });
  863. const pageModePromise = pdfDocument.getPageMode().catch(function () { });
  864. const openActionPromise = pdfDocument.getOpenAction().catch(function () { });
  865. (_this$toolbar2 = this.toolbar) === null || _this$toolbar2 === void 0 ? void 0 : _this$toolbar2.setPagesCount(pdfDocument.numPages, false);
  866. (_this$secondaryToolba2 = this.secondaryToolbar) === null || _this$secondaryToolba2 === void 0 ? void 0 : _this$secondaryToolba2.setPagesCount(pdfDocument.numPages);
  867. let baseDocumentUrl;
  868. baseDocumentUrl = null;
  869. if (baseDocumentUrl && (0, _pdfjsLib.isDataScheme)(baseDocumentUrl)) {
  870. baseDocumentUrl = null;
  871. }
  872. this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
  873. (_this$pdfDocumentProp2 = this.pdfDocumentProperties) === null || _this$pdfDocumentProp2 === void 0 ? void 0 : _this$pdfDocumentProp2.setDocument(pdfDocument);
  874. const pdfViewer = this.pdfViewer;
  875. pdfViewer.setDocument(pdfDocument);
  876. const {
  877. firstPagePromise,
  878. onePageRendered,
  879. pagesPromise
  880. } = pdfViewer;
  881. (_this$pdfThumbnailVie2 = this.pdfThumbnailViewer) === null || _this$pdfThumbnailVie2 === void 0 ? void 0 : _this$pdfThumbnailVie2.setDocument(pdfDocument);
  882. const storedPromise = (this.store = new _view_history.ViewHistory(pdfDocument.fingerprints[0])).getMultiple({
  883. page: null,
  884. zoom: _ui_utils.DEFAULT_SCALE_VALUE,
  885. scrollLeft: "0",
  886. scrollTop: "0",
  887. rotation: null,
  888. sidebarView: _ui_utils.SidebarView.UNKNOWN,
  889. scrollMode: _ui_utils.ScrollMode.UNKNOWN,
  890. spreadMode: _ui_utils.SpreadMode.UNKNOWN
  891. }).catch(() => {
  892. return Object.create(null);
  893. });
  894. firstPagePromise.then(pdfPage => {
  895. var _this$loadingBar2;
  896. (_this$loadingBar2 = this.loadingBar) === null || _this$loadingBar2 === void 0 ? void 0 : _this$loadingBar2.setWidth(this.appConfig.viewerContainer);
  897. this._initializeAnnotationStorageCallbacks(pdfDocument);
  898. Promise.all([_ui_utils.animationStarted, storedPromise, pageLayoutPromise, pageModePromise, openActionPromise]).then(async _ref3 => {
  899. let [timeStamp, stored, pageLayout, pageMode, openAction] = _ref3;
  900. const viewOnLoad = _app_options.AppOptions.get("viewOnLoad");
  901. this._initializePdfHistory({
  902. fingerprint: pdfDocument.fingerprints[0],
  903. viewOnLoad,
  904. initialDest: openAction === null || openAction === void 0 ? void 0 : openAction.dest
  905. });
  906. const initialBookmark = this.initialBookmark;
  907. const zoom = _app_options.AppOptions.get("defaultZoomValue");
  908. let hash = zoom ? `zoom=${zoom}` : null;
  909. let rotation = null;
  910. let sidebarView = _app_options.AppOptions.get("sidebarViewOnLoad");
  911. let scrollMode = _app_options.AppOptions.get("scrollModeOnLoad");
  912. let spreadMode = _app_options.AppOptions.get("spreadModeOnLoad");
  913. if (stored.page && viewOnLoad !== ViewOnLoad.INITIAL) {
  914. hash = `page=${stored.page}&zoom=${zoom || stored.zoom},` + `${stored.scrollLeft},${stored.scrollTop}`;
  915. rotation = parseInt(stored.rotation, 10);
  916. if (sidebarView === _ui_utils.SidebarView.UNKNOWN) {
  917. sidebarView = stored.sidebarView | 0;
  918. }
  919. if (scrollMode === _ui_utils.ScrollMode.UNKNOWN) {
  920. scrollMode = stored.scrollMode | 0;
  921. }
  922. if (spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
  923. spreadMode = stored.spreadMode | 0;
  924. }
  925. }
  926. if (pageMode && sidebarView === _ui_utils.SidebarView.UNKNOWN) {
  927. sidebarView = (0, _ui_utils.apiPageModeToSidebarView)(pageMode);
  928. }
  929. if (pageLayout && scrollMode === _ui_utils.ScrollMode.UNKNOWN && spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
  930. const modes = (0, _ui_utils.apiPageLayoutToViewerModes)(pageLayout);
  931. spreadMode = modes.spreadMode;
  932. }
  933. this.setInitialView(hash, {
  934. rotation,
  935. sidebarView,
  936. scrollMode,
  937. spreadMode
  938. });
  939. this.eventBus.dispatch("documentinit", {
  940. source: this
  941. });
  942. if (!this.isViewerEmbedded) {
  943. pdfViewer.focus();
  944. }
  945. await Promise.race([pagesPromise, new Promise(resolve => {
  946. setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT);
  947. })]);
  948. if (!initialBookmark && !hash) {
  949. return;
  950. }
  951. if (pdfViewer.hasEqualPageSizes) {
  952. return;
  953. }
  954. this.initialBookmark = initialBookmark;
  955. pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;
  956. this.setInitialView(hash);
  957. }).catch(() => {
  958. this.setInitialView();
  959. }).then(function () {
  960. pdfViewer.update();
  961. });
  962. });
  963. pagesPromise.then(() => {
  964. this._unblockDocumentLoadEvent();
  965. this._initializeAutoPrint(pdfDocument, openActionPromise);
  966. }, reason => {
  967. this.l10n.get("loading_error").then(msg => {
  968. this._documentError(msg, {
  969. message: reason === null || reason === void 0 ? void 0 : reason.message
  970. });
  971. });
  972. });
  973. onePageRendered.then(data => {
  974. this.externalServices.reportTelemetry({
  975. type: "pageInfo",
  976. timestamp: data.timestamp
  977. });
  978. if (this.pdfOutlineViewer) {
  979. pdfDocument.getOutline().then(outline => {
  980. if (pdfDocument !== this.pdfDocument) {
  981. return;
  982. }
  983. this.pdfOutlineViewer.render({
  984. outline,
  985. pdfDocument
  986. });
  987. });
  988. }
  989. if (this.pdfAttachmentViewer) {
  990. pdfDocument.getAttachments().then(attachments => {
  991. if (pdfDocument !== this.pdfDocument) {
  992. return;
  993. }
  994. this.pdfAttachmentViewer.render({
  995. attachments
  996. });
  997. });
  998. }
  999. if (this.pdfLayerViewer) {
  1000. pdfViewer.optionalContentConfigPromise.then(optionalContentConfig => {
  1001. if (pdfDocument !== this.pdfDocument) {
  1002. return;
  1003. }
  1004. this.pdfLayerViewer.render({
  1005. optionalContentConfig,
  1006. pdfDocument
  1007. });
  1008. });
  1009. }
  1010. });
  1011. this._initializePageLabels(pdfDocument);
  1012. this._initializeMetadata(pdfDocument);
  1013. },
  1014. async _scriptingDocProperties(pdfDocument) {
  1015. var _this$metadata, _this$metadata2;
  1016. if (!this.documentInfo) {
  1017. await new Promise(resolve => {
  1018. this.eventBus._on("metadataloaded", resolve, {
  1019. once: true
  1020. });
  1021. });
  1022. if (pdfDocument !== this.pdfDocument) {
  1023. return null;
  1024. }
  1025. }
  1026. if (!this._contentLength) {
  1027. await new Promise(resolve => {
  1028. this.eventBus._on("documentloaded", resolve, {
  1029. once: true
  1030. });
  1031. });
  1032. if (pdfDocument !== this.pdfDocument) {
  1033. return null;
  1034. }
  1035. }
  1036. return {
  1037. ...this.documentInfo,
  1038. baseURL: this.baseUrl,
  1039. filesize: this._contentLength,
  1040. filename: this._docFilename,
  1041. metadata: (_this$metadata = this.metadata) === null || _this$metadata === void 0 ? void 0 : _this$metadata.getRaw(),
  1042. authors: (_this$metadata2 = this.metadata) === null || _this$metadata2 === void 0 ? void 0 : _this$metadata2.get("dc:creator"),
  1043. numPages: this.pagesCount,
  1044. URL: this.url
  1045. };
  1046. },
  1047. async _initializeAutoPrint(pdfDocument, openActionPromise) {
  1048. const [openAction, javaScript] = await Promise.all([openActionPromise, !this.pdfViewer.enableScripting ? pdfDocument.getJavaScript() : null]);
  1049. if (pdfDocument !== this.pdfDocument) {
  1050. return;
  1051. }
  1052. let triggerAutoPrint = false;
  1053. if ((openAction === null || openAction === void 0 ? void 0 : openAction.action) === "Print") {
  1054. triggerAutoPrint = true;
  1055. }
  1056. if (javaScript) {
  1057. javaScript.some(js => {
  1058. if (!js) {
  1059. return false;
  1060. }
  1061. console.warn("Warning: JavaScript support is not enabled");
  1062. return true;
  1063. });
  1064. if (!triggerAutoPrint) {
  1065. for (const js of javaScript) {
  1066. if (js && _ui_utils.AutoPrintRegExp.test(js)) {
  1067. triggerAutoPrint = true;
  1068. break;
  1069. }
  1070. }
  1071. }
  1072. }
  1073. if (triggerAutoPrint) {
  1074. this.triggerPrinting();
  1075. }
  1076. },
  1077. async _initializeMetadata(pdfDocument) {
  1078. const {
  1079. info,
  1080. metadata,
  1081. contentDispositionFilename,
  1082. contentLength
  1083. } = await pdfDocument.getMetadata();
  1084. if (pdfDocument !== this.pdfDocument) {
  1085. return;
  1086. }
  1087. this.documentInfo = info;
  1088. this.metadata = metadata;
  1089. this._contentDispositionFilename ?? (this._contentDispositionFilename = contentDispositionFilename);
  1090. this._contentLength ?? (this._contentLength = contentLength);
  1091. console.log(`PDF ${pdfDocument.fingerprints[0]} [${info.PDFFormatVersion} ` + `${(info.Producer || "-").trim()} / ${(info.Creator || "-").trim()}] ` + `(PDF.js: ${_pdfjsLib.version || "?"} [${_pdfjsLib.build || "?"}])`);
  1092. let pdfTitle = info.Title;
  1093. const metadataTitle = metadata === null || metadata === void 0 ? void 0 : metadata.get("dc:title");
  1094. if (metadataTitle) {
  1095. if (metadataTitle !== "Untitled" && !/[\uFFF0-\uFFFF]/g.test(metadataTitle)) {
  1096. pdfTitle = metadataTitle;
  1097. }
  1098. }
  1099. if (pdfTitle) {
  1100. this.setTitle(`${pdfTitle} - ${this._contentDispositionFilename || this._title}`);
  1101. } else if (this._contentDispositionFilename) {
  1102. this.setTitle(this._contentDispositionFilename);
  1103. }
  1104. if (info.IsXFAPresent && !info.IsAcroFormPresent && !pdfDocument.isPureXfa) {
  1105. if (pdfDocument.loadingParams.enableXfa) {
  1106. console.warn("Warning: XFA Foreground documents are not supported");
  1107. } else {
  1108. console.warn("Warning: XFA support is not enabled");
  1109. }
  1110. } else if ((info.IsAcroFormPresent || info.IsXFAPresent) && !this.pdfViewer.renderForms) {
  1111. console.warn("Warning: Interactive form support is not enabled");
  1112. }
  1113. if (info.IsSignaturesPresent) {
  1114. console.warn("Warning: Digital signatures validation is not supported");
  1115. }
  1116. this.eventBus.dispatch("metadataloaded", {
  1117. source: this
  1118. });
  1119. },
  1120. async _initializePageLabels(pdfDocument) {
  1121. const labels = await pdfDocument.getPageLabels();
  1122. if (pdfDocument !== this.pdfDocument) {
  1123. return;
  1124. }
  1125. if (!labels || _app_options.AppOptions.get("disablePageLabels")) {
  1126. return;
  1127. }
  1128. const numLabels = labels.length;
  1129. let standardLabels = 0,
  1130. emptyLabels = 0;
  1131. for (let i = 0; i < numLabels; i++) {
  1132. const label = labels[i];
  1133. if (label === (i + 1).toString()) {
  1134. standardLabels++;
  1135. } else if (label === "") {
  1136. emptyLabels++;
  1137. } else {
  1138. break;
  1139. }
  1140. }
  1141. if (standardLabels >= numLabels || emptyLabels >= numLabels) {
  1142. return;
  1143. }
  1144. const {
  1145. pdfViewer,
  1146. pdfThumbnailViewer,
  1147. toolbar
  1148. } = this;
  1149. pdfViewer.setPageLabels(labels);
  1150. pdfThumbnailViewer === null || pdfThumbnailViewer === void 0 ? void 0 : pdfThumbnailViewer.setPageLabels(labels);
  1151. toolbar === null || toolbar === void 0 ? void 0 : toolbar.setPagesCount(numLabels, true);
  1152. toolbar === null || toolbar === void 0 ? void 0 : toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  1153. },
  1154. _initializePdfHistory(_ref4) {
  1155. let {
  1156. fingerprint,
  1157. viewOnLoad,
  1158. initialDest = null
  1159. } = _ref4;
  1160. if (!this.pdfHistory) {
  1161. return;
  1162. }
  1163. this.pdfHistory.initialize({
  1164. fingerprint,
  1165. resetHistory: viewOnLoad === ViewOnLoad.INITIAL,
  1166. updateUrl: _app_options.AppOptions.get("historyUpdateUrl")
  1167. });
  1168. if (this.pdfHistory.initialBookmark) {
  1169. this.initialBookmark = this.pdfHistory.initialBookmark;
  1170. this.initialRotation = this.pdfHistory.initialRotation;
  1171. }
  1172. if (initialDest && !this.initialBookmark && viewOnLoad === ViewOnLoad.UNKNOWN) {
  1173. this.initialBookmark = JSON.stringify(initialDest);
  1174. this.pdfHistory.push({
  1175. explicitDest: initialDest,
  1176. pageNumber: null
  1177. });
  1178. }
  1179. },
  1180. _initializeAnnotationStorageCallbacks(pdfDocument) {
  1181. if (pdfDocument !== this.pdfDocument) {
  1182. return;
  1183. }
  1184. const {
  1185. annotationStorage
  1186. } = pdfDocument;
  1187. annotationStorage.onSetModified = () => {
  1188. window.addEventListener("beforeunload", beforeUnload);
  1189. this._annotationStorageModified = true;
  1190. };
  1191. annotationStorage.onResetModified = () => {
  1192. window.removeEventListener("beforeunload", beforeUnload);
  1193. delete this._annotationStorageModified;
  1194. };
  1195. annotationStorage.onAnnotationEditor = typeStr => {
  1196. this._hasAnnotationEditors = !!typeStr;
  1197. this.setTitle();
  1198. if (typeStr) {
  1199. this.externalServices.reportTelemetry({
  1200. type: "editing",
  1201. data: {
  1202. type: typeStr
  1203. }
  1204. });
  1205. }
  1206. };
  1207. },
  1208. setInitialView(storedHash) {
  1209. var _this$pdfSidebar2, _this$toolbar3, _this$secondaryToolba3;
  1210. let {
  1211. rotation,
  1212. sidebarView,
  1213. scrollMode,
  1214. spreadMode
  1215. } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1216. const setRotation = angle => {
  1217. if ((0, _ui_utils.isValidRotation)(angle)) {
  1218. this.pdfViewer.pagesRotation = angle;
  1219. }
  1220. };
  1221. const setViewerModes = (scroll, spread) => {
  1222. if ((0, _ui_utils.isValidScrollMode)(scroll)) {
  1223. this.pdfViewer.scrollMode = scroll;
  1224. }
  1225. if ((0, _ui_utils.isValidSpreadMode)(spread)) {
  1226. this.pdfViewer.spreadMode = spread;
  1227. }
  1228. };
  1229. this.isInitialViewSet = true;
  1230. (_this$pdfSidebar2 = this.pdfSidebar) === null || _this$pdfSidebar2 === void 0 ? void 0 : _this$pdfSidebar2.setInitialView(sidebarView);
  1231. setViewerModes(scrollMode, spreadMode);
  1232. if (this.initialBookmark) {
  1233. setRotation(this.initialRotation);
  1234. delete this.initialRotation;
  1235. this.pdfLinkService.setHash(this.initialBookmark);
  1236. this.initialBookmark = null;
  1237. } else if (storedHash) {
  1238. setRotation(rotation);
  1239. this.pdfLinkService.setHash(storedHash);
  1240. }
  1241. (_this$toolbar3 = this.toolbar) === null || _this$toolbar3 === void 0 ? void 0 : _this$toolbar3.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel);
  1242. (_this$secondaryToolba3 = this.secondaryToolbar) === null || _this$secondaryToolba3 === void 0 ? void 0 : _this$secondaryToolba3.setPageNumber(this.pdfViewer.currentPageNumber);
  1243. if (!this.pdfViewer.currentScaleValue) {
  1244. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  1245. }
  1246. },
  1247. _cleanup() {
  1248. var _this$pdfThumbnailVie3;
  1249. if (!this.pdfDocument) {
  1250. return;
  1251. }
  1252. this.pdfViewer.cleanup();
  1253. (_this$pdfThumbnailVie3 = this.pdfThumbnailViewer) === null || _this$pdfThumbnailVie3 === void 0 ? void 0 : _this$pdfThumbnailVie3.cleanup();
  1254. this.pdfDocument.cleanup(this.pdfViewer.renderer === _ui_utils.RendererType.SVG);
  1255. },
  1256. forceRendering() {
  1257. var _this$pdfSidebar3;
  1258. this.pdfRenderingQueue.printing = !!this.printService;
  1259. this.pdfRenderingQueue.isThumbnailViewEnabled = ((_this$pdfSidebar3 = this.pdfSidebar) === null || _this$pdfSidebar3 === void 0 ? void 0 : _this$pdfSidebar3.visibleView) === _ui_utils.SidebarView.THUMBS;
  1260. this.pdfRenderingQueue.renderHighestPriority();
  1261. },
  1262. beforePrint() {
  1263. this._printAnnotationStoragePromise = this.pdfScriptingManager.dispatchWillPrint().catch(() => { }).then(() => {
  1264. var _this$pdfDocument4;
  1265. return (_this$pdfDocument4 = this.pdfDocument) === null || _this$pdfDocument4 === void 0 ? void 0 : _this$pdfDocument4.annotationStorage.print;
  1266. });
  1267. if (this.printService) {
  1268. return;
  1269. }
  1270. if (!this.supportsPrinting) {
  1271. this.l10n.get("printing_not_supported").then(msg => {
  1272. this._otherError(msg);
  1273. });
  1274. return;
  1275. }
  1276. if (!this.pdfViewer.pageViewsReady) {
  1277. this.l10n.get("printing_not_ready").then(msg => {
  1278. window.alert(msg);
  1279. });
  1280. return;
  1281. }
  1282. const pagesOverview = this.pdfViewer.getPagesOverview();
  1283. const printContainer = this.appConfig.printContainer;
  1284. const printResolution = _app_options.AppOptions.get("printResolution");
  1285. const optionalContentConfigPromise = this.pdfViewer.optionalContentConfigPromise;
  1286. const printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, this._printAnnotationStoragePromise, this.l10n);
  1287. this.printService = printService;
  1288. this.forceRendering();
  1289. this.setTitle();
  1290. printService.layout();
  1291. if (this._hasAnnotationEditors) {
  1292. this.externalServices.reportTelemetry({
  1293. type: "editing",
  1294. data: {
  1295. type: "print"
  1296. }
  1297. });
  1298. }
  1299. },
  1300. afterPrint() {
  1301. if (this._printAnnotationStoragePromise) {
  1302. this._printAnnotationStoragePromise.then(() => {
  1303. this.pdfScriptingManager.dispatchDidPrint();
  1304. });
  1305. this._printAnnotationStoragePromise = null;
  1306. }
  1307. if (this.printService) {
  1308. var _this$pdfDocument5;
  1309. this.printService.destroy();
  1310. this.printService = null;
  1311. (_this$pdfDocument5 = this.pdfDocument) === null || _this$pdfDocument5 === void 0 ? void 0 : _this$pdfDocument5.annotationStorage.resetModified();
  1312. }
  1313. this.forceRendering();
  1314. this.setTitle();
  1315. },
  1316. rotatePages(delta) {
  1317. this.pdfViewer.pagesRotation += delta;
  1318. },
  1319. requestPresentationMode() {
  1320. var _this$pdfPresentation;
  1321. (_this$pdfPresentation = this.pdfPresentationMode) === null || _this$pdfPresentation === void 0 ? void 0 : _this$pdfPresentation.request();
  1322. },
  1323. triggerPrinting() {
  1324. if (!this.supportsPrinting) {
  1325. return;
  1326. }
  1327. window.print();
  1328. },
  1329. bindEvents() {
  1330. const {
  1331. eventBus,
  1332. _boundEvents
  1333. } = this;
  1334. _boundEvents.beforePrint = this.beforePrint.bind(this);
  1335. _boundEvents.afterPrint = this.afterPrint.bind(this);
  1336. eventBus._on("resize", webViewerResize);
  1337. eventBus._on("hashchange", webViewerHashchange);
  1338. eventBus._on("beforeprint", _boundEvents.beforePrint);
  1339. eventBus._on("afterprint", _boundEvents.afterPrint);
  1340. eventBus._on("pagerender", webViewerPageRender);
  1341. eventBus._on("pagerendered", webViewerPageRendered);
  1342. eventBus._on("updateviewarea", webViewerUpdateViewarea);
  1343. eventBus._on("pagechanging", webViewerPageChanging);
  1344. eventBus._on("scalechanging", webViewerScaleChanging);
  1345. eventBus._on("rotationchanging", webViewerRotationChanging);
  1346. eventBus._on("sidebarviewchanged", webViewerSidebarViewChanged);
  1347. eventBus._on("pagemode", webViewerPageMode);
  1348. eventBus._on("namedaction", webViewerNamedAction);
  1349. eventBus._on("presentationmodechanged", webViewerPresentationModeChanged);
  1350. eventBus._on("presentationmode", webViewerPresentationMode);
  1351. eventBus._on("switchannotationeditormode", webViewerSwitchAnnotationEditorMode);
  1352. eventBus._on("switchannotationeditorparams", webViewerSwitchAnnotationEditorParams);
  1353. eventBus._on("print", webViewerPrint);
  1354. eventBus._on("download", webViewerDownload);
  1355. eventBus._on("firstpage", webViewerFirstPage);
  1356. eventBus._on("lastpage", webViewerLastPage);
  1357. eventBus._on("nextpage", webViewerNextPage);
  1358. eventBus._on("previouspage", webViewerPreviousPage);
  1359. eventBus._on("zoomin", webViewerZoomIn);
  1360. eventBus._on("zoomout", webViewerZoomOut);
  1361. eventBus._on("zoomreset", webViewerZoomReset);
  1362. eventBus._on("pagenumberchanged", webViewerPageNumberChanged);
  1363. eventBus._on("scalechanged", webViewerScaleChanged);
  1364. eventBus._on("rotatecw", webViewerRotateCw);
  1365. eventBus._on("rotateccw", webViewerRotateCcw);
  1366. eventBus._on("optionalcontentconfig", webViewerOptionalContentConfig);
  1367. eventBus._on("switchscrollmode", webViewerSwitchScrollMode);
  1368. eventBus._on("scrollmodechanged", webViewerScrollModeChanged);
  1369. eventBus._on("switchspreadmode", webViewerSwitchSpreadMode);
  1370. eventBus._on("spreadmodechanged", webViewerSpreadModeChanged);
  1371. eventBus._on("documentproperties", webViewerDocumentProperties);
  1372. eventBus._on("findfromurlhash", webViewerFindFromUrlHash);
  1373. eventBus._on("updatefindmatchescount", webViewerUpdateFindMatchesCount);
  1374. eventBus._on("updatefindcontrolstate", webViewerUpdateFindControlState);
  1375. if (_app_options.AppOptions.get("pdfBug")) {
  1376. _boundEvents.reportPageStatsPDFBug = reportPageStatsPDFBug;
  1377. eventBus._on("pagerendered", _boundEvents.reportPageStatsPDFBug);
  1378. eventBus._on("pagechanging", _boundEvents.reportPageStatsPDFBug);
  1379. }
  1380. eventBus._on("fileinputchange", webViewerFileInputChange);
  1381. eventBus._on("openfile", webViewerOpenFile);
  1382. },
  1383. bindWindowEvents() {
  1384. const {
  1385. eventBus,
  1386. _boundEvents
  1387. } = this;
  1388. function addWindowResolutionChange() {
  1389. let evt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  1390. if (evt) {
  1391. webViewerResolutionChange(evt);
  1392. }
  1393. const mediaQueryList = window.matchMedia(`(resolution: ${window.devicePixelRatio || 1}dppx)`);
  1394. mediaQueryList.addEventListener("change", addWindowResolutionChange, {
  1395. once: true
  1396. });
  1397. _boundEvents.removeWindowResolutionChange || (_boundEvents.removeWindowResolutionChange = function () {
  1398. mediaQueryList.removeEventListener("change", addWindowResolutionChange);
  1399. _boundEvents.removeWindowResolutionChange = null;
  1400. });
  1401. }
  1402. addWindowResolutionChange();
  1403. _boundEvents.windowResize = () => {
  1404. eventBus.dispatch("resize", {
  1405. source: window
  1406. });
  1407. };
  1408. _boundEvents.windowHashChange = () => {
  1409. eventBus.dispatch("hashchange", {
  1410. source: window,
  1411. hash: document.location.hash.substring(1)
  1412. });
  1413. };
  1414. _boundEvents.windowBeforePrint = () => {
  1415. eventBus.dispatch("beforeprint", {
  1416. source: window
  1417. });
  1418. };
  1419. _boundEvents.windowAfterPrint = () => {
  1420. eventBus.dispatch("afterprint", {
  1421. source: window
  1422. });
  1423. };
  1424. _boundEvents.windowUpdateFromSandbox = event => {
  1425. eventBus.dispatch("updatefromsandbox", {
  1426. source: window,
  1427. detail: event.detail
  1428. });
  1429. };
  1430. window.addEventListener("visibilitychange", webViewerVisibilityChange);
  1431. window.addEventListener("wheel", webViewerWheel, {
  1432. passive: false
  1433. });
  1434. window.addEventListener("touchstart", webViewerTouchStart, {
  1435. passive: false
  1436. });
  1437. window.addEventListener("touchmove", webViewerTouchMove, {
  1438. passive: false
  1439. });
  1440. window.addEventListener("touchend", webViewerTouchEnd, {
  1441. passive: false
  1442. });
  1443. window.addEventListener("click", webViewerClick);
  1444. window.addEventListener("keydown", webViewerKeyDown);
  1445. window.addEventListener("keyup", webViewerKeyUp);
  1446. window.addEventListener("resize", _boundEvents.windowResize);
  1447. window.addEventListener("hashchange", _boundEvents.windowHashChange);
  1448. window.addEventListener("beforeprint", _boundEvents.windowBeforePrint);
  1449. window.addEventListener("afterprint", _boundEvents.windowAfterPrint);
  1450. window.addEventListener("updatefromsandbox", _boundEvents.windowUpdateFromSandbox);
  1451. },
  1452. unbindEvents() {
  1453. const {
  1454. eventBus,
  1455. _boundEvents
  1456. } = this;
  1457. eventBus._off("resize", webViewerResize);
  1458. eventBus._off("hashchange", webViewerHashchange);
  1459. eventBus._off("beforeprint", _boundEvents.beforePrint);
  1460. eventBus._off("afterprint", _boundEvents.afterPrint);
  1461. eventBus._off("pagerender", webViewerPageRender);
  1462. eventBus._off("pagerendered", webViewerPageRendered);
  1463. eventBus._off("updateviewarea", webViewerUpdateViewarea);
  1464. eventBus._off("pagechanging", webViewerPageChanging);
  1465. eventBus._off("scalechanging", webViewerScaleChanging);
  1466. eventBus._off("rotationchanging", webViewerRotationChanging);
  1467. eventBus._off("sidebarviewchanged", webViewerSidebarViewChanged);
  1468. eventBus._off("pagemode", webViewerPageMode);
  1469. eventBus._off("namedaction", webViewerNamedAction);
  1470. eventBus._off("presentationmodechanged", webViewerPresentationModeChanged);
  1471. eventBus._off("presentationmode", webViewerPresentationMode);
  1472. eventBus._off("print", webViewerPrint);
  1473. eventBus._off("download", webViewerDownload);
  1474. eventBus._off("firstpage", webViewerFirstPage);
  1475. eventBus._off("lastpage", webViewerLastPage);
  1476. eventBus._off("nextpage", webViewerNextPage);
  1477. eventBus._off("previouspage", webViewerPreviousPage);
  1478. eventBus._off("zoomin", webViewerZoomIn);
  1479. eventBus._off("zoomout", webViewerZoomOut);
  1480. eventBus._off("zoomreset", webViewerZoomReset);
  1481. eventBus._off("pagenumberchanged", webViewerPageNumberChanged);
  1482. eventBus._off("scalechanged", webViewerScaleChanged);
  1483. eventBus._off("rotatecw", webViewerRotateCw);
  1484. eventBus._off("rotateccw", webViewerRotateCcw);
  1485. eventBus._off("optionalcontentconfig", webViewerOptionalContentConfig);
  1486. eventBus._off("switchscrollmode", webViewerSwitchScrollMode);
  1487. eventBus._off("scrollmodechanged", webViewerScrollModeChanged);
  1488. eventBus._off("switchspreadmode", webViewerSwitchSpreadMode);
  1489. eventBus._off("spreadmodechanged", webViewerSpreadModeChanged);
  1490. eventBus._off("documentproperties", webViewerDocumentProperties);
  1491. eventBus._off("findfromurlhash", webViewerFindFromUrlHash);
  1492. eventBus._off("updatefindmatchescount", webViewerUpdateFindMatchesCount);
  1493. eventBus._off("updatefindcontrolstate", webViewerUpdateFindControlState);
  1494. if (_boundEvents.reportPageStatsPDFBug) {
  1495. eventBus._off("pagerendered", _boundEvents.reportPageStatsPDFBug);
  1496. eventBus._off("pagechanging", _boundEvents.reportPageStatsPDFBug);
  1497. _boundEvents.reportPageStatsPDFBug = null;
  1498. }
  1499. eventBus._off("fileinputchange", webViewerFileInputChange);
  1500. eventBus._off("openfile", webViewerOpenFile);
  1501. _boundEvents.beforePrint = null;
  1502. _boundEvents.afterPrint = null;
  1503. },
  1504. unbindWindowEvents() {
  1505. var _boundEvents$removeWi;
  1506. const {
  1507. _boundEvents
  1508. } = this;
  1509. window.removeEventListener("visibilitychange", webViewerVisibilityChange);
  1510. window.removeEventListener("wheel", webViewerWheel, {
  1511. passive: false
  1512. });
  1513. window.removeEventListener("touchstart", webViewerTouchStart, {
  1514. passive: false
  1515. });
  1516. window.removeEventListener("touchmove", webViewerTouchMove, {
  1517. passive: false
  1518. });
  1519. window.removeEventListener("touchend", webViewerTouchEnd, {
  1520. passive: false
  1521. });
  1522. window.removeEventListener("click", webViewerClick);
  1523. window.removeEventListener("keydown", webViewerKeyDown);
  1524. window.removeEventListener("keyup", webViewerKeyUp);
  1525. window.removeEventListener("resize", _boundEvents.windowResize);
  1526. window.removeEventListener("hashchange", _boundEvents.windowHashChange);
  1527. window.removeEventListener("beforeprint", _boundEvents.windowBeforePrint);
  1528. window.removeEventListener("afterprint", _boundEvents.windowAfterPrint);
  1529. window.removeEventListener("updatefromsandbox", _boundEvents.windowUpdateFromSandbox);
  1530. (_boundEvents$removeWi = _boundEvents.removeWindowResolutionChange) === null || _boundEvents$removeWi === void 0 ? void 0 : _boundEvents$removeWi.call(_boundEvents);
  1531. _boundEvents.windowResize = null;
  1532. _boundEvents.windowHashChange = null;
  1533. _boundEvents.windowBeforePrint = null;
  1534. _boundEvents.windowAfterPrint = null;
  1535. _boundEvents.windowUpdateFromSandbox = null;
  1536. },
  1537. _accumulateTicks(ticks, prop) {
  1538. if (this[prop] > 0 && ticks < 0 || this[prop] < 0 && ticks > 0) {
  1539. this[prop] = 0;
  1540. }
  1541. this[prop] += ticks;
  1542. const wholeTicks = Math.trunc(this[prop]);
  1543. this[prop] -= wholeTicks;
  1544. return wholeTicks;
  1545. },
  1546. _accumulateFactor(previousScale, factor, prop) {
  1547. if (factor === 1) {
  1548. return 1;
  1549. }
  1550. if (this[prop] > 1 && factor < 1 || this[prop] < 1 && factor > 1) {
  1551. this[prop] = 1;
  1552. }
  1553. const newFactor = Math.floor(previousScale * factor * this[prop] * 100) / (100 * previousScale);
  1554. this[prop] = factor / newFactor;
  1555. return newFactor;
  1556. },
  1557. _centerAtPos(previousScale, x, y) {
  1558. const {
  1559. pdfViewer
  1560. } = this;
  1561. const scaleDiff = pdfViewer.currentScale / previousScale - 1;
  1562. if (scaleDiff !== 0) {
  1563. const [top, left] = pdfViewer.containerTopLeft;
  1564. pdfViewer.container.scrollLeft += (x - left) * scaleDiff;
  1565. pdfViewer.container.scrollTop += (y - top) * scaleDiff;
  1566. }
  1567. },
  1568. _unblockDocumentLoadEvent() {
  1569. var _document$blockUnbloc, _document;
  1570. (_document$blockUnbloc = (_document = document).blockUnblockOnload) === null || _document$blockUnbloc === void 0 ? void 0 : _document$blockUnbloc.call(_document, false);
  1571. this._unblockDocumentLoadEvent = () => { };
  1572. },
  1573. get scriptingReady() {
  1574. return this.pdfScriptingManager.ready;
  1575. }
  1576. };
  1577. exports.PDFViewerApplication = PDFViewerApplication;
  1578. {
  1579. const HOSTED_VIEWER_ORIGINS = ["null", "http://mozilla.github.io", "https://mozilla.github.io"];
  1580. var validateFileURL = function (file) {
  1581. if (!file) {
  1582. return;
  1583. }
  1584. try {
  1585. const viewerOrigin = new URL(window.location.href).origin || "null";
  1586. if (HOSTED_VIEWER_ORIGINS.includes(viewerOrigin)) {
  1587. return;
  1588. }
  1589. // const fileOrigin = new URL(file, window.location.href).origin;
  1590. // if (fileOrigin !== viewerOrigin) {
  1591. // throw new Error("file origin does not match viewer's");
  1592. // }
  1593. } catch (ex) {
  1594. PDFViewerApplication.l10n.get("loading_error").then(msg => {
  1595. PDFViewerApplication._documentError(msg, {
  1596. message: ex === null || ex === void 0 ? void 0 : ex.message
  1597. });
  1598. });
  1599. throw ex;
  1600. }
  1601. };
  1602. }
  1603. async function loadFakeWorker() {
  1604. _pdfjsLib.GlobalWorkerOptions.workerSrc || (_pdfjsLib.GlobalWorkerOptions.workerSrc = _app_options.AppOptions.get("workerSrc"));
  1605. await (0, _pdfjsLib.loadScript)(_pdfjsLib.PDFWorker.workerSrc);
  1606. }
  1607. async function loadPDFBug(self) {
  1608. const {
  1609. debuggerScriptPath
  1610. } = self.appConfig;
  1611. const {
  1612. PDFBug
  1613. } = await import(debuggerScriptPath);
  1614. self._PDFBug = PDFBug;
  1615. }
  1616. function reportPageStatsPDFBug(_ref5) {
  1617. var _globalThis$Stats, _pageView$pdfPage;
  1618. let {
  1619. pageNumber
  1620. } = _ref5;
  1621. if (!((_globalThis$Stats = globalThis.Stats) !== null && _globalThis$Stats !== void 0 && _globalThis$Stats.enabled)) {
  1622. return;
  1623. }
  1624. const pageView = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
  1625. globalThis.Stats.add(pageNumber, pageView === null || pageView === void 0 ? void 0 : (_pageView$pdfPage = pageView.pdfPage) === null || _pageView$pdfPage === void 0 ? void 0 : _pageView$pdfPage.stats);
  1626. }
  1627. function webViewerInitialized() {
  1628. const {
  1629. appConfig,
  1630. eventBus,
  1631. l10n
  1632. } = PDFViewerApplication;
  1633. let file;
  1634. const queryString = document.location.search.substring(1);
  1635. const params = (0, _ui_utils.parseQueryString)(queryString);
  1636. file = params.get("file") ?? _app_options.AppOptions.get("defaultUrl");
  1637. validateFileURL(file);
  1638. const fileInput = appConfig.openFileInput;
  1639. fileInput.value = null;
  1640. fileInput.addEventListener("change", function (evt) {
  1641. const {
  1642. files
  1643. } = evt.target;
  1644. if (!files || files.length === 0) {
  1645. return;
  1646. }
  1647. eventBus.dispatch("fileinputchange", {
  1648. source: this,
  1649. fileInput: evt.target
  1650. });
  1651. });
  1652. appConfig.mainContainer.addEventListener("dragover", function (evt) {
  1653. evt.preventDefault();
  1654. evt.dataTransfer.dropEffect = evt.dataTransfer.effectAllowed === "copy" ? "copy" : "move";
  1655. });
  1656. appConfig.mainContainer.addEventListener("drop", function (evt) {
  1657. evt.preventDefault();
  1658. const {
  1659. files
  1660. } = evt.dataTransfer;
  1661. if (!files || files.length === 0) {
  1662. return;
  1663. }
  1664. eventBus.dispatch("fileinputchange", {
  1665. source: this,
  1666. fileInput: evt.dataTransfer
  1667. });
  1668. });
  1669. if (!PDFViewerApplication.supportsDocumentFonts) {
  1670. _app_options.AppOptions.set("disableFontFace", true);
  1671. l10n.get("web_fonts_disabled").then(msg => {
  1672. console.warn(msg);
  1673. });
  1674. }
  1675. if (!PDFViewerApplication.supportsPrinting) {
  1676. var _appConfig$toolbar, _appConfig$secondaryT3;
  1677. (_appConfig$toolbar = appConfig.toolbar) === null || _appConfig$toolbar === void 0 ? void 0 : _appConfig$toolbar.print.classList.add("hidden");
  1678. (_appConfig$secondaryT3 = appConfig.secondaryToolbar) === null || _appConfig$secondaryT3 === void 0 ? void 0 : _appConfig$secondaryT3.printButton.classList.add("hidden");
  1679. }
  1680. if (!PDFViewerApplication.supportsFullscreen) {
  1681. var _appConfig$secondaryT4;
  1682. (_appConfig$secondaryT4 = appConfig.secondaryToolbar) === null || _appConfig$secondaryT4 === void 0 ? void 0 : _appConfig$secondaryT4.presentationModeButton.classList.add("hidden");
  1683. }
  1684. if (PDFViewerApplication.supportsIntegratedFind) {
  1685. var _appConfig$toolbar2;
  1686. (_appConfig$toolbar2 = appConfig.toolbar) === null || _appConfig$toolbar2 === void 0 ? void 0 : _appConfig$toolbar2.viewFind.classList.add("hidden");
  1687. }
  1688. appConfig.mainContainer.addEventListener("transitionend", function (evt) {
  1689. if (evt.target === this) {
  1690. eventBus.dispatch("resize", {
  1691. source: this
  1692. });
  1693. }
  1694. }, true);
  1695. try {
  1696. if (file) {
  1697. PDFViewerApplication.open({
  1698. url: file
  1699. });
  1700. } else {
  1701. PDFViewerApplication._hideViewBookmark();
  1702. }
  1703. } catch (reason) {
  1704. l10n.get("loading_error").then(msg => {
  1705. PDFViewerApplication._documentError(msg, reason);
  1706. });
  1707. }
  1708. }
  1709. function webViewerPageRender(_ref6) {
  1710. let {
  1711. pageNumber
  1712. } = _ref6;
  1713. if (pageNumber === PDFViewerApplication.page) {
  1714. var _PDFViewerApplication;
  1715. (_PDFViewerApplication = PDFViewerApplication.toolbar) === null || _PDFViewerApplication === void 0 ? void 0 : _PDFViewerApplication.updateLoadingIndicatorState(true);
  1716. }
  1717. }
  1718. function webViewerPageRendered(_ref7) {
  1719. var _PDFViewerApplication3;
  1720. let {
  1721. pageNumber,
  1722. error
  1723. } = _ref7;
  1724. if (pageNumber === PDFViewerApplication.page) {
  1725. var _PDFViewerApplication2;
  1726. (_PDFViewerApplication2 = PDFViewerApplication.toolbar) === null || _PDFViewerApplication2 === void 0 ? void 0 : _PDFViewerApplication2.updateLoadingIndicatorState(false);
  1727. }
  1728. if (((_PDFViewerApplication3 = PDFViewerApplication.pdfSidebar) === null || _PDFViewerApplication3 === void 0 ? void 0 : _PDFViewerApplication3.visibleView) === _ui_utils.SidebarView.THUMBS) {
  1729. var _PDFViewerApplication4;
  1730. const pageView = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
  1731. const thumbnailView = (_PDFViewerApplication4 = PDFViewerApplication.pdfThumbnailViewer) === null || _PDFViewerApplication4 === void 0 ? void 0 : _PDFViewerApplication4.getThumbnail(pageNumber - 1);
  1732. if (pageView && thumbnailView) {
  1733. thumbnailView.setImage(pageView);
  1734. }
  1735. }
  1736. if (error) {
  1737. PDFViewerApplication.l10n.get("rendering_error").then(msg => {
  1738. PDFViewerApplication._otherError(msg, error);
  1739. });
  1740. }
  1741. }
  1742. function webViewerPageMode(_ref8) {
  1743. var _PDFViewerApplication5;
  1744. let {
  1745. mode
  1746. } = _ref8;
  1747. let view;
  1748. switch (mode) {
  1749. case "thumbs":
  1750. view = _ui_utils.SidebarView.THUMBS;
  1751. break;
  1752. case "bookmarks":
  1753. case "outline":
  1754. view = _ui_utils.SidebarView.OUTLINE;
  1755. break;
  1756. case "attachments":
  1757. view = _ui_utils.SidebarView.ATTACHMENTS;
  1758. break;
  1759. case "layers":
  1760. view = _ui_utils.SidebarView.LAYERS;
  1761. break;
  1762. case "none":
  1763. view = _ui_utils.SidebarView.NONE;
  1764. break;
  1765. default:
  1766. console.error('Invalid "pagemode" hash parameter: ' + mode);
  1767. return;
  1768. }
  1769. (_PDFViewerApplication5 = PDFViewerApplication.pdfSidebar) === null || _PDFViewerApplication5 === void 0 ? void 0 : _PDFViewerApplication5.switchView(view, true);
  1770. }
  1771. function webViewerNamedAction(evt) {
  1772. var _PDFViewerApplication6;
  1773. switch (evt.action) {
  1774. case "GoToPage":
  1775. (_PDFViewerApplication6 = PDFViewerApplication.appConfig.toolbar) === null || _PDFViewerApplication6 === void 0 ? void 0 : _PDFViewerApplication6.pageNumber.select();
  1776. break;
  1777. case "Find":
  1778. if (!PDFViewerApplication.supportsIntegratedFind) {
  1779. PDFViewerApplication === null || PDFViewerApplication === void 0 ? void 0 : PDFViewerApplication.findBar.toggle();
  1780. }
  1781. break;
  1782. case "Print":
  1783. PDFViewerApplication.triggerPrinting();
  1784. break;
  1785. case "SaveAs":
  1786. PDFViewerApplication.downloadOrSave();
  1787. break;
  1788. }
  1789. }
  1790. function webViewerPresentationModeChanged(evt) {
  1791. PDFViewerApplication.pdfViewer.presentationModeState = evt.state;
  1792. }
  1793. function webViewerSidebarViewChanged(_ref9) {
  1794. let {
  1795. view
  1796. } = _ref9;
  1797. PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = view === _ui_utils.SidebarView.THUMBS;
  1798. if (PDFViewerApplication.isInitialViewSet) {
  1799. var _PDFViewerApplication7;
  1800. (_PDFViewerApplication7 = PDFViewerApplication.store) === null || _PDFViewerApplication7 === void 0 ? void 0 : _PDFViewerApplication7.set("sidebarView", view).catch(() => { });
  1801. }
  1802. }
  1803. function webViewerUpdateViewarea(_ref10) {
  1804. let {
  1805. location
  1806. } = _ref10;
  1807. if (PDFViewerApplication.isInitialViewSet) {
  1808. var _PDFViewerApplication8;
  1809. (_PDFViewerApplication8 = PDFViewerApplication.store) === null || _PDFViewerApplication8 === void 0 ? void 0 : _PDFViewerApplication8.setMultiple({
  1810. page: location.pageNumber,
  1811. zoom: location.scale,
  1812. scrollLeft: location.left,
  1813. scrollTop: location.top,
  1814. rotation: location.rotation
  1815. }).catch(() => { });
  1816. }
  1817. if (PDFViewerApplication.appConfig.secondaryToolbar) {
  1818. const href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
  1819. PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
  1820. }
  1821. }
  1822. function webViewerScrollModeChanged(evt) {
  1823. if (PDFViewerApplication.isInitialViewSet && !PDFViewerApplication.pdfViewer.isInPresentationMode) {
  1824. var _PDFViewerApplication9;
  1825. (_PDFViewerApplication9 = PDFViewerApplication.store) === null || _PDFViewerApplication9 === void 0 ? void 0 : _PDFViewerApplication9.set("scrollMode", evt.mode).catch(() => { });
  1826. }
  1827. }
  1828. function webViewerSpreadModeChanged(evt) {
  1829. if (PDFViewerApplication.isInitialViewSet && !PDFViewerApplication.pdfViewer.isInPresentationMode) {
  1830. var _PDFViewerApplication10;
  1831. (_PDFViewerApplication10 = PDFViewerApplication.store) === null || _PDFViewerApplication10 === void 0 ? void 0 : _PDFViewerApplication10.set("spreadMode", evt.mode).catch(() => { });
  1832. }
  1833. }
  1834. function webViewerResize() {
  1835. const {
  1836. pdfDocument,
  1837. pdfViewer,
  1838. pdfRenderingQueue
  1839. } = PDFViewerApplication;
  1840. if (pdfRenderingQueue.printing && window.matchMedia("print").matches) {
  1841. return;
  1842. }
  1843. if (!pdfDocument) {
  1844. return;
  1845. }
  1846. const currentScaleValue = pdfViewer.currentScaleValue;
  1847. if (currentScaleValue === "auto" || currentScaleValue === "page-fit" || currentScaleValue === "page-width") {
  1848. pdfViewer.currentScaleValue = currentScaleValue;
  1849. }
  1850. pdfViewer.update();
  1851. }
  1852. function webViewerHashchange(evt) {
  1853. var _PDFViewerApplication11;
  1854. const hash = evt.hash;
  1855. if (!hash) {
  1856. return;
  1857. }
  1858. if (!PDFViewerApplication.isInitialViewSet) {
  1859. PDFViewerApplication.initialBookmark = hash;
  1860. } else if (!((_PDFViewerApplication11 = PDFViewerApplication.pdfHistory) !== null && _PDFViewerApplication11 !== void 0 && _PDFViewerApplication11.popStateInProgress)) {
  1861. PDFViewerApplication.pdfLinkService.setHash(hash);
  1862. }
  1863. }
  1864. {
  1865. var webViewerFileInputChange = function (evt) {
  1866. var _PDFViewerApplication12;
  1867. if ((_PDFViewerApplication12 = PDFViewerApplication.pdfViewer) !== null && _PDFViewerApplication12 !== void 0 && _PDFViewerApplication12.isInPresentationMode) {
  1868. return;
  1869. }
  1870. const file = evt.fileInput.files[0];
  1871. PDFViewerApplication.open({
  1872. url: URL.createObjectURL(file),
  1873. originalUrl: file.name
  1874. });
  1875. };
  1876. var webViewerOpenFile = function (evt) {
  1877. const fileInput = PDFViewerApplication.appConfig.openFileInput;
  1878. fileInput.click();
  1879. };
  1880. }
  1881. function webViewerPresentationMode() {
  1882. PDFViewerApplication.requestPresentationMode();
  1883. }
  1884. function webViewerSwitchAnnotationEditorMode(evt) {
  1885. PDFViewerApplication.pdfViewer.annotationEditorMode = evt.mode;
  1886. }
  1887. function webViewerSwitchAnnotationEditorParams(evt) {
  1888. PDFViewerApplication.pdfViewer.annotationEditorParams = evt;
  1889. }
  1890. function webViewerPrint() {
  1891. PDFViewerApplication.triggerPrinting();
  1892. }
  1893. function webViewerDownload() {
  1894. PDFViewerApplication.downloadOrSave();
  1895. }
  1896. function webViewerFirstPage() {
  1897. PDFViewerApplication.page = 1;
  1898. }
  1899. function webViewerLastPage() {
  1900. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  1901. }
  1902. function webViewerNextPage() {
  1903. PDFViewerApplication.pdfViewer.nextPage();
  1904. }
  1905. function webViewerPreviousPage() {
  1906. PDFViewerApplication.pdfViewer.previousPage();
  1907. }
  1908. function webViewerZoomIn() {
  1909. PDFViewerApplication.zoomIn();
  1910. }
  1911. function webViewerZoomOut() {
  1912. PDFViewerApplication.zoomOut();
  1913. }
  1914. function webViewerZoomReset() {
  1915. PDFViewerApplication.zoomReset();
  1916. }
  1917. function webViewerPageNumberChanged(evt) {
  1918. const pdfViewer = PDFViewerApplication.pdfViewer;
  1919. if (evt.value !== "") {
  1920. PDFViewerApplication.pdfLinkService.goToPage(evt.value);
  1921. }
  1922. if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) {
  1923. var _PDFViewerApplication13;
  1924. (_PDFViewerApplication13 = PDFViewerApplication.toolbar) === null || _PDFViewerApplication13 === void 0 ? void 0 : _PDFViewerApplication13.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  1925. }
  1926. }
  1927. function webViewerScaleChanged(evt) {
  1928. PDFViewerApplication.pdfViewer.currentScaleValue = evt.value;
  1929. }
  1930. function webViewerRotateCw() {
  1931. PDFViewerApplication.rotatePages(90);
  1932. }
  1933. function webViewerRotateCcw() {
  1934. PDFViewerApplication.rotatePages(-90);
  1935. }
  1936. function webViewerOptionalContentConfig(evt) {
  1937. PDFViewerApplication.pdfViewer.optionalContentConfigPromise = evt.promise;
  1938. }
  1939. function webViewerSwitchScrollMode(evt) {
  1940. PDFViewerApplication.pdfViewer.scrollMode = evt.mode;
  1941. }
  1942. function webViewerSwitchSpreadMode(evt) {
  1943. PDFViewerApplication.pdfViewer.spreadMode = evt.mode;
  1944. }
  1945. function webViewerDocumentProperties() {
  1946. var _PDFViewerApplication14;
  1947. (_PDFViewerApplication14 = PDFViewerApplication.pdfDocumentProperties) === null || _PDFViewerApplication14 === void 0 ? void 0 : _PDFViewerApplication14.open();
  1948. }
  1949. function webViewerFindFromUrlHash(evt) {
  1950. PDFViewerApplication.eventBus.dispatch("find", {
  1951. source: evt.source,
  1952. type: "",
  1953. query: evt.query,
  1954. phraseSearch: evt.phraseSearch,
  1955. caseSensitive: false,
  1956. entireWord: false,
  1957. highlightAll: true,
  1958. findPrevious: false,
  1959. matchDiacritics: true
  1960. });
  1961. }
  1962. function webViewerUpdateFindMatchesCount(_ref11) {
  1963. let {
  1964. matchesCount
  1965. } = _ref11;
  1966. if (PDFViewerApplication.supportsIntegratedFind) {
  1967. PDFViewerApplication.externalServices.updateFindMatchesCount(matchesCount);
  1968. } else {
  1969. PDFViewerApplication.findBar.updateResultsCount(matchesCount);
  1970. }
  1971. }
  1972. function webViewerUpdateFindControlState(_ref12) {
  1973. let {
  1974. state,
  1975. previous,
  1976. matchesCount,
  1977. rawQuery
  1978. } = _ref12;
  1979. if (PDFViewerApplication.supportsIntegratedFind) {
  1980. PDFViewerApplication.externalServices.updateFindControlState({
  1981. result: state,
  1982. findPrevious: previous,
  1983. matchesCount,
  1984. rawQuery
  1985. });
  1986. } else {
  1987. var _PDFViewerApplication15;
  1988. (_PDFViewerApplication15 = PDFViewerApplication.findBar) === null || _PDFViewerApplication15 === void 0 ? void 0 : _PDFViewerApplication15.updateUIState(state, previous, matchesCount);
  1989. }
  1990. }
  1991. function webViewerScaleChanging(evt) {
  1992. var _PDFViewerApplication16;
  1993. (_PDFViewerApplication16 = PDFViewerApplication.toolbar) === null || _PDFViewerApplication16 === void 0 ? void 0 : _PDFViewerApplication16.setPageScale(evt.presetValue, evt.scale);
  1994. PDFViewerApplication.pdfViewer.update();
  1995. }
  1996. function webViewerRotationChanging(evt) {
  1997. if (PDFViewerApplication.pdfThumbnailViewer) {
  1998. PDFViewerApplication.pdfThumbnailViewer.pagesRotation = evt.pagesRotation;
  1999. }
  2000. PDFViewerApplication.forceRendering();
  2001. PDFViewerApplication.pdfViewer.currentPageNumber = evt.pageNumber;
  2002. }
  2003. function webViewerPageChanging(_ref13) {
  2004. var _PDFViewerApplication17, _PDFViewerApplication18, _PDFViewerApplication19, _PDFViewerApplication21;
  2005. let {
  2006. pageNumber,
  2007. pageLabel
  2008. } = _ref13;
  2009. (_PDFViewerApplication17 = PDFViewerApplication.toolbar) === null || _PDFViewerApplication17 === void 0 ? void 0 : _PDFViewerApplication17.setPageNumber(pageNumber, pageLabel);
  2010. (_PDFViewerApplication18 = PDFViewerApplication.secondaryToolbar) === null || _PDFViewerApplication18 === void 0 ? void 0 : _PDFViewerApplication18.setPageNumber(pageNumber);
  2011. if (((_PDFViewerApplication19 = PDFViewerApplication.pdfSidebar) === null || _PDFViewerApplication19 === void 0 ? void 0 : _PDFViewerApplication19.visibleView) === _ui_utils.SidebarView.THUMBS) {
  2012. var _PDFViewerApplication20;
  2013. (_PDFViewerApplication20 = PDFViewerApplication.pdfThumbnailViewer) === null || _PDFViewerApplication20 === void 0 ? void 0 : _PDFViewerApplication20.scrollThumbnailIntoView(pageNumber);
  2014. }
  2015. const currentPage = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
  2016. (_PDFViewerApplication21 = PDFViewerApplication.toolbar) === null || _PDFViewerApplication21 === void 0 ? void 0 : _PDFViewerApplication21.updateLoadingIndicatorState((currentPage === null || currentPage === void 0 ? void 0 : currentPage.renderingState) === _ui_utils.RenderingStates.RUNNING);
  2017. }
  2018. function webViewerResolutionChange(evt) {
  2019. PDFViewerApplication.pdfViewer.refresh();
  2020. }
  2021. function webViewerVisibilityChange(evt) {
  2022. if (document.visibilityState === "visible") {
  2023. setZoomDisabledTimeout();
  2024. }
  2025. }
  2026. let zoomDisabledTimeout = null;
  2027. function setZoomDisabledTimeout() {
  2028. if (zoomDisabledTimeout) {
  2029. clearTimeout(zoomDisabledTimeout);
  2030. }
  2031. zoomDisabledTimeout = setTimeout(function () {
  2032. zoomDisabledTimeout = null;
  2033. }, WHEEL_ZOOM_DISABLED_TIMEOUT);
  2034. }
  2035. function webViewerWheel(evt) {
  2036. const {
  2037. pdfViewer,
  2038. supportedMouseWheelZoomModifierKeys,
  2039. supportsPinchToZoom
  2040. } = PDFViewerApplication;
  2041. if (pdfViewer.isInPresentationMode) {
  2042. return;
  2043. }
  2044. const deltaMode = evt.deltaMode;
  2045. let scaleFactor = Math.exp(-evt.deltaY / 100);
  2046. const isBuiltInMac = false;
  2047. const isPinchToZoom = evt.ctrlKey && !PDFViewerApplication._isCtrlKeyDown && deltaMode === WheelEvent.DOM_DELTA_PIXEL && evt.deltaX === 0 && (Math.abs(scaleFactor - 1) < 0.05 || isBuiltInMac) && evt.deltaZ === 0;
  2048. if (isPinchToZoom || evt.ctrlKey && supportedMouseWheelZoomModifierKeys.ctrlKey || evt.metaKey && supportedMouseWheelZoomModifierKeys.metaKey) {
  2049. evt.preventDefault();
  2050. if (zoomDisabledTimeout || document.visibilityState === "hidden") {
  2051. return;
  2052. }
  2053. const previousScale = pdfViewer.currentScale;
  2054. if (isPinchToZoom && supportsPinchToZoom) {
  2055. scaleFactor = PDFViewerApplication._accumulateFactor(previousScale, scaleFactor, "_wheelUnusedFactor");
  2056. if (scaleFactor < 1) {
  2057. PDFViewerApplication.zoomOut(null, scaleFactor);
  2058. } else if (scaleFactor > 1) {
  2059. PDFViewerApplication.zoomIn(null, scaleFactor);
  2060. } else {
  2061. return;
  2062. }
  2063. } else {
  2064. const delta = (0, _ui_utils.normalizeWheelEventDirection)(evt);
  2065. let ticks = 0;
  2066. if (deltaMode === WheelEvent.DOM_DELTA_LINE || deltaMode === WheelEvent.DOM_DELTA_PAGE) {
  2067. if (Math.abs(delta) >= 1) {
  2068. ticks = Math.sign(delta);
  2069. } else {
  2070. ticks = PDFViewerApplication._accumulateTicks(delta, "_wheelUnusedTicks");
  2071. }
  2072. } else {
  2073. const PIXELS_PER_LINE_SCALE = 30;
  2074. ticks = PDFViewerApplication._accumulateTicks(delta / PIXELS_PER_LINE_SCALE, "_wheelUnusedTicks");
  2075. }
  2076. if (ticks < 0) {
  2077. PDFViewerApplication.zoomOut(-ticks);
  2078. } else if (ticks > 0) {
  2079. PDFViewerApplication.zoomIn(ticks);
  2080. } else {
  2081. return;
  2082. }
  2083. }
  2084. PDFViewerApplication._centerAtPos(previousScale, evt.clientX, evt.clientY);
  2085. } else {
  2086. setZoomDisabledTimeout();
  2087. }
  2088. }
  2089. function webViewerTouchStart(evt) {
  2090. if (PDFViewerApplication.pdfViewer.isInPresentationMode || evt.touches.length < 2) {
  2091. return;
  2092. }
  2093. evt.preventDefault();
  2094. if (evt.touches.length !== 2) {
  2095. PDFViewerApplication._touchInfo = null;
  2096. return;
  2097. }
  2098. let [touch0, touch1] = evt.touches;
  2099. if (touch0.identifier > touch1.identifier) {
  2100. [touch0, touch1] = [touch1, touch0];
  2101. }
  2102. PDFViewerApplication._touchInfo = {
  2103. touch0X: touch0.pageX,
  2104. touch0Y: touch0.pageY,
  2105. touch1X: touch1.pageX,
  2106. touch1Y: touch1.pageY
  2107. };
  2108. }
  2109. function webViewerTouchMove(evt) {
  2110. if (!PDFViewerApplication._touchInfo || evt.touches.length !== 2) {
  2111. return;
  2112. }
  2113. const {
  2114. pdfViewer,
  2115. _touchInfo,
  2116. supportsPinchToZoom
  2117. } = PDFViewerApplication;
  2118. let [touch0, touch1] = evt.touches;
  2119. if (touch0.identifier > touch1.identifier) {
  2120. [touch0, touch1] = [touch1, touch0];
  2121. }
  2122. const {
  2123. pageX: page0X,
  2124. pageY: page0Y
  2125. } = touch0;
  2126. const {
  2127. pageX: page1X,
  2128. pageY: page1Y
  2129. } = touch1;
  2130. const {
  2131. touch0X: pTouch0X,
  2132. touch0Y: pTouch0Y,
  2133. touch1X: pTouch1X,
  2134. touch1Y: pTouch1Y
  2135. } = _touchInfo;
  2136. if (Math.abs(pTouch0X - page0X) <= 1 && Math.abs(pTouch0Y - page0Y) <= 1 && Math.abs(pTouch1X - page1X) <= 1 && Math.abs(pTouch1Y - page1Y) <= 1) {
  2137. return;
  2138. }
  2139. _touchInfo.touch0X = page0X;
  2140. _touchInfo.touch0Y = page0Y;
  2141. _touchInfo.touch1X = page1X;
  2142. _touchInfo.touch1Y = page1Y;
  2143. if (pTouch0X === page0X && pTouch0Y === page0Y) {
  2144. const v1X = pTouch1X - page0X;
  2145. const v1Y = pTouch1Y - page0Y;
  2146. const v2X = page1X - page0X;
  2147. const v2Y = page1Y - page0Y;
  2148. const det = v1X * v2Y - v1Y * v2X;
  2149. if (Math.abs(det) > 0.02 * Math.hypot(v1X, v1Y) * Math.hypot(v2X, v2Y)) {
  2150. return;
  2151. }
  2152. } else if (pTouch1X === page1X && pTouch1Y === page1Y) {
  2153. const v1X = pTouch0X - page1X;
  2154. const v1Y = pTouch0Y - page1Y;
  2155. const v2X = page0X - page1X;
  2156. const v2Y = page0Y - page1Y;
  2157. const det = v1X * v2Y - v1Y * v2X;
  2158. if (Math.abs(det) > 0.02 * Math.hypot(v1X, v1Y) * Math.hypot(v2X, v2Y)) {
  2159. return;
  2160. }
  2161. } else {
  2162. const diff0X = page0X - pTouch0X;
  2163. const diff1X = page1X - pTouch1X;
  2164. const diff0Y = page0Y - pTouch0Y;
  2165. const diff1Y = page1Y - pTouch1Y;
  2166. const dotProduct = diff0X * diff1X + diff0Y * diff1Y;
  2167. if (dotProduct >= 0) {
  2168. return;
  2169. }
  2170. }
  2171. evt.preventDefault();
  2172. const distance = Math.hypot(page0X - page1X, page0Y - page1Y) || 1;
  2173. const pDistance = Math.hypot(pTouch0X - pTouch1X, pTouch0Y - pTouch1Y) || 1;
  2174. const previousScale = pdfViewer.currentScale;
  2175. if (supportsPinchToZoom) {
  2176. const newScaleFactor = PDFViewerApplication._accumulateFactor(previousScale, distance / pDistance, "_touchUnusedFactor");
  2177. if (newScaleFactor < 1) {
  2178. PDFViewerApplication.zoomOut(null, newScaleFactor);
  2179. } else if (newScaleFactor > 1) {
  2180. PDFViewerApplication.zoomIn(null, newScaleFactor);
  2181. } else {
  2182. return;
  2183. }
  2184. } else {
  2185. const PIXELS_PER_LINE_SCALE = 30;
  2186. const ticks = PDFViewerApplication._accumulateTicks((distance - pDistance) / PIXELS_PER_LINE_SCALE, "_touchUnusedTicks");
  2187. if (ticks < 0) {
  2188. PDFViewerApplication.zoomOut(-ticks);
  2189. } else if (ticks > 0) {
  2190. PDFViewerApplication.zoomIn(ticks);
  2191. } else {
  2192. return;
  2193. }
  2194. }
  2195. PDFViewerApplication._centerAtPos(previousScale, (page0X + page1X) / 2, (page0Y + page1Y) / 2);
  2196. }
  2197. function webViewerTouchEnd(evt) {
  2198. if (!PDFViewerApplication._touchInfo) {
  2199. return;
  2200. }
  2201. evt.preventDefault();
  2202. PDFViewerApplication._touchInfo = null;
  2203. PDFViewerApplication._touchUnusedTicks = 0;
  2204. PDFViewerApplication._touchUnusedFactor = 1;
  2205. }
  2206. function webViewerClick(evt) {
  2207. var _PDFViewerApplication22, _appConfig$toolbar3, _appConfig$secondaryT5;
  2208. if (!((_PDFViewerApplication22 = PDFViewerApplication.secondaryToolbar) !== null && _PDFViewerApplication22 !== void 0 && _PDFViewerApplication22.isOpen)) {
  2209. return;
  2210. }
  2211. const appConfig = PDFViewerApplication.appConfig;
  2212. if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || (_appConfig$toolbar3 = appConfig.toolbar) !== null && _appConfig$toolbar3 !== void 0 && _appConfig$toolbar3.container.contains(evt.target) && evt.target !== ((_appConfig$secondaryT5 = appConfig.secondaryToolbar) === null || _appConfig$secondaryT5 === void 0 ? void 0 : _appConfig$secondaryT5.toggleButton)) {
  2213. PDFViewerApplication.secondaryToolbar.close();
  2214. }
  2215. }
  2216. function webViewerKeyUp(evt) {
  2217. if (evt.key === "Control") {
  2218. PDFViewerApplication._isCtrlKeyDown = false;
  2219. }
  2220. }
  2221. function webViewerKeyDown(evt) {
  2222. var _PDFViewerApplication24, _PDFViewerApplication25, _PDFViewerApplication26, _PDFViewerApplication27, _PDFViewerApplication28;
  2223. PDFViewerApplication._isCtrlKeyDown = evt.key === "Control";
  2224. if (PDFViewerApplication.overlayManager.active) {
  2225. return;
  2226. }
  2227. const {
  2228. eventBus,
  2229. pdfViewer
  2230. } = PDFViewerApplication;
  2231. const isViewerInPresentationMode = pdfViewer.isInPresentationMode;
  2232. let handled = false,
  2233. ensureViewerFocused = false;
  2234. const cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0);
  2235. if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
  2236. switch (evt.keyCode) {
  2237. case 70:
  2238. if (!PDFViewerApplication.supportsIntegratedFind && !evt.shiftKey) {
  2239. var _PDFViewerApplication23;
  2240. (_PDFViewerApplication23 = PDFViewerApplication.findBar) === null || _PDFViewerApplication23 === void 0 ? void 0 : _PDFViewerApplication23.open();
  2241. handled = true;
  2242. }
  2243. break;
  2244. case 71:
  2245. if (!PDFViewerApplication.supportsIntegratedFind) {
  2246. const {
  2247. state
  2248. } = PDFViewerApplication.findController;
  2249. if (state) {
  2250. const newState = {
  2251. source: window,
  2252. type: "again",
  2253. findPrevious: cmd === 5 || cmd === 12
  2254. };
  2255. eventBus.dispatch("find", {
  2256. ...state,
  2257. ...newState
  2258. });
  2259. }
  2260. handled = true;
  2261. }
  2262. break;
  2263. case 61:
  2264. case 107:
  2265. case 187:
  2266. case 171:
  2267. PDFViewerApplication.zoomIn();
  2268. handled = true;
  2269. break;
  2270. case 173:
  2271. case 109:
  2272. case 189:
  2273. PDFViewerApplication.zoomOut();
  2274. handled = true;
  2275. break;
  2276. case 48:
  2277. case 96:
  2278. if (!isViewerInPresentationMode) {
  2279. setTimeout(function () {
  2280. PDFViewerApplication.zoomReset();
  2281. });
  2282. handled = false;
  2283. }
  2284. break;
  2285. case 38:
  2286. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  2287. PDFViewerApplication.page = 1;
  2288. handled = true;
  2289. ensureViewerFocused = true;
  2290. }
  2291. break;
  2292. case 40:
  2293. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2294. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2295. handled = true;
  2296. ensureViewerFocused = true;
  2297. }
  2298. break;
  2299. }
  2300. }
  2301. if (cmd === 1 || cmd === 8) {
  2302. switch (evt.keyCode) {
  2303. case 83:
  2304. eventBus.dispatch("download", {
  2305. source: window
  2306. });
  2307. handled = true;
  2308. break;
  2309. case 79:
  2310. {
  2311. eventBus.dispatch("openfile", {
  2312. source: window
  2313. });
  2314. handled = true;
  2315. }
  2316. break;
  2317. }
  2318. }
  2319. if (cmd === 3 || cmd === 10) {
  2320. switch (evt.keyCode) {
  2321. case 80:
  2322. PDFViewerApplication.requestPresentationMode();
  2323. handled = true;
  2324. PDFViewerApplication.externalServices.reportTelemetry({
  2325. type: "buttons",
  2326. data: {
  2327. id: "presentationModeKeyboard"
  2328. }
  2329. });
  2330. break;
  2331. case 71:
  2332. if (PDFViewerApplication.appConfig.toolbar) {
  2333. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  2334. handled = true;
  2335. }
  2336. break;
  2337. }
  2338. }
  2339. if (handled) {
  2340. if (ensureViewerFocused && !isViewerInPresentationMode) {
  2341. pdfViewer.focus();
  2342. }
  2343. evt.preventDefault();
  2344. return;
  2345. }
  2346. const curElement = (0, _ui_utils.getActiveOrFocusedElement)();
  2347. const curElementTagName = curElement === null || curElement === void 0 ? void 0 : curElement.tagName.toUpperCase();
  2348. if (curElementTagName === "INPUT" || curElementTagName === "TEXTAREA" || curElementTagName === "SELECT" || curElement !== null && curElement !== void 0 && curElement.isContentEditable) {
  2349. if (evt.keyCode !== 27) {
  2350. return;
  2351. }
  2352. }
  2353. if (cmd === 0) {
  2354. let turnPage = 0,
  2355. turnOnlyIfPageFit = false;
  2356. switch (evt.keyCode) {
  2357. case 38:
  2358. case 33:
  2359. if (pdfViewer.isVerticalScrollbarEnabled) {
  2360. turnOnlyIfPageFit = true;
  2361. }
  2362. turnPage = -1;
  2363. break;
  2364. case 8:
  2365. if (!isViewerInPresentationMode) {
  2366. turnOnlyIfPageFit = true;
  2367. }
  2368. turnPage = -1;
  2369. break;
  2370. case 37:
  2371. if (pdfViewer.isHorizontalScrollbarEnabled) {
  2372. turnOnlyIfPageFit = true;
  2373. }
  2374. case 75:
  2375. case 80:
  2376. turnPage = -1;
  2377. break;
  2378. case 27:
  2379. if ((_PDFViewerApplication24 = PDFViewerApplication.secondaryToolbar) !== null && _PDFViewerApplication24 !== void 0 && _PDFViewerApplication24.isOpen) {
  2380. PDFViewerApplication.secondaryToolbar.close();
  2381. handled = true;
  2382. }
  2383. if (!PDFViewerApplication.supportsIntegratedFind && (_PDFViewerApplication25 = PDFViewerApplication.findBar) !== null && _PDFViewerApplication25 !== void 0 && _PDFViewerApplication25.opened) {
  2384. PDFViewerApplication.findBar.close();
  2385. handled = true;
  2386. }
  2387. break;
  2388. case 40:
  2389. case 34:
  2390. if (pdfViewer.isVerticalScrollbarEnabled) {
  2391. turnOnlyIfPageFit = true;
  2392. }
  2393. turnPage = 1;
  2394. break;
  2395. case 13:
  2396. case 32:
  2397. if (!isViewerInPresentationMode) {
  2398. turnOnlyIfPageFit = true;
  2399. }
  2400. turnPage = 1;
  2401. break;
  2402. case 39:
  2403. if (pdfViewer.isHorizontalScrollbarEnabled) {
  2404. turnOnlyIfPageFit = true;
  2405. }
  2406. case 74:
  2407. case 78:
  2408. turnPage = 1;
  2409. break;
  2410. case 36:
  2411. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  2412. PDFViewerApplication.page = 1;
  2413. handled = true;
  2414. ensureViewerFocused = true;
  2415. }
  2416. break;
  2417. case 35:
  2418. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2419. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2420. handled = true;
  2421. ensureViewerFocused = true;
  2422. }
  2423. break;
  2424. case 83:
  2425. (_PDFViewerApplication26 = PDFViewerApplication.pdfCursorTools) === null || _PDFViewerApplication26 === void 0 ? void 0 : _PDFViewerApplication26.switchTool(_ui_utils.CursorTool.SELECT);
  2426. break;
  2427. case 72:
  2428. (_PDFViewerApplication27 = PDFViewerApplication.pdfCursorTools) === null || _PDFViewerApplication27 === void 0 ? void 0 : _PDFViewerApplication27.switchTool(_ui_utils.CursorTool.HAND);
  2429. break;
  2430. case 82:
  2431. PDFViewerApplication.rotatePages(90);
  2432. break;
  2433. case 115:
  2434. (_PDFViewerApplication28 = PDFViewerApplication.pdfSidebar) === null || _PDFViewerApplication28 === void 0 ? void 0 : _PDFViewerApplication28.toggle();
  2435. break;
  2436. }
  2437. if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === "page-fit")) {
  2438. if (turnPage > 0) {
  2439. pdfViewer.nextPage();
  2440. } else {
  2441. pdfViewer.previousPage();
  2442. }
  2443. handled = true;
  2444. }
  2445. }
  2446. if (cmd === 4) {
  2447. switch (evt.keyCode) {
  2448. case 13:
  2449. case 32:
  2450. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== "page-fit") {
  2451. break;
  2452. }
  2453. pdfViewer.previousPage();
  2454. handled = true;
  2455. break;
  2456. case 82:
  2457. PDFViewerApplication.rotatePages(-90);
  2458. break;
  2459. }
  2460. }
  2461. if (!handled && !isViewerInPresentationMode) {
  2462. if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !== "BUTTON") {
  2463. ensureViewerFocused = true;
  2464. }
  2465. }
  2466. if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
  2467. pdfViewer.focus();
  2468. }
  2469. if (handled) {
  2470. evt.preventDefault();
  2471. }
  2472. }
  2473. function beforeUnload(evt) {
  2474. evt.preventDefault();
  2475. evt.returnValue = "";
  2476. return false;
  2477. }
  2478. function webViewerAnnotationEditorStatesChanged(data) {
  2479. PDFViewerApplication.externalServices.updateEditorStates(data);
  2480. }
  2481. const PDFPrintServiceFactory = {
  2482. instance: {
  2483. supportsPrinting: false,
  2484. createPrintService() {
  2485. throw new Error("Not implemented: createPrintService");
  2486. }
  2487. }
  2488. };
  2489. exports.PDFPrintServiceFactory = PDFPrintServiceFactory;
  2490. /***/
  2491. }),
  2492. /* 3 */
  2493. /***/ ((__unused_webpack_module, exports) => {
  2494. Object.defineProperty(exports, "__esModule", ({
  2495. value: true
  2496. }));
  2497. 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.CursorTool = exports.AutoPrintRegExp = void 0;
  2498. exports.apiPageLayoutToViewerModes = apiPageLayoutToViewerModes;
  2499. exports.apiPageModeToSidebarView = apiPageModeToSidebarView;
  2500. exports.approximateFraction = approximateFraction;
  2501. exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
  2502. exports.binarySearchFirstItem = binarySearchFirstItem;
  2503. exports.docStyle = void 0;
  2504. exports.getActiveOrFocusedElement = getActiveOrFocusedElement;
  2505. exports.getPageSizeInches = getPageSizeInches;
  2506. exports.getVisibleElements = getVisibleElements;
  2507. exports.isPortraitOrientation = isPortraitOrientation;
  2508. exports.isValidRotation = isValidRotation;
  2509. exports.isValidScrollMode = isValidScrollMode;
  2510. exports.isValidSpreadMode = isValidSpreadMode;
  2511. exports.noContextMenuHandler = noContextMenuHandler;
  2512. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  2513. exports.normalizeWheelEventDirection = normalizeWheelEventDirection;
  2514. exports.parseQueryString = parseQueryString;
  2515. exports.removeNullCharacters = removeNullCharacters;
  2516. exports.roundToDivide = roundToDivide;
  2517. exports.scrollIntoView = scrollIntoView;
  2518. exports.watchScroll = watchScroll;
  2519. const DEFAULT_SCALE_VALUE = "auto";
  2520. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  2521. const DEFAULT_SCALE = 1.0;
  2522. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  2523. const DEFAULT_SCALE_DELTA = 1.1;
  2524. exports.DEFAULT_SCALE_DELTA = DEFAULT_SCALE_DELTA;
  2525. const MIN_SCALE = 0.1;
  2526. exports.MIN_SCALE = MIN_SCALE;
  2527. const MAX_SCALE = 10.0;
  2528. exports.MAX_SCALE = MAX_SCALE;
  2529. const UNKNOWN_SCALE = 0;
  2530. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  2531. const MAX_AUTO_SCALE = 1.25;
  2532. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  2533. //const SCROLLBAR_PADDING = 40;
  2534. const SCROLLBAR_PADDING = 0;
  2535. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  2536. const VERTICAL_PADDING = 5;
  2537. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  2538. const RenderingStates = {
  2539. INITIAL: 0,
  2540. RUNNING: 1,
  2541. PAUSED: 2,
  2542. FINISHED: 3
  2543. };
  2544. exports.RenderingStates = RenderingStates;
  2545. const PresentationModeState = {
  2546. UNKNOWN: 0,
  2547. NORMAL: 1,
  2548. CHANGING: 2,
  2549. FULLSCREEN: 3
  2550. };
  2551. exports.PresentationModeState = PresentationModeState;
  2552. const SidebarView = {
  2553. UNKNOWN: -1,
  2554. NONE: 0,
  2555. THUMBS: 1,
  2556. OUTLINE: 2,
  2557. ATTACHMENTS: 3,
  2558. LAYERS: 4
  2559. };
  2560. exports.SidebarView = SidebarView;
  2561. const RendererType = {
  2562. CANVAS: "canvas",
  2563. SVG: "svg"
  2564. };
  2565. exports.RendererType = RendererType;
  2566. const TextLayerMode = {
  2567. DISABLE: 0,
  2568. ENABLE: 1
  2569. };
  2570. exports.TextLayerMode = TextLayerMode;
  2571. const ScrollMode = {
  2572. UNKNOWN: -1,
  2573. VERTICAL: 0,
  2574. HORIZONTAL: 1,
  2575. WRAPPED: 2,
  2576. PAGE: 3
  2577. };
  2578. exports.ScrollMode = ScrollMode;
  2579. const SpreadMode = {
  2580. UNKNOWN: -1,
  2581. NONE: 0,
  2582. ODD: 1,
  2583. EVEN: 2
  2584. };
  2585. exports.SpreadMode = SpreadMode;
  2586. const CursorTool = {
  2587. SELECT: 0,
  2588. HAND: 1,
  2589. ZOOM: 2
  2590. };
  2591. exports.CursorTool = CursorTool;
  2592. const AutoPrintRegExp = /\bprint\s*\(/;
  2593. exports.AutoPrintRegExp = AutoPrintRegExp;
  2594. class OutputScale {
  2595. constructor() {
  2596. const pixelRatio = window.devicePixelRatio || 1;
  2597. this.sx = pixelRatio;
  2598. this.sy = pixelRatio;
  2599. }
  2600. get scaled() {
  2601. return this.sx !== 1 || this.sy !== 1;
  2602. }
  2603. }
  2604. exports.OutputScale = OutputScale;
  2605. function scrollIntoView(element, spot) {
  2606. let scrollMatches = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  2607. let parent = element.offsetParent;
  2608. if (!parent) {
  2609. console.error("offsetParent is not set -- cannot scroll");
  2610. return;
  2611. }
  2612. let offsetY = element.offsetTop + element.clientTop;
  2613. let offsetX = element.offsetLeft + element.clientLeft;
  2614. while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || scrollMatches && (parent.classList.contains("markedContent") || getComputedStyle(parent).overflow === "hidden")) {
  2615. offsetY += parent.offsetTop;
  2616. offsetX += parent.offsetLeft;
  2617. parent = parent.offsetParent;
  2618. if (!parent) {
  2619. return;
  2620. }
  2621. }
  2622. if (spot) {
  2623. if (spot.top !== undefined) {
  2624. offsetY += spot.top;
  2625. }
  2626. if (spot.left !== undefined) {
  2627. offsetX += spot.left;
  2628. parent.scrollLeft = offsetX;
  2629. }
  2630. }
  2631. parent.scrollTop = offsetY;
  2632. }
  2633. function watchScroll(viewAreaElement, callback) {
  2634. const debounceScroll = function (evt) {
  2635. if (rAF) {
  2636. return;
  2637. }
  2638. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  2639. rAF = null;
  2640. const currentX = viewAreaElement.scrollLeft;
  2641. const lastX = state.lastX;
  2642. if (currentX !== lastX) {
  2643. state.right = currentX > lastX;
  2644. }
  2645. state.lastX = currentX;
  2646. const currentY = viewAreaElement.scrollTop;
  2647. const lastY = state.lastY;
  2648. if (currentY !== lastY) {
  2649. state.down = currentY > lastY;
  2650. }
  2651. state.lastY = currentY;
  2652. callback(state);
  2653. });
  2654. };
  2655. const state = {
  2656. right: true,
  2657. down: true,
  2658. lastX: viewAreaElement.scrollLeft,
  2659. lastY: viewAreaElement.scrollTop,
  2660. _eventHandler: debounceScroll
  2661. };
  2662. let rAF = null;
  2663. viewAreaElement.addEventListener("scroll", debounceScroll, true);
  2664. return state;
  2665. }
  2666. function parseQueryString(query) {
  2667. const params = new Map();
  2668. for (const [key, value] of new URLSearchParams(query)) {
  2669. params.set(key.toLowerCase(), value);
  2670. }
  2671. return params;
  2672. }
  2673. const NullCharactersRegExp = /\x00/g;
  2674. const InvisibleCharactersRegExp = /[\x01-\x1F]/g;
  2675. function removeNullCharacters(str) {
  2676. let replaceInvisible = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  2677. if (typeof str !== "string") {
  2678. console.error(`The argument must be a string.`);
  2679. return str;
  2680. }
  2681. if (replaceInvisible) {
  2682. str = str.replace(InvisibleCharactersRegExp, " ");
  2683. }
  2684. return str.replace(NullCharactersRegExp, "");
  2685. }
  2686. function binarySearchFirstItem(items, condition) {
  2687. let start = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  2688. let minIndex = start;
  2689. let maxIndex = items.length - 1;
  2690. if (maxIndex < 0 || !condition(items[maxIndex])) {
  2691. return items.length;
  2692. }
  2693. if (condition(items[minIndex])) {
  2694. return minIndex;
  2695. }
  2696. while (minIndex < maxIndex) {
  2697. const currentIndex = minIndex + maxIndex >> 1;
  2698. const currentItem = items[currentIndex];
  2699. if (condition(currentItem)) {
  2700. maxIndex = currentIndex;
  2701. } else {
  2702. minIndex = currentIndex + 1;
  2703. }
  2704. }
  2705. return minIndex;
  2706. }
  2707. function approximateFraction(x) {
  2708. if (Math.floor(x) === x) {
  2709. return [x, 1];
  2710. }
  2711. const xinv = 1 / x;
  2712. const limit = 8;
  2713. if (xinv > limit) {
  2714. return [1, limit];
  2715. } else if (Math.floor(xinv) === xinv) {
  2716. return [1, xinv];
  2717. }
  2718. const x_ = x > 1 ? xinv : x;
  2719. let a = 0,
  2720. b = 1,
  2721. c = 1,
  2722. d = 1;
  2723. while (true) {
  2724. const p = a + c,
  2725. q = b + d;
  2726. if (q > limit) {
  2727. break;
  2728. }
  2729. if (x_ <= p / q) {
  2730. c = p;
  2731. d = q;
  2732. } else {
  2733. a = p;
  2734. b = q;
  2735. }
  2736. }
  2737. let result;
  2738. if (x_ - a / b < c / d - x_) {
  2739. result = x_ === x ? [a, b] : [b, a];
  2740. } else {
  2741. result = x_ === x ? [c, d] : [d, c];
  2742. }
  2743. return result;
  2744. }
  2745. function roundToDivide(x, div) {
  2746. const r = x % div;
  2747. return r === 0 ? x : Math.round(x - r + div);
  2748. }
  2749. function getPageSizeInches(_ref) {
  2750. let {
  2751. view,
  2752. userUnit,
  2753. rotate
  2754. } = _ref;
  2755. const [x1, y1, x2, y2] = view;
  2756. const changeOrientation = rotate % 180 !== 0;
  2757. const width = (x2 - x1) / 72 * userUnit;
  2758. const height = (y2 - y1) / 72 * userUnit;
  2759. return {
  2760. width: changeOrientation ? height : width,
  2761. height: changeOrientation ? width : height
  2762. };
  2763. }
  2764. function backtrackBeforeAllVisibleElements(index, views, top) {
  2765. if (index < 2) {
  2766. return index;
  2767. }
  2768. let elt = views[index].div;
  2769. let pageTop = elt.offsetTop + elt.clientTop;
  2770. if (pageTop >= top) {
  2771. elt = views[index - 1].div;
  2772. pageTop = elt.offsetTop + elt.clientTop;
  2773. }
  2774. for (let i = index - 2; i >= 0; --i) {
  2775. elt = views[i].div;
  2776. if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
  2777. break;
  2778. }
  2779. index = i;
  2780. }
  2781. return index;
  2782. }
  2783. function getVisibleElements(_ref2) {
  2784. let {
  2785. scrollEl,
  2786. views,
  2787. sortByVisibility = false,
  2788. horizontal = false,
  2789. rtl = false
  2790. } = _ref2;
  2791. const top = scrollEl.scrollTop,
  2792. bottom = top + scrollEl.clientHeight;
  2793. const left = scrollEl.scrollLeft,
  2794. right = left + scrollEl.clientWidth;
  2795. function isElementBottomAfterViewTop(view) {
  2796. const element = view.div;
  2797. const elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  2798. return elementBottom > top;
  2799. }
  2800. function isElementNextAfterViewHorizontally(view) {
  2801. const element = view.div;
  2802. const elementLeft = element.offsetLeft + element.clientLeft;
  2803. const elementRight = elementLeft + element.clientWidth;
  2804. return rtl ? elementLeft < right : elementRight > left;
  2805. }
  2806. const visible = [],
  2807. ids = new Set(),
  2808. numViews = views.length;
  2809. let firstVisibleElementInd = binarySearchFirstItem(views, horizontal ? isElementNextAfterViewHorizontally : isElementBottomAfterViewTop);
  2810. if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
  2811. firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
  2812. }
  2813. let lastEdge = horizontal ? right : -1;
  2814. for (let i = firstVisibleElementInd; i < numViews; i++) {
  2815. const view = views[i],
  2816. element = view.div;
  2817. const currentWidth = element.offsetLeft + element.clientLeft;
  2818. const currentHeight = element.offsetTop + element.clientTop;
  2819. const viewWidth = element.clientWidth,
  2820. viewHeight = element.clientHeight;
  2821. const viewRight = currentWidth + viewWidth;
  2822. const viewBottom = currentHeight + viewHeight;
  2823. if (lastEdge === -1) {
  2824. if (viewBottom >= bottom) {
  2825. lastEdge = viewBottom;
  2826. }
  2827. } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
  2828. break;
  2829. }
  2830. if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) {
  2831. continue;
  2832. }
  2833. const hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
  2834. const hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
  2835. const fractionHeight = (viewHeight - hiddenHeight) / viewHeight,
  2836. fractionWidth = (viewWidth - hiddenWidth) / viewWidth;
  2837. const percent = fractionHeight * fractionWidth * 100 | 0;
  2838. visible.push({
  2839. id: view.id,
  2840. x: currentWidth,
  2841. y: currentHeight,
  2842. view,
  2843. percent,
  2844. widthPercent: fractionWidth * 100 | 0
  2845. });
  2846. ids.add(view.id);
  2847. }
  2848. const first = visible[0],
  2849. last = visible.at(-1);
  2850. if (sortByVisibility) {
  2851. visible.sort(function (a, b) {
  2852. const pc = a.percent - b.percent;
  2853. if (Math.abs(pc) > 0.001) {
  2854. return -pc;
  2855. }
  2856. return a.id - b.id;
  2857. });
  2858. }
  2859. return {
  2860. first,
  2861. last,
  2862. views: visible,
  2863. ids
  2864. };
  2865. }
  2866. function noContextMenuHandler(evt) {
  2867. evt.preventDefault();
  2868. }
  2869. function normalizeWheelEventDirection(evt) {
  2870. let delta = Math.hypot(evt.deltaX, evt.deltaY);
  2871. const angle = Math.atan2(evt.deltaY, evt.deltaX);
  2872. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  2873. delta = -delta;
  2874. }
  2875. return delta;
  2876. }
  2877. function normalizeWheelEventDelta(evt) {
  2878. const deltaMode = evt.deltaMode;
  2879. let delta = normalizeWheelEventDirection(evt);
  2880. const MOUSE_PIXELS_PER_LINE = 30;
  2881. const MOUSE_LINES_PER_PAGE = 30;
  2882. if (deltaMode === WheelEvent.DOM_DELTA_PIXEL) {
  2883. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  2884. } else if (deltaMode === WheelEvent.DOM_DELTA_LINE) {
  2885. delta /= MOUSE_LINES_PER_PAGE;
  2886. }
  2887. return delta;
  2888. }
  2889. function isValidRotation(angle) {
  2890. return Number.isInteger(angle) && angle % 90 === 0;
  2891. }
  2892. function isValidScrollMode(mode) {
  2893. return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN;
  2894. }
  2895. function isValidSpreadMode(mode) {
  2896. return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN;
  2897. }
  2898. function isPortraitOrientation(size) {
  2899. return size.width <= size.height;
  2900. }
  2901. const animationStarted = new Promise(function (resolve) {
  2902. window.requestAnimationFrame(resolve);
  2903. });
  2904. exports.animationStarted = animationStarted;
  2905. const docStyle = document.documentElement.style;
  2906. exports.docStyle = docStyle;
  2907. function clamp(v, min, max) {
  2908. return Math.min(Math.max(v, min), max);
  2909. }
  2910. class ProgressBar {
  2911. #classList = null;
  2912. #disableAutoFetchTimeout = null;
  2913. #percent = 0;
  2914. #style = null;
  2915. #visible = true;
  2916. constructor(bar) {
  2917. this.#classList = bar.classList;
  2918. this.#style = bar.style;
  2919. }
  2920. get percent() {
  2921. return this.#percent;
  2922. }
  2923. set percent(val) {
  2924. this.#percent = clamp(val, 0, 100);
  2925. if (isNaN(val)) {
  2926. this.#classList.add("indeterminate");
  2927. return;
  2928. }
  2929. this.#classList.remove("indeterminate");
  2930. this.#style.setProperty("--progressBar-percent", `${this.#percent}%`);
  2931. }
  2932. setWidth(viewer) {
  2933. if (!viewer) {
  2934. return;
  2935. }
  2936. const container = viewer.parentNode;
  2937. const scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  2938. if (scrollbarWidth > 0) {
  2939. this.#style.setProperty("--progressBar-end-offset", `${scrollbarWidth}px`);
  2940. }
  2941. }
  2942. setDisableAutoFetch() {
  2943. let delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 5000;
  2944. if (isNaN(this.#percent)) {
  2945. return;
  2946. }
  2947. if (this.#disableAutoFetchTimeout) {
  2948. clearTimeout(this.#disableAutoFetchTimeout);
  2949. }
  2950. this.show();
  2951. this.#disableAutoFetchTimeout = setTimeout(() => {
  2952. this.#disableAutoFetchTimeout = null;
  2953. this.hide();
  2954. }, delay);
  2955. }
  2956. hide() {
  2957. if (!this.#visible) {
  2958. return;
  2959. }
  2960. this.#visible = false;
  2961. this.#classList.add("hidden");
  2962. }
  2963. show() {
  2964. if (this.#visible) {
  2965. return;
  2966. }
  2967. this.#visible = true;
  2968. this.#classList.remove("hidden");
  2969. }
  2970. }
  2971. exports.ProgressBar = ProgressBar;
  2972. function getActiveOrFocusedElement() {
  2973. let curRoot = document;
  2974. let curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
  2975. while ((_curActiveOrFocused = curActiveOrFocused) !== null && _curActiveOrFocused !== void 0 && _curActiveOrFocused.shadowRoot) {
  2976. var _curActiveOrFocused;
  2977. curRoot = curActiveOrFocused.shadowRoot;
  2978. curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
  2979. }
  2980. return curActiveOrFocused;
  2981. }
  2982. function apiPageLayoutToViewerModes(layout) {
  2983. let scrollMode = ScrollMode.VERTICAL,
  2984. spreadMode = SpreadMode.NONE;
  2985. switch (layout) {
  2986. case "SinglePage":
  2987. scrollMode = ScrollMode.PAGE;
  2988. break;
  2989. case "OneColumn":
  2990. break;
  2991. case "TwoPageLeft":
  2992. scrollMode = ScrollMode.PAGE;
  2993. case "TwoColumnLeft":
  2994. spreadMode = SpreadMode.ODD;
  2995. break;
  2996. case "TwoPageRight":
  2997. scrollMode = ScrollMode.PAGE;
  2998. case "TwoColumnRight":
  2999. spreadMode = SpreadMode.EVEN;
  3000. break;
  3001. }
  3002. return {
  3003. scrollMode,
  3004. spreadMode
  3005. };
  3006. }
  3007. function apiPageModeToSidebarView(mode) {
  3008. switch (mode) {
  3009. case "UseNone":
  3010. return SidebarView.NONE;
  3011. case "UseThumbs":
  3012. return SidebarView.THUMBS;
  3013. case "UseOutlines":
  3014. return SidebarView.OUTLINE;
  3015. case "UseAttachments":
  3016. return SidebarView.ATTACHMENTS;
  3017. case "UseOC":
  3018. return SidebarView.LAYERS;
  3019. }
  3020. return SidebarView.NONE;
  3021. }
  3022. /***/
  3023. }),
  3024. /* 4 */
  3025. /***/ ((module) => {
  3026. let pdfjsLib;
  3027. if (typeof window !== "undefined" && window["pdfjs-dist/build/pdf"]) {
  3028. pdfjsLib = window["pdfjs-dist/build/pdf"];
  3029. } else {
  3030. pdfjsLib = require("../build/pdf.js");
  3031. }
  3032. module.exports = pdfjsLib;
  3033. /***/
  3034. }),
  3035. /* 5 */
  3036. /***/ ((__unused_webpack_module, exports) => {
  3037. Object.defineProperty(exports, "__esModule", ({
  3038. value: true
  3039. }));
  3040. exports.compatibilityParams = exports.OptionKind = exports.AppOptions = void 0;
  3041. const compatibilityParams = Object.create(null);
  3042. exports.compatibilityParams = compatibilityParams;
  3043. {
  3044. const userAgent = navigator.userAgent || "";
  3045. const platform = navigator.platform || "";
  3046. const maxTouchPoints = navigator.maxTouchPoints || 1;
  3047. const isAndroid = /Android/.test(userAgent);
  3048. const isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" && maxTouchPoints > 1;
  3049. (function checkCanvasSizeLimitation() {
  3050. if (isIOS || isAndroid) {
  3051. compatibilityParams.maxCanvasPixels = 5242880;
  3052. }
  3053. })();
  3054. }
  3055. const OptionKind = {
  3056. VIEWER: 0x02,
  3057. API: 0x04,
  3058. WORKER: 0x08,
  3059. PREFERENCE: 0x80
  3060. };
  3061. exports.OptionKind = OptionKind;
  3062. const defaultOptions = {
  3063. annotationEditorMode: {
  3064. value: 0,
  3065. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3066. },
  3067. annotationMode: {
  3068. value: 2,
  3069. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3070. },
  3071. cursorToolOnLoad: {
  3072. value: 0,
  3073. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3074. },
  3075. defaultZoomDelay: {
  3076. value: 400,
  3077. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3078. },
  3079. defaultZoomValue: {
  3080. value: "",
  3081. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3082. },
  3083. disableHistory: {
  3084. value: false,
  3085. kind: OptionKind.VIEWER
  3086. },
  3087. disablePageLabels: {
  3088. value: false,
  3089. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3090. },
  3091. enablePermissions: {
  3092. value: false,
  3093. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3094. },
  3095. enablePrintAutoRotate: {
  3096. value: true,
  3097. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3098. },
  3099. enableScripting: {
  3100. value: true,
  3101. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3102. },
  3103. externalLinkRel: {
  3104. value: "noopener noreferrer nofollow",
  3105. kind: OptionKind.VIEWER
  3106. },
  3107. externalLinkTarget: {
  3108. value: 0,
  3109. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3110. },
  3111. historyUpdateUrl: {
  3112. value: false,
  3113. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3114. },
  3115. ignoreDestinationZoom: {
  3116. value: false,
  3117. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3118. },
  3119. imageResourcesPath: {
  3120. value: "./images/",
  3121. kind: OptionKind.VIEWER
  3122. },
  3123. maxCanvasPixels: {
  3124. value: 16777216,
  3125. kind: OptionKind.VIEWER
  3126. },
  3127. forcePageColors: {
  3128. value: false,
  3129. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3130. },
  3131. pageColorsBackground: {
  3132. value: "Canvas",
  3133. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3134. },
  3135. pageColorsForeground: {
  3136. value: "CanvasText",
  3137. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3138. },
  3139. pdfBugEnabled: {
  3140. value: false,
  3141. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3142. },
  3143. printResolution: {
  3144. value: 150,
  3145. kind: OptionKind.VIEWER
  3146. },
  3147. sidebarViewOnLoad: {
  3148. value: -1,
  3149. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3150. },
  3151. scrollModeOnLoad: {
  3152. value: -1,
  3153. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3154. },
  3155. spreadModeOnLoad: {
  3156. value: -1,
  3157. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3158. },
  3159. textLayerMode: {
  3160. value: 1,
  3161. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3162. },
  3163. useOnlyCssZoom: {
  3164. value: false,
  3165. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3166. },
  3167. viewerCssTheme: {
  3168. value: 0,
  3169. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3170. },
  3171. viewOnLoad: {
  3172. value: 0,
  3173. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3174. },
  3175. cMapPacked: {
  3176. value: true,
  3177. kind: OptionKind.API
  3178. },
  3179. cMapUrl: {
  3180. value: "../web/cmaps/",
  3181. kind: OptionKind.API
  3182. },
  3183. disableAutoFetch: {
  3184. value: false,
  3185. kind: OptionKind.API + OptionKind.PREFERENCE
  3186. },
  3187. disableFontFace: {
  3188. value: false,
  3189. kind: OptionKind.API + OptionKind.PREFERENCE
  3190. },
  3191. disableRange: {
  3192. value: false,
  3193. kind: OptionKind.API + OptionKind.PREFERENCE
  3194. },
  3195. disableStream: {
  3196. value: false,
  3197. kind: OptionKind.API + OptionKind.PREFERENCE
  3198. },
  3199. docBaseUrl: {
  3200. value: "",
  3201. kind: OptionKind.API
  3202. },
  3203. enableXfa: {
  3204. value: true,
  3205. kind: OptionKind.API + OptionKind.PREFERENCE
  3206. },
  3207. fontExtraProperties: {
  3208. value: false,
  3209. kind: OptionKind.API
  3210. },
  3211. isEvalSupported: {
  3212. value: true,
  3213. kind: OptionKind.API
  3214. },
  3215. isOffscreenCanvasSupported: {
  3216. value: true,
  3217. kind: OptionKind.API
  3218. },
  3219. maxImageSize: {
  3220. value: -1,
  3221. kind: OptionKind.API
  3222. },
  3223. pdfBug: {
  3224. value: false,
  3225. kind: OptionKind.API
  3226. },
  3227. standardFontDataUrl: {
  3228. value: "../web/standard_fonts/",
  3229. kind: OptionKind.API
  3230. },
  3231. verbosity: {
  3232. value: 1,
  3233. kind: OptionKind.API
  3234. },
  3235. workerPort: {
  3236. value: null,
  3237. kind: OptionKind.WORKER
  3238. },
  3239. workerSrc: {
  3240. value: "../build/pdf.worker.js",
  3241. kind: OptionKind.WORKER
  3242. }
  3243. };
  3244. {
  3245. defaultOptions.defaultUrl = {
  3246. value: "compressed.tracemonkey-pldi-09.pdf",
  3247. kind: OptionKind.VIEWER
  3248. };
  3249. defaultOptions.disablePreferences = {
  3250. value: false,
  3251. kind: OptionKind.VIEWER
  3252. };
  3253. defaultOptions.locale = {
  3254. value: navigator.language || "en-US",
  3255. kind: OptionKind.VIEWER
  3256. };
  3257. defaultOptions.renderer = {
  3258. value: "canvas",
  3259. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3260. };
  3261. defaultOptions.sandboxBundleSrc = {
  3262. value: "../build/pdf.sandbox.js",
  3263. kind: OptionKind.VIEWER
  3264. };
  3265. }
  3266. const userOptions = Object.create(null);
  3267. class AppOptions {
  3268. constructor() {
  3269. throw new Error("Cannot initialize AppOptions.");
  3270. }
  3271. static get(name) {
  3272. const userOption = userOptions[name];
  3273. if (userOption !== undefined) {
  3274. return userOption;
  3275. }
  3276. const defaultOption = defaultOptions[name];
  3277. if (defaultOption !== undefined) {
  3278. return compatibilityParams[name] ?? defaultOption.value;
  3279. }
  3280. return undefined;
  3281. }
  3282. static getAll() {
  3283. let kind = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  3284. const options = Object.create(null);
  3285. for (const name in defaultOptions) {
  3286. const defaultOption = defaultOptions[name];
  3287. if (kind) {
  3288. if ((kind & defaultOption.kind) === 0) {
  3289. continue;
  3290. }
  3291. if (kind === OptionKind.PREFERENCE) {
  3292. const value = defaultOption.value,
  3293. valueType = typeof value;
  3294. if (valueType === "boolean" || valueType === "string" || valueType === "number" && Number.isInteger(value)) {
  3295. options[name] = value;
  3296. continue;
  3297. }
  3298. throw new Error(`Invalid type for preference: ${name}`);
  3299. }
  3300. }
  3301. const userOption = userOptions[name];
  3302. options[name] = userOption !== undefined ? userOption : compatibilityParams[name] ?? defaultOption.value;
  3303. }
  3304. return options;
  3305. }
  3306. static set(name, value) {
  3307. userOptions[name] = value;
  3308. }
  3309. static setAll(options) {
  3310. for (const name in options) {
  3311. userOptions[name] = options[name];
  3312. }
  3313. }
  3314. static remove(name) {
  3315. delete userOptions[name];
  3316. }
  3317. }
  3318. exports.AppOptions = AppOptions;
  3319. {
  3320. AppOptions._hasUserOptions = function () {
  3321. return Object.keys(userOptions).length > 0;
  3322. };
  3323. }
  3324. /***/
  3325. }),
  3326. /* 6 */
  3327. /***/ ((__unused_webpack_module, exports) => {
  3328. Object.defineProperty(exports, "__esModule", ({
  3329. value: true
  3330. }));
  3331. exports.WaitOnType = exports.EventBus = exports.AutomationEventBus = void 0;
  3332. exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
  3333. const WaitOnType = {
  3334. EVENT: "event",
  3335. TIMEOUT: "timeout"
  3336. };
  3337. exports.WaitOnType = WaitOnType;
  3338. function waitOnEventOrTimeout(_ref) {
  3339. let {
  3340. target,
  3341. name,
  3342. delay = 0
  3343. } = _ref;
  3344. return new Promise(function (resolve, reject) {
  3345. if (typeof target !== "object" || !(name && typeof name === "string") || !(Number.isInteger(delay) && delay >= 0)) {
  3346. throw new Error("waitOnEventOrTimeout - invalid parameters.");
  3347. }
  3348. function handler(type) {
  3349. if (target instanceof EventBus) {
  3350. target._off(name, eventHandler);
  3351. } else {
  3352. target.removeEventListener(name, eventHandler);
  3353. }
  3354. if (timeout) {
  3355. clearTimeout(timeout);
  3356. }
  3357. resolve(type);
  3358. }
  3359. const eventHandler = handler.bind(null, WaitOnType.EVENT);
  3360. if (target instanceof EventBus) {
  3361. target._on(name, eventHandler);
  3362. } else {
  3363. target.addEventListener(name, eventHandler);
  3364. }
  3365. const timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
  3366. const timeout = setTimeout(timeoutHandler, delay);
  3367. });
  3368. }
  3369. class EventBus {
  3370. #listeners = Object.create(null);
  3371. on(eventName, listener) {
  3372. let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  3373. this._on(eventName, listener, {
  3374. external: true,
  3375. once: options === null || options === void 0 ? void 0 : options.once
  3376. });
  3377. }
  3378. off(eventName, listener) {
  3379. let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  3380. this._off(eventName, listener, {
  3381. external: true,
  3382. once: options === null || options === void 0 ? void 0 : options.once
  3383. });
  3384. }
  3385. dispatch(eventName, data) {
  3386. const eventListeners = this.#listeners[eventName];
  3387. if (!eventListeners || eventListeners.length === 0) {
  3388. return;
  3389. }
  3390. let externalListeners;
  3391. for (const {
  3392. listener,
  3393. external,
  3394. once
  3395. } of eventListeners.slice(0)) {
  3396. if (once) {
  3397. this._off(eventName, listener);
  3398. }
  3399. if (external) {
  3400. (externalListeners || (externalListeners = [])).push(listener);
  3401. continue;
  3402. }
  3403. listener(data);
  3404. }
  3405. if (externalListeners) {
  3406. for (const listener of externalListeners) {
  3407. listener(data);
  3408. }
  3409. externalListeners = null;
  3410. }
  3411. }
  3412. _on(eventName, listener) {
  3413. var _this$listeners;
  3414. let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  3415. const eventListeners = (_this$listeners = this.#listeners)[eventName] || (_this$listeners[eventName] = []);
  3416. eventListeners.push({
  3417. listener,
  3418. external: (options === null || options === void 0 ? void 0 : options.external) === true,
  3419. once: (options === null || options === void 0 ? void 0 : options.once) === true
  3420. });
  3421. }
  3422. _off(eventName, listener) {
  3423. let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  3424. const eventListeners = this.#listeners[eventName];
  3425. if (!eventListeners) {
  3426. return;
  3427. }
  3428. for (let i = 0, ii = eventListeners.length; i < ii; i++) {
  3429. if (eventListeners[i].listener === listener) {
  3430. eventListeners.splice(i, 1);
  3431. return;
  3432. }
  3433. }
  3434. }
  3435. }
  3436. exports.EventBus = EventBus;
  3437. class AutomationEventBus extends EventBus {
  3438. dispatch(eventName, data) {
  3439. throw new Error("Not implemented: AutomationEventBus.dispatch");
  3440. }
  3441. }
  3442. exports.AutomationEventBus = AutomationEventBus;
  3443. /***/
  3444. }),
  3445. /* 7 */
  3446. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  3447. Object.defineProperty(exports, "__esModule", ({
  3448. value: true
  3449. }));
  3450. exports.SimpleLinkService = exports.PDFLinkService = exports.LinkTarget = void 0;
  3451. var _ui_utils = __webpack_require__(3);
  3452. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  3453. function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
  3454. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  3455. function _classStaticPrivateMethodGet(receiver, classConstructor, method) { _classCheckPrivateStaticAccess(receiver, classConstructor); return method; }
  3456. function _classCheckPrivateStaticAccess(receiver, classConstructor) { if (receiver !== classConstructor) { throw new TypeError("Private static access of wrong provenance"); } }
  3457. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  3458. function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
  3459. function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
  3460. function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
  3461. const DEFAULT_LINK_REL = "noopener noreferrer nofollow";
  3462. const LinkTarget = {
  3463. NONE: 0,
  3464. SELF: 1,
  3465. BLANK: 2,
  3466. PARENT: 3,
  3467. TOP: 4
  3468. };
  3469. exports.LinkTarget = LinkTarget;
  3470. function addLinkAttributes(link) {
  3471. let {
  3472. url,
  3473. target,
  3474. rel,
  3475. enabled = true
  3476. } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  3477. if (!url || typeof url !== "string") {
  3478. throw new Error('A valid "url" parameter must provided.');
  3479. }
  3480. const urlNullRemoved = (0, _ui_utils.removeNullCharacters)(url);
  3481. if (enabled) {
  3482. link.href = link.title = urlNullRemoved;
  3483. } else {
  3484. link.href = "";
  3485. link.title = `Disabled: ${urlNullRemoved}`;
  3486. link.onclick = () => {
  3487. return false;
  3488. };
  3489. }
  3490. let targetStr = "";
  3491. switch (target) {
  3492. case LinkTarget.NONE:
  3493. break;
  3494. case LinkTarget.SELF:
  3495. targetStr = "_self";
  3496. break;
  3497. case LinkTarget.BLANK:
  3498. targetStr = "_blank";
  3499. break;
  3500. case LinkTarget.PARENT:
  3501. targetStr = "_parent";
  3502. break;
  3503. case LinkTarget.TOP:
  3504. targetStr = "_top";
  3505. break;
  3506. }
  3507. link.target = targetStr;
  3508. link.rel = typeof rel === "string" ? rel : DEFAULT_LINK_REL;
  3509. }
  3510. var _pagesRefCache = /*#__PURE__*/new WeakMap();
  3511. var _goToDestinationHelper = /*#__PURE__*/new WeakSet();
  3512. class PDFLinkService {
  3513. constructor() {
  3514. let {
  3515. eventBus,
  3516. externalLinkTarget = null,
  3517. externalLinkRel = null,
  3518. ignoreDestinationZoom = false
  3519. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  3520. _classPrivateMethodInitSpec(this, _goToDestinationHelper);
  3521. _classPrivateFieldInitSpec(this, _pagesRefCache, {
  3522. writable: true,
  3523. value: new Map()
  3524. });
  3525. this.eventBus = eventBus;
  3526. this.externalLinkTarget = externalLinkTarget;
  3527. this.externalLinkRel = externalLinkRel;
  3528. this.externalLinkEnabled = true;
  3529. this._ignoreDestinationZoom = ignoreDestinationZoom;
  3530. this.baseUrl = null;
  3531. this.pdfDocument = null;
  3532. this.pdfViewer = null;
  3533. this.pdfHistory = null;
  3534. }
  3535. setDocument(pdfDocument) {
  3536. let baseUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  3537. this.baseUrl = baseUrl;
  3538. this.pdfDocument = pdfDocument;
  3539. _classPrivateFieldGet(this, _pagesRefCache).clear();
  3540. }
  3541. setViewer(pdfViewer) {
  3542. this.pdfViewer = pdfViewer;
  3543. }
  3544. setHistory(pdfHistory) {
  3545. this.pdfHistory = pdfHistory;
  3546. }
  3547. get pagesCount() {
  3548. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  3549. }
  3550. get page() {
  3551. return this.pdfViewer.currentPageNumber;
  3552. }
  3553. set page(value) {
  3554. this.pdfViewer.currentPageNumber = value;
  3555. }
  3556. get rotation() {
  3557. return this.pdfViewer.pagesRotation;
  3558. }
  3559. set rotation(value) {
  3560. this.pdfViewer.pagesRotation = value;
  3561. }
  3562. get isInPresentationMode() {
  3563. return this.pdfViewer.isInPresentationMode;
  3564. }
  3565. async goToDestination(dest) {
  3566. if (!this.pdfDocument) {
  3567. return;
  3568. }
  3569. let namedDest, explicitDest;
  3570. if (typeof dest === "string") {
  3571. namedDest = dest;
  3572. explicitDest = await this.pdfDocument.getDestination(dest);
  3573. } else {
  3574. namedDest = null;
  3575. explicitDest = await dest;
  3576. }
  3577. if (!Array.isArray(explicitDest)) {
  3578. console.error(`PDFLinkService.goToDestination: "${explicitDest}" is not ` + `a valid destination array, for dest="${dest}".`);
  3579. return;
  3580. }
  3581. _classPrivateMethodGet(this, _goToDestinationHelper, _goToDestinationHelper2).call(this, dest, namedDest, explicitDest);
  3582. }
  3583. goToPage(val) {
  3584. if (!this.pdfDocument) {
  3585. return;
  3586. }
  3587. const pageNumber = typeof val === "string" && this.pdfViewer.pageLabelToPageNumber(val) || val | 0;
  3588. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
  3589. console.error(`PDFLinkService.goToPage: "${val}" is not a valid page.`);
  3590. return;
  3591. }
  3592. if (this.pdfHistory) {
  3593. this.pdfHistory.pushCurrentPosition();
  3594. this.pdfHistory.pushPage(pageNumber);
  3595. }
  3596. this.pdfViewer.scrollPageIntoView({
  3597. pageNumber
  3598. });
  3599. }
  3600. addLinkAttributes(link, url) {
  3601. let newWindow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  3602. addLinkAttributes(link, {
  3603. url,
  3604. target: newWindow ? LinkTarget.BLANK : this.externalLinkTarget,
  3605. rel: this.externalLinkRel,
  3606. enabled: this.externalLinkEnabled
  3607. });
  3608. }
  3609. getDestinationHash(dest) {
  3610. if (typeof dest === "string") {
  3611. if (dest.length > 0) {
  3612. return this.getAnchorUrl("#" + escape(dest));
  3613. }
  3614. } else if (Array.isArray(dest)) {
  3615. const str = JSON.stringify(dest);
  3616. if (str.length > 0) {
  3617. return this.getAnchorUrl("#" + escape(str));
  3618. }
  3619. }
  3620. return this.getAnchorUrl("");
  3621. }
  3622. getAnchorUrl(anchor) {
  3623. return (this.baseUrl || "") + anchor;
  3624. }
  3625. setHash(hash) {
  3626. if (!this.pdfDocument) {
  3627. return;
  3628. }
  3629. let pageNumber, dest;
  3630. if (hash.includes("=")) {
  3631. const params = (0, _ui_utils.parseQueryString)(hash);
  3632. if (params.has("search")) {
  3633. this.eventBus.dispatch("findfromurlhash", {
  3634. source: this,
  3635. query: params.get("search").replace(/"/g, ""),
  3636. phraseSearch: params.get("phrase") === "true"
  3637. });
  3638. }
  3639. if (params.has("page")) {
  3640. pageNumber = params.get("page") | 0 || 1;
  3641. }
  3642. if (params.has("zoom")) {
  3643. const zoomArgs = params.get("zoom").split(",");
  3644. const zoomArg = zoomArgs[0];
  3645. const zoomArgNumber = parseFloat(zoomArg);
  3646. if (!zoomArg.includes("Fit")) {
  3647. dest = [null, {
  3648. name: "XYZ"
  3649. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
  3650. } else {
  3651. if (zoomArg === "Fit" || zoomArg === "FitB") {
  3652. dest = [null, {
  3653. name: zoomArg
  3654. }];
  3655. } else if (zoomArg === "FitH" || zoomArg === "FitBH" || zoomArg === "FitV" || zoomArg === "FitBV") {
  3656. dest = [null, {
  3657. name: zoomArg
  3658. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  3659. } else if (zoomArg === "FitR") {
  3660. if (zoomArgs.length !== 5) {
  3661. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
  3662. } else {
  3663. dest = [null, {
  3664. name: zoomArg
  3665. }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
  3666. }
  3667. } else {
  3668. console.error(`PDFLinkService.setHash: "${zoomArg}" is not a valid zoom value.`);
  3669. }
  3670. }
  3671. }
  3672. if (dest) {
  3673. this.pdfViewer.scrollPageIntoView({
  3674. pageNumber: pageNumber || this.page,
  3675. destArray: dest,
  3676. allowNegativeOffset: true
  3677. });
  3678. } else if (pageNumber) {
  3679. this.page = pageNumber;
  3680. }
  3681. if (params.has("pagemode")) {
  3682. this.eventBus.dispatch("pagemode", {
  3683. source: this,
  3684. mode: params.get("pagemode")
  3685. });
  3686. }
  3687. if (params.has("nameddest")) {
  3688. this.goToDestination(params.get("nameddest"));
  3689. }
  3690. } else {
  3691. dest = unescape(hash);
  3692. try {
  3693. dest = JSON.parse(dest);
  3694. if (!Array.isArray(dest)) {
  3695. dest = dest.toString();
  3696. }
  3697. } catch (ex) { }
  3698. if (typeof dest === "string" || _classStaticPrivateMethodGet(PDFLinkService, PDFLinkService, _isValidExplicitDestination).call(PDFLinkService, dest)) {
  3699. this.goToDestination(dest);
  3700. return;
  3701. }
  3702. console.error(`PDFLinkService.setHash: "${unescape(hash)}" is not a valid destination.`);
  3703. }
  3704. }
  3705. executeNamedAction(action) {
  3706. var _this$pdfHistory, _this$pdfHistory2;
  3707. switch (action) {
  3708. case "GoBack":
  3709. (_this$pdfHistory = this.pdfHistory) === null || _this$pdfHistory === void 0 ? void 0 : _this$pdfHistory.back();
  3710. break;
  3711. case "GoForward":
  3712. (_this$pdfHistory2 = this.pdfHistory) === null || _this$pdfHistory2 === void 0 ? void 0 : _this$pdfHistory2.forward();
  3713. break;
  3714. case "NextPage":
  3715. this.pdfViewer.nextPage();
  3716. break;
  3717. case "PrevPage":
  3718. this.pdfViewer.previousPage();
  3719. break;
  3720. case "LastPage":
  3721. this.page = this.pagesCount;
  3722. break;
  3723. case "FirstPage":
  3724. this.page = 1;
  3725. break;
  3726. default:
  3727. break;
  3728. }
  3729. this.eventBus.dispatch("namedaction", {
  3730. source: this,
  3731. action
  3732. });
  3733. }
  3734. async executeSetOCGState(action) {
  3735. const pdfDocument = this.pdfDocument;
  3736. const optionalContentConfig = await this.pdfViewer.optionalContentConfigPromise;
  3737. if (pdfDocument !== this.pdfDocument) {
  3738. return;
  3739. }
  3740. let operator;
  3741. for (const elem of action.state) {
  3742. switch (elem) {
  3743. case "ON":
  3744. case "OFF":
  3745. case "Toggle":
  3746. operator = elem;
  3747. continue;
  3748. }
  3749. switch (operator) {
  3750. case "ON":
  3751. optionalContentConfig.setVisibility(elem, true);
  3752. break;
  3753. case "OFF":
  3754. optionalContentConfig.setVisibility(elem, false);
  3755. break;
  3756. case "Toggle":
  3757. const group = optionalContentConfig.getGroup(elem);
  3758. if (group) {
  3759. optionalContentConfig.setVisibility(elem, !group.visible);
  3760. }
  3761. break;
  3762. }
  3763. }
  3764. this.pdfViewer.optionalContentConfigPromise = Promise.resolve(optionalContentConfig);
  3765. }
  3766. cachePageRef(pageNum, pageRef) {
  3767. if (!pageRef) {
  3768. return;
  3769. }
  3770. const refStr = pageRef.gen === 0 ? `${pageRef.num}R` : `${pageRef.num}R${pageRef.gen}`;
  3771. _classPrivateFieldGet(this, _pagesRefCache).set(refStr, pageNum);
  3772. }
  3773. _cachedPageNumber(pageRef) {
  3774. if (!pageRef) {
  3775. return null;
  3776. }
  3777. const refStr = pageRef.gen === 0 ? `${pageRef.num}R` : `${pageRef.num}R${pageRef.gen}`;
  3778. return _classPrivateFieldGet(this, _pagesRefCache).get(refStr) || null;
  3779. }
  3780. isPageVisible(pageNumber) {
  3781. return this.pdfViewer.isPageVisible(pageNumber);
  3782. }
  3783. isPageCached(pageNumber) {
  3784. return this.pdfViewer.isPageCached(pageNumber);
  3785. }
  3786. }
  3787. exports.PDFLinkService = PDFLinkService;
  3788. function _goToDestinationHelper2(rawDest) {
  3789. let namedDest = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  3790. let explicitDest = arguments.length > 2 ? arguments[2] : undefined;
  3791. const destRef = explicitDest[0];
  3792. let pageNumber;
  3793. if (typeof destRef === "object" && destRef !== null) {
  3794. pageNumber = this._cachedPageNumber(destRef);
  3795. if (!pageNumber) {
  3796. this.pdfDocument.getPageIndex(destRef).then(pageIndex => {
  3797. this.cachePageRef(pageIndex + 1, destRef);
  3798. _classPrivateMethodGet(this, _goToDestinationHelper, _goToDestinationHelper2).call(this, rawDest, namedDest, explicitDest);
  3799. }).catch(() => {
  3800. console.error(`PDFLinkService.#goToDestinationHelper: "${destRef}" is not ` + `a valid page reference, for dest="${rawDest}".`);
  3801. });
  3802. return;
  3803. }
  3804. } else if (Number.isInteger(destRef)) {
  3805. pageNumber = destRef + 1;
  3806. } else {
  3807. console.error(`PDFLinkService.#goToDestinationHelper: "${destRef}" is not ` + `a valid destination reference, for dest="${rawDest}".`);
  3808. return;
  3809. }
  3810. if (!pageNumber || pageNumber < 1 || pageNumber > this.pagesCount) {
  3811. console.error(`PDFLinkService.#goToDestinationHelper: "${pageNumber}" is not ` + `a valid page number, for dest="${rawDest}".`);
  3812. return;
  3813. }
  3814. if (this.pdfHistory) {
  3815. this.pdfHistory.pushCurrentPosition();
  3816. this.pdfHistory.push({
  3817. namedDest,
  3818. explicitDest,
  3819. pageNumber
  3820. });
  3821. }
  3822. this.pdfViewer.scrollPageIntoView({
  3823. pageNumber,
  3824. destArray: explicitDest,
  3825. ignoreDestinationZoom: this._ignoreDestinationZoom
  3826. });
  3827. }
  3828. function _isValidExplicitDestination(dest) {
  3829. if (!Array.isArray(dest)) {
  3830. return false;
  3831. }
  3832. const destLength = dest.length;
  3833. if (destLength < 2) {
  3834. return false;
  3835. }
  3836. const page = dest[0];
  3837. if (!(typeof page === "object" && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
  3838. return false;
  3839. }
  3840. const zoom = dest[1];
  3841. if (!(typeof zoom === "object" && typeof zoom.name === "string")) {
  3842. return false;
  3843. }
  3844. let allowNull = true;
  3845. switch (zoom.name) {
  3846. case "XYZ":
  3847. if (destLength !== 5) {
  3848. return false;
  3849. }
  3850. break;
  3851. case "Fit":
  3852. case "FitB":
  3853. return destLength === 2;
  3854. case "FitH":
  3855. case "FitBH":
  3856. case "FitV":
  3857. case "FitBV":
  3858. if (destLength !== 3) {
  3859. return false;
  3860. }
  3861. break;
  3862. case "FitR":
  3863. if (destLength !== 6) {
  3864. return false;
  3865. }
  3866. allowNull = false;
  3867. break;
  3868. default:
  3869. return false;
  3870. }
  3871. for (let i = 2; i < destLength; i++) {
  3872. const param = dest[i];
  3873. if (!(typeof param === "number" || allowNull && param === null)) {
  3874. return false;
  3875. }
  3876. }
  3877. return true;
  3878. }
  3879. class SimpleLinkService {
  3880. constructor() {
  3881. this.externalLinkEnabled = true;
  3882. }
  3883. get pagesCount() {
  3884. return 0;
  3885. }
  3886. get page() {
  3887. return 0;
  3888. }
  3889. set page(value) { }
  3890. get rotation() {
  3891. return 0;
  3892. }
  3893. set rotation(value) { }
  3894. get isInPresentationMode() {
  3895. return false;
  3896. }
  3897. async goToDestination(dest) { }
  3898. goToPage(val) { }
  3899. addLinkAttributes(link, url) {
  3900. let newWindow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  3901. addLinkAttributes(link, {
  3902. url,
  3903. enabled: this.externalLinkEnabled
  3904. });
  3905. }
  3906. getDestinationHash(dest) {
  3907. return "#";
  3908. }
  3909. getAnchorUrl(hash) {
  3910. return "#";
  3911. }
  3912. setHash(hash) { }
  3913. executeNamedAction(action) { }
  3914. executeSetOCGState(action) { }
  3915. cachePageRef(pageNum, pageRef) { }
  3916. isPageVisible(pageNumber) {
  3917. return true;
  3918. }
  3919. isPageCached(pageNumber) {
  3920. return true;
  3921. }
  3922. }
  3923. exports.SimpleLinkService = SimpleLinkService;
  3924. /***/
  3925. }),
  3926. /* 8 */
  3927. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  3928. Object.defineProperty(exports, "__esModule", ({
  3929. value: true
  3930. }));
  3931. exports.AnnotationEditorParams = void 0;
  3932. var _pdfjsLib = __webpack_require__(4);
  3933. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  3934. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  3935. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  3936. var _bindListeners = /*#__PURE__*/new WeakSet();
  3937. class AnnotationEditorParams {
  3938. constructor(options, eventBus) {
  3939. _classPrivateMethodInitSpec(this, _bindListeners);
  3940. this.eventBus = eventBus;
  3941. _classPrivateMethodGet(this, _bindListeners, _bindListeners2).call(this, options);
  3942. }
  3943. }
  3944. exports.AnnotationEditorParams = AnnotationEditorParams;
  3945. function _bindListeners2(_ref) {
  3946. let {
  3947. editorFreeTextFontSize,
  3948. editorFreeTextColor,
  3949. editorInkColor,
  3950. editorInkThickness,
  3951. editorInkOpacity
  3952. } = _ref;
  3953. editorFreeTextFontSize.addEventListener("input", evt => {
  3954. this.eventBus.dispatch("switchannotationeditorparams", {
  3955. source: this,
  3956. type: _pdfjsLib.AnnotationEditorParamsType.FREETEXT_SIZE,
  3957. value: editorFreeTextFontSize.valueAsNumber
  3958. });
  3959. });
  3960. editorFreeTextColor.addEventListener("input", evt => {
  3961. this.eventBus.dispatch("switchannotationeditorparams", {
  3962. source: this,
  3963. type: _pdfjsLib.AnnotationEditorParamsType.FREETEXT_COLOR,
  3964. value: editorFreeTextColor.value
  3965. });
  3966. });
  3967. editorInkColor.addEventListener("input", evt => {
  3968. this.eventBus.dispatch("switchannotationeditorparams", {
  3969. source: this,
  3970. type: _pdfjsLib.AnnotationEditorParamsType.INK_COLOR,
  3971. value: editorInkColor.value
  3972. });
  3973. });
  3974. editorInkThickness.addEventListener("input", evt => {
  3975. this.eventBus.dispatch("switchannotationeditorparams", {
  3976. source: this,
  3977. type: _pdfjsLib.AnnotationEditorParamsType.INK_THICKNESS,
  3978. value: editorInkThickness.valueAsNumber
  3979. });
  3980. });
  3981. editorInkOpacity.addEventListener("input", evt => {
  3982. this.eventBus.dispatch("switchannotationeditorparams", {
  3983. source: this,
  3984. type: _pdfjsLib.AnnotationEditorParamsType.INK_OPACITY,
  3985. value: editorInkOpacity.valueAsNumber
  3986. });
  3987. });
  3988. this.eventBus._on("annotationeditorparamschanged", evt => {
  3989. for (const [type, value] of evt.details) {
  3990. switch (type) {
  3991. case _pdfjsLib.AnnotationEditorParamsType.FREETEXT_SIZE:
  3992. editorFreeTextFontSize.value = value;
  3993. break;
  3994. case _pdfjsLib.AnnotationEditorParamsType.FREETEXT_COLOR:
  3995. editorFreeTextColor.value = value;
  3996. break;
  3997. case _pdfjsLib.AnnotationEditorParamsType.INK_COLOR:
  3998. editorInkColor.value = value;
  3999. break;
  4000. case _pdfjsLib.AnnotationEditorParamsType.INK_THICKNESS:
  4001. editorInkThickness.value = value;
  4002. break;
  4003. case _pdfjsLib.AnnotationEditorParamsType.INK_OPACITY:
  4004. editorInkOpacity.value = value;
  4005. break;
  4006. }
  4007. }
  4008. });
  4009. }
  4010. /***/
  4011. }),
  4012. /* 9 */
  4013. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  4014. Object.defineProperty(exports, "__esModule", ({
  4015. value: true
  4016. }));
  4017. exports.OverlayManager = void 0;
  4018. class OverlayManager {
  4019. #overlays = new WeakMap();
  4020. #active = null;
  4021. get active() {
  4022. return this.#active;
  4023. }
  4024. async register(dialog) {
  4025. let canForceClose = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4026. if (typeof dialog !== "object") {
  4027. throw new Error("Not enough parameters.");
  4028. } else if (this.#overlays.has(dialog)) {
  4029. throw new Error("The overlay is already registered.");
  4030. }
  4031. this.#overlays.set(dialog, {
  4032. canForceClose
  4033. });
  4034. if (!dialog.showModal) {
  4035. const dialogPolyfill = __webpack_require__(10);
  4036. dialogPolyfill.registerDialog(dialog);
  4037. if (!this._dialogPolyfillCSS) {
  4038. this._dialogPolyfillCSS = true;
  4039. const style = document.createElement("style");
  4040. style.textContent = 'dialog {\n position: absolute;\n left: 0; right: 0;\n width: -moz-fit-content;\n width: -webkit-fit-content;\n width: fit-content;\n height: -moz-fit-content;\n height: -webkit-fit-content;\n height: fit-content;\n margin: auto;\n border: solid;\n padding: 1em;\n background: white;\n color: black;\n display: block;\n}\n\ndialog:not([open]) {\n display: none;\n}\n\ndialog + .backdrop {\n position: fixed;\n top: 0; right: 0; bottom: 0; left: 0;\n background: rgba(0,0,0,0.1);\n}\n\n._dialog_overlay {\n position: fixed;\n top: 0; right: 0; bottom: 0; left: 0;\n}\n\ndialog.fixed {\n position: fixed;\n top: 50%;\n transform: translate(0, -50%);\n}';
  4041. document.head.prepend(style);
  4042. }
  4043. }
  4044. dialog.addEventListener("cancel", evt => {
  4045. this.#active = null;
  4046. });
  4047. }
  4048. async unregister(dialog) {
  4049. if (!this.#overlays.has(dialog)) {
  4050. throw new Error("The overlay does not exist.");
  4051. } else if (this.#active === dialog) {
  4052. throw new Error("The overlay cannot be removed while it is active.");
  4053. }
  4054. this.#overlays.delete(dialog);
  4055. }
  4056. async open(dialog) {
  4057. if (!this.#overlays.has(dialog)) {
  4058. throw new Error("The overlay does not exist.");
  4059. } else if (this.#active) {
  4060. if (this.#active === dialog) {
  4061. throw new Error("The overlay is already active.");
  4062. } else if (this.#overlays.get(dialog).canForceClose) {
  4063. await this.close();
  4064. } else {
  4065. throw new Error("Another overlay is currently active.");
  4066. }
  4067. }
  4068. this.#active = dialog;
  4069. dialog.showModal();
  4070. }
  4071. async close() {
  4072. let dialog = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.#active;
  4073. if (!this.#overlays.has(dialog)) {
  4074. throw new Error("The overlay does not exist.");
  4075. } else if (!this.#active) {
  4076. throw new Error("The overlay is currently not active.");
  4077. } else if (this.#active !== dialog) {
  4078. throw new Error("Another overlay is currently active.");
  4079. }
  4080. dialog.close();
  4081. this.#active = null;
  4082. }
  4083. }
  4084. exports.OverlayManager = OverlayManager;
  4085. /***/
  4086. }),
  4087. /* 10 */
  4088. /***/ ((module) => {
  4089. (function (global, factory) {
  4090. true ? module.exports = factory() : 0;
  4091. })(void 0, function () {
  4092. 'use strict';
  4093. var supportCustomEvent = window.CustomEvent;
  4094. if (!supportCustomEvent || typeof supportCustomEvent === 'object') {
  4095. supportCustomEvent = function CustomEvent(event, x) {
  4096. x = x || {};
  4097. var ev = document.createEvent('CustomEvent');
  4098. ev.initCustomEvent(event, !!x.bubbles, !!x.cancelable, x.detail || null);
  4099. return ev;
  4100. };
  4101. supportCustomEvent.prototype = window.Event.prototype;
  4102. }
  4103. function safeDispatchEvent(target, event) {
  4104. var check = 'on' + event.type.toLowerCase();
  4105. if (typeof target[check] === 'function') {
  4106. target[check](event);
  4107. }
  4108. return target.dispatchEvent(event);
  4109. }
  4110. function createsStackingContext(el) {
  4111. while (el && el !== document.body) {
  4112. var s = window.getComputedStyle(el);
  4113. var invalid = function (k, ok) {
  4114. return !(s[k] === undefined || s[k] === ok);
  4115. };
  4116. if (s.opacity < 1 || invalid('zIndex', 'auto') || invalid('transform', 'none') || invalid('mixBlendMode', 'normal') || invalid('filter', 'none') || invalid('perspective', 'none') || s['isolation'] === 'isolate' || s.position === 'fixed' || s.webkitOverflowScrolling === 'touch') {
  4117. return true;
  4118. }
  4119. el = el.parentElement;
  4120. }
  4121. return false;
  4122. }
  4123. function findNearestDialog(el) {
  4124. while (el) {
  4125. if (el.localName === 'dialog') {
  4126. return el;
  4127. }
  4128. if (el.parentElement) {
  4129. el = el.parentElement;
  4130. } else if (el.parentNode) {
  4131. el = el.parentNode.host;
  4132. } else {
  4133. el = null;
  4134. }
  4135. }
  4136. return null;
  4137. }
  4138. function safeBlur(el) {
  4139. while (el && el.shadowRoot && el.shadowRoot.activeElement) {
  4140. el = el.shadowRoot.activeElement;
  4141. }
  4142. if (el && el.blur && el !== document.body) {
  4143. el.blur();
  4144. }
  4145. }
  4146. function inNodeList(nodeList, node) {
  4147. for (var i = 0; i < nodeList.length; ++i) {
  4148. if (nodeList[i] === node) {
  4149. return true;
  4150. }
  4151. }
  4152. return false;
  4153. }
  4154. function isFormMethodDialog(el) {
  4155. if (!el || !el.hasAttribute('method')) {
  4156. return false;
  4157. }
  4158. return el.getAttribute('method').toLowerCase() === 'dialog';
  4159. }
  4160. function findFocusableElementWithin(hostElement) {
  4161. var opts = ['button', 'input', 'keygen', 'select', 'textarea'];
  4162. var query = opts.map(function (el) {
  4163. return el + ':not([disabled])';
  4164. });
  4165. query.push('[tabindex]:not([disabled]):not([tabindex=""])');
  4166. var target = hostElement.querySelector(query.join(', '));
  4167. if (!target && 'attachShadow' in Element.prototype) {
  4168. var elems = hostElement.querySelectorAll('*');
  4169. for (var i = 0; i < elems.length; i++) {
  4170. if (elems[i].tagName && elems[i].shadowRoot) {
  4171. target = findFocusableElementWithin(elems[i].shadowRoot);
  4172. if (target) {
  4173. break;
  4174. }
  4175. }
  4176. }
  4177. }
  4178. return target;
  4179. }
  4180. function isConnected(element) {
  4181. return element.isConnected || document.body.contains(element);
  4182. }
  4183. function findFormSubmitter(event) {
  4184. if (event.submitter) {
  4185. return event.submitter;
  4186. }
  4187. var form = event.target;
  4188. if (!(form instanceof HTMLFormElement)) {
  4189. return null;
  4190. }
  4191. var submitter = dialogPolyfill.formSubmitter;
  4192. if (!submitter) {
  4193. var target = event.target;
  4194. var root = 'getRootNode' in target && target.getRootNode() || document;
  4195. submitter = root.activeElement;
  4196. }
  4197. if (!submitter || submitter.form !== form) {
  4198. return null;
  4199. }
  4200. return submitter;
  4201. }
  4202. function maybeHandleSubmit(event) {
  4203. if (event.defaultPrevented) {
  4204. return;
  4205. }
  4206. var form = event.target;
  4207. var value = dialogPolyfill.imagemapUseValue;
  4208. var submitter = findFormSubmitter(event);
  4209. if (value === null && submitter) {
  4210. value = submitter.value;
  4211. }
  4212. var dialog = findNearestDialog(form);
  4213. if (!dialog) {
  4214. return;
  4215. }
  4216. var formmethod = submitter && submitter.getAttribute('formmethod') || form.getAttribute('method');
  4217. if (formmethod !== 'dialog') {
  4218. return;
  4219. }
  4220. event.preventDefault();
  4221. if (value != null) {
  4222. dialog.close(value);
  4223. } else {
  4224. dialog.close();
  4225. }
  4226. }
  4227. function dialogPolyfillInfo(dialog) {
  4228. this.dialog_ = dialog;
  4229. this.replacedStyleTop_ = false;
  4230. this.openAsModal_ = false;
  4231. if (!dialog.hasAttribute('role')) {
  4232. dialog.setAttribute('role', 'dialog');
  4233. }
  4234. dialog.show = this.show.bind(this);
  4235. dialog.showModal = this.showModal.bind(this);
  4236. dialog.close = this.close.bind(this);
  4237. dialog.addEventListener('submit', maybeHandleSubmit, false);
  4238. if (!('returnValue' in dialog)) {
  4239. dialog.returnValue = '';
  4240. }
  4241. if ('MutationObserver' in window) {
  4242. var mo = new MutationObserver(this.maybeHideModal.bind(this));
  4243. mo.observe(dialog, {
  4244. attributes: true,
  4245. attributeFilter: ['open']
  4246. });
  4247. } else {
  4248. var removed = false;
  4249. var cb = function () {
  4250. removed ? this.downgradeModal() : this.maybeHideModal();
  4251. removed = false;
  4252. }.bind(this);
  4253. var timeout;
  4254. var delayModel = function (ev) {
  4255. if (ev.target !== dialog) {
  4256. return;
  4257. }
  4258. var cand = 'DOMNodeRemoved';
  4259. removed |= ev.type.substr(0, cand.length) === cand;
  4260. window.clearTimeout(timeout);
  4261. timeout = window.setTimeout(cb, 0);
  4262. };
  4263. ['DOMAttrModified', 'DOMNodeRemoved', 'DOMNodeRemovedFromDocument'].forEach(function (name) {
  4264. dialog.addEventListener(name, delayModel);
  4265. });
  4266. }
  4267. Object.defineProperty(dialog, 'open', {
  4268. set: this.setOpen.bind(this),
  4269. get: dialog.hasAttribute.bind(dialog, 'open')
  4270. });
  4271. this.backdrop_ = document.createElement('div');
  4272. this.backdrop_.className = 'backdrop';
  4273. this.backdrop_.addEventListener('mouseup', this.backdropMouseEvent_.bind(this));
  4274. this.backdrop_.addEventListener('mousedown', this.backdropMouseEvent_.bind(this));
  4275. this.backdrop_.addEventListener('click', this.backdropMouseEvent_.bind(this));
  4276. }
  4277. dialogPolyfillInfo.prototype = {
  4278. get dialog() {
  4279. return this.dialog_;
  4280. },
  4281. maybeHideModal: function () {
  4282. if (this.dialog_.hasAttribute('open') && isConnected(this.dialog_)) {
  4283. return;
  4284. }
  4285. this.downgradeModal();
  4286. },
  4287. downgradeModal: function () {
  4288. if (!this.openAsModal_) {
  4289. return;
  4290. }
  4291. this.openAsModal_ = false;
  4292. this.dialog_.style.zIndex = '';
  4293. if (this.replacedStyleTop_) {
  4294. this.dialog_.style.top = '';
  4295. this.replacedStyleTop_ = false;
  4296. }
  4297. this.backdrop_.parentNode && this.backdrop_.parentNode.removeChild(this.backdrop_);
  4298. dialogPolyfill.dm.removeDialog(this);
  4299. },
  4300. setOpen: function (value) {
  4301. if (value) {
  4302. this.dialog_.hasAttribute('open') || this.dialog_.setAttribute('open', '');
  4303. } else {
  4304. this.dialog_.removeAttribute('open');
  4305. this.maybeHideModal();
  4306. }
  4307. },
  4308. backdropMouseEvent_: function (e) {
  4309. if (!this.dialog_.hasAttribute('tabindex')) {
  4310. var fake = document.createElement('div');
  4311. this.dialog_.insertBefore(fake, this.dialog_.firstChild);
  4312. fake.tabIndex = -1;
  4313. fake.focus();
  4314. this.dialog_.removeChild(fake);
  4315. } else {
  4316. this.dialog_.focus();
  4317. }
  4318. var redirectedEvent = document.createEvent('MouseEvents');
  4319. redirectedEvent.initMouseEvent(e.type, e.bubbles, e.cancelable, window, e.detail, e.screenX, e.screenY, e.clientX, e.clientY, e.ctrlKey, e.altKey, e.shiftKey, e.metaKey, e.button, e.relatedTarget);
  4320. this.dialog_.dispatchEvent(redirectedEvent);
  4321. e.stopPropagation();
  4322. },
  4323. focus_: function () {
  4324. var target = this.dialog_.querySelector('[autofocus]:not([disabled])');
  4325. if (!target && this.dialog_.tabIndex >= 0) {
  4326. target = this.dialog_;
  4327. }
  4328. if (!target) {
  4329. target = findFocusableElementWithin(this.dialog_);
  4330. }
  4331. safeBlur(document.activeElement);
  4332. target && target.focus();
  4333. },
  4334. updateZIndex: function (dialogZ, backdropZ) {
  4335. if (dialogZ < backdropZ) {
  4336. throw new Error('dialogZ should never be < backdropZ');
  4337. }
  4338. this.dialog_.style.zIndex = dialogZ;
  4339. this.backdrop_.style.zIndex = backdropZ;
  4340. },
  4341. show: function () {
  4342. if (!this.dialog_.open) {
  4343. this.setOpen(true);
  4344. this.focus_();
  4345. }
  4346. },
  4347. showModal: function () {
  4348. if (this.dialog_.hasAttribute('open')) {
  4349. throw new Error('Failed to execute \'showModal\' on dialog: The element is already open, and therefore cannot be opened modally.');
  4350. }
  4351. if (!isConnected(this.dialog_)) {
  4352. throw new Error('Failed to execute \'showModal\' on dialog: The element is not in a Document.');
  4353. }
  4354. if (!dialogPolyfill.dm.pushDialog(this)) {
  4355. throw new Error('Failed to execute \'showModal\' on dialog: There are too many open modal dialogs.');
  4356. }
  4357. if (createsStackingContext(this.dialog_.parentElement)) {
  4358. console.warn('A dialog is being shown inside a stacking context. ' + 'This may cause it to be unusable. For more information, see this link: ' + 'https://github.com/GoogleChrome/dialog-polyfill/#stacking-context');
  4359. }
  4360. this.setOpen(true);
  4361. this.openAsModal_ = true;
  4362. if (dialogPolyfill.needsCentering(this.dialog_)) {
  4363. dialogPolyfill.reposition(this.dialog_);
  4364. this.replacedStyleTop_ = true;
  4365. } else {
  4366. this.replacedStyleTop_ = false;
  4367. }
  4368. this.dialog_.parentNode.insertBefore(this.backdrop_, this.dialog_.nextSibling);
  4369. this.focus_();
  4370. },
  4371. close: function (opt_returnValue) {
  4372. if (!this.dialog_.hasAttribute('open')) {
  4373. throw new Error('Failed to execute \'close\' on dialog: The element does not have an \'open\' attribute, and therefore cannot be closed.');
  4374. }
  4375. this.setOpen(false);
  4376. if (opt_returnValue !== undefined) {
  4377. this.dialog_.returnValue = opt_returnValue;
  4378. }
  4379. var closeEvent = new supportCustomEvent('close', {
  4380. bubbles: false,
  4381. cancelable: false
  4382. });
  4383. safeDispatchEvent(this.dialog_, closeEvent);
  4384. }
  4385. };
  4386. var dialogPolyfill = {};
  4387. dialogPolyfill.reposition = function (element) {
  4388. var scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
  4389. var topValue = scrollTop + (window.innerHeight - element.offsetHeight) / 2;
  4390. element.style.top = Math.max(scrollTop, topValue) + 'px';
  4391. };
  4392. dialogPolyfill.isInlinePositionSetByStylesheet = function (element) {
  4393. for (var i = 0; i < document.styleSheets.length; ++i) {
  4394. var styleSheet = document.styleSheets[i];
  4395. var cssRules = null;
  4396. try {
  4397. cssRules = styleSheet.cssRules;
  4398. } catch (e) { }
  4399. if (!cssRules) {
  4400. continue;
  4401. }
  4402. for (var j = 0; j < cssRules.length; ++j) {
  4403. var rule = cssRules[j];
  4404. var selectedNodes = null;
  4405. try {
  4406. selectedNodes = document.querySelectorAll(rule.selectorText);
  4407. } catch (e) { }
  4408. if (!selectedNodes || !inNodeList(selectedNodes, element)) {
  4409. continue;
  4410. }
  4411. var cssTop = rule.style.getPropertyValue('top');
  4412. var cssBottom = rule.style.getPropertyValue('bottom');
  4413. if (cssTop && cssTop !== 'auto' || cssBottom && cssBottom !== 'auto') {
  4414. return true;
  4415. }
  4416. }
  4417. }
  4418. return false;
  4419. };
  4420. dialogPolyfill.needsCentering = function (dialog) {
  4421. var computedStyle = window.getComputedStyle(dialog);
  4422. if (computedStyle.position !== 'absolute') {
  4423. return false;
  4424. }
  4425. if (dialog.style.top !== 'auto' && dialog.style.top !== '' || dialog.style.bottom !== 'auto' && dialog.style.bottom !== '') {
  4426. return false;
  4427. }
  4428. return !dialogPolyfill.isInlinePositionSetByStylesheet(dialog);
  4429. };
  4430. dialogPolyfill.forceRegisterDialog = function (element) {
  4431. if (window.HTMLDialogElement || element.showModal) {
  4432. console.warn('This browser already supports <dialog>, the polyfill ' + 'may not work correctly', element);
  4433. }
  4434. if (element.localName !== 'dialog') {
  4435. throw new Error('Failed to register dialog: The element is not a dialog.');
  4436. }
  4437. new dialogPolyfillInfo(element);
  4438. };
  4439. dialogPolyfill.registerDialog = function (element) {
  4440. if (!element.showModal) {
  4441. dialogPolyfill.forceRegisterDialog(element);
  4442. }
  4443. };
  4444. dialogPolyfill.DialogManager = function () {
  4445. this.pendingDialogStack = [];
  4446. var checkDOM = this.checkDOM_.bind(this);
  4447. this.overlay = document.createElement('div');
  4448. this.overlay.className = '_dialog_overlay';
  4449. this.overlay.addEventListener('click', function (e) {
  4450. this.forwardTab_ = undefined;
  4451. e.stopPropagation();
  4452. checkDOM([]);
  4453. }.bind(this));
  4454. this.handleKey_ = this.handleKey_.bind(this);
  4455. this.handleFocus_ = this.handleFocus_.bind(this);
  4456. this.zIndexLow_ = 100000;
  4457. this.zIndexHigh_ = 100000 + 150;
  4458. this.forwardTab_ = undefined;
  4459. if ('MutationObserver' in window) {
  4460. this.mo_ = new MutationObserver(function (records) {
  4461. var removed = [];
  4462. records.forEach(function (rec) {
  4463. for (var i = 0, c; c = rec.removedNodes[i]; ++i) {
  4464. if (!(c instanceof Element)) {
  4465. continue;
  4466. } else if (c.localName === 'dialog') {
  4467. removed.push(c);
  4468. }
  4469. removed = removed.concat(c.querySelectorAll('dialog'));
  4470. }
  4471. });
  4472. removed.length && checkDOM(removed);
  4473. });
  4474. }
  4475. };
  4476. dialogPolyfill.DialogManager.prototype.blockDocument = function () {
  4477. document.documentElement.addEventListener('focus', this.handleFocus_, true);
  4478. document.addEventListener('keydown', this.handleKey_);
  4479. this.mo_ && this.mo_.observe(document, {
  4480. childList: true,
  4481. subtree: true
  4482. });
  4483. };
  4484. dialogPolyfill.DialogManager.prototype.unblockDocument = function () {
  4485. document.documentElement.removeEventListener('focus', this.handleFocus_, true);
  4486. document.removeEventListener('keydown', this.handleKey_);
  4487. this.mo_ && this.mo_.disconnect();
  4488. };
  4489. dialogPolyfill.DialogManager.prototype.updateStacking = function () {
  4490. var zIndex = this.zIndexHigh_;
  4491. for (var i = 0, dpi; dpi = this.pendingDialogStack[i]; ++i) {
  4492. dpi.updateZIndex(--zIndex, --zIndex);
  4493. if (i === 0) {
  4494. this.overlay.style.zIndex = --zIndex;
  4495. }
  4496. }
  4497. var last = this.pendingDialogStack[0];
  4498. if (last) {
  4499. var p = last.dialog.parentNode || document.body;
  4500. p.appendChild(this.overlay);
  4501. } else if (this.overlay.parentNode) {
  4502. this.overlay.parentNode.removeChild(this.overlay);
  4503. }
  4504. };
  4505. dialogPolyfill.DialogManager.prototype.containedByTopDialog_ = function (candidate) {
  4506. while (candidate = findNearestDialog(candidate)) {
  4507. for (var i = 0, dpi; dpi = this.pendingDialogStack[i]; ++i) {
  4508. if (dpi.dialog === candidate) {
  4509. return i === 0;
  4510. }
  4511. }
  4512. candidate = candidate.parentElement;
  4513. }
  4514. return false;
  4515. };
  4516. dialogPolyfill.DialogManager.prototype.handleFocus_ = function (event) {
  4517. var target = event.composedPath ? event.composedPath()[0] : event.target;
  4518. if (this.containedByTopDialog_(target)) {
  4519. return;
  4520. }
  4521. if (document.activeElement === document.documentElement) {
  4522. return;
  4523. }
  4524. event.preventDefault();
  4525. event.stopPropagation();
  4526. safeBlur(target);
  4527. if (this.forwardTab_ === undefined) {
  4528. return;
  4529. }
  4530. var dpi = this.pendingDialogStack[0];
  4531. var dialog = dpi.dialog;
  4532. var position = dialog.compareDocumentPosition(target);
  4533. if (position & Node.DOCUMENT_POSITION_PRECEDING) {
  4534. if (this.forwardTab_) {
  4535. dpi.focus_();
  4536. } else if (target !== document.documentElement) {
  4537. document.documentElement.focus();
  4538. }
  4539. }
  4540. return false;
  4541. };
  4542. dialogPolyfill.DialogManager.prototype.handleKey_ = function (event) {
  4543. this.forwardTab_ = undefined;
  4544. if (event.keyCode === 27) {
  4545. event.preventDefault();
  4546. event.stopPropagation();
  4547. var cancelEvent = new supportCustomEvent('cancel', {
  4548. bubbles: false,
  4549. cancelable: true
  4550. });
  4551. var dpi = this.pendingDialogStack[0];
  4552. if (dpi && safeDispatchEvent(dpi.dialog, cancelEvent)) {
  4553. dpi.dialog.close();
  4554. }
  4555. } else if (event.keyCode === 9) {
  4556. this.forwardTab_ = !event.shiftKey;
  4557. }
  4558. };
  4559. dialogPolyfill.DialogManager.prototype.checkDOM_ = function (removed) {
  4560. var clone = this.pendingDialogStack.slice();
  4561. clone.forEach(function (dpi) {
  4562. if (removed.indexOf(dpi.dialog) !== -1) {
  4563. dpi.downgradeModal();
  4564. } else {
  4565. dpi.maybeHideModal();
  4566. }
  4567. });
  4568. };
  4569. dialogPolyfill.DialogManager.prototype.pushDialog = function (dpi) {
  4570. var allowed = (this.zIndexHigh_ - this.zIndexLow_) / 2 - 1;
  4571. if (this.pendingDialogStack.length >= allowed) {
  4572. return false;
  4573. }
  4574. if (this.pendingDialogStack.unshift(dpi) === 1) {
  4575. this.blockDocument();
  4576. }
  4577. this.updateStacking();
  4578. return true;
  4579. };
  4580. dialogPolyfill.DialogManager.prototype.removeDialog = function (dpi) {
  4581. var index = this.pendingDialogStack.indexOf(dpi);
  4582. if (index === -1) {
  4583. return;
  4584. }
  4585. this.pendingDialogStack.splice(index, 1);
  4586. if (this.pendingDialogStack.length === 0) {
  4587. this.unblockDocument();
  4588. }
  4589. this.updateStacking();
  4590. };
  4591. dialogPolyfill.dm = new dialogPolyfill.DialogManager();
  4592. dialogPolyfill.formSubmitter = null;
  4593. dialogPolyfill.imagemapUseValue = null;
  4594. if (window.HTMLDialogElement === undefined) {
  4595. var testForm = document.createElement('form');
  4596. testForm.setAttribute('method', 'dialog');
  4597. if (testForm.method !== 'dialog') {
  4598. var methodDescriptor = Object.getOwnPropertyDescriptor(HTMLFormElement.prototype, 'method');
  4599. if (methodDescriptor) {
  4600. var realGet = methodDescriptor.get;
  4601. methodDescriptor.get = function () {
  4602. if (isFormMethodDialog(this)) {
  4603. return 'dialog';
  4604. }
  4605. return realGet.call(this);
  4606. };
  4607. var realSet = methodDescriptor.set;
  4608. methodDescriptor.set = function (v) {
  4609. if (typeof v === 'string' && v.toLowerCase() === 'dialog') {
  4610. return this.setAttribute('method', v);
  4611. }
  4612. return realSet.call(this, v);
  4613. };
  4614. Object.defineProperty(HTMLFormElement.prototype, 'method', methodDescriptor);
  4615. }
  4616. }
  4617. document.addEventListener('click', function (ev) {
  4618. dialogPolyfill.formSubmitter = null;
  4619. dialogPolyfill.imagemapUseValue = null;
  4620. if (ev.defaultPrevented) {
  4621. return;
  4622. }
  4623. var target = ev.target;
  4624. if ('composedPath' in ev) {
  4625. var path = ev.composedPath();
  4626. target = path.shift() || target;
  4627. }
  4628. if (!target || !isFormMethodDialog(target.form)) {
  4629. return;
  4630. }
  4631. var valid = target.type === 'submit' && ['button', 'input'].indexOf(target.localName) > -1;
  4632. if (!valid) {
  4633. if (!(target.localName === 'input' && target.type === 'image')) {
  4634. return;
  4635. }
  4636. dialogPolyfill.imagemapUseValue = ev.offsetX + ',' + ev.offsetY;
  4637. }
  4638. var dialog = findNearestDialog(target);
  4639. if (!dialog) {
  4640. return;
  4641. }
  4642. dialogPolyfill.formSubmitter = target;
  4643. }, false);
  4644. document.addEventListener('submit', function (ev) {
  4645. var form = ev.target;
  4646. var dialog = findNearestDialog(form);
  4647. if (dialog) {
  4648. return;
  4649. }
  4650. var submitter = findFormSubmitter(ev);
  4651. var formmethod = submitter && submitter.getAttribute('formmethod') || form.getAttribute('method');
  4652. if (formmethod === 'dialog') {
  4653. ev.preventDefault();
  4654. }
  4655. });
  4656. var nativeFormSubmit = HTMLFormElement.prototype.submit;
  4657. var replacementFormSubmit = function () {
  4658. if (!isFormMethodDialog(this)) {
  4659. return nativeFormSubmit.call(this);
  4660. }
  4661. var dialog = findNearestDialog(this);
  4662. dialog && dialog.close();
  4663. };
  4664. HTMLFormElement.prototype.submit = replacementFormSubmit;
  4665. }
  4666. return dialogPolyfill;
  4667. });
  4668. /***/
  4669. }),
  4670. /* 11 */
  4671. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  4672. Object.defineProperty(exports, "__esModule", ({
  4673. value: true
  4674. }));
  4675. exports.PasswordPrompt = void 0;
  4676. var _pdfjsLib = __webpack_require__(4);
  4677. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  4678. function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
  4679. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  4680. function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
  4681. function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
  4682. function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
  4683. function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
  4684. function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
  4685. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  4686. var _activeCapability = /*#__PURE__*/new WeakMap();
  4687. var _updateCallback = /*#__PURE__*/new WeakMap();
  4688. var _reason = /*#__PURE__*/new WeakMap();
  4689. var _verify = /*#__PURE__*/new WeakSet();
  4690. var _cancel = /*#__PURE__*/new WeakSet();
  4691. var _invokeCallback = /*#__PURE__*/new WeakSet();
  4692. class PasswordPrompt {
  4693. constructor(options, overlayManager, l10n) {
  4694. let isViewerEmbedded = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  4695. _classPrivateMethodInitSpec(this, _invokeCallback);
  4696. _classPrivateMethodInitSpec(this, _cancel);
  4697. _classPrivateMethodInitSpec(this, _verify);
  4698. _classPrivateFieldInitSpec(this, _activeCapability, {
  4699. writable: true,
  4700. value: null
  4701. });
  4702. _classPrivateFieldInitSpec(this, _updateCallback, {
  4703. writable: true,
  4704. value: null
  4705. });
  4706. _classPrivateFieldInitSpec(this, _reason, {
  4707. writable: true,
  4708. value: null
  4709. });
  4710. this.dialog = options.dialog;
  4711. this.label = options.label;
  4712. this.input = options.input;
  4713. this.submitButton = options.submitButton;
  4714. this.cancelButton = options.cancelButton;
  4715. this.overlayManager = overlayManager;
  4716. this.l10n = l10n;
  4717. this._isViewerEmbedded = isViewerEmbedded;
  4718. this.submitButton.addEventListener("click", _classPrivateMethodGet(this, _verify, _verify2).bind(this));
  4719. this.cancelButton.addEventListener("click", this.close.bind(this));
  4720. this.input.addEventListener("keydown", e => {
  4721. if (e.keyCode === 13) {
  4722. _classPrivateMethodGet(this, _verify, _verify2).call(this);
  4723. }
  4724. });
  4725. this.overlayManager.register(this.dialog, true);
  4726. this.dialog.addEventListener("close", _classPrivateMethodGet(this, _cancel, _cancel2).bind(this));
  4727. }
  4728. async open() {
  4729. if (_classPrivateFieldGet(this, _activeCapability)) {
  4730. await _classPrivateFieldGet(this, _activeCapability).promise;
  4731. }
  4732. _classPrivateFieldSet(this, _activeCapability, (0, _pdfjsLib.createPromiseCapability)());
  4733. try {
  4734. await this.overlayManager.open(this.dialog);
  4735. } catch (ex) {
  4736. _classPrivateFieldSet(this, _activeCapability, null);
  4737. throw ex;
  4738. }
  4739. const passwordIncorrect = _classPrivateFieldGet(this, _reason) === _pdfjsLib.PasswordResponses.INCORRECT_PASSWORD;
  4740. if (!this._isViewerEmbedded || passwordIncorrect) {
  4741. this.input.focus();
  4742. }
  4743. this.label.textContent = await this.l10n.get(`password_${passwordIncorrect ? "invalid" : "label"}`);
  4744. }
  4745. async close() {
  4746. if (this.overlayManager.active === this.dialog) {
  4747. this.overlayManager.close(this.dialog);
  4748. }
  4749. }
  4750. async setUpdateCallback(updateCallback, reason) {
  4751. if (_classPrivateFieldGet(this, _activeCapability)) {
  4752. await _classPrivateFieldGet(this, _activeCapability).promise;
  4753. }
  4754. _classPrivateFieldSet(this, _updateCallback, updateCallback);
  4755. _classPrivateFieldSet(this, _reason, reason);
  4756. }
  4757. }
  4758. exports.PasswordPrompt = PasswordPrompt;
  4759. function _verify2() {
  4760. const password = this.input.value;
  4761. if ((password === null || password === void 0 ? void 0 : password.length) > 0) {
  4762. _classPrivateMethodGet(this, _invokeCallback, _invokeCallback2).call(this, password);
  4763. }
  4764. }
  4765. function _cancel2() {
  4766. _classPrivateMethodGet(this, _invokeCallback, _invokeCallback2).call(this, new Error("PasswordPrompt cancelled."));
  4767. _classPrivateFieldGet(this, _activeCapability).resolve();
  4768. }
  4769. function _invokeCallback2(password) {
  4770. if (!_classPrivateFieldGet(this, _updateCallback)) {
  4771. return;
  4772. }
  4773. this.close();
  4774. this.input.value = "";
  4775. _classPrivateFieldGet(this, _updateCallback).call(this, password);
  4776. _classPrivateFieldSet(this, _updateCallback, null);
  4777. }
  4778. /***/
  4779. }),
  4780. /* 12 */
  4781. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  4782. Object.defineProperty(exports, "__esModule", ({
  4783. value: true
  4784. }));
  4785. exports.PDFAttachmentViewer = void 0;
  4786. var _pdfjsLib = __webpack_require__(4);
  4787. var _base_tree_viewer = __webpack_require__(13);
  4788. var _event_utils = __webpack_require__(6);
  4789. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  4790. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  4791. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  4792. var _appendAttachment = /*#__PURE__*/new WeakSet();
  4793. class PDFAttachmentViewer extends _base_tree_viewer.BaseTreeViewer {
  4794. constructor(options) {
  4795. super(options);
  4796. _classPrivateMethodInitSpec(this, _appendAttachment);
  4797. this.downloadManager = options.downloadManager;
  4798. this.eventBus._on("fileattachmentannotation", _classPrivateMethodGet(this, _appendAttachment, _appendAttachment2).bind(this));
  4799. }
  4800. reset() {
  4801. let keepRenderedCapability = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4802. super.reset();
  4803. this._attachments = null;
  4804. if (!keepRenderedCapability) {
  4805. this._renderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  4806. }
  4807. this._pendingDispatchEvent = false;
  4808. }
  4809. async _dispatchEvent(attachmentsCount) {
  4810. this._renderedCapability.resolve();
  4811. if (attachmentsCount === 0 && !this._pendingDispatchEvent) {
  4812. this._pendingDispatchEvent = true;
  4813. await (0, _event_utils.waitOnEventOrTimeout)({
  4814. target: this.eventBus,
  4815. name: "annotationlayerrendered",
  4816. delay: 1000
  4817. });
  4818. if (!this._pendingDispatchEvent) {
  4819. return;
  4820. }
  4821. }
  4822. this._pendingDispatchEvent = false;
  4823. this.eventBus.dispatch("attachmentsloaded", {
  4824. source: this,
  4825. attachmentsCount
  4826. });
  4827. }
  4828. _bindLink(element, _ref) {
  4829. let {
  4830. content,
  4831. filename
  4832. } = _ref;
  4833. element.onclick = () => {
  4834. this.downloadManager.openOrDownloadData(element, content, filename);
  4835. return false;
  4836. };
  4837. }
  4838. render(_ref2) {
  4839. let {
  4840. attachments,
  4841. keepRenderedCapability = false
  4842. } = _ref2;
  4843. if (this._attachments) {
  4844. this.reset(keepRenderedCapability);
  4845. }
  4846. this._attachments = attachments || null;
  4847. if (!attachments) {
  4848. this._dispatchEvent(0);
  4849. return;
  4850. }
  4851. const names = Object.keys(attachments).sort(function (a, b) {
  4852. return a.toLowerCase().localeCompare(b.toLowerCase());
  4853. });
  4854. const fragment = document.createDocumentFragment();
  4855. let attachmentsCount = 0;
  4856. for (const name of names) {
  4857. const item = attachments[name];
  4858. const content = item.content,
  4859. filename = (0, _pdfjsLib.getFilenameFromUrl)(item.filename, true);
  4860. const div = document.createElement("div");
  4861. div.className = "treeItem";
  4862. const element = document.createElement("a");
  4863. this._bindLink(element, {
  4864. content,
  4865. filename
  4866. });
  4867. element.textContent = this._normalizeTextContent(filename);
  4868. div.append(element);
  4869. fragment.append(div);
  4870. attachmentsCount++;
  4871. }
  4872. this._finishRendering(fragment, attachmentsCount);
  4873. }
  4874. }
  4875. exports.PDFAttachmentViewer = PDFAttachmentViewer;
  4876. function _appendAttachment2(_ref3) {
  4877. let {
  4878. filename,
  4879. content
  4880. } = _ref3;
  4881. const renderedPromise = this._renderedCapability.promise;
  4882. renderedPromise.then(() => {
  4883. if (renderedPromise !== this._renderedCapability.promise) {
  4884. return;
  4885. }
  4886. const attachments = this._attachments || Object.create(null);
  4887. for (const name in attachments) {
  4888. if (filename === name) {
  4889. return;
  4890. }
  4891. }
  4892. attachments[filename] = {
  4893. filename,
  4894. content
  4895. };
  4896. this.render({
  4897. attachments,
  4898. keepRenderedCapability: true
  4899. });
  4900. });
  4901. }
  4902. /***/
  4903. }),
  4904. /* 13 */
  4905. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  4906. Object.defineProperty(exports, "__esModule", ({
  4907. value: true
  4908. }));
  4909. exports.BaseTreeViewer = void 0;
  4910. var _ui_utils = __webpack_require__(3);
  4911. const TREEITEM_OFFSET_TOP = -100;
  4912. const TREEITEM_SELECTED_CLASS = "selected";
  4913. class BaseTreeViewer {
  4914. constructor(options) {
  4915. if (this.constructor === BaseTreeViewer) {
  4916. throw new Error("Cannot initialize BaseTreeViewer.");
  4917. }
  4918. this.container = options.container;
  4919. this.eventBus = options.eventBus;
  4920. this.reset();
  4921. }
  4922. reset() {
  4923. this._pdfDocument = null;
  4924. this._lastToggleIsShow = true;
  4925. this._currentTreeItem = null;
  4926. this.container.textContent = "";
  4927. this.container.classList.remove("treeWithDeepNesting");
  4928. }
  4929. _dispatchEvent(count) {
  4930. throw new Error("Not implemented: _dispatchEvent");
  4931. }
  4932. _bindLink(element, params) {
  4933. throw new Error("Not implemented: _bindLink");
  4934. }
  4935. _normalizeTextContent(str) {
  4936. return (0, _ui_utils.removeNullCharacters)(str, true) || "\u2013";
  4937. }
  4938. _addToggleButton(div) {
  4939. let hidden = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4940. const toggler = document.createElement("div");
  4941. toggler.className = "treeItemToggler";
  4942. if (hidden) {
  4943. toggler.classList.add("treeItemsHidden");
  4944. }
  4945. toggler.onclick = evt => {
  4946. evt.stopPropagation();
  4947. toggler.classList.toggle("treeItemsHidden");
  4948. if (evt.shiftKey) {
  4949. const shouldShowAll = !toggler.classList.contains("treeItemsHidden");
  4950. this._toggleTreeItem(div, shouldShowAll);
  4951. }
  4952. };
  4953. div.prepend(toggler);
  4954. }
  4955. _toggleTreeItem(root) {
  4956. let show = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4957. this._lastToggleIsShow = show;
  4958. for (const toggler of root.querySelectorAll(".treeItemToggler")) {
  4959. toggler.classList.toggle("treeItemsHidden", !show);
  4960. }
  4961. }
  4962. _toggleAllTreeItems() {
  4963. this._toggleTreeItem(this.container, !this._lastToggleIsShow);
  4964. }
  4965. _finishRendering(fragment, count) {
  4966. let hasAnyNesting = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  4967. if (hasAnyNesting) {
  4968. this.container.classList.add("treeWithDeepNesting");
  4969. this._lastToggleIsShow = !fragment.querySelector(".treeItemsHidden");
  4970. }
  4971. this.container.append(fragment);
  4972. this._dispatchEvent(count);
  4973. }
  4974. render(params) {
  4975. throw new Error("Not implemented: render");
  4976. }
  4977. _updateCurrentTreeItem() {
  4978. let treeItem = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  4979. if (this._currentTreeItem) {
  4980. this._currentTreeItem.classList.remove(TREEITEM_SELECTED_CLASS);
  4981. this._currentTreeItem = null;
  4982. }
  4983. if (treeItem) {
  4984. treeItem.classList.add(TREEITEM_SELECTED_CLASS);
  4985. this._currentTreeItem = treeItem;
  4986. }
  4987. }
  4988. _scrollToCurrentTreeItem(treeItem) {
  4989. if (!treeItem) {
  4990. return;
  4991. }
  4992. let currentNode = treeItem.parentNode;
  4993. while (currentNode && currentNode !== this.container) {
  4994. if (currentNode.classList.contains("treeItem")) {
  4995. const toggler = currentNode.firstElementChild;
  4996. toggler === null || toggler === void 0 ? void 0 : toggler.classList.remove("treeItemsHidden");
  4997. }
  4998. currentNode = currentNode.parentNode;
  4999. }
  5000. this._updateCurrentTreeItem(treeItem);
  5001. this.container.scrollTo(treeItem.offsetLeft, treeItem.offsetTop + TREEITEM_OFFSET_TOP);
  5002. }
  5003. }
  5004. exports.BaseTreeViewer = BaseTreeViewer;
  5005. /***/
  5006. }),
  5007. /* 14 */
  5008. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5009. Object.defineProperty(exports, "__esModule", ({
  5010. value: true
  5011. }));
  5012. exports.PDFCursorTools = void 0;
  5013. var _ui_utils = __webpack_require__(3);
  5014. var _pdfjsLib = __webpack_require__(4);
  5015. var _grab_to_pan = __webpack_require__(15);
  5016. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  5017. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  5018. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  5019. var _dispatchEvent = /*#__PURE__*/new WeakSet();
  5020. var _addEventListeners = /*#__PURE__*/new WeakSet();
  5021. class PDFCursorTools {
  5022. constructor(_ref) {
  5023. let {
  5024. container,
  5025. eventBus,
  5026. cursorToolOnLoad = _ui_utils.CursorTool.SELECT
  5027. } = _ref;
  5028. _classPrivateMethodInitSpec(this, _addEventListeners);
  5029. _classPrivateMethodInitSpec(this, _dispatchEvent);
  5030. this.container = container;
  5031. this.eventBus = eventBus;
  5032. this.active = _ui_utils.CursorTool.SELECT;
  5033. this.previouslyActive = null;
  5034. this.handTool = new _grab_to_pan.GrabToPan({
  5035. element: this.container
  5036. });
  5037. _classPrivateMethodGet(this, _addEventListeners, _addEventListeners2).call(this);
  5038. Promise.resolve().then(() => {
  5039. this.switchTool(cursorToolOnLoad);
  5040. });
  5041. }
  5042. get activeTool() {
  5043. return this.active;
  5044. }
  5045. switchTool(tool) {
  5046. if (this.previouslyActive !== null) {
  5047. return;
  5048. }
  5049. if (tool === this.active) {
  5050. return;
  5051. }
  5052. const disableActiveTool = () => {
  5053. switch (this.active) {
  5054. case _ui_utils.CursorTool.SELECT:
  5055. break;
  5056. case _ui_utils.CursorTool.HAND:
  5057. this.handTool.deactivate();
  5058. break;
  5059. case _ui_utils.CursorTool.ZOOM:
  5060. }
  5061. };
  5062. switch (tool) {
  5063. case _ui_utils.CursorTool.SELECT:
  5064. disableActiveTool();
  5065. break;
  5066. case _ui_utils.CursorTool.HAND:
  5067. disableActiveTool();
  5068. this.handTool.activate();
  5069. break;
  5070. case _ui_utils.CursorTool.ZOOM:
  5071. default:
  5072. console.error(`switchTool: "${tool}" is an unsupported value.`);
  5073. return;
  5074. }
  5075. this.active = tool;
  5076. _classPrivateMethodGet(this, _dispatchEvent, _dispatchEvent2).call(this);
  5077. }
  5078. }
  5079. exports.PDFCursorTools = PDFCursorTools;
  5080. function _dispatchEvent2() {
  5081. this.eventBus.dispatch("cursortoolchanged", {
  5082. source: this,
  5083. tool: this.active
  5084. });
  5085. }
  5086. function _addEventListeners2() {
  5087. this.eventBus._on("switchcursortool", evt => {
  5088. this.switchTool(evt.tool);
  5089. });
  5090. let annotationEditorMode = _pdfjsLib.AnnotationEditorType.NONE,
  5091. presentationModeState = _ui_utils.PresentationModeState.NORMAL;
  5092. const disableActive = () => {
  5093. const previouslyActive = this.active;
  5094. this.switchTool(_ui_utils.CursorTool.SELECT);
  5095. this.previouslyActive ?? (this.previouslyActive = previouslyActive);
  5096. };
  5097. const enableActive = () => {
  5098. const previouslyActive = this.previouslyActive;
  5099. if (previouslyActive !== null && annotationEditorMode === _pdfjsLib.AnnotationEditorType.NONE && presentationModeState === _ui_utils.PresentationModeState.NORMAL) {
  5100. this.previouslyActive = null;
  5101. this.switchTool(previouslyActive);
  5102. }
  5103. };
  5104. this.eventBus._on("secondarytoolbarreset", evt => {
  5105. if (this.previouslyActive !== null) {
  5106. annotationEditorMode = _pdfjsLib.AnnotationEditorType.NONE;
  5107. presentationModeState = _ui_utils.PresentationModeState.NORMAL;
  5108. enableActive();
  5109. }
  5110. });
  5111. this.eventBus._on("annotationeditormodechanged", _ref2 => {
  5112. let {
  5113. mode
  5114. } = _ref2;
  5115. annotationEditorMode = mode;
  5116. if (mode === _pdfjsLib.AnnotationEditorType.NONE) {
  5117. enableActive();
  5118. } else {
  5119. disableActive();
  5120. }
  5121. });
  5122. this.eventBus._on("presentationmodechanged", _ref3 => {
  5123. let {
  5124. state
  5125. } = _ref3;
  5126. presentationModeState = state;
  5127. if (state === _ui_utils.PresentationModeState.NORMAL) {
  5128. enableActive();
  5129. } else if (state === _ui_utils.PresentationModeState.FULLSCREEN) {
  5130. disableActive();
  5131. }
  5132. });
  5133. }
  5134. /***/
  5135. }),
  5136. /* 15 */
  5137. /***/ ((__unused_webpack_module, exports) => {
  5138. Object.defineProperty(exports, "__esModule", ({
  5139. value: true
  5140. }));
  5141. exports.GrabToPan = void 0;
  5142. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  5143. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  5144. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  5145. const CSS_CLASS_GRAB = "grab-to-pan-grab";
  5146. var _onMouseDown = /*#__PURE__*/new WeakSet();
  5147. var _onMouseMove = /*#__PURE__*/new WeakSet();
  5148. var _endPan = /*#__PURE__*/new WeakSet();
  5149. class GrabToPan {
  5150. constructor(options) {
  5151. _classPrivateMethodInitSpec(this, _endPan);
  5152. _classPrivateMethodInitSpec(this, _onMouseMove);
  5153. _classPrivateMethodInitSpec(this, _onMouseDown);
  5154. this.element = options.element;
  5155. this.document = options.element.ownerDocument;
  5156. if (typeof options.ignoreTarget === "function") {
  5157. this.ignoreTarget = options.ignoreTarget;
  5158. }
  5159. this.onActiveChanged = options.onActiveChanged;
  5160. this.activate = this.activate.bind(this);
  5161. this.deactivate = this.deactivate.bind(this);
  5162. this.toggle = this.toggle.bind(this);
  5163. this._onMouseDown = _classPrivateMethodGet(this, _onMouseDown, _onMouseDown2).bind(this);
  5164. this._onMouseMove = _classPrivateMethodGet(this, _onMouseMove, _onMouseMove2).bind(this);
  5165. this._endPan = _classPrivateMethodGet(this, _endPan, _endPan2).bind(this);
  5166. const overlay = this.overlay = document.createElement("div");
  5167. overlay.className = "grab-to-pan-grabbing";
  5168. }
  5169. activate() {
  5170. if (!this.active) {
  5171. var _this$onActiveChanged;
  5172. this.active = true;
  5173. this.element.addEventListener("mousedown", this._onMouseDown, true);
  5174. this.element.classList.add(CSS_CLASS_GRAB);
  5175. (_this$onActiveChanged = this.onActiveChanged) === null || _this$onActiveChanged === void 0 ? void 0 : _this$onActiveChanged.call(this, true);
  5176. }
  5177. }
  5178. deactivate() {
  5179. if (this.active) {
  5180. var _this$onActiveChanged2;
  5181. this.active = false;
  5182. this.element.removeEventListener("mousedown", this._onMouseDown, true);
  5183. this._endPan();
  5184. this.element.classList.remove(CSS_CLASS_GRAB);
  5185. (_this$onActiveChanged2 = this.onActiveChanged) === null || _this$onActiveChanged2 === void 0 ? void 0 : _this$onActiveChanged2.call(this, false);
  5186. }
  5187. }
  5188. toggle() {
  5189. if (this.active) {
  5190. this.deactivate();
  5191. } else {
  5192. this.activate();
  5193. }
  5194. }
  5195. ignoreTarget(node) {
  5196. return node.matches("a[href], a[href] *, input, textarea, button, button *, select, option");
  5197. }
  5198. }
  5199. exports.GrabToPan = GrabToPan;
  5200. function _onMouseDown2(event) {
  5201. if (event.button !== 0 || this.ignoreTarget(event.target)) {
  5202. return;
  5203. }
  5204. if (event.originalTarget) {
  5205. try {
  5206. event.originalTarget.tagName;
  5207. } catch (e) {
  5208. return;
  5209. }
  5210. }
  5211. this.scrollLeftStart = this.element.scrollLeft;
  5212. this.scrollTopStart = this.element.scrollTop;
  5213. this.clientXStart = event.clientX;
  5214. this.clientYStart = event.clientY;
  5215. this.document.addEventListener("mousemove", this._onMouseMove, true);
  5216. this.document.addEventListener("mouseup", this._endPan, true);
  5217. this.element.addEventListener("scroll", this._endPan, true);
  5218. event.preventDefault();
  5219. event.stopPropagation();
  5220. const focusedElement = document.activeElement;
  5221. if (focusedElement && !focusedElement.contains(event.target)) {
  5222. focusedElement.blur();
  5223. }
  5224. }
  5225. function _onMouseMove2(event) {
  5226. this.element.removeEventListener("scroll", this._endPan, true);
  5227. if (!(event.buttons & 1)) {
  5228. this._endPan();
  5229. return;
  5230. }
  5231. const xDiff = event.clientX - this.clientXStart;
  5232. const yDiff = event.clientY - this.clientYStart;
  5233. const scrollTop = this.scrollTopStart - yDiff;
  5234. const scrollLeft = this.scrollLeftStart - xDiff;
  5235. if (this.element.scrollTo) {
  5236. this.element.scrollTo({
  5237. top: scrollTop,
  5238. left: scrollLeft,
  5239. behavior: "instant"
  5240. });
  5241. } else {
  5242. this.element.scrollTop = scrollTop;
  5243. this.element.scrollLeft = scrollLeft;
  5244. }
  5245. if (!this.overlay.parentNode) {
  5246. document.body.append(this.overlay);
  5247. }
  5248. }
  5249. function _endPan2() {
  5250. this.element.removeEventListener("scroll", this._endPan, true);
  5251. this.document.removeEventListener("mousemove", this._onMouseMove, true);
  5252. this.document.removeEventListener("mouseup", this._endPan, true);
  5253. this.overlay.remove();
  5254. }
  5255. /***/
  5256. }),
  5257. /* 16 */
  5258. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5259. Object.defineProperty(exports, "__esModule", ({
  5260. value: true
  5261. }));
  5262. exports.PDFDocumentProperties = void 0;
  5263. var _pdfjsLib = __webpack_require__(4);
  5264. var _ui_utils = __webpack_require__(3);
  5265. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  5266. function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
  5267. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  5268. function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
  5269. function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
  5270. function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
  5271. function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
  5272. function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
  5273. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  5274. const DEFAULT_FIELD_CONTENT = "-";
  5275. const NON_METRIC_LOCALES = ["en-us", "en-lr", "my"];
  5276. const US_PAGE_NAMES = {
  5277. "8.5x11": "Letter",
  5278. "8.5x14": "Legal"
  5279. };
  5280. const METRIC_PAGE_NAMES = {
  5281. "297x420": "A3",
  5282. "210x297": "A4"
  5283. };
  5284. function getPageName(size, isPortrait, pageNames) {
  5285. const width = isPortrait ? size.width : size.height;
  5286. const height = isPortrait ? size.height : size.width;
  5287. return pageNames[`${width}x${height}`];
  5288. }
  5289. var _fieldData = /*#__PURE__*/new WeakMap();
  5290. var _reset = /*#__PURE__*/new WeakSet();
  5291. var _updateUI = /*#__PURE__*/new WeakSet();
  5292. var _parseFileSize = /*#__PURE__*/new WeakSet();
  5293. var _parsePageSize = /*#__PURE__*/new WeakSet();
  5294. var _parseDate = /*#__PURE__*/new WeakSet();
  5295. var _parseLinearization = /*#__PURE__*/new WeakSet();
  5296. class PDFDocumentProperties {
  5297. constructor(_ref, overlayManager, eventBus, l10n, fileNameLookup) {
  5298. let {
  5299. dialog,
  5300. fields,
  5301. closeButton
  5302. } = _ref;
  5303. _classPrivateMethodInitSpec(this, _parseLinearization);
  5304. _classPrivateMethodInitSpec(this, _parseDate);
  5305. _classPrivateMethodInitSpec(this, _parsePageSize);
  5306. _classPrivateMethodInitSpec(this, _parseFileSize);
  5307. _classPrivateMethodInitSpec(this, _updateUI);
  5308. _classPrivateMethodInitSpec(this, _reset);
  5309. _classPrivateFieldInitSpec(this, _fieldData, {
  5310. writable: true,
  5311. value: null
  5312. });
  5313. this.dialog = dialog;
  5314. this.fields = fields;
  5315. this.overlayManager = overlayManager;
  5316. this.l10n = l10n;
  5317. this._fileNameLookup = fileNameLookup;
  5318. _classPrivateMethodGet(this, _reset, _reset2).call(this);
  5319. closeButton.addEventListener("click", this.close.bind(this));
  5320. this.overlayManager.register(this.dialog);
  5321. eventBus._on("pagechanging", evt => {
  5322. this._currentPageNumber = evt.pageNumber;
  5323. });
  5324. eventBus._on("rotationchanging", evt => {
  5325. this._pagesRotation = evt.pagesRotation;
  5326. });
  5327. this._isNonMetricLocale = true;
  5328. l10n.getLanguage().then(locale => {
  5329. this._isNonMetricLocale = NON_METRIC_LOCALES.includes(locale);
  5330. });
  5331. }
  5332. async open() {
  5333. await Promise.all([this.overlayManager.open(this.dialog), this._dataAvailableCapability.promise]);
  5334. const currentPageNumber = this._currentPageNumber;
  5335. const pagesRotation = this._pagesRotation;
  5336. if (_classPrivateFieldGet(this, _fieldData) && currentPageNumber === _classPrivateFieldGet(this, _fieldData)._currentPageNumber && pagesRotation === _classPrivateFieldGet(this, _fieldData)._pagesRotation) {
  5337. _classPrivateMethodGet(this, _updateUI, _updateUI2).call(this);
  5338. return;
  5339. }
  5340. const {
  5341. info,
  5342. contentLength
  5343. } = await this.pdfDocument.getMetadata();
  5344. const [fileName, fileSize, creationDate, modificationDate, pageSize, isLinearized] = await Promise.all([this._fileNameLookup(), _classPrivateMethodGet(this, _parseFileSize, _parseFileSize2).call(this, contentLength), _classPrivateMethodGet(this, _parseDate, _parseDate2).call(this, info.CreationDate), _classPrivateMethodGet(this, _parseDate, _parseDate2).call(this, info.ModDate), this.pdfDocument.getPage(currentPageNumber).then(pdfPage => {
  5345. return _classPrivateMethodGet(this, _parsePageSize, _parsePageSize2).call(this, (0, _ui_utils.getPageSizeInches)(pdfPage), pagesRotation);
  5346. }), _classPrivateMethodGet(this, _parseLinearization, _parseLinearization2).call(this, info.IsLinearized)]);
  5347. _classPrivateFieldSet(this, _fieldData, Object.freeze({
  5348. fileName,
  5349. fileSize,
  5350. title: info.Title,
  5351. author: info.Author,
  5352. subject: info.Subject,
  5353. keywords: info.Keywords,
  5354. creationDate,
  5355. modificationDate,
  5356. creator: info.Creator,
  5357. producer: info.Producer,
  5358. version: info.PDFFormatVersion,
  5359. pageCount: this.pdfDocument.numPages,
  5360. pageSize,
  5361. linearized: isLinearized,
  5362. _currentPageNumber: currentPageNumber,
  5363. _pagesRotation: pagesRotation
  5364. }));
  5365. _classPrivateMethodGet(this, _updateUI, _updateUI2).call(this);
  5366. const {
  5367. length
  5368. } = await this.pdfDocument.getDownloadInfo();
  5369. if (contentLength === length) {
  5370. return;
  5371. }
  5372. const data = Object.assign(Object.create(null), _classPrivateFieldGet(this, _fieldData));
  5373. data.fileSize = await _classPrivateMethodGet(this, _parseFileSize, _parseFileSize2).call(this, length);
  5374. _classPrivateFieldSet(this, _fieldData, Object.freeze(data));
  5375. _classPrivateMethodGet(this, _updateUI, _updateUI2).call(this);
  5376. }
  5377. async close() {
  5378. this.overlayManager.close(this.dialog);
  5379. }
  5380. setDocument(pdfDocument) {
  5381. if (this.pdfDocument) {
  5382. _classPrivateMethodGet(this, _reset, _reset2).call(this);
  5383. _classPrivateMethodGet(this, _updateUI, _updateUI2).call(this, true);
  5384. }
  5385. if (!pdfDocument) {
  5386. return;
  5387. }
  5388. this.pdfDocument = pdfDocument;
  5389. this._dataAvailableCapability.resolve();
  5390. }
  5391. }
  5392. exports.PDFDocumentProperties = PDFDocumentProperties;
  5393. function _reset2() {
  5394. this.pdfDocument = null;
  5395. _classPrivateFieldSet(this, _fieldData, null);
  5396. this._dataAvailableCapability = (0, _pdfjsLib.createPromiseCapability)();
  5397. this._currentPageNumber = 1;
  5398. this._pagesRotation = 0;
  5399. }
  5400. function _updateUI2() {
  5401. let reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5402. if (reset || !_classPrivateFieldGet(this, _fieldData)) {
  5403. for (const id in this.fields) {
  5404. this.fields[id].textContent = DEFAULT_FIELD_CONTENT;
  5405. }
  5406. return;
  5407. }
  5408. if (this.overlayManager.active !== this.dialog) {
  5409. return;
  5410. }
  5411. for (const id in this.fields) {
  5412. const content = _classPrivateFieldGet(this, _fieldData)[id];
  5413. this.fields[id].textContent = content || content === 0 ? content : DEFAULT_FIELD_CONTENT;
  5414. }
  5415. }
  5416. async function _parseFileSize2() {
  5417. let fileSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  5418. const kb = fileSize / 1024,
  5419. mb = kb / 1024;
  5420. if (!kb) {
  5421. return undefined;
  5422. }
  5423. return this.l10n.get(`document_properties_${mb >= 1 ? "mb" : "kb"}`, {
  5424. size_mb: mb >= 1 && (+mb.toPrecision(3)).toLocaleString(),
  5425. size_kb: mb < 1 && (+kb.toPrecision(3)).toLocaleString(),
  5426. size_b: fileSize.toLocaleString()
  5427. });
  5428. }
  5429. async function _parsePageSize2(pageSizeInches, pagesRotation) {
  5430. if (!pageSizeInches) {
  5431. return undefined;
  5432. }
  5433. if (pagesRotation % 180 !== 0) {
  5434. pageSizeInches = {
  5435. width: pageSizeInches.height,
  5436. height: pageSizeInches.width
  5437. };
  5438. }
  5439. const isPortrait = (0, _ui_utils.isPortraitOrientation)(pageSizeInches);
  5440. let sizeInches = {
  5441. width: Math.round(pageSizeInches.width * 100) / 100,
  5442. height: Math.round(pageSizeInches.height * 100) / 100
  5443. };
  5444. let sizeMillimeters = {
  5445. width: Math.round(pageSizeInches.width * 25.4 * 10) / 10,
  5446. height: Math.round(pageSizeInches.height * 25.4 * 10) / 10
  5447. };
  5448. let rawName = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES);
  5449. if (!rawName && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(sizeMillimeters.height))) {
  5450. const exactMillimeters = {
  5451. width: pageSizeInches.width * 25.4,
  5452. height: pageSizeInches.height * 25.4
  5453. };
  5454. const intMillimeters = {
  5455. width: Math.round(sizeMillimeters.width),
  5456. height: Math.round(sizeMillimeters.height)
  5457. };
  5458. if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) {
  5459. rawName = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES);
  5460. if (rawName) {
  5461. sizeInches = {
  5462. width: Math.round(intMillimeters.width / 25.4 * 100) / 100,
  5463. height: Math.round(intMillimeters.height / 25.4 * 100) / 100
  5464. };
  5465. sizeMillimeters = intMillimeters;
  5466. }
  5467. }
  5468. }
  5469. const [{
  5470. width,
  5471. height
  5472. }, unit, name, orientation] = await Promise.all([this._isNonMetricLocale ? sizeInches : sizeMillimeters, this.l10n.get(`document_properties_page_size_unit_${this._isNonMetricLocale ? "inches" : "millimeters"}`), rawName && this.l10n.get(`document_properties_page_size_name_${rawName.toLowerCase()}`), this.l10n.get(`document_properties_page_size_orientation_${isPortrait ? "portrait" : "landscape"}`)]);
  5473. return this.l10n.get(`document_properties_page_size_dimension_${name ? "name_" : ""}string`, {
  5474. width: width.toLocaleString(),
  5475. height: height.toLocaleString(),
  5476. unit,
  5477. name,
  5478. orientation
  5479. });
  5480. }
  5481. async function _parseDate2(inputDate) {
  5482. const dateObject = _pdfjsLib.PDFDateString.toDateObject(inputDate);
  5483. if (!dateObject) {
  5484. return undefined;
  5485. }
  5486. return this.l10n.get("document_properties_date_string", {
  5487. date: dateObject.toLocaleDateString(),
  5488. time: dateObject.toLocaleTimeString()
  5489. });
  5490. }
  5491. function _parseLinearization2(isLinearized) {
  5492. return this.l10n.get(`document_properties_linearized_${isLinearized ? "yes" : "no"}`);
  5493. }
  5494. /***/
  5495. }),
  5496. /* 17 */
  5497. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5498. Object.defineProperty(exports, "__esModule", ({
  5499. value: true
  5500. }));
  5501. exports.PDFFindBar = void 0;
  5502. var _pdf_find_controller = __webpack_require__(18);
  5503. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  5504. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  5505. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  5506. const MATCHES_COUNT_LIMIT = 1000;
  5507. var _adjustWidth = /*#__PURE__*/new WeakSet();
  5508. class PDFFindBar {
  5509. constructor(options, eventBus, l10n) {
  5510. _classPrivateMethodInitSpec(this, _adjustWidth);
  5511. this.opened = false;
  5512. this.bar = options.bar;
  5513. this.toggleButton = options.toggleButton;
  5514. this.findField = options.findField;
  5515. this.highlightAll = options.highlightAllCheckbox;
  5516. this.caseSensitive = options.caseSensitiveCheckbox;
  5517. this.matchDiacritics = options.matchDiacriticsCheckbox;
  5518. this.entireWord = options.entireWordCheckbox;
  5519. this.findMsg = options.findMsg;
  5520. this.findResultsCount = options.findResultsCount;
  5521. this.findPreviousButton = options.findPreviousButton;
  5522. this.findNextButton = options.findNextButton;
  5523. this.eventBus = eventBus;
  5524. this.l10n = l10n;
  5525. this.toggleButton.addEventListener("click", () => {
  5526. this.toggle();
  5527. });
  5528. this.findField.addEventListener("input", () => {
  5529. this.dispatchEvent("");
  5530. });
  5531. this.bar.addEventListener("keydown", e => {
  5532. switch (e.keyCode) {
  5533. case 13:
  5534. if (e.target === this.findField) {
  5535. this.dispatchEvent("again", e.shiftKey);
  5536. }
  5537. break;
  5538. case 27:
  5539. this.close();
  5540. break;
  5541. }
  5542. });
  5543. this.findPreviousButton.addEventListener("click", () => {
  5544. this.dispatchEvent("again", true);
  5545. });
  5546. this.findNextButton.addEventListener("click", () => {
  5547. this.dispatchEvent("again", false);
  5548. });
  5549. this.highlightAll.addEventListener("click", () => {
  5550. this.dispatchEvent("highlightallchange");
  5551. });
  5552. this.caseSensitive.addEventListener("click", () => {
  5553. this.dispatchEvent("casesensitivitychange");
  5554. });
  5555. this.entireWord.addEventListener("click", () => {
  5556. this.dispatchEvent("entirewordchange");
  5557. });
  5558. this.matchDiacritics.addEventListener("click", () => {
  5559. this.dispatchEvent("diacriticmatchingchange");
  5560. });
  5561. this.eventBus._on("resize", _classPrivateMethodGet(this, _adjustWidth, _adjustWidth2).bind(this));
  5562. }
  5563. reset() {
  5564. this.updateUIState();
  5565. }
  5566. dispatchEvent(type) {
  5567. let findPrev = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  5568. this.eventBus.dispatch("find", {
  5569. source: this,
  5570. type,
  5571. query: this.findField.value,
  5572. phraseSearch: true,
  5573. caseSensitive: this.caseSensitive.checked,
  5574. entireWord: this.entireWord.checked,
  5575. highlightAll: this.highlightAll.checked,
  5576. findPrevious: findPrev,
  5577. matchDiacritics: this.matchDiacritics.checked
  5578. });
  5579. }
  5580. updateUIState(state, previous, matchesCount) {
  5581. let findMsg = Promise.resolve("");
  5582. let status = "";
  5583. switch (state) {
  5584. case _pdf_find_controller.FindState.FOUND:
  5585. break;
  5586. case _pdf_find_controller.FindState.PENDING:
  5587. status = "pending";
  5588. break;
  5589. case _pdf_find_controller.FindState.NOT_FOUND:
  5590. findMsg = this.l10n.get("find_not_found");
  5591. status = "notFound";
  5592. break;
  5593. case _pdf_find_controller.FindState.WRAPPED:
  5594. findMsg = this.l10n.get(`find_reached_${previous ? "top" : "bottom"}`);
  5595. break;
  5596. }
  5597. this.findField.setAttribute("data-status", status);
  5598. this.findField.setAttribute("aria-invalid", state === _pdf_find_controller.FindState.NOT_FOUND);
  5599. findMsg.then(msg => {
  5600. this.findMsg.textContent = msg;
  5601. _classPrivateMethodGet(this, _adjustWidth, _adjustWidth2).call(this);
  5602. });
  5603. this.updateResultsCount(matchesCount);
  5604. }
  5605. updateResultsCount() {
  5606. let {
  5607. current = 0,
  5608. total = 0
  5609. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  5610. const limit = MATCHES_COUNT_LIMIT;
  5611. let matchCountMsg = Promise.resolve("");
  5612. if (total > 0) {
  5613. if (total > limit) {
  5614. let key = "find_match_count_limit";
  5615. matchCountMsg = this.l10n.get(key, {
  5616. limit
  5617. });
  5618. } else {
  5619. let key = "find_match_count";
  5620. matchCountMsg = this.l10n.get(key, {
  5621. current,
  5622. total
  5623. });
  5624. }
  5625. }
  5626. matchCountMsg.then(msg => {
  5627. this.findResultsCount.textContent = msg;
  5628. _classPrivateMethodGet(this, _adjustWidth, _adjustWidth2).call(this);
  5629. });
  5630. }
  5631. open() {
  5632. if (!this.opened) {
  5633. this.opened = true;
  5634. this.toggleButton.classList.add("toggled");
  5635. this.toggleButton.setAttribute("aria-expanded", "true");
  5636. this.bar.classList.remove("hidden");
  5637. }
  5638. this.findField.select();
  5639. this.findField.focus();
  5640. _classPrivateMethodGet(this, _adjustWidth, _adjustWidth2).call(this);
  5641. }
  5642. close() {
  5643. if (!this.opened) {
  5644. return;
  5645. }
  5646. this.opened = false;
  5647. this.toggleButton.classList.remove("toggled");
  5648. this.toggleButton.setAttribute("aria-expanded", "false");
  5649. this.bar.classList.add("hidden");
  5650. this.eventBus.dispatch("findbarclose", {
  5651. source: this
  5652. });
  5653. }
  5654. toggle() {
  5655. if (this.opened) {
  5656. this.close();
  5657. } else {
  5658. this.open();
  5659. }
  5660. }
  5661. }
  5662. exports.PDFFindBar = PDFFindBar;
  5663. function _adjustWidth2() {
  5664. if (!this.opened) {
  5665. return;
  5666. }
  5667. this.bar.classList.remove("wrapContainers");
  5668. const findbarHeight = this.bar.clientHeight;
  5669. const inputContainerHeight = this.bar.firstElementChild.clientHeight;
  5670. if (findbarHeight > inputContainerHeight) {
  5671. this.bar.classList.add("wrapContainers");
  5672. }
  5673. }
  5674. /***/
  5675. }),
  5676. /* 18 */
  5677. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5678. Object.defineProperty(exports, "__esModule", ({
  5679. value: true
  5680. }));
  5681. exports.PDFFindController = exports.FindState = void 0;
  5682. var _ui_utils = __webpack_require__(3);
  5683. var _pdfjsLib = __webpack_require__(4);
  5684. var _pdf_find_utils = __webpack_require__(19);
  5685. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  5686. function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
  5687. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  5688. function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
  5689. function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
  5690. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  5691. function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
  5692. function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
  5693. function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
  5694. const FindState = {
  5695. FOUND: 0,
  5696. NOT_FOUND: 1,
  5697. WRAPPED: 2,
  5698. PENDING: 3
  5699. };
  5700. exports.FindState = FindState;
  5701. const FIND_TIMEOUT = 250;
  5702. const MATCH_SCROLL_OFFSET_TOP = -50;
  5703. const MATCH_SCROLL_OFFSET_LEFT = -400;
  5704. const CHARACTERS_TO_NORMALIZE = {
  5705. "\u2010": "-",
  5706. "\u2018": "'",
  5707. "\u2019": "'",
  5708. "\u201A": "'",
  5709. "\u201B": "'",
  5710. "\u201C": '"',
  5711. "\u201D": '"',
  5712. "\u201E": '"',
  5713. "\u201F": '"',
  5714. "\u00BC": "1/4",
  5715. "\u00BD": "1/2",
  5716. "\u00BE": "3/4"
  5717. };
  5718. 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]);
  5719. let DIACRITICS_EXCEPTION_STR;
  5720. const DIACRITICS_REG_EXP = /\p{M}+/gu;
  5721. const SPECIAL_CHARS_REG_EXP = /([.*+?^${}()|[\]\\])|(\p{P})|(\s+)|(\p{M})|(\p{L})/gu;
  5722. const NOT_DIACRITIC_FROM_END_REG_EXP = /([^\p{M}])\p{M}*$/u;
  5723. const NOT_DIACRITIC_FROM_START_REG_EXP = /^\p{M}*([^\p{M}])/u;
  5724. const SYLLABLES_REG_EXP = /[\uAC00-\uD7AF\uFA6C\uFACF-\uFAD1\uFAD5-\uFAD7]+/g;
  5725. const SYLLABLES_LENGTHS = new Map();
  5726. const FIRST_CHAR_SYLLABLES_REG_EXP = "[\\u1100-\\u1112\\ud7a4-\\ud7af\\ud84a\\ud84c\\ud850\\ud854\\ud857\\ud85f]";
  5727. const NFKC_CHARS_TO_NORMALIZE = new Map();
  5728. let noSyllablesRegExp = null;
  5729. let withSyllablesRegExp = null;
  5730. function normalize(text) {
  5731. const syllablePositions = [];
  5732. let m;
  5733. while ((m = SYLLABLES_REG_EXP.exec(text)) !== null) {
  5734. let {
  5735. index
  5736. } = m;
  5737. for (const char of m[0]) {
  5738. let len = SYLLABLES_LENGTHS.get(char);
  5739. if (!len) {
  5740. len = char.normalize("NFD").length;
  5741. SYLLABLES_LENGTHS.set(char, len);
  5742. }
  5743. syllablePositions.push([len, index++]);
  5744. }
  5745. }
  5746. let normalizationRegex;
  5747. if (syllablePositions.length === 0 && noSyllablesRegExp) {
  5748. normalizationRegex = noSyllablesRegExp;
  5749. } else if (syllablePositions.length > 0 && withSyllablesRegExp) {
  5750. normalizationRegex = withSyllablesRegExp;
  5751. } else {
  5752. const replace = Object.keys(CHARACTERS_TO_NORMALIZE).join("");
  5753. const toNormalizeWithNFKC = "\u2460-\u2473" + "\u24b6-\u24ff" + "\u3244-\u32bf" + "\u32d0-\u32fe" + "\uff00-\uffef";
  5754. const CJK = "(?:\\p{Ideographic}|[\u3040-\u30FF])";
  5755. const HKDiacritics = "(?:\u3099|\u309A)";
  5756. const regexp = `([${replace}])|([${toNormalizeWithNFKC}])|(${HKDiacritics}\\n)|(\\p{M}+(?:-\\n)?)|(\\S-\\n)|(${CJK}\\n)|(\\n)`;
  5757. if (syllablePositions.length === 0) {
  5758. normalizationRegex = noSyllablesRegExp = new RegExp(regexp + "|(\\u0000)", "gum");
  5759. } else {
  5760. normalizationRegex = withSyllablesRegExp = new RegExp(regexp + `|(${FIRST_CHAR_SYLLABLES_REG_EXP})`, "gum");
  5761. }
  5762. }
  5763. const rawDiacriticsPositions = [];
  5764. while ((m = DIACRITICS_REG_EXP.exec(text)) !== null) {
  5765. rawDiacriticsPositions.push([m[0].length, m.index]);
  5766. }
  5767. let normalized = text.normalize("NFD");
  5768. const positions = [[0, 0]];
  5769. let rawDiacriticsIndex = 0;
  5770. let syllableIndex = 0;
  5771. let shift = 0;
  5772. let shiftOrigin = 0;
  5773. let eol = 0;
  5774. let hasDiacritics = false;
  5775. normalized = normalized.replace(normalizationRegex, (match, p1, p2, p3, p4, p5, p6, p7, p8, i) => {
  5776. var _syllablePositions$sy;
  5777. i -= shiftOrigin;
  5778. if (p1) {
  5779. const replacement = CHARACTERS_TO_NORMALIZE[p1];
  5780. const jj = replacement.length;
  5781. for (let j = 1; j < jj; j++) {
  5782. positions.push([i - shift + j, shift - j]);
  5783. }
  5784. shift -= jj - 1;
  5785. return replacement;
  5786. }
  5787. if (p2) {
  5788. let replacement = NFKC_CHARS_TO_NORMALIZE.get(p2);
  5789. if (!replacement) {
  5790. replacement = p2.normalize("NFKC");
  5791. NFKC_CHARS_TO_NORMALIZE.set(p2, replacement);
  5792. }
  5793. const jj = replacement.length;
  5794. for (let j = 1; j < jj; j++) {
  5795. positions.push([i - shift + j, shift - j]);
  5796. }
  5797. shift -= jj - 1;
  5798. return replacement;
  5799. }
  5800. if (p3) {
  5801. var _rawDiacriticsPositio;
  5802. hasDiacritics = true;
  5803. if (i + eol === ((_rawDiacriticsPositio = rawDiacriticsPositions[rawDiacriticsIndex]) === null || _rawDiacriticsPositio === void 0 ? void 0 : _rawDiacriticsPositio[1])) {
  5804. ++rawDiacriticsIndex;
  5805. } else {
  5806. positions.push([i - 1 - shift + 1, shift - 1]);
  5807. shift -= 1;
  5808. shiftOrigin += 1;
  5809. }
  5810. positions.push([i - shift + 1, shift]);
  5811. shiftOrigin += 1;
  5812. eol += 1;
  5813. return p3.charAt(0);
  5814. }
  5815. if (p4) {
  5816. var _rawDiacriticsPositio2;
  5817. const hasTrailingDashEOL = p4.endsWith("\n");
  5818. const len = hasTrailingDashEOL ? p4.length - 2 : p4.length;
  5819. hasDiacritics = true;
  5820. let jj = len;
  5821. if (i + eol === ((_rawDiacriticsPositio2 = rawDiacriticsPositions[rawDiacriticsIndex]) === null || _rawDiacriticsPositio2 === void 0 ? void 0 : _rawDiacriticsPositio2[1])) {
  5822. jj -= rawDiacriticsPositions[rawDiacriticsIndex][0];
  5823. ++rawDiacriticsIndex;
  5824. }
  5825. for (let j = 1; j <= jj; j++) {
  5826. positions.push([i - 1 - shift + j, shift - j]);
  5827. }
  5828. shift -= jj;
  5829. shiftOrigin += jj;
  5830. if (hasTrailingDashEOL) {
  5831. i += len - 1;
  5832. positions.push([i - shift + 1, 1 + shift]);
  5833. shift += 1;
  5834. shiftOrigin += 1;
  5835. eol += 1;
  5836. return p4.slice(0, len);
  5837. }
  5838. return p4;
  5839. }
  5840. if (p5) {
  5841. positions.push([i - shift + 1, 1 + shift]);
  5842. shift += 1;
  5843. shiftOrigin += 1;
  5844. eol += 1;
  5845. return p5.charAt(0);
  5846. }
  5847. if (p6) {
  5848. positions.push([i - shift + 1, shift]);
  5849. shiftOrigin += 1;
  5850. eol += 1;
  5851. return p6.charAt(0);
  5852. }
  5853. if (p7) {
  5854. positions.push([i - shift + 1, shift - 1]);
  5855. shift -= 1;
  5856. shiftOrigin += 1;
  5857. eol += 1;
  5858. return " ";
  5859. }
  5860. if (i + eol === ((_syllablePositions$sy = syllablePositions[syllableIndex]) === null || _syllablePositions$sy === void 0 ? void 0 : _syllablePositions$sy[1])) {
  5861. const newCharLen = syllablePositions[syllableIndex][0] - 1;
  5862. ++syllableIndex;
  5863. for (let j = 1; j <= newCharLen; j++) {
  5864. positions.push([i - (shift - j), shift - j]);
  5865. }
  5866. shift -= newCharLen;
  5867. shiftOrigin += newCharLen;
  5868. }
  5869. return p8;
  5870. });
  5871. positions.push([normalized.length, shift]);
  5872. return [normalized, positions, hasDiacritics];
  5873. }
  5874. function getOriginalIndex(diffs, pos, len) {
  5875. if (!diffs) {
  5876. return [pos, len];
  5877. }
  5878. const start = pos;
  5879. const end = pos + len;
  5880. let i = (0, _ui_utils.binarySearchFirstItem)(diffs, x => x[0] >= start);
  5881. if (diffs[i][0] > start) {
  5882. --i;
  5883. }
  5884. let j = (0, _ui_utils.binarySearchFirstItem)(diffs, x => x[0] >= end, i);
  5885. if (diffs[j][0] > end) {
  5886. --j;
  5887. }
  5888. return [start + diffs[i][1], len + diffs[j][1] - diffs[i][1]];
  5889. }
  5890. var _updateMatchesCountOnProgress = /*#__PURE__*/new WeakMap();
  5891. var _visitedPagesCount = /*#__PURE__*/new WeakMap();
  5892. var _onFind = /*#__PURE__*/new WeakSet();
  5893. var _reset = /*#__PURE__*/new WeakSet();
  5894. var _query = /*#__PURE__*/new WeakMap();
  5895. var _shouldDirtyMatch = /*#__PURE__*/new WeakSet();
  5896. var _isEntireWord = /*#__PURE__*/new WeakSet();
  5897. var _calculateRegExpMatch = /*#__PURE__*/new WeakSet();
  5898. var _convertToRegExpString = /*#__PURE__*/new WeakSet();
  5899. var _calculateMatch = /*#__PURE__*/new WeakSet();
  5900. var _extractText = /*#__PURE__*/new WeakSet();
  5901. var _updatePage = /*#__PURE__*/new WeakSet();
  5902. var _updateAllPages = /*#__PURE__*/new WeakSet();
  5903. var _nextMatch = /*#__PURE__*/new WeakSet();
  5904. var _matchesReady = /*#__PURE__*/new WeakSet();
  5905. var _nextPageMatch = /*#__PURE__*/new WeakSet();
  5906. var _advanceOffsetPage = /*#__PURE__*/new WeakSet();
  5907. var _updateMatch = /*#__PURE__*/new WeakSet();
  5908. var _onFindBarClose = /*#__PURE__*/new WeakSet();
  5909. var _requestMatchesCount = /*#__PURE__*/new WeakSet();
  5910. var _updateUIResultsCount = /*#__PURE__*/new WeakSet();
  5911. var _updateUIState = /*#__PURE__*/new WeakSet();
  5912. class PDFFindController {
  5913. constructor(_ref) {
  5914. let {
  5915. linkService: _linkService,
  5916. eventBus,
  5917. updateMatchesCountOnProgress = true
  5918. } = _ref;
  5919. _classPrivateMethodInitSpec(this, _updateUIState);
  5920. _classPrivateMethodInitSpec(this, _updateUIResultsCount);
  5921. _classPrivateMethodInitSpec(this, _requestMatchesCount);
  5922. _classPrivateMethodInitSpec(this, _onFindBarClose);
  5923. _classPrivateMethodInitSpec(this, _updateMatch);
  5924. _classPrivateMethodInitSpec(this, _advanceOffsetPage);
  5925. _classPrivateMethodInitSpec(this, _nextPageMatch);
  5926. _classPrivateMethodInitSpec(this, _matchesReady);
  5927. _classPrivateMethodInitSpec(this, _nextMatch);
  5928. _classPrivateMethodInitSpec(this, _updateAllPages);
  5929. _classPrivateMethodInitSpec(this, _updatePage);
  5930. _classPrivateMethodInitSpec(this, _extractText);
  5931. _classPrivateMethodInitSpec(this, _calculateMatch);
  5932. _classPrivateMethodInitSpec(this, _convertToRegExpString);
  5933. _classPrivateMethodInitSpec(this, _calculateRegExpMatch);
  5934. _classPrivateMethodInitSpec(this, _isEntireWord);
  5935. _classPrivateMethodInitSpec(this, _shouldDirtyMatch);
  5936. _classPrivateFieldInitSpec(this, _query, {
  5937. get: _get_query,
  5938. set: void 0
  5939. });
  5940. _classPrivateMethodInitSpec(this, _reset);
  5941. _classPrivateMethodInitSpec(this, _onFind);
  5942. _classPrivateFieldInitSpec(this, _updateMatchesCountOnProgress, {
  5943. writable: true,
  5944. value: true
  5945. });
  5946. _classPrivateFieldInitSpec(this, _visitedPagesCount, {
  5947. writable: true,
  5948. value: 0
  5949. });
  5950. this._linkService = _linkService;
  5951. this._eventBus = eventBus;
  5952. _classPrivateFieldSet(this, _updateMatchesCountOnProgress, updateMatchesCountOnProgress);
  5953. _classPrivateMethodGet(this, _reset, _reset2).call(this);
  5954. eventBus._on("find", _classPrivateMethodGet(this, _onFind, _onFind2).bind(this));
  5955. eventBus._on("findbarclose", _classPrivateMethodGet(this, _onFindBarClose, _onFindBarClose2).bind(this));
  5956. }
  5957. get highlightMatches() {
  5958. return this._highlightMatches;
  5959. }
  5960. get pageMatches() {
  5961. return this._pageMatches;
  5962. }
  5963. get pageMatchesLength() {
  5964. return this._pageMatchesLength;
  5965. }
  5966. get selected() {
  5967. return this._selected;
  5968. }
  5969. get state() {
  5970. return this._state;
  5971. }
  5972. setDocument(pdfDocument) {
  5973. if (this._pdfDocument) {
  5974. _classPrivateMethodGet(this, _reset, _reset2).call(this);
  5975. }
  5976. if (!pdfDocument) {
  5977. return;
  5978. }
  5979. this._pdfDocument = pdfDocument;
  5980. this._firstPageCapability.resolve();
  5981. }
  5982. scrollMatchIntoView(_ref2) {
  5983. let {
  5984. element = null,
  5985. selectedLeft = 0,
  5986. pageIndex = -1,
  5987. matchIndex = -1
  5988. } = _ref2;
  5989. if (!this._scrollMatches || !element) {
  5990. return;
  5991. } else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) {
  5992. return;
  5993. } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) {
  5994. return;
  5995. }
  5996. this._scrollMatches = false;
  5997. const spot = {
  5998. top: MATCH_SCROLL_OFFSET_TOP,
  5999. left: selectedLeft + MATCH_SCROLL_OFFSET_LEFT
  6000. };
  6001. (0, _ui_utils.scrollIntoView)(element, spot, true);
  6002. }
  6003. }
  6004. exports.PDFFindController = PDFFindController;
  6005. function _onFind2(state) {
  6006. if (!state) {
  6007. return;
  6008. }
  6009. const pdfDocument = this._pdfDocument;
  6010. const {
  6011. type
  6012. } = state;
  6013. if (this._state === null || _classPrivateMethodGet(this, _shouldDirtyMatch, _shouldDirtyMatch2).call(this, state)) {
  6014. this._dirtyMatch = true;
  6015. }
  6016. this._state = state;
  6017. if (type !== "highlightallchange") {
  6018. _classPrivateMethodGet(this, _updateUIState, _updateUIState2).call(this, FindState.PENDING);
  6019. }
  6020. this._firstPageCapability.promise.then(() => {
  6021. if (!this._pdfDocument || pdfDocument && this._pdfDocument !== pdfDocument) {
  6022. return;
  6023. }
  6024. _classPrivateMethodGet(this, _extractText, _extractText2).call(this);
  6025. const findbarClosed = !this._highlightMatches;
  6026. const pendingTimeout = !!this._findTimeout;
  6027. if (this._findTimeout) {
  6028. clearTimeout(this._findTimeout);
  6029. this._findTimeout = null;
  6030. }
  6031. if (!type) {
  6032. this._findTimeout = setTimeout(() => {
  6033. _classPrivateMethodGet(this, _nextMatch, _nextMatch2).call(this);
  6034. this._findTimeout = null;
  6035. }, FIND_TIMEOUT);
  6036. } else if (this._dirtyMatch) {
  6037. _classPrivateMethodGet(this, _nextMatch, _nextMatch2).call(this);
  6038. } else if (type === "again") {
  6039. _classPrivateMethodGet(this, _nextMatch, _nextMatch2).call(this);
  6040. if (findbarClosed && this._state.highlightAll) {
  6041. _classPrivateMethodGet(this, _updateAllPages, _updateAllPages2).call(this);
  6042. }
  6043. } else if (type === "highlightallchange") {
  6044. if (pendingTimeout) {
  6045. _classPrivateMethodGet(this, _nextMatch, _nextMatch2).call(this);
  6046. } else {
  6047. this._highlightMatches = true;
  6048. }
  6049. _classPrivateMethodGet(this, _updateAllPages, _updateAllPages2).call(this);
  6050. } else {
  6051. _classPrivateMethodGet(this, _nextMatch, _nextMatch2).call(this);
  6052. }
  6053. });
  6054. }
  6055. function _reset2() {
  6056. this._highlightMatches = false;
  6057. this._scrollMatches = false;
  6058. this._pdfDocument = null;
  6059. this._pageMatches = [];
  6060. this._pageMatchesLength = [];
  6061. _classPrivateFieldSet(this, _visitedPagesCount, 0);
  6062. this._state = null;
  6063. this._selected = {
  6064. pageIdx: -1,
  6065. matchIdx: -1
  6066. };
  6067. this._offset = {
  6068. pageIdx: null,
  6069. matchIdx: null,
  6070. wrapped: false
  6071. };
  6072. this._extractTextPromises = [];
  6073. this._pageContents = [];
  6074. this._pageDiffs = [];
  6075. this._hasDiacritics = [];
  6076. this._matchesCountTotal = 0;
  6077. this._pagesToSearch = null;
  6078. this._pendingFindMatches = new Set();
  6079. this._resumePageIdx = null;
  6080. this._dirtyMatch = false;
  6081. clearTimeout(this._findTimeout);
  6082. this._findTimeout = null;
  6083. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  6084. }
  6085. function _get_query() {
  6086. if (this._state.query !== this._rawQuery) {
  6087. this._rawQuery = this._state.query;
  6088. [this._normalizedQuery] = normalize(this._state.query);
  6089. }
  6090. return this._normalizedQuery;
  6091. }
  6092. function _shouldDirtyMatch2(state) {
  6093. if (state.query !== this._state.query) {
  6094. return true;
  6095. }
  6096. switch (state.type) {
  6097. case "again":
  6098. const pageNumber = this._selected.pageIdx + 1;
  6099. const linkService = this._linkService;
  6100. if (pageNumber >= 1 && pageNumber <= linkService.pagesCount && pageNumber !== linkService.page && !linkService.isPageVisible(pageNumber)) {
  6101. return true;
  6102. }
  6103. return false;
  6104. case "highlightallchange":
  6105. return false;
  6106. }
  6107. return true;
  6108. }
  6109. function _isEntireWord2(content, startIdx, length) {
  6110. let match = content.slice(0, startIdx).match(NOT_DIACRITIC_FROM_END_REG_EXP);
  6111. if (match) {
  6112. const first = content.charCodeAt(startIdx);
  6113. const limit = match[1].charCodeAt(0);
  6114. if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils.getCharacterType)(limit)) {
  6115. return false;
  6116. }
  6117. }
  6118. match = content.slice(startIdx + length).match(NOT_DIACRITIC_FROM_START_REG_EXP);
  6119. if (match) {
  6120. const last = content.charCodeAt(startIdx + length - 1);
  6121. const limit = match[1].charCodeAt(0);
  6122. if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils.getCharacterType)(limit)) {
  6123. return false;
  6124. }
  6125. }
  6126. return true;
  6127. }
  6128. function _calculateRegExpMatch2(query, entireWord, pageIndex, pageContent) {
  6129. const matches = this._pageMatches[pageIndex] = [];
  6130. const matchesLength = this._pageMatchesLength[pageIndex] = [];
  6131. if (!query) {
  6132. return;
  6133. }
  6134. const diffs = this._pageDiffs[pageIndex];
  6135. let match;
  6136. while ((match = query.exec(pageContent)) !== null) {
  6137. if (entireWord && !_classPrivateMethodGet(this, _isEntireWord, _isEntireWord2).call(this, pageContent, match.index, match[0].length)) {
  6138. continue;
  6139. }
  6140. const [matchPos, matchLen] = getOriginalIndex(diffs, match.index, match[0].length);
  6141. if (matchLen) {
  6142. matches.push(matchPos);
  6143. matchesLength.push(matchLen);
  6144. }
  6145. }
  6146. }
  6147. function _convertToRegExpString2(query, hasDiacritics) {
  6148. const {
  6149. matchDiacritics
  6150. } = this._state;
  6151. let isUnicode = false;
  6152. query = query.replace(SPECIAL_CHARS_REG_EXP, (match, p1, p2, p3, p4, p5) => {
  6153. if (p1) {
  6154. return `[ ]*\\${p1}[ ]*`;
  6155. }
  6156. if (p2) {
  6157. return `[ ]*${p2}[ ]*`;
  6158. }
  6159. if (p3) {
  6160. return "[ ]+";
  6161. }
  6162. if (matchDiacritics) {
  6163. return p4 || p5;
  6164. }
  6165. if (p4) {
  6166. return DIACRITICS_EXCEPTION.has(p4.charCodeAt(0)) ? p4 : "";
  6167. }
  6168. if (hasDiacritics) {
  6169. isUnicode = true;
  6170. return `${p5}\\p{M}*`;
  6171. }
  6172. return p5;
  6173. });
  6174. const trailingSpaces = "[ ]*";
  6175. if (query.endsWith(trailingSpaces)) {
  6176. query = query.slice(0, query.length - trailingSpaces.length);
  6177. }
  6178. if (matchDiacritics) {
  6179. if (hasDiacritics) {
  6180. DIACRITICS_EXCEPTION_STR || (DIACRITICS_EXCEPTION_STR = String.fromCharCode(...DIACRITICS_EXCEPTION));
  6181. isUnicode = true;
  6182. query = `${query}(?=[${DIACRITICS_EXCEPTION_STR}]|[^\\p{M}]|$)`;
  6183. }
  6184. }
  6185. return [isUnicode, query];
  6186. }
  6187. function _calculateMatch2(pageIndex) {
  6188. var _this$visitedPagesCou;
  6189. let query = _classPrivateFieldGet(this, _query);
  6190. if (!query) {
  6191. return;
  6192. }
  6193. const {
  6194. caseSensitive,
  6195. entireWord,
  6196. phraseSearch
  6197. } = this._state;
  6198. const pageContent = this._pageContents[pageIndex];
  6199. const hasDiacritics = this._hasDiacritics[pageIndex];
  6200. let isUnicode = false;
  6201. if (phraseSearch) {
  6202. [isUnicode, query] = _classPrivateMethodGet(this, _convertToRegExpString, _convertToRegExpString2).call(this, query, hasDiacritics);
  6203. } else {
  6204. const match = query.match(/\S+/g);
  6205. if (match) {
  6206. query = match.sort().reverse().map(q => {
  6207. const [isUnicodePart, queryPart] = _classPrivateMethodGet(this, _convertToRegExpString, _convertToRegExpString2).call(this, q, hasDiacritics);
  6208. isUnicode || (isUnicode = isUnicodePart);
  6209. return `(${queryPart})`;
  6210. }).join("|");
  6211. }
  6212. }
  6213. const flags = `g${isUnicode ? "u" : ""}${caseSensitive ? "" : "i"}`;
  6214. query = query ? new RegExp(query, flags) : null;
  6215. _classPrivateMethodGet(this, _calculateRegExpMatch, _calculateRegExpMatch2).call(this, query, entireWord, pageIndex, pageContent);
  6216. if (this._state.highlightAll) {
  6217. _classPrivateMethodGet(this, _updatePage, _updatePage2).call(this, pageIndex);
  6218. }
  6219. if (this._resumePageIdx === pageIndex) {
  6220. this._resumePageIdx = null;
  6221. _classPrivateMethodGet(this, _nextPageMatch, _nextPageMatch2).call(this);
  6222. }
  6223. const pageMatchesCount = this._pageMatches[pageIndex].length;
  6224. this._matchesCountTotal += pageMatchesCount;
  6225. if (_classPrivateFieldGet(this, _updateMatchesCountOnProgress)) {
  6226. if (pageMatchesCount > 0) {
  6227. _classPrivateMethodGet(this, _updateUIResultsCount, _updateUIResultsCount2).call(this);
  6228. }
  6229. } else if (_classPrivateFieldSet(this, _visitedPagesCount, (_this$visitedPagesCou = _classPrivateFieldGet(this, _visitedPagesCount), ++_this$visitedPagesCou)) === this._linkService.pagesCount) {
  6230. _classPrivateMethodGet(this, _updateUIResultsCount, _updateUIResultsCount2).call(this);
  6231. }
  6232. }
  6233. function _extractText2() {
  6234. if (this._extractTextPromises.length > 0) {
  6235. return;
  6236. }
  6237. let promise = Promise.resolve();
  6238. for (let i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
  6239. const extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
  6240. this._extractTextPromises[i] = extractTextCapability.promise;
  6241. promise = promise.then(() => {
  6242. return this._pdfDocument.getPage(i + 1).then(pdfPage => {
  6243. return pdfPage.getTextContent();
  6244. }).then(textContent => {
  6245. const strBuf = [];
  6246. for (const textItem of textContent.items) {
  6247. strBuf.push(textItem.str);
  6248. if (textItem.hasEOL) {
  6249. strBuf.push("\n");
  6250. }
  6251. }
  6252. [this._pageContents[i], this._pageDiffs[i], this._hasDiacritics[i]] = normalize(strBuf.join(""));
  6253. extractTextCapability.resolve();
  6254. }, reason => {
  6255. console.error(`Unable to get text content for page ${i + 1}`, reason);
  6256. this._pageContents[i] = "";
  6257. this._pageDiffs[i] = null;
  6258. this._hasDiacritics[i] = false;
  6259. extractTextCapability.resolve();
  6260. });
  6261. });
  6262. }
  6263. }
  6264. function _updatePage2(index) {
  6265. if (this._scrollMatches && this._selected.pageIdx === index) {
  6266. this._linkService.page = index + 1;
  6267. }
  6268. this._eventBus.dispatch("updatetextlayermatches", {
  6269. source: this,
  6270. pageIndex: index
  6271. });
  6272. }
  6273. function _updateAllPages2() {
  6274. this._eventBus.dispatch("updatetextlayermatches", {
  6275. source: this,
  6276. pageIndex: -1
  6277. });
  6278. }
  6279. function _nextMatch2() {
  6280. const previous = this._state.findPrevious;
  6281. const currentPageIndex = this._linkService.page - 1;
  6282. const numPages = this._linkService.pagesCount;
  6283. this._highlightMatches = true;
  6284. if (this._dirtyMatch) {
  6285. this._dirtyMatch = false;
  6286. this._selected.pageIdx = this._selected.matchIdx = -1;
  6287. this._offset.pageIdx = currentPageIndex;
  6288. this._offset.matchIdx = null;
  6289. this._offset.wrapped = false;
  6290. this._resumePageIdx = null;
  6291. this._pageMatches.length = 0;
  6292. this._pageMatchesLength.length = 0;
  6293. _classPrivateFieldSet(this, _visitedPagesCount, 0);
  6294. this._matchesCountTotal = 0;
  6295. _classPrivateMethodGet(this, _updateAllPages, _updateAllPages2).call(this);
  6296. for (let i = 0; i < numPages; i++) {
  6297. if (this._pendingFindMatches.has(i)) {
  6298. continue;
  6299. }
  6300. this._pendingFindMatches.add(i);
  6301. this._extractTextPromises[i].then(() => {
  6302. this._pendingFindMatches.delete(i);
  6303. _classPrivateMethodGet(this, _calculateMatch, _calculateMatch2).call(this, i);
  6304. });
  6305. }
  6306. }
  6307. if (!_classPrivateFieldGet(this, _query)) {
  6308. _classPrivateMethodGet(this, _updateUIState, _updateUIState2).call(this, FindState.FOUND);
  6309. return;
  6310. }
  6311. if (this._resumePageIdx) {
  6312. return;
  6313. }
  6314. const offset = this._offset;
  6315. this._pagesToSearch = numPages;
  6316. if (offset.matchIdx !== null) {
  6317. const numPageMatches = this._pageMatches[offset.pageIdx].length;
  6318. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  6319. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  6320. _classPrivateMethodGet(this, _updateMatch, _updateMatch2).call(this, true);
  6321. return;
  6322. }
  6323. _classPrivateMethodGet(this, _advanceOffsetPage, _advanceOffsetPage2).call(this, previous);
  6324. }
  6325. _classPrivateMethodGet(this, _nextPageMatch, _nextPageMatch2).call(this);
  6326. }
  6327. function _matchesReady2(matches) {
  6328. const offset = this._offset;
  6329. const numMatches = matches.length;
  6330. const previous = this._state.findPrevious;
  6331. if (numMatches) {
  6332. offset.matchIdx = previous ? numMatches - 1 : 0;
  6333. _classPrivateMethodGet(this, _updateMatch, _updateMatch2).call(this, true);
  6334. return true;
  6335. }
  6336. _classPrivateMethodGet(this, _advanceOffsetPage, _advanceOffsetPage2).call(this, previous);
  6337. if (offset.wrapped) {
  6338. offset.matchIdx = null;
  6339. if (this._pagesToSearch < 0) {
  6340. _classPrivateMethodGet(this, _updateMatch, _updateMatch2).call(this, false);
  6341. return true;
  6342. }
  6343. }
  6344. return false;
  6345. }
  6346. function _nextPageMatch2() {
  6347. if (this._resumePageIdx !== null) {
  6348. console.error("There can only be one pending page.");
  6349. }
  6350. let matches = null;
  6351. do {
  6352. const pageIdx = this._offset.pageIdx;
  6353. matches = this._pageMatches[pageIdx];
  6354. if (!matches) {
  6355. this._resumePageIdx = pageIdx;
  6356. break;
  6357. }
  6358. } while (!_classPrivateMethodGet(this, _matchesReady, _matchesReady2).call(this, matches));
  6359. }
  6360. function _advanceOffsetPage2(previous) {
  6361. const offset = this._offset;
  6362. const numPages = this._linkService.pagesCount;
  6363. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  6364. offset.matchIdx = null;
  6365. this._pagesToSearch--;
  6366. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  6367. offset.pageIdx = previous ? numPages - 1 : 0;
  6368. offset.wrapped = true;
  6369. }
  6370. }
  6371. function _updateMatch2() {
  6372. let found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6373. let state = FindState.NOT_FOUND;
  6374. const wrapped = this._offset.wrapped;
  6375. this._offset.wrapped = false;
  6376. if (found) {
  6377. const previousPage = this._selected.pageIdx;
  6378. this._selected.pageIdx = this._offset.pageIdx;
  6379. this._selected.matchIdx = this._offset.matchIdx;
  6380. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  6381. if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {
  6382. _classPrivateMethodGet(this, _updatePage, _updatePage2).call(this, previousPage);
  6383. }
  6384. }
  6385. _classPrivateMethodGet(this, _updateUIState, _updateUIState2).call(this, state, this._state.findPrevious);
  6386. if (this._selected.pageIdx !== -1) {
  6387. this._scrollMatches = true;
  6388. _classPrivateMethodGet(this, _updatePage, _updatePage2).call(this, this._selected.pageIdx);
  6389. }
  6390. }
  6391. function _onFindBarClose2(evt) {
  6392. const pdfDocument = this._pdfDocument;
  6393. this._firstPageCapability.promise.then(() => {
  6394. if (!this._pdfDocument || pdfDocument && this._pdfDocument !== pdfDocument) {
  6395. return;
  6396. }
  6397. if (this._findTimeout) {
  6398. clearTimeout(this._findTimeout);
  6399. this._findTimeout = null;
  6400. }
  6401. if (this._resumePageIdx) {
  6402. this._resumePageIdx = null;
  6403. this._dirtyMatch = true;
  6404. }
  6405. _classPrivateMethodGet(this, _updateUIState, _updateUIState2).call(this, FindState.FOUND);
  6406. this._highlightMatches = false;
  6407. _classPrivateMethodGet(this, _updateAllPages, _updateAllPages2).call(this);
  6408. });
  6409. }
  6410. function _requestMatchesCount2() {
  6411. const {
  6412. pageIdx,
  6413. matchIdx
  6414. } = this._selected;
  6415. let current = 0,
  6416. total = this._matchesCountTotal;
  6417. if (matchIdx !== -1) {
  6418. for (let i = 0; i < pageIdx; i++) {
  6419. var _this$_pageMatches$i;
  6420. current += ((_this$_pageMatches$i = this._pageMatches[i]) === null || _this$_pageMatches$i === void 0 ? void 0 : _this$_pageMatches$i.length) || 0;
  6421. }
  6422. current += matchIdx + 1;
  6423. }
  6424. if (current < 1 || current > total) {
  6425. current = total = 0;
  6426. }
  6427. return {
  6428. current,
  6429. total
  6430. };
  6431. }
  6432. function _updateUIResultsCount2() {
  6433. this._eventBus.dispatch("updatefindmatchescount", {
  6434. source: this,
  6435. matchesCount: _classPrivateMethodGet(this, _requestMatchesCount, _requestMatchesCount2).call(this)
  6436. });
  6437. }
  6438. function _updateUIState2(state) {
  6439. var _this$_state;
  6440. let previous = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6441. if (!_classPrivateFieldGet(this, _updateMatchesCountOnProgress) && (_classPrivateFieldGet(this, _visitedPagesCount) !== this._linkService.pagesCount || state === FindState.PENDING)) {
  6442. return;
  6443. }
  6444. this._eventBus.dispatch("updatefindcontrolstate", {
  6445. source: this,
  6446. state,
  6447. previous,
  6448. matchesCount: _classPrivateMethodGet(this, _requestMatchesCount, _requestMatchesCount2).call(this),
  6449. rawQuery: ((_this$_state = this._state) === null || _this$_state === void 0 ? void 0 : _this$_state.query) ?? null
  6450. });
  6451. }
  6452. /***/
  6453. }),
  6454. /* 19 */
  6455. /***/ ((__unused_webpack_module, exports) => {
  6456. Object.defineProperty(exports, "__esModule", ({
  6457. value: true
  6458. }));
  6459. exports.CharacterType = void 0;
  6460. exports.getCharacterType = getCharacterType;
  6461. const CharacterType = {
  6462. SPACE: 0,
  6463. ALPHA_LETTER: 1,
  6464. PUNCT: 2,
  6465. HAN_LETTER: 3,
  6466. KATAKANA_LETTER: 4,
  6467. HIRAGANA_LETTER: 5,
  6468. HALFWIDTH_KATAKANA_LETTER: 6,
  6469. THAI_LETTER: 7
  6470. };
  6471. exports.CharacterType = CharacterType;
  6472. function isAlphabeticalScript(charCode) {
  6473. return charCode < 0x2e80;
  6474. }
  6475. function isAscii(charCode) {
  6476. return (charCode & 0xff80) === 0;
  6477. }
  6478. function isAsciiAlpha(charCode) {
  6479. return charCode >= 0x61 && charCode <= 0x7a || charCode >= 0x41 && charCode <= 0x5a;
  6480. }
  6481. function isAsciiDigit(charCode) {
  6482. return charCode >= 0x30 && charCode <= 0x39;
  6483. }
  6484. function isAsciiSpace(charCode) {
  6485. return charCode === 0x20 || charCode === 0x09 || charCode === 0x0d || charCode === 0x0a;
  6486. }
  6487. function isHan(charCode) {
  6488. return charCode >= 0x3400 && charCode <= 0x9fff || charCode >= 0xf900 && charCode <= 0xfaff;
  6489. }
  6490. function isKatakana(charCode) {
  6491. return charCode >= 0x30a0 && charCode <= 0x30ff;
  6492. }
  6493. function isHiragana(charCode) {
  6494. return charCode >= 0x3040 && charCode <= 0x309f;
  6495. }
  6496. function isHalfwidthKatakana(charCode) {
  6497. return charCode >= 0xff60 && charCode <= 0xff9f;
  6498. }
  6499. function isThai(charCode) {
  6500. return (charCode & 0xff80) === 0x0e00;
  6501. }
  6502. function getCharacterType(charCode) {
  6503. if (isAlphabeticalScript(charCode)) {
  6504. if (isAscii(charCode)) {
  6505. if (isAsciiSpace(charCode)) {
  6506. return CharacterType.SPACE;
  6507. } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5f) {
  6508. return CharacterType.ALPHA_LETTER;
  6509. }
  6510. return CharacterType.PUNCT;
  6511. } else if (isThai(charCode)) {
  6512. return CharacterType.THAI_LETTER;
  6513. } else if (charCode === 0xa0) {
  6514. return CharacterType.SPACE;
  6515. }
  6516. return CharacterType.ALPHA_LETTER;
  6517. }
  6518. if (isHan(charCode)) {
  6519. return CharacterType.HAN_LETTER;
  6520. } else if (isKatakana(charCode)) {
  6521. return CharacterType.KATAKANA_LETTER;
  6522. } else if (isHiragana(charCode)) {
  6523. return CharacterType.HIRAGANA_LETTER;
  6524. } else if (isHalfwidthKatakana(charCode)) {
  6525. return CharacterType.HALFWIDTH_KATAKANA_LETTER;
  6526. }
  6527. return CharacterType.ALPHA_LETTER;
  6528. }
  6529. /***/
  6530. }),
  6531. /* 20 */
  6532. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6533. Object.defineProperty(exports, "__esModule", ({
  6534. value: true
  6535. }));
  6536. exports.PDFHistory = void 0;
  6537. exports.isDestArraysEqual = isDestArraysEqual;
  6538. exports.isDestHashesEqual = isDestHashesEqual;
  6539. var _ui_utils = __webpack_require__(3);
  6540. var _event_utils = __webpack_require__(6);
  6541. const HASH_CHANGE_TIMEOUT = 1000;
  6542. const POSITION_UPDATED_THRESHOLD = 50;
  6543. const UPDATE_VIEWAREA_TIMEOUT = 1000;
  6544. function getCurrentHash() {
  6545. return document.location.hash;
  6546. }
  6547. class PDFHistory {
  6548. constructor(_ref) {
  6549. let {
  6550. linkService,
  6551. eventBus
  6552. } = _ref;
  6553. this.linkService = linkService;
  6554. this.eventBus = eventBus;
  6555. this._initialized = false;
  6556. this._fingerprint = "";
  6557. this.reset();
  6558. this._boundEvents = null;
  6559. this.eventBus._on("pagesinit", () => {
  6560. this._isPagesLoaded = false;
  6561. this.eventBus._on("pagesloaded", evt => {
  6562. this._isPagesLoaded = !!evt.pagesCount;
  6563. }, {
  6564. once: true
  6565. });
  6566. });
  6567. }
  6568. initialize(_ref2) {
  6569. let {
  6570. fingerprint,
  6571. resetHistory = false,
  6572. updateUrl = false
  6573. } = _ref2;
  6574. if (!fingerprint || typeof fingerprint !== "string") {
  6575. console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
  6576. return;
  6577. }
  6578. if (this._initialized) {
  6579. this.reset();
  6580. }
  6581. const reInitialized = this._fingerprint !== "" && this._fingerprint !== fingerprint;
  6582. this._fingerprint = fingerprint;
  6583. this._updateUrl = updateUrl === true;
  6584. this._initialized = true;
  6585. this._bindEvents();
  6586. const state = window.history.state;
  6587. this._popStateInProgress = false;
  6588. this._blockHashChange = 0;
  6589. this._currentHash = getCurrentHash();
  6590. this._numPositionUpdates = 0;
  6591. this._uid = this._maxUid = 0;
  6592. this._destination = null;
  6593. this._position = null;
  6594. if (!this._isValidState(state, true) || resetHistory) {
  6595. const {
  6596. hash,
  6597. page,
  6598. rotation
  6599. } = this._parseCurrentHash(true);
  6600. if (!hash || reInitialized || resetHistory) {
  6601. this._pushOrReplaceState(null, true);
  6602. return;
  6603. }
  6604. this._pushOrReplaceState({
  6605. hash,
  6606. page,
  6607. rotation
  6608. }, true);
  6609. return;
  6610. }
  6611. const destination = state.destination;
  6612. this._updateInternalState(destination, state.uid, true);
  6613. if (destination.rotation !== undefined) {
  6614. this._initialRotation = destination.rotation;
  6615. }
  6616. if (destination.dest) {
  6617. this._initialBookmark = JSON.stringify(destination.dest);
  6618. this._destination.page = null;
  6619. } else if (destination.hash) {
  6620. this._initialBookmark = destination.hash;
  6621. } else if (destination.page) {
  6622. this._initialBookmark = `page=${destination.page}`;
  6623. }
  6624. }
  6625. reset() {
  6626. if (this._initialized) {
  6627. this._pageHide();
  6628. this._initialized = false;
  6629. this._unbindEvents();
  6630. }
  6631. if (this._updateViewareaTimeout) {
  6632. clearTimeout(this._updateViewareaTimeout);
  6633. this._updateViewareaTimeout = null;
  6634. }
  6635. this._initialBookmark = null;
  6636. this._initialRotation = null;
  6637. }
  6638. push(_ref3) {
  6639. let {
  6640. namedDest = null,
  6641. explicitDest,
  6642. pageNumber
  6643. } = _ref3;
  6644. if (!this._initialized) {
  6645. return;
  6646. }
  6647. if (namedDest && typeof namedDest !== "string") {
  6648. console.error("PDFHistory.push: " + `"${namedDest}" is not a valid namedDest parameter.`);
  6649. return;
  6650. } else if (!Array.isArray(explicitDest)) {
  6651. console.error("PDFHistory.push: " + `"${explicitDest}" is not a valid explicitDest parameter.`);
  6652. return;
  6653. } else if (!this._isValidPage(pageNumber)) {
  6654. if (pageNumber !== null || this._destination) {
  6655. console.error("PDFHistory.push: " + `"${pageNumber}" is not a valid pageNumber parameter.`);
  6656. return;
  6657. }
  6658. }
  6659. const hash = namedDest || JSON.stringify(explicitDest);
  6660. if (!hash) {
  6661. return;
  6662. }
  6663. let forceReplace = false;
  6664. if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
  6665. if (this._destination.page) {
  6666. return;
  6667. }
  6668. forceReplace = true;
  6669. }
  6670. if (this._popStateInProgress && !forceReplace) {
  6671. return;
  6672. }
  6673. this._pushOrReplaceState({
  6674. dest: explicitDest,
  6675. hash,
  6676. page: pageNumber,
  6677. rotation: this.linkService.rotation
  6678. }, forceReplace);
  6679. if (!this._popStateInProgress) {
  6680. this._popStateInProgress = true;
  6681. Promise.resolve().then(() => {
  6682. this._popStateInProgress = false;
  6683. });
  6684. }
  6685. }
  6686. pushPage(pageNumber) {
  6687. var _this$_destination;
  6688. if (!this._initialized) {
  6689. return;
  6690. }
  6691. if (!this._isValidPage(pageNumber)) {
  6692. console.error(`PDFHistory.pushPage: "${pageNumber}" is not a valid page number.`);
  6693. return;
  6694. }
  6695. if (((_this$_destination = this._destination) === null || _this$_destination === void 0 ? void 0 : _this$_destination.page) === pageNumber) {
  6696. return;
  6697. }
  6698. if (this._popStateInProgress) {
  6699. return;
  6700. }
  6701. this._pushOrReplaceState({
  6702. dest: null,
  6703. hash: `page=${pageNumber}`,
  6704. page: pageNumber,
  6705. rotation: this.linkService.rotation
  6706. });
  6707. if (!this._popStateInProgress) {
  6708. this._popStateInProgress = true;
  6709. Promise.resolve().then(() => {
  6710. this._popStateInProgress = false;
  6711. });
  6712. }
  6713. }
  6714. pushCurrentPosition() {
  6715. if (!this._initialized || this._popStateInProgress) {
  6716. return;
  6717. }
  6718. this._tryPushCurrentPosition();
  6719. }
  6720. back() {
  6721. if (!this._initialized || this._popStateInProgress) {
  6722. return;
  6723. }
  6724. const state = window.history.state;
  6725. if (this._isValidState(state) && state.uid > 0) {
  6726. window.history.back();
  6727. }
  6728. }
  6729. forward() {
  6730. if (!this._initialized || this._popStateInProgress) {
  6731. return;
  6732. }
  6733. const state = window.history.state;
  6734. if (this._isValidState(state) && state.uid < this._maxUid) {
  6735. window.history.forward();
  6736. }
  6737. }
  6738. get popStateInProgress() {
  6739. return this._initialized && (this._popStateInProgress || this._blockHashChange > 0);
  6740. }
  6741. get initialBookmark() {
  6742. return this._initialized ? this._initialBookmark : null;
  6743. }
  6744. get initialRotation() {
  6745. return this._initialized ? this._initialRotation : null;
  6746. }
  6747. _pushOrReplaceState(destination) {
  6748. let forceReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6749. const shouldReplace = forceReplace || !this._destination;
  6750. const newState = {
  6751. fingerprint: this._fingerprint,
  6752. uid: shouldReplace ? this._uid : this._uid + 1,
  6753. destination
  6754. };
  6755. this._updateInternalState(destination, newState.uid);
  6756. let newUrl;
  6757. if (this._updateUrl && destination !== null && destination !== void 0 && destination.hash) {
  6758. const baseUrl = document.location.href.split("#")[0];
  6759. if (!baseUrl.startsWith("file://")) {
  6760. newUrl = `${baseUrl}#${destination.hash}`;
  6761. }
  6762. }
  6763. if (shouldReplace) {
  6764. window.history.replaceState(newState, "", newUrl);
  6765. } else {
  6766. window.history.pushState(newState, "", newUrl);
  6767. }
  6768. }
  6769. _tryPushCurrentPosition() {
  6770. let temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6771. if (!this._position) {
  6772. return;
  6773. }
  6774. let position = this._position;
  6775. if (temporary) {
  6776. position = Object.assign(Object.create(null), this._position);
  6777. position.temporary = true;
  6778. }
  6779. if (!this._destination) {
  6780. this._pushOrReplaceState(position);
  6781. return;
  6782. }
  6783. if (this._destination.temporary) {
  6784. this._pushOrReplaceState(position, true);
  6785. return;
  6786. }
  6787. if (this._destination.hash === position.hash) {
  6788. return;
  6789. }
  6790. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  6791. return;
  6792. }
  6793. let forceReplace = false;
  6794. if (this._destination.page >= position.first && this._destination.page <= position.page) {
  6795. if (this._destination.dest !== undefined || !this._destination.first) {
  6796. return;
  6797. }
  6798. forceReplace = true;
  6799. }
  6800. this._pushOrReplaceState(position, forceReplace);
  6801. }
  6802. _isValidPage(val) {
  6803. return Number.isInteger(val) && val > 0 && val <= this.linkService.pagesCount;
  6804. }
  6805. _isValidState(state) {
  6806. let checkReload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6807. if (!state) {
  6808. return false;
  6809. }
  6810. if (state.fingerprint !== this._fingerprint) {
  6811. if (checkReload) {
  6812. if (typeof state.fingerprint !== "string" || state.fingerprint.length !== this._fingerprint.length) {
  6813. return false;
  6814. }
  6815. const [perfEntry] = performance.getEntriesByType("navigation");
  6816. if ((perfEntry === null || perfEntry === void 0 ? void 0 : perfEntry.type) !== "reload") {
  6817. return false;
  6818. }
  6819. } else {
  6820. return false;
  6821. }
  6822. }
  6823. if (!Number.isInteger(state.uid) || state.uid < 0) {
  6824. return false;
  6825. }
  6826. if (state.destination === null || typeof state.destination !== "object") {
  6827. return false;
  6828. }
  6829. return true;
  6830. }
  6831. _updateInternalState(destination, uid) {
  6832. let removeTemporary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  6833. if (this._updateViewareaTimeout) {
  6834. clearTimeout(this._updateViewareaTimeout);
  6835. this._updateViewareaTimeout = null;
  6836. }
  6837. if (removeTemporary && destination !== null && destination !== void 0 && destination.temporary) {
  6838. delete destination.temporary;
  6839. }
  6840. this._destination = destination;
  6841. this._uid = uid;
  6842. this._maxUid = Math.max(this._maxUid, uid);
  6843. this._numPositionUpdates = 0;
  6844. }
  6845. _parseCurrentHash() {
  6846. let checkNameddest = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6847. const hash = unescape(getCurrentHash()).substring(1);
  6848. const params = (0, _ui_utils.parseQueryString)(hash);
  6849. const nameddest = params.get("nameddest") || "";
  6850. let page = params.get("page") | 0;
  6851. if (!this._isValidPage(page) || checkNameddest && nameddest.length > 0) {
  6852. page = null;
  6853. }
  6854. return {
  6855. hash,
  6856. page,
  6857. rotation: this.linkService.rotation
  6858. };
  6859. }
  6860. _updateViewarea(_ref4) {
  6861. let {
  6862. location
  6863. } = _ref4;
  6864. if (this._updateViewareaTimeout) {
  6865. clearTimeout(this._updateViewareaTimeout);
  6866. this._updateViewareaTimeout = null;
  6867. }
  6868. this._position = {
  6869. hash: location.pdfOpenParams.substring(1),
  6870. page: this.linkService.page,
  6871. first: location.pageNumber,
  6872. rotation: location.rotation
  6873. };
  6874. if (this._popStateInProgress) {
  6875. return;
  6876. }
  6877. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
  6878. this._numPositionUpdates++;
  6879. }
  6880. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  6881. this._updateViewareaTimeout = setTimeout(() => {
  6882. if (!this._popStateInProgress) {
  6883. this._tryPushCurrentPosition(true);
  6884. }
  6885. this._updateViewareaTimeout = null;
  6886. }, UPDATE_VIEWAREA_TIMEOUT);
  6887. }
  6888. }
  6889. _popState(_ref5) {
  6890. let {
  6891. state
  6892. } = _ref5;
  6893. const newHash = getCurrentHash(),
  6894. hashChanged = this._currentHash !== newHash;
  6895. this._currentHash = newHash;
  6896. if (!state) {
  6897. this._uid++;
  6898. const {
  6899. hash,
  6900. page,
  6901. rotation
  6902. } = this._parseCurrentHash();
  6903. this._pushOrReplaceState({
  6904. hash,
  6905. page,
  6906. rotation
  6907. }, true);
  6908. return;
  6909. }
  6910. if (!this._isValidState(state)) {
  6911. return;
  6912. }
  6913. this._popStateInProgress = true;
  6914. if (hashChanged) {
  6915. this._blockHashChange++;
  6916. (0, _event_utils.waitOnEventOrTimeout)({
  6917. target: window,
  6918. name: "hashchange",
  6919. delay: HASH_CHANGE_TIMEOUT
  6920. }).then(() => {
  6921. this._blockHashChange--;
  6922. });
  6923. }
  6924. const destination = state.destination;
  6925. this._updateInternalState(destination, state.uid, true);
  6926. if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
  6927. this.linkService.rotation = destination.rotation;
  6928. }
  6929. if (destination.dest) {
  6930. this.linkService.goToDestination(destination.dest);
  6931. } else if (destination.hash) {
  6932. this.linkService.setHash(destination.hash);
  6933. } else if (destination.page) {
  6934. this.linkService.page = destination.page;
  6935. }
  6936. Promise.resolve().then(() => {
  6937. this._popStateInProgress = false;
  6938. });
  6939. }
  6940. _pageHide() {
  6941. if (!this._destination || this._destination.temporary) {
  6942. this._tryPushCurrentPosition();
  6943. }
  6944. }
  6945. _bindEvents() {
  6946. if (this._boundEvents) {
  6947. return;
  6948. }
  6949. this._boundEvents = {
  6950. updateViewarea: this._updateViewarea.bind(this),
  6951. popState: this._popState.bind(this),
  6952. pageHide: this._pageHide.bind(this)
  6953. };
  6954. this.eventBus._on("updateviewarea", this._boundEvents.updateViewarea);
  6955. window.addEventListener("popstate", this._boundEvents.popState);
  6956. window.addEventListener("pagehide", this._boundEvents.pageHide);
  6957. }
  6958. _unbindEvents() {
  6959. if (!this._boundEvents) {
  6960. return;
  6961. }
  6962. this.eventBus._off("updateviewarea", this._boundEvents.updateViewarea);
  6963. window.removeEventListener("popstate", this._boundEvents.popState);
  6964. window.removeEventListener("pagehide", this._boundEvents.pageHide);
  6965. this._boundEvents = null;
  6966. }
  6967. }
  6968. exports.PDFHistory = PDFHistory;
  6969. function isDestHashesEqual(destHash, pushHash) {
  6970. if (typeof destHash !== "string" || typeof pushHash !== "string") {
  6971. return false;
  6972. }
  6973. if (destHash === pushHash) {
  6974. return true;
  6975. }
  6976. const nameddest = (0, _ui_utils.parseQueryString)(destHash).get("nameddest");
  6977. if (nameddest === pushHash) {
  6978. return true;
  6979. }
  6980. return false;
  6981. }
  6982. function isDestArraysEqual(firstDest, secondDest) {
  6983. function isEntryEqual(first, second) {
  6984. if (typeof first !== typeof second) {
  6985. return false;
  6986. }
  6987. if (Array.isArray(first) || Array.isArray(second)) {
  6988. return false;
  6989. }
  6990. if (first !== null && typeof first === "object" && second !== null) {
  6991. if (Object.keys(first).length !== Object.keys(second).length) {
  6992. return false;
  6993. }
  6994. for (const key in first) {
  6995. if (!isEntryEqual(first[key], second[key])) {
  6996. return false;
  6997. }
  6998. }
  6999. return true;
  7000. }
  7001. return first === second || Number.isNaN(first) && Number.isNaN(second);
  7002. }
  7003. if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
  7004. return false;
  7005. }
  7006. if (firstDest.length !== secondDest.length) {
  7007. return false;
  7008. }
  7009. for (let i = 0, ii = firstDest.length; i < ii; i++) {
  7010. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  7011. return false;
  7012. }
  7013. }
  7014. return true;
  7015. }
  7016. /***/
  7017. }),
  7018. /* 21 */
  7019. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  7020. Object.defineProperty(exports, "__esModule", ({
  7021. value: true
  7022. }));
  7023. exports.PDFLayerViewer = void 0;
  7024. var _base_tree_viewer = __webpack_require__(13);
  7025. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  7026. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  7027. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  7028. var _updateLayers = /*#__PURE__*/new WeakSet();
  7029. class PDFLayerViewer extends _base_tree_viewer.BaseTreeViewer {
  7030. constructor(options) {
  7031. super(options);
  7032. _classPrivateMethodInitSpec(this, _updateLayers);
  7033. this.l10n = options.l10n;
  7034. this.eventBus._on("optionalcontentconfigchanged", evt => {
  7035. _classPrivateMethodGet(this, _updateLayers, _updateLayers2).call(this, evt.promise);
  7036. });
  7037. this.eventBus._on("resetlayers", () => {
  7038. _classPrivateMethodGet(this, _updateLayers, _updateLayers2).call(this);
  7039. });
  7040. this.eventBus._on("togglelayerstree", this._toggleAllTreeItems.bind(this));
  7041. }
  7042. reset() {
  7043. super.reset();
  7044. this._optionalContentConfig = null;
  7045. this._optionalContentHash = null;
  7046. }
  7047. _dispatchEvent(layersCount) {
  7048. this.eventBus.dispatch("layersloaded", {
  7049. source: this,
  7050. layersCount
  7051. });
  7052. }
  7053. _bindLink(element, _ref) {
  7054. let {
  7055. groupId,
  7056. input
  7057. } = _ref;
  7058. const setVisibility = () => {
  7059. this._optionalContentConfig.setVisibility(groupId, input.checked);
  7060. this._optionalContentHash = this._optionalContentConfig.getHash();
  7061. this.eventBus.dispatch("optionalcontentconfig", {
  7062. source: this,
  7063. promise: Promise.resolve(this._optionalContentConfig)
  7064. });
  7065. };
  7066. element.onclick = evt => {
  7067. if (evt.target === input) {
  7068. setVisibility();
  7069. return true;
  7070. } else if (evt.target !== element) {
  7071. return true;
  7072. }
  7073. input.checked = !input.checked;
  7074. setVisibility();
  7075. return false;
  7076. };
  7077. }
  7078. async _setNestedName(element, _ref2) {
  7079. let {
  7080. name = null
  7081. } = _ref2;
  7082. if (typeof name === "string") {
  7083. element.textContent = this._normalizeTextContent(name);
  7084. return;
  7085. }
  7086. element.textContent = await this.l10n.get("additional_layers");
  7087. element.style.fontStyle = "italic";
  7088. }
  7089. _addToggleButton(div, _ref3) {
  7090. let {
  7091. name = null
  7092. } = _ref3;
  7093. super._addToggleButton(div, name === null);
  7094. }
  7095. _toggleAllTreeItems() {
  7096. if (!this._optionalContentConfig) {
  7097. return;
  7098. }
  7099. super._toggleAllTreeItems();
  7100. }
  7101. render(_ref4) {
  7102. let {
  7103. optionalContentConfig,
  7104. pdfDocument
  7105. } = _ref4;
  7106. if (this._optionalContentConfig) {
  7107. this.reset();
  7108. }
  7109. this._optionalContentConfig = optionalContentConfig || null;
  7110. this._pdfDocument = pdfDocument || null;
  7111. const groups = optionalContentConfig === null || optionalContentConfig === void 0 ? void 0 : optionalContentConfig.getOrder();
  7112. if (!groups) {
  7113. this._dispatchEvent(0);
  7114. return;
  7115. }
  7116. this._optionalContentHash = optionalContentConfig.getHash();
  7117. const fragment = document.createDocumentFragment(),
  7118. queue = [{
  7119. parent: fragment,
  7120. groups
  7121. }];
  7122. let layersCount = 0,
  7123. hasAnyNesting = false;
  7124. while (queue.length > 0) {
  7125. const levelData = queue.shift();
  7126. for (const groupId of levelData.groups) {
  7127. const div = document.createElement("div");
  7128. div.className = "treeItem";
  7129. const element = document.createElement("a");
  7130. div.append(element);
  7131. if (typeof groupId === "object") {
  7132. hasAnyNesting = true;
  7133. this._addToggleButton(div, groupId);
  7134. this._setNestedName(element, groupId);
  7135. const itemsDiv = document.createElement("div");
  7136. itemsDiv.className = "treeItems";
  7137. div.append(itemsDiv);
  7138. queue.push({
  7139. parent: itemsDiv,
  7140. groups: groupId.order
  7141. });
  7142. } else {
  7143. const group = optionalContentConfig.getGroup(groupId);
  7144. const input = document.createElement("input");
  7145. this._bindLink(element, {
  7146. groupId,
  7147. input
  7148. });
  7149. input.type = "checkbox";
  7150. input.checked = group.visible;
  7151. const label = document.createElement("label");
  7152. label.textContent = this._normalizeTextContent(group.name);
  7153. label.append(input);
  7154. element.append(label);
  7155. layersCount++;
  7156. }
  7157. levelData.parent.append(div);
  7158. }
  7159. }
  7160. this._finishRendering(fragment, layersCount, hasAnyNesting);
  7161. }
  7162. }
  7163. exports.PDFLayerViewer = PDFLayerViewer;
  7164. async function _updateLayers2() {
  7165. let promise = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  7166. if (!this._optionalContentConfig) {
  7167. return;
  7168. }
  7169. const pdfDocument = this._pdfDocument;
  7170. const optionalContentConfig = await (promise || pdfDocument.getOptionalContentConfig());
  7171. if (pdfDocument !== this._pdfDocument) {
  7172. return;
  7173. }
  7174. if (promise) {
  7175. if (optionalContentConfig.getHash() === this._optionalContentHash) {
  7176. return;
  7177. }
  7178. } else {
  7179. this.eventBus.dispatch("optionalcontentconfig", {
  7180. source: this,
  7181. promise: Promise.resolve(optionalContentConfig)
  7182. });
  7183. }
  7184. this.render({
  7185. optionalContentConfig,
  7186. pdfDocument: this._pdfDocument
  7187. });
  7188. }
  7189. /***/
  7190. }),
  7191. /* 22 */
  7192. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  7193. Object.defineProperty(exports, "__esModule", ({
  7194. value: true
  7195. }));
  7196. exports.PDFOutlineViewer = void 0;
  7197. var _base_tree_viewer = __webpack_require__(13);
  7198. var _pdfjsLib = __webpack_require__(4);
  7199. var _ui_utils = __webpack_require__(3);
  7200. class PDFOutlineViewer extends _base_tree_viewer.BaseTreeViewer {
  7201. constructor(options) {
  7202. super(options);
  7203. this.linkService = options.linkService;
  7204. this.downloadManager = options.downloadManager;
  7205. this.eventBus._on("toggleoutlinetree", this._toggleAllTreeItems.bind(this));
  7206. this.eventBus._on("currentoutlineitem", this._currentOutlineItem.bind(this));
  7207. this.eventBus._on("pagechanging", evt => {
  7208. this._currentPageNumber = evt.pageNumber;
  7209. });
  7210. this.eventBus._on("pagesloaded", evt => {
  7211. this._isPagesLoaded = !!evt.pagesCount;
  7212. if (this._currentOutlineItemCapability && !this._currentOutlineItemCapability.settled) {
  7213. this._currentOutlineItemCapability.resolve(this._isPagesLoaded);
  7214. }
  7215. });
  7216. this.eventBus._on("sidebarviewchanged", evt => {
  7217. this._sidebarView = evt.view;
  7218. });
  7219. }
  7220. reset() {
  7221. super.reset();
  7222. this._outline = null;
  7223. this._pageNumberToDestHashCapability = null;
  7224. this._currentPageNumber = 1;
  7225. this._isPagesLoaded = null;
  7226. if (this._currentOutlineItemCapability && !this._currentOutlineItemCapability.settled) {
  7227. this._currentOutlineItemCapability.resolve(false);
  7228. }
  7229. this._currentOutlineItemCapability = null;
  7230. }
  7231. _dispatchEvent(outlineCount) {
  7232. var _this$_pdfDocument;
  7233. this._currentOutlineItemCapability = (0, _pdfjsLib.createPromiseCapability)();
  7234. if (outlineCount === 0 || (_this$_pdfDocument = this._pdfDocument) !== null && _this$_pdfDocument !== void 0 && _this$_pdfDocument.loadingParams.disableAutoFetch) {
  7235. this._currentOutlineItemCapability.resolve(false);
  7236. } else if (this._isPagesLoaded !== null) {
  7237. this._currentOutlineItemCapability.resolve(this._isPagesLoaded);
  7238. }
  7239. this.eventBus.dispatch("outlineloaded", {
  7240. source: this,
  7241. outlineCount,
  7242. currentOutlineItemPromise: this._currentOutlineItemCapability.promise
  7243. });
  7244. }
  7245. _bindLink(element, _ref) {
  7246. let {
  7247. url,
  7248. newWindow,
  7249. action,
  7250. attachment,
  7251. dest,
  7252. setOCGState
  7253. } = _ref;
  7254. const {
  7255. linkService
  7256. } = this;
  7257. if (url) {
  7258. linkService.addLinkAttributes(element, url, newWindow);
  7259. return;
  7260. }
  7261. if (action) {
  7262. element.href = linkService.getAnchorUrl("");
  7263. element.onclick = () => {
  7264. linkService.executeNamedAction(action);
  7265. return false;
  7266. };
  7267. return;
  7268. }
  7269. if (attachment) {
  7270. element.href = linkService.getAnchorUrl("");
  7271. element.onclick = () => {
  7272. this.downloadManager.openOrDownloadData(element, attachment.content, attachment.filename);
  7273. return false;
  7274. };
  7275. return;
  7276. }
  7277. if (setOCGState) {
  7278. element.href = linkService.getAnchorUrl("");
  7279. element.onclick = () => {
  7280. linkService.executeSetOCGState(setOCGState);
  7281. return false;
  7282. };
  7283. return;
  7284. }
  7285. element.href = linkService.getDestinationHash(dest);
  7286. element.onclick = evt => {
  7287. this._updateCurrentTreeItem(evt.target.parentNode);
  7288. if (dest) {
  7289. linkService.goToDestination(dest);
  7290. }
  7291. return false;
  7292. };
  7293. }
  7294. _setStyles(element, _ref2) {
  7295. let {
  7296. bold,
  7297. italic
  7298. } = _ref2;
  7299. if (bold) {
  7300. element.style.fontWeight = "bold";
  7301. }
  7302. if (italic) {
  7303. element.style.fontStyle = "italic";
  7304. }
  7305. }
  7306. _addToggleButton(div, _ref3) {
  7307. let {
  7308. count,
  7309. items
  7310. } = _ref3;
  7311. let hidden = false;
  7312. if (count < 0) {
  7313. let totalCount = items.length;
  7314. if (totalCount > 0) {
  7315. const queue = [...items];
  7316. while (queue.length > 0) {
  7317. const {
  7318. count: nestedCount,
  7319. items: nestedItems
  7320. } = queue.shift();
  7321. if (nestedCount > 0 && nestedItems.length > 0) {
  7322. totalCount += nestedItems.length;
  7323. queue.push(...nestedItems);
  7324. }
  7325. }
  7326. }
  7327. if (Math.abs(count) === totalCount) {
  7328. hidden = true;
  7329. }
  7330. }
  7331. super._addToggleButton(div, hidden);
  7332. }
  7333. _toggleAllTreeItems() {
  7334. if (!this._outline) {
  7335. return;
  7336. }
  7337. super._toggleAllTreeItems();
  7338. }
  7339. render(_ref4) {
  7340. let {
  7341. outline,
  7342. pdfDocument
  7343. } = _ref4;
  7344. if (this._outline) {
  7345. this.reset();
  7346. }
  7347. this._outline = outline || null;
  7348. this._pdfDocument = pdfDocument || null;
  7349. if (!outline) {
  7350. this._dispatchEvent(0);
  7351. return;
  7352. }
  7353. const fragment = document.createDocumentFragment();
  7354. const queue = [{
  7355. parent: fragment,
  7356. items: outline
  7357. }];
  7358. let outlineCount = 0,
  7359. hasAnyNesting = false;
  7360. while (queue.length > 0) {
  7361. const levelData = queue.shift();
  7362. for (const item of levelData.items) {
  7363. const div = document.createElement("div");
  7364. div.className = "treeItem";
  7365. const element = document.createElement("a");
  7366. this._bindLink(element, item);
  7367. this._setStyles(element, item);
  7368. element.textContent = this._normalizeTextContent(item.title);
  7369. div.append(element);
  7370. if (item.items.length > 0) {
  7371. hasAnyNesting = true;
  7372. this._addToggleButton(div, item);
  7373. const itemsDiv = document.createElement("div");
  7374. itemsDiv.className = "treeItems";
  7375. div.append(itemsDiv);
  7376. queue.push({
  7377. parent: itemsDiv,
  7378. items: item.items
  7379. });
  7380. }
  7381. levelData.parent.append(div);
  7382. outlineCount++;
  7383. }
  7384. }
  7385. this._finishRendering(fragment, outlineCount, hasAnyNesting);
  7386. }
  7387. async _currentOutlineItem() {
  7388. if (!this._isPagesLoaded) {
  7389. throw new Error("_currentOutlineItem: All pages have not been loaded.");
  7390. }
  7391. if (!this._outline || !this._pdfDocument) {
  7392. return;
  7393. }
  7394. const pageNumberToDestHash = await this._getPageNumberToDestHash(this._pdfDocument);
  7395. if (!pageNumberToDestHash) {
  7396. return;
  7397. }
  7398. this._updateCurrentTreeItem(null);
  7399. if (this._sidebarView !== _ui_utils.SidebarView.OUTLINE) {
  7400. return;
  7401. }
  7402. for (let i = this._currentPageNumber; i > 0; i--) {
  7403. const destHash = pageNumberToDestHash.get(i);
  7404. if (!destHash) {
  7405. continue;
  7406. }
  7407. const linkElement = this.container.querySelector(`a[href="${destHash}"]`);
  7408. if (!linkElement) {
  7409. continue;
  7410. }
  7411. this._scrollToCurrentTreeItem(linkElement.parentNode);
  7412. break;
  7413. }
  7414. }
  7415. async _getPageNumberToDestHash(pdfDocument) {
  7416. if (this._pageNumberToDestHashCapability) {
  7417. return this._pageNumberToDestHashCapability.promise;
  7418. }
  7419. this._pageNumberToDestHashCapability = (0, _pdfjsLib.createPromiseCapability)();
  7420. const pageNumberToDestHash = new Map(),
  7421. pageNumberNesting = new Map();
  7422. const queue = [{
  7423. nesting: 0,
  7424. items: this._outline
  7425. }];
  7426. while (queue.length > 0) {
  7427. const levelData = queue.shift(),
  7428. currentNesting = levelData.nesting;
  7429. for (const {
  7430. dest,
  7431. items
  7432. } of levelData.items) {
  7433. let explicitDest, pageNumber;
  7434. if (typeof dest === "string") {
  7435. explicitDest = await pdfDocument.getDestination(dest);
  7436. if (pdfDocument !== this._pdfDocument) {
  7437. return null;
  7438. }
  7439. } else {
  7440. explicitDest = dest;
  7441. }
  7442. if (Array.isArray(explicitDest)) {
  7443. const [destRef] = explicitDest;
  7444. if (typeof destRef === "object" && destRef !== null) {
  7445. pageNumber = this.linkService._cachedPageNumber(destRef);
  7446. if (!pageNumber) {
  7447. try {
  7448. pageNumber = (await pdfDocument.getPageIndex(destRef)) + 1;
  7449. if (pdfDocument !== this._pdfDocument) {
  7450. return null;
  7451. }
  7452. this.linkService.cachePageRef(pageNumber, destRef);
  7453. } catch (ex) { }
  7454. }
  7455. } else if (Number.isInteger(destRef)) {
  7456. pageNumber = destRef + 1;
  7457. }
  7458. if (Number.isInteger(pageNumber) && (!pageNumberToDestHash.has(pageNumber) || currentNesting > pageNumberNesting.get(pageNumber))) {
  7459. const destHash = this.linkService.getDestinationHash(dest);
  7460. pageNumberToDestHash.set(pageNumber, destHash);
  7461. pageNumberNesting.set(pageNumber, currentNesting);
  7462. }
  7463. }
  7464. if (items.length > 0) {
  7465. queue.push({
  7466. nesting: currentNesting + 1,
  7467. items
  7468. });
  7469. }
  7470. }
  7471. }
  7472. this._pageNumberToDestHashCapability.resolve(pageNumberToDestHash.size > 0 ? pageNumberToDestHash : null);
  7473. return this._pageNumberToDestHashCapability.promise;
  7474. }
  7475. }
  7476. exports.PDFOutlineViewer = PDFOutlineViewer;
  7477. /***/
  7478. }),
  7479. /* 23 */
  7480. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  7481. Object.defineProperty(exports, "__esModule", ({
  7482. value: true
  7483. }));
  7484. exports.PDFPresentationMode = void 0;
  7485. var _ui_utils = __webpack_require__(3);
  7486. var _pdfjsLib = __webpack_require__(4);
  7487. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  7488. function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
  7489. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  7490. function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
  7491. function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
  7492. function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
  7493. function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
  7494. function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
  7495. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  7496. const DELAY_BEFORE_HIDING_CONTROLS = 3000;
  7497. const ACTIVE_SELECTOR = "pdfPresentationMode";
  7498. const CONTROLS_SELECTOR = "pdfPresentationModeControls";
  7499. const MOUSE_SCROLL_COOLDOWN_TIME = 50;
  7500. const PAGE_SWITCH_THRESHOLD = 0.1;
  7501. const SWIPE_MIN_DISTANCE_THRESHOLD = 50;
  7502. const SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
  7503. var _state = /*#__PURE__*/new WeakMap();
  7504. var _args = /*#__PURE__*/new WeakMap();
  7505. var _mouseWheel = /*#__PURE__*/new WeakSet();
  7506. var _notifyStateChange = /*#__PURE__*/new WeakSet();
  7507. var _enter = /*#__PURE__*/new WeakSet();
  7508. var _exit = /*#__PURE__*/new WeakSet();
  7509. var _mouseDown = /*#__PURE__*/new WeakSet();
  7510. var _contextMenu = /*#__PURE__*/new WeakSet();
  7511. var _showControls = /*#__PURE__*/new WeakSet();
  7512. var _hideControls = /*#__PURE__*/new WeakSet();
  7513. var _resetMouseScrollState = /*#__PURE__*/new WeakSet();
  7514. var _touchSwipe = /*#__PURE__*/new WeakSet();
  7515. var _addWindowListeners = /*#__PURE__*/new WeakSet();
  7516. var _removeWindowListeners = /*#__PURE__*/new WeakSet();
  7517. var _fullscreenChange = /*#__PURE__*/new WeakSet();
  7518. var _addFullscreenChangeListeners = /*#__PURE__*/new WeakSet();
  7519. var _removeFullscreenChangeListeners = /*#__PURE__*/new WeakSet();
  7520. class PDFPresentationMode {
  7521. constructor(_ref) {
  7522. let {
  7523. container,
  7524. pdfViewer,
  7525. eventBus
  7526. } = _ref;
  7527. _classPrivateMethodInitSpec(this, _removeFullscreenChangeListeners);
  7528. _classPrivateMethodInitSpec(this, _addFullscreenChangeListeners);
  7529. _classPrivateMethodInitSpec(this, _fullscreenChange);
  7530. _classPrivateMethodInitSpec(this, _removeWindowListeners);
  7531. _classPrivateMethodInitSpec(this, _addWindowListeners);
  7532. _classPrivateMethodInitSpec(this, _touchSwipe);
  7533. _classPrivateMethodInitSpec(this, _resetMouseScrollState);
  7534. _classPrivateMethodInitSpec(this, _hideControls);
  7535. _classPrivateMethodInitSpec(this, _showControls);
  7536. _classPrivateMethodInitSpec(this, _contextMenu);
  7537. _classPrivateMethodInitSpec(this, _mouseDown);
  7538. _classPrivateMethodInitSpec(this, _exit);
  7539. _classPrivateMethodInitSpec(this, _enter);
  7540. _classPrivateMethodInitSpec(this, _notifyStateChange);
  7541. _classPrivateMethodInitSpec(this, _mouseWheel);
  7542. _classPrivateFieldInitSpec(this, _state, {
  7543. writable: true,
  7544. value: _ui_utils.PresentationModeState.UNKNOWN
  7545. });
  7546. _classPrivateFieldInitSpec(this, _args, {
  7547. writable: true,
  7548. value: null
  7549. });
  7550. this.container = container;
  7551. this.pdfViewer = pdfViewer;
  7552. this.eventBus = eventBus;
  7553. this.contextMenuOpen = false;
  7554. this.mouseScrollTimeStamp = 0;
  7555. this.mouseScrollDelta = 0;
  7556. this.touchSwipeState = null;
  7557. }
  7558. async request() {
  7559. const {
  7560. container,
  7561. pdfViewer
  7562. } = this;
  7563. if (this.active || !pdfViewer.pagesCount || !container.requestFullscreen) {
  7564. return false;
  7565. }
  7566. _classPrivateMethodGet(this, _addFullscreenChangeListeners, _addFullscreenChangeListeners2).call(this);
  7567. _classPrivateMethodGet(this, _notifyStateChange, _notifyStateChange2).call(this, _ui_utils.PresentationModeState.CHANGING);
  7568. const promise = container.requestFullscreen();
  7569. _classPrivateFieldSet(this, _args, {
  7570. pageNumber: pdfViewer.currentPageNumber,
  7571. scaleValue: pdfViewer.currentScaleValue,
  7572. scrollMode: pdfViewer.scrollMode,
  7573. spreadMode: null,
  7574. annotationEditorMode: null
  7575. });
  7576. if (pdfViewer.spreadMode !== _ui_utils.SpreadMode.NONE && !(pdfViewer.pageViewsReady && pdfViewer.hasEqualPageSizes)) {
  7577. console.warn("Ignoring Spread modes when entering PresentationMode, " + "since the document may contain varying page sizes.");
  7578. _classPrivateFieldGet(this, _args).spreadMode = pdfViewer.spreadMode;
  7579. }
  7580. if (pdfViewer.annotationEditorMode !== _pdfjsLib.AnnotationEditorType.DISABLE) {
  7581. _classPrivateFieldGet(this, _args).annotationEditorMode = pdfViewer.annotationEditorMode;
  7582. }
  7583. try {
  7584. await promise;
  7585. pdfViewer.focus();
  7586. return true;
  7587. } catch (reason) {
  7588. _classPrivateMethodGet(this, _removeFullscreenChangeListeners, _removeFullscreenChangeListeners2).call(this);
  7589. _classPrivateMethodGet(this, _notifyStateChange, _notifyStateChange2).call(this, _ui_utils.PresentationModeState.NORMAL);
  7590. }
  7591. return false;
  7592. }
  7593. get active() {
  7594. return _classPrivateFieldGet(this, _state) === _ui_utils.PresentationModeState.CHANGING || _classPrivateFieldGet(this, _state) === _ui_utils.PresentationModeState.FULLSCREEN;
  7595. }
  7596. }
  7597. exports.PDFPresentationMode = PDFPresentationMode;
  7598. function _mouseWheel2(evt) {
  7599. if (!this.active) {
  7600. return;
  7601. }
  7602. evt.preventDefault();
  7603. const delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  7604. const currentTime = Date.now();
  7605. const storedTime = this.mouseScrollTimeStamp;
  7606. if (currentTime > storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {
  7607. return;
  7608. }
  7609. if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) {
  7610. _classPrivateMethodGet(this, _resetMouseScrollState, _resetMouseScrollState2).call(this);
  7611. }
  7612. this.mouseScrollDelta += delta;
  7613. if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
  7614. const totalDelta = this.mouseScrollDelta;
  7615. _classPrivateMethodGet(this, _resetMouseScrollState, _resetMouseScrollState2).call(this);
  7616. const success = totalDelta > 0 ? this.pdfViewer.previousPage() : this.pdfViewer.nextPage();
  7617. if (success) {
  7618. this.mouseScrollTimeStamp = currentTime;
  7619. }
  7620. }
  7621. }
  7622. function _notifyStateChange2(state) {
  7623. _classPrivateFieldSet(this, _state, state);
  7624. this.eventBus.dispatch("presentationmodechanged", {
  7625. source: this,
  7626. state
  7627. });
  7628. }
  7629. function _enter2() {
  7630. _classPrivateMethodGet(this, _notifyStateChange, _notifyStateChange2).call(this, _ui_utils.PresentationModeState.FULLSCREEN);
  7631. this.container.classList.add(ACTIVE_SELECTOR);
  7632. setTimeout(() => {
  7633. this.pdfViewer.scrollMode = _ui_utils.ScrollMode.PAGE;
  7634. if (_classPrivateFieldGet(this, _args).spreadMode !== null) {
  7635. this.pdfViewer.spreadMode = _ui_utils.SpreadMode.NONE;
  7636. }
  7637. this.pdfViewer.currentPageNumber = _classPrivateFieldGet(this, _args).pageNumber;
  7638. this.pdfViewer.currentScaleValue = "page-fit";
  7639. if (_classPrivateFieldGet(this, _args).annotationEditorMode !== null) {
  7640. this.pdfViewer.annotationEditorMode = _pdfjsLib.AnnotationEditorType.NONE;
  7641. }
  7642. }, 0);
  7643. _classPrivateMethodGet(this, _addWindowListeners, _addWindowListeners2).call(this);
  7644. _classPrivateMethodGet(this, _showControls, _showControls2).call(this);
  7645. this.contextMenuOpen = false;
  7646. window.getSelection().removeAllRanges();
  7647. }
  7648. function _exit2() {
  7649. const pageNumber = this.pdfViewer.currentPageNumber;
  7650. this.container.classList.remove(ACTIVE_SELECTOR);
  7651. setTimeout(() => {
  7652. _classPrivateMethodGet(this, _removeFullscreenChangeListeners, _removeFullscreenChangeListeners2).call(this);
  7653. _classPrivateMethodGet(this, _notifyStateChange, _notifyStateChange2).call(this, _ui_utils.PresentationModeState.NORMAL);
  7654. this.pdfViewer.scrollMode = _classPrivateFieldGet(this, _args).scrollMode;
  7655. if (_classPrivateFieldGet(this, _args).spreadMode !== null) {
  7656. this.pdfViewer.spreadMode = _classPrivateFieldGet(this, _args).spreadMode;
  7657. }
  7658. this.pdfViewer.currentScaleValue = _classPrivateFieldGet(this, _args).scaleValue;
  7659. this.pdfViewer.currentPageNumber = pageNumber;
  7660. if (_classPrivateFieldGet(this, _args).annotationEditorMode !== null) {
  7661. this.pdfViewer.annotationEditorMode = _classPrivateFieldGet(this, _args).annotationEditorMode;
  7662. }
  7663. _classPrivateFieldSet(this, _args, null);
  7664. }, 0);
  7665. _classPrivateMethodGet(this, _removeWindowListeners, _removeWindowListeners2).call(this);
  7666. _classPrivateMethodGet(this, _hideControls, _hideControls2).call(this);
  7667. _classPrivateMethodGet(this, _resetMouseScrollState, _resetMouseScrollState2).call(this);
  7668. this.contextMenuOpen = false;
  7669. }
  7670. function _mouseDown2(evt) {
  7671. var _evt$target$parentNod;
  7672. if (this.contextMenuOpen) {
  7673. this.contextMenuOpen = false;
  7674. evt.preventDefault();
  7675. return;
  7676. }
  7677. if (evt.button !== 0) {
  7678. return;
  7679. }
  7680. if (evt.target.href && (_evt$target$parentNod = evt.target.parentNode) !== null && _evt$target$parentNod !== void 0 && _evt$target$parentNod.hasAttribute("data-internal-link")) {
  7681. return;
  7682. }
  7683. evt.preventDefault();
  7684. if (evt.shiftKey) {
  7685. this.pdfViewer.previousPage();
  7686. } else {
  7687. this.pdfViewer.nextPage();
  7688. }
  7689. }
  7690. function _contextMenu2() {
  7691. this.contextMenuOpen = true;
  7692. }
  7693. function _showControls2() {
  7694. if (this.controlsTimeout) {
  7695. clearTimeout(this.controlsTimeout);
  7696. } else {
  7697. this.container.classList.add(CONTROLS_SELECTOR);
  7698. }
  7699. this.controlsTimeout = setTimeout(() => {
  7700. this.container.classList.remove(CONTROLS_SELECTOR);
  7701. delete this.controlsTimeout;
  7702. }, DELAY_BEFORE_HIDING_CONTROLS);
  7703. }
  7704. function _hideControls2() {
  7705. if (!this.controlsTimeout) {
  7706. return;
  7707. }
  7708. clearTimeout(this.controlsTimeout);
  7709. this.container.classList.remove(CONTROLS_SELECTOR);
  7710. delete this.controlsTimeout;
  7711. }
  7712. function _resetMouseScrollState2() {
  7713. this.mouseScrollTimeStamp = 0;
  7714. this.mouseScrollDelta = 0;
  7715. }
  7716. function _touchSwipe2(evt) {
  7717. if (!this.active) {
  7718. return;
  7719. }
  7720. if (evt.touches.length > 1) {
  7721. this.touchSwipeState = null;
  7722. return;
  7723. }
  7724. switch (evt.type) {
  7725. case "touchstart":
  7726. this.touchSwipeState = {
  7727. startX: evt.touches[0].pageX,
  7728. startY: evt.touches[0].pageY,
  7729. endX: evt.touches[0].pageX,
  7730. endY: evt.touches[0].pageY
  7731. };
  7732. break;
  7733. case "touchmove":
  7734. if (this.touchSwipeState === null) {
  7735. return;
  7736. }
  7737. this.touchSwipeState.endX = evt.touches[0].pageX;
  7738. this.touchSwipeState.endY = evt.touches[0].pageY;
  7739. evt.preventDefault();
  7740. break;
  7741. case "touchend":
  7742. if (this.touchSwipeState === null) {
  7743. return;
  7744. }
  7745. let delta = 0;
  7746. const dx = this.touchSwipeState.endX - this.touchSwipeState.startX;
  7747. const dy = this.touchSwipeState.endY - this.touchSwipeState.startY;
  7748. const absAngle = Math.abs(Math.atan2(dy, dx));
  7749. if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <= SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI - SWIPE_ANGLE_THRESHOLD)) {
  7750. delta = dx;
  7751. } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math.abs(absAngle - Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) {
  7752. delta = dy;
  7753. }
  7754. if (delta > 0) {
  7755. this.pdfViewer.previousPage();
  7756. } else if (delta < 0) {
  7757. this.pdfViewer.nextPage();
  7758. }
  7759. break;
  7760. }
  7761. }
  7762. function _addWindowListeners2() {
  7763. this.showControlsBind = _classPrivateMethodGet(this, _showControls, _showControls2).bind(this);
  7764. this.mouseDownBind = _classPrivateMethodGet(this, _mouseDown, _mouseDown2).bind(this);
  7765. this.mouseWheelBind = _classPrivateMethodGet(this, _mouseWheel, _mouseWheel2).bind(this);
  7766. this.resetMouseScrollStateBind = _classPrivateMethodGet(this, _resetMouseScrollState, _resetMouseScrollState2).bind(this);
  7767. this.contextMenuBind = _classPrivateMethodGet(this, _contextMenu, _contextMenu2).bind(this);
  7768. this.touchSwipeBind = _classPrivateMethodGet(this, _touchSwipe, _touchSwipe2).bind(this);
  7769. window.addEventListener("mousemove", this.showControlsBind);
  7770. window.addEventListener("mousedown", this.mouseDownBind);
  7771. window.addEventListener("wheel", this.mouseWheelBind, {
  7772. passive: false
  7773. });
  7774. window.addEventListener("keydown", this.resetMouseScrollStateBind);
  7775. window.addEventListener("contextmenu", this.contextMenuBind);
  7776. window.addEventListener("touchstart", this.touchSwipeBind);
  7777. window.addEventListener("touchmove", this.touchSwipeBind);
  7778. window.addEventListener("touchend", this.touchSwipeBind);
  7779. }
  7780. function _removeWindowListeners2() {
  7781. window.removeEventListener("mousemove", this.showControlsBind);
  7782. window.removeEventListener("mousedown", this.mouseDownBind);
  7783. window.removeEventListener("wheel", this.mouseWheelBind, {
  7784. passive: false
  7785. });
  7786. window.removeEventListener("keydown", this.resetMouseScrollStateBind);
  7787. window.removeEventListener("contextmenu", this.contextMenuBind);
  7788. window.removeEventListener("touchstart", this.touchSwipeBind);
  7789. window.removeEventListener("touchmove", this.touchSwipeBind);
  7790. window.removeEventListener("touchend", this.touchSwipeBind);
  7791. delete this.showControlsBind;
  7792. delete this.mouseDownBind;
  7793. delete this.mouseWheelBind;
  7794. delete this.resetMouseScrollStateBind;
  7795. delete this.contextMenuBind;
  7796. delete this.touchSwipeBind;
  7797. }
  7798. function _fullscreenChange2() {
  7799. if (document.fullscreenElement) {
  7800. _classPrivateMethodGet(this, _enter, _enter2).call(this);
  7801. } else {
  7802. _classPrivateMethodGet(this, _exit, _exit2).call(this);
  7803. }
  7804. }
  7805. function _addFullscreenChangeListeners2() {
  7806. this.fullscreenChangeBind = _classPrivateMethodGet(this, _fullscreenChange, _fullscreenChange2).bind(this);
  7807. window.addEventListener("fullscreenchange", this.fullscreenChangeBind);
  7808. }
  7809. function _removeFullscreenChangeListeners2() {
  7810. window.removeEventListener("fullscreenchange", this.fullscreenChangeBind);
  7811. delete this.fullscreenChangeBind;
  7812. }
  7813. /***/
  7814. }),
  7815. /* 24 */
  7816. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  7817. Object.defineProperty(exports, "__esModule", ({
  7818. value: true
  7819. }));
  7820. exports.PDFRenderingQueue = void 0;
  7821. var _pdfjsLib = __webpack_require__(4);
  7822. var _ui_utils = __webpack_require__(3);
  7823. const CLEANUP_TIMEOUT = 30000;
  7824. class PDFRenderingQueue {
  7825. constructor() {
  7826. this.pdfViewer = null;
  7827. this.pdfThumbnailViewer = null;
  7828. this.onIdle = null;
  7829. this.highestPriorityPage = null;
  7830. this.idleTimeout = null;
  7831. this.printing = false;
  7832. this.isThumbnailViewEnabled = false;
  7833. }
  7834. setViewer(pdfViewer) {
  7835. this.pdfViewer = pdfViewer;
  7836. }
  7837. setThumbnailViewer(pdfThumbnailViewer) {
  7838. this.pdfThumbnailViewer = pdfThumbnailViewer;
  7839. }
  7840. isHighestPriority(view) {
  7841. return this.highestPriorityPage === view.renderingId;
  7842. }
  7843. hasViewer() {
  7844. return !!this.pdfViewer;
  7845. }
  7846. renderHighestPriority(currentlyVisiblePages) {
  7847. var _this$pdfThumbnailVie;
  7848. if (this.idleTimeout) {
  7849. clearTimeout(this.idleTimeout);
  7850. this.idleTimeout = null;
  7851. }
  7852. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  7853. return;
  7854. }
  7855. if (this.isThumbnailViewEnabled && (_this$pdfThumbnailVie = this.pdfThumbnailViewer) !== null && _this$pdfThumbnailVie !== void 0 && _this$pdfThumbnailVie.forceRendering()) {
  7856. return;
  7857. }
  7858. if (this.printing) {
  7859. return;
  7860. }
  7861. if (this.onIdle) {
  7862. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
  7863. }
  7864. }
  7865. getHighestPriority(visible, views, scrolledDown) {
  7866. let preRenderExtra = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  7867. const visibleViews = visible.views,
  7868. numVisible = visibleViews.length;
  7869. if (numVisible === 0) {
  7870. return null;
  7871. }
  7872. for (let i = 0; i < numVisible; i++) {
  7873. const view = visibleViews[i].view;
  7874. if (!this.isViewFinished(view)) {
  7875. return view;
  7876. }
  7877. }
  7878. const firstId = visible.first.id,
  7879. lastId = visible.last.id;
  7880. if (lastId - firstId + 1 > numVisible) {
  7881. const visibleIds = visible.ids;
  7882. for (let i = 1, ii = lastId - firstId; i < ii; i++) {
  7883. const holeId = scrolledDown ? firstId + i : lastId - i;
  7884. if (visibleIds.has(holeId)) {
  7885. continue;
  7886. }
  7887. const holeView = views[holeId - 1];
  7888. if (!this.isViewFinished(holeView)) {
  7889. return holeView;
  7890. }
  7891. }
  7892. }
  7893. let preRenderIndex = scrolledDown ? lastId : firstId - 2;
  7894. let preRenderView = views[preRenderIndex];
  7895. if (preRenderView && !this.isViewFinished(preRenderView)) {
  7896. return preRenderView;
  7897. }
  7898. if (preRenderExtra) {
  7899. preRenderIndex += scrolledDown ? 1 : -1;
  7900. preRenderView = views[preRenderIndex];
  7901. if (preRenderView && !this.isViewFinished(preRenderView)) {
  7902. return preRenderView;
  7903. }
  7904. }
  7905. return null;
  7906. }
  7907. isViewFinished(view) {
  7908. return view.renderingState === _ui_utils.RenderingStates.FINISHED;
  7909. }
  7910. renderView(view) {
  7911. switch (view.renderingState) {
  7912. case _ui_utils.RenderingStates.FINISHED:
  7913. return false;
  7914. case _ui_utils.RenderingStates.PAUSED:
  7915. this.highestPriorityPage = view.renderingId;
  7916. view.resume();
  7917. break;
  7918. case _ui_utils.RenderingStates.RUNNING:
  7919. this.highestPriorityPage = view.renderingId;
  7920. break;
  7921. case _ui_utils.RenderingStates.INITIAL:
  7922. this.highestPriorityPage = view.renderingId;
  7923. view.draw().finally(() => {
  7924. this.renderHighestPriority();
  7925. }).catch(reason => {
  7926. if (reason instanceof _pdfjsLib.RenderingCancelledException) {
  7927. return;
  7928. }
  7929. console.error(`renderView: "${reason}"`);
  7930. });
  7931. break;
  7932. }
  7933. return true;
  7934. }
  7935. }
  7936. exports.PDFRenderingQueue = PDFRenderingQueue;
  7937. /***/
  7938. }),
  7939. /* 25 */
  7940. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  7941. Object.defineProperty(exports, "__esModule", ({
  7942. value: true
  7943. }));
  7944. exports.PDFScriptingManager = void 0;
  7945. var _ui_utils = __webpack_require__(3);
  7946. var _pdfjsLib = __webpack_require__(4);
  7947. class PDFScriptingManager {
  7948. constructor(_ref) {
  7949. let {
  7950. eventBus,
  7951. sandboxBundleSrc = null,
  7952. scriptingFactory = null,
  7953. docPropertiesLookup = null
  7954. } = _ref;
  7955. this._pdfDocument = null;
  7956. this._pdfViewer = null;
  7957. this._closeCapability = null;
  7958. this._destroyCapability = null;
  7959. this._scripting = null;
  7960. this._ready = false;
  7961. this._eventBus = eventBus;
  7962. this._sandboxBundleSrc = sandboxBundleSrc;
  7963. this._scriptingFactory = scriptingFactory;
  7964. this._docPropertiesLookup = docPropertiesLookup;
  7965. }
  7966. setViewer(pdfViewer) {
  7967. this._pdfViewer = pdfViewer;
  7968. }
  7969. async setDocument(pdfDocument) {
  7970. var _this$_scripting3;
  7971. if (this._pdfDocument) {
  7972. await this._destroyScripting();
  7973. }
  7974. this._pdfDocument = pdfDocument;
  7975. if (!pdfDocument) {
  7976. return;
  7977. }
  7978. const [objects, calculationOrder, docActions] = await Promise.all([pdfDocument.getFieldObjects(), pdfDocument.getCalculationOrderIds(), pdfDocument.getJSActions()]);
  7979. if (!objects && !docActions) {
  7980. await this._destroyScripting();
  7981. return;
  7982. }
  7983. if (pdfDocument !== this._pdfDocument) {
  7984. return;
  7985. }
  7986. try {
  7987. this._scripting = this._createScripting();
  7988. } catch (error) {
  7989. console.error(`PDFScriptingManager.setDocument: "${error === null || error === void 0 ? void 0 : error.message}".`);
  7990. await this._destroyScripting();
  7991. return;
  7992. }
  7993. this._internalEvents.set("updatefromsandbox", event => {
  7994. if ((event === null || event === void 0 ? void 0 : event.source) !== window) {
  7995. return;
  7996. }
  7997. this._updateFromSandbox(event.detail);
  7998. });
  7999. this._internalEvents.set("dispatcheventinsandbox", event => {
  8000. var _this$_scripting;
  8001. (_this$_scripting = this._scripting) === null || _this$_scripting === void 0 ? void 0 : _this$_scripting.dispatchEventInSandbox(event.detail);
  8002. });
  8003. this._internalEvents.set("pagechanging", _ref2 => {
  8004. let {
  8005. pageNumber,
  8006. previous
  8007. } = _ref2;
  8008. if (pageNumber === previous) {
  8009. return;
  8010. }
  8011. this._dispatchPageClose(previous);
  8012. this._dispatchPageOpen(pageNumber);
  8013. });
  8014. this._internalEvents.set("pagerendered", _ref3 => {
  8015. let {
  8016. pageNumber
  8017. } = _ref3;
  8018. if (!this._pageOpenPending.has(pageNumber)) {
  8019. return;
  8020. }
  8021. if (pageNumber !== this._pdfViewer.currentPageNumber) {
  8022. return;
  8023. }
  8024. this._dispatchPageOpen(pageNumber);
  8025. });
  8026. this._internalEvents.set("pagesdestroy", async event => {
  8027. var _this$_scripting2, _this$_closeCapabilit;
  8028. await this._dispatchPageClose(this._pdfViewer.currentPageNumber);
  8029. await ((_this$_scripting2 = this._scripting) === null || _this$_scripting2 === void 0 ? void 0 : _this$_scripting2.dispatchEventInSandbox({
  8030. id: "doc",
  8031. name: "WillClose"
  8032. }));
  8033. (_this$_closeCapabilit = this._closeCapability) === null || _this$_closeCapabilit === void 0 ? void 0 : _this$_closeCapabilit.resolve();
  8034. });
  8035. for (const [name, listener] of this._internalEvents) {
  8036. this._eventBus._on(name, listener);
  8037. }
  8038. try {
  8039. const docProperties = await this._getDocProperties();
  8040. if (pdfDocument !== this._pdfDocument) {
  8041. return;
  8042. }
  8043. await this._scripting.createSandbox({
  8044. objects,
  8045. calculationOrder,
  8046. appInfo: {
  8047. platform: navigator.platform,
  8048. language: navigator.language
  8049. },
  8050. docInfo: {
  8051. ...docProperties,
  8052. actions: docActions
  8053. }
  8054. });
  8055. this._eventBus.dispatch("sandboxcreated", {
  8056. source: this
  8057. });
  8058. } catch (error) {
  8059. console.error(`PDFScriptingManager.setDocument: "${error === null || error === void 0 ? void 0 : error.message}".`);
  8060. await this._destroyScripting();
  8061. return;
  8062. }
  8063. await ((_this$_scripting3 = this._scripting) === null || _this$_scripting3 === void 0 ? void 0 : _this$_scripting3.dispatchEventInSandbox({
  8064. id: "doc",
  8065. name: "Open"
  8066. }));
  8067. await this._dispatchPageOpen(this._pdfViewer.currentPageNumber, true);
  8068. Promise.resolve().then(() => {
  8069. if (pdfDocument === this._pdfDocument) {
  8070. this._ready = true;
  8071. }
  8072. });
  8073. }
  8074. async dispatchWillSave(detail) {
  8075. var _this$_scripting4;
  8076. return (_this$_scripting4 = this._scripting) === null || _this$_scripting4 === void 0 ? void 0 : _this$_scripting4.dispatchEventInSandbox({
  8077. id: "doc",
  8078. name: "WillSave"
  8079. });
  8080. }
  8081. async dispatchDidSave(detail) {
  8082. var _this$_scripting5;
  8083. return (_this$_scripting5 = this._scripting) === null || _this$_scripting5 === void 0 ? void 0 : _this$_scripting5.dispatchEventInSandbox({
  8084. id: "doc",
  8085. name: "DidSave"
  8086. });
  8087. }
  8088. async dispatchWillPrint(detail) {
  8089. var _this$_scripting6;
  8090. return (_this$_scripting6 = this._scripting) === null || _this$_scripting6 === void 0 ? void 0 : _this$_scripting6.dispatchEventInSandbox({
  8091. id: "doc",
  8092. name: "WillPrint"
  8093. });
  8094. }
  8095. async dispatchDidPrint(detail) {
  8096. var _this$_scripting7;
  8097. return (_this$_scripting7 = this._scripting) === null || _this$_scripting7 === void 0 ? void 0 : _this$_scripting7.dispatchEventInSandbox({
  8098. id: "doc",
  8099. name: "DidPrint"
  8100. });
  8101. }
  8102. get destroyPromise() {
  8103. var _this$_destroyCapabil;
  8104. return ((_this$_destroyCapabil = this._destroyCapability) === null || _this$_destroyCapabil === void 0 ? void 0 : _this$_destroyCapabil.promise) || null;
  8105. }
  8106. get ready() {
  8107. return this._ready;
  8108. }
  8109. get _internalEvents() {
  8110. return (0, _pdfjsLib.shadow)(this, "_internalEvents", new Map());
  8111. }
  8112. get _pageOpenPending() {
  8113. return (0, _pdfjsLib.shadow)(this, "_pageOpenPending", new Set());
  8114. }
  8115. get _visitedPages() {
  8116. return (0, _pdfjsLib.shadow)(this, "_visitedPages", new Map());
  8117. }
  8118. async _updateFromSandbox(detail) {
  8119. const isInPresentationMode = this._pdfViewer.isInPresentationMode || this._pdfViewer.isChangingPresentationMode;
  8120. const {
  8121. id,
  8122. siblings,
  8123. command,
  8124. value
  8125. } = detail;
  8126. if (!id) {
  8127. switch (command) {
  8128. case "clear":
  8129. console.clear();
  8130. break;
  8131. case "error":
  8132. console.error(value);
  8133. break;
  8134. case "layout":
  8135. {
  8136. if (isInPresentationMode) {
  8137. return;
  8138. }
  8139. const modes = (0, _ui_utils.apiPageLayoutToViewerModes)(value);
  8140. this._pdfViewer.spreadMode = modes.spreadMode;
  8141. break;
  8142. }
  8143. case "page-num":
  8144. this._pdfViewer.currentPageNumber = value + 1;
  8145. break;
  8146. case "print":
  8147. await this._pdfViewer.pagesPromise;
  8148. this._eventBus.dispatch("print", {
  8149. source: this
  8150. });
  8151. break;
  8152. case "println":
  8153. console.log(value);
  8154. break;
  8155. case "zoom":
  8156. if (isInPresentationMode) {
  8157. return;
  8158. }
  8159. this._pdfViewer.currentScaleValue = value;
  8160. break;
  8161. case "SaveAs":
  8162. this._eventBus.dispatch("download", {
  8163. source: this
  8164. });
  8165. break;
  8166. case "FirstPage":
  8167. this._pdfViewer.currentPageNumber = 1;
  8168. break;
  8169. case "LastPage":
  8170. this._pdfViewer.currentPageNumber = this._pdfViewer.pagesCount;
  8171. break;
  8172. case "NextPage":
  8173. this._pdfViewer.nextPage();
  8174. break;
  8175. case "PrevPage":
  8176. this._pdfViewer.previousPage();
  8177. break;
  8178. case "ZoomViewIn":
  8179. if (isInPresentationMode) {
  8180. return;
  8181. }
  8182. this._pdfViewer.increaseScale();
  8183. break;
  8184. case "ZoomViewOut":
  8185. if (isInPresentationMode) {
  8186. return;
  8187. }
  8188. this._pdfViewer.decreaseScale();
  8189. break;
  8190. }
  8191. return;
  8192. }
  8193. if (isInPresentationMode) {
  8194. if (detail.focus) {
  8195. return;
  8196. }
  8197. }
  8198. delete detail.id;
  8199. delete detail.siblings;
  8200. const ids = siblings ? [id, ...siblings] : [id];
  8201. for (const elementId of ids) {
  8202. const element = document.querySelector(`[data-element-id="${elementId}"]`);
  8203. if (element) {
  8204. element.dispatchEvent(new CustomEvent("updatefromsandbox", {
  8205. detail
  8206. }));
  8207. } else {
  8208. var _this$_pdfDocument;
  8209. (_this$_pdfDocument = this._pdfDocument) === null || _this$_pdfDocument === void 0 ? void 0 : _this$_pdfDocument.annotationStorage.setValue(elementId, detail);
  8210. }
  8211. }
  8212. }
  8213. async _dispatchPageOpen(pageNumber) {
  8214. let initialize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  8215. const pdfDocument = this._pdfDocument,
  8216. visitedPages = this._visitedPages;
  8217. if (initialize) {
  8218. this._closeCapability = (0, _pdfjsLib.createPromiseCapability)();
  8219. }
  8220. if (!this._closeCapability) {
  8221. return;
  8222. }
  8223. const pageView = this._pdfViewer.getPageView(pageNumber - 1);
  8224. if ((pageView === null || pageView === void 0 ? void 0 : pageView.renderingState) !== _ui_utils.RenderingStates.FINISHED) {
  8225. this._pageOpenPending.add(pageNumber);
  8226. return;
  8227. }
  8228. this._pageOpenPending.delete(pageNumber);
  8229. const actionsPromise = (async () => {
  8230. var _pageView$pdfPage, _this$_scripting8;
  8231. const actions = await (!visitedPages.has(pageNumber) ? (_pageView$pdfPage = pageView.pdfPage) === null || _pageView$pdfPage === void 0 ? void 0 : _pageView$pdfPage.getJSActions() : null);
  8232. if (pdfDocument !== this._pdfDocument) {
  8233. return;
  8234. }
  8235. await ((_this$_scripting8 = this._scripting) === null || _this$_scripting8 === void 0 ? void 0 : _this$_scripting8.dispatchEventInSandbox({
  8236. id: "page",
  8237. name: "PageOpen",
  8238. pageNumber,
  8239. actions
  8240. }));
  8241. })();
  8242. visitedPages.set(pageNumber, actionsPromise);
  8243. }
  8244. async _dispatchPageClose(pageNumber) {
  8245. var _this$_scripting9;
  8246. const pdfDocument = this._pdfDocument,
  8247. visitedPages = this._visitedPages;
  8248. if (!this._closeCapability) {
  8249. return;
  8250. }
  8251. if (this._pageOpenPending.has(pageNumber)) {
  8252. return;
  8253. }
  8254. const actionsPromise = visitedPages.get(pageNumber);
  8255. if (!actionsPromise) {
  8256. return;
  8257. }
  8258. visitedPages.set(pageNumber, null);
  8259. await actionsPromise;
  8260. if (pdfDocument !== this._pdfDocument) {
  8261. return;
  8262. }
  8263. await ((_this$_scripting9 = this._scripting) === null || _this$_scripting9 === void 0 ? void 0 : _this$_scripting9.dispatchEventInSandbox({
  8264. id: "page",
  8265. name: "PageClose",
  8266. pageNumber
  8267. }));
  8268. }
  8269. async _getDocProperties() {
  8270. if (this._docPropertiesLookup) {
  8271. return this._docPropertiesLookup(this._pdfDocument);
  8272. }
  8273. throw new Error("_getDocProperties: Unable to lookup properties.");
  8274. }
  8275. _createScripting() {
  8276. this._destroyCapability = (0, _pdfjsLib.createPromiseCapability)();
  8277. if (this._scripting) {
  8278. throw new Error("_createScripting: Scripting already exists.");
  8279. }
  8280. if (this._scriptingFactory) {
  8281. return this._scriptingFactory.createScripting({
  8282. sandboxBundleSrc: this._sandboxBundleSrc
  8283. });
  8284. }
  8285. throw new Error("_createScripting: Cannot create scripting.");
  8286. }
  8287. async _destroyScripting() {
  8288. var _this$_destroyCapabil3;
  8289. if (!this._scripting) {
  8290. var _this$_destroyCapabil2;
  8291. this._pdfDocument = null;
  8292. (_this$_destroyCapabil2 = this._destroyCapability) === null || _this$_destroyCapabil2 === void 0 ? void 0 : _this$_destroyCapabil2.resolve();
  8293. return;
  8294. }
  8295. if (this._closeCapability) {
  8296. await Promise.race([this._closeCapability.promise, new Promise(resolve => {
  8297. setTimeout(resolve, 1000);
  8298. })]).catch(reason => { });
  8299. this._closeCapability = null;
  8300. }
  8301. this._pdfDocument = null;
  8302. try {
  8303. await this._scripting.destroySandbox();
  8304. } catch (ex) { }
  8305. for (const [name, listener] of this._internalEvents) {
  8306. this._eventBus._off(name, listener);
  8307. }
  8308. this._internalEvents.clear();
  8309. this._pageOpenPending.clear();
  8310. this._visitedPages.clear();
  8311. this._scripting = null;
  8312. this._ready = false;
  8313. (_this$_destroyCapabil3 = this._destroyCapability) === null || _this$_destroyCapabil3 === void 0 ? void 0 : _this$_destroyCapabil3.resolve();
  8314. }
  8315. }
  8316. exports.PDFScriptingManager = PDFScriptingManager;
  8317. /***/
  8318. }),
  8319. /* 26 */
  8320. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  8321. Object.defineProperty(exports, "__esModule", ({
  8322. value: true
  8323. }));
  8324. exports.PDFSidebar = void 0;
  8325. var _ui_utils = __webpack_require__(3);
  8326. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  8327. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  8328. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  8329. const UI_NOTIFICATION_CLASS = "pdfSidebarNotification";
  8330. var _dispatchEvent = /*#__PURE__*/new WeakSet();
  8331. var _forceRendering = /*#__PURE__*/new WeakSet();
  8332. var _updateThumbnailViewer = /*#__PURE__*/new WeakSet();
  8333. var _showUINotification = /*#__PURE__*/new WeakSet();
  8334. var _hideUINotification = /*#__PURE__*/new WeakSet();
  8335. var _addEventListeners = /*#__PURE__*/new WeakSet();
  8336. class PDFSidebar {
  8337. constructor(_ref) {
  8338. let {
  8339. elements,
  8340. pdfViewer: _pdfViewer,
  8341. pdfThumbnailViewer: _pdfThumbnailViewer,
  8342. eventBus,
  8343. l10n
  8344. } = _ref;
  8345. _classPrivateMethodInitSpec(this, _addEventListeners);
  8346. _classPrivateMethodInitSpec(this, _hideUINotification);
  8347. _classPrivateMethodInitSpec(this, _showUINotification);
  8348. _classPrivateMethodInitSpec(this, _updateThumbnailViewer);
  8349. _classPrivateMethodInitSpec(this, _forceRendering);
  8350. _classPrivateMethodInitSpec(this, _dispatchEvent);
  8351. this.isOpen = false;
  8352. this.active = _ui_utils.SidebarView.THUMBS;
  8353. this.isInitialViewSet = false;
  8354. this.isInitialEventDispatched = false;
  8355. this.onToggled = null;
  8356. this.pdfViewer = _pdfViewer;
  8357. this.pdfThumbnailViewer = _pdfThumbnailViewer;
  8358. this.outerContainer = elements.outerContainer;
  8359. this.sidebarContainer = elements.sidebarContainer;
  8360. this.toggleButton = elements.toggleButton;
  8361. this.thumbnailButton = elements.thumbnailButton;
  8362. this.outlineButton = elements.outlineButton;
  8363. this.attachmentsButton = elements.attachmentsButton;
  8364. this.layersButton = elements.layersButton;
  8365. this.thumbnailView = elements.thumbnailView;
  8366. this.outlineView = elements.outlineView;
  8367. this.attachmentsView = elements.attachmentsView;
  8368. this.layersView = elements.layersView;
  8369. this._outlineOptionsContainer = elements.outlineOptionsContainer;
  8370. this._currentOutlineItemButton = elements.currentOutlineItemButton;
  8371. this.eventBus = eventBus;
  8372. this.l10n = l10n;
  8373. _classPrivateMethodGet(this, _addEventListeners, _addEventListeners2).call(this);
  8374. }
  8375. reset() {
  8376. this.isInitialViewSet = false;
  8377. this.isInitialEventDispatched = false;
  8378. _classPrivateMethodGet(this, _hideUINotification, _hideUINotification2).call(this, true);
  8379. this.switchView(_ui_utils.SidebarView.THUMBS);
  8380. this.outlineButton.disabled = false;
  8381. this.attachmentsButton.disabled = false;
  8382. this.layersButton.disabled = false;
  8383. this._currentOutlineItemButton.disabled = true;
  8384. }
  8385. get visibleView() {
  8386. return this.isOpen ? this.active : _ui_utils.SidebarView.NONE;
  8387. }
  8388. setInitialView() {
  8389. let view = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _ui_utils.SidebarView.NONE;
  8390. if (this.isInitialViewSet) {
  8391. return;
  8392. }
  8393. this.isInitialViewSet = true;
  8394. if (view === _ui_utils.SidebarView.NONE || view === _ui_utils.SidebarView.UNKNOWN) {
  8395. _classPrivateMethodGet(this, _dispatchEvent, _dispatchEvent2).call(this);
  8396. return;
  8397. }
  8398. this.switchView(view, true);
  8399. if (!this.isInitialEventDispatched) {
  8400. _classPrivateMethodGet(this, _dispatchEvent, _dispatchEvent2).call(this);
  8401. }
  8402. }
  8403. switchView(view) {
  8404. let forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  8405. const isViewChanged = view !== this.active;
  8406. let shouldForceRendering = false;
  8407. switch (view) {
  8408. case _ui_utils.SidebarView.NONE:
  8409. if (this.isOpen) {
  8410. this.close();
  8411. }
  8412. return;
  8413. case _ui_utils.SidebarView.THUMBS:
  8414. if (this.isOpen && isViewChanged) {
  8415. shouldForceRendering = true;
  8416. }
  8417. break;
  8418. case _ui_utils.SidebarView.OUTLINE:
  8419. if (this.outlineButton.disabled) {
  8420. return;
  8421. }
  8422. break;
  8423. case _ui_utils.SidebarView.ATTACHMENTS:
  8424. if (this.attachmentsButton.disabled) {
  8425. return;
  8426. }
  8427. break;
  8428. case _ui_utils.SidebarView.LAYERS:
  8429. if (this.layersButton.disabled) {
  8430. return;
  8431. }
  8432. break;
  8433. default:
  8434. console.error(`PDFSidebar.switchView: "${view}" is not a valid view.`);
  8435. return;
  8436. }
  8437. this.active = view;
  8438. const isThumbs = view === _ui_utils.SidebarView.THUMBS,
  8439. isOutline = view === _ui_utils.SidebarView.OUTLINE,
  8440. isAttachments = view === _ui_utils.SidebarView.ATTACHMENTS,
  8441. isLayers = view === _ui_utils.SidebarView.LAYERS;
  8442. this.thumbnailButton.classList.toggle("toggled", isThumbs);
  8443. this.outlineButton.classList.toggle("toggled", isOutline);
  8444. this.attachmentsButton.classList.toggle("toggled", isAttachments);
  8445. this.layersButton.classList.toggle("toggled", isLayers);
  8446. this.thumbnailButton.setAttribute("aria-checked", isThumbs);
  8447. this.outlineButton.setAttribute("aria-checked", isOutline);
  8448. this.attachmentsButton.setAttribute("aria-checked", isAttachments);
  8449. this.layersButton.setAttribute("aria-checked", isLayers);
  8450. this.thumbnailView.classList.toggle("hidden", !isThumbs);
  8451. this.outlineView.classList.toggle("hidden", !isOutline);
  8452. this.attachmentsView.classList.toggle("hidden", !isAttachments);
  8453. this.layersView.classList.toggle("hidden", !isLayers);
  8454. this._outlineOptionsContainer.classList.toggle("hidden", !isOutline);
  8455. if (forceOpen && !this.isOpen) {
  8456. this.open();
  8457. return;
  8458. }
  8459. if (shouldForceRendering) {
  8460. _classPrivateMethodGet(this, _updateThumbnailViewer, _updateThumbnailViewer2).call(this);
  8461. _classPrivateMethodGet(this, _forceRendering, _forceRendering2).call(this);
  8462. }
  8463. if (isViewChanged) {
  8464. _classPrivateMethodGet(this, _dispatchEvent, _dispatchEvent2).call(this);
  8465. }
  8466. }
  8467. open() {
  8468. if (this.isOpen) {
  8469. return;
  8470. }
  8471. this.isOpen = true;
  8472. this.toggleButton.classList.add("toggled");
  8473. this.toggleButton.setAttribute("aria-expanded", "true");
  8474. this.outerContainer.classList.add("sidebarMoving", "sidebarOpen");
  8475. if (this.active === _ui_utils.SidebarView.THUMBS) {
  8476. _classPrivateMethodGet(this, _updateThumbnailViewer, _updateThumbnailViewer2).call(this);
  8477. }
  8478. _classPrivateMethodGet(this, _forceRendering, _forceRendering2).call(this);
  8479. _classPrivateMethodGet(this, _dispatchEvent, _dispatchEvent2).call(this);
  8480. _classPrivateMethodGet(this, _hideUINotification, _hideUINotification2).call(this);
  8481. }
  8482. close() {
  8483. if (!this.isOpen) {
  8484. return;
  8485. }
  8486. this.isOpen = false;
  8487. this.toggleButton.classList.remove("toggled");
  8488. this.toggleButton.setAttribute("aria-expanded", "false");
  8489. this.outerContainer.classList.add("sidebarMoving");
  8490. this.outerContainer.classList.remove("sidebarOpen");
  8491. _classPrivateMethodGet(this, _forceRendering, _forceRendering2).call(this);
  8492. _classPrivateMethodGet(this, _dispatchEvent, _dispatchEvent2).call(this);
  8493. }
  8494. toggle() {
  8495. if (this.isOpen) {
  8496. this.close();
  8497. } else {
  8498. this.open();
  8499. }
  8500. }
  8501. }
  8502. exports.PDFSidebar = PDFSidebar;
  8503. function _dispatchEvent2() {
  8504. if (this.isInitialViewSet && !this.isInitialEventDispatched) {
  8505. this.isInitialEventDispatched = true;
  8506. }
  8507. this.eventBus.dispatch("sidebarviewchanged", {
  8508. source: this,
  8509. view: this.visibleView
  8510. });
  8511. }
  8512. function _forceRendering2() {
  8513. if (this.onToggled) {
  8514. this.onToggled();
  8515. } else {
  8516. this.pdfViewer.forceRendering();
  8517. this.pdfThumbnailViewer.forceRendering();
  8518. }
  8519. }
  8520. function _updateThumbnailViewer2() {
  8521. const {
  8522. pdfViewer,
  8523. pdfThumbnailViewer
  8524. } = this;
  8525. const pagesCount = pdfViewer.pagesCount;
  8526. for (let pageIndex = 0; pageIndex < pagesCount; pageIndex++) {
  8527. const pageView = pdfViewer.getPageView(pageIndex);
  8528. if ((pageView === null || pageView === void 0 ? void 0 : pageView.renderingState) === _ui_utils.RenderingStates.FINISHED) {
  8529. const thumbnailView = pdfThumbnailViewer.getThumbnail(pageIndex);
  8530. thumbnailView.setImage(pageView);
  8531. }
  8532. }
  8533. pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
  8534. }
  8535. function _showUINotification2() {
  8536. this.toggleButton.setAttribute("data-l10n-id", "toggle_sidebar_notification2");
  8537. this.l10n.translate(this.toggleButton);
  8538. if (!this.isOpen) {
  8539. this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
  8540. }
  8541. }
  8542. function _hideUINotification2() {
  8543. let reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  8544. if (this.isOpen || reset) {
  8545. this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
  8546. }
  8547. if (reset) {
  8548. this.toggleButton.setAttribute("data-l10n-id", "toggle_sidebar");
  8549. this.l10n.translate(this.toggleButton);
  8550. }
  8551. }
  8552. function _addEventListeners2() {
  8553. this.sidebarContainer.addEventListener("transitionend", evt => {
  8554. if (evt.target === this.sidebarContainer) {
  8555. this.outerContainer.classList.remove("sidebarMoving");
  8556. }
  8557. });
  8558. this.toggleButton.addEventListener("click", () => {
  8559. this.toggle();
  8560. });
  8561. this.thumbnailButton.addEventListener("click", () => {
  8562. this.switchView(_ui_utils.SidebarView.THUMBS);
  8563. });
  8564. this.outlineButton.addEventListener("click", () => {
  8565. this.switchView(_ui_utils.SidebarView.OUTLINE);
  8566. });
  8567. this.outlineButton.addEventListener("dblclick", () => {
  8568. this.eventBus.dispatch("toggleoutlinetree", {
  8569. source: this
  8570. });
  8571. });
  8572. this.attachmentsButton.addEventListener("click", () => {
  8573. this.switchView(_ui_utils.SidebarView.ATTACHMENTS);
  8574. });
  8575. this.layersButton.addEventListener("click", () => {
  8576. this.switchView(_ui_utils.SidebarView.LAYERS);
  8577. });
  8578. this.layersButton.addEventListener("dblclick", () => {
  8579. this.eventBus.dispatch("resetlayers", {
  8580. source: this
  8581. });
  8582. });
  8583. this._currentOutlineItemButton.addEventListener("click", () => {
  8584. this.eventBus.dispatch("currentoutlineitem", {
  8585. source: this
  8586. });
  8587. });
  8588. const onTreeLoaded = (count, button, view) => {
  8589. button.disabled = !count;
  8590. if (count) {
  8591. _classPrivateMethodGet(this, _showUINotification, _showUINotification2).call(this);
  8592. } else if (this.active === view) {
  8593. this.switchView(_ui_utils.SidebarView.THUMBS);
  8594. }
  8595. };
  8596. this.eventBus._on("outlineloaded", evt => {
  8597. onTreeLoaded(evt.outlineCount, this.outlineButton, _ui_utils.SidebarView.OUTLINE);
  8598. evt.currentOutlineItemPromise.then(enabled => {
  8599. if (!this.isInitialViewSet) {
  8600. return;
  8601. }
  8602. this._currentOutlineItemButton.disabled = !enabled;
  8603. });
  8604. });
  8605. this.eventBus._on("attachmentsloaded", evt => {
  8606. onTreeLoaded(evt.attachmentsCount, this.attachmentsButton, _ui_utils.SidebarView.ATTACHMENTS);
  8607. });
  8608. this.eventBus._on("layersloaded", evt => {
  8609. onTreeLoaded(evt.layersCount, this.layersButton, _ui_utils.SidebarView.LAYERS);
  8610. });
  8611. this.eventBus._on("presentationmodechanged", evt => {
  8612. if (evt.state === _ui_utils.PresentationModeState.NORMAL && this.visibleView === _ui_utils.SidebarView.THUMBS) {
  8613. _classPrivateMethodGet(this, _updateThumbnailViewer, _updateThumbnailViewer2).call(this);
  8614. }
  8615. });
  8616. }
  8617. /***/
  8618. }),
  8619. /* 27 */
  8620. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  8621. Object.defineProperty(exports, "__esModule", ({
  8622. value: true
  8623. }));
  8624. exports.PDFSidebarResizer = void 0;
  8625. var _ui_utils = __webpack_require__(3);
  8626. const SIDEBAR_WIDTH_VAR = "--sidebar-width";
  8627. const SIDEBAR_MIN_WIDTH = 200;
  8628. const SIDEBAR_RESIZING_CLASS = "sidebarResizing";
  8629. class PDFSidebarResizer {
  8630. constructor(options, eventBus, l10n) {
  8631. this.isRTL = false;
  8632. this.sidebarOpen = false;
  8633. this._width = null;
  8634. this._outerContainerWidth = null;
  8635. this._boundEvents = Object.create(null);
  8636. this.outerContainer = options.outerContainer;
  8637. this.resizer = options.resizer;
  8638. this.eventBus = eventBus;
  8639. l10n.getDirection().then(dir => {
  8640. this.isRTL = dir === "rtl";
  8641. });
  8642. this._addEventListeners();
  8643. }
  8644. get outerContainerWidth() {
  8645. return this._outerContainerWidth || (this._outerContainerWidth = this.outerContainer.clientWidth);
  8646. }
  8647. _updateWidth() {
  8648. let width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  8649. const maxWidth = Math.floor(this.outerContainerWidth / 2);
  8650. if (width > maxWidth) {
  8651. width = maxWidth;
  8652. }
  8653. if (width < SIDEBAR_MIN_WIDTH) {
  8654. width = SIDEBAR_MIN_WIDTH;
  8655. }
  8656. if (width === this._width) {
  8657. return false;
  8658. }
  8659. this._width = width;
  8660. _ui_utils.docStyle.setProperty(SIDEBAR_WIDTH_VAR, `${width}px`);
  8661. return true;
  8662. }
  8663. _mouseMove(evt) {
  8664. let width = evt.clientX;
  8665. if (this.isRTL) {
  8666. width = this.outerContainerWidth - width;
  8667. }
  8668. this._updateWidth(width);
  8669. }
  8670. _mouseUp(evt) {
  8671. this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  8672. this.eventBus.dispatch("resize", {
  8673. source: this
  8674. });
  8675. const _boundEvents = this._boundEvents;
  8676. window.removeEventListener("mousemove", _boundEvents.mouseMove);
  8677. window.removeEventListener("mouseup", _boundEvents.mouseUp);
  8678. }
  8679. _addEventListeners() {
  8680. const _boundEvents = this._boundEvents;
  8681. _boundEvents.mouseMove = this._mouseMove.bind(this);
  8682. _boundEvents.mouseUp = this._mouseUp.bind(this);
  8683. this.resizer.addEventListener("mousedown", evt => {
  8684. if (evt.button !== 0) {
  8685. return;
  8686. }
  8687. this.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  8688. window.addEventListener("mousemove", _boundEvents.mouseMove);
  8689. window.addEventListener("mouseup", _boundEvents.mouseUp);
  8690. });
  8691. this.eventBus._on("sidebarviewchanged", evt => {
  8692. this.sidebarOpen = !!(evt !== null && evt !== void 0 && evt.view);
  8693. });
  8694. this.eventBus._on("resize", evt => {
  8695. if ((evt === null || evt === void 0 ? void 0 : evt.source) !== window) {
  8696. return;
  8697. }
  8698. this._outerContainerWidth = null;
  8699. if (!this._width) {
  8700. return;
  8701. }
  8702. if (!this.sidebarOpen) {
  8703. this._updateWidth(this._width);
  8704. return;
  8705. }
  8706. this.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  8707. const updated = this._updateWidth(this._width);
  8708. Promise.resolve().then(() => {
  8709. this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  8710. if (updated) {
  8711. this.eventBus.dispatch("resize", {
  8712. source: this
  8713. });
  8714. }
  8715. });
  8716. });
  8717. }
  8718. }
  8719. exports.PDFSidebarResizer = PDFSidebarResizer;
  8720. /***/
  8721. }),
  8722. /* 28 */
  8723. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  8724. Object.defineProperty(exports, "__esModule", ({
  8725. value: true
  8726. }));
  8727. exports.PDFThumbnailViewer = void 0;
  8728. var _ui_utils = __webpack_require__(3);
  8729. var _pdf_thumbnail_view = __webpack_require__(29);
  8730. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  8731. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  8732. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  8733. const THUMBNAIL_SCROLL_MARGIN = -19;
  8734. const THUMBNAIL_SELECTED_CLASS = "selected";
  8735. var _ensurePdfPageLoaded = /*#__PURE__*/new WeakSet();
  8736. var _getScrollAhead = /*#__PURE__*/new WeakSet();
  8737. class PDFThumbnailViewer {
  8738. constructor(_ref) {
  8739. let {
  8740. container,
  8741. linkService,
  8742. renderingQueue,
  8743. l10n,
  8744. pageColors
  8745. } = _ref;
  8746. _classPrivateMethodInitSpec(this, _getScrollAhead);
  8747. _classPrivateMethodInitSpec(this, _ensurePdfPageLoaded);
  8748. this.container = container;
  8749. this.linkService = linkService;
  8750. this.renderingQueue = renderingQueue;
  8751. this.l10n = l10n;
  8752. this.pageColors = pageColors || null;
  8753. if (this.pageColors && !(CSS.supports("color", this.pageColors.background) && CSS.supports("color", this.pageColors.foreground))) {
  8754. if (this.pageColors.background || this.pageColors.foreground) {
  8755. console.warn("PDFThumbnailViewer: Ignoring `pageColors`-option, since the browser doesn't support the values used.");
  8756. }
  8757. this.pageColors = null;
  8758. }
  8759. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdated.bind(this));
  8760. this._resetView();
  8761. }
  8762. _scrollUpdated() {
  8763. this.renderingQueue.renderHighestPriority();
  8764. }
  8765. getThumbnail(index) {
  8766. return this._thumbnails[index];
  8767. }
  8768. _getVisibleThumbs() {
  8769. return (0, _ui_utils.getVisibleElements)({
  8770. scrollEl: this.container,
  8771. views: this._thumbnails
  8772. });
  8773. }
  8774. scrollThumbnailIntoView(pageNumber) {
  8775. if (!this.pdfDocument) {
  8776. return;
  8777. }
  8778. const thumbnailView = this._thumbnails[pageNumber - 1];
  8779. if (!thumbnailView) {
  8780. console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');
  8781. return;
  8782. }
  8783. if (pageNumber !== this._currentPageNumber) {
  8784. const prevThumbnailView = this._thumbnails[this._currentPageNumber - 1];
  8785. prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS);
  8786. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  8787. }
  8788. const {
  8789. first,
  8790. last,
  8791. views
  8792. } = this._getVisibleThumbs();
  8793. if (views.length > 0) {
  8794. let shouldScroll = false;
  8795. if (pageNumber <= first.id || pageNumber >= last.id) {
  8796. shouldScroll = true;
  8797. } else {
  8798. for (const {
  8799. id,
  8800. percent
  8801. } of views) {
  8802. if (id !== pageNumber) {
  8803. continue;
  8804. }
  8805. shouldScroll = percent < 100;
  8806. break;
  8807. }
  8808. }
  8809. if (shouldScroll) {
  8810. (0, _ui_utils.scrollIntoView)(thumbnailView.div, {
  8811. top: THUMBNAIL_SCROLL_MARGIN
  8812. });
  8813. }
  8814. }
  8815. this._currentPageNumber = pageNumber;
  8816. }
  8817. get pagesRotation() {
  8818. return this._pagesRotation;
  8819. }
  8820. set pagesRotation(rotation) {
  8821. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  8822. throw new Error("Invalid thumbnails rotation angle.");
  8823. }
  8824. if (!this.pdfDocument) {
  8825. return;
  8826. }
  8827. if (this._pagesRotation === rotation) {
  8828. return;
  8829. }
  8830. this._pagesRotation = rotation;
  8831. const updateArgs = {
  8832. rotation
  8833. };
  8834. for (const thumbnail of this._thumbnails) {
  8835. thumbnail.update(updateArgs);
  8836. }
  8837. }
  8838. cleanup() {
  8839. for (const thumbnail of this._thumbnails) {
  8840. if (thumbnail.renderingState !== _ui_utils.RenderingStates.FINISHED) {
  8841. thumbnail.reset();
  8842. }
  8843. }
  8844. _pdf_thumbnail_view.TempImageFactory.destroyCanvas();
  8845. }
  8846. _resetView() {
  8847. this._thumbnails = [];
  8848. this._currentPageNumber = 1;
  8849. this._pageLabels = null;
  8850. this._pagesRotation = 0;
  8851. this.container.textContent = "";
  8852. }
  8853. setDocument(pdfDocument) {
  8854. if (this.pdfDocument) {
  8855. this._cancelRendering();
  8856. this._resetView();
  8857. }
  8858. this.pdfDocument = pdfDocument;
  8859. if (!pdfDocument) {
  8860. return;
  8861. }
  8862. const firstPagePromise = pdfDocument.getPage(1);
  8863. const optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
  8864. firstPagePromise.then(firstPdfPage => {
  8865. var _this$_thumbnails$;
  8866. const pagesCount = pdfDocument.numPages;
  8867. const viewport = firstPdfPage.getViewport({
  8868. scale: 1
  8869. });
  8870. for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  8871. const thumbnail = new _pdf_thumbnail_view.PDFThumbnailView({
  8872. container: this.container,
  8873. id: pageNum,
  8874. defaultViewport: viewport.clone(),
  8875. optionalContentConfigPromise,
  8876. linkService: this.linkService,
  8877. renderingQueue: this.renderingQueue,
  8878. l10n: this.l10n,
  8879. pageColors: this.pageColors
  8880. });
  8881. this._thumbnails.push(thumbnail);
  8882. }
  8883. (_this$_thumbnails$ = this._thumbnails[0]) === null || _this$_thumbnails$ === void 0 ? void 0 : _this$_thumbnails$.setPdfPage(firstPdfPage);
  8884. const thumbnailView = this._thumbnails[this._currentPageNumber - 1];
  8885. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  8886. }).catch(reason => {
  8887. console.error("Unable to initialize thumbnail viewer", reason);
  8888. });
  8889. }
  8890. _cancelRendering() {
  8891. for (const thumbnail of this._thumbnails) {
  8892. thumbnail.cancelRendering();
  8893. }
  8894. }
  8895. setPageLabels(labels) {
  8896. if (!this.pdfDocument) {
  8897. return;
  8898. }
  8899. if (!labels) {
  8900. this._pageLabels = null;
  8901. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  8902. this._pageLabels = null;
  8903. console.error("PDFThumbnailViewer_setPageLabels: Invalid page labels.");
  8904. } else {
  8905. this._pageLabels = labels;
  8906. }
  8907. for (let i = 0, ii = this._thumbnails.length; i < ii; i++) {
  8908. var _this$_pageLabels;
  8909. this._thumbnails[i].setPageLabel(((_this$_pageLabels = this._pageLabels) === null || _this$_pageLabels === void 0 ? void 0 : _this$_pageLabels[i]) ?? null);
  8910. }
  8911. }
  8912. forceRendering() {
  8913. const visibleThumbs = this._getVisibleThumbs();
  8914. const scrollAhead = _classPrivateMethodGet(this, _getScrollAhead, _getScrollAhead2).call(this, visibleThumbs);
  8915. const thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, scrollAhead);
  8916. if (thumbView) {
  8917. _classPrivateMethodGet(this, _ensurePdfPageLoaded, _ensurePdfPageLoaded2).call(this, thumbView).then(() => {
  8918. this.renderingQueue.renderView(thumbView);
  8919. });
  8920. return true;
  8921. }
  8922. return false;
  8923. }
  8924. }
  8925. exports.PDFThumbnailViewer = PDFThumbnailViewer;
  8926. async function _ensurePdfPageLoaded2(thumbView) {
  8927. if (thumbView.pdfPage) {
  8928. return thumbView.pdfPage;
  8929. }
  8930. try {
  8931. const pdfPage = await this.pdfDocument.getPage(thumbView.id);
  8932. if (!thumbView.pdfPage) {
  8933. thumbView.setPdfPage(pdfPage);
  8934. }
  8935. return pdfPage;
  8936. } catch (reason) {
  8937. console.error("Unable to get page for thumb view", reason);
  8938. return null;
  8939. }
  8940. }
  8941. function _getScrollAhead2(visible) {
  8942. var _visible$first, _visible$last;
  8943. if (((_visible$first = visible.first) === null || _visible$first === void 0 ? void 0 : _visible$first.id) === 1) {
  8944. return true;
  8945. } else if (((_visible$last = visible.last) === null || _visible$last === void 0 ? void 0 : _visible$last.id) === this._thumbnails.length) {
  8946. return false;
  8947. }
  8948. return this.scroll.down;
  8949. }
  8950. /***/
  8951. }),
  8952. /* 29 */
  8953. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  8954. Object.defineProperty(exports, "__esModule", ({
  8955. value: true
  8956. }));
  8957. exports.TempImageFactory = exports.PDFThumbnailView = void 0;
  8958. var _ui_utils = __webpack_require__(3);
  8959. var _pdfjsLib = __webpack_require__(4);
  8960. const DRAW_UPSCALE_FACTOR = 2;
  8961. const MAX_NUM_SCALING_STEPS = 3;
  8962. const THUMBNAIL_CANVAS_BORDER_WIDTH = 1;
  8963. const THUMBNAIL_WIDTH = 98;
  8964. class TempImageFactory {
  8965. static #tempCanvas = null;
  8966. static getCanvas(width, height) {
  8967. const tempCanvas = this.#tempCanvas || (this.#tempCanvas = document.createElement("canvas"));
  8968. tempCanvas.width = width;
  8969. tempCanvas.height = height;
  8970. const ctx = tempCanvas.getContext("2d", {
  8971. alpha: false
  8972. });
  8973. ctx.save();
  8974. ctx.fillStyle = "rgb(255, 255, 255)";
  8975. ctx.fillRect(0, 0, width, height);
  8976. ctx.restore();
  8977. return [tempCanvas, tempCanvas.getContext("2d")];
  8978. }
  8979. static destroyCanvas() {
  8980. const tempCanvas = this.#tempCanvas;
  8981. if (tempCanvas) {
  8982. tempCanvas.width = 0;
  8983. tempCanvas.height = 0;
  8984. }
  8985. this.#tempCanvas = null;
  8986. }
  8987. }
  8988. exports.TempImageFactory = TempImageFactory;
  8989. class PDFThumbnailView {
  8990. constructor(_ref) {
  8991. let {
  8992. container,
  8993. id,
  8994. defaultViewport,
  8995. optionalContentConfigPromise,
  8996. linkService,
  8997. renderingQueue,
  8998. l10n,
  8999. pageColors
  9000. } = _ref;
  9001. this.id = id;
  9002. this.renderingId = "thumbnail" + id;
  9003. this.pageLabel = null;
  9004. this.pdfPage = null;
  9005. this.rotation = 0;
  9006. this.viewport = defaultViewport;
  9007. this.pdfPageRotate = defaultViewport.rotation;
  9008. this._optionalContentConfigPromise = optionalContentConfigPromise || null;
  9009. this.pageColors = pageColors || null;
  9010. this.linkService = linkService;
  9011. this.renderingQueue = renderingQueue;
  9012. this.renderTask = null;
  9013. this.renderingState = _ui_utils.RenderingStates.INITIAL;
  9014. this.resume = null;
  9015. const pageWidth = this.viewport.width,
  9016. pageHeight = this.viewport.height,
  9017. pageRatio = pageWidth / pageHeight;
  9018. this.canvasWidth = THUMBNAIL_WIDTH;
  9019. this.canvasHeight = this.canvasWidth / pageRatio | 0;
  9020. this.scale = this.canvasWidth / pageWidth;
  9021. this.l10n = l10n;
  9022. const anchor = document.createElement("a");
  9023. anchor.href = linkService.getAnchorUrl("#page=" + id);
  9024. this._thumbPageTitle.then(msg => {
  9025. anchor.title = msg;
  9026. });
  9027. anchor.onclick = function () {
  9028. linkService.goToPage(id);
  9029. return false;
  9030. };
  9031. this.anchor = anchor;
  9032. const div = document.createElement("div");
  9033. div.className = "thumbnail";
  9034. div.setAttribute("data-page-number", this.id);
  9035. this.div = div;
  9036. const ring = document.createElement("div");
  9037. ring.className = "thumbnailSelectionRing";
  9038. const borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  9039. ring.style.width = this.canvasWidth + borderAdjustment + "px";
  9040. ring.style.height = this.canvasHeight + borderAdjustment + "px";
  9041. this.ring = ring;
  9042. div.append(ring);
  9043. anchor.append(div);
  9044. container.append(anchor);
  9045. }
  9046. setPdfPage(pdfPage) {
  9047. this.pdfPage = pdfPage;
  9048. this.pdfPageRotate = pdfPage.rotate;
  9049. const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  9050. this.viewport = pdfPage.getViewport({
  9051. scale: 1,
  9052. rotation: totalRotation
  9053. });
  9054. this.reset();
  9055. }
  9056. reset() {
  9057. this.cancelRendering();
  9058. this.renderingState = _ui_utils.RenderingStates.INITIAL;
  9059. const pageWidth = this.viewport.width,
  9060. pageHeight = this.viewport.height,
  9061. pageRatio = pageWidth / pageHeight;
  9062. this.canvasHeight = this.canvasWidth / pageRatio | 0;
  9063. this.scale = this.canvasWidth / pageWidth;
  9064. this.div.removeAttribute("data-loaded");
  9065. const ring = this.ring;
  9066. ring.textContent = "";
  9067. const borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  9068. ring.style.width = this.canvasWidth + borderAdjustment + "px";
  9069. ring.style.height = this.canvasHeight + borderAdjustment + "px";
  9070. if (this.canvas) {
  9071. this.canvas.width = 0;
  9072. this.canvas.height = 0;
  9073. delete this.canvas;
  9074. }
  9075. if (this.image) {
  9076. this.image.removeAttribute("src");
  9077. delete this.image;
  9078. }
  9079. }
  9080. update(_ref2) {
  9081. let {
  9082. rotation = null
  9083. } = _ref2;
  9084. if (typeof rotation === "number") {
  9085. this.rotation = rotation;
  9086. }
  9087. const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  9088. this.viewport = this.viewport.clone({
  9089. scale: 1,
  9090. rotation: totalRotation
  9091. });
  9092. this.reset();
  9093. }
  9094. cancelRendering() {
  9095. if (this.renderTask) {
  9096. this.renderTask.cancel();
  9097. this.renderTask = null;
  9098. }
  9099. this.resume = null;
  9100. }
  9101. _getPageDrawContext() {
  9102. let upscaleFactor = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
  9103. const canvas = document.createElement("canvas");
  9104. const ctx = canvas.getContext("2d", {
  9105. alpha: false
  9106. });
  9107. const outputScale = new _ui_utils.OutputScale();
  9108. canvas.width = upscaleFactor * this.canvasWidth * outputScale.sx | 0;
  9109. canvas.height = upscaleFactor * this.canvasHeight * outputScale.sy | 0;
  9110. const transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null;
  9111. return {
  9112. ctx,
  9113. canvas,
  9114. transform
  9115. };
  9116. }
  9117. _convertCanvasToImage(canvas) {
  9118. if (this.renderingState !== _ui_utils.RenderingStates.FINISHED) {
  9119. throw new Error("_convertCanvasToImage: Rendering has not finished.");
  9120. }
  9121. const reducedCanvas = this._reduceImage(canvas);
  9122. const image = document.createElement("img");
  9123. image.className = "thumbnailImage";
  9124. this._thumbPageCanvas.then(msg => {
  9125. image.setAttribute("aria-label", msg);
  9126. });
  9127. image.style.width = this.canvasWidth + "px";
  9128. image.style.height = this.canvasHeight + "px";
  9129. image.src = reducedCanvas.toDataURL();
  9130. this.image = image;
  9131. this.div.setAttribute("data-loaded", true);
  9132. this.ring.append(image);
  9133. reducedCanvas.width = 0;
  9134. reducedCanvas.height = 0;
  9135. }
  9136. draw() {
  9137. var _this = this;
  9138. if (this.renderingState !== _ui_utils.RenderingStates.INITIAL) {
  9139. console.error("Must be in new state before drawing");
  9140. return Promise.resolve();
  9141. }
  9142. const {
  9143. pdfPage
  9144. } = this;
  9145. if (!pdfPage) {
  9146. this.renderingState = _ui_utils.RenderingStates.FINISHED;
  9147. return Promise.reject(new Error("pdfPage is not loaded"));
  9148. }
  9149. this.renderingState = _ui_utils.RenderingStates.RUNNING;
  9150. const finishRenderTask = async function () {
  9151. let error = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  9152. if (renderTask === _this.renderTask) {
  9153. _this.renderTask = null;
  9154. }
  9155. if (error instanceof _pdfjsLib.RenderingCancelledException) {
  9156. return;
  9157. }
  9158. _this.renderingState = _ui_utils.RenderingStates.FINISHED;
  9159. _this._convertCanvasToImage(canvas);
  9160. if (error) {
  9161. throw error;
  9162. }
  9163. };
  9164. const {
  9165. ctx,
  9166. canvas,
  9167. transform
  9168. } = this._getPageDrawContext(DRAW_UPSCALE_FACTOR);
  9169. const drawViewport = this.viewport.clone({
  9170. scale: DRAW_UPSCALE_FACTOR * this.scale
  9171. });
  9172. const renderContinueCallback = cont => {
  9173. if (!this.renderingQueue.isHighestPriority(this)) {
  9174. this.renderingState = _ui_utils.RenderingStates.PAUSED;
  9175. this.resume = () => {
  9176. this.renderingState = _ui_utils.RenderingStates.RUNNING;
  9177. cont();
  9178. };
  9179. return;
  9180. }
  9181. cont();
  9182. };
  9183. const renderContext = {
  9184. canvasContext: ctx,
  9185. transform,
  9186. viewport: drawViewport,
  9187. optionalContentConfigPromise: this._optionalContentConfigPromise,
  9188. pageColors: this.pageColors
  9189. };
  9190. const renderTask = this.renderTask = pdfPage.render(renderContext);
  9191. renderTask.onContinue = renderContinueCallback;
  9192. const resultPromise = renderTask.promise.then(function () {
  9193. return finishRenderTask(null);
  9194. }, function (error) {
  9195. return finishRenderTask(error);
  9196. });
  9197. resultPromise.finally(() => {
  9198. canvas.width = 0;
  9199. canvas.height = 0;
  9200. const pageCached = this.linkService.isPageCached(this.id);
  9201. if (!pageCached) {
  9202. var _this$pdfPage;
  9203. (_this$pdfPage = this.pdfPage) === null || _this$pdfPage === void 0 ? void 0 : _this$pdfPage.cleanup();
  9204. }
  9205. });
  9206. return resultPromise;
  9207. }
  9208. setImage(pageView) {
  9209. if (this.renderingState !== _ui_utils.RenderingStates.INITIAL) {
  9210. return;
  9211. }
  9212. const {
  9213. thumbnailCanvas: canvas,
  9214. pdfPage,
  9215. scale
  9216. } = pageView;
  9217. if (!canvas) {
  9218. return;
  9219. }
  9220. if (!this.pdfPage) {
  9221. this.setPdfPage(pdfPage);
  9222. }
  9223. if (scale < this.scale) {
  9224. return;
  9225. }
  9226. this.renderingState = _ui_utils.RenderingStates.FINISHED;
  9227. this._convertCanvasToImage(canvas);
  9228. }
  9229. _reduceImage(img) {
  9230. const {
  9231. ctx,
  9232. canvas
  9233. } = this._getPageDrawContext();
  9234. if (img.width <= 2 * canvas.width) {
  9235. ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height);
  9236. return canvas;
  9237. }
  9238. let reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
  9239. let reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
  9240. const [reducedImage, reducedImageCtx] = TempImageFactory.getCanvas(reducedWidth, reducedHeight);
  9241. while (reducedWidth > img.width || reducedHeight > img.height) {
  9242. reducedWidth >>= 1;
  9243. reducedHeight >>= 1;
  9244. }
  9245. reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0, reducedWidth, reducedHeight);
  9246. while (reducedWidth > 2 * canvas.width) {
  9247. reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, reducedWidth >> 1, reducedHeight >> 1);
  9248. reducedWidth >>= 1;
  9249. reducedHeight >>= 1;
  9250. }
  9251. ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height);
  9252. return canvas;
  9253. }
  9254. get _thumbPageTitle() {
  9255. return this.l10n.get("thumb_page_title", {
  9256. page: this.pageLabel ?? this.id
  9257. });
  9258. }
  9259. get _thumbPageCanvas() {
  9260. return this.l10n.get("thumb_page_canvas", {
  9261. page: this.pageLabel ?? this.id
  9262. });
  9263. }
  9264. setPageLabel(label) {
  9265. this.pageLabel = typeof label === "string" ? label : null;
  9266. this._thumbPageTitle.then(msg => {
  9267. this.anchor.title = msg;
  9268. });
  9269. if (this.renderingState !== _ui_utils.RenderingStates.FINISHED) {
  9270. return;
  9271. }
  9272. this._thumbPageCanvas.then(msg => {
  9273. var _this$image;
  9274. (_this$image = this.image) === null || _this$image === void 0 ? void 0 : _this$image.setAttribute("aria-label", msg);
  9275. });
  9276. }
  9277. }
  9278. exports.PDFThumbnailView = PDFThumbnailView;
  9279. /***/
  9280. }),
  9281. /* 30 */
  9282. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  9283. Object.defineProperty(exports, "__esModule", ({
  9284. value: true
  9285. }));
  9286. exports.PagesCountLimit = exports.PDFViewer = exports.PDFPageViewBuffer = void 0;
  9287. var _pdfjsLib = __webpack_require__(4);
  9288. var _ui_utils = __webpack_require__(3);
  9289. var _l10n_utils = __webpack_require__(31);
  9290. var _pdf_page_view = __webpack_require__(32);
  9291. var _pdf_rendering_queue = __webpack_require__(24);
  9292. var _pdf_link_service = __webpack_require__(7);
  9293. let _Symbol$iterator;
  9294. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  9295. function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
  9296. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  9297. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  9298. function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
  9299. function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
  9300. function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
  9301. function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
  9302. function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
  9303. const DEFAULT_CACHE_SIZE = 10;
  9304. const ENABLE_PERMISSIONS_CLASS = "enablePermissions";
  9305. const PagesCountLimit = {
  9306. FORCE_SCROLL_MODE_PAGE: 15000,
  9307. FORCE_LAZY_PAGE_INIT: 7500,
  9308. PAUSE_EAGER_PAGE_INIT: 250
  9309. };
  9310. exports.PagesCountLimit = PagesCountLimit;
  9311. function isValidAnnotationEditorMode(mode) {
  9312. return Object.values(_pdfjsLib.AnnotationEditorType).includes(mode) && mode !== _pdfjsLib.AnnotationEditorType.DISABLE;
  9313. }
  9314. var _buf = /*#__PURE__*/new WeakMap();
  9315. var _size = /*#__PURE__*/new WeakMap();
  9316. var _destroyFirstView = /*#__PURE__*/new WeakSet();
  9317. _Symbol$iterator = Symbol.iterator;
  9318. class PDFPageViewBuffer {
  9319. constructor(size) {
  9320. _classPrivateMethodInitSpec(this, _destroyFirstView);
  9321. _classPrivateFieldInitSpec(this, _buf, {
  9322. writable: true,
  9323. value: new Set()
  9324. });
  9325. _classPrivateFieldInitSpec(this, _size, {
  9326. writable: true,
  9327. value: 0
  9328. });
  9329. _classPrivateFieldSet(this, _size, size);
  9330. }
  9331. push(view) {
  9332. const buf = _classPrivateFieldGet(this, _buf);
  9333. if (buf.has(view)) {
  9334. buf.delete(view);
  9335. }
  9336. buf.add(view);
  9337. if (buf.size > _classPrivateFieldGet(this, _size)) {
  9338. _classPrivateMethodGet(this, _destroyFirstView, _destroyFirstView2).call(this);
  9339. }
  9340. }
  9341. resize(newSize) {
  9342. let idsToKeep = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  9343. _classPrivateFieldSet(this, _size, newSize);
  9344. const buf = _classPrivateFieldGet(this, _buf);
  9345. if (idsToKeep) {
  9346. const ii = buf.size;
  9347. let i = 1;
  9348. for (const view of buf) {
  9349. if (idsToKeep.has(view.id)) {
  9350. buf.delete(view);
  9351. buf.add(view);
  9352. }
  9353. if (++i > ii) {
  9354. break;
  9355. }
  9356. }
  9357. }
  9358. while (buf.size > _classPrivateFieldGet(this, _size)) {
  9359. _classPrivateMethodGet(this, _destroyFirstView, _destroyFirstView2).call(this);
  9360. }
  9361. }
  9362. has(view) {
  9363. return _classPrivateFieldGet(this, _buf).has(view);
  9364. }
  9365. [_Symbol$iterator]() {
  9366. return _classPrivateFieldGet(this, _buf).keys();
  9367. }
  9368. }
  9369. exports.PDFPageViewBuffer = PDFPageViewBuffer;
  9370. function _destroyFirstView2() {
  9371. const firstView = _classPrivateFieldGet(this, _buf).keys().next().value;
  9372. firstView === null || firstView === void 0 ? void 0 : firstView.destroy();
  9373. _classPrivateFieldGet(this, _buf).delete(firstView);
  9374. }
  9375. var _buffer = /*#__PURE__*/new WeakMap();
  9376. var _annotationEditorMode = /*#__PURE__*/new WeakMap();
  9377. var _annotationEditorUIManager = /*#__PURE__*/new WeakMap();
  9378. var _annotationMode = /*#__PURE__*/new WeakMap();
  9379. var _containerTopLeft = /*#__PURE__*/new WeakMap();
  9380. var _enablePermissions = /*#__PURE__*/new WeakMap();
  9381. var _previousContainerHeight = /*#__PURE__*/new WeakMap();
  9382. var _resizeObserver = /*#__PURE__*/new WeakMap();
  9383. var _scrollModePageState = /*#__PURE__*/new WeakMap();
  9384. var _onVisibilityChange = /*#__PURE__*/new WeakMap();
  9385. var _scaleTimeoutId = /*#__PURE__*/new WeakMap();
  9386. var _layerProperties = /*#__PURE__*/new WeakSet();
  9387. var _initializePermissions = /*#__PURE__*/new WeakSet();
  9388. var _onePageRenderedOrForceFetch = /*#__PURE__*/new WeakSet();
  9389. var _ensurePageViewVisible = /*#__PURE__*/new WeakSet();
  9390. var _scrollIntoView = /*#__PURE__*/new WeakSet();
  9391. var _isSameScale = /*#__PURE__*/new WeakSet();
  9392. var _resetCurrentPageView = /*#__PURE__*/new WeakSet();
  9393. var _ensurePdfPageLoaded = /*#__PURE__*/new WeakSet();
  9394. var _getScrollAhead = /*#__PURE__*/new WeakSet();
  9395. var _updateContainerHeightCss = /*#__PURE__*/new WeakSet();
  9396. var _resizeObserverCallback = /*#__PURE__*/new WeakSet();
  9397. class PDFViewer {
  9398. constructor(options) {
  9399. var _this$container, _this$viewer;
  9400. _classPrivateMethodInitSpec(this, _resizeObserverCallback);
  9401. _classPrivateMethodInitSpec(this, _updateContainerHeightCss);
  9402. _classPrivateMethodInitSpec(this, _getScrollAhead);
  9403. _classPrivateMethodInitSpec(this, _ensurePdfPageLoaded);
  9404. _classPrivateMethodInitSpec(this, _resetCurrentPageView);
  9405. _classPrivateMethodInitSpec(this, _isSameScale);
  9406. _classPrivateMethodInitSpec(this, _scrollIntoView);
  9407. _classPrivateMethodInitSpec(this, _ensurePageViewVisible);
  9408. _classPrivateMethodInitSpec(this, _onePageRenderedOrForceFetch);
  9409. _classPrivateMethodInitSpec(this, _initializePermissions);
  9410. _classPrivateMethodInitSpec(this, _layerProperties);
  9411. _classPrivateFieldInitSpec(this, _buffer, {
  9412. writable: true,
  9413. value: null
  9414. });
  9415. _classPrivateFieldInitSpec(this, _annotationEditorMode, {
  9416. writable: true,
  9417. value: _pdfjsLib.AnnotationEditorType.NONE
  9418. });
  9419. _classPrivateFieldInitSpec(this, _annotationEditorUIManager, {
  9420. writable: true,
  9421. value: null
  9422. });
  9423. _classPrivateFieldInitSpec(this, _annotationMode, {
  9424. writable: true,
  9425. value: _pdfjsLib.AnnotationMode.ENABLE_FORMS
  9426. });
  9427. _classPrivateFieldInitSpec(this, _containerTopLeft, {
  9428. writable: true,
  9429. value: null
  9430. });
  9431. _classPrivateFieldInitSpec(this, _enablePermissions, {
  9432. writable: true,
  9433. value: false
  9434. });
  9435. _classPrivateFieldInitSpec(this, _previousContainerHeight, {
  9436. writable: true,
  9437. value: 0
  9438. });
  9439. _classPrivateFieldInitSpec(this, _resizeObserver, {
  9440. writable: true,
  9441. value: new ResizeObserver(_classPrivateMethodGet(this, _resizeObserverCallback, _resizeObserverCallback2).bind(this))
  9442. });
  9443. _classPrivateFieldInitSpec(this, _scrollModePageState, {
  9444. writable: true,
  9445. value: null
  9446. });
  9447. _classPrivateFieldInitSpec(this, _onVisibilityChange, {
  9448. writable: true,
  9449. value: null
  9450. });
  9451. _classPrivateFieldInitSpec(this, _scaleTimeoutId, {
  9452. writable: true,
  9453. value: null
  9454. });
  9455. const viewerVersion = '3.4.120';
  9456. if (_pdfjsLib.version !== viewerVersion) {
  9457. throw new Error(`The API version "${_pdfjsLib.version}" does not match the Viewer version "${viewerVersion}".`);
  9458. }
  9459. this.container = options.container;
  9460. this.viewer = options.viewer || options.container.firstElementChild;
  9461. if (((_this$container = this.container) === null || _this$container === void 0 ? void 0 : _this$container.tagName) !== "DIV" || ((_this$viewer = this.viewer) === null || _this$viewer === void 0 ? void 0 : _this$viewer.tagName) !== "DIV") {
  9462. throw new Error("Invalid `container` and/or `viewer` option.");
  9463. }
  9464. if (this.container.offsetParent && getComputedStyle(this.container).position !== "absolute") {
  9465. throw new Error("The `container` must be absolutely positioned.");
  9466. }
  9467. _classPrivateFieldGet(this, _resizeObserver).observe(this.container);
  9468. this.eventBus = options.eventBus;
  9469. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  9470. this.downloadManager = options.downloadManager || null;
  9471. this.findController = options.findController || null;
  9472. this._scriptingManager = options.scriptingManager || null;
  9473. this.textLayerMode = options.textLayerMode ?? _ui_utils.TextLayerMode.ENABLE;
  9474. _classPrivateFieldSet(this, _annotationMode, options.annotationMode ?? _pdfjsLib.AnnotationMode.ENABLE_FORMS);
  9475. _classPrivateFieldSet(this, _annotationEditorMode, options.annotationEditorMode ?? _pdfjsLib.AnnotationEditorType.NONE);
  9476. this.imageResourcesPath = options.imageResourcesPath || "";
  9477. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  9478. this.removePageBorders = options.removePageBorders || false;
  9479. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  9480. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  9481. this.isOffscreenCanvasSupported = options.isOffscreenCanvasSupported ?? true;
  9482. this.maxCanvasPixels = options.maxCanvasPixels;
  9483. this.l10n = options.l10n || _l10n_utils.NullL10n;
  9484. _classPrivateFieldSet(this, _enablePermissions, options.enablePermissions || false);
  9485. this.pageColors = options.pageColors || null;
  9486. if (this.pageColors && !(CSS.supports("color", this.pageColors.background) && CSS.supports("color", this.pageColors.foreground))) {
  9487. if (this.pageColors.background || this.pageColors.foreground) {
  9488. console.warn("PDFViewer: Ignoring `pageColors`-option, since the browser doesn't support the values used.");
  9489. }
  9490. this.pageColors = null;
  9491. }
  9492. this.defaultRenderingQueue = !options.renderingQueue;
  9493. if (this.defaultRenderingQueue) {
  9494. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  9495. this.renderingQueue.setViewer(this);
  9496. } else {
  9497. this.renderingQueue = options.renderingQueue;
  9498. }
  9499. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  9500. this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
  9501. this._onBeforeDraw = this._onAfterDraw = null;
  9502. this._resetView();
  9503. if (this.removePageBorders) {
  9504. this.viewer.classList.add("removePageBorders");
  9505. }
  9506. _classPrivateMethodGet(this, _updateContainerHeightCss, _updateContainerHeightCss2).call(this);
  9507. }
  9508. get pagesCount() {
  9509. return this._pages.length;
  9510. }
  9511. getPageView(index) {
  9512. return this._pages[index];
  9513. }
  9514. get pageViewsReady() {
  9515. if (!this._pagesCapability.settled) {
  9516. return false;
  9517. }
  9518. return this._pages.every(function (pageView) {
  9519. return pageView === null || pageView === void 0 ? void 0 : pageView.pdfPage;
  9520. });
  9521. }
  9522. get renderForms() {
  9523. return _classPrivateFieldGet(this, _annotationMode) === _pdfjsLib.AnnotationMode.ENABLE_FORMS;
  9524. }
  9525. get enableScripting() {
  9526. return !!this._scriptingManager;
  9527. }
  9528. get currentPageNumber() {
  9529. return this._currentPageNumber;
  9530. }
  9531. set currentPageNumber(val) {
  9532. if (!Number.isInteger(val)) {
  9533. throw new Error("Invalid page number.");
  9534. }
  9535. if (!this.pdfDocument) {
  9536. return;
  9537. }
  9538. if (!this._setCurrentPageNumber(val, true)) {
  9539. console.error(`currentPageNumber: "${val}" is not a valid page.`);
  9540. }
  9541. }
  9542. _setCurrentPageNumber(val) {
  9543. var _this$_pageLabels;
  9544. let resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9545. if (this._currentPageNumber === val) {
  9546. if (resetCurrentPageView) {
  9547. _classPrivateMethodGet(this, _resetCurrentPageView, _resetCurrentPageView2).call(this);
  9548. }
  9549. return true;
  9550. }
  9551. if (!(0 < val && val <= this.pagesCount)) {
  9552. return false;
  9553. }
  9554. const previous = this._currentPageNumber;
  9555. this._currentPageNumber = val;
  9556. this.eventBus.dispatch("pagechanging", {
  9557. source: this,
  9558. pageNumber: val,
  9559. pageLabel: ((_this$_pageLabels = this._pageLabels) === null || _this$_pageLabels === void 0 ? void 0 : _this$_pageLabels[val - 1]) ?? null,
  9560. previous
  9561. });
  9562. if (resetCurrentPageView) {
  9563. _classPrivateMethodGet(this, _resetCurrentPageView, _resetCurrentPageView2).call(this);
  9564. }
  9565. return true;
  9566. }
  9567. get currentPageLabel() {
  9568. var _this$_pageLabels2;
  9569. return ((_this$_pageLabels2 = this._pageLabels) === null || _this$_pageLabels2 === void 0 ? void 0 : _this$_pageLabels2[this._currentPageNumber - 1]) ?? null;
  9570. }
  9571. set currentPageLabel(val) {
  9572. if (!this.pdfDocument) {
  9573. return;
  9574. }
  9575. let page = val | 0;
  9576. if (this._pageLabels) {
  9577. const i = this._pageLabels.indexOf(val);
  9578. if (i >= 0) {
  9579. page = i + 1;
  9580. }
  9581. }
  9582. if (!this._setCurrentPageNumber(page, true)) {
  9583. console.error(`currentPageLabel: "${val}" is not a valid page.`);
  9584. }
  9585. }
  9586. get currentScale() {
  9587. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
  9588. }
  9589. set currentScale(val) {
  9590. if (isNaN(val)) {
  9591. throw new Error("Invalid numeric scale.");
  9592. }
  9593. if (!this.pdfDocument) {
  9594. return;
  9595. }
  9596. this._setScale(val, {
  9597. noScroll: false
  9598. });
  9599. }
  9600. get currentScaleValue() {
  9601. return this._currentScaleValue;
  9602. }
  9603. set currentScaleValue(val) {
  9604. if (!this.pdfDocument) {
  9605. return;
  9606. }
  9607. this._setScale(val, {
  9608. noScroll: false
  9609. });
  9610. }
  9611. get pagesRotation() {
  9612. return this._pagesRotation;
  9613. }
  9614. set pagesRotation(rotation) {
  9615. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  9616. throw new Error("Invalid pages rotation angle.");
  9617. }
  9618. if (!this.pdfDocument) {
  9619. return;
  9620. }
  9621. rotation %= 360;
  9622. if (rotation < 0) {
  9623. rotation += 360;
  9624. }
  9625. if (this._pagesRotation === rotation) {
  9626. return;
  9627. }
  9628. this._pagesRotation = rotation;
  9629. const pageNumber = this._currentPageNumber;
  9630. this.refresh(true, {
  9631. rotation
  9632. });
  9633. if (this._currentScaleValue) {
  9634. this._setScale(this._currentScaleValue, {
  9635. noScroll: true
  9636. });
  9637. }
  9638. this.eventBus.dispatch("rotationchanging", {
  9639. source: this,
  9640. pagesRotation: rotation,
  9641. pageNumber
  9642. });
  9643. if (this.defaultRenderingQueue) {
  9644. this.update();
  9645. }
  9646. }
  9647. get firstPagePromise() {
  9648. return this.pdfDocument ? this._firstPageCapability.promise : null;
  9649. }
  9650. get onePageRendered() {
  9651. return this.pdfDocument ? this._onePageRenderedCapability.promise : null;
  9652. }
  9653. get pagesPromise() {
  9654. return this.pdfDocument ? this._pagesCapability.promise : null;
  9655. }
  9656. setDocument(pdfDocument) {
  9657. if (this.pdfDocument) {
  9658. var _this$findController, _this$_scriptingManag;
  9659. this.eventBus.dispatch("pagesdestroy", {
  9660. source: this
  9661. });
  9662. this._cancelRendering();
  9663. this._resetView();
  9664. (_this$findController = this.findController) === null || _this$findController === void 0 ? void 0 : _this$findController.setDocument(null);
  9665. (_this$_scriptingManag = this._scriptingManager) === null || _this$_scriptingManag === void 0 ? void 0 : _this$_scriptingManag.setDocument(null);
  9666. if (_classPrivateFieldGet(this, _annotationEditorUIManager)) {
  9667. _classPrivateFieldGet(this, _annotationEditorUIManager).destroy();
  9668. _classPrivateFieldSet(this, _annotationEditorUIManager, null);
  9669. }
  9670. }
  9671. this.pdfDocument = pdfDocument;
  9672. if (!pdfDocument) {
  9673. return;
  9674. }
  9675. const pagesCount = pdfDocument.numPages;
  9676. const firstPagePromise = pdfDocument.getPage(1);
  9677. const optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
  9678. const permissionsPromise = _classPrivateFieldGet(this, _enablePermissions) ? pdfDocument.getPermissions() : Promise.resolve();
  9679. if (pagesCount > PagesCountLimit.FORCE_SCROLL_MODE_PAGE) {
  9680. console.warn("Forcing PAGE-scrolling for performance reasons, given the length of the document.");
  9681. const mode = this._scrollMode = _ui_utils.ScrollMode.PAGE;
  9682. this.eventBus.dispatch("scrollmodechanged", {
  9683. source: this,
  9684. mode
  9685. });
  9686. }
  9687. this._pagesCapability.promise.then(() => {
  9688. this.eventBus.dispatch("pagesloaded", {
  9689. source: this,
  9690. pagesCount
  9691. });
  9692. }, () => { });
  9693. this._onBeforeDraw = evt => {
  9694. const pageView = this._pages[evt.pageNumber - 1];
  9695. if (!pageView) {
  9696. return;
  9697. }
  9698. _classPrivateFieldGet(this, _buffer).push(pageView);
  9699. };
  9700. this.eventBus._on("pagerender", this._onBeforeDraw);
  9701. this._onAfterDraw = evt => {
  9702. if (evt.cssTransform || this._onePageRenderedCapability.settled) {
  9703. return;
  9704. }
  9705. this._onePageRenderedCapability.resolve({
  9706. timestamp: evt.timestamp
  9707. });
  9708. this.eventBus._off("pagerendered", this._onAfterDraw);
  9709. this._onAfterDraw = null;
  9710. if (_classPrivateFieldGet(this, _onVisibilityChange)) {
  9711. document.removeEventListener("visibilitychange", _classPrivateFieldGet(this, _onVisibilityChange));
  9712. _classPrivateFieldSet(this, _onVisibilityChange, null);
  9713. }
  9714. };
  9715. this.eventBus._on("pagerendered", this._onAfterDraw);
  9716. Promise.all([firstPagePromise, permissionsPromise]).then(_ref => {
  9717. let [firstPdfPage, permissions] = _ref;
  9718. if (pdfDocument !== this.pdfDocument) {
  9719. return;
  9720. }
  9721. this._firstPageCapability.resolve(firstPdfPage);
  9722. this._optionalContentConfigPromise = optionalContentConfigPromise;
  9723. const {
  9724. annotationEditorMode,
  9725. annotationMode,
  9726. textLayerMode
  9727. } = _classPrivateMethodGet(this, _initializePermissions, _initializePermissions2).call(this, permissions);
  9728. if (annotationEditorMode !== _pdfjsLib.AnnotationEditorType.DISABLE) {
  9729. const mode = annotationEditorMode;
  9730. if (pdfDocument.isPureXfa) {
  9731. console.warn("Warning: XFA-editing is not implemented.");
  9732. } else if (isValidAnnotationEditorMode(mode)) {
  9733. _classPrivateFieldSet(this, _annotationEditorUIManager, new _pdfjsLib.AnnotationEditorUIManager(this.container, this.eventBus, pdfDocument === null || pdfDocument === void 0 ? void 0 : pdfDocument.annotationStorage));
  9734. if (mode !== _pdfjsLib.AnnotationEditorType.NONE) {
  9735. _classPrivateFieldGet(this, _annotationEditorUIManager).updateMode(mode);
  9736. }
  9737. } else {
  9738. console.error(`Invalid AnnotationEditor mode: ${mode}`);
  9739. }
  9740. }
  9741. const layerProperties = _classPrivateMethodGet(this, _layerProperties, _layerProperties2).bind(this);
  9742. const viewerElement = this._scrollMode === _ui_utils.ScrollMode.PAGE ? null : this.viewer;
  9743. const scale = this.currentScale;
  9744. const viewport = firstPdfPage.getViewport({
  9745. scale: scale * _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS
  9746. });
  9747. this.viewer.style.setProperty("--scale-factor", viewport.scale);
  9748. for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  9749. const pageView = new _pdf_page_view.PDFPageView({
  9750. container: viewerElement,
  9751. eventBus: this.eventBus,
  9752. id: pageNum,
  9753. scale,
  9754. defaultViewport: viewport.clone(),
  9755. optionalContentConfigPromise,
  9756. renderingQueue: this.renderingQueue,
  9757. textLayerMode,
  9758. annotationMode,
  9759. imageResourcesPath: this.imageResourcesPath,
  9760. renderer: this.renderer,
  9761. useOnlyCssZoom: this.useOnlyCssZoom,
  9762. isOffscreenCanvasSupported: this.isOffscreenCanvasSupported,
  9763. maxCanvasPixels: this.maxCanvasPixels,
  9764. pageColors: this.pageColors,
  9765. l10n: this.l10n,
  9766. layerProperties
  9767. });
  9768. this._pages.push(pageView);
  9769. }
  9770. const firstPageView = this._pages[0];
  9771. if (firstPageView) {
  9772. firstPageView.setPdfPage(firstPdfPage);
  9773. this.linkService.cachePageRef(1, firstPdfPage.ref);
  9774. }
  9775. if (this._scrollMode === _ui_utils.ScrollMode.PAGE) {
  9776. _classPrivateMethodGet(this, _ensurePageViewVisible, _ensurePageViewVisible2).call(this);
  9777. } else if (this._spreadMode !== _ui_utils.SpreadMode.NONE) {
  9778. this._updateSpreadMode();
  9779. }
  9780. _classPrivateMethodGet(this, _onePageRenderedOrForceFetch, _onePageRenderedOrForceFetch2).call(this).then(async () => {
  9781. var _this$findController2, _this$_scriptingManag2;
  9782. (_this$findController2 = this.findController) === null || _this$findController2 === void 0 ? void 0 : _this$findController2.setDocument(pdfDocument);
  9783. (_this$_scriptingManag2 = this._scriptingManager) === null || _this$_scriptingManag2 === void 0 ? void 0 : _this$_scriptingManag2.setDocument(pdfDocument);
  9784. if (_classPrivateFieldGet(this, _annotationEditorUIManager)) {
  9785. this.eventBus.dispatch("annotationeditormodechanged", {
  9786. source: this,
  9787. mode: _classPrivateFieldGet(this, _annotationEditorMode)
  9788. });
  9789. }
  9790. if (pdfDocument.loadingParams.disableAutoFetch || pagesCount > PagesCountLimit.FORCE_LAZY_PAGE_INIT) {
  9791. this._pagesCapability.resolve();
  9792. return;
  9793. }
  9794. let getPagesLeft = pagesCount - 1;
  9795. if (getPagesLeft <= 0) {
  9796. this._pagesCapability.resolve();
  9797. return;
  9798. }
  9799. for (let pageNum = 2; pageNum <= pagesCount; ++pageNum) {
  9800. const promise = pdfDocument.getPage(pageNum).then(pdfPage => {
  9801. const pageView = this._pages[pageNum - 1];
  9802. if (!pageView.pdfPage) {
  9803. pageView.setPdfPage(pdfPage);
  9804. }
  9805. this.linkService.cachePageRef(pageNum, pdfPage.ref);
  9806. if (--getPagesLeft === 0) {
  9807. this._pagesCapability.resolve();
  9808. }
  9809. }, reason => {
  9810. console.error(`Unable to get page ${pageNum} to initialize viewer`, reason);
  9811. if (--getPagesLeft === 0) {
  9812. this._pagesCapability.resolve();
  9813. }
  9814. });
  9815. if (pageNum % PagesCountLimit.PAUSE_EAGER_PAGE_INIT === 0) {
  9816. await promise;
  9817. }
  9818. }
  9819. });
  9820. this.eventBus.dispatch("pagesinit", {
  9821. source: this
  9822. });
  9823. pdfDocument.getMetadata().then(_ref2 => {
  9824. let {
  9825. info
  9826. } = _ref2;
  9827. if (pdfDocument !== this.pdfDocument) {
  9828. return;
  9829. }
  9830. if (info.Language) {
  9831. this.viewer.lang = info.Language;
  9832. }
  9833. });
  9834. if (this.defaultRenderingQueue) {
  9835. this.update();
  9836. }
  9837. }).catch(reason => {
  9838. console.error("Unable to initialize viewer", reason);
  9839. this._pagesCapability.reject(reason);
  9840. });
  9841. }
  9842. setPageLabels(labels) {
  9843. if (!this.pdfDocument) {
  9844. return;
  9845. }
  9846. if (!labels) {
  9847. this._pageLabels = null;
  9848. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  9849. this._pageLabels = null;
  9850. console.error(`setPageLabels: Invalid page labels.`);
  9851. } else {
  9852. this._pageLabels = labels;
  9853. }
  9854. for (let i = 0, ii = this._pages.length; i < ii; i++) {
  9855. var _this$_pageLabels3;
  9856. this._pages[i].setPageLabel(((_this$_pageLabels3 = this._pageLabels) === null || _this$_pageLabels3 === void 0 ? void 0 : _this$_pageLabels3[i]) ?? null);
  9857. }
  9858. }
  9859. _resetView() {
  9860. this._pages = [];
  9861. this._currentPageNumber = 1;
  9862. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  9863. this._currentScaleValue = null;
  9864. this._pageLabels = null;
  9865. _classPrivateFieldSet(this, _buffer, new PDFPageViewBuffer(DEFAULT_CACHE_SIZE));
  9866. this._location = null;
  9867. this._pagesRotation = 0;
  9868. this._optionalContentConfigPromise = null;
  9869. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  9870. this._onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  9871. this._pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
  9872. this._scrollMode = _ui_utils.ScrollMode.VERTICAL;
  9873. this._previousScrollMode = _ui_utils.ScrollMode.UNKNOWN;
  9874. this._spreadMode = _ui_utils.SpreadMode.NONE;
  9875. _classPrivateFieldSet(this, _scrollModePageState, {
  9876. previousPageNumber: 1,
  9877. scrollDown: true,
  9878. pages: []
  9879. });
  9880. if (this._onBeforeDraw) {
  9881. this.eventBus._off("pagerender", this._onBeforeDraw);
  9882. this._onBeforeDraw = null;
  9883. }
  9884. if (this._onAfterDraw) {
  9885. this.eventBus._off("pagerendered", this._onAfterDraw);
  9886. this._onAfterDraw = null;
  9887. }
  9888. if (_classPrivateFieldGet(this, _onVisibilityChange)) {
  9889. document.removeEventListener("visibilitychange", _classPrivateFieldGet(this, _onVisibilityChange));
  9890. _classPrivateFieldSet(this, _onVisibilityChange, null);
  9891. }
  9892. this.viewer.textContent = "";
  9893. this._updateScrollMode();
  9894. this.viewer.removeAttribute("lang");
  9895. this.viewer.classList.remove(ENABLE_PERMISSIONS_CLASS);
  9896. }
  9897. _scrollUpdate() {
  9898. if (this.pagesCount === 0) {
  9899. return;
  9900. }
  9901. this.update();
  9902. }
  9903. _setScaleUpdatePages(newScale, newValue, _ref3) {
  9904. let {
  9905. noScroll = false,
  9906. preset = false,
  9907. drawingDelay = -1
  9908. } = _ref3;
  9909. this._currentScaleValue = newValue.toString();
  9910. if (_classPrivateMethodGet(this, _isSameScale, _isSameScale2).call(this, newScale)) {
  9911. if (preset) {
  9912. this.eventBus.dispatch("scalechanging", {
  9913. source: this,
  9914. scale: newScale,
  9915. presetValue: newValue
  9916. });
  9917. }
  9918. return;
  9919. }
  9920. this.viewer.style.setProperty("--scale-factor", newScale * _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS);
  9921. const postponeDrawing = drawingDelay >= 0 && drawingDelay < 1000;
  9922. this.refresh(true, {
  9923. scale: newScale,
  9924. drawingDelay: postponeDrawing ? drawingDelay : -1
  9925. });
  9926. if (postponeDrawing) {
  9927. _classPrivateFieldSet(this, _scaleTimeoutId, setTimeout(() => {
  9928. _classPrivateFieldSet(this, _scaleTimeoutId, null);
  9929. this.refresh();
  9930. }, drawingDelay));
  9931. }
  9932. this._currentScale = newScale;
  9933. if (!noScroll) {
  9934. let page = this._currentPageNumber,
  9935. dest;
  9936. if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  9937. page = this._location.pageNumber;
  9938. dest = [null, {
  9939. name: "XYZ"
  9940. }, this._location.left, this._location.top, null];
  9941. }
  9942. this.scrollPageIntoView({
  9943. pageNumber: page,
  9944. destArray: dest,
  9945. allowNegativeOffset: true
  9946. });
  9947. }
  9948. this.eventBus.dispatch("scalechanging", {
  9949. source: this,
  9950. scale: newScale,
  9951. presetValue: preset ? newValue : undefined
  9952. });
  9953. if (this.defaultRenderingQueue) {
  9954. this.update();
  9955. }
  9956. }
  9957. get _pageWidthScaleFactor() {
  9958. if (this._spreadMode !== _ui_utils.SpreadMode.NONE && this._scrollMode !== _ui_utils.ScrollMode.HORIZONTAL) {
  9959. return 2;
  9960. }
  9961. return 1;
  9962. }
  9963. _setScale(value, options) {
  9964. let scale = parseFloat(value);
  9965. if (scale > 0) {
  9966. options.preset = false;
  9967. this._setScaleUpdatePages(scale, value, options);
  9968. } else {
  9969. const currentPage = this._pages[this._currentPageNumber - 1];
  9970. if (!currentPage) {
  9971. return;
  9972. }
  9973. let hPadding = _ui_utils.SCROLLBAR_PADDING,
  9974. vPadding = _ui_utils.VERTICAL_PADDING;
  9975. if (this.isInPresentationMode) {
  9976. hPadding = vPadding = 4;
  9977. if (this._spreadMode !== _ui_utils.SpreadMode.NONE) {
  9978. hPadding *= 2;
  9979. }
  9980. } else if (this.removePageBorders) {
  9981. hPadding = vPadding = 0;
  9982. } else if (this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL) {
  9983. [hPadding, vPadding] = [vPadding, hPadding];
  9984. }
  9985. const pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale / this._pageWidthScaleFactor;
  9986. const pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  9987. switch (value) {
  9988. case "page-actual":
  9989. scale = 1;
  9990. break;
  9991. case "page-width":
  9992. scale = pageWidthScale;
  9993. break;
  9994. case "page-height":
  9995. scale = pageHeightScale;
  9996. break;
  9997. case "page-fit":
  9998. scale = Math.min(pageWidthScale, pageHeightScale);
  9999. break;
  10000. case "auto":
  10001. const horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
  10002. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  10003. break;
  10004. default:
  10005. console.error(`_setScale: "${value}" is an unknown zoom value.`);
  10006. return;
  10007. }
  10008. options.preset = true;
  10009. this._setScaleUpdatePages(scale, value, options);
  10010. }
  10011. }
  10012. pageLabelToPageNumber(label) {
  10013. if (!this._pageLabels) {
  10014. return null;
  10015. }
  10016. const i = this._pageLabels.indexOf(label);
  10017. if (i < 0) {
  10018. return null;
  10019. }
  10020. return i + 1;
  10021. }
  10022. scrollPageIntoView(_ref4) {
  10023. let {
  10024. pageNumber,
  10025. destArray = null,
  10026. allowNegativeOffset = false,
  10027. ignoreDestinationZoom = false
  10028. } = _ref4;
  10029. if (!this.pdfDocument) {
  10030. return;
  10031. }
  10032. const pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1];
  10033. if (!pageView) {
  10034. console.error(`scrollPageIntoView: "${pageNumber}" is not a valid pageNumber parameter.`);
  10035. return;
  10036. }
  10037. if (this.isInPresentationMode || !destArray) {
  10038. this._setCurrentPageNumber(pageNumber, true);
  10039. return;
  10040. }
  10041. let x = 0,
  10042. y = 0;
  10043. let width = 0,
  10044. height = 0,
  10045. widthScale,
  10046. heightScale;
  10047. const changeOrientation = pageView.rotation % 180 !== 0;
  10048. const pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS;
  10049. const pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS;
  10050. let scale = 0;
  10051. switch (destArray[1].name) {
  10052. case "XYZ":
  10053. x = destArray[2];
  10054. y = destArray[3];
  10055. scale = destArray[4];
  10056. x = x !== null ? x : 0;
  10057. y = y !== null ? y : pageHeight;
  10058. break;
  10059. case "Fit":
  10060. case "FitB":
  10061. scale = "page-fit";
  10062. break;
  10063. case "FitH":
  10064. case "FitBH":
  10065. y = destArray[2];
  10066. scale = "page-width";
  10067. if (y === null && this._location) {
  10068. x = this._location.left;
  10069. y = this._location.top;
  10070. } else if (typeof y !== "number" || y < 0) {
  10071. y = pageHeight;
  10072. }
  10073. break;
  10074. case "FitV":
  10075. case "FitBV":
  10076. x = destArray[2];
  10077. width = pageWidth;
  10078. height = pageHeight;
  10079. scale = "page-height";
  10080. break;
  10081. case "FitR":
  10082. x = destArray[2];
  10083. y = destArray[3];
  10084. width = destArray[4] - x;
  10085. height = destArray[5] - y;
  10086. let hPadding = _ui_utils.SCROLLBAR_PADDING,
  10087. vPadding = _ui_utils.VERTICAL_PADDING;
  10088. if (this.removePageBorders) {
  10089. hPadding = vPadding = 0;
  10090. }
  10091. widthScale = (this.container.clientWidth - hPadding) / width / _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS;
  10092. heightScale = (this.container.clientHeight - vPadding) / height / _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS;
  10093. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  10094. break;
  10095. default:
  10096. console.error(`scrollPageIntoView: "${destArray[1].name}" is not a valid destination type.`);
  10097. return;
  10098. }
  10099. if (!ignoreDestinationZoom) {
  10100. if (scale && scale !== this._currentScale) {
  10101. this.currentScaleValue = scale;
  10102. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  10103. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  10104. }
  10105. }
  10106. if (scale === "page-fit" && !destArray[4]) {
  10107. _classPrivateMethodGet(this, _scrollIntoView, _scrollIntoView2).call(this, pageView);
  10108. return;
  10109. }
  10110. const boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  10111. let left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  10112. let top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  10113. if (!allowNegativeOffset) {
  10114. left = Math.max(left, 0);
  10115. top = Math.max(top, 0);
  10116. }
  10117. _classPrivateMethodGet(this, _scrollIntoView, _scrollIntoView2).call(this, pageView, {
  10118. left,
  10119. top
  10120. });
  10121. }
  10122. _updateLocation(firstPage) {
  10123. const currentScale = this._currentScale;
  10124. const currentScaleValue = this._currentScaleValue;
  10125. const normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  10126. const pageNumber = firstPage.id;
  10127. const currentPageView = this._pages[pageNumber - 1];
  10128. const container = this.container;
  10129. const topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  10130. const intLeft = Math.round(topLeft[0]);
  10131. const intTop = Math.round(topLeft[1]);
  10132. let pdfOpenParams = `#page=${pageNumber}`;
  10133. if (!this.isInPresentationMode) {
  10134. pdfOpenParams += `&zoom=${normalizedScaleValue},${intLeft},${intTop}`;
  10135. }
  10136. this._location = {
  10137. pageNumber,
  10138. scale: normalizedScaleValue,
  10139. top: intTop,
  10140. left: intLeft,
  10141. rotation: this._pagesRotation,
  10142. pdfOpenParams
  10143. };
  10144. }
  10145. update() {
  10146. const visible = this._getVisiblePages();
  10147. const visiblePages = visible.views,
  10148. numVisiblePages = visiblePages.length;
  10149. if (numVisiblePages === 0) {
  10150. return;
  10151. }
  10152. const newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
  10153. _classPrivateFieldGet(this, _buffer).resize(newCacheSize, visible.ids);
  10154. this.renderingQueue.renderHighestPriority(visible);
  10155. const isSimpleLayout = this._spreadMode === _ui_utils.SpreadMode.NONE && (this._scrollMode === _ui_utils.ScrollMode.PAGE || this._scrollMode === _ui_utils.ScrollMode.VERTICAL);
  10156. const currentId = this._currentPageNumber;
  10157. let stillFullyVisible = false;
  10158. for (const page of visiblePages) {
  10159. if (page.percent < 100) {
  10160. break;
  10161. }
  10162. if (page.id === currentId && isSimpleLayout) {
  10163. stillFullyVisible = true;
  10164. break;
  10165. }
  10166. }
  10167. this._setCurrentPageNumber(stillFullyVisible ? currentId : visiblePages[0].id);
  10168. this._updateLocation(visible.first);
  10169. this.eventBus.dispatch("updateviewarea", {
  10170. source: this,
  10171. location: this._location
  10172. });
  10173. }
  10174. containsElement(element) {
  10175. return this.container.contains(element);
  10176. }
  10177. focus() {
  10178. this.container.focus();
  10179. }
  10180. get _isContainerRtl() {
  10181. return getComputedStyle(this.container).direction === "rtl";
  10182. }
  10183. get isInPresentationMode() {
  10184. return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
  10185. }
  10186. get isChangingPresentationMode() {
  10187. return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
  10188. }
  10189. get isHorizontalScrollbarEnabled() {
  10190. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  10191. }
  10192. get isVerticalScrollbarEnabled() {
  10193. return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight;
  10194. }
  10195. _getVisiblePages() {
  10196. const views = this._scrollMode === _ui_utils.ScrollMode.PAGE ? _classPrivateFieldGet(this, _scrollModePageState).pages : this._pages,
  10197. horizontal = this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL,
  10198. rtl = horizontal && this._isContainerRtl;
  10199. return (0, _ui_utils.getVisibleElements)({
  10200. scrollEl: this.container,
  10201. views,
  10202. sortByVisibility: true,
  10203. horizontal,
  10204. rtl
  10205. });
  10206. }
  10207. isPageVisible(pageNumber) {
  10208. if (!this.pdfDocument) {
  10209. return false;
  10210. }
  10211. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
  10212. console.error(`isPageVisible: "${pageNumber}" is not a valid page.`);
  10213. return false;
  10214. }
  10215. return this._getVisiblePages().ids.has(pageNumber);
  10216. }
  10217. isPageCached(pageNumber) {
  10218. if (!this.pdfDocument) {
  10219. return false;
  10220. }
  10221. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
  10222. console.error(`isPageCached: "${pageNumber}" is not a valid page.`);
  10223. return false;
  10224. }
  10225. const pageView = this._pages[pageNumber - 1];
  10226. return _classPrivateFieldGet(this, _buffer).has(pageView);
  10227. }
  10228. cleanup() {
  10229. for (const pageView of this._pages) {
  10230. if (pageView.renderingState !== _ui_utils.RenderingStates.FINISHED) {
  10231. pageView.reset();
  10232. }
  10233. }
  10234. }
  10235. _cancelRendering() {
  10236. for (const pageView of this._pages) {
  10237. pageView.cancelRendering();
  10238. }
  10239. }
  10240. forceRendering(currentlyVisiblePages) {
  10241. const visiblePages = currentlyVisiblePages || this._getVisiblePages();
  10242. const scrollAhead = _classPrivateMethodGet(this, _getScrollAhead, _getScrollAhead2).call(this, visiblePages);
  10243. const preRenderExtra = this._spreadMode !== _ui_utils.SpreadMode.NONE && this._scrollMode !== _ui_utils.ScrollMode.HORIZONTAL;
  10244. const pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead, preRenderExtra);
  10245. if (pageView) {
  10246. _classPrivateMethodGet(this, _ensurePdfPageLoaded, _ensurePdfPageLoaded2).call(this, pageView).then(() => {
  10247. this.renderingQueue.renderView(pageView);
  10248. });
  10249. return true;
  10250. }
  10251. return false;
  10252. }
  10253. get hasEqualPageSizes() {
  10254. const firstPageView = this._pages[0];
  10255. for (let i = 1, ii = this._pages.length; i < ii; ++i) {
  10256. const pageView = this._pages[i];
  10257. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  10258. return false;
  10259. }
  10260. }
  10261. return true;
  10262. }
  10263. getPagesOverview() {
  10264. return this._pages.map(pageView => {
  10265. const viewport = pageView.pdfPage.getViewport({
  10266. scale: 1
  10267. });
  10268. if (!this.enablePrintAutoRotate || (0, _ui_utils.isPortraitOrientation)(viewport)) {
  10269. return {
  10270. width: viewport.width,
  10271. height: viewport.height,
  10272. rotation: viewport.rotation
  10273. };
  10274. }
  10275. return {
  10276. width: viewport.height,
  10277. height: viewport.width,
  10278. rotation: (viewport.rotation - 90) % 360
  10279. };
  10280. });
  10281. }
  10282. get optionalContentConfigPromise() {
  10283. if (!this.pdfDocument) {
  10284. return Promise.resolve(null);
  10285. }
  10286. if (!this._optionalContentConfigPromise) {
  10287. console.error("optionalContentConfigPromise: Not initialized yet.");
  10288. return this.pdfDocument.getOptionalContentConfig();
  10289. }
  10290. return this._optionalContentConfigPromise;
  10291. }
  10292. set optionalContentConfigPromise(promise) {
  10293. if (!(promise instanceof Promise)) {
  10294. throw new Error(`Invalid optionalContentConfigPromise: ${promise}`);
  10295. }
  10296. if (!this.pdfDocument) {
  10297. return;
  10298. }
  10299. if (!this._optionalContentConfigPromise) {
  10300. return;
  10301. }
  10302. this._optionalContentConfigPromise = promise;
  10303. this.refresh(false, {
  10304. optionalContentConfigPromise: promise
  10305. });
  10306. this.eventBus.dispatch("optionalcontentconfigchanged", {
  10307. source: this,
  10308. promise
  10309. });
  10310. }
  10311. get scrollMode() {
  10312. return this._scrollMode;
  10313. }
  10314. set scrollMode(mode) {
  10315. if (this._scrollMode === mode) {
  10316. return;
  10317. }
  10318. if (!(0, _ui_utils.isValidScrollMode)(mode)) {
  10319. throw new Error(`Invalid scroll mode: ${mode}`);
  10320. }
  10321. if (this.pagesCount > PagesCountLimit.FORCE_SCROLL_MODE_PAGE) {
  10322. return;
  10323. }
  10324. this._previousScrollMode = this._scrollMode;
  10325. this._scrollMode = mode;
  10326. this.eventBus.dispatch("scrollmodechanged", {
  10327. source: this,
  10328. mode
  10329. });
  10330. this._updateScrollMode(this._currentPageNumber);
  10331. }
  10332. _updateScrollMode() {
  10333. let pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  10334. const scrollMode = this._scrollMode,
  10335. viewer = this.viewer;
  10336. viewer.classList.toggle("scrollHorizontal", scrollMode === _ui_utils.ScrollMode.HORIZONTAL);
  10337. viewer.classList.toggle("scrollWrapped", scrollMode === _ui_utils.ScrollMode.WRAPPED);
  10338. if (!this.pdfDocument || !pageNumber) {
  10339. return;
  10340. }
  10341. if (scrollMode === _ui_utils.ScrollMode.PAGE) {
  10342. _classPrivateMethodGet(this, _ensurePageViewVisible, _ensurePageViewVisible2).call(this);
  10343. } else if (this._previousScrollMode === _ui_utils.ScrollMode.PAGE) {
  10344. this._updateSpreadMode();
  10345. }
  10346. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  10347. this._setScale(this._currentScaleValue, {
  10348. noScroll: true
  10349. });
  10350. }
  10351. this._setCurrentPageNumber(pageNumber, true);
  10352. this.update();
  10353. }
  10354. get spreadMode() {
  10355. return this._spreadMode;
  10356. }
  10357. set spreadMode(mode) {
  10358. if (this._spreadMode === mode) {
  10359. return;
  10360. }
  10361. if (!(0, _ui_utils.isValidSpreadMode)(mode)) {
  10362. throw new Error(`Invalid spread mode: ${mode}`);
  10363. }
  10364. this._spreadMode = mode;
  10365. this.eventBus.dispatch("spreadmodechanged", {
  10366. source: this,
  10367. mode
  10368. });
  10369. this._updateSpreadMode(this._currentPageNumber);
  10370. }
  10371. _updateSpreadMode() {
  10372. let pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  10373. if (!this.pdfDocument) {
  10374. return;
  10375. }
  10376. const viewer = this.viewer,
  10377. pages = this._pages;
  10378. if (this._scrollMode === _ui_utils.ScrollMode.PAGE) {
  10379. _classPrivateMethodGet(this, _ensurePageViewVisible, _ensurePageViewVisible2).call(this);
  10380. } else {
  10381. viewer.textContent = "";
  10382. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  10383. for (const pageView of this._pages) {
  10384. viewer.append(pageView.div);
  10385. }
  10386. } else {
  10387. const parity = this._spreadMode - 1;
  10388. let spread = null;
  10389. for (let i = 0, ii = pages.length; i < ii; ++i) {
  10390. if (spread === null) {
  10391. spread = document.createElement("div");
  10392. spread.className = "spread";
  10393. viewer.append(spread);
  10394. } else if (i % 2 === parity) {
  10395. spread = spread.cloneNode(false);
  10396. viewer.append(spread);
  10397. }
  10398. spread.append(pages[i].div);
  10399. }
  10400. }
  10401. }
  10402. if (!pageNumber) {
  10403. return;
  10404. }
  10405. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  10406. this._setScale(this._currentScaleValue, {
  10407. noScroll: true
  10408. });
  10409. }
  10410. this._setCurrentPageNumber(pageNumber, true);
  10411. this.update();
  10412. }
  10413. _getPageAdvance(currentPageNumber) {
  10414. let previous = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  10415. switch (this._scrollMode) {
  10416. case _ui_utils.ScrollMode.WRAPPED:
  10417. {
  10418. const {
  10419. views
  10420. } = this._getVisiblePages(),
  10421. pageLayout = new Map();
  10422. for (const {
  10423. id,
  10424. y,
  10425. percent,
  10426. widthPercent
  10427. } of views) {
  10428. if (percent === 0 || widthPercent < 100) {
  10429. continue;
  10430. }
  10431. let yArray = pageLayout.get(y);
  10432. if (!yArray) {
  10433. pageLayout.set(y, yArray || (yArray = []));
  10434. }
  10435. yArray.push(id);
  10436. }
  10437. for (const yArray of pageLayout.values()) {
  10438. const currentIndex = yArray.indexOf(currentPageNumber);
  10439. if (currentIndex === -1) {
  10440. continue;
  10441. }
  10442. const numPages = yArray.length;
  10443. if (numPages === 1) {
  10444. break;
  10445. }
  10446. if (previous) {
  10447. for (let i = currentIndex - 1, ii = 0; i >= ii; i--) {
  10448. const currentId = yArray[i],
  10449. expectedId = yArray[i + 1] - 1;
  10450. if (currentId < expectedId) {
  10451. return currentPageNumber - expectedId;
  10452. }
  10453. }
  10454. } else {
  10455. for (let i = currentIndex + 1, ii = numPages; i < ii; i++) {
  10456. const currentId = yArray[i],
  10457. expectedId = yArray[i - 1] + 1;
  10458. if (currentId > expectedId) {
  10459. return expectedId - currentPageNumber;
  10460. }
  10461. }
  10462. }
  10463. if (previous) {
  10464. const firstId = yArray[0];
  10465. if (firstId < currentPageNumber) {
  10466. return currentPageNumber - firstId + 1;
  10467. }
  10468. } else {
  10469. const lastId = yArray[numPages - 1];
  10470. if (lastId > currentPageNumber) {
  10471. return lastId - currentPageNumber + 1;
  10472. }
  10473. }
  10474. break;
  10475. }
  10476. break;
  10477. }
  10478. case _ui_utils.ScrollMode.HORIZONTAL:
  10479. {
  10480. break;
  10481. }
  10482. case _ui_utils.ScrollMode.PAGE:
  10483. case _ui_utils.ScrollMode.VERTICAL:
  10484. {
  10485. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  10486. break;
  10487. }
  10488. const parity = this._spreadMode - 1;
  10489. if (previous && currentPageNumber % 2 !== parity) {
  10490. break;
  10491. } else if (!previous && currentPageNumber % 2 === parity) {
  10492. break;
  10493. }
  10494. const {
  10495. views
  10496. } = this._getVisiblePages(),
  10497. expectedId = previous ? currentPageNumber - 1 : currentPageNumber + 1;
  10498. for (const {
  10499. id,
  10500. percent,
  10501. widthPercent
  10502. } of views) {
  10503. if (id !== expectedId) {
  10504. continue;
  10505. }
  10506. if (percent > 0 && widthPercent === 100) {
  10507. return 2;
  10508. }
  10509. break;
  10510. }
  10511. break;
  10512. }
  10513. }
  10514. return 1;
  10515. }
  10516. nextPage() {
  10517. const currentPageNumber = this._currentPageNumber,
  10518. pagesCount = this.pagesCount;
  10519. if (currentPageNumber >= pagesCount) {
  10520. return false;
  10521. }
  10522. const advance = this._getPageAdvance(currentPageNumber, false) || 1;
  10523. this.currentPageNumber = Math.min(currentPageNumber + advance, pagesCount);
  10524. return true;
  10525. }
  10526. previousPage() {
  10527. const currentPageNumber = this._currentPageNumber;
  10528. if (currentPageNumber <= 1) {
  10529. return false;
  10530. }
  10531. const advance = this._getPageAdvance(currentPageNumber, true) || 1;
  10532. this.currentPageNumber = Math.max(currentPageNumber - advance, 1);
  10533. return true;
  10534. }
  10535. increaseScale() {
  10536. let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  10537. if (typeof options === "number") {
  10538. console.error("The `increaseScale` method-signature was updated, please use an object instead.");
  10539. options = {
  10540. steps: options
  10541. };
  10542. }
  10543. if (!this.pdfDocument) {
  10544. return;
  10545. }
  10546. options || (options = Object.create(null));
  10547. let newScale = this._currentScale;
  10548. if (options.scaleFactor > 1) {
  10549. newScale = Math.min(_ui_utils.MAX_SCALE, Math.round(newScale * options.scaleFactor * 100) / 100);
  10550. } else {
  10551. let steps = options.steps ?? 1;
  10552. do {
  10553. newScale = (newScale * _ui_utils.DEFAULT_SCALE_DELTA).toFixed(2);
  10554. newScale = Math.ceil(newScale * 10) / 10;
  10555. newScale = Math.min(_ui_utils.MAX_SCALE, newScale);
  10556. } while (--steps > 0 && newScale < _ui_utils.MAX_SCALE);
  10557. }
  10558. options.noScroll = false;
  10559. this._setScale(newScale, options);
  10560. }
  10561. decreaseScale() {
  10562. let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  10563. if (typeof options === "number") {
  10564. console.error("The `decreaseScale` method-signature was updated, please use an object instead.");
  10565. options = {
  10566. steps: options
  10567. };
  10568. }
  10569. if (!this.pdfDocument) {
  10570. return;
  10571. }
  10572. options || (options = Object.create(null));
  10573. let newScale = this._currentScale;
  10574. if (options.scaleFactor > 0 && options.scaleFactor < 1) {
  10575. newScale = Math.max(_ui_utils.MIN_SCALE, Math.round(newScale * options.scaleFactor * 100) / 100);
  10576. } else {
  10577. let steps = options.steps ?? 1;
  10578. do {
  10579. newScale = (newScale / _ui_utils.DEFAULT_SCALE_DELTA).toFixed(2);
  10580. newScale = Math.floor(newScale * 10) / 10;
  10581. newScale = Math.max(_ui_utils.MIN_SCALE, newScale);
  10582. } while (--steps > 0 && newScale > _ui_utils.MIN_SCALE);
  10583. }
  10584. options.noScroll = false;
  10585. this._setScale(newScale, options);
  10586. }
  10587. get containerTopLeft() {
  10588. return _classPrivateFieldGet(this, _containerTopLeft) || _classPrivateFieldSet(this, _containerTopLeft, [this.container.offsetTop, this.container.offsetLeft]);
  10589. }
  10590. get annotationEditorMode() {
  10591. return _classPrivateFieldGet(this, _annotationEditorUIManager) ? _classPrivateFieldGet(this, _annotationEditorMode) : _pdfjsLib.AnnotationEditorType.DISABLE;
  10592. }
  10593. set annotationEditorMode(mode) {
  10594. if (!_classPrivateFieldGet(this, _annotationEditorUIManager)) {
  10595. throw new Error(`The AnnotationEditor is not enabled.`);
  10596. }
  10597. if (_classPrivateFieldGet(this, _annotationEditorMode) === mode) {
  10598. return;
  10599. }
  10600. if (!isValidAnnotationEditorMode(mode)) {
  10601. throw new Error(`Invalid AnnotationEditor mode: ${mode}`);
  10602. }
  10603. if (!this.pdfDocument) {
  10604. return;
  10605. }
  10606. _classPrivateFieldSet(this, _annotationEditorMode, mode);
  10607. this.eventBus.dispatch("annotationeditormodechanged", {
  10608. source: this,
  10609. mode
  10610. });
  10611. _classPrivateFieldGet(this, _annotationEditorUIManager).updateMode(mode);
  10612. }
  10613. set annotationEditorParams(_ref5) {
  10614. let {
  10615. type,
  10616. value
  10617. } = _ref5;
  10618. if (!_classPrivateFieldGet(this, _annotationEditorUIManager)) {
  10619. throw new Error(`The AnnotationEditor is not enabled.`);
  10620. }
  10621. _classPrivateFieldGet(this, _annotationEditorUIManager).updateParams(type, value);
  10622. }
  10623. refresh() {
  10624. let noUpdate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  10625. let updateArgs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Object.create(null);
  10626. if (!this.pdfDocument) {
  10627. return;
  10628. }
  10629. for (const pageView of this._pages) {
  10630. pageView.update(updateArgs);
  10631. }
  10632. if (_classPrivateFieldGet(this, _scaleTimeoutId) !== null) {
  10633. clearTimeout(_classPrivateFieldGet(this, _scaleTimeoutId));
  10634. _classPrivateFieldSet(this, _scaleTimeoutId, null);
  10635. }
  10636. if (!noUpdate) {
  10637. this.update();
  10638. }
  10639. }
  10640. }
  10641. exports.PDFViewer = PDFViewer;
  10642. function _layerProperties2() {
  10643. const self = this;
  10644. return {
  10645. get annotationEditorUIManager() {
  10646. return _classPrivateFieldGet(self, _annotationEditorUIManager);
  10647. },
  10648. get annotationStorage() {
  10649. var _self$pdfDocument;
  10650. return (_self$pdfDocument = self.pdfDocument) === null || _self$pdfDocument === void 0 ? void 0 : _self$pdfDocument.annotationStorage;
  10651. },
  10652. get downloadManager() {
  10653. return self.downloadManager;
  10654. },
  10655. get enableScripting() {
  10656. return !!self._scriptingManager;
  10657. },
  10658. get fieldObjectsPromise() {
  10659. var _self$pdfDocument2;
  10660. return (_self$pdfDocument2 = self.pdfDocument) === null || _self$pdfDocument2 === void 0 ? void 0 : _self$pdfDocument2.getFieldObjects();
  10661. },
  10662. get findController() {
  10663. return self.findController;
  10664. },
  10665. get hasJSActionsPromise() {
  10666. var _self$pdfDocument3;
  10667. return (_self$pdfDocument3 = self.pdfDocument) === null || _self$pdfDocument3 === void 0 ? void 0 : _self$pdfDocument3.hasJSActions();
  10668. },
  10669. get linkService() {
  10670. return self.linkService;
  10671. }
  10672. };
  10673. }
  10674. function _initializePermissions2(permissions) {
  10675. const params = {
  10676. annotationEditorMode: _classPrivateFieldGet(this, _annotationEditorMode),
  10677. annotationMode: _classPrivateFieldGet(this, _annotationMode),
  10678. textLayerMode: this.textLayerMode
  10679. };
  10680. if (!permissions) {
  10681. return params;
  10682. }
  10683. if (!permissions.includes(_pdfjsLib.PermissionFlag.COPY)) {
  10684. this.viewer.classList.add(ENABLE_PERMISSIONS_CLASS);
  10685. }
  10686. if (!permissions.includes(_pdfjsLib.PermissionFlag.MODIFY_CONTENTS)) {
  10687. params.annotationEditorMode = _pdfjsLib.AnnotationEditorType.DISABLE;
  10688. }
  10689. if (!permissions.includes(_pdfjsLib.PermissionFlag.MODIFY_ANNOTATIONS) && !permissions.includes(_pdfjsLib.PermissionFlag.FILL_INTERACTIVE_FORMS) && _classPrivateFieldGet(this, _annotationMode) === _pdfjsLib.AnnotationMode.ENABLE_FORMS) {
  10690. params.annotationMode = _pdfjsLib.AnnotationMode.ENABLE;
  10691. }
  10692. return params;
  10693. }
  10694. function _onePageRenderedOrForceFetch2() {
  10695. if (document.visibilityState === "hidden" || !this.container.offsetParent || this._getVisiblePages().views.length === 0) {
  10696. return Promise.resolve();
  10697. }
  10698. const visibilityChangePromise = new Promise(resolve => {
  10699. _classPrivateFieldSet(this, _onVisibilityChange, () => {
  10700. if (document.visibilityState !== "hidden") {
  10701. return;
  10702. }
  10703. resolve();
  10704. document.removeEventListener("visibilitychange", _classPrivateFieldGet(this, _onVisibilityChange));
  10705. _classPrivateFieldSet(this, _onVisibilityChange, null);
  10706. });
  10707. document.addEventListener("visibilitychange", _classPrivateFieldGet(this, _onVisibilityChange));
  10708. });
  10709. return Promise.race([this._onePageRenderedCapability.promise, visibilityChangePromise]);
  10710. }
  10711. function _ensurePageViewVisible2() {
  10712. if (this._scrollMode !== _ui_utils.ScrollMode.PAGE) {
  10713. throw new Error("#ensurePageViewVisible: Invalid scrollMode value.");
  10714. }
  10715. const pageNumber = this._currentPageNumber,
  10716. state = _classPrivateFieldGet(this, _scrollModePageState),
  10717. viewer = this.viewer;
  10718. viewer.textContent = "";
  10719. state.pages.length = 0;
  10720. if (this._spreadMode === _ui_utils.SpreadMode.NONE && !this.isInPresentationMode) {
  10721. const pageView = this._pages[pageNumber - 1];
  10722. viewer.append(pageView.div);
  10723. state.pages.push(pageView);
  10724. } else {
  10725. const pageIndexSet = new Set(),
  10726. parity = this._spreadMode - 1;
  10727. if (parity === -1) {
  10728. pageIndexSet.add(pageNumber - 1);
  10729. } else if (pageNumber % 2 !== parity) {
  10730. pageIndexSet.add(pageNumber - 1);
  10731. pageIndexSet.add(pageNumber);
  10732. } else {
  10733. pageIndexSet.add(pageNumber - 2);
  10734. pageIndexSet.add(pageNumber - 1);
  10735. }
  10736. const spread = document.createElement("div");
  10737. spread.className = "spread";
  10738. if (this.isInPresentationMode) {
  10739. const dummyPage = document.createElement("div");
  10740. dummyPage.className = "dummyPage";
  10741. spread.append(dummyPage);
  10742. }
  10743. for (const i of pageIndexSet) {
  10744. const pageView = this._pages[i];
  10745. if (!pageView) {
  10746. continue;
  10747. }
  10748. spread.append(pageView.div);
  10749. state.pages.push(pageView);
  10750. }
  10751. viewer.append(spread);
  10752. }
  10753. state.scrollDown = pageNumber >= state.previousPageNumber;
  10754. state.previousPageNumber = pageNumber;
  10755. }
  10756. function _scrollIntoView2(pageView) {
  10757. let pageSpot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  10758. const {
  10759. div,
  10760. id
  10761. } = pageView;
  10762. if (this._currentPageNumber !== id) {
  10763. this._setCurrentPageNumber(id);
  10764. }
  10765. if (this._scrollMode === _ui_utils.ScrollMode.PAGE) {
  10766. _classPrivateMethodGet(this, _ensurePageViewVisible, _ensurePageViewVisible2).call(this);
  10767. this.update();
  10768. }
  10769. if (!pageSpot && !this.isInPresentationMode) {
  10770. const left = div.offsetLeft + div.clientLeft,
  10771. right = left + div.clientWidth;
  10772. const {
  10773. scrollLeft,
  10774. clientWidth
  10775. } = this.container;
  10776. if (this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL || left < scrollLeft || right > scrollLeft + clientWidth) {
  10777. pageSpot = {
  10778. left: 0,
  10779. top: 0
  10780. };
  10781. }
  10782. }
  10783. (0, _ui_utils.scrollIntoView)(div, pageSpot);
  10784. if (!this._currentScaleValue && this._location) {
  10785. this._location = null;
  10786. }
  10787. }
  10788. function _isSameScale2(newScale) {
  10789. return newScale === this._currentScale || Math.abs(newScale - this._currentScale) < 1e-15;
  10790. }
  10791. function _resetCurrentPageView2() {
  10792. const pageView = this._pages[this._currentPageNumber - 1];
  10793. if (this.isInPresentationMode) {
  10794. this._setScale(this._currentScaleValue, {
  10795. noScroll: true
  10796. });
  10797. }
  10798. _classPrivateMethodGet(this, _scrollIntoView, _scrollIntoView2).call(this, pageView);
  10799. }
  10800. async function _ensurePdfPageLoaded2(pageView) {
  10801. if (pageView.pdfPage) {
  10802. return pageView.pdfPage;
  10803. }
  10804. try {
  10805. var _this$linkService$_ca, _this$linkService;
  10806. const pdfPage = await this.pdfDocument.getPage(pageView.id);
  10807. if (!pageView.pdfPage) {
  10808. pageView.setPdfPage(pdfPage);
  10809. }
  10810. if (!((_this$linkService$_ca = (_this$linkService = this.linkService)._cachedPageNumber) !== null && _this$linkService$_ca !== void 0 && _this$linkService$_ca.call(_this$linkService, pdfPage.ref))) {
  10811. this.linkService.cachePageRef(pageView.id, pdfPage.ref);
  10812. }
  10813. return pdfPage;
  10814. } catch (reason) {
  10815. console.error("Unable to get page for page view", reason);
  10816. return null;
  10817. }
  10818. }
  10819. function _getScrollAhead2(visible) {
  10820. var _visible$first, _visible$last;
  10821. if (((_visible$first = visible.first) === null || _visible$first === void 0 ? void 0 : _visible$first.id) === 1) {
  10822. return true;
  10823. } else if (((_visible$last = visible.last) === null || _visible$last === void 0 ? void 0 : _visible$last.id) === this.pagesCount) {
  10824. return false;
  10825. }
  10826. switch (this._scrollMode) {
  10827. case _ui_utils.ScrollMode.PAGE:
  10828. return _classPrivateFieldGet(this, _scrollModePageState).scrollDown;
  10829. case _ui_utils.ScrollMode.HORIZONTAL:
  10830. return this.scroll.right;
  10831. }
  10832. return this.scroll.down;
  10833. }
  10834. function _updateContainerHeightCss2() {
  10835. let height = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.container.clientHeight;
  10836. if (height !== _classPrivateFieldGet(this, _previousContainerHeight)) {
  10837. _classPrivateFieldSet(this, _previousContainerHeight, height);
  10838. _ui_utils.docStyle.setProperty("--viewer-container-height", `${height}px`);
  10839. }
  10840. }
  10841. function _resizeObserverCallback2(entries) {
  10842. for (const entry of entries) {
  10843. if (entry.target === this.container) {
  10844. _classPrivateMethodGet(this, _updateContainerHeightCss, _updateContainerHeightCss2).call(this, Math.floor(entry.borderBoxSize[0].blockSize));
  10845. _classPrivateFieldSet(this, _containerTopLeft, null);
  10846. break;
  10847. }
  10848. }
  10849. }
  10850. /***/
  10851. }),
  10852. /* 31 */
  10853. /***/ ((__unused_webpack_module, exports) => {
  10854. Object.defineProperty(exports, "__esModule", ({
  10855. value: true
  10856. }));
  10857. exports.NullL10n = void 0;
  10858. exports.fixupLangCode = fixupLangCode;
  10859. exports.getL10nFallback = getL10nFallback;
  10860. const DEFAULT_L10N_STRINGS = {
  10861. of_pages: "of {{pagesCount}}",
  10862. page_of_pages: "({{pageNumber}} of {{pagesCount}})",
  10863. document_properties_kb: "{{size_kb}} KB ({{size_b}} bytes)",
  10864. document_properties_mb: "{{size_mb}} MB ({{size_b}} bytes)",
  10865. document_properties_date_string: "{{date}}, {{time}}",
  10866. document_properties_page_size_unit_inches: "in",
  10867. document_properties_page_size_unit_millimeters: "mm",
  10868. document_properties_page_size_orientation_portrait: "portrait",
  10869. document_properties_page_size_orientation_landscape: "landscape",
  10870. document_properties_page_size_name_a3: "A3",
  10871. document_properties_page_size_name_a4: "A4",
  10872. document_properties_page_size_name_letter: "Letter",
  10873. document_properties_page_size_name_legal: "Legal",
  10874. document_properties_page_size_dimension_string: "{{width}} × {{height}} {{unit}} ({{orientation}})",
  10875. document_properties_page_size_dimension_name_string: "{{width}} × {{height}} {{unit}} ({{name}}, {{orientation}})",
  10876. document_properties_linearized_yes: "Yes",
  10877. document_properties_linearized_no: "No",
  10878. additional_layers: "Additional Layers",
  10879. page_landmark: "Page {{page}}",
  10880. thumb_page_title: "Page {{page}}",
  10881. thumb_page_canvas: "Thumbnail of Page {{page}}",
  10882. find_reached_top: "Reached top of document, continued from bottom",
  10883. find_reached_bottom: "Reached end of document, continued from top",
  10884. "find_match_count[one]": "{{current}} of {{total}} match",
  10885. "find_match_count[other]": "{{current}} of {{total}} matches",
  10886. "find_match_count_limit[one]": "More than {{limit}} match",
  10887. "find_match_count_limit[other]": "More than {{limit}} matches",
  10888. find_not_found: "Phrase not found",
  10889. page_scale_width: "Page Width",
  10890. page_scale_fit: "Page Fit",
  10891. page_scale_auto: "Automatic Zoom",
  10892. page_scale_actual: "Actual Size",
  10893. page_scale_percent: "{{scale}}%",
  10894. loading_error: "An error occurred while loading the PDF.",
  10895. invalid_file_error: "Invalid or corrupted PDF file.",
  10896. missing_file_error: "Missing PDF file.",
  10897. unexpected_response_error: "Unexpected server response.",
  10898. rendering_error: "An error occurred while rendering the page.",
  10899. printing_not_supported: "Warning: Printing is not fully supported by this browser.",
  10900. printing_not_ready: "Warning: The PDF is not fully loaded for printing.",
  10901. web_fonts_disabled: "Web fonts are disabled: unable to use embedded PDF fonts.",
  10902. free_text2_default_content: "Start typing…",
  10903. editor_free_text2_aria_label: "Text Editor",
  10904. editor_ink2_aria_label: "Draw Editor",
  10905. editor_ink_canvas_aria_label: "User-created image"
  10906. };
  10907. {
  10908. DEFAULT_L10N_STRINGS.print_progress_percent = "{{progress}}%";
  10909. }
  10910. function getL10nFallback(key, args) {
  10911. switch (key) {
  10912. case "find_match_count":
  10913. key = `find_match_count[${args.total === 1 ? "one" : "other"}]`;
  10914. break;
  10915. case "find_match_count_limit":
  10916. key = `find_match_count_limit[${args.limit === 1 ? "one" : "other"}]`;
  10917. break;
  10918. }
  10919. return DEFAULT_L10N_STRINGS[key] || "";
  10920. }
  10921. const PARTIAL_LANG_CODES = {
  10922. en: "en-US",
  10923. es: "es-ES",
  10924. fy: "fy-NL",
  10925. ga: "ga-IE",
  10926. gu: "gu-IN",
  10927. hi: "hi-IN",
  10928. hy: "hy-AM",
  10929. nb: "nb-NO",
  10930. ne: "ne-NP",
  10931. nn: "nn-NO",
  10932. pa: "pa-IN",
  10933. pt: "pt-PT",
  10934. sv: "sv-SE",
  10935. zh: "zh-CN"
  10936. };
  10937. function fixupLangCode(langCode) {
  10938. return PARTIAL_LANG_CODES[langCode === null || langCode === void 0 ? void 0 : langCode.toLowerCase()] || langCode;
  10939. }
  10940. function formatL10nValue(text, args) {
  10941. if (!args) {
  10942. return text;
  10943. }
  10944. return text.replace(/\{\{\s*(\w+)\s*\}\}/g, (all, name) => {
  10945. return name in args ? args[name] : "{{" + name + "}}";
  10946. });
  10947. }
  10948. const NullL10n = {
  10949. async getLanguage() {
  10950. return "en-us";
  10951. },
  10952. async getDirection() {
  10953. return "ltr";
  10954. },
  10955. async get(key) {
  10956. let args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  10957. let fallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : getL10nFallback(key, args);
  10958. return formatL10nValue(fallback, args);
  10959. },
  10960. async translate(element) { }
  10961. };
  10962. exports.NullL10n = NullL10n;
  10963. /***/
  10964. }),
  10965. /* 32 */
  10966. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  10967. Object.defineProperty(exports, "__esModule", ({
  10968. value: true
  10969. }));
  10970. exports.PDFPageView = void 0;
  10971. var _pdfjsLib = __webpack_require__(4);
  10972. var _ui_utils = __webpack_require__(3);
  10973. var _annotation_editor_layer_builder = __webpack_require__(33);
  10974. var _annotation_layer_builder = __webpack_require__(34);
  10975. var _app_options = __webpack_require__(5);
  10976. var _l10n_utils = __webpack_require__(31);
  10977. var _pdf_link_service = __webpack_require__(7);
  10978. var _struct_tree_layer_builder = __webpack_require__(35);
  10979. var _text_accessibility = __webpack_require__(36);
  10980. var _text_highlighter = __webpack_require__(37);
  10981. var _text_layer_builder = __webpack_require__(38);
  10982. var _xfa_layer_builder = __webpack_require__(39);
  10983. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  10984. function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
  10985. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  10986. function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
  10987. function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
  10988. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  10989. function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
  10990. function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
  10991. function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
  10992. const MAX_CANVAS_PIXELS = _app_options.compatibilityParams.maxCanvasPixels || 16777216;
  10993. const DEFAULT_LAYER_PROPERTIES = () => {
  10994. return null;
  10995. };
  10996. var _annotationMode = /*#__PURE__*/new WeakMap();
  10997. var _layerProperties = /*#__PURE__*/new WeakMap();
  10998. var _loadingId = /*#__PURE__*/new WeakMap();
  10999. var _previousRotation = /*#__PURE__*/new WeakMap();
  11000. var _renderingState = /*#__PURE__*/new WeakMap();
  11001. var _useThumbnailCanvas = /*#__PURE__*/new WeakMap();
  11002. var _setDimensions = /*#__PURE__*/new WeakSet();
  11003. var _renderAnnotationLayer = /*#__PURE__*/new WeakSet();
  11004. var _renderAnnotationEditorLayer = /*#__PURE__*/new WeakSet();
  11005. var _renderXfaLayer = /*#__PURE__*/new WeakSet();
  11006. var _renderTextLayer = /*#__PURE__*/new WeakSet();
  11007. var _renderStructTreeLayer = /*#__PURE__*/new WeakSet();
  11008. var _buildXfaTextContentItems = /*#__PURE__*/new WeakSet();
  11009. class PDFPageView {
  11010. constructor(options) {
  11011. var _this$renderingQueue;
  11012. _classPrivateMethodInitSpec(this, _buildXfaTextContentItems);
  11013. _classPrivateMethodInitSpec(this, _renderStructTreeLayer);
  11014. _classPrivateMethodInitSpec(this, _renderTextLayer);
  11015. _classPrivateMethodInitSpec(this, _renderXfaLayer);
  11016. _classPrivateMethodInitSpec(this, _renderAnnotationEditorLayer);
  11017. _classPrivateMethodInitSpec(this, _renderAnnotationLayer);
  11018. _classPrivateMethodInitSpec(this, _setDimensions);
  11019. _classPrivateFieldInitSpec(this, _annotationMode, {
  11020. writable: true,
  11021. value: _pdfjsLib.AnnotationMode.ENABLE_FORMS
  11022. });
  11023. _classPrivateFieldInitSpec(this, _layerProperties, {
  11024. writable: true,
  11025. value: null
  11026. });
  11027. _classPrivateFieldInitSpec(this, _loadingId, {
  11028. writable: true,
  11029. value: null
  11030. });
  11031. _classPrivateFieldInitSpec(this, _previousRotation, {
  11032. writable: true,
  11033. value: null
  11034. });
  11035. _classPrivateFieldInitSpec(this, _renderingState, {
  11036. writable: true,
  11037. value: _ui_utils.RenderingStates.INITIAL
  11038. });
  11039. _classPrivateFieldInitSpec(this, _useThumbnailCanvas, {
  11040. writable: true,
  11041. value: {
  11042. initialOptionalContent: true,
  11043. regularAnnotations: true
  11044. }
  11045. });
  11046. const container = options.container;
  11047. const defaultViewport = options.defaultViewport;
  11048. this.id = options.id;
  11049. this.renderingId = "page" + this.id;
  11050. _classPrivateFieldSet(this, _layerProperties, options.layerProperties || DEFAULT_LAYER_PROPERTIES);
  11051. this.pdfPage = null;
  11052. this.pageLabel = null;
  11053. this.rotation = 0;
  11054. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  11055. this.viewport = defaultViewport;
  11056. this.pdfPageRotate = defaultViewport.rotation;
  11057. this._optionalContentConfigPromise = options.optionalContentConfigPromise || null;
  11058. this.hasRestrictedScaling = false;
  11059. this.textLayerMode = options.textLayerMode ?? _ui_utils.TextLayerMode.ENABLE;
  11060. _classPrivateFieldSet(this, _annotationMode, options.annotationMode ?? _pdfjsLib.AnnotationMode.ENABLE_FORMS);
  11061. this.imageResourcesPath = options.imageResourcesPath || "";
  11062. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  11063. this.isOffscreenCanvasSupported = options.isOffscreenCanvasSupported ?? true;
  11064. this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
  11065. this.pageColors = options.pageColors || null;
  11066. this.eventBus = options.eventBus;
  11067. this.renderingQueue = options.renderingQueue;
  11068. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  11069. this.l10n = options.l10n || _l10n_utils.NullL10n;
  11070. this.paintTask = null;
  11071. this.paintedViewportMap = new WeakMap();
  11072. this.resume = null;
  11073. this._renderError = null;
  11074. this._isStandalone = !((_this$renderingQueue = this.renderingQueue) !== null && _this$renderingQueue !== void 0 && _this$renderingQueue.hasViewer());
  11075. this._annotationCanvasMap = null;
  11076. this.annotationLayer = null;
  11077. this.annotationEditorLayer = null;
  11078. this.textLayer = null;
  11079. this.zoomLayer = null;
  11080. this.xfaLayer = null;
  11081. this.structTreeLayer = null;
  11082. const div = document.createElement("div");
  11083. div.className = "page";
  11084. div.setAttribute("data-page-number", this.id);
  11085. div.setAttribute("role", "region");
  11086. this.l10n.get("page_landmark", {
  11087. page: this.id
  11088. }).then(msg => {
  11089. div.setAttribute("aria-label", msg);
  11090. });
  11091. this.div = div;
  11092. _classPrivateMethodGet(this, _setDimensions, _setDimensions2).call(this);
  11093. container === null || container === void 0 ? void 0 : container.append(div);
  11094. if (this._isStandalone) {
  11095. container === null || container === void 0 ? void 0 : container.style.setProperty("--scale-factor", this.scale * _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS);
  11096. const {
  11097. optionalContentConfigPromise
  11098. } = options;
  11099. if (optionalContentConfigPromise) {
  11100. optionalContentConfigPromise.then(optionalContentConfig => {
  11101. if (optionalContentConfigPromise !== this._optionalContentConfigPromise) {
  11102. return;
  11103. }
  11104. _classPrivateFieldGet(this, _useThumbnailCanvas).initialOptionalContent = optionalContentConfig.hasInitialVisibility;
  11105. });
  11106. }
  11107. }
  11108. }
  11109. get renderingState() {
  11110. return _classPrivateFieldGet(this, _renderingState);
  11111. }
  11112. set renderingState(state) {
  11113. if (state === _classPrivateFieldGet(this, _renderingState)) {
  11114. return;
  11115. }
  11116. _classPrivateFieldSet(this, _renderingState, state);
  11117. if (_classPrivateFieldGet(this, _loadingId)) {
  11118. clearTimeout(_classPrivateFieldGet(this, _loadingId));
  11119. _classPrivateFieldSet(this, _loadingId, null);
  11120. }
  11121. switch (state) {
  11122. case _ui_utils.RenderingStates.PAUSED:
  11123. this.div.classList.remove("loading");
  11124. break;
  11125. case _ui_utils.RenderingStates.RUNNING:
  11126. this.div.classList.add("loadingIcon");
  11127. _classPrivateFieldSet(this, _loadingId, setTimeout(() => {
  11128. this.div.classList.add("loading");
  11129. _classPrivateFieldSet(this, _loadingId, null);
  11130. }, 0));
  11131. break;
  11132. case _ui_utils.RenderingStates.INITIAL:
  11133. case _ui_utils.RenderingStates.FINISHED:
  11134. this.div.classList.remove("loadingIcon", "loading");
  11135. break;
  11136. }
  11137. }
  11138. setPdfPage(pdfPage) {
  11139. this.pdfPage = pdfPage;
  11140. this.pdfPageRotate = pdfPage.rotate;
  11141. const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  11142. this.viewport = pdfPage.getViewport({
  11143. scale: this.scale * _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS,
  11144. rotation: totalRotation
  11145. });
  11146. _classPrivateMethodGet(this, _setDimensions, _setDimensions2).call(this);
  11147. this.reset();
  11148. }
  11149. destroy() {
  11150. var _this$pdfPage;
  11151. this.reset();
  11152. (_this$pdfPage = this.pdfPage) === null || _this$pdfPage === void 0 ? void 0 : _this$pdfPage.cleanup();
  11153. }
  11154. get _textHighlighter() {
  11155. return (0, _pdfjsLib.shadow)(this, "_textHighlighter", new _text_highlighter.TextHighlighter({
  11156. pageIndex: this.id - 1,
  11157. eventBus: this.eventBus,
  11158. findController: _classPrivateFieldGet(this, _layerProperties).call(this).findController
  11159. }));
  11160. }
  11161. _resetZoomLayer() {
  11162. let removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  11163. if (!this.zoomLayer) {
  11164. return;
  11165. }
  11166. const zoomLayerCanvas = this.zoomLayer.firstChild;
  11167. this.paintedViewportMap.delete(zoomLayerCanvas);
  11168. zoomLayerCanvas.width = 0;
  11169. zoomLayerCanvas.height = 0;
  11170. if (removeFromDOM) {
  11171. this.zoomLayer.remove();
  11172. }
  11173. this.zoomLayer = null;
  11174. }
  11175. reset() {
  11176. var _this$annotationLayer, _this$annotationEdito, _this$xfaLayer, _this$textLayer, _this$structTreeLayer;
  11177. let {
  11178. keepZoomLayer = false,
  11179. keepAnnotationLayer = false,
  11180. keepAnnotationEditorLayer = false,
  11181. keepXfaLayer = false,
  11182. keepTextLayer = false
  11183. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  11184. this.cancelRendering({
  11185. keepAnnotationLayer,
  11186. keepAnnotationEditorLayer,
  11187. keepXfaLayer,
  11188. keepTextLayer
  11189. });
  11190. this.renderingState = _ui_utils.RenderingStates.INITIAL;
  11191. const div = this.div;
  11192. const childNodes = div.childNodes,
  11193. zoomLayerNode = keepZoomLayer && this.zoomLayer || null,
  11194. annotationLayerNode = keepAnnotationLayer && ((_this$annotationLayer = this.annotationLayer) === null || _this$annotationLayer === void 0 ? void 0 : _this$annotationLayer.div) || null,
  11195. annotationEditorLayerNode = keepAnnotationEditorLayer && ((_this$annotationEdito = this.annotationEditorLayer) === null || _this$annotationEdito === void 0 ? void 0 : _this$annotationEdito.div) || null,
  11196. xfaLayerNode = keepXfaLayer && ((_this$xfaLayer = this.xfaLayer) === null || _this$xfaLayer === void 0 ? void 0 : _this$xfaLayer.div) || null,
  11197. textLayerNode = keepTextLayer && ((_this$textLayer = this.textLayer) === null || _this$textLayer === void 0 ? void 0 : _this$textLayer.div) || null;
  11198. for (let i = childNodes.length - 1; i >= 0; i--) {
  11199. const node = childNodes[i];
  11200. switch (node) {
  11201. case zoomLayerNode:
  11202. case annotationLayerNode:
  11203. case annotationEditorLayerNode:
  11204. case xfaLayerNode:
  11205. case textLayerNode:
  11206. continue;
  11207. }
  11208. node.remove();
  11209. }
  11210. div.removeAttribute("data-loaded");
  11211. if (annotationLayerNode) {
  11212. this.annotationLayer.hide();
  11213. }
  11214. if (annotationEditorLayerNode) {
  11215. this.annotationEditorLayer.hide();
  11216. }
  11217. if (xfaLayerNode) {
  11218. this.xfaLayer.hide();
  11219. }
  11220. if (textLayerNode) {
  11221. this.textLayer.hide();
  11222. }
  11223. (_this$structTreeLayer = this.structTreeLayer) === null || _this$structTreeLayer === void 0 ? void 0 : _this$structTreeLayer.hide();
  11224. if (!zoomLayerNode) {
  11225. if (this.canvas) {
  11226. this.paintedViewportMap.delete(this.canvas);
  11227. this.canvas.width = 0;
  11228. this.canvas.height = 0;
  11229. delete this.canvas;
  11230. }
  11231. this._resetZoomLayer();
  11232. }
  11233. if (this.svg) {
  11234. this.paintedViewportMap.delete(this.svg);
  11235. delete this.svg;
  11236. }
  11237. }
  11238. update(_ref) {
  11239. let {
  11240. scale = 0,
  11241. rotation = null,
  11242. optionalContentConfigPromise = null,
  11243. drawingDelay = -1
  11244. } = _ref;
  11245. this.scale = scale || this.scale;
  11246. if (typeof rotation === "number") {
  11247. this.rotation = rotation;
  11248. }
  11249. if (optionalContentConfigPromise instanceof Promise) {
  11250. this._optionalContentConfigPromise = optionalContentConfigPromise;
  11251. optionalContentConfigPromise.then(optionalContentConfig => {
  11252. if (optionalContentConfigPromise !== this._optionalContentConfigPromise) {
  11253. return;
  11254. }
  11255. _classPrivateFieldGet(this, _useThumbnailCanvas).initialOptionalContent = optionalContentConfig.hasInitialVisibility;
  11256. });
  11257. }
  11258. const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  11259. this.viewport = this.viewport.clone({
  11260. scale: this.scale * _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS,
  11261. rotation: totalRotation
  11262. });
  11263. _classPrivateMethodGet(this, _setDimensions, _setDimensions2).call(this);
  11264. if (this._isStandalone) {
  11265. var _this$div$parentNode;
  11266. (_this$div$parentNode = this.div.parentNode) === null || _this$div$parentNode === void 0 ? void 0 : _this$div$parentNode.style.setProperty("--scale-factor", this.viewport.scale);
  11267. }
  11268. if (this.svg) {
  11269. this.cssTransform({
  11270. target: this.svg,
  11271. redrawAnnotationLayer: true,
  11272. redrawAnnotationEditorLayer: true,
  11273. redrawXfaLayer: true,
  11274. redrawTextLayer: true
  11275. });
  11276. this.eventBus.dispatch("pagerendered", {
  11277. source: this,
  11278. pageNumber: this.id,
  11279. cssTransform: true,
  11280. timestamp: performance.now(),
  11281. error: this._renderError
  11282. });
  11283. return;
  11284. }
  11285. let isScalingRestricted = false;
  11286. if (this.canvas && this.maxCanvasPixels > 0) {
  11287. const outputScale = this.outputScale;
  11288. if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > this.maxCanvasPixels) {
  11289. isScalingRestricted = true;
  11290. }
  11291. }
  11292. const postponeDrawing = drawingDelay >= 0 && drawingDelay < 1000;
  11293. if (this.canvas) {
  11294. if (postponeDrawing || this.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
  11295. if (postponeDrawing && this.renderingState !== _ui_utils.RenderingStates.FINISHED) {
  11296. this.cancelRendering({
  11297. keepZoomLayer: true,
  11298. keepAnnotationLayer: true,
  11299. keepAnnotationEditorLayer: true,
  11300. keepXfaLayer: true,
  11301. keepTextLayer: true,
  11302. cancelExtraDelay: drawingDelay
  11303. });
  11304. this.renderingState = _ui_utils.RenderingStates.FINISHED;
  11305. }
  11306. this.cssTransform({
  11307. target: this.canvas,
  11308. redrawAnnotationLayer: true,
  11309. redrawAnnotationEditorLayer: true,
  11310. redrawXfaLayer: true,
  11311. redrawTextLayer: !postponeDrawing,
  11312. hideTextLayer: postponeDrawing
  11313. });
  11314. this.eventBus.dispatch("pagerendered", {
  11315. source: this,
  11316. pageNumber: this.id,
  11317. cssTransform: true,
  11318. timestamp: performance.now(),
  11319. error: this._renderError
  11320. });
  11321. return;
  11322. }
  11323. if (!this.zoomLayer && !this.canvas.hidden) {
  11324. this.zoomLayer = this.canvas.parentNode;
  11325. this.zoomLayer.style.position = "absolute";
  11326. }
  11327. }
  11328. if (this.zoomLayer) {
  11329. this.cssTransform({
  11330. target: this.zoomLayer.firstChild
  11331. });
  11332. }
  11333. this.reset({
  11334. keepZoomLayer: true,
  11335. keepAnnotationLayer: true,
  11336. keepAnnotationEditorLayer: true,
  11337. keepXfaLayer: true,
  11338. keepTextLayer: true
  11339. });
  11340. }
  11341. cancelRendering() {
  11342. let {
  11343. keepAnnotationLayer = false,
  11344. keepAnnotationEditorLayer = false,
  11345. keepXfaLayer = false,
  11346. keepTextLayer = false,
  11347. cancelExtraDelay = 0
  11348. } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  11349. if (this.paintTask) {
  11350. this.paintTask.cancel(cancelExtraDelay);
  11351. this.paintTask = null;
  11352. }
  11353. this.resume = null;
  11354. if (this.textLayer && (!keepTextLayer || !this.textLayer.div)) {
  11355. this.textLayer.cancel();
  11356. this.textLayer = null;
  11357. }
  11358. if (this.structTreeLayer && !this.textLayer) {
  11359. this.structTreeLayer = null;
  11360. }
  11361. if (this.annotationLayer && (!keepAnnotationLayer || !this.annotationLayer.div)) {
  11362. this.annotationLayer.cancel();
  11363. this.annotationLayer = null;
  11364. this._annotationCanvasMap = null;
  11365. }
  11366. if (this.annotationEditorLayer && (!keepAnnotationEditorLayer || !this.annotationEditorLayer.div)) {
  11367. this.annotationEditorLayer.cancel();
  11368. this.annotationEditorLayer = null;
  11369. }
  11370. if (this.xfaLayer && (!keepXfaLayer || !this.xfaLayer.div)) {
  11371. var _this$_textHighlighte;
  11372. this.xfaLayer.cancel();
  11373. this.xfaLayer = null;
  11374. (_this$_textHighlighte = this._textHighlighter) === null || _this$_textHighlighte === void 0 ? void 0 : _this$_textHighlighte.disable();
  11375. }
  11376. }
  11377. cssTransform(_ref2) {
  11378. let {
  11379. target,
  11380. redrawAnnotationLayer = false,
  11381. redrawAnnotationEditorLayer = false,
  11382. redrawXfaLayer = false,
  11383. redrawTextLayer = false,
  11384. hideTextLayer = false
  11385. } = _ref2;
  11386. if (target instanceof HTMLCanvasElement) {
  11387. if (!target.hasAttribute("zooming")) {
  11388. target.setAttribute("zooming", true);
  11389. const {
  11390. style
  11391. } = target;
  11392. style.width = style.height = "";
  11393. }
  11394. } else {
  11395. const div = this.div;
  11396. const {
  11397. width,
  11398. height
  11399. } = this.viewport;
  11400. target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + "px";
  11401. target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + "px";
  11402. }
  11403. const originalViewport = this.paintedViewportMap.get(target);
  11404. if (this.viewport !== originalViewport) {
  11405. const relativeRotation = this.viewport.rotation - originalViewport.rotation;
  11406. const absRotation = Math.abs(relativeRotation);
  11407. let scaleX = 1,
  11408. scaleY = 1;
  11409. if (absRotation === 90 || absRotation === 270) {
  11410. const {
  11411. width,
  11412. height
  11413. } = this.viewport;
  11414. scaleX = height / width;
  11415. scaleY = width / height;
  11416. }
  11417. if (absRotation !== 0) {
  11418. target.style.transform = `rotate(${relativeRotation}deg) scale(${scaleX}, ${scaleY})`;
  11419. }
  11420. }
  11421. if (redrawAnnotationLayer && this.annotationLayer) {
  11422. _classPrivateMethodGet(this, _renderAnnotationLayer, _renderAnnotationLayer2).call(this);
  11423. }
  11424. if (redrawAnnotationEditorLayer && this.annotationEditorLayer) {
  11425. _classPrivateMethodGet(this, _renderAnnotationEditorLayer, _renderAnnotationEditorLayer2).call(this);
  11426. }
  11427. if (redrawXfaLayer && this.xfaLayer) {
  11428. _classPrivateMethodGet(this, _renderXfaLayer, _renderXfaLayer2).call(this);
  11429. }
  11430. if (this.textLayer) {
  11431. if (hideTextLayer) {
  11432. var _this$structTreeLayer2;
  11433. this.textLayer.hide();
  11434. (_this$structTreeLayer2 = this.structTreeLayer) === null || _this$structTreeLayer2 === void 0 ? void 0 : _this$structTreeLayer2.hide();
  11435. } else if (redrawTextLayer) {
  11436. _classPrivateMethodGet(this, _renderTextLayer, _renderTextLayer2).call(this);
  11437. }
  11438. }
  11439. }
  11440. get width() {
  11441. return this.viewport.width;
  11442. }
  11443. get height() {
  11444. return this.viewport.height;
  11445. }
  11446. getPagePoint(x, y) {
  11447. return this.viewport.convertToPdfPoint(x, y);
  11448. }
  11449. draw() {
  11450. var _this = this;
  11451. if (this.renderingState !== _ui_utils.RenderingStates.INITIAL) {
  11452. console.error("Must be in new state before drawing");
  11453. this.reset();
  11454. }
  11455. const {
  11456. div,
  11457. pdfPage
  11458. } = this;
  11459. if (!pdfPage) {
  11460. this.renderingState = _ui_utils.RenderingStates.FINISHED;
  11461. return Promise.reject(new Error("pdfPage is not loaded"));
  11462. }
  11463. this.renderingState = _ui_utils.RenderingStates.RUNNING;
  11464. const canvasWrapper = document.createElement("div");
  11465. canvasWrapper.classList.add("canvasWrapper");
  11466. div.append(canvasWrapper);
  11467. if (!this.textLayer && this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && !pdfPage.isPureXfa) {
  11468. this._accessibilityManager || (this._accessibilityManager = new _text_accessibility.TextAccessibilityManager());
  11469. this.textLayer = new _text_layer_builder.TextLayerBuilder({
  11470. highlighter: this._textHighlighter,
  11471. accessibilityManager: this._accessibilityManager,
  11472. isOffscreenCanvasSupported: this.isOffscreenCanvasSupported
  11473. });
  11474. div.append(this.textLayer.div);
  11475. }
  11476. if (!this.annotationLayer && _classPrivateFieldGet(this, _annotationMode) !== _pdfjsLib.AnnotationMode.DISABLE) {
  11477. const {
  11478. annotationStorage,
  11479. downloadManager,
  11480. enableScripting,
  11481. fieldObjectsPromise,
  11482. hasJSActionsPromise,
  11483. linkService
  11484. } = _classPrivateFieldGet(this, _layerProperties).call(this);
  11485. this._annotationCanvasMap || (this._annotationCanvasMap = new Map());
  11486. this.annotationLayer = new _annotation_layer_builder.AnnotationLayerBuilder({
  11487. pageDiv: div,
  11488. pdfPage,
  11489. annotationStorage,
  11490. imageResourcesPath: this.imageResourcesPath,
  11491. renderForms: _classPrivateFieldGet(this, _annotationMode) === _pdfjsLib.AnnotationMode.ENABLE_FORMS,
  11492. linkService,
  11493. downloadManager,
  11494. l10n: this.l10n,
  11495. enableScripting,
  11496. hasJSActionsPromise,
  11497. fieldObjectsPromise,
  11498. annotationCanvasMap: this._annotationCanvasMap,
  11499. accessibilityManager: this._accessibilityManager
  11500. });
  11501. }
  11502. let renderContinueCallback = null;
  11503. if (this.renderingQueue) {
  11504. renderContinueCallback = cont => {
  11505. if (!this.renderingQueue.isHighestPriority(this)) {
  11506. this.renderingState = _ui_utils.RenderingStates.PAUSED;
  11507. this.resume = () => {
  11508. this.renderingState = _ui_utils.RenderingStates.RUNNING;
  11509. cont();
  11510. };
  11511. return;
  11512. }
  11513. cont();
  11514. };
  11515. }
  11516. const finishPaintTask = async function () {
  11517. let error = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  11518. if (paintTask === _this.paintTask) {
  11519. _this.paintTask = null;
  11520. }
  11521. if (error instanceof _pdfjsLib.RenderingCancelledException) {
  11522. _this._renderError = null;
  11523. return;
  11524. }
  11525. _this._renderError = error;
  11526. _this.renderingState = _ui_utils.RenderingStates.FINISHED;
  11527. _this._resetZoomLayer(true);
  11528. _classPrivateFieldGet(_this, _useThumbnailCanvas).regularAnnotations = !paintTask.separateAnnots;
  11529. _this.eventBus.dispatch("pagerendered", {
  11530. source: _this,
  11531. pageNumber: _this.id,
  11532. cssTransform: false,
  11533. timestamp: performance.now(),
  11534. error: _this._renderError
  11535. });
  11536. if (error) {
  11537. throw error;
  11538. }
  11539. };
  11540. const paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
  11541. paintTask.onRenderContinue = renderContinueCallback;
  11542. this.paintTask = paintTask;
  11543. const resultPromise = paintTask.promise.then(() => {
  11544. return finishPaintTask(null).then(async () => {
  11545. _classPrivateMethodGet(this, _renderTextLayer, _renderTextLayer2).call(this);
  11546. if (this.annotationLayer) {
  11547. await _classPrivateMethodGet(this, _renderAnnotationLayer, _renderAnnotationLayer2).call(this);
  11548. }
  11549. if (!this.annotationEditorLayer) {
  11550. const {
  11551. annotationEditorUIManager
  11552. } = _classPrivateFieldGet(this, _layerProperties).call(this);
  11553. if (!annotationEditorUIManager) {
  11554. return;
  11555. }
  11556. this.annotationEditorLayer = new _annotation_editor_layer_builder.AnnotationEditorLayerBuilder({
  11557. uiManager: annotationEditorUIManager,
  11558. pageDiv: div,
  11559. pdfPage,
  11560. l10n: this.l10n,
  11561. accessibilityManager: this._accessibilityManager
  11562. });
  11563. }
  11564. _classPrivateMethodGet(this, _renderAnnotationEditorLayer, _renderAnnotationEditorLayer2).call(this);
  11565. });
  11566. }, function (reason) {
  11567. return finishPaintTask(reason);
  11568. });
  11569. if (pdfPage.isPureXfa) {
  11570. if (!this.xfaLayer) {
  11571. const {
  11572. annotationStorage,
  11573. linkService
  11574. } = _classPrivateFieldGet(this, _layerProperties).call(this);
  11575. this.xfaLayer = new _xfa_layer_builder.XfaLayerBuilder({
  11576. pageDiv: div,
  11577. pdfPage,
  11578. annotationStorage,
  11579. linkService
  11580. });
  11581. } else if (this.xfaLayer.div) {
  11582. div.append(this.xfaLayer.div);
  11583. }
  11584. _classPrivateMethodGet(this, _renderXfaLayer, _renderXfaLayer2).call(this);
  11585. }
  11586. div.setAttribute("data-loaded", true);
  11587. this.eventBus.dispatch("pagerender", {
  11588. source: this,
  11589. pageNumber: this.id
  11590. });
  11591. return resultPromise;
  11592. }
  11593. paintOnCanvas(canvasWrapper) {
  11594. const renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  11595. const result = {
  11596. promise: renderCapability.promise,
  11597. onRenderContinue(cont) {
  11598. cont();
  11599. },
  11600. cancel() {
  11601. let extraDelay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  11602. renderTask.cancel(extraDelay);
  11603. },
  11604. get separateAnnots() {
  11605. return renderTask.separateAnnots;
  11606. }
  11607. };
  11608. const viewport = this.viewport;
  11609. const {
  11610. width,
  11611. height
  11612. } = viewport;
  11613. const canvas = document.createElement("canvas");
  11614. canvas.setAttribute("role", "presentation");
  11615. canvas.hidden = true;
  11616. let isCanvasHidden = true;
  11617. const showCanvas = function () {
  11618. if (isCanvasHidden) {
  11619. canvas.hidden = false;
  11620. isCanvasHidden = false;
  11621. }
  11622. };
  11623. canvasWrapper.append(canvas);
  11624. this.canvas = canvas;
  11625. const ctx = canvas.getContext("2d", {
  11626. alpha: false
  11627. });
  11628. const outputScale = this.outputScale = new _ui_utils.OutputScale();
  11629. if (this.useOnlyCssZoom) {
  11630. const actualSizeViewport = viewport.clone({
  11631. scale: _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS
  11632. });
  11633. outputScale.sx *= actualSizeViewport.width / width;
  11634. outputScale.sy *= actualSizeViewport.height / height;
  11635. }
  11636. if (this.maxCanvasPixels > 0) {
  11637. const pixelsInViewport = width * height;
  11638. const maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
  11639. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  11640. outputScale.sx = maxScale;
  11641. outputScale.sy = maxScale;
  11642. this.hasRestrictedScaling = true;
  11643. } else {
  11644. this.hasRestrictedScaling = false;
  11645. }
  11646. }
  11647. const sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  11648. const sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  11649. canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
  11650. canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
  11651. const {
  11652. style
  11653. } = canvas;
  11654. style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + "px";
  11655. style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + "px";
  11656. this.paintedViewportMap.set(canvas, viewport);
  11657. const transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null;
  11658. const renderContext = {
  11659. canvasContext: ctx,
  11660. transform,
  11661. viewport,
  11662. annotationMode: _classPrivateFieldGet(this, _annotationMode),
  11663. optionalContentConfigPromise: this._optionalContentConfigPromise,
  11664. annotationCanvasMap: this._annotationCanvasMap,
  11665. pageColors: this.pageColors
  11666. };
  11667. const renderTask = this.pdfPage.render(renderContext);
  11668. renderTask.onContinue = function (cont) {
  11669. showCanvas();
  11670. if (result.onRenderContinue) {
  11671. result.onRenderContinue(cont);
  11672. } else {
  11673. cont();
  11674. }
  11675. };
  11676. renderTask.promise.then(function () {
  11677. showCanvas();
  11678. renderCapability.resolve();
  11679. }, function (error) {
  11680. if (!(error instanceof _pdfjsLib.RenderingCancelledException)) {
  11681. showCanvas();
  11682. }
  11683. renderCapability.reject(error);
  11684. });
  11685. return result;
  11686. }
  11687. paintOnSvg(wrapper) {
  11688. let cancelled = false;
  11689. const ensureNotCancelled = () => {
  11690. if (cancelled) {
  11691. throw new _pdfjsLib.RenderingCancelledException(`Rendering cancelled, page ${this.id}`, "svg");
  11692. }
  11693. };
  11694. const pdfPage = this.pdfPage;
  11695. const actualSizeViewport = this.viewport.clone({
  11696. scale: _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS
  11697. });
  11698. const promise = pdfPage.getOperatorList({
  11699. annotationMode: _classPrivateFieldGet(this, _annotationMode)
  11700. }).then(opList => {
  11701. ensureNotCancelled();
  11702. const svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
  11703. return svgGfx.getSVG(opList, actualSizeViewport).then(svg => {
  11704. ensureNotCancelled();
  11705. this.svg = svg;
  11706. this.paintedViewportMap.set(svg, actualSizeViewport);
  11707. svg.style.width = wrapper.style.width;
  11708. svg.style.height = wrapper.style.height;
  11709. this.renderingState = _ui_utils.RenderingStates.FINISHED;
  11710. wrapper.append(svg);
  11711. });
  11712. });
  11713. return {
  11714. promise,
  11715. onRenderContinue(cont) {
  11716. cont();
  11717. },
  11718. cancel() {
  11719. cancelled = true;
  11720. },
  11721. get separateAnnots() {
  11722. return false;
  11723. }
  11724. };
  11725. }
  11726. setPageLabel(label) {
  11727. this.pageLabel = typeof label === "string" ? label : null;
  11728. if (this.pageLabel !== null) {
  11729. this.div.setAttribute("data-page-label", this.pageLabel);
  11730. } else {
  11731. this.div.removeAttribute("data-page-label");
  11732. }
  11733. }
  11734. get thumbnailCanvas() {
  11735. const {
  11736. initialOptionalContent,
  11737. regularAnnotations
  11738. } = _classPrivateFieldGet(this, _useThumbnailCanvas);
  11739. return initialOptionalContent && regularAnnotations ? this.canvas : null;
  11740. }
  11741. }
  11742. exports.PDFPageView = PDFPageView;
  11743. function _setDimensions2() {
  11744. const {
  11745. viewport
  11746. } = this;
  11747. if (this.pdfPage) {
  11748. if (_classPrivateFieldGet(this, _previousRotation) === viewport.rotation) {
  11749. return;
  11750. }
  11751. _classPrivateFieldSet(this, _previousRotation, viewport.rotation);
  11752. }
  11753. (0, _pdfjsLib.setLayerDimensions)(this.div, viewport, true, false);
  11754. }
  11755. async function _renderAnnotationLayer2() {
  11756. let error = null;
  11757. try {
  11758. await this.annotationLayer.render(this.viewport, "display");
  11759. } catch (ex) {
  11760. console.error(`#renderAnnotationLayer: "${ex}".`);
  11761. error = ex;
  11762. } finally {
  11763. this.eventBus.dispatch("annotationlayerrendered", {
  11764. source: this,
  11765. pageNumber: this.id,
  11766. error
  11767. });
  11768. }
  11769. }
  11770. async function _renderAnnotationEditorLayer2() {
  11771. let error = null;
  11772. try {
  11773. await this.annotationEditorLayer.render(this.viewport, "display");
  11774. } catch (ex) {
  11775. console.error(`#renderAnnotationEditorLayer: "${ex}".`);
  11776. error = ex;
  11777. } finally {
  11778. this.eventBus.dispatch("annotationeditorlayerrendered", {
  11779. source: this,
  11780. pageNumber: this.id,
  11781. error
  11782. });
  11783. }
  11784. }
  11785. async function _renderXfaLayer2() {
  11786. let error = null;
  11787. try {
  11788. const result = await this.xfaLayer.render(this.viewport, "display");
  11789. if (result !== null && result !== void 0 && result.textDivs && this._textHighlighter) {
  11790. _classPrivateMethodGet(this, _buildXfaTextContentItems, _buildXfaTextContentItems2).call(this, result.textDivs);
  11791. }
  11792. } catch (ex) {
  11793. console.error(`#renderXfaLayer: "${ex}".`);
  11794. error = ex;
  11795. } finally {
  11796. this.eventBus.dispatch("xfalayerrendered", {
  11797. source: this,
  11798. pageNumber: this.id,
  11799. error
  11800. });
  11801. }
  11802. }
  11803. async function _renderTextLayer2() {
  11804. const {
  11805. pdfPage,
  11806. textLayer,
  11807. viewport
  11808. } = this;
  11809. if (!textLayer) {
  11810. return;
  11811. }
  11812. let error = null;
  11813. try {
  11814. if (!textLayer.renderingDone) {
  11815. const readableStream = pdfPage.streamTextContent({
  11816. includeMarkedContent: true
  11817. });
  11818. textLayer.setTextContentSource(readableStream);
  11819. }
  11820. await textLayer.render(viewport);
  11821. } catch (ex) {
  11822. if (ex instanceof _pdfjsLib.AbortException) {
  11823. return;
  11824. }
  11825. console.error(`#renderTextLayer: "${ex}".`);
  11826. error = ex;
  11827. }
  11828. this.eventBus.dispatch("textlayerrendered", {
  11829. source: this,
  11830. pageNumber: this.id,
  11831. numTextDivs: textLayer.numTextDivs,
  11832. error
  11833. });
  11834. _classPrivateMethodGet(this, _renderStructTreeLayer, _renderStructTreeLayer2).call(this);
  11835. }
  11836. async function _renderStructTreeLayer2() {
  11837. var _this$structTreeLayer3, _this$structTreeLayer4;
  11838. if (!this.textLayer) {
  11839. return;
  11840. }
  11841. this.structTreeLayer || (this.structTreeLayer = new _struct_tree_layer_builder.StructTreeLayerBuilder());
  11842. const tree = await (!this.structTreeLayer.renderingDone ? this.pdfPage.getStructTree() : null);
  11843. const treeDom = (_this$structTreeLayer3 = this.structTreeLayer) === null || _this$structTreeLayer3 === void 0 ? void 0 : _this$structTreeLayer3.render(tree);
  11844. if (treeDom) {
  11845. var _this$canvas;
  11846. (_this$canvas = this.canvas) === null || _this$canvas === void 0 ? void 0 : _this$canvas.append(treeDom);
  11847. }
  11848. (_this$structTreeLayer4 = this.structTreeLayer) === null || _this$structTreeLayer4 === void 0 ? void 0 : _this$structTreeLayer4.show();
  11849. }
  11850. async function _buildXfaTextContentItems2(textDivs) {
  11851. const text = await this.pdfPage.getTextContent();
  11852. const items = [];
  11853. for (const item of text.items) {
  11854. items.push(item.str);
  11855. }
  11856. this._textHighlighter.setTextMapping(textDivs, items);
  11857. this._textHighlighter.enable();
  11858. }
  11859. /***/
  11860. }),
  11861. /* 33 */
  11862. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  11863. Object.defineProperty(exports, "__esModule", ({
  11864. value: true
  11865. }));
  11866. exports.AnnotationEditorLayerBuilder = void 0;
  11867. var _pdfjsLib = __webpack_require__(4);
  11868. var _l10n_utils = __webpack_require__(31);
  11869. class AnnotationEditorLayerBuilder {
  11870. #uiManager;
  11871. constructor(options) {
  11872. this.pageDiv = options.pageDiv;
  11873. this.pdfPage = options.pdfPage;
  11874. this.accessibilityManager = options.accessibilityManager;
  11875. this.l10n = options.l10n || _l10n_utils.NullL10n;
  11876. this.annotationEditorLayer = null;
  11877. this.div = null;
  11878. this._cancelled = false;
  11879. this.#uiManager = options.uiManager;
  11880. }
  11881. async render(viewport) {
  11882. let intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "display";
  11883. if (intent !== "display") {
  11884. return;
  11885. }
  11886. if (this._cancelled) {
  11887. return;
  11888. }
  11889. const clonedViewport = viewport.clone({
  11890. dontFlip: true
  11891. });
  11892. if (this.div) {
  11893. this.annotationEditorLayer.update({
  11894. viewport: clonedViewport
  11895. });
  11896. this.show();
  11897. return;
  11898. }
  11899. const div = this.div = document.createElement("div");
  11900. div.className = "annotationEditorLayer";
  11901. div.tabIndex = 0;
  11902. div.hidden = true;
  11903. this.pageDiv.append(div);
  11904. this.annotationEditorLayer = new _pdfjsLib.AnnotationEditorLayer({
  11905. uiManager: this.#uiManager,
  11906. div,
  11907. accessibilityManager: this.accessibilityManager,
  11908. pageIndex: this.pdfPage.pageNumber - 1,
  11909. l10n: this.l10n,
  11910. viewport: clonedViewport
  11911. });
  11912. const parameters = {
  11913. viewport: clonedViewport,
  11914. div,
  11915. annotations: null,
  11916. intent
  11917. };
  11918. this.annotationEditorLayer.render(parameters);
  11919. this.show();
  11920. }
  11921. cancel() {
  11922. this._cancelled = true;
  11923. if (!this.div) {
  11924. return;
  11925. }
  11926. this.pageDiv = null;
  11927. this.annotationEditorLayer.destroy();
  11928. this.div.remove();
  11929. }
  11930. hide() {
  11931. if (!this.div) {
  11932. return;
  11933. }
  11934. this.div.hidden = true;
  11935. }
  11936. show() {
  11937. if (!this.div || this.annotationEditorLayer.isEmpty) {
  11938. return;
  11939. }
  11940. this.div.hidden = false;
  11941. }
  11942. }
  11943. exports.AnnotationEditorLayerBuilder = AnnotationEditorLayerBuilder;
  11944. /***/
  11945. }),
  11946. /* 34 */
  11947. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  11948. Object.defineProperty(exports, "__esModule", ({
  11949. value: true
  11950. }));
  11951. exports.AnnotationLayerBuilder = void 0;
  11952. var _pdfjsLib = __webpack_require__(4);
  11953. var _l10n_utils = __webpack_require__(31);
  11954. var _ui_utils = __webpack_require__(3);
  11955. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  11956. function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
  11957. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  11958. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  11959. function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
  11960. function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
  11961. function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
  11962. function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
  11963. function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
  11964. var _numAnnotations = /*#__PURE__*/new WeakMap();
  11965. var _onPresentationModeChanged = /*#__PURE__*/new WeakMap();
  11966. var _updatePresentationModeState = /*#__PURE__*/new WeakSet();
  11967. class AnnotationLayerBuilder {
  11968. constructor(_ref) {
  11969. let {
  11970. pageDiv,
  11971. pdfPage,
  11972. linkService,
  11973. downloadManager,
  11974. annotationStorage = null,
  11975. imageResourcesPath = "",
  11976. renderForms = true,
  11977. l10n = _l10n_utils.NullL10n,
  11978. enableScripting = false,
  11979. hasJSActionsPromise = null,
  11980. fieldObjectsPromise = null,
  11981. annotationCanvasMap = null,
  11982. accessibilityManager = null
  11983. } = _ref;
  11984. _classPrivateMethodInitSpec(this, _updatePresentationModeState);
  11985. _classPrivateFieldInitSpec(this, _numAnnotations, {
  11986. writable: true,
  11987. value: 0
  11988. });
  11989. _classPrivateFieldInitSpec(this, _onPresentationModeChanged, {
  11990. writable: true,
  11991. value: null
  11992. });
  11993. this.pageDiv = pageDiv;
  11994. this.pdfPage = pdfPage;
  11995. this.linkService = linkService;
  11996. this.downloadManager = downloadManager;
  11997. this.imageResourcesPath = imageResourcesPath;
  11998. this.renderForms = renderForms;
  11999. this.l10n = l10n;
  12000. this.annotationStorage = annotationStorage;
  12001. this.enableScripting = enableScripting;
  12002. this._hasJSActionsPromise = hasJSActionsPromise || Promise.resolve(false);
  12003. this._fieldObjectsPromise = fieldObjectsPromise || Promise.resolve(null);
  12004. this._annotationCanvasMap = annotationCanvasMap;
  12005. this._accessibilityManager = accessibilityManager;
  12006. this.div = null;
  12007. this._cancelled = false;
  12008. this._eventBus = linkService.eventBus;
  12009. }
  12010. async render(viewport) {
  12011. let intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "display";
  12012. if (this.div) {
  12013. if (this._cancelled || _classPrivateFieldGet(this, _numAnnotations) === 0) {
  12014. return;
  12015. }
  12016. _pdfjsLib.AnnotationLayer.update({
  12017. viewport: viewport.clone({
  12018. dontFlip: true
  12019. }),
  12020. div: this.div,
  12021. annotationCanvasMap: this._annotationCanvasMap
  12022. });
  12023. return;
  12024. }
  12025. const [annotations, hasJSActions, fieldObjects] = await Promise.all([this.pdfPage.getAnnotations({
  12026. intent
  12027. }), this._hasJSActionsPromise, this._fieldObjectsPromise]);
  12028. if (this._cancelled) {
  12029. return;
  12030. }
  12031. _classPrivateFieldSet(this, _numAnnotations, annotations.length);
  12032. this.div = document.createElement("div");
  12033. this.div.className = "annotationLayer";
  12034. this.pageDiv.append(this.div);
  12035. if (_classPrivateFieldGet(this, _numAnnotations) === 0) {
  12036. this.hide();
  12037. return;
  12038. }
  12039. _pdfjsLib.AnnotationLayer.render({
  12040. viewport: viewport.clone({
  12041. dontFlip: true
  12042. }),
  12043. div: this.div,
  12044. annotations,
  12045. page: this.pdfPage,
  12046. imageResourcesPath: this.imageResourcesPath,
  12047. renderForms: this.renderForms,
  12048. linkService: this.linkService,
  12049. downloadManager: this.downloadManager,
  12050. annotationStorage: this.annotationStorage,
  12051. enableScripting: this.enableScripting,
  12052. hasJSActions,
  12053. fieldObjects,
  12054. annotationCanvasMap: this._annotationCanvasMap,
  12055. accessibilityManager: this._accessibilityManager
  12056. });
  12057. this.l10n.translate(this.div);
  12058. if (this.linkService.isInPresentationMode) {
  12059. _classPrivateMethodGet(this, _updatePresentationModeState, _updatePresentationModeState2).call(this, _ui_utils.PresentationModeState.FULLSCREEN);
  12060. }
  12061. if (!_classPrivateFieldGet(this, _onPresentationModeChanged)) {
  12062. var _this$_eventBus;
  12063. _classPrivateFieldSet(this, _onPresentationModeChanged, evt => {
  12064. _classPrivateMethodGet(this, _updatePresentationModeState, _updatePresentationModeState2).call(this, evt.state);
  12065. });
  12066. (_this$_eventBus = this._eventBus) === null || _this$_eventBus === void 0 ? void 0 : _this$_eventBus._on("presentationmodechanged", _classPrivateFieldGet(this, _onPresentationModeChanged));
  12067. }
  12068. }
  12069. cancel() {
  12070. this._cancelled = true;
  12071. if (_classPrivateFieldGet(this, _onPresentationModeChanged)) {
  12072. var _this$_eventBus2;
  12073. (_this$_eventBus2 = this._eventBus) === null || _this$_eventBus2 === void 0 ? void 0 : _this$_eventBus2._off("presentationmodechanged", _classPrivateFieldGet(this, _onPresentationModeChanged));
  12074. _classPrivateFieldSet(this, _onPresentationModeChanged, null);
  12075. }
  12076. }
  12077. hide() {
  12078. if (!this.div) {
  12079. return;
  12080. }
  12081. this.div.hidden = true;
  12082. }
  12083. }
  12084. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  12085. function _updatePresentationModeState2(state) {
  12086. if (!this.div) {
  12087. return;
  12088. }
  12089. let disableFormElements = false;
  12090. switch (state) {
  12091. case _ui_utils.PresentationModeState.FULLSCREEN:
  12092. disableFormElements = true;
  12093. break;
  12094. case _ui_utils.PresentationModeState.NORMAL:
  12095. break;
  12096. default:
  12097. return;
  12098. }
  12099. for (const section of this.div.childNodes) {
  12100. if (section.hasAttribute("data-internal-link")) {
  12101. continue;
  12102. }
  12103. section.inert = disableFormElements;
  12104. }
  12105. }
  12106. /***/
  12107. }),
  12108. /* 35 */
  12109. /***/ ((__unused_webpack_module, exports) => {
  12110. Object.defineProperty(exports, "__esModule", ({
  12111. value: true
  12112. }));
  12113. exports.StructTreeLayerBuilder = void 0;
  12114. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  12115. function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
  12116. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  12117. function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
  12118. function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
  12119. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  12120. function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
  12121. function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
  12122. function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
  12123. const PDF_ROLE_TO_HTML_ROLE = {
  12124. Document: null,
  12125. DocumentFragment: null,
  12126. Part: "group",
  12127. Sect: "group",
  12128. Div: "group",
  12129. Aside: "note",
  12130. NonStruct: "none",
  12131. P: null,
  12132. H: "heading",
  12133. Title: null,
  12134. FENote: "note",
  12135. Sub: "group",
  12136. Lbl: null,
  12137. Span: null,
  12138. Em: null,
  12139. Strong: null,
  12140. Link: "link",
  12141. Annot: "note",
  12142. Form: "form",
  12143. Ruby: null,
  12144. RB: null,
  12145. RT: null,
  12146. RP: null,
  12147. Warichu: null,
  12148. WT: null,
  12149. WP: null,
  12150. L: "list",
  12151. LI: "listitem",
  12152. LBody: null,
  12153. Table: "table",
  12154. TR: "row",
  12155. TH: "columnheader",
  12156. TD: "cell",
  12157. THead: "columnheader",
  12158. TBody: null,
  12159. TFoot: null,
  12160. Caption: null,
  12161. Figure: "figure",
  12162. Formula: null,
  12163. Artifact: null
  12164. };
  12165. const HEADING_PATTERN = /^H(\d+)$/;
  12166. var _treeDom = /*#__PURE__*/new WeakMap();
  12167. var _setAttributes = /*#__PURE__*/new WeakSet();
  12168. var _walk = /*#__PURE__*/new WeakSet();
  12169. class StructTreeLayerBuilder {
  12170. constructor() {
  12171. _classPrivateMethodInitSpec(this, _walk);
  12172. _classPrivateMethodInitSpec(this, _setAttributes);
  12173. _classPrivateFieldInitSpec(this, _treeDom, {
  12174. writable: true,
  12175. value: undefined
  12176. });
  12177. }
  12178. get renderingDone() {
  12179. return _classPrivateFieldGet(this, _treeDom) !== undefined;
  12180. }
  12181. render(structTree) {
  12182. if (_classPrivateFieldGet(this, _treeDom) !== undefined) {
  12183. return _classPrivateFieldGet(this, _treeDom);
  12184. }
  12185. const treeDom = _classPrivateMethodGet(this, _walk, _walk2).call(this, structTree);
  12186. treeDom === null || treeDom === void 0 ? void 0 : treeDom.classList.add("structTree");
  12187. return _classPrivateFieldSet(this, _treeDom, treeDom);
  12188. }
  12189. hide() {
  12190. if (_classPrivateFieldGet(this, _treeDom) && !_classPrivateFieldGet(this, _treeDom).hidden) {
  12191. _classPrivateFieldGet(this, _treeDom).hidden = true;
  12192. }
  12193. }
  12194. show() {
  12195. var _classPrivateFieldGet2;
  12196. if ((_classPrivateFieldGet2 = _classPrivateFieldGet(this, _treeDom)) !== null && _classPrivateFieldGet2 !== void 0 && _classPrivateFieldGet2.hidden) {
  12197. _classPrivateFieldGet(this, _treeDom).hidden = false;
  12198. }
  12199. }
  12200. }
  12201. exports.StructTreeLayerBuilder = StructTreeLayerBuilder;
  12202. function _setAttributes2(structElement, htmlElement) {
  12203. if (structElement.alt !== undefined) {
  12204. htmlElement.setAttribute("aria-label", structElement.alt);
  12205. }
  12206. if (structElement.id !== undefined) {
  12207. htmlElement.setAttribute("aria-owns", structElement.id);
  12208. }
  12209. if (structElement.lang !== undefined) {
  12210. htmlElement.setAttribute("lang", structElement.lang);
  12211. }
  12212. }
  12213. function _walk2(node) {
  12214. if (!node) {
  12215. return null;
  12216. }
  12217. const element = document.createElement("span");
  12218. if ("role" in node) {
  12219. const {
  12220. role
  12221. } = node;
  12222. const match = role.match(HEADING_PATTERN);
  12223. if (match) {
  12224. element.setAttribute("role", "heading");
  12225. element.setAttribute("aria-level", match[1]);
  12226. } else if (PDF_ROLE_TO_HTML_ROLE[role]) {
  12227. element.setAttribute("role", PDF_ROLE_TO_HTML_ROLE[role]);
  12228. }
  12229. }
  12230. _classPrivateMethodGet(this, _setAttributes, _setAttributes2).call(this, node, element);
  12231. if (node.children) {
  12232. if (node.children.length === 1 && "id" in node.children[0]) {
  12233. _classPrivateMethodGet(this, _setAttributes, _setAttributes2).call(this, node.children[0], element);
  12234. } else {
  12235. for (const kid of node.children) {
  12236. element.append(_classPrivateMethodGet(this, _walk, _walk2).call(this, kid));
  12237. }
  12238. }
  12239. }
  12240. return element;
  12241. }
  12242. /***/
  12243. }),
  12244. /* 36 */
  12245. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  12246. Object.defineProperty(exports, "__esModule", ({
  12247. value: true
  12248. }));
  12249. exports.TextAccessibilityManager = void 0;
  12250. var _ui_utils = __webpack_require__(3);
  12251. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  12252. function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
  12253. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  12254. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  12255. function _classStaticPrivateMethodGet(receiver, classConstructor, method) { _classCheckPrivateStaticAccess(receiver, classConstructor); return method; }
  12256. function _classCheckPrivateStaticAccess(receiver, classConstructor) { if (receiver !== classConstructor) { throw new TypeError("Private static access of wrong provenance"); } }
  12257. function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
  12258. function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
  12259. function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
  12260. function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
  12261. function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
  12262. var _enabled = /*#__PURE__*/new WeakMap();
  12263. var _textChildren = /*#__PURE__*/new WeakMap();
  12264. var _textNodes = /*#__PURE__*/new WeakMap();
  12265. var _waitingElements = /*#__PURE__*/new WeakMap();
  12266. var _addIdToAriaOwns = /*#__PURE__*/new WeakSet();
  12267. class TextAccessibilityManager {
  12268. constructor() {
  12269. _classPrivateMethodInitSpec(this, _addIdToAriaOwns);
  12270. _classPrivateFieldInitSpec(this, _enabled, {
  12271. writable: true,
  12272. value: false
  12273. });
  12274. _classPrivateFieldInitSpec(this, _textChildren, {
  12275. writable: true,
  12276. value: null
  12277. });
  12278. _classPrivateFieldInitSpec(this, _textNodes, {
  12279. writable: true,
  12280. value: new Map()
  12281. });
  12282. _classPrivateFieldInitSpec(this, _waitingElements, {
  12283. writable: true,
  12284. value: new Map()
  12285. });
  12286. }
  12287. setTextMapping(textDivs) {
  12288. _classPrivateFieldSet(this, _textChildren, textDivs);
  12289. }
  12290. enable() {
  12291. if (_classPrivateFieldGet(this, _enabled)) {
  12292. throw new Error("TextAccessibilityManager is already enabled.");
  12293. }
  12294. if (!_classPrivateFieldGet(this, _textChildren)) {
  12295. throw new Error("Text divs and strings have not been set.");
  12296. }
  12297. _classPrivateFieldSet(this, _enabled, true);
  12298. _classPrivateFieldSet(this, _textChildren, _classPrivateFieldGet(this, _textChildren).slice());
  12299. _classPrivateFieldGet(this, _textChildren).sort(_classStaticPrivateMethodGet(TextAccessibilityManager, TextAccessibilityManager, _compareElementPositions));
  12300. if (_classPrivateFieldGet(this, _textNodes).size > 0) {
  12301. const textChildren = _classPrivateFieldGet(this, _textChildren);
  12302. for (const [id, nodeIndex] of _classPrivateFieldGet(this, _textNodes)) {
  12303. const element = document.getElementById(id);
  12304. if (!element) {
  12305. _classPrivateFieldGet(this, _textNodes).delete(id);
  12306. continue;
  12307. }
  12308. _classPrivateMethodGet(this, _addIdToAriaOwns, _addIdToAriaOwns2).call(this, id, textChildren[nodeIndex]);
  12309. }
  12310. }
  12311. for (const [element, isRemovable] of _classPrivateFieldGet(this, _waitingElements)) {
  12312. this.addPointerInTextLayer(element, isRemovable);
  12313. }
  12314. _classPrivateFieldGet(this, _waitingElements).clear();
  12315. }
  12316. disable() {
  12317. if (!_classPrivateFieldGet(this, _enabled)) {
  12318. return;
  12319. }
  12320. _classPrivateFieldGet(this, _waitingElements).clear();
  12321. _classPrivateFieldSet(this, _textChildren, null);
  12322. _classPrivateFieldSet(this, _enabled, false);
  12323. }
  12324. removePointerInTextLayer(element) {
  12325. var _owns;
  12326. if (!_classPrivateFieldGet(this, _enabled)) {
  12327. _classPrivateFieldGet(this, _waitingElements).delete(element);
  12328. return;
  12329. }
  12330. const children = _classPrivateFieldGet(this, _textChildren);
  12331. if (!children || children.length === 0) {
  12332. return;
  12333. }
  12334. const {
  12335. id
  12336. } = element;
  12337. const nodeIndex = _classPrivateFieldGet(this, _textNodes).get(id);
  12338. if (nodeIndex === undefined) {
  12339. return;
  12340. }
  12341. const node = children[nodeIndex];
  12342. _classPrivateFieldGet(this, _textNodes).delete(id);
  12343. let owns = node.getAttribute("aria-owns");
  12344. if ((_owns = owns) !== null && _owns !== void 0 && _owns.includes(id)) {
  12345. owns = owns.split(" ").filter(x => x !== id).join(" ");
  12346. if (owns) {
  12347. node.setAttribute("aria-owns", owns);
  12348. } else {
  12349. node.removeAttribute("aria-owns");
  12350. node.setAttribute("role", "presentation");
  12351. }
  12352. }
  12353. }
  12354. addPointerInTextLayer(element, isRemovable) {
  12355. const {
  12356. id
  12357. } = element;
  12358. if (!id) {
  12359. return;
  12360. }
  12361. if (!_classPrivateFieldGet(this, _enabled)) {
  12362. _classPrivateFieldGet(this, _waitingElements).set(element, isRemovable);
  12363. return;
  12364. }
  12365. if (isRemovable) {
  12366. this.removePointerInTextLayer(element);
  12367. }
  12368. const children = _classPrivateFieldGet(this, _textChildren);
  12369. if (!children || children.length === 0) {
  12370. return;
  12371. }
  12372. const index = (0, _ui_utils.binarySearchFirstItem)(children, node => _classStaticPrivateMethodGet(TextAccessibilityManager, TextAccessibilityManager, _compareElementPositions).call(TextAccessibilityManager, element, node) < 0);
  12373. const nodeIndex = Math.max(0, index - 1);
  12374. _classPrivateMethodGet(this, _addIdToAriaOwns, _addIdToAriaOwns2).call(this, id, children[nodeIndex]);
  12375. _classPrivateFieldGet(this, _textNodes).set(id, nodeIndex);
  12376. }
  12377. moveElementInDOM(container, element, contentElement, isRemovable) {
  12378. this.addPointerInTextLayer(contentElement, isRemovable);
  12379. if (!container.hasChildNodes()) {
  12380. container.append(element);
  12381. return;
  12382. }
  12383. const children = Array.from(container.childNodes).filter(node => node !== element);
  12384. if (children.length === 0) {
  12385. return;
  12386. }
  12387. const elementToCompare = contentElement || element;
  12388. const index = (0, _ui_utils.binarySearchFirstItem)(children, node => _classStaticPrivateMethodGet(TextAccessibilityManager, TextAccessibilityManager, _compareElementPositions).call(TextAccessibilityManager, elementToCompare, node) < 0);
  12389. if (index === 0) {
  12390. children[0].before(element);
  12391. } else {
  12392. children[index - 1].after(element);
  12393. }
  12394. }
  12395. }
  12396. exports.TextAccessibilityManager = TextAccessibilityManager;
  12397. function _compareElementPositions(e1, e2) {
  12398. const rect1 = e1.getBoundingClientRect();
  12399. const rect2 = e2.getBoundingClientRect();
  12400. if (rect1.width === 0 && rect1.height === 0) {
  12401. return +1;
  12402. }
  12403. if (rect2.width === 0 && rect2.height === 0) {
  12404. return -1;
  12405. }
  12406. const top1 = rect1.y;
  12407. const bot1 = rect1.y + rect1.height;
  12408. const mid1 = rect1.y + rect1.height / 2;
  12409. const top2 = rect2.y;
  12410. const bot2 = rect2.y + rect2.height;
  12411. const mid2 = rect2.y + rect2.height / 2;
  12412. if (mid1 <= top2 && mid2 >= bot1) {
  12413. return -1;
  12414. }
  12415. if (mid2 <= top1 && mid1 >= bot2) {
  12416. return +1;
  12417. }
  12418. const centerX1 = rect1.x + rect1.width / 2;
  12419. const centerX2 = rect2.x + rect2.width / 2;
  12420. return centerX1 - centerX2;
  12421. }
  12422. function _addIdToAriaOwns2(id, node) {
  12423. const owns = node.getAttribute("aria-owns");
  12424. if (!(owns !== null && owns !== void 0 && owns.includes(id))) {
  12425. node.setAttribute("aria-owns", owns ? `${owns} ${id}` : id);
  12426. }
  12427. node.removeAttribute("role");
  12428. }
  12429. /***/
  12430. }),
  12431. /* 37 */
  12432. /***/ ((__unused_webpack_module, exports) => {
  12433. Object.defineProperty(exports, "__esModule", ({
  12434. value: true
  12435. }));
  12436. exports.TextHighlighter = void 0;
  12437. class TextHighlighter {
  12438. constructor(_ref) {
  12439. let {
  12440. findController,
  12441. eventBus,
  12442. pageIndex
  12443. } = _ref;
  12444. this.findController = findController;
  12445. this.matches = [];
  12446. this.eventBus = eventBus;
  12447. this.pageIdx = pageIndex;
  12448. this._onUpdateTextLayerMatches = null;
  12449. this.textDivs = null;
  12450. this.textContentItemsStr = null;
  12451. this.enabled = false;
  12452. }
  12453. setTextMapping(divs, texts) {
  12454. this.textDivs = divs;
  12455. this.textContentItemsStr = texts;
  12456. }
  12457. enable() {
  12458. if (!this.textDivs || !this.textContentItemsStr) {
  12459. throw new Error("Text divs and strings have not been set.");
  12460. }
  12461. if (this.enabled) {
  12462. throw new Error("TextHighlighter is already enabled.");
  12463. }
  12464. this.enabled = true;
  12465. if (!this._onUpdateTextLayerMatches) {
  12466. this._onUpdateTextLayerMatches = evt => {
  12467. if (evt.pageIndex === this.pageIdx || evt.pageIndex === -1) {
  12468. this._updateMatches();
  12469. }
  12470. };
  12471. this.eventBus._on("updatetextlayermatches", this._onUpdateTextLayerMatches);
  12472. }
  12473. this._updateMatches();
  12474. }
  12475. disable() {
  12476. if (!this.enabled) {
  12477. return;
  12478. }
  12479. this.enabled = false;
  12480. if (this._onUpdateTextLayerMatches) {
  12481. this.eventBus._off("updatetextlayermatches", this._onUpdateTextLayerMatches);
  12482. this._onUpdateTextLayerMatches = null;
  12483. }
  12484. this._updateMatches(true);
  12485. }
  12486. _convertMatches(matches, matchesLength) {
  12487. if (!matches) {
  12488. return [];
  12489. }
  12490. const {
  12491. textContentItemsStr
  12492. } = this;
  12493. let i = 0,
  12494. iIndex = 0;
  12495. const end = textContentItemsStr.length - 1;
  12496. const result = [];
  12497. for (let m = 0, mm = matches.length; m < mm; m++) {
  12498. let matchIdx = matches[m];
  12499. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  12500. iIndex += textContentItemsStr[i].length;
  12501. i++;
  12502. }
  12503. if (i === textContentItemsStr.length) {
  12504. console.error("Could not find a matching mapping");
  12505. }
  12506. const match = {
  12507. begin: {
  12508. divIdx: i,
  12509. offset: matchIdx - iIndex
  12510. }
  12511. };
  12512. matchIdx += matchesLength[m];
  12513. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  12514. iIndex += textContentItemsStr[i].length;
  12515. i++;
  12516. }
  12517. match.end = {
  12518. divIdx: i,
  12519. offset: matchIdx - iIndex
  12520. };
  12521. result.push(match);
  12522. }
  12523. return result;
  12524. }
  12525. _renderMatches(matches) {
  12526. if (matches.length === 0) {
  12527. return;
  12528. }
  12529. const {
  12530. findController,
  12531. pageIdx
  12532. } = this;
  12533. const {
  12534. textContentItemsStr,
  12535. textDivs
  12536. } = this;
  12537. const isSelectedPage = pageIdx === findController.selected.pageIdx;
  12538. const selectedMatchIdx = findController.selected.matchIdx;
  12539. const highlightAll = findController.state.highlightAll;
  12540. let prevEnd = null;
  12541. const infinity = {
  12542. divIdx: -1,
  12543. offset: undefined
  12544. };
  12545. function beginText(begin, className) {
  12546. const divIdx = begin.divIdx;
  12547. textDivs[divIdx].textContent = "";
  12548. return appendTextToDiv(divIdx, 0, begin.offset, className);
  12549. }
  12550. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  12551. let div = textDivs[divIdx];
  12552. if (div.nodeType === Node.TEXT_NODE) {
  12553. const span = document.createElement("span");
  12554. div.before(span);
  12555. span.append(div);
  12556. textDivs[divIdx] = span;
  12557. div = span;
  12558. }
  12559. const content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  12560. const node = document.createTextNode(content);
  12561. if (className) {
  12562. const span = document.createElement("span");
  12563. span.className = `${className} appended`;
  12564. span.append(node);
  12565. div.append(span);
  12566. return className.includes("selected") ? span.offsetLeft : 0;
  12567. }
  12568. div.append(node);
  12569. return 0;
  12570. }
  12571. let i0 = selectedMatchIdx,
  12572. i1 = i0 + 1;
  12573. if (highlightAll) {
  12574. i0 = 0;
  12575. i1 = matches.length;
  12576. } else if (!isSelectedPage) {
  12577. return;
  12578. }
  12579. for (let i = i0; i < i1; i++) {
  12580. const match = matches[i];
  12581. const begin = match.begin;
  12582. const end = match.end;
  12583. const isSelected = isSelectedPage && i === selectedMatchIdx;
  12584. const highlightSuffix = isSelected ? " selected" : "";
  12585. let selectedLeft = 0;
  12586. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  12587. if (prevEnd !== null) {
  12588. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  12589. }
  12590. beginText(begin);
  12591. } else {
  12592. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  12593. }
  12594. if (begin.divIdx === end.divIdx) {
  12595. selectedLeft = appendTextToDiv(begin.divIdx, begin.offset, end.offset, "highlight" + highlightSuffix);
  12596. } else {
  12597. selectedLeft = appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, "highlight begin" + highlightSuffix);
  12598. for (let n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  12599. textDivs[n0].className = "highlight middle" + highlightSuffix;
  12600. }
  12601. beginText(end, "highlight end" + highlightSuffix);
  12602. }
  12603. prevEnd = end;
  12604. if (isSelected) {
  12605. findController.scrollMatchIntoView({
  12606. element: textDivs[begin.divIdx],
  12607. selectedLeft,
  12608. pageIndex: pageIdx,
  12609. matchIndex: selectedMatchIdx
  12610. });
  12611. }
  12612. }
  12613. if (prevEnd) {
  12614. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  12615. }
  12616. }
  12617. _updateMatches() {
  12618. let reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  12619. if (!this.enabled && !reset) {
  12620. return;
  12621. }
  12622. const {
  12623. findController,
  12624. matches,
  12625. pageIdx
  12626. } = this;
  12627. const {
  12628. textContentItemsStr,
  12629. textDivs
  12630. } = this;
  12631. let clearedUntilDivIdx = -1;
  12632. for (const match of matches) {
  12633. const begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  12634. for (let n = begin, end = match.end.divIdx; n <= end; n++) {
  12635. const div = textDivs[n];
  12636. div.textContent = textContentItemsStr[n];
  12637. div.className = "";
  12638. }
  12639. clearedUntilDivIdx = match.end.divIdx + 1;
  12640. }
  12641. if (!(findController !== null && findController !== void 0 && findController.highlightMatches) || reset) {
  12642. return;
  12643. }
  12644. const pageMatches = findController.pageMatches[pageIdx] || null;
  12645. const pageMatchesLength = findController.pageMatchesLength[pageIdx] || null;
  12646. this.matches = this._convertMatches(pageMatches, pageMatchesLength);
  12647. this._renderMatches(this.matches);
  12648. }
  12649. }
  12650. exports.TextHighlighter = TextHighlighter;
  12651. /***/
  12652. }),
  12653. /* 38 */
  12654. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  12655. Object.defineProperty(exports, "__esModule", ({
  12656. value: true
  12657. }));
  12658. exports.TextLayerBuilder = void 0;
  12659. var _pdfjsLib = __webpack_require__(4);
  12660. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  12661. function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
  12662. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  12663. function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
  12664. function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
  12665. function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
  12666. function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
  12667. function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
  12668. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  12669. var _rotation = /*#__PURE__*/new WeakMap();
  12670. var _scale = /*#__PURE__*/new WeakMap();
  12671. var _textContentSource = /*#__PURE__*/new WeakMap();
  12672. var _finishRendering = /*#__PURE__*/new WeakSet();
  12673. var _bindMouse = /*#__PURE__*/new WeakSet();
  12674. class TextLayerBuilder {
  12675. constructor(_ref) {
  12676. let {
  12677. highlighter = null,
  12678. accessibilityManager = null,
  12679. isOffscreenCanvasSupported = true
  12680. } = _ref;
  12681. _classPrivateMethodInitSpec(this, _bindMouse);
  12682. _classPrivateMethodInitSpec(this, _finishRendering);
  12683. _classPrivateFieldInitSpec(this, _rotation, {
  12684. writable: true,
  12685. value: 0
  12686. });
  12687. _classPrivateFieldInitSpec(this, _scale, {
  12688. writable: true,
  12689. value: 0
  12690. });
  12691. _classPrivateFieldInitSpec(this, _textContentSource, {
  12692. writable: true,
  12693. value: null
  12694. });
  12695. this.textContentItemsStr = [];
  12696. this.renderingDone = false;
  12697. this.textDivs = [];
  12698. this.textDivProperties = new WeakMap();
  12699. this.textLayerRenderTask = null;
  12700. this.highlighter = highlighter;
  12701. this.accessibilityManager = accessibilityManager;
  12702. this.isOffscreenCanvasSupported = isOffscreenCanvasSupported;
  12703. this.div = document.createElement("div");
  12704. this.div.className = "textLayer";
  12705. this.hide();
  12706. }
  12707. get numTextDivs() {
  12708. return this.textDivs.length;
  12709. }
  12710. async render(viewport) {
  12711. var _this$highlighter, _this$accessibilityMa, _this$accessibilityMa2;
  12712. if (!_classPrivateFieldGet(this, _textContentSource)) {
  12713. throw new Error('No "textContentSource" parameter specified.');
  12714. }
  12715. const scale = viewport.scale * (globalThis.devicePixelRatio || 1);
  12716. const {
  12717. rotation
  12718. } = viewport;
  12719. if (this.renderingDone) {
  12720. const mustRotate = rotation !== _classPrivateFieldGet(this, _rotation);
  12721. const mustRescale = scale !== _classPrivateFieldGet(this, _scale);
  12722. if (mustRotate || mustRescale) {
  12723. this.hide();
  12724. (0, _pdfjsLib.updateTextLayer)({
  12725. container: this.div,
  12726. viewport,
  12727. textDivs: this.textDivs,
  12728. textDivProperties: this.textDivProperties,
  12729. isOffscreenCanvasSupported: this.isOffscreenCanvasSupported,
  12730. mustRescale,
  12731. mustRotate
  12732. });
  12733. _classPrivateFieldSet(this, _scale, scale);
  12734. _classPrivateFieldSet(this, _rotation, rotation);
  12735. }
  12736. this.show();
  12737. return;
  12738. }
  12739. this.cancel();
  12740. (_this$highlighter = this.highlighter) === null || _this$highlighter === void 0 ? void 0 : _this$highlighter.setTextMapping(this.textDivs, this.textContentItemsStr);
  12741. (_this$accessibilityMa = this.accessibilityManager) === null || _this$accessibilityMa === void 0 ? void 0 : _this$accessibilityMa.setTextMapping(this.textDivs);
  12742. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  12743. textContentSource: _classPrivateFieldGet(this, _textContentSource),
  12744. container: this.div,
  12745. viewport,
  12746. textDivs: this.textDivs,
  12747. textDivProperties: this.textDivProperties,
  12748. textContentItemsStr: this.textContentItemsStr,
  12749. isOffscreenCanvasSupported: this.isOffscreenCanvasSupported
  12750. });
  12751. await this.textLayerRenderTask.promise;
  12752. _classPrivateMethodGet(this, _finishRendering, _finishRendering2).call(this);
  12753. _classPrivateFieldSet(this, _scale, scale);
  12754. _classPrivateFieldSet(this, _rotation, rotation);
  12755. this.show();
  12756. (_this$accessibilityMa2 = this.accessibilityManager) === null || _this$accessibilityMa2 === void 0 ? void 0 : _this$accessibilityMa2.enable();
  12757. }
  12758. hide() {
  12759. if (!this.div.hidden) {
  12760. var _this$highlighter2;
  12761. (_this$highlighter2 = this.highlighter) === null || _this$highlighter2 === void 0 ? void 0 : _this$highlighter2.disable();
  12762. this.div.hidden = true;
  12763. }
  12764. }
  12765. show() {
  12766. if (this.div.hidden && this.renderingDone) {
  12767. var _this$highlighter3;
  12768. this.div.hidden = false;
  12769. (_this$highlighter3 = this.highlighter) === null || _this$highlighter3 === void 0 ? void 0 : _this$highlighter3.enable();
  12770. }
  12771. }
  12772. cancel() {
  12773. var _this$highlighter4, _this$accessibilityMa3;
  12774. if (this.textLayerRenderTask) {
  12775. this.textLayerRenderTask.cancel();
  12776. this.textLayerRenderTask = null;
  12777. }
  12778. (_this$highlighter4 = this.highlighter) === null || _this$highlighter4 === void 0 ? void 0 : _this$highlighter4.disable();
  12779. (_this$accessibilityMa3 = this.accessibilityManager) === null || _this$accessibilityMa3 === void 0 ? void 0 : _this$accessibilityMa3.disable();
  12780. this.textContentItemsStr.length = 0;
  12781. this.textDivs.length = 0;
  12782. this.textDivProperties = new WeakMap();
  12783. }
  12784. setTextContentSource(source) {
  12785. this.cancel();
  12786. _classPrivateFieldSet(this, _textContentSource, source);
  12787. }
  12788. }
  12789. exports.TextLayerBuilder = TextLayerBuilder;
  12790. function _finishRendering2() {
  12791. this.renderingDone = true;
  12792. const endOfContent = document.createElement("div");
  12793. endOfContent.className = "endOfContent";
  12794. this.div.append(endOfContent);
  12795. _classPrivateMethodGet(this, _bindMouse, _bindMouse2).call(this);
  12796. }
  12797. function _bindMouse2() {
  12798. const {
  12799. div
  12800. } = this;
  12801. div.addEventListener("mousedown", evt => {
  12802. const end = div.querySelector(".endOfContent");
  12803. if (!end) {
  12804. return;
  12805. }
  12806. let adjustTop = evt.target !== div;
  12807. adjustTop && (adjustTop = getComputedStyle(end).getPropertyValue("-moz-user-select") !== "none");
  12808. if (adjustTop) {
  12809. const divBounds = div.getBoundingClientRect();
  12810. const r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  12811. end.style.top = (r * 100).toFixed(2) + "%";
  12812. }
  12813. end.classList.add("active");
  12814. });
  12815. div.addEventListener("mouseup", () => {
  12816. const end = div.querySelector(".endOfContent");
  12817. if (!end) {
  12818. return;
  12819. }
  12820. end.style.top = "";
  12821. end.classList.remove("active");
  12822. });
  12823. }
  12824. /***/
  12825. }),
  12826. /* 39 */
  12827. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  12828. Object.defineProperty(exports, "__esModule", ({
  12829. value: true
  12830. }));
  12831. exports.XfaLayerBuilder = void 0;
  12832. var _pdfjsLib = __webpack_require__(4);
  12833. class XfaLayerBuilder {
  12834. constructor(_ref) {
  12835. let {
  12836. pageDiv,
  12837. pdfPage,
  12838. annotationStorage = null,
  12839. linkService,
  12840. xfaHtml = null
  12841. } = _ref;
  12842. this.pageDiv = pageDiv;
  12843. this.pdfPage = pdfPage;
  12844. this.annotationStorage = annotationStorage;
  12845. this.linkService = linkService;
  12846. this.xfaHtml = xfaHtml;
  12847. this.div = null;
  12848. this._cancelled = false;
  12849. }
  12850. async render(viewport) {
  12851. let intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "display";
  12852. if (intent === "print") {
  12853. const parameters = {
  12854. viewport: viewport.clone({
  12855. dontFlip: true
  12856. }),
  12857. div: this.div,
  12858. xfaHtml: this.xfaHtml,
  12859. annotationStorage: this.annotationStorage,
  12860. linkService: this.linkService,
  12861. intent
  12862. };
  12863. const div = document.createElement("div");
  12864. this.pageDiv.append(div);
  12865. parameters.div = div;
  12866. return _pdfjsLib.XfaLayer.render(parameters);
  12867. }
  12868. const xfaHtml = await this.pdfPage.getXfa();
  12869. if (this._cancelled || !xfaHtml) {
  12870. return {
  12871. textDivs: []
  12872. };
  12873. }
  12874. const parameters = {
  12875. viewport: viewport.clone({
  12876. dontFlip: true
  12877. }),
  12878. div: this.div,
  12879. xfaHtml,
  12880. annotationStorage: this.annotationStorage,
  12881. linkService: this.linkService,
  12882. intent
  12883. };
  12884. if (this.div) {
  12885. return _pdfjsLib.XfaLayer.update(parameters);
  12886. }
  12887. this.div = document.createElement("div");
  12888. this.pageDiv.append(this.div);
  12889. parameters.div = this.div;
  12890. return _pdfjsLib.XfaLayer.render(parameters);
  12891. }
  12892. cancel() {
  12893. this._cancelled = true;
  12894. }
  12895. hide() {
  12896. if (!this.div) {
  12897. return;
  12898. }
  12899. this.div.hidden = true;
  12900. }
  12901. }
  12902. exports.XfaLayerBuilder = XfaLayerBuilder;
  12903. /***/
  12904. }),
  12905. /* 40 */
  12906. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  12907. Object.defineProperty(exports, "__esModule", ({
  12908. value: true
  12909. }));
  12910. exports.SecondaryToolbar = void 0;
  12911. var _ui_utils = __webpack_require__(3);
  12912. var _pdf_viewer = __webpack_require__(30);
  12913. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  12914. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  12915. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  12916. var _updateUIState = /*#__PURE__*/new WeakSet();
  12917. var _bindClickListeners = /*#__PURE__*/new WeakSet();
  12918. var _bindCursorToolsListener = /*#__PURE__*/new WeakSet();
  12919. var _bindScrollModeListener = /*#__PURE__*/new WeakSet();
  12920. var _bindSpreadModeListener = /*#__PURE__*/new WeakSet();
  12921. class SecondaryToolbar {
  12922. constructor(options, eventBus, externalServices) {
  12923. _classPrivateMethodInitSpec(this, _bindSpreadModeListener);
  12924. _classPrivateMethodInitSpec(this, _bindScrollModeListener);
  12925. _classPrivateMethodInitSpec(this, _bindCursorToolsListener);
  12926. _classPrivateMethodInitSpec(this, _bindClickListeners);
  12927. _classPrivateMethodInitSpec(this, _updateUIState);
  12928. this.toolbar = options.toolbar;
  12929. this.toggleButton = options.toggleButton;
  12930. this.buttons = [{
  12931. element: options.presentationModeButton,
  12932. eventName: "presentationmode",
  12933. close: true
  12934. }, {
  12935. element: options.printButton,
  12936. eventName: "print",
  12937. close: true
  12938. }, {
  12939. element: options.downloadButton,
  12940. eventName: "download",
  12941. close: true
  12942. }, {
  12943. element: options.viewBookmarkButton,
  12944. eventName: null,
  12945. close: true
  12946. }, {
  12947. element: options.firstPageButton,
  12948. eventName: "firstpage",
  12949. close: true
  12950. }, {
  12951. element: options.lastPageButton,
  12952. eventName: "lastpage",
  12953. close: true
  12954. }, {
  12955. element: options.pageRotateCwButton,
  12956. eventName: "rotatecw",
  12957. close: false
  12958. }, {
  12959. element: options.pageRotateCcwButton,
  12960. eventName: "rotateccw",
  12961. close: false
  12962. }, {
  12963. element: options.cursorSelectToolButton,
  12964. eventName: "switchcursortool",
  12965. eventDetails: {
  12966. tool: _ui_utils.CursorTool.SELECT
  12967. },
  12968. close: true
  12969. }, {
  12970. element: options.cursorHandToolButton,
  12971. eventName: "switchcursortool",
  12972. eventDetails: {
  12973. tool: _ui_utils.CursorTool.HAND
  12974. },
  12975. close: true
  12976. }, {
  12977. element: options.scrollPageButton,
  12978. eventName: "switchscrollmode",
  12979. eventDetails: {
  12980. mode: _ui_utils.ScrollMode.PAGE
  12981. },
  12982. close: true
  12983. }, {
  12984. element: options.scrollVerticalButton,
  12985. eventName: "switchscrollmode",
  12986. eventDetails: {
  12987. mode: _ui_utils.ScrollMode.VERTICAL
  12988. },
  12989. close: true
  12990. }, {
  12991. element: options.scrollHorizontalButton,
  12992. eventName: "switchscrollmode",
  12993. eventDetails: {
  12994. mode: _ui_utils.ScrollMode.HORIZONTAL
  12995. },
  12996. close: true
  12997. }, {
  12998. element: options.scrollWrappedButton,
  12999. eventName: "switchscrollmode",
  13000. eventDetails: {
  13001. mode: _ui_utils.ScrollMode.WRAPPED
  13002. },
  13003. close: true
  13004. }, {
  13005. element: options.spreadNoneButton,
  13006. eventName: "switchspreadmode",
  13007. eventDetails: {
  13008. mode: _ui_utils.SpreadMode.NONE
  13009. },
  13010. close: true
  13011. }, {
  13012. element: options.spreadOddButton,
  13013. eventName: "switchspreadmode",
  13014. eventDetails: {
  13015. mode: _ui_utils.SpreadMode.ODD
  13016. },
  13017. close: true
  13018. }, {
  13019. element: options.spreadEvenButton,
  13020. eventName: "switchspreadmode",
  13021. eventDetails: {
  13022. mode: _ui_utils.SpreadMode.EVEN
  13023. },
  13024. close: true
  13025. }, {
  13026. element: options.documentPropertiesButton,
  13027. eventName: "documentproperties",
  13028. close: true
  13029. }];
  13030. this.buttons.push({
  13031. element: options.openFileButton,
  13032. eventName: "openfile",
  13033. close: true
  13034. });
  13035. this.items = {
  13036. firstPage: options.firstPageButton,
  13037. lastPage: options.lastPageButton,
  13038. pageRotateCw: options.pageRotateCwButton,
  13039. pageRotateCcw: options.pageRotateCcwButton
  13040. };
  13041. this.eventBus = eventBus;
  13042. this.externalServices = externalServices;
  13043. this.opened = false;
  13044. _classPrivateMethodGet(this, _bindClickListeners, _bindClickListeners2).call(this);
  13045. _classPrivateMethodGet(this, _bindCursorToolsListener, _bindCursorToolsListener2).call(this, options);
  13046. _classPrivateMethodGet(this, _bindScrollModeListener, _bindScrollModeListener2).call(this, options);
  13047. _classPrivateMethodGet(this, _bindSpreadModeListener, _bindSpreadModeListener2).call(this, options);
  13048. this.reset();
  13049. }
  13050. get isOpen() {
  13051. return this.opened;
  13052. }
  13053. setPageNumber(pageNumber) {
  13054. this.pageNumber = pageNumber;
  13055. _classPrivateMethodGet(this, _updateUIState, _updateUIState2).call(this);
  13056. }
  13057. setPagesCount(pagesCount) {
  13058. this.pagesCount = pagesCount;
  13059. _classPrivateMethodGet(this, _updateUIState, _updateUIState2).call(this);
  13060. }
  13061. reset() {
  13062. this.pageNumber = 0;
  13063. this.pagesCount = 0;
  13064. _classPrivateMethodGet(this, _updateUIState, _updateUIState2).call(this);
  13065. this.eventBus.dispatch("secondarytoolbarreset", {
  13066. source: this
  13067. });
  13068. }
  13069. open() {
  13070. if (this.opened) {
  13071. return;
  13072. }
  13073. this.opened = true;
  13074. this.toggleButton.classList.add("toggled");
  13075. this.toggleButton.setAttribute("aria-expanded", "true");
  13076. this.toolbar.classList.remove("hidden");
  13077. }
  13078. close() {
  13079. if (!this.opened) {
  13080. return;
  13081. }
  13082. this.opened = false;
  13083. this.toolbar.classList.add("hidden");
  13084. this.toggleButton.classList.remove("toggled");
  13085. this.toggleButton.setAttribute("aria-expanded", "false");
  13086. }
  13087. toggle() {
  13088. if (this.opened) {
  13089. this.close();
  13090. } else {
  13091. this.open();
  13092. }
  13093. }
  13094. }
  13095. exports.SecondaryToolbar = SecondaryToolbar;
  13096. function _updateUIState2() {
  13097. this.items.firstPage.disabled = this.pageNumber <= 1;
  13098. this.items.lastPage.disabled = this.pageNumber >= this.pagesCount;
  13099. this.items.pageRotateCw.disabled = this.pagesCount === 0;
  13100. this.items.pageRotateCcw.disabled = this.pagesCount === 0;
  13101. }
  13102. function _bindClickListeners2() {
  13103. this.toggleButton.addEventListener("click", this.toggle.bind(this));
  13104. for (const {
  13105. element,
  13106. eventName,
  13107. close,
  13108. eventDetails
  13109. } of this.buttons) {
  13110. element.addEventListener("click", evt => {
  13111. if (eventName !== null) {
  13112. const details = {
  13113. source: this
  13114. };
  13115. for (const property in eventDetails) {
  13116. details[property] = eventDetails[property];
  13117. }
  13118. this.eventBus.dispatch(eventName, details);
  13119. }
  13120. if (close) {
  13121. this.close();
  13122. }
  13123. this.externalServices.reportTelemetry({
  13124. type: "buttons",
  13125. data: {
  13126. id: element.id
  13127. }
  13128. });
  13129. });
  13130. }
  13131. }
  13132. function _bindCursorToolsListener2(_ref) {
  13133. let {
  13134. cursorSelectToolButton,
  13135. cursorHandToolButton
  13136. } = _ref;
  13137. this.eventBus._on("cursortoolchanged", function (_ref2) {
  13138. let {
  13139. tool
  13140. } = _ref2;
  13141. const isSelect = tool === _ui_utils.CursorTool.SELECT,
  13142. isHand = tool === _ui_utils.CursorTool.HAND;
  13143. cursorSelectToolButton.classList.toggle("toggled", isSelect);
  13144. cursorHandToolButton.classList.toggle("toggled", isHand);
  13145. cursorSelectToolButton.setAttribute("aria-checked", isSelect);
  13146. cursorHandToolButton.setAttribute("aria-checked", isHand);
  13147. });
  13148. }
  13149. function _bindScrollModeListener2(_ref3) {
  13150. let {
  13151. scrollPageButton,
  13152. scrollVerticalButton,
  13153. scrollHorizontalButton,
  13154. scrollWrappedButton,
  13155. spreadNoneButton,
  13156. spreadOddButton,
  13157. spreadEvenButton
  13158. } = _ref3;
  13159. const scrollModeChanged = _ref4 => {
  13160. let {
  13161. mode
  13162. } = _ref4;
  13163. const isPage = mode === _ui_utils.ScrollMode.PAGE,
  13164. isVertical = mode === _ui_utils.ScrollMode.VERTICAL,
  13165. isHorizontal = mode === _ui_utils.ScrollMode.HORIZONTAL,
  13166. isWrapped = mode === _ui_utils.ScrollMode.WRAPPED;
  13167. scrollPageButton.classList.toggle("toggled", isPage);
  13168. scrollVerticalButton.classList.toggle("toggled", isVertical);
  13169. scrollHorizontalButton.classList.toggle("toggled", isHorizontal);
  13170. scrollWrappedButton.classList.toggle("toggled", isWrapped);
  13171. scrollPageButton.setAttribute("aria-checked", isPage);
  13172. scrollVerticalButton.setAttribute("aria-checked", isVertical);
  13173. scrollHorizontalButton.setAttribute("aria-checked", isHorizontal);
  13174. scrollWrappedButton.setAttribute("aria-checked", isWrapped);
  13175. const forceScrollModePage = this.pagesCount > _pdf_viewer.PagesCountLimit.FORCE_SCROLL_MODE_PAGE;
  13176. scrollPageButton.disabled = forceScrollModePage;
  13177. scrollVerticalButton.disabled = forceScrollModePage;
  13178. scrollHorizontalButton.disabled = forceScrollModePage;
  13179. scrollWrappedButton.disabled = forceScrollModePage;
  13180. spreadNoneButton.disabled = isHorizontal;
  13181. spreadOddButton.disabled = isHorizontal;
  13182. spreadEvenButton.disabled = isHorizontal;
  13183. };
  13184. this.eventBus._on("scrollmodechanged", scrollModeChanged);
  13185. this.eventBus._on("secondarytoolbarreset", evt => {
  13186. if (evt.source === this) {
  13187. scrollModeChanged({
  13188. mode: _ui_utils.ScrollMode.VERTICAL
  13189. });
  13190. }
  13191. });
  13192. }
  13193. function _bindSpreadModeListener2(_ref5) {
  13194. let {
  13195. spreadNoneButton,
  13196. spreadOddButton,
  13197. spreadEvenButton
  13198. } = _ref5;
  13199. function spreadModeChanged(_ref6) {
  13200. let {
  13201. mode
  13202. } = _ref6;
  13203. const isNone = mode === _ui_utils.SpreadMode.NONE,
  13204. isOdd = mode === _ui_utils.SpreadMode.ODD,
  13205. isEven = mode === _ui_utils.SpreadMode.EVEN;
  13206. spreadNoneButton.classList.toggle("toggled", isNone);
  13207. spreadOddButton.classList.toggle("toggled", isOdd);
  13208. spreadEvenButton.classList.toggle("toggled", isEven);
  13209. spreadNoneButton.setAttribute("aria-checked", isNone);
  13210. spreadOddButton.setAttribute("aria-checked", isOdd);
  13211. spreadEvenButton.setAttribute("aria-checked", isEven);
  13212. }
  13213. this.eventBus._on("spreadmodechanged", spreadModeChanged);
  13214. this.eventBus._on("secondarytoolbarreset", evt => {
  13215. if (evt.source === this) {
  13216. spreadModeChanged({
  13217. mode: _ui_utils.SpreadMode.NONE
  13218. });
  13219. }
  13220. });
  13221. }
  13222. /***/
  13223. }),
  13224. /* 41 */
  13225. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13226. Object.defineProperty(exports, "__esModule", ({
  13227. value: true
  13228. }));
  13229. exports.Toolbar = void 0;
  13230. var _ui_utils = __webpack_require__(3);
  13231. var _pdfjsLib = __webpack_require__(4);
  13232. function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
  13233. function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
  13234. function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
  13235. function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
  13236. function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
  13237. function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
  13238. function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
  13239. function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
  13240. function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
  13241. const PAGE_NUMBER_LOADING_INDICATOR = "visiblePageIsLoading";
  13242. var _wasLocalized = /*#__PURE__*/new WeakMap();
  13243. var _bindListeners = /*#__PURE__*/new WeakSet();
  13244. var _bindEditorToolsListener = /*#__PURE__*/new WeakSet();
  13245. var _updateUIState = /*#__PURE__*/new WeakSet();
  13246. var _adjustScaleWidth = /*#__PURE__*/new WeakSet();
  13247. class Toolbar {
  13248. constructor(_options, eventBus, _l10n) {
  13249. _classPrivateMethodInitSpec(this, _adjustScaleWidth);
  13250. _classPrivateMethodInitSpec(this, _updateUIState);
  13251. _classPrivateMethodInitSpec(this, _bindEditorToolsListener);
  13252. _classPrivateMethodInitSpec(this, _bindListeners);
  13253. _classPrivateFieldInitSpec(this, _wasLocalized, {
  13254. writable: true,
  13255. value: false
  13256. });
  13257. this.toolbar = _options.container;
  13258. this.eventBus = eventBus;
  13259. this.l10n = _l10n;
  13260. this.buttons = [{
  13261. element: _options.previous,
  13262. eventName: "previouspage"
  13263. }, {
  13264. element: _options.next,
  13265. eventName: "nextpage"
  13266. }, {
  13267. element: _options.zoomIn,
  13268. eventName: "zoomin"
  13269. }, {
  13270. element: _options.zoomOut,
  13271. eventName: "zoomout"
  13272. }, {
  13273. element: _options.print,
  13274. eventName: "print"
  13275. }, {
  13276. element: _options.download,
  13277. eventName: "download"
  13278. }, {
  13279. element: _options.editorFreeTextButton,
  13280. eventName: "switchannotationeditormode",
  13281. eventDetails: {
  13282. get mode() {
  13283. const {
  13284. classList
  13285. } = _options.editorFreeTextButton;
  13286. return classList.contains("toggled") ? _pdfjsLib.AnnotationEditorType.NONE : _pdfjsLib.AnnotationEditorType.FREETEXT;
  13287. }
  13288. }
  13289. }, {
  13290. element: _options.editorInkButton,
  13291. eventName: "switchannotationeditormode",
  13292. eventDetails: {
  13293. get mode() {
  13294. const {
  13295. classList
  13296. } = _options.editorInkButton;
  13297. return classList.contains("toggled") ? _pdfjsLib.AnnotationEditorType.NONE : _pdfjsLib.AnnotationEditorType.INK;
  13298. }
  13299. }
  13300. }];
  13301. this.buttons.push({
  13302. element: _options.openFile,
  13303. eventName: "openfile"
  13304. });
  13305. this.items = {
  13306. numPages: _options.numPages,
  13307. pageNumber: _options.pageNumber,
  13308. scaleSelect: _options.scaleSelect,
  13309. customScaleOption: _options.customScaleOption,
  13310. previous: _options.previous,
  13311. next: _options.next,
  13312. zoomIn: _options.zoomIn,
  13313. zoomOut: _options.zoomOut
  13314. };
  13315. _classPrivateMethodGet(this, _bindListeners, _bindListeners2).call(this, _options);
  13316. this.reset();
  13317. }
  13318. setPageNumber(pageNumber, pageLabel) {
  13319. this.pageNumber = pageNumber;
  13320. this.pageLabel = pageLabel;
  13321. _classPrivateMethodGet(this, _updateUIState, _updateUIState2).call(this, false);
  13322. }
  13323. setPagesCount(pagesCount, hasPageLabels) {
  13324. this.pagesCount = pagesCount;
  13325. this.hasPageLabels = hasPageLabels;
  13326. _classPrivateMethodGet(this, _updateUIState, _updateUIState2).call(this, true);
  13327. }
  13328. setPageScale(pageScaleValue, pageScale) {
  13329. this.pageScaleValue = (pageScaleValue || pageScale).toString();
  13330. this.pageScale = pageScale;
  13331. _classPrivateMethodGet(this, _updateUIState, _updateUIState2).call(this, false);
  13332. }
  13333. reset() {
  13334. this.pageNumber = 0;
  13335. this.pageLabel = null;
  13336. this.hasPageLabels = false;
  13337. this.pagesCount = 0;
  13338. this.pageScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  13339. this.pageScale = _ui_utils.DEFAULT_SCALE;
  13340. _classPrivateMethodGet(this, _updateUIState, _updateUIState2).call(this, true);
  13341. this.updateLoadingIndicatorState();
  13342. this.eventBus.dispatch("toolbarreset", {
  13343. source: this
  13344. });
  13345. }
  13346. updateLoadingIndicatorState() {
  13347. let loading = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  13348. const {
  13349. pageNumber
  13350. } = this.items;
  13351. pageNumber.classList.toggle(PAGE_NUMBER_LOADING_INDICATOR, loading);
  13352. }
  13353. }
  13354. exports.Toolbar = Toolbar;
  13355. function _bindListeners2(options) {
  13356. const {
  13357. pageNumber,
  13358. scaleSelect
  13359. } = this.items;
  13360. const self = this;
  13361. for (const {
  13362. element,
  13363. eventName,
  13364. eventDetails
  13365. } of this.buttons) {
  13366. element.addEventListener("click", evt => {
  13367. if (eventName !== null) {
  13368. const details = {
  13369. source: this
  13370. };
  13371. if (eventDetails) {
  13372. for (const property in eventDetails) {
  13373. details[property] = eventDetails[property];
  13374. }
  13375. }
  13376. this.eventBus.dispatch(eventName, details);
  13377. }
  13378. });
  13379. }
  13380. pageNumber.addEventListener("click", function () {
  13381. this.select();
  13382. });
  13383. pageNumber.addEventListener("change", function () {
  13384. self.eventBus.dispatch("pagenumberchanged", {
  13385. source: self,
  13386. value: this.value
  13387. });
  13388. });
  13389. scaleSelect.addEventListener("change", function () {
  13390. if (this.value === "custom") {
  13391. return;
  13392. }
  13393. self.eventBus.dispatch("scalechanged", {
  13394. source: self,
  13395. value: this.value
  13396. });
  13397. });
  13398. scaleSelect.addEventListener("click", function (evt) {
  13399. const target = evt.target;
  13400. if (this.value === self.pageScaleValue && target.tagName.toUpperCase() === "OPTION") {
  13401. this.blur();
  13402. }
  13403. });
  13404. scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler;
  13405. this.eventBus._on("localized", () => {
  13406. _classPrivateFieldSet(this, _wasLocalized, true);
  13407. _classPrivateMethodGet(this, _adjustScaleWidth, _adjustScaleWidth2).call(this);
  13408. _classPrivateMethodGet(this, _updateUIState, _updateUIState2).call(this, true);
  13409. });
  13410. _classPrivateMethodGet(this, _bindEditorToolsListener, _bindEditorToolsListener2).call(this, options);
  13411. }
  13412. function _bindEditorToolsListener2(_ref) {
  13413. let {
  13414. editorFreeTextButton,
  13415. editorFreeTextParamsToolbar,
  13416. editorInkButton,
  13417. editorInkParamsToolbar
  13418. } = _ref;
  13419. const editorModeChanged = function (evt) {
  13420. let disableButtons = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  13421. const editorButtons = [{
  13422. mode: _pdfjsLib.AnnotationEditorType.FREETEXT,
  13423. button: editorFreeTextButton,
  13424. toolbar: editorFreeTextParamsToolbar
  13425. }, {
  13426. mode: _pdfjsLib.AnnotationEditorType.INK,
  13427. button: editorInkButton,
  13428. toolbar: editorInkParamsToolbar
  13429. }];
  13430. for (const {
  13431. mode,
  13432. button,
  13433. toolbar
  13434. } of editorButtons) {
  13435. const checked = mode === evt.mode;
  13436. button.classList.toggle("toggled", checked);
  13437. button.setAttribute("aria-checked", checked);
  13438. button.disabled = disableButtons;
  13439. toolbar === null || toolbar === void 0 ? void 0 : toolbar.classList.toggle("hidden", !checked);
  13440. }
  13441. };
  13442. this.eventBus._on("annotationeditormodechanged", editorModeChanged);
  13443. this.eventBus._on("toolbarreset", evt => {
  13444. if (evt.source === this) {
  13445. editorModeChanged({
  13446. mode: _pdfjsLib.AnnotationEditorType.NONE
  13447. }, true);
  13448. }
  13449. });
  13450. }
  13451. function _updateUIState2() {
  13452. let resetNumPages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  13453. if (!_classPrivateFieldGet(this, _wasLocalized)) {
  13454. return;
  13455. }
  13456. const {
  13457. pageNumber,
  13458. pagesCount,
  13459. pageScaleValue,
  13460. pageScale,
  13461. items
  13462. } = this;
  13463. if (resetNumPages) {
  13464. if (this.hasPageLabels) {
  13465. items.pageNumber.type = "text";
  13466. } else {
  13467. items.pageNumber.type = "number";
  13468. this.l10n.get("of_pages", {
  13469. pagesCount
  13470. }).then(msg => {
  13471. items.numPages.textContent = msg;
  13472. });
  13473. }
  13474. items.pageNumber.max = pagesCount;
  13475. }
  13476. if (this.hasPageLabels) {
  13477. items.pageNumber.value = this.pageLabel;
  13478. this.l10n.get("page_of_pages", {
  13479. pageNumber,
  13480. pagesCount
  13481. }).then(msg => {
  13482. items.numPages.textContent = msg;
  13483. });
  13484. } else {
  13485. items.pageNumber.value = pageNumber;
  13486. }
  13487. items.previous.disabled = pageNumber <= 1;
  13488. items.next.disabled = pageNumber >= pagesCount;
  13489. items.zoomOut.disabled = pageScale <= _ui_utils.MIN_SCALE;
  13490. items.zoomIn.disabled = pageScale >= _ui_utils.MAX_SCALE;
  13491. this.l10n.get("page_scale_percent", {
  13492. scale: Math.round(pageScale * 10000) / 100
  13493. }).then(msg => {
  13494. let predefinedValueFound = false;
  13495. for (const option of items.scaleSelect.options) {
  13496. if (option.value !== pageScaleValue) {
  13497. option.selected = false;
  13498. continue;
  13499. }
  13500. option.selected = true;
  13501. predefinedValueFound = true;
  13502. }
  13503. if (!predefinedValueFound) {
  13504. items.customScaleOption.textContent = msg;
  13505. items.customScaleOption.selected = true;
  13506. }
  13507. });
  13508. }
  13509. async function _adjustScaleWidth2() {
  13510. const {
  13511. items,
  13512. l10n
  13513. } = this;
  13514. const predefinedValuesPromise = Promise.all([l10n.get("page_scale_auto"), l10n.get("page_scale_actual"), l10n.get("page_scale_fit"), l10n.get("page_scale_width")]);
  13515. await _ui_utils.animationStarted;
  13516. const style = getComputedStyle(items.scaleSelect);
  13517. const scaleSelectWidth = parseFloat(style.getPropertyValue("--scale-select-width"));
  13518. const canvas = document.createElement("canvas");
  13519. const ctx = canvas.getContext("2d", {
  13520. alpha: false
  13521. });
  13522. ctx.font = `${style.fontSize} ${style.fontFamily}`;
  13523. let maxWidth = 0;
  13524. for (const predefinedValue of await predefinedValuesPromise) {
  13525. const {
  13526. width
  13527. } = ctx.measureText(predefinedValue);
  13528. if (width > maxWidth) {
  13529. maxWidth = width;
  13530. }
  13531. }
  13532. maxWidth += 0.3 * scaleSelectWidth;
  13533. if (maxWidth > scaleSelectWidth) {
  13534. const container = items.scaleSelect.parentNode;
  13535. container.style.setProperty("--scale-select-width", `${maxWidth}px`);
  13536. }
  13537. canvas.width = 0;
  13538. canvas.height = 0;
  13539. }
  13540. /***/
  13541. }),
  13542. /* 42 */
  13543. /***/ ((__unused_webpack_module, exports) => {
  13544. Object.defineProperty(exports, "__esModule", ({
  13545. value: true
  13546. }));
  13547. exports.ViewHistory = void 0;
  13548. const DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
  13549. class ViewHistory {
  13550. constructor(fingerprint) {
  13551. let cacheSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_VIEW_HISTORY_CACHE_SIZE;
  13552. this.fingerprint = fingerprint;
  13553. this.cacheSize = cacheSize;
  13554. this._initializedPromise = this._readFromStorage().then(databaseStr => {
  13555. //const database = JSON.parse(databaseStr || "{}");
  13556. const database = {};
  13557. let index = -1;
  13558. if (!Array.isArray(database.files)) {
  13559. database.files = [];
  13560. } else {
  13561. while (database.files.length >= this.cacheSize) {
  13562. database.files.shift();
  13563. }
  13564. for (let i = 0, ii = database.files.length; i < ii; i++) {
  13565. const branch = database.files[i];
  13566. if (branch.fingerprint === this.fingerprint) {
  13567. index = i;
  13568. break;
  13569. }
  13570. }
  13571. }
  13572. if (index === -1) {
  13573. index = database.files.push({
  13574. fingerprint: this.fingerprint
  13575. }) - 1;
  13576. }
  13577. this.file = database.files[index];
  13578. this.database = database;
  13579. });
  13580. }
  13581. async _writeToStorage() {
  13582. const databaseStr = JSON.stringify(this.database);
  13583. localStorage.setItem("pdfjs.history", databaseStr);
  13584. }
  13585. async _readFromStorage() {
  13586. return localStorage.getItem("pdfjs.history");
  13587. }
  13588. async set(name, val) {
  13589. await this._initializedPromise;
  13590. this.file[name] = val;
  13591. return this._writeToStorage();
  13592. }
  13593. async setMultiple(properties) {
  13594. await this._initializedPromise;
  13595. for (const name in properties) {
  13596. this.file[name] = properties[name];
  13597. }
  13598. return this._writeToStorage();
  13599. }
  13600. async get(name, defaultValue) {
  13601. await this._initializedPromise;
  13602. const val = this.file[name];
  13603. return val !== undefined ? val : defaultValue;
  13604. }
  13605. async getMultiple(properties) {
  13606. await this._initializedPromise;
  13607. const values = Object.create(null);
  13608. for (const name in properties) {
  13609. const val = this.file[name];
  13610. values[name] = val !== undefined ? val : properties[name];
  13611. }
  13612. return values;
  13613. }
  13614. }
  13615. exports.ViewHistory = ViewHistory;
  13616. /***/
  13617. }),
  13618. /* 43 */
  13619. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13620. Object.defineProperty(exports, "__esModule", ({
  13621. value: true
  13622. }));
  13623. exports.BasePreferences = void 0;
  13624. var _app_options = __webpack_require__(5);
  13625. class BasePreferences {
  13626. #defaults = Object.freeze({
  13627. "annotationEditorMode": 0,
  13628. "annotationMode": 2,
  13629. "cursorToolOnLoad": 0,
  13630. "defaultZoomDelay": 400,
  13631. "defaultZoomValue": "",
  13632. "disablePageLabels": false,
  13633. "enablePermissions": false,
  13634. "enablePrintAutoRotate": true,
  13635. "enableScripting": true,
  13636. "externalLinkTarget": 0,
  13637. "historyUpdateUrl": false,
  13638. "ignoreDestinationZoom": false,
  13639. "forcePageColors": false,
  13640. "pageColorsBackground": "Canvas",
  13641. "pageColorsForeground": "CanvasText",
  13642. "pdfBugEnabled": false,
  13643. "sidebarViewOnLoad": -1,
  13644. "scrollModeOnLoad": -1,
  13645. "spreadModeOnLoad": -1,
  13646. "textLayerMode": 1,
  13647. "useOnlyCssZoom": false,
  13648. "viewerCssTheme": 0,
  13649. "viewOnLoad": 0,
  13650. "disableAutoFetch": false,
  13651. "disableFontFace": false,
  13652. "disableRange": false,
  13653. "disableStream": false,
  13654. "enableXfa": true,
  13655. "renderer": "canvas"
  13656. });
  13657. #prefs = Object.create(null);
  13658. #initializedPromise = null;
  13659. constructor() {
  13660. if (this.constructor === BasePreferences) {
  13661. throw new Error("Cannot initialize BasePreferences.");
  13662. }
  13663. this.#initializedPromise = this._readFromStorage(this.#defaults).then(prefs => {
  13664. for (const name in this.#defaults) {
  13665. const prefValue = prefs === null || prefs === void 0 ? void 0 : prefs[name];
  13666. if (typeof prefValue === typeof this.#defaults[name]) {
  13667. this.#prefs[name] = prefValue;
  13668. }
  13669. }
  13670. });
  13671. }
  13672. async _writeToStorage(prefObj) {
  13673. throw new Error("Not implemented: _writeToStorage");
  13674. }
  13675. async _readFromStorage(prefObj) {
  13676. throw new Error("Not implemented: _readFromStorage");
  13677. }
  13678. async reset() {
  13679. await this.#initializedPromise;
  13680. const prefs = this.#prefs;
  13681. this.#prefs = Object.create(null);
  13682. return this._writeToStorage(this.#defaults).catch(reason => {
  13683. this.#prefs = prefs;
  13684. throw reason;
  13685. });
  13686. }
  13687. async set(name, value) {
  13688. await this.#initializedPromise;
  13689. const defaultValue = this.#defaults[name],
  13690. prefs = this.#prefs;
  13691. if (defaultValue === undefined) {
  13692. throw new Error(`Set preference: "${name}" is undefined.`);
  13693. } else if (value === undefined) {
  13694. throw new Error("Set preference: no value is specified.");
  13695. }
  13696. const valueType = typeof value,
  13697. defaultType = typeof defaultValue;
  13698. if (valueType !== defaultType) {
  13699. if (valueType === "number" && defaultType === "string") {
  13700. value = value.toString();
  13701. } else {
  13702. throw new Error(`Set preference: "${value}" is a ${valueType}, expected a ${defaultType}.`);
  13703. }
  13704. } else {
  13705. if (valueType === "number" && !Number.isInteger(value)) {
  13706. throw new Error(`Set preference: "${value}" must be an integer.`);
  13707. }
  13708. }
  13709. this.#prefs[name] = value;
  13710. return this._writeToStorage(this.#prefs).catch(reason => {
  13711. this.#prefs = prefs;
  13712. throw reason;
  13713. });
  13714. }
  13715. async get(name) {
  13716. await this.#initializedPromise;
  13717. const defaultValue = this.#defaults[name];
  13718. if (defaultValue === undefined) {
  13719. throw new Error(`Get preference: "${name}" is undefined.`);
  13720. }
  13721. return this.#prefs[name] ?? defaultValue;
  13722. }
  13723. async getAll() {
  13724. await this.#initializedPromise;
  13725. const obj = Object.create(null);
  13726. for (const name in this.#defaults) {
  13727. obj[name] = this.#prefs[name] ?? this.#defaults[name];
  13728. }
  13729. return obj;
  13730. }
  13731. }
  13732. exports.BasePreferences = BasePreferences;
  13733. /***/
  13734. }),
  13735. /* 44 */
  13736. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13737. Object.defineProperty(exports, "__esModule", ({
  13738. value: true
  13739. }));
  13740. exports.DownloadManager = void 0;
  13741. var _pdfjsLib = __webpack_require__(4);
  13742. ;
  13743. function download(blobUrl, filename) {
  13744. const a = document.createElement("a");
  13745. if (!a.click) {
  13746. throw new Error('DownloadManager: "a.click()" is not supported.');
  13747. }
  13748. a.href = blobUrl;
  13749. a.target = "_parent";
  13750. if ("download" in a) {
  13751. a.download = filename;
  13752. }
  13753. (document.body || document.documentElement).append(a);
  13754. a.click();
  13755. a.remove();
  13756. }
  13757. class DownloadManager {
  13758. #openBlobUrls = new WeakMap();
  13759. downloadUrl(url, filename) {
  13760. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, "http://example.com")) {
  13761. console.error(`downloadUrl - not a valid URL: ${url}`);
  13762. return;
  13763. }
  13764. download(url + "#pdfjs.action=download", filename);
  13765. }
  13766. downloadData(data, filename, contentType) {
  13767. const blobUrl = URL.createObjectURL(new Blob([data], {
  13768. type: contentType
  13769. }));
  13770. download(blobUrl, filename);
  13771. }
  13772. openOrDownloadData(element, data, filename) {
  13773. const isPdfData = (0, _pdfjsLib.isPdfFile)(filename);
  13774. const contentType = isPdfData ? "application/pdf" : "";
  13775. if (isPdfData) {
  13776. let blobUrl = this.#openBlobUrls.get(element);
  13777. if (!blobUrl) {
  13778. blobUrl = URL.createObjectURL(new Blob([data], {
  13779. type: contentType
  13780. }));
  13781. this.#openBlobUrls.set(element, blobUrl);
  13782. }
  13783. let viewerUrl;
  13784. viewerUrl = "?file=" + encodeURIComponent(blobUrl + "#" + filename);
  13785. try {
  13786. window.open(viewerUrl);
  13787. return true;
  13788. } catch (ex) {
  13789. console.error(`openOrDownloadData: ${ex}`);
  13790. URL.revokeObjectURL(blobUrl);
  13791. this.#openBlobUrls.delete(element);
  13792. }
  13793. }
  13794. this.downloadData(data, filename, contentType);
  13795. return false;
  13796. }
  13797. download(blob, url, filename) {
  13798. const blobUrl = URL.createObjectURL(blob);
  13799. download(blobUrl, filename);
  13800. }
  13801. }
  13802. exports.DownloadManager = DownloadManager;
  13803. /***/
  13804. }),
  13805. /* 45 */
  13806. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13807. Object.defineProperty(exports, "__esModule", ({
  13808. value: true
  13809. }));
  13810. exports.GenericL10n = void 0;
  13811. __webpack_require__(46);
  13812. var _l10n_utils = __webpack_require__(31);
  13813. const webL10n = document.webL10n;
  13814. class GenericL10n {
  13815. constructor(lang) {
  13816. this._lang = lang;
  13817. this._ready = new Promise((resolve, reject) => {
  13818. webL10n.setLanguage((0, _l10n_utils.fixupLangCode)(lang), () => {
  13819. resolve(webL10n);
  13820. });
  13821. });
  13822. }
  13823. async getLanguage() {
  13824. const l10n = await this._ready;
  13825. return l10n.getLanguage();
  13826. }
  13827. async getDirection() {
  13828. const l10n = await this._ready;
  13829. return l10n.getDirection();
  13830. }
  13831. async get(key) {
  13832. let args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  13833. let fallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : (0, _l10n_utils.getL10nFallback)(key, args);
  13834. const l10n = await this._ready;
  13835. return l10n.get(key, args, fallback);
  13836. }
  13837. async translate(element) {
  13838. const l10n = await this._ready;
  13839. return l10n.translate(element);
  13840. }
  13841. }
  13842. exports.GenericL10n = GenericL10n;
  13843. /***/
  13844. }),
  13845. /* 46 */
  13846. /***/ (() => {
  13847. document.webL10n = function (window, document, undefined) {
  13848. var gL10nData = {};
  13849. var gTextData = '';
  13850. var gTextProp = 'textContent';
  13851. var gLanguage = '';
  13852. var gMacros = {};
  13853. var gReadyState = 'loading';
  13854. var gAsyncResourceLoading = true;
  13855. function getL10nResourceLinks() {
  13856. return document.querySelectorAll('link[type="application/l10n"]');
  13857. }
  13858. function getL10nDictionary() {
  13859. var script = document.querySelector('script[type="application/l10n"]');
  13860. return script ? JSON.parse(script.innerHTML) : null;
  13861. }
  13862. function getTranslatableChildren(element) {
  13863. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  13864. }
  13865. function getL10nAttributes(element) {
  13866. if (!element) return {};
  13867. var l10nId = element.getAttribute('data-l10n-id');
  13868. var l10nArgs = element.getAttribute('data-l10n-args');
  13869. var args = {};
  13870. if (l10nArgs) {
  13871. try {
  13872. args = JSON.parse(l10nArgs);
  13873. } catch (e) {
  13874. console.warn('could not parse arguments for #' + l10nId);
  13875. }
  13876. }
  13877. return {
  13878. id: l10nId,
  13879. args: args
  13880. };
  13881. }
  13882. function xhrLoadText(url, onSuccess, onFailure) {
  13883. onSuccess = onSuccess || function _onSuccess(data) { };
  13884. onFailure = onFailure || function _onFailure() { };
  13885. var xhr = new XMLHttpRequest();
  13886. xhr.open('GET', url, gAsyncResourceLoading);
  13887. if (xhr.overrideMimeType) {
  13888. xhr.overrideMimeType('text/plain; charset=utf-8');
  13889. }
  13890. xhr.onreadystatechange = function () {
  13891. if (xhr.readyState == 4) {
  13892. if (xhr.status == 200 || xhr.status === 0) {
  13893. onSuccess(xhr.responseText);
  13894. } else {
  13895. onFailure();
  13896. }
  13897. }
  13898. };
  13899. xhr.onerror = onFailure;
  13900. xhr.ontimeout = onFailure;
  13901. try {
  13902. xhr.send(null);
  13903. } catch (e) {
  13904. onFailure();
  13905. }
  13906. }
  13907. function parseResource(href, lang, successCallback, failureCallback) {
  13908. var baseURL = href.replace(/[^\/]*$/, '') || './';
  13909. function evalString(text) {
  13910. if (text.lastIndexOf('\\') < 0) return text;
  13911. 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, "'");
  13912. }
  13913. function parseProperties(text, parsedPropertiesCallback) {
  13914. var dictionary = {};
  13915. var reBlank = /^\s*|\s*$/;
  13916. var reComment = /^\s*#|^\s*$/;
  13917. var reSection = /^\s*\[(.*)\]\s*$/;
  13918. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  13919. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  13920. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  13921. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  13922. var currentLang = '*';
  13923. var genericLang = lang.split('-', 1)[0];
  13924. var skipLang = false;
  13925. var match = '';
  13926. function nextEntry() {
  13927. while (true) {
  13928. if (!entries.length) {
  13929. parsedRawLinesCallback();
  13930. return;
  13931. }
  13932. var line = entries.shift();
  13933. if (reComment.test(line)) continue;
  13934. if (extendedSyntax) {
  13935. match = reSection.exec(line);
  13936. if (match) {
  13937. currentLang = match[1].toLowerCase();
  13938. skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
  13939. continue;
  13940. } else if (skipLang) {
  13941. continue;
  13942. }
  13943. match = reImport.exec(line);
  13944. if (match) {
  13945. loadImport(baseURL + match[1], nextEntry);
  13946. return;
  13947. }
  13948. }
  13949. var tmp = line.match(reSplit);
  13950. if (tmp && tmp.length == 3) {
  13951. dictionary[tmp[1]] = evalString(tmp[2]);
  13952. }
  13953. }
  13954. }
  13955. nextEntry();
  13956. }
  13957. function loadImport(url, callback) {
  13958. xhrLoadText(url, function (content) {
  13959. parseRawLines(content, false, callback);
  13960. }, function () {
  13961. console.warn(url + ' not found.');
  13962. callback();
  13963. });
  13964. }
  13965. parseRawLines(text, true, function () {
  13966. parsedPropertiesCallback(dictionary);
  13967. });
  13968. }
  13969. xhrLoadText(href, function (response) {
  13970. gTextData += response;
  13971. parseProperties(response, function (data) {
  13972. for (var key in data) {
  13973. var id,
  13974. prop,
  13975. index = key.lastIndexOf('.');
  13976. if (index > 0) {
  13977. id = key.substring(0, index);
  13978. prop = key.substring(index + 1);
  13979. } else {
  13980. id = key;
  13981. prop = gTextProp;
  13982. }
  13983. if (!gL10nData[id]) {
  13984. gL10nData[id] = {};
  13985. }
  13986. gL10nData[id][prop] = data[key];
  13987. }
  13988. if (successCallback) {
  13989. successCallback();
  13990. }
  13991. });
  13992. }, failureCallback);
  13993. }
  13994. function loadLocale(lang, callback) {
  13995. if (lang) {
  13996. lang = lang.toLowerCase();
  13997. }
  13998. callback = callback || function _callback() { };
  13999. clear();
  14000. gLanguage = lang;
  14001. var langLinks = getL10nResourceLinks();
  14002. var langCount = langLinks.length;
  14003. if (langCount === 0) {
  14004. var dict = getL10nDictionary();
  14005. if (dict && dict.locales && dict.default_locale) {
  14006. console.log('using the embedded JSON directory, early way out');
  14007. gL10nData = dict.locales[lang];
  14008. if (!gL10nData) {
  14009. var defaultLocale = dict.default_locale.toLowerCase();
  14010. for (var anyCaseLang in dict.locales) {
  14011. anyCaseLang = anyCaseLang.toLowerCase();
  14012. if (anyCaseLang === lang) {
  14013. gL10nData = dict.locales[lang];
  14014. break;
  14015. } else if (anyCaseLang === defaultLocale) {
  14016. gL10nData = dict.locales[defaultLocale];
  14017. }
  14018. }
  14019. }
  14020. callback();
  14021. } else {
  14022. console.log('no resource to load, early way out');
  14023. }
  14024. gReadyState = 'complete';
  14025. return;
  14026. }
  14027. var onResourceLoaded = null;
  14028. var gResourceCount = 0;
  14029. onResourceLoaded = function () {
  14030. gResourceCount++;
  14031. if (gResourceCount >= langCount) {
  14032. callback();
  14033. gReadyState = 'complete';
  14034. }
  14035. };
  14036. function L10nResourceLink(link) {
  14037. var href = link.href;
  14038. this.load = function (lang, callback) {
  14039. parseResource(href, lang, callback, function () {
  14040. console.warn(href + ' not found.');
  14041. console.warn('"' + lang + '" resource not found');
  14042. gLanguage = '';
  14043. callback();
  14044. });
  14045. };
  14046. }
  14047. for (var i = 0; i < langCount; i++) {
  14048. var resource = new L10nResourceLink(langLinks[i]);
  14049. resource.load(lang, onResourceLoaded);
  14050. }
  14051. }
  14052. function clear() {
  14053. gL10nData = {};
  14054. gTextData = '';
  14055. gLanguage = '';
  14056. }
  14057. function getPluralRules(lang) {
  14058. var locales2rules = {
  14059. 'af': 3,
  14060. 'ak': 4,
  14061. 'am': 4,
  14062. 'ar': 1,
  14063. 'asa': 3,
  14064. 'az': 0,
  14065. 'be': 11,
  14066. 'bem': 3,
  14067. 'bez': 3,
  14068. 'bg': 3,
  14069. 'bh': 4,
  14070. 'bm': 0,
  14071. 'bn': 3,
  14072. 'bo': 0,
  14073. 'br': 20,
  14074. 'brx': 3,
  14075. 'bs': 11,
  14076. 'ca': 3,
  14077. 'cgg': 3,
  14078. 'chr': 3,
  14079. 'cs': 12,
  14080. 'cy': 17,
  14081. 'da': 3,
  14082. 'de': 3,
  14083. 'dv': 3,
  14084. 'dz': 0,
  14085. 'ee': 3,
  14086. 'el': 3,
  14087. 'en': 3,
  14088. 'eo': 3,
  14089. 'es': 3,
  14090. 'et': 3,
  14091. 'eu': 3,
  14092. 'fa': 0,
  14093. 'ff': 5,
  14094. 'fi': 3,
  14095. 'fil': 4,
  14096. 'fo': 3,
  14097. 'fr': 5,
  14098. 'fur': 3,
  14099. 'fy': 3,
  14100. 'ga': 8,
  14101. 'gd': 24,
  14102. 'gl': 3,
  14103. 'gsw': 3,
  14104. 'gu': 3,
  14105. 'guw': 4,
  14106. 'gv': 23,
  14107. 'ha': 3,
  14108. 'haw': 3,
  14109. 'he': 2,
  14110. 'hi': 4,
  14111. 'hr': 11,
  14112. 'hu': 0,
  14113. 'id': 0,
  14114. 'ig': 0,
  14115. 'ii': 0,
  14116. 'is': 3,
  14117. 'it': 3,
  14118. 'iu': 7,
  14119. 'ja': 0,
  14120. 'jmc': 3,
  14121. 'jv': 0,
  14122. 'ka': 0,
  14123. 'kab': 5,
  14124. 'kaj': 3,
  14125. 'kcg': 3,
  14126. 'kde': 0,
  14127. 'kea': 0,
  14128. 'kk': 3,
  14129. 'kl': 3,
  14130. 'km': 0,
  14131. 'kn': 0,
  14132. 'ko': 0,
  14133. 'ksb': 3,
  14134. 'ksh': 21,
  14135. 'ku': 3,
  14136. 'kw': 7,
  14137. 'lag': 18,
  14138. 'lb': 3,
  14139. 'lg': 3,
  14140. 'ln': 4,
  14141. 'lo': 0,
  14142. 'lt': 10,
  14143. 'lv': 6,
  14144. 'mas': 3,
  14145. 'mg': 4,
  14146. 'mk': 16,
  14147. 'ml': 3,
  14148. 'mn': 3,
  14149. 'mo': 9,
  14150. 'mr': 3,
  14151. 'ms': 0,
  14152. 'mt': 15,
  14153. 'my': 0,
  14154. 'nah': 3,
  14155. 'naq': 7,
  14156. 'nb': 3,
  14157. 'nd': 3,
  14158. 'ne': 3,
  14159. 'nl': 3,
  14160. 'nn': 3,
  14161. 'no': 3,
  14162. 'nr': 3,
  14163. 'nso': 4,
  14164. 'ny': 3,
  14165. 'nyn': 3,
  14166. 'om': 3,
  14167. 'or': 3,
  14168. 'pa': 3,
  14169. 'pap': 3,
  14170. 'pl': 13,
  14171. 'ps': 3,
  14172. 'pt': 3,
  14173. 'rm': 3,
  14174. 'ro': 9,
  14175. 'rof': 3,
  14176. 'ru': 11,
  14177. 'rwk': 3,
  14178. 'sah': 0,
  14179. 'saq': 3,
  14180. 'se': 7,
  14181. 'seh': 3,
  14182. 'ses': 0,
  14183. 'sg': 0,
  14184. 'sh': 11,
  14185. 'shi': 19,
  14186. 'sk': 12,
  14187. 'sl': 14,
  14188. 'sma': 7,
  14189. 'smi': 7,
  14190. 'smj': 7,
  14191. 'smn': 7,
  14192. 'sms': 7,
  14193. 'sn': 3,
  14194. 'so': 3,
  14195. 'sq': 3,
  14196. 'sr': 11,
  14197. 'ss': 3,
  14198. 'ssy': 3,
  14199. 'st': 3,
  14200. 'sv': 3,
  14201. 'sw': 3,
  14202. 'syr': 3,
  14203. 'ta': 3,
  14204. 'te': 3,
  14205. 'teo': 3,
  14206. 'th': 0,
  14207. 'ti': 4,
  14208. 'tig': 3,
  14209. 'tk': 3,
  14210. 'tl': 4,
  14211. 'tn': 3,
  14212. 'to': 0,
  14213. 'tr': 0,
  14214. 'ts': 3,
  14215. 'tzm': 22,
  14216. 'uk': 11,
  14217. 'ur': 3,
  14218. 've': 3,
  14219. 'vi': 0,
  14220. 'vun': 3,
  14221. 'wa': 4,
  14222. 'wae': 3,
  14223. 'wo': 0,
  14224. 'xh': 3,
  14225. 'xog': 3,
  14226. 'yo': 0,
  14227. 'zh': 0,
  14228. 'zu': 3
  14229. };
  14230. function isIn(n, list) {
  14231. return list.indexOf(n) !== -1;
  14232. }
  14233. function isBetween(n, start, end) {
  14234. return start <= n && n <= end;
  14235. }
  14236. var pluralRules = {
  14237. '0': function (n) {
  14238. return 'other';
  14239. },
  14240. '1': function (n) {
  14241. if (isBetween(n % 100, 3, 10)) return 'few';
  14242. if (n === 0) return 'zero';
  14243. if (isBetween(n % 100, 11, 99)) return 'many';
  14244. if (n == 2) return 'two';
  14245. if (n == 1) return 'one';
  14246. return 'other';
  14247. },
  14248. '2': function (n) {
  14249. if (n !== 0 && n % 10 === 0) return 'many';
  14250. if (n == 2) return 'two';
  14251. if (n == 1) return 'one';
  14252. return 'other';
  14253. },
  14254. '3': function (n) {
  14255. if (n == 1) return 'one';
  14256. return 'other';
  14257. },
  14258. '4': function (n) {
  14259. if (isBetween(n, 0, 1)) return 'one';
  14260. return 'other';
  14261. },
  14262. '5': function (n) {
  14263. if (isBetween(n, 0, 2) && n != 2) return 'one';
  14264. return 'other';
  14265. },
  14266. '6': function (n) {
  14267. if (n === 0) return 'zero';
  14268. if (n % 10 == 1 && n % 100 != 11) return 'one';
  14269. return 'other';
  14270. },
  14271. '7': function (n) {
  14272. if (n == 2) return 'two';
  14273. if (n == 1) return 'one';
  14274. return 'other';
  14275. },
  14276. '8': function (n) {
  14277. if (isBetween(n, 3, 6)) return 'few';
  14278. if (isBetween(n, 7, 10)) return 'many';
  14279. if (n == 2) return 'two';
  14280. if (n == 1) return 'one';
  14281. return 'other';
  14282. },
  14283. '9': function (n) {
  14284. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  14285. if (n == 1) return 'one';
  14286. return 'other';
  14287. },
  14288. '10': function (n) {
  14289. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  14290. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  14291. return 'other';
  14292. },
  14293. '11': function (n) {
  14294. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  14295. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
  14296. if (n % 10 == 1 && n % 100 != 11) return 'one';
  14297. return 'other';
  14298. },
  14299. '12': function (n) {
  14300. if (isBetween(n, 2, 4)) return 'few';
  14301. if (n == 1) return 'one';
  14302. return 'other';
  14303. },
  14304. '13': function (n) {
  14305. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  14306. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
  14307. if (n == 1) return 'one';
  14308. return 'other';
  14309. },
  14310. '14': function (n) {
  14311. if (isBetween(n % 100, 3, 4)) return 'few';
  14312. if (n % 100 == 2) return 'two';
  14313. if (n % 100 == 1) return 'one';
  14314. return 'other';
  14315. },
  14316. '15': function (n) {
  14317. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  14318. if (isBetween(n % 100, 11, 19)) return 'many';
  14319. if (n == 1) return 'one';
  14320. return 'other';
  14321. },
  14322. '16': function (n) {
  14323. if (n % 10 == 1 && n != 11) return 'one';
  14324. return 'other';
  14325. },
  14326. '17': function (n) {
  14327. if (n == 3) return 'few';
  14328. if (n === 0) return 'zero';
  14329. if (n == 6) return 'many';
  14330. if (n == 2) return 'two';
  14331. if (n == 1) return 'one';
  14332. return 'other';
  14333. },
  14334. '18': function (n) {
  14335. if (n === 0) return 'zero';
  14336. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  14337. return 'other';
  14338. },
  14339. '19': function (n) {
  14340. if (isBetween(n, 2, 10)) return 'few';
  14341. if (isBetween(n, 0, 1)) return 'one';
  14342. return 'other';
  14343. },
  14344. '20': function (n) {
  14345. 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';
  14346. if (n % 1000000 === 0 && n !== 0) return 'many';
  14347. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  14348. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  14349. return 'other';
  14350. },
  14351. '21': function (n) {
  14352. if (n === 0) return 'zero';
  14353. if (n == 1) return 'one';
  14354. return 'other';
  14355. },
  14356. '22': function (n) {
  14357. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  14358. return 'other';
  14359. },
  14360. '23': function (n) {
  14361. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  14362. return 'other';
  14363. },
  14364. '24': function (n) {
  14365. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  14366. if (isIn(n, [2, 12])) return 'two';
  14367. if (isIn(n, [1, 11])) return 'one';
  14368. return 'other';
  14369. }
  14370. };
  14371. var index = locales2rules[lang.replace(/-.*$/, '')];
  14372. if (!(index in pluralRules)) {
  14373. console.warn('plural form unknown for [' + lang + ']');
  14374. return function () {
  14375. return 'other';
  14376. };
  14377. }
  14378. return pluralRules[index];
  14379. }
  14380. gMacros.plural = function (str, param, key, prop) {
  14381. var n = parseFloat(param);
  14382. if (isNaN(n)) return str;
  14383. if (prop != gTextProp) return str;
  14384. if (!gMacros._pluralRules) {
  14385. gMacros._pluralRules = getPluralRules(gLanguage);
  14386. }
  14387. var index = '[' + gMacros._pluralRules(n) + ']';
  14388. if (n === 0 && key + '[zero]' in gL10nData) {
  14389. str = gL10nData[key + '[zero]'][prop];
  14390. } else if (n == 1 && key + '[one]' in gL10nData) {
  14391. str = gL10nData[key + '[one]'][prop];
  14392. } else if (n == 2 && key + '[two]' in gL10nData) {
  14393. str = gL10nData[key + '[two]'][prop];
  14394. } else if (key + index in gL10nData) {
  14395. str = gL10nData[key + index][prop];
  14396. } else if (key + '[other]' in gL10nData) {
  14397. str = gL10nData[key + '[other]'][prop];
  14398. }
  14399. return str;
  14400. };
  14401. function getL10nData(key, args, fallback) {
  14402. var data = gL10nData[key];
  14403. if (!data) {
  14404. console.warn('#' + key + ' is undefined.');
  14405. if (!fallback) {
  14406. return null;
  14407. }
  14408. data = fallback;
  14409. }
  14410. var rv = {};
  14411. for (var prop in data) {
  14412. var str = data[prop];
  14413. str = substIndexes(str, args, key, prop);
  14414. str = substArguments(str, args, key);
  14415. rv[prop] = str;
  14416. }
  14417. return rv;
  14418. }
  14419. function substIndexes(str, args, key, prop) {
  14420. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  14421. var reMatch = reIndex.exec(str);
  14422. if (!reMatch || !reMatch.length) return str;
  14423. var macroName = reMatch[1];
  14424. var paramName = reMatch[2];
  14425. var param;
  14426. if (args && paramName in args) {
  14427. param = args[paramName];
  14428. } else if (paramName in gL10nData) {
  14429. param = gL10nData[paramName];
  14430. }
  14431. if (macroName in gMacros) {
  14432. var macro = gMacros[macroName];
  14433. str = macro(str, param, key, prop);
  14434. }
  14435. return str;
  14436. }
  14437. function substArguments(str, args, key) {
  14438. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  14439. return str.replace(reArgs, function (matched_text, arg) {
  14440. if (args && arg in args) {
  14441. return args[arg];
  14442. }
  14443. if (arg in gL10nData) {
  14444. return gL10nData[arg];
  14445. }
  14446. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  14447. return matched_text;
  14448. });
  14449. }
  14450. function translateElement(element) {
  14451. var l10n = getL10nAttributes(element);
  14452. if (!l10n.id) return;
  14453. var data = getL10nData(l10n.id, l10n.args);
  14454. if (!data) {
  14455. console.warn('#' + l10n.id + ' is undefined.');
  14456. return;
  14457. }
  14458. if (data[gTextProp]) {
  14459. if (getChildElementCount(element) === 0) {
  14460. element[gTextProp] = data[gTextProp];
  14461. } else {
  14462. var children = element.childNodes;
  14463. var found = false;
  14464. for (var i = 0, l = children.length; i < l; i++) {
  14465. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  14466. if (found) {
  14467. children[i].nodeValue = '';
  14468. } else {
  14469. children[i].nodeValue = data[gTextProp];
  14470. found = true;
  14471. }
  14472. }
  14473. }
  14474. if (!found) {
  14475. var textNode = document.createTextNode(data[gTextProp]);
  14476. element.prepend(textNode);
  14477. }
  14478. }
  14479. delete data[gTextProp];
  14480. }
  14481. for (var k in data) {
  14482. element[k] = data[k];
  14483. }
  14484. }
  14485. function getChildElementCount(element) {
  14486. if (element.children) {
  14487. return element.children.length;
  14488. }
  14489. if (typeof element.childElementCount !== 'undefined') {
  14490. return element.childElementCount;
  14491. }
  14492. var count = 0;
  14493. for (var i = 0; i < element.childNodes.length; i++) {
  14494. count += element.nodeType === 1 ? 1 : 0;
  14495. }
  14496. return count;
  14497. }
  14498. function translateFragment(element) {
  14499. element = element || document.documentElement;
  14500. var children = getTranslatableChildren(element);
  14501. var elementCount = children.length;
  14502. for (var i = 0; i < elementCount; i++) {
  14503. translateElement(children[i]);
  14504. }
  14505. translateElement(element);
  14506. }
  14507. return {
  14508. get: function (key, args, fallbackString) {
  14509. var index = key.lastIndexOf('.');
  14510. var prop = gTextProp;
  14511. if (index > 0) {
  14512. prop = key.substring(index + 1);
  14513. key = key.substring(0, index);
  14514. }
  14515. var fallback;
  14516. if (fallbackString) {
  14517. fallback = {};
  14518. fallback[prop] = fallbackString;
  14519. }
  14520. var data = getL10nData(key, args, fallback);
  14521. if (data && prop in data) {
  14522. return data[prop];
  14523. }
  14524. return '{{' + key + '}}';
  14525. },
  14526. getData: function () {
  14527. return gL10nData;
  14528. },
  14529. getText: function () {
  14530. return gTextData;
  14531. },
  14532. getLanguage: function () {
  14533. return gLanguage;
  14534. },
  14535. setLanguage: function (lang, callback) {
  14536. loadLocale(lang, function () {
  14537. if (callback) callback();
  14538. });
  14539. },
  14540. getDirection: function () {
  14541. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  14542. var shortCode = gLanguage.split('-', 1)[0];
  14543. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  14544. },
  14545. translate: translateFragment,
  14546. getReadyState: function () {
  14547. return gReadyState;
  14548. },
  14549. ready: function (callback) {
  14550. if (!callback) {
  14551. return;
  14552. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  14553. window.setTimeout(function () {
  14554. callback();
  14555. });
  14556. } else if (document.addEventListener) {
  14557. document.addEventListener('localized', function once() {
  14558. document.removeEventListener('localized', once);
  14559. callback();
  14560. });
  14561. }
  14562. }
  14563. };
  14564. }(window, document);
  14565. /***/
  14566. }),
  14567. /* 47 */
  14568. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  14569. Object.defineProperty(exports, "__esModule", ({
  14570. value: true
  14571. }));
  14572. exports.GenericScripting = void 0;
  14573. exports.docPropertiesLookup = docPropertiesLookup;
  14574. var _pdfjsLib = __webpack_require__(4);
  14575. async function docPropertiesLookup(pdfDocument) {
  14576. const url = "",
  14577. baseUrl = url.split("#")[0];
  14578. let {
  14579. info,
  14580. metadata,
  14581. contentDispositionFilename,
  14582. contentLength
  14583. } = await pdfDocument.getMetadata();
  14584. if (!contentLength) {
  14585. const {
  14586. length
  14587. } = await pdfDocument.getDownloadInfo();
  14588. contentLength = length;
  14589. }
  14590. return {
  14591. ...info,
  14592. baseURL: baseUrl,
  14593. filesize: contentLength,
  14594. filename: contentDispositionFilename || (0, _pdfjsLib.getPdfFilenameFromUrl)(url),
  14595. metadata: metadata === null || metadata === void 0 ? void 0 : metadata.getRaw(),
  14596. authors: metadata === null || metadata === void 0 ? void 0 : metadata.get("dc:creator"),
  14597. numPages: pdfDocument.numPages,
  14598. URL: url
  14599. };
  14600. }
  14601. class GenericScripting {
  14602. constructor(sandboxBundleSrc) {
  14603. this._ready = (0, _pdfjsLib.loadScript)(sandboxBundleSrc, true).then(() => {
  14604. return window.pdfjsSandbox.QuickJSSandbox();
  14605. });
  14606. }
  14607. async createSandbox(data) {
  14608. const sandbox = await this._ready;
  14609. sandbox.create(data);
  14610. }
  14611. async dispatchEventInSandbox(event) {
  14612. const sandbox = await this._ready;
  14613. setTimeout(() => sandbox.dispatchEvent(event), 0);
  14614. }
  14615. async destroySandbox() {
  14616. const sandbox = await this._ready;
  14617. sandbox.nukeSandbox();
  14618. }
  14619. }
  14620. exports.GenericScripting = GenericScripting;
  14621. /***/
  14622. }),
  14623. /* 48 */
  14624. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  14625. Object.defineProperty(exports, "__esModule", ({
  14626. value: true
  14627. }));
  14628. exports.PDFPrintService = PDFPrintService;
  14629. var _pdfjsLib = __webpack_require__(4);
  14630. var _app = __webpack_require__(2);
  14631. var _print_utils = __webpack_require__(49);
  14632. let activeService = null;
  14633. let dialog = null;
  14634. let overlayManager = null;
  14635. function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size, printResolution, optionalContentConfigPromise, printAnnotationStoragePromise) {
  14636. const scratchCanvas = activeService.scratchCanvas;
  14637. const PRINT_UNITS = printResolution / _pdfjsLib.PixelsPerInch.PDF;
  14638. scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
  14639. scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
  14640. const ctx = scratchCanvas.getContext("2d");
  14641. ctx.save();
  14642. ctx.fillStyle = "rgb(255, 255, 255)";
  14643. ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height);
  14644. ctx.restore();
  14645. return Promise.all([pdfDocument.getPage(pageNumber), printAnnotationStoragePromise]).then(function (_ref) {
  14646. let [pdfPage, printAnnotationStorage] = _ref;
  14647. const renderContext = {
  14648. canvasContext: ctx,
  14649. transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
  14650. viewport: pdfPage.getViewport({
  14651. scale: 1,
  14652. rotation: size.rotation
  14653. }),
  14654. intent: "print",
  14655. annotationMode: _pdfjsLib.AnnotationMode.ENABLE_STORAGE,
  14656. optionalContentConfigPromise,
  14657. printAnnotationStorage
  14658. };
  14659. return pdfPage.render(renderContext).promise;
  14660. });
  14661. }
  14662. function PDFPrintService(pdfDocument, pagesOverview, printContainer, printResolution) {
  14663. let optionalContentConfigPromise = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
  14664. let printAnnotationStoragePromise = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
  14665. let l10n = arguments.length > 6 ? arguments[6] : undefined;
  14666. this.pdfDocument = pdfDocument;
  14667. this.pagesOverview = pagesOverview;
  14668. this.printContainer = printContainer;
  14669. this._printResolution = printResolution || 150;
  14670. this._optionalContentConfigPromise = optionalContentConfigPromise || pdfDocument.getOptionalContentConfig();
  14671. this._printAnnotationStoragePromise = printAnnotationStoragePromise || Promise.resolve();
  14672. this.l10n = l10n;
  14673. this.currentPage = -1;
  14674. this.scratchCanvas = document.createElement("canvas");
  14675. }
  14676. PDFPrintService.prototype = {
  14677. layout() {
  14678. this.throwIfInactive();
  14679. const body = document.querySelector("body");
  14680. body.setAttribute("data-pdfjsprinting", true);
  14681. const hasEqualPageSizes = this.pagesOverview.every(function (size) {
  14682. return size.width === this.pagesOverview[0].width && size.height === this.pagesOverview[0].height;
  14683. }, this);
  14684. if (!hasEqualPageSizes) {
  14685. console.warn("Not all pages have the same size. The printed " + "result may be incorrect!");
  14686. }
  14687. this.pageStyleSheet = document.createElement("style");
  14688. const pageSize = this.pagesOverview[0];
  14689. this.pageStyleSheet.textContent = "@page { size: " + pageSize.width + "pt " + pageSize.height + "pt;}";
  14690. body.append(this.pageStyleSheet);
  14691. },
  14692. destroy() {
  14693. if (activeService !== this) {
  14694. return;
  14695. }
  14696. this.printContainer.textContent = "";
  14697. const body = document.querySelector("body");
  14698. body.removeAttribute("data-pdfjsprinting");
  14699. if (this.pageStyleSheet) {
  14700. this.pageStyleSheet.remove();
  14701. this.pageStyleSheet = null;
  14702. }
  14703. this.scratchCanvas.width = this.scratchCanvas.height = 0;
  14704. this.scratchCanvas = null;
  14705. activeService = null;
  14706. ensureOverlay().then(function () {
  14707. if (overlayManager.active === dialog) {
  14708. overlayManager.close(dialog);
  14709. }
  14710. });
  14711. },
  14712. renderPages() {
  14713. if (this.pdfDocument.isPureXfa) {
  14714. (0, _print_utils.getXfaHtmlForPrinting)(this.printContainer, this.pdfDocument);
  14715. return Promise.resolve();
  14716. }
  14717. const pageCount = this.pagesOverview.length;
  14718. const renderNextPage = (resolve, reject) => {
  14719. this.throwIfInactive();
  14720. if (++this.currentPage >= pageCount) {
  14721. renderProgress(pageCount, pageCount, this.l10n);
  14722. resolve();
  14723. return;
  14724. }
  14725. const index = this.currentPage;
  14726. renderProgress(index, pageCount, this.l10n);
  14727. renderPage(this, this.pdfDocument, index + 1, this.pagesOverview[index], this._printResolution, this._optionalContentConfigPromise, this._printAnnotationStoragePromise).then(this.useRenderedPage.bind(this)).then(function () {
  14728. renderNextPage(resolve, reject);
  14729. }, reject);
  14730. };
  14731. return new Promise(renderNextPage);
  14732. },
  14733. useRenderedPage() {
  14734. this.throwIfInactive();
  14735. const img = document.createElement("img");
  14736. const scratchCanvas = this.scratchCanvas;
  14737. if ("toBlob" in scratchCanvas) {
  14738. scratchCanvas.toBlob(function (blob) {
  14739. img.src = URL.createObjectURL(blob);
  14740. });
  14741. } else {
  14742. img.src = scratchCanvas.toDataURL();
  14743. }
  14744. const wrapper = document.createElement("div");
  14745. wrapper.className = "printedPage";
  14746. wrapper.append(img);
  14747. this.printContainer.append(wrapper);
  14748. return new Promise(function (resolve, reject) {
  14749. img.onload = resolve;
  14750. img.onerror = reject;
  14751. });
  14752. },
  14753. performPrint() {
  14754. this.throwIfInactive();
  14755. return new Promise(resolve => {
  14756. setTimeout(() => {
  14757. if (!this.active) {
  14758. resolve();
  14759. return;
  14760. }
  14761. print.call(window);
  14762. setTimeout(resolve, 20);
  14763. }, 0);
  14764. });
  14765. },
  14766. get active() {
  14767. return this === activeService;
  14768. },
  14769. throwIfInactive() {
  14770. if (!this.active) {
  14771. throw new Error("This print request was cancelled or completed.");
  14772. }
  14773. }
  14774. };
  14775. const print = window.print;
  14776. window.print = function () {
  14777. if (activeService) {
  14778. console.warn("Ignored window.print() because of a pending print job.");
  14779. return;
  14780. }
  14781. ensureOverlay().then(function () {
  14782. if (activeService) {
  14783. overlayManager.open(dialog);
  14784. }
  14785. });
  14786. try {
  14787. dispatchEvent("beforeprint");
  14788. } finally {
  14789. if (!activeService) {
  14790. console.error("Expected print service to be initialized.");
  14791. ensureOverlay().then(function () {
  14792. if (overlayManager.active === dialog) {
  14793. overlayManager.close(dialog);
  14794. }
  14795. });
  14796. return;
  14797. }
  14798. const activeServiceOnEntry = activeService;
  14799. activeService.renderPages().then(function () {
  14800. return activeServiceOnEntry.performPrint();
  14801. }).catch(function () { }).then(function () {
  14802. if (activeServiceOnEntry.active) {
  14803. abort();
  14804. }
  14805. });
  14806. }
  14807. };
  14808. function dispatchEvent(eventType) {
  14809. const event = document.createEvent("CustomEvent");
  14810. event.initCustomEvent(eventType, false, false, "custom");
  14811. window.dispatchEvent(event);
  14812. }
  14813. function abort() {
  14814. if (activeService) {
  14815. activeService.destroy();
  14816. dispatchEvent("afterprint");
  14817. }
  14818. }
  14819. function renderProgress(index, total, l10n) {
  14820. dialog || (dialog = document.getElementById("printServiceDialog"));
  14821. const progress = Math.round(100 * index / total);
  14822. const progressBar = dialog.querySelector("progress");
  14823. const progressPerc = dialog.querySelector(".relative-progress");
  14824. progressBar.value = progress;
  14825. l10n.get("print_progress_percent", {
  14826. progress
  14827. }).then(msg => {
  14828. progressPerc.textContent = msg;
  14829. });
  14830. }
  14831. window.addEventListener("keydown", function (event) {
  14832. if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
  14833. window.print();
  14834. event.preventDefault();
  14835. event.stopImmediatePropagation();
  14836. }
  14837. }, true);
  14838. if ("onbeforeprint" in window) {
  14839. const stopPropagationIfNeeded = function (event) {
  14840. if (event.detail !== "custom") {
  14841. event.stopImmediatePropagation();
  14842. }
  14843. };
  14844. window.addEventListener("beforeprint", stopPropagationIfNeeded);
  14845. window.addEventListener("afterprint", stopPropagationIfNeeded);
  14846. }
  14847. let overlayPromise;
  14848. function ensureOverlay() {
  14849. if (!overlayPromise) {
  14850. overlayManager = _app.PDFViewerApplication.overlayManager;
  14851. if (!overlayManager) {
  14852. throw new Error("The overlay manager has not yet been initialized.");
  14853. }
  14854. dialog || (dialog = document.getElementById("printServiceDialog"));
  14855. overlayPromise = overlayManager.register(dialog, true);
  14856. document.getElementById("printCancel").onclick = abort;
  14857. dialog.addEventListener("close", abort);
  14858. }
  14859. return overlayPromise;
  14860. }
  14861. _app.PDFPrintServiceFactory.instance = {
  14862. supportsPrinting: true,
  14863. createPrintService(pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, printAnnotationStoragePromise, l10n) {
  14864. if (activeService) {
  14865. throw new Error("The print service is created and active.");
  14866. }
  14867. activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, printAnnotationStoragePromise, l10n);
  14868. return activeService;
  14869. }
  14870. };
  14871. /***/
  14872. }),
  14873. /* 49 */
  14874. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  14875. Object.defineProperty(exports, "__esModule", ({
  14876. value: true
  14877. }));
  14878. exports.getXfaHtmlForPrinting = getXfaHtmlForPrinting;
  14879. var _pdfjsLib = __webpack_require__(4);
  14880. var _pdf_link_service = __webpack_require__(7);
  14881. var _xfa_layer_builder = __webpack_require__(39);
  14882. function getXfaHtmlForPrinting(printContainer, pdfDocument) {
  14883. const xfaHtml = pdfDocument.allXfaHtml;
  14884. const linkService = new _pdf_link_service.SimpleLinkService();
  14885. const scale = Math.round(_pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS * 100) / 100;
  14886. for (const xfaPage of xfaHtml.children) {
  14887. const page = document.createElement("div");
  14888. page.className = "xfaPrintedPage";
  14889. printContainer.append(page);
  14890. const builder = new _xfa_layer_builder.XfaLayerBuilder({
  14891. pageDiv: page,
  14892. pdfPage: null,
  14893. annotationStorage: pdfDocument.annotationStorage,
  14894. linkService,
  14895. xfaHtml: xfaPage
  14896. });
  14897. const viewport = (0, _pdfjsLib.getXfaPageViewport)(xfaPage, {
  14898. scale
  14899. });
  14900. builder.render(viewport, "print");
  14901. }
  14902. }
  14903. /***/
  14904. })
  14905. /******/]);
  14906. /************************************************************************/
  14907. /******/ // The module cache
  14908. /******/ var __webpack_module_cache__ = {};
  14909. /******/
  14910. /******/ // The require function
  14911. /******/ function __webpack_require__(moduleId) {
  14912. /******/ // Check if module is in cache
  14913. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  14914. /******/ if (cachedModule !== undefined) {
  14915. /******/ return cachedModule.exports;
  14916. /******/
  14917. }
  14918. /******/ // Create a new module (and put it into the cache)
  14919. /******/ var module = __webpack_module_cache__[moduleId] = {
  14920. /******/ // no module.id needed
  14921. /******/ // no module.loaded needed
  14922. /******/ exports: {}
  14923. /******/
  14924. };
  14925. /******/
  14926. /******/ // Execute the module function
  14927. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  14928. /******/
  14929. /******/ // Return the exports of the module
  14930. /******/ return module.exports;
  14931. /******/
  14932. }
  14933. /******/
  14934. /************************************************************************/
  14935. var __webpack_exports__ = {};
  14936. // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
  14937. (() => {
  14938. var exports = __webpack_exports__;
  14939. Object.defineProperty(exports, "__esModule", ({
  14940. value: true
  14941. }));
  14942. Object.defineProperty(exports, "PDFViewerApplication", ({
  14943. enumerable: true,
  14944. get: function () {
  14945. return _app.PDFViewerApplication;
  14946. }
  14947. }));
  14948. exports.PDFViewerApplicationConstants = void 0;
  14949. Object.defineProperty(exports, "PDFViewerApplicationOptions", ({
  14950. enumerable: true,
  14951. get: function () {
  14952. return _app_options.AppOptions;
  14953. }
  14954. }));
  14955. __webpack_require__(1);
  14956. __webpack_require__(48);
  14957. var _ui_utils = __webpack_require__(3);
  14958. var _app_options = __webpack_require__(5);
  14959. var _pdf_link_service = __webpack_require__(7);
  14960. var _app = __webpack_require__(2);
  14961. var _document$blockUnbloc, _document;
  14962. const pdfjsVersion = '3.4.120';
  14963. const pdfjsBuild = 'af6414988';
  14964. const AppConstants = {
  14965. LinkTarget: _pdf_link_service.LinkTarget,
  14966. RenderingStates: _ui_utils.RenderingStates,
  14967. ScrollMode: _ui_utils.ScrollMode,
  14968. SpreadMode: _ui_utils.SpreadMode
  14969. };
  14970. exports.PDFViewerApplicationConstants = AppConstants;
  14971. window.PDFViewerApplication = _app.PDFViewerApplication;
  14972. window.PDFViewerApplicationConstants = AppConstants;
  14973. window.PDFViewerApplicationOptions = _app_options.AppOptions;
  14974. function getViewerConfiguration() {
  14975. return {
  14976. appContainer: document.body,
  14977. mainContainer: document.getElementById("viewerContainer"),
  14978. viewerContainer: document.getElementById("viewer"),
  14979. toolbar: {
  14980. container: document.getElementById("toolbarViewer"),
  14981. numPages: document.getElementById("numPages"),
  14982. pageNumber: document.getElementById("pageNumber"),
  14983. scaleSelect: document.getElementById("scaleSelect"),
  14984. customScaleOption: document.getElementById("customScaleOption"),
  14985. previous: document.getElementById("previous"),
  14986. next: document.getElementById("next"),
  14987. zoomIn: document.getElementById("zoomIn"),
  14988. zoomOut: document.getElementById("zoomOut"),
  14989. viewFind: document.getElementById("viewFind"),
  14990. openFile: document.getElementById("openFile"),
  14991. print: document.getElementById("print"),
  14992. editorFreeTextButton: document.getElementById("editorFreeText"),
  14993. editorFreeTextParamsToolbar: document.getElementById("editorFreeTextParamsToolbar"),
  14994. editorInkButton: document.getElementById("editorInk"),
  14995. editorInkParamsToolbar: document.getElementById("editorInkParamsToolbar"),
  14996. download: document.getElementById("download")
  14997. },
  14998. secondaryToolbar: {
  14999. toolbar: document.getElementById("secondaryToolbar"),
  15000. toggleButton: document.getElementById("secondaryToolbarToggle"),
  15001. presentationModeButton: document.getElementById("presentationMode"),
  15002. openFileButton: document.getElementById("secondaryOpenFile"),
  15003. printButton: document.getElementById("secondaryPrint"),
  15004. downloadButton: document.getElementById("secondaryDownload"),
  15005. viewBookmarkButton: document.getElementById("viewBookmark"),
  15006. firstPageButton: document.getElementById("firstPage"),
  15007. lastPageButton: document.getElementById("lastPage"),
  15008. pageRotateCwButton: document.getElementById("pageRotateCw"),
  15009. pageRotateCcwButton: document.getElementById("pageRotateCcw"),
  15010. cursorSelectToolButton: document.getElementById("cursorSelectTool"),
  15011. cursorHandToolButton: document.getElementById("cursorHandTool"),
  15012. scrollPageButton: document.getElementById("scrollPage"),
  15013. scrollVerticalButton: document.getElementById("scrollVertical"),
  15014. scrollHorizontalButton: document.getElementById("scrollHorizontal"),
  15015. scrollWrappedButton: document.getElementById("scrollWrapped"),
  15016. spreadNoneButton: document.getElementById("spreadNone"),
  15017. spreadOddButton: document.getElementById("spreadOdd"),
  15018. spreadEvenButton: document.getElementById("spreadEven"),
  15019. documentPropertiesButton: document.getElementById("documentProperties")
  15020. },
  15021. sidebar: {
  15022. outerContainer: document.getElementById("outerContainer"),
  15023. sidebarContainer: document.getElementById("sidebarContainer"),
  15024. toggleButton: document.getElementById("sidebarToggle"),
  15025. thumbnailButton: document.getElementById("viewThumbnail"),
  15026. outlineButton: document.getElementById("viewOutline"),
  15027. attachmentsButton: document.getElementById("viewAttachments"),
  15028. layersButton: document.getElementById("viewLayers"),
  15029. thumbnailView: document.getElementById("thumbnailView"),
  15030. outlineView: document.getElementById("outlineView"),
  15031. attachmentsView: document.getElementById("attachmentsView"),
  15032. layersView: document.getElementById("layersView"),
  15033. outlineOptionsContainer: document.getElementById("outlineOptionsContainer"),
  15034. currentOutlineItemButton: document.getElementById("currentOutlineItem")
  15035. },
  15036. sidebarResizer: {
  15037. outerContainer: document.getElementById("outerContainer"),
  15038. resizer: document.getElementById("sidebarResizer")
  15039. },
  15040. findBar: {
  15041. bar: document.getElementById("findbar"),
  15042. toggleButton: document.getElementById("viewFind"),
  15043. findField: document.getElementById("findInput"),
  15044. highlightAllCheckbox: document.getElementById("findHighlightAll"),
  15045. caseSensitiveCheckbox: document.getElementById("findMatchCase"),
  15046. matchDiacriticsCheckbox: document.getElementById("findMatchDiacritics"),
  15047. entireWordCheckbox: document.getElementById("findEntireWord"),
  15048. findMsg: document.getElementById("findMsg"),
  15049. findResultsCount: document.getElementById("findResultsCount"),
  15050. findPreviousButton: document.getElementById("findPrevious"),
  15051. findNextButton: document.getElementById("findNext")
  15052. },
  15053. passwordOverlay: {
  15054. dialog: document.getElementById("passwordDialog"),
  15055. label: document.getElementById("passwordText"),
  15056. input: document.getElementById("password"),
  15057. submitButton: document.getElementById("passwordSubmit"),
  15058. cancelButton: document.getElementById("passwordCancel")
  15059. },
  15060. documentProperties: {
  15061. dialog: document.getElementById("documentPropertiesDialog"),
  15062. closeButton: document.getElementById("documentPropertiesClose"),
  15063. fields: {
  15064. fileName: document.getElementById("fileNameField"),
  15065. fileSize: document.getElementById("fileSizeField"),
  15066. title: document.getElementById("titleField"),
  15067. author: document.getElementById("authorField"),
  15068. subject: document.getElementById("subjectField"),
  15069. keywords: document.getElementById("keywordsField"),
  15070. creationDate: document.getElementById("creationDateField"),
  15071. modificationDate: document.getElementById("modificationDateField"),
  15072. creator: document.getElementById("creatorField"),
  15073. producer: document.getElementById("producerField"),
  15074. version: document.getElementById("versionField"),
  15075. pageCount: document.getElementById("pageCountField"),
  15076. pageSize: document.getElementById("pageSizeField"),
  15077. linearized: document.getElementById("linearizedField")
  15078. }
  15079. },
  15080. annotationEditorParams: {
  15081. editorFreeTextFontSize: document.getElementById("editorFreeTextFontSize"),
  15082. editorFreeTextColor: document.getElementById("editorFreeTextColor"),
  15083. editorInkColor: document.getElementById("editorInkColor"),
  15084. editorInkThickness: document.getElementById("editorInkThickness"),
  15085. editorInkOpacity: document.getElementById("editorInkOpacity")
  15086. },
  15087. printContainer: document.getElementById("printContainer"),
  15088. openFileInput: document.getElementById("fileInput"),
  15089. debuggerScriptPath: "./debugger.js"
  15090. };
  15091. }
  15092. function webViewerLoad() {
  15093. const config = getViewerConfiguration();
  15094. const event = document.createEvent("CustomEvent");
  15095. event.initCustomEvent("webviewerloaded", true, true, {
  15096. source: window
  15097. });
  15098. try {
  15099. parent.document.dispatchEvent(event);
  15100. } catch (ex) {
  15101. console.error(`webviewerloaded: ${ex}`);
  15102. document.dispatchEvent(event);
  15103. }
  15104. _app.PDFViewerApplication.run(config);
  15105. }
  15106. (_document$blockUnbloc = (_document = document).blockUnblockOnload) === null || _document$blockUnbloc === void 0 ? void 0 : _document$blockUnbloc.call(_document, true);
  15107. if (document.readyState === "interactive" || document.readyState === "complete") {
  15108. webViewerLoad();
  15109. } else {
  15110. document.addEventListener("DOMContentLoaded", webViewerLoad, true);
  15111. }
  15112. })();
  15113. /******/
  15114. })();
  15115. //# sourceMappingURL=viewer.js.map