viewer.js 608 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2020 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. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  27. Object.defineProperty(exports, "__esModule", ({
  28. value: true
  29. }));
  30. Object.defineProperty(exports, "PDFViewerApplicationOptions", ({
  31. enumerable: true,
  32. get: function get() {
  33. return _app_options.AppOptions;
  34. }
  35. }));
  36. Object.defineProperty(exports, "PDFViewerApplication", ({
  37. enumerable: true,
  38. get: function get() {
  39. return _app.PDFViewerApplication;
  40. }
  41. }));
  42. var _app_options = __webpack_require__(1);
  43. var _app = __webpack_require__(3);
  44. var pdfjsVersion = '2.7.570';
  45. var pdfjsBuild = 'f2c7338b0';
  46. window.PDFViewerApplication = _app.PDFViewerApplication;
  47. window.PDFViewerApplicationOptions = _app_options.AppOptions;
  48. ;
  49. ;
  50. {
  51. __webpack_require__(37);
  52. }
  53. ;
  54. {
  55. __webpack_require__(43);
  56. }
  57. function getViewerConfiguration() {
  58. return {
  59. appContainer: document.body,
  60. mainContainer: document.getElementById("viewerContainer"),
  61. viewerContainer: document.getElementById("viewer"),
  62. eventBus: null,
  63. toolbar: {
  64. container: document.getElementById("toolbarViewer"),
  65. numPages: document.getElementById("numPages"),
  66. pageNumber: document.getElementById("pageNumber"),
  67. scaleSelectContainer: document.getElementById("scaleSelectContainer"),
  68. scaleSelect: document.getElementById("scaleSelect"),
  69. customScaleOption: document.getElementById("customScaleOption"),
  70. previous: document.getElementById("previous"),
  71. next: document.getElementById("next"),
  72. zoomIn: document.getElementById("zoomIn"),
  73. zoomOut: document.getElementById("zoomOut"),
  74. viewFind: document.getElementById("viewFind"),
  75. openFile: document.getElementById("openFile"),
  76. print: document.getElementById("print"),
  77. presentationModeButton: document.getElementById("presentationMode"),
  78. download: document.getElementById("download"),
  79. viewBookmark: document.getElementById("viewBookmark")
  80. },
  81. secondaryToolbar: {
  82. toolbar: document.getElementById("secondaryToolbar"),
  83. toggleButton: document.getElementById("secondaryToolbarToggle"),
  84. toolbarButtonContainer: document.getElementById("secondaryToolbarButtonContainer"),
  85. presentationModeButton: document.getElementById("secondaryPresentationMode"),
  86. openFileButton: document.getElementById("secondaryOpenFile"),
  87. printButton: document.getElementById("secondaryPrint"),
  88. downloadButton: document.getElementById("secondaryDownload"),
  89. viewBookmarkButton: document.getElementById("secondaryViewBookmark"),
  90. firstPageButton: document.getElementById("firstPage"),
  91. lastPageButton: document.getElementById("lastPage"),
  92. pageRotateCwButton: document.getElementById("pageRotateCw"),
  93. pageRotateCcwButton: document.getElementById("pageRotateCcw"),
  94. cursorSelectToolButton: document.getElementById("cursorSelectTool"),
  95. cursorHandToolButton: document.getElementById("cursorHandTool"),
  96. scrollVerticalButton: document.getElementById("scrollVertical"),
  97. scrollHorizontalButton: document.getElementById("scrollHorizontal"),
  98. scrollWrappedButton: document.getElementById("scrollWrapped"),
  99. spreadNoneButton: document.getElementById("spreadNone"),
  100. spreadOddButton: document.getElementById("spreadOdd"),
  101. spreadEvenButton: document.getElementById("spreadEven"),
  102. documentPropertiesButton: document.getElementById("documentProperties")
  103. },
  104. fullscreen: {
  105. contextFirstPage: document.getElementById("contextFirstPage"),
  106. contextLastPage: document.getElementById("contextLastPage"),
  107. contextPageRotateCw: document.getElementById("contextPageRotateCw"),
  108. contextPageRotateCcw: document.getElementById("contextPageRotateCcw")
  109. },
  110. sidebar: {
  111. outerContainer: document.getElementById("outerContainer"),
  112. viewerContainer: document.getElementById("viewerContainer"),
  113. toggleButton: document.getElementById("sidebarToggle"),
  114. thumbnailButton: document.getElementById("viewThumbnail"),
  115. outlineButton: document.getElementById("viewOutline"),
  116. attachmentsButton: document.getElementById("viewAttachments"),
  117. layersButton: document.getElementById("viewLayers"),
  118. thumbnailView: document.getElementById("thumbnailView"),
  119. outlineView: document.getElementById("outlineView"),
  120. attachmentsView: document.getElementById("attachmentsView"),
  121. layersView: document.getElementById("layersView"),
  122. outlineOptionsContainer: document.getElementById("outlineOptionsContainer"),
  123. currentOutlineItemButton: document.getElementById("currentOutlineItem")
  124. },
  125. sidebarResizer: {
  126. outerContainer: document.getElementById("outerContainer"),
  127. resizer: document.getElementById("sidebarResizer")
  128. },
  129. findBar: {
  130. bar: document.getElementById("findbar"),
  131. toggleButton: document.getElementById("viewFind"),
  132. findField: document.getElementById("findInput"),
  133. highlightAllCheckbox: document.getElementById("findHighlightAll"),
  134. caseSensitiveCheckbox: document.getElementById("findMatchCase"),
  135. entireWordCheckbox: document.getElementById("findEntireWord"),
  136. findMsg: document.getElementById("findMsg"),
  137. findResultsCount: document.getElementById("findResultsCount"),
  138. findPreviousButton: document.getElementById("findPrevious"),
  139. findNextButton: document.getElementById("findNext")
  140. },
  141. passwordOverlay: {
  142. overlayName: "passwordOverlay",
  143. container: document.getElementById("passwordOverlay"),
  144. label: document.getElementById("passwordText"),
  145. input: document.getElementById("password"),
  146. submitButton: document.getElementById("passwordSubmit"),
  147. cancelButton: document.getElementById("passwordCancel")
  148. },
  149. documentProperties: {
  150. overlayName: "documentPropertiesOverlay",
  151. container: document.getElementById("documentPropertiesOverlay"),
  152. closeButton: document.getElementById("documentPropertiesClose"),
  153. fields: {
  154. fileName: document.getElementById("fileNameField"),
  155. fileSize: document.getElementById("fileSizeField"),
  156. title: document.getElementById("titleField"),
  157. author: document.getElementById("authorField"),
  158. subject: document.getElementById("subjectField"),
  159. keywords: document.getElementById("keywordsField"),
  160. creationDate: document.getElementById("creationDateField"),
  161. modificationDate: document.getElementById("modificationDateField"),
  162. creator: document.getElementById("creatorField"),
  163. producer: document.getElementById("producerField"),
  164. version: document.getElementById("versionField"),
  165. pageCount: document.getElementById("pageCountField"),
  166. pageSize: document.getElementById("pageSizeField"),
  167. linearized: document.getElementById("linearizedField")
  168. }
  169. },
  170. errorWrapper: {
  171. container: document.getElementById("errorWrapper"),
  172. errorMessage: document.getElementById("errorMessage"),
  173. closeButton: document.getElementById("errorClose"),
  174. errorMoreInfo: document.getElementById("errorMoreInfo"),
  175. moreInfoButton: document.getElementById("errorShowMore"),
  176. lessInfoButton: document.getElementById("errorShowLess")
  177. },
  178. printContainer: document.getElementById("printContainer"),
  179. openFileInputName: "fileInput",
  180. debuggerScriptPath: "./debugger.js"
  181. };
  182. }
  183. function webViewerLoad() {
  184. var config = getViewerConfiguration();
  185. var event = document.createEvent("CustomEvent");
  186. event.initCustomEvent("webviewerloaded", true, true, {
  187. source: window
  188. });
  189. try {
  190. parent.document.dispatchEvent(event);
  191. } catch (ex) {
  192. console.error("webviewerloaded: ".concat(ex));
  193. document.dispatchEvent(event);
  194. }
  195. _app.PDFViewerApplication.run(config);
  196. }
  197. if (document.readyState === "interactive" || document.readyState === "complete") {
  198. webViewerLoad();
  199. } else {
  200. document.addEventListener("DOMContentLoaded", webViewerLoad, true);
  201. }
  202. /***/ }),
  203. /* 1 */
  204. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  205. Object.defineProperty(exports, "__esModule", ({
  206. value: true
  207. }));
  208. exports.OptionKind = exports.AppOptions = void 0;
  209. var _viewer_compatibility = __webpack_require__(2);
  210. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  211. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  212. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  213. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  214. var OptionKind = {
  215. VIEWER: 0x02,
  216. API: 0x04,
  217. WORKER: 0x08,
  218. PREFERENCE: 0x80
  219. };
  220. exports.OptionKind = OptionKind;
  221. var defaultOptions = {
  222. cursorToolOnLoad: {
  223. value: 0,
  224. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  225. },
  226. defaultUrl: {
  227. value: "compressed.tracemonkey-pldi-09.pdf",
  228. kind: OptionKind.VIEWER
  229. },
  230. defaultZoomValue: {
  231. value: "",
  232. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  233. },
  234. disableHistory: {
  235. value: false,
  236. kind: OptionKind.VIEWER
  237. },
  238. disablePageLabels: {
  239. value: false,
  240. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  241. },
  242. enablePermissions: {
  243. value: false,
  244. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  245. },
  246. enablePrintAutoRotate: {
  247. value: false,
  248. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  249. },
  250. enableScripting: {
  251. value: false,
  252. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  253. },
  254. enableWebGL: {
  255. value: false,
  256. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  257. },
  258. externalLinkRel: {
  259. value: "noopener noreferrer nofollow",
  260. kind: OptionKind.VIEWER
  261. },
  262. externalLinkTarget: {
  263. value: 0,
  264. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  265. },
  266. historyUpdateUrl: {
  267. value: false,
  268. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  269. },
  270. ignoreDestinationZoom: {
  271. value: false,
  272. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  273. },
  274. imageResourcesPath: {
  275. value: "./images/",
  276. kind: OptionKind.VIEWER
  277. },
  278. maxCanvasPixels: {
  279. value: 16777216,
  280. compatibility: _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels,
  281. kind: OptionKind.VIEWER
  282. },
  283. pdfBugEnabled: {
  284. value: false,
  285. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  286. },
  287. printResolution: {
  288. value: 150,
  289. kind: OptionKind.VIEWER
  290. },
  291. renderer: {
  292. value: "canvas",
  293. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  294. },
  295. renderInteractiveForms: {
  296. value: true,
  297. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  298. },
  299. sidebarViewOnLoad: {
  300. value: -1,
  301. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  302. },
  303. scrollModeOnLoad: {
  304. value: -1,
  305. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  306. },
  307. spreadModeOnLoad: {
  308. value: -1,
  309. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  310. },
  311. textLayerMode: {
  312. value: 1,
  313. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  314. },
  315. useOnlyCssZoom: {
  316. value: false,
  317. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  318. },
  319. viewerCssTheme: {
  320. value: 0,
  321. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  322. },
  323. viewOnLoad: {
  324. value: 0,
  325. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  326. },
  327. cMapPacked: {
  328. value: true,
  329. kind: OptionKind.API
  330. },
  331. cMapUrl: {
  332. value: "../web/cmaps/",
  333. kind: OptionKind.API
  334. },
  335. disableAutoFetch: {
  336. value: false,
  337. kind: OptionKind.API + OptionKind.PREFERENCE
  338. },
  339. disableFontFace: {
  340. value: false,
  341. kind: OptionKind.API + OptionKind.PREFERENCE
  342. },
  343. disableRange: {
  344. value: false,
  345. kind: OptionKind.API + OptionKind.PREFERENCE
  346. },
  347. disableStream: {
  348. value: false,
  349. kind: OptionKind.API + OptionKind.PREFERENCE
  350. },
  351. docBaseUrl: {
  352. value: "",
  353. kind: OptionKind.API
  354. },
  355. fontExtraProperties: {
  356. value: false,
  357. kind: OptionKind.API
  358. },
  359. isEvalSupported: {
  360. value: true,
  361. kind: OptionKind.API
  362. },
  363. maxImageSize: {
  364. value: -1,
  365. kind: OptionKind.API
  366. },
  367. pdfBug: {
  368. value: false,
  369. kind: OptionKind.API
  370. },
  371. verbosity: {
  372. value: 1,
  373. kind: OptionKind.API
  374. },
  375. workerPort: {
  376. value: null,
  377. kind: OptionKind.WORKER
  378. },
  379. workerSrc: {
  380. value: "../build/pdf.worker.js",
  381. kind: OptionKind.WORKER
  382. }
  383. };
  384. {
  385. defaultOptions.disablePreferences = {
  386. value: false,
  387. kind: OptionKind.VIEWER
  388. };
  389. defaultOptions.locale = {
  390. value: typeof navigator !== "undefined" ? navigator.language : "en-US",
  391. kind: OptionKind.VIEWER
  392. };
  393. defaultOptions.sandboxBundleSrc = {
  394. value: "../build/pdf.sandbox.js",
  395. kind: OptionKind.VIEWER
  396. };
  397. }
  398. var userOptions = Object.create(null);
  399. var AppOptions = /*#__PURE__*/function () {
  400. function AppOptions() {
  401. _classCallCheck(this, AppOptions);
  402. throw new Error("Cannot initialize AppOptions.");
  403. }
  404. _createClass(AppOptions, null, [{
  405. key: "get",
  406. value: function get(name) {
  407. var userOption = userOptions[name];
  408. if (userOption !== undefined) {
  409. return userOption;
  410. }
  411. var defaultOption = defaultOptions[name];
  412. if (defaultOption !== undefined) {
  413. return defaultOption.compatibility || defaultOption.value;
  414. }
  415. return undefined;
  416. }
  417. }, {
  418. key: "getAll",
  419. value: function getAll() {
  420. var kind = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  421. var options = Object.create(null);
  422. for (var name in defaultOptions) {
  423. var defaultOption = defaultOptions[name];
  424. if (kind) {
  425. if ((kind & defaultOption.kind) === 0) {
  426. continue;
  427. }
  428. if (kind === OptionKind.PREFERENCE) {
  429. var value = defaultOption.value,
  430. valueType = _typeof(value);
  431. if (valueType === "boolean" || valueType === "string" || valueType === "number" && Number.isInteger(value)) {
  432. options[name] = value;
  433. continue;
  434. }
  435. throw new Error("Invalid type for preference: ".concat(name));
  436. }
  437. }
  438. var userOption = userOptions[name];
  439. options[name] = userOption !== undefined ? userOption : defaultOption.compatibility || defaultOption.value;
  440. }
  441. return options;
  442. }
  443. }, {
  444. key: "set",
  445. value: function set(name, value) {
  446. userOptions[name] = value;
  447. }
  448. }, {
  449. key: "setAll",
  450. value: function setAll(options) {
  451. for (var name in options) {
  452. userOptions[name] = options[name];
  453. }
  454. }
  455. }, {
  456. key: "remove",
  457. value: function remove(name) {
  458. delete userOptions[name];
  459. }
  460. }]);
  461. return AppOptions;
  462. }();
  463. exports.AppOptions = AppOptions;
  464. /***/ }),
  465. /* 2 */
  466. /***/ ((__unused_webpack_module, exports) => {
  467. Object.defineProperty(exports, "__esModule", ({
  468. value: true
  469. }));
  470. exports.viewerCompatibilityParams = void 0;
  471. var compatibilityParams = Object.create(null);
  472. {
  473. var userAgent = typeof navigator !== "undefined" && navigator.userAgent || "";
  474. var platform = typeof navigator !== "undefined" && navigator.platform || "";
  475. var maxTouchPoints = typeof navigator !== "undefined" && navigator.maxTouchPoints || 1;
  476. var isAndroid = /Android/.test(userAgent);
  477. var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" && maxTouchPoints > 1;
  478. var isIOSChrome = /CriOS/.test(userAgent);
  479. (function checkOnBlobSupport() {
  480. if (isIOSChrome) {
  481. compatibilityParams.disableCreateObjectURL = true;
  482. }
  483. })();
  484. (function checkCanvasSizeLimitation() {
  485. if (isIOS || isAndroid) {
  486. compatibilityParams.maxCanvasPixels = 5242880;
  487. }
  488. })();
  489. }
  490. var viewerCompatibilityParams = Object.freeze(compatibilityParams);
  491. exports.viewerCompatibilityParams = viewerCompatibilityParams;
  492. /***/ }),
  493. /* 3 */
  494. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  495. Object.defineProperty(exports, "__esModule", ({
  496. value: true
  497. }));
  498. exports.PDFViewerApplication = exports.PDFPrintServiceFactory = exports.DefaultExternalServices = void 0;
  499. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  500. var _ui_utils = __webpack_require__(6);
  501. var _app_options = __webpack_require__(1);
  502. var _pdfjsLib = __webpack_require__(7);
  503. var _pdf_cursor_tools = __webpack_require__(8);
  504. var _pdf_rendering_queue = __webpack_require__(10);
  505. var _overlay_manager = __webpack_require__(11);
  506. var _password_prompt = __webpack_require__(12);
  507. var _pdf_attachment_viewer = __webpack_require__(13);
  508. var _pdf_document_properties = __webpack_require__(15);
  509. var _pdf_find_bar = __webpack_require__(16);
  510. var _pdf_find_controller = __webpack_require__(17);
  511. var _pdf_history = __webpack_require__(19);
  512. var _pdf_layer_viewer = __webpack_require__(20);
  513. var _pdf_link_service = __webpack_require__(21);
  514. var _pdf_outline_viewer = __webpack_require__(22);
  515. var _pdf_presentation_mode = __webpack_require__(23);
  516. var _pdf_sidebar = __webpack_require__(24);
  517. var _pdf_sidebar_resizer = __webpack_require__(25);
  518. var _pdf_thumbnail_viewer = __webpack_require__(26);
  519. var _pdf_viewer = __webpack_require__(28);
  520. var _secondary_toolbar = __webpack_require__(33);
  521. var _toolbar = __webpack_require__(35);
  522. var _viewer_compatibility = __webpack_require__(2);
  523. var _view_history = __webpack_require__(36);
  524. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  525. function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
  526. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
  527. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  528. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  529. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  530. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  531. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  532. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  533. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  534. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  535. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  536. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  537. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  538. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  539. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  540. var DEFAULT_SCALE_DELTA = 1.1;
  541. var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
  542. var FORCE_PAGES_LOADED_TIMEOUT = 10000;
  543. var WHEEL_ZOOM_DISABLED_TIMEOUT = 1000;
  544. var ENABLE_PERMISSIONS_CLASS = "enablePermissions";
  545. var ViewOnLoad = {
  546. UNKNOWN: -1,
  547. PREVIOUS: 0,
  548. INITIAL: 1
  549. };
  550. var ViewerCssTheme = {
  551. AUTOMATIC: 0,
  552. LIGHT: 1,
  553. DARK: 2
  554. };
  555. var KNOWN_VERSIONS = ["1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "2.0", "2.1", "2.2", "2.3"];
  556. var KNOWN_GENERATORS = ["acrobat distiller", "acrobat pdfwriter", "adobe livecycle", "adobe pdf library", "adobe photoshop", "ghostscript", "tcpdf", "cairo", "dvipdfm", "dvips", "pdftex", "pdfkit", "itext", "prince", "quarkxpress", "mac os x", "microsoft", "openoffice", "oracle", "luradocument", "pdf-xchange", "antenna house", "aspose.cells", "fpdf"];
  557. var DefaultExternalServices = /*#__PURE__*/function () {
  558. function DefaultExternalServices() {
  559. _classCallCheck(this, DefaultExternalServices);
  560. throw new Error("Cannot initialize DefaultExternalServices.");
  561. }
  562. _createClass(DefaultExternalServices, null, [{
  563. key: "updateFindControlState",
  564. value: function updateFindControlState(data) {}
  565. }, {
  566. key: "updateFindMatchesCount",
  567. value: function updateFindMatchesCount(data) {}
  568. }, {
  569. key: "initPassiveLoading",
  570. value: function initPassiveLoading(callbacks) {}
  571. }, {
  572. key: "fallback",
  573. value: function () {
  574. var _fallback = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(data) {
  575. return _regenerator["default"].wrap(function _callee$(_context) {
  576. while (1) {
  577. switch (_context.prev = _context.next) {
  578. case 0:
  579. case "end":
  580. return _context.stop();
  581. }
  582. }
  583. }, _callee);
  584. }));
  585. function fallback(_x) {
  586. return _fallback.apply(this, arguments);
  587. }
  588. return fallback;
  589. }()
  590. }, {
  591. key: "reportTelemetry",
  592. value: function reportTelemetry(data) {}
  593. }, {
  594. key: "createDownloadManager",
  595. value: function createDownloadManager(options) {
  596. throw new Error("Not implemented: createDownloadManager");
  597. }
  598. }, {
  599. key: "createPreferences",
  600. value: function createPreferences() {
  601. throw new Error("Not implemented: createPreferences");
  602. }
  603. }, {
  604. key: "createL10n",
  605. value: function createL10n(options) {
  606. throw new Error("Not implemented: createL10n");
  607. }
  608. }, {
  609. key: "createScripting",
  610. value: function createScripting(options) {
  611. throw new Error("Not implemented: createScripting");
  612. }
  613. }, {
  614. key: "supportsIntegratedFind",
  615. get: function get() {
  616. return (0, _pdfjsLib.shadow)(this, "supportsIntegratedFind", false);
  617. }
  618. }, {
  619. key: "supportsDocumentFonts",
  620. get: function get() {
  621. return (0, _pdfjsLib.shadow)(this, "supportsDocumentFonts", true);
  622. }
  623. }, {
  624. key: "supportedMouseWheelZoomModifierKeys",
  625. get: function get() {
  626. return (0, _pdfjsLib.shadow)(this, "supportedMouseWheelZoomModifierKeys", {
  627. ctrlKey: true,
  628. metaKey: true
  629. });
  630. }
  631. }, {
  632. key: "isInAutomation",
  633. get: function get() {
  634. return (0, _pdfjsLib.shadow)(this, "isInAutomation", false);
  635. }
  636. }]);
  637. return DefaultExternalServices;
  638. }();
  639. exports.DefaultExternalServices = DefaultExternalServices;
  640. var PDFViewerApplication = {
  641. initialBookmark: document.location.hash.substring(1),
  642. _initializedCapability: (0, _pdfjsLib.createPromiseCapability)(),
  643. fellback: false,
  644. appConfig: null,
  645. pdfDocument: null,
  646. pdfLoadingTask: null,
  647. printService: null,
  648. pdfViewer: null,
  649. pdfThumbnailViewer: null,
  650. pdfRenderingQueue: null,
  651. pdfPresentationMode: null,
  652. pdfDocumentProperties: null,
  653. pdfLinkService: null,
  654. pdfHistory: null,
  655. pdfSidebar: null,
  656. pdfSidebarResizer: null,
  657. pdfOutlineViewer: null,
  658. pdfAttachmentViewer: null,
  659. pdfLayerViewer: null,
  660. pdfCursorTools: null,
  661. store: null,
  662. downloadManager: null,
  663. overlayManager: null,
  664. preferences: null,
  665. toolbar: null,
  666. secondaryToolbar: null,
  667. eventBus: null,
  668. l10n: null,
  669. isInitialViewSet: false,
  670. downloadComplete: false,
  671. isViewerEmbedded: window.parent !== window,
  672. url: "",
  673. baseUrl: "",
  674. externalServices: DefaultExternalServices,
  675. _boundEvents: Object.create(null),
  676. documentInfo: null,
  677. metadata: null,
  678. _contentDispositionFilename: null,
  679. _contentLength: null,
  680. triggerDelayedFallback: null,
  681. _saveInProgress: false,
  682. _wheelUnusedTicks: 0,
  683. _idleCallbacks: new Set(),
  684. _scriptingInstance: null,
  685. _mouseState: Object.create(null),
  686. initialize: function initialize(appConfig) {
  687. var _this = this;
  688. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  689. var appContainer;
  690. return _regenerator["default"].wrap(function _callee2$(_context2) {
  691. while (1) {
  692. switch (_context2.prev = _context2.next) {
  693. case 0:
  694. _this.preferences = _this.externalServices.createPreferences();
  695. _this.appConfig = appConfig;
  696. _context2.next = 4;
  697. return _this._readPreferences();
  698. case 4:
  699. _context2.next = 6;
  700. return _this._parseHashParameters();
  701. case 6:
  702. _this._forceCssTheme();
  703. _context2.next = 9;
  704. return _this._initializeL10n();
  705. case 9:
  706. if (_this.isViewerEmbedded && _app_options.AppOptions.get("externalLinkTarget") === _pdfjsLib.LinkTarget.NONE) {
  707. _app_options.AppOptions.set("externalLinkTarget", _pdfjsLib.LinkTarget.TOP);
  708. }
  709. _context2.next = 12;
  710. return _this._initializeViewerComponents();
  711. case 12:
  712. _this.bindEvents();
  713. _this.bindWindowEvents();
  714. appContainer = appConfig.appContainer || document.documentElement;
  715. _this.l10n.translate(appContainer).then(function () {
  716. _this.eventBus.dispatch("localized", {
  717. source: _this
  718. });
  719. });
  720. _this._initializedCapability.resolve();
  721. case 17:
  722. case "end":
  723. return _context2.stop();
  724. }
  725. }
  726. }, _callee2);
  727. }))();
  728. },
  729. _readPreferences: function _readPreferences() {
  730. var _this2 = this;
  731. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  732. return _regenerator["default"].wrap(function _callee3$(_context3) {
  733. while (1) {
  734. switch (_context3.prev = _context3.next) {
  735. case 0:
  736. if (!_app_options.AppOptions.get("disablePreferences")) {
  737. _context3.next = 2;
  738. break;
  739. }
  740. return _context3.abrupt("return");
  741. case 2:
  742. _context3.prev = 2;
  743. _context3.t0 = _app_options.AppOptions;
  744. _context3.next = 6;
  745. return _this2.preferences.getAll();
  746. case 6:
  747. _context3.t1 = _context3.sent;
  748. _context3.t0.setAll.call(_context3.t0, _context3.t1);
  749. _context3.next = 13;
  750. break;
  751. case 10:
  752. _context3.prev = 10;
  753. _context3.t2 = _context3["catch"](2);
  754. console.error("_readPreferences: \"".concat(_context3.t2 === null || _context3.t2 === void 0 ? void 0 : _context3.t2.message, "\"."));
  755. case 13:
  756. case "end":
  757. return _context3.stop();
  758. }
  759. }
  760. }, _callee3, null, [[2, 10]]);
  761. }))();
  762. },
  763. _parseHashParameters: function _parseHashParameters() {
  764. var _this3 = this;
  765. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
  766. var hash, hashParams, waitOn, viewer, enabled;
  767. return _regenerator["default"].wrap(function _callee4$(_context4) {
  768. while (1) {
  769. switch (_context4.prev = _context4.next) {
  770. case 0:
  771. if (_app_options.AppOptions.get("pdfBugEnabled")) {
  772. _context4.next = 2;
  773. break;
  774. }
  775. return _context4.abrupt("return", undefined);
  776. case 2:
  777. hash = document.location.hash.substring(1);
  778. if (hash) {
  779. _context4.next = 5;
  780. break;
  781. }
  782. return _context4.abrupt("return", undefined);
  783. case 5:
  784. hashParams = (0, _ui_utils.parseQueryString)(hash), waitOn = [];
  785. if ("disableworker" in hashParams && hashParams.disableworker === "true") {
  786. waitOn.push(loadFakeWorker());
  787. }
  788. if ("disablerange" in hashParams) {
  789. _app_options.AppOptions.set("disableRange", hashParams.disablerange === "true");
  790. }
  791. if ("disablestream" in hashParams) {
  792. _app_options.AppOptions.set("disableStream", hashParams.disablestream === "true");
  793. }
  794. if ("disableautofetch" in hashParams) {
  795. _app_options.AppOptions.set("disableAutoFetch", hashParams.disableautofetch === "true");
  796. }
  797. if ("disablefontface" in hashParams) {
  798. _app_options.AppOptions.set("disableFontFace", hashParams.disablefontface === "true");
  799. }
  800. if ("disablehistory" in hashParams) {
  801. _app_options.AppOptions.set("disableHistory", hashParams.disablehistory === "true");
  802. }
  803. if ("webgl" in hashParams) {
  804. _app_options.AppOptions.set("enableWebGL", hashParams.webgl === "true");
  805. }
  806. if ("verbosity" in hashParams) {
  807. _app_options.AppOptions.set("verbosity", hashParams.verbosity | 0);
  808. }
  809. if (!("textlayer" in hashParams)) {
  810. _context4.next = 23;
  811. break;
  812. }
  813. _context4.t0 = hashParams.textlayer;
  814. _context4.next = _context4.t0 === "off" ? 18 : _context4.t0 === "visible" ? 20 : _context4.t0 === "shadow" ? 20 : _context4.t0 === "hover" ? 20 : 23;
  815. break;
  816. case 18:
  817. _app_options.AppOptions.set("textLayerMode", _ui_utils.TextLayerMode.DISABLE);
  818. return _context4.abrupt("break", 23);
  819. case 20:
  820. viewer = _this3.appConfig.viewerContainer;
  821. viewer.classList.add("textLayer-" + hashParams.textlayer);
  822. return _context4.abrupt("break", 23);
  823. case 23:
  824. if ("pdfbug" in hashParams) {
  825. _app_options.AppOptions.set("pdfBug", true);
  826. _app_options.AppOptions.set("fontExtraProperties", true);
  827. enabled = hashParams.pdfbug.split(",");
  828. waitOn.push(loadAndEnablePDFBug(enabled));
  829. }
  830. if ("locale" in hashParams) {
  831. _app_options.AppOptions.set("locale", hashParams.locale);
  832. }
  833. if (!(waitOn.length === 0)) {
  834. _context4.next = 27;
  835. break;
  836. }
  837. return _context4.abrupt("return", undefined);
  838. case 27:
  839. return _context4.abrupt("return", Promise.all(waitOn)["catch"](function (reason) {
  840. console.error("_parseHashParameters: \"".concat(reason.message, "\"."));
  841. }));
  842. case 28:
  843. case "end":
  844. return _context4.stop();
  845. }
  846. }
  847. }, _callee4);
  848. }))();
  849. },
  850. _initializeL10n: function _initializeL10n() {
  851. var _this4 = this;
  852. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5() {
  853. var dir;
  854. return _regenerator["default"].wrap(function _callee5$(_context5) {
  855. while (1) {
  856. switch (_context5.prev = _context5.next) {
  857. case 0:
  858. _this4.l10n = _this4.externalServices.createL10n({
  859. locale: _app_options.AppOptions.get("locale")
  860. });
  861. _context5.next = 3;
  862. return _this4.l10n.getDirection();
  863. case 3:
  864. dir = _context5.sent;
  865. document.getElementsByTagName("html")[0].dir = dir;
  866. case 5:
  867. case "end":
  868. return _context5.stop();
  869. }
  870. }
  871. }, _callee5);
  872. }))();
  873. },
  874. _forceCssTheme: function _forceCssTheme() {
  875. var cssTheme = _app_options.AppOptions.get("viewerCssTheme");
  876. if (cssTheme === ViewerCssTheme.AUTOMATIC || !Object.values(ViewerCssTheme).includes(cssTheme)) {
  877. return;
  878. }
  879. try {
  880. var styleSheet = document.styleSheets[0];
  881. var cssRules = (styleSheet === null || styleSheet === void 0 ? void 0 : styleSheet.cssRules) || [];
  882. for (var i = 0, ii = cssRules.length; i < ii; i++) {
  883. var _rule$media;
  884. var rule = cssRules[i];
  885. if (rule instanceof CSSMediaRule && ((_rule$media = rule.media) === null || _rule$media === void 0 ? void 0 : _rule$media[0]) === "(prefers-color-scheme: dark)") {
  886. if (cssTheme === ViewerCssTheme.LIGHT) {
  887. styleSheet.deleteRule(i);
  888. return;
  889. }
  890. var darkRules = /^@media \(prefers-color-scheme: dark\) {\n\s*([\w\s-.,:;/\\{}()]+)\n}$/.exec(rule.cssText);
  891. if (darkRules !== null && darkRules !== void 0 && darkRules[1]) {
  892. styleSheet.deleteRule(i);
  893. styleSheet.insertRule(darkRules[1], i);
  894. }
  895. return;
  896. }
  897. }
  898. } catch (reason) {
  899. console.error("_forceCssTheme: \"".concat(reason === null || reason === void 0 ? void 0 : reason.message, "\"."));
  900. }
  901. },
  902. _initializeViewerComponents: function _initializeViewerComponents() {
  903. var _this5 = this;
  904. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
  905. var appConfig, eventBus, pdfRenderingQueue, pdfLinkService, downloadManager, findController, container, viewer;
  906. return _regenerator["default"].wrap(function _callee6$(_context6) {
  907. while (1) {
  908. switch (_context6.prev = _context6.next) {
  909. case 0:
  910. appConfig = _this5.appConfig;
  911. eventBus = appConfig.eventBus || new _ui_utils.EventBus({
  912. isInAutomation: _this5.externalServices.isInAutomation
  913. });
  914. _this5.eventBus = eventBus;
  915. _this5.overlayManager = new _overlay_manager.OverlayManager();
  916. pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  917. pdfRenderingQueue.onIdle = _this5.cleanup.bind(_this5);
  918. _this5.pdfRenderingQueue = pdfRenderingQueue;
  919. pdfLinkService = new _pdf_link_service.PDFLinkService({
  920. eventBus: eventBus,
  921. externalLinkTarget: _app_options.AppOptions.get("externalLinkTarget"),
  922. externalLinkRel: _app_options.AppOptions.get("externalLinkRel"),
  923. ignoreDestinationZoom: _app_options.AppOptions.get("ignoreDestinationZoom")
  924. });
  925. _this5.pdfLinkService = pdfLinkService;
  926. downloadManager = _this5.externalServices.createDownloadManager();
  927. _this5.downloadManager = downloadManager;
  928. findController = new _pdf_find_controller.PDFFindController({
  929. linkService: pdfLinkService,
  930. eventBus: eventBus
  931. });
  932. _this5.findController = findController;
  933. container = appConfig.mainContainer;
  934. viewer = appConfig.viewerContainer;
  935. _this5.pdfViewer = new _pdf_viewer.PDFViewer({
  936. container: container,
  937. viewer: viewer,
  938. eventBus: eventBus,
  939. renderingQueue: pdfRenderingQueue,
  940. linkService: pdfLinkService,
  941. downloadManager: downloadManager,
  942. findController: findController,
  943. renderer: _app_options.AppOptions.get("renderer"),
  944. enableWebGL: _app_options.AppOptions.get("enableWebGL"),
  945. l10n: _this5.l10n,
  946. textLayerMode: _app_options.AppOptions.get("textLayerMode"),
  947. imageResourcesPath: _app_options.AppOptions.get("imageResourcesPath"),
  948. renderInteractiveForms: _app_options.AppOptions.get("renderInteractiveForms"),
  949. enablePrintAutoRotate: _app_options.AppOptions.get("enablePrintAutoRotate"),
  950. useOnlyCssZoom: _app_options.AppOptions.get("useOnlyCssZoom"),
  951. maxCanvasPixels: _app_options.AppOptions.get("maxCanvasPixels"),
  952. enableScripting: _app_options.AppOptions.get("enableScripting"),
  953. mouseState: _this5._mouseState
  954. });
  955. pdfRenderingQueue.setViewer(_this5.pdfViewer);
  956. pdfLinkService.setViewer(_this5.pdfViewer);
  957. _this5.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({
  958. container: appConfig.sidebar.thumbnailView,
  959. eventBus: eventBus,
  960. renderingQueue: pdfRenderingQueue,
  961. linkService: pdfLinkService,
  962. l10n: _this5.l10n
  963. });
  964. pdfRenderingQueue.setThumbnailViewer(_this5.pdfThumbnailViewer);
  965. _this5.pdfHistory = new _pdf_history.PDFHistory({
  966. linkService: pdfLinkService,
  967. eventBus: eventBus
  968. });
  969. pdfLinkService.setHistory(_this5.pdfHistory);
  970. if (!_this5.supportsIntegratedFind) {
  971. _this5.findBar = new _pdf_find_bar.PDFFindBar(appConfig.findBar, eventBus, _this5.l10n);
  972. }
  973. _this5.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, _this5.overlayManager, eventBus, _this5.l10n);
  974. _this5.pdfCursorTools = new _pdf_cursor_tools.PDFCursorTools({
  975. container: container,
  976. eventBus: eventBus,
  977. cursorToolOnLoad: _app_options.AppOptions.get("cursorToolOnLoad")
  978. });
  979. _this5.toolbar = new _toolbar.Toolbar(appConfig.toolbar, eventBus, _this5.l10n);
  980. _this5.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus);
  981. if (_this5.supportsFullscreen) {
  982. _this5.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({
  983. container: container,
  984. pdfViewer: _this5.pdfViewer,
  985. eventBus: eventBus,
  986. contextMenuItems: appConfig.fullscreen
  987. });
  988. }
  989. _this5.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, _this5.overlayManager, _this5.l10n);
  990. _this5.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({
  991. container: appConfig.sidebar.outlineView,
  992. eventBus: eventBus,
  993. linkService: pdfLinkService
  994. });
  995. _this5.pdfAttachmentViewer = new _pdf_attachment_viewer.PDFAttachmentViewer({
  996. container: appConfig.sidebar.attachmentsView,
  997. eventBus: eventBus,
  998. downloadManager: downloadManager
  999. });
  1000. _this5.pdfLayerViewer = new _pdf_layer_viewer.PDFLayerViewer({
  1001. container: appConfig.sidebar.layersView,
  1002. eventBus: eventBus,
  1003. l10n: _this5.l10n
  1004. });
  1005. _this5.pdfSidebar = new _pdf_sidebar.PDFSidebar({
  1006. elements: appConfig.sidebar,
  1007. pdfViewer: _this5.pdfViewer,
  1008. pdfThumbnailViewer: _this5.pdfThumbnailViewer,
  1009. eventBus: eventBus,
  1010. l10n: _this5.l10n
  1011. });
  1012. _this5.pdfSidebar.onToggled = _this5.forceRendering.bind(_this5);
  1013. _this5.pdfSidebarResizer = new _pdf_sidebar_resizer.PDFSidebarResizer(appConfig.sidebarResizer, eventBus, _this5.l10n);
  1014. case 35:
  1015. case "end":
  1016. return _context6.stop();
  1017. }
  1018. }
  1019. }, _callee6);
  1020. }))();
  1021. },
  1022. run: function run(config) {
  1023. this.initialize(config).then(webViewerInitialized);
  1024. },
  1025. get initialized() {
  1026. return this._initializedCapability.settled;
  1027. },
  1028. get initializedPromise() {
  1029. return this._initializedCapability.promise;
  1030. },
  1031. zoomIn: function zoomIn(ticks) {
  1032. if (this.pdfViewer.isInPresentationMode) {
  1033. return;
  1034. }
  1035. var newScale = this.pdfViewer.currentScale;
  1036. do {
  1037. newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2);
  1038. newScale = Math.ceil(newScale * 10) / 10;
  1039. newScale = Math.min(_ui_utils.MAX_SCALE, newScale);
  1040. } while (--ticks > 0 && newScale < _ui_utils.MAX_SCALE);
  1041. this.pdfViewer.currentScaleValue = newScale;
  1042. },
  1043. zoomOut: function zoomOut(ticks) {
  1044. if (this.pdfViewer.isInPresentationMode) {
  1045. return;
  1046. }
  1047. var newScale = this.pdfViewer.currentScale;
  1048. do {
  1049. newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2);
  1050. newScale = Math.floor(newScale * 10) / 10;
  1051. newScale = Math.max(_ui_utils.MIN_SCALE, newScale);
  1052. } while (--ticks > 0 && newScale > _ui_utils.MIN_SCALE);
  1053. this.pdfViewer.currentScaleValue = newScale;
  1054. },
  1055. zoomReset: function zoomReset() {
  1056. if (this.pdfViewer.isInPresentationMode) {
  1057. return;
  1058. }
  1059. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  1060. },
  1061. get pagesCount() {
  1062. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  1063. },
  1064. get page() {
  1065. return this.pdfViewer.currentPageNumber;
  1066. },
  1067. set page(val) {
  1068. this.pdfViewer.currentPageNumber = val;
  1069. },
  1070. get supportsPrinting() {
  1071. return PDFPrintServiceFactory.instance.supportsPrinting;
  1072. },
  1073. get supportsFullscreen() {
  1074. var support;
  1075. var doc = document.documentElement;
  1076. support = !!(doc.requestFullscreen || doc.mozRequestFullScreen || doc.webkitRequestFullScreen);
  1077. if (document.fullscreenEnabled === false || document.mozFullScreenEnabled === false || document.webkitFullscreenEnabled === false) {
  1078. support = false;
  1079. }
  1080. return (0, _pdfjsLib.shadow)(this, "supportsFullscreen", support);
  1081. },
  1082. get supportsIntegratedFind() {
  1083. return this.externalServices.supportsIntegratedFind;
  1084. },
  1085. get supportsDocumentFonts() {
  1086. return this.externalServices.supportsDocumentFonts;
  1087. },
  1088. get loadingBar() {
  1089. var bar = new _ui_utils.ProgressBar("#loadingBar");
  1090. return (0, _pdfjsLib.shadow)(this, "loadingBar", bar);
  1091. },
  1092. get supportedMouseWheelZoomModifierKeys() {
  1093. return this.externalServices.supportedMouseWheelZoomModifierKeys;
  1094. },
  1095. initPassiveLoading: function initPassiveLoading() {
  1096. throw new Error("Not implemented: initPassiveLoading");
  1097. },
  1098. setTitleUsingUrl: function setTitleUsingUrl() {
  1099. var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
  1100. this.url = url;
  1101. this.baseUrl = url.split("#")[0];
  1102. var title = (0, _ui_utils.getPDFFileNameFromURL)(url, "");
  1103. if (!title) {
  1104. try {
  1105. title = decodeURIComponent((0, _pdfjsLib.getFilenameFromUrl)(url)) || url;
  1106. } catch (ex) {
  1107. title = url;
  1108. }
  1109. }
  1110. this.setTitle(title);
  1111. },
  1112. setTitle: function setTitle(title) {
  1113. if (this.isViewerEmbedded) {
  1114. return;
  1115. }
  1116. document.title = title;
  1117. },
  1118. get _docFilename() {
  1119. return this._contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(this.url);
  1120. },
  1121. _cancelIdleCallbacks: function _cancelIdleCallbacks() {
  1122. if (!this._idleCallbacks.size) {
  1123. return;
  1124. }
  1125. var _iterator = _createForOfIteratorHelper(this._idleCallbacks),
  1126. _step;
  1127. try {
  1128. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  1129. var callback = _step.value;
  1130. window.cancelIdleCallback(callback);
  1131. }
  1132. } catch (err) {
  1133. _iterator.e(err);
  1134. } finally {
  1135. _iterator.f();
  1136. }
  1137. this._idleCallbacks.clear();
  1138. },
  1139. _destroyScriptingInstance: function _destroyScriptingInstance() {
  1140. var _this6 = this;
  1141. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee7() {
  1142. var _this6$_scriptingInst, scripting, internalEvents, domEvents, _iterator2, _step2, _step2$value, name, listener, _iterator3, _step3, _step3$value, _name, _listener;
  1143. return _regenerator["default"].wrap(function _callee7$(_context7) {
  1144. while (1) {
  1145. switch (_context7.prev = _context7.next) {
  1146. case 0:
  1147. if (_this6._scriptingInstance) {
  1148. _context7.next = 2;
  1149. break;
  1150. }
  1151. return _context7.abrupt("return");
  1152. case 2:
  1153. _this6$_scriptingInst = _this6._scriptingInstance, scripting = _this6$_scriptingInst.scripting, internalEvents = _this6$_scriptingInst.internalEvents, domEvents = _this6$_scriptingInst.domEvents;
  1154. _context7.prev = 3;
  1155. _context7.next = 6;
  1156. return scripting.destroySandbox();
  1157. case 6:
  1158. _context7.next = 10;
  1159. break;
  1160. case 8:
  1161. _context7.prev = 8;
  1162. _context7.t0 = _context7["catch"](3);
  1163. case 10:
  1164. _iterator2 = _createForOfIteratorHelper(internalEvents);
  1165. try {
  1166. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  1167. _step2$value = _slicedToArray(_step2.value, 2), name = _step2$value[0], listener = _step2$value[1];
  1168. _this6.eventBus._off(name, listener);
  1169. }
  1170. } catch (err) {
  1171. _iterator2.e(err);
  1172. } finally {
  1173. _iterator2.f();
  1174. }
  1175. internalEvents.clear();
  1176. _iterator3 = _createForOfIteratorHelper(domEvents);
  1177. try {
  1178. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  1179. _step3$value = _slicedToArray(_step3.value, 2), _name = _step3$value[0], _listener = _step3$value[1];
  1180. window.removeEventListener(_name, _listener);
  1181. }
  1182. } catch (err) {
  1183. _iterator3.e(err);
  1184. } finally {
  1185. _iterator3.f();
  1186. }
  1187. domEvents.clear();
  1188. delete _this6._mouseState.isDown;
  1189. _this6._scriptingInstance = null;
  1190. case 18:
  1191. case "end":
  1192. return _context7.stop();
  1193. }
  1194. }
  1195. }, _callee7, null, [[3, 8]]);
  1196. }))();
  1197. },
  1198. close: function close() {
  1199. var _this7 = this;
  1200. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee8() {
  1201. var errorWrapper, promises;
  1202. return _regenerator["default"].wrap(function _callee8$(_context8) {
  1203. while (1) {
  1204. switch (_context8.prev = _context8.next) {
  1205. case 0:
  1206. errorWrapper = _this7.appConfig.errorWrapper.container;
  1207. errorWrapper.setAttribute("hidden", "true");
  1208. if (_this7.pdfLoadingTask) {
  1209. _context8.next = 4;
  1210. break;
  1211. }
  1212. return _context8.abrupt("return", undefined);
  1213. case 4:
  1214. promises = [];
  1215. promises.push(_this7.pdfLoadingTask.destroy());
  1216. _this7.pdfLoadingTask = null;
  1217. if (_this7.pdfDocument) {
  1218. _this7.pdfDocument = null;
  1219. _this7.pdfThumbnailViewer.setDocument(null);
  1220. _this7.pdfViewer.setDocument(null);
  1221. _this7.pdfLinkService.setDocument(null);
  1222. _this7.pdfDocumentProperties.setDocument(null);
  1223. }
  1224. webViewerResetPermissions();
  1225. _this7.store = null;
  1226. _this7.isInitialViewSet = false;
  1227. _this7.downloadComplete = false;
  1228. _this7.url = "";
  1229. _this7.baseUrl = "";
  1230. _this7.documentInfo = null;
  1231. _this7.metadata = null;
  1232. _this7._contentDispositionFilename = null;
  1233. _this7._contentLength = null;
  1234. _this7.triggerDelayedFallback = null;
  1235. _this7._saveInProgress = false;
  1236. _this7._cancelIdleCallbacks();
  1237. promises.push(_this7._destroyScriptingInstance());
  1238. _this7.pdfSidebar.reset();
  1239. _this7.pdfOutlineViewer.reset();
  1240. _this7.pdfAttachmentViewer.reset();
  1241. _this7.pdfLayerViewer.reset();
  1242. if (_this7.pdfHistory) {
  1243. _this7.pdfHistory.reset();
  1244. }
  1245. if (_this7.findBar) {
  1246. _this7.findBar.reset();
  1247. }
  1248. _this7.toolbar.reset();
  1249. _this7.secondaryToolbar.reset();
  1250. if (typeof PDFBug !== "undefined") {
  1251. PDFBug.cleanup();
  1252. }
  1253. _context8.next = 33;
  1254. return Promise.all(promises);
  1255. case 33:
  1256. return _context8.abrupt("return", undefined);
  1257. case 34:
  1258. case "end":
  1259. return _context8.stop();
  1260. }
  1261. }
  1262. }, _callee8);
  1263. }))();
  1264. },
  1265. open: function open(file, args) {
  1266. var _this8 = this;
  1267. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee9() {
  1268. var workerParameters, key, parameters, apiParameters, _key, value, _key2, loadingTask;
  1269. return _regenerator["default"].wrap(function _callee9$(_context9) {
  1270. while (1) {
  1271. switch (_context9.prev = _context9.next) {
  1272. case 0:
  1273. if (!_this8.pdfLoadingTask) {
  1274. _context9.next = 3;
  1275. break;
  1276. }
  1277. _context9.next = 3;
  1278. return _this8.close();
  1279. case 3:
  1280. workerParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.WORKER);
  1281. for (key in workerParameters) {
  1282. _pdfjsLib.GlobalWorkerOptions[key] = workerParameters[key];
  1283. }
  1284. parameters = Object.create(null);
  1285. if (typeof file === "string") {
  1286. _this8.setTitleUsingUrl(file);
  1287. parameters.url = file;
  1288. } else if (file && "byteLength" in file) {
  1289. parameters.data = file;
  1290. } else if (file.url && file.originalUrl) {
  1291. _this8.setTitleUsingUrl(file.originalUrl);
  1292. parameters.url = file.url;
  1293. }
  1294. apiParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.API);
  1295. for (_key in apiParameters) {
  1296. value = apiParameters[_key];
  1297. if (_key === "docBaseUrl" && !value) {}
  1298. parameters[_key] = value;
  1299. }
  1300. if (args) {
  1301. for (_key2 in args) {
  1302. parameters[_key2] = args[_key2];
  1303. }
  1304. }
  1305. loadingTask = (0, _pdfjsLib.getDocument)(parameters);
  1306. _this8.pdfLoadingTask = loadingTask;
  1307. loadingTask.onPassword = function (updateCallback, reason) {
  1308. _this8.pdfLinkService.externalLinkEnabled = false;
  1309. _this8.passwordPrompt.setUpdateCallback(updateCallback, reason);
  1310. _this8.passwordPrompt.open();
  1311. };
  1312. loadingTask.onProgress = function (_ref) {
  1313. var loaded = _ref.loaded,
  1314. total = _ref.total;
  1315. _this8.progress(loaded / total);
  1316. };
  1317. loadingTask.onUnsupportedFeature = _this8.fallback.bind(_this8);
  1318. return _context9.abrupt("return", loadingTask.promise.then(function (pdfDocument) {
  1319. _this8.load(pdfDocument);
  1320. }, function (exception) {
  1321. if (loadingTask !== _this8.pdfLoadingTask) {
  1322. return undefined;
  1323. }
  1324. var message = exception === null || exception === void 0 ? void 0 : exception.message;
  1325. var loadingErrorMessage;
  1326. if (exception instanceof _pdfjsLib.InvalidPDFException) {
  1327. loadingErrorMessage = _this8.l10n.get("invalid_file_error", null, "Invalid or corrupted PDF file.");
  1328. } else if (exception instanceof _pdfjsLib.MissingPDFException) {
  1329. loadingErrorMessage = _this8.l10n.get("missing_file_error", null, "Missing PDF file.");
  1330. } else if (exception instanceof _pdfjsLib.UnexpectedResponseException) {
  1331. loadingErrorMessage = _this8.l10n.get("unexpected_response_error", null, "Unexpected server response.");
  1332. } else {
  1333. loadingErrorMessage = _this8.l10n.get("loading_error", null, "An error occurred while loading the PDF.");
  1334. }
  1335. return loadingErrorMessage.then(function (msg) {
  1336. _this8.error(msg, {
  1337. message: message
  1338. });
  1339. throw exception;
  1340. });
  1341. }));
  1342. case 16:
  1343. case "end":
  1344. return _context9.stop();
  1345. }
  1346. }
  1347. }, _callee9);
  1348. }))();
  1349. },
  1350. download: function download() {
  1351. var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  1352. _ref2$sourceEventType = _ref2.sourceEventType,
  1353. sourceEventType = _ref2$sourceEventType === void 0 ? "download" : _ref2$sourceEventType;
  1354. function downloadByUrl() {
  1355. downloadManager.downloadUrl(url, filename);
  1356. }
  1357. var downloadManager = this.downloadManager,
  1358. url = this.baseUrl,
  1359. filename = this._docFilename;
  1360. if (!this.pdfDocument || !this.downloadComplete) {
  1361. downloadByUrl();
  1362. return;
  1363. }
  1364. this.pdfDocument.getData().then(function (data) {
  1365. var blob = new Blob([data], {
  1366. type: "application/pdf"
  1367. });
  1368. downloadManager.download(blob, url, filename, sourceEventType);
  1369. })["catch"](downloadByUrl);
  1370. },
  1371. save: function save() {
  1372. var _arguments = arguments,
  1373. _this9 = this;
  1374. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee11() {
  1375. var _this9$_scriptingInst;
  1376. var _ref3, _ref3$sourceEventType, sourceEventType, downloadManager, url, filename;
  1377. return _regenerator["default"].wrap(function _callee11$(_context11) {
  1378. while (1) {
  1379. switch (_context11.prev = _context11.next) {
  1380. case 0:
  1381. _ref3 = _arguments.length > 0 && _arguments[0] !== undefined ? _arguments[0] : {}, _ref3$sourceEventType = _ref3.sourceEventType, sourceEventType = _ref3$sourceEventType === void 0 ? "download" : _ref3$sourceEventType;
  1382. if (!_this9._saveInProgress) {
  1383. _context11.next = 3;
  1384. break;
  1385. }
  1386. return _context11.abrupt("return");
  1387. case 3:
  1388. downloadManager = _this9.downloadManager, url = _this9.baseUrl, filename = _this9._docFilename;
  1389. if (!(!_this9.pdfDocument || !_this9.downloadComplete)) {
  1390. _context11.next = 7;
  1391. break;
  1392. }
  1393. _this9.download({
  1394. sourceEventType: sourceEventType
  1395. });
  1396. return _context11.abrupt("return");
  1397. case 7:
  1398. _this9._saveInProgress = true;
  1399. _context11.next = 10;
  1400. return (_this9$_scriptingInst = _this9._scriptingInstance) === null || _this9$_scriptingInst === void 0 ? void 0 : _this9$_scriptingInst.scripting.dispatchEventInSandbox({
  1401. id: "doc",
  1402. name: "WillSave"
  1403. });
  1404. case 10:
  1405. _this9.pdfDocument.saveDocument(_this9.pdfDocument.annotationStorage).then(function (data) {
  1406. var blob = new Blob([data], {
  1407. type: "application/pdf"
  1408. });
  1409. downloadManager.download(blob, url, filename, sourceEventType);
  1410. })["catch"](function () {
  1411. _this9.download({
  1412. sourceEventType: sourceEventType
  1413. });
  1414. })["finally"]( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee10() {
  1415. var _this9$_scriptingInst2;
  1416. return _regenerator["default"].wrap(function _callee10$(_context10) {
  1417. while (1) {
  1418. switch (_context10.prev = _context10.next) {
  1419. case 0:
  1420. _context10.next = 2;
  1421. return (_this9$_scriptingInst2 = _this9._scriptingInstance) === null || _this9$_scriptingInst2 === void 0 ? void 0 : _this9$_scriptingInst2.scripting.dispatchEventInSandbox({
  1422. id: "doc",
  1423. name: "DidSave"
  1424. });
  1425. case 2:
  1426. _this9._saveInProgress = false;
  1427. case 3:
  1428. case "end":
  1429. return _context10.stop();
  1430. }
  1431. }
  1432. }, _callee10);
  1433. })));
  1434. case 11:
  1435. case "end":
  1436. return _context11.stop();
  1437. }
  1438. }
  1439. }, _callee11);
  1440. }))();
  1441. },
  1442. downloadOrSave: function downloadOrSave(options) {
  1443. var _this$pdfDocument;
  1444. if (((_this$pdfDocument = this.pdfDocument) === null || _this$pdfDocument === void 0 ? void 0 : _this$pdfDocument.annotationStorage.size) > 0) {
  1445. this.save(options);
  1446. } else {
  1447. this.download(options);
  1448. }
  1449. },
  1450. _delayedFallback: function _delayedFallback(featureId) {
  1451. var _this10 = this;
  1452. this.externalServices.reportTelemetry({
  1453. type: "unsupportedFeature",
  1454. featureId: featureId
  1455. });
  1456. if (!this.triggerDelayedFallback) {
  1457. this.triggerDelayedFallback = function () {
  1458. _this10.fallback(featureId);
  1459. _this10.triggerDelayedFallback = null;
  1460. };
  1461. }
  1462. },
  1463. fallback: function fallback(featureId) {
  1464. var _this11 = this;
  1465. this.externalServices.reportTelemetry({
  1466. type: "unsupportedFeature",
  1467. featureId: featureId
  1468. });
  1469. if (this.fellback) {
  1470. return;
  1471. }
  1472. this.fellback = true;
  1473. this.externalServices.fallback({
  1474. featureId: featureId,
  1475. url: this.baseUrl
  1476. }).then(function (download) {
  1477. if (!download) {
  1478. return;
  1479. }
  1480. _this11.download({
  1481. sourceEventType: "download"
  1482. });
  1483. });
  1484. },
  1485. error: function error(message, moreInfo) {
  1486. var moreInfoText = [this.l10n.get("error_version_info", {
  1487. version: _pdfjsLib.version || "?",
  1488. build: _pdfjsLib.build || "?"
  1489. }, "PDF.js v{{version}} (build: {{build}})")];
  1490. if (moreInfo) {
  1491. moreInfoText.push(this.l10n.get("error_message", {
  1492. message: moreInfo.message
  1493. }, "Message: {{message}}"));
  1494. if (moreInfo.stack) {
  1495. moreInfoText.push(this.l10n.get("error_stack", {
  1496. stack: moreInfo.stack
  1497. }, "Stack: {{stack}}"));
  1498. } else {
  1499. if (moreInfo.filename) {
  1500. moreInfoText.push(this.l10n.get("error_file", {
  1501. file: moreInfo.filename
  1502. }, "File: {{file}}"));
  1503. }
  1504. if (moreInfo.lineNumber) {
  1505. moreInfoText.push(this.l10n.get("error_line", {
  1506. line: moreInfo.lineNumber
  1507. }, "Line: {{line}}"));
  1508. }
  1509. }
  1510. }
  1511. var errorWrapperConfig = this.appConfig.errorWrapper;
  1512. var errorWrapper = errorWrapperConfig.container;
  1513. errorWrapper.removeAttribute("hidden");
  1514. var errorMessage = errorWrapperConfig.errorMessage;
  1515. errorMessage.textContent = message;
  1516. var closeButton = errorWrapperConfig.closeButton;
  1517. closeButton.onclick = function () {
  1518. errorWrapper.setAttribute("hidden", "true");
  1519. };
  1520. var errorMoreInfo = errorWrapperConfig.errorMoreInfo;
  1521. var moreInfoButton = errorWrapperConfig.moreInfoButton;
  1522. var lessInfoButton = errorWrapperConfig.lessInfoButton;
  1523. moreInfoButton.onclick = function () {
  1524. errorMoreInfo.removeAttribute("hidden");
  1525. moreInfoButton.setAttribute("hidden", "true");
  1526. lessInfoButton.removeAttribute("hidden");
  1527. errorMoreInfo.style.height = errorMoreInfo.scrollHeight + "px";
  1528. };
  1529. lessInfoButton.onclick = function () {
  1530. errorMoreInfo.setAttribute("hidden", "true");
  1531. moreInfoButton.removeAttribute("hidden");
  1532. lessInfoButton.setAttribute("hidden", "true");
  1533. };
  1534. moreInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1535. lessInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1536. closeButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1537. moreInfoButton.removeAttribute("hidden");
  1538. lessInfoButton.setAttribute("hidden", "true");
  1539. Promise.all(moreInfoText).then(function (parts) {
  1540. errorMoreInfo.value = parts.join("\n");
  1541. });
  1542. },
  1543. progress: function progress(level) {
  1544. var _this12 = this;
  1545. if (this.downloadComplete) {
  1546. return;
  1547. }
  1548. var percent = Math.round(level * 100);
  1549. if (percent > this.loadingBar.percent || isNaN(percent)) {
  1550. this.loadingBar.percent = percent;
  1551. var disableAutoFetch = this.pdfDocument ? this.pdfDocument.loadingParams.disableAutoFetch : _app_options.AppOptions.get("disableAutoFetch");
  1552. if (disableAutoFetch && percent) {
  1553. if (this.disableAutoFetchLoadingBarTimeout) {
  1554. clearTimeout(this.disableAutoFetchLoadingBarTimeout);
  1555. this.disableAutoFetchLoadingBarTimeout = null;
  1556. }
  1557. this.loadingBar.show();
  1558. this.disableAutoFetchLoadingBarTimeout = setTimeout(function () {
  1559. _this12.loadingBar.hide();
  1560. document.querySelector('#m_loading').style.display = 'none'
  1561. _this12.disableAutoFetchLoadingBarTimeout = null;
  1562. }, DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT);
  1563. }
  1564. }
  1565. },
  1566. load: function load(pdfDocument) {
  1567. var _this13 = this;
  1568. this.pdfDocument = pdfDocument;
  1569. pdfDocument.getDownloadInfo().then(function (_ref5) {
  1570. var length = _ref5.length;
  1571. _this13._contentLength = length;
  1572. _this13.downloadComplete = true;
  1573. _this13.loadingBar.hide();
  1574. document.querySelector('#m_loading').style.display = 'none'
  1575. firstPagePromise.then(function () {
  1576. _this13.eventBus.dispatch("documentloaded", {
  1577. source: _this13
  1578. });
  1579. });
  1580. });
  1581. var pageLayoutPromise = pdfDocument.getPageLayout()["catch"](function () {});
  1582. var pageModePromise = pdfDocument.getPageMode()["catch"](function () {});
  1583. var openActionPromise = pdfDocument.getOpenAction()["catch"](function () {});
  1584. this.toolbar.setPagesCount(pdfDocument.numPages, false);
  1585. this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
  1586. var baseDocumentUrl;
  1587. baseDocumentUrl = null;
  1588. this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
  1589. this.pdfDocumentProperties.setDocument(pdfDocument, this.url);
  1590. var pdfViewer = this.pdfViewer;
  1591. pdfViewer.setDocument(pdfDocument);
  1592. var firstPagePromise = pdfViewer.firstPagePromise,
  1593. onePageRendered = pdfViewer.onePageRendered,
  1594. pagesPromise = pdfViewer.pagesPromise;
  1595. var pdfThumbnailViewer = this.pdfThumbnailViewer;
  1596. pdfThumbnailViewer.setDocument(pdfDocument);
  1597. var storedPromise = (this.store = new _view_history.ViewHistory(pdfDocument.fingerprint)).getMultiple({
  1598. page: null,
  1599. zoom: _ui_utils.DEFAULT_SCALE_VALUE,
  1600. scrollLeft: "0",
  1601. scrollTop: "0",
  1602. rotation: null,
  1603. sidebarView: _ui_utils.SidebarView.UNKNOWN,
  1604. scrollMode: _ui_utils.ScrollMode.UNKNOWN,
  1605. spreadMode: _ui_utils.SpreadMode.UNKNOWN
  1606. })["catch"](function () {
  1607. return Object.create(null);
  1608. });
  1609. firstPagePromise.then(function (pdfPage) {
  1610. _this13.loadingBar.setWidth(_this13.appConfig.viewerContainer);
  1611. _this13._initializeAnnotationStorageCallbacks(pdfDocument);
  1612. Promise.all([_ui_utils.animationStarted, storedPromise, pageLayoutPromise, pageModePromise, openActionPromise]).then( /*#__PURE__*/function () {
  1613. var _ref7 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee12(_ref6) {
  1614. var _ref8, timeStamp, stored, pageLayout, pageMode, openAction, viewOnLoad, initialBookmark, zoom, hash, rotation, sidebarView, scrollMode, spreadMode;
  1615. return _regenerator["default"].wrap(function _callee12$(_context12) {
  1616. while (1) {
  1617. switch (_context12.prev = _context12.next) {
  1618. case 0:
  1619. _ref8 = _slicedToArray(_ref6, 5), timeStamp = _ref8[0], stored = _ref8[1], pageLayout = _ref8[2], pageMode = _ref8[3], openAction = _ref8[4];
  1620. viewOnLoad = _app_options.AppOptions.get("viewOnLoad");
  1621. _this13._initializePdfHistory({
  1622. fingerprint: pdfDocument.fingerprint,
  1623. viewOnLoad: viewOnLoad,
  1624. initialDest: openAction && openAction.dest
  1625. });
  1626. initialBookmark = _this13.initialBookmark;
  1627. zoom = _app_options.AppOptions.get("defaultZoomValue");
  1628. hash = zoom ? "zoom=".concat(zoom) : null;
  1629. rotation = null;
  1630. sidebarView = _app_options.AppOptions.get("sidebarViewOnLoad");
  1631. scrollMode = _app_options.AppOptions.get("scrollModeOnLoad");
  1632. spreadMode = _app_options.AppOptions.get("spreadModeOnLoad");
  1633. if (stored.page && viewOnLoad !== ViewOnLoad.INITIAL) {
  1634. hash = "page=".concat(stored.page, "&zoom=").concat(zoom || stored.zoom, ",") + "".concat(stored.scrollLeft, ",").concat(stored.scrollTop);
  1635. rotation = parseInt(stored.rotation, 10);
  1636. if (sidebarView === _ui_utils.SidebarView.UNKNOWN) {
  1637. sidebarView = stored.sidebarView | 0;
  1638. }
  1639. if (scrollMode === _ui_utils.ScrollMode.UNKNOWN) {
  1640. scrollMode = stored.scrollMode | 0;
  1641. }
  1642. if (spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
  1643. spreadMode = stored.spreadMode | 0;
  1644. }
  1645. }
  1646. if (pageMode && sidebarView === _ui_utils.SidebarView.UNKNOWN) {
  1647. sidebarView = apiPageModeToSidebarView(pageMode);
  1648. }
  1649. if (pageLayout && spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
  1650. spreadMode = apiPageLayoutToSpreadMode(pageLayout);
  1651. }
  1652. _this13.setInitialView(hash, {
  1653. rotation: rotation,
  1654. sidebarView: sidebarView,
  1655. scrollMode: scrollMode,
  1656. spreadMode: spreadMode
  1657. });
  1658. _this13.eventBus.dispatch("documentinit", {
  1659. source: _this13
  1660. });
  1661. if (!_this13.isViewerEmbedded) {
  1662. pdfViewer.focus();
  1663. }
  1664. _this13._initializePermissions(pdfDocument);
  1665. _context12.next = 19;
  1666. return Promise.race([pagesPromise, new Promise(function (resolve) {
  1667. setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT);
  1668. })]);
  1669. case 19:
  1670. if (!(!initialBookmark && !hash)) {
  1671. _context12.next = 21;
  1672. break;
  1673. }
  1674. return _context12.abrupt("return");
  1675. case 21:
  1676. if (!pdfViewer.hasEqualPageSizes) {
  1677. _context12.next = 23;
  1678. break;
  1679. }
  1680. return _context12.abrupt("return");
  1681. case 23:
  1682. _this13.initialBookmark = initialBookmark;
  1683. pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;
  1684. _this13.setInitialView(hash);
  1685. case 26:
  1686. case "end":
  1687. return _context12.stop();
  1688. }
  1689. }
  1690. }, _callee12);
  1691. }));
  1692. return function (_x2) {
  1693. return _ref7.apply(this, arguments);
  1694. };
  1695. }())["catch"](function () {
  1696. _this13.setInitialView();
  1697. }).then(function () {
  1698. pdfViewer.update();
  1699. });
  1700. });
  1701. pagesPromise.then(function () {
  1702. _this13._initializeAutoPrint(pdfDocument, openActionPromise);
  1703. });
  1704. onePageRendered.then(function () {
  1705. pdfDocument.getOutline().then(function (outline) {
  1706. _this13.pdfOutlineViewer.render({
  1707. outline: outline,
  1708. pdfDocument: pdfDocument
  1709. });
  1710. });
  1711. pdfDocument.getAttachments().then(function (attachments) {
  1712. _this13.pdfAttachmentViewer.render({
  1713. attachments: attachments
  1714. });
  1715. });
  1716. pdfViewer.optionalContentConfigPromise.then(function (optionalContentConfig) {
  1717. _this13.pdfLayerViewer.render({
  1718. optionalContentConfig: optionalContentConfig,
  1719. pdfDocument: pdfDocument
  1720. });
  1721. });
  1722. if ("requestIdleCallback" in window) {
  1723. var callback = window.requestIdleCallback(function () {
  1724. _this13._collectTelemetry(pdfDocument);
  1725. _this13._idleCallbacks["delete"](callback);
  1726. }, {
  1727. timeout: 1000
  1728. });
  1729. _this13._idleCallbacks.add(callback);
  1730. }
  1731. _this13._initializeJavaScript(pdfDocument);
  1732. });
  1733. this._initializePageLabels(pdfDocument);
  1734. this._initializeMetadata(pdfDocument);
  1735. },
  1736. _initializeJavaScript: function _initializeJavaScript(pdfDocument) {
  1737. var _this14 = this;
  1738. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee15() {
  1739. var _yield$Promise$all, _yield$Promise$all2, objects, calculationOrder, docActions, scripting, internalEvents, domEvents, updateFromSandbox, visitedPages, pageOpen, pageClose, dispatchEventInSandbox, mouseDown, mouseUp, _iterator4, _step4, _step4$value, name, listener, _iterator5, _step5, _step5$value, _name2, _listener2, _this14$metadata, _this14$metadata2;
  1740. return _regenerator["default"].wrap(function _callee15$(_context15) {
  1741. while (1) {
  1742. switch (_context15.prev = _context15.next) {
  1743. case 0:
  1744. if (_app_options.AppOptions.get("enableScripting")) {
  1745. _context15.next = 2;
  1746. break;
  1747. }
  1748. return _context15.abrupt("return");
  1749. case 2:
  1750. _context15.next = 4;
  1751. return Promise.all([pdfDocument.getFieldObjects(), pdfDocument.getCalculationOrderIds(), pdfDocument.getJSActions()]);
  1752. case 4:
  1753. _yield$Promise$all = _context15.sent;
  1754. _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 3);
  1755. objects = _yield$Promise$all2[0];
  1756. calculationOrder = _yield$Promise$all2[1];
  1757. docActions = _yield$Promise$all2[2];
  1758. if (!(!objects && !docActions)) {
  1759. _context15.next = 11;
  1760. break;
  1761. }
  1762. return _context15.abrupt("return");
  1763. case 11:
  1764. if (!(pdfDocument !== _this14.pdfDocument)) {
  1765. _context15.next = 13;
  1766. break;
  1767. }
  1768. return _context15.abrupt("return");
  1769. case 13:
  1770. scripting = _this14.externalServices.createScripting({
  1771. sandboxBundleSrc: _app_options.AppOptions.get("sandboxBundleSrc")
  1772. });
  1773. internalEvents = new Map(), domEvents = new Map();
  1774. _this14._scriptingInstance = {
  1775. scripting: scripting,
  1776. ready: false,
  1777. internalEvents: internalEvents,
  1778. domEvents: domEvents
  1779. };
  1780. if (_this14.documentInfo) {
  1781. _context15.next = 21;
  1782. break;
  1783. }
  1784. _context15.next = 19;
  1785. return new Promise(function (resolve) {
  1786. _this14.eventBus._on("metadataloaded", function (evt) {
  1787. resolve();
  1788. }, {
  1789. once: true
  1790. });
  1791. });
  1792. case 19:
  1793. if (!(pdfDocument !== _this14.pdfDocument)) {
  1794. _context15.next = 21;
  1795. break;
  1796. }
  1797. return _context15.abrupt("return");
  1798. case 21:
  1799. if (_this14._contentLength) {
  1800. _context15.next = 26;
  1801. break;
  1802. }
  1803. _context15.next = 24;
  1804. return new Promise(function (resolve) {
  1805. _this14.eventBus._on("documentloaded", function (evt) {
  1806. resolve();
  1807. }, {
  1808. once: true
  1809. });
  1810. });
  1811. case 24:
  1812. if (!(pdfDocument !== _this14.pdfDocument)) {
  1813. _context15.next = 26;
  1814. break;
  1815. }
  1816. return _context15.abrupt("return");
  1817. case 26:
  1818. updateFromSandbox = function updateFromSandbox(_ref9) {
  1819. var detail = _ref9.detail;
  1820. var id = detail.id,
  1821. command = detail.command,
  1822. value = detail.value;
  1823. if (!id) {
  1824. switch (command) {
  1825. case "clear":
  1826. console.clear();
  1827. break;
  1828. case "error":
  1829. console.error(value);
  1830. break;
  1831. case "layout":
  1832. _this14.pdfViewer.spreadMode = apiPageLayoutToSpreadMode(value);
  1833. break;
  1834. case "page-num":
  1835. _this14.pdfViewer.currentPageNumber = value + 1;
  1836. break;
  1837. case "print":
  1838. _this14.pdfViewer.pagesPromise.then(function () {
  1839. _this14.triggerPrinting();
  1840. });
  1841. break;
  1842. case "println":
  1843. console.log(value);
  1844. break;
  1845. case "zoom":
  1846. _this14.pdfViewer.currentScaleValue = value;
  1847. break;
  1848. }
  1849. return;
  1850. }
  1851. var element = document.getElementById(id);
  1852. if (element) {
  1853. element.dispatchEvent(new CustomEvent("updatefromsandbox", {
  1854. detail: detail
  1855. }));
  1856. } else {
  1857. if (value !== undefined && value !== null) {
  1858. pdfDocument.annotationStorage.setValue(id, value);
  1859. }
  1860. }
  1861. };
  1862. internalEvents.set("updatefromsandbox", updateFromSandbox);
  1863. visitedPages = new Map();
  1864. pageOpen = function pageOpen(_ref10) {
  1865. var pageNumber = _ref10.pageNumber,
  1866. actionsPromise = _ref10.actionsPromise;
  1867. visitedPages.set(pageNumber, _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee13() {
  1868. var _this14$_scriptingIns;
  1869. var actions;
  1870. return _regenerator["default"].wrap(function _callee13$(_context13) {
  1871. while (1) {
  1872. switch (_context13.prev = _context13.next) {
  1873. case 0:
  1874. actions = null;
  1875. if (visitedPages.has(pageNumber)) {
  1876. _context13.next = 7;
  1877. break;
  1878. }
  1879. _context13.next = 4;
  1880. return actionsPromise;
  1881. case 4:
  1882. actions = _context13.sent;
  1883. if (!(pdfDocument !== _this14.pdfDocument)) {
  1884. _context13.next = 7;
  1885. break;
  1886. }
  1887. return _context13.abrupt("return");
  1888. case 7:
  1889. _context13.next = 9;
  1890. return (_this14$_scriptingIns = _this14._scriptingInstance) === null || _this14$_scriptingIns === void 0 ? void 0 : _this14$_scriptingIns.scripting.dispatchEventInSandbox({
  1891. id: "page",
  1892. name: "PageOpen",
  1893. pageNumber: pageNumber,
  1894. actions: actions
  1895. });
  1896. case 9:
  1897. case "end":
  1898. return _context13.stop();
  1899. }
  1900. }
  1901. }, _callee13);
  1902. }))());
  1903. };
  1904. pageClose = /*#__PURE__*/function () {
  1905. var _ref13 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee14(_ref12) {
  1906. var _this14$_scriptingIns2;
  1907. var pageNumber, actionsPromise;
  1908. return _regenerator["default"].wrap(function _callee14$(_context14) {
  1909. while (1) {
  1910. switch (_context14.prev = _context14.next) {
  1911. case 0:
  1912. pageNumber = _ref12.pageNumber;
  1913. actionsPromise = visitedPages.get(pageNumber);
  1914. if (actionsPromise) {
  1915. _context14.next = 4;
  1916. break;
  1917. }
  1918. return _context14.abrupt("return");
  1919. case 4:
  1920. visitedPages.set(pageNumber, null);
  1921. _context14.next = 7;
  1922. return actionsPromise;
  1923. case 7:
  1924. if (!(pdfDocument !== _this14.pdfDocument)) {
  1925. _context14.next = 9;
  1926. break;
  1927. }
  1928. return _context14.abrupt("return");
  1929. case 9:
  1930. _context14.next = 11;
  1931. return (_this14$_scriptingIns2 = _this14._scriptingInstance) === null || _this14$_scriptingIns2 === void 0 ? void 0 : _this14$_scriptingIns2.scripting.dispatchEventInSandbox({
  1932. id: "page",
  1933. name: "PageClose",
  1934. pageNumber: pageNumber
  1935. });
  1936. case 11:
  1937. case "end":
  1938. return _context14.stop();
  1939. }
  1940. }
  1941. }, _callee14);
  1942. }));
  1943. return function pageClose(_x3) {
  1944. return _ref13.apply(this, arguments);
  1945. };
  1946. }();
  1947. internalEvents.set("pageopen", pageOpen);
  1948. internalEvents.set("pageclose", pageClose);
  1949. dispatchEventInSandbox = function dispatchEventInSandbox(_ref14) {
  1950. var detail = _ref14.detail;
  1951. scripting.dispatchEventInSandbox(detail);
  1952. };
  1953. internalEvents.set("dispatcheventinsandbox", dispatchEventInSandbox);
  1954. mouseDown = function mouseDown(event) {
  1955. _this14._mouseState.isDown = true;
  1956. };
  1957. domEvents.set("mousedown", mouseDown);
  1958. mouseUp = function mouseUp(event) {
  1959. _this14._mouseState.isDown = false;
  1960. };
  1961. domEvents.set("mouseup", mouseUp);
  1962. _iterator4 = _createForOfIteratorHelper(internalEvents);
  1963. try {
  1964. for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
  1965. _step4$value = _slicedToArray(_step4.value, 2), name = _step4$value[0], listener = _step4$value[1];
  1966. _this14.eventBus._on(name, listener);
  1967. }
  1968. } catch (err) {
  1969. _iterator4.e(err);
  1970. } finally {
  1971. _iterator4.f();
  1972. }
  1973. _iterator5 = _createForOfIteratorHelper(domEvents);
  1974. try {
  1975. for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
  1976. _step5$value = _slicedToArray(_step5.value, 2), _name2 = _step5$value[0], _listener2 = _step5$value[1];
  1977. window.addEventListener(_name2, _listener2);
  1978. }
  1979. } catch (err) {
  1980. _iterator5.e(err);
  1981. } finally {
  1982. _iterator5.f();
  1983. }
  1984. _context15.prev = 43;
  1985. _context15.next = 46;
  1986. return scripting.createSandbox({
  1987. objects: objects,
  1988. calculationOrder: calculationOrder,
  1989. appInfo: {
  1990. platform: navigator.platform,
  1991. language: navigator.language
  1992. },
  1993. docInfo: _objectSpread(_objectSpread({}, _this14.documentInfo), {}, {
  1994. baseURL: _this14.baseUrl,
  1995. filesize: _this14._contentLength,
  1996. filename: _this14._docFilename,
  1997. metadata: (_this14$metadata = _this14.metadata) === null || _this14$metadata === void 0 ? void 0 : _this14$metadata.getRaw(),
  1998. authors: (_this14$metadata2 = _this14.metadata) === null || _this14$metadata2 === void 0 ? void 0 : _this14$metadata2.get("dc:creator"),
  1999. numPages: pdfDocument.numPages,
  2000. URL: _this14.url,
  2001. actions: docActions
  2002. })
  2003. });
  2004. case 46:
  2005. if (_this14.externalServices.isInAutomation) {
  2006. _this14.eventBus.dispatch("sandboxcreated", {
  2007. source: _this14
  2008. });
  2009. }
  2010. _context15.next = 54;
  2011. break;
  2012. case 49:
  2013. _context15.prev = 49;
  2014. _context15.t0 = _context15["catch"](43);
  2015. console.error("_initializeJavaScript: \"".concat(_context15.t0 === null || _context15.t0 === void 0 ? void 0 : _context15.t0.message, "\"."));
  2016. _this14._destroyScriptingInstance();
  2017. return _context15.abrupt("return");
  2018. case 54:
  2019. _context15.next = 56;
  2020. return scripting.dispatchEventInSandbox({
  2021. id: "doc",
  2022. name: "Open"
  2023. });
  2024. case 56:
  2025. _context15.next = 58;
  2026. return _this14.pdfViewer.initializeScriptingEvents();
  2027. case 58:
  2028. Promise.resolve().then(function () {
  2029. if (_this14._scriptingInstance) {
  2030. _this14._scriptingInstance.ready = true;
  2031. }
  2032. });
  2033. case 59:
  2034. case "end":
  2035. return _context15.stop();
  2036. }
  2037. }
  2038. }, _callee15, null, [[43, 49]]);
  2039. }))();
  2040. },
  2041. _collectTelemetry: function _collectTelemetry(pdfDocument) {
  2042. var _this15 = this;
  2043. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee16() {
  2044. var markInfo, tagged;
  2045. return _regenerator["default"].wrap(function _callee16$(_context16) {
  2046. while (1) {
  2047. switch (_context16.prev = _context16.next) {
  2048. case 0:
  2049. _context16.next = 2;
  2050. return _this15.pdfDocument.getMarkInfo();
  2051. case 2:
  2052. markInfo = _context16.sent;
  2053. if (!(pdfDocument !== _this15.pdfDocument)) {
  2054. _context16.next = 5;
  2055. break;
  2056. }
  2057. return _context16.abrupt("return");
  2058. case 5:
  2059. tagged = (markInfo === null || markInfo === void 0 ? void 0 : markInfo.Marked) || false;
  2060. _this15.externalServices.reportTelemetry({
  2061. type: "tagged",
  2062. tagged: tagged
  2063. });
  2064. case 7:
  2065. case "end":
  2066. return _context16.stop();
  2067. }
  2068. }
  2069. }, _callee16);
  2070. }))();
  2071. },
  2072. _initializeAutoPrint: function _initializeAutoPrint(pdfDocument, openActionPromise) {
  2073. var _this16 = this;
  2074. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee17() {
  2075. var _yield$Promise$all3, _yield$Promise$all4, openAction, javaScript, triggerAutoPrint, _iterator6, _step6, js;
  2076. return _regenerator["default"].wrap(function _callee17$(_context17) {
  2077. while (1) {
  2078. switch (_context17.prev = _context17.next) {
  2079. case 0:
  2080. _context17.next = 2;
  2081. return Promise.all([openActionPromise, !_app_options.AppOptions.get("enableScripting") ? pdfDocument.getJavaScript() : null]);
  2082. case 2:
  2083. _yield$Promise$all3 = _context17.sent;
  2084. _yield$Promise$all4 = _slicedToArray(_yield$Promise$all3, 2);
  2085. openAction = _yield$Promise$all4[0];
  2086. javaScript = _yield$Promise$all4[1];
  2087. if (!(pdfDocument !== _this16.pdfDocument)) {
  2088. _context17.next = 8;
  2089. break;
  2090. }
  2091. return _context17.abrupt("return");
  2092. case 8:
  2093. triggerAutoPrint = false;
  2094. if ((openAction === null || openAction === void 0 ? void 0 : openAction.action) === "Print") {
  2095. triggerAutoPrint = true;
  2096. }
  2097. if (!javaScript) {
  2098. _context17.next = 31;
  2099. break;
  2100. }
  2101. javaScript.some(function (js) {
  2102. if (!js) {
  2103. return false;
  2104. }
  2105. console.warn("Warning: JavaScript is not supported");
  2106. _this16._delayedFallback(_pdfjsLib.UNSUPPORTED_FEATURES.javaScript);
  2107. return true;
  2108. });
  2109. if (triggerAutoPrint) {
  2110. _context17.next = 31;
  2111. break;
  2112. }
  2113. _iterator6 = _createForOfIteratorHelper(javaScript);
  2114. _context17.prev = 14;
  2115. _iterator6.s();
  2116. case 16:
  2117. if ((_step6 = _iterator6.n()).done) {
  2118. _context17.next = 23;
  2119. break;
  2120. }
  2121. js = _step6.value;
  2122. if (!(js && _ui_utils.AutoPrintRegExp.test(js))) {
  2123. _context17.next = 21;
  2124. break;
  2125. }
  2126. triggerAutoPrint = true;
  2127. return _context17.abrupt("break", 23);
  2128. case 21:
  2129. _context17.next = 16;
  2130. break;
  2131. case 23:
  2132. _context17.next = 28;
  2133. break;
  2134. case 25:
  2135. _context17.prev = 25;
  2136. _context17.t0 = _context17["catch"](14);
  2137. _iterator6.e(_context17.t0);
  2138. case 28:
  2139. _context17.prev = 28;
  2140. _iterator6.f();
  2141. return _context17.finish(28);
  2142. case 31:
  2143. if (triggerAutoPrint) {
  2144. _this16.triggerPrinting();
  2145. }
  2146. case 32:
  2147. case "end":
  2148. return _context17.stop();
  2149. }
  2150. }
  2151. }, _callee17, null, [[14, 25, 28, 31]]);
  2152. }))();
  2153. },
  2154. _initializeMetadata: function _initializeMetadata(pdfDocument) {
  2155. var _this17 = this;
  2156. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee18() {
  2157. var _this17$_contentLengt;
  2158. var _yield$pdfDocument$ge, info, metadata, contentDispositionFilename, contentLength, pdfTitle, infoTitle, metadataTitle, versionId, generatorId, producer, formType;
  2159. return _regenerator["default"].wrap(function _callee18$(_context18) {
  2160. while (1) {
  2161. switch (_context18.prev = _context18.next) {
  2162. case 0:
  2163. _context18.next = 2;
  2164. return pdfDocument.getMetadata();
  2165. case 2:
  2166. _yield$pdfDocument$ge = _context18.sent;
  2167. info = _yield$pdfDocument$ge.info;
  2168. metadata = _yield$pdfDocument$ge.metadata;
  2169. contentDispositionFilename = _yield$pdfDocument$ge.contentDispositionFilename;
  2170. contentLength = _yield$pdfDocument$ge.contentLength;
  2171. if (!(pdfDocument !== _this17.pdfDocument)) {
  2172. _context18.next = 9;
  2173. break;
  2174. }
  2175. return _context18.abrupt("return");
  2176. case 9:
  2177. _this17.documentInfo = info;
  2178. _this17.metadata = metadata;
  2179. _this17._contentDispositionFilename = contentDispositionFilename;
  2180. (_this17$_contentLengt = _this17._contentLength) !== null && _this17$_contentLengt !== void 0 ? _this17$_contentLengt : _this17._contentLength = contentLength;
  2181. console.log("PDF ".concat(pdfDocument.fingerprint, " [").concat(info.PDFFormatVersion, " ") + "".concat((info.Producer || "-").trim(), " / ").concat((info.Creator || "-").trim(), "] ") + "(PDF.js: ".concat(_pdfjsLib.version || "-") + "".concat(_this17.pdfViewer.enableWebGL ? " [WebGL]" : "", ")"));
  2182. infoTitle = info && info.Title;
  2183. if (infoTitle) {
  2184. pdfTitle = infoTitle;
  2185. }
  2186. metadataTitle = metadata && metadata.get("dc:title");
  2187. if (metadataTitle) {
  2188. if (metadataTitle !== "Untitled" && !/[\uFFF0-\uFFFF]/g.test(metadataTitle)) {
  2189. pdfTitle = metadataTitle;
  2190. }
  2191. }
  2192. if (pdfTitle) {
  2193. _this17.setTitle("".concat(pdfTitle, " - ").concat(contentDispositionFilename || document.title));
  2194. } else if (contentDispositionFilename) {
  2195. _this17.setTitle(contentDispositionFilename);
  2196. }
  2197. if (info.IsXFAPresent && !info.IsAcroFormPresent) {
  2198. console.warn("Warning: XFA is not supported");
  2199. _this17._delayedFallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms);
  2200. } else if ((info.IsAcroFormPresent || info.IsXFAPresent) && !_this17.pdfViewer.renderInteractiveForms) {
  2201. console.warn("Warning: Interactive form support is not enabled");
  2202. _this17._delayedFallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms);
  2203. }
  2204. versionId = "other";
  2205. if (KNOWN_VERSIONS.includes(info.PDFFormatVersion)) {
  2206. versionId = "v".concat(info.PDFFormatVersion.replace(".", "_"));
  2207. }
  2208. generatorId = "other";
  2209. if (info.Producer) {
  2210. producer = info.Producer.toLowerCase();
  2211. KNOWN_GENERATORS.some(function (generator) {
  2212. if (!producer.includes(generator)) {
  2213. return false;
  2214. }
  2215. generatorId = generator.replace(/[ .-]/g, "_");
  2216. return true;
  2217. });
  2218. }
  2219. formType = null;
  2220. if (info.IsXFAPresent) {
  2221. formType = "xfa";
  2222. } else if (info.IsAcroFormPresent) {
  2223. formType = "acroform";
  2224. }
  2225. _this17.externalServices.reportTelemetry({
  2226. type: "documentInfo",
  2227. version: versionId,
  2228. generator: generatorId,
  2229. formType: formType
  2230. });
  2231. _this17.eventBus.dispatch("metadataloaded", {
  2232. source: _this17
  2233. });
  2234. console.log(document.querySelectorAll('canvas'), 'title')
  2235. setTimeout(() => {
  2236. const canvas = document.querySelectorAll('canvas')[0]
  2237. if(canvas) {
  2238. canvas.style.margin = '0.1px'
  2239. }
  2240. }, 300);
  2241. case 28:
  2242. case "end":
  2243. return _context18.stop();
  2244. }
  2245. }
  2246. }, _callee18);
  2247. }))();
  2248. },
  2249. _initializePageLabels: function _initializePageLabels(pdfDocument) {
  2250. var _this18 = this;
  2251. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee19() {
  2252. var labels, numLabels, i, pdfViewer, pdfThumbnailViewer, toolbar;
  2253. return _regenerator["default"].wrap(function _callee19$(_context19) {
  2254. while (1) {
  2255. switch (_context19.prev = _context19.next) {
  2256. case 0:
  2257. _context19.next = 2;
  2258. return pdfDocument.getPageLabels();
  2259. case 2:
  2260. labels = _context19.sent;
  2261. if (!(pdfDocument !== _this18.pdfDocument)) {
  2262. _context19.next = 5;
  2263. break;
  2264. }
  2265. return _context19.abrupt("return");
  2266. case 5:
  2267. if (!(!labels || _app_options.AppOptions.get("disablePageLabels"))) {
  2268. _context19.next = 7;
  2269. break;
  2270. }
  2271. return _context19.abrupt("return");
  2272. case 7:
  2273. numLabels = labels.length;
  2274. if (!(numLabels !== _this18.pagesCount)) {
  2275. _context19.next = 11;
  2276. break;
  2277. }
  2278. console.error("The number of Page Labels does not match the number of pages in the document.");
  2279. return _context19.abrupt("return");
  2280. case 11:
  2281. i = 0;
  2282. while (i < numLabels && labels[i] === (i + 1).toString()) {
  2283. i++;
  2284. }
  2285. if (!(i === numLabels)) {
  2286. _context19.next = 15;
  2287. break;
  2288. }
  2289. return _context19.abrupt("return");
  2290. case 15:
  2291. pdfViewer = _this18.pdfViewer, pdfThumbnailViewer = _this18.pdfThumbnailViewer, toolbar = _this18.toolbar;
  2292. pdfViewer.setPageLabels(labels);
  2293. pdfThumbnailViewer.setPageLabels(labels);
  2294. toolbar.setPagesCount(numLabels, true);
  2295. toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  2296. case 20:
  2297. case "end":
  2298. return _context19.stop();
  2299. }
  2300. }
  2301. }, _callee19);
  2302. }))();
  2303. },
  2304. _initializePdfHistory: function _initializePdfHistory(_ref15) {
  2305. var fingerprint = _ref15.fingerprint,
  2306. viewOnLoad = _ref15.viewOnLoad,
  2307. _ref15$initialDest = _ref15.initialDest,
  2308. initialDest = _ref15$initialDest === void 0 ? null : _ref15$initialDest;
  2309. if (this.isViewerEmbedded || _app_options.AppOptions.get("disableHistory")) {
  2310. return;
  2311. }
  2312. this.pdfHistory.initialize({
  2313. fingerprint: fingerprint,
  2314. resetHistory: viewOnLoad === ViewOnLoad.INITIAL,
  2315. updateUrl: _app_options.AppOptions.get("historyUpdateUrl")
  2316. });
  2317. if (this.pdfHistory.initialBookmark) {
  2318. this.initialBookmark = this.pdfHistory.initialBookmark;
  2319. this.initialRotation = this.pdfHistory.initialRotation;
  2320. }
  2321. if (initialDest && !this.initialBookmark && viewOnLoad === ViewOnLoad.UNKNOWN) {
  2322. this.initialBookmark = JSON.stringify(initialDest);
  2323. this.pdfHistory.push({
  2324. explicitDest: initialDest,
  2325. pageNumber: null
  2326. });
  2327. }
  2328. },
  2329. _initializePermissions: function _initializePermissions(pdfDocument) {
  2330. var _this19 = this;
  2331. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee20() {
  2332. var permissions;
  2333. return _regenerator["default"].wrap(function _callee20$(_context20) {
  2334. while (1) {
  2335. switch (_context20.prev = _context20.next) {
  2336. case 0:
  2337. _context20.next = 2;
  2338. return pdfDocument.getPermissions();
  2339. case 2:
  2340. permissions = _context20.sent;
  2341. if (!(pdfDocument !== _this19.pdfDocument)) {
  2342. _context20.next = 5;
  2343. break;
  2344. }
  2345. return _context20.abrupt("return");
  2346. case 5:
  2347. if (!(!permissions || !_app_options.AppOptions.get("enablePermissions"))) {
  2348. _context20.next = 7;
  2349. break;
  2350. }
  2351. return _context20.abrupt("return");
  2352. case 7:
  2353. if (!permissions.includes(_pdfjsLib.PermissionFlag.COPY)) {
  2354. _this19.appConfig.viewerContainer.classList.add(ENABLE_PERMISSIONS_CLASS);
  2355. }
  2356. case 8:
  2357. case "end":
  2358. return _context20.stop();
  2359. }
  2360. }
  2361. }, _callee20);
  2362. }))();
  2363. },
  2364. _initializeAnnotationStorageCallbacks: function _initializeAnnotationStorageCallbacks(pdfDocument) {
  2365. if (pdfDocument !== this.pdfDocument) {
  2366. return;
  2367. }
  2368. var annotationStorage = pdfDocument.annotationStorage;
  2369. annotationStorage.onSetModified = function () {
  2370. window.addEventListener("beforeunload", beforeUnload);
  2371. };
  2372. annotationStorage.onResetModified = function () {
  2373. window.removeEventListener("beforeunload", beforeUnload);
  2374. };
  2375. },
  2376. setInitialView: function setInitialView(storedHash) {
  2377. var _this20 = this;
  2378. var _ref16 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  2379. rotation = _ref16.rotation,
  2380. sidebarView = _ref16.sidebarView,
  2381. scrollMode = _ref16.scrollMode,
  2382. spreadMode = _ref16.spreadMode;
  2383. var setRotation = function setRotation(angle) {
  2384. if ((0, _ui_utils.isValidRotation)(angle)) {
  2385. _this20.pdfViewer.pagesRotation = angle;
  2386. }
  2387. };
  2388. var setViewerModes = function setViewerModes(scroll, spread) {
  2389. if ((0, _ui_utils.isValidScrollMode)(scroll)) {
  2390. _this20.pdfViewer.scrollMode = scroll;
  2391. }
  2392. if ((0, _ui_utils.isValidSpreadMode)(spread)) {
  2393. _this20.pdfViewer.spreadMode = spread;
  2394. }
  2395. };
  2396. this.isInitialViewSet = true;
  2397. this.pdfSidebar.setInitialView(sidebarView);
  2398. setViewerModes(scrollMode, spreadMode);
  2399. if (this.initialBookmark) {
  2400. setRotation(this.initialRotation);
  2401. delete this.initialRotation;
  2402. this.pdfLinkService.setHash(this.initialBookmark);
  2403. this.initialBookmark = null;
  2404. } else if (storedHash) {
  2405. setRotation(rotation);
  2406. this.pdfLinkService.setHash(storedHash);
  2407. }
  2408. this.toolbar.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel);
  2409. this.secondaryToolbar.setPageNumber(this.pdfViewer.currentPageNumber);
  2410. if (!this.pdfViewer.currentScaleValue) {
  2411. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  2412. }
  2413. },
  2414. cleanup: function cleanup() {
  2415. if (!this.pdfDocument) {
  2416. return;
  2417. }
  2418. this.pdfViewer.cleanup();
  2419. this.pdfThumbnailViewer.cleanup();
  2420. if (this.pdfViewer.renderer !== _ui_utils.RendererType.SVG) {
  2421. this.pdfDocument.cleanup();
  2422. }
  2423. },
  2424. forceRendering: function forceRendering() {
  2425. this.pdfRenderingQueue.printing = !!this.printService;
  2426. this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar.isThumbnailViewVisible;
  2427. this.pdfRenderingQueue.renderHighestPriority();
  2428. },
  2429. beforePrint: function beforePrint() {
  2430. var _this$_scriptingInsta,
  2431. _this21 = this;
  2432. (_this$_scriptingInsta = this._scriptingInstance) === null || _this$_scriptingInsta === void 0 ? void 0 : _this$_scriptingInsta.scripting.dispatchEventInSandbox({
  2433. id: "doc",
  2434. name: "WillPrint"
  2435. });
  2436. if (this.printService) {
  2437. return;
  2438. }
  2439. if (!this.supportsPrinting) {
  2440. this.l10n.get("printing_not_supported", null, "Warning: Printing is not fully supported by this browser.").then(function (printMessage) {
  2441. _this21.error(printMessage);
  2442. });
  2443. return;
  2444. }
  2445. if (!this.pdfViewer.pageViewsReady) {
  2446. this.l10n.get("printing_not_ready", null, "Warning: The PDF is not fully loaded for printing.").then(function (notReadyMessage) {
  2447. window.alert(notReadyMessage);
  2448. });
  2449. return;
  2450. }
  2451. var pagesOverview = this.pdfViewer.getPagesOverview();
  2452. var printContainer = this.appConfig.printContainer;
  2453. var printResolution = _app_options.AppOptions.get("printResolution");
  2454. var optionalContentConfigPromise = this.pdfViewer.optionalContentConfigPromise;
  2455. var printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, this.l10n);
  2456. this.printService = printService;
  2457. this.forceRendering();
  2458. printService.layout();
  2459. this.externalServices.reportTelemetry({
  2460. type: "print"
  2461. });
  2462. },
  2463. afterPrint: function afterPrint() {
  2464. var _this$_scriptingInsta2;
  2465. (_this$_scriptingInsta2 = this._scriptingInstance) === null || _this$_scriptingInsta2 === void 0 ? void 0 : _this$_scriptingInsta2.scripting.dispatchEventInSandbox({
  2466. id: "doc",
  2467. name: "DidPrint"
  2468. });
  2469. if (this.printService) {
  2470. this.printService.destroy();
  2471. this.printService = null;
  2472. if (this.pdfDocument) {
  2473. this.pdfDocument.annotationStorage.resetModified();
  2474. }
  2475. }
  2476. this.forceRendering();
  2477. },
  2478. rotatePages: function rotatePages(delta) {
  2479. if (!this.pdfDocument) {
  2480. return;
  2481. }
  2482. var newRotation = (this.pdfViewer.pagesRotation + 360 + delta) % 360;
  2483. this.pdfViewer.pagesRotation = newRotation;
  2484. },
  2485. requestPresentationMode: function requestPresentationMode() {
  2486. if (!this.pdfPresentationMode) {
  2487. return;
  2488. }
  2489. this.pdfPresentationMode.request();
  2490. },
  2491. triggerPrinting: function triggerPrinting() {
  2492. if (!this.supportsPrinting) {
  2493. return;
  2494. }
  2495. window.print();
  2496. },
  2497. bindEvents: function bindEvents() {
  2498. var eventBus = this.eventBus,
  2499. _boundEvents = this._boundEvents;
  2500. _boundEvents.beforePrint = this.beforePrint.bind(this);
  2501. _boundEvents.afterPrint = this.afterPrint.bind(this);
  2502. eventBus._on("resize", webViewerResize);
  2503. eventBus._on("hashchange", webViewerHashchange);
  2504. eventBus._on("beforeprint", _boundEvents.beforePrint);
  2505. eventBus._on("afterprint", _boundEvents.afterPrint);
  2506. eventBus._on("pagerendered", webViewerPageRendered);
  2507. eventBus._on("updateviewarea", webViewerUpdateViewarea);
  2508. eventBus._on("pagechanging", webViewerPageChanging);
  2509. eventBus._on("scalechanging", webViewerScaleChanging);
  2510. eventBus._on("rotationchanging", webViewerRotationChanging);
  2511. eventBus._on("sidebarviewchanged", webViewerSidebarViewChanged);
  2512. eventBus._on("pagemode", webViewerPageMode);
  2513. eventBus._on("namedaction", webViewerNamedAction);
  2514. eventBus._on("presentationmodechanged", webViewerPresentationModeChanged);
  2515. eventBus._on("presentationmode", webViewerPresentationMode);
  2516. eventBus._on("print", webViewerPrint);
  2517. eventBus._on("download", webViewerDownload);
  2518. eventBus._on("save", webViewerSave);
  2519. eventBus._on("firstpage", webViewerFirstPage);
  2520. eventBus._on("lastpage", webViewerLastPage);
  2521. eventBus._on("nextpage", webViewerNextPage);
  2522. eventBus._on("previouspage", webViewerPreviousPage);
  2523. eventBus._on("zoomin", webViewerZoomIn);
  2524. eventBus._on("zoomout", webViewerZoomOut);
  2525. eventBus._on("zoomreset", webViewerZoomReset);
  2526. eventBus._on("pagenumberchanged", webViewerPageNumberChanged);
  2527. eventBus._on("scalechanged", webViewerScaleChanged);
  2528. eventBus._on("rotatecw", webViewerRotateCw);
  2529. eventBus._on("rotateccw", webViewerRotateCcw);
  2530. eventBus._on("optionalcontentconfig", webViewerOptionalContentConfig);
  2531. eventBus._on("switchscrollmode", webViewerSwitchScrollMode);
  2532. eventBus._on("scrollmodechanged", webViewerScrollModeChanged);
  2533. eventBus._on("switchspreadmode", webViewerSwitchSpreadMode);
  2534. eventBus._on("spreadmodechanged", webViewerSpreadModeChanged);
  2535. eventBus._on("documentproperties", webViewerDocumentProperties);
  2536. eventBus._on("find", webViewerFind);
  2537. eventBus._on("findfromurlhash", webViewerFindFromUrlHash);
  2538. eventBus._on("updatefindmatchescount", webViewerUpdateFindMatchesCount);
  2539. eventBus._on("updatefindcontrolstate", webViewerUpdateFindControlState);
  2540. if (_app_options.AppOptions.get("pdfBug")) {
  2541. _boundEvents.reportPageStatsPDFBug = reportPageStatsPDFBug;
  2542. eventBus._on("pagerendered", _boundEvents.reportPageStatsPDFBug);
  2543. eventBus._on("pagechanging", _boundEvents.reportPageStatsPDFBug);
  2544. }
  2545. eventBus._on("fileinputchange", webViewerFileInputChange);
  2546. eventBus._on("openfile", webViewerOpenFile);
  2547. },
  2548. bindWindowEvents: function bindWindowEvents() {
  2549. var eventBus = this.eventBus,
  2550. _boundEvents = this._boundEvents;
  2551. _boundEvents.windowResize = function () {
  2552. eventBus.dispatch("resize", {
  2553. source: window
  2554. });
  2555. };
  2556. _boundEvents.windowHashChange = function () {
  2557. eventBus.dispatch("hashchange", {
  2558. source: window,
  2559. hash: document.location.hash.substring(1)
  2560. });
  2561. };
  2562. _boundEvents.windowBeforePrint = function () {
  2563. eventBus.dispatch("beforeprint", {
  2564. source: window
  2565. });
  2566. };
  2567. _boundEvents.windowAfterPrint = function () {
  2568. eventBus.dispatch("afterprint", {
  2569. source: window
  2570. });
  2571. };
  2572. _boundEvents.windowUpdateFromSandbox = function (event) {
  2573. eventBus.dispatch("updatefromsandbox", {
  2574. source: window,
  2575. detail: event.detail
  2576. });
  2577. };
  2578. window.addEventListener("visibilitychange", webViewerVisibilityChange);
  2579. window.addEventListener("wheel", webViewerWheel, {
  2580. passive: false
  2581. });
  2582. window.addEventListener("touchstart", webViewerTouchStart, {
  2583. passive: false
  2584. });
  2585. window.addEventListener("click", webViewerClick);
  2586. window.addEventListener("keydown", webViewerKeyDown);
  2587. window.addEventListener("keyup", webViewerKeyUp);
  2588. window.addEventListener("resize", _boundEvents.windowResize);
  2589. window.addEventListener("hashchange", _boundEvents.windowHashChange);
  2590. window.addEventListener("beforeprint", _boundEvents.windowBeforePrint);
  2591. window.addEventListener("afterprint", _boundEvents.windowAfterPrint);
  2592. window.addEventListener("updatefromsandbox", _boundEvents.windowUpdateFromSandbox);
  2593. },
  2594. unbindEvents: function unbindEvents() {
  2595. var eventBus = this.eventBus,
  2596. _boundEvents = this._boundEvents;
  2597. eventBus._off("resize", webViewerResize);
  2598. eventBus._off("hashchange", webViewerHashchange);
  2599. eventBus._off("beforeprint", _boundEvents.beforePrint);
  2600. eventBus._off("afterprint", _boundEvents.afterPrint);
  2601. eventBus._off("pagerendered", webViewerPageRendered);
  2602. eventBus._off("updateviewarea", webViewerUpdateViewarea);
  2603. eventBus._off("pagechanging", webViewerPageChanging);
  2604. eventBus._off("scalechanging", webViewerScaleChanging);
  2605. eventBus._off("rotationchanging", webViewerRotationChanging);
  2606. eventBus._off("sidebarviewchanged", webViewerSidebarViewChanged);
  2607. eventBus._off("pagemode", webViewerPageMode);
  2608. eventBus._off("namedaction", webViewerNamedAction);
  2609. eventBus._off("presentationmodechanged", webViewerPresentationModeChanged);
  2610. eventBus._off("presentationmode", webViewerPresentationMode);
  2611. eventBus._off("print", webViewerPrint);
  2612. eventBus._off("download", webViewerDownload);
  2613. eventBus._off("save", webViewerSave);
  2614. eventBus._off("firstpage", webViewerFirstPage);
  2615. eventBus._off("lastpage", webViewerLastPage);
  2616. eventBus._off("nextpage", webViewerNextPage);
  2617. eventBus._off("previouspage", webViewerPreviousPage);
  2618. eventBus._off("zoomin", webViewerZoomIn);
  2619. eventBus._off("zoomout", webViewerZoomOut);
  2620. eventBus._off("zoomreset", webViewerZoomReset);
  2621. eventBus._off("pagenumberchanged", webViewerPageNumberChanged);
  2622. eventBus._off("scalechanged", webViewerScaleChanged);
  2623. eventBus._off("rotatecw", webViewerRotateCw);
  2624. eventBus._off("rotateccw", webViewerRotateCcw);
  2625. eventBus._off("optionalcontentconfig", webViewerOptionalContentConfig);
  2626. eventBus._off("switchscrollmode", webViewerSwitchScrollMode);
  2627. eventBus._off("scrollmodechanged", webViewerScrollModeChanged);
  2628. eventBus._off("switchspreadmode", webViewerSwitchSpreadMode);
  2629. eventBus._off("spreadmodechanged", webViewerSpreadModeChanged);
  2630. eventBus._off("documentproperties", webViewerDocumentProperties);
  2631. eventBus._off("find", webViewerFind);
  2632. eventBus._off("findfromurlhash", webViewerFindFromUrlHash);
  2633. eventBus._off("updatefindmatchescount", webViewerUpdateFindMatchesCount);
  2634. eventBus._off("updatefindcontrolstate", webViewerUpdateFindControlState);
  2635. if (_boundEvents.reportPageStatsPDFBug) {
  2636. eventBus._off("pagerendered", _boundEvents.reportPageStatsPDFBug);
  2637. eventBus._off("pagechanging", _boundEvents.reportPageStatsPDFBug);
  2638. _boundEvents.reportPageStatsPDFBug = null;
  2639. }
  2640. eventBus._off("fileinputchange", webViewerFileInputChange);
  2641. eventBus._off("openfile", webViewerOpenFile);
  2642. _boundEvents.beforePrint = null;
  2643. _boundEvents.afterPrint = null;
  2644. },
  2645. unbindWindowEvents: function unbindWindowEvents() {
  2646. var _boundEvents = this._boundEvents;
  2647. window.removeEventListener("visibilitychange", webViewerVisibilityChange);
  2648. window.removeEventListener("wheel", webViewerWheel, {
  2649. passive: false
  2650. });
  2651. window.removeEventListener("touchstart", webViewerTouchStart, {
  2652. passive: false
  2653. });
  2654. window.removeEventListener("click", webViewerClick);
  2655. window.removeEventListener("keydown", webViewerKeyDown);
  2656. window.removeEventListener("keyup", webViewerKeyUp);
  2657. window.removeEventListener("resize", _boundEvents.windowResize);
  2658. window.removeEventListener("hashchange", _boundEvents.windowHashChange);
  2659. window.removeEventListener("beforeprint", _boundEvents.windowBeforePrint);
  2660. window.removeEventListener("afterprint", _boundEvents.windowAfterPrint);
  2661. window.removeEventListener("updatefromsandbox", _boundEvents.windowUpdateFromSandbox);
  2662. _boundEvents.windowResize = null;
  2663. _boundEvents.windowHashChange = null;
  2664. _boundEvents.windowBeforePrint = null;
  2665. _boundEvents.windowAfterPrint = null;
  2666. _boundEvents.windowUpdateFromSandbox = null;
  2667. },
  2668. accumulateWheelTicks: function accumulateWheelTicks(ticks) {
  2669. if (this._wheelUnusedTicks > 0 && ticks < 0 || this._wheelUnusedTicks < 0 && ticks > 0) {
  2670. this._wheelUnusedTicks = 0;
  2671. }
  2672. this._wheelUnusedTicks += ticks;
  2673. var wholeTicks = Math.sign(this._wheelUnusedTicks) * Math.floor(Math.abs(this._wheelUnusedTicks));
  2674. this._wheelUnusedTicks -= wholeTicks;
  2675. return wholeTicks;
  2676. },
  2677. get scriptingReady() {
  2678. var _this$_scriptingInsta3;
  2679. return ((_this$_scriptingInsta3 = this._scriptingInstance) === null || _this$_scriptingInsta3 === void 0 ? void 0 : _this$_scriptingInsta3.ready) || false;
  2680. }
  2681. };
  2682. exports.PDFViewerApplication = PDFViewerApplication;
  2683. var validateFileURL;
  2684. {
  2685. var HOSTED_VIEWER_ORIGINS = ["null", "http://mozilla.github.io", "https://mozilla.github.io"];
  2686. validateFileURL = function validateFileURL(file) {
  2687. if (file === undefined) {
  2688. return;
  2689. }
  2690. try {
  2691. var viewerOrigin = new URL(window.location.href).origin || "null";
  2692. if (HOSTED_VIEWER_ORIGINS.includes(viewerOrigin)) {
  2693. return;
  2694. }
  2695. var _URL = new URL(file, window.location.href),
  2696. origin = _URL.origin,
  2697. protocol = _URL.protocol;
  2698. // if (origin !== viewerOrigin && protocol !== "blob:") {
  2699. // throw new Error("file origin does not match viewer's");
  2700. // }
  2701. } catch (ex) {
  2702. var message = ex && ex.message;
  2703. PDFViewerApplication.l10n.get("loading_error", null, "An error occurred while loading the PDF.").then(function (loadingErrorMessage) {
  2704. PDFViewerApplication.error(loadingErrorMessage, {
  2705. message: message
  2706. });
  2707. });
  2708. throw ex;
  2709. }
  2710. };
  2711. }
  2712. function loadFakeWorker() {
  2713. return _loadFakeWorker.apply(this, arguments);
  2714. }
  2715. function _loadFakeWorker() {
  2716. _loadFakeWorker = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee21() {
  2717. return _regenerator["default"].wrap(function _callee21$(_context21) {
  2718. while (1) {
  2719. switch (_context21.prev = _context21.next) {
  2720. case 0:
  2721. if (!_pdfjsLib.GlobalWorkerOptions.workerSrc) {
  2722. _pdfjsLib.GlobalWorkerOptions.workerSrc = _app_options.AppOptions.get("workerSrc");
  2723. }
  2724. return _context21.abrupt("return", (0, _pdfjsLib.loadScript)(_pdfjsLib.PDFWorker.getWorkerSrc()));
  2725. case 2:
  2726. case "end":
  2727. return _context21.stop();
  2728. }
  2729. }
  2730. }, _callee21);
  2731. }));
  2732. return _loadFakeWorker.apply(this, arguments);
  2733. }
  2734. function loadAndEnablePDFBug(enabledTabs) {
  2735. var appConfig = PDFViewerApplication.appConfig;
  2736. return (0, _pdfjsLib.loadScript)(appConfig.debuggerScriptPath).then(function () {
  2737. PDFBug.enable(enabledTabs);
  2738. PDFBug.init({
  2739. OPS: _pdfjsLib.OPS
  2740. }, appConfig.mainContainer);
  2741. });
  2742. }
  2743. function reportPageStatsPDFBug(_ref17) {
  2744. var pageNumber = _ref17.pageNumber;
  2745. if (typeof Stats === "undefined" || !Stats.enabled) {
  2746. return;
  2747. }
  2748. var pageView = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
  2749. var pageStats = pageView && pageView.pdfPage && pageView.pdfPage.stats;
  2750. if (!pageStats) {
  2751. return;
  2752. }
  2753. Stats.add(pageNumber, pageStats);
  2754. }
  2755. function webViewerInitialized() {
  2756. var appConfig = PDFViewerApplication.appConfig;
  2757. var file;
  2758. var queryString = document.location.search.substring(1);
  2759. var params = (0, _ui_utils.parseQueryString)(queryString);
  2760. file = "file" in params ? params.file : _app_options.AppOptions.get("defaultUrl");
  2761. validateFileURL(file);
  2762. var fileInput = document.createElement("input");
  2763. fileInput.id = appConfig.openFileInputName;
  2764. fileInput.className = "fileInput";
  2765. fileInput.setAttribute("type", "file");
  2766. fileInput.oncontextmenu = _ui_utils.noContextMenuHandler;
  2767. document.body.appendChild(fileInput);
  2768. if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
  2769. appConfig.toolbar.openFile.setAttribute("hidden", "true");
  2770. appConfig.secondaryToolbar.openFileButton.setAttribute("hidden", "true");
  2771. } else {
  2772. fileInput.value = null;
  2773. }
  2774. fileInput.addEventListener("change", function (evt) {
  2775. var files = evt.target.files;
  2776. if (!files || files.length === 0) {
  2777. return;
  2778. }
  2779. PDFViewerApplication.eventBus.dispatch("fileinputchange", {
  2780. source: this,
  2781. fileInput: evt.target
  2782. });
  2783. });
  2784. appConfig.mainContainer.addEventListener("dragover", function (evt) {
  2785. evt.preventDefault();
  2786. evt.dataTransfer.dropEffect = "move";
  2787. });
  2788. appConfig.mainContainer.addEventListener("drop", function (evt) {
  2789. evt.preventDefault();
  2790. var files = evt.dataTransfer.files;
  2791. if (!files || files.length === 0) {
  2792. return;
  2793. }
  2794. PDFViewerApplication.eventBus.dispatch("fileinputchange", {
  2795. source: this,
  2796. fileInput: evt.dataTransfer
  2797. });
  2798. });
  2799. if (!PDFViewerApplication.supportsDocumentFonts) {
  2800. _app_options.AppOptions.set("disableFontFace", true);
  2801. PDFViewerApplication.l10n.get("web_fonts_disabled", null, "Web fonts are disabled: unable to use embedded PDF fonts.").then(function (msg) {
  2802. console.warn(msg);
  2803. });
  2804. }
  2805. if (!PDFViewerApplication.supportsPrinting) {
  2806. appConfig.toolbar.print.classList.add("hidden");
  2807. appConfig.secondaryToolbar.printButton.classList.add("hidden");
  2808. }
  2809. if (!PDFViewerApplication.supportsFullscreen) {
  2810. appConfig.toolbar.presentationModeButton.classList.add("hidden");
  2811. appConfig.secondaryToolbar.presentationModeButton.classList.add("hidden");
  2812. }
  2813. if (PDFViewerApplication.supportsIntegratedFind) {
  2814. appConfig.toolbar.viewFind.classList.add("hidden");
  2815. }
  2816. appConfig.mainContainer.addEventListener("transitionend", function (evt) {
  2817. if (evt.target === this) {
  2818. PDFViewerApplication.eventBus.dispatch("resize", {
  2819. source: this
  2820. });
  2821. }
  2822. }, true);
  2823. try {
  2824. webViewerOpenFileViaURL(file);
  2825. } catch (reason) {
  2826. PDFViewerApplication.l10n.get("loading_error", null, "An error occurred while loading the PDF.").then(function (msg) {
  2827. PDFViewerApplication.error(msg, reason);
  2828. });
  2829. }
  2830. }
  2831. var webViewerOpenFileViaURL;
  2832. {
  2833. webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) {
  2834. if (file && file.lastIndexOf("file:", 0) === 0) {
  2835. PDFViewerApplication.setTitleUsingUrl(file);
  2836. var xhr = new XMLHttpRequest();
  2837. xhr.onload = function () {
  2838. PDFViewerApplication.open(new Uint8Array(xhr.response));
  2839. };
  2840. xhr.open("GET", file);
  2841. xhr.responseType = "arraybuffer";
  2842. xhr.send();
  2843. return;
  2844. }
  2845. if (file) {
  2846. PDFViewerApplication.open(file);
  2847. }
  2848. };
  2849. }
  2850. function webViewerResetPermissions() {
  2851. var appConfig = PDFViewerApplication.appConfig;
  2852. if (!appConfig) {
  2853. return;
  2854. }
  2855. appConfig.viewerContainer.classList.remove(ENABLE_PERMISSIONS_CLASS);
  2856. }
  2857. function webViewerPageRendered(_ref18) {
  2858. var pageNumber = _ref18.pageNumber,
  2859. timestamp = _ref18.timestamp,
  2860. error = _ref18.error;
  2861. if (pageNumber === PDFViewerApplication.page) {
  2862. PDFViewerApplication.toolbar.updateLoadingIndicatorState(false);
  2863. }
  2864. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  2865. var pageView = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
  2866. var thumbnailView = PDFViewerApplication.pdfThumbnailViewer.getThumbnail(pageNumber - 1);
  2867. if (pageView && thumbnailView) {
  2868. thumbnailView.setImage(pageView);
  2869. }
  2870. }
  2871. if (error) {
  2872. PDFViewerApplication.l10n.get("rendering_error", null, "An error occurred while rendering the page.").then(function (msg) {
  2873. PDFViewerApplication.error(msg, error);
  2874. });
  2875. }
  2876. PDFViewerApplication.externalServices.reportTelemetry({
  2877. type: "pageInfo",
  2878. timestamp: timestamp
  2879. });
  2880. PDFViewerApplication.pdfDocument.getStats().then(function (stats) {
  2881. PDFViewerApplication.externalServices.reportTelemetry({
  2882. type: "documentStats",
  2883. stats: stats
  2884. });
  2885. });
  2886. }
  2887. function webViewerPageMode(_ref19) {
  2888. var mode = _ref19.mode;
  2889. var view;
  2890. switch (mode) {
  2891. case "thumbs":
  2892. view = _ui_utils.SidebarView.THUMBS;
  2893. break;
  2894. case "bookmarks":
  2895. case "outline":
  2896. view = _ui_utils.SidebarView.OUTLINE;
  2897. break;
  2898. case "attachments":
  2899. view = _ui_utils.SidebarView.ATTACHMENTS;
  2900. break;
  2901. case "layers":
  2902. view = _ui_utils.SidebarView.LAYERS;
  2903. break;
  2904. case "none":
  2905. view = _ui_utils.SidebarView.NONE;
  2906. break;
  2907. default:
  2908. console.error('Invalid "pagemode" hash parameter: ' + mode);
  2909. return;
  2910. }
  2911. PDFViewerApplication.pdfSidebar.switchView(view, true);
  2912. }
  2913. function webViewerNamedAction(evt) {
  2914. switch (evt.action) {
  2915. case "GoToPage":
  2916. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  2917. break;
  2918. case "Find":
  2919. if (!PDFViewerApplication.supportsIntegratedFind) {
  2920. PDFViewerApplication.findBar.toggle();
  2921. }
  2922. break;
  2923. case "Print":
  2924. PDFViewerApplication.triggerPrinting();
  2925. break;
  2926. case "SaveAs":
  2927. webViewerSave();
  2928. break;
  2929. }
  2930. }
  2931. function webViewerPresentationModeChanged(evt) {
  2932. PDFViewerApplication.pdfViewer.presentationModeState = evt.state;
  2933. }
  2934. function webViewerSidebarViewChanged(evt) {
  2935. PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = PDFViewerApplication.pdfSidebar.isThumbnailViewVisible;
  2936. var store = PDFViewerApplication.store;
  2937. if (store && PDFViewerApplication.isInitialViewSet) {
  2938. store.set("sidebarView", evt.view)["catch"](function () {});
  2939. }
  2940. }
  2941. function webViewerUpdateViewarea(evt) {
  2942. var location = evt.location,
  2943. store = PDFViewerApplication.store;
  2944. if (store && PDFViewerApplication.isInitialViewSet) {
  2945. store.setMultiple({
  2946. page: location.pageNumber,
  2947. zoom: location.scale,
  2948. scrollLeft: location.left,
  2949. scrollTop: location.top,
  2950. rotation: location.rotation
  2951. })["catch"](function () {});
  2952. }
  2953. var href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
  2954. PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href;
  2955. PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
  2956. var currentPage = PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page - 1);
  2957. var loading = (currentPage && currentPage.renderingState) !== _pdf_rendering_queue.RenderingStates.FINISHED;
  2958. PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading);
  2959. }
  2960. function webViewerScrollModeChanged(evt) {
  2961. var store = PDFViewerApplication.store;
  2962. if (store && PDFViewerApplication.isInitialViewSet) {
  2963. store.set("scrollMode", evt.mode)["catch"](function () {});
  2964. }
  2965. }
  2966. function webViewerSpreadModeChanged(evt) {
  2967. var store = PDFViewerApplication.store;
  2968. if (store && PDFViewerApplication.isInitialViewSet) {
  2969. store.set("spreadMode", evt.mode)["catch"](function () {});
  2970. }
  2971. }
  2972. function webViewerResize() {
  2973. var pdfDocument = PDFViewerApplication.pdfDocument,
  2974. pdfViewer = PDFViewerApplication.pdfViewer;
  2975. if (!pdfDocument) {
  2976. return;
  2977. }
  2978. var currentScaleValue = pdfViewer.currentScaleValue;
  2979. if (currentScaleValue === "auto" || currentScaleValue === "page-fit" || currentScaleValue === "page-width") {
  2980. pdfViewer.currentScaleValue = currentScaleValue;
  2981. }
  2982. pdfViewer.update();
  2983. }
  2984. function webViewerHashchange(evt) {
  2985. var hash = evt.hash;
  2986. if (!hash) {
  2987. return;
  2988. }
  2989. if (!PDFViewerApplication.isInitialViewSet) {
  2990. PDFViewerApplication.initialBookmark = hash;
  2991. } else if (!PDFViewerApplication.pdfHistory.popStateInProgress) {
  2992. PDFViewerApplication.pdfLinkService.setHash(hash);
  2993. }
  2994. }
  2995. var webViewerFileInputChange, webViewerOpenFile;
  2996. {
  2997. webViewerFileInputChange = function webViewerFileInputChange(evt) {
  2998. if (PDFViewerApplication.pdfViewer && PDFViewerApplication.pdfViewer.isInPresentationMode) {
  2999. return;
  3000. }
  3001. var file = evt.fileInput.files[0];
  3002. if (!_viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL) {
  3003. var url = URL.createObjectURL(file);
  3004. if (file.name) {
  3005. url = {
  3006. url: url,
  3007. originalUrl: file.name
  3008. };
  3009. }
  3010. PDFViewerApplication.open(url);
  3011. } else {
  3012. PDFViewerApplication.setTitleUsingUrl(file.name);
  3013. var fileReader = new FileReader();
  3014. fileReader.onload = function webViewerChangeFileReaderOnload(event) {
  3015. var buffer = event.target.result;
  3016. PDFViewerApplication.open(new Uint8Array(buffer));
  3017. };
  3018. fileReader.readAsArrayBuffer(file);
  3019. }
  3020. var appConfig = PDFViewerApplication.appConfig;
  3021. appConfig.toolbar.viewBookmark.setAttribute("hidden", "true");
  3022. appConfig.secondaryToolbar.viewBookmarkButton.setAttribute("hidden", "true");
  3023. appConfig.toolbar.download.setAttribute("hidden", "true");
  3024. appConfig.secondaryToolbar.downloadButton.setAttribute("hidden", "true");
  3025. };
  3026. webViewerOpenFile = function webViewerOpenFile(evt) {
  3027. var openFileInputName = PDFViewerApplication.appConfig.openFileInputName;
  3028. document.getElementById(openFileInputName).click();
  3029. };
  3030. }
  3031. function webViewerPresentationMode() {
  3032. PDFViewerApplication.requestPresentationMode();
  3033. }
  3034. function webViewerPrint() {
  3035. PDFViewerApplication.triggerPrinting();
  3036. }
  3037. function webViewerDownload() {
  3038. PDFViewerApplication.downloadOrSave({
  3039. sourceEventType: "download"
  3040. });
  3041. }
  3042. function webViewerSave() {
  3043. PDFViewerApplication.downloadOrSave({
  3044. sourceEventType: "save"
  3045. });
  3046. }
  3047. function webViewerFirstPage() {
  3048. if (PDFViewerApplication.pdfDocument) {
  3049. PDFViewerApplication.page = 1;
  3050. }
  3051. }
  3052. function webViewerLastPage() {
  3053. if (PDFViewerApplication.pdfDocument) {
  3054. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  3055. }
  3056. }
  3057. function webViewerNextPage() {
  3058. PDFViewerApplication.pdfViewer.nextPage();
  3059. }
  3060. function webViewerPreviousPage() {
  3061. PDFViewerApplication.pdfViewer.previousPage();
  3062. }
  3063. function webViewerZoomIn() {
  3064. PDFViewerApplication.zoomIn();
  3065. }
  3066. function webViewerZoomOut() {
  3067. PDFViewerApplication.zoomOut();
  3068. }
  3069. function webViewerZoomReset() {
  3070. PDFViewerApplication.zoomReset();
  3071. }
  3072. function webViewerPageNumberChanged(evt) {
  3073. var pdfViewer = PDFViewerApplication.pdfViewer;
  3074. if (evt.value !== "") {
  3075. PDFViewerApplication.pdfLinkService.goToPage(evt.value);
  3076. }
  3077. if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) {
  3078. PDFViewerApplication.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  3079. }
  3080. }
  3081. function webViewerScaleChanged(evt) {
  3082. PDFViewerApplication.pdfViewer.currentScaleValue = evt.value;
  3083. }
  3084. function webViewerRotateCw() {
  3085. PDFViewerApplication.rotatePages(90);
  3086. }
  3087. function webViewerRotateCcw() {
  3088. PDFViewerApplication.rotatePages(-90);
  3089. }
  3090. function webViewerOptionalContentConfig(evt) {
  3091. PDFViewerApplication.pdfViewer.optionalContentConfigPromise = evt.promise;
  3092. }
  3093. function webViewerSwitchScrollMode(evt) {
  3094. PDFViewerApplication.pdfViewer.scrollMode = evt.mode;
  3095. }
  3096. function webViewerSwitchSpreadMode(evt) {
  3097. PDFViewerApplication.pdfViewer.spreadMode = evt.mode;
  3098. }
  3099. function webViewerDocumentProperties() {
  3100. PDFViewerApplication.pdfDocumentProperties.open();
  3101. }
  3102. function webViewerFind(evt) {
  3103. PDFViewerApplication.findController.executeCommand("find" + evt.type, {
  3104. query: evt.query,
  3105. phraseSearch: evt.phraseSearch,
  3106. caseSensitive: evt.caseSensitive,
  3107. entireWord: evt.entireWord,
  3108. highlightAll: evt.highlightAll,
  3109. findPrevious: evt.findPrevious
  3110. });
  3111. }
  3112. function webViewerFindFromUrlHash(evt) {
  3113. PDFViewerApplication.findController.executeCommand("find", {
  3114. query: evt.query,
  3115. phraseSearch: evt.phraseSearch,
  3116. caseSensitive: false,
  3117. entireWord: false,
  3118. highlightAll: true,
  3119. findPrevious: false
  3120. });
  3121. }
  3122. function webViewerUpdateFindMatchesCount(_ref20) {
  3123. var matchesCount = _ref20.matchesCount;
  3124. if (PDFViewerApplication.supportsIntegratedFind) {
  3125. PDFViewerApplication.externalServices.updateFindMatchesCount(matchesCount);
  3126. } else {
  3127. PDFViewerApplication.findBar.updateResultsCount(matchesCount);
  3128. }
  3129. }
  3130. function webViewerUpdateFindControlState(_ref21) {
  3131. var state = _ref21.state,
  3132. previous = _ref21.previous,
  3133. matchesCount = _ref21.matchesCount,
  3134. rawQuery = _ref21.rawQuery;
  3135. if (PDFViewerApplication.supportsIntegratedFind) {
  3136. PDFViewerApplication.externalServices.updateFindControlState({
  3137. result: state,
  3138. findPrevious: previous,
  3139. matchesCount: matchesCount,
  3140. rawQuery: rawQuery
  3141. });
  3142. } else {
  3143. PDFViewerApplication.findBar.updateUIState(state, previous, matchesCount);
  3144. }
  3145. }
  3146. function webViewerScaleChanging(evt) {
  3147. PDFViewerApplication.toolbar.setPageScale(evt.presetValue, evt.scale);
  3148. PDFViewerApplication.pdfViewer.update();
  3149. }
  3150. function webViewerRotationChanging(evt) {
  3151. PDFViewerApplication.pdfThumbnailViewer.pagesRotation = evt.pagesRotation;
  3152. PDFViewerApplication.forceRendering();
  3153. PDFViewerApplication.pdfViewer.currentPageNumber = evt.pageNumber;
  3154. }
  3155. function webViewerPageChanging(_ref22) {
  3156. var pageNumber = _ref22.pageNumber,
  3157. pageLabel = _ref22.pageLabel;
  3158. PDFViewerApplication.toolbar.setPageNumber(pageNumber, pageLabel);
  3159. PDFViewerApplication.secondaryToolbar.setPageNumber(pageNumber);
  3160. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  3161. PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(pageNumber);
  3162. }
  3163. }
  3164. function webViewerVisibilityChange(evt) {
  3165. if (document.visibilityState === "visible") {
  3166. setZoomDisabledTimeout();
  3167. }
  3168. }
  3169. var zoomDisabledTimeout = null;
  3170. function setZoomDisabledTimeout() {
  3171. if (zoomDisabledTimeout) {
  3172. clearTimeout(zoomDisabledTimeout);
  3173. }
  3174. zoomDisabledTimeout = setTimeout(function () {
  3175. zoomDisabledTimeout = null;
  3176. }, WHEEL_ZOOM_DISABLED_TIMEOUT);
  3177. }
  3178. function webViewerWheel(evt) {
  3179. var pdfViewer = PDFViewerApplication.pdfViewer,
  3180. supportedMouseWheelZoomModifierKeys = PDFViewerApplication.supportedMouseWheelZoomModifierKeys;
  3181. if (pdfViewer.isInPresentationMode) {
  3182. return;
  3183. }
  3184. if (evt.ctrlKey && supportedMouseWheelZoomModifierKeys.ctrlKey || evt.metaKey && supportedMouseWheelZoomModifierKeys.metaKey) {
  3185. evt.preventDefault();
  3186. if (zoomDisabledTimeout || document.visibilityState === "hidden") {
  3187. return;
  3188. }
  3189. var previousScale = pdfViewer.currentScale;
  3190. var delta = (0, _ui_utils.normalizeWheelEventDirection)(evt);
  3191. var ticks = 0;
  3192. if (evt.deltaMode === WheelEvent.DOM_DELTA_LINE || evt.deltaMode === WheelEvent.DOM_DELTA_PAGE) {
  3193. if (Math.abs(delta) >= 1) {
  3194. ticks = Math.sign(delta);
  3195. } else {
  3196. ticks = PDFViewerApplication.accumulateWheelTicks(delta);
  3197. }
  3198. } else {
  3199. var PIXELS_PER_LINE_SCALE = 30;
  3200. ticks = PDFViewerApplication.accumulateWheelTicks(delta / PIXELS_PER_LINE_SCALE);
  3201. }
  3202. if (ticks < 0) {
  3203. PDFViewerApplication.zoomOut(-ticks);
  3204. } else if (ticks > 0) {
  3205. PDFViewerApplication.zoomIn(ticks);
  3206. }
  3207. var currentScale = pdfViewer.currentScale;
  3208. if (previousScale !== currentScale) {
  3209. var scaleCorrectionFactor = currentScale / previousScale - 1;
  3210. var rect = pdfViewer.container.getBoundingClientRect();
  3211. var dx = evt.clientX - rect.left;
  3212. var dy = evt.clientY - rect.top;
  3213. pdfViewer.container.scrollLeft += dx * scaleCorrectionFactor;
  3214. pdfViewer.container.scrollTop += dy * scaleCorrectionFactor;
  3215. }
  3216. } else {
  3217. setZoomDisabledTimeout();
  3218. }
  3219. }
  3220. function webViewerTouchStart(evt) {
  3221. if (evt.touches.length > 1) {
  3222. evt.preventDefault();
  3223. }
  3224. }
  3225. function webViewerClick(evt) {
  3226. if (PDFViewerApplication.triggerDelayedFallback && PDFViewerApplication.pdfViewer.containsElement(evt.target)) {
  3227. PDFViewerApplication.triggerDelayedFallback();
  3228. }
  3229. if (!PDFViewerApplication.secondaryToolbar.isOpen) {
  3230. return;
  3231. }
  3232. var appConfig = PDFViewerApplication.appConfig;
  3233. if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar.container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar.toggleButton) {
  3234. PDFViewerApplication.secondaryToolbar.close();
  3235. }
  3236. }
  3237. function webViewerKeyUp(evt) {
  3238. if (evt.keyCode === 9) {
  3239. if (PDFViewerApplication.triggerDelayedFallback) {
  3240. PDFViewerApplication.triggerDelayedFallback();
  3241. }
  3242. }
  3243. }
  3244. function webViewerKeyDown(evt) {
  3245. if (PDFViewerApplication.overlayManager.active) {
  3246. return;
  3247. }
  3248. var handled = false,
  3249. ensureViewerFocused = false;
  3250. var cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0);
  3251. var pdfViewer = PDFViewerApplication.pdfViewer;
  3252. var isViewerInPresentationMode = pdfViewer && pdfViewer.isInPresentationMode;
  3253. if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
  3254. switch (evt.keyCode) {
  3255. case 70:
  3256. if (!PDFViewerApplication.supportsIntegratedFind && !evt.shiftKey) {
  3257. PDFViewerApplication.findBar.open();
  3258. handled = true;
  3259. }
  3260. break;
  3261. case 71:
  3262. if (!PDFViewerApplication.supportsIntegratedFind) {
  3263. var findState = PDFViewerApplication.findController.state;
  3264. if (findState) {
  3265. PDFViewerApplication.findController.executeCommand("findagain", {
  3266. query: findState.query,
  3267. phraseSearch: findState.phraseSearch,
  3268. caseSensitive: findState.caseSensitive,
  3269. entireWord: findState.entireWord,
  3270. highlightAll: findState.highlightAll,
  3271. findPrevious: cmd === 5 || cmd === 12
  3272. });
  3273. }
  3274. handled = true;
  3275. }
  3276. break;
  3277. case 61:
  3278. case 107:
  3279. case 187:
  3280. case 171:
  3281. if (!isViewerInPresentationMode) {
  3282. PDFViewerApplication.zoomIn();
  3283. }
  3284. handled = true;
  3285. break;
  3286. case 173:
  3287. case 109:
  3288. case 189:
  3289. if (!isViewerInPresentationMode) {
  3290. PDFViewerApplication.zoomOut();
  3291. }
  3292. handled = true;
  3293. break;
  3294. case 48:
  3295. case 96:
  3296. if (!isViewerInPresentationMode) {
  3297. setTimeout(function () {
  3298. PDFViewerApplication.zoomReset();
  3299. });
  3300. handled = false;
  3301. }
  3302. break;
  3303. case 38:
  3304. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  3305. PDFViewerApplication.page = 1;
  3306. handled = true;
  3307. ensureViewerFocused = true;
  3308. }
  3309. break;
  3310. case 40:
  3311. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  3312. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  3313. handled = true;
  3314. ensureViewerFocused = true;
  3315. }
  3316. break;
  3317. }
  3318. }
  3319. var eventBus = PDFViewerApplication.eventBus;
  3320. if (cmd === 1 || cmd === 8) {
  3321. switch (evt.keyCode) {
  3322. case 83:
  3323. eventBus.dispatch("download", {
  3324. source: window
  3325. });
  3326. handled = true;
  3327. break;
  3328. case 79:
  3329. {
  3330. eventBus.dispatch("openfile", {
  3331. source: window
  3332. });
  3333. handled = true;
  3334. }
  3335. break;
  3336. }
  3337. }
  3338. if (cmd === 3 || cmd === 10) {
  3339. switch (evt.keyCode) {
  3340. case 80:
  3341. PDFViewerApplication.requestPresentationMode();
  3342. handled = true;
  3343. break;
  3344. case 71:
  3345. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  3346. handled = true;
  3347. break;
  3348. }
  3349. }
  3350. if (handled) {
  3351. if (ensureViewerFocused && !isViewerInPresentationMode) {
  3352. pdfViewer.focus();
  3353. }
  3354. evt.preventDefault();
  3355. return;
  3356. }
  3357. var curElement = (0, _ui_utils.getActiveOrFocusedElement)();
  3358. var curElementTagName = curElement && curElement.tagName.toUpperCase();
  3359. if (curElementTagName === "INPUT" || curElementTagName === "TEXTAREA" || curElementTagName === "SELECT" || curElement && curElement.isContentEditable) {
  3360. if (evt.keyCode !== 27) {
  3361. return;
  3362. }
  3363. }
  3364. if (cmd === 0) {
  3365. var turnPage = 0,
  3366. turnOnlyIfPageFit = false;
  3367. switch (evt.keyCode) {
  3368. case 38:
  3369. case 33:
  3370. if (pdfViewer.isVerticalScrollbarEnabled) {
  3371. turnOnlyIfPageFit = true;
  3372. }
  3373. turnPage = -1;
  3374. break;
  3375. case 8:
  3376. if (!isViewerInPresentationMode) {
  3377. turnOnlyIfPageFit = true;
  3378. }
  3379. turnPage = -1;
  3380. break;
  3381. case 37:
  3382. if (pdfViewer.isHorizontalScrollbarEnabled) {
  3383. turnOnlyIfPageFit = true;
  3384. }
  3385. case 75:
  3386. case 80:
  3387. turnPage = -1;
  3388. break;
  3389. case 27:
  3390. if (PDFViewerApplication.secondaryToolbar.isOpen) {
  3391. PDFViewerApplication.secondaryToolbar.close();
  3392. handled = true;
  3393. }
  3394. if (!PDFViewerApplication.supportsIntegratedFind && PDFViewerApplication.findBar.opened) {
  3395. PDFViewerApplication.findBar.close();
  3396. handled = true;
  3397. }
  3398. break;
  3399. case 40:
  3400. case 34:
  3401. if (pdfViewer.isVerticalScrollbarEnabled) {
  3402. turnOnlyIfPageFit = true;
  3403. }
  3404. turnPage = 1;
  3405. break;
  3406. case 13:
  3407. case 32:
  3408. if (!isViewerInPresentationMode) {
  3409. turnOnlyIfPageFit = true;
  3410. }
  3411. turnPage = 1;
  3412. break;
  3413. case 39:
  3414. if (pdfViewer.isHorizontalScrollbarEnabled) {
  3415. turnOnlyIfPageFit = true;
  3416. }
  3417. case 74:
  3418. case 78:
  3419. turnPage = 1;
  3420. break;
  3421. case 36:
  3422. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  3423. PDFViewerApplication.page = 1;
  3424. handled = true;
  3425. ensureViewerFocused = true;
  3426. }
  3427. break;
  3428. case 35:
  3429. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  3430. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  3431. handled = true;
  3432. ensureViewerFocused = true;
  3433. }
  3434. break;
  3435. case 83:
  3436. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.SELECT);
  3437. break;
  3438. case 72:
  3439. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.HAND);
  3440. break;
  3441. case 82:
  3442. PDFViewerApplication.rotatePages(90);
  3443. break;
  3444. case 115:
  3445. PDFViewerApplication.pdfSidebar.toggle();
  3446. break;
  3447. }
  3448. if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === "page-fit")) {
  3449. if (turnPage > 0) {
  3450. pdfViewer.nextPage();
  3451. } else {
  3452. pdfViewer.previousPage();
  3453. }
  3454. handled = true;
  3455. }
  3456. }
  3457. if (cmd === 4) {
  3458. switch (evt.keyCode) {
  3459. case 13:
  3460. case 32:
  3461. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== "page-fit") {
  3462. break;
  3463. }
  3464. if (PDFViewerApplication.page > 1) {
  3465. PDFViewerApplication.page--;
  3466. }
  3467. handled = true;
  3468. break;
  3469. case 82:
  3470. PDFViewerApplication.rotatePages(-90);
  3471. break;
  3472. }
  3473. }
  3474. if (!handled && !isViewerInPresentationMode) {
  3475. if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !== "BUTTON") {
  3476. ensureViewerFocused = true;
  3477. }
  3478. }
  3479. if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
  3480. pdfViewer.focus();
  3481. }
  3482. if (handled) {
  3483. evt.preventDefault();
  3484. }
  3485. }
  3486. function beforeUnload(evt) {
  3487. evt.preventDefault();
  3488. evt.returnValue = "";
  3489. return false;
  3490. }
  3491. function apiPageLayoutToSpreadMode(layout) {
  3492. switch (layout) {
  3493. case "SinglePage":
  3494. case "OneColumn":
  3495. return _ui_utils.SpreadMode.NONE;
  3496. case "TwoColumnLeft":
  3497. case "TwoPageLeft":
  3498. return _ui_utils.SpreadMode.ODD;
  3499. case "TwoColumnRight":
  3500. case "TwoPageRight":
  3501. return _ui_utils.SpreadMode.EVEN;
  3502. }
  3503. return _ui_utils.SpreadMode.NONE;
  3504. }
  3505. function apiPageModeToSidebarView(mode) {
  3506. switch (mode) {
  3507. case "UseNone":
  3508. return _ui_utils.SidebarView.NONE;
  3509. case "UseThumbs":
  3510. return _ui_utils.SidebarView.THUMBS;
  3511. case "UseOutlines":
  3512. return _ui_utils.SidebarView.OUTLINE;
  3513. case "UseAttachments":
  3514. return _ui_utils.SidebarView.ATTACHMENTS;
  3515. case "UseOC":
  3516. return _ui_utils.SidebarView.LAYERS;
  3517. }
  3518. return _ui_utils.SidebarView.NONE;
  3519. }
  3520. var PDFPrintServiceFactory = {
  3521. instance: {
  3522. supportsPrinting: false,
  3523. createPrintService: function createPrintService() {
  3524. throw new Error("Not implemented: createPrintService");
  3525. }
  3526. }
  3527. };
  3528. exports.PDFPrintServiceFactory = PDFPrintServiceFactory;
  3529. /***/ }),
  3530. /* 4 */
  3531. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3532. module.exports = __webpack_require__(5);
  3533. /***/ }),
  3534. /* 5 */
  3535. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  3536. /* module decorator */ module = __webpack_require__.nmd(module);
  3537. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  3538. var runtime = function (exports) {
  3539. "use strict";
  3540. var Op = Object.prototype;
  3541. var hasOwn = Op.hasOwnProperty;
  3542. var undefined;
  3543. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  3544. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  3545. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  3546. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  3547. function define(obj, key, value) {
  3548. Object.defineProperty(obj, key, {
  3549. value: value,
  3550. enumerable: true,
  3551. configurable: true,
  3552. writable: true
  3553. });
  3554. return obj[key];
  3555. }
  3556. try {
  3557. define({}, "");
  3558. } catch (err) {
  3559. define = function define(obj, key, value) {
  3560. return obj[key] = value;
  3561. };
  3562. }
  3563. function wrap(innerFn, outerFn, self, tryLocsList) {
  3564. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  3565. var generator = Object.create(protoGenerator.prototype);
  3566. var context = new Context(tryLocsList || []);
  3567. generator._invoke = makeInvokeMethod(innerFn, self, context);
  3568. return generator;
  3569. }
  3570. exports.wrap = wrap;
  3571. function tryCatch(fn, obj, arg) {
  3572. try {
  3573. return {
  3574. type: "normal",
  3575. arg: fn.call(obj, arg)
  3576. };
  3577. } catch (err) {
  3578. return {
  3579. type: "throw",
  3580. arg: err
  3581. };
  3582. }
  3583. }
  3584. var GenStateSuspendedStart = "suspendedStart";
  3585. var GenStateSuspendedYield = "suspendedYield";
  3586. var GenStateExecuting = "executing";
  3587. var GenStateCompleted = "completed";
  3588. var ContinueSentinel = {};
  3589. function Generator() {}
  3590. function GeneratorFunction() {}
  3591. function GeneratorFunctionPrototype() {}
  3592. var IteratorPrototype = {};
  3593. IteratorPrototype[iteratorSymbol] = function () {
  3594. return this;
  3595. };
  3596. var getProto = Object.getPrototypeOf;
  3597. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  3598. if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  3599. IteratorPrototype = NativeIteratorPrototype;
  3600. }
  3601. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
  3602. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  3603. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  3604. GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
  3605. function defineIteratorMethods(prototype) {
  3606. ["next", "throw", "return"].forEach(function (method) {
  3607. define(prototype, method, function (arg) {
  3608. return this._invoke(method, arg);
  3609. });
  3610. });
  3611. }
  3612. exports.isGeneratorFunction = function (genFun) {
  3613. var ctor = typeof genFun === "function" && genFun.constructor;
  3614. return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
  3615. };
  3616. exports.mark = function (genFun) {
  3617. if (Object.setPrototypeOf) {
  3618. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  3619. } else {
  3620. genFun.__proto__ = GeneratorFunctionPrototype;
  3621. define(genFun, toStringTagSymbol, "GeneratorFunction");
  3622. }
  3623. genFun.prototype = Object.create(Gp);
  3624. return genFun;
  3625. };
  3626. exports.awrap = function (arg) {
  3627. return {
  3628. __await: arg
  3629. };
  3630. };
  3631. function AsyncIterator(generator, PromiseImpl) {
  3632. function invoke(method, arg, resolve, reject) {
  3633. var record = tryCatch(generator[method], generator, arg);
  3634. if (record.type === "throw") {
  3635. reject(record.arg);
  3636. } else {
  3637. var result = record.arg;
  3638. var value = result.value;
  3639. if (value && _typeof(value) === "object" && hasOwn.call(value, "__await")) {
  3640. return PromiseImpl.resolve(value.__await).then(function (value) {
  3641. invoke("next", value, resolve, reject);
  3642. }, function (err) {
  3643. invoke("throw", err, resolve, reject);
  3644. });
  3645. }
  3646. return PromiseImpl.resolve(value).then(function (unwrapped) {
  3647. result.value = unwrapped;
  3648. resolve(result);
  3649. }, function (error) {
  3650. return invoke("throw", error, resolve, reject);
  3651. });
  3652. }
  3653. }
  3654. var previousPromise;
  3655. function enqueue(method, arg) {
  3656. function callInvokeWithMethodAndArg() {
  3657. return new PromiseImpl(function (resolve, reject) {
  3658. invoke(method, arg, resolve, reject);
  3659. });
  3660. }
  3661. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  3662. }
  3663. this._invoke = enqueue;
  3664. }
  3665. defineIteratorMethods(AsyncIterator.prototype);
  3666. AsyncIterator.prototype[asyncIteratorSymbol] = function () {
  3667. return this;
  3668. };
  3669. exports.AsyncIterator = AsyncIterator;
  3670. exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  3671. if (PromiseImpl === void 0) PromiseImpl = Promise;
  3672. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  3673. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  3674. return result.done ? result.value : iter.next();
  3675. });
  3676. };
  3677. function makeInvokeMethod(innerFn, self, context) {
  3678. var state = GenStateSuspendedStart;
  3679. return function invoke(method, arg) {
  3680. if (state === GenStateExecuting) {
  3681. throw new Error("Generator is already running");
  3682. }
  3683. if (state === GenStateCompleted) {
  3684. if (method === "throw") {
  3685. throw arg;
  3686. }
  3687. return doneResult();
  3688. }
  3689. context.method = method;
  3690. context.arg = arg;
  3691. while (true) {
  3692. var delegate = context.delegate;
  3693. if (delegate) {
  3694. var delegateResult = maybeInvokeDelegate(delegate, context);
  3695. if (delegateResult) {
  3696. if (delegateResult === ContinueSentinel) continue;
  3697. return delegateResult;
  3698. }
  3699. }
  3700. if (context.method === "next") {
  3701. context.sent = context._sent = context.arg;
  3702. } else if (context.method === "throw") {
  3703. if (state === GenStateSuspendedStart) {
  3704. state = GenStateCompleted;
  3705. throw context.arg;
  3706. }
  3707. context.dispatchException(context.arg);
  3708. } else if (context.method === "return") {
  3709. context.abrupt("return", context.arg);
  3710. }
  3711. state = GenStateExecuting;
  3712. var record = tryCatch(innerFn, self, context);
  3713. if (record.type === "normal") {
  3714. state = context.done ? GenStateCompleted : GenStateSuspendedYield;
  3715. if (record.arg === ContinueSentinel) {
  3716. continue;
  3717. }
  3718. return {
  3719. value: record.arg,
  3720. done: context.done
  3721. };
  3722. } else if (record.type === "throw") {
  3723. state = GenStateCompleted;
  3724. context.method = "throw";
  3725. context.arg = record.arg;
  3726. }
  3727. }
  3728. };
  3729. }
  3730. function maybeInvokeDelegate(delegate, context) {
  3731. var method = delegate.iterator[context.method];
  3732. if (method === undefined) {
  3733. context.delegate = null;
  3734. if (context.method === "throw") {
  3735. if (delegate.iterator["return"]) {
  3736. context.method = "return";
  3737. context.arg = undefined;
  3738. maybeInvokeDelegate(delegate, context);
  3739. if (context.method === "throw") {
  3740. return ContinueSentinel;
  3741. }
  3742. }
  3743. context.method = "throw";
  3744. context.arg = new TypeError("The iterator does not provide a 'throw' method");
  3745. }
  3746. return ContinueSentinel;
  3747. }
  3748. var record = tryCatch(method, delegate.iterator, context.arg);
  3749. if (record.type === "throw") {
  3750. context.method = "throw";
  3751. context.arg = record.arg;
  3752. context.delegate = null;
  3753. return ContinueSentinel;
  3754. }
  3755. var info = record.arg;
  3756. if (!info) {
  3757. context.method = "throw";
  3758. context.arg = new TypeError("iterator result is not an object");
  3759. context.delegate = null;
  3760. return ContinueSentinel;
  3761. }
  3762. if (info.done) {
  3763. context[delegate.resultName] = info.value;
  3764. context.next = delegate.nextLoc;
  3765. if (context.method !== "return") {
  3766. context.method = "next";
  3767. context.arg = undefined;
  3768. }
  3769. } else {
  3770. return info;
  3771. }
  3772. context.delegate = null;
  3773. return ContinueSentinel;
  3774. }
  3775. defineIteratorMethods(Gp);
  3776. define(Gp, toStringTagSymbol, "Generator");
  3777. Gp[iteratorSymbol] = function () {
  3778. return this;
  3779. };
  3780. Gp.toString = function () {
  3781. return "[object Generator]";
  3782. };
  3783. function pushTryEntry(locs) {
  3784. var entry = {
  3785. tryLoc: locs[0]
  3786. };
  3787. if (1 in locs) {
  3788. entry.catchLoc = locs[1];
  3789. }
  3790. if (2 in locs) {
  3791. entry.finallyLoc = locs[2];
  3792. entry.afterLoc = locs[3];
  3793. }
  3794. this.tryEntries.push(entry);
  3795. }
  3796. function resetTryEntry(entry) {
  3797. var record = entry.completion || {};
  3798. record.type = "normal";
  3799. delete record.arg;
  3800. entry.completion = record;
  3801. }
  3802. function Context(tryLocsList) {
  3803. this.tryEntries = [{
  3804. tryLoc: "root"
  3805. }];
  3806. tryLocsList.forEach(pushTryEntry, this);
  3807. this.reset(true);
  3808. }
  3809. exports.keys = function (object) {
  3810. var keys = [];
  3811. for (var key in object) {
  3812. keys.push(key);
  3813. }
  3814. keys.reverse();
  3815. return function next() {
  3816. while (keys.length) {
  3817. var key = keys.pop();
  3818. if (key in object) {
  3819. next.value = key;
  3820. next.done = false;
  3821. return next;
  3822. }
  3823. }
  3824. next.done = true;
  3825. return next;
  3826. };
  3827. };
  3828. function values(iterable) {
  3829. if (iterable) {
  3830. var iteratorMethod = iterable[iteratorSymbol];
  3831. if (iteratorMethod) {
  3832. return iteratorMethod.call(iterable);
  3833. }
  3834. if (typeof iterable.next === "function") {
  3835. return iterable;
  3836. }
  3837. if (!isNaN(iterable.length)) {
  3838. var i = -1,
  3839. next = function next() {
  3840. while (++i < iterable.length) {
  3841. if (hasOwn.call(iterable, i)) {
  3842. next.value = iterable[i];
  3843. next.done = false;
  3844. return next;
  3845. }
  3846. }
  3847. next.value = undefined;
  3848. next.done = true;
  3849. return next;
  3850. };
  3851. return next.next = next;
  3852. }
  3853. }
  3854. return {
  3855. next: doneResult
  3856. };
  3857. }
  3858. exports.values = values;
  3859. function doneResult() {
  3860. return {
  3861. value: undefined,
  3862. done: true
  3863. };
  3864. }
  3865. Context.prototype = {
  3866. constructor: Context,
  3867. reset: function reset(skipTempReset) {
  3868. this.prev = 0;
  3869. this.next = 0;
  3870. this.sent = this._sent = undefined;
  3871. this.done = false;
  3872. this.delegate = null;
  3873. this.method = "next";
  3874. this.arg = undefined;
  3875. this.tryEntries.forEach(resetTryEntry);
  3876. if (!skipTempReset) {
  3877. for (var name in this) {
  3878. if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
  3879. this[name] = undefined;
  3880. }
  3881. }
  3882. }
  3883. },
  3884. stop: function stop() {
  3885. this.done = true;
  3886. var rootEntry = this.tryEntries[0];
  3887. var rootRecord = rootEntry.completion;
  3888. if (rootRecord.type === "throw") {
  3889. throw rootRecord.arg;
  3890. }
  3891. return this.rval;
  3892. },
  3893. dispatchException: function dispatchException(exception) {
  3894. if (this.done) {
  3895. throw exception;
  3896. }
  3897. var context = this;
  3898. function handle(loc, caught) {
  3899. record.type = "throw";
  3900. record.arg = exception;
  3901. context.next = loc;
  3902. if (caught) {
  3903. context.method = "next";
  3904. context.arg = undefined;
  3905. }
  3906. return !!caught;
  3907. }
  3908. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3909. var entry = this.tryEntries[i];
  3910. var record = entry.completion;
  3911. if (entry.tryLoc === "root") {
  3912. return handle("end");
  3913. }
  3914. if (entry.tryLoc <= this.prev) {
  3915. var hasCatch = hasOwn.call(entry, "catchLoc");
  3916. var hasFinally = hasOwn.call(entry, "finallyLoc");
  3917. if (hasCatch && hasFinally) {
  3918. if (this.prev < entry.catchLoc) {
  3919. return handle(entry.catchLoc, true);
  3920. } else if (this.prev < entry.finallyLoc) {
  3921. return handle(entry.finallyLoc);
  3922. }
  3923. } else if (hasCatch) {
  3924. if (this.prev < entry.catchLoc) {
  3925. return handle(entry.catchLoc, true);
  3926. }
  3927. } else if (hasFinally) {
  3928. if (this.prev < entry.finallyLoc) {
  3929. return handle(entry.finallyLoc);
  3930. }
  3931. } else {
  3932. throw new Error("try statement without catch or finally");
  3933. }
  3934. }
  3935. }
  3936. },
  3937. abrupt: function abrupt(type, arg) {
  3938. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3939. var entry = this.tryEntries[i];
  3940. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  3941. var finallyEntry = entry;
  3942. break;
  3943. }
  3944. }
  3945. if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
  3946. finallyEntry = null;
  3947. }
  3948. var record = finallyEntry ? finallyEntry.completion : {};
  3949. record.type = type;
  3950. record.arg = arg;
  3951. if (finallyEntry) {
  3952. this.method = "next";
  3953. this.next = finallyEntry.finallyLoc;
  3954. return ContinueSentinel;
  3955. }
  3956. return this.complete(record);
  3957. },
  3958. complete: function complete(record, afterLoc) {
  3959. if (record.type === "throw") {
  3960. throw record.arg;
  3961. }
  3962. if (record.type === "break" || record.type === "continue") {
  3963. this.next = record.arg;
  3964. } else if (record.type === "return") {
  3965. this.rval = this.arg = record.arg;
  3966. this.method = "return";
  3967. this.next = "end";
  3968. } else if (record.type === "normal" && afterLoc) {
  3969. this.next = afterLoc;
  3970. }
  3971. return ContinueSentinel;
  3972. },
  3973. finish: function finish(finallyLoc) {
  3974. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3975. var entry = this.tryEntries[i];
  3976. if (entry.finallyLoc === finallyLoc) {
  3977. this.complete(entry.completion, entry.afterLoc);
  3978. resetTryEntry(entry);
  3979. return ContinueSentinel;
  3980. }
  3981. }
  3982. },
  3983. "catch": function _catch(tryLoc) {
  3984. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3985. var entry = this.tryEntries[i];
  3986. if (entry.tryLoc === tryLoc) {
  3987. var record = entry.completion;
  3988. if (record.type === "throw") {
  3989. var thrown = record.arg;
  3990. resetTryEntry(entry);
  3991. }
  3992. return thrown;
  3993. }
  3994. }
  3995. throw new Error("illegal catch attempt");
  3996. },
  3997. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  3998. this.delegate = {
  3999. iterator: values(iterable),
  4000. resultName: resultName,
  4001. nextLoc: nextLoc
  4002. };
  4003. if (this.method === "next") {
  4004. this.arg = undefined;
  4005. }
  4006. return ContinueSentinel;
  4007. }
  4008. };
  4009. return exports;
  4010. }(( false ? 0 : _typeof(module)) === "object" ? module.exports : {});
  4011. try {
  4012. regeneratorRuntime = runtime;
  4013. } catch (accidentalStrictMode) {
  4014. Function("r", "regeneratorRuntime = r")(runtime);
  4015. }
  4016. /***/ }),
  4017. /* 6 */
  4018. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  4019. Object.defineProperty(exports, "__esModule", ({
  4020. value: true
  4021. }));
  4022. exports.approximateFraction = approximateFraction;
  4023. exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
  4024. exports.binarySearchFirstItem = binarySearchFirstItem;
  4025. exports.getActiveOrFocusedElement = getActiveOrFocusedElement;
  4026. exports.getOutputScale = getOutputScale;
  4027. exports.getPageSizeInches = getPageSizeInches;
  4028. exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
  4029. exports.getVisibleElements = getVisibleElements;
  4030. exports.isPortraitOrientation = isPortraitOrientation;
  4031. exports.isValidRotation = isValidRotation;
  4032. exports.isValidScrollMode = isValidScrollMode;
  4033. exports.isValidSpreadMode = isValidSpreadMode;
  4034. exports.moveToEndOfArray = moveToEndOfArray;
  4035. exports.noContextMenuHandler = noContextMenuHandler;
  4036. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  4037. exports.normalizeWheelEventDirection = normalizeWheelEventDirection;
  4038. exports.parseQueryString = parseQueryString;
  4039. exports.roundToDivide = roundToDivide;
  4040. exports.scrollIntoView = scrollIntoView;
  4041. exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
  4042. exports.watchScroll = watchScroll;
  4043. exports.WaitOnType = exports.VERTICAL_PADDING = exports.UNKNOWN_SCALE = exports.TextLayerMode = exports.SpreadMode = exports.SidebarView = exports.ScrollMode = exports.SCROLLBAR_PADDING = exports.RendererType = exports.ProgressBar = exports.PresentationModeState = exports.NullL10n = exports.MIN_SCALE = exports.MAX_SCALE = exports.MAX_AUTO_SCALE = exports.EventBus = exports.DEFAULT_SCALE_VALUE = exports.DEFAULT_SCALE = exports.CSS_UNITS = exports.AutoPrintRegExp = exports.animationStarted = void 0;
  4044. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  4045. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  4046. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4047. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  4048. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4049. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  4050. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  4051. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  4052. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  4053. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  4054. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  4055. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  4056. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  4057. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  4058. var CSS_UNITS = 96.0 / 72.0;
  4059. exports.CSS_UNITS = CSS_UNITS;
  4060. var DEFAULT_SCALE_VALUE = "auto";
  4061. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  4062. var DEFAULT_SCALE = 1.0;
  4063. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  4064. var MIN_SCALE = 0.1;
  4065. exports.MIN_SCALE = MIN_SCALE;
  4066. var MAX_SCALE = 10.0;
  4067. exports.MAX_SCALE = MAX_SCALE;
  4068. var UNKNOWN_SCALE = 0;
  4069. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  4070. var MAX_AUTO_SCALE = 1.25;
  4071. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  4072. var SCROLLBAR_PADDING = 0;
  4073. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  4074. var VERTICAL_PADDING = 5;
  4075. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  4076. var LOADINGBAR_END_OFFSET_VAR = "--loadingBar-end-offset";
  4077. var PresentationModeState = {
  4078. UNKNOWN: 0,
  4079. NORMAL: 1,
  4080. CHANGING: 2,
  4081. FULLSCREEN: 3
  4082. };
  4083. exports.PresentationModeState = PresentationModeState;
  4084. var SidebarView = {
  4085. UNKNOWN: -1,
  4086. NONE: 0,
  4087. THUMBS: 1,
  4088. OUTLINE: 2,
  4089. ATTACHMENTS: 3,
  4090. LAYERS: 4
  4091. };
  4092. exports.SidebarView = SidebarView;
  4093. var RendererType = {
  4094. CANVAS: "canvas",
  4095. SVG: "svg"
  4096. };
  4097. exports.RendererType = RendererType;
  4098. var TextLayerMode = {
  4099. DISABLE: 0,
  4100. ENABLE: 1,
  4101. ENABLE_ENHANCE: 2
  4102. };
  4103. exports.TextLayerMode = TextLayerMode;
  4104. var ScrollMode = {
  4105. UNKNOWN: -1,
  4106. VERTICAL: 0,
  4107. HORIZONTAL: 1,
  4108. WRAPPED: 2
  4109. };
  4110. exports.ScrollMode = ScrollMode;
  4111. var SpreadMode = {
  4112. UNKNOWN: -1,
  4113. NONE: 0,
  4114. ODD: 1,
  4115. EVEN: 2
  4116. };
  4117. exports.SpreadMode = SpreadMode;
  4118. var AutoPrintRegExp = /\bprint\s*\(/;
  4119. exports.AutoPrintRegExp = AutoPrintRegExp;
  4120. function formatL10nValue(text, args) {
  4121. if (!args) {
  4122. return text;
  4123. }
  4124. return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function (all, name) {
  4125. return name in args ? args[name] : "{{" + name + "}}";
  4126. });
  4127. }
  4128. var NullL10n = {
  4129. getLanguage: function getLanguage() {
  4130. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  4131. return _regenerator["default"].wrap(function _callee$(_context) {
  4132. while (1) {
  4133. switch (_context.prev = _context.next) {
  4134. case 0:
  4135. return _context.abrupt("return", "en-us");
  4136. case 1:
  4137. case "end":
  4138. return _context.stop();
  4139. }
  4140. }
  4141. }, _callee);
  4142. }))();
  4143. },
  4144. getDirection: function getDirection() {
  4145. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  4146. return _regenerator["default"].wrap(function _callee2$(_context2) {
  4147. while (1) {
  4148. switch (_context2.prev = _context2.next) {
  4149. case 0:
  4150. return _context2.abrupt("return", "ltr");
  4151. case 1:
  4152. case "end":
  4153. return _context2.stop();
  4154. }
  4155. }
  4156. }, _callee2);
  4157. }))();
  4158. },
  4159. get: function get(property, args, fallback) {
  4160. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  4161. return _regenerator["default"].wrap(function _callee3$(_context3) {
  4162. while (1) {
  4163. switch (_context3.prev = _context3.next) {
  4164. case 0:
  4165. return _context3.abrupt("return", formatL10nValue(fallback, args));
  4166. case 1:
  4167. case "end":
  4168. return _context3.stop();
  4169. }
  4170. }
  4171. }, _callee3);
  4172. }))();
  4173. },
  4174. translate: function translate(element) {
  4175. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
  4176. return _regenerator["default"].wrap(function _callee4$(_context4) {
  4177. while (1) {
  4178. switch (_context4.prev = _context4.next) {
  4179. case 0:
  4180. case "end":
  4181. return _context4.stop();
  4182. }
  4183. }
  4184. }, _callee4);
  4185. }))();
  4186. }
  4187. };
  4188. exports.NullL10n = NullL10n;
  4189. function getOutputScale(ctx) {
  4190. var devicePixelRatio = window.devicePixelRatio || 1;
  4191. var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
  4192. var pixelRatio = devicePixelRatio / backingStoreRatio;
  4193. return {
  4194. sx: pixelRatio,
  4195. sy: pixelRatio,
  4196. scaled: pixelRatio !== 1
  4197. };
  4198. }
  4199. function scrollIntoView(element, spot) {
  4200. var skipOverflowHiddenElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  4201. var parent = element.offsetParent;
  4202. if (!parent) {
  4203. console.error("offsetParent is not set -- cannot scroll");
  4204. return;
  4205. }
  4206. var offsetY = element.offsetTop + element.clientTop;
  4207. var offsetX = element.offsetLeft + element.clientLeft;
  4208. while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || skipOverflowHiddenElements && getComputedStyle(parent).overflow === "hidden") {
  4209. if (parent.dataset._scaleY) {
  4210. offsetY /= parent.dataset._scaleY;
  4211. offsetX /= parent.dataset._scaleX;
  4212. }
  4213. offsetY += parent.offsetTop;
  4214. offsetX += parent.offsetLeft;
  4215. parent = parent.offsetParent;
  4216. if (!parent) {
  4217. return;
  4218. }
  4219. }
  4220. if (spot) {
  4221. if (spot.top !== undefined) {
  4222. offsetY += spot.top;
  4223. }
  4224. if (spot.left !== undefined) {
  4225. offsetX += spot.left;
  4226. parent.scrollLeft = offsetX;
  4227. }
  4228. }
  4229. parent.scrollTop = offsetY;
  4230. }
  4231. function watchScroll(viewAreaElement, callback) {
  4232. var debounceScroll = function debounceScroll(evt) {
  4233. if (rAF) {
  4234. return;
  4235. }
  4236. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  4237. rAF = null;
  4238. var currentX = viewAreaElement.scrollLeft;
  4239. var lastX = state.lastX;
  4240. if (currentX !== lastX) {
  4241. state.right = currentX > lastX;
  4242. }
  4243. state.lastX = currentX;
  4244. var currentY = viewAreaElement.scrollTop;
  4245. var lastY = state.lastY;
  4246. if (currentY !== lastY) {
  4247. state.down = currentY > lastY;
  4248. }
  4249. state.lastY = currentY;
  4250. callback(state);
  4251. });
  4252. };
  4253. var state = {
  4254. right: true,
  4255. down: true,
  4256. lastX: viewAreaElement.scrollLeft,
  4257. lastY: viewAreaElement.scrollTop,
  4258. _eventHandler: debounceScroll
  4259. };
  4260. var rAF = null;
  4261. viewAreaElement.addEventListener("scroll", debounceScroll, true);
  4262. return state;
  4263. }
  4264. function parseQueryString(query) {
  4265. var parts = query.split("&");
  4266. var params = Object.create(null);
  4267. for (var i = 0, ii = parts.length; i < ii; ++i) {
  4268. var param = parts[i].split("=");
  4269. var key = param[0].toLowerCase();
  4270. var value = param.length > 1 ? param[1] : null;
  4271. params[decodeURIComponent(key)] = decodeURIComponent(value);
  4272. }
  4273. return params;
  4274. }
  4275. function binarySearchFirstItem(items, condition) {
  4276. var minIndex = 0;
  4277. var maxIndex = items.length - 1;
  4278. if (maxIndex < 0 || !condition(items[maxIndex])) {
  4279. return items.length;
  4280. }
  4281. if (condition(items[minIndex])) {
  4282. return minIndex;
  4283. }
  4284. while (minIndex < maxIndex) {
  4285. var currentIndex = minIndex + maxIndex >> 1;
  4286. var currentItem = items[currentIndex];
  4287. if (condition(currentItem)) {
  4288. maxIndex = currentIndex;
  4289. } else {
  4290. minIndex = currentIndex + 1;
  4291. }
  4292. }
  4293. return minIndex;
  4294. }
  4295. function approximateFraction(x) {
  4296. if (Math.floor(x) === x) {
  4297. return [x, 1];
  4298. }
  4299. var xinv = 1 / x;
  4300. var limit = 8;
  4301. if (xinv > limit) {
  4302. return [1, limit];
  4303. } else if (Math.floor(xinv) === xinv) {
  4304. return [1, xinv];
  4305. }
  4306. var x_ = x > 1 ? xinv : x;
  4307. var a = 0,
  4308. b = 1,
  4309. c = 1,
  4310. d = 1;
  4311. while (true) {
  4312. var p = a + c,
  4313. q = b + d;
  4314. if (q > limit) {
  4315. break;
  4316. }
  4317. if (x_ <= p / q) {
  4318. c = p;
  4319. d = q;
  4320. } else {
  4321. a = p;
  4322. b = q;
  4323. }
  4324. }
  4325. var result;
  4326. if (x_ - a / b < c / d - x_) {
  4327. result = x_ === x ? [a, b] : [b, a];
  4328. } else {
  4329. result = x_ === x ? [c, d] : [d, c];
  4330. }
  4331. return result;
  4332. }
  4333. function roundToDivide(x, div) {
  4334. var r = x % div;
  4335. return r === 0 ? x : Math.round(x - r + div);
  4336. }
  4337. function getPageSizeInches(_ref) {
  4338. var view = _ref.view,
  4339. userUnit = _ref.userUnit,
  4340. rotate = _ref.rotate;
  4341. var _view = _slicedToArray(view, 4),
  4342. x1 = _view[0],
  4343. y1 = _view[1],
  4344. x2 = _view[2],
  4345. y2 = _view[3];
  4346. var changeOrientation = rotate % 180 !== 0;
  4347. var width = (x2 - x1) / 72 * userUnit;
  4348. var height = (y2 - y1) / 72 * userUnit;
  4349. return {
  4350. width: changeOrientation ? height : width,
  4351. height: changeOrientation ? width : height
  4352. };
  4353. }
  4354. function backtrackBeforeAllVisibleElements(index, views, top) {
  4355. if (index < 2) {
  4356. return index;
  4357. }
  4358. var elt = views[index].div;
  4359. var pageTop = elt.offsetTop + elt.clientTop;
  4360. if (pageTop >= top) {
  4361. elt = views[index - 1].div;
  4362. pageTop = elt.offsetTop + elt.clientTop;
  4363. }
  4364. for (var i = index - 2; i >= 0; --i) {
  4365. elt = views[i].div;
  4366. if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
  4367. break;
  4368. }
  4369. index = i;
  4370. }
  4371. return index;
  4372. }
  4373. function getVisibleElements(_ref2) {
  4374. var scrollEl = _ref2.scrollEl,
  4375. views = _ref2.views,
  4376. _ref2$sortByVisibilit = _ref2.sortByVisibility,
  4377. sortByVisibility = _ref2$sortByVisibilit === void 0 ? false : _ref2$sortByVisibilit,
  4378. _ref2$horizontal = _ref2.horizontal,
  4379. horizontal = _ref2$horizontal === void 0 ? false : _ref2$horizontal,
  4380. _ref2$rtl = _ref2.rtl,
  4381. rtl = _ref2$rtl === void 0 ? false : _ref2$rtl;
  4382. var top = scrollEl.scrollTop,
  4383. bottom = top + scrollEl.clientHeight;
  4384. var left = scrollEl.scrollLeft,
  4385. right = left + scrollEl.clientWidth;
  4386. function isElementBottomAfterViewTop(view) {
  4387. var element = view.div;
  4388. var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  4389. return elementBottom > top;
  4390. }
  4391. function isElementNextAfterViewHorizontally(view) {
  4392. var element = view.div;
  4393. var elementLeft = element.offsetLeft + element.clientLeft;
  4394. var elementRight = elementLeft + element.clientWidth;
  4395. return rtl ? elementLeft < right : elementRight > left;
  4396. }
  4397. var visible = [],
  4398. numViews = views.length;
  4399. var firstVisibleElementInd = binarySearchFirstItem(views, horizontal ? isElementNextAfterViewHorizontally : isElementBottomAfterViewTop);
  4400. if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
  4401. firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
  4402. }
  4403. var lastEdge = horizontal ? right : -1;
  4404. for (var i = firstVisibleElementInd; i < numViews; i++) {
  4405. var view = views[i],
  4406. element = view.div;
  4407. var currentWidth = element.offsetLeft + element.clientLeft;
  4408. var currentHeight = element.offsetTop + element.clientTop;
  4409. var viewWidth = element.clientWidth,
  4410. viewHeight = element.clientHeight;
  4411. var viewRight = currentWidth + viewWidth;
  4412. var viewBottom = currentHeight + viewHeight;
  4413. if (lastEdge === -1) {
  4414. if (viewBottom >= bottom) {
  4415. lastEdge = viewBottom;
  4416. }
  4417. } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
  4418. break;
  4419. }
  4420. if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) {
  4421. continue;
  4422. }
  4423. var hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
  4424. var hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
  4425. var fractionHeight = (viewHeight - hiddenHeight) / viewHeight,
  4426. fractionWidth = (viewWidth - hiddenWidth) / viewWidth;
  4427. var percent = fractionHeight * fractionWidth * 100 | 0;
  4428. visible.push({
  4429. id: view.id,
  4430. x: currentWidth,
  4431. y: currentHeight,
  4432. view: view,
  4433. percent: percent,
  4434. widthPercent: fractionWidth * 100 | 0
  4435. });
  4436. }
  4437. var first = visible[0],
  4438. last = visible[visible.length - 1];
  4439. if (sortByVisibility) {
  4440. visible.sort(function (a, b) {
  4441. var pc = a.percent - b.percent;
  4442. if (Math.abs(pc) > 0.001) {
  4443. return -pc;
  4444. }
  4445. return a.id - b.id;
  4446. });
  4447. }
  4448. return {
  4449. first: first,
  4450. last: last,
  4451. views: visible
  4452. };
  4453. }
  4454. function noContextMenuHandler(evt) {
  4455. evt.preventDefault();
  4456. }
  4457. function isDataSchema(url) {
  4458. var i = 0;
  4459. var ii = url.length;
  4460. while (i < ii && url[i].trim() === "") {
  4461. i++;
  4462. }
  4463. return url.substring(i, i + 5).toLowerCase() === "data:";
  4464. }
  4465. function getPDFFileNameFromURL(url) {
  4466. var defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "document.pdf";
  4467. if (typeof url !== "string") {
  4468. return defaultFilename;
  4469. }
  4470. if (isDataSchema(url)) {
  4471. console.warn("getPDFFileNameFromURL: " + 'ignoring "data:" URL for performance reasons.');
  4472. return defaultFilename;
  4473. }
  4474. var reURI = /^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
  4475. var reFilename = /[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
  4476. var splitURI = reURI.exec(url);
  4477. var suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
  4478. if (suggestedFilename) {
  4479. suggestedFilename = suggestedFilename[0];
  4480. if (suggestedFilename.includes("%")) {
  4481. try {
  4482. suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
  4483. } catch (ex) {}
  4484. }
  4485. }
  4486. return suggestedFilename || defaultFilename;
  4487. }
  4488. function normalizeWheelEventDirection(evt) {
  4489. var delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
  4490. var angle = Math.atan2(evt.deltaY, evt.deltaX);
  4491. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  4492. delta = -delta;
  4493. }
  4494. return delta;
  4495. }
  4496. function normalizeWheelEventDelta(evt) {
  4497. var delta = normalizeWheelEventDirection(evt);
  4498. var MOUSE_DOM_DELTA_PIXEL_MODE = 0;
  4499. var MOUSE_DOM_DELTA_LINE_MODE = 1;
  4500. var MOUSE_PIXELS_PER_LINE = 30;
  4501. var MOUSE_LINES_PER_PAGE = 30;
  4502. if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
  4503. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  4504. } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
  4505. delta /= MOUSE_LINES_PER_PAGE;
  4506. }
  4507. return delta;
  4508. }
  4509. function isValidRotation(angle) {
  4510. return Number.isInteger(angle) && angle % 90 === 0;
  4511. }
  4512. function isValidScrollMode(mode) {
  4513. return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN;
  4514. }
  4515. function isValidSpreadMode(mode) {
  4516. return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN;
  4517. }
  4518. function isPortraitOrientation(size) {
  4519. return size.width <= size.height;
  4520. }
  4521. var WaitOnType = {
  4522. EVENT: "event",
  4523. TIMEOUT: "timeout"
  4524. };
  4525. exports.WaitOnType = WaitOnType;
  4526. function waitOnEventOrTimeout(_ref3) {
  4527. var target = _ref3.target,
  4528. name = _ref3.name,
  4529. _ref3$delay = _ref3.delay,
  4530. delay = _ref3$delay === void 0 ? 0 : _ref3$delay;
  4531. return new Promise(function (resolve, reject) {
  4532. if (_typeof(target) !== "object" || !(name && typeof name === "string") || !(Number.isInteger(delay) && delay >= 0)) {
  4533. throw new Error("waitOnEventOrTimeout - invalid parameters.");
  4534. }
  4535. function handler(type) {
  4536. if (target instanceof EventBus) {
  4537. target._off(name, eventHandler);
  4538. } else {
  4539. target.removeEventListener(name, eventHandler);
  4540. }
  4541. if (timeout) {
  4542. clearTimeout(timeout);
  4543. }
  4544. resolve(type);
  4545. }
  4546. var eventHandler = handler.bind(null, WaitOnType.EVENT);
  4547. if (target instanceof EventBus) {
  4548. target._on(name, eventHandler);
  4549. } else {
  4550. target.addEventListener(name, eventHandler);
  4551. }
  4552. var timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
  4553. var timeout = setTimeout(timeoutHandler, delay);
  4554. });
  4555. }
  4556. var animationStarted = new Promise(function (resolve) {
  4557. window.requestAnimationFrame(resolve);
  4558. });
  4559. exports.animationStarted = animationStarted;
  4560. function dispatchDOMEvent(eventName) {
  4561. var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  4562. throw new Error("Not implemented: dispatchDOMEvent");
  4563. }
  4564. var EventBus = /*#__PURE__*/function () {
  4565. function EventBus(options) {
  4566. _classCallCheck(this, EventBus);
  4567. this._listeners = Object.create(null);
  4568. }
  4569. _createClass(EventBus, [{
  4570. key: "on",
  4571. value: function on(eventName, listener) {
  4572. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4573. this._on(eventName, listener, {
  4574. external: true,
  4575. once: options === null || options === void 0 ? void 0 : options.once
  4576. });
  4577. }
  4578. }, {
  4579. key: "off",
  4580. value: function off(eventName, listener) {
  4581. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4582. this._off(eventName, listener, {
  4583. external: true,
  4584. once: options === null || options === void 0 ? void 0 : options.once
  4585. });
  4586. }
  4587. }, {
  4588. key: "dispatch",
  4589. value: function dispatch(eventName) {
  4590. var _this = this;
  4591. var eventListeners = this._listeners[eventName];
  4592. if (!eventListeners || eventListeners.length === 0) {
  4593. return;
  4594. }
  4595. var args = Array.prototype.slice.call(arguments, 1);
  4596. var externalListeners;
  4597. eventListeners.slice(0).forEach(function (_ref4) {
  4598. var listener = _ref4.listener,
  4599. external = _ref4.external,
  4600. once = _ref4.once;
  4601. if (once) {
  4602. _this._off(eventName, listener);
  4603. }
  4604. if (external) {
  4605. (externalListeners || (externalListeners = [])).push(listener);
  4606. return;
  4607. }
  4608. listener.apply(null, args);
  4609. });
  4610. if (externalListeners) {
  4611. externalListeners.forEach(function (listener) {
  4612. listener.apply(null, args);
  4613. });
  4614. externalListeners = null;
  4615. }
  4616. }
  4617. }, {
  4618. key: "_on",
  4619. value: function _on(eventName, listener) {
  4620. var _this$_listeners;
  4621. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4622. var eventListeners = (_this$_listeners = this._listeners)[eventName] || (_this$_listeners[eventName] = []);
  4623. eventListeners.push({
  4624. listener: listener,
  4625. external: (options === null || options === void 0 ? void 0 : options.external) === true,
  4626. once: (options === null || options === void 0 ? void 0 : options.once) === true
  4627. });
  4628. }
  4629. }, {
  4630. key: "_off",
  4631. value: function _off(eventName, listener) {
  4632. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  4633. var eventListeners = this._listeners[eventName];
  4634. if (!eventListeners) {
  4635. return;
  4636. }
  4637. for (var i = 0, ii = eventListeners.length; i < ii; i++) {
  4638. if (eventListeners[i].listener === listener) {
  4639. eventListeners.splice(i, 1);
  4640. return;
  4641. }
  4642. }
  4643. }
  4644. }]);
  4645. return EventBus;
  4646. }();
  4647. exports.EventBus = EventBus;
  4648. function clamp(v, min, max) {
  4649. return Math.min(Math.max(v, min), max);
  4650. }
  4651. var ProgressBar = /*#__PURE__*/function () {
  4652. function ProgressBar(id) {
  4653. var _ref5 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  4654. height = _ref5.height,
  4655. width = _ref5.width,
  4656. units = _ref5.units;
  4657. _classCallCheck(this, ProgressBar);
  4658. this.visible = true;
  4659. this.div = document.querySelector(id + " .progress");
  4660. this.bar = this.div.parentNode;
  4661. this.height = height || 100;
  4662. this.width = width || 100;
  4663. this.units = units || "%";
  4664. this.div.style.height = this.height + this.units;
  4665. this.percent = 0;
  4666. }
  4667. _createClass(ProgressBar, [{
  4668. key: "_updateBar",
  4669. value: function _updateBar() {
  4670. if (this._indeterminate) {
  4671. this.div.classList.add("indeterminate");
  4672. this.div.style.width = this.width + this.units;
  4673. return;
  4674. }
  4675. this.div.classList.remove("indeterminate");
  4676. var progressSize = this.width * this._percent / 100;
  4677. this.div.style.width = progressSize + this.units;
  4678. }
  4679. }, {
  4680. key: "setWidth",
  4681. value: function setWidth(viewer) {
  4682. if (!viewer) {
  4683. return;
  4684. }
  4685. var container = viewer.parentNode;
  4686. var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  4687. if (scrollbarWidth > 0) {
  4688. var doc = document.documentElement;
  4689. doc.style.setProperty(LOADINGBAR_END_OFFSET_VAR, "".concat(scrollbarWidth, "px"));
  4690. }
  4691. }
  4692. }, {
  4693. key: "hide",
  4694. value: function hide() {
  4695. if (!this.visible) {
  4696. return;
  4697. }
  4698. this.visible = false;
  4699. this.bar.classList.add("hidden");
  4700. }
  4701. }, {
  4702. key: "show",
  4703. value: function show() {
  4704. if (this.visible) {
  4705. return;
  4706. }
  4707. this.visible = true;
  4708. this.bar.classList.remove("hidden");
  4709. }
  4710. }, {
  4711. key: "percent",
  4712. get: function get() {
  4713. return this._percent;
  4714. },
  4715. set: function set(val) {
  4716. this._indeterminate = isNaN(val);
  4717. this._percent = clamp(val, 0, 100);
  4718. this._updateBar();
  4719. }
  4720. }]);
  4721. return ProgressBar;
  4722. }();
  4723. exports.ProgressBar = ProgressBar;
  4724. function moveToEndOfArray(arr, condition) {
  4725. var moved = [],
  4726. len = arr.length;
  4727. var write = 0;
  4728. for (var read = 0; read < len; ++read) {
  4729. if (condition(arr[read])) {
  4730. moved.push(arr[read]);
  4731. } else {
  4732. arr[write] = arr[read];
  4733. ++write;
  4734. }
  4735. }
  4736. for (var _read = 0; write < len; ++_read, ++write) {
  4737. arr[write] = moved[_read];
  4738. }
  4739. }
  4740. function getActiveOrFocusedElement() {
  4741. var curRoot = document;
  4742. var curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
  4743. while (curActiveOrFocused && curActiveOrFocused.shadowRoot) {
  4744. curRoot = curActiveOrFocused.shadowRoot;
  4745. curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
  4746. }
  4747. return curActiveOrFocused;
  4748. }
  4749. /***/ }),
  4750. /* 7 */
  4751. /***/ ((module) => {
  4752. var pdfjsLib;
  4753. if (typeof window !== "undefined" && window["pdfjs-dist/build/pdf"]) {
  4754. pdfjsLib = window["pdfjs-dist/build/pdf"];
  4755. } else {
  4756. pdfjsLib = require("../build/pdf.js");
  4757. }
  4758. module.exports = pdfjsLib;
  4759. /***/ }),
  4760. /* 8 */
  4761. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  4762. Object.defineProperty(exports, "__esModule", ({
  4763. value: true
  4764. }));
  4765. exports.PDFCursorTools = exports.CursorTool = void 0;
  4766. var _grab_to_pan = __webpack_require__(9);
  4767. var _ui_utils = __webpack_require__(6);
  4768. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4769. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  4770. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4771. var CursorTool = {
  4772. SELECT: 0,
  4773. HAND: 1,
  4774. ZOOM: 2
  4775. };
  4776. exports.CursorTool = CursorTool;
  4777. var PDFCursorTools = /*#__PURE__*/function () {
  4778. function PDFCursorTools(_ref) {
  4779. var _this = this;
  4780. var container = _ref.container,
  4781. eventBus = _ref.eventBus,
  4782. _ref$cursorToolOnLoad = _ref.cursorToolOnLoad,
  4783. cursorToolOnLoad = _ref$cursorToolOnLoad === void 0 ? CursorTool.SELECT : _ref$cursorToolOnLoad;
  4784. _classCallCheck(this, PDFCursorTools);
  4785. this.container = container;
  4786. this.eventBus = eventBus;
  4787. this.active = CursorTool.SELECT;
  4788. this.activeBeforePresentationMode = null;
  4789. this.handTool = new _grab_to_pan.GrabToPan({
  4790. element: this.container
  4791. });
  4792. this._addEventListeners();
  4793. Promise.resolve().then(function () {
  4794. _this.switchTool(cursorToolOnLoad);
  4795. });
  4796. }
  4797. _createClass(PDFCursorTools, [{
  4798. key: "switchTool",
  4799. value: function switchTool(tool) {
  4800. var _this2 = this;
  4801. if (this.activeBeforePresentationMode !== null) {
  4802. return;
  4803. }
  4804. if (tool === this.active) {
  4805. return;
  4806. }
  4807. var disableActiveTool = function disableActiveTool() {
  4808. switch (_this2.active) {
  4809. case CursorTool.SELECT:
  4810. break;
  4811. case CursorTool.HAND:
  4812. _this2.handTool.deactivate();
  4813. break;
  4814. case CursorTool.ZOOM:
  4815. }
  4816. };
  4817. switch (tool) {
  4818. case CursorTool.SELECT:
  4819. disableActiveTool();
  4820. break;
  4821. case CursorTool.HAND:
  4822. disableActiveTool();
  4823. this.handTool.activate();
  4824. break;
  4825. case CursorTool.ZOOM:
  4826. default:
  4827. console.error("switchTool: \"".concat(tool, "\" is an unsupported value."));
  4828. return;
  4829. }
  4830. this.active = tool;
  4831. this._dispatchEvent();
  4832. }
  4833. }, {
  4834. key: "_dispatchEvent",
  4835. value: function _dispatchEvent() {
  4836. this.eventBus.dispatch("cursortoolchanged", {
  4837. source: this,
  4838. tool: this.active
  4839. });
  4840. }
  4841. }, {
  4842. key: "_addEventListeners",
  4843. value: function _addEventListeners() {
  4844. var _this3 = this;
  4845. this.eventBus._on("switchcursortool", function (evt) {
  4846. _this3.switchTool(evt.tool);
  4847. });
  4848. this.eventBus._on("presentationmodechanged", function (evt) {
  4849. switch (evt.state) {
  4850. case _ui_utils.PresentationModeState.CHANGING:
  4851. break;
  4852. case _ui_utils.PresentationModeState.FULLSCREEN:
  4853. {
  4854. var previouslyActive = _this3.active;
  4855. _this3.switchTool(CursorTool.SELECT);
  4856. _this3.activeBeforePresentationMode = previouslyActive;
  4857. break;
  4858. }
  4859. case _ui_utils.PresentationModeState.NORMAL:
  4860. {
  4861. var _previouslyActive = _this3.activeBeforePresentationMode;
  4862. _this3.activeBeforePresentationMode = null;
  4863. _this3.switchTool(_previouslyActive);
  4864. break;
  4865. }
  4866. }
  4867. });
  4868. }
  4869. }, {
  4870. key: "activeTool",
  4871. get: function get() {
  4872. return this.active;
  4873. }
  4874. }]);
  4875. return PDFCursorTools;
  4876. }();
  4877. exports.PDFCursorTools = PDFCursorTools;
  4878. /***/ }),
  4879. /* 9 */
  4880. /***/ ((__unused_webpack_module, exports) => {
  4881. Object.defineProperty(exports, "__esModule", ({
  4882. value: true
  4883. }));
  4884. exports.GrabToPan = GrabToPan;
  4885. function GrabToPan(options) {
  4886. this.element = options.element;
  4887. this.document = options.element.ownerDocument;
  4888. if (typeof options.ignoreTarget === "function") {
  4889. this.ignoreTarget = options.ignoreTarget;
  4890. }
  4891. this.onActiveChanged = options.onActiveChanged;
  4892. this.activate = this.activate.bind(this);
  4893. this.deactivate = this.deactivate.bind(this);
  4894. this.toggle = this.toggle.bind(this);
  4895. this._onmousedown = this._onmousedown.bind(this);
  4896. this._onmousemove = this._onmousemove.bind(this);
  4897. this._endPan = this._endPan.bind(this);
  4898. var overlay = this.overlay = document.createElement("div");
  4899. overlay.className = "grab-to-pan-grabbing";
  4900. }
  4901. GrabToPan.prototype = {
  4902. CSS_CLASS_GRAB: "grab-to-pan-grab",
  4903. activate: function GrabToPan_activate() {
  4904. if (!this.active) {
  4905. this.active = true;
  4906. this.element.addEventListener("mousedown", this._onmousedown, true);
  4907. this.element.classList.add(this.CSS_CLASS_GRAB);
  4908. if (this.onActiveChanged) {
  4909. this.onActiveChanged(true);
  4910. }
  4911. }
  4912. },
  4913. deactivate: function GrabToPan_deactivate() {
  4914. if (this.active) {
  4915. this.active = false;
  4916. this.element.removeEventListener("mousedown", this._onmousedown, true);
  4917. this._endPan();
  4918. this.element.classList.remove(this.CSS_CLASS_GRAB);
  4919. if (this.onActiveChanged) {
  4920. this.onActiveChanged(false);
  4921. }
  4922. }
  4923. },
  4924. toggle: function GrabToPan_toggle() {
  4925. if (this.active) {
  4926. this.deactivate();
  4927. } else {
  4928. this.activate();
  4929. }
  4930. },
  4931. ignoreTarget: function GrabToPan_ignoreTarget(node) {
  4932. return node[matchesSelector]("a[href], a[href] *, input, textarea, button, button *, select, option");
  4933. },
  4934. _onmousedown: function GrabToPan__onmousedown(event) {
  4935. if (event.button !== 0 || this.ignoreTarget(event.target)) {
  4936. return;
  4937. }
  4938. if (event.originalTarget) {
  4939. try {
  4940. event.originalTarget.tagName;
  4941. } catch (e) {
  4942. return;
  4943. }
  4944. }
  4945. this.scrollLeftStart = this.element.scrollLeft;
  4946. this.scrollTopStart = this.element.scrollTop;
  4947. this.clientXStart = event.clientX;
  4948. this.clientYStart = event.clientY;
  4949. this.document.addEventListener("mousemove", this._onmousemove, true);
  4950. this.document.addEventListener("mouseup", this._endPan, true);
  4951. this.element.addEventListener("scroll", this._endPan, true);
  4952. event.preventDefault();
  4953. event.stopPropagation();
  4954. var focusedElement = document.activeElement;
  4955. if (focusedElement && !focusedElement.contains(event.target)) {
  4956. focusedElement.blur();
  4957. }
  4958. },
  4959. _onmousemove: function GrabToPan__onmousemove(event) {
  4960. this.element.removeEventListener("scroll", this._endPan, true);
  4961. if (isLeftMouseReleased(event)) {
  4962. this._endPan();
  4963. return;
  4964. }
  4965. var xDiff = event.clientX - this.clientXStart;
  4966. var yDiff = event.clientY - this.clientYStart;
  4967. var scrollTop = this.scrollTopStart - yDiff;
  4968. var scrollLeft = this.scrollLeftStart - xDiff;
  4969. if (this.element.scrollTo) {
  4970. this.element.scrollTo({
  4971. top: scrollTop,
  4972. left: scrollLeft,
  4973. behavior: "instant"
  4974. });
  4975. } else {
  4976. this.element.scrollTop = scrollTop;
  4977. this.element.scrollLeft = scrollLeft;
  4978. }
  4979. if (!this.overlay.parentNode) {
  4980. document.body.appendChild(this.overlay);
  4981. }
  4982. },
  4983. _endPan: function GrabToPan__endPan() {
  4984. this.element.removeEventListener("scroll", this._endPan, true);
  4985. this.document.removeEventListener("mousemove", this._onmousemove, true);
  4986. this.document.removeEventListener("mouseup", this._endPan, true);
  4987. this.overlay.remove();
  4988. }
  4989. };
  4990. var matchesSelector;
  4991. ["webkitM", "mozM", "m"].some(function (prefix) {
  4992. var name = prefix + "atches";
  4993. if (name in document.documentElement) {
  4994. matchesSelector = name;
  4995. }
  4996. name += "Selector";
  4997. if (name in document.documentElement) {
  4998. matchesSelector = name;
  4999. }
  5000. return matchesSelector;
  5001. });
  5002. var isNotIEorIsIE10plus = !document.documentMode || document.documentMode > 9;
  5003. var chrome = window.chrome;
  5004. var isChrome15OrOpera15plus = chrome && (chrome.webstore || chrome.app);
  5005. var isSafari6plus = /Apple/.test(navigator.vendor) && /Version\/([6-9]\d*|[1-5]\d+)/.test(navigator.userAgent);
  5006. function isLeftMouseReleased(event) {
  5007. if ("buttons" in event && isNotIEorIsIE10plus) {
  5008. return !(event.buttons & 1);
  5009. }
  5010. if (isChrome15OrOpera15plus || isSafari6plus) {
  5011. return event.which === 0;
  5012. }
  5013. return false;
  5014. }
  5015. /***/ }),
  5016. /* 10 */
  5017. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5018. Object.defineProperty(exports, "__esModule", ({
  5019. value: true
  5020. }));
  5021. exports.RenderingStates = exports.PDFRenderingQueue = void 0;
  5022. var _pdfjsLib = __webpack_require__(7);
  5023. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5024. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  5025. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5026. var CLEANUP_TIMEOUT = 30000;
  5027. var RenderingStates = {
  5028. INITIAL: 0,
  5029. RUNNING: 1,
  5030. PAUSED: 2,
  5031. FINISHED: 3
  5032. };
  5033. exports.RenderingStates = RenderingStates;
  5034. var PDFRenderingQueue = /*#__PURE__*/function () {
  5035. function PDFRenderingQueue() {
  5036. _classCallCheck(this, PDFRenderingQueue);
  5037. this.pdfViewer = null;
  5038. this.pdfThumbnailViewer = null;
  5039. this.onIdle = null;
  5040. this.highestPriorityPage = null;
  5041. this.idleTimeout = null;
  5042. this.printing = false;
  5043. this.isThumbnailViewEnabled = false;
  5044. }
  5045. _createClass(PDFRenderingQueue, [{
  5046. key: "setViewer",
  5047. value: function setViewer(pdfViewer) {
  5048. this.pdfViewer = pdfViewer;
  5049. }
  5050. }, {
  5051. key: "setThumbnailViewer",
  5052. value: function setThumbnailViewer(pdfThumbnailViewer) {
  5053. this.pdfThumbnailViewer = pdfThumbnailViewer;
  5054. }
  5055. }, {
  5056. key: "isHighestPriority",
  5057. value: function isHighestPriority(view) {
  5058. return this.highestPriorityPage === view.renderingId;
  5059. }
  5060. }, {
  5061. key: "renderHighestPriority",
  5062. value: function renderHighestPriority(currentlyVisiblePages) {
  5063. if (this.idleTimeout) {
  5064. clearTimeout(this.idleTimeout);
  5065. this.idleTimeout = null;
  5066. }
  5067. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  5068. return;
  5069. }
  5070. if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
  5071. if (this.pdfThumbnailViewer.forceRendering()) {
  5072. return;
  5073. }
  5074. }
  5075. if (this.printing) {
  5076. return;
  5077. }
  5078. if (this.onIdle) {
  5079. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
  5080. }
  5081. }
  5082. }, {
  5083. key: "getHighestPriority",
  5084. value: function getHighestPriority(visible, views, scrolledDown) {
  5085. var visibleViews = visible.views;
  5086. var numVisible = visibleViews.length;
  5087. if (numVisible === 0) {
  5088. return null;
  5089. }
  5090. for (var i = 0; i < numVisible; ++i) {
  5091. var view = visibleViews[i].view;
  5092. if (!this.isViewFinished(view)) {
  5093. return view;
  5094. }
  5095. }
  5096. if (scrolledDown) {
  5097. var nextPageIndex = visible.last.id;
  5098. if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {
  5099. return views[nextPageIndex];
  5100. }
  5101. } else {
  5102. var previousPageIndex = visible.first.id - 2;
  5103. if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) {
  5104. return views[previousPageIndex];
  5105. }
  5106. }
  5107. return null;
  5108. }
  5109. }, {
  5110. key: "isViewFinished",
  5111. value: function isViewFinished(view) {
  5112. return view.renderingState === RenderingStates.FINISHED;
  5113. }
  5114. }, {
  5115. key: "renderView",
  5116. value: function renderView(view) {
  5117. var _this = this;
  5118. switch (view.renderingState) {
  5119. case RenderingStates.FINISHED:
  5120. return false;
  5121. case RenderingStates.PAUSED:
  5122. this.highestPriorityPage = view.renderingId;
  5123. view.resume();
  5124. break;
  5125. case RenderingStates.RUNNING:
  5126. this.highestPriorityPage = view.renderingId;
  5127. break;
  5128. case RenderingStates.INITIAL:
  5129. this.highestPriorityPage = view.renderingId;
  5130. view.draw()["finally"](function () {
  5131. _this.renderHighestPriority();
  5132. })["catch"](function (reason) {
  5133. if (reason instanceof _pdfjsLib.RenderingCancelledException) {
  5134. return;
  5135. }
  5136. console.error("renderView: \"".concat(reason, "\""));
  5137. });
  5138. break;
  5139. }
  5140. return true;
  5141. }
  5142. }]);
  5143. return PDFRenderingQueue;
  5144. }();
  5145. exports.PDFRenderingQueue = PDFRenderingQueue;
  5146. /***/ }),
  5147. /* 11 */
  5148. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5149. Object.defineProperty(exports, "__esModule", ({
  5150. value: true
  5151. }));
  5152. exports.OverlayManager = void 0;
  5153. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  5154. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5155. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  5156. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  5157. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5158. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  5159. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5160. var OverlayManager = /*#__PURE__*/function () {
  5161. function OverlayManager() {
  5162. _classCallCheck(this, OverlayManager);
  5163. this._overlays = {};
  5164. this._active = null;
  5165. this._keyDownBound = this._keyDown.bind(this);
  5166. }
  5167. _createClass(OverlayManager, [{
  5168. key: "register",
  5169. value: function () {
  5170. var _register = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(name, element) {
  5171. var callerCloseMethod,
  5172. canForceClose,
  5173. container,
  5174. _args = arguments;
  5175. return _regenerator["default"].wrap(function _callee$(_context) {
  5176. while (1) {
  5177. switch (_context.prev = _context.next) {
  5178. case 0:
  5179. callerCloseMethod = _args.length > 2 && _args[2] !== undefined ? _args[2] : null;
  5180. canForceClose = _args.length > 3 && _args[3] !== undefined ? _args[3] : false;
  5181. if (!(!name || !element || !(container = element.parentNode))) {
  5182. _context.next = 6;
  5183. break;
  5184. }
  5185. throw new Error("Not enough parameters.");
  5186. case 6:
  5187. if (!this._overlays[name]) {
  5188. _context.next = 8;
  5189. break;
  5190. }
  5191. throw new Error("The overlay is already registered.");
  5192. case 8:
  5193. this._overlays[name] = {
  5194. element: element,
  5195. container: container,
  5196. callerCloseMethod: callerCloseMethod,
  5197. canForceClose: canForceClose
  5198. };
  5199. case 9:
  5200. case "end":
  5201. return _context.stop();
  5202. }
  5203. }
  5204. }, _callee, this);
  5205. }));
  5206. function register(_x, _x2) {
  5207. return _register.apply(this, arguments);
  5208. }
  5209. return register;
  5210. }()
  5211. }, {
  5212. key: "unregister",
  5213. value: function () {
  5214. var _unregister = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(name) {
  5215. return _regenerator["default"].wrap(function _callee2$(_context2) {
  5216. while (1) {
  5217. switch (_context2.prev = _context2.next) {
  5218. case 0:
  5219. if (this._overlays[name]) {
  5220. _context2.next = 4;
  5221. break;
  5222. }
  5223. throw new Error("The overlay does not exist.");
  5224. case 4:
  5225. if (!(this._active === name)) {
  5226. _context2.next = 6;
  5227. break;
  5228. }
  5229. throw new Error("The overlay cannot be removed while it is active.");
  5230. case 6:
  5231. delete this._overlays[name];
  5232. case 7:
  5233. case "end":
  5234. return _context2.stop();
  5235. }
  5236. }
  5237. }, _callee2, this);
  5238. }));
  5239. function unregister(_x3) {
  5240. return _unregister.apply(this, arguments);
  5241. }
  5242. return unregister;
  5243. }()
  5244. }, {
  5245. key: "open",
  5246. value: function () {
  5247. var _open = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(name) {
  5248. return _regenerator["default"].wrap(function _callee3$(_context3) {
  5249. while (1) {
  5250. switch (_context3.prev = _context3.next) {
  5251. case 0:
  5252. if (this._overlays[name]) {
  5253. _context3.next = 4;
  5254. break;
  5255. }
  5256. throw new Error("The overlay does not exist.");
  5257. case 4:
  5258. if (!this._active) {
  5259. _context3.next = 14;
  5260. break;
  5261. }
  5262. if (!this._overlays[name].canForceClose) {
  5263. _context3.next = 9;
  5264. break;
  5265. }
  5266. this._closeThroughCaller();
  5267. _context3.next = 14;
  5268. break;
  5269. case 9:
  5270. if (!(this._active === name)) {
  5271. _context3.next = 13;
  5272. break;
  5273. }
  5274. throw new Error("The overlay is already active.");
  5275. case 13:
  5276. throw new Error("Another overlay is currently active.");
  5277. case 14:
  5278. this._active = name;
  5279. this._overlays[this._active].element.classList.remove("hidden");
  5280. this._overlays[this._active].container.classList.remove("hidden");
  5281. window.addEventListener("keydown", this._keyDownBound);
  5282. case 18:
  5283. case "end":
  5284. return _context3.stop();
  5285. }
  5286. }
  5287. }, _callee3, this);
  5288. }));
  5289. function open(_x4) {
  5290. return _open.apply(this, arguments);
  5291. }
  5292. return open;
  5293. }()
  5294. }, {
  5295. key: "close",
  5296. value: function () {
  5297. var _close = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(name) {
  5298. return _regenerator["default"].wrap(function _callee4$(_context4) {
  5299. while (1) {
  5300. switch (_context4.prev = _context4.next) {
  5301. case 0:
  5302. if (this._overlays[name]) {
  5303. _context4.next = 4;
  5304. break;
  5305. }
  5306. throw new Error("The overlay does not exist.");
  5307. case 4:
  5308. if (this._active) {
  5309. _context4.next = 8;
  5310. break;
  5311. }
  5312. throw new Error("The overlay is currently not active.");
  5313. case 8:
  5314. if (!(this._active !== name)) {
  5315. _context4.next = 10;
  5316. break;
  5317. }
  5318. throw new Error("Another overlay is currently active.");
  5319. case 10:
  5320. this._overlays[this._active].container.classList.add("hidden");
  5321. this._overlays[this._active].element.classList.add("hidden");
  5322. this._active = null;
  5323. window.removeEventListener("keydown", this._keyDownBound);
  5324. case 14:
  5325. case "end":
  5326. return _context4.stop();
  5327. }
  5328. }
  5329. }, _callee4, this);
  5330. }));
  5331. function close(_x5) {
  5332. return _close.apply(this, arguments);
  5333. }
  5334. return close;
  5335. }()
  5336. }, {
  5337. key: "_keyDown",
  5338. value: function _keyDown(evt) {
  5339. if (this._active && evt.keyCode === 27) {
  5340. this._closeThroughCaller();
  5341. evt.preventDefault();
  5342. }
  5343. }
  5344. }, {
  5345. key: "_closeThroughCaller",
  5346. value: function _closeThroughCaller() {
  5347. if (this._overlays[this._active].callerCloseMethod) {
  5348. this._overlays[this._active].callerCloseMethod();
  5349. }
  5350. if (this._active) {
  5351. this.close(this._active);
  5352. }
  5353. }
  5354. }, {
  5355. key: "active",
  5356. get: function get() {
  5357. return this._active;
  5358. }
  5359. }]);
  5360. return OverlayManager;
  5361. }();
  5362. exports.OverlayManager = OverlayManager;
  5363. /***/ }),
  5364. /* 12 */
  5365. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5366. Object.defineProperty(exports, "__esModule", ({
  5367. value: true
  5368. }));
  5369. exports.PasswordPrompt = void 0;
  5370. var _ui_utils = __webpack_require__(6);
  5371. var _pdfjsLib = __webpack_require__(7);
  5372. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5373. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  5374. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5375. var PasswordPrompt = /*#__PURE__*/function () {
  5376. function PasswordPrompt(options, overlayManager) {
  5377. var _this = this;
  5378. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  5379. _classCallCheck(this, PasswordPrompt);
  5380. this.overlayName = options.overlayName;
  5381. this.container = options.container;
  5382. this.label = options.label;
  5383. this.input = options.input;
  5384. this.submitButton = options.submitButton;
  5385. this.cancelButton = options.cancelButton;
  5386. this.overlayManager = overlayManager;
  5387. this.l10n = l10n;
  5388. this.updateCallback = null;
  5389. this.reason = null;
  5390. this.submitButton.addEventListener("click", this.verify.bind(this));
  5391. this.cancelButton.addEventListener("click", this.close.bind(this));
  5392. this.input.addEventListener("keydown", function (e) {
  5393. if (e.keyCode === 13) {
  5394. _this.verify();
  5395. }
  5396. });
  5397. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this), true);
  5398. }
  5399. _createClass(PasswordPrompt, [{
  5400. key: "open",
  5401. value: function open() {
  5402. var _this2 = this;
  5403. this.overlayManager.open(this.overlayName).then(function () {
  5404. _this2.input.focus();
  5405. var promptString;
  5406. if (_this2.reason === _pdfjsLib.PasswordResponses.INCORRECT_PASSWORD) {
  5407. promptString = _this2.l10n.get("password_invalid", null, "Invalid password. Please try again.");
  5408. } else {
  5409. promptString = _this2.l10n.get("password_label", null, "Enter the password to open this PDF file.");
  5410. }
  5411. promptString.then(function (msg) {
  5412. _this2.label.textContent = msg;
  5413. });
  5414. });
  5415. }
  5416. }, {
  5417. key: "close",
  5418. value: function close() {
  5419. var _this3 = this;
  5420. this.overlayManager.close(this.overlayName).then(function () {
  5421. _this3.input.value = "";
  5422. });
  5423. }
  5424. }, {
  5425. key: "verify",
  5426. value: function verify() {
  5427. var password = this.input.value;
  5428. if (password && password.length > 0) {
  5429. this.close();
  5430. this.updateCallback(password);
  5431. }
  5432. }
  5433. }, {
  5434. key: "setUpdateCallback",
  5435. value: function setUpdateCallback(updateCallback, reason) {
  5436. this.updateCallback = updateCallback;
  5437. this.reason = reason;
  5438. }
  5439. }]);
  5440. return PasswordPrompt;
  5441. }();
  5442. exports.PasswordPrompt = PasswordPrompt;
  5443. /***/ }),
  5444. /* 13 */
  5445. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5446. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  5447. Object.defineProperty(exports, "__esModule", ({
  5448. value: true
  5449. }));
  5450. exports.PDFAttachmentViewer = void 0;
  5451. var _pdfjsLib = __webpack_require__(7);
  5452. var _base_tree_viewer = __webpack_require__(14);
  5453. var _viewer_compatibility = __webpack_require__(2);
  5454. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  5455. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  5456. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  5457. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5458. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  5459. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5460. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  5461. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  5462. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  5463. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  5464. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  5465. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  5466. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  5467. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  5468. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  5469. var PdfFileRegExp = /\.pdf$/i;
  5470. var PDFAttachmentViewer = /*#__PURE__*/function (_BaseTreeViewer) {
  5471. _inherits(PDFAttachmentViewer, _BaseTreeViewer);
  5472. var _super = _createSuper(PDFAttachmentViewer);
  5473. function PDFAttachmentViewer(options) {
  5474. var _this;
  5475. _classCallCheck(this, PDFAttachmentViewer);
  5476. _this = _super.call(this, options);
  5477. _this.downloadManager = options.downloadManager;
  5478. _this.eventBus._on("fileattachmentannotation", _this._appendAttachment.bind(_assertThisInitialized(_this)));
  5479. return _this;
  5480. }
  5481. _createClass(PDFAttachmentViewer, [{
  5482. key: "reset",
  5483. value: function reset() {
  5484. var keepRenderedCapability = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5485. _get(_getPrototypeOf(PDFAttachmentViewer.prototype), "reset", this).call(this);
  5486. this._attachments = null;
  5487. if (!keepRenderedCapability) {
  5488. this._renderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  5489. }
  5490. if (this._pendingDispatchEvent) {
  5491. clearTimeout(this._pendingDispatchEvent);
  5492. }
  5493. this._pendingDispatchEvent = null;
  5494. }
  5495. }, {
  5496. key: "_dispatchEvent",
  5497. value: function _dispatchEvent(attachmentsCount) {
  5498. var _this2 = this;
  5499. this._renderedCapability.resolve();
  5500. if (this._pendingDispatchEvent) {
  5501. clearTimeout(this._pendingDispatchEvent);
  5502. this._pendingDispatchEvent = null;
  5503. }
  5504. if (attachmentsCount === 0) {
  5505. this._pendingDispatchEvent = setTimeout(function () {
  5506. _this2.eventBus.dispatch("attachmentsloaded", {
  5507. source: _this2,
  5508. attachmentsCount: 0
  5509. });
  5510. _this2._pendingDispatchEvent = null;
  5511. });
  5512. return;
  5513. }
  5514. this.eventBus.dispatch("attachmentsloaded", {
  5515. source: this,
  5516. attachmentsCount: attachmentsCount
  5517. });
  5518. }
  5519. }, {
  5520. key: "_bindPdfLink",
  5521. value: function _bindPdfLink(element, _ref) {
  5522. var _this3 = this;
  5523. var content = _ref.content,
  5524. filename = _ref.filename;
  5525. var blobUrl;
  5526. element.onclick = function () {
  5527. if (!blobUrl) {
  5528. blobUrl = URL.createObjectURL(new Blob([content], {
  5529. type: "application/pdf"
  5530. }));
  5531. }
  5532. var viewerUrl;
  5533. viewerUrl = "?file=" + encodeURIComponent(blobUrl + "#" + filename);
  5534. try {
  5535. window.open(viewerUrl);
  5536. } catch (ex) {
  5537. console.error("_bindPdfLink: ".concat(ex));
  5538. URL.revokeObjectURL(blobUrl);
  5539. blobUrl = null;
  5540. _this3.downloadManager.downloadData(content, filename, "application/pdf");
  5541. }
  5542. return false;
  5543. };
  5544. }
  5545. }, {
  5546. key: "_bindLink",
  5547. value: function _bindLink(element, _ref2) {
  5548. var _this4 = this;
  5549. var content = _ref2.content,
  5550. filename = _ref2.filename;
  5551. element.onclick = function () {
  5552. var contentType = PdfFileRegExp.test(filename) ? "application/pdf" : "";
  5553. _this4.downloadManager.downloadData(content, filename, contentType);
  5554. return false;
  5555. };
  5556. }
  5557. }, {
  5558. key: "render",
  5559. value: function render(_ref3) {
  5560. var attachments = _ref3.attachments,
  5561. _ref3$keepRenderedCap = _ref3.keepRenderedCapability,
  5562. keepRenderedCapability = _ref3$keepRenderedCap === void 0 ? false : _ref3$keepRenderedCap;
  5563. if (this._attachments) {
  5564. this.reset(keepRenderedCapability);
  5565. }
  5566. this._attachments = attachments || null;
  5567. if (!attachments) {
  5568. this._dispatchEvent(0);
  5569. return;
  5570. }
  5571. var names = Object.keys(attachments).sort(function (a, b) {
  5572. return a.toLowerCase().localeCompare(b.toLowerCase());
  5573. });
  5574. var fragment = document.createDocumentFragment();
  5575. var attachmentsCount = 0;
  5576. var _iterator = _createForOfIteratorHelper(names),
  5577. _step;
  5578. try {
  5579. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  5580. var name = _step.value;
  5581. var item = attachments[name];
  5582. var filename = (0, _pdfjsLib.getFilenameFromUrl)(item.filename);
  5583. var div = document.createElement("div");
  5584. div.className = "treeItem";
  5585. var element = document.createElement("a");
  5586. if (PdfFileRegExp.test(filename) && !_viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL) {
  5587. this._bindPdfLink(element, {
  5588. content: item.content,
  5589. filename: filename
  5590. });
  5591. } else {
  5592. this._bindLink(element, {
  5593. content: item.content,
  5594. filename: filename
  5595. });
  5596. }
  5597. element.textContent = this._normalizeTextContent(filename);
  5598. div.appendChild(element);
  5599. fragment.appendChild(div);
  5600. attachmentsCount++;
  5601. }
  5602. } catch (err) {
  5603. _iterator.e(err);
  5604. } finally {
  5605. _iterator.f();
  5606. }
  5607. this._finishRendering(fragment, attachmentsCount);
  5608. }
  5609. }, {
  5610. key: "_appendAttachment",
  5611. value: function _appendAttachment(_ref4) {
  5612. var _this5 = this;
  5613. var id = _ref4.id,
  5614. filename = _ref4.filename,
  5615. content = _ref4.content;
  5616. var renderedPromise = this._renderedCapability.promise;
  5617. renderedPromise.then(function () {
  5618. if (renderedPromise !== _this5._renderedCapability.promise) {
  5619. return;
  5620. }
  5621. var attachments = _this5._attachments;
  5622. if (!attachments) {
  5623. attachments = Object.create(null);
  5624. } else {
  5625. for (var name in attachments) {
  5626. if (id === name) {
  5627. return;
  5628. }
  5629. }
  5630. }
  5631. attachments[id] = {
  5632. filename: filename,
  5633. content: content
  5634. };
  5635. _this5.render({
  5636. attachments: attachments,
  5637. keepRenderedCapability: true
  5638. });
  5639. });
  5640. }
  5641. }]);
  5642. return PDFAttachmentViewer;
  5643. }(_base_tree_viewer.BaseTreeViewer);
  5644. exports.PDFAttachmentViewer = PDFAttachmentViewer;
  5645. /***/ }),
  5646. /* 14 */
  5647. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5648. Object.defineProperty(exports, "__esModule", ({
  5649. value: true
  5650. }));
  5651. exports.BaseTreeViewer = void 0;
  5652. var _pdfjsLib = __webpack_require__(7);
  5653. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  5654. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  5655. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  5656. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5657. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  5658. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5659. var TREEITEM_OFFSET_TOP = -100;
  5660. var TREEITEM_SELECTED_CLASS = "selected";
  5661. var BaseTreeViewer = /*#__PURE__*/function () {
  5662. function BaseTreeViewer(options) {
  5663. _classCallCheck(this, BaseTreeViewer);
  5664. if (this.constructor === BaseTreeViewer) {
  5665. throw new Error("Cannot initialize BaseTreeViewer.");
  5666. }
  5667. this.container = options.container;
  5668. this.eventBus = options.eventBus;
  5669. this.reset();
  5670. }
  5671. _createClass(BaseTreeViewer, [{
  5672. key: "reset",
  5673. value: function reset() {
  5674. this._pdfDocument = null;
  5675. this._lastToggleIsShow = true;
  5676. this._currentTreeItem = null;
  5677. this.container.textContent = "";
  5678. this.container.classList.remove("treeWithDeepNesting");
  5679. }
  5680. }, {
  5681. key: "_dispatchEvent",
  5682. value: function _dispatchEvent(count) {
  5683. throw new Error("Not implemented: _dispatchEvent");
  5684. }
  5685. }, {
  5686. key: "_bindLink",
  5687. value: function _bindLink(element, params) {
  5688. throw new Error("Not implemented: _bindLink");
  5689. }
  5690. }, {
  5691. key: "_normalizeTextContent",
  5692. value: function _normalizeTextContent(str) {
  5693. return (0, _pdfjsLib.removeNullCharacters)(str) || "\u2013";
  5694. }
  5695. }, {
  5696. key: "_addToggleButton",
  5697. value: function _addToggleButton(div) {
  5698. var _this = this;
  5699. var hidden = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  5700. var toggler = document.createElement("div");
  5701. toggler.className = "treeItemToggler";
  5702. if (hidden) {
  5703. toggler.classList.add("treeItemsHidden");
  5704. }
  5705. toggler.onclick = function (evt) {
  5706. evt.stopPropagation();
  5707. toggler.classList.toggle("treeItemsHidden");
  5708. if (evt.shiftKey) {
  5709. var shouldShowAll = !toggler.classList.contains("treeItemsHidden");
  5710. _this._toggleTreeItem(div, shouldShowAll);
  5711. }
  5712. };
  5713. div.insertBefore(toggler, div.firstChild);
  5714. }
  5715. }, {
  5716. key: "_toggleTreeItem",
  5717. value: function _toggleTreeItem(root) {
  5718. var show = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  5719. this._lastToggleIsShow = show;
  5720. var _iterator = _createForOfIteratorHelper(root.querySelectorAll(".treeItemToggler")),
  5721. _step;
  5722. try {
  5723. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  5724. var toggler = _step.value;
  5725. toggler.classList.toggle("treeItemsHidden", !show);
  5726. }
  5727. } catch (err) {
  5728. _iterator.e(err);
  5729. } finally {
  5730. _iterator.f();
  5731. }
  5732. }
  5733. }, {
  5734. key: "_toggleAllTreeItems",
  5735. value: function _toggleAllTreeItems() {
  5736. this._toggleTreeItem(this.container, !this._lastToggleIsShow);
  5737. }
  5738. }, {
  5739. key: "_finishRendering",
  5740. value: function _finishRendering(fragment, count) {
  5741. var hasAnyNesting = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  5742. if (hasAnyNesting) {
  5743. this.container.classList.add("treeWithDeepNesting");
  5744. this._lastToggleIsShow = !fragment.querySelector(".treeItemsHidden");
  5745. }
  5746. this.container.appendChild(fragment);
  5747. this._dispatchEvent(count);
  5748. }
  5749. }, {
  5750. key: "render",
  5751. value: function render(params) {
  5752. throw new Error("Not implemented: render");
  5753. }
  5754. }, {
  5755. key: "_updateCurrentTreeItem",
  5756. value: function _updateCurrentTreeItem() {
  5757. var treeItem = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  5758. if (this._currentTreeItem) {
  5759. this._currentTreeItem.classList.remove(TREEITEM_SELECTED_CLASS);
  5760. this._currentTreeItem = null;
  5761. }
  5762. if (treeItem) {
  5763. treeItem.classList.add(TREEITEM_SELECTED_CLASS);
  5764. this._currentTreeItem = treeItem;
  5765. }
  5766. }
  5767. }, {
  5768. key: "_scrollToCurrentTreeItem",
  5769. value: function _scrollToCurrentTreeItem(treeItem) {
  5770. if (!treeItem) {
  5771. return;
  5772. }
  5773. var currentNode = treeItem.parentNode;
  5774. while (currentNode && currentNode !== this.container) {
  5775. if (currentNode.classList.contains("treeItem")) {
  5776. var toggler = currentNode.firstElementChild;
  5777. toggler === null || toggler === void 0 ? void 0 : toggler.classList.remove("treeItemsHidden");
  5778. }
  5779. currentNode = currentNode.parentNode;
  5780. }
  5781. this._updateCurrentTreeItem(treeItem);
  5782. this.container.scrollTo(treeItem.offsetLeft, treeItem.offsetTop + TREEITEM_OFFSET_TOP);
  5783. }
  5784. }]);
  5785. return BaseTreeViewer;
  5786. }();
  5787. exports.BaseTreeViewer = BaseTreeViewer;
  5788. /***/ }),
  5789. /* 15 */
  5790. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5791. Object.defineProperty(exports, "__esModule", ({
  5792. value: true
  5793. }));
  5794. exports.PDFDocumentProperties = void 0;
  5795. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  5796. var _pdfjsLib = __webpack_require__(7);
  5797. var _ui_utils = __webpack_require__(6);
  5798. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5799. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  5800. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  5801. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  5802. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  5803. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  5804. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  5805. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  5806. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  5807. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5808. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  5809. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5810. var DEFAULT_FIELD_CONTENT = "-";
  5811. var NON_METRIC_LOCALES = ["en-us", "en-lr", "my"];
  5812. var US_PAGE_NAMES = {
  5813. "8.5x11": "Letter",
  5814. "8.5x14": "Legal"
  5815. };
  5816. var METRIC_PAGE_NAMES = {
  5817. "297x420": "A3",
  5818. "210x297": "A4"
  5819. };
  5820. function getPageName(size, isPortrait, pageNames) {
  5821. var width = isPortrait ? size.width : size.height;
  5822. var height = isPortrait ? size.height : size.width;
  5823. return pageNames["".concat(width, "x").concat(height)];
  5824. }
  5825. var PDFDocumentProperties = /*#__PURE__*/function () {
  5826. function PDFDocumentProperties(_ref, overlayManager, eventBus) {
  5827. var _this = this;
  5828. var overlayName = _ref.overlayName,
  5829. fields = _ref.fields,
  5830. container = _ref.container,
  5831. closeButton = _ref.closeButton;
  5832. var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
  5833. _classCallCheck(this, PDFDocumentProperties);
  5834. this.overlayName = overlayName;
  5835. this.fields = fields;
  5836. this.container = container;
  5837. this.overlayManager = overlayManager;
  5838. this.l10n = l10n;
  5839. this._reset();
  5840. closeButton.addEventListener("click", this.close.bind(this));
  5841. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this));
  5842. eventBus._on("pagechanging", function (evt) {
  5843. _this._currentPageNumber = evt.pageNumber;
  5844. });
  5845. eventBus._on("rotationchanging", function (evt) {
  5846. _this._pagesRotation = evt.pagesRotation;
  5847. });
  5848. this._isNonMetricLocale = true;
  5849. l10n.getLanguage().then(function (locale) {
  5850. _this._isNonMetricLocale = NON_METRIC_LOCALES.includes(locale);
  5851. });
  5852. }
  5853. _createClass(PDFDocumentProperties, [{
  5854. key: "open",
  5855. value: function () {
  5856. var _open = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  5857. var _this2 = this;
  5858. var freezeFieldData, currentPageNumber, pagesRotation, _yield$this$pdfDocume, info, contentDispositionFilename, contentLength, _yield$Promise$all, _yield$Promise$all2, fileName, fileSize, creationDate, modificationDate, pageSize, isLinearized, _yield$this$pdfDocume2, length, data;
  5859. return _regenerator["default"].wrap(function _callee$(_context) {
  5860. while (1) {
  5861. switch (_context.prev = _context.next) {
  5862. case 0:
  5863. freezeFieldData = function freezeFieldData(data) {
  5864. Object.defineProperty(_this2, "fieldData", {
  5865. value: Object.freeze(data),
  5866. writable: false,
  5867. enumerable: true,
  5868. configurable: true
  5869. });
  5870. };
  5871. _context.next = 3;
  5872. return Promise.all([this.overlayManager.open(this.overlayName), this._dataAvailableCapability.promise]);
  5873. case 3:
  5874. currentPageNumber = this._currentPageNumber;
  5875. pagesRotation = this._pagesRotation;
  5876. if (!(this.fieldData && currentPageNumber === this.fieldData._currentPageNumber && pagesRotation === this.fieldData._pagesRotation)) {
  5877. _context.next = 8;
  5878. break;
  5879. }
  5880. this._updateUI();
  5881. return _context.abrupt("return");
  5882. case 8:
  5883. _context.next = 10;
  5884. return this.pdfDocument.getMetadata();
  5885. case 10:
  5886. _yield$this$pdfDocume = _context.sent;
  5887. info = _yield$this$pdfDocume.info;
  5888. contentDispositionFilename = _yield$this$pdfDocume.contentDispositionFilename;
  5889. contentLength = _yield$this$pdfDocume.contentLength;
  5890. _context.next = 16;
  5891. return Promise.all([contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(this.url), this._parseFileSize(contentLength), this._parseDate(info.CreationDate), this._parseDate(info.ModDate), this.pdfDocument.getPage(currentPageNumber).then(function (pdfPage) {
  5892. return _this2._parsePageSize((0, _ui_utils.getPageSizeInches)(pdfPage), pagesRotation);
  5893. }), this._parseLinearization(info.IsLinearized)]);
  5894. case 16:
  5895. _yield$Promise$all = _context.sent;
  5896. _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 6);
  5897. fileName = _yield$Promise$all2[0];
  5898. fileSize = _yield$Promise$all2[1];
  5899. creationDate = _yield$Promise$all2[2];
  5900. modificationDate = _yield$Promise$all2[3];
  5901. pageSize = _yield$Promise$all2[4];
  5902. isLinearized = _yield$Promise$all2[5];
  5903. freezeFieldData({
  5904. fileName: fileName,
  5905. fileSize: fileSize,
  5906. title: info.Title,
  5907. author: info.Author,
  5908. subject: info.Subject,
  5909. keywords: info.Keywords,
  5910. creationDate: creationDate,
  5911. modificationDate: modificationDate,
  5912. creator: info.Creator,
  5913. producer: info.Producer,
  5914. version: info.PDFFormatVersion,
  5915. pageCount: this.pdfDocument.numPages,
  5916. pageSize: pageSize,
  5917. linearized: isLinearized,
  5918. _currentPageNumber: currentPageNumber,
  5919. _pagesRotation: pagesRotation
  5920. });
  5921. this._updateUI();
  5922. _context.next = 28;
  5923. return this.pdfDocument.getDownloadInfo();
  5924. case 28:
  5925. _yield$this$pdfDocume2 = _context.sent;
  5926. length = _yield$this$pdfDocume2.length;
  5927. if (!(contentLength === length)) {
  5928. _context.next = 32;
  5929. break;
  5930. }
  5931. return _context.abrupt("return");
  5932. case 32:
  5933. data = Object.assign(Object.create(null), this.fieldData);
  5934. _context.next = 35;
  5935. return this._parseFileSize(length);
  5936. case 35:
  5937. data.fileSize = _context.sent;
  5938. freezeFieldData(data);
  5939. this._updateUI();
  5940. case 38:
  5941. case "end":
  5942. return _context.stop();
  5943. }
  5944. }
  5945. }, _callee, this);
  5946. }));
  5947. function open() {
  5948. return _open.apply(this, arguments);
  5949. }
  5950. return open;
  5951. }()
  5952. }, {
  5953. key: "close",
  5954. value: function close() {
  5955. this.overlayManager.close(this.overlayName);
  5956. }
  5957. }, {
  5958. key: "setDocument",
  5959. value: function setDocument(pdfDocument) {
  5960. var url = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  5961. if (this.pdfDocument) {
  5962. this._reset();
  5963. this._updateUI(true);
  5964. }
  5965. if (!pdfDocument) {
  5966. return;
  5967. }
  5968. this.pdfDocument = pdfDocument;
  5969. this.url = url;
  5970. this._dataAvailableCapability.resolve();
  5971. }
  5972. }, {
  5973. key: "_reset",
  5974. value: function _reset() {
  5975. this.pdfDocument = null;
  5976. this.url = null;
  5977. delete this.fieldData;
  5978. this._dataAvailableCapability = (0, _pdfjsLib.createPromiseCapability)();
  5979. this._currentPageNumber = 1;
  5980. this._pagesRotation = 0;
  5981. }
  5982. }, {
  5983. key: "_updateUI",
  5984. value: function _updateUI() {
  5985. var reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5986. if (reset || !this.fieldData) {
  5987. for (var id in this.fields) {
  5988. this.fields[id].textContent = DEFAULT_FIELD_CONTENT;
  5989. }
  5990. return;
  5991. }
  5992. if (this.overlayManager.active !== this.overlayName) {
  5993. return;
  5994. }
  5995. for (var _id in this.fields) {
  5996. var content = this.fieldData[_id];
  5997. this.fields[_id].textContent = content || content === 0 ? content : DEFAULT_FIELD_CONTENT;
  5998. }
  5999. }
  6000. }, {
  6001. key: "_parseFileSize",
  6002. value: function () {
  6003. var _parseFileSize2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  6004. var fileSize,
  6005. kb,
  6006. _args2 = arguments;
  6007. return _regenerator["default"].wrap(function _callee2$(_context2) {
  6008. while (1) {
  6009. switch (_context2.prev = _context2.next) {
  6010. case 0:
  6011. fileSize = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : 0;
  6012. kb = fileSize / 1024;
  6013. if (kb) {
  6014. _context2.next = 6;
  6015. break;
  6016. }
  6017. return _context2.abrupt("return", undefined);
  6018. case 6:
  6019. if (!(kb < 1024)) {
  6020. _context2.next = 8;
  6021. break;
  6022. }
  6023. return _context2.abrupt("return", this.l10n.get("document_properties_kb", {
  6024. size_kb: (+kb.toPrecision(3)).toLocaleString(),
  6025. size_b: fileSize.toLocaleString()
  6026. }, "{{size_kb}} KB ({{size_b}} bytes)"));
  6027. case 8:
  6028. return _context2.abrupt("return", this.l10n.get("document_properties_mb", {
  6029. size_mb: (+(kb / 1024).toPrecision(3)).toLocaleString(),
  6030. size_b: fileSize.toLocaleString()
  6031. }, "{{size_mb}} MB ({{size_b}} bytes)"));
  6032. case 9:
  6033. case "end":
  6034. return _context2.stop();
  6035. }
  6036. }
  6037. }, _callee2, this);
  6038. }));
  6039. function _parseFileSize() {
  6040. return _parseFileSize2.apply(this, arguments);
  6041. }
  6042. return _parseFileSize;
  6043. }()
  6044. }, {
  6045. key: "_parsePageSize",
  6046. value: function () {
  6047. var _parsePageSize2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(pageSizeInches, pagesRotation) {
  6048. var _this3 = this;
  6049. var isPortrait, sizeInches, sizeMillimeters, pageName, rawName, exactMillimeters, intMillimeters;
  6050. return _regenerator["default"].wrap(function _callee3$(_context3) {
  6051. while (1) {
  6052. switch (_context3.prev = _context3.next) {
  6053. case 0:
  6054. if (pageSizeInches) {
  6055. _context3.next = 2;
  6056. break;
  6057. }
  6058. return _context3.abrupt("return", undefined);
  6059. case 2:
  6060. if (pagesRotation % 180 !== 0) {
  6061. pageSizeInches = {
  6062. width: pageSizeInches.height,
  6063. height: pageSizeInches.width
  6064. };
  6065. }
  6066. isPortrait = (0, _ui_utils.isPortraitOrientation)(pageSizeInches);
  6067. sizeInches = {
  6068. width: Math.round(pageSizeInches.width * 100) / 100,
  6069. height: Math.round(pageSizeInches.height * 100) / 100
  6070. };
  6071. sizeMillimeters = {
  6072. width: Math.round(pageSizeInches.width * 25.4 * 10) / 10,
  6073. height: Math.round(pageSizeInches.height * 25.4 * 10) / 10
  6074. };
  6075. pageName = null;
  6076. rawName = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES);
  6077. if (!rawName && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(sizeMillimeters.height))) {
  6078. exactMillimeters = {
  6079. width: pageSizeInches.width * 25.4,
  6080. height: pageSizeInches.height * 25.4
  6081. };
  6082. intMillimeters = {
  6083. width: Math.round(sizeMillimeters.width),
  6084. height: Math.round(sizeMillimeters.height)
  6085. };
  6086. if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) {
  6087. rawName = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES);
  6088. if (rawName) {
  6089. sizeInches = {
  6090. width: Math.round(intMillimeters.width / 25.4 * 100) / 100,
  6091. height: Math.round(intMillimeters.height / 25.4 * 100) / 100
  6092. };
  6093. sizeMillimeters = intMillimeters;
  6094. }
  6095. }
  6096. }
  6097. if (rawName) {
  6098. pageName = this.l10n.get("document_properties_page_size_name_" + rawName.toLowerCase(), null, rawName);
  6099. }
  6100. return _context3.abrupt("return", Promise.all([this._isNonMetricLocale ? sizeInches : sizeMillimeters, this.l10n.get("document_properties_page_size_unit_" + (this._isNonMetricLocale ? "inches" : "millimeters"), null, this._isNonMetricLocale ? "in" : "mm"), pageName, this.l10n.get("document_properties_page_size_orientation_" + (isPortrait ? "portrait" : "landscape"), null, isPortrait ? "portrait" : "landscape")]).then(function (_ref2) {
  6101. var _ref3 = _slicedToArray(_ref2, 4),
  6102. _ref3$ = _ref3[0],
  6103. width = _ref3$.width,
  6104. height = _ref3$.height,
  6105. unit = _ref3[1],
  6106. name = _ref3[2],
  6107. orientation = _ref3[3];
  6108. return _this3.l10n.get("document_properties_page_size_dimension_" + (name ? "name_" : "") + "string", {
  6109. width: width.toLocaleString(),
  6110. height: height.toLocaleString(),
  6111. unit: unit,
  6112. name: name,
  6113. orientation: orientation
  6114. }, "{{width}} × {{height}} {{unit}} (" + (name ? "{{name}}, " : "") + "{{orientation}})");
  6115. }));
  6116. case 11:
  6117. case "end":
  6118. return _context3.stop();
  6119. }
  6120. }
  6121. }, _callee3, this);
  6122. }));
  6123. function _parsePageSize(_x, _x2) {
  6124. return _parsePageSize2.apply(this, arguments);
  6125. }
  6126. return _parsePageSize;
  6127. }()
  6128. }, {
  6129. key: "_parseDate",
  6130. value: function () {
  6131. var _parseDate2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(inputDate) {
  6132. var dateObject;
  6133. return _regenerator["default"].wrap(function _callee4$(_context4) {
  6134. while (1) {
  6135. switch (_context4.prev = _context4.next) {
  6136. case 0:
  6137. dateObject = _pdfjsLib.PDFDateString.toDateObject(inputDate);
  6138. if (dateObject) {
  6139. _context4.next = 3;
  6140. break;
  6141. }
  6142. return _context4.abrupt("return", undefined);
  6143. case 3:
  6144. return _context4.abrupt("return", this.l10n.get("document_properties_date_string", {
  6145. date: dateObject.toLocaleDateString(),
  6146. time: dateObject.toLocaleTimeString()
  6147. }, "{{date}}, {{time}}"));
  6148. case 4:
  6149. case "end":
  6150. return _context4.stop();
  6151. }
  6152. }
  6153. }, _callee4, this);
  6154. }));
  6155. function _parseDate(_x3) {
  6156. return _parseDate2.apply(this, arguments);
  6157. }
  6158. return _parseDate;
  6159. }()
  6160. }, {
  6161. key: "_parseLinearization",
  6162. value: function _parseLinearization(isLinearized) {
  6163. return this.l10n.get("document_properties_linearized_" + (isLinearized ? "yes" : "no"), null, isLinearized ? "Yes" : "No");
  6164. }
  6165. }]);
  6166. return PDFDocumentProperties;
  6167. }();
  6168. exports.PDFDocumentProperties = PDFDocumentProperties;
  6169. /***/ }),
  6170. /* 16 */
  6171. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6172. Object.defineProperty(exports, "__esModule", ({
  6173. value: true
  6174. }));
  6175. exports.PDFFindBar = void 0;
  6176. var _pdf_find_controller = __webpack_require__(17);
  6177. var _ui_utils = __webpack_require__(6);
  6178. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6179. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  6180. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6181. var MATCHES_COUNT_LIMIT = 1000;
  6182. var PDFFindBar = /*#__PURE__*/function () {
  6183. function PDFFindBar(options, eventBus) {
  6184. var _this = this;
  6185. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  6186. _classCallCheck(this, PDFFindBar);
  6187. this.opened = false;
  6188. this.bar = options.bar || null;
  6189. this.toggleButton = options.toggleButton || null;
  6190. this.findField = options.findField || null;
  6191. this.highlightAll = options.highlightAllCheckbox || null;
  6192. this.caseSensitive = options.caseSensitiveCheckbox || null;
  6193. this.entireWord = options.entireWordCheckbox || null;
  6194. this.findMsg = options.findMsg || null;
  6195. this.findResultsCount = options.findResultsCount || null;
  6196. this.findPreviousButton = options.findPreviousButton || null;
  6197. this.findNextButton = options.findNextButton || null;
  6198. this.eventBus = eventBus;
  6199. this.l10n = l10n;
  6200. this.toggleButton.addEventListener("click", function () {
  6201. _this.toggle();
  6202. });
  6203. this.findField.addEventListener("input", function () {
  6204. _this.dispatchEvent("");
  6205. });
  6206. this.bar.addEventListener("keydown", function (e) {
  6207. switch (e.keyCode) {
  6208. case 13:
  6209. if (e.target === _this.findField) {
  6210. _this.dispatchEvent("again", e.shiftKey);
  6211. }
  6212. break;
  6213. case 27:
  6214. _this.close();
  6215. break;
  6216. }
  6217. });
  6218. this.findPreviousButton.addEventListener("click", function () {
  6219. _this.dispatchEvent("again", true);
  6220. });
  6221. this.findNextButton.addEventListener("click", function () {
  6222. _this.dispatchEvent("again", false);
  6223. });
  6224. this.highlightAll.addEventListener("click", function () {
  6225. _this.dispatchEvent("highlightallchange");
  6226. });
  6227. this.caseSensitive.addEventListener("click", function () {
  6228. _this.dispatchEvent("casesensitivitychange");
  6229. });
  6230. this.entireWord.addEventListener("click", function () {
  6231. _this.dispatchEvent("entirewordchange");
  6232. });
  6233. this.eventBus._on("resize", this._adjustWidth.bind(this));
  6234. }
  6235. _createClass(PDFFindBar, [{
  6236. key: "reset",
  6237. value: function reset() {
  6238. this.updateUIState();
  6239. }
  6240. }, {
  6241. key: "dispatchEvent",
  6242. value: function dispatchEvent(type, findPrev) {
  6243. this.eventBus.dispatch("find", {
  6244. source: this,
  6245. type: type,
  6246. query: this.findField.value,
  6247. phraseSearch: true,
  6248. caseSensitive: this.caseSensitive.checked,
  6249. entireWord: this.entireWord.checked,
  6250. highlightAll: this.highlightAll.checked,
  6251. findPrevious: findPrev
  6252. });
  6253. }
  6254. }, {
  6255. key: "updateUIState",
  6256. value: function updateUIState(state, previous, matchesCount) {
  6257. var _this2 = this;
  6258. var findMsg = "";
  6259. var status = "";
  6260. switch (state) {
  6261. case _pdf_find_controller.FindState.FOUND:
  6262. break;
  6263. case _pdf_find_controller.FindState.PENDING:
  6264. status = "pending";
  6265. break;
  6266. case _pdf_find_controller.FindState.NOT_FOUND:
  6267. findMsg = this.l10n.get("find_not_found", null, "Phrase not found");
  6268. status = "notFound";
  6269. break;
  6270. case _pdf_find_controller.FindState.WRAPPED:
  6271. if (previous) {
  6272. findMsg = this.l10n.get("find_reached_top", null, "Reached top of document, continued from bottom");
  6273. } else {
  6274. findMsg = this.l10n.get("find_reached_bottom", null, "Reached end of document, continued from top");
  6275. }
  6276. break;
  6277. }
  6278. this.findField.setAttribute("data-status", status);
  6279. Promise.resolve(findMsg).then(function (msg) {
  6280. _this2.findMsg.textContent = msg;
  6281. _this2._adjustWidth();
  6282. });
  6283. this.updateResultsCount(matchesCount);
  6284. }
  6285. }, {
  6286. key: "updateResultsCount",
  6287. value: function updateResultsCount() {
  6288. var _this3 = this;
  6289. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  6290. _ref$current = _ref.current,
  6291. current = _ref$current === void 0 ? 0 : _ref$current,
  6292. _ref$total = _ref.total,
  6293. total = _ref$total === void 0 ? 0 : _ref$total;
  6294. if (!this.findResultsCount) {
  6295. return;
  6296. }
  6297. var limit = MATCHES_COUNT_LIMIT;
  6298. var matchesCountMsg = "";
  6299. if (total > 0) {
  6300. if (total > limit) {
  6301. matchesCountMsg = this.l10n.get("find_match_count_limit", {
  6302. limit: limit
  6303. }, "More than {{limit}} match" + (limit !== 1 ? "es" : ""));
  6304. } else {
  6305. matchesCountMsg = this.l10n.get("find_match_count", {
  6306. current: current,
  6307. total: total
  6308. }, "{{current}} of {{total}} match" + (total !== 1 ? "es" : ""));
  6309. }
  6310. }
  6311. Promise.resolve(matchesCountMsg).then(function (msg) {
  6312. _this3.findResultsCount.textContent = msg;
  6313. _this3.findResultsCount.classList.toggle("hidden", !total);
  6314. _this3._adjustWidth();
  6315. });
  6316. }
  6317. }, {
  6318. key: "open",
  6319. value: function open() {
  6320. if (!this.opened) {
  6321. this.opened = true;
  6322. this.toggleButton.classList.add("toggled");
  6323. this.bar.classList.remove("hidden");
  6324. }
  6325. this.findField.select();
  6326. this.findField.focus();
  6327. this._adjustWidth();
  6328. }
  6329. }, {
  6330. key: "close",
  6331. value: function close() {
  6332. if (!this.opened) {
  6333. return;
  6334. }
  6335. this.opened = false;
  6336. this.toggleButton.classList.remove("toggled");
  6337. this.bar.classList.add("hidden");
  6338. this.eventBus.dispatch("findbarclose", {
  6339. source: this
  6340. });
  6341. }
  6342. }, {
  6343. key: "toggle",
  6344. value: function toggle() {
  6345. if (this.opened) {
  6346. this.close();
  6347. } else {
  6348. this.open();
  6349. }
  6350. }
  6351. }, {
  6352. key: "_adjustWidth",
  6353. value: function _adjustWidth() {
  6354. if (!this.opened) {
  6355. return;
  6356. }
  6357. this.bar.classList.remove("wrapContainers");
  6358. var findbarHeight = this.bar.clientHeight;
  6359. var inputContainerHeight = this.bar.firstElementChild.clientHeight;
  6360. if (findbarHeight > inputContainerHeight) {
  6361. this.bar.classList.add("wrapContainers");
  6362. }
  6363. }
  6364. }]);
  6365. return PDFFindBar;
  6366. }();
  6367. exports.PDFFindBar = PDFFindBar;
  6368. /***/ }),
  6369. /* 17 */
  6370. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6371. Object.defineProperty(exports, "__esModule", ({
  6372. value: true
  6373. }));
  6374. exports.PDFFindController = exports.FindState = void 0;
  6375. var _pdfjsLib = __webpack_require__(7);
  6376. var _pdf_find_utils = __webpack_require__(18);
  6377. var _ui_utils = __webpack_require__(6);
  6378. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6379. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  6380. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6381. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  6382. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  6383. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  6384. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  6385. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  6386. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  6387. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  6388. var FindState = {
  6389. FOUND: 0,
  6390. NOT_FOUND: 1,
  6391. WRAPPED: 2,
  6392. PENDING: 3
  6393. };
  6394. exports.FindState = FindState;
  6395. var FIND_TIMEOUT = 250;
  6396. var MATCH_SCROLL_OFFSET_TOP = -50;
  6397. var MATCH_SCROLL_OFFSET_LEFT = -400;
  6398. var CHARACTERS_TO_NORMALIZE = {
  6399. "\u2018": "'",
  6400. "\u2019": "'",
  6401. "\u201A": "'",
  6402. "\u201B": "'",
  6403. "\u201C": '"',
  6404. "\u201D": '"',
  6405. "\u201E": '"',
  6406. "\u201F": '"',
  6407. "\xBC": "1/4",
  6408. "\xBD": "1/2",
  6409. "\xBE": "3/4"
  6410. };
  6411. var normalizationRegex = null;
  6412. function normalize(text) {
  6413. if (!normalizationRegex) {
  6414. var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join("");
  6415. normalizationRegex = new RegExp("[".concat(replace, "]"), "g");
  6416. }
  6417. var diffs = null;
  6418. var normalizedText = text.replace(normalizationRegex, function (ch, index) {
  6419. var normalizedCh = CHARACTERS_TO_NORMALIZE[ch],
  6420. diff = normalizedCh.length - ch.length;
  6421. if (diff !== 0) {
  6422. (diffs || (diffs = [])).push([index, diff]);
  6423. }
  6424. return normalizedCh;
  6425. });
  6426. return [normalizedText, diffs];
  6427. }
  6428. function getOriginalIndex(matchIndex) {
  6429. var diffs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  6430. if (!diffs) {
  6431. return matchIndex;
  6432. }
  6433. var totalDiff = 0;
  6434. var _iterator = _createForOfIteratorHelper(diffs),
  6435. _step;
  6436. try {
  6437. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  6438. var _step$value = _slicedToArray(_step.value, 2),
  6439. index = _step$value[0],
  6440. diff = _step$value[1];
  6441. var currentIndex = index + totalDiff;
  6442. if (currentIndex >= matchIndex) {
  6443. break;
  6444. }
  6445. if (currentIndex + diff > matchIndex) {
  6446. totalDiff += matchIndex - currentIndex;
  6447. break;
  6448. }
  6449. totalDiff += diff;
  6450. }
  6451. } catch (err) {
  6452. _iterator.e(err);
  6453. } finally {
  6454. _iterator.f();
  6455. }
  6456. return matchIndex - totalDiff;
  6457. }
  6458. var PDFFindController = /*#__PURE__*/function () {
  6459. function PDFFindController(_ref) {
  6460. var linkService = _ref.linkService,
  6461. eventBus = _ref.eventBus;
  6462. _classCallCheck(this, PDFFindController);
  6463. this._linkService = linkService;
  6464. this._eventBus = eventBus;
  6465. this._reset();
  6466. eventBus._on("findbarclose", this._onFindBarClose.bind(this));
  6467. }
  6468. _createClass(PDFFindController, [{
  6469. key: "setDocument",
  6470. value: function setDocument(pdfDocument) {
  6471. if (this._pdfDocument) {
  6472. this._reset();
  6473. }
  6474. if (!pdfDocument) {
  6475. return;
  6476. }
  6477. this._pdfDocument = pdfDocument;
  6478. this._firstPageCapability.resolve();
  6479. }
  6480. }, {
  6481. key: "executeCommand",
  6482. value: function executeCommand(cmd, state) {
  6483. var _this = this;
  6484. if (!state) {
  6485. return;
  6486. }
  6487. var pdfDocument = this._pdfDocument;
  6488. if (this._state === null || this._shouldDirtyMatch(cmd, state)) {
  6489. this._dirtyMatch = true;
  6490. }
  6491. this._state = state;
  6492. if (cmd !== "findhighlightallchange") {
  6493. this._updateUIState(FindState.PENDING);
  6494. }
  6495. this._firstPageCapability.promise.then(function () {
  6496. if (!_this._pdfDocument || pdfDocument && _this._pdfDocument !== pdfDocument) {
  6497. return;
  6498. }
  6499. _this._extractText();
  6500. var findbarClosed = !_this._highlightMatches;
  6501. var pendingTimeout = !!_this._findTimeout;
  6502. if (_this._findTimeout) {
  6503. clearTimeout(_this._findTimeout);
  6504. _this._findTimeout = null;
  6505. }
  6506. if (cmd === "find") {
  6507. _this._findTimeout = setTimeout(function () {
  6508. _this._nextMatch();
  6509. _this._findTimeout = null;
  6510. }, FIND_TIMEOUT);
  6511. } else if (_this._dirtyMatch) {
  6512. _this._nextMatch();
  6513. } else if (cmd === "findagain") {
  6514. _this._nextMatch();
  6515. if (findbarClosed && _this._state.highlightAll) {
  6516. _this._updateAllPages();
  6517. }
  6518. } else if (cmd === "findhighlightallchange") {
  6519. if (pendingTimeout) {
  6520. _this._nextMatch();
  6521. } else {
  6522. _this._highlightMatches = true;
  6523. }
  6524. _this._updateAllPages();
  6525. } else {
  6526. _this._nextMatch();
  6527. }
  6528. });
  6529. }
  6530. }, {
  6531. key: "scrollMatchIntoView",
  6532. value: function scrollMatchIntoView(_ref2) {
  6533. var _ref2$element = _ref2.element,
  6534. element = _ref2$element === void 0 ? null : _ref2$element,
  6535. _ref2$pageIndex = _ref2.pageIndex,
  6536. pageIndex = _ref2$pageIndex === void 0 ? -1 : _ref2$pageIndex,
  6537. _ref2$matchIndex = _ref2.matchIndex,
  6538. matchIndex = _ref2$matchIndex === void 0 ? -1 : _ref2$matchIndex;
  6539. if (!this._scrollMatches || !element) {
  6540. return;
  6541. } else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) {
  6542. return;
  6543. } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) {
  6544. return;
  6545. }
  6546. this._scrollMatches = false;
  6547. var spot = {
  6548. top: MATCH_SCROLL_OFFSET_TOP,
  6549. left: MATCH_SCROLL_OFFSET_LEFT
  6550. };
  6551. (0, _ui_utils.scrollIntoView)(element, spot, true);
  6552. }
  6553. }, {
  6554. key: "_reset",
  6555. value: function _reset() {
  6556. this._highlightMatches = false;
  6557. this._scrollMatches = false;
  6558. this._pdfDocument = null;
  6559. this._pageMatches = [];
  6560. this._pageMatchesLength = [];
  6561. this._state = null;
  6562. this._selected = {
  6563. pageIdx: -1,
  6564. matchIdx: -1
  6565. };
  6566. this._offset = {
  6567. pageIdx: null,
  6568. matchIdx: null,
  6569. wrapped: false
  6570. };
  6571. this._extractTextPromises = [];
  6572. this._pageContents = [];
  6573. this._pageDiffs = [];
  6574. this._matchesCountTotal = 0;
  6575. this._pagesToSearch = null;
  6576. this._pendingFindMatches = Object.create(null);
  6577. this._resumePageIdx = null;
  6578. this._dirtyMatch = false;
  6579. clearTimeout(this._findTimeout);
  6580. this._findTimeout = null;
  6581. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  6582. }
  6583. }, {
  6584. key: "_shouldDirtyMatch",
  6585. value: function _shouldDirtyMatch(cmd, state) {
  6586. if (state.query !== this._state.query) {
  6587. return true;
  6588. }
  6589. switch (cmd) {
  6590. case "findagain":
  6591. var pageNumber = this._selected.pageIdx + 1;
  6592. var linkService = this._linkService;
  6593. if (pageNumber >= 1 && pageNumber <= linkService.pagesCount && pageNumber !== linkService.page && !linkService.isPageVisible(pageNumber)) {
  6594. return true;
  6595. }
  6596. return false;
  6597. case "findhighlightallchange":
  6598. return false;
  6599. }
  6600. return true;
  6601. }
  6602. }, {
  6603. key: "_prepareMatches",
  6604. value: function _prepareMatches(matchesWithLength, matches, matchesLength) {
  6605. function isSubTerm(currentIndex) {
  6606. var currentElem = matchesWithLength[currentIndex];
  6607. var nextElem = matchesWithLength[currentIndex + 1];
  6608. if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {
  6609. currentElem.skipped = true;
  6610. return true;
  6611. }
  6612. for (var i = currentIndex - 1; i >= 0; i--) {
  6613. var prevElem = matchesWithLength[i];
  6614. if (prevElem.skipped) {
  6615. continue;
  6616. }
  6617. if (prevElem.match + prevElem.matchLength < currentElem.match) {
  6618. break;
  6619. }
  6620. if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {
  6621. currentElem.skipped = true;
  6622. return true;
  6623. }
  6624. }
  6625. return false;
  6626. }
  6627. matchesWithLength.sort(function (a, b) {
  6628. return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match;
  6629. });
  6630. for (var i = 0, len = matchesWithLength.length; i < len; i++) {
  6631. if (isSubTerm(i)) {
  6632. continue;
  6633. }
  6634. matches.push(matchesWithLength[i].match);
  6635. matchesLength.push(matchesWithLength[i].matchLength);
  6636. }
  6637. }
  6638. }, {
  6639. key: "_isEntireWord",
  6640. value: function _isEntireWord(content, startIdx, length) {
  6641. if (startIdx > 0) {
  6642. var first = content.charCodeAt(startIdx);
  6643. var limit = content.charCodeAt(startIdx - 1);
  6644. if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils.getCharacterType)(limit)) {
  6645. return false;
  6646. }
  6647. }
  6648. var endIdx = startIdx + length - 1;
  6649. if (endIdx < content.length - 1) {
  6650. var last = content.charCodeAt(endIdx);
  6651. var _limit = content.charCodeAt(endIdx + 1);
  6652. if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils.getCharacterType)(_limit)) {
  6653. return false;
  6654. }
  6655. }
  6656. return true;
  6657. }
  6658. }, {
  6659. key: "_calculatePhraseMatch",
  6660. value: function _calculatePhraseMatch(query, pageIndex, pageContent, pageDiffs, entireWord) {
  6661. var matches = [],
  6662. matchesLength = [];
  6663. var queryLen = query.length;
  6664. var matchIdx = -queryLen;
  6665. while (true) {
  6666. matchIdx = pageContent.indexOf(query, matchIdx + queryLen);
  6667. if (matchIdx === -1) {
  6668. break;
  6669. }
  6670. if (entireWord && !this._isEntireWord(pageContent, matchIdx, queryLen)) {
  6671. continue;
  6672. }
  6673. var originalMatchIdx = getOriginalIndex(matchIdx, pageDiffs),
  6674. matchEnd = matchIdx + queryLen - 1,
  6675. originalQueryLen = getOriginalIndex(matchEnd, pageDiffs) - originalMatchIdx + 1;
  6676. matches.push(originalMatchIdx);
  6677. matchesLength.push(originalQueryLen);
  6678. }
  6679. this._pageMatches[pageIndex] = matches;
  6680. this._pageMatchesLength[pageIndex] = matchesLength;
  6681. }
  6682. }, {
  6683. key: "_calculateWordMatch",
  6684. value: function _calculateWordMatch(query, pageIndex, pageContent, pageDiffs, entireWord) {
  6685. var matchesWithLength = [];
  6686. var queryArray = query.match(/\S+/g);
  6687. for (var i = 0, len = queryArray.length; i < len; i++) {
  6688. var subquery = queryArray[i];
  6689. var subqueryLen = subquery.length;
  6690. var matchIdx = -subqueryLen;
  6691. while (true) {
  6692. matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen);
  6693. if (matchIdx === -1) {
  6694. break;
  6695. }
  6696. if (entireWord && !this._isEntireWord(pageContent, matchIdx, subqueryLen)) {
  6697. continue;
  6698. }
  6699. var originalMatchIdx = getOriginalIndex(matchIdx, pageDiffs),
  6700. matchEnd = matchIdx + subqueryLen - 1,
  6701. originalQueryLen = getOriginalIndex(matchEnd, pageDiffs) - originalMatchIdx + 1;
  6702. matchesWithLength.push({
  6703. match: originalMatchIdx,
  6704. matchLength: originalQueryLen,
  6705. skipped: false
  6706. });
  6707. }
  6708. }
  6709. this._pageMatchesLength[pageIndex] = [];
  6710. this._pageMatches[pageIndex] = [];
  6711. this._prepareMatches(matchesWithLength, this._pageMatches[pageIndex], this._pageMatchesLength[pageIndex]);
  6712. }
  6713. }, {
  6714. key: "_calculateMatch",
  6715. value: function _calculateMatch(pageIndex) {
  6716. var pageContent = this._pageContents[pageIndex];
  6717. var pageDiffs = this._pageDiffs[pageIndex];
  6718. var query = this._query;
  6719. var _this$_state = this._state,
  6720. caseSensitive = _this$_state.caseSensitive,
  6721. entireWord = _this$_state.entireWord,
  6722. phraseSearch = _this$_state.phraseSearch;
  6723. if (query.length === 0) {
  6724. return;
  6725. }
  6726. if (!caseSensitive) {
  6727. pageContent = pageContent.toLowerCase();
  6728. query = query.toLowerCase();
  6729. }
  6730. if (phraseSearch) {
  6731. this._calculatePhraseMatch(query, pageIndex, pageContent, pageDiffs, entireWord);
  6732. } else {
  6733. this._calculateWordMatch(query, pageIndex, pageContent, pageDiffs, entireWord);
  6734. }
  6735. if (this._state.highlightAll) {
  6736. this._updatePage(pageIndex);
  6737. }
  6738. if (this._resumePageIdx === pageIndex) {
  6739. this._resumePageIdx = null;
  6740. this._nextPageMatch();
  6741. }
  6742. var pageMatchesCount = this._pageMatches[pageIndex].length;
  6743. if (pageMatchesCount > 0) {
  6744. this._matchesCountTotal += pageMatchesCount;
  6745. this._updateUIResultsCount();
  6746. }
  6747. }
  6748. }, {
  6749. key: "_extractText",
  6750. value: function _extractText() {
  6751. var _this2 = this;
  6752. if (this._extractTextPromises.length > 0) {
  6753. return;
  6754. }
  6755. var promise = Promise.resolve();
  6756. var _loop = function _loop(i, ii) {
  6757. var extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
  6758. _this2._extractTextPromises[i] = extractTextCapability.promise;
  6759. promise = promise.then(function () {
  6760. return _this2._pdfDocument.getPage(i + 1).then(function (pdfPage) {
  6761. return pdfPage.getTextContent({
  6762. normalizeWhitespace: true
  6763. });
  6764. }).then(function (textContent) {
  6765. var textItems = textContent.items;
  6766. var strBuf = [];
  6767. for (var j = 0, jj = textItems.length; j < jj; j++) {
  6768. strBuf.push(textItems[j].str);
  6769. }
  6770. var _normalize = normalize(strBuf.join(""));
  6771. var _normalize2 = _slicedToArray(_normalize, 2);
  6772. _this2._pageContents[i] = _normalize2[0];
  6773. _this2._pageDiffs[i] = _normalize2[1];
  6774. extractTextCapability.resolve(i);
  6775. }, function (reason) {
  6776. console.error("Unable to get text content for page ".concat(i + 1), reason);
  6777. _this2._pageContents[i] = "";
  6778. _this2._pageDiffs[i] = null;
  6779. extractTextCapability.resolve(i);
  6780. });
  6781. });
  6782. };
  6783. for (var i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
  6784. _loop(i, ii);
  6785. }
  6786. }
  6787. }, {
  6788. key: "_updatePage",
  6789. value: function _updatePage(index) {
  6790. if (this._scrollMatches && this._selected.pageIdx === index) {
  6791. this._linkService.page = index + 1;
  6792. }
  6793. this._eventBus.dispatch("updatetextlayermatches", {
  6794. source: this,
  6795. pageIndex: index
  6796. });
  6797. }
  6798. }, {
  6799. key: "_updateAllPages",
  6800. value: function _updateAllPages() {
  6801. this._eventBus.dispatch("updatetextlayermatches", {
  6802. source: this,
  6803. pageIndex: -1
  6804. });
  6805. }
  6806. }, {
  6807. key: "_nextMatch",
  6808. value: function _nextMatch() {
  6809. var _this3 = this;
  6810. var previous = this._state.findPrevious;
  6811. var currentPageIndex = this._linkService.page - 1;
  6812. var numPages = this._linkService.pagesCount;
  6813. this._highlightMatches = true;
  6814. if (this._dirtyMatch) {
  6815. this._dirtyMatch = false;
  6816. this._selected.pageIdx = this._selected.matchIdx = -1;
  6817. this._offset.pageIdx = currentPageIndex;
  6818. this._offset.matchIdx = null;
  6819. this._offset.wrapped = false;
  6820. this._resumePageIdx = null;
  6821. this._pageMatches.length = 0;
  6822. this._pageMatchesLength.length = 0;
  6823. this._matchesCountTotal = 0;
  6824. this._updateAllPages();
  6825. for (var i = 0; i < numPages; i++) {
  6826. if (this._pendingFindMatches[i] === true) {
  6827. continue;
  6828. }
  6829. this._pendingFindMatches[i] = true;
  6830. this._extractTextPromises[i].then(function (pageIdx) {
  6831. delete _this3._pendingFindMatches[pageIdx];
  6832. _this3._calculateMatch(pageIdx);
  6833. });
  6834. }
  6835. }
  6836. if (this._query === "") {
  6837. this._updateUIState(FindState.FOUND);
  6838. return;
  6839. }
  6840. if (this._resumePageIdx) {
  6841. return;
  6842. }
  6843. var offset = this._offset;
  6844. this._pagesToSearch = numPages;
  6845. if (offset.matchIdx !== null) {
  6846. var numPageMatches = this._pageMatches[offset.pageIdx].length;
  6847. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  6848. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  6849. this._updateMatch(true);
  6850. return;
  6851. }
  6852. this._advanceOffsetPage(previous);
  6853. }
  6854. this._nextPageMatch();
  6855. }
  6856. }, {
  6857. key: "_matchesReady",
  6858. value: function _matchesReady(matches) {
  6859. var offset = this._offset;
  6860. var numMatches = matches.length;
  6861. var previous = this._state.findPrevious;
  6862. if (numMatches) {
  6863. offset.matchIdx = previous ? numMatches - 1 : 0;
  6864. this._updateMatch(true);
  6865. return true;
  6866. }
  6867. this._advanceOffsetPage(previous);
  6868. if (offset.wrapped) {
  6869. offset.matchIdx = null;
  6870. if (this._pagesToSearch < 0) {
  6871. this._updateMatch(false);
  6872. return true;
  6873. }
  6874. }
  6875. return false;
  6876. }
  6877. }, {
  6878. key: "_nextPageMatch",
  6879. value: function _nextPageMatch() {
  6880. if (this._resumePageIdx !== null) {
  6881. console.error("There can only be one pending page.");
  6882. }
  6883. var matches = null;
  6884. do {
  6885. var pageIdx = this._offset.pageIdx;
  6886. matches = this._pageMatches[pageIdx];
  6887. if (!matches) {
  6888. this._resumePageIdx = pageIdx;
  6889. break;
  6890. }
  6891. } while (!this._matchesReady(matches));
  6892. }
  6893. }, {
  6894. key: "_advanceOffsetPage",
  6895. value: function _advanceOffsetPage(previous) {
  6896. var offset = this._offset;
  6897. var numPages = this._linkService.pagesCount;
  6898. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  6899. offset.matchIdx = null;
  6900. this._pagesToSearch--;
  6901. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  6902. offset.pageIdx = previous ? numPages - 1 : 0;
  6903. offset.wrapped = true;
  6904. }
  6905. }
  6906. }, {
  6907. key: "_updateMatch",
  6908. value: function _updateMatch() {
  6909. var found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6910. var state = FindState.NOT_FOUND;
  6911. var wrapped = this._offset.wrapped;
  6912. this._offset.wrapped = false;
  6913. if (found) {
  6914. var previousPage = this._selected.pageIdx;
  6915. this._selected.pageIdx = this._offset.pageIdx;
  6916. this._selected.matchIdx = this._offset.matchIdx;
  6917. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  6918. if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {
  6919. this._updatePage(previousPage);
  6920. }
  6921. }
  6922. this._updateUIState(state, this._state.findPrevious);
  6923. if (this._selected.pageIdx !== -1) {
  6924. this._scrollMatches = true;
  6925. this._updatePage(this._selected.pageIdx);
  6926. }
  6927. }
  6928. }, {
  6929. key: "_onFindBarClose",
  6930. value: function _onFindBarClose(evt) {
  6931. var _this4 = this;
  6932. var pdfDocument = this._pdfDocument;
  6933. this._firstPageCapability.promise.then(function () {
  6934. if (!_this4._pdfDocument || pdfDocument && _this4._pdfDocument !== pdfDocument) {
  6935. return;
  6936. }
  6937. if (_this4._findTimeout) {
  6938. clearTimeout(_this4._findTimeout);
  6939. _this4._findTimeout = null;
  6940. }
  6941. if (_this4._resumePageIdx) {
  6942. _this4._resumePageIdx = null;
  6943. _this4._dirtyMatch = true;
  6944. }
  6945. _this4._updateUIState(FindState.FOUND);
  6946. _this4._highlightMatches = false;
  6947. _this4._updateAllPages();
  6948. });
  6949. }
  6950. }, {
  6951. key: "_requestMatchesCount",
  6952. value: function _requestMatchesCount() {
  6953. var _this$_selected = this._selected,
  6954. pageIdx = _this$_selected.pageIdx,
  6955. matchIdx = _this$_selected.matchIdx;
  6956. var current = 0,
  6957. total = this._matchesCountTotal;
  6958. if (matchIdx !== -1) {
  6959. for (var i = 0; i < pageIdx; i++) {
  6960. current += this._pageMatches[i] && this._pageMatches[i].length || 0;
  6961. }
  6962. current += matchIdx + 1;
  6963. }
  6964. if (current < 1 || current > total) {
  6965. current = total = 0;
  6966. }
  6967. return {
  6968. current: current,
  6969. total: total
  6970. };
  6971. }
  6972. }, {
  6973. key: "_updateUIResultsCount",
  6974. value: function _updateUIResultsCount() {
  6975. this._eventBus.dispatch("updatefindmatchescount", {
  6976. source: this,
  6977. matchesCount: this._requestMatchesCount()
  6978. });
  6979. }
  6980. }, {
  6981. key: "_updateUIState",
  6982. value: function _updateUIState(state, previous) {
  6983. this._eventBus.dispatch("updatefindcontrolstate", {
  6984. source: this,
  6985. state: state,
  6986. previous: previous,
  6987. matchesCount: this._requestMatchesCount(),
  6988. rawQuery: this._state ? this._state.query : null
  6989. });
  6990. }
  6991. }, {
  6992. key: "highlightMatches",
  6993. get: function get() {
  6994. return this._highlightMatches;
  6995. }
  6996. }, {
  6997. key: "pageMatches",
  6998. get: function get() {
  6999. return this._pageMatches;
  7000. }
  7001. }, {
  7002. key: "pageMatchesLength",
  7003. get: function get() {
  7004. return this._pageMatchesLength;
  7005. }
  7006. }, {
  7007. key: "selected",
  7008. get: function get() {
  7009. return this._selected;
  7010. }
  7011. }, {
  7012. key: "state",
  7013. get: function get() {
  7014. return this._state;
  7015. }
  7016. }, {
  7017. key: "_query",
  7018. get: function get() {
  7019. if (this._state.query !== this._rawQuery) {
  7020. this._rawQuery = this._state.query;
  7021. var _normalize3 = normalize(this._state.query);
  7022. var _normalize4 = _slicedToArray(_normalize3, 1);
  7023. this._normalizedQuery = _normalize4[0];
  7024. }
  7025. return this._normalizedQuery;
  7026. }
  7027. }]);
  7028. return PDFFindController;
  7029. }();
  7030. exports.PDFFindController = PDFFindController;
  7031. /***/ }),
  7032. /* 18 */
  7033. /***/ ((__unused_webpack_module, exports) => {
  7034. Object.defineProperty(exports, "__esModule", ({
  7035. value: true
  7036. }));
  7037. exports.getCharacterType = getCharacterType;
  7038. exports.CharacterType = void 0;
  7039. var CharacterType = {
  7040. SPACE: 0,
  7041. ALPHA_LETTER: 1,
  7042. PUNCT: 2,
  7043. HAN_LETTER: 3,
  7044. KATAKANA_LETTER: 4,
  7045. HIRAGANA_LETTER: 5,
  7046. HALFWIDTH_KATAKANA_LETTER: 6,
  7047. THAI_LETTER: 7
  7048. };
  7049. exports.CharacterType = CharacterType;
  7050. function isAlphabeticalScript(charCode) {
  7051. return charCode < 0x2e80;
  7052. }
  7053. function isAscii(charCode) {
  7054. return (charCode & 0xff80) === 0;
  7055. }
  7056. function isAsciiAlpha(charCode) {
  7057. return charCode >= 0x61 && charCode <= 0x7a || charCode >= 0x41 && charCode <= 0x5a;
  7058. }
  7059. function isAsciiDigit(charCode) {
  7060. return charCode >= 0x30 && charCode <= 0x39;
  7061. }
  7062. function isAsciiSpace(charCode) {
  7063. return charCode === 0x20 || charCode === 0x09 || charCode === 0x0d || charCode === 0x0a;
  7064. }
  7065. function isHan(charCode) {
  7066. return charCode >= 0x3400 && charCode <= 0x9fff || charCode >= 0xf900 && charCode <= 0xfaff;
  7067. }
  7068. function isKatakana(charCode) {
  7069. return charCode >= 0x30a0 && charCode <= 0x30ff;
  7070. }
  7071. function isHiragana(charCode) {
  7072. return charCode >= 0x3040 && charCode <= 0x309f;
  7073. }
  7074. function isHalfwidthKatakana(charCode) {
  7075. return charCode >= 0xff60 && charCode <= 0xff9f;
  7076. }
  7077. function isThai(charCode) {
  7078. return (charCode & 0xff80) === 0x0e00;
  7079. }
  7080. function getCharacterType(charCode) {
  7081. if (isAlphabeticalScript(charCode)) {
  7082. if (isAscii(charCode)) {
  7083. if (isAsciiSpace(charCode)) {
  7084. return CharacterType.SPACE;
  7085. } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5f) {
  7086. return CharacterType.ALPHA_LETTER;
  7087. }
  7088. return CharacterType.PUNCT;
  7089. } else if (isThai(charCode)) {
  7090. return CharacterType.THAI_LETTER;
  7091. } else if (charCode === 0xa0) {
  7092. return CharacterType.SPACE;
  7093. }
  7094. return CharacterType.ALPHA_LETTER;
  7095. }
  7096. if (isHan(charCode)) {
  7097. return CharacterType.HAN_LETTER;
  7098. } else if (isKatakana(charCode)) {
  7099. return CharacterType.KATAKANA_LETTER;
  7100. } else if (isHiragana(charCode)) {
  7101. return CharacterType.HIRAGANA_LETTER;
  7102. } else if (isHalfwidthKatakana(charCode)) {
  7103. return CharacterType.HALFWIDTH_KATAKANA_LETTER;
  7104. }
  7105. return CharacterType.ALPHA_LETTER;
  7106. }
  7107. /***/ }),
  7108. /* 19 */
  7109. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  7110. Object.defineProperty(exports, "__esModule", ({
  7111. value: true
  7112. }));
  7113. exports.isDestArraysEqual = isDestArraysEqual;
  7114. exports.isDestHashesEqual = isDestHashesEqual;
  7115. exports.PDFHistory = void 0;
  7116. var _ui_utils = __webpack_require__(6);
  7117. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  7118. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  7119. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  7120. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  7121. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  7122. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  7123. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  7124. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7125. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  7126. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7127. var HASH_CHANGE_TIMEOUT = 1000;
  7128. var POSITION_UPDATED_THRESHOLD = 50;
  7129. var UPDATE_VIEWAREA_TIMEOUT = 1000;
  7130. function getCurrentHash() {
  7131. return document.location.hash;
  7132. }
  7133. var PDFHistory = /*#__PURE__*/function () {
  7134. function PDFHistory(_ref) {
  7135. var _this = this;
  7136. var linkService = _ref.linkService,
  7137. eventBus = _ref.eventBus;
  7138. _classCallCheck(this, PDFHistory);
  7139. this.linkService = linkService;
  7140. this.eventBus = eventBus;
  7141. this._initialized = false;
  7142. this._fingerprint = "";
  7143. this.reset();
  7144. this._boundEvents = null;
  7145. this._isViewerInPresentationMode = false;
  7146. this.eventBus._on("presentationmodechanged", function (evt) {
  7147. _this._isViewerInPresentationMode = evt.state !== _ui_utils.PresentationModeState.NORMAL;
  7148. });
  7149. this.eventBus._on("pagesinit", function () {
  7150. _this._isPagesLoaded = false;
  7151. _this.eventBus._on("pagesloaded", function (evt) {
  7152. _this._isPagesLoaded = !!evt.pagesCount;
  7153. }, {
  7154. once: true
  7155. });
  7156. });
  7157. }
  7158. _createClass(PDFHistory, [{
  7159. key: "initialize",
  7160. value: function initialize(_ref2) {
  7161. var fingerprint = _ref2.fingerprint,
  7162. _ref2$resetHistory = _ref2.resetHistory,
  7163. resetHistory = _ref2$resetHistory === void 0 ? false : _ref2$resetHistory,
  7164. _ref2$updateUrl = _ref2.updateUrl,
  7165. updateUrl = _ref2$updateUrl === void 0 ? false : _ref2$updateUrl;
  7166. if (!fingerprint || typeof fingerprint !== "string") {
  7167. console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
  7168. return;
  7169. }
  7170. if (this._initialized) {
  7171. this.reset();
  7172. }
  7173. var reInitialized = this._fingerprint !== "" && this._fingerprint !== fingerprint;
  7174. this._fingerprint = fingerprint;
  7175. this._updateUrl = updateUrl === true;
  7176. this._initialized = true;
  7177. this._bindEvents();
  7178. var state = window.history.state;
  7179. this._popStateInProgress = false;
  7180. this._blockHashChange = 0;
  7181. this._currentHash = getCurrentHash();
  7182. this._numPositionUpdates = 0;
  7183. this._uid = this._maxUid = 0;
  7184. this._destination = null;
  7185. this._position = null;
  7186. if (!this._isValidState(state, true) || resetHistory) {
  7187. var _this$_parseCurrentHa = this._parseCurrentHash(true),
  7188. hash = _this$_parseCurrentHa.hash,
  7189. page = _this$_parseCurrentHa.page,
  7190. rotation = _this$_parseCurrentHa.rotation;
  7191. if (!hash || reInitialized || resetHistory) {
  7192. this._pushOrReplaceState(null, true);
  7193. return;
  7194. }
  7195. this._pushOrReplaceState({
  7196. hash: hash,
  7197. page: page,
  7198. rotation: rotation
  7199. }, true);
  7200. return;
  7201. }
  7202. var destination = state.destination;
  7203. this._updateInternalState(destination, state.uid, true);
  7204. if (destination.rotation !== undefined) {
  7205. this._initialRotation = destination.rotation;
  7206. }
  7207. if (destination.dest) {
  7208. this._initialBookmark = JSON.stringify(destination.dest);
  7209. this._destination.page = null;
  7210. } else if (destination.hash) {
  7211. this._initialBookmark = destination.hash;
  7212. } else if (destination.page) {
  7213. this._initialBookmark = "page=".concat(destination.page);
  7214. }
  7215. }
  7216. }, {
  7217. key: "reset",
  7218. value: function reset() {
  7219. if (this._initialized) {
  7220. this._pageHide();
  7221. this._initialized = false;
  7222. this._unbindEvents();
  7223. }
  7224. if (this._updateViewareaTimeout) {
  7225. clearTimeout(this._updateViewareaTimeout);
  7226. this._updateViewareaTimeout = null;
  7227. }
  7228. this._initialBookmark = null;
  7229. this._initialRotation = null;
  7230. }
  7231. }, {
  7232. key: "push",
  7233. value: function push(_ref3) {
  7234. var _this2 = this;
  7235. var _ref3$namedDest = _ref3.namedDest,
  7236. namedDest = _ref3$namedDest === void 0 ? null : _ref3$namedDest,
  7237. explicitDest = _ref3.explicitDest,
  7238. pageNumber = _ref3.pageNumber;
  7239. if (!this._initialized) {
  7240. return;
  7241. }
  7242. if (namedDest && typeof namedDest !== "string") {
  7243. console.error("PDFHistory.push: " + "\"".concat(namedDest, "\" is not a valid namedDest parameter."));
  7244. return;
  7245. } else if (!Array.isArray(explicitDest)) {
  7246. console.error("PDFHistory.push: " + "\"".concat(explicitDest, "\" is not a valid explicitDest parameter."));
  7247. return;
  7248. } else if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {
  7249. if (pageNumber !== null || this._destination) {
  7250. console.error("PDFHistory.push: " + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  7251. return;
  7252. }
  7253. }
  7254. var hash = namedDest || JSON.stringify(explicitDest);
  7255. if (!hash) {
  7256. return;
  7257. }
  7258. var forceReplace = false;
  7259. if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
  7260. if (this._destination.page) {
  7261. return;
  7262. }
  7263. forceReplace = true;
  7264. }
  7265. if (this._popStateInProgress && !forceReplace) {
  7266. return;
  7267. }
  7268. this._pushOrReplaceState({
  7269. dest: explicitDest,
  7270. hash: hash,
  7271. page: pageNumber,
  7272. rotation: this.linkService.rotation
  7273. }, forceReplace);
  7274. if (!this._popStateInProgress) {
  7275. this._popStateInProgress = true;
  7276. Promise.resolve().then(function () {
  7277. _this2._popStateInProgress = false;
  7278. });
  7279. }
  7280. }
  7281. }, {
  7282. key: "pushPage",
  7283. value: function pushPage(pageNumber) {
  7284. var _this$_destination,
  7285. _this3 = this;
  7286. if (!this._initialized) {
  7287. return;
  7288. }
  7289. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {
  7290. console.error("PDFHistory.pushPage: \"".concat(pageNumber, "\" is not a valid page number."));
  7291. return;
  7292. }
  7293. if (((_this$_destination = this._destination) === null || _this$_destination === void 0 ? void 0 : _this$_destination.page) === pageNumber) {
  7294. return;
  7295. }
  7296. if (this._popStateInProgress) {
  7297. return;
  7298. }
  7299. this._pushOrReplaceState({
  7300. hash: "page=".concat(pageNumber),
  7301. page: pageNumber,
  7302. rotation: this.linkService.rotation
  7303. });
  7304. if (!this._popStateInProgress) {
  7305. this._popStateInProgress = true;
  7306. Promise.resolve().then(function () {
  7307. _this3._popStateInProgress = false;
  7308. });
  7309. }
  7310. }
  7311. }, {
  7312. key: "pushCurrentPosition",
  7313. value: function pushCurrentPosition() {
  7314. if (!this._initialized || this._popStateInProgress) {
  7315. return;
  7316. }
  7317. this._tryPushCurrentPosition();
  7318. }
  7319. }, {
  7320. key: "back",
  7321. value: function back() {
  7322. if (!this._initialized || this._popStateInProgress) {
  7323. return;
  7324. }
  7325. var state = window.history.state;
  7326. if (this._isValidState(state) && state.uid > 0) {
  7327. window.history.back();
  7328. }
  7329. }
  7330. }, {
  7331. key: "forward",
  7332. value: function forward() {
  7333. if (!this._initialized || this._popStateInProgress) {
  7334. return;
  7335. }
  7336. var state = window.history.state;
  7337. if (this._isValidState(state) && state.uid < this._maxUid) {
  7338. window.history.forward();
  7339. }
  7340. }
  7341. }, {
  7342. key: "_pushOrReplaceState",
  7343. value: function _pushOrReplaceState(destination) {
  7344. var forceReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7345. var shouldReplace = forceReplace || !this._destination;
  7346. var newState = {
  7347. fingerprint: this._fingerprint,
  7348. uid: shouldReplace ? this._uid : this._uid + 1,
  7349. destination: destination
  7350. };
  7351. this._updateInternalState(destination, newState.uid);
  7352. var newUrl;
  7353. if (this._updateUrl && destination !== null && destination !== void 0 && destination.hash) {
  7354. var baseUrl = document.location.href.split("#")[0];
  7355. if (!baseUrl.startsWith("file://")) {
  7356. newUrl = "".concat(baseUrl, "#").concat(destination.hash);
  7357. }
  7358. }
  7359. if (shouldReplace) {
  7360. window.history.replaceState(newState, "", newUrl);
  7361. } else {
  7362. window.history.pushState(newState, "", newUrl);
  7363. }
  7364. }
  7365. }, {
  7366. key: "_tryPushCurrentPosition",
  7367. value: function _tryPushCurrentPosition() {
  7368. var temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  7369. if (!this._position) {
  7370. return;
  7371. }
  7372. var position = this._position;
  7373. if (temporary) {
  7374. position = Object.assign(Object.create(null), this._position);
  7375. position.temporary = true;
  7376. }
  7377. if (!this._destination) {
  7378. this._pushOrReplaceState(position);
  7379. return;
  7380. }
  7381. if (this._destination.temporary) {
  7382. this._pushOrReplaceState(position, true);
  7383. return;
  7384. }
  7385. if (this._destination.hash === position.hash) {
  7386. return;
  7387. }
  7388. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  7389. return;
  7390. }
  7391. var forceReplace = false;
  7392. if (this._destination.page >= position.first && this._destination.page <= position.page) {
  7393. if (this._destination.dest || !this._destination.first) {
  7394. return;
  7395. }
  7396. forceReplace = true;
  7397. }
  7398. this._pushOrReplaceState(position, forceReplace);
  7399. }
  7400. }, {
  7401. key: "_isValidState",
  7402. value: function _isValidState(state) {
  7403. var checkReload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7404. if (!state) {
  7405. return false;
  7406. }
  7407. if (state.fingerprint !== this._fingerprint) {
  7408. if (checkReload) {
  7409. if (typeof state.fingerprint !== "string" || state.fingerprint.length !== this._fingerprint.length) {
  7410. return false;
  7411. }
  7412. var _performance$getEntri = performance.getEntriesByType("navigation"),
  7413. _performance$getEntri2 = _slicedToArray(_performance$getEntri, 1),
  7414. perfEntry = _performance$getEntri2[0];
  7415. if ((perfEntry === null || perfEntry === void 0 ? void 0 : perfEntry.type) !== "reload") {
  7416. return false;
  7417. }
  7418. } else {
  7419. return false;
  7420. }
  7421. }
  7422. if (!Number.isInteger(state.uid) || state.uid < 0) {
  7423. return false;
  7424. }
  7425. if (state.destination === null || _typeof(state.destination) !== "object") {
  7426. return false;
  7427. }
  7428. return true;
  7429. }
  7430. }, {
  7431. key: "_updateInternalState",
  7432. value: function _updateInternalState(destination, uid) {
  7433. var removeTemporary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  7434. if (this._updateViewareaTimeout) {
  7435. clearTimeout(this._updateViewareaTimeout);
  7436. this._updateViewareaTimeout = null;
  7437. }
  7438. if (removeTemporary && destination !== null && destination !== void 0 && destination.temporary) {
  7439. delete destination.temporary;
  7440. }
  7441. this._destination = destination;
  7442. this._uid = uid;
  7443. this._maxUid = Math.max(this._maxUid, uid);
  7444. this._numPositionUpdates = 0;
  7445. }
  7446. }, {
  7447. key: "_parseCurrentHash",
  7448. value: function _parseCurrentHash() {
  7449. var checkNameddest = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  7450. var hash = unescape(getCurrentHash()).substring(1);
  7451. var params = (0, _ui_utils.parseQueryString)(hash);
  7452. var nameddest = params.nameddest || "";
  7453. var page = params.page | 0;
  7454. if (!(Number.isInteger(page) && page > 0 && page <= this.linkService.pagesCount) || checkNameddest && nameddest.length > 0) {
  7455. page = null;
  7456. }
  7457. return {
  7458. hash: hash,
  7459. page: page,
  7460. rotation: this.linkService.rotation
  7461. };
  7462. }
  7463. }, {
  7464. key: "_updateViewarea",
  7465. value: function _updateViewarea(_ref4) {
  7466. var _this4 = this;
  7467. var location = _ref4.location;
  7468. if (this._updateViewareaTimeout) {
  7469. clearTimeout(this._updateViewareaTimeout);
  7470. this._updateViewareaTimeout = null;
  7471. }
  7472. this._position = {
  7473. hash: this._isViewerInPresentationMode ? "page=".concat(location.pageNumber) : location.pdfOpenParams.substring(1),
  7474. page: this.linkService.page,
  7475. first: location.pageNumber,
  7476. rotation: location.rotation
  7477. };
  7478. if (this._popStateInProgress) {
  7479. return;
  7480. }
  7481. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
  7482. this._numPositionUpdates++;
  7483. }
  7484. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  7485. this._updateViewareaTimeout = setTimeout(function () {
  7486. if (!_this4._popStateInProgress) {
  7487. _this4._tryPushCurrentPosition(true);
  7488. }
  7489. _this4._updateViewareaTimeout = null;
  7490. }, UPDATE_VIEWAREA_TIMEOUT);
  7491. }
  7492. }
  7493. }, {
  7494. key: "_popState",
  7495. value: function _popState(_ref5) {
  7496. var _this5 = this;
  7497. var state = _ref5.state;
  7498. var newHash = getCurrentHash(),
  7499. hashChanged = this._currentHash !== newHash;
  7500. this._currentHash = newHash;
  7501. if (!state) {
  7502. this._uid++;
  7503. var _this$_parseCurrentHa2 = this._parseCurrentHash(),
  7504. hash = _this$_parseCurrentHa2.hash,
  7505. page = _this$_parseCurrentHa2.page,
  7506. rotation = _this$_parseCurrentHa2.rotation;
  7507. this._pushOrReplaceState({
  7508. hash: hash,
  7509. page: page,
  7510. rotation: rotation
  7511. }, true);
  7512. return;
  7513. }
  7514. if (!this._isValidState(state)) {
  7515. return;
  7516. }
  7517. this._popStateInProgress = true;
  7518. if (hashChanged) {
  7519. this._blockHashChange++;
  7520. (0, _ui_utils.waitOnEventOrTimeout)({
  7521. target: window,
  7522. name: "hashchange",
  7523. delay: HASH_CHANGE_TIMEOUT
  7524. }).then(function () {
  7525. _this5._blockHashChange--;
  7526. });
  7527. }
  7528. var destination = state.destination;
  7529. this._updateInternalState(destination, state.uid, true);
  7530. if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
  7531. this.linkService.rotation = destination.rotation;
  7532. }
  7533. if (destination.dest) {
  7534. this.linkService.goToDestination(destination.dest);
  7535. } else if (destination.hash) {
  7536. this.linkService.setHash(destination.hash);
  7537. } else if (destination.page) {
  7538. this.linkService.page = destination.page;
  7539. }
  7540. Promise.resolve().then(function () {
  7541. _this5._popStateInProgress = false;
  7542. });
  7543. }
  7544. }, {
  7545. key: "_pageHide",
  7546. value: function _pageHide() {
  7547. if (!this._destination || this._destination.temporary) {
  7548. this._tryPushCurrentPosition();
  7549. }
  7550. }
  7551. }, {
  7552. key: "_bindEvents",
  7553. value: function _bindEvents() {
  7554. if (this._boundEvents) {
  7555. return;
  7556. }
  7557. this._boundEvents = {
  7558. updateViewarea: this._updateViewarea.bind(this),
  7559. popState: this._popState.bind(this),
  7560. pageHide: this._pageHide.bind(this)
  7561. };
  7562. this.eventBus._on("updateviewarea", this._boundEvents.updateViewarea);
  7563. window.addEventListener("popstate", this._boundEvents.popState);
  7564. window.addEventListener("pagehide", this._boundEvents.pageHide);
  7565. }
  7566. }, {
  7567. key: "_unbindEvents",
  7568. value: function _unbindEvents() {
  7569. if (!this._boundEvents) {
  7570. return;
  7571. }
  7572. this.eventBus._off("updateviewarea", this._boundEvents.updateViewarea);
  7573. window.removeEventListener("popstate", this._boundEvents.popState);
  7574. window.removeEventListener("pagehide", this._boundEvents.pageHide);
  7575. this._boundEvents = null;
  7576. }
  7577. }, {
  7578. key: "popStateInProgress",
  7579. get: function get() {
  7580. return this._initialized && (this._popStateInProgress || this._blockHashChange > 0);
  7581. }
  7582. }, {
  7583. key: "initialBookmark",
  7584. get: function get() {
  7585. return this._initialized ? this._initialBookmark : null;
  7586. }
  7587. }, {
  7588. key: "initialRotation",
  7589. get: function get() {
  7590. return this._initialized ? this._initialRotation : null;
  7591. }
  7592. }]);
  7593. return PDFHistory;
  7594. }();
  7595. exports.PDFHistory = PDFHistory;
  7596. function isDestHashesEqual(destHash, pushHash) {
  7597. if (typeof destHash !== "string" || typeof pushHash !== "string") {
  7598. return false;
  7599. }
  7600. if (destHash === pushHash) {
  7601. return true;
  7602. }
  7603. var _parseQueryString = (0, _ui_utils.parseQueryString)(destHash),
  7604. nameddest = _parseQueryString.nameddest;
  7605. if (nameddest === pushHash) {
  7606. return true;
  7607. }
  7608. return false;
  7609. }
  7610. function isDestArraysEqual(firstDest, secondDest) {
  7611. function isEntryEqual(first, second) {
  7612. if (_typeof(first) !== _typeof(second)) {
  7613. return false;
  7614. }
  7615. if (Array.isArray(first) || Array.isArray(second)) {
  7616. return false;
  7617. }
  7618. if (first !== null && _typeof(first) === "object" && second !== null) {
  7619. if (Object.keys(first).length !== Object.keys(second).length) {
  7620. return false;
  7621. }
  7622. for (var key in first) {
  7623. if (!isEntryEqual(first[key], second[key])) {
  7624. return false;
  7625. }
  7626. }
  7627. return true;
  7628. }
  7629. return first === second || Number.isNaN(first) && Number.isNaN(second);
  7630. }
  7631. if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
  7632. return false;
  7633. }
  7634. if (firstDest.length !== secondDest.length) {
  7635. return false;
  7636. }
  7637. for (var i = 0, ii = firstDest.length; i < ii; i++) {
  7638. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  7639. return false;
  7640. }
  7641. }
  7642. return true;
  7643. }
  7644. /***/ }),
  7645. /* 20 */
  7646. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  7647. Object.defineProperty(exports, "__esModule", ({
  7648. value: true
  7649. }));
  7650. exports.PDFLayerViewer = void 0;
  7651. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  7652. var _base_tree_viewer = __webpack_require__(14);
  7653. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7654. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  7655. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  7656. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  7657. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  7658. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  7659. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  7660. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7661. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  7662. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7663. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  7664. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  7665. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  7666. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  7667. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  7668. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  7669. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  7670. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  7671. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  7672. var PDFLayerViewer = /*#__PURE__*/function (_BaseTreeViewer) {
  7673. _inherits(PDFLayerViewer, _BaseTreeViewer);
  7674. var _super = _createSuper(PDFLayerViewer);
  7675. function PDFLayerViewer(options) {
  7676. var _this;
  7677. _classCallCheck(this, PDFLayerViewer);
  7678. _this = _super.call(this, options);
  7679. _this.l10n = options.l10n;
  7680. _this.eventBus._on("resetlayers", _this._resetLayers.bind(_assertThisInitialized(_this)));
  7681. _this.eventBus._on("togglelayerstree", _this._toggleAllTreeItems.bind(_assertThisInitialized(_this)));
  7682. return _this;
  7683. }
  7684. _createClass(PDFLayerViewer, [{
  7685. key: "reset",
  7686. value: function reset() {
  7687. _get(_getPrototypeOf(PDFLayerViewer.prototype), "reset", this).call(this);
  7688. this._optionalContentConfig = null;
  7689. }
  7690. }, {
  7691. key: "_dispatchEvent",
  7692. value: function _dispatchEvent(layersCount) {
  7693. this.eventBus.dispatch("layersloaded", {
  7694. source: this,
  7695. layersCount: layersCount
  7696. });
  7697. }
  7698. }, {
  7699. key: "_bindLink",
  7700. value: function _bindLink(element, _ref) {
  7701. var _this2 = this;
  7702. var groupId = _ref.groupId,
  7703. input = _ref.input;
  7704. var setVisibility = function setVisibility() {
  7705. _this2._optionalContentConfig.setVisibility(groupId, input.checked);
  7706. _this2.eventBus.dispatch("optionalcontentconfig", {
  7707. source: _this2,
  7708. promise: Promise.resolve(_this2._optionalContentConfig)
  7709. });
  7710. };
  7711. element.onclick = function (evt) {
  7712. if (evt.target === input) {
  7713. setVisibility();
  7714. return true;
  7715. } else if (evt.target !== element) {
  7716. return true;
  7717. }
  7718. input.checked = !input.checked;
  7719. setVisibility();
  7720. return false;
  7721. };
  7722. }
  7723. }, {
  7724. key: "_setNestedName",
  7725. value: function () {
  7726. var _setNestedName2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(element, _ref2) {
  7727. var _ref2$name, name;
  7728. return _regenerator["default"].wrap(function _callee$(_context) {
  7729. while (1) {
  7730. switch (_context.prev = _context.next) {
  7731. case 0:
  7732. _ref2$name = _ref2.name, name = _ref2$name === void 0 ? null : _ref2$name;
  7733. if (!(typeof name === "string")) {
  7734. _context.next = 4;
  7735. break;
  7736. }
  7737. element.textContent = this._normalizeTextContent(name);
  7738. return _context.abrupt("return");
  7739. case 4:
  7740. _context.next = 6;
  7741. return this.l10n.get("additional_layers", null, "Additional Layers");
  7742. case 6:
  7743. element.textContent = _context.sent;
  7744. element.style.fontStyle = "italic";
  7745. case 8:
  7746. case "end":
  7747. return _context.stop();
  7748. }
  7749. }
  7750. }, _callee, this);
  7751. }));
  7752. function _setNestedName(_x, _x2) {
  7753. return _setNestedName2.apply(this, arguments);
  7754. }
  7755. return _setNestedName;
  7756. }()
  7757. }, {
  7758. key: "_addToggleButton",
  7759. value: function _addToggleButton(div, _ref3) {
  7760. var _ref3$name = _ref3.name,
  7761. name = _ref3$name === void 0 ? null : _ref3$name;
  7762. _get(_getPrototypeOf(PDFLayerViewer.prototype), "_addToggleButton", this).call(this, div, name === null);
  7763. }
  7764. }, {
  7765. key: "_toggleAllTreeItems",
  7766. value: function _toggleAllTreeItems() {
  7767. if (!this._optionalContentConfig) {
  7768. return;
  7769. }
  7770. _get(_getPrototypeOf(PDFLayerViewer.prototype), "_toggleAllTreeItems", this).call(this);
  7771. }
  7772. }, {
  7773. key: "render",
  7774. value: function render(_ref4) {
  7775. var optionalContentConfig = _ref4.optionalContentConfig,
  7776. pdfDocument = _ref4.pdfDocument;
  7777. if (this._optionalContentConfig) {
  7778. this.reset();
  7779. }
  7780. this._optionalContentConfig = optionalContentConfig || null;
  7781. this._pdfDocument = pdfDocument || null;
  7782. var groups = optionalContentConfig && optionalContentConfig.getOrder();
  7783. if (!groups) {
  7784. this._dispatchEvent(0);
  7785. return;
  7786. }
  7787. var fragment = document.createDocumentFragment(),
  7788. queue = [{
  7789. parent: fragment,
  7790. groups: groups
  7791. }];
  7792. var layersCount = 0,
  7793. hasAnyNesting = false;
  7794. while (queue.length > 0) {
  7795. var levelData = queue.shift();
  7796. var _iterator = _createForOfIteratorHelper(levelData.groups),
  7797. _step;
  7798. try {
  7799. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  7800. var groupId = _step.value;
  7801. var div = document.createElement("div");
  7802. div.className = "treeItem";
  7803. var element = document.createElement("a");
  7804. div.appendChild(element);
  7805. if (_typeof(groupId) === "object") {
  7806. hasAnyNesting = true;
  7807. this._addToggleButton(div, groupId);
  7808. this._setNestedName(element, groupId);
  7809. var itemsDiv = document.createElement("div");
  7810. itemsDiv.className = "treeItems";
  7811. div.appendChild(itemsDiv);
  7812. queue.push({
  7813. parent: itemsDiv,
  7814. groups: groupId.order
  7815. });
  7816. } else {
  7817. var group = optionalContentConfig.getGroup(groupId);
  7818. var input = document.createElement("input");
  7819. this._bindLink(element, {
  7820. groupId: groupId,
  7821. input: input
  7822. });
  7823. input.type = "checkbox";
  7824. input.id = groupId;
  7825. input.checked = group.visible;
  7826. var label = document.createElement("label");
  7827. label.setAttribute("for", groupId);
  7828. label.textContent = this._normalizeTextContent(group.name);
  7829. element.appendChild(input);
  7830. element.appendChild(label);
  7831. layersCount++;
  7832. }
  7833. levelData.parent.appendChild(div);
  7834. }
  7835. } catch (err) {
  7836. _iterator.e(err);
  7837. } finally {
  7838. _iterator.f();
  7839. }
  7840. }
  7841. this._finishRendering(fragment, layersCount, hasAnyNesting);
  7842. }
  7843. }, {
  7844. key: "_resetLayers",
  7845. value: function () {
  7846. var _resetLayers2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  7847. var optionalContentConfig;
  7848. return _regenerator["default"].wrap(function _callee2$(_context2) {
  7849. while (1) {
  7850. switch (_context2.prev = _context2.next) {
  7851. case 0:
  7852. if (this._optionalContentConfig) {
  7853. _context2.next = 2;
  7854. break;
  7855. }
  7856. return _context2.abrupt("return");
  7857. case 2:
  7858. _context2.next = 4;
  7859. return this._pdfDocument.getOptionalContentConfig();
  7860. case 4:
  7861. optionalContentConfig = _context2.sent;
  7862. this.eventBus.dispatch("optionalcontentconfig", {
  7863. source: this,
  7864. promise: Promise.resolve(optionalContentConfig)
  7865. });
  7866. this.render({
  7867. optionalContentConfig: optionalContentConfig,
  7868. pdfDocument: this._pdfDocument
  7869. });
  7870. case 7:
  7871. case "end":
  7872. return _context2.stop();
  7873. }
  7874. }
  7875. }, _callee2, this);
  7876. }));
  7877. function _resetLayers() {
  7878. return _resetLayers2.apply(this, arguments);
  7879. }
  7880. return _resetLayers;
  7881. }()
  7882. }]);
  7883. return PDFLayerViewer;
  7884. }(_base_tree_viewer.BaseTreeViewer);
  7885. exports.PDFLayerViewer = PDFLayerViewer;
  7886. /***/ }),
  7887. /* 21 */
  7888. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  7889. Object.defineProperty(exports, "__esModule", ({
  7890. value: true
  7891. }));
  7892. exports.SimpleLinkService = exports.PDFLinkService = void 0;
  7893. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  7894. var _ui_utils = __webpack_require__(6);
  7895. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7896. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  7897. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  7898. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  7899. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7900. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  7901. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7902. var PDFLinkService = /*#__PURE__*/function () {
  7903. function PDFLinkService() {
  7904. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  7905. eventBus = _ref.eventBus,
  7906. _ref$externalLinkTarg = _ref.externalLinkTarget,
  7907. externalLinkTarget = _ref$externalLinkTarg === void 0 ? null : _ref$externalLinkTarg,
  7908. _ref$externalLinkRel = _ref.externalLinkRel,
  7909. externalLinkRel = _ref$externalLinkRel === void 0 ? null : _ref$externalLinkRel,
  7910. _ref$externalLinkEnab = _ref.externalLinkEnabled,
  7911. externalLinkEnabled = _ref$externalLinkEnab === void 0 ? true : _ref$externalLinkEnab,
  7912. _ref$ignoreDestinatio = _ref.ignoreDestinationZoom,
  7913. ignoreDestinationZoom = _ref$ignoreDestinatio === void 0 ? false : _ref$ignoreDestinatio;
  7914. _classCallCheck(this, PDFLinkService);
  7915. this.eventBus = eventBus;
  7916. this.externalLinkTarget = externalLinkTarget;
  7917. this.externalLinkRel = externalLinkRel;
  7918. this.externalLinkEnabled = externalLinkEnabled;
  7919. this._ignoreDestinationZoom = ignoreDestinationZoom;
  7920. this.baseUrl = null;
  7921. this.pdfDocument = null;
  7922. this.pdfViewer = null;
  7923. this.pdfHistory = null;
  7924. this._pagesRefCache = null;
  7925. }
  7926. _createClass(PDFLinkService, [{
  7927. key: "setDocument",
  7928. value: function setDocument(pdfDocument) {
  7929. var baseUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  7930. this.baseUrl = baseUrl;
  7931. this.pdfDocument = pdfDocument;
  7932. this._pagesRefCache = Object.create(null);
  7933. }
  7934. }, {
  7935. key: "setViewer",
  7936. value: function setViewer(pdfViewer) {
  7937. this.pdfViewer = pdfViewer;
  7938. }
  7939. }, {
  7940. key: "setHistory",
  7941. value: function setHistory(pdfHistory) {
  7942. this.pdfHistory = pdfHistory;
  7943. }
  7944. }, {
  7945. key: "navigateTo",
  7946. value: function navigateTo(dest) {
  7947. console.error("Deprecated method: `navigateTo`, use `goToDestination` instead.");
  7948. this.goToDestination(dest);
  7949. }
  7950. }, {
  7951. key: "_goToDestinationHelper",
  7952. value: function _goToDestinationHelper(rawDest) {
  7953. var _this = this;
  7954. var namedDest = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  7955. var explicitDest = arguments.length > 2 ? arguments[2] : undefined;
  7956. var destRef = explicitDest[0];
  7957. var pageNumber;
  7958. if (destRef instanceof Object) {
  7959. pageNumber = this._cachedPageNumber(destRef);
  7960. if (pageNumber === null) {
  7961. this.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
  7962. _this.cachePageRef(pageIndex + 1, destRef);
  7963. _this._goToDestinationHelper(rawDest, namedDest, explicitDest);
  7964. })["catch"](function () {
  7965. console.error("PDFLinkService._goToDestinationHelper: \"".concat(destRef, "\" is not ") + "a valid page reference, for dest=\"".concat(rawDest, "\"."));
  7966. });
  7967. return;
  7968. }
  7969. } else if (Number.isInteger(destRef)) {
  7970. pageNumber = destRef + 1;
  7971. } else {
  7972. console.error("PDFLinkService._goToDestinationHelper: \"".concat(destRef, "\" is not ") + "a valid destination reference, for dest=\"".concat(rawDest, "\"."));
  7973. return;
  7974. }
  7975. if (!pageNumber || pageNumber < 1 || pageNumber > this.pagesCount) {
  7976. console.error("PDFLinkService._goToDestinationHelper: \"".concat(pageNumber, "\" is not ") + "a valid page number, for dest=\"".concat(rawDest, "\"."));
  7977. return;
  7978. }
  7979. if (this.pdfHistory) {
  7980. this.pdfHistory.pushCurrentPosition();
  7981. this.pdfHistory.push({
  7982. namedDest: namedDest,
  7983. explicitDest: explicitDest,
  7984. pageNumber: pageNumber
  7985. });
  7986. }
  7987. this.pdfViewer.scrollPageIntoView({
  7988. pageNumber: pageNumber,
  7989. destArray: explicitDest,
  7990. ignoreDestinationZoom: this._ignoreDestinationZoom
  7991. });
  7992. }
  7993. }, {
  7994. key: "goToDestination",
  7995. value: function () {
  7996. var _goToDestination = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(dest) {
  7997. var namedDest, explicitDest;
  7998. return _regenerator["default"].wrap(function _callee$(_context) {
  7999. while (1) {
  8000. switch (_context.prev = _context.next) {
  8001. case 0:
  8002. if (this.pdfDocument) {
  8003. _context.next = 2;
  8004. break;
  8005. }
  8006. return _context.abrupt("return");
  8007. case 2:
  8008. if (!(typeof dest === "string")) {
  8009. _context.next = 9;
  8010. break;
  8011. }
  8012. namedDest = dest;
  8013. _context.next = 6;
  8014. return this.pdfDocument.getDestination(dest);
  8015. case 6:
  8016. explicitDest = _context.sent;
  8017. _context.next = 13;
  8018. break;
  8019. case 9:
  8020. namedDest = null;
  8021. _context.next = 12;
  8022. return dest;
  8023. case 12:
  8024. explicitDest = _context.sent;
  8025. case 13:
  8026. if (Array.isArray(explicitDest)) {
  8027. _context.next = 16;
  8028. break;
  8029. }
  8030. console.error("PDFLinkService.goToDestination: \"".concat(explicitDest, "\" is not ") + "a valid destination array, for dest=\"".concat(dest, "\"."));
  8031. return _context.abrupt("return");
  8032. case 16:
  8033. this._goToDestinationHelper(dest, namedDest, explicitDest);
  8034. case 17:
  8035. case "end":
  8036. return _context.stop();
  8037. }
  8038. }
  8039. }, _callee, this);
  8040. }));
  8041. function goToDestination(_x) {
  8042. return _goToDestination.apply(this, arguments);
  8043. }
  8044. return goToDestination;
  8045. }()
  8046. }, {
  8047. key: "goToPage",
  8048. value: function goToPage(val) {
  8049. if (!this.pdfDocument) {
  8050. return;
  8051. }
  8052. var pageNumber = typeof val === "string" && this.pdfViewer.pageLabelToPageNumber(val) || val | 0;
  8053. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
  8054. console.error("PDFLinkService.goToPage: \"".concat(val, "\" is not a valid page."));
  8055. return;
  8056. }
  8057. if (this.pdfHistory) {
  8058. this.pdfHistory.pushCurrentPosition();
  8059. this.pdfHistory.pushPage(pageNumber);
  8060. }
  8061. this.pdfViewer.scrollPageIntoView({
  8062. pageNumber: pageNumber
  8063. });
  8064. }
  8065. }, {
  8066. key: "getDestinationHash",
  8067. value: function getDestinationHash(dest) {
  8068. if (typeof dest === "string") {
  8069. if (dest.length > 0) {
  8070. return this.getAnchorUrl("#" + escape(dest));
  8071. }
  8072. } else if (Array.isArray(dest)) {
  8073. var str = JSON.stringify(dest);
  8074. if (str.length > 0) {
  8075. return this.getAnchorUrl("#" + escape(str));
  8076. }
  8077. }
  8078. return this.getAnchorUrl("");
  8079. }
  8080. }, {
  8081. key: "getAnchorUrl",
  8082. value: function getAnchorUrl(anchor) {
  8083. return (this.baseUrl || "") + anchor;
  8084. }
  8085. }, {
  8086. key: "setHash",
  8087. value: function setHash(hash) {
  8088. if (!this.pdfDocument) {
  8089. return;
  8090. }
  8091. var pageNumber, dest;
  8092. if (hash.includes("=")) {
  8093. var params = (0, _ui_utils.parseQueryString)(hash);
  8094. if ("search" in params) {
  8095. this.eventBus.dispatch("findfromurlhash", {
  8096. source: this,
  8097. query: params.search.replace(/"/g, ""),
  8098. phraseSearch: params.phrase === "true"
  8099. });
  8100. }
  8101. if ("page" in params) {
  8102. pageNumber = params.page | 0 || 1;
  8103. }
  8104. if ("zoom" in params) {
  8105. var zoomArgs = params.zoom.split(",");
  8106. var zoomArg = zoomArgs[0];
  8107. var zoomArgNumber = parseFloat(zoomArg);
  8108. if (!zoomArg.includes("Fit")) {
  8109. dest = [null, {
  8110. name: "XYZ"
  8111. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
  8112. } else {
  8113. if (zoomArg === "Fit" || zoomArg === "FitB") {
  8114. dest = [null, {
  8115. name: zoomArg
  8116. }];
  8117. } else if (zoomArg === "FitH" || zoomArg === "FitBH" || zoomArg === "FitV" || zoomArg === "FitBV") {
  8118. dest = [null, {
  8119. name: zoomArg
  8120. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  8121. } else if (zoomArg === "FitR") {
  8122. if (zoomArgs.length !== 5) {
  8123. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
  8124. } else {
  8125. dest = [null, {
  8126. name: zoomArg
  8127. }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
  8128. }
  8129. } else {
  8130. console.error("PDFLinkService.setHash: \"".concat(zoomArg, "\" is not ") + "a valid zoom value.");
  8131. }
  8132. }
  8133. }
  8134. if (dest) {
  8135. this.pdfViewer.scrollPageIntoView({
  8136. pageNumber: pageNumber || this.page,
  8137. destArray: dest,
  8138. allowNegativeOffset: true
  8139. });
  8140. } else if (pageNumber) {
  8141. this.page = pageNumber;
  8142. }
  8143. if ("pagemode" in params) {
  8144. this.eventBus.dispatch("pagemode", {
  8145. source: this,
  8146. mode: params.pagemode
  8147. });
  8148. }
  8149. if ("nameddest" in params) {
  8150. this.goToDestination(params.nameddest);
  8151. }
  8152. } else {
  8153. dest = unescape(hash);
  8154. try {
  8155. dest = JSON.parse(dest);
  8156. if (!Array.isArray(dest)) {
  8157. dest = dest.toString();
  8158. }
  8159. } catch (ex) {}
  8160. if (typeof dest === "string" || isValidExplicitDestination(dest)) {
  8161. this.goToDestination(dest);
  8162. return;
  8163. }
  8164. console.error("PDFLinkService.setHash: \"".concat(unescape(hash), "\" is not ") + "a valid destination.");
  8165. }
  8166. }
  8167. }, {
  8168. key: "executeNamedAction",
  8169. value: function executeNamedAction(action) {
  8170. switch (action) {
  8171. case "GoBack":
  8172. if (this.pdfHistory) {
  8173. this.pdfHistory.back();
  8174. }
  8175. break;
  8176. case "GoForward":
  8177. if (this.pdfHistory) {
  8178. this.pdfHistory.forward();
  8179. }
  8180. break;
  8181. case "NextPage":
  8182. this.pdfViewer.nextPage();
  8183. break;
  8184. case "PrevPage":
  8185. this.pdfViewer.previousPage();
  8186. break;
  8187. case "LastPage":
  8188. this.page = this.pagesCount;
  8189. break;
  8190. case "FirstPage":
  8191. this.page = 1;
  8192. break;
  8193. default:
  8194. break;
  8195. }
  8196. this.eventBus.dispatch("namedaction", {
  8197. source: this,
  8198. action: action
  8199. });
  8200. }
  8201. }, {
  8202. key: "cachePageRef",
  8203. value: function cachePageRef(pageNum, pageRef) {
  8204. if (!pageRef) {
  8205. return;
  8206. }
  8207. var refStr = pageRef.gen === 0 ? "".concat(pageRef.num, "R") : "".concat(pageRef.num, "R").concat(pageRef.gen);
  8208. this._pagesRefCache[refStr] = pageNum;
  8209. }
  8210. }, {
  8211. key: "_cachedPageNumber",
  8212. value: function _cachedPageNumber(pageRef) {
  8213. var refStr = pageRef.gen === 0 ? "".concat(pageRef.num, "R") : "".concat(pageRef.num, "R").concat(pageRef.gen);
  8214. return this._pagesRefCache && this._pagesRefCache[refStr] || null;
  8215. }
  8216. }, {
  8217. key: "isPageVisible",
  8218. value: function isPageVisible(pageNumber) {
  8219. return this.pdfViewer.isPageVisible(pageNumber);
  8220. }
  8221. }, {
  8222. key: "isPageCached",
  8223. value: function isPageCached(pageNumber) {
  8224. return this.pdfViewer.isPageCached(pageNumber);
  8225. }
  8226. }, {
  8227. key: "pagesCount",
  8228. get: function get() {
  8229. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  8230. }
  8231. }, {
  8232. key: "page",
  8233. get: function get() {
  8234. return this.pdfViewer.currentPageNumber;
  8235. },
  8236. set: function set(value) {
  8237. this.pdfViewer.currentPageNumber = value;
  8238. }
  8239. }, {
  8240. key: "rotation",
  8241. get: function get() {
  8242. return this.pdfViewer.pagesRotation;
  8243. },
  8244. set: function set(value) {
  8245. this.pdfViewer.pagesRotation = value;
  8246. }
  8247. }]);
  8248. return PDFLinkService;
  8249. }();
  8250. exports.PDFLinkService = PDFLinkService;
  8251. function isValidExplicitDestination(dest) {
  8252. if (!Array.isArray(dest)) {
  8253. return false;
  8254. }
  8255. var destLength = dest.length;
  8256. if (destLength < 2) {
  8257. return false;
  8258. }
  8259. var page = dest[0];
  8260. if (!(_typeof(page) === "object" && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
  8261. return false;
  8262. }
  8263. var zoom = dest[1];
  8264. if (!(_typeof(zoom) === "object" && typeof zoom.name === "string")) {
  8265. return false;
  8266. }
  8267. var allowNull = true;
  8268. switch (zoom.name) {
  8269. case "XYZ":
  8270. if (destLength !== 5) {
  8271. return false;
  8272. }
  8273. break;
  8274. case "Fit":
  8275. case "FitB":
  8276. return destLength === 2;
  8277. case "FitH":
  8278. case "FitBH":
  8279. case "FitV":
  8280. case "FitBV":
  8281. if (destLength !== 3) {
  8282. return false;
  8283. }
  8284. break;
  8285. case "FitR":
  8286. if (destLength !== 6) {
  8287. return false;
  8288. }
  8289. allowNull = false;
  8290. break;
  8291. default:
  8292. return false;
  8293. }
  8294. for (var i = 2; i < destLength; i++) {
  8295. var param = dest[i];
  8296. if (!(typeof param === "number" || allowNull && param === null)) {
  8297. return false;
  8298. }
  8299. }
  8300. return true;
  8301. }
  8302. var SimpleLinkService = /*#__PURE__*/function () {
  8303. function SimpleLinkService() {
  8304. _classCallCheck(this, SimpleLinkService);
  8305. this.externalLinkTarget = null;
  8306. this.externalLinkRel = null;
  8307. this.externalLinkEnabled = true;
  8308. this._ignoreDestinationZoom = false;
  8309. }
  8310. _createClass(SimpleLinkService, [{
  8311. key: "goToDestination",
  8312. value: function () {
  8313. var _goToDestination2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(dest) {
  8314. return _regenerator["default"].wrap(function _callee2$(_context2) {
  8315. while (1) {
  8316. switch (_context2.prev = _context2.next) {
  8317. case 0:
  8318. case "end":
  8319. return _context2.stop();
  8320. }
  8321. }
  8322. }, _callee2);
  8323. }));
  8324. function goToDestination(_x2) {
  8325. return _goToDestination2.apply(this, arguments);
  8326. }
  8327. return goToDestination;
  8328. }()
  8329. }, {
  8330. key: "goToPage",
  8331. value: function goToPage(val) {}
  8332. }, {
  8333. key: "getDestinationHash",
  8334. value: function getDestinationHash(dest) {
  8335. return "#";
  8336. }
  8337. }, {
  8338. key: "getAnchorUrl",
  8339. value: function getAnchorUrl(hash) {
  8340. return "#";
  8341. }
  8342. }, {
  8343. key: "setHash",
  8344. value: function setHash(hash) {}
  8345. }, {
  8346. key: "executeNamedAction",
  8347. value: function executeNamedAction(action) {}
  8348. }, {
  8349. key: "cachePageRef",
  8350. value: function cachePageRef(pageNum, pageRef) {}
  8351. }, {
  8352. key: "isPageVisible",
  8353. value: function isPageVisible(pageNumber) {
  8354. return true;
  8355. }
  8356. }, {
  8357. key: "isPageCached",
  8358. value: function isPageCached(pageNumber) {
  8359. return true;
  8360. }
  8361. }, {
  8362. key: "pagesCount",
  8363. get: function get() {
  8364. return 0;
  8365. }
  8366. }, {
  8367. key: "page",
  8368. get: function get() {
  8369. return 0;
  8370. },
  8371. set: function set(value) {}
  8372. }, {
  8373. key: "rotation",
  8374. get: function get() {
  8375. return 0;
  8376. },
  8377. set: function set(value) {}
  8378. }]);
  8379. return SimpleLinkService;
  8380. }();
  8381. exports.SimpleLinkService = SimpleLinkService;
  8382. /***/ }),
  8383. /* 22 */
  8384. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  8385. Object.defineProperty(exports, "__esModule", ({
  8386. value: true
  8387. }));
  8388. exports.PDFOutlineViewer = void 0;
  8389. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  8390. var _pdfjsLib = __webpack_require__(7);
  8391. var _base_tree_viewer = __webpack_require__(14);
  8392. var _ui_utils = __webpack_require__(6);
  8393. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  8394. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  8395. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  8396. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  8397. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  8398. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  8399. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  8400. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  8401. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  8402. function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
  8403. function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  8404. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  8405. function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
  8406. function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
  8407. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  8408. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8409. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  8410. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8411. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  8412. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  8413. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  8414. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  8415. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  8416. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  8417. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  8418. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  8419. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  8420. var PDFOutlineViewer = /*#__PURE__*/function (_BaseTreeViewer) {
  8421. _inherits(PDFOutlineViewer, _BaseTreeViewer);
  8422. var _super = _createSuper(PDFOutlineViewer);
  8423. function PDFOutlineViewer(options) {
  8424. var _this;
  8425. _classCallCheck(this, PDFOutlineViewer);
  8426. _this = _super.call(this, options);
  8427. _this.linkService = options.linkService;
  8428. _this.eventBus._on("toggleoutlinetree", _this._toggleAllTreeItems.bind(_assertThisInitialized(_this)));
  8429. _this.eventBus._on("currentoutlineitem", _this._currentOutlineItem.bind(_assertThisInitialized(_this)));
  8430. _this.eventBus._on("pagechanging", function (evt) {
  8431. _this._currentPageNumber = evt.pageNumber;
  8432. });
  8433. _this.eventBus._on("pagesloaded", function (evt) {
  8434. _this._isPagesLoaded = !!evt.pagesCount;
  8435. });
  8436. _this.eventBus._on("sidebarviewchanged", function (evt) {
  8437. _this._sidebarView = evt.view;
  8438. });
  8439. return _this;
  8440. }
  8441. _createClass(PDFOutlineViewer, [{
  8442. key: "reset",
  8443. value: function reset() {
  8444. _get(_getPrototypeOf(PDFOutlineViewer.prototype), "reset", this).call(this);
  8445. this._outline = null;
  8446. this._pageNumberToDestHashCapability = null;
  8447. this._currentPageNumber = 1;
  8448. this._isPagesLoaded = false;
  8449. }
  8450. }, {
  8451. key: "_dispatchEvent",
  8452. value: function _dispatchEvent(outlineCount) {
  8453. var _this$_pdfDocument;
  8454. this.eventBus.dispatch("outlineloaded", {
  8455. source: this,
  8456. outlineCount: outlineCount,
  8457. enableCurrentOutlineItemButton: outlineCount > 0 && !((_this$_pdfDocument = this._pdfDocument) !== null && _this$_pdfDocument !== void 0 && _this$_pdfDocument.loadingParams.disableAutoFetch)
  8458. });
  8459. }
  8460. }, {
  8461. key: "_bindLink",
  8462. value: function _bindLink(element, _ref) {
  8463. var _this2 = this;
  8464. var url = _ref.url,
  8465. newWindow = _ref.newWindow,
  8466. dest = _ref.dest;
  8467. var linkService = this.linkService;
  8468. if (url) {
  8469. (0, _pdfjsLib.addLinkAttributes)(element, {
  8470. url: url,
  8471. target: newWindow ? _pdfjsLib.LinkTarget.BLANK : linkService.externalLinkTarget,
  8472. rel: linkService.externalLinkRel,
  8473. enabled: linkService.externalLinkEnabled
  8474. });
  8475. return;
  8476. }
  8477. element.href = linkService.getDestinationHash(dest);
  8478. element.onclick = function (evt) {
  8479. _this2._updateCurrentTreeItem(evt.target.parentNode);
  8480. if (dest) {
  8481. linkService.goToDestination(dest);
  8482. }
  8483. return false;
  8484. };
  8485. }
  8486. }, {
  8487. key: "_setStyles",
  8488. value: function _setStyles(element, _ref2) {
  8489. var bold = _ref2.bold,
  8490. italic = _ref2.italic;
  8491. if (bold) {
  8492. element.style.fontWeight = "bold";
  8493. }
  8494. if (italic) {
  8495. element.style.fontStyle = "italic";
  8496. }
  8497. }
  8498. }, {
  8499. key: "_addToggleButton",
  8500. value: function _addToggleButton(div, _ref3) {
  8501. var count = _ref3.count,
  8502. items = _ref3.items;
  8503. var hidden = false;
  8504. if (count < 0) {
  8505. var totalCount = items.length;
  8506. if (totalCount > 0) {
  8507. var queue = _toConsumableArray(items);
  8508. while (queue.length > 0) {
  8509. var _queue$shift = queue.shift(),
  8510. nestedCount = _queue$shift.count,
  8511. nestedItems = _queue$shift.items;
  8512. if (nestedCount > 0 && nestedItems.length > 0) {
  8513. totalCount += nestedItems.length;
  8514. queue.push.apply(queue, _toConsumableArray(nestedItems));
  8515. }
  8516. }
  8517. }
  8518. if (Math.abs(count) === totalCount) {
  8519. hidden = true;
  8520. }
  8521. }
  8522. _get(_getPrototypeOf(PDFOutlineViewer.prototype), "_addToggleButton", this).call(this, div, hidden);
  8523. }
  8524. }, {
  8525. key: "_toggleAllTreeItems",
  8526. value: function _toggleAllTreeItems() {
  8527. if (!this._outline) {
  8528. return;
  8529. }
  8530. _get(_getPrototypeOf(PDFOutlineViewer.prototype), "_toggleAllTreeItems", this).call(this);
  8531. }
  8532. }, {
  8533. key: "render",
  8534. value: function render(_ref4) {
  8535. var outline = _ref4.outline,
  8536. pdfDocument = _ref4.pdfDocument;
  8537. if (this._outline) {
  8538. this.reset();
  8539. }
  8540. this._outline = outline || null;
  8541. this._pdfDocument = pdfDocument || null;
  8542. if (!outline) {
  8543. this._dispatchEvent(0);
  8544. return;
  8545. }
  8546. var fragment = document.createDocumentFragment();
  8547. var queue = [{
  8548. parent: fragment,
  8549. items: outline
  8550. }];
  8551. var outlineCount = 0,
  8552. hasAnyNesting = false;
  8553. while (queue.length > 0) {
  8554. var levelData = queue.shift();
  8555. var _iterator = _createForOfIteratorHelper(levelData.items),
  8556. _step;
  8557. try {
  8558. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  8559. var item = _step.value;
  8560. var div = document.createElement("div");
  8561. div.className = "treeItem";
  8562. var element = document.createElement("a");
  8563. this._bindLink(element, item);
  8564. this._setStyles(element, item);
  8565. element.textContent = this._normalizeTextContent(item.title);
  8566. div.appendChild(element);
  8567. if (item.items.length > 0) {
  8568. hasAnyNesting = true;
  8569. this._addToggleButton(div, item);
  8570. var itemsDiv = document.createElement("div");
  8571. itemsDiv.className = "treeItems";
  8572. div.appendChild(itemsDiv);
  8573. queue.push({
  8574. parent: itemsDiv,
  8575. items: item.items
  8576. });
  8577. }
  8578. levelData.parent.appendChild(div);
  8579. outlineCount++;
  8580. }
  8581. } catch (err) {
  8582. _iterator.e(err);
  8583. } finally {
  8584. _iterator.f();
  8585. }
  8586. }
  8587. this._finishRendering(fragment, outlineCount, hasAnyNesting);
  8588. }
  8589. }, {
  8590. key: "_currentOutlineItem",
  8591. value: function () {
  8592. var _currentOutlineItem2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  8593. var pageNumberToDestHash, i, destHash, linkElement;
  8594. return _regenerator["default"].wrap(function _callee$(_context) {
  8595. while (1) {
  8596. switch (_context.prev = _context.next) {
  8597. case 0:
  8598. if (this._isPagesLoaded) {
  8599. _context.next = 2;
  8600. break;
  8601. }
  8602. throw new Error("_currentOutlineItem: All pages have not been loaded.");
  8603. case 2:
  8604. if (!(!this._outline || !this._pdfDocument)) {
  8605. _context.next = 4;
  8606. break;
  8607. }
  8608. return _context.abrupt("return");
  8609. case 4:
  8610. _context.next = 6;
  8611. return this._getPageNumberToDestHash(this._pdfDocument);
  8612. case 6:
  8613. pageNumberToDestHash = _context.sent;
  8614. if (pageNumberToDestHash) {
  8615. _context.next = 9;
  8616. break;
  8617. }
  8618. return _context.abrupt("return");
  8619. case 9:
  8620. this._updateCurrentTreeItem(null);
  8621. if (!(this._sidebarView !== _ui_utils.SidebarView.OUTLINE)) {
  8622. _context.next = 12;
  8623. break;
  8624. }
  8625. return _context.abrupt("return");
  8626. case 12:
  8627. i = this._currentPageNumber;
  8628. case 13:
  8629. if (!(i > 0)) {
  8630. _context.next = 25;
  8631. break;
  8632. }
  8633. destHash = pageNumberToDestHash.get(i);
  8634. if (destHash) {
  8635. _context.next = 17;
  8636. break;
  8637. }
  8638. return _context.abrupt("continue", 22);
  8639. case 17:
  8640. linkElement = this.container.querySelector("a[href=\"".concat(destHash, "\"]"));
  8641. if (linkElement) {
  8642. _context.next = 20;
  8643. break;
  8644. }
  8645. return _context.abrupt("continue", 22);
  8646. case 20:
  8647. this._scrollToCurrentTreeItem(linkElement.parentNode);
  8648. return _context.abrupt("break", 25);
  8649. case 22:
  8650. i--;
  8651. _context.next = 13;
  8652. break;
  8653. case 25:
  8654. case "end":
  8655. return _context.stop();
  8656. }
  8657. }
  8658. }, _callee, this);
  8659. }));
  8660. function _currentOutlineItem() {
  8661. return _currentOutlineItem2.apply(this, arguments);
  8662. }
  8663. return _currentOutlineItem;
  8664. }()
  8665. }, {
  8666. key: "_getPageNumberToDestHash",
  8667. value: function () {
  8668. var _getPageNumberToDestHash2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(pdfDocument) {
  8669. var pageNumberToDestHash, pageNumberNesting, queue, levelData, currentNesting, _iterator2, _step2, _step2$value, dest, items, explicitDest, pageNumber, _explicitDest, _explicitDest2, destRef, destHash;
  8670. return _regenerator["default"].wrap(function _callee2$(_context2) {
  8671. while (1) {
  8672. switch (_context2.prev = _context2.next) {
  8673. case 0:
  8674. if (!this._pageNumberToDestHashCapability) {
  8675. _context2.next = 2;
  8676. break;
  8677. }
  8678. return _context2.abrupt("return", this._pageNumberToDestHashCapability.promise);
  8679. case 2:
  8680. this._pageNumberToDestHashCapability = (0, _pdfjsLib.createPromiseCapability)();
  8681. pageNumberToDestHash = new Map(), pageNumberNesting = new Map();
  8682. queue = [{
  8683. nesting: 0,
  8684. items: this._outline
  8685. }];
  8686. case 5:
  8687. if (!(queue.length > 0)) {
  8688. _context2.next = 56;
  8689. break;
  8690. }
  8691. levelData = queue.shift(), currentNesting = levelData.nesting;
  8692. _iterator2 = _createForOfIteratorHelper(levelData.items);
  8693. _context2.prev = 8;
  8694. _iterator2.s();
  8695. case 10:
  8696. if ((_step2 = _iterator2.n()).done) {
  8697. _context2.next = 46;
  8698. break;
  8699. }
  8700. _step2$value = _step2.value, dest = _step2$value.dest, items = _step2$value.items;
  8701. explicitDest = void 0, pageNumber = void 0;
  8702. if (!(typeof dest === "string")) {
  8703. _context2.next = 21;
  8704. break;
  8705. }
  8706. _context2.next = 16;
  8707. return pdfDocument.getDestination(dest);
  8708. case 16:
  8709. explicitDest = _context2.sent;
  8710. if (!(pdfDocument !== this._pdfDocument)) {
  8711. _context2.next = 19;
  8712. break;
  8713. }
  8714. return _context2.abrupt("return", null);
  8715. case 19:
  8716. _context2.next = 22;
  8717. break;
  8718. case 21:
  8719. explicitDest = dest;
  8720. case 22:
  8721. if (!Array.isArray(explicitDest)) {
  8722. _context2.next = 43;
  8723. break;
  8724. }
  8725. _explicitDest = explicitDest, _explicitDest2 = _slicedToArray(_explicitDest, 1), destRef = _explicitDest2[0];
  8726. if (!(_typeof(destRef) === "object")) {
  8727. _context2.next = 41;
  8728. break;
  8729. }
  8730. pageNumber = this.linkService._cachedPageNumber(destRef);
  8731. if (pageNumber) {
  8732. _context2.next = 39;
  8733. break;
  8734. }
  8735. _context2.prev = 27;
  8736. _context2.next = 30;
  8737. return pdfDocument.getPageIndex(destRef);
  8738. case 30:
  8739. _context2.t0 = _context2.sent;
  8740. pageNumber = _context2.t0 + 1;
  8741. if (!(pdfDocument !== this._pdfDocument)) {
  8742. _context2.next = 34;
  8743. break;
  8744. }
  8745. return _context2.abrupt("return", null);
  8746. case 34:
  8747. this.linkService.cachePageRef(pageNumber, destRef);
  8748. _context2.next = 39;
  8749. break;
  8750. case 37:
  8751. _context2.prev = 37;
  8752. _context2.t1 = _context2["catch"](27);
  8753. case 39:
  8754. _context2.next = 42;
  8755. break;
  8756. case 41:
  8757. if (Number.isInteger(destRef)) {
  8758. pageNumber = destRef + 1;
  8759. }
  8760. case 42:
  8761. if (Number.isInteger(pageNumber) && (!pageNumberToDestHash.has(pageNumber) || currentNesting > pageNumberNesting.get(pageNumber))) {
  8762. destHash = this.linkService.getDestinationHash(dest);
  8763. pageNumberToDestHash.set(pageNumber, destHash);
  8764. pageNumberNesting.set(pageNumber, currentNesting);
  8765. }
  8766. case 43:
  8767. if (items.length > 0) {
  8768. queue.push({
  8769. nesting: currentNesting + 1,
  8770. items: items
  8771. });
  8772. }
  8773. case 44:
  8774. _context2.next = 10;
  8775. break;
  8776. case 46:
  8777. _context2.next = 51;
  8778. break;
  8779. case 48:
  8780. _context2.prev = 48;
  8781. _context2.t2 = _context2["catch"](8);
  8782. _iterator2.e(_context2.t2);
  8783. case 51:
  8784. _context2.prev = 51;
  8785. _iterator2.f();
  8786. return _context2.finish(51);
  8787. case 54:
  8788. _context2.next = 5;
  8789. break;
  8790. case 56:
  8791. this._pageNumberToDestHashCapability.resolve(pageNumberToDestHash.size > 0 ? pageNumberToDestHash : null);
  8792. return _context2.abrupt("return", this._pageNumberToDestHashCapability.promise);
  8793. case 58:
  8794. case "end":
  8795. return _context2.stop();
  8796. }
  8797. }
  8798. }, _callee2, this, [[8, 48, 51, 54], [27, 37]]);
  8799. }));
  8800. function _getPageNumberToDestHash(_x) {
  8801. return _getPageNumberToDestHash2.apply(this, arguments);
  8802. }
  8803. return _getPageNumberToDestHash;
  8804. }()
  8805. }]);
  8806. return PDFOutlineViewer;
  8807. }(_base_tree_viewer.BaseTreeViewer);
  8808. exports.PDFOutlineViewer = PDFOutlineViewer;
  8809. /***/ }),
  8810. /* 23 */
  8811. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  8812. Object.defineProperty(exports, "__esModule", ({
  8813. value: true
  8814. }));
  8815. exports.PDFPresentationMode = void 0;
  8816. var _ui_utils = __webpack_require__(6);
  8817. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8818. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  8819. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8820. var DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1500;
  8821. var DELAY_BEFORE_HIDING_CONTROLS = 3000;
  8822. var ACTIVE_SELECTOR = "pdfPresentationMode";
  8823. var CONTROLS_SELECTOR = "pdfPresentationModeControls";
  8824. var MOUSE_SCROLL_COOLDOWN_TIME = 50;
  8825. var PAGE_SWITCH_THRESHOLD = 0.1;
  8826. var SWIPE_MIN_DISTANCE_THRESHOLD = 50;
  8827. var SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
  8828. var PDFPresentationMode = /*#__PURE__*/function () {
  8829. function PDFPresentationMode(_ref) {
  8830. var _this = this;
  8831. var container = _ref.container,
  8832. pdfViewer = _ref.pdfViewer,
  8833. eventBus = _ref.eventBus,
  8834. _ref$contextMenuItems = _ref.contextMenuItems,
  8835. contextMenuItems = _ref$contextMenuItems === void 0 ? null : _ref$contextMenuItems;
  8836. _classCallCheck(this, PDFPresentationMode);
  8837. this.container = container;
  8838. this.pdfViewer = pdfViewer;
  8839. this.eventBus = eventBus;
  8840. this.active = false;
  8841. this.args = null;
  8842. this.contextMenuOpen = false;
  8843. this.mouseScrollTimeStamp = 0;
  8844. this.mouseScrollDelta = 0;
  8845. this.touchSwipeState = null;
  8846. if (contextMenuItems) {
  8847. contextMenuItems.contextFirstPage.addEventListener("click", function () {
  8848. _this.contextMenuOpen = false;
  8849. _this.eventBus.dispatch("firstpage", {
  8850. source: _this
  8851. });
  8852. });
  8853. contextMenuItems.contextLastPage.addEventListener("click", function () {
  8854. _this.contextMenuOpen = false;
  8855. _this.eventBus.dispatch("lastpage", {
  8856. source: _this
  8857. });
  8858. });
  8859. contextMenuItems.contextPageRotateCw.addEventListener("click", function () {
  8860. _this.contextMenuOpen = false;
  8861. _this.eventBus.dispatch("rotatecw", {
  8862. source: _this
  8863. });
  8864. });
  8865. contextMenuItems.contextPageRotateCcw.addEventListener("click", function () {
  8866. _this.contextMenuOpen = false;
  8867. _this.eventBus.dispatch("rotateccw", {
  8868. source: _this
  8869. });
  8870. });
  8871. }
  8872. }
  8873. _createClass(PDFPresentationMode, [{
  8874. key: "request",
  8875. value: function request() {
  8876. if (this.switchInProgress || this.active || !this.pdfViewer.pagesCount) {
  8877. return false;
  8878. }
  8879. this._addFullscreenChangeListeners();
  8880. this._setSwitchInProgress();
  8881. this._notifyStateChange();
  8882. if (this.container.requestFullscreen) {
  8883. this.container.requestFullscreen();
  8884. } else if (this.container.mozRequestFullScreen) {
  8885. this.container.mozRequestFullScreen();
  8886. } else if (this.container.webkitRequestFullscreen) {
  8887. this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
  8888. } else {
  8889. return false;
  8890. }
  8891. this.args = {
  8892. page: this.pdfViewer.currentPageNumber,
  8893. previousScale: this.pdfViewer.currentScaleValue
  8894. };
  8895. return true;
  8896. }
  8897. }, {
  8898. key: "_mouseWheel",
  8899. value: function _mouseWheel(evt) {
  8900. if (!this.active) {
  8901. return;
  8902. }
  8903. evt.preventDefault();
  8904. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  8905. var currentTime = new Date().getTime();
  8906. var storedTime = this.mouseScrollTimeStamp;
  8907. if (currentTime > storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {
  8908. return;
  8909. }
  8910. if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) {
  8911. this._resetMouseScrollState();
  8912. }
  8913. this.mouseScrollDelta += delta;
  8914. if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
  8915. var totalDelta = this.mouseScrollDelta;
  8916. this._resetMouseScrollState();
  8917. var success = totalDelta > 0 ? this.pdfViewer.previousPage() : this.pdfViewer.nextPage();
  8918. if (success) {
  8919. this.mouseScrollTimeStamp = currentTime;
  8920. }
  8921. }
  8922. }
  8923. }, {
  8924. key: "_notifyStateChange",
  8925. value: function _notifyStateChange() {
  8926. var state = _ui_utils.PresentationModeState.NORMAL;
  8927. if (this.switchInProgress) {
  8928. state = _ui_utils.PresentationModeState.CHANGING;
  8929. } else if (this.active) {
  8930. state = _ui_utils.PresentationModeState.FULLSCREEN;
  8931. }
  8932. this.eventBus.dispatch("presentationmodechanged", {
  8933. source: this,
  8934. state: state,
  8935. get active() {
  8936. throw new Error("Deprecated parameter: `active`, please use `state` instead.");
  8937. },
  8938. get switchInProgress() {
  8939. throw new Error("Deprecated parameter: `switchInProgress`, please use `state` instead.");
  8940. }
  8941. });
  8942. }
  8943. }, {
  8944. key: "_setSwitchInProgress",
  8945. value: function _setSwitchInProgress() {
  8946. var _this2 = this;
  8947. if (this.switchInProgress) {
  8948. clearTimeout(this.switchInProgress);
  8949. }
  8950. this.switchInProgress = setTimeout(function () {
  8951. _this2._removeFullscreenChangeListeners();
  8952. delete _this2.switchInProgress;
  8953. _this2._notifyStateChange();
  8954. }, DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS);
  8955. }
  8956. }, {
  8957. key: "_resetSwitchInProgress",
  8958. value: function _resetSwitchInProgress() {
  8959. if (this.switchInProgress) {
  8960. clearTimeout(this.switchInProgress);
  8961. delete this.switchInProgress;
  8962. }
  8963. }
  8964. }, {
  8965. key: "_enter",
  8966. value: function _enter() {
  8967. var _this3 = this;
  8968. this.active = true;
  8969. this._resetSwitchInProgress();
  8970. this._notifyStateChange();
  8971. this.container.classList.add(ACTIVE_SELECTOR);
  8972. setTimeout(function () {
  8973. _this3.pdfViewer.currentPageNumber = _this3.args.page;
  8974. _this3.pdfViewer.currentScaleValue = "page-fit";
  8975. }, 0);
  8976. this._addWindowListeners();
  8977. this._showControls();
  8978. this.contextMenuOpen = false;
  8979. this.container.setAttribute("contextmenu", "viewerContextMenu");
  8980. window.getSelection().removeAllRanges();
  8981. }
  8982. }, {
  8983. key: "_exit",
  8984. value: function _exit() {
  8985. var _this4 = this;
  8986. var page = this.pdfViewer.currentPageNumber;
  8987. this.container.classList.remove(ACTIVE_SELECTOR);
  8988. setTimeout(function () {
  8989. _this4.active = false;
  8990. _this4._removeFullscreenChangeListeners();
  8991. _this4._notifyStateChange();
  8992. _this4.pdfViewer.currentScaleValue = _this4.args.previousScale;
  8993. _this4.pdfViewer.currentPageNumber = page;
  8994. _this4.args = null;
  8995. }, 0);
  8996. this._removeWindowListeners();
  8997. this._hideControls();
  8998. this._resetMouseScrollState();
  8999. this.container.removeAttribute("contextmenu");
  9000. this.contextMenuOpen = false;
  9001. }
  9002. }, {
  9003. key: "_mouseDown",
  9004. value: function _mouseDown(evt) {
  9005. if (this.contextMenuOpen) {
  9006. this.contextMenuOpen = false;
  9007. evt.preventDefault();
  9008. return;
  9009. }
  9010. if (evt.button === 0) {
  9011. var isInternalLink = evt.target.href && evt.target.classList.contains("internalLink");
  9012. if (!isInternalLink) {
  9013. evt.preventDefault();
  9014. if (evt.shiftKey) {
  9015. this.pdfViewer.previousPage();
  9016. } else {
  9017. this.pdfViewer.nextPage();
  9018. }
  9019. }
  9020. }
  9021. }
  9022. }, {
  9023. key: "_contextMenu",
  9024. value: function _contextMenu() {
  9025. this.contextMenuOpen = true;
  9026. }
  9027. }, {
  9028. key: "_showControls",
  9029. value: function _showControls() {
  9030. var _this5 = this;
  9031. if (this.controlsTimeout) {
  9032. clearTimeout(this.controlsTimeout);
  9033. } else {
  9034. this.container.classList.add(CONTROLS_SELECTOR);
  9035. }
  9036. this.controlsTimeout = setTimeout(function () {
  9037. _this5.container.classList.remove(CONTROLS_SELECTOR);
  9038. delete _this5.controlsTimeout;
  9039. }, DELAY_BEFORE_HIDING_CONTROLS);
  9040. }
  9041. }, {
  9042. key: "_hideControls",
  9043. value: function _hideControls() {
  9044. if (!this.controlsTimeout) {
  9045. return;
  9046. }
  9047. clearTimeout(this.controlsTimeout);
  9048. this.container.classList.remove(CONTROLS_SELECTOR);
  9049. delete this.controlsTimeout;
  9050. }
  9051. }, {
  9052. key: "_resetMouseScrollState",
  9053. value: function _resetMouseScrollState() {
  9054. this.mouseScrollTimeStamp = 0;
  9055. this.mouseScrollDelta = 0;
  9056. }
  9057. }, {
  9058. key: "_touchSwipe",
  9059. value: function _touchSwipe(evt) {
  9060. if (!this.active) {
  9061. return;
  9062. }
  9063. if (evt.touches.length > 1) {
  9064. this.touchSwipeState = null;
  9065. return;
  9066. }
  9067. switch (evt.type) {
  9068. case "touchstart":
  9069. this.touchSwipeState = {
  9070. startX: evt.touches[0].pageX,
  9071. startY: evt.touches[0].pageY,
  9072. endX: evt.touches[0].pageX,
  9073. endY: evt.touches[0].pageY
  9074. };
  9075. break;
  9076. case "touchmove":
  9077. if (this.touchSwipeState === null) {
  9078. return;
  9079. }
  9080. this.touchSwipeState.endX = evt.touches[0].pageX;
  9081. this.touchSwipeState.endY = evt.touches[0].pageY;
  9082. evt.preventDefault();
  9083. break;
  9084. case "touchend":
  9085. if (this.touchSwipeState === null) {
  9086. return;
  9087. }
  9088. var delta = 0;
  9089. var dx = this.touchSwipeState.endX - this.touchSwipeState.startX;
  9090. var dy = this.touchSwipeState.endY - this.touchSwipeState.startY;
  9091. var absAngle = Math.abs(Math.atan2(dy, dx));
  9092. if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <= SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI - SWIPE_ANGLE_THRESHOLD)) {
  9093. delta = dx;
  9094. } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math.abs(absAngle - Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) {
  9095. delta = dy;
  9096. }
  9097. if (delta > 0) {
  9098. this.pdfViewer.previousPage();
  9099. } else if (delta < 0) {
  9100. this.pdfViewer.nextPage();
  9101. }
  9102. break;
  9103. }
  9104. }
  9105. }, {
  9106. key: "_addWindowListeners",
  9107. value: function _addWindowListeners() {
  9108. this.showControlsBind = this._showControls.bind(this);
  9109. this.mouseDownBind = this._mouseDown.bind(this);
  9110. this.mouseWheelBind = this._mouseWheel.bind(this);
  9111. this.resetMouseScrollStateBind = this._resetMouseScrollState.bind(this);
  9112. this.contextMenuBind = this._contextMenu.bind(this);
  9113. this.touchSwipeBind = this._touchSwipe.bind(this);
  9114. window.addEventListener("mousemove", this.showControlsBind);
  9115. window.addEventListener("mousedown", this.mouseDownBind);
  9116. window.addEventListener("wheel", this.mouseWheelBind, {
  9117. passive: false
  9118. });
  9119. window.addEventListener("keydown", this.resetMouseScrollStateBind);
  9120. window.addEventListener("contextmenu", this.contextMenuBind);
  9121. window.addEventListener("touchstart", this.touchSwipeBind);
  9122. window.addEventListener("touchmove", this.touchSwipeBind);
  9123. window.addEventListener("touchend", this.touchSwipeBind);
  9124. }
  9125. }, {
  9126. key: "_removeWindowListeners",
  9127. value: function _removeWindowListeners() {
  9128. window.removeEventListener("mousemove", this.showControlsBind);
  9129. window.removeEventListener("mousedown", this.mouseDownBind);
  9130. window.removeEventListener("wheel", this.mouseWheelBind, {
  9131. passive: false
  9132. });
  9133. window.removeEventListener("keydown", this.resetMouseScrollStateBind);
  9134. window.removeEventListener("contextmenu", this.contextMenuBind);
  9135. window.removeEventListener("touchstart", this.touchSwipeBind);
  9136. window.removeEventListener("touchmove", this.touchSwipeBind);
  9137. window.removeEventListener("touchend", this.touchSwipeBind);
  9138. delete this.showControlsBind;
  9139. delete this.mouseDownBind;
  9140. delete this.mouseWheelBind;
  9141. delete this.resetMouseScrollStateBind;
  9142. delete this.contextMenuBind;
  9143. delete this.touchSwipeBind;
  9144. }
  9145. }, {
  9146. key: "_fullscreenChange",
  9147. value: function _fullscreenChange() {
  9148. if (this.isFullscreen) {
  9149. this._enter();
  9150. } else {
  9151. this._exit();
  9152. }
  9153. }
  9154. }, {
  9155. key: "_addFullscreenChangeListeners",
  9156. value: function _addFullscreenChangeListeners() {
  9157. this.fullscreenChangeBind = this._fullscreenChange.bind(this);
  9158. window.addEventListener("fullscreenchange", this.fullscreenChangeBind);
  9159. window.addEventListener("mozfullscreenchange", this.fullscreenChangeBind);
  9160. window.addEventListener("webkitfullscreenchange", this.fullscreenChangeBind);
  9161. }
  9162. }, {
  9163. key: "_removeFullscreenChangeListeners",
  9164. value: function _removeFullscreenChangeListeners() {
  9165. window.removeEventListener("fullscreenchange", this.fullscreenChangeBind);
  9166. window.removeEventListener("mozfullscreenchange", this.fullscreenChangeBind);
  9167. window.removeEventListener("webkitfullscreenchange", this.fullscreenChangeBind);
  9168. delete this.fullscreenChangeBind;
  9169. }
  9170. }, {
  9171. key: "isFullscreen",
  9172. get: function get() {
  9173. return !!(document.fullscreenElement || document.mozFullScreen || document.webkitIsFullScreen);
  9174. }
  9175. }]);
  9176. return PDFPresentationMode;
  9177. }();
  9178. exports.PDFPresentationMode = PDFPresentationMode;
  9179. /***/ }),
  9180. /* 24 */
  9181. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  9182. Object.defineProperty(exports, "__esModule", ({
  9183. value: true
  9184. }));
  9185. exports.PDFSidebar = void 0;
  9186. var _ui_utils = __webpack_require__(6);
  9187. var _pdf_rendering_queue = __webpack_require__(10);
  9188. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9189. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  9190. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9191. var UI_NOTIFICATION_CLASS = "pdfSidebarNotification";
  9192. var PDFSidebar = /*#__PURE__*/function () {
  9193. function PDFSidebar(_ref) {
  9194. var elements = _ref.elements,
  9195. pdfViewer = _ref.pdfViewer,
  9196. pdfThumbnailViewer = _ref.pdfThumbnailViewer,
  9197. eventBus = _ref.eventBus,
  9198. _ref$l10n = _ref.l10n,
  9199. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  9200. _classCallCheck(this, PDFSidebar);
  9201. this.isOpen = false;
  9202. this.active = _ui_utils.SidebarView.THUMBS;
  9203. this.isInitialViewSet = false;
  9204. this.onToggled = null;
  9205. this.pdfViewer = pdfViewer;
  9206. this.pdfThumbnailViewer = pdfThumbnailViewer;
  9207. this.outerContainer = elements.outerContainer;
  9208. this.viewerContainer = elements.viewerContainer;
  9209. this.toggleButton = elements.toggleButton;
  9210. this.thumbnailButton = elements.thumbnailButton;
  9211. this.outlineButton = elements.outlineButton;
  9212. this.attachmentsButton = elements.attachmentsButton;
  9213. this.layersButton = elements.layersButton;
  9214. this.thumbnailView = elements.thumbnailView;
  9215. this.outlineView = elements.outlineView;
  9216. this.attachmentsView = elements.attachmentsView;
  9217. this.layersView = elements.layersView;
  9218. this._outlineOptionsContainer = elements.outlineOptionsContainer;
  9219. this._currentOutlineItemButton = elements.currentOutlineItemButton;
  9220. this.eventBus = eventBus;
  9221. this.l10n = l10n;
  9222. this._addEventListeners();
  9223. }
  9224. _createClass(PDFSidebar, [{
  9225. key: "reset",
  9226. value: function reset() {
  9227. this.isInitialViewSet = false;
  9228. this._hideUINotification(true);
  9229. this.switchView(_ui_utils.SidebarView.THUMBS);
  9230. this.outlineButton.disabled = false;
  9231. this.attachmentsButton.disabled = false;
  9232. this.layersButton.disabled = false;
  9233. this._currentOutlineItemButton.disabled = true;
  9234. }
  9235. }, {
  9236. key: "setInitialView",
  9237. value: function setInitialView() {
  9238. var view = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _ui_utils.SidebarView.NONE;
  9239. if (this.isInitialViewSet) {
  9240. return;
  9241. }
  9242. this.isInitialViewSet = true;
  9243. if (view === _ui_utils.SidebarView.NONE || view === _ui_utils.SidebarView.UNKNOWN) {
  9244. this._dispatchEvent();
  9245. return;
  9246. }
  9247. if (!this._switchView(view, true)) {
  9248. this._dispatchEvent();
  9249. }
  9250. }
  9251. }, {
  9252. key: "switchView",
  9253. value: function switchView(view) {
  9254. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9255. this._switchView(view, forceOpen);
  9256. }
  9257. }, {
  9258. key: "_switchView",
  9259. value: function _switchView(view) {
  9260. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9261. var isViewChanged = view !== this.active;
  9262. var shouldForceRendering = false;
  9263. switch (view) {
  9264. case _ui_utils.SidebarView.NONE:
  9265. if (this.isOpen) {
  9266. this.close();
  9267. return true;
  9268. }
  9269. return false;
  9270. case _ui_utils.SidebarView.THUMBS:
  9271. if (this.isOpen && isViewChanged) {
  9272. shouldForceRendering = true;
  9273. }
  9274. break;
  9275. case _ui_utils.SidebarView.OUTLINE:
  9276. if (this.outlineButton.disabled) {
  9277. return false;
  9278. }
  9279. break;
  9280. case _ui_utils.SidebarView.ATTACHMENTS:
  9281. if (this.attachmentsButton.disabled) {
  9282. return false;
  9283. }
  9284. break;
  9285. case _ui_utils.SidebarView.LAYERS:
  9286. if (this.layersButton.disabled) {
  9287. return false;
  9288. }
  9289. break;
  9290. default:
  9291. console.error("PDFSidebar._switchView: \"".concat(view, "\" is not a valid view."));
  9292. return false;
  9293. }
  9294. this.active = view;
  9295. this.thumbnailButton.classList.toggle("toggled", view === _ui_utils.SidebarView.THUMBS);
  9296. this.outlineButton.classList.toggle("toggled", view === _ui_utils.SidebarView.OUTLINE);
  9297. this.attachmentsButton.classList.toggle("toggled", view === _ui_utils.SidebarView.ATTACHMENTS);
  9298. this.layersButton.classList.toggle("toggled", view === _ui_utils.SidebarView.LAYERS);
  9299. this.thumbnailView.classList.toggle("hidden", view !== _ui_utils.SidebarView.THUMBS);
  9300. this.outlineView.classList.toggle("hidden", view !== _ui_utils.SidebarView.OUTLINE);
  9301. this.attachmentsView.classList.toggle("hidden", view !== _ui_utils.SidebarView.ATTACHMENTS);
  9302. this.layersView.classList.toggle("hidden", view !== _ui_utils.SidebarView.LAYERS);
  9303. this._outlineOptionsContainer.classList.toggle("hidden", view !== _ui_utils.SidebarView.OUTLINE);
  9304. if (forceOpen && !this.isOpen) {
  9305. this.open();
  9306. return true;
  9307. }
  9308. if (shouldForceRendering) {
  9309. this._updateThumbnailViewer();
  9310. this._forceRendering();
  9311. }
  9312. if (isViewChanged) {
  9313. this._dispatchEvent();
  9314. }
  9315. return isViewChanged;
  9316. }
  9317. }, {
  9318. key: "open",
  9319. value: function open() {
  9320. if (this.isOpen) {
  9321. return;
  9322. }
  9323. this.isOpen = true;
  9324. this.toggleButton.classList.add("toggled");
  9325. this.outerContainer.classList.add("sidebarMoving", "sidebarOpen");
  9326. if (this.active === _ui_utils.SidebarView.THUMBS) {
  9327. this._updateThumbnailViewer();
  9328. }
  9329. this._forceRendering();
  9330. this._dispatchEvent();
  9331. this._hideUINotification();
  9332. }
  9333. }, {
  9334. key: "close",
  9335. value: function close() {
  9336. if (!this.isOpen) {
  9337. return;
  9338. }
  9339. this.isOpen = false;
  9340. this.toggleButton.classList.remove("toggled");
  9341. this.outerContainer.classList.add("sidebarMoving");
  9342. this.outerContainer.classList.remove("sidebarOpen");
  9343. this._forceRendering();
  9344. this._dispatchEvent();
  9345. }
  9346. }, {
  9347. key: "toggle",
  9348. value: function toggle() {
  9349. if (this.isOpen) {
  9350. this.close();
  9351. } else {
  9352. this.open();
  9353. }
  9354. }
  9355. }, {
  9356. key: "_dispatchEvent",
  9357. value: function _dispatchEvent() {
  9358. this.eventBus.dispatch("sidebarviewchanged", {
  9359. source: this,
  9360. view: this.visibleView
  9361. });
  9362. }
  9363. }, {
  9364. key: "_forceRendering",
  9365. value: function _forceRendering() {
  9366. if (this.onToggled) {
  9367. this.onToggled();
  9368. } else {
  9369. this.pdfViewer.forceRendering();
  9370. this.pdfThumbnailViewer.forceRendering();
  9371. }
  9372. }
  9373. }, {
  9374. key: "_updateThumbnailViewer",
  9375. value: function _updateThumbnailViewer() {
  9376. var pdfViewer = this.pdfViewer,
  9377. pdfThumbnailViewer = this.pdfThumbnailViewer;
  9378. var pagesCount = pdfViewer.pagesCount;
  9379. for (var pageIndex = 0; pageIndex < pagesCount; pageIndex++) {
  9380. var pageView = pdfViewer.getPageView(pageIndex);
  9381. if (pageView && pageView.renderingState === _pdf_rendering_queue.RenderingStates.FINISHED) {
  9382. var thumbnailView = pdfThumbnailViewer.getThumbnail(pageIndex);
  9383. thumbnailView.setImage(pageView);
  9384. }
  9385. }
  9386. pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
  9387. }
  9388. }, {
  9389. key: "_showUINotification",
  9390. value: function _showUINotification() {
  9391. var _this = this;
  9392. this.l10n.get("toggle_sidebar_notification2.title", null, "Toggle Sidebar (document contains outline/attachments/layers)").then(function (msg) {
  9393. _this.toggleButton.title = msg;
  9394. });
  9395. if (!this.isOpen) {
  9396. this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
  9397. }
  9398. }
  9399. }, {
  9400. key: "_hideUINotification",
  9401. value: function _hideUINotification() {
  9402. var _this2 = this;
  9403. var reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9404. if (this.isOpen || reset) {
  9405. this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
  9406. }
  9407. if (reset) {
  9408. this.l10n.get("toggle_sidebar.title", null, "Toggle Sidebar").then(function (msg) {
  9409. _this2.toggleButton.title = msg;
  9410. });
  9411. }
  9412. }
  9413. }, {
  9414. key: "_addEventListeners",
  9415. value: function _addEventListeners() {
  9416. var _this3 = this;
  9417. this.viewerContainer.addEventListener("transitionend", function (evt) {
  9418. if (evt.target === _this3.viewerContainer) {
  9419. _this3.outerContainer.classList.remove("sidebarMoving");
  9420. }
  9421. });
  9422. this.toggleButton.addEventListener("click", function () {
  9423. _this3.toggle();
  9424. });
  9425. this.thumbnailButton.addEventListener("click", function () {
  9426. _this3.switchView(_ui_utils.SidebarView.THUMBS);
  9427. });
  9428. this.outlineButton.addEventListener("click", function () {
  9429. _this3.switchView(_ui_utils.SidebarView.OUTLINE);
  9430. });
  9431. this.outlineButton.addEventListener("dblclick", function () {
  9432. _this3.eventBus.dispatch("toggleoutlinetree", {
  9433. source: _this3
  9434. });
  9435. });
  9436. this.attachmentsButton.addEventListener("click", function () {
  9437. _this3.switchView(_ui_utils.SidebarView.ATTACHMENTS);
  9438. });
  9439. this.layersButton.addEventListener("click", function () {
  9440. _this3.switchView(_ui_utils.SidebarView.LAYERS);
  9441. });
  9442. this.layersButton.addEventListener("dblclick", function () {
  9443. _this3.eventBus.dispatch("resetlayers", {
  9444. source: _this3
  9445. });
  9446. });
  9447. this._currentOutlineItemButton.addEventListener("click", function () {
  9448. _this3.eventBus.dispatch("currentoutlineitem", {
  9449. source: _this3
  9450. });
  9451. });
  9452. var onTreeLoaded = function onTreeLoaded(count, button, view) {
  9453. button.disabled = !count;
  9454. if (count) {
  9455. _this3._showUINotification();
  9456. } else if (_this3.active === view) {
  9457. _this3.switchView(_ui_utils.SidebarView.THUMBS);
  9458. }
  9459. };
  9460. this.eventBus._on("outlineloaded", function (evt) {
  9461. onTreeLoaded(evt.outlineCount, _this3.outlineButton, _ui_utils.SidebarView.OUTLINE);
  9462. if (evt.enableCurrentOutlineItemButton) {
  9463. _this3.pdfViewer.pagesPromise.then(function () {
  9464. _this3._currentOutlineItemButton.disabled = !_this3.isInitialViewSet;
  9465. });
  9466. }
  9467. });
  9468. this.eventBus._on("attachmentsloaded", function (evt) {
  9469. onTreeLoaded(evt.attachmentsCount, _this3.attachmentsButton, _ui_utils.SidebarView.ATTACHMENTS);
  9470. });
  9471. this.eventBus._on("layersloaded", function (evt) {
  9472. onTreeLoaded(evt.layersCount, _this3.layersButton, _ui_utils.SidebarView.LAYERS);
  9473. });
  9474. this.eventBus._on("presentationmodechanged", function (evt) {
  9475. if (evt.state === _ui_utils.PresentationModeState.NORMAL && _this3.isThumbnailViewVisible) {
  9476. _this3._updateThumbnailViewer();
  9477. }
  9478. });
  9479. }
  9480. }, {
  9481. key: "visibleView",
  9482. get: function get() {
  9483. return this.isOpen ? this.active : _ui_utils.SidebarView.NONE;
  9484. }
  9485. }, {
  9486. key: "isThumbnailViewVisible",
  9487. get: function get() {
  9488. return this.isOpen && this.active === _ui_utils.SidebarView.THUMBS;
  9489. }
  9490. }, {
  9491. key: "isOutlineViewVisible",
  9492. get: function get() {
  9493. return this.isOpen && this.active === _ui_utils.SidebarView.OUTLINE;
  9494. }
  9495. }, {
  9496. key: "isAttachmentsViewVisible",
  9497. get: function get() {
  9498. return this.isOpen && this.active === _ui_utils.SidebarView.ATTACHMENTS;
  9499. }
  9500. }, {
  9501. key: "isLayersViewVisible",
  9502. get: function get() {
  9503. return this.isOpen && this.active === _ui_utils.SidebarView.LAYERS;
  9504. }
  9505. }]);
  9506. return PDFSidebar;
  9507. }();
  9508. exports.PDFSidebar = PDFSidebar;
  9509. /***/ }),
  9510. /* 25 */
  9511. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  9512. Object.defineProperty(exports, "__esModule", ({
  9513. value: true
  9514. }));
  9515. exports.PDFSidebarResizer = void 0;
  9516. var _ui_utils = __webpack_require__(6);
  9517. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9518. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  9519. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9520. var SIDEBAR_WIDTH_VAR = "--sidebar-width";
  9521. var SIDEBAR_MIN_WIDTH = 200;
  9522. var SIDEBAR_RESIZING_CLASS = "sidebarResizing";
  9523. var PDFSidebarResizer = /*#__PURE__*/function () {
  9524. function PDFSidebarResizer(options, eventBus) {
  9525. var _this = this;
  9526. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  9527. _classCallCheck(this, PDFSidebarResizer);
  9528. this.isRTL = false;
  9529. this.sidebarOpen = false;
  9530. this.doc = document.documentElement;
  9531. this._width = null;
  9532. this._outerContainerWidth = null;
  9533. this._boundEvents = Object.create(null);
  9534. this.outerContainer = options.outerContainer;
  9535. this.resizer = options.resizer;
  9536. this.eventBus = eventBus;
  9537. l10n.getDirection().then(function (dir) {
  9538. _this.isRTL = dir === "rtl";
  9539. });
  9540. this._addEventListeners();
  9541. }
  9542. _createClass(PDFSidebarResizer, [{
  9543. key: "_updateWidth",
  9544. value: function _updateWidth() {
  9545. var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  9546. var maxWidth = Math.floor(this.outerContainerWidth / 2);
  9547. if (width > maxWidth) {
  9548. width = maxWidth;
  9549. }
  9550. if (width < SIDEBAR_MIN_WIDTH) {
  9551. width = SIDEBAR_MIN_WIDTH;
  9552. }
  9553. if (width === this._width) {
  9554. return false;
  9555. }
  9556. this._width = width;
  9557. this.doc.style.setProperty(SIDEBAR_WIDTH_VAR, "".concat(width, "px"));
  9558. return true;
  9559. }
  9560. }, {
  9561. key: "_mouseMove",
  9562. value: function _mouseMove(evt) {
  9563. var width = evt.clientX;
  9564. if (this.isRTL) {
  9565. width = this.outerContainerWidth - width;
  9566. }
  9567. this._updateWidth(width);
  9568. }
  9569. }, {
  9570. key: "_mouseUp",
  9571. value: function _mouseUp(evt) {
  9572. this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  9573. this.eventBus.dispatch("resize", {
  9574. source: this
  9575. });
  9576. var _boundEvents = this._boundEvents;
  9577. window.removeEventListener("mousemove", _boundEvents.mouseMove);
  9578. window.removeEventListener("mouseup", _boundEvents.mouseUp);
  9579. }
  9580. }, {
  9581. key: "_addEventListeners",
  9582. value: function _addEventListeners() {
  9583. var _this2 = this;
  9584. var _boundEvents = this._boundEvents;
  9585. _boundEvents.mouseMove = this._mouseMove.bind(this);
  9586. _boundEvents.mouseUp = this._mouseUp.bind(this);
  9587. this.resizer.addEventListener("mousedown", function (evt) {
  9588. if (evt.button !== 0) {
  9589. return;
  9590. }
  9591. _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  9592. window.addEventListener("mousemove", _boundEvents.mouseMove);
  9593. window.addEventListener("mouseup", _boundEvents.mouseUp);
  9594. });
  9595. this.eventBus._on("sidebarviewchanged", function (evt) {
  9596. _this2.sidebarOpen = !!(evt && evt.view);
  9597. });
  9598. this.eventBus._on("resize", function (evt) {
  9599. if (!evt || evt.source !== window) {
  9600. return;
  9601. }
  9602. _this2._outerContainerWidth = null;
  9603. if (!_this2._width) {
  9604. return;
  9605. }
  9606. if (!_this2.sidebarOpen) {
  9607. _this2._updateWidth(_this2._width);
  9608. return;
  9609. }
  9610. _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  9611. var updated = _this2._updateWidth(_this2._width);
  9612. Promise.resolve().then(function () {
  9613. _this2.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  9614. if (updated) {
  9615. _this2.eventBus.dispatch("resize", {
  9616. source: _this2
  9617. });
  9618. }
  9619. });
  9620. });
  9621. }
  9622. }, {
  9623. key: "outerContainerWidth",
  9624. get: function get() {
  9625. if (!this._outerContainerWidth) {
  9626. this._outerContainerWidth = this.outerContainer.clientWidth;
  9627. }
  9628. return this._outerContainerWidth;
  9629. }
  9630. }]);
  9631. return PDFSidebarResizer;
  9632. }();
  9633. exports.PDFSidebarResizer = PDFSidebarResizer;
  9634. /***/ }),
  9635. /* 26 */
  9636. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  9637. Object.defineProperty(exports, "__esModule", ({
  9638. value: true
  9639. }));
  9640. exports.PDFThumbnailViewer = void 0;
  9641. var _ui_utils = __webpack_require__(6);
  9642. var _pdf_thumbnail_view = __webpack_require__(27);
  9643. var _pdf_rendering_queue = __webpack_require__(10);
  9644. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9645. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  9646. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9647. var THUMBNAIL_SCROLL_MARGIN = -19;
  9648. var THUMBNAIL_SELECTED_CLASS = "selected";
  9649. var PDFThumbnailViewer = /*#__PURE__*/function () {
  9650. function PDFThumbnailViewer(_ref) {
  9651. var _this = this;
  9652. var container = _ref.container,
  9653. eventBus = _ref.eventBus,
  9654. linkService = _ref.linkService,
  9655. renderingQueue = _ref.renderingQueue,
  9656. _ref$l10n = _ref.l10n,
  9657. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  9658. _classCallCheck(this, PDFThumbnailViewer);
  9659. this.container = container;
  9660. this.linkService = linkService;
  9661. this.renderingQueue = renderingQueue;
  9662. this.l10n = l10n;
  9663. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdated.bind(this));
  9664. this._resetView();
  9665. eventBus._on("optionalcontentconfigchanged", function () {
  9666. _this._setImageDisabled = true;
  9667. });
  9668. }
  9669. _createClass(PDFThumbnailViewer, [{
  9670. key: "_scrollUpdated",
  9671. value: function _scrollUpdated() {
  9672. this.renderingQueue.renderHighestPriority();
  9673. }
  9674. }, {
  9675. key: "getThumbnail",
  9676. value: function getThumbnail(index) {
  9677. return this._thumbnails[index];
  9678. }
  9679. }, {
  9680. key: "_getVisibleThumbs",
  9681. value: function _getVisibleThumbs() {
  9682. return (0, _ui_utils.getVisibleElements)({
  9683. scrollEl: this.container,
  9684. views: this._thumbnails
  9685. });
  9686. }
  9687. }, {
  9688. key: "scrollThumbnailIntoView",
  9689. value: function scrollThumbnailIntoView(pageNumber) {
  9690. if (!this.pdfDocument) {
  9691. return;
  9692. }
  9693. var thumbnailView = this._thumbnails[pageNumber - 1];
  9694. if (!thumbnailView) {
  9695. console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');
  9696. return;
  9697. }
  9698. if (pageNumber !== this._currentPageNumber) {
  9699. var prevThumbnailView = this._thumbnails[this._currentPageNumber - 1];
  9700. prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS);
  9701. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  9702. }
  9703. var visibleThumbs = this._getVisibleThumbs();
  9704. var numVisibleThumbs = visibleThumbs.views.length;
  9705. if (numVisibleThumbs > 0) {
  9706. var first = visibleThumbs.first.id;
  9707. var last = numVisibleThumbs > 1 ? visibleThumbs.last.id : first;
  9708. var shouldScroll = false;
  9709. if (pageNumber <= first || pageNumber >= last) {
  9710. shouldScroll = true;
  9711. } else {
  9712. visibleThumbs.views.some(function (view) {
  9713. if (view.id !== pageNumber) {
  9714. return false;
  9715. }
  9716. shouldScroll = view.percent < 100;
  9717. return true;
  9718. });
  9719. }
  9720. if (shouldScroll) {
  9721. (0, _ui_utils.scrollIntoView)(thumbnailView.div, {
  9722. top: THUMBNAIL_SCROLL_MARGIN
  9723. });
  9724. }
  9725. }
  9726. this._currentPageNumber = pageNumber;
  9727. }
  9728. }, {
  9729. key: "cleanup",
  9730. value: function cleanup() {
  9731. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  9732. if (this._thumbnails[i] && this._thumbnails[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  9733. this._thumbnails[i].reset();
  9734. }
  9735. }
  9736. _pdf_thumbnail_view.TempImageFactory.destroyCanvas();
  9737. }
  9738. }, {
  9739. key: "_resetView",
  9740. value: function _resetView() {
  9741. this._thumbnails = [];
  9742. this._currentPageNumber = 1;
  9743. this._pageLabels = null;
  9744. this._pagesRotation = 0;
  9745. this._optionalContentConfigPromise = null;
  9746. this._pagesRequests = new WeakMap();
  9747. this._setImageDisabled = false;
  9748. this.container.textContent = "";
  9749. }
  9750. }, {
  9751. key: "setDocument",
  9752. value: function setDocument(pdfDocument) {
  9753. var _this2 = this;
  9754. if (this.pdfDocument) {
  9755. this._cancelRendering();
  9756. this._resetView();
  9757. }
  9758. this.pdfDocument = pdfDocument;
  9759. if (!pdfDocument) {
  9760. return;
  9761. }
  9762. var firstPagePromise = pdfDocument.getPage(1);
  9763. var optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
  9764. firstPagePromise.then(function (firstPdfPage) {
  9765. _this2._optionalContentConfigPromise = optionalContentConfigPromise;
  9766. var pagesCount = pdfDocument.numPages;
  9767. var viewport = firstPdfPage.getViewport({
  9768. scale: 1
  9769. });
  9770. var checkSetImageDisabled = function checkSetImageDisabled() {
  9771. return _this2._setImageDisabled;
  9772. };
  9773. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  9774. var thumbnail = new _pdf_thumbnail_view.PDFThumbnailView({
  9775. container: _this2.container,
  9776. id: pageNum,
  9777. defaultViewport: viewport.clone(),
  9778. optionalContentConfigPromise: optionalContentConfigPromise,
  9779. linkService: _this2.linkService,
  9780. renderingQueue: _this2.renderingQueue,
  9781. checkSetImageDisabled: checkSetImageDisabled,
  9782. disableCanvasToImageConversion: false,
  9783. l10n: _this2.l10n
  9784. });
  9785. _this2._thumbnails.push(thumbnail);
  9786. }
  9787. var firstThumbnailView = _this2._thumbnails[0];
  9788. if (firstThumbnailView) {
  9789. firstThumbnailView.setPdfPage(firstPdfPage);
  9790. }
  9791. var thumbnailView = _this2._thumbnails[_this2._currentPageNumber - 1];
  9792. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  9793. })["catch"](function (reason) {
  9794. console.error("Unable to initialize thumbnail viewer", reason);
  9795. });
  9796. }
  9797. }, {
  9798. key: "_cancelRendering",
  9799. value: function _cancelRendering() {
  9800. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  9801. if (this._thumbnails[i]) {
  9802. this._thumbnails[i].cancelRendering();
  9803. }
  9804. }
  9805. }
  9806. }, {
  9807. key: "setPageLabels",
  9808. value: function setPageLabels(labels) {
  9809. if (!this.pdfDocument) {
  9810. return;
  9811. }
  9812. if (!labels) {
  9813. this._pageLabels = null;
  9814. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  9815. this._pageLabels = null;
  9816. console.error("PDFThumbnailViewer_setPageLabels: Invalid page labels.");
  9817. } else {
  9818. this._pageLabels = labels;
  9819. }
  9820. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  9821. var label = this._pageLabels && this._pageLabels[i];
  9822. this._thumbnails[i].setPageLabel(label);
  9823. }
  9824. }
  9825. }, {
  9826. key: "_ensurePdfPageLoaded",
  9827. value: function _ensurePdfPageLoaded(thumbView) {
  9828. var _this3 = this;
  9829. if (thumbView.pdfPage) {
  9830. return Promise.resolve(thumbView.pdfPage);
  9831. }
  9832. if (this._pagesRequests.has(thumbView)) {
  9833. return this._pagesRequests.get(thumbView);
  9834. }
  9835. var promise = this.pdfDocument.getPage(thumbView.id).then(function (pdfPage) {
  9836. if (!thumbView.pdfPage) {
  9837. thumbView.setPdfPage(pdfPage);
  9838. }
  9839. _this3._pagesRequests["delete"](thumbView);
  9840. return pdfPage;
  9841. })["catch"](function (reason) {
  9842. console.error("Unable to get page for thumb view", reason);
  9843. _this3._pagesRequests["delete"](thumbView);
  9844. });
  9845. this._pagesRequests.set(thumbView, promise);
  9846. return promise;
  9847. }
  9848. }, {
  9849. key: "forceRendering",
  9850. value: function forceRendering() {
  9851. var _this4 = this;
  9852. var visibleThumbs = this._getVisibleThumbs();
  9853. var thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, this.scroll.down);
  9854. if (thumbView) {
  9855. this._ensurePdfPageLoaded(thumbView).then(function () {
  9856. _this4.renderingQueue.renderView(thumbView);
  9857. });
  9858. return true;
  9859. }
  9860. return false;
  9861. }
  9862. }, {
  9863. key: "pagesRotation",
  9864. get: function get() {
  9865. return this._pagesRotation;
  9866. },
  9867. set: function set(rotation) {
  9868. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  9869. throw new Error("Invalid thumbnails rotation angle.");
  9870. }
  9871. if (!this.pdfDocument) {
  9872. return;
  9873. }
  9874. if (this._pagesRotation === rotation) {
  9875. return;
  9876. }
  9877. this._pagesRotation = rotation;
  9878. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  9879. this._thumbnails[i].update(rotation);
  9880. }
  9881. }
  9882. }]);
  9883. return PDFThumbnailViewer;
  9884. }();
  9885. exports.PDFThumbnailViewer = PDFThumbnailViewer;
  9886. /***/ }),
  9887. /* 27 */
  9888. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  9889. Object.defineProperty(exports, "__esModule", ({
  9890. value: true
  9891. }));
  9892. exports.TempImageFactory = exports.PDFThumbnailView = void 0;
  9893. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  9894. var _ui_utils = __webpack_require__(6);
  9895. var _pdfjsLib = __webpack_require__(7);
  9896. var _pdf_rendering_queue = __webpack_require__(10);
  9897. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  9898. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  9899. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  9900. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  9901. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  9902. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  9903. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  9904. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  9905. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  9906. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9907. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  9908. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9909. var MAX_NUM_SCALING_STEPS = 3;
  9910. var THUMBNAIL_CANVAS_BORDER_WIDTH = 1;
  9911. var THUMBNAIL_WIDTH = 98;
  9912. var TempImageFactory = function TempImageFactoryClosure() {
  9913. var tempCanvasCache = null;
  9914. return {
  9915. getCanvas: function getCanvas(width, height) {
  9916. var tempCanvas = tempCanvasCache;
  9917. if (!tempCanvas) {
  9918. tempCanvas = document.createElement("canvas");
  9919. tempCanvasCache = tempCanvas;
  9920. }
  9921. tempCanvas.width = width;
  9922. tempCanvas.height = height;
  9923. tempCanvas.mozOpaque = true;
  9924. var ctx = tempCanvas.getContext("2d", {
  9925. alpha: false
  9926. });
  9927. ctx.save();
  9928. ctx.fillStyle = "rgb(255, 255, 255)";
  9929. ctx.fillRect(0, 0, width, height);
  9930. ctx.restore();
  9931. return tempCanvas;
  9932. },
  9933. destroyCanvas: function destroyCanvas() {
  9934. var tempCanvas = tempCanvasCache;
  9935. if (tempCanvas) {
  9936. tempCanvas.width = 0;
  9937. tempCanvas.height = 0;
  9938. }
  9939. tempCanvasCache = null;
  9940. }
  9941. };
  9942. }();
  9943. exports.TempImageFactory = TempImageFactory;
  9944. var PDFThumbnailView = /*#__PURE__*/function () {
  9945. function PDFThumbnailView(_ref) {
  9946. var container = _ref.container,
  9947. id = _ref.id,
  9948. defaultViewport = _ref.defaultViewport,
  9949. optionalContentConfigPromise = _ref.optionalContentConfigPromise,
  9950. linkService = _ref.linkService,
  9951. renderingQueue = _ref.renderingQueue,
  9952. checkSetImageDisabled = _ref.checkSetImageDisabled,
  9953. _ref$disableCanvasToI = _ref.disableCanvasToImageConversion,
  9954. disableCanvasToImageConversion = _ref$disableCanvasToI === void 0 ? false : _ref$disableCanvasToI,
  9955. _ref$l10n = _ref.l10n,
  9956. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  9957. _classCallCheck(this, PDFThumbnailView);
  9958. this.id = id;
  9959. this.renderingId = "thumbnail" + id;
  9960. this.pageLabel = null;
  9961. this.pdfPage = null;
  9962. this.rotation = 0;
  9963. this.viewport = defaultViewport;
  9964. this.pdfPageRotate = defaultViewport.rotation;
  9965. this._optionalContentConfigPromise = optionalContentConfigPromise || null;
  9966. this.linkService = linkService;
  9967. this.renderingQueue = renderingQueue;
  9968. this.renderTask = null;
  9969. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  9970. this.resume = null;
  9971. this._checkSetImageDisabled = checkSetImageDisabled || function () {
  9972. return false;
  9973. };
  9974. this.disableCanvasToImageConversion = disableCanvasToImageConversion;
  9975. this.pageWidth = this.viewport.width;
  9976. this.pageHeight = this.viewport.height;
  9977. this.pageRatio = this.pageWidth / this.pageHeight;
  9978. this.canvasWidth = THUMBNAIL_WIDTH;
  9979. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  9980. this.scale = this.canvasWidth / this.pageWidth;
  9981. this.l10n = l10n;
  9982. var anchor = document.createElement("a");
  9983. anchor.href = linkService.getAnchorUrl("#page=" + id);
  9984. this._thumbPageTitle.then(function (msg) {
  9985. anchor.title = msg;
  9986. });
  9987. anchor.onclick = function () {
  9988. linkService.goToPage(id);
  9989. return false;
  9990. };
  9991. this.anchor = anchor;
  9992. var div = document.createElement("div");
  9993. div.className = "thumbnail";
  9994. div.setAttribute("data-page-number", this.id);
  9995. this.div = div;
  9996. var ring = document.createElement("div");
  9997. ring.className = "thumbnailSelectionRing";
  9998. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  9999. ring.style.width = this.canvasWidth + borderAdjustment + "px";
  10000. ring.style.height = this.canvasHeight + borderAdjustment + "px";
  10001. this.ring = ring;
  10002. div.appendChild(ring);
  10003. anchor.appendChild(div);
  10004. container.appendChild(anchor);
  10005. }
  10006. _createClass(PDFThumbnailView, [{
  10007. key: "setPdfPage",
  10008. value: function setPdfPage(pdfPage) {
  10009. this.pdfPage = pdfPage;
  10010. this.pdfPageRotate = pdfPage.rotate;
  10011. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  10012. this.viewport = pdfPage.getViewport({
  10013. scale: 1,
  10014. rotation: totalRotation
  10015. });
  10016. this.reset();
  10017. }
  10018. }, {
  10019. key: "reset",
  10020. value: function reset() {
  10021. this.cancelRendering();
  10022. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  10023. this.pageWidth = this.viewport.width;
  10024. this.pageHeight = this.viewport.height;
  10025. this.pageRatio = this.pageWidth / this.pageHeight;
  10026. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  10027. this.scale = this.canvasWidth / this.pageWidth;
  10028. this.div.removeAttribute("data-loaded");
  10029. var ring = this.ring;
  10030. var childNodes = ring.childNodes;
  10031. for (var i = childNodes.length - 1; i >= 0; i--) {
  10032. ring.removeChild(childNodes[i]);
  10033. }
  10034. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  10035. ring.style.width = this.canvasWidth + borderAdjustment + "px";
  10036. ring.style.height = this.canvasHeight + borderAdjustment + "px";
  10037. if (this.canvas) {
  10038. this.canvas.width = 0;
  10039. this.canvas.height = 0;
  10040. delete this.canvas;
  10041. }
  10042. if (this.image) {
  10043. this.image.removeAttribute("src");
  10044. delete this.image;
  10045. }
  10046. }
  10047. }, {
  10048. key: "update",
  10049. value: function update(rotation) {
  10050. if (typeof rotation !== "undefined") {
  10051. this.rotation = rotation;
  10052. }
  10053. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  10054. this.viewport = this.viewport.clone({
  10055. scale: 1,
  10056. rotation: totalRotation
  10057. });
  10058. this.reset();
  10059. }
  10060. }, {
  10061. key: "cancelRendering",
  10062. value: function cancelRendering() {
  10063. if (this.renderTask) {
  10064. this.renderTask.cancel();
  10065. this.renderTask = null;
  10066. }
  10067. this.resume = null;
  10068. }
  10069. }, {
  10070. key: "_getPageDrawContext",
  10071. value: function _getPageDrawContext() {
  10072. var canvas = document.createElement("canvas");
  10073. this.canvas = canvas;
  10074. canvas.mozOpaque = true;
  10075. var ctx = canvas.getContext("2d", {
  10076. alpha: false
  10077. });
  10078. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  10079. canvas.width = this.canvasWidth * outputScale.sx | 0;
  10080. canvas.height = this.canvasHeight * outputScale.sy | 0;
  10081. canvas.style.width = this.canvasWidth + "px";
  10082. canvas.style.height = this.canvasHeight + "px";
  10083. var transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null;
  10084. return [ctx, transform];
  10085. }
  10086. }, {
  10087. key: "_convertCanvasToImage",
  10088. value: function _convertCanvasToImage() {
  10089. var _this = this;
  10090. if (!this.canvas) {
  10091. return;
  10092. }
  10093. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  10094. return;
  10095. }
  10096. var className = "thumbnailImage";
  10097. if (this.disableCanvasToImageConversion) {
  10098. this.canvas.className = className;
  10099. this._thumbPageCanvas.then(function (msg) {
  10100. _this.canvas.setAttribute("aria-label", msg);
  10101. });
  10102. this.div.setAttribute("data-loaded", true);
  10103. this.ring.appendChild(this.canvas);
  10104. return;
  10105. }
  10106. var image = document.createElement("img");
  10107. image.className = className;
  10108. this._thumbPageCanvas.then(function (msg) {
  10109. image.setAttribute("aria-label", msg);
  10110. });
  10111. image.style.width = this.canvasWidth + "px";
  10112. image.style.height = this.canvasHeight + "px";
  10113. image.src = this.canvas.toDataURL();
  10114. this.image = image;
  10115. this.div.setAttribute("data-loaded", true);
  10116. this.ring.appendChild(image);
  10117. this.canvas.width = 0;
  10118. this.canvas.height = 0;
  10119. delete this.canvas;
  10120. }
  10121. }, {
  10122. key: "draw",
  10123. value: function draw() {
  10124. var _this2 = this;
  10125. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  10126. console.error("Must be in new state before drawing");
  10127. return Promise.resolve(undefined);
  10128. }
  10129. var pdfPage = this.pdfPage;
  10130. if (!pdfPage) {
  10131. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  10132. return Promise.reject(new Error("pdfPage is not loaded"));
  10133. }
  10134. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  10135. var finishRenderTask = /*#__PURE__*/function () {
  10136. var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  10137. var error,
  10138. _args = arguments;
  10139. return _regenerator["default"].wrap(function _callee$(_context) {
  10140. while (1) {
  10141. switch (_context.prev = _context.next) {
  10142. case 0:
  10143. error = _args.length > 0 && _args[0] !== undefined ? _args[0] : null;
  10144. if (renderTask === _this2.renderTask) {
  10145. _this2.renderTask = null;
  10146. }
  10147. if (!(error instanceof _pdfjsLib.RenderingCancelledException)) {
  10148. _context.next = 4;
  10149. break;
  10150. }
  10151. return _context.abrupt("return");
  10152. case 4:
  10153. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  10154. _this2._convertCanvasToImage();
  10155. if (!error) {
  10156. _context.next = 8;
  10157. break;
  10158. }
  10159. throw error;
  10160. case 8:
  10161. case "end":
  10162. return _context.stop();
  10163. }
  10164. }
  10165. }, _callee);
  10166. }));
  10167. return function finishRenderTask() {
  10168. return _ref2.apply(this, arguments);
  10169. };
  10170. }();
  10171. var _this$_getPageDrawCon = this._getPageDrawContext(),
  10172. _this$_getPageDrawCon2 = _slicedToArray(_this$_getPageDrawCon, 2),
  10173. ctx = _this$_getPageDrawCon2[0],
  10174. transform = _this$_getPageDrawCon2[1];
  10175. var drawViewport = this.viewport.clone({
  10176. scale: this.scale
  10177. });
  10178. var renderContinueCallback = function renderContinueCallback(cont) {
  10179. if (!_this2.renderingQueue.isHighestPriority(_this2)) {
  10180. _this2.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  10181. _this2.resume = function () {
  10182. _this2.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  10183. cont();
  10184. };
  10185. return;
  10186. }
  10187. cont();
  10188. };
  10189. var renderContext = {
  10190. canvasContext: ctx,
  10191. transform: transform,
  10192. viewport: drawViewport,
  10193. optionalContentConfigPromise: this._optionalContentConfigPromise
  10194. };
  10195. var renderTask = this.renderTask = pdfPage.render(renderContext);
  10196. renderTask.onContinue = renderContinueCallback;
  10197. var resultPromise = renderTask.promise.then(function () {
  10198. finishRenderTask(null);
  10199. }, function (error) {
  10200. finishRenderTask(error);
  10201. });
  10202. resultPromise["finally"](function () {
  10203. var _this2$pdfPage;
  10204. var pageCached = _this2.linkService.isPageCached(_this2.id);
  10205. if (pageCached) {
  10206. return;
  10207. }
  10208. (_this2$pdfPage = _this2.pdfPage) === null || _this2$pdfPage === void 0 ? void 0 : _this2$pdfPage.cleanup();
  10209. });
  10210. return resultPromise;
  10211. }
  10212. }, {
  10213. key: "setImage",
  10214. value: function setImage(pageView) {
  10215. if (this._checkSetImageDisabled()) {
  10216. return;
  10217. }
  10218. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  10219. return;
  10220. }
  10221. var img = pageView.canvas;
  10222. if (!img) {
  10223. return;
  10224. }
  10225. if (!this.pdfPage) {
  10226. this.setPdfPage(pageView.pdfPage);
  10227. }
  10228. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  10229. var _this$_getPageDrawCon3 = this._getPageDrawContext(),
  10230. _this$_getPageDrawCon4 = _slicedToArray(_this$_getPageDrawCon3, 1),
  10231. ctx = _this$_getPageDrawCon4[0];
  10232. var canvas = ctx.canvas;
  10233. if (img.width <= 2 * canvas.width) {
  10234. ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height);
  10235. this._convertCanvasToImage();
  10236. return;
  10237. }
  10238. var reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
  10239. var reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
  10240. var reducedImage = TempImageFactory.getCanvas(reducedWidth, reducedHeight);
  10241. var reducedImageCtx = reducedImage.getContext("2d");
  10242. while (reducedWidth > img.width || reducedHeight > img.height) {
  10243. reducedWidth >>= 1;
  10244. reducedHeight >>= 1;
  10245. }
  10246. reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0, reducedWidth, reducedHeight);
  10247. while (reducedWidth > 2 * canvas.width) {
  10248. reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, reducedWidth >> 1, reducedHeight >> 1);
  10249. reducedWidth >>= 1;
  10250. reducedHeight >>= 1;
  10251. }
  10252. ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height);
  10253. this._convertCanvasToImage();
  10254. }
  10255. }, {
  10256. key: "setPageLabel",
  10257. value: function setPageLabel(label) {
  10258. var _this3 = this;
  10259. this.pageLabel = typeof label === "string" ? label : null;
  10260. this._thumbPageTitle.then(function (msg) {
  10261. _this3.anchor.title = msg;
  10262. });
  10263. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  10264. return;
  10265. }
  10266. this._thumbPageCanvas.then(function (msg) {
  10267. if (_this3.image) {
  10268. _this3.image.setAttribute("aria-label", msg);
  10269. } else if (_this3.disableCanvasToImageConversion && _this3.canvas) {
  10270. _this3.canvas.setAttribute("aria-label", msg);
  10271. }
  10272. });
  10273. }
  10274. }, {
  10275. key: "_thumbPageTitle",
  10276. get: function get() {
  10277. var _this$pageLabel;
  10278. return this.l10n.get("thumb_page_title", {
  10279. page: (_this$pageLabel = this.pageLabel) !== null && _this$pageLabel !== void 0 ? _this$pageLabel : this.id
  10280. }, "Page {{page}}");
  10281. }
  10282. }, {
  10283. key: "_thumbPageCanvas",
  10284. get: function get() {
  10285. var _this$pageLabel2;
  10286. return this.l10n.get("thumb_page_canvas", {
  10287. page: (_this$pageLabel2 = this.pageLabel) !== null && _this$pageLabel2 !== void 0 ? _this$pageLabel2 : this.id
  10288. }, "Thumbnail of Page {{page}}");
  10289. }
  10290. }]);
  10291. return PDFThumbnailView;
  10292. }();
  10293. exports.PDFThumbnailView = PDFThumbnailView;
  10294. /***/ }),
  10295. /* 28 */
  10296. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  10297. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  10298. Object.defineProperty(exports, "__esModule", ({
  10299. value: true
  10300. }));
  10301. exports.PDFViewer = void 0;
  10302. var _ui_utils = __webpack_require__(6);
  10303. var _base_viewer = __webpack_require__(29);
  10304. var _pdfjsLib = __webpack_require__(7);
  10305. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  10306. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  10307. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  10308. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10309. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  10310. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10311. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  10312. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  10313. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  10314. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  10315. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  10316. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  10317. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  10318. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  10319. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  10320. var PDFViewer = /*#__PURE__*/function (_BaseViewer) {
  10321. _inherits(PDFViewer, _BaseViewer);
  10322. var _super = _createSuper(PDFViewer);
  10323. function PDFViewer() {
  10324. _classCallCheck(this, PDFViewer);
  10325. return _super.apply(this, arguments);
  10326. }
  10327. _createClass(PDFViewer, [{
  10328. key: "_scrollIntoView",
  10329. value: function _scrollIntoView(_ref) {
  10330. var pageDiv = _ref.pageDiv,
  10331. _ref$pageSpot = _ref.pageSpot,
  10332. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  10333. _ref$pageNumber = _ref.pageNumber,
  10334. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  10335. if (!pageSpot && !this.isInPresentationMode) {
  10336. var left = pageDiv.offsetLeft + pageDiv.clientLeft;
  10337. var right = left + pageDiv.clientWidth;
  10338. var _this$container = this.container,
  10339. scrollLeft = _this$container.scrollLeft,
  10340. clientWidth = _this$container.clientWidth;
  10341. if (this._isScrollModeHorizontal || left < scrollLeft || right > scrollLeft + clientWidth) {
  10342. pageSpot = {
  10343. left: 0,
  10344. top: 0
  10345. };
  10346. }
  10347. }
  10348. _get(_getPrototypeOf(PDFViewer.prototype), "_scrollIntoView", this).call(this, {
  10349. pageDiv: pageDiv,
  10350. pageSpot: pageSpot,
  10351. pageNumber: pageNumber
  10352. });
  10353. }
  10354. }, {
  10355. key: "_getVisiblePages",
  10356. value: function _getVisiblePages() {
  10357. if (this.isInPresentationMode) {
  10358. return this._getCurrentVisiblePage();
  10359. }
  10360. return _get(_getPrototypeOf(PDFViewer.prototype), "_getVisiblePages", this).call(this);
  10361. }
  10362. }, {
  10363. key: "_updateHelper",
  10364. value: function _updateHelper(visiblePages) {
  10365. if (this.isInPresentationMode) {
  10366. return;
  10367. }
  10368. var currentId = this._currentPageNumber;
  10369. var stillFullyVisible = false;
  10370. var _iterator = _createForOfIteratorHelper(visiblePages),
  10371. _step;
  10372. try {
  10373. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  10374. var page = _step.value;
  10375. if (page.percent < 100) {
  10376. break;
  10377. }
  10378. if (page.id === currentId && this._scrollMode === _ui_utils.ScrollMode.VERTICAL && this._spreadMode === _ui_utils.SpreadMode.NONE) {
  10379. stillFullyVisible = true;
  10380. break;
  10381. }
  10382. }
  10383. } catch (err) {
  10384. _iterator.e(err);
  10385. } finally {
  10386. _iterator.f();
  10387. }
  10388. if (!stillFullyVisible) {
  10389. currentId = visiblePages[0].id;
  10390. }
  10391. this._setCurrentPageNumber(currentId);
  10392. }
  10393. }, {
  10394. key: "_viewerElement",
  10395. get: function get() {
  10396. return (0, _pdfjsLib.shadow)(this, "_viewerElement", this.viewer);
  10397. }
  10398. }]);
  10399. return PDFViewer;
  10400. }(_base_viewer.BaseViewer);
  10401. exports.PDFViewer = PDFViewer;
  10402. /***/ }),
  10403. /* 29 */
  10404. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  10405. Object.defineProperty(exports, "__esModule", ({
  10406. value: true
  10407. }));
  10408. exports.BaseViewer = void 0;
  10409. var _pdfjsLib = __webpack_require__(7);
  10410. var _ui_utils = __webpack_require__(6);
  10411. var _pdf_rendering_queue = __webpack_require__(10);
  10412. var _annotation_layer_builder = __webpack_require__(30);
  10413. var _pdf_page_view = __webpack_require__(31);
  10414. var _pdf_link_service = __webpack_require__(21);
  10415. var _text_layer_builder = __webpack_require__(32);
  10416. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  10417. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  10418. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  10419. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10420. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  10421. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10422. var DEFAULT_CACHE_SIZE = 10;
  10423. function PDFPageViewBuffer(size) {
  10424. var data = [];
  10425. this.push = function (view) {
  10426. var i = data.indexOf(view);
  10427. if (i >= 0) {
  10428. data.splice(i, 1);
  10429. }
  10430. data.push(view);
  10431. if (data.length > size) {
  10432. data.shift().destroy();
  10433. }
  10434. };
  10435. this.resize = function (newSize, pagesToKeep) {
  10436. size = newSize;
  10437. if (pagesToKeep) {
  10438. var pageIdsToKeep = new Set();
  10439. for (var i = 0, iMax = pagesToKeep.length; i < iMax; ++i) {
  10440. pageIdsToKeep.add(pagesToKeep[i].id);
  10441. }
  10442. (0, _ui_utils.moveToEndOfArray)(data, function (page) {
  10443. return pageIdsToKeep.has(page.id);
  10444. });
  10445. }
  10446. while (data.length > size) {
  10447. data.shift().destroy();
  10448. }
  10449. };
  10450. this.has = function (view) {
  10451. return data.includes(view);
  10452. };
  10453. }
  10454. function isSameScale(oldScale, newScale) {
  10455. if (newScale === oldScale) {
  10456. return true;
  10457. }
  10458. if (Math.abs(newScale - oldScale) < 1e-15) {
  10459. return true;
  10460. }
  10461. return false;
  10462. }
  10463. var BaseViewer = /*#__PURE__*/function () {
  10464. function BaseViewer(options) {
  10465. var _this$container,
  10466. _this$viewer,
  10467. _this = this;
  10468. _classCallCheck(this, BaseViewer);
  10469. if (this.constructor === BaseViewer) {
  10470. throw new Error("Cannot initialize BaseViewer.");
  10471. }
  10472. var viewerVersion = '2.7.570';
  10473. if (_pdfjsLib.version !== viewerVersion) {
  10474. throw new Error("The API version \"".concat(_pdfjsLib.version, "\" does not match the Viewer version \"").concat(viewerVersion, "\"."));
  10475. }
  10476. this._name = this.constructor.name;
  10477. this.container = options.container;
  10478. this.viewer = options.viewer || options.container.firstElementChild;
  10479. if (!(((_this$container = this.container) === null || _this$container === void 0 ? void 0 : _this$container.tagName.toUpperCase()) === "DIV" && ((_this$viewer = this.viewer) === null || _this$viewer === void 0 ? void 0 : _this$viewer.tagName.toUpperCase()) === "DIV")) {
  10480. throw new Error("Invalid `container` and/or `viewer` option.");
  10481. }
  10482. if (getComputedStyle(this.container).position !== "absolute") {
  10483. throw new Error("The `container` must be absolutely positioned.");
  10484. }
  10485. this.eventBus = options.eventBus;
  10486. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  10487. this.downloadManager = options.downloadManager || null;
  10488. this.findController = options.findController || null;
  10489. this.removePageBorders = options.removePageBorders || false;
  10490. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  10491. this.imageResourcesPath = options.imageResourcesPath || "";
  10492. this.renderInteractiveForms = typeof options.renderInteractiveForms === "boolean" ? options.renderInteractiveForms : true;
  10493. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  10494. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  10495. this.enableWebGL = options.enableWebGL || false;
  10496. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  10497. this.maxCanvasPixels = options.maxCanvasPixels;
  10498. this.l10n = options.l10n || _ui_utils.NullL10n;
  10499. this.enableScripting = options.enableScripting || false;
  10500. this._mouseState = options.mouseState || null;
  10501. this.defaultRenderingQueue = !options.renderingQueue;
  10502. if (this.defaultRenderingQueue) {
  10503. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  10504. this.renderingQueue.setViewer(this);
  10505. } else {
  10506. this.renderingQueue = options.renderingQueue;
  10507. }
  10508. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  10509. this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
  10510. this._onBeforeDraw = this._onAfterDraw = null;
  10511. this._resetView();
  10512. if (this.removePageBorders) {
  10513. this.viewer.classList.add("removePageBorders");
  10514. }
  10515. Promise.resolve().then(function () {
  10516. _this.eventBus.dispatch("baseviewerinit", {
  10517. source: _this
  10518. });
  10519. });
  10520. }
  10521. _createClass(BaseViewer, [{
  10522. key: "getPageView",
  10523. value: function getPageView(index) {
  10524. return this._pages[index];
  10525. }
  10526. }, {
  10527. key: "_setCurrentPageNumber",
  10528. value: function _setCurrentPageNumber(val) {
  10529. var resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  10530. if (this._currentPageNumber === val) {
  10531. if (resetCurrentPageView) {
  10532. this._resetCurrentPageView();
  10533. }
  10534. return true;
  10535. }
  10536. if (!(0 < val && val <= this.pagesCount)) {
  10537. return false;
  10538. }
  10539. var previous = this._currentPageNumber;
  10540. this._currentPageNumber = val;
  10541. this.eventBus.dispatch("pagechanging", {
  10542. source: this,
  10543. pageNumber: val,
  10544. pageLabel: this._pageLabels && this._pageLabels[val - 1],
  10545. previous: previous
  10546. });
  10547. if (resetCurrentPageView) {
  10548. this._resetCurrentPageView();
  10549. }
  10550. return true;
  10551. }
  10552. }, {
  10553. key: "_onePageRenderedOrForceFetch",
  10554. value: function _onePageRenderedOrForceFetch() {
  10555. if (!this.container.offsetParent || this._getVisiblePages().views.length === 0) {
  10556. return Promise.resolve();
  10557. }
  10558. return this._onePageRenderedCapability.promise;
  10559. }
  10560. }, {
  10561. key: "setDocument",
  10562. value: function setDocument(pdfDocument) {
  10563. var _this2 = this;
  10564. if (this.pdfDocument) {
  10565. this.eventBus.dispatch("pagesdestroy", {
  10566. source: this
  10567. });
  10568. this._cancelRendering();
  10569. this._resetView();
  10570. if (this.findController) {
  10571. this.findController.setDocument(null);
  10572. }
  10573. }
  10574. this.pdfDocument = pdfDocument;
  10575. if (!pdfDocument) {
  10576. return;
  10577. }
  10578. var pagesCount = pdfDocument.numPages;
  10579. var firstPagePromise = pdfDocument.getPage(1);
  10580. var optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
  10581. this._pagesCapability.promise.then(function () {
  10582. _this2.eventBus.dispatch("pagesloaded", {
  10583. source: _this2,
  10584. pagesCount: pagesCount
  10585. });
  10586. });
  10587. this._onBeforeDraw = function (evt) {
  10588. var pageView = _this2._pages[evt.pageNumber - 1];
  10589. if (!pageView) {
  10590. return;
  10591. }
  10592. _this2._buffer.push(pageView);
  10593. };
  10594. this.eventBus._on("pagerender", this._onBeforeDraw);
  10595. this._onAfterDraw = function (evt) {
  10596. if (evt.cssTransform || _this2._onePageRenderedCapability.settled) {
  10597. return;
  10598. }
  10599. _this2._onePageRenderedCapability.resolve();
  10600. _this2.eventBus._off("pagerendered", _this2._onAfterDraw);
  10601. _this2._onAfterDraw = null;
  10602. };
  10603. this.eventBus._on("pagerendered", this._onAfterDraw);
  10604. firstPagePromise.then(function (firstPdfPage) {
  10605. _this2._firstPageCapability.resolve(firstPdfPage);
  10606. _this2._optionalContentConfigPromise = optionalContentConfigPromise;
  10607. var scale = _this2.currentScale;
  10608. var viewport = firstPdfPage.getViewport({
  10609. scale: scale * _ui_utils.CSS_UNITS
  10610. });
  10611. var textLayerFactory = _this2.textLayerMode !== _ui_utils.TextLayerMode.DISABLE ? _this2 : null;
  10612. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  10613. var pageView = new _pdf_page_view.PDFPageView({
  10614. container: _this2._viewerElement,
  10615. eventBus: _this2.eventBus,
  10616. id: pageNum,
  10617. scale: scale,
  10618. defaultViewport: viewport.clone(),
  10619. optionalContentConfigPromise: optionalContentConfigPromise,
  10620. renderingQueue: _this2.renderingQueue,
  10621. textLayerFactory: textLayerFactory,
  10622. textLayerMode: _this2.textLayerMode,
  10623. annotationLayerFactory: _this2,
  10624. imageResourcesPath: _this2.imageResourcesPath,
  10625. renderInteractiveForms: _this2.renderInteractiveForms,
  10626. renderer: _this2.renderer,
  10627. enableWebGL: _this2.enableWebGL,
  10628. useOnlyCssZoom: _this2.useOnlyCssZoom,
  10629. maxCanvasPixels: _this2.maxCanvasPixels,
  10630. l10n: _this2.l10n,
  10631. enableScripting: _this2.enableScripting
  10632. });
  10633. _this2._pages.push(pageView);
  10634. }
  10635. var firstPageView = _this2._pages[0];
  10636. if (firstPageView) {
  10637. firstPageView.setPdfPage(firstPdfPage);
  10638. _this2.linkService.cachePageRef(1, firstPdfPage.ref);
  10639. }
  10640. if (_this2._spreadMode !== _ui_utils.SpreadMode.NONE) {
  10641. _this2._updateSpreadMode();
  10642. }
  10643. _this2._onePageRenderedOrForceFetch().then(function () {
  10644. if (_this2.findController) {
  10645. _this2.findController.setDocument(pdfDocument);
  10646. }
  10647. if (pdfDocument.loadingParams.disableAutoFetch || pagesCount > 7500) {
  10648. _this2._pagesCapability.resolve();
  10649. return;
  10650. }
  10651. var getPagesLeft = pagesCount - 1;
  10652. if (getPagesLeft <= 0) {
  10653. _this2._pagesCapability.resolve();
  10654. return;
  10655. }
  10656. var _loop = function _loop(_pageNum) {
  10657. pdfDocument.getPage(_pageNum).then(function (pdfPage) {
  10658. var pageView = _this2._pages[_pageNum - 1];
  10659. if (!pageView.pdfPage) {
  10660. pageView.setPdfPage(pdfPage);
  10661. }
  10662. _this2.linkService.cachePageRef(_pageNum, pdfPage.ref);
  10663. if (--getPagesLeft === 0) {
  10664. _this2._pagesCapability.resolve();
  10665. }
  10666. }, function (reason) {
  10667. console.error("Unable to get page ".concat(_pageNum, " to initialize viewer"), reason);
  10668. if (--getPagesLeft === 0) {
  10669. _this2._pagesCapability.resolve();
  10670. }
  10671. });
  10672. };
  10673. for (var _pageNum = 2; _pageNum <= pagesCount; ++_pageNum) {
  10674. _loop(_pageNum);
  10675. }
  10676. });
  10677. _this2.eventBus.dispatch("pagesinit", {
  10678. source: _this2
  10679. });
  10680. if (_this2.defaultRenderingQueue) {
  10681. _this2.update();
  10682. }
  10683. })["catch"](function (reason) {
  10684. console.error("Unable to initialize viewer", reason);
  10685. });
  10686. }
  10687. }, {
  10688. key: "setPageLabels",
  10689. value: function setPageLabels(labels) {
  10690. if (!this.pdfDocument) {
  10691. return;
  10692. }
  10693. if (!labels) {
  10694. this._pageLabels = null;
  10695. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  10696. this._pageLabels = null;
  10697. console.error("".concat(this._name, ".setPageLabels: Invalid page labels."));
  10698. } else {
  10699. this._pageLabels = labels;
  10700. }
  10701. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  10702. var pageView = this._pages[i];
  10703. var label = this._pageLabels && this._pageLabels[i];
  10704. pageView.setPageLabel(label);
  10705. }
  10706. }
  10707. }, {
  10708. key: "_resetView",
  10709. value: function _resetView() {
  10710. this._pages = [];
  10711. this._currentPageNumber = 1;
  10712. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  10713. this._currentScaleValue = null;
  10714. this._pageLabels = null;
  10715. this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  10716. this._location = null;
  10717. this._pagesRotation = 0;
  10718. this._optionalContentConfigPromise = null;
  10719. this._pagesRequests = new WeakMap();
  10720. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  10721. this._onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  10722. this._pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
  10723. this._scrollMode = _ui_utils.ScrollMode.VERTICAL;
  10724. this._spreadMode = _ui_utils.SpreadMode.NONE;
  10725. if (this._onBeforeDraw) {
  10726. this.eventBus._off("pagerender", this._onBeforeDraw);
  10727. this._onBeforeDraw = null;
  10728. }
  10729. if (this._onAfterDraw) {
  10730. this.eventBus._off("pagerendered", this._onAfterDraw);
  10731. this._onAfterDraw = null;
  10732. }
  10733. this._resetScriptingEvents();
  10734. this.viewer.textContent = "";
  10735. this._updateScrollMode();
  10736. }
  10737. }, {
  10738. key: "_scrollUpdate",
  10739. value: function _scrollUpdate() {
  10740. if (this.pagesCount === 0) {
  10741. return;
  10742. }
  10743. this.update();
  10744. }
  10745. }, {
  10746. key: "_scrollIntoView",
  10747. value: function _scrollIntoView(_ref) {
  10748. var pageDiv = _ref.pageDiv,
  10749. _ref$pageSpot = _ref.pageSpot,
  10750. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  10751. _ref$pageNumber = _ref.pageNumber,
  10752. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  10753. (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
  10754. }
  10755. }, {
  10756. key: "_setScaleUpdatePages",
  10757. value: function _setScaleUpdatePages(newScale, newValue) {
  10758. var noScroll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  10759. var preset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  10760. this._currentScaleValue = newValue.toString();
  10761. if (isSameScale(this._currentScale, newScale)) {
  10762. if (preset) {
  10763. this.eventBus.dispatch("scalechanging", {
  10764. source: this,
  10765. scale: newScale,
  10766. presetValue: newValue
  10767. });
  10768. }
  10769. return;
  10770. }
  10771. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  10772. this._pages[i].update(newScale);
  10773. }
  10774. this._currentScale = newScale;
  10775. if (!noScroll) {
  10776. var page = this._currentPageNumber,
  10777. dest;
  10778. if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  10779. page = this._location.pageNumber;
  10780. dest = [null, {
  10781. name: "XYZ"
  10782. }, this._location.left, this._location.top, null];
  10783. }
  10784. this.scrollPageIntoView({
  10785. pageNumber: page,
  10786. destArray: dest,
  10787. allowNegativeOffset: true
  10788. });
  10789. }
  10790. this.eventBus.dispatch("scalechanging", {
  10791. source: this,
  10792. scale: newScale,
  10793. presetValue: preset ? newValue : undefined
  10794. });
  10795. if (this.defaultRenderingQueue) {
  10796. this.update();
  10797. }
  10798. }
  10799. }, {
  10800. key: "_setScale",
  10801. value: function _setScale(value) {
  10802. var noScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  10803. var scale = parseFloat(value);
  10804. if (scale > 0) {
  10805. this._setScaleUpdatePages(scale, value, noScroll, false);
  10806. } else {
  10807. var currentPage = this._pages[this._currentPageNumber - 1];
  10808. if (!currentPage) {
  10809. return;
  10810. }
  10811. var noPadding = this.isInPresentationMode || this.removePageBorders;
  10812. var hPadding = noPadding ? 0 : _ui_utils.SCROLLBAR_PADDING;
  10813. var vPadding = noPadding ? 0 : _ui_utils.VERTICAL_PADDING;
  10814. if (!noPadding && this._isScrollModeHorizontal) {
  10815. var _ref2 = [vPadding, hPadding];
  10816. hPadding = _ref2[0];
  10817. vPadding = _ref2[1];
  10818. }
  10819. var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale / this._pageWidthScaleFactor;
  10820. var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  10821. switch (value) {
  10822. case "page-actual":
  10823. scale = 1;
  10824. break;
  10825. case "page-width":
  10826. scale = pageWidthScale;
  10827. break;
  10828. case "page-height":
  10829. scale = pageHeightScale;
  10830. break;
  10831. case "page-fit":
  10832. scale = Math.min(pageWidthScale, pageHeightScale);
  10833. break;
  10834. case "auto":
  10835. var horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
  10836. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  10837. break;
  10838. default:
  10839. console.error("".concat(this._name, "._setScale: \"").concat(value, "\" is an unknown zoom value."));
  10840. return;
  10841. }
  10842. this._setScaleUpdatePages(scale, value, noScroll, true);
  10843. }
  10844. }
  10845. }, {
  10846. key: "_resetCurrentPageView",
  10847. value: function _resetCurrentPageView() {
  10848. if (this.isInPresentationMode) {
  10849. this._setScale(this._currentScaleValue, true);
  10850. }
  10851. var pageView = this._pages[this._currentPageNumber - 1];
  10852. this._scrollIntoView({
  10853. pageDiv: pageView.div
  10854. });
  10855. }
  10856. }, {
  10857. key: "pageLabelToPageNumber",
  10858. value: function pageLabelToPageNumber(label) {
  10859. if (!this._pageLabels) {
  10860. return null;
  10861. }
  10862. var i = this._pageLabels.indexOf(label);
  10863. if (i < 0) {
  10864. return null;
  10865. }
  10866. return i + 1;
  10867. }
  10868. }, {
  10869. key: "scrollPageIntoView",
  10870. value: function scrollPageIntoView(_ref3) {
  10871. var pageNumber = _ref3.pageNumber,
  10872. _ref3$destArray = _ref3.destArray,
  10873. destArray = _ref3$destArray === void 0 ? null : _ref3$destArray,
  10874. _ref3$allowNegativeOf = _ref3.allowNegativeOffset,
  10875. allowNegativeOffset = _ref3$allowNegativeOf === void 0 ? false : _ref3$allowNegativeOf,
  10876. _ref3$ignoreDestinati = _ref3.ignoreDestinationZoom,
  10877. ignoreDestinationZoom = _ref3$ignoreDestinati === void 0 ? false : _ref3$ignoreDestinati;
  10878. if (!this.pdfDocument) {
  10879. return;
  10880. }
  10881. var pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1];
  10882. if (!pageView) {
  10883. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  10884. return;
  10885. }
  10886. if (this.isInPresentationMode || !destArray) {
  10887. this._setCurrentPageNumber(pageNumber, true);
  10888. return;
  10889. }
  10890. var x = 0,
  10891. y = 0;
  10892. var width = 0,
  10893. height = 0,
  10894. widthScale,
  10895. heightScale;
  10896. var changeOrientation = pageView.rotation % 180 !== 0;
  10897. var pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;
  10898. var pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;
  10899. var scale = 0;
  10900. switch (destArray[1].name) {
  10901. case "XYZ":
  10902. x = destArray[2];
  10903. y = destArray[3];
  10904. scale = destArray[4];
  10905. x = x !== null ? x : 0;
  10906. y = y !== null ? y : pageHeight;
  10907. break;
  10908. case "Fit":
  10909. case "FitB":
  10910. scale = "page-fit";
  10911. break;
  10912. case "FitH":
  10913. case "FitBH":
  10914. y = destArray[2];
  10915. scale = "page-width";
  10916. if (y === null && this._location) {
  10917. x = this._location.left;
  10918. y = this._location.top;
  10919. } else if (typeof y !== "number") {
  10920. y = pageHeight;
  10921. }
  10922. break;
  10923. case "FitV":
  10924. case "FitBV":
  10925. x = destArray[2];
  10926. width = pageWidth;
  10927. height = pageHeight;
  10928. scale = "page-height";
  10929. break;
  10930. case "FitR":
  10931. x = destArray[2];
  10932. y = destArray[3];
  10933. width = destArray[4] - x;
  10934. height = destArray[5] - y;
  10935. var hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  10936. var vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  10937. widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;
  10938. heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;
  10939. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  10940. break;
  10941. default:
  10942. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(destArray[1].name, "\" is not a valid destination type."));
  10943. return;
  10944. }
  10945. if (!ignoreDestinationZoom) {
  10946. if (scale && scale !== this._currentScale) {
  10947. this.currentScaleValue = scale;
  10948. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  10949. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  10950. }
  10951. }
  10952. if (scale === "page-fit" && !destArray[4]) {
  10953. this._scrollIntoView({
  10954. pageDiv: pageView.div,
  10955. pageNumber: pageNumber
  10956. });
  10957. return;
  10958. }
  10959. var boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  10960. var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  10961. var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  10962. if (!allowNegativeOffset) {
  10963. left = Math.max(left, 0);
  10964. top = Math.max(top, 0);
  10965. }
  10966. this._scrollIntoView({
  10967. pageDiv: pageView.div,
  10968. pageSpot: {
  10969. left: left,
  10970. top: top
  10971. },
  10972. pageNumber: pageNumber
  10973. });
  10974. }
  10975. }, {
  10976. key: "_updateLocation",
  10977. value: function _updateLocation(firstPage) {
  10978. var currentScale = this._currentScale;
  10979. var currentScaleValue = this._currentScaleValue;
  10980. var normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  10981. var pageNumber = firstPage.id;
  10982. var pdfOpenParams = "#page=" + pageNumber;
  10983. pdfOpenParams += "&zoom=" + normalizedScaleValue;
  10984. var currentPageView = this._pages[pageNumber - 1];
  10985. var container = this.container;
  10986. var topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  10987. var intLeft = Math.round(topLeft[0]);
  10988. var intTop = Math.round(topLeft[1]);
  10989. pdfOpenParams += "," + intLeft + "," + intTop;
  10990. this._location = {
  10991. pageNumber: pageNumber,
  10992. scale: normalizedScaleValue,
  10993. top: intTop,
  10994. left: intLeft,
  10995. rotation: this._pagesRotation,
  10996. pdfOpenParams: pdfOpenParams
  10997. };
  10998. }
  10999. }, {
  11000. key: "_updateHelper",
  11001. value: function _updateHelper(visiblePages) {
  11002. throw new Error("Not implemented: _updateHelper");
  11003. }
  11004. }, {
  11005. key: "update",
  11006. value: function update() {
  11007. var visible = this._getVisiblePages();
  11008. var visiblePages = visible.views,
  11009. numVisiblePages = visiblePages.length;
  11010. if (numVisiblePages === 0) {
  11011. return;
  11012. }
  11013. var newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
  11014. this._buffer.resize(newCacheSize, visiblePages);
  11015. this.renderingQueue.renderHighestPriority(visible);
  11016. this._updateHelper(visiblePages);
  11017. this._updateLocation(visible.first);
  11018. this.eventBus.dispatch("updateviewarea", {
  11019. source: this,
  11020. location: this._location
  11021. });
  11022. }
  11023. }, {
  11024. key: "containsElement",
  11025. value: function containsElement(element) {
  11026. return this.container.contains(element);
  11027. }
  11028. }, {
  11029. key: "focus",
  11030. value: function focus() {
  11031. this.container.focus();
  11032. }
  11033. }, {
  11034. key: "_getCurrentVisiblePage",
  11035. value: function _getCurrentVisiblePage() {
  11036. if (!this.pagesCount) {
  11037. return {
  11038. views: []
  11039. };
  11040. }
  11041. var pageView = this._pages[this._currentPageNumber - 1];
  11042. var element = pageView.div;
  11043. var view = {
  11044. id: pageView.id,
  11045. x: element.offsetLeft + element.clientLeft,
  11046. y: element.offsetTop + element.clientTop,
  11047. view: pageView
  11048. };
  11049. return {
  11050. first: view,
  11051. last: view,
  11052. views: [view]
  11053. };
  11054. }
  11055. }, {
  11056. key: "_getVisiblePages",
  11057. value: function _getVisiblePages() {
  11058. return (0, _ui_utils.getVisibleElements)({
  11059. scrollEl: this.container,
  11060. views: this._pages,
  11061. sortByVisibility: true,
  11062. horizontal: this._isScrollModeHorizontal,
  11063. rtl: this._isScrollModeHorizontal && this._isContainerRtl
  11064. });
  11065. }
  11066. }, {
  11067. key: "isPageVisible",
  11068. value: function isPageVisible(pageNumber) {
  11069. if (!this.pdfDocument) {
  11070. return false;
  11071. }
  11072. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
  11073. console.error("".concat(this._name, ".isPageVisible: \"").concat(pageNumber, "\" is not a valid page."));
  11074. return false;
  11075. }
  11076. return this._getVisiblePages().views.some(function (view) {
  11077. return view.id === pageNumber;
  11078. });
  11079. }
  11080. }, {
  11081. key: "isPageCached",
  11082. value: function isPageCached(pageNumber) {
  11083. if (!this.pdfDocument || !this._buffer) {
  11084. return false;
  11085. }
  11086. if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
  11087. console.error("".concat(this._name, ".isPageCached: \"").concat(pageNumber, "\" is not a valid page."));
  11088. return false;
  11089. }
  11090. var pageView = this._pages[pageNumber - 1];
  11091. if (!pageView) {
  11092. return false;
  11093. }
  11094. return this._buffer.has(pageView);
  11095. }
  11096. }, {
  11097. key: "cleanup",
  11098. value: function cleanup() {
  11099. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  11100. if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  11101. this._pages[i].reset();
  11102. }
  11103. }
  11104. }
  11105. }, {
  11106. key: "_cancelRendering",
  11107. value: function _cancelRendering() {
  11108. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  11109. if (this._pages[i]) {
  11110. this._pages[i].cancelRendering();
  11111. }
  11112. }
  11113. }
  11114. }, {
  11115. key: "_ensurePdfPageLoaded",
  11116. value: function _ensurePdfPageLoaded(pageView) {
  11117. var _this3 = this;
  11118. if (pageView.pdfPage) {
  11119. return Promise.resolve(pageView.pdfPage);
  11120. }
  11121. if (this._pagesRequests.has(pageView)) {
  11122. return this._pagesRequests.get(pageView);
  11123. }
  11124. var promise = this.pdfDocument.getPage(pageView.id).then(function (pdfPage) {
  11125. if (!pageView.pdfPage) {
  11126. pageView.setPdfPage(pdfPage);
  11127. }
  11128. _this3._pagesRequests["delete"](pageView);
  11129. return pdfPage;
  11130. })["catch"](function (reason) {
  11131. console.error("Unable to get page for page view", reason);
  11132. _this3._pagesRequests["delete"](pageView);
  11133. });
  11134. this._pagesRequests.set(pageView, promise);
  11135. return promise;
  11136. }
  11137. }, {
  11138. key: "forceRendering",
  11139. value: function forceRendering(currentlyVisiblePages) {
  11140. var _this4 = this;
  11141. var visiblePages = currentlyVisiblePages || this._getVisiblePages();
  11142. var scrollAhead = this._isScrollModeHorizontal ? this.scroll.right : this.scroll.down;
  11143. var pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead);
  11144. if (pageView) {
  11145. this._ensurePdfPageLoaded(pageView).then(function () {
  11146. _this4.renderingQueue.renderView(pageView);
  11147. });
  11148. return true;
  11149. }
  11150. return false;
  11151. }
  11152. }, {
  11153. key: "createTextLayerBuilder",
  11154. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  11155. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  11156. var eventBus = arguments.length > 4 ? arguments[4] : undefined;
  11157. return new _text_layer_builder.TextLayerBuilder({
  11158. textLayerDiv: textLayerDiv,
  11159. eventBus: eventBus,
  11160. pageIndex: pageIndex,
  11161. viewport: viewport,
  11162. findController: this.isInPresentationMode ? null : this.findController,
  11163. enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection
  11164. });
  11165. }
  11166. }, {
  11167. key: "createAnnotationLayerBuilder",
  11168. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  11169. var _this$pdfDocument, _this$pdfDocument2;
  11170. var annotationStorage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  11171. var imageResourcesPath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "";
  11172. var renderInteractiveForms = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  11173. var l10n = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : _ui_utils.NullL10n;
  11174. var enableScripting = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
  11175. var hasJSActionsPromise = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
  11176. var mouseState = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
  11177. return new _annotation_layer_builder.AnnotationLayerBuilder({
  11178. pageDiv: pageDiv,
  11179. pdfPage: pdfPage,
  11180. annotationStorage: annotationStorage || ((_this$pdfDocument = this.pdfDocument) === null || _this$pdfDocument === void 0 ? void 0 : _this$pdfDocument.annotationStorage),
  11181. imageResourcesPath: imageResourcesPath,
  11182. renderInteractiveForms: renderInteractiveForms,
  11183. linkService: this.linkService,
  11184. downloadManager: this.downloadManager,
  11185. l10n: l10n,
  11186. enableScripting: enableScripting,
  11187. hasJSActionsPromise: hasJSActionsPromise || ((_this$pdfDocument2 = this.pdfDocument) === null || _this$pdfDocument2 === void 0 ? void 0 : _this$pdfDocument2.hasJSActions()),
  11188. mouseState: mouseState || this._mouseState
  11189. });
  11190. }
  11191. }, {
  11192. key: "getPagesOverview",
  11193. value: function getPagesOverview() {
  11194. var pagesOverview = this._pages.map(function (pageView) {
  11195. var viewport = pageView.pdfPage.getViewport({
  11196. scale: 1
  11197. });
  11198. return {
  11199. width: viewport.width,
  11200. height: viewport.height,
  11201. rotation: viewport.rotation
  11202. };
  11203. });
  11204. if (!this.enablePrintAutoRotate) {
  11205. return pagesOverview;
  11206. }
  11207. return pagesOverview.map(function (size) {
  11208. if ((0, _ui_utils.isPortraitOrientation)(size)) {
  11209. return size;
  11210. }
  11211. return {
  11212. width: size.height,
  11213. height: size.width,
  11214. rotation: (size.rotation + 90) % 360
  11215. };
  11216. });
  11217. }
  11218. }, {
  11219. key: "_updateScrollMode",
  11220. value: function _updateScrollMode() {
  11221. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  11222. var scrollMode = this._scrollMode,
  11223. viewer = this.viewer;
  11224. viewer.classList.toggle("scrollHorizontal", scrollMode === _ui_utils.ScrollMode.HORIZONTAL);
  11225. viewer.classList.toggle("scrollWrapped", scrollMode === _ui_utils.ScrollMode.WRAPPED);
  11226. if (!this.pdfDocument || !pageNumber) {
  11227. return;
  11228. }
  11229. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  11230. this._setScale(this._currentScaleValue, true);
  11231. }
  11232. this._setCurrentPageNumber(pageNumber, true);
  11233. this.update();
  11234. }
  11235. }, {
  11236. key: "_updateSpreadMode",
  11237. value: function _updateSpreadMode() {
  11238. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  11239. if (!this.pdfDocument) {
  11240. return;
  11241. }
  11242. var viewer = this.viewer,
  11243. pages = this._pages;
  11244. viewer.textContent = "";
  11245. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  11246. for (var i = 0, iMax = pages.length; i < iMax; ++i) {
  11247. viewer.appendChild(pages[i].div);
  11248. }
  11249. } else {
  11250. var parity = this._spreadMode - 1;
  11251. var spread = null;
  11252. for (var _i = 0, _iMax = pages.length; _i < _iMax; ++_i) {
  11253. if (spread === null) {
  11254. spread = document.createElement("div");
  11255. spread.className = "spread";
  11256. viewer.appendChild(spread);
  11257. } else if (_i % 2 === parity) {
  11258. spread = spread.cloneNode(false);
  11259. viewer.appendChild(spread);
  11260. }
  11261. spread.appendChild(pages[_i].div);
  11262. }
  11263. }
  11264. if (!pageNumber) {
  11265. return;
  11266. }
  11267. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  11268. this._setScale(this._currentScaleValue, true);
  11269. }
  11270. this._setCurrentPageNumber(pageNumber, true);
  11271. this.update();
  11272. }
  11273. }, {
  11274. key: "_getPageAdvance",
  11275. value: function _getPageAdvance(currentPageNumber) {
  11276. var previous = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  11277. if (this.isInPresentationMode) {
  11278. return 1;
  11279. }
  11280. switch (this._scrollMode) {
  11281. case _ui_utils.ScrollMode.WRAPPED:
  11282. {
  11283. var _this$_getVisiblePage = this._getVisiblePages(),
  11284. views = _this$_getVisiblePage.views,
  11285. pageLayout = new Map();
  11286. var _iterator = _createForOfIteratorHelper(views),
  11287. _step;
  11288. try {
  11289. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  11290. var _step$value = _step.value,
  11291. id = _step$value.id,
  11292. y = _step$value.y,
  11293. percent = _step$value.percent,
  11294. widthPercent = _step$value.widthPercent;
  11295. if (percent === 0 || widthPercent < 100) {
  11296. continue;
  11297. }
  11298. var yArray = pageLayout.get(y);
  11299. if (!yArray) {
  11300. pageLayout.set(y, yArray || (yArray = []));
  11301. }
  11302. yArray.push(id);
  11303. }
  11304. } catch (err) {
  11305. _iterator.e(err);
  11306. } finally {
  11307. _iterator.f();
  11308. }
  11309. var _iterator2 = _createForOfIteratorHelper(pageLayout.values()),
  11310. _step2;
  11311. try {
  11312. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  11313. var _yArray = _step2.value;
  11314. var currentIndex = _yArray.indexOf(currentPageNumber);
  11315. if (currentIndex === -1) {
  11316. continue;
  11317. }
  11318. var numPages = _yArray.length;
  11319. if (numPages === 1) {
  11320. break;
  11321. }
  11322. if (previous) {
  11323. for (var i = currentIndex - 1, ii = 0; i >= ii; i--) {
  11324. var currentId = _yArray[i],
  11325. expectedId = _yArray[i + 1] - 1;
  11326. if (currentId < expectedId) {
  11327. return currentPageNumber - expectedId;
  11328. }
  11329. }
  11330. } else {
  11331. for (var _i2 = currentIndex + 1, _ii = numPages; _i2 < _ii; _i2++) {
  11332. var _currentId = _yArray[_i2],
  11333. _expectedId = _yArray[_i2 - 1] + 1;
  11334. if (_currentId > _expectedId) {
  11335. return _expectedId - currentPageNumber;
  11336. }
  11337. }
  11338. }
  11339. if (previous) {
  11340. var firstId = _yArray[0];
  11341. if (firstId < currentPageNumber) {
  11342. return currentPageNumber - firstId + 1;
  11343. }
  11344. } else {
  11345. var lastId = _yArray[numPages - 1];
  11346. if (lastId > currentPageNumber) {
  11347. return lastId - currentPageNumber + 1;
  11348. }
  11349. }
  11350. break;
  11351. }
  11352. } catch (err) {
  11353. _iterator2.e(err);
  11354. } finally {
  11355. _iterator2.f();
  11356. }
  11357. break;
  11358. }
  11359. case _ui_utils.ScrollMode.HORIZONTAL:
  11360. {
  11361. break;
  11362. }
  11363. case _ui_utils.ScrollMode.VERTICAL:
  11364. {
  11365. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  11366. break;
  11367. }
  11368. var parity = this._spreadMode - 1;
  11369. if (previous && currentPageNumber % 2 !== parity) {
  11370. break;
  11371. } else if (!previous && currentPageNumber % 2 === parity) {
  11372. break;
  11373. }
  11374. var _this$_getVisiblePage2 = this._getVisiblePages(),
  11375. _views = _this$_getVisiblePage2.views,
  11376. _expectedId2 = previous ? currentPageNumber - 1 : currentPageNumber + 1;
  11377. var _iterator3 = _createForOfIteratorHelper(_views),
  11378. _step3;
  11379. try {
  11380. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  11381. var _step3$value = _step3.value,
  11382. _id = _step3$value.id,
  11383. _percent = _step3$value.percent,
  11384. _widthPercent = _step3$value.widthPercent;
  11385. if (_id !== _expectedId2) {
  11386. continue;
  11387. }
  11388. if (_percent > 0 && _widthPercent === 100) {
  11389. return 2;
  11390. }
  11391. break;
  11392. }
  11393. } catch (err) {
  11394. _iterator3.e(err);
  11395. } finally {
  11396. _iterator3.f();
  11397. }
  11398. break;
  11399. }
  11400. }
  11401. return 1;
  11402. }
  11403. }, {
  11404. key: "nextPage",
  11405. value: function nextPage() {
  11406. var currentPageNumber = this._currentPageNumber,
  11407. pagesCount = this.pagesCount;
  11408. if (currentPageNumber >= pagesCount) {
  11409. return false;
  11410. }
  11411. var advance = this._getPageAdvance(currentPageNumber, false) || 1;
  11412. this.currentPageNumber = Math.min(currentPageNumber + advance, pagesCount);
  11413. return true;
  11414. }
  11415. }, {
  11416. key: "previousPage",
  11417. value: function previousPage() {
  11418. var currentPageNumber = this._currentPageNumber;
  11419. if (currentPageNumber <= 1) {
  11420. return false;
  11421. }
  11422. var advance = this._getPageAdvance(currentPageNumber, true) || 1;
  11423. this.currentPageNumber = Math.max(currentPageNumber - advance, 1);
  11424. return true;
  11425. }
  11426. }, {
  11427. key: "initializeScriptingEvents",
  11428. value: function initializeScriptingEvents() {
  11429. var _this5 = this;
  11430. if (!this.enableScripting || this._pageOpenPendingSet) {
  11431. return;
  11432. }
  11433. var eventBus = this.eventBus,
  11434. pageOpenPendingSet = this._pageOpenPendingSet = new Set(),
  11435. scriptingEvents = this._scriptingEvents || (this._scriptingEvents = Object.create(null));
  11436. var dispatchPageClose = function dispatchPageClose(pageNumber) {
  11437. if (pageOpenPendingSet.has(pageNumber)) {
  11438. return;
  11439. }
  11440. eventBus.dispatch("pageclose", {
  11441. source: _this5,
  11442. pageNumber: pageNumber
  11443. });
  11444. };
  11445. var dispatchPageOpen = function dispatchPageOpen(pageNumber) {
  11446. var pageView = _this5._pages[pageNumber - 1];
  11447. if ((pageView === null || pageView === void 0 ? void 0 : pageView.renderingState) === _pdf_rendering_queue.RenderingStates.FINISHED) {
  11448. var _pageView$pdfPage;
  11449. pageOpenPendingSet["delete"](pageNumber);
  11450. eventBus.dispatch("pageopen", {
  11451. source: _this5,
  11452. pageNumber: pageNumber,
  11453. actionsPromise: (_pageView$pdfPage = pageView.pdfPage) === null || _pageView$pdfPage === void 0 ? void 0 : _pageView$pdfPage.getJSActions()
  11454. });
  11455. } else {
  11456. pageOpenPendingSet.add(pageNumber);
  11457. }
  11458. };
  11459. scriptingEvents.onPageChanging = function (_ref4) {
  11460. var pageNumber = _ref4.pageNumber,
  11461. previous = _ref4.previous;
  11462. if (pageNumber === previous) {
  11463. return;
  11464. }
  11465. dispatchPageClose(previous);
  11466. dispatchPageOpen(pageNumber);
  11467. };
  11468. eventBus._on("pagechanging", scriptingEvents.onPageChanging);
  11469. scriptingEvents.onPageRendered = function (_ref5) {
  11470. var pageNumber = _ref5.pageNumber;
  11471. if (!pageOpenPendingSet.has(pageNumber)) {
  11472. return;
  11473. }
  11474. if (pageNumber !== _this5._currentPageNumber) {
  11475. return;
  11476. }
  11477. dispatchPageOpen(pageNumber);
  11478. };
  11479. eventBus._on("pagerendered", scriptingEvents.onPageRendered);
  11480. scriptingEvents.onPagesDestroy = function () {
  11481. dispatchPageClose(_this5._currentPageNumber);
  11482. };
  11483. eventBus._on("pagesdestroy", scriptingEvents.onPagesDestroy);
  11484. dispatchPageOpen(this._currentPageNumber);
  11485. }
  11486. }, {
  11487. key: "_resetScriptingEvents",
  11488. value: function _resetScriptingEvents() {
  11489. if (!this.enableScripting || !this._pageOpenPendingSet) {
  11490. return;
  11491. }
  11492. var eventBus = this.eventBus,
  11493. scriptingEvents = this._scriptingEvents;
  11494. eventBus._off("pagechanging", scriptingEvents.onPageChanging);
  11495. scriptingEvents.onPageChanging = null;
  11496. eventBus._off("pagerendered", scriptingEvents.onPageRendered);
  11497. scriptingEvents.onPageRendered = null;
  11498. eventBus._off("pagesdestroy", scriptingEvents.onPagesDestroy);
  11499. scriptingEvents.onPagesDestroy = null;
  11500. this._pageOpenPendingSet = null;
  11501. }
  11502. }, {
  11503. key: "pagesCount",
  11504. get: function get() {
  11505. return this._pages.length;
  11506. }
  11507. }, {
  11508. key: "pageViewsReady",
  11509. get: function get() {
  11510. if (!this._pagesCapability.settled) {
  11511. return false;
  11512. }
  11513. return this._pages.every(function (pageView) {
  11514. return pageView && pageView.pdfPage;
  11515. });
  11516. }
  11517. }, {
  11518. key: "currentPageNumber",
  11519. get: function get() {
  11520. return this._currentPageNumber;
  11521. },
  11522. set: function set(val) {
  11523. if (!Number.isInteger(val)) {
  11524. throw new Error("Invalid page number.");
  11525. }
  11526. if (!this.pdfDocument) {
  11527. return;
  11528. }
  11529. if (!this._setCurrentPageNumber(val, true)) {
  11530. console.error("".concat(this._name, ".currentPageNumber: \"").concat(val, "\" is not a valid page."));
  11531. }
  11532. }
  11533. }, {
  11534. key: "currentPageLabel",
  11535. get: function get() {
  11536. return this._pageLabels && this._pageLabels[this._currentPageNumber - 1];
  11537. },
  11538. set: function set(val) {
  11539. if (!this.pdfDocument) {
  11540. return;
  11541. }
  11542. var page = val | 0;
  11543. if (this._pageLabels) {
  11544. var i = this._pageLabels.indexOf(val);
  11545. if (i >= 0) {
  11546. page = i + 1;
  11547. }
  11548. }
  11549. if (!this._setCurrentPageNumber(page, true)) {
  11550. console.error("".concat(this._name, ".currentPageLabel: \"").concat(val, "\" is not a valid page."));
  11551. }
  11552. }
  11553. }, {
  11554. key: "currentScale",
  11555. get: function get() {
  11556. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
  11557. },
  11558. set: function set(val) {
  11559. if (isNaN(val)) {
  11560. throw new Error("Invalid numeric scale.");
  11561. }
  11562. if (!this.pdfDocument) {
  11563. return;
  11564. }
  11565. this._setScale(val, false);
  11566. }
  11567. }, {
  11568. key: "currentScaleValue",
  11569. get: function get() {
  11570. return this._currentScaleValue;
  11571. },
  11572. set: function set(val) {
  11573. if (!this.pdfDocument) {
  11574. return;
  11575. }
  11576. this._setScale(val, false);
  11577. }
  11578. }, {
  11579. key: "pagesRotation",
  11580. get: function get() {
  11581. return this._pagesRotation;
  11582. },
  11583. set: function set(rotation) {
  11584. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  11585. throw new Error("Invalid pages rotation angle.");
  11586. }
  11587. if (!this.pdfDocument) {
  11588. return;
  11589. }
  11590. if (this._pagesRotation === rotation) {
  11591. return;
  11592. }
  11593. this._pagesRotation = rotation;
  11594. var pageNumber = this._currentPageNumber;
  11595. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  11596. var pageView = this._pages[i];
  11597. pageView.update(pageView.scale, rotation);
  11598. }
  11599. if (this._currentScaleValue) {
  11600. this._setScale(this._currentScaleValue, true);
  11601. }
  11602. this.eventBus.dispatch("rotationchanging", {
  11603. source: this,
  11604. pagesRotation: rotation,
  11605. pageNumber: pageNumber
  11606. });
  11607. if (this.defaultRenderingQueue) {
  11608. this.update();
  11609. }
  11610. }
  11611. }, {
  11612. key: "firstPagePromise",
  11613. get: function get() {
  11614. return this.pdfDocument ? this._firstPageCapability.promise : null;
  11615. }
  11616. }, {
  11617. key: "onePageRendered",
  11618. get: function get() {
  11619. return this.pdfDocument ? this._onePageRenderedCapability.promise : null;
  11620. }
  11621. }, {
  11622. key: "pagesPromise",
  11623. get: function get() {
  11624. return this.pdfDocument ? this._pagesCapability.promise : null;
  11625. }
  11626. }, {
  11627. key: "_viewerElement",
  11628. get: function get() {
  11629. throw new Error("Not implemented: _viewerElement");
  11630. }
  11631. }, {
  11632. key: "_pageWidthScaleFactor",
  11633. get: function get() {
  11634. if (this.spreadMode !== _ui_utils.SpreadMode.NONE && this.scrollMode !== _ui_utils.ScrollMode.HORIZONTAL && !this.isInPresentationMode) {
  11635. return 2;
  11636. }
  11637. return 1;
  11638. }
  11639. }, {
  11640. key: "_isScrollModeHorizontal",
  11641. get: function get() {
  11642. return this.isInPresentationMode ? false : this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL;
  11643. }
  11644. }, {
  11645. key: "_isContainerRtl",
  11646. get: function get() {
  11647. return getComputedStyle(this.container).direction === "rtl";
  11648. }
  11649. }, {
  11650. key: "isInPresentationMode",
  11651. get: function get() {
  11652. return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
  11653. }
  11654. }, {
  11655. key: "isChangingPresentationMode",
  11656. get: function get() {
  11657. return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
  11658. }
  11659. }, {
  11660. key: "isHorizontalScrollbarEnabled",
  11661. get: function get() {
  11662. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  11663. }
  11664. }, {
  11665. key: "isVerticalScrollbarEnabled",
  11666. get: function get() {
  11667. return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight;
  11668. }
  11669. }, {
  11670. key: "hasEqualPageSizes",
  11671. get: function get() {
  11672. var firstPageView = this._pages[0];
  11673. for (var i = 1, ii = this._pages.length; i < ii; ++i) {
  11674. var pageView = this._pages[i];
  11675. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  11676. return false;
  11677. }
  11678. }
  11679. return true;
  11680. }
  11681. }, {
  11682. key: "optionalContentConfigPromise",
  11683. get: function get() {
  11684. if (!this.pdfDocument) {
  11685. return Promise.resolve(null);
  11686. }
  11687. if (!this._optionalContentConfigPromise) {
  11688. return this.pdfDocument.getOptionalContentConfig();
  11689. }
  11690. return this._optionalContentConfigPromise;
  11691. },
  11692. set: function set(promise) {
  11693. if (!(promise instanceof Promise)) {
  11694. throw new Error("Invalid optionalContentConfigPromise: ".concat(promise));
  11695. }
  11696. if (!this.pdfDocument) {
  11697. return;
  11698. }
  11699. if (!this._optionalContentConfigPromise) {
  11700. return;
  11701. }
  11702. this._optionalContentConfigPromise = promise;
  11703. var _iterator4 = _createForOfIteratorHelper(this._pages),
  11704. _step4;
  11705. try {
  11706. for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
  11707. var pageView = _step4.value;
  11708. pageView.update(pageView.scale, pageView.rotation, promise);
  11709. }
  11710. } catch (err) {
  11711. _iterator4.e(err);
  11712. } finally {
  11713. _iterator4.f();
  11714. }
  11715. this.update();
  11716. this.eventBus.dispatch("optionalcontentconfigchanged", {
  11717. source: this,
  11718. promise: promise
  11719. });
  11720. }
  11721. }, {
  11722. key: "scrollMode",
  11723. get: function get() {
  11724. return this._scrollMode;
  11725. },
  11726. set: function set(mode) {
  11727. if (this._scrollMode === mode) {
  11728. return;
  11729. }
  11730. if (!(0, _ui_utils.isValidScrollMode)(mode)) {
  11731. throw new Error("Invalid scroll mode: ".concat(mode));
  11732. }
  11733. this._scrollMode = mode;
  11734. this.eventBus.dispatch("scrollmodechanged", {
  11735. source: this,
  11736. mode: mode
  11737. });
  11738. this._updateScrollMode(this._currentPageNumber);
  11739. }
  11740. }, {
  11741. key: "spreadMode",
  11742. get: function get() {
  11743. return this._spreadMode;
  11744. },
  11745. set: function set(mode) {
  11746. if (this._spreadMode === mode) {
  11747. return;
  11748. }
  11749. if (!(0, _ui_utils.isValidSpreadMode)(mode)) {
  11750. throw new Error("Invalid spread mode: ".concat(mode));
  11751. }
  11752. this._spreadMode = mode;
  11753. this.eventBus.dispatch("spreadmodechanged", {
  11754. source: this,
  11755. mode: mode
  11756. });
  11757. this._updateSpreadMode(this._currentPageNumber);
  11758. }
  11759. }]);
  11760. return BaseViewer;
  11761. }();
  11762. exports.BaseViewer = BaseViewer;
  11763. /***/ }),
  11764. /* 30 */
  11765. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  11766. Object.defineProperty(exports, "__esModule", ({
  11767. value: true
  11768. }));
  11769. exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = void 0;
  11770. var _pdfjsLib = __webpack_require__(7);
  11771. var _ui_utils = __webpack_require__(6);
  11772. var _pdf_link_service = __webpack_require__(21);
  11773. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  11774. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  11775. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  11776. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  11777. function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  11778. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  11779. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11780. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  11781. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11782. var AnnotationLayerBuilder = /*#__PURE__*/function () {
  11783. function AnnotationLayerBuilder(_ref) {
  11784. var pageDiv = _ref.pageDiv,
  11785. pdfPage = _ref.pdfPage,
  11786. linkService = _ref.linkService,
  11787. downloadManager = _ref.downloadManager,
  11788. _ref$annotationStorag = _ref.annotationStorage,
  11789. annotationStorage = _ref$annotationStorag === void 0 ? null : _ref$annotationStorag,
  11790. _ref$imageResourcesPa = _ref.imageResourcesPath,
  11791. imageResourcesPath = _ref$imageResourcesPa === void 0 ? "" : _ref$imageResourcesPa,
  11792. _ref$renderInteractiv = _ref.renderInteractiveForms,
  11793. renderInteractiveForms = _ref$renderInteractiv === void 0 ? true : _ref$renderInteractiv,
  11794. _ref$l10n = _ref.l10n,
  11795. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n,
  11796. _ref$enableScripting = _ref.enableScripting,
  11797. enableScripting = _ref$enableScripting === void 0 ? false : _ref$enableScripting,
  11798. _ref$hasJSActionsProm = _ref.hasJSActionsPromise,
  11799. hasJSActionsPromise = _ref$hasJSActionsProm === void 0 ? null : _ref$hasJSActionsProm,
  11800. _ref$mouseState = _ref.mouseState,
  11801. mouseState = _ref$mouseState === void 0 ? null : _ref$mouseState;
  11802. _classCallCheck(this, AnnotationLayerBuilder);
  11803. this.pageDiv = pageDiv;
  11804. this.pdfPage = pdfPage;
  11805. this.linkService = linkService;
  11806. this.downloadManager = downloadManager;
  11807. this.imageResourcesPath = imageResourcesPath;
  11808. this.renderInteractiveForms = renderInteractiveForms;
  11809. this.l10n = l10n;
  11810. this.annotationStorage = annotationStorage;
  11811. this.enableScripting = enableScripting;
  11812. this._hasJSActionsPromise = hasJSActionsPromise;
  11813. this._mouseState = mouseState;
  11814. this.div = null;
  11815. this._cancelled = false;
  11816. }
  11817. _createClass(AnnotationLayerBuilder, [{
  11818. key: "render",
  11819. value: function render(viewport) {
  11820. var _this = this;
  11821. var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "display";
  11822. return Promise.all([this.pdfPage.getAnnotations({
  11823. intent: intent
  11824. }), this._hasJSActionsPromise]).then(function (_ref2) {
  11825. var _ref3 = _slicedToArray(_ref2, 2),
  11826. annotations = _ref3[0],
  11827. _ref3$ = _ref3[1],
  11828. hasJSActions = _ref3$ === void 0 ? false : _ref3$;
  11829. if (_this._cancelled) {
  11830. return;
  11831. }
  11832. if (annotations.length === 0) {
  11833. return;
  11834. }
  11835. var parameters = {
  11836. viewport: viewport.clone({
  11837. dontFlip: true
  11838. }),
  11839. div: _this.div,
  11840. annotations: annotations,
  11841. page: _this.pdfPage,
  11842. imageResourcesPath: _this.imageResourcesPath,
  11843. renderInteractiveForms: _this.renderInteractiveForms,
  11844. linkService: _this.linkService,
  11845. downloadManager: _this.downloadManager,
  11846. annotationStorage: _this.annotationStorage,
  11847. enableScripting: _this.enableScripting,
  11848. hasJSActions: hasJSActions,
  11849. mouseState: _this._mouseState
  11850. };
  11851. if (_this.div) {
  11852. _pdfjsLib.AnnotationLayer.update(parameters);
  11853. } else {
  11854. _this.div = document.createElement("div");
  11855. _this.div.className = "annotationLayer";
  11856. _this.pageDiv.appendChild(_this.div);
  11857. parameters.div = _this.div;
  11858. _pdfjsLib.AnnotationLayer.render(parameters);
  11859. _this.l10n.translate(_this.div);
  11860. }
  11861. });
  11862. }
  11863. }, {
  11864. key: "cancel",
  11865. value: function cancel() {
  11866. this._cancelled = true;
  11867. }
  11868. }, {
  11869. key: "hide",
  11870. value: function hide() {
  11871. if (!this.div) {
  11872. return;
  11873. }
  11874. this.div.setAttribute("hidden", "true");
  11875. }
  11876. }]);
  11877. return AnnotationLayerBuilder;
  11878. }();
  11879. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  11880. var DefaultAnnotationLayerFactory = /*#__PURE__*/function () {
  11881. function DefaultAnnotationLayerFactory() {
  11882. _classCallCheck(this, DefaultAnnotationLayerFactory);
  11883. }
  11884. _createClass(DefaultAnnotationLayerFactory, [{
  11885. key: "createAnnotationLayerBuilder",
  11886. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  11887. var annotationStorage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  11888. var imageResourcesPath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "";
  11889. var renderInteractiveForms = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
  11890. var l10n = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : _ui_utils.NullL10n;
  11891. var enableScripting = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
  11892. var hasJSActionsPromise = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
  11893. var mouseState = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
  11894. return new AnnotationLayerBuilder({
  11895. pageDiv: pageDiv,
  11896. pdfPage: pdfPage,
  11897. imageResourcesPath: imageResourcesPath,
  11898. renderInteractiveForms: renderInteractiveForms,
  11899. linkService: new _pdf_link_service.SimpleLinkService(),
  11900. l10n: l10n,
  11901. annotationStorage: annotationStorage,
  11902. enableScripting: enableScripting,
  11903. hasJSActionsPromise: hasJSActionsPromise,
  11904. mouseState: mouseState
  11905. });
  11906. }
  11907. }]);
  11908. return DefaultAnnotationLayerFactory;
  11909. }();
  11910. exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
  11911. /***/ }),
  11912. /* 31 */
  11913. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  11914. Object.defineProperty(exports, "__esModule", ({
  11915. value: true
  11916. }));
  11917. exports.PDFPageView = void 0;
  11918. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  11919. var _ui_utils = __webpack_require__(6);
  11920. var _pdfjsLib = __webpack_require__(7);
  11921. var _pdf_rendering_queue = __webpack_require__(10);
  11922. var _viewer_compatibility = __webpack_require__(2);
  11923. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11924. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  11925. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  11926. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11927. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  11928. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11929. var MAX_CANVAS_PIXELS = _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216;
  11930. var PDFPageView = /*#__PURE__*/function () {
  11931. function PDFPageView(options) {
  11932. _classCallCheck(this, PDFPageView);
  11933. var container = options.container;
  11934. var defaultViewport = options.defaultViewport;
  11935. this.id = options.id;
  11936. this.renderingId = "page" + this.id;
  11937. this.pdfPage = null;
  11938. this.pageLabel = null;
  11939. this.rotation = 0;
  11940. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  11941. this.viewport = defaultViewport;
  11942. this.pdfPageRotate = defaultViewport.rotation;
  11943. this._optionalContentConfigPromise = options.optionalContentConfigPromise || null;
  11944. this.hasRestrictedScaling = false;
  11945. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  11946. this.imageResourcesPath = options.imageResourcesPath || "";
  11947. this.renderInteractiveForms = typeof options.renderInteractiveForms === "boolean" ? options.renderInteractiveForms : true;
  11948. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  11949. this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
  11950. this.eventBus = options.eventBus;
  11951. this.renderingQueue = options.renderingQueue;
  11952. this.textLayerFactory = options.textLayerFactory;
  11953. this.annotationLayerFactory = options.annotationLayerFactory;
  11954. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  11955. this.enableWebGL = options.enableWebGL || false;
  11956. this.l10n = options.l10n || _ui_utils.NullL10n;
  11957. this.enableScripting = options.enableScripting || false;
  11958. this.paintTask = null;
  11959. this.paintedViewportMap = new WeakMap();
  11960. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  11961. this.resume = null;
  11962. this._renderError = null;
  11963. this.annotationLayer = null;
  11964. this.textLayer = null;
  11965. this.zoomLayer = null;
  11966. var div = document.createElement("div");
  11967. div.className = "page";
  11968. div.style.width = Math.floor(this.viewport.width) + "px";
  11969. div.style.height = Math.floor(this.viewport.height) + "px";
  11970. div.setAttribute("data-page-number", this.id);
  11971. this.div = div;
  11972. container.appendChild(div);
  11973. }
  11974. _createClass(PDFPageView, [{
  11975. key: "setPdfPage",
  11976. value: function setPdfPage(pdfPage) {
  11977. this.pdfPage = pdfPage;
  11978. this.pdfPageRotate = pdfPage.rotate;
  11979. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  11980. this.viewport = pdfPage.getViewport({
  11981. scale: this.scale * _ui_utils.CSS_UNITS,
  11982. rotation: totalRotation
  11983. });
  11984. this.reset();
  11985. }
  11986. }, {
  11987. key: "destroy",
  11988. value: function destroy() {
  11989. this.reset();
  11990. if (this.pdfPage) {
  11991. this.pdfPage.cleanup();
  11992. }
  11993. }
  11994. }, {
  11995. key: "_renderAnnotationLayer",
  11996. value: function () {
  11997. var _renderAnnotationLayer2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  11998. var error;
  11999. return _regenerator["default"].wrap(function _callee$(_context) {
  12000. while (1) {
  12001. switch (_context.prev = _context.next) {
  12002. case 0:
  12003. error = null;
  12004. _context.prev = 1;
  12005. _context.next = 4;
  12006. return this.annotationLayer.render(this.viewport, "display");
  12007. case 4:
  12008. _context.next = 9;
  12009. break;
  12010. case 6:
  12011. _context.prev = 6;
  12012. _context.t0 = _context["catch"](1);
  12013. error = _context.t0;
  12014. case 9:
  12015. _context.prev = 9;
  12016. this.eventBus.dispatch("annotationlayerrendered", {
  12017. source: this,
  12018. pageNumber: this.id,
  12019. error: error
  12020. });
  12021. return _context.finish(9);
  12022. case 12:
  12023. case "end":
  12024. return _context.stop();
  12025. }
  12026. }
  12027. }, _callee, this, [[1, 6, 9, 12]]);
  12028. }));
  12029. function _renderAnnotationLayer() {
  12030. return _renderAnnotationLayer2.apply(this, arguments);
  12031. }
  12032. return _renderAnnotationLayer;
  12033. }()
  12034. }, {
  12035. key: "_resetZoomLayer",
  12036. value: function _resetZoomLayer() {
  12037. var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  12038. if (!this.zoomLayer) {
  12039. return;
  12040. }
  12041. var zoomLayerCanvas = this.zoomLayer.firstChild;
  12042. this.paintedViewportMap["delete"](zoomLayerCanvas);
  12043. zoomLayerCanvas.width = 0;
  12044. zoomLayerCanvas.height = 0;
  12045. if (removeFromDOM) {
  12046. this.zoomLayer.remove();
  12047. }
  12048. this.zoomLayer = null;
  12049. }
  12050. }, {
  12051. key: "reset",
  12052. value: function reset() {
  12053. var keepZoomLayer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  12054. var keepAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  12055. this.cancelRendering(keepAnnotations);
  12056. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  12057. var div = this.div;
  12058. div.style.width = Math.floor(this.viewport.width) + "px";
  12059. div.style.height = Math.floor(this.viewport.height) + "px";
  12060. var childNodes = div.childNodes;
  12061. var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
  12062. var currentAnnotationNode = keepAnnotations && this.annotationLayer && this.annotationLayer.div || null;
  12063. for (var i = childNodes.length - 1; i >= 0; i--) {
  12064. var node = childNodes[i];
  12065. if (currentZoomLayerNode === node || currentAnnotationNode === node) {
  12066. continue;
  12067. }
  12068. div.removeChild(node);
  12069. }
  12070. div.removeAttribute("data-loaded");
  12071. if (currentAnnotationNode) {
  12072. this.annotationLayer.hide();
  12073. } else if (this.annotationLayer) {
  12074. this.annotationLayer.cancel();
  12075. this.annotationLayer = null;
  12076. }
  12077. if (!currentZoomLayerNode) {
  12078. if (this.canvas) {
  12079. this.paintedViewportMap["delete"](this.canvas);
  12080. this.canvas.width = 0;
  12081. this.canvas.height = 0;
  12082. delete this.canvas;
  12083. }
  12084. this._resetZoomLayer();
  12085. }
  12086. if (this.svg) {
  12087. this.paintedViewportMap["delete"](this.svg);
  12088. delete this.svg;
  12089. }
  12090. this.loadingIconDiv = document.createElement("div");
  12091. this.loadingIconDiv.className = "loadingIcon";
  12092. div.appendChild(this.loadingIconDiv);
  12093. }
  12094. }, {
  12095. key: "update",
  12096. value: function update(scale, rotation) {
  12097. var optionalContentConfigPromise = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  12098. this.scale = scale || this.scale;
  12099. if (typeof rotation !== "undefined") {
  12100. this.rotation = rotation;
  12101. }
  12102. if (optionalContentConfigPromise instanceof Promise) {
  12103. this._optionalContentConfigPromise = optionalContentConfigPromise;
  12104. }
  12105. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  12106. this.viewport = this.viewport.clone({
  12107. scale: this.scale * _ui_utils.CSS_UNITS,
  12108. rotation: totalRotation
  12109. });
  12110. if (this.svg) {
  12111. this.cssTransform(this.svg, true);
  12112. this.eventBus.dispatch("pagerendered", {
  12113. source: this,
  12114. pageNumber: this.id,
  12115. cssTransform: true,
  12116. timestamp: performance.now(),
  12117. error: this._renderError
  12118. });
  12119. return;
  12120. }
  12121. var isScalingRestricted = false;
  12122. if (this.canvas && this.maxCanvasPixels > 0) {
  12123. var outputScale = this.outputScale;
  12124. if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > this.maxCanvasPixels) {
  12125. isScalingRestricted = true;
  12126. }
  12127. }
  12128. if (this.canvas) {
  12129. if (this.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
  12130. this.cssTransform(this.canvas, true);
  12131. this.eventBus.dispatch("pagerendered", {
  12132. source: this,
  12133. pageNumber: this.id,
  12134. cssTransform: true,
  12135. timestamp: performance.now(),
  12136. error: this._renderError
  12137. });
  12138. return;
  12139. }
  12140. if (!this.zoomLayer && !this.canvas.hasAttribute("hidden")) {
  12141. this.zoomLayer = this.canvas.parentNode;
  12142. this.zoomLayer.style.position = "absolute";
  12143. }
  12144. }
  12145. if (this.zoomLayer) {
  12146. this.cssTransform(this.zoomLayer.firstChild);
  12147. }
  12148. this.reset(true, true);
  12149. }
  12150. }, {
  12151. key: "cancelRendering",
  12152. value: function cancelRendering() {
  12153. var keepAnnotations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  12154. if (this.paintTask) {
  12155. this.paintTask.cancel();
  12156. this.paintTask = null;
  12157. }
  12158. this.resume = null;
  12159. if (this.textLayer) {
  12160. this.textLayer.cancel();
  12161. this.textLayer = null;
  12162. }
  12163. if (!keepAnnotations && this.annotationLayer) {
  12164. this.annotationLayer.cancel();
  12165. this.annotationLayer = null;
  12166. }
  12167. }
  12168. }, {
  12169. key: "cssTransform",
  12170. value: function cssTransform(target) {
  12171. var redrawAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  12172. var width = this.viewport.width;
  12173. var height = this.viewport.height;
  12174. var div = this.div;
  12175. target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + "px";
  12176. target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + "px";
  12177. var relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
  12178. var absRotation = Math.abs(relativeRotation);
  12179. var scaleX = 1,
  12180. scaleY = 1;
  12181. if (absRotation === 90 || absRotation === 270) {
  12182. scaleX = height / width;
  12183. scaleY = width / height;
  12184. }
  12185. target.style.transform = "rotate(".concat(relativeRotation, "deg) scale(").concat(scaleX, ", ").concat(scaleY, ")");
  12186. if (this.textLayer) {
  12187. var textLayerViewport = this.textLayer.viewport;
  12188. var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
  12189. var textAbsRotation = Math.abs(textRelativeRotation);
  12190. var scale = width / textLayerViewport.width;
  12191. if (textAbsRotation === 90 || textAbsRotation === 270) {
  12192. scale = width / textLayerViewport.height;
  12193. }
  12194. var textLayerDiv = this.textLayer.textLayerDiv;
  12195. var transX, transY;
  12196. switch (textAbsRotation) {
  12197. case 0:
  12198. transX = transY = 0;
  12199. break;
  12200. case 90:
  12201. transX = 0;
  12202. transY = "-" + textLayerDiv.style.height;
  12203. break;
  12204. case 180:
  12205. transX = "-" + textLayerDiv.style.width;
  12206. transY = "-" + textLayerDiv.style.height;
  12207. break;
  12208. case 270:
  12209. transX = "-" + textLayerDiv.style.width;
  12210. transY = 0;
  12211. break;
  12212. default:
  12213. console.error("Bad rotation value.");
  12214. break;
  12215. }
  12216. textLayerDiv.style.transform = "rotate(".concat(textAbsRotation, "deg) ") + "scale(".concat(scale, ") ") + "translate(".concat(transX, ", ").concat(transY, ")");
  12217. textLayerDiv.style.transformOrigin = "0% 0%";
  12218. }
  12219. if (redrawAnnotations && this.annotationLayer) {
  12220. this._renderAnnotationLayer();
  12221. }
  12222. }
  12223. }, {
  12224. key: "getPagePoint",
  12225. value: function getPagePoint(x, y) {
  12226. return this.viewport.convertToPdfPoint(x, y);
  12227. }
  12228. }, {
  12229. key: "draw",
  12230. value: function draw() {
  12231. var _this = this;
  12232. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  12233. console.error("Must be in new state before drawing");
  12234. this.reset();
  12235. }
  12236. var div = this.div,
  12237. pdfPage = this.pdfPage;
  12238. if (!pdfPage) {
  12239. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  12240. if (this.loadingIconDiv) {
  12241. div.removeChild(this.loadingIconDiv);
  12242. delete this.loadingIconDiv;
  12243. }
  12244. return Promise.reject(new Error("pdfPage is not loaded"));
  12245. }
  12246. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  12247. var canvasWrapper = document.createElement("div");
  12248. canvasWrapper.style.width = div.style.width;
  12249. canvasWrapper.style.height = div.style.height;
  12250. canvasWrapper.classList.add("canvasWrapper");
  12251. if (this.annotationLayer && this.annotationLayer.div) {
  12252. div.insertBefore(canvasWrapper, this.annotationLayer.div);
  12253. } else {
  12254. div.appendChild(canvasWrapper);
  12255. }
  12256. var textLayer = null;
  12257. if (this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && this.textLayerFactory) {
  12258. var textLayerDiv = document.createElement("div");
  12259. textLayerDiv.className = "textLayer";
  12260. textLayerDiv.style.width = canvasWrapper.style.width;
  12261. textLayerDiv.style.height = canvasWrapper.style.height;
  12262. if (this.annotationLayer && this.annotationLayer.div) {
  12263. div.insertBefore(textLayerDiv, this.annotationLayer.div);
  12264. } else {
  12265. div.appendChild(textLayerDiv);
  12266. }
  12267. textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.textLayerMode === _ui_utils.TextLayerMode.ENABLE_ENHANCE, this.eventBus);
  12268. }
  12269. this.textLayer = textLayer;
  12270. var renderContinueCallback = null;
  12271. if (this.renderingQueue) {
  12272. renderContinueCallback = function renderContinueCallback(cont) {
  12273. if (!_this.renderingQueue.isHighestPriority(_this)) {
  12274. _this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  12275. _this.resume = function () {
  12276. _this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  12277. cont();
  12278. };
  12279. return;
  12280. }
  12281. cont();
  12282. };
  12283. }
  12284. var finishPaintTask = /*#__PURE__*/function () {
  12285. var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  12286. var error,
  12287. _args2 = arguments;
  12288. return _regenerator["default"].wrap(function _callee2$(_context2) {
  12289. while (1) {
  12290. switch (_context2.prev = _context2.next) {
  12291. case 0:
  12292. error = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : null;
  12293. if (paintTask === _this.paintTask) {
  12294. _this.paintTask = null;
  12295. }
  12296. if (!(error instanceof _pdfjsLib.RenderingCancelledException)) {
  12297. _context2.next = 5;
  12298. break;
  12299. }
  12300. _this._renderError = null;
  12301. return _context2.abrupt("return");
  12302. case 5:
  12303. _this._renderError = error;
  12304. _this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  12305. if (_this.loadingIconDiv) {
  12306. div.removeChild(_this.loadingIconDiv);
  12307. delete _this.loadingIconDiv;
  12308. }
  12309. _this._resetZoomLayer(true);
  12310. _this.eventBus.dispatch("pagerendered", {
  12311. source: _this,
  12312. pageNumber: _this.id,
  12313. cssTransform: false,
  12314. timestamp: performance.now(),
  12315. error: _this._renderError
  12316. });
  12317. if (!error) {
  12318. _context2.next = 12;
  12319. break;
  12320. }
  12321. throw error;
  12322. case 12:
  12323. case "end":
  12324. return _context2.stop();
  12325. }
  12326. }
  12327. }, _callee2);
  12328. }));
  12329. return function finishPaintTask() {
  12330. return _ref.apply(this, arguments);
  12331. };
  12332. }();
  12333. var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
  12334. paintTask.onRenderContinue = renderContinueCallback;
  12335. this.paintTask = paintTask;
  12336. var resultPromise = paintTask.promise.then(function () {
  12337. return finishPaintTask(null).then(function () {
  12338. if (textLayer) {
  12339. var readableStream = pdfPage.streamTextContent({
  12340. normalizeWhitespace: true
  12341. });
  12342. textLayer.setTextContentStream(readableStream);
  12343. textLayer.render();
  12344. }
  12345. });
  12346. }, function (reason) {
  12347. return finishPaintTask(reason);
  12348. });
  12349. if (this.annotationLayerFactory) {
  12350. if (!this.annotationLayer) {
  12351. this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, null, this.imageResourcesPath, this.renderInteractiveForms, this.l10n, this.enableScripting, null, null);
  12352. }
  12353. this._renderAnnotationLayer();
  12354. }
  12355. div.setAttribute("data-loaded", true);
  12356. this.eventBus.dispatch("pagerender", {
  12357. source: this,
  12358. pageNumber: this.id
  12359. });
  12360. return resultPromise;
  12361. }
  12362. }, {
  12363. key: "paintOnCanvas",
  12364. value: function paintOnCanvas(canvasWrapper) {
  12365. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  12366. var result = {
  12367. promise: renderCapability.promise,
  12368. onRenderContinue: function onRenderContinue(cont) {
  12369. cont();
  12370. },
  12371. cancel: function cancel() {
  12372. renderTask.cancel();
  12373. }
  12374. };
  12375. var viewport = this.viewport;
  12376. var canvas = document.createElement("canvas");
  12377. this.l10n.get("page_canvas", {
  12378. page: this.id
  12379. }, "Page {{page}}").then(function (msg) {
  12380. canvas.setAttribute("aria-label", msg);
  12381. });
  12382. canvas.setAttribute("hidden", "hidden");
  12383. var isCanvasHidden = true;
  12384. var showCanvas = function showCanvas() {
  12385. if (isCanvasHidden) {
  12386. canvas.removeAttribute("hidden");
  12387. isCanvasHidden = false;
  12388. }
  12389. };
  12390. canvasWrapper.appendChild(canvas);
  12391. this.canvas = canvas;
  12392. canvas.mozOpaque = true;
  12393. var ctx = canvas.getContext("2d", {
  12394. alpha: false
  12395. });
  12396. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  12397. this.outputScale = outputScale;
  12398. if (this.useOnlyCssZoom) {
  12399. var actualSizeViewport = viewport.clone({
  12400. scale: _ui_utils.CSS_UNITS
  12401. });
  12402. outputScale.sx *= actualSizeViewport.width / viewport.width;
  12403. outputScale.sy *= actualSizeViewport.height / viewport.height;
  12404. outputScale.scaled = true;
  12405. }
  12406. if (this.maxCanvasPixels > 0) {
  12407. var pixelsInViewport = viewport.width * viewport.height;
  12408. var maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
  12409. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  12410. outputScale.sx = maxScale;
  12411. outputScale.sy = maxScale;
  12412. outputScale.scaled = true;
  12413. this.hasRestrictedScaling = true;
  12414. } else {
  12415. this.hasRestrictedScaling = false;
  12416. }
  12417. }
  12418. var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  12419. var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  12420. canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
  12421. canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
  12422. canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + "px";
  12423. canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + "px";
  12424. this.paintedViewportMap.set(canvas, viewport);
  12425. var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
  12426. var renderContext = {
  12427. canvasContext: ctx,
  12428. transform: transform,
  12429. viewport: this.viewport,
  12430. enableWebGL: this.enableWebGL,
  12431. renderInteractiveForms: this.renderInteractiveForms,
  12432. optionalContentConfigPromise: this._optionalContentConfigPromise
  12433. };
  12434. var renderTask = this.pdfPage.render(renderContext);
  12435. renderTask.onContinue = function (cont) {
  12436. showCanvas();
  12437. if (result.onRenderContinue) {
  12438. result.onRenderContinue(cont);
  12439. } else {
  12440. cont();
  12441. }
  12442. };
  12443. renderTask.promise.then(function () {
  12444. showCanvas();
  12445. renderCapability.resolve(undefined);
  12446. }, function (error) {
  12447. showCanvas();
  12448. renderCapability.reject(error);
  12449. });
  12450. return result;
  12451. }
  12452. }, {
  12453. key: "paintOnSvg",
  12454. value: function paintOnSvg(wrapper) {
  12455. var _this2 = this;
  12456. var cancelled = false;
  12457. var ensureNotCancelled = function ensureNotCancelled() {
  12458. if (cancelled) {
  12459. throw new _pdfjsLib.RenderingCancelledException("Rendering cancelled, page ".concat(_this2.id), "svg");
  12460. }
  12461. };
  12462. var pdfPage = this.pdfPage;
  12463. var actualSizeViewport = this.viewport.clone({
  12464. scale: _ui_utils.CSS_UNITS
  12465. });
  12466. var promise = pdfPage.getOperatorList().then(function (opList) {
  12467. ensureNotCancelled();
  12468. var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
  12469. return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {
  12470. ensureNotCancelled();
  12471. _this2.svg = svg;
  12472. _this2.paintedViewportMap.set(svg, actualSizeViewport);
  12473. svg.style.width = wrapper.style.width;
  12474. svg.style.height = wrapper.style.height;
  12475. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  12476. wrapper.appendChild(svg);
  12477. });
  12478. });
  12479. return {
  12480. promise: promise,
  12481. onRenderContinue: function onRenderContinue(cont) {
  12482. cont();
  12483. },
  12484. cancel: function cancel() {
  12485. cancelled = true;
  12486. }
  12487. };
  12488. }
  12489. }, {
  12490. key: "setPageLabel",
  12491. value: function setPageLabel(label) {
  12492. this.pageLabel = typeof label === "string" ? label : null;
  12493. if (this.pageLabel !== null) {
  12494. this.div.setAttribute("data-page-label", this.pageLabel);
  12495. } else {
  12496. this.div.removeAttribute("data-page-label");
  12497. }
  12498. }
  12499. }, {
  12500. key: "width",
  12501. get: function get() {
  12502. return this.viewport.width;
  12503. }
  12504. }, {
  12505. key: "height",
  12506. get: function get() {
  12507. return this.viewport.height;
  12508. }
  12509. }]);
  12510. return PDFPageView;
  12511. }();
  12512. exports.PDFPageView = PDFPageView;
  12513. /***/ }),
  12514. /* 32 */
  12515. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  12516. Object.defineProperty(exports, "__esModule", ({
  12517. value: true
  12518. }));
  12519. exports.TextLayerBuilder = exports.DefaultTextLayerFactory = void 0;
  12520. var _pdfjsLib = __webpack_require__(7);
  12521. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12522. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  12523. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12524. var EXPAND_DIVS_TIMEOUT = 300;
  12525. var TextLayerBuilder = /*#__PURE__*/function () {
  12526. function TextLayerBuilder(_ref) {
  12527. var textLayerDiv = _ref.textLayerDiv,
  12528. eventBus = _ref.eventBus,
  12529. pageIndex = _ref.pageIndex,
  12530. viewport = _ref.viewport,
  12531. _ref$findController = _ref.findController,
  12532. findController = _ref$findController === void 0 ? null : _ref$findController,
  12533. _ref$enhanceTextSelec = _ref.enhanceTextSelection,
  12534. enhanceTextSelection = _ref$enhanceTextSelec === void 0 ? false : _ref$enhanceTextSelec;
  12535. _classCallCheck(this, TextLayerBuilder);
  12536. this.textLayerDiv = textLayerDiv;
  12537. this.eventBus = eventBus;
  12538. this.textContent = null;
  12539. this.textContentItemsStr = [];
  12540. this.textContentStream = null;
  12541. this.renderingDone = false;
  12542. this.pageIdx = pageIndex;
  12543. this.pageNumber = this.pageIdx + 1;
  12544. this.matches = [];
  12545. this.viewport = viewport;
  12546. this.textDivs = [];
  12547. this.findController = findController;
  12548. this.textLayerRenderTask = null;
  12549. this.enhanceTextSelection = enhanceTextSelection;
  12550. this._onUpdateTextLayerMatches = null;
  12551. this._bindMouse();
  12552. }
  12553. _createClass(TextLayerBuilder, [{
  12554. key: "_finishRendering",
  12555. value: function _finishRendering() {
  12556. this.renderingDone = true;
  12557. if (!this.enhanceTextSelection) {
  12558. var endOfContent = document.createElement("div");
  12559. endOfContent.className = "endOfContent";
  12560. this.textLayerDiv.appendChild(endOfContent);
  12561. }
  12562. this.eventBus.dispatch("textlayerrendered", {
  12563. source: this,
  12564. pageNumber: this.pageNumber,
  12565. numTextDivs: this.textDivs.length
  12566. });
  12567. }
  12568. }, {
  12569. key: "render",
  12570. value: function render() {
  12571. var _this = this;
  12572. var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  12573. if (!(this.textContent || this.textContentStream) || this.renderingDone) {
  12574. return;
  12575. }
  12576. this.cancel();
  12577. this.textDivs = [];
  12578. var textLayerFrag = document.createDocumentFragment();
  12579. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  12580. textContent: this.textContent,
  12581. textContentStream: this.textContentStream,
  12582. container: textLayerFrag,
  12583. viewport: this.viewport,
  12584. textDivs: this.textDivs,
  12585. textContentItemsStr: this.textContentItemsStr,
  12586. timeout: timeout,
  12587. enhanceTextSelection: this.enhanceTextSelection
  12588. });
  12589. this.textLayerRenderTask.promise.then(function () {
  12590. _this.textLayerDiv.appendChild(textLayerFrag);
  12591. _this._finishRendering();
  12592. _this._updateMatches();
  12593. }, function (reason) {});
  12594. if (!this._onUpdateTextLayerMatches) {
  12595. this._onUpdateTextLayerMatches = function (evt) {
  12596. if (evt.pageIndex === _this.pageIdx || evt.pageIndex === -1) {
  12597. _this._updateMatches();
  12598. }
  12599. };
  12600. this.eventBus._on("updatetextlayermatches", this._onUpdateTextLayerMatches);
  12601. }
  12602. }
  12603. }, {
  12604. key: "cancel",
  12605. value: function cancel() {
  12606. if (this.textLayerRenderTask) {
  12607. this.textLayerRenderTask.cancel();
  12608. this.textLayerRenderTask = null;
  12609. }
  12610. if (this._onUpdateTextLayerMatches) {
  12611. this.eventBus._off("updatetextlayermatches", this._onUpdateTextLayerMatches);
  12612. this._onUpdateTextLayerMatches = null;
  12613. }
  12614. }
  12615. }, {
  12616. key: "setTextContentStream",
  12617. value: function setTextContentStream(readableStream) {
  12618. this.cancel();
  12619. this.textContentStream = readableStream;
  12620. }
  12621. }, {
  12622. key: "setTextContent",
  12623. value: function setTextContent(textContent) {
  12624. this.cancel();
  12625. this.textContent = textContent;
  12626. }
  12627. }, {
  12628. key: "_convertMatches",
  12629. value: function _convertMatches(matches, matchesLength) {
  12630. if (!matches) {
  12631. return [];
  12632. }
  12633. var textContentItemsStr = this.textContentItemsStr;
  12634. var i = 0,
  12635. iIndex = 0;
  12636. var end = textContentItemsStr.length - 1;
  12637. var result = [];
  12638. for (var m = 0, mm = matches.length; m < mm; m++) {
  12639. var matchIdx = matches[m];
  12640. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  12641. iIndex += textContentItemsStr[i].length;
  12642. i++;
  12643. }
  12644. if (i === textContentItemsStr.length) {
  12645. console.error("Could not find a matching mapping");
  12646. }
  12647. var match = {
  12648. begin: {
  12649. divIdx: i,
  12650. offset: matchIdx - iIndex
  12651. }
  12652. };
  12653. matchIdx += matchesLength[m];
  12654. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  12655. iIndex += textContentItemsStr[i].length;
  12656. i++;
  12657. }
  12658. match.end = {
  12659. divIdx: i,
  12660. offset: matchIdx - iIndex
  12661. };
  12662. result.push(match);
  12663. }
  12664. return result;
  12665. }
  12666. }, {
  12667. key: "_renderMatches",
  12668. value: function _renderMatches(matches) {
  12669. if (matches.length === 0) {
  12670. return;
  12671. }
  12672. var findController = this.findController,
  12673. pageIdx = this.pageIdx,
  12674. textContentItemsStr = this.textContentItemsStr,
  12675. textDivs = this.textDivs;
  12676. var isSelectedPage = pageIdx === findController.selected.pageIdx;
  12677. var selectedMatchIdx = findController.selected.matchIdx;
  12678. var highlightAll = findController.state.highlightAll;
  12679. var prevEnd = null;
  12680. var infinity = {
  12681. divIdx: -1,
  12682. offset: undefined
  12683. };
  12684. function beginText(begin, className) {
  12685. var divIdx = begin.divIdx;
  12686. textDivs[divIdx].textContent = "";
  12687. appendTextToDiv(divIdx, 0, begin.offset, className);
  12688. }
  12689. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  12690. var div = textDivs[divIdx];
  12691. var content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  12692. var node = document.createTextNode(content);
  12693. if (className) {
  12694. var span = document.createElement("span");
  12695. span.className = className;
  12696. span.appendChild(node);
  12697. div.appendChild(span);
  12698. return;
  12699. }
  12700. div.appendChild(node);
  12701. }
  12702. var i0 = selectedMatchIdx,
  12703. i1 = i0 + 1;
  12704. if (highlightAll) {
  12705. i0 = 0;
  12706. i1 = matches.length;
  12707. } else if (!isSelectedPage) {
  12708. return;
  12709. }
  12710. for (var i = i0; i < i1; i++) {
  12711. var match = matches[i];
  12712. var begin = match.begin;
  12713. var end = match.end;
  12714. var isSelected = isSelectedPage && i === selectedMatchIdx;
  12715. var highlightSuffix = isSelected ? " selected" : "";
  12716. if (isSelected) {
  12717. findController.scrollMatchIntoView({
  12718. element: textDivs[begin.divIdx],
  12719. pageIndex: pageIdx,
  12720. matchIndex: selectedMatchIdx
  12721. });
  12722. }
  12723. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  12724. if (prevEnd !== null) {
  12725. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  12726. }
  12727. beginText(begin);
  12728. } else {
  12729. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  12730. }
  12731. if (begin.divIdx === end.divIdx) {
  12732. appendTextToDiv(begin.divIdx, begin.offset, end.offset, "highlight" + highlightSuffix);
  12733. } else {
  12734. appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, "highlight begin" + highlightSuffix);
  12735. for (var n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  12736. textDivs[n0].className = "highlight middle" + highlightSuffix;
  12737. }
  12738. beginText(end, "highlight end" + highlightSuffix);
  12739. }
  12740. prevEnd = end;
  12741. }
  12742. if (prevEnd) {
  12743. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  12744. }
  12745. }
  12746. }, {
  12747. key: "_updateMatches",
  12748. value: function _updateMatches() {
  12749. if (!this.renderingDone) {
  12750. return;
  12751. }
  12752. var findController = this.findController,
  12753. matches = this.matches,
  12754. pageIdx = this.pageIdx,
  12755. textContentItemsStr = this.textContentItemsStr,
  12756. textDivs = this.textDivs;
  12757. var clearedUntilDivIdx = -1;
  12758. for (var i = 0, ii = matches.length; i < ii; i++) {
  12759. var match = matches[i];
  12760. var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  12761. for (var n = begin, end = match.end.divIdx; n <= end; n++) {
  12762. var div = textDivs[n];
  12763. div.textContent = textContentItemsStr[n];
  12764. div.className = "";
  12765. }
  12766. clearedUntilDivIdx = match.end.divIdx + 1;
  12767. }
  12768. if (!findController || !findController.highlightMatches) {
  12769. return;
  12770. }
  12771. var pageMatches = findController.pageMatches[pageIdx] || null;
  12772. var pageMatchesLength = findController.pageMatchesLength[pageIdx] || null;
  12773. this.matches = this._convertMatches(pageMatches, pageMatchesLength);
  12774. this._renderMatches(this.matches);
  12775. }
  12776. }, {
  12777. key: "_bindMouse",
  12778. value: function _bindMouse() {
  12779. var _this2 = this;
  12780. var div = this.textLayerDiv;
  12781. var expandDivsTimer = null;
  12782. div.addEventListener("mousedown", function (evt) {
  12783. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  12784. _this2.textLayerRenderTask.expandTextDivs(true);
  12785. if (expandDivsTimer) {
  12786. clearTimeout(expandDivsTimer);
  12787. expandDivsTimer = null;
  12788. }
  12789. return;
  12790. }
  12791. var end = div.querySelector(".endOfContent");
  12792. if (!end) {
  12793. return;
  12794. }
  12795. var adjustTop = evt.target !== div;
  12796. adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue("-moz-user-select") !== "none";
  12797. if (adjustTop) {
  12798. var divBounds = div.getBoundingClientRect();
  12799. var r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  12800. end.style.top = (r * 100).toFixed(2) + "%";
  12801. }
  12802. end.classList.add("active");
  12803. });
  12804. div.addEventListener("mouseup", function () {
  12805. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  12806. expandDivsTimer = setTimeout(function () {
  12807. if (_this2.textLayerRenderTask) {
  12808. _this2.textLayerRenderTask.expandTextDivs(false);
  12809. }
  12810. expandDivsTimer = null;
  12811. }, EXPAND_DIVS_TIMEOUT);
  12812. return;
  12813. }
  12814. var end = div.querySelector(".endOfContent");
  12815. if (!end) {
  12816. return;
  12817. }
  12818. end.style.top = "";
  12819. end.classList.remove("active");
  12820. });
  12821. }
  12822. }]);
  12823. return TextLayerBuilder;
  12824. }();
  12825. exports.TextLayerBuilder = TextLayerBuilder;
  12826. var DefaultTextLayerFactory = /*#__PURE__*/function () {
  12827. function DefaultTextLayerFactory() {
  12828. _classCallCheck(this, DefaultTextLayerFactory);
  12829. }
  12830. _createClass(DefaultTextLayerFactory, [{
  12831. key: "createTextLayerBuilder",
  12832. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  12833. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  12834. var eventBus = arguments.length > 4 ? arguments[4] : undefined;
  12835. return new TextLayerBuilder({
  12836. textLayerDiv: textLayerDiv,
  12837. pageIndex: pageIndex,
  12838. viewport: viewport,
  12839. enhanceTextSelection: enhanceTextSelection,
  12840. eventBus: eventBus
  12841. });
  12842. }
  12843. }]);
  12844. return DefaultTextLayerFactory;
  12845. }();
  12846. exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
  12847. /***/ }),
  12848. /* 33 */
  12849. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  12850. Object.defineProperty(exports, "__esModule", ({
  12851. value: true
  12852. }));
  12853. exports.SecondaryToolbar = void 0;
  12854. var _ui_utils = __webpack_require__(6);
  12855. var _pdf_cursor_tools = __webpack_require__(8);
  12856. var _pdf_single_page_viewer = __webpack_require__(34);
  12857. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  12858. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  12859. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  12860. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12861. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  12862. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12863. var SecondaryToolbar = /*#__PURE__*/function () {
  12864. function SecondaryToolbar(options, mainContainer, eventBus) {
  12865. var _this = this;
  12866. _classCallCheck(this, SecondaryToolbar);
  12867. this.toolbar = options.toolbar;
  12868. this.toggleButton = options.toggleButton;
  12869. this.toolbarButtonContainer = options.toolbarButtonContainer;
  12870. this.buttons = [{
  12871. element: options.presentationModeButton,
  12872. eventName: "presentationmode",
  12873. close: true
  12874. }, {
  12875. element: options.openFileButton,
  12876. eventName: "openfile",
  12877. close: true
  12878. }, {
  12879. element: options.printButton,
  12880. eventName: "print",
  12881. close: true
  12882. }, {
  12883. element: options.downloadButton,
  12884. eventName: "download",
  12885. close: true
  12886. }, {
  12887. element: options.viewBookmarkButton,
  12888. eventName: null,
  12889. close: true
  12890. }, {
  12891. element: options.firstPageButton,
  12892. eventName: "firstpage",
  12893. close: true
  12894. }, {
  12895. element: options.lastPageButton,
  12896. eventName: "lastpage",
  12897. close: true
  12898. }, {
  12899. element: options.pageRotateCwButton,
  12900. eventName: "rotatecw",
  12901. close: false
  12902. }, {
  12903. element: options.pageRotateCcwButton,
  12904. eventName: "rotateccw",
  12905. close: false
  12906. }, {
  12907. element: options.cursorSelectToolButton,
  12908. eventName: "switchcursortool",
  12909. eventDetails: {
  12910. tool: _pdf_cursor_tools.CursorTool.SELECT
  12911. },
  12912. close: true
  12913. }, {
  12914. element: options.cursorHandToolButton,
  12915. eventName: "switchcursortool",
  12916. eventDetails: {
  12917. tool: _pdf_cursor_tools.CursorTool.HAND
  12918. },
  12919. close: true
  12920. }, {
  12921. element: options.scrollVerticalButton,
  12922. eventName: "switchscrollmode",
  12923. eventDetails: {
  12924. mode: _ui_utils.ScrollMode.VERTICAL
  12925. },
  12926. close: true
  12927. }, {
  12928. element: options.scrollHorizontalButton,
  12929. eventName: "switchscrollmode",
  12930. eventDetails: {
  12931. mode: _ui_utils.ScrollMode.HORIZONTAL
  12932. },
  12933. close: true
  12934. }, {
  12935. element: options.scrollWrappedButton,
  12936. eventName: "switchscrollmode",
  12937. eventDetails: {
  12938. mode: _ui_utils.ScrollMode.WRAPPED
  12939. },
  12940. close: true
  12941. }, {
  12942. element: options.spreadNoneButton,
  12943. eventName: "switchspreadmode",
  12944. eventDetails: {
  12945. mode: _ui_utils.SpreadMode.NONE
  12946. },
  12947. close: true
  12948. }, {
  12949. element: options.spreadOddButton,
  12950. eventName: "switchspreadmode",
  12951. eventDetails: {
  12952. mode: _ui_utils.SpreadMode.ODD
  12953. },
  12954. close: true
  12955. }, {
  12956. element: options.spreadEvenButton,
  12957. eventName: "switchspreadmode",
  12958. eventDetails: {
  12959. mode: _ui_utils.SpreadMode.EVEN
  12960. },
  12961. close: true
  12962. }, {
  12963. element: options.documentPropertiesButton,
  12964. eventName: "documentproperties",
  12965. close: true
  12966. }];
  12967. this.items = {
  12968. firstPage: options.firstPageButton,
  12969. lastPage: options.lastPageButton,
  12970. pageRotateCw: options.pageRotateCwButton,
  12971. pageRotateCcw: options.pageRotateCcwButton
  12972. };
  12973. this.mainContainer = mainContainer;
  12974. this.eventBus = eventBus;
  12975. this.opened = false;
  12976. this.containerHeight = null;
  12977. this.previousContainerHeight = null;
  12978. this.reset();
  12979. this._bindClickListeners();
  12980. this._bindCursorToolsListener(options);
  12981. this._bindScrollModeListener(options);
  12982. this._bindSpreadModeListener(options);
  12983. this.eventBus._on("resize", this._setMaxHeight.bind(this));
  12984. this.eventBus._on("baseviewerinit", function (evt) {
  12985. if (evt.source instanceof _pdf_single_page_viewer.PDFSinglePageViewer) {
  12986. _this.toolbarButtonContainer.classList.add("hiddenScrollModeButtons", "hiddenSpreadModeButtons");
  12987. } else {
  12988. _this.toolbarButtonContainer.classList.remove("hiddenScrollModeButtons", "hiddenSpreadModeButtons");
  12989. }
  12990. });
  12991. }
  12992. _createClass(SecondaryToolbar, [{
  12993. key: "setPageNumber",
  12994. value: function setPageNumber(pageNumber) {
  12995. this.pageNumber = pageNumber;
  12996. this._updateUIState();
  12997. }
  12998. }, {
  12999. key: "setPagesCount",
  13000. value: function setPagesCount(pagesCount) {
  13001. this.pagesCount = pagesCount;
  13002. this._updateUIState();
  13003. }
  13004. }, {
  13005. key: "reset",
  13006. value: function reset() {
  13007. this.pageNumber = 0;
  13008. this.pagesCount = 0;
  13009. this._updateUIState();
  13010. this.eventBus.dispatch("secondarytoolbarreset", {
  13011. source: this
  13012. });
  13013. }
  13014. }, {
  13015. key: "_updateUIState",
  13016. value: function _updateUIState() {
  13017. this.items.firstPage.disabled = this.pageNumber <= 1;
  13018. this.items.lastPage.disabled = this.pageNumber >= this.pagesCount;
  13019. this.items.pageRotateCw.disabled = this.pagesCount === 0;
  13020. this.items.pageRotateCcw.disabled = this.pagesCount === 0;
  13021. }
  13022. }, {
  13023. key: "_bindClickListeners",
  13024. value: function _bindClickListeners() {
  13025. var _this2 = this;
  13026. this.toggleButton.addEventListener("click", this.toggle.bind(this));
  13027. var _iterator = _createForOfIteratorHelper(this.buttons),
  13028. _step;
  13029. try {
  13030. var _loop = function _loop() {
  13031. var _step$value = _step.value,
  13032. element = _step$value.element,
  13033. eventName = _step$value.eventName,
  13034. close = _step$value.close,
  13035. eventDetails = _step$value.eventDetails;
  13036. element.addEventListener("click", function (evt) {
  13037. if (eventName !== null) {
  13038. var details = {
  13039. source: _this2
  13040. };
  13041. for (var property in eventDetails) {
  13042. details[property] = eventDetails[property];
  13043. }
  13044. _this2.eventBus.dispatch(eventName, details);
  13045. }
  13046. if (close) {
  13047. _this2.close();
  13048. }
  13049. });
  13050. };
  13051. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  13052. _loop();
  13053. }
  13054. } catch (err) {
  13055. _iterator.e(err);
  13056. } finally {
  13057. _iterator.f();
  13058. }
  13059. }
  13060. }, {
  13061. key: "_bindCursorToolsListener",
  13062. value: function _bindCursorToolsListener(buttons) {
  13063. this.eventBus._on("cursortoolchanged", function (_ref) {
  13064. var tool = _ref.tool;
  13065. buttons.cursorSelectToolButton.classList.toggle("toggled", tool === _pdf_cursor_tools.CursorTool.SELECT);
  13066. buttons.cursorHandToolButton.classList.toggle("toggled", tool === _pdf_cursor_tools.CursorTool.HAND);
  13067. });
  13068. }
  13069. }, {
  13070. key: "_bindScrollModeListener",
  13071. value: function _bindScrollModeListener(buttons) {
  13072. var _this3 = this;
  13073. function scrollModeChanged(_ref2) {
  13074. var mode = _ref2.mode;
  13075. buttons.scrollVerticalButton.classList.toggle("toggled", mode === _ui_utils.ScrollMode.VERTICAL);
  13076. buttons.scrollHorizontalButton.classList.toggle("toggled", mode === _ui_utils.ScrollMode.HORIZONTAL);
  13077. buttons.scrollWrappedButton.classList.toggle("toggled", mode === _ui_utils.ScrollMode.WRAPPED);
  13078. var isScrollModeHorizontal = mode === _ui_utils.ScrollMode.HORIZONTAL;
  13079. buttons.spreadNoneButton.disabled = isScrollModeHorizontal;
  13080. buttons.spreadOddButton.disabled = isScrollModeHorizontal;
  13081. buttons.spreadEvenButton.disabled = isScrollModeHorizontal;
  13082. }
  13083. this.eventBus._on("scrollmodechanged", scrollModeChanged);
  13084. this.eventBus._on("secondarytoolbarreset", function (evt) {
  13085. if (evt.source === _this3) {
  13086. scrollModeChanged({
  13087. mode: _ui_utils.ScrollMode.VERTICAL
  13088. });
  13089. }
  13090. });
  13091. }
  13092. }, {
  13093. key: "_bindSpreadModeListener",
  13094. value: function _bindSpreadModeListener(buttons) {
  13095. var _this4 = this;
  13096. function spreadModeChanged(_ref3) {
  13097. var mode = _ref3.mode;
  13098. buttons.spreadNoneButton.classList.toggle("toggled", mode === _ui_utils.SpreadMode.NONE);
  13099. buttons.spreadOddButton.classList.toggle("toggled", mode === _ui_utils.SpreadMode.ODD);
  13100. buttons.spreadEvenButton.classList.toggle("toggled", mode === _ui_utils.SpreadMode.EVEN);
  13101. }
  13102. this.eventBus._on("spreadmodechanged", spreadModeChanged);
  13103. this.eventBus._on("secondarytoolbarreset", function (evt) {
  13104. if (evt.source === _this4) {
  13105. spreadModeChanged({
  13106. mode: _ui_utils.SpreadMode.NONE
  13107. });
  13108. }
  13109. });
  13110. }
  13111. }, {
  13112. key: "open",
  13113. value: function open() {
  13114. if (this.opened) {
  13115. return;
  13116. }
  13117. this.opened = true;
  13118. this._setMaxHeight();
  13119. this.toggleButton.classList.add("toggled");
  13120. this.toolbar.classList.remove("hidden");
  13121. }
  13122. }, {
  13123. key: "close",
  13124. value: function close() {
  13125. if (!this.opened) {
  13126. return;
  13127. }
  13128. this.opened = false;
  13129. this.toolbar.classList.add("hidden");
  13130. this.toggleButton.classList.remove("toggled");
  13131. }
  13132. }, {
  13133. key: "toggle",
  13134. value: function toggle() {
  13135. if (this.opened) {
  13136. this.close();
  13137. } else {
  13138. this.open();
  13139. }
  13140. }
  13141. }, {
  13142. key: "_setMaxHeight",
  13143. value: function _setMaxHeight() {
  13144. if (!this.opened) {
  13145. return;
  13146. }
  13147. this.containerHeight = this.mainContainer.clientHeight;
  13148. if (this.containerHeight === this.previousContainerHeight) {
  13149. return;
  13150. }
  13151. this.toolbarButtonContainer.style.maxHeight = "".concat(this.containerHeight - _ui_utils.SCROLLBAR_PADDING, "px");
  13152. this.previousContainerHeight = this.containerHeight;
  13153. }
  13154. }, {
  13155. key: "isOpen",
  13156. get: function get() {
  13157. return this.opened;
  13158. }
  13159. }]);
  13160. return SecondaryToolbar;
  13161. }();
  13162. exports.SecondaryToolbar = SecondaryToolbar;
  13163. /***/ }),
  13164. /* 34 */
  13165. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13166. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  13167. Object.defineProperty(exports, "__esModule", ({
  13168. value: true
  13169. }));
  13170. exports.PDFSinglePageViewer = void 0;
  13171. var _base_viewer = __webpack_require__(29);
  13172. var _pdfjsLib = __webpack_require__(7);
  13173. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13174. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  13175. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13176. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  13177. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  13178. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  13179. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13180. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  13181. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  13182. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  13183. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  13184. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  13185. var PDFSinglePageViewer = /*#__PURE__*/function (_BaseViewer) {
  13186. _inherits(PDFSinglePageViewer, _BaseViewer);
  13187. var _super = _createSuper(PDFSinglePageViewer);
  13188. function PDFSinglePageViewer(options) {
  13189. var _this;
  13190. _classCallCheck(this, PDFSinglePageViewer);
  13191. _this = _super.call(this, options);
  13192. _this.eventBus._on("pagesinit", function (evt) {
  13193. _this._ensurePageViewVisible();
  13194. });
  13195. return _this;
  13196. }
  13197. _createClass(PDFSinglePageViewer, [{
  13198. key: "_resetView",
  13199. value: function _resetView() {
  13200. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_resetView", this).call(this);
  13201. this._previousPageNumber = 1;
  13202. this._shadowViewer = document.createDocumentFragment();
  13203. this._updateScrollDown = null;
  13204. }
  13205. }, {
  13206. key: "_ensurePageViewVisible",
  13207. value: function _ensurePageViewVisible() {
  13208. var pageView = this._pages[this._currentPageNumber - 1];
  13209. var previousPageView = this._pages[this._previousPageNumber - 1];
  13210. var viewerNodes = this.viewer.childNodes;
  13211. switch (viewerNodes.length) {
  13212. case 0:
  13213. this.viewer.appendChild(pageView.div);
  13214. break;
  13215. case 1:
  13216. if (viewerNodes[0] !== previousPageView.div) {
  13217. throw new Error("_ensurePageViewVisible: Unexpected previously visible page.");
  13218. }
  13219. if (pageView === previousPageView) {
  13220. break;
  13221. }
  13222. this._shadowViewer.appendChild(previousPageView.div);
  13223. this.viewer.appendChild(pageView.div);
  13224. this.container.scrollTop = 0;
  13225. break;
  13226. default:
  13227. throw new Error("_ensurePageViewVisible: Only one page should be visible at a time.");
  13228. }
  13229. this._previousPageNumber = this._currentPageNumber;
  13230. }
  13231. }, {
  13232. key: "_scrollUpdate",
  13233. value: function _scrollUpdate() {
  13234. if (this._updateScrollDown) {
  13235. this._updateScrollDown();
  13236. }
  13237. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollUpdate", this).call(this);
  13238. }
  13239. }, {
  13240. key: "_scrollIntoView",
  13241. value: function _scrollIntoView(_ref) {
  13242. var _this2 = this;
  13243. var pageDiv = _ref.pageDiv,
  13244. _ref$pageSpot = _ref.pageSpot,
  13245. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  13246. _ref$pageNumber = _ref.pageNumber,
  13247. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  13248. if (pageNumber) {
  13249. this._setCurrentPageNumber(pageNumber);
  13250. }
  13251. var scrolledDown = this._currentPageNumber >= this._previousPageNumber;
  13252. this._ensurePageViewVisible();
  13253. this.update();
  13254. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollIntoView", this).call(this, {
  13255. pageDiv: pageDiv,
  13256. pageSpot: pageSpot,
  13257. pageNumber: pageNumber
  13258. });
  13259. this._updateScrollDown = function () {
  13260. _this2.scroll.down = scrolledDown;
  13261. _this2._updateScrollDown = null;
  13262. };
  13263. }
  13264. }, {
  13265. key: "_getVisiblePages",
  13266. value: function _getVisiblePages() {
  13267. return this._getCurrentVisiblePage();
  13268. }
  13269. }, {
  13270. key: "_updateHelper",
  13271. value: function _updateHelper(visiblePages) {}
  13272. }, {
  13273. key: "_updateScrollMode",
  13274. value: function _updateScrollMode() {}
  13275. }, {
  13276. key: "_updateSpreadMode",
  13277. value: function _updateSpreadMode() {}
  13278. }, {
  13279. key: "_getPageAdvance",
  13280. value: function _getPageAdvance() {
  13281. return 1;
  13282. }
  13283. }, {
  13284. key: "_viewerElement",
  13285. get: function get() {
  13286. return (0, _pdfjsLib.shadow)(this, "_viewerElement", this._shadowViewer);
  13287. }
  13288. }, {
  13289. key: "_pageWidthScaleFactor",
  13290. get: function get() {
  13291. return 1;
  13292. }
  13293. }, {
  13294. key: "_isScrollModeHorizontal",
  13295. get: function get() {
  13296. return (0, _pdfjsLib.shadow)(this, "_isScrollModeHorizontal", false);
  13297. }
  13298. }]);
  13299. return PDFSinglePageViewer;
  13300. }(_base_viewer.BaseViewer);
  13301. exports.PDFSinglePageViewer = PDFSinglePageViewer;
  13302. /***/ }),
  13303. /* 35 */
  13304. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13305. Object.defineProperty(exports, "__esModule", ({
  13306. value: true
  13307. }));
  13308. exports.Toolbar = void 0;
  13309. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  13310. var _ui_utils = __webpack_require__(6);
  13311. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13312. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  13313. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  13314. function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  13315. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  13316. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  13317. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13318. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  13319. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13320. var PAGE_NUMBER_LOADING_INDICATOR = "visiblePageIsLoading";
  13321. var SCALE_SELECT_CONTAINER_WIDTH = 140;
  13322. var SCALE_SELECT_WIDTH = 162;
  13323. var Toolbar = /*#__PURE__*/function () {
  13324. function Toolbar(options, eventBus) {
  13325. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  13326. _classCallCheck(this, Toolbar);
  13327. this.toolbar = options.container;
  13328. this.eventBus = eventBus;
  13329. this.l10n = l10n;
  13330. this.buttons = [{
  13331. element: options.previous,
  13332. eventName: "previouspage"
  13333. }, {
  13334. element: options.next,
  13335. eventName: "nextpage"
  13336. }, {
  13337. element: options.zoomIn,
  13338. eventName: "zoomin"
  13339. }, {
  13340. element: options.zoomOut,
  13341. eventName: "zoomout"
  13342. }, {
  13343. element: options.openFile,
  13344. eventName: "openfile"
  13345. }, {
  13346. element: options.print,
  13347. eventName: "print"
  13348. }, {
  13349. element: options.presentationModeButton,
  13350. eventName: "presentationmode"
  13351. }, {
  13352. element: options.download,
  13353. eventName: "download"
  13354. }, {
  13355. element: options.viewBookmark,
  13356. eventName: null
  13357. }];
  13358. this.items = {
  13359. numPages: options.numPages,
  13360. pageNumber: options.pageNumber,
  13361. scaleSelectContainer: options.scaleSelectContainer,
  13362. scaleSelect: options.scaleSelect,
  13363. customScaleOption: options.customScaleOption,
  13364. previous: options.previous,
  13365. next: options.next,
  13366. zoomIn: options.zoomIn,
  13367. zoomOut: options.zoomOut
  13368. };
  13369. this._wasLocalized = false;
  13370. this.reset();
  13371. this._bindListeners();
  13372. }
  13373. _createClass(Toolbar, [{
  13374. key: "setPageNumber",
  13375. value: function setPageNumber(pageNumber, pageLabel) {
  13376. this.pageNumber = pageNumber;
  13377. this.pageLabel = pageLabel;
  13378. this._updateUIState(false);
  13379. }
  13380. }, {
  13381. key: "setPagesCount",
  13382. value: function setPagesCount(pagesCount, hasPageLabels) {
  13383. this.pagesCount = pagesCount;
  13384. this.hasPageLabels = hasPageLabels;
  13385. this._updateUIState(true);
  13386. }
  13387. }, {
  13388. key: "setPageScale",
  13389. value: function setPageScale(pageScaleValue, pageScale) {
  13390. this.pageScaleValue = (pageScaleValue || pageScale).toString();
  13391. this.pageScale = pageScale;
  13392. this._updateUIState(false);
  13393. }
  13394. }, {
  13395. key: "reset",
  13396. value: function reset() {
  13397. this.pageNumber = 0;
  13398. this.pageLabel = null;
  13399. this.hasPageLabels = false;
  13400. this.pagesCount = 0;
  13401. this.pageScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  13402. this.pageScale = _ui_utils.DEFAULT_SCALE;
  13403. this._updateUIState(true);
  13404. this.updateLoadingIndicatorState();
  13405. }
  13406. }, {
  13407. key: "_bindListeners",
  13408. value: function _bindListeners() {
  13409. var _this = this;
  13410. var _this$items = this.items,
  13411. pageNumber = _this$items.pageNumber,
  13412. scaleSelect = _this$items.scaleSelect;
  13413. var self = this;
  13414. var _iterator = _createForOfIteratorHelper(this.buttons),
  13415. _step;
  13416. try {
  13417. var _loop = function _loop() {
  13418. var _step$value = _step.value,
  13419. element = _step$value.element,
  13420. eventName = _step$value.eventName;
  13421. element.addEventListener("click", function (evt) {
  13422. if (eventName !== null) {
  13423. _this.eventBus.dispatch(eventName, {
  13424. source: _this
  13425. });
  13426. }
  13427. });
  13428. };
  13429. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  13430. _loop();
  13431. }
  13432. } catch (err) {
  13433. _iterator.e(err);
  13434. } finally {
  13435. _iterator.f();
  13436. }
  13437. pageNumber.addEventListener("click", function () {
  13438. this.select();
  13439. });
  13440. pageNumber.addEventListener("change", function () {
  13441. self.eventBus.dispatch("pagenumberchanged", {
  13442. source: self,
  13443. value: this.value
  13444. });
  13445. });
  13446. scaleSelect.addEventListener("change", function () {
  13447. if (this.value === "custom") {
  13448. return;
  13449. }
  13450. self.eventBus.dispatch("scalechanged", {
  13451. source: self,
  13452. value: this.value
  13453. });
  13454. });
  13455. scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler;
  13456. this.eventBus._on("localized", function () {
  13457. _this._wasLocalized = true;
  13458. _this._adjustScaleWidth();
  13459. _this._updateUIState(true);
  13460. });
  13461. }
  13462. }, {
  13463. key: "_updateUIState",
  13464. value: function _updateUIState() {
  13465. var resetNumPages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  13466. if (!this._wasLocalized) {
  13467. return;
  13468. }
  13469. var pageNumber = this.pageNumber,
  13470. pagesCount = this.pagesCount,
  13471. pageScaleValue = this.pageScaleValue,
  13472. pageScale = this.pageScale,
  13473. items = this.items;
  13474. if (resetNumPages) {
  13475. if (this.hasPageLabels) {
  13476. items.pageNumber.type = "text";
  13477. } else {
  13478. items.pageNumber.type = "number";
  13479. this.l10n.get("of_pages", {
  13480. pagesCount: pagesCount
  13481. }, "of {{pagesCount}}").then(function (msg) {
  13482. items.numPages.textContent = msg;
  13483. });
  13484. }
  13485. items.pageNumber.max = pagesCount;
  13486. }
  13487. if (this.hasPageLabels) {
  13488. items.pageNumber.value = this.pageLabel;
  13489. this.l10n.get("page_of_pages", {
  13490. pageNumber: pageNumber,
  13491. pagesCount: pagesCount
  13492. }, "({{pageNumber}} of {{pagesCount}})").then(function (msg) {
  13493. items.numPages.textContent = msg;
  13494. });
  13495. } else {
  13496. items.pageNumber.value = pageNumber;
  13497. }
  13498. items.previous.disabled = pageNumber <= 1;
  13499. items.next.disabled = pageNumber >= pagesCount;
  13500. items.zoomOut.disabled = pageScale <= _ui_utils.MIN_SCALE;
  13501. items.zoomIn.disabled = pageScale >= _ui_utils.MAX_SCALE;
  13502. var customScale = Math.round(pageScale * 10000) / 100;
  13503. this.l10n.get("page_scale_percent", {
  13504. scale: customScale
  13505. }, "{{scale}}%").then(function (msg) {
  13506. var predefinedValueFound = false;
  13507. var _iterator2 = _createForOfIteratorHelper(items.scaleSelect.options),
  13508. _step2;
  13509. try {
  13510. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  13511. var option = _step2.value;
  13512. if (option.value !== pageScaleValue) {
  13513. option.selected = false;
  13514. continue;
  13515. }
  13516. option.selected = true;
  13517. predefinedValueFound = true;
  13518. }
  13519. } catch (err) {
  13520. _iterator2.e(err);
  13521. } finally {
  13522. _iterator2.f();
  13523. }
  13524. if (!predefinedValueFound) {
  13525. items.customScaleOption.textContent = msg;
  13526. items.customScaleOption.selected = true;
  13527. }
  13528. });
  13529. }
  13530. }, {
  13531. key: "updateLoadingIndicatorState",
  13532. value: function updateLoadingIndicatorState() {
  13533. var loading = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  13534. var pageNumberInput = this.items.pageNumber;
  13535. pageNumberInput.classList.toggle(PAGE_NUMBER_LOADING_INDICATOR, loading);
  13536. }
  13537. }, {
  13538. key: "_adjustScaleWidth",
  13539. value: function () {
  13540. var _adjustScaleWidth2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  13541. var items, l10n, predefinedValuesPromise, canvas, ctx, _getComputedStyle, fontSize, fontFamily, maxWidth, _iterator3, _step3, predefinedValue, _ctx$measureText, width, overflow;
  13542. return _regenerator["default"].wrap(function _callee$(_context) {
  13543. while (1) {
  13544. switch (_context.prev = _context.next) {
  13545. case 0:
  13546. items = this.items, l10n = this.l10n;
  13547. predefinedValuesPromise = Promise.all([l10n.get("page_scale_auto", null, "Automatic Zoom"), l10n.get("page_scale_actual", null, "Actual Size"), l10n.get("page_scale_fit", null, "Page Fit"), l10n.get("page_scale_width", null, "Page Width")]);
  13548. canvas = document.createElement("canvas");
  13549. canvas.mozOpaque = true;
  13550. ctx = canvas.getContext("2d", {
  13551. alpha: false
  13552. });
  13553. _context.next = 7;
  13554. return _ui_utils.animationStarted;
  13555. case 7:
  13556. _getComputedStyle = getComputedStyle(items.scaleSelect), fontSize = _getComputedStyle.fontSize, fontFamily = _getComputedStyle.fontFamily;
  13557. ctx.font = "".concat(fontSize, " ").concat(fontFamily);
  13558. maxWidth = 0;
  13559. _context.t0 = _createForOfIteratorHelper;
  13560. _context.next = 13;
  13561. return predefinedValuesPromise;
  13562. case 13:
  13563. _context.t1 = _context.sent;
  13564. _iterator3 = (0, _context.t0)(_context.t1);
  13565. try {
  13566. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  13567. predefinedValue = _step3.value;
  13568. _ctx$measureText = ctx.measureText(predefinedValue), width = _ctx$measureText.width;
  13569. if (width > maxWidth) {
  13570. maxWidth = width;
  13571. }
  13572. }
  13573. } catch (err) {
  13574. _iterator3.e(err);
  13575. } finally {
  13576. _iterator3.f();
  13577. }
  13578. overflow = SCALE_SELECT_WIDTH - SCALE_SELECT_CONTAINER_WIDTH;
  13579. maxWidth += 2 * overflow;
  13580. if (maxWidth > SCALE_SELECT_CONTAINER_WIDTH) {
  13581. items.scaleSelect.style.width = "".concat(maxWidth + overflow, "px");
  13582. items.scaleSelectContainer.style.width = "".concat(maxWidth, "px");
  13583. }
  13584. canvas.width = 0;
  13585. canvas.height = 0;
  13586. canvas = ctx = null;
  13587. case 22:
  13588. case "end":
  13589. return _context.stop();
  13590. }
  13591. }
  13592. }, _callee, this);
  13593. }));
  13594. function _adjustScaleWidth() {
  13595. return _adjustScaleWidth2.apply(this, arguments);
  13596. }
  13597. return _adjustScaleWidth;
  13598. }()
  13599. }]);
  13600. return Toolbar;
  13601. }();
  13602. exports.Toolbar = Toolbar;
  13603. /***/ }),
  13604. /* 36 */
  13605. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13606. Object.defineProperty(exports, "__esModule", ({
  13607. value: true
  13608. }));
  13609. exports.ViewHistory = void 0;
  13610. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  13611. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13612. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  13613. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  13614. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13615. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  13616. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13617. var DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
  13618. var ViewHistory = /*#__PURE__*/function () {
  13619. function ViewHistory(fingerprint) {
  13620. var _this = this;
  13621. var cacheSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_VIEW_HISTORY_CACHE_SIZE;
  13622. _classCallCheck(this, ViewHistory);
  13623. this.fingerprint = fingerprint;
  13624. this.cacheSize = cacheSize;
  13625. this._initializedPromise = this._readFromStorage().then(function (databaseStr) {
  13626. var database = JSON.parse(databaseStr || "{}");
  13627. var index = -1;
  13628. if (!Array.isArray(database.files)) {
  13629. database.files = [];
  13630. } else {
  13631. while (database.files.length >= _this.cacheSize) {
  13632. database.files.shift();
  13633. }
  13634. for (var i = 0, ii = database.files.length; i < ii; i++) {
  13635. var branch = database.files[i];
  13636. if (branch.fingerprint === _this.fingerprint) {
  13637. index = i;
  13638. break;
  13639. }
  13640. }
  13641. }
  13642. if (index === -1) {
  13643. index = database.files.push({
  13644. fingerprint: _this.fingerprint
  13645. }) - 1;
  13646. }
  13647. _this.file = database.files[index];
  13648. _this.database = database;
  13649. });
  13650. }
  13651. _createClass(ViewHistory, [{
  13652. key: "_writeToStorage",
  13653. value: function () {
  13654. var _writeToStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  13655. var databaseStr;
  13656. return _regenerator["default"].wrap(function _callee$(_context) {
  13657. while (1) {
  13658. switch (_context.prev = _context.next) {
  13659. case 0:
  13660. databaseStr = JSON.stringify(this.database);
  13661. localStorage.setItem("pdfjs.history", databaseStr);
  13662. case 2:
  13663. case "end":
  13664. return _context.stop();
  13665. }
  13666. }
  13667. }, _callee, this);
  13668. }));
  13669. function _writeToStorage() {
  13670. return _writeToStorage2.apply(this, arguments);
  13671. }
  13672. return _writeToStorage;
  13673. }()
  13674. }, {
  13675. key: "_readFromStorage",
  13676. value: function () {
  13677. var _readFromStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  13678. return _regenerator["default"].wrap(function _callee2$(_context2) {
  13679. while (1) {
  13680. switch (_context2.prev = _context2.next) {
  13681. case 0:
  13682. return _context2.abrupt("return", localStorage.getItem("pdfjs.history"));
  13683. case 1:
  13684. case "end":
  13685. return _context2.stop();
  13686. }
  13687. }
  13688. }, _callee2);
  13689. }));
  13690. function _readFromStorage() {
  13691. return _readFromStorage2.apply(this, arguments);
  13692. }
  13693. return _readFromStorage;
  13694. }()
  13695. }, {
  13696. key: "set",
  13697. value: function () {
  13698. var _set = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(name, val) {
  13699. return _regenerator["default"].wrap(function _callee3$(_context3) {
  13700. while (1) {
  13701. switch (_context3.prev = _context3.next) {
  13702. case 0:
  13703. _context3.next = 2;
  13704. return this._initializedPromise;
  13705. case 2:
  13706. this.file[name] = val;
  13707. return _context3.abrupt("return", this._writeToStorage());
  13708. case 4:
  13709. case "end":
  13710. return _context3.stop();
  13711. }
  13712. }
  13713. }, _callee3, this);
  13714. }));
  13715. function set(_x, _x2) {
  13716. return _set.apply(this, arguments);
  13717. }
  13718. return set;
  13719. }()
  13720. }, {
  13721. key: "setMultiple",
  13722. value: function () {
  13723. var _setMultiple = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(properties) {
  13724. var name;
  13725. return _regenerator["default"].wrap(function _callee4$(_context4) {
  13726. while (1) {
  13727. switch (_context4.prev = _context4.next) {
  13728. case 0:
  13729. _context4.next = 2;
  13730. return this._initializedPromise;
  13731. case 2:
  13732. for (name in properties) {
  13733. this.file[name] = properties[name];
  13734. }
  13735. return _context4.abrupt("return", this._writeToStorage());
  13736. case 4:
  13737. case "end":
  13738. return _context4.stop();
  13739. }
  13740. }
  13741. }, _callee4, this);
  13742. }));
  13743. function setMultiple(_x3) {
  13744. return _setMultiple.apply(this, arguments);
  13745. }
  13746. return setMultiple;
  13747. }()
  13748. }, {
  13749. key: "get",
  13750. value: function () {
  13751. var _get = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5(name, defaultValue) {
  13752. var val;
  13753. return _regenerator["default"].wrap(function _callee5$(_context5) {
  13754. while (1) {
  13755. switch (_context5.prev = _context5.next) {
  13756. case 0:
  13757. _context5.next = 2;
  13758. return this._initializedPromise;
  13759. case 2:
  13760. val = this.file[name];
  13761. return _context5.abrupt("return", val !== undefined ? val : defaultValue);
  13762. case 4:
  13763. case "end":
  13764. return _context5.stop();
  13765. }
  13766. }
  13767. }, _callee5, this);
  13768. }));
  13769. function get(_x4, _x5) {
  13770. return _get.apply(this, arguments);
  13771. }
  13772. return get;
  13773. }()
  13774. }, {
  13775. key: "getMultiple",
  13776. value: function () {
  13777. var _getMultiple = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6(properties) {
  13778. var values, name, val;
  13779. return _regenerator["default"].wrap(function _callee6$(_context6) {
  13780. while (1) {
  13781. switch (_context6.prev = _context6.next) {
  13782. case 0:
  13783. _context6.next = 2;
  13784. return this._initializedPromise;
  13785. case 2:
  13786. values = Object.create(null);
  13787. for (name in properties) {
  13788. val = this.file[name];
  13789. values[name] = val !== undefined ? val : properties[name];
  13790. }
  13791. return _context6.abrupt("return", values);
  13792. case 5:
  13793. case "end":
  13794. return _context6.stop();
  13795. }
  13796. }
  13797. }, _callee6, this);
  13798. }));
  13799. function getMultiple(_x6) {
  13800. return _getMultiple.apply(this, arguments);
  13801. }
  13802. return getMultiple;
  13803. }()
  13804. }]);
  13805. return ViewHistory;
  13806. }();
  13807. exports.ViewHistory = ViewHistory;
  13808. /***/ }),
  13809. /* 37 */
  13810. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13811. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  13812. Object.defineProperty(exports, "__esModule", ({
  13813. value: true
  13814. }));
  13815. exports.GenericCom = void 0;
  13816. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  13817. var _app = __webpack_require__(3);
  13818. var _preferences = __webpack_require__(38);
  13819. var _download_manager = __webpack_require__(39);
  13820. var _genericl10n = __webpack_require__(40);
  13821. var _generic_scripting = __webpack_require__(42);
  13822. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13823. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  13824. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  13825. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13826. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  13827. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13828. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  13829. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13830. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  13831. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  13832. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  13833. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  13834. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  13835. ;
  13836. var GenericCom = {};
  13837. exports.GenericCom = GenericCom;
  13838. var GenericPreferences = /*#__PURE__*/function (_BasePreferences) {
  13839. _inherits(GenericPreferences, _BasePreferences);
  13840. var _super = _createSuper(GenericPreferences);
  13841. function GenericPreferences() {
  13842. _classCallCheck(this, GenericPreferences);
  13843. return _super.apply(this, arguments);
  13844. }
  13845. _createClass(GenericPreferences, [{
  13846. key: "_writeToStorage",
  13847. value: function () {
  13848. var _writeToStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(prefObj) {
  13849. return _regenerator["default"].wrap(function _callee$(_context) {
  13850. while (1) {
  13851. switch (_context.prev = _context.next) {
  13852. case 0:
  13853. localStorage.setItem("pdfjs.preferences", JSON.stringify(prefObj));
  13854. case 1:
  13855. case "end":
  13856. return _context.stop();
  13857. }
  13858. }
  13859. }, _callee);
  13860. }));
  13861. function _writeToStorage(_x) {
  13862. return _writeToStorage2.apply(this, arguments);
  13863. }
  13864. return _writeToStorage;
  13865. }()
  13866. }, {
  13867. key: "_readFromStorage",
  13868. value: function () {
  13869. var _readFromStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(prefObj) {
  13870. return _regenerator["default"].wrap(function _callee2$(_context2) {
  13871. while (1) {
  13872. switch (_context2.prev = _context2.next) {
  13873. case 0:
  13874. return _context2.abrupt("return", JSON.parse(localStorage.getItem("pdfjs.preferences")));
  13875. case 1:
  13876. case "end":
  13877. return _context2.stop();
  13878. }
  13879. }
  13880. }, _callee2);
  13881. }));
  13882. function _readFromStorage(_x2) {
  13883. return _readFromStorage2.apply(this, arguments);
  13884. }
  13885. return _readFromStorage;
  13886. }()
  13887. }]);
  13888. return GenericPreferences;
  13889. }(_preferences.BasePreferences);
  13890. var GenericExternalServices = /*#__PURE__*/function (_DefaultExternalServi) {
  13891. _inherits(GenericExternalServices, _DefaultExternalServi);
  13892. var _super2 = _createSuper(GenericExternalServices);
  13893. function GenericExternalServices() {
  13894. _classCallCheck(this, GenericExternalServices);
  13895. return _super2.apply(this, arguments);
  13896. }
  13897. _createClass(GenericExternalServices, null, [{
  13898. key: "createDownloadManager",
  13899. value: function createDownloadManager(options) {
  13900. return new _download_manager.DownloadManager();
  13901. }
  13902. }, {
  13903. key: "createPreferences",
  13904. value: function createPreferences() {
  13905. return new GenericPreferences();
  13906. }
  13907. }, {
  13908. key: "createL10n",
  13909. value: function createL10n(_ref) {
  13910. var _ref$locale = _ref.locale,
  13911. locale = _ref$locale === void 0 ? "en-US" : _ref$locale;
  13912. return new _genericl10n.GenericL10n(locale);
  13913. }
  13914. }, {
  13915. key: "createScripting",
  13916. value: function createScripting(_ref2) {
  13917. var sandboxBundleSrc = _ref2.sandboxBundleSrc;
  13918. return new _generic_scripting.GenericScripting(sandboxBundleSrc);
  13919. }
  13920. }]);
  13921. return GenericExternalServices;
  13922. }(_app.DefaultExternalServices);
  13923. _app.PDFViewerApplication.externalServices = GenericExternalServices;
  13924. /***/ }),
  13925. /* 38 */
  13926. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  13927. Object.defineProperty(exports, "__esModule", ({
  13928. value: true
  13929. }));
  13930. exports.BasePreferences = void 0;
  13931. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  13932. var _app_options = __webpack_require__(1);
  13933. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13934. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  13935. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  13936. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  13937. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13938. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  13939. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13940. var BasePreferences = /*#__PURE__*/function () {
  13941. function BasePreferences() {
  13942. var _this = this;
  13943. _classCallCheck(this, BasePreferences);
  13944. if (this.constructor === BasePreferences) {
  13945. throw new Error("Cannot initialize BasePreferences.");
  13946. }
  13947. Object.defineProperty(this, "defaults", {
  13948. value: Object.freeze({
  13949. "cursorToolOnLoad": 0,
  13950. "defaultZoomValue": "",
  13951. "disablePageLabels": false,
  13952. "enablePermissions": false,
  13953. "enablePrintAutoRotate": false,
  13954. "enableScripting": false,
  13955. "enableWebGL": false,
  13956. "externalLinkTarget": 0,
  13957. "historyUpdateUrl": false,
  13958. "ignoreDestinationZoom": false,
  13959. "pdfBugEnabled": false,
  13960. "renderer": "canvas",
  13961. "renderInteractiveForms": true,
  13962. "sidebarViewOnLoad": -1,
  13963. "scrollModeOnLoad": -1,
  13964. "spreadModeOnLoad": -1,
  13965. "textLayerMode": 1,
  13966. "useOnlyCssZoom": false,
  13967. "viewerCssTheme": 0,
  13968. "viewOnLoad": 0,
  13969. "disableAutoFetch": false,
  13970. "disableFontFace": false,
  13971. "disableRange": false,
  13972. "disableStream": false
  13973. }),
  13974. writable: false,
  13975. enumerable: true,
  13976. configurable: false
  13977. });
  13978. this.prefs = Object.assign(Object.create(null), this.defaults);
  13979. this._initializedPromise = this._readFromStorage(this.defaults).then(function (prefs) {
  13980. if (!prefs) {
  13981. return;
  13982. }
  13983. for (var name in prefs) {
  13984. var defaultValue = _this.defaults[name],
  13985. prefValue = prefs[name];
  13986. if (defaultValue === undefined || _typeof(prefValue) !== _typeof(defaultValue)) {
  13987. continue;
  13988. }
  13989. _this.prefs[name] = prefValue;
  13990. }
  13991. });
  13992. }
  13993. _createClass(BasePreferences, [{
  13994. key: "_writeToStorage",
  13995. value: function () {
  13996. var _writeToStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(prefObj) {
  13997. return _regenerator["default"].wrap(function _callee$(_context) {
  13998. while (1) {
  13999. switch (_context.prev = _context.next) {
  14000. case 0:
  14001. throw new Error("Not implemented: _writeToStorage");
  14002. case 1:
  14003. case "end":
  14004. return _context.stop();
  14005. }
  14006. }
  14007. }, _callee);
  14008. }));
  14009. function _writeToStorage(_x) {
  14010. return _writeToStorage2.apply(this, arguments);
  14011. }
  14012. return _writeToStorage;
  14013. }()
  14014. }, {
  14015. key: "_readFromStorage",
  14016. value: function () {
  14017. var _readFromStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(prefObj) {
  14018. return _regenerator["default"].wrap(function _callee2$(_context2) {
  14019. while (1) {
  14020. switch (_context2.prev = _context2.next) {
  14021. case 0:
  14022. throw new Error("Not implemented: _readFromStorage");
  14023. case 1:
  14024. case "end":
  14025. return _context2.stop();
  14026. }
  14027. }
  14028. }, _callee2);
  14029. }));
  14030. function _readFromStorage(_x2) {
  14031. return _readFromStorage2.apply(this, arguments);
  14032. }
  14033. return _readFromStorage;
  14034. }()
  14035. }, {
  14036. key: "reset",
  14037. value: function () {
  14038. var _reset = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  14039. return _regenerator["default"].wrap(function _callee3$(_context3) {
  14040. while (1) {
  14041. switch (_context3.prev = _context3.next) {
  14042. case 0:
  14043. _context3.next = 2;
  14044. return this._initializedPromise;
  14045. case 2:
  14046. this.prefs = Object.assign(Object.create(null), this.defaults);
  14047. return _context3.abrupt("return", this._writeToStorage(this.defaults));
  14048. case 4:
  14049. case "end":
  14050. return _context3.stop();
  14051. }
  14052. }
  14053. }, _callee3, this);
  14054. }));
  14055. function reset() {
  14056. return _reset.apply(this, arguments);
  14057. }
  14058. return reset;
  14059. }()
  14060. }, {
  14061. key: "set",
  14062. value: function () {
  14063. var _set = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(name, value) {
  14064. var defaultValue, valueType, defaultType;
  14065. return _regenerator["default"].wrap(function _callee4$(_context4) {
  14066. while (1) {
  14067. switch (_context4.prev = _context4.next) {
  14068. case 0:
  14069. _context4.next = 2;
  14070. return this._initializedPromise;
  14071. case 2:
  14072. defaultValue = this.defaults[name];
  14073. if (!(defaultValue === undefined)) {
  14074. _context4.next = 7;
  14075. break;
  14076. }
  14077. throw new Error("Set preference: \"".concat(name, "\" is undefined."));
  14078. case 7:
  14079. if (!(value === undefined)) {
  14080. _context4.next = 9;
  14081. break;
  14082. }
  14083. throw new Error("Set preference: no value is specified.");
  14084. case 9:
  14085. valueType = _typeof(value);
  14086. defaultType = _typeof(defaultValue);
  14087. if (!(valueType !== defaultType)) {
  14088. _context4.next = 19;
  14089. break;
  14090. }
  14091. if (!(valueType === "number" && defaultType === "string")) {
  14092. _context4.next = 16;
  14093. break;
  14094. }
  14095. value = value.toString();
  14096. _context4.next = 17;
  14097. break;
  14098. case 16:
  14099. throw new Error("Set preference: \"".concat(value, "\" is a ").concat(valueType, ", ") + "expected a ".concat(defaultType, "."));
  14100. case 17:
  14101. _context4.next = 21;
  14102. break;
  14103. case 19:
  14104. if (!(valueType === "number" && !Number.isInteger(value))) {
  14105. _context4.next = 21;
  14106. break;
  14107. }
  14108. throw new Error("Set preference: \"".concat(value, "\" must be an integer."));
  14109. case 21:
  14110. this.prefs[name] = value;
  14111. return _context4.abrupt("return", this._writeToStorage(this.prefs));
  14112. case 23:
  14113. case "end":
  14114. return _context4.stop();
  14115. }
  14116. }
  14117. }, _callee4, this);
  14118. }));
  14119. function set(_x3, _x4) {
  14120. return _set.apply(this, arguments);
  14121. }
  14122. return set;
  14123. }()
  14124. }, {
  14125. key: "get",
  14126. value: function () {
  14127. var _get = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5(name) {
  14128. var defaultValue, prefValue;
  14129. return _regenerator["default"].wrap(function _callee5$(_context5) {
  14130. while (1) {
  14131. switch (_context5.prev = _context5.next) {
  14132. case 0:
  14133. _context5.next = 2;
  14134. return this._initializedPromise;
  14135. case 2:
  14136. defaultValue = this.defaults[name];
  14137. if (!(defaultValue === undefined)) {
  14138. _context5.next = 7;
  14139. break;
  14140. }
  14141. throw new Error("Get preference: \"".concat(name, "\" is undefined."));
  14142. case 7:
  14143. prefValue = this.prefs[name];
  14144. if (!(prefValue !== undefined)) {
  14145. _context5.next = 10;
  14146. break;
  14147. }
  14148. return _context5.abrupt("return", prefValue);
  14149. case 10:
  14150. return _context5.abrupt("return", defaultValue);
  14151. case 11:
  14152. case "end":
  14153. return _context5.stop();
  14154. }
  14155. }
  14156. }, _callee5, this);
  14157. }));
  14158. function get(_x5) {
  14159. return _get.apply(this, arguments);
  14160. }
  14161. return get;
  14162. }()
  14163. }, {
  14164. key: "getAll",
  14165. value: function () {
  14166. var _getAll = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
  14167. return _regenerator["default"].wrap(function _callee6$(_context6) {
  14168. while (1) {
  14169. switch (_context6.prev = _context6.next) {
  14170. case 0:
  14171. _context6.next = 2;
  14172. return this._initializedPromise;
  14173. case 2:
  14174. return _context6.abrupt("return", Object.assign(Object.create(null), this.defaults, this.prefs));
  14175. case 3:
  14176. case "end":
  14177. return _context6.stop();
  14178. }
  14179. }
  14180. }, _callee6, this);
  14181. }));
  14182. function getAll() {
  14183. return _getAll.apply(this, arguments);
  14184. }
  14185. return getAll;
  14186. }()
  14187. }]);
  14188. return BasePreferences;
  14189. }();
  14190. exports.BasePreferences = BasePreferences;
  14191. /***/ }),
  14192. /* 39 */
  14193. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  14194. Object.defineProperty(exports, "__esModule", ({
  14195. value: true
  14196. }));
  14197. exports.DownloadManager = void 0;
  14198. var _pdfjsLib = __webpack_require__(7);
  14199. var _viewer_compatibility = __webpack_require__(2);
  14200. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14201. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  14202. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  14203. ;
  14204. function _download(blobUrl, filename) {
  14205. var a = document.createElement("a");
  14206. if (!a.click) {
  14207. throw new Error('DownloadManager: "a.click()" is not supported.');
  14208. }
  14209. a.href = blobUrl;
  14210. a.target = "_parent";
  14211. if ("download" in a) {
  14212. a.download = filename;
  14213. }
  14214. (document.body || document.documentElement).appendChild(a);
  14215. a.click();
  14216. a.remove();
  14217. }
  14218. var DownloadManager = /*#__PURE__*/function () {
  14219. function DownloadManager() {
  14220. _classCallCheck(this, DownloadManager);
  14221. }
  14222. _createClass(DownloadManager, [{
  14223. key: "downloadUrl",
  14224. value: function downloadUrl(url, filename) {
  14225. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, "http://example.com")) {
  14226. return;
  14227. }
  14228. _download(url + "#pdfjs.action=download", filename);
  14229. }
  14230. }, {
  14231. key: "downloadData",
  14232. value: function downloadData(data, filename, contentType) {
  14233. var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, _viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL);
  14234. _download(blobUrl, filename);
  14235. }
  14236. }, {
  14237. key: "download",
  14238. value: function download(blob, url, filename) {
  14239. var sourceEventType = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "download";
  14240. if (_viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL) {
  14241. this.downloadUrl(url, filename);
  14242. return;
  14243. }
  14244. var blobUrl = URL.createObjectURL(blob);
  14245. _download(blobUrl, filename);
  14246. }
  14247. }]);
  14248. return DownloadManager;
  14249. }();
  14250. exports.DownloadManager = DownloadManager;
  14251. /***/ }),
  14252. /* 40 */
  14253. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  14254. Object.defineProperty(exports, "__esModule", ({
  14255. value: true
  14256. }));
  14257. exports.GenericL10n = void 0;
  14258. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  14259. __webpack_require__(41);
  14260. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  14261. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  14262. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  14263. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14264. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  14265. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  14266. var webL10n = document.webL10n;
  14267. var GenericL10n = /*#__PURE__*/function () {
  14268. function GenericL10n(lang) {
  14269. _classCallCheck(this, GenericL10n);
  14270. this._lang = lang;
  14271. this._ready = new Promise(function (resolve, reject) {
  14272. webL10n.setLanguage(lang, function () {
  14273. resolve(webL10n);
  14274. });
  14275. });
  14276. }
  14277. _createClass(GenericL10n, [{
  14278. key: "getLanguage",
  14279. value: function () {
  14280. var _getLanguage = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  14281. var l10n;
  14282. return _regenerator["default"].wrap(function _callee$(_context) {
  14283. while (1) {
  14284. switch (_context.prev = _context.next) {
  14285. case 0:
  14286. _context.next = 2;
  14287. return this._ready;
  14288. case 2:
  14289. l10n = _context.sent;
  14290. return _context.abrupt("return", l10n.getLanguage());
  14291. case 4:
  14292. case "end":
  14293. return _context.stop();
  14294. }
  14295. }
  14296. }, _callee, this);
  14297. }));
  14298. function getLanguage() {
  14299. return _getLanguage.apply(this, arguments);
  14300. }
  14301. return getLanguage;
  14302. }()
  14303. }, {
  14304. key: "getDirection",
  14305. value: function () {
  14306. var _getDirection = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  14307. var l10n;
  14308. return _regenerator["default"].wrap(function _callee2$(_context2) {
  14309. while (1) {
  14310. switch (_context2.prev = _context2.next) {
  14311. case 0:
  14312. _context2.next = 2;
  14313. return this._ready;
  14314. case 2:
  14315. l10n = _context2.sent;
  14316. return _context2.abrupt("return", l10n.getDirection());
  14317. case 4:
  14318. case "end":
  14319. return _context2.stop();
  14320. }
  14321. }
  14322. }, _callee2, this);
  14323. }));
  14324. function getDirection() {
  14325. return _getDirection.apply(this, arguments);
  14326. }
  14327. return getDirection;
  14328. }()
  14329. }, {
  14330. key: "get",
  14331. value: function () {
  14332. var _get = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(property, args, fallback) {
  14333. var l10n;
  14334. return _regenerator["default"].wrap(function _callee3$(_context3) {
  14335. while (1) {
  14336. switch (_context3.prev = _context3.next) {
  14337. case 0:
  14338. _context3.next = 2;
  14339. return this._ready;
  14340. case 2:
  14341. l10n = _context3.sent;
  14342. return _context3.abrupt("return", l10n.get(property, args, fallback));
  14343. case 4:
  14344. case "end":
  14345. return _context3.stop();
  14346. }
  14347. }
  14348. }, _callee3, this);
  14349. }));
  14350. function get(_x, _x2, _x3) {
  14351. return _get.apply(this, arguments);
  14352. }
  14353. return get;
  14354. }()
  14355. }, {
  14356. key: "translate",
  14357. value: function () {
  14358. var _translate = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(element) {
  14359. var l10n;
  14360. return _regenerator["default"].wrap(function _callee4$(_context4) {
  14361. while (1) {
  14362. switch (_context4.prev = _context4.next) {
  14363. case 0:
  14364. _context4.next = 2;
  14365. return this._ready;
  14366. case 2:
  14367. l10n = _context4.sent;
  14368. return _context4.abrupt("return", l10n.translate(element));
  14369. case 4:
  14370. case "end":
  14371. return _context4.stop();
  14372. }
  14373. }
  14374. }, _callee4, this);
  14375. }));
  14376. function translate(_x4) {
  14377. return _translate.apply(this, arguments);
  14378. }
  14379. return translate;
  14380. }()
  14381. }]);
  14382. return GenericL10n;
  14383. }();
  14384. exports.GenericL10n = GenericL10n;
  14385. /***/ }),
  14386. /* 41 */
  14387. /***/ (() => {
  14388. document.webL10n = function (window, document, undefined) {
  14389. var gL10nData = {};
  14390. var gTextData = '';
  14391. var gTextProp = 'textContent';
  14392. var gLanguage = '';
  14393. var gMacros = {};
  14394. var gReadyState = 'loading';
  14395. var gAsyncResourceLoading = true;
  14396. function getL10nResourceLinks() {
  14397. return document.querySelectorAll('link[type="application/l10n"]');
  14398. }
  14399. function getL10nDictionary() {
  14400. var script = document.querySelector('script[type="application/l10n"]');
  14401. return script ? JSON.parse(script.innerHTML) : null;
  14402. }
  14403. function getTranslatableChildren(element) {
  14404. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  14405. }
  14406. function getL10nAttributes(element) {
  14407. if (!element) return {};
  14408. var l10nId = element.getAttribute('data-l10n-id');
  14409. var l10nArgs = element.getAttribute('data-l10n-args');
  14410. var args = {};
  14411. if (l10nArgs) {
  14412. try {
  14413. args = JSON.parse(l10nArgs);
  14414. } catch (e) {
  14415. console.warn('could not parse arguments for #' + l10nId);
  14416. }
  14417. }
  14418. return {
  14419. id: l10nId,
  14420. args: args
  14421. };
  14422. }
  14423. function xhrLoadText(url, onSuccess, onFailure) {
  14424. onSuccess = onSuccess || function _onSuccess(data) {};
  14425. onFailure = onFailure || function _onFailure() {};
  14426. var xhr = new XMLHttpRequest();
  14427. xhr.open('GET', url, gAsyncResourceLoading);
  14428. if (xhr.overrideMimeType) {
  14429. xhr.overrideMimeType('text/plain; charset=utf-8');
  14430. }
  14431. xhr.onreadystatechange = function () {
  14432. if (xhr.readyState == 4) {
  14433. if (xhr.status == 200 || xhr.status === 0) {
  14434. onSuccess(xhr.responseText);
  14435. } else {
  14436. onFailure();
  14437. }
  14438. }
  14439. };
  14440. xhr.onerror = onFailure;
  14441. xhr.ontimeout = onFailure;
  14442. try {
  14443. xhr.send(null);
  14444. } catch (e) {
  14445. onFailure();
  14446. }
  14447. }
  14448. function parseResource(href, lang, successCallback, failureCallback) {
  14449. var baseURL = href.replace(/[^\/]*$/, '') || './';
  14450. function evalString(text) {
  14451. if (text.lastIndexOf('\\') < 0) return text;
  14452. 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, "'");
  14453. }
  14454. function parseProperties(text, parsedPropertiesCallback) {
  14455. var dictionary = {};
  14456. var reBlank = /^\s*|\s*$/;
  14457. var reComment = /^\s*#|^\s*$/;
  14458. var reSection = /^\s*\[(.*)\]\s*$/;
  14459. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  14460. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  14461. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  14462. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  14463. var currentLang = '*';
  14464. var genericLang = lang.split('-', 1)[0];
  14465. var skipLang = false;
  14466. var match = '';
  14467. function nextEntry() {
  14468. while (true) {
  14469. if (!entries.length) {
  14470. parsedRawLinesCallback();
  14471. return;
  14472. }
  14473. var line = entries.shift();
  14474. if (reComment.test(line)) continue;
  14475. if (extendedSyntax) {
  14476. match = reSection.exec(line);
  14477. if (match) {
  14478. currentLang = match[1].toLowerCase();
  14479. skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
  14480. continue;
  14481. } else if (skipLang) {
  14482. continue;
  14483. }
  14484. match = reImport.exec(line);
  14485. if (match) {
  14486. loadImport(baseURL + match[1], nextEntry);
  14487. return;
  14488. }
  14489. }
  14490. var tmp = line.match(reSplit);
  14491. if (tmp && tmp.length == 3) {
  14492. dictionary[tmp[1]] = evalString(tmp[2]);
  14493. }
  14494. }
  14495. }
  14496. nextEntry();
  14497. }
  14498. function loadImport(url, callback) {
  14499. xhrLoadText(url, function (content) {
  14500. parseRawLines(content, false, callback);
  14501. }, function () {
  14502. console.warn(url + ' not found.');
  14503. callback();
  14504. });
  14505. }
  14506. parseRawLines(text, true, function () {
  14507. parsedPropertiesCallback(dictionary);
  14508. });
  14509. }
  14510. xhrLoadText(href, function (response) {
  14511. gTextData += response;
  14512. parseProperties(response, function (data) {
  14513. for (var key in data) {
  14514. var id,
  14515. prop,
  14516. index = key.lastIndexOf('.');
  14517. if (index > 0) {
  14518. id = key.substring(0, index);
  14519. prop = key.substring(index + 1);
  14520. } else {
  14521. id = key;
  14522. prop = gTextProp;
  14523. }
  14524. if (!gL10nData[id]) {
  14525. gL10nData[id] = {};
  14526. }
  14527. gL10nData[id][prop] = data[key];
  14528. }
  14529. if (successCallback) {
  14530. successCallback();
  14531. }
  14532. });
  14533. }, failureCallback);
  14534. }
  14535. function loadLocale(lang, callback) {
  14536. if (lang) {
  14537. lang = lang.toLowerCase();
  14538. }
  14539. callback = callback || function _callback() {};
  14540. clear();
  14541. gLanguage = lang;
  14542. var langLinks = getL10nResourceLinks();
  14543. var langCount = langLinks.length;
  14544. if (langCount === 0) {
  14545. var dict = getL10nDictionary();
  14546. if (dict && dict.locales && dict.default_locale) {
  14547. console.log('using the embedded JSON directory, early way out');
  14548. gL10nData = dict.locales[lang];
  14549. if (!gL10nData) {
  14550. var defaultLocale = dict.default_locale.toLowerCase();
  14551. for (var anyCaseLang in dict.locales) {
  14552. anyCaseLang = anyCaseLang.toLowerCase();
  14553. if (anyCaseLang === lang) {
  14554. gL10nData = dict.locales[lang];
  14555. break;
  14556. } else if (anyCaseLang === defaultLocale) {
  14557. gL10nData = dict.locales[defaultLocale];
  14558. }
  14559. }
  14560. }
  14561. callback();
  14562. } else {
  14563. console.log('no resource to load, early way out');
  14564. }
  14565. gReadyState = 'complete';
  14566. return;
  14567. }
  14568. var onResourceLoaded = null;
  14569. var gResourceCount = 0;
  14570. onResourceLoaded = function onResourceLoaded() {
  14571. gResourceCount++;
  14572. if (gResourceCount >= langCount) {
  14573. callback();
  14574. gReadyState = 'complete';
  14575. }
  14576. };
  14577. function L10nResourceLink(link) {
  14578. var href = link.href;
  14579. this.load = function (lang, callback) {
  14580. parseResource(href, lang, callback, function () {
  14581. console.warn(href + ' not found.');
  14582. console.warn('"' + lang + '" resource not found');
  14583. gLanguage = '';
  14584. callback();
  14585. });
  14586. };
  14587. }
  14588. for (var i = 0; i < langCount; i++) {
  14589. var resource = new L10nResourceLink(langLinks[i]);
  14590. resource.load(lang, onResourceLoaded);
  14591. }
  14592. }
  14593. function clear() {
  14594. gL10nData = {};
  14595. gTextData = '';
  14596. gLanguage = '';
  14597. }
  14598. function getPluralRules(lang) {
  14599. var locales2rules = {
  14600. 'af': 3,
  14601. 'ak': 4,
  14602. 'am': 4,
  14603. 'ar': 1,
  14604. 'asa': 3,
  14605. 'az': 0,
  14606. 'be': 11,
  14607. 'bem': 3,
  14608. 'bez': 3,
  14609. 'bg': 3,
  14610. 'bh': 4,
  14611. 'bm': 0,
  14612. 'bn': 3,
  14613. 'bo': 0,
  14614. 'br': 20,
  14615. 'brx': 3,
  14616. 'bs': 11,
  14617. 'ca': 3,
  14618. 'cgg': 3,
  14619. 'chr': 3,
  14620. 'cs': 12,
  14621. 'cy': 17,
  14622. 'da': 3,
  14623. 'de': 3,
  14624. 'dv': 3,
  14625. 'dz': 0,
  14626. 'ee': 3,
  14627. 'el': 3,
  14628. 'en': 3,
  14629. 'eo': 3,
  14630. 'es': 3,
  14631. 'et': 3,
  14632. 'eu': 3,
  14633. 'fa': 0,
  14634. 'ff': 5,
  14635. 'fi': 3,
  14636. 'fil': 4,
  14637. 'fo': 3,
  14638. 'fr': 5,
  14639. 'fur': 3,
  14640. 'fy': 3,
  14641. 'ga': 8,
  14642. 'gd': 24,
  14643. 'gl': 3,
  14644. 'gsw': 3,
  14645. 'gu': 3,
  14646. 'guw': 4,
  14647. 'gv': 23,
  14648. 'ha': 3,
  14649. 'haw': 3,
  14650. 'he': 2,
  14651. 'hi': 4,
  14652. 'hr': 11,
  14653. 'hu': 0,
  14654. 'id': 0,
  14655. 'ig': 0,
  14656. 'ii': 0,
  14657. 'is': 3,
  14658. 'it': 3,
  14659. 'iu': 7,
  14660. 'ja': 0,
  14661. 'jmc': 3,
  14662. 'jv': 0,
  14663. 'ka': 0,
  14664. 'kab': 5,
  14665. 'kaj': 3,
  14666. 'kcg': 3,
  14667. 'kde': 0,
  14668. 'kea': 0,
  14669. 'kk': 3,
  14670. 'kl': 3,
  14671. 'km': 0,
  14672. 'kn': 0,
  14673. 'ko': 0,
  14674. 'ksb': 3,
  14675. 'ksh': 21,
  14676. 'ku': 3,
  14677. 'kw': 7,
  14678. 'lag': 18,
  14679. 'lb': 3,
  14680. 'lg': 3,
  14681. 'ln': 4,
  14682. 'lo': 0,
  14683. 'lt': 10,
  14684. 'lv': 6,
  14685. 'mas': 3,
  14686. 'mg': 4,
  14687. 'mk': 16,
  14688. 'ml': 3,
  14689. 'mn': 3,
  14690. 'mo': 9,
  14691. 'mr': 3,
  14692. 'ms': 0,
  14693. 'mt': 15,
  14694. 'my': 0,
  14695. 'nah': 3,
  14696. 'naq': 7,
  14697. 'nb': 3,
  14698. 'nd': 3,
  14699. 'ne': 3,
  14700. 'nl': 3,
  14701. 'nn': 3,
  14702. 'no': 3,
  14703. 'nr': 3,
  14704. 'nso': 4,
  14705. 'ny': 3,
  14706. 'nyn': 3,
  14707. 'om': 3,
  14708. 'or': 3,
  14709. 'pa': 3,
  14710. 'pap': 3,
  14711. 'pl': 13,
  14712. 'ps': 3,
  14713. 'pt': 3,
  14714. 'rm': 3,
  14715. 'ro': 9,
  14716. 'rof': 3,
  14717. 'ru': 11,
  14718. 'rwk': 3,
  14719. 'sah': 0,
  14720. 'saq': 3,
  14721. 'se': 7,
  14722. 'seh': 3,
  14723. 'ses': 0,
  14724. 'sg': 0,
  14725. 'sh': 11,
  14726. 'shi': 19,
  14727. 'sk': 12,
  14728. 'sl': 14,
  14729. 'sma': 7,
  14730. 'smi': 7,
  14731. 'smj': 7,
  14732. 'smn': 7,
  14733. 'sms': 7,
  14734. 'sn': 3,
  14735. 'so': 3,
  14736. 'sq': 3,
  14737. 'sr': 11,
  14738. 'ss': 3,
  14739. 'ssy': 3,
  14740. 'st': 3,
  14741. 'sv': 3,
  14742. 'sw': 3,
  14743. 'syr': 3,
  14744. 'ta': 3,
  14745. 'te': 3,
  14746. 'teo': 3,
  14747. 'th': 0,
  14748. 'ti': 4,
  14749. 'tig': 3,
  14750. 'tk': 3,
  14751. 'tl': 4,
  14752. 'tn': 3,
  14753. 'to': 0,
  14754. 'tr': 0,
  14755. 'ts': 3,
  14756. 'tzm': 22,
  14757. 'uk': 11,
  14758. 'ur': 3,
  14759. 've': 3,
  14760. 'vi': 0,
  14761. 'vun': 3,
  14762. 'wa': 4,
  14763. 'wae': 3,
  14764. 'wo': 0,
  14765. 'xh': 3,
  14766. 'xog': 3,
  14767. 'yo': 0,
  14768. 'zh': 0,
  14769. 'zu': 3
  14770. };
  14771. function isIn(n, list) {
  14772. return list.indexOf(n) !== -1;
  14773. }
  14774. function isBetween(n, start, end) {
  14775. return start <= n && n <= end;
  14776. }
  14777. var pluralRules = {
  14778. '0': function _(n) {
  14779. return 'other';
  14780. },
  14781. '1': function _(n) {
  14782. if (isBetween(n % 100, 3, 10)) return 'few';
  14783. if (n === 0) return 'zero';
  14784. if (isBetween(n % 100, 11, 99)) return 'many';
  14785. if (n == 2) return 'two';
  14786. if (n == 1) return 'one';
  14787. return 'other';
  14788. },
  14789. '2': function _(n) {
  14790. if (n !== 0 && n % 10 === 0) return 'many';
  14791. if (n == 2) return 'two';
  14792. if (n == 1) return 'one';
  14793. return 'other';
  14794. },
  14795. '3': function _(n) {
  14796. if (n == 1) return 'one';
  14797. return 'other';
  14798. },
  14799. '4': function _(n) {
  14800. if (isBetween(n, 0, 1)) return 'one';
  14801. return 'other';
  14802. },
  14803. '5': function _(n) {
  14804. if (isBetween(n, 0, 2) && n != 2) return 'one';
  14805. return 'other';
  14806. },
  14807. '6': function _(n) {
  14808. if (n === 0) return 'zero';
  14809. if (n % 10 == 1 && n % 100 != 11) return 'one';
  14810. return 'other';
  14811. },
  14812. '7': function _(n) {
  14813. if (n == 2) return 'two';
  14814. if (n == 1) return 'one';
  14815. return 'other';
  14816. },
  14817. '8': function _(n) {
  14818. if (isBetween(n, 3, 6)) return 'few';
  14819. if (isBetween(n, 7, 10)) return 'many';
  14820. if (n == 2) return 'two';
  14821. if (n == 1) return 'one';
  14822. return 'other';
  14823. },
  14824. '9': function _(n) {
  14825. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  14826. if (n == 1) return 'one';
  14827. return 'other';
  14828. },
  14829. '10': function _(n) {
  14830. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  14831. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  14832. return 'other';
  14833. },
  14834. '11': function _(n) {
  14835. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  14836. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
  14837. if (n % 10 == 1 && n % 100 != 11) return 'one';
  14838. return 'other';
  14839. },
  14840. '12': function _(n) {
  14841. if (isBetween(n, 2, 4)) return 'few';
  14842. if (n == 1) return 'one';
  14843. return 'other';
  14844. },
  14845. '13': function _(n) {
  14846. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  14847. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
  14848. if (n == 1) return 'one';
  14849. return 'other';
  14850. },
  14851. '14': function _(n) {
  14852. if (isBetween(n % 100, 3, 4)) return 'few';
  14853. if (n % 100 == 2) return 'two';
  14854. if (n % 100 == 1) return 'one';
  14855. return 'other';
  14856. },
  14857. '15': function _(n) {
  14858. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  14859. if (isBetween(n % 100, 11, 19)) return 'many';
  14860. if (n == 1) return 'one';
  14861. return 'other';
  14862. },
  14863. '16': function _(n) {
  14864. if (n % 10 == 1 && n != 11) return 'one';
  14865. return 'other';
  14866. },
  14867. '17': function _(n) {
  14868. if (n == 3) return 'few';
  14869. if (n === 0) return 'zero';
  14870. if (n == 6) return 'many';
  14871. if (n == 2) return 'two';
  14872. if (n == 1) return 'one';
  14873. return 'other';
  14874. },
  14875. '18': function _(n) {
  14876. if (n === 0) return 'zero';
  14877. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  14878. return 'other';
  14879. },
  14880. '19': function _(n) {
  14881. if (isBetween(n, 2, 10)) return 'few';
  14882. if (isBetween(n, 0, 1)) return 'one';
  14883. return 'other';
  14884. },
  14885. '20': function _(n) {
  14886. 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';
  14887. if (n % 1000000 === 0 && n !== 0) return 'many';
  14888. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  14889. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  14890. return 'other';
  14891. },
  14892. '21': function _(n) {
  14893. if (n === 0) return 'zero';
  14894. if (n == 1) return 'one';
  14895. return 'other';
  14896. },
  14897. '22': function _(n) {
  14898. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  14899. return 'other';
  14900. },
  14901. '23': function _(n) {
  14902. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  14903. return 'other';
  14904. },
  14905. '24': function _(n) {
  14906. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  14907. if (isIn(n, [2, 12])) return 'two';
  14908. if (isIn(n, [1, 11])) return 'one';
  14909. return 'other';
  14910. }
  14911. };
  14912. var index = locales2rules[lang.replace(/-.*$/, '')];
  14913. if (!(index in pluralRules)) {
  14914. console.warn('plural form unknown for [' + lang + ']');
  14915. return function () {
  14916. return 'other';
  14917. };
  14918. }
  14919. return pluralRules[index];
  14920. }
  14921. gMacros.plural = function (str, param, key, prop) {
  14922. var n = parseFloat(param);
  14923. if (isNaN(n)) return str;
  14924. if (prop != gTextProp) return str;
  14925. if (!gMacros._pluralRules) {
  14926. gMacros._pluralRules = getPluralRules(gLanguage);
  14927. }
  14928. var index = '[' + gMacros._pluralRules(n) + ']';
  14929. if (n === 0 && key + '[zero]' in gL10nData) {
  14930. str = gL10nData[key + '[zero]'][prop];
  14931. } else if (n == 1 && key + '[one]' in gL10nData) {
  14932. str = gL10nData[key + '[one]'][prop];
  14933. } else if (n == 2 && key + '[two]' in gL10nData) {
  14934. str = gL10nData[key + '[two]'][prop];
  14935. } else if (key + index in gL10nData) {
  14936. str = gL10nData[key + index][prop];
  14937. } else if (key + '[other]' in gL10nData) {
  14938. str = gL10nData[key + '[other]'][prop];
  14939. }
  14940. return str;
  14941. };
  14942. function getL10nData(key, args, fallback) {
  14943. var data = gL10nData[key];
  14944. if (!data) {
  14945. console.warn('#' + key + ' is undefined.');
  14946. if (!fallback) {
  14947. return null;
  14948. }
  14949. data = fallback;
  14950. }
  14951. var rv = {};
  14952. for (var prop in data) {
  14953. var str = data[prop];
  14954. str = substIndexes(str, args, key, prop);
  14955. str = substArguments(str, args, key);
  14956. rv[prop] = str;
  14957. }
  14958. return rv;
  14959. }
  14960. function substIndexes(str, args, key, prop) {
  14961. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  14962. var reMatch = reIndex.exec(str);
  14963. if (!reMatch || !reMatch.length) return str;
  14964. var macroName = reMatch[1];
  14965. var paramName = reMatch[2];
  14966. var param;
  14967. if (args && paramName in args) {
  14968. param = args[paramName];
  14969. } else if (paramName in gL10nData) {
  14970. param = gL10nData[paramName];
  14971. }
  14972. if (macroName in gMacros) {
  14973. var macro = gMacros[macroName];
  14974. str = macro(str, param, key, prop);
  14975. }
  14976. return str;
  14977. }
  14978. function substArguments(str, args, key) {
  14979. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  14980. return str.replace(reArgs, function (matched_text, arg) {
  14981. if (args && arg in args) {
  14982. return args[arg];
  14983. }
  14984. if (arg in gL10nData) {
  14985. return gL10nData[arg];
  14986. }
  14987. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  14988. return matched_text;
  14989. });
  14990. }
  14991. function translateElement(element) {
  14992. var l10n = getL10nAttributes(element);
  14993. if (!l10n.id) return;
  14994. var data = getL10nData(l10n.id, l10n.args);
  14995. if (!data) {
  14996. console.warn('#' + l10n.id + ' is undefined.');
  14997. return;
  14998. }
  14999. if (data[gTextProp]) {
  15000. if (getChildElementCount(element) === 0) {
  15001. element[gTextProp] = data[gTextProp];
  15002. } else {
  15003. var children = element.childNodes;
  15004. var found = false;
  15005. for (var i = 0, l = children.length; i < l; i++) {
  15006. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  15007. if (found) {
  15008. children[i].nodeValue = '';
  15009. } else {
  15010. children[i].nodeValue = data[gTextProp];
  15011. found = true;
  15012. }
  15013. }
  15014. }
  15015. if (!found) {
  15016. var textNode = document.createTextNode(data[gTextProp]);
  15017. element.insertBefore(textNode, element.firstChild);
  15018. }
  15019. }
  15020. delete data[gTextProp];
  15021. }
  15022. for (var k in data) {
  15023. element[k] = data[k];
  15024. }
  15025. }
  15026. function getChildElementCount(element) {
  15027. if (element.children) {
  15028. return element.children.length;
  15029. }
  15030. if (typeof element.childElementCount !== 'undefined') {
  15031. return element.childElementCount;
  15032. }
  15033. var count = 0;
  15034. for (var i = 0; i < element.childNodes.length; i++) {
  15035. count += element.nodeType === 1 ? 1 : 0;
  15036. }
  15037. return count;
  15038. }
  15039. function translateFragment(element) {
  15040. element = element || document.documentElement;
  15041. var children = getTranslatableChildren(element);
  15042. var elementCount = children.length;
  15043. for (var i = 0; i < elementCount; i++) {
  15044. translateElement(children[i]);
  15045. }
  15046. translateElement(element);
  15047. }
  15048. return {
  15049. get: function get(key, args, fallbackString) {
  15050. var index = key.lastIndexOf('.');
  15051. var prop = gTextProp;
  15052. if (index > 0) {
  15053. prop = key.substring(index + 1);
  15054. key = key.substring(0, index);
  15055. }
  15056. var fallback;
  15057. if (fallbackString) {
  15058. fallback = {};
  15059. fallback[prop] = fallbackString;
  15060. }
  15061. var data = getL10nData(key, args, fallback);
  15062. if (data && prop in data) {
  15063. return data[prop];
  15064. }
  15065. return '{{' + key + '}}';
  15066. },
  15067. getData: function getData() {
  15068. return gL10nData;
  15069. },
  15070. getText: function getText() {
  15071. return gTextData;
  15072. },
  15073. getLanguage: function getLanguage() {
  15074. return gLanguage;
  15075. },
  15076. setLanguage: function setLanguage(lang, callback) {
  15077. loadLocale(lang, function () {
  15078. if (callback) callback();
  15079. });
  15080. },
  15081. getDirection: function getDirection() {
  15082. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  15083. var shortCode = gLanguage.split('-', 1)[0];
  15084. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  15085. },
  15086. translate: translateFragment,
  15087. getReadyState: function getReadyState() {
  15088. return gReadyState;
  15089. },
  15090. ready: function ready(callback) {
  15091. if (!callback) {
  15092. return;
  15093. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  15094. window.setTimeout(function () {
  15095. callback();
  15096. });
  15097. } else if (document.addEventListener) {
  15098. document.addEventListener('localized', function once() {
  15099. document.removeEventListener('localized', once);
  15100. callback();
  15101. });
  15102. }
  15103. }
  15104. };
  15105. }(window, document);
  15106. /***/ }),
  15107. /* 42 */
  15108. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  15109. Object.defineProperty(exports, "__esModule", ({
  15110. value: true
  15111. }));
  15112. exports.GenericScripting = void 0;
  15113. var _regenerator = _interopRequireDefault(__webpack_require__(4));
  15114. var _pdfjsLib = __webpack_require__(7);
  15115. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  15116. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
  15117. function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
  15118. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15119. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  15120. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  15121. var GenericScripting = /*#__PURE__*/function () {
  15122. function GenericScripting(sandboxBundleSrc) {
  15123. _classCallCheck(this, GenericScripting);
  15124. this._ready = (0, _pdfjsLib.loadScript)(sandboxBundleSrc, true).then(function () {
  15125. return window.pdfjsSandbox.QuickJSSandbox();
  15126. });
  15127. }
  15128. _createClass(GenericScripting, [{
  15129. key: "createSandbox",
  15130. value: function () {
  15131. var _createSandbox = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(data) {
  15132. var sandbox;
  15133. return _regenerator["default"].wrap(function _callee$(_context) {
  15134. while (1) {
  15135. switch (_context.prev = _context.next) {
  15136. case 0:
  15137. _context.next = 2;
  15138. return this._ready;
  15139. case 2:
  15140. sandbox = _context.sent;
  15141. sandbox.create(data);
  15142. case 4:
  15143. case "end":
  15144. return _context.stop();
  15145. }
  15146. }
  15147. }, _callee, this);
  15148. }));
  15149. function createSandbox(_x) {
  15150. return _createSandbox.apply(this, arguments);
  15151. }
  15152. return createSandbox;
  15153. }()
  15154. }, {
  15155. key: "dispatchEventInSandbox",
  15156. value: function () {
  15157. var _dispatchEventInSandbox = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(event) {
  15158. var sandbox;
  15159. return _regenerator["default"].wrap(function _callee2$(_context2) {
  15160. while (1) {
  15161. switch (_context2.prev = _context2.next) {
  15162. case 0:
  15163. _context2.next = 2;
  15164. return this._ready;
  15165. case 2:
  15166. sandbox = _context2.sent;
  15167. sandbox.dispatchEvent(event);
  15168. case 4:
  15169. case "end":
  15170. return _context2.stop();
  15171. }
  15172. }
  15173. }, _callee2, this);
  15174. }));
  15175. function dispatchEventInSandbox(_x2) {
  15176. return _dispatchEventInSandbox.apply(this, arguments);
  15177. }
  15178. return dispatchEventInSandbox;
  15179. }()
  15180. }, {
  15181. key: "destroySandbox",
  15182. value: function () {
  15183. var _destroySandbox = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  15184. var sandbox;
  15185. return _regenerator["default"].wrap(function _callee3$(_context3) {
  15186. while (1) {
  15187. switch (_context3.prev = _context3.next) {
  15188. case 0:
  15189. _context3.next = 2;
  15190. return this._ready;
  15191. case 2:
  15192. sandbox = _context3.sent;
  15193. sandbox.nukeSandbox();
  15194. case 4:
  15195. case "end":
  15196. return _context3.stop();
  15197. }
  15198. }
  15199. }, _callee3, this);
  15200. }));
  15201. function destroySandbox() {
  15202. return _destroySandbox.apply(this, arguments);
  15203. }
  15204. return destroySandbox;
  15205. }()
  15206. }]);
  15207. return GenericScripting;
  15208. }();
  15209. exports.GenericScripting = GenericScripting;
  15210. /***/ }),
  15211. /* 43 */
  15212. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  15213. Object.defineProperty(exports, "__esModule", ({
  15214. value: true
  15215. }));
  15216. exports.PDFPrintService = PDFPrintService;
  15217. var _ui_utils = __webpack_require__(6);
  15218. var _app = __webpack_require__(3);
  15219. var _viewer_compatibility = __webpack_require__(2);
  15220. var activeService = null;
  15221. var overlayManager = null;
  15222. function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size, printResolution, optionalContentConfigPromise) {
  15223. var scratchCanvas = activeService.scratchCanvas;
  15224. var PRINT_UNITS = printResolution / 72.0;
  15225. scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
  15226. scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
  15227. var width = Math.floor(size.width * _ui_utils.CSS_UNITS) + "px";
  15228. var height = Math.floor(size.height * _ui_utils.CSS_UNITS) + "px";
  15229. var ctx = scratchCanvas.getContext("2d");
  15230. ctx.save();
  15231. ctx.fillStyle = "rgb(255, 255, 255)";
  15232. ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height);
  15233. ctx.restore();
  15234. return pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  15235. var renderContext = {
  15236. canvasContext: ctx,
  15237. transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
  15238. viewport: pdfPage.getViewport({
  15239. scale: 1,
  15240. rotation: size.rotation
  15241. }),
  15242. intent: "print",
  15243. annotationStorage: pdfDocument.annotationStorage,
  15244. optionalContentConfigPromise: optionalContentConfigPromise
  15245. };
  15246. return pdfPage.render(renderContext).promise;
  15247. }).then(function () {
  15248. return {
  15249. width: width,
  15250. height: height
  15251. };
  15252. });
  15253. }
  15254. function PDFPrintService(pdfDocument, pagesOverview, printContainer, printResolution) {
  15255. var optionalContentConfigPromise = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
  15256. var l10n = arguments.length > 5 ? arguments[5] : undefined;
  15257. this.pdfDocument = pdfDocument;
  15258. this.pagesOverview = pagesOverview;
  15259. this.printContainer = printContainer;
  15260. this._printResolution = printResolution || 150;
  15261. this._optionalContentConfigPromise = optionalContentConfigPromise || pdfDocument.getOptionalContentConfig();
  15262. this.l10n = l10n || _ui_utils.NullL10n;
  15263. this.currentPage = -1;
  15264. this.scratchCanvas = document.createElement("canvas");
  15265. }
  15266. PDFPrintService.prototype = {
  15267. layout: function layout() {
  15268. this.throwIfInactive();
  15269. var body = document.querySelector("body");
  15270. body.setAttribute("data-pdfjsprinting", true);
  15271. var hasEqualPageSizes = this.pagesOverview.every(function (size) {
  15272. return size.width === this.pagesOverview[0].width && size.height === this.pagesOverview[0].height;
  15273. }, this);
  15274. if (!hasEqualPageSizes) {
  15275. console.warn("Not all pages have the same size. The printed " + "result may be incorrect!");
  15276. }
  15277. this.pageStyleSheet = document.createElement("style");
  15278. var pageSize = this.pagesOverview[0];
  15279. this.pageStyleSheet.textContent = "@supports ((size:A4) and (size:1pt 1pt)) {" + "@page { size: " + pageSize.width + "pt " + pageSize.height + "pt;}" + "}";
  15280. body.appendChild(this.pageStyleSheet);
  15281. },
  15282. destroy: function destroy() {
  15283. if (activeService !== this) {
  15284. return;
  15285. }
  15286. this.printContainer.textContent = "";
  15287. var body = document.querySelector("body");
  15288. body.removeAttribute("data-pdfjsprinting");
  15289. if (this.pageStyleSheet) {
  15290. this.pageStyleSheet.remove();
  15291. this.pageStyleSheet = null;
  15292. }
  15293. this.scratchCanvas.width = this.scratchCanvas.height = 0;
  15294. this.scratchCanvas = null;
  15295. activeService = null;
  15296. ensureOverlay().then(function () {
  15297. if (overlayManager.active !== "printServiceOverlay") {
  15298. return;
  15299. }
  15300. overlayManager.close("printServiceOverlay");
  15301. });
  15302. },
  15303. renderPages: function renderPages() {
  15304. var _this = this;
  15305. var pageCount = this.pagesOverview.length;
  15306. var renderNextPage = function renderNextPage(resolve, reject) {
  15307. _this.throwIfInactive();
  15308. if (++_this.currentPage >= pageCount) {
  15309. renderProgress(pageCount, pageCount, _this.l10n);
  15310. resolve();
  15311. return;
  15312. }
  15313. var index = _this.currentPage;
  15314. renderProgress(index, pageCount, _this.l10n);
  15315. renderPage(_this, _this.pdfDocument, index + 1, _this.pagesOverview[index], _this._printResolution, _this._optionalContentConfigPromise).then(_this.useRenderedPage.bind(_this)).then(function () {
  15316. renderNextPage(resolve, reject);
  15317. }, reject);
  15318. };
  15319. return new Promise(renderNextPage);
  15320. },
  15321. useRenderedPage: function useRenderedPage(printItem) {
  15322. this.throwIfInactive();
  15323. var img = document.createElement("img");
  15324. img.style.width = printItem.width;
  15325. img.style.height = printItem.height;
  15326. var scratchCanvas = this.scratchCanvas;
  15327. if ("toBlob" in scratchCanvas && !_viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL) {
  15328. scratchCanvas.toBlob(function (blob) {
  15329. img.src = URL.createObjectURL(blob);
  15330. });
  15331. } else {
  15332. img.src = scratchCanvas.toDataURL();
  15333. }
  15334. var wrapper = document.createElement("div");
  15335. wrapper.appendChild(img);
  15336. this.printContainer.appendChild(wrapper);
  15337. return new Promise(function (resolve, reject) {
  15338. img.onload = resolve;
  15339. img.onerror = reject;
  15340. });
  15341. },
  15342. performPrint: function performPrint() {
  15343. var _this2 = this;
  15344. this.throwIfInactive();
  15345. return new Promise(function (resolve) {
  15346. setTimeout(function () {
  15347. if (!_this2.active) {
  15348. resolve();
  15349. return;
  15350. }
  15351. print.call(window);
  15352. setTimeout(resolve, 20);
  15353. }, 0);
  15354. });
  15355. },
  15356. get active() {
  15357. return this === activeService;
  15358. },
  15359. throwIfInactive: function throwIfInactive() {
  15360. if (!this.active) {
  15361. throw new Error("This print request was cancelled or completed.");
  15362. }
  15363. }
  15364. };
  15365. var print = window.print;
  15366. window.print = function () {
  15367. if (activeService) {
  15368. console.warn("Ignored window.print() because of a pending print job.");
  15369. return;
  15370. }
  15371. ensureOverlay().then(function () {
  15372. if (activeService) {
  15373. overlayManager.open("printServiceOverlay");
  15374. }
  15375. });
  15376. try {
  15377. dispatchEvent("beforeprint");
  15378. } finally {
  15379. if (!activeService) {
  15380. console.error("Expected print service to be initialized.");
  15381. ensureOverlay().then(function () {
  15382. if (overlayManager.active === "printServiceOverlay") {
  15383. overlayManager.close("printServiceOverlay");
  15384. }
  15385. });
  15386. return;
  15387. }
  15388. var activeServiceOnEntry = activeService;
  15389. activeService.renderPages().then(function () {
  15390. return activeServiceOnEntry.performPrint();
  15391. })["catch"](function () {}).then(function () {
  15392. if (activeServiceOnEntry.active) {
  15393. abort();
  15394. }
  15395. });
  15396. }
  15397. };
  15398. function dispatchEvent(eventType) {
  15399. var event = document.createEvent("CustomEvent");
  15400. event.initCustomEvent(eventType, false, false, "custom");
  15401. window.dispatchEvent(event);
  15402. }
  15403. function abort() {
  15404. if (activeService) {
  15405. activeService.destroy();
  15406. dispatchEvent("afterprint");
  15407. }
  15408. }
  15409. function renderProgress(index, total, l10n) {
  15410. var progressContainer = document.getElementById("printServiceOverlay");
  15411. var progress = Math.round(100 * index / total);
  15412. var progressBar = progressContainer.querySelector("progress");
  15413. var progressPerc = progressContainer.querySelector(".relative-progress");
  15414. progressBar.value = progress;
  15415. l10n.get("print_progress_percent", {
  15416. progress: progress
  15417. }, progress + "%").then(function (msg) {
  15418. progressPerc.textContent = msg;
  15419. });
  15420. }
  15421. window.addEventListener("keydown", function (event) {
  15422. if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
  15423. window.print();
  15424. event.preventDefault();
  15425. if (event.stopImmediatePropagation) {
  15426. event.stopImmediatePropagation();
  15427. } else {
  15428. event.stopPropagation();
  15429. }
  15430. }
  15431. }, true);
  15432. if ("onbeforeprint" in window) {
  15433. var stopPropagationIfNeeded = function stopPropagationIfNeeded(event) {
  15434. if (event.detail !== "custom" && event.stopImmediatePropagation) {
  15435. event.stopImmediatePropagation();
  15436. }
  15437. };
  15438. window.addEventListener("beforeprint", stopPropagationIfNeeded);
  15439. window.addEventListener("afterprint", stopPropagationIfNeeded);
  15440. }
  15441. var overlayPromise;
  15442. function ensureOverlay() {
  15443. if (!overlayPromise) {
  15444. overlayManager = _app.PDFViewerApplication.overlayManager;
  15445. if (!overlayManager) {
  15446. throw new Error("The overlay manager has not yet been initialized.");
  15447. }
  15448. overlayPromise = overlayManager.register("printServiceOverlay", document.getElementById("printServiceOverlay"), abort, true);
  15449. document.getElementById("printCancel").onclick = abort;
  15450. }
  15451. return overlayPromise;
  15452. }
  15453. _app.PDFPrintServiceFactory.instance = {
  15454. supportsPrinting: true,
  15455. createPrintService: function createPrintService(pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, l10n) {
  15456. if (activeService) {
  15457. throw new Error("The print service is created and active.");
  15458. }
  15459. activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, l10n);
  15460. return activeService;
  15461. }
  15462. };
  15463. /***/ })
  15464. /******/ ]);
  15465. /************************************************************************/
  15466. /******/ // The module cache
  15467. /******/ var __webpack_module_cache__ = {};
  15468. /******/
  15469. /******/ // The require function
  15470. /******/ function __webpack_require__(moduleId) {
  15471. /******/ // Check if module is in cache
  15472. /******/ if(__webpack_module_cache__[moduleId]) {
  15473. /******/ return __webpack_module_cache__[moduleId].exports;
  15474. /******/ }
  15475. /******/ // Create a new module (and put it into the cache)
  15476. /******/ var module = __webpack_module_cache__[moduleId] = {
  15477. /******/ id: moduleId,
  15478. /******/ loaded: false,
  15479. /******/ exports: {}
  15480. /******/ };
  15481. /******/
  15482. /******/ // Execute the module function
  15483. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  15484. /******/
  15485. /******/ // Flag the module as loaded
  15486. /******/ module.loaded = true;
  15487. /******/
  15488. /******/ // Return the exports of the module
  15489. /******/ return module.exports;
  15490. /******/ }
  15491. /******/
  15492. /************************************************************************/
  15493. /******/ /* webpack/runtime/node module decorator */
  15494. /******/ (() => {
  15495. /******/ __webpack_require__.nmd = (module) => {
  15496. /******/ module.paths = [];
  15497. /******/ if (!module.children) module.children = [];
  15498. /******/ return module;
  15499. /******/ };
  15500. /******/ })();
  15501. /******/
  15502. /************************************************************************/
  15503. /******/ // startup
  15504. /******/ // Load entry module
  15505. /******/ __webpack_require__(0);
  15506. /******/ // This entry module used 'exports' so it can't be inlined
  15507. /******/ })()
  15508. ;
  15509. //# sourceMappingURL=viewer.js.map