viewer.js 536 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219
  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. /******/ (function(modules) { // webpackBootstrap
  23. /******/ // The module cache
  24. /******/ var installedModules = {};
  25. /******/
  26. /******/ // The require function
  27. /******/ function __webpack_require__(moduleId) {
  28. /******/
  29. /******/ // Check if module is in cache
  30. /******/ if(installedModules[moduleId]) {
  31. /******/ return installedModules[moduleId].exports;
  32. /******/ }
  33. /******/ // Create a new module (and put it into the cache)
  34. /******/ var module = installedModules[moduleId] = {
  35. /******/ i: moduleId,
  36. /******/ l: false,
  37. /******/ exports: {}
  38. /******/ };
  39. /******/
  40. /******/ // Execute the module function
  41. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  42. /******/
  43. /******/ // Flag the module as loaded
  44. /******/ module.l = true;
  45. /******/
  46. /******/ // Return the exports of the module
  47. /******/ return module.exports;
  48. /******/ }
  49. /******/
  50. /******/
  51. /******/ // expose the modules object (__webpack_modules__)
  52. /******/ __webpack_require__.m = modules;
  53. /******/
  54. /******/ // expose the module cache
  55. /******/ __webpack_require__.c = installedModules;
  56. /******/
  57. /******/ // define getter function for harmony exports
  58. /******/ __webpack_require__.d = function(exports, name, getter) {
  59. /******/ if(!__webpack_require__.o(exports, name)) {
  60. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  61. /******/ }
  62. /******/ };
  63. /******/
  64. /******/ // define __esModule on exports
  65. /******/ __webpack_require__.r = function(exports) {
  66. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  67. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  68. /******/ }
  69. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  70. /******/ };
  71. /******/
  72. /******/ // create a fake namespace object
  73. /******/ // mode & 1: value is a module id, require it
  74. /******/ // mode & 2: merge all properties of value into the ns
  75. /******/ // mode & 4: return value when already ns object
  76. /******/ // mode & 8|1: behave like require
  77. /******/ __webpack_require__.t = function(value, mode) {
  78. /******/ if(mode & 1) value = __webpack_require__(value);
  79. /******/ if(mode & 8) return value;
  80. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  81. /******/ var ns = Object.create(null);
  82. /******/ __webpack_require__.r(ns);
  83. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  84. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  85. /******/ return ns;
  86. /******/ };
  87. /******/
  88. /******/ // getDefaultExport function for compatibility with non-harmony modules
  89. /******/ __webpack_require__.n = function(module) {
  90. /******/ var getter = module && module.__esModule ?
  91. /******/ function getDefault() { return module['default']; } :
  92. /******/ function getModuleExports() { return module; };
  93. /******/ __webpack_require__.d(getter, 'a', getter);
  94. /******/ return getter;
  95. /******/ };
  96. /******/
  97. /******/ // Object.prototype.hasOwnProperty.call
  98. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  99. /******/
  100. /******/ // __webpack_public_path__
  101. /******/ __webpack_require__.p = "";
  102. /******/
  103. /******/
  104. /******/ // Load entry module and return exports
  105. /******/ return __webpack_require__(__webpack_require__.s = 0);
  106. /******/ })
  107. /************************************************************************/
  108. /******/ ([
  109. /* 0 */
  110. /***/ (function(module, exports, __webpack_require__) {
  111. "use strict";
  112. ;
  113. var pdfjsWebApp, pdfjsWebAppOptions;
  114. {
  115. pdfjsWebApp = __webpack_require__(1);
  116. pdfjsWebAppOptions = __webpack_require__(6);
  117. }
  118. ;
  119. {
  120. __webpack_require__(38);
  121. }
  122. ;
  123. {
  124. __webpack_require__(43);
  125. }
  126. function getViewerConfiguration() {
  127. return {
  128. appContainer: document.body,
  129. mainContainer: document.getElementById("viewerContainer"),
  130. viewerContainer: document.getElementById("viewer"),
  131. eventBus: null,
  132. toolbar: {
  133. container: document.getElementById("toolbarViewer"),
  134. numPages: document.getElementById("numPages"),
  135. pageNumber: document.getElementById("pageNumber"),
  136. scaleSelectContainer: document.getElementById("scaleSelectContainer"),
  137. scaleSelect: document.getElementById("scaleSelect"),
  138. customScaleOption: document.getElementById("customScaleOption"),
  139. previous: document.getElementById("previous"),
  140. next: document.getElementById("next"),
  141. zoomIn: document.getElementById("zoomIn"),
  142. zoomOut: document.getElementById("zoomOut"),
  143. viewFind: document.getElementById("viewFind"),
  144. openFile: document.getElementById("openFile"),
  145. print: document.getElementById("print"),
  146. presentationModeButton: document.getElementById("presentationMode"),
  147. download: document.getElementById("download"),
  148. viewBookmark: document.getElementById("viewBookmark")
  149. },
  150. secondaryToolbar: {
  151. toolbar: document.getElementById("secondaryToolbar"),
  152. toggleButton: document.getElementById("secondaryToolbarToggle"),
  153. toolbarButtonContainer: document.getElementById("secondaryToolbarButtonContainer"),
  154. presentationModeButton: document.getElementById("secondaryPresentationMode"),
  155. openFileButton: document.getElementById("secondaryOpenFile"),
  156. printButton: document.getElementById("secondaryPrint"),
  157. downloadButton: document.getElementById("secondaryDownload"),
  158. viewBookmarkButton: document.getElementById("secondaryViewBookmark"),
  159. firstPageButton: document.getElementById("firstPage"),
  160. lastPageButton: document.getElementById("lastPage"),
  161. pageRotateCwButton: document.getElementById("pageRotateCw"),
  162. pageRotateCcwButton: document.getElementById("pageRotateCcw"),
  163. cursorSelectToolButton: document.getElementById("cursorSelectTool"),
  164. cursorHandToolButton: document.getElementById("cursorHandTool"),
  165. scrollVerticalButton: document.getElementById("scrollVertical"),
  166. scrollHorizontalButton: document.getElementById("scrollHorizontal"),
  167. scrollWrappedButton: document.getElementById("scrollWrapped"),
  168. spreadNoneButton: document.getElementById("spreadNone"),
  169. spreadOddButton: document.getElementById("spreadOdd"),
  170. spreadEvenButton: document.getElementById("spreadEven"),
  171. documentPropertiesButton: document.getElementById("documentProperties")
  172. },
  173. fullscreen: {
  174. contextFirstPage: document.getElementById("contextFirstPage"),
  175. contextLastPage: document.getElementById("contextLastPage"),
  176. contextPageRotateCw: document.getElementById("contextPageRotateCw"),
  177. contextPageRotateCcw: document.getElementById("contextPageRotateCcw")
  178. },
  179. sidebar: {
  180. outerContainer: document.getElementById("outerContainer"),
  181. viewerContainer: document.getElementById("viewerContainer"),
  182. toggleButton: document.getElementById("sidebarToggle"),
  183. thumbnailButton: document.getElementById("viewThumbnail"),
  184. outlineButton: document.getElementById("viewOutline"),
  185. attachmentsButton: document.getElementById("viewAttachments"),
  186. layersButton: document.getElementById("viewLayers"),
  187. thumbnailView: document.getElementById("thumbnailView"),
  188. outlineView: document.getElementById("outlineView"),
  189. attachmentsView: document.getElementById("attachmentsView"),
  190. layersView: document.getElementById("layersView")
  191. },
  192. sidebarResizer: {
  193. outerContainer: document.getElementById("outerContainer"),
  194. resizer: document.getElementById("sidebarResizer")
  195. },
  196. findBar: {
  197. bar: document.getElementById("findbar"),
  198. toggleButton: document.getElementById("viewFind"),
  199. findField: document.getElementById("findInput"),
  200. highlightAllCheckbox: document.getElementById("findHighlightAll"),
  201. caseSensitiveCheckbox: document.getElementById("findMatchCase"),
  202. entireWordCheckbox: document.getElementById("findEntireWord"),
  203. findMsg: document.getElementById("findMsg"),
  204. findResultsCount: document.getElementById("findResultsCount"),
  205. findPreviousButton: document.getElementById("findPrevious"),
  206. findNextButton: document.getElementById("findNext")
  207. },
  208. passwordOverlay: {
  209. overlayName: "passwordOverlay",
  210. container: document.getElementById("passwordOverlay"),
  211. label: document.getElementById("passwordText"),
  212. input: document.getElementById("password"),
  213. submitButton: document.getElementById("passwordSubmit"),
  214. cancelButton: document.getElementById("passwordCancel")
  215. },
  216. documentProperties: {
  217. overlayName: "documentPropertiesOverlay",
  218. container: document.getElementById("documentPropertiesOverlay"),
  219. closeButton: document.getElementById("documentPropertiesClose"),
  220. fields: {
  221. fileName: document.getElementById("fileNameField"),
  222. fileSize: document.getElementById("fileSizeField"),
  223. title: document.getElementById("titleField"),
  224. author: document.getElementById("authorField"),
  225. subject: document.getElementById("subjectField"),
  226. keywords: document.getElementById("keywordsField"),
  227. creationDate: document.getElementById("creationDateField"),
  228. modificationDate: document.getElementById("modificationDateField"),
  229. creator: document.getElementById("creatorField"),
  230. producer: document.getElementById("producerField"),
  231. version: document.getElementById("versionField"),
  232. pageCount: document.getElementById("pageCountField"),
  233. pageSize: document.getElementById("pageSizeField"),
  234. linearized: document.getElementById("linearizedField")
  235. }
  236. },
  237. errorWrapper: {
  238. container: document.getElementById("errorWrapper"),
  239. errorMessage: document.getElementById("errorMessage"),
  240. closeButton: document.getElementById("errorClose"),
  241. errorMoreInfo: document.getElementById("errorMoreInfo"),
  242. moreInfoButton: document.getElementById("errorShowMore"),
  243. lessInfoButton: document.getElementById("errorShowLess")
  244. },
  245. printContainer: document.getElementById("printContainer"),
  246. openFileInputName: "fileInput",
  247. debuggerScriptPath: "./debugger.js"
  248. };
  249. }
  250. function webViewerLoad() {
  251. var config = getViewerConfiguration();
  252. window.PDFViewerApplication = pdfjsWebApp.PDFViewerApplication;
  253. window.PDFViewerApplicationOptions = pdfjsWebAppOptions.AppOptions;
  254. var event = document.createEvent("CustomEvent");
  255. event.initCustomEvent("webviewerloaded", true, true, {
  256. source: window
  257. });
  258. try {
  259. parent.document.dispatchEvent(event);
  260. } catch (ex) {
  261. console.error("webviewerloaded: ".concat(ex));
  262. document.dispatchEvent(event);
  263. }
  264. pdfjsWebApp.PDFViewerApplication.run(config);
  265. }
  266. if (document.readyState === "interactive" || document.readyState === "complete") {
  267. webViewerLoad();
  268. } else {
  269. document.addEventListener("DOMContentLoaded", webViewerLoad, true);
  270. }
  271. /***/ }),
  272. /* 1 */
  273. /***/ (function(module, exports, __webpack_require__) {
  274. "use strict";
  275. Object.defineProperty(exports, "__esModule", {
  276. value: true
  277. });
  278. exports.PDFPrintServiceFactory = exports.DefaultExternalServices = exports.PDFViewerApplication = void 0;
  279. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  280. var _ui_utils = __webpack_require__(5);
  281. var _app_options = __webpack_require__(6);
  282. var _pdfjsLib = __webpack_require__(8);
  283. var _pdf_cursor_tools = __webpack_require__(9);
  284. var _pdf_rendering_queue = __webpack_require__(11);
  285. var _pdf_sidebar = __webpack_require__(12);
  286. var _overlay_manager = __webpack_require__(13);
  287. var _password_prompt = __webpack_require__(14);
  288. var _pdf_attachment_viewer = __webpack_require__(15);
  289. var _pdf_document_properties = __webpack_require__(17);
  290. var _pdf_find_bar = __webpack_require__(18);
  291. var _pdf_find_controller = __webpack_require__(19);
  292. var _pdf_history = __webpack_require__(21);
  293. var _pdf_layer_viewer = __webpack_require__(22);
  294. var _pdf_link_service = __webpack_require__(23);
  295. var _pdf_outline_viewer = __webpack_require__(24);
  296. var _pdf_presentation_mode = __webpack_require__(25);
  297. var _pdf_sidebar_resizer = __webpack_require__(26);
  298. var _pdf_thumbnail_viewer = __webpack_require__(27);
  299. var _pdf_viewer = __webpack_require__(29);
  300. var _secondary_toolbar = __webpack_require__(34);
  301. var _toolbar = __webpack_require__(36);
  302. var _viewer_compatibility = __webpack_require__(7);
  303. var _view_history = __webpack_require__(37);
  304. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  305. 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; } } }; }
  306. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  307. 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."); }
  308. 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); }
  309. 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; }
  310. 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; }
  311. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  312. 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); } }
  313. 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); }); }; }
  314. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  315. 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); } }
  316. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  317. var DEFAULT_SCALE_DELTA = 1.1;
  318. var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
  319. var FORCE_PAGES_LOADED_TIMEOUT = 10000;
  320. var WHEEL_ZOOM_DISABLED_TIMEOUT = 1000;
  321. var ENABLE_PERMISSIONS_CLASS = "enablePermissions";
  322. var ViewOnLoad = {
  323. UNKNOWN: -1,
  324. PREVIOUS: 0,
  325. INITIAL: 1
  326. };
  327. 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"];
  328. 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"];
  329. var DefaultExternalServices = /*#__PURE__*/function () {
  330. function DefaultExternalServices() {
  331. _classCallCheck(this, DefaultExternalServices);
  332. throw new Error("Cannot initialize DefaultExternalServices.");
  333. }
  334. _createClass(DefaultExternalServices, null, [{
  335. key: "updateFindControlState",
  336. value: function updateFindControlState(data) {}
  337. }, {
  338. key: "updateFindMatchesCount",
  339. value: function updateFindMatchesCount(data) {}
  340. }, {
  341. key: "initPassiveLoading",
  342. value: function initPassiveLoading(callbacks) {}
  343. }, {
  344. key: "fallback",
  345. value: function fallback(data, callback) {}
  346. }, {
  347. key: "reportTelemetry",
  348. value: function reportTelemetry(data) {}
  349. }, {
  350. key: "createDownloadManager",
  351. value: function createDownloadManager(options) {
  352. throw new Error("Not implemented: createDownloadManager");
  353. }
  354. }, {
  355. key: "createPreferences",
  356. value: function createPreferences() {
  357. throw new Error("Not implemented: createPreferences");
  358. }
  359. }, {
  360. key: "createL10n",
  361. value: function createL10n(options) {
  362. throw new Error("Not implemented: createL10n");
  363. }
  364. }, {
  365. key: "supportsIntegratedFind",
  366. get: function get() {
  367. return (0, _pdfjsLib.shadow)(this, "supportsIntegratedFind", false);
  368. }
  369. }, {
  370. key: "supportsDocumentFonts",
  371. get: function get() {
  372. return (0, _pdfjsLib.shadow)(this, "supportsDocumentFonts", true);
  373. }
  374. }, {
  375. key: "supportedMouseWheelZoomModifierKeys",
  376. get: function get() {
  377. return (0, _pdfjsLib.shadow)(this, "supportedMouseWheelZoomModifierKeys", {
  378. ctrlKey: true,
  379. metaKey: true
  380. });
  381. }
  382. }, {
  383. key: "isInAutomation",
  384. get: function get() {
  385. return (0, _pdfjsLib.shadow)(this, "isInAutomation", false);
  386. }
  387. }]);
  388. return DefaultExternalServices;
  389. }();
  390. exports.DefaultExternalServices = DefaultExternalServices;
  391. var PDFViewerApplication = {
  392. initialBookmark: document.location.hash.substring(1),
  393. _initializedCapability: (0, _pdfjsLib.createPromiseCapability)(),
  394. fellback: false,
  395. appConfig: null,
  396. pdfDocument: null,
  397. pdfLoadingTask: null,
  398. printService: null,
  399. pdfViewer: null,
  400. pdfThumbnailViewer: null,
  401. pdfRenderingQueue: null,
  402. pdfPresentationMode: null,
  403. pdfDocumentProperties: null,
  404. pdfLinkService: null,
  405. pdfHistory: null,
  406. pdfSidebar: null,
  407. pdfSidebarResizer: null,
  408. pdfOutlineViewer: null,
  409. pdfAttachmentViewer: null,
  410. pdfLayerViewer: null,
  411. pdfCursorTools: null,
  412. store: null,
  413. downloadManager: null,
  414. overlayManager: null,
  415. preferences: null,
  416. toolbar: null,
  417. secondaryToolbar: null,
  418. eventBus: null,
  419. l10n: null,
  420. isInitialViewSet: false,
  421. downloadComplete: false,
  422. isViewerEmbedded: window.parent !== window,
  423. url: "",
  424. baseUrl: "",
  425. externalServices: DefaultExternalServices,
  426. _boundEvents: {},
  427. contentDispositionFilename: null,
  428. triggerDelayedFallback: null,
  429. _saveInProgress: false,
  430. _wheelUnusedTicks: 0,
  431. initialize: function initialize(appConfig) {
  432. var _this = this;
  433. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  434. var appContainer;
  435. return _regenerator["default"].wrap(function _callee$(_context) {
  436. while (1) {
  437. switch (_context.prev = _context.next) {
  438. case 0:
  439. _this.preferences = _this.externalServices.createPreferences();
  440. _this.appConfig = appConfig;
  441. _context.next = 4;
  442. return _this._readPreferences();
  443. case 4:
  444. _context.next = 6;
  445. return _this._parseHashParameters();
  446. case 6:
  447. _context.next = 8;
  448. return _this._initializeL10n();
  449. case 8:
  450. if (_this.isViewerEmbedded && _app_options.AppOptions.get("externalLinkTarget") === _pdfjsLib.LinkTarget.NONE) {
  451. _app_options.AppOptions.set("externalLinkTarget", _pdfjsLib.LinkTarget.TOP);
  452. }
  453. _context.next = 11;
  454. return _this._initializeViewerComponents();
  455. case 11:
  456. _this.bindEvents();
  457. _this.bindWindowEvents();
  458. appContainer = appConfig.appContainer || document.documentElement;
  459. _this.l10n.translate(appContainer).then(function () {
  460. _this.eventBus.dispatch("localized", {
  461. source: _this
  462. });
  463. });
  464. _this._initializedCapability.resolve();
  465. case 16:
  466. case "end":
  467. return _context.stop();
  468. }
  469. }
  470. }, _callee);
  471. }))();
  472. },
  473. _readPreferences: function _readPreferences() {
  474. var _this2 = this;
  475. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  476. var prefs, name;
  477. return _regenerator["default"].wrap(function _callee2$(_context2) {
  478. while (1) {
  479. switch (_context2.prev = _context2.next) {
  480. case 0:
  481. if (!_app_options.AppOptions.get("disablePreferences")) {
  482. _context2.next = 2;
  483. break;
  484. }
  485. return _context2.abrupt("return");
  486. case 2:
  487. _context2.prev = 2;
  488. _context2.next = 5;
  489. return _this2.preferences.getAll();
  490. case 5:
  491. prefs = _context2.sent;
  492. for (name in prefs) {
  493. _app_options.AppOptions.set(name, prefs[name]);
  494. }
  495. _context2.next = 12;
  496. break;
  497. case 9:
  498. _context2.prev = 9;
  499. _context2.t0 = _context2["catch"](2);
  500. console.error("_readPreferences: \"".concat(_context2.t0.message, "\"."));
  501. case 12:
  502. case "end":
  503. return _context2.stop();
  504. }
  505. }
  506. }, _callee2, null, [[2, 9]]);
  507. }))();
  508. },
  509. _parseHashParameters: function _parseHashParameters() {
  510. var _this3 = this;
  511. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  512. var hash, hashParams, waitOn, viewer, enabled;
  513. return _regenerator["default"].wrap(function _callee3$(_context3) {
  514. while (1) {
  515. switch (_context3.prev = _context3.next) {
  516. case 0:
  517. if (_app_options.AppOptions.get("pdfBugEnabled")) {
  518. _context3.next = 2;
  519. break;
  520. }
  521. return _context3.abrupt("return", undefined);
  522. case 2:
  523. hash = document.location.hash.substring(1);
  524. if (hash) {
  525. _context3.next = 5;
  526. break;
  527. }
  528. return _context3.abrupt("return", undefined);
  529. case 5:
  530. hashParams = (0, _ui_utils.parseQueryString)(hash), waitOn = [];
  531. if ("disableworker" in hashParams && hashParams.disableworker === "true") {
  532. waitOn.push(loadFakeWorker());
  533. }
  534. if ("disablerange" in hashParams) {
  535. _app_options.AppOptions.set("disableRange", hashParams.disablerange === "true");
  536. }
  537. if ("disablestream" in hashParams) {
  538. _app_options.AppOptions.set("disableStream", hashParams.disablestream === "true");
  539. }
  540. if ("disableautofetch" in hashParams) {
  541. _app_options.AppOptions.set("disableAutoFetch", hashParams.disableautofetch === "true");
  542. }
  543. if ("disablefontface" in hashParams) {
  544. _app_options.AppOptions.set("disableFontFace", hashParams.disablefontface === "true");
  545. }
  546. if ("disablehistory" in hashParams) {
  547. _app_options.AppOptions.set("disableHistory", hashParams.disablehistory === "true");
  548. }
  549. if ("webgl" in hashParams) {
  550. _app_options.AppOptions.set("enableWebGL", hashParams.webgl === "true");
  551. }
  552. if ("verbosity" in hashParams) {
  553. _app_options.AppOptions.set("verbosity", hashParams.verbosity | 0);
  554. }
  555. if (!("textlayer" in hashParams)) {
  556. _context3.next = 23;
  557. break;
  558. }
  559. _context3.t0 = hashParams.textlayer;
  560. _context3.next = _context3.t0 === "off" ? 18 : _context3.t0 === "visible" ? 20 : _context3.t0 === "shadow" ? 20 : _context3.t0 === "hover" ? 20 : 23;
  561. break;
  562. case 18:
  563. _app_options.AppOptions.set("textLayerMode", _ui_utils.TextLayerMode.DISABLE);
  564. return _context3.abrupt("break", 23);
  565. case 20:
  566. viewer = _this3.appConfig.viewerContainer;
  567. viewer.classList.add("textLayer-" + hashParams.textlayer);
  568. return _context3.abrupt("break", 23);
  569. case 23:
  570. if ("pdfbug" in hashParams) {
  571. _app_options.AppOptions.set("pdfBug", true);
  572. _app_options.AppOptions.set("fontExtraProperties", true);
  573. enabled = hashParams.pdfbug.split(",");
  574. waitOn.push(loadAndEnablePDFBug(enabled));
  575. }
  576. if ("locale" in hashParams) {
  577. _app_options.AppOptions.set("locale", hashParams.locale);
  578. }
  579. return _context3.abrupt("return", Promise.all(waitOn)["catch"](function (reason) {
  580. console.error("_parseHashParameters: \"".concat(reason.message, "\"."));
  581. }));
  582. case 26:
  583. case "end":
  584. return _context3.stop();
  585. }
  586. }
  587. }, _callee3);
  588. }))();
  589. },
  590. _initializeL10n: function _initializeL10n() {
  591. var _this4 = this;
  592. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
  593. var dir;
  594. return _regenerator["default"].wrap(function _callee4$(_context4) {
  595. while (1) {
  596. switch (_context4.prev = _context4.next) {
  597. case 0:
  598. _this4.l10n = _this4.externalServices.createL10n({
  599. locale: _app_options.AppOptions.get("locale")
  600. });
  601. _context4.next = 3;
  602. return _this4.l10n.getDirection();
  603. case 3:
  604. dir = _context4.sent;
  605. document.getElementsByTagName("html")[0].dir = dir;
  606. case 5:
  607. case "end":
  608. return _context4.stop();
  609. }
  610. }
  611. }, _callee4);
  612. }))();
  613. },
  614. _initializeViewerComponents: function _initializeViewerComponents() {
  615. var _this5 = this;
  616. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5() {
  617. var appConfig, eventBus, pdfRenderingQueue, pdfLinkService, downloadManager, findController, container, viewer;
  618. return _regenerator["default"].wrap(function _callee5$(_context5) {
  619. while (1) {
  620. switch (_context5.prev = _context5.next) {
  621. case 0:
  622. appConfig = _this5.appConfig;
  623. eventBus = appConfig.eventBus || new _ui_utils.EventBus({
  624. isInAutomation: _this5.externalServices.isInAutomation
  625. });
  626. _this5.eventBus = eventBus;
  627. _this5.overlayManager = new _overlay_manager.OverlayManager();
  628. pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  629. pdfRenderingQueue.onIdle = _this5.cleanup.bind(_this5);
  630. _this5.pdfRenderingQueue = pdfRenderingQueue;
  631. pdfLinkService = new _pdf_link_service.PDFLinkService({
  632. eventBus: eventBus,
  633. externalLinkTarget: _app_options.AppOptions.get("externalLinkTarget"),
  634. externalLinkRel: _app_options.AppOptions.get("externalLinkRel"),
  635. ignoreDestinationZoom: _app_options.AppOptions.get("ignoreDestinationZoom")
  636. });
  637. _this5.pdfLinkService = pdfLinkService;
  638. downloadManager = _this5.externalServices.createDownloadManager();
  639. _this5.downloadManager = downloadManager;
  640. findController = new _pdf_find_controller.PDFFindController({
  641. linkService: pdfLinkService,
  642. eventBus: eventBus
  643. });
  644. _this5.findController = findController;
  645. container = appConfig.mainContainer;
  646. viewer = appConfig.viewerContainer;
  647. _this5.pdfViewer = new _pdf_viewer.PDFViewer({
  648. container: container,
  649. viewer: viewer,
  650. eventBus: eventBus,
  651. renderingQueue: pdfRenderingQueue,
  652. linkService: pdfLinkService,
  653. downloadManager: downloadManager,
  654. findController: findController,
  655. renderer: _app_options.AppOptions.get("renderer"),
  656. enableWebGL: _app_options.AppOptions.get("enableWebGL"),
  657. l10n: _this5.l10n,
  658. textLayerMode: _app_options.AppOptions.get("textLayerMode"),
  659. imageResourcesPath: _app_options.AppOptions.get("imageResourcesPath"),
  660. renderInteractiveForms: _app_options.AppOptions.get("renderInteractiveForms"),
  661. enablePrintAutoRotate: _app_options.AppOptions.get("enablePrintAutoRotate"),
  662. useOnlyCssZoom: _app_options.AppOptions.get("useOnlyCssZoom"),
  663. maxCanvasPixels: _app_options.AppOptions.get("maxCanvasPixels")
  664. });
  665. pdfRenderingQueue.setViewer(_this5.pdfViewer);
  666. pdfLinkService.setViewer(_this5.pdfViewer);
  667. _this5.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({
  668. container: appConfig.sidebar.thumbnailView,
  669. eventBus: eventBus,
  670. renderingQueue: pdfRenderingQueue,
  671. linkService: pdfLinkService,
  672. l10n: _this5.l10n
  673. });
  674. pdfRenderingQueue.setThumbnailViewer(_this5.pdfThumbnailViewer);
  675. _this5.pdfHistory = new _pdf_history.PDFHistory({
  676. linkService: pdfLinkService,
  677. eventBus: eventBus
  678. });
  679. pdfLinkService.setHistory(_this5.pdfHistory);
  680. if (!_this5.supportsIntegratedFind) {
  681. _this5.findBar = new _pdf_find_bar.PDFFindBar(appConfig.findBar, eventBus, _this5.l10n);
  682. }
  683. _this5.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, _this5.overlayManager, eventBus, _this5.l10n);
  684. _this5.pdfCursorTools = new _pdf_cursor_tools.PDFCursorTools({
  685. container: container,
  686. eventBus: eventBus,
  687. cursorToolOnLoad: _app_options.AppOptions.get("cursorToolOnLoad")
  688. });
  689. _this5.toolbar = new _toolbar.Toolbar(appConfig.toolbar, eventBus, _this5.l10n);
  690. _this5.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus);
  691. if (_this5.supportsFullscreen) {
  692. _this5.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({
  693. container: container,
  694. pdfViewer: _this5.pdfViewer,
  695. eventBus: eventBus,
  696. contextMenuItems: appConfig.fullscreen
  697. });
  698. }
  699. _this5.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, _this5.overlayManager, _this5.l10n);
  700. _this5.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({
  701. container: appConfig.sidebar.outlineView,
  702. eventBus: eventBus,
  703. linkService: pdfLinkService
  704. });
  705. _this5.pdfAttachmentViewer = new _pdf_attachment_viewer.PDFAttachmentViewer({
  706. container: appConfig.sidebar.attachmentsView,
  707. eventBus: eventBus,
  708. downloadManager: downloadManager
  709. });
  710. _this5.pdfLayerViewer = new _pdf_layer_viewer.PDFLayerViewer({
  711. container: appConfig.sidebar.layersView,
  712. eventBus: eventBus,
  713. l10n: _this5.l10n
  714. });
  715. _this5.pdfSidebar = new _pdf_sidebar.PDFSidebar({
  716. elements: appConfig.sidebar,
  717. pdfViewer: _this5.pdfViewer,
  718. pdfThumbnailViewer: _this5.pdfThumbnailViewer,
  719. eventBus: eventBus,
  720. l10n: _this5.l10n
  721. });
  722. _this5.pdfSidebar.onToggled = _this5.forceRendering.bind(_this5);
  723. _this5.pdfSidebarResizer = new _pdf_sidebar_resizer.PDFSidebarResizer(appConfig.sidebarResizer, eventBus, _this5.l10n);
  724. case 35:
  725. case "end":
  726. return _context5.stop();
  727. }
  728. }
  729. }, _callee5);
  730. }))();
  731. },
  732. run: function run(config) {
  733. this.initialize(config).then(webViewerInitialized);
  734. },
  735. get initialized() {
  736. return this._initializedCapability.settled;
  737. },
  738. get initializedPromise() {
  739. return this._initializedCapability.promise;
  740. },
  741. zoomIn: function zoomIn(ticks) {
  742. if (this.pdfViewer.isInPresentationMode) {
  743. return;
  744. }
  745. var newScale = this.pdfViewer.currentScale;
  746. do {
  747. newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2);
  748. newScale = Math.ceil(newScale * 10) / 10;
  749. newScale = Math.min(_ui_utils.MAX_SCALE, newScale);
  750. } while (--ticks > 0 && newScale < _ui_utils.MAX_SCALE);
  751. this.pdfViewer.currentScaleValue = newScale;
  752. },
  753. zoomOut: function zoomOut(ticks) {
  754. if (this.pdfViewer.isInPresentationMode) {
  755. return;
  756. }
  757. var newScale = this.pdfViewer.currentScale;
  758. do {
  759. newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2);
  760. newScale = Math.floor(newScale * 10) / 10;
  761. newScale = Math.max(_ui_utils.MIN_SCALE, newScale);
  762. } while (--ticks > 0 && newScale > _ui_utils.MIN_SCALE);
  763. this.pdfViewer.currentScaleValue = newScale;
  764. },
  765. zoomReset: function zoomReset() {
  766. if (this.pdfViewer.isInPresentationMode) {
  767. return;
  768. }
  769. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  770. },
  771. get pagesCount() {
  772. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  773. },
  774. get page() {
  775. return this.pdfViewer.currentPageNumber;
  776. },
  777. set page(val) {
  778. this.pdfViewer.currentPageNumber = val;
  779. },
  780. get printing() {
  781. return !!this.printService;
  782. },
  783. get supportsPrinting() {
  784. return PDFPrintServiceFactory.instance.supportsPrinting;
  785. },
  786. get supportsFullscreen() {
  787. var support;
  788. var doc = document.documentElement;
  789. support = !!(doc.requestFullscreen || doc.mozRequestFullScreen || doc.webkitRequestFullScreen || doc.msRequestFullscreen);
  790. if (document.fullscreenEnabled === false || document.mozFullScreenEnabled === false || document.webkitFullscreenEnabled === false || document.msFullscreenEnabled === false) {
  791. support = false;
  792. }
  793. return (0, _pdfjsLib.shadow)(this, "supportsFullscreen", support);
  794. },
  795. get supportsIntegratedFind() {
  796. return this.externalServices.supportsIntegratedFind;
  797. },
  798. get supportsDocumentFonts() {
  799. return this.externalServices.supportsDocumentFonts;
  800. },
  801. get loadingBar() {
  802. var bar = new _ui_utils.ProgressBar("#loadingBar");
  803. return (0, _pdfjsLib.shadow)(this, "loadingBar", bar);
  804. },
  805. get supportedMouseWheelZoomModifierKeys() {
  806. return this.externalServices.supportedMouseWheelZoomModifierKeys;
  807. },
  808. initPassiveLoading: function initPassiveLoading() {
  809. throw new Error("Not implemented: initPassiveLoading");
  810. },
  811. setTitleUsingUrl: function setTitleUsingUrl() {
  812. var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
  813. this.url = url;
  814. this.baseUrl = url.split("#")[0];
  815. var title = (0, _ui_utils.getPDFFileNameFromURL)(url, "");
  816. if (!title) {
  817. try {
  818. title = decodeURIComponent((0, _pdfjsLib.getFilenameFromUrl)(url)) || url;
  819. } catch (ex) {
  820. title = url;
  821. }
  822. }
  823. this.setTitle(title);
  824. },
  825. setTitle: function setTitle(title) {
  826. if (this.isViewerEmbedded) {
  827. return;
  828. }
  829. document.title = title;
  830. },
  831. close: function close() {
  832. var _this6 = this;
  833. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
  834. var errorWrapper, promise;
  835. return _regenerator["default"].wrap(function _callee6$(_context6) {
  836. while (1) {
  837. switch (_context6.prev = _context6.next) {
  838. case 0:
  839. errorWrapper = _this6.appConfig.errorWrapper.container;
  840. errorWrapper.setAttribute("hidden", "true");
  841. if (_this6.pdfLoadingTask) {
  842. _context6.next = 4;
  843. break;
  844. }
  845. return _context6.abrupt("return", undefined);
  846. case 4:
  847. promise = _this6.pdfLoadingTask.destroy();
  848. _this6.pdfLoadingTask = null;
  849. if (_this6.pdfDocument) {
  850. _this6.pdfDocument = null;
  851. _this6.pdfThumbnailViewer.setDocument(null);
  852. _this6.pdfViewer.setDocument(null);
  853. _this6.pdfLinkService.setDocument(null);
  854. _this6.pdfDocumentProperties.setDocument(null);
  855. }
  856. webViewerResetPermissions();
  857. _this6.store = null;
  858. _this6.isInitialViewSet = false;
  859. _this6.downloadComplete = false;
  860. _this6.url = "";
  861. _this6.baseUrl = "";
  862. _this6.contentDispositionFilename = null;
  863. _this6.triggerDelayedFallback = null;
  864. _this6._saveInProgress = false;
  865. _this6.pdfSidebar.reset();
  866. _this6.pdfOutlineViewer.reset();
  867. _this6.pdfAttachmentViewer.reset();
  868. _this6.pdfLayerViewer.reset();
  869. if (_this6.pdfHistory) {
  870. _this6.pdfHistory.reset();
  871. }
  872. if (_this6.findBar) {
  873. _this6.findBar.reset();
  874. }
  875. _this6.toolbar.reset();
  876. _this6.secondaryToolbar.reset();
  877. if (typeof PDFBug !== "undefined") {
  878. PDFBug.cleanup();
  879. }
  880. return _context6.abrupt("return", promise);
  881. case 26:
  882. case "end":
  883. return _context6.stop();
  884. }
  885. }
  886. }, _callee6);
  887. }))();
  888. },
  889. open: function open(file, args) {
  890. var _this7 = this;
  891. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee7() {
  892. var workerParameters, key, parameters, apiParameters, _key, value, _key2, _value, loadingTask;
  893. return _regenerator["default"].wrap(function _callee7$(_context7) {
  894. while (1) {
  895. switch (_context7.prev = _context7.next) {
  896. case 0:
  897. if (!_this7.pdfLoadingTask) {
  898. _context7.next = 3;
  899. break;
  900. }
  901. _context7.next = 3;
  902. return _this7.close();
  903. case 3:
  904. workerParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.WORKER);
  905. for (key in workerParameters) {
  906. _pdfjsLib.GlobalWorkerOptions[key] = workerParameters[key];
  907. }
  908. parameters = Object.create(null);
  909. if (typeof file === "string") {
  910. _this7.setTitleUsingUrl(file);
  911. parameters.url = file;
  912. } else if (file && "byteLength" in file) {
  913. parameters.data = file;
  914. } else if (file.url && file.originalUrl) {
  915. _this7.setTitleUsingUrl(file.originalUrl);
  916. parameters.url = file.url;
  917. }
  918. apiParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.API);
  919. for (_key in apiParameters) {
  920. value = apiParameters[_key];
  921. if (_key === "docBaseUrl" && !value) {}
  922. parameters[_key] = value;
  923. }
  924. if (args) {
  925. for (_key2 in args) {
  926. _value = args[_key2];
  927. if (_key2 === "length") {
  928. _this7.pdfDocumentProperties.setFileSize(_value);
  929. }
  930. parameters[_key2] = _value;
  931. }
  932. }
  933. loadingTask = (0, _pdfjsLib.getDocument)(parameters);
  934. _this7.pdfLoadingTask = loadingTask;
  935. loadingTask.onPassword = function (updateCallback, reason) {
  936. _this7.pdfLinkService.externalLinkEnabled = false;
  937. _this7.passwordPrompt.setUpdateCallback(updateCallback, reason);
  938. _this7.passwordPrompt.open();
  939. };
  940. loadingTask.onProgress = function (_ref) {
  941. var loaded = _ref.loaded,
  942. total = _ref.total;
  943. _this7.progress(loaded / total);
  944. };
  945. loadingTask.onUnsupportedFeature = _this7.fallback.bind(_this7);
  946. return _context7.abrupt("return", loadingTask.promise.then(function (pdfDocument) {
  947. _this7.load(pdfDocument);
  948. }, function (exception) {
  949. if (loadingTask !== _this7.pdfLoadingTask) {
  950. return undefined;
  951. }
  952. var message = exception && exception.message;
  953. var loadingErrorMessage;
  954. if (exception instanceof _pdfjsLib.InvalidPDFException) {
  955. loadingErrorMessage = _this7.l10n.get("invalid_file_error", null, "Invalid or corrupted PDF file.");
  956. } else if (exception instanceof _pdfjsLib.MissingPDFException) {
  957. loadingErrorMessage = _this7.l10n.get("missing_file_error", null, "Missing PDF file.");
  958. } else if (exception instanceof _pdfjsLib.UnexpectedResponseException) {
  959. loadingErrorMessage = _this7.l10n.get("unexpected_response_error", null, "Unexpected server response.");
  960. } else {
  961. loadingErrorMessage = _this7.l10n.get("loading_error", null, "An error occurred while loading the PDF.");
  962. }
  963. return loadingErrorMessage.then(function (msg) {
  964. _this7.error(msg, {
  965. message: message
  966. });
  967. throw exception;
  968. });
  969. }));
  970. case 16:
  971. case "end":
  972. return _context7.stop();
  973. }
  974. }
  975. }, _callee7);
  976. }))();
  977. },
  978. download: function download() {
  979. var _this8 = this;
  980. var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  981. _ref2$sourceEventType = _ref2.sourceEventType,
  982. sourceEventType = _ref2$sourceEventType === void 0 ? "download" : _ref2$sourceEventType;
  983. function downloadByUrl() {
  984. downloadManager.downloadUrl(url, filename);
  985. }
  986. var url = this.baseUrl;
  987. var filename = this.contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(this.url);
  988. var downloadManager = this.downloadManager;
  989. downloadManager.onerror = function (err) {
  990. _this8.error("PDF failed to download: ".concat(err));
  991. };
  992. if (!this.pdfDocument || !this.downloadComplete) {
  993. downloadByUrl();
  994. return;
  995. }
  996. this.pdfDocument.getData().then(function (data) {
  997. var blob = new Blob([data], {
  998. type: "application/pdf"
  999. });
  1000. downloadManager.download(blob, url, filename, sourceEventType);
  1001. })["catch"](downloadByUrl);
  1002. },
  1003. save: function save() {
  1004. var _this9 = this;
  1005. var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  1006. _ref3$sourceEventType = _ref3.sourceEventType,
  1007. sourceEventType = _ref3$sourceEventType === void 0 ? "download" : _ref3$sourceEventType;
  1008. if (this._saveInProgress) {
  1009. return;
  1010. }
  1011. var url = this.baseUrl;
  1012. var filename = this.contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(this.url);
  1013. var downloadManager = this.downloadManager;
  1014. downloadManager.onerror = function (err) {
  1015. _this9.error("PDF failed to be saved: ".concat(err));
  1016. };
  1017. if (!this.pdfDocument || !this.downloadComplete) {
  1018. this.download({
  1019. sourceEventType: sourceEventType
  1020. });
  1021. return;
  1022. }
  1023. this._saveInProgress = true;
  1024. this.pdfDocument.saveDocument(this.pdfDocument.annotationStorage).then(function (data) {
  1025. var blob = new Blob([data], {
  1026. type: "application/pdf"
  1027. });
  1028. downloadManager.download(blob, url, filename, sourceEventType);
  1029. })["catch"](function () {
  1030. _this9.download({
  1031. sourceEventType: sourceEventType
  1032. });
  1033. })["finally"](function () {
  1034. _this9._saveInProgress = false;
  1035. });
  1036. },
  1037. _delayedFallback: function _delayedFallback(featureId) {
  1038. var _this10 = this;
  1039. this.externalServices.reportTelemetry({
  1040. type: "unsupportedFeature",
  1041. featureId: featureId
  1042. });
  1043. if (!this.triggerDelayedFallback) {
  1044. this.triggerDelayedFallback = function () {
  1045. _this10.fallback(featureId);
  1046. _this10.triggerDelayedFallback = null;
  1047. };
  1048. }
  1049. },
  1050. fallback: function fallback(featureId) {
  1051. this.externalServices.reportTelemetry({
  1052. type: "unsupportedFeature",
  1053. featureId: featureId
  1054. });
  1055. if (this.fellback) {
  1056. return;
  1057. }
  1058. this.fellback = true;
  1059. this.externalServices.fallback({
  1060. featureId: featureId,
  1061. url: this.baseUrl
  1062. }, function response(download) {
  1063. if (!download) {
  1064. return;
  1065. }
  1066. PDFViewerApplication.download({
  1067. sourceEventType: "download"
  1068. });
  1069. });
  1070. },
  1071. error: function error(message, moreInfo) {
  1072. var moreInfoText = [this.l10n.get("error_version_info", {
  1073. version: _pdfjsLib.version || "?",
  1074. build: _pdfjsLib.build || "?"
  1075. }, "PDF.js v{{version}} (build: {{build}})")];
  1076. if (moreInfo) {
  1077. moreInfoText.push(this.l10n.get("error_message", {
  1078. message: moreInfo.message
  1079. }, "Message: {{message}}"));
  1080. if (moreInfo.stack) {
  1081. moreInfoText.push(this.l10n.get("error_stack", {
  1082. stack: moreInfo.stack
  1083. }, "Stack: {{stack}}"));
  1084. } else {
  1085. if (moreInfo.filename) {
  1086. moreInfoText.push(this.l10n.get("error_file", {
  1087. file: moreInfo.filename
  1088. }, "File: {{file}}"));
  1089. }
  1090. if (moreInfo.lineNumber) {
  1091. moreInfoText.push(this.l10n.get("error_line", {
  1092. line: moreInfo.lineNumber
  1093. }, "Line: {{line}}"));
  1094. }
  1095. }
  1096. }
  1097. var errorWrapperConfig = this.appConfig.errorWrapper;
  1098. var errorWrapper = errorWrapperConfig.container;
  1099. errorWrapper.removeAttribute("hidden");
  1100. var errorMessage = errorWrapperConfig.errorMessage;
  1101. errorMessage.textContent = message;
  1102. var closeButton = errorWrapperConfig.closeButton;
  1103. closeButton.onclick = function () {
  1104. errorWrapper.setAttribute("hidden", "true");
  1105. };
  1106. var errorMoreInfo = errorWrapperConfig.errorMoreInfo;
  1107. var moreInfoButton = errorWrapperConfig.moreInfoButton;
  1108. var lessInfoButton = errorWrapperConfig.lessInfoButton;
  1109. moreInfoButton.onclick = function () {
  1110. errorMoreInfo.removeAttribute("hidden");
  1111. moreInfoButton.setAttribute("hidden", "true");
  1112. lessInfoButton.removeAttribute("hidden");
  1113. errorMoreInfo.style.height = errorMoreInfo.scrollHeight + "px";
  1114. };
  1115. lessInfoButton.onclick = function () {
  1116. errorMoreInfo.setAttribute("hidden", "true");
  1117. moreInfoButton.removeAttribute("hidden");
  1118. lessInfoButton.setAttribute("hidden", "true");
  1119. };
  1120. moreInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1121. lessInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1122. closeButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1123. moreInfoButton.removeAttribute("hidden");
  1124. lessInfoButton.setAttribute("hidden", "true");
  1125. Promise.all(moreInfoText).then(function (parts) {
  1126. errorMoreInfo.value = parts.join("\n");
  1127. });
  1128. },
  1129. progress: function progress(level) {
  1130. var _this11 = this;
  1131. if (this.downloadComplete) {
  1132. return;
  1133. }
  1134. var percent = Math.round(level * 100);
  1135. if (percent > this.loadingBar.percent || isNaN(percent)) {
  1136. this.loadingBar.percent = percent;
  1137. var disableAutoFetch = this.pdfDocument ? this.pdfDocument.loadingParams.disableAutoFetch : _app_options.AppOptions.get("disableAutoFetch");
  1138. if (disableAutoFetch && percent) {
  1139. if (this.disableAutoFetchLoadingBarTimeout) {
  1140. clearTimeout(this.disableAutoFetchLoadingBarTimeout);
  1141. this.disableAutoFetchLoadingBarTimeout = null;
  1142. }
  1143. this.loadingBar.show();
  1144. this.disableAutoFetchLoadingBarTimeout = setTimeout(function () {
  1145. _this11.loadingBar.hide();
  1146. _this11.disableAutoFetchLoadingBarTimeout = null;
  1147. }, DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT);
  1148. }
  1149. }
  1150. },
  1151. load: function load(pdfDocument) {
  1152. var _this12 = this;
  1153. this.pdfDocument = pdfDocument;
  1154. pdfDocument.getDownloadInfo().then(function () {
  1155. _this12.downloadComplete = true;
  1156. _this12.loadingBar.hide();
  1157. firstPagePromise.then(function () {
  1158. _this12.eventBus.dispatch("documentloaded", {
  1159. source: _this12
  1160. });
  1161. });
  1162. });
  1163. var pageLayoutPromise = pdfDocument.getPageLayout()["catch"](function () {});
  1164. var pageModePromise = pdfDocument.getPageMode()["catch"](function () {});
  1165. var openActionPromise = pdfDocument.getOpenAction()["catch"](function () {});
  1166. this.toolbar.setPagesCount(pdfDocument.numPages, false);
  1167. this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
  1168. var baseDocumentUrl;
  1169. baseDocumentUrl = null;
  1170. this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
  1171. this.pdfDocumentProperties.setDocument(pdfDocument, this.url);
  1172. var annotationStorage = pdfDocument.annotationStorage;
  1173. annotationStorage.onSetModified = function () {
  1174. window.addEventListener("beforeunload", beforeUnload);
  1175. };
  1176. annotationStorage.onResetModified = function () {
  1177. window.removeEventListener("beforeunload", beforeUnload);
  1178. };
  1179. var pdfViewer = this.pdfViewer;
  1180. pdfViewer.setDocument(pdfDocument);
  1181. var firstPagePromise = pdfViewer.firstPagePromise,
  1182. onePageRendered = pdfViewer.onePageRendered,
  1183. pagesPromise = pdfViewer.pagesPromise;
  1184. var pdfThumbnailViewer = this.pdfThumbnailViewer;
  1185. pdfThumbnailViewer.setDocument(pdfDocument);
  1186. var storedPromise = (this.store = new _view_history.ViewHistory(pdfDocument.fingerprint)).getMultiple({
  1187. page: null,
  1188. zoom: _ui_utils.DEFAULT_SCALE_VALUE,
  1189. scrollLeft: "0",
  1190. scrollTop: "0",
  1191. rotation: null,
  1192. sidebarView: _pdf_sidebar.SidebarView.UNKNOWN,
  1193. scrollMode: _ui_utils.ScrollMode.UNKNOWN,
  1194. spreadMode: _ui_utils.SpreadMode.UNKNOWN
  1195. })["catch"](function () {
  1196. return Object.create(null);
  1197. });
  1198. firstPagePromise.then(function (pdfPage) {
  1199. _this12.loadingBar.setWidth(_this12.appConfig.viewerContainer);
  1200. Promise.all([_ui_utils.animationStarted, storedPromise, pageLayoutPromise, pageModePromise, openActionPromise]).then( /*#__PURE__*/function () {
  1201. var _ref5 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee8(_ref4) {
  1202. var _ref6, timeStamp, stored, pageLayout, pageMode, openAction, viewOnLoad, initialBookmark, zoom, hash, rotation, sidebarView, scrollMode, spreadMode;
  1203. return _regenerator["default"].wrap(function _callee8$(_context8) {
  1204. while (1) {
  1205. switch (_context8.prev = _context8.next) {
  1206. case 0:
  1207. _ref6 = _slicedToArray(_ref4, 5), timeStamp = _ref6[0], stored = _ref6[1], pageLayout = _ref6[2], pageMode = _ref6[3], openAction = _ref6[4];
  1208. viewOnLoad = _app_options.AppOptions.get("viewOnLoad");
  1209. _this12._initializePdfHistory({
  1210. fingerprint: pdfDocument.fingerprint,
  1211. viewOnLoad: viewOnLoad,
  1212. initialDest: openAction && openAction.dest
  1213. });
  1214. initialBookmark = _this12.initialBookmark;
  1215. zoom = _app_options.AppOptions.get("defaultZoomValue");
  1216. hash = zoom ? "zoom=".concat(zoom) : null;
  1217. rotation = null;
  1218. sidebarView = _app_options.AppOptions.get("sidebarViewOnLoad");
  1219. scrollMode = _app_options.AppOptions.get("scrollModeOnLoad");
  1220. spreadMode = _app_options.AppOptions.get("spreadModeOnLoad");
  1221. if (stored.page && viewOnLoad !== ViewOnLoad.INITIAL) {
  1222. hash = "page=".concat(stored.page, "&zoom=").concat(zoom || stored.zoom, ",") + "".concat(stored.scrollLeft, ",").concat(stored.scrollTop);
  1223. rotation = parseInt(stored.rotation, 10);
  1224. if (sidebarView === _pdf_sidebar.SidebarView.UNKNOWN) {
  1225. sidebarView = stored.sidebarView | 0;
  1226. }
  1227. if (scrollMode === _ui_utils.ScrollMode.UNKNOWN) {
  1228. scrollMode = stored.scrollMode | 0;
  1229. }
  1230. if (spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
  1231. spreadMode = stored.spreadMode | 0;
  1232. }
  1233. }
  1234. if (pageMode && sidebarView === _pdf_sidebar.SidebarView.UNKNOWN) {
  1235. sidebarView = apiPageModeToSidebarView(pageMode);
  1236. }
  1237. if (pageLayout && spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
  1238. spreadMode = apiPageLayoutToSpreadMode(pageLayout);
  1239. }
  1240. _this12.setInitialView(hash, {
  1241. rotation: rotation,
  1242. sidebarView: sidebarView,
  1243. scrollMode: scrollMode,
  1244. spreadMode: spreadMode
  1245. });
  1246. _this12.eventBus.dispatch("documentinit", {
  1247. source: _this12
  1248. });
  1249. if (!_this12.isViewerEmbedded) {
  1250. pdfViewer.focus();
  1251. }
  1252. _this12._initializePermissions(pdfDocument);
  1253. _context8.next = 19;
  1254. return Promise.race([pagesPromise, new Promise(function (resolve) {
  1255. setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT);
  1256. })]);
  1257. case 19:
  1258. if (!(!initialBookmark && !hash)) {
  1259. _context8.next = 21;
  1260. break;
  1261. }
  1262. return _context8.abrupt("return");
  1263. case 21:
  1264. if (!pdfViewer.hasEqualPageSizes) {
  1265. _context8.next = 23;
  1266. break;
  1267. }
  1268. return _context8.abrupt("return");
  1269. case 23:
  1270. _this12.initialBookmark = initialBookmark;
  1271. pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;
  1272. _this12.setInitialView(hash);
  1273. case 26:
  1274. case "end":
  1275. return _context8.stop();
  1276. }
  1277. }
  1278. }, _callee8);
  1279. }));
  1280. return function (_x) {
  1281. return _ref5.apply(this, arguments);
  1282. };
  1283. }())["catch"](function () {
  1284. _this12.setInitialView();
  1285. }).then(function () {
  1286. pdfViewer.update();
  1287. });
  1288. });
  1289. pagesPromise.then(function () {
  1290. _this12._initializeAutoPrint(pdfDocument, openActionPromise);
  1291. });
  1292. onePageRendered.then(function () {
  1293. pdfDocument.getOutline().then(function (outline) {
  1294. _this12.pdfOutlineViewer.render({
  1295. outline: outline
  1296. });
  1297. });
  1298. pdfDocument.getAttachments().then(function (attachments) {
  1299. _this12.pdfAttachmentViewer.render({
  1300. attachments: attachments
  1301. });
  1302. });
  1303. pdfViewer.optionalContentConfigPromise.then(function (optionalContentConfig) {
  1304. _this12.pdfLayerViewer.render({
  1305. optionalContentConfig: optionalContentConfig,
  1306. pdfDocument: pdfDocument
  1307. });
  1308. });
  1309. });
  1310. this._initializePageLabels(pdfDocument);
  1311. this._initializeMetadata(pdfDocument);
  1312. },
  1313. _initializeAutoPrint: function _initializeAutoPrint(pdfDocument, openActionPromise) {
  1314. var _this13 = this;
  1315. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee9() {
  1316. var _yield$Promise$all, _yield$Promise$all2, openAction, javaScript, triggerAutoPrint, _iterator, _step, js;
  1317. return _regenerator["default"].wrap(function _callee9$(_context9) {
  1318. while (1) {
  1319. switch (_context9.prev = _context9.next) {
  1320. case 0:
  1321. _context9.next = 2;
  1322. return Promise.all([openActionPromise, pdfDocument.getJavaScript()]);
  1323. case 2:
  1324. _yield$Promise$all = _context9.sent;
  1325. _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
  1326. openAction = _yield$Promise$all2[0];
  1327. javaScript = _yield$Promise$all2[1];
  1328. if (!(pdfDocument !== _this13.pdfDocument)) {
  1329. _context9.next = 8;
  1330. break;
  1331. }
  1332. return _context9.abrupt("return");
  1333. case 8:
  1334. triggerAutoPrint = false;
  1335. if (openAction && openAction.action === "Print") {
  1336. triggerAutoPrint = true;
  1337. }
  1338. if (!javaScript) {
  1339. _context9.next = 31;
  1340. break;
  1341. }
  1342. javaScript.some(function (js) {
  1343. if (!js) {
  1344. return false;
  1345. }
  1346. console.warn("Warning: JavaScript is not supported");
  1347. _this13._delayedFallback(_pdfjsLib.UNSUPPORTED_FEATURES.javaScript);
  1348. return true;
  1349. });
  1350. if (triggerAutoPrint) {
  1351. _context9.next = 31;
  1352. break;
  1353. }
  1354. _iterator = _createForOfIteratorHelper(javaScript);
  1355. _context9.prev = 14;
  1356. _iterator.s();
  1357. case 16:
  1358. if ((_step = _iterator.n()).done) {
  1359. _context9.next = 23;
  1360. break;
  1361. }
  1362. js = _step.value;
  1363. if (!(js && _ui_utils.AutoPrintRegExp.test(js))) {
  1364. _context9.next = 21;
  1365. break;
  1366. }
  1367. triggerAutoPrint = true;
  1368. return _context9.abrupt("break", 23);
  1369. case 21:
  1370. _context9.next = 16;
  1371. break;
  1372. case 23:
  1373. _context9.next = 28;
  1374. break;
  1375. case 25:
  1376. _context9.prev = 25;
  1377. _context9.t0 = _context9["catch"](14);
  1378. _iterator.e(_context9.t0);
  1379. case 28:
  1380. _context9.prev = 28;
  1381. _iterator.f();
  1382. return _context9.finish(28);
  1383. case 31:
  1384. if (_this13.supportsPrinting) {
  1385. _context9.next = 33;
  1386. break;
  1387. }
  1388. return _context9.abrupt("return");
  1389. case 33:
  1390. if (triggerAutoPrint) {
  1391. setTimeout(function () {
  1392. window.print();
  1393. });
  1394. }
  1395. case 34:
  1396. case "end":
  1397. return _context9.stop();
  1398. }
  1399. }
  1400. }, _callee9, null, [[14, 25, 28, 31]]);
  1401. }))();
  1402. },
  1403. _initializeMetadata: function _initializeMetadata(pdfDocument) {
  1404. var _this14 = this;
  1405. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee10() {
  1406. var _yield$pdfDocument$ge, info, metadata, contentDispositionFilename, pdfTitle, infoTitle, metadataTitle, versionId, generatorId, producer, formType;
  1407. return _regenerator["default"].wrap(function _callee10$(_context10) {
  1408. while (1) {
  1409. switch (_context10.prev = _context10.next) {
  1410. case 0:
  1411. _context10.next = 2;
  1412. return pdfDocument.getMetadata();
  1413. case 2:
  1414. _yield$pdfDocument$ge = _context10.sent;
  1415. info = _yield$pdfDocument$ge.info;
  1416. metadata = _yield$pdfDocument$ge.metadata;
  1417. contentDispositionFilename = _yield$pdfDocument$ge.contentDispositionFilename;
  1418. if (!(pdfDocument !== _this14.pdfDocument)) {
  1419. _context10.next = 8;
  1420. break;
  1421. }
  1422. return _context10.abrupt("return");
  1423. case 8:
  1424. _this14.documentInfo = info;
  1425. _this14.metadata = metadata;
  1426. _this14.contentDispositionFilename = contentDispositionFilename;
  1427. console.log("PDF ".concat(pdfDocument.fingerprint, " [").concat(info.PDFFormatVersion, " ") + "".concat((info.Producer || "-").trim(), " / ").concat((info.Creator || "-").trim(), "] ") + "(PDF.js: ".concat(_pdfjsLib.version || "-") + "".concat(_this14.pdfViewer.enableWebGL ? " [WebGL]" : "", ")"));
  1428. infoTitle = info && info.Title;
  1429. if (infoTitle) {
  1430. pdfTitle = infoTitle;
  1431. }
  1432. metadataTitle = metadata && metadata.get("dc:title");
  1433. if (metadataTitle) {
  1434. if (metadataTitle !== "Untitled" && !/[\uFFF0-\uFFFF]/g.test(metadataTitle)) {
  1435. pdfTitle = metadataTitle;
  1436. }
  1437. }
  1438. if (pdfTitle) {
  1439. _this14.setTitle("".concat(pdfTitle, " - ").concat(contentDispositionFilename || document.title));
  1440. } else if (contentDispositionFilename) {
  1441. _this14.setTitle(contentDispositionFilename);
  1442. }
  1443. if (info.IsXFAPresent && !info.IsAcroFormPresent) {
  1444. console.warn("Warning: XFA is not supported");
  1445. _this14._delayedFallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms);
  1446. } else if ((info.IsAcroFormPresent || info.IsXFAPresent) && !_this14.pdfViewer.renderInteractiveForms) {
  1447. console.warn("Warning: Interactive form support is not enabled");
  1448. _this14._delayedFallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms);
  1449. }
  1450. versionId = "other";
  1451. if (KNOWN_VERSIONS.includes(info.PDFFormatVersion)) {
  1452. versionId = "v".concat(info.PDFFormatVersion.replace(".", "_"));
  1453. }
  1454. generatorId = "other";
  1455. if (info.Producer) {
  1456. producer = info.Producer.toLowerCase();
  1457. KNOWN_GENERATORS.some(function (generator) {
  1458. if (!producer.includes(generator)) {
  1459. return false;
  1460. }
  1461. generatorId = generator.replace(/[ .\-]/g, "_");
  1462. return true;
  1463. });
  1464. }
  1465. formType = null;
  1466. if (info.IsXFAPresent) {
  1467. formType = "xfa";
  1468. } else if (info.IsAcroFormPresent) {
  1469. formType = "acroform";
  1470. }
  1471. _this14.externalServices.reportTelemetry({
  1472. type: "documentInfo",
  1473. version: versionId,
  1474. generator: generatorId,
  1475. formType: formType
  1476. });
  1477. case 25:
  1478. case "end":
  1479. return _context10.stop();
  1480. }
  1481. }
  1482. }, _callee10);
  1483. }))();
  1484. },
  1485. _initializePageLabels: function _initializePageLabels(pdfDocument) {
  1486. var _this15 = this;
  1487. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee11() {
  1488. var labels, numLabels, i, pdfViewer, pdfThumbnailViewer, toolbar;
  1489. return _regenerator["default"].wrap(function _callee11$(_context11) {
  1490. while (1) {
  1491. switch (_context11.prev = _context11.next) {
  1492. case 0:
  1493. _context11.next = 2;
  1494. return pdfDocument.getPageLabels();
  1495. case 2:
  1496. labels = _context11.sent;
  1497. if (!(pdfDocument !== _this15.pdfDocument)) {
  1498. _context11.next = 5;
  1499. break;
  1500. }
  1501. return _context11.abrupt("return");
  1502. case 5:
  1503. if (!(!labels || _app_options.AppOptions.get("disablePageLabels"))) {
  1504. _context11.next = 7;
  1505. break;
  1506. }
  1507. return _context11.abrupt("return");
  1508. case 7:
  1509. numLabels = labels.length;
  1510. if (!(numLabels !== _this15.pagesCount)) {
  1511. _context11.next = 11;
  1512. break;
  1513. }
  1514. console.error("The number of Page Labels does not match the number of pages in the document.");
  1515. return _context11.abrupt("return");
  1516. case 11:
  1517. i = 0;
  1518. while (i < numLabels && labels[i] === (i + 1).toString()) {
  1519. i++;
  1520. }
  1521. if (!(i === numLabels)) {
  1522. _context11.next = 15;
  1523. break;
  1524. }
  1525. return _context11.abrupt("return");
  1526. case 15:
  1527. pdfViewer = _this15.pdfViewer, pdfThumbnailViewer = _this15.pdfThumbnailViewer, toolbar = _this15.toolbar;
  1528. pdfViewer.setPageLabels(labels);
  1529. pdfThumbnailViewer.setPageLabels(labels);
  1530. toolbar.setPagesCount(numLabels, true);
  1531. toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  1532. case 20:
  1533. case "end":
  1534. return _context11.stop();
  1535. }
  1536. }
  1537. }, _callee11);
  1538. }))();
  1539. },
  1540. _initializePdfHistory: function _initializePdfHistory(_ref7) {
  1541. var fingerprint = _ref7.fingerprint,
  1542. viewOnLoad = _ref7.viewOnLoad,
  1543. _ref7$initialDest = _ref7.initialDest,
  1544. initialDest = _ref7$initialDest === void 0 ? null : _ref7$initialDest;
  1545. if (this.isViewerEmbedded || _app_options.AppOptions.get("disableHistory")) {
  1546. return;
  1547. }
  1548. this.pdfHistory.initialize({
  1549. fingerprint: fingerprint,
  1550. resetHistory: viewOnLoad === ViewOnLoad.INITIAL,
  1551. updateUrl: _app_options.AppOptions.get("historyUpdateUrl")
  1552. });
  1553. if (this.pdfHistory.initialBookmark) {
  1554. this.initialBookmark = this.pdfHistory.initialBookmark;
  1555. this.initialRotation = this.pdfHistory.initialRotation;
  1556. }
  1557. if (initialDest && !this.initialBookmark && viewOnLoad === ViewOnLoad.UNKNOWN) {
  1558. this.initialBookmark = JSON.stringify(initialDest);
  1559. this.pdfHistory.push({
  1560. explicitDest: initialDest,
  1561. pageNumber: null
  1562. });
  1563. }
  1564. },
  1565. _initializePermissions: function _initializePermissions(pdfDocument) {
  1566. var _this16 = this;
  1567. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee12() {
  1568. var permissions;
  1569. return _regenerator["default"].wrap(function _callee12$(_context12) {
  1570. while (1) {
  1571. switch (_context12.prev = _context12.next) {
  1572. case 0:
  1573. _context12.next = 2;
  1574. return pdfDocument.getPermissions();
  1575. case 2:
  1576. permissions = _context12.sent;
  1577. if (!(pdfDocument !== _this16.pdfDocument)) {
  1578. _context12.next = 5;
  1579. break;
  1580. }
  1581. return _context12.abrupt("return");
  1582. case 5:
  1583. if (!(!permissions || !_app_options.AppOptions.get("enablePermissions"))) {
  1584. _context12.next = 7;
  1585. break;
  1586. }
  1587. return _context12.abrupt("return");
  1588. case 7:
  1589. if (!permissions.includes(_pdfjsLib.PermissionFlag.COPY)) {
  1590. _this16.appConfig.viewerContainer.classList.add(ENABLE_PERMISSIONS_CLASS);
  1591. }
  1592. case 8:
  1593. case "end":
  1594. return _context12.stop();
  1595. }
  1596. }
  1597. }, _callee12);
  1598. }))();
  1599. },
  1600. setInitialView: function setInitialView(storedHash) {
  1601. var _this17 = this;
  1602. var _ref8 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  1603. rotation = _ref8.rotation,
  1604. sidebarView = _ref8.sidebarView,
  1605. scrollMode = _ref8.scrollMode,
  1606. spreadMode = _ref8.spreadMode;
  1607. var setRotation = function setRotation(angle) {
  1608. if ((0, _ui_utils.isValidRotation)(angle)) {
  1609. _this17.pdfViewer.pagesRotation = angle;
  1610. }
  1611. };
  1612. var setViewerModes = function setViewerModes(scroll, spread) {
  1613. if ((0, _ui_utils.isValidScrollMode)(scroll)) {
  1614. _this17.pdfViewer.scrollMode = scroll;
  1615. }
  1616. if ((0, _ui_utils.isValidSpreadMode)(spread)) {
  1617. _this17.pdfViewer.spreadMode = spread;
  1618. }
  1619. };
  1620. this.isInitialViewSet = true;
  1621. this.pdfSidebar.setInitialView(sidebarView);
  1622. setViewerModes(scrollMode, spreadMode);
  1623. if (this.initialBookmark) {
  1624. setRotation(this.initialRotation);
  1625. delete this.initialRotation;
  1626. this.pdfLinkService.setHash(this.initialBookmark);
  1627. this.initialBookmark = null;
  1628. } else if (storedHash) {
  1629. setRotation(rotation);
  1630. this.pdfLinkService.setHash(storedHash);
  1631. }
  1632. this.toolbar.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel);
  1633. this.secondaryToolbar.setPageNumber(this.pdfViewer.currentPageNumber);
  1634. if (!this.pdfViewer.currentScaleValue) {
  1635. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  1636. }
  1637. },
  1638. cleanup: function cleanup() {
  1639. if (!this.pdfDocument) {
  1640. return;
  1641. }
  1642. this.pdfViewer.cleanup();
  1643. this.pdfThumbnailViewer.cleanup();
  1644. if (this.pdfViewer.renderer !== _ui_utils.RendererType.SVG) {
  1645. this.pdfDocument.cleanup();
  1646. }
  1647. },
  1648. forceRendering: function forceRendering() {
  1649. this.pdfRenderingQueue.printing = this.printing;
  1650. this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar.isThumbnailViewVisible;
  1651. this.pdfRenderingQueue.renderHighestPriority();
  1652. },
  1653. beforePrint: function beforePrint() {
  1654. var _this18 = this;
  1655. if (this.printService) {
  1656. return;
  1657. }
  1658. if (!this.supportsPrinting) {
  1659. this.l10n.get("printing_not_supported", null, "Warning: Printing is not fully supported by this browser.").then(function (printMessage) {
  1660. _this18.error(printMessage);
  1661. });
  1662. return;
  1663. }
  1664. if (!this.pdfViewer.pageViewsReady) {
  1665. this.l10n.get("printing_not_ready", null, "Warning: The PDF is not fully loaded for printing.").then(function (notReadyMessage) {
  1666. window.alert(notReadyMessage);
  1667. });
  1668. return;
  1669. }
  1670. var pagesOverview = this.pdfViewer.getPagesOverview();
  1671. var printContainer = this.appConfig.printContainer;
  1672. var printResolution = _app_options.AppOptions.get("printResolution");
  1673. var optionalContentConfigPromise = this.pdfViewer.optionalContentConfigPromise;
  1674. var printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, this.l10n);
  1675. this.printService = printService;
  1676. this.forceRendering();
  1677. printService.layout();
  1678. this.externalServices.reportTelemetry({
  1679. type: "print"
  1680. });
  1681. },
  1682. afterPrint: function afterPrint() {
  1683. if (this.printService) {
  1684. this.printService.destroy();
  1685. this.printService = null;
  1686. if (this.pdfDocument) {
  1687. this.pdfDocument.annotationStorage.resetModified();
  1688. }
  1689. }
  1690. this.forceRendering();
  1691. },
  1692. rotatePages: function rotatePages(delta) {
  1693. if (!this.pdfDocument) {
  1694. return;
  1695. }
  1696. var newRotation = (this.pdfViewer.pagesRotation + 360 + delta) % 360;
  1697. this.pdfViewer.pagesRotation = newRotation;
  1698. },
  1699. requestPresentationMode: function requestPresentationMode() {
  1700. if (!this.pdfPresentationMode) {
  1701. return;
  1702. }
  1703. this.pdfPresentationMode.request();
  1704. },
  1705. bindEvents: function bindEvents() {
  1706. var eventBus = this.eventBus,
  1707. _boundEvents = this._boundEvents;
  1708. _boundEvents.beforePrint = this.beforePrint.bind(this);
  1709. _boundEvents.afterPrint = this.afterPrint.bind(this);
  1710. eventBus._on("resize", webViewerResize);
  1711. eventBus._on("hashchange", webViewerHashchange);
  1712. eventBus._on("beforeprint", _boundEvents.beforePrint);
  1713. eventBus._on("afterprint", _boundEvents.afterPrint);
  1714. eventBus._on("pagerendered", webViewerPageRendered);
  1715. eventBus._on("updateviewarea", webViewerUpdateViewarea);
  1716. eventBus._on("pagechanging", webViewerPageChanging);
  1717. eventBus._on("scalechanging", webViewerScaleChanging);
  1718. eventBus._on("rotationchanging", webViewerRotationChanging);
  1719. eventBus._on("sidebarviewchanged", webViewerSidebarViewChanged);
  1720. eventBus._on("pagemode", webViewerPageMode);
  1721. eventBus._on("namedaction", webViewerNamedAction);
  1722. eventBus._on("presentationmodechanged", webViewerPresentationModeChanged);
  1723. eventBus._on("presentationmode", webViewerPresentationMode);
  1724. eventBus._on("print", webViewerPrint);
  1725. eventBus._on("download", webViewerDownload);
  1726. eventBus._on("save", webViewerSave);
  1727. eventBus._on("firstpage", webViewerFirstPage);
  1728. eventBus._on("lastpage", webViewerLastPage);
  1729. eventBus._on("nextpage", webViewerNextPage);
  1730. eventBus._on("previouspage", webViewerPreviousPage);
  1731. eventBus._on("zoomin", webViewerZoomIn);
  1732. eventBus._on("zoomout", webViewerZoomOut);
  1733. eventBus._on("zoomreset", webViewerZoomReset);
  1734. eventBus._on("pagenumberchanged", webViewerPageNumberChanged);
  1735. eventBus._on("scalechanged", webViewerScaleChanged);
  1736. eventBus._on("rotatecw", webViewerRotateCw);
  1737. eventBus._on("rotateccw", webViewerRotateCcw);
  1738. eventBus._on("optionalcontentconfig", webViewerOptionalContentConfig);
  1739. eventBus._on("switchscrollmode", webViewerSwitchScrollMode);
  1740. eventBus._on("scrollmodechanged", webViewerScrollModeChanged);
  1741. eventBus._on("switchspreadmode", webViewerSwitchSpreadMode);
  1742. eventBus._on("spreadmodechanged", webViewerSpreadModeChanged);
  1743. eventBus._on("documentproperties", webViewerDocumentProperties);
  1744. eventBus._on("find", webViewerFind);
  1745. eventBus._on("findfromurlhash", webViewerFindFromUrlHash);
  1746. eventBus._on("updatefindmatchescount", webViewerUpdateFindMatchesCount);
  1747. eventBus._on("updatefindcontrolstate", webViewerUpdateFindControlState);
  1748. eventBus._on("fileinputchange", webViewerFileInputChange);
  1749. eventBus._on("openfile", webViewerOpenFile);
  1750. },
  1751. bindWindowEvents: function bindWindowEvents() {
  1752. var eventBus = this.eventBus,
  1753. _boundEvents = this._boundEvents;
  1754. _boundEvents.windowResize = function () {
  1755. eventBus.dispatch("resize", {
  1756. source: window
  1757. });
  1758. };
  1759. _boundEvents.windowHashChange = function () {
  1760. eventBus.dispatch("hashchange", {
  1761. source: window,
  1762. hash: document.location.hash.substring(1)
  1763. });
  1764. };
  1765. _boundEvents.windowBeforePrint = function () {
  1766. eventBus.dispatch("beforeprint", {
  1767. source: window
  1768. });
  1769. };
  1770. _boundEvents.windowAfterPrint = function () {
  1771. eventBus.dispatch("afterprint", {
  1772. source: window
  1773. });
  1774. };
  1775. window.addEventListener("visibilitychange", webViewerVisibilityChange);
  1776. window.addEventListener("wheel", webViewerWheel, {
  1777. passive: false
  1778. });
  1779. window.addEventListener("touchstart", webViewerTouchStart, {
  1780. passive: false
  1781. });
  1782. window.addEventListener("click", webViewerClick);
  1783. window.addEventListener("keydown", webViewerKeyDown);
  1784. window.addEventListener("keyup", webViewerKeyUp);
  1785. window.addEventListener("resize", _boundEvents.windowResize);
  1786. window.addEventListener("hashchange", _boundEvents.windowHashChange);
  1787. window.addEventListener("beforeprint", _boundEvents.windowBeforePrint);
  1788. window.addEventListener("afterprint", _boundEvents.windowAfterPrint);
  1789. },
  1790. unbindEvents: function unbindEvents() {
  1791. var eventBus = this.eventBus,
  1792. _boundEvents = this._boundEvents;
  1793. eventBus._off("resize", webViewerResize);
  1794. eventBus._off("hashchange", webViewerHashchange);
  1795. eventBus._off("beforeprint", _boundEvents.beforePrint);
  1796. eventBus._off("afterprint", _boundEvents.afterPrint);
  1797. eventBus._off("pagerendered", webViewerPageRendered);
  1798. eventBus._off("updateviewarea", webViewerUpdateViewarea);
  1799. eventBus._off("pagechanging", webViewerPageChanging);
  1800. eventBus._off("scalechanging", webViewerScaleChanging);
  1801. eventBus._off("rotationchanging", webViewerRotationChanging);
  1802. eventBus._off("sidebarviewchanged", webViewerSidebarViewChanged);
  1803. eventBus._off("pagemode", webViewerPageMode);
  1804. eventBus._off("namedaction", webViewerNamedAction);
  1805. eventBus._off("presentationmodechanged", webViewerPresentationModeChanged);
  1806. eventBus._off("presentationmode", webViewerPresentationMode);
  1807. eventBus._off("print", webViewerPrint);
  1808. eventBus._off("download", webViewerDownload);
  1809. eventBus._off("save", webViewerSave);
  1810. eventBus._off("firstpage", webViewerFirstPage);
  1811. eventBus._off("lastpage", webViewerLastPage);
  1812. eventBus._off("nextpage", webViewerNextPage);
  1813. eventBus._off("previouspage", webViewerPreviousPage);
  1814. eventBus._off("zoomin", webViewerZoomIn);
  1815. eventBus._off("zoomout", webViewerZoomOut);
  1816. eventBus._off("zoomreset", webViewerZoomReset);
  1817. eventBus._off("pagenumberchanged", webViewerPageNumberChanged);
  1818. eventBus._off("scalechanged", webViewerScaleChanged);
  1819. eventBus._off("rotatecw", webViewerRotateCw);
  1820. eventBus._off("rotateccw", webViewerRotateCcw);
  1821. eventBus._off("optionalcontentconfig", webViewerOptionalContentConfig);
  1822. eventBus._off("switchscrollmode", webViewerSwitchScrollMode);
  1823. eventBus._off("scrollmodechanged", webViewerScrollModeChanged);
  1824. eventBus._off("switchspreadmode", webViewerSwitchSpreadMode);
  1825. eventBus._off("spreadmodechanged", webViewerSpreadModeChanged);
  1826. eventBus._off("documentproperties", webViewerDocumentProperties);
  1827. eventBus._off("find", webViewerFind);
  1828. eventBus._off("findfromurlhash", webViewerFindFromUrlHash);
  1829. eventBus._off("updatefindmatchescount", webViewerUpdateFindMatchesCount);
  1830. eventBus._off("updatefindcontrolstate", webViewerUpdateFindControlState);
  1831. eventBus._off("fileinputchange", webViewerFileInputChange);
  1832. eventBus._off("openfile", webViewerOpenFile);
  1833. _boundEvents.beforePrint = null;
  1834. _boundEvents.afterPrint = null;
  1835. },
  1836. unbindWindowEvents: function unbindWindowEvents() {
  1837. var _boundEvents = this._boundEvents;
  1838. window.removeEventListener("visibilitychange", webViewerVisibilityChange);
  1839. window.removeEventListener("wheel", webViewerWheel, {
  1840. passive: false
  1841. });
  1842. window.removeEventListener("touchstart", webViewerTouchStart, {
  1843. passive: false
  1844. });
  1845. window.removeEventListener("click", webViewerClick);
  1846. window.removeEventListener("keydown", webViewerKeyDown);
  1847. window.removeEventListener("keyup", webViewerKeyUp);
  1848. window.removeEventListener("resize", _boundEvents.windowResize);
  1849. window.removeEventListener("hashchange", _boundEvents.windowHashChange);
  1850. window.removeEventListener("beforeprint", _boundEvents.windowBeforePrint);
  1851. window.removeEventListener("afterprint", _boundEvents.windowAfterPrint);
  1852. _boundEvents.windowResize = null;
  1853. _boundEvents.windowHashChange = null;
  1854. _boundEvents.windowBeforePrint = null;
  1855. _boundEvents.windowAfterPrint = null;
  1856. },
  1857. accumulateWheelTicks: function accumulateWheelTicks(ticks) {
  1858. if (this._wheelUnusedTicks > 0 && ticks < 0 || this._wheelUnusedTicks < 0 && ticks > 0) {
  1859. this._wheelUnusedTicks = 0;
  1860. }
  1861. this._wheelUnusedTicks += ticks;
  1862. var wholeTicks = Math.sign(this._wheelUnusedTicks) * Math.floor(Math.abs(this._wheelUnusedTicks));
  1863. this._wheelUnusedTicks -= wholeTicks;
  1864. return wholeTicks;
  1865. }
  1866. };
  1867. exports.PDFViewerApplication = PDFViewerApplication;
  1868. var validateFileURL;
  1869. {
  1870. var HOSTED_VIEWER_ORIGINS = ["null", "http://mozilla.github.io", "https://mozilla.github.io"];
  1871. validateFileURL = function validateFileURL(file) {
  1872. if (file === undefined) {
  1873. return;
  1874. }
  1875. try {
  1876. var viewerOrigin = new URL(window.location.href).origin || "null";
  1877. if (HOSTED_VIEWER_ORIGINS.includes(viewerOrigin)) {
  1878. return;
  1879. }
  1880. var _URL = new URL(file, window.location.href),
  1881. origin = _URL.origin,
  1882. protocol = _URL.protocol;
  1883. if (origin !== viewerOrigin && protocol !== "blob:") {
  1884. throw new Error("file origin does not match viewer's");
  1885. }
  1886. } catch (ex) {
  1887. var message = ex && ex.message;
  1888. PDFViewerApplication.l10n.get("loading_error", null, "An error occurred while loading the PDF.").then(function (loadingErrorMessage) {
  1889. PDFViewerApplication.error(loadingErrorMessage, {
  1890. message: message
  1891. });
  1892. });
  1893. throw ex;
  1894. }
  1895. };
  1896. }
  1897. function loadFakeWorker() {
  1898. return _loadFakeWorker.apply(this, arguments);
  1899. }
  1900. function _loadFakeWorker() {
  1901. _loadFakeWorker = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee13() {
  1902. return _regenerator["default"].wrap(function _callee13$(_context13) {
  1903. while (1) {
  1904. switch (_context13.prev = _context13.next) {
  1905. case 0:
  1906. if (!_pdfjsLib.GlobalWorkerOptions.workerSrc) {
  1907. _pdfjsLib.GlobalWorkerOptions.workerSrc = _app_options.AppOptions.get("workerSrc");
  1908. }
  1909. return _context13.abrupt("return", (0, _pdfjsLib.loadScript)(_pdfjsLib.PDFWorker.getWorkerSrc()));
  1910. case 2:
  1911. case "end":
  1912. return _context13.stop();
  1913. }
  1914. }
  1915. }, _callee13);
  1916. }));
  1917. return _loadFakeWorker.apply(this, arguments);
  1918. }
  1919. function loadAndEnablePDFBug(enabledTabs) {
  1920. var appConfig = PDFViewerApplication.appConfig;
  1921. return (0, _pdfjsLib.loadScript)(appConfig.debuggerScriptPath).then(function () {
  1922. PDFBug.enable(enabledTabs);
  1923. PDFBug.init({
  1924. OPS: _pdfjsLib.OPS
  1925. }, appConfig.mainContainer);
  1926. });
  1927. }
  1928. function webViewerInitialized() {
  1929. var appConfig = PDFViewerApplication.appConfig;
  1930. var file;
  1931. var queryString = document.location.search.substring(1);
  1932. var params = (0, _ui_utils.parseQueryString)(queryString);
  1933. file = "file" in params ? params.file : _app_options.AppOptions.get("defaultUrl");
  1934. validateFileURL(file);
  1935. var fileInput = document.createElement("input");
  1936. fileInput.id = appConfig.openFileInputName;
  1937. fileInput.className = "fileInput";
  1938. fileInput.setAttribute("type", "file");
  1939. fileInput.oncontextmenu = _ui_utils.noContextMenuHandler;
  1940. document.body.appendChild(fileInput);
  1941. if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
  1942. appConfig.toolbar.openFile.setAttribute("hidden", "true");
  1943. appConfig.secondaryToolbar.openFileButton.setAttribute("hidden", "true");
  1944. } else {
  1945. fileInput.value = null;
  1946. }
  1947. fileInput.addEventListener("change", function (evt) {
  1948. var files = evt.target.files;
  1949. if (!files || files.length === 0) {
  1950. return;
  1951. }
  1952. PDFViewerApplication.eventBus.dispatch("fileinputchange", {
  1953. source: this,
  1954. fileInput: evt.target
  1955. });
  1956. });
  1957. appConfig.mainContainer.addEventListener("dragover", function (evt) {
  1958. evt.preventDefault();
  1959. evt.dataTransfer.dropEffect = "move";
  1960. });
  1961. appConfig.mainContainer.addEventListener("drop", function (evt) {
  1962. evt.preventDefault();
  1963. var files = evt.dataTransfer.files;
  1964. if (!files || files.length === 0) {
  1965. return;
  1966. }
  1967. PDFViewerApplication.eventBus.dispatch("fileinputchange", {
  1968. source: this,
  1969. fileInput: evt.dataTransfer
  1970. });
  1971. });
  1972. if (!PDFViewerApplication.supportsDocumentFonts) {
  1973. _app_options.AppOptions.set("disableFontFace", true);
  1974. PDFViewerApplication.l10n.get("web_fonts_disabled", null, "Web fonts are disabled: unable to use embedded PDF fonts.").then(function (msg) {
  1975. console.warn(msg);
  1976. });
  1977. }
  1978. if (!PDFViewerApplication.supportsPrinting) {
  1979. appConfig.toolbar.print.classList.add("hidden");
  1980. appConfig.secondaryToolbar.printButton.classList.add("hidden");
  1981. }
  1982. if (!PDFViewerApplication.supportsFullscreen) {
  1983. appConfig.toolbar.presentationModeButton.classList.add("hidden");
  1984. appConfig.secondaryToolbar.presentationModeButton.classList.add("hidden");
  1985. }
  1986. if (PDFViewerApplication.supportsIntegratedFind) {
  1987. appConfig.toolbar.viewFind.classList.add("hidden");
  1988. }
  1989. appConfig.mainContainer.addEventListener("transitionend", function (evt) {
  1990. if (evt.target === this) {
  1991. PDFViewerApplication.eventBus.dispatch("resize", {
  1992. source: this
  1993. });
  1994. }
  1995. }, true);
  1996. try {
  1997. webViewerOpenFileViaURL(file);
  1998. } catch (reason) {
  1999. PDFViewerApplication.l10n.get("loading_error", null, "An error occurred while loading the PDF.").then(function (msg) {
  2000. PDFViewerApplication.error(msg, reason);
  2001. });
  2002. }
  2003. }
  2004. var webViewerOpenFileViaURL;
  2005. {
  2006. webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) {
  2007. if (file && file.lastIndexOf("file:", 0) === 0) {
  2008. PDFViewerApplication.setTitleUsingUrl(file);
  2009. var xhr = new XMLHttpRequest();
  2010. xhr.onload = function () {
  2011. PDFViewerApplication.open(new Uint8Array(xhr.response));
  2012. };
  2013. xhr.open("GET", file);
  2014. xhr.responseType = "arraybuffer";
  2015. xhr.send();
  2016. return;
  2017. }
  2018. if (file) {
  2019. PDFViewerApplication.open(file);
  2020. }
  2021. };
  2022. }
  2023. function webViewerResetPermissions() {
  2024. var appConfig = PDFViewerApplication.appConfig;
  2025. if (!appConfig) {
  2026. return;
  2027. }
  2028. appConfig.viewerContainer.classList.remove(ENABLE_PERMISSIONS_CLASS);
  2029. }
  2030. function webViewerPageRendered(evt) {
  2031. var pageNumber = evt.pageNumber;
  2032. var pageIndex = pageNumber - 1;
  2033. var pageView = PDFViewerApplication.pdfViewer.getPageView(pageIndex);
  2034. if (pageNumber === PDFViewerApplication.page) {
  2035. PDFViewerApplication.toolbar.updateLoadingIndicatorState(false);
  2036. }
  2037. if (!pageView) {
  2038. return;
  2039. }
  2040. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  2041. var thumbnailView = PDFViewerApplication.pdfThumbnailViewer.getThumbnail(pageIndex);
  2042. thumbnailView.setImage(pageView);
  2043. }
  2044. if (typeof Stats !== "undefined" && Stats.enabled && pageView.stats) {
  2045. Stats.add(pageNumber, pageView.stats);
  2046. }
  2047. if (pageView.error) {
  2048. PDFViewerApplication.l10n.get("rendering_error", null, "An error occurred while rendering the page.").then(function (msg) {
  2049. PDFViewerApplication.error(msg, pageView.error);
  2050. });
  2051. }
  2052. PDFViewerApplication.externalServices.reportTelemetry({
  2053. type: "pageInfo",
  2054. timestamp: evt.timestamp
  2055. });
  2056. PDFViewerApplication.pdfDocument.getStats().then(function (stats) {
  2057. PDFViewerApplication.externalServices.reportTelemetry({
  2058. type: "documentStats",
  2059. stats: stats
  2060. });
  2061. });
  2062. }
  2063. function webViewerPageMode(_ref9) {
  2064. var mode = _ref9.mode;
  2065. var view;
  2066. switch (mode) {
  2067. case "thumbs":
  2068. view = _pdf_sidebar.SidebarView.THUMBS;
  2069. break;
  2070. case "bookmarks":
  2071. case "outline":
  2072. view = _pdf_sidebar.SidebarView.OUTLINE;
  2073. break;
  2074. case "attachments":
  2075. view = _pdf_sidebar.SidebarView.ATTACHMENTS;
  2076. break;
  2077. case "layers":
  2078. view = _pdf_sidebar.SidebarView.LAYERS;
  2079. break;
  2080. case "none":
  2081. view = _pdf_sidebar.SidebarView.NONE;
  2082. break;
  2083. default:
  2084. console.error('Invalid "pagemode" hash parameter: ' + mode);
  2085. return;
  2086. }
  2087. PDFViewerApplication.pdfSidebar.switchView(view, true);
  2088. }
  2089. function webViewerNamedAction(evt) {
  2090. switch (evt.action) {
  2091. case "GoToPage":
  2092. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  2093. break;
  2094. case "Find":
  2095. if (!PDFViewerApplication.supportsIntegratedFind) {
  2096. PDFViewerApplication.findBar.toggle();
  2097. }
  2098. break;
  2099. case "Print":
  2100. if (PDFViewerApplication.supportsPrinting) {
  2101. webViewerPrint();
  2102. }
  2103. break;
  2104. case "SaveAs":
  2105. webViewerSave();
  2106. break;
  2107. }
  2108. }
  2109. function webViewerPresentationModeChanged(_ref10) {
  2110. var active = _ref10.active,
  2111. switchInProgress = _ref10.switchInProgress;
  2112. var state = _ui_utils.PresentationModeState.NORMAL;
  2113. if (switchInProgress) {
  2114. state = _ui_utils.PresentationModeState.CHANGING;
  2115. } else if (active) {
  2116. state = _ui_utils.PresentationModeState.FULLSCREEN;
  2117. }
  2118. PDFViewerApplication.pdfViewer.presentationModeState = state;
  2119. }
  2120. function webViewerSidebarViewChanged(evt) {
  2121. PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = PDFViewerApplication.pdfSidebar.isThumbnailViewVisible;
  2122. var store = PDFViewerApplication.store;
  2123. if (store && PDFViewerApplication.isInitialViewSet) {
  2124. store.set("sidebarView", evt.view)["catch"](function () {});
  2125. }
  2126. }
  2127. function webViewerUpdateViewarea(evt) {
  2128. var location = evt.location,
  2129. store = PDFViewerApplication.store;
  2130. if (store && PDFViewerApplication.isInitialViewSet) {
  2131. store.setMultiple({
  2132. page: location.pageNumber,
  2133. zoom: location.scale,
  2134. scrollLeft: location.left,
  2135. scrollTop: location.top,
  2136. rotation: location.rotation
  2137. })["catch"](function () {});
  2138. }
  2139. var href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
  2140. PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href;
  2141. PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
  2142. var currentPage = PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page - 1);
  2143. var loading = currentPage.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED;
  2144. PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading);
  2145. }
  2146. function webViewerScrollModeChanged(evt) {
  2147. var store = PDFViewerApplication.store;
  2148. if (store && PDFViewerApplication.isInitialViewSet) {
  2149. store.set("scrollMode", evt.mode)["catch"](function () {});
  2150. }
  2151. }
  2152. function webViewerSpreadModeChanged(evt) {
  2153. var store = PDFViewerApplication.store;
  2154. if (store && PDFViewerApplication.isInitialViewSet) {
  2155. store.set("spreadMode", evt.mode)["catch"](function () {});
  2156. }
  2157. }
  2158. function webViewerResize() {
  2159. var pdfDocument = PDFViewerApplication.pdfDocument,
  2160. pdfViewer = PDFViewerApplication.pdfViewer;
  2161. if (!pdfDocument) {
  2162. return;
  2163. }
  2164. var currentScaleValue = pdfViewer.currentScaleValue;
  2165. if (currentScaleValue === "auto" || currentScaleValue === "page-fit" || currentScaleValue === "page-width") {
  2166. pdfViewer.currentScaleValue = currentScaleValue;
  2167. }
  2168. pdfViewer.update();
  2169. }
  2170. function webViewerHashchange(evt) {
  2171. var hash = evt.hash;
  2172. if (!hash) {
  2173. return;
  2174. }
  2175. if (!PDFViewerApplication.isInitialViewSet) {
  2176. PDFViewerApplication.initialBookmark = hash;
  2177. } else if (!PDFViewerApplication.pdfHistory.popStateInProgress) {
  2178. PDFViewerApplication.pdfLinkService.setHash(hash);
  2179. }
  2180. }
  2181. var webViewerFileInputChange, webViewerOpenFile;
  2182. {
  2183. webViewerFileInputChange = function webViewerFileInputChange(evt) {
  2184. if (PDFViewerApplication.pdfViewer && PDFViewerApplication.pdfViewer.isInPresentationMode) {
  2185. return;
  2186. }
  2187. var file = evt.fileInput.files[0];
  2188. if (!_viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL) {
  2189. var url = URL.createObjectURL(file);
  2190. if (file.name) {
  2191. url = {
  2192. url: url,
  2193. originalUrl: file.name
  2194. };
  2195. }
  2196. PDFViewerApplication.open(url);
  2197. } else {
  2198. PDFViewerApplication.setTitleUsingUrl(file.name);
  2199. var fileReader = new FileReader();
  2200. fileReader.onload = function webViewerChangeFileReaderOnload(event) {
  2201. var buffer = event.target.result;
  2202. PDFViewerApplication.open(new Uint8Array(buffer));
  2203. };
  2204. fileReader.readAsArrayBuffer(file);
  2205. }
  2206. var appConfig = PDFViewerApplication.appConfig;
  2207. appConfig.toolbar.viewBookmark.setAttribute("hidden", "true");
  2208. appConfig.secondaryToolbar.viewBookmarkButton.setAttribute("hidden", "true");
  2209. appConfig.toolbar.download.setAttribute("hidden", "true");
  2210. appConfig.secondaryToolbar.downloadButton.setAttribute("hidden", "true");
  2211. };
  2212. webViewerOpenFile = function webViewerOpenFile(evt) {
  2213. var openFileInputName = PDFViewerApplication.appConfig.openFileInputName;
  2214. document.getElementById(openFileInputName).click();
  2215. };
  2216. }
  2217. function webViewerPresentationMode() {
  2218. PDFViewerApplication.requestPresentationMode();
  2219. }
  2220. function webViewerPrint() {
  2221. window.print();
  2222. }
  2223. function webViewerDownloadOrSave(sourceEventType) {
  2224. if (PDFViewerApplication.pdfDocument && PDFViewerApplication.pdfDocument.annotationStorage.size > 0) {
  2225. PDFViewerApplication.save({
  2226. sourceEventType: sourceEventType
  2227. });
  2228. } else {
  2229. PDFViewerApplication.download({
  2230. sourceEventType: sourceEventType
  2231. });
  2232. }
  2233. }
  2234. function webViewerDownload() {
  2235. webViewerDownloadOrSave("download");
  2236. }
  2237. function webViewerSave() {
  2238. webViewerDownloadOrSave("save");
  2239. }
  2240. function webViewerFirstPage() {
  2241. if (PDFViewerApplication.pdfDocument) {
  2242. PDFViewerApplication.page = 1;
  2243. }
  2244. }
  2245. function webViewerLastPage() {
  2246. if (PDFViewerApplication.pdfDocument) {
  2247. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2248. }
  2249. }
  2250. function webViewerNextPage() {
  2251. PDFViewerApplication.page++;
  2252. }
  2253. function webViewerPreviousPage() {
  2254. PDFViewerApplication.page--;
  2255. }
  2256. function webViewerZoomIn() {
  2257. PDFViewerApplication.zoomIn();
  2258. }
  2259. function webViewerZoomOut() {
  2260. PDFViewerApplication.zoomOut();
  2261. }
  2262. function webViewerZoomReset() {
  2263. PDFViewerApplication.zoomReset();
  2264. }
  2265. function webViewerPageNumberChanged(evt) {
  2266. var pdfViewer = PDFViewerApplication.pdfViewer;
  2267. if (evt.value !== "") {
  2268. pdfViewer.currentPageLabel = evt.value;
  2269. }
  2270. if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) {
  2271. PDFViewerApplication.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  2272. }
  2273. }
  2274. function webViewerScaleChanged(evt) {
  2275. PDFViewerApplication.pdfViewer.currentScaleValue = evt.value;
  2276. }
  2277. function webViewerRotateCw() {
  2278. PDFViewerApplication.rotatePages(90);
  2279. }
  2280. function webViewerRotateCcw() {
  2281. PDFViewerApplication.rotatePages(-90);
  2282. }
  2283. function webViewerOptionalContentConfig(evt) {
  2284. PDFViewerApplication.pdfViewer.optionalContentConfigPromise = evt.promise;
  2285. }
  2286. function webViewerSwitchScrollMode(evt) {
  2287. PDFViewerApplication.pdfViewer.scrollMode = evt.mode;
  2288. }
  2289. function webViewerSwitchSpreadMode(evt) {
  2290. PDFViewerApplication.pdfViewer.spreadMode = evt.mode;
  2291. }
  2292. function webViewerDocumentProperties() {
  2293. PDFViewerApplication.pdfDocumentProperties.open();
  2294. }
  2295. function webViewerFind(evt) {
  2296. PDFViewerApplication.findController.executeCommand("find" + evt.type, {
  2297. query: evt.query,
  2298. phraseSearch: evt.phraseSearch,
  2299. caseSensitive: evt.caseSensitive,
  2300. entireWord: evt.entireWord,
  2301. highlightAll: evt.highlightAll,
  2302. findPrevious: evt.findPrevious
  2303. });
  2304. }
  2305. function webViewerFindFromUrlHash(evt) {
  2306. PDFViewerApplication.findController.executeCommand("find", {
  2307. query: evt.query,
  2308. phraseSearch: evt.phraseSearch,
  2309. caseSensitive: false,
  2310. entireWord: false,
  2311. highlightAll: true,
  2312. findPrevious: false
  2313. });
  2314. }
  2315. function webViewerUpdateFindMatchesCount(_ref11) {
  2316. var matchesCount = _ref11.matchesCount;
  2317. if (PDFViewerApplication.supportsIntegratedFind) {
  2318. PDFViewerApplication.externalServices.updateFindMatchesCount(matchesCount);
  2319. } else {
  2320. PDFViewerApplication.findBar.updateResultsCount(matchesCount);
  2321. }
  2322. }
  2323. function webViewerUpdateFindControlState(_ref12) {
  2324. var state = _ref12.state,
  2325. previous = _ref12.previous,
  2326. matchesCount = _ref12.matchesCount,
  2327. rawQuery = _ref12.rawQuery;
  2328. if (PDFViewerApplication.supportsIntegratedFind) {
  2329. PDFViewerApplication.externalServices.updateFindControlState({
  2330. result: state,
  2331. findPrevious: previous,
  2332. matchesCount: matchesCount,
  2333. rawQuery: rawQuery
  2334. });
  2335. } else {
  2336. PDFViewerApplication.findBar.updateUIState(state, previous, matchesCount);
  2337. }
  2338. }
  2339. function webViewerScaleChanging(evt) {
  2340. PDFViewerApplication.toolbar.setPageScale(evt.presetValue, evt.scale);
  2341. PDFViewerApplication.pdfViewer.update();
  2342. }
  2343. function webViewerRotationChanging(evt) {
  2344. PDFViewerApplication.pdfThumbnailViewer.pagesRotation = evt.pagesRotation;
  2345. PDFViewerApplication.forceRendering();
  2346. PDFViewerApplication.pdfViewer.currentPageNumber = evt.pageNumber;
  2347. }
  2348. function webViewerPageChanging(evt) {
  2349. var page = evt.pageNumber;
  2350. PDFViewerApplication.toolbar.setPageNumber(page, evt.pageLabel || null);
  2351. PDFViewerApplication.secondaryToolbar.setPageNumber(page);
  2352. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  2353. PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(page);
  2354. }
  2355. if (typeof Stats !== "undefined" && Stats.enabled) {
  2356. var pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1);
  2357. if (pageView && pageView.stats) {
  2358. Stats.add(page, pageView.stats);
  2359. }
  2360. }
  2361. }
  2362. function webViewerVisibilityChange(evt) {
  2363. if (document.visibilityState === "visible") {
  2364. setZoomDisabledTimeout();
  2365. }
  2366. }
  2367. var zoomDisabledTimeout = null;
  2368. function setZoomDisabledTimeout() {
  2369. if (zoomDisabledTimeout) {
  2370. clearTimeout(zoomDisabledTimeout);
  2371. }
  2372. zoomDisabledTimeout = setTimeout(function () {
  2373. zoomDisabledTimeout = null;
  2374. }, WHEEL_ZOOM_DISABLED_TIMEOUT);
  2375. }
  2376. function webViewerWheel(evt) {
  2377. var pdfViewer = PDFViewerApplication.pdfViewer,
  2378. supportedMouseWheelZoomModifierKeys = PDFViewerApplication.supportedMouseWheelZoomModifierKeys;
  2379. if (pdfViewer.isInPresentationMode) {
  2380. return;
  2381. }
  2382. if (evt.ctrlKey && supportedMouseWheelZoomModifierKeys.ctrlKey || evt.metaKey && supportedMouseWheelZoomModifierKeys.metaKey) {
  2383. evt.preventDefault();
  2384. if (zoomDisabledTimeout || document.visibilityState === "hidden") {
  2385. return;
  2386. }
  2387. var previousScale = pdfViewer.currentScale;
  2388. var delta = (0, _ui_utils.normalizeWheelEventDirection)(evt);
  2389. var ticks = 0;
  2390. if (evt.deltaMode === WheelEvent.DOM_DELTA_LINE || evt.deltaMode === WheelEvent.DOM_DELTA_PAGE) {
  2391. if (Math.abs(delta) >= 1) {
  2392. ticks = Math.sign(delta);
  2393. } else {
  2394. ticks = PDFViewerApplication.accumulateWheelTicks(delta);
  2395. }
  2396. } else {
  2397. var PIXELS_PER_LINE_SCALE = 30;
  2398. ticks = PDFViewerApplication.accumulateWheelTicks(delta / PIXELS_PER_LINE_SCALE);
  2399. }
  2400. if (ticks < 0) {
  2401. PDFViewerApplication.zoomOut(-ticks);
  2402. } else if (ticks > 0) {
  2403. PDFViewerApplication.zoomIn(ticks);
  2404. }
  2405. var currentScale = pdfViewer.currentScale;
  2406. if (previousScale !== currentScale) {
  2407. var scaleCorrectionFactor = currentScale / previousScale - 1;
  2408. var rect = pdfViewer.container.getBoundingClientRect();
  2409. var dx = evt.clientX - rect.left;
  2410. var dy = evt.clientY - rect.top;
  2411. pdfViewer.container.scrollLeft += dx * scaleCorrectionFactor;
  2412. pdfViewer.container.scrollTop += dy * scaleCorrectionFactor;
  2413. }
  2414. } else {
  2415. setZoomDisabledTimeout();
  2416. }
  2417. }
  2418. function webViewerTouchStart(evt) {
  2419. if (evt.touches.length > 1) {
  2420. evt.preventDefault();
  2421. }
  2422. }
  2423. function webViewerClick(evt) {
  2424. if (PDFViewerApplication.triggerDelayedFallback && PDFViewerApplication.pdfViewer.containsElement(evt.target)) {
  2425. PDFViewerApplication.triggerDelayedFallback();
  2426. }
  2427. if (!PDFViewerApplication.secondaryToolbar.isOpen) {
  2428. return;
  2429. }
  2430. var appConfig = PDFViewerApplication.appConfig;
  2431. if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar.container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar.toggleButton) {
  2432. PDFViewerApplication.secondaryToolbar.close();
  2433. }
  2434. }
  2435. function webViewerKeyUp(evt) {
  2436. if (evt.keyCode === 9) {
  2437. if (PDFViewerApplication.triggerDelayedFallback) {
  2438. PDFViewerApplication.triggerDelayedFallback();
  2439. }
  2440. }
  2441. }
  2442. function webViewerKeyDown(evt) {
  2443. if (PDFViewerApplication.overlayManager.active) {
  2444. return;
  2445. }
  2446. var handled = false,
  2447. ensureViewerFocused = false;
  2448. var cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0);
  2449. var pdfViewer = PDFViewerApplication.pdfViewer;
  2450. var isViewerInPresentationMode = pdfViewer && pdfViewer.isInPresentationMode;
  2451. if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
  2452. switch (evt.keyCode) {
  2453. case 70:
  2454. if (!PDFViewerApplication.supportsIntegratedFind) {
  2455. PDFViewerApplication.findBar.open();
  2456. handled = true;
  2457. }
  2458. break;
  2459. case 71:
  2460. if (!PDFViewerApplication.supportsIntegratedFind) {
  2461. var findState = PDFViewerApplication.findController.state;
  2462. if (findState) {
  2463. PDFViewerApplication.findController.executeCommand("findagain", {
  2464. query: findState.query,
  2465. phraseSearch: findState.phraseSearch,
  2466. caseSensitive: findState.caseSensitive,
  2467. entireWord: findState.entireWord,
  2468. highlightAll: findState.highlightAll,
  2469. findPrevious: cmd === 5 || cmd === 12
  2470. });
  2471. }
  2472. handled = true;
  2473. }
  2474. break;
  2475. case 61:
  2476. case 107:
  2477. case 187:
  2478. case 171:
  2479. if (!isViewerInPresentationMode) {
  2480. PDFViewerApplication.zoomIn();
  2481. }
  2482. handled = true;
  2483. break;
  2484. case 173:
  2485. case 109:
  2486. case 189:
  2487. if (!isViewerInPresentationMode) {
  2488. PDFViewerApplication.zoomOut();
  2489. }
  2490. handled = true;
  2491. break;
  2492. case 48:
  2493. case 96:
  2494. if (!isViewerInPresentationMode) {
  2495. setTimeout(function () {
  2496. PDFViewerApplication.zoomReset();
  2497. });
  2498. handled = false;
  2499. }
  2500. break;
  2501. case 38:
  2502. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  2503. PDFViewerApplication.page = 1;
  2504. handled = true;
  2505. ensureViewerFocused = true;
  2506. }
  2507. break;
  2508. case 40:
  2509. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2510. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2511. handled = true;
  2512. ensureViewerFocused = true;
  2513. }
  2514. break;
  2515. }
  2516. }
  2517. var eventBus = PDFViewerApplication.eventBus;
  2518. if (cmd === 1 || cmd === 8) {
  2519. switch (evt.keyCode) {
  2520. case 83:
  2521. eventBus.dispatch("download", {
  2522. source: window
  2523. });
  2524. handled = true;
  2525. break;
  2526. case 79:
  2527. {
  2528. eventBus.dispatch("openfile", {
  2529. source: window
  2530. });
  2531. handled = true;
  2532. }
  2533. break;
  2534. }
  2535. }
  2536. if (cmd === 3 || cmd === 10) {
  2537. switch (evt.keyCode) {
  2538. case 80:
  2539. PDFViewerApplication.requestPresentationMode();
  2540. handled = true;
  2541. break;
  2542. case 71:
  2543. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  2544. handled = true;
  2545. break;
  2546. }
  2547. }
  2548. if (handled) {
  2549. if (ensureViewerFocused && !isViewerInPresentationMode) {
  2550. pdfViewer.focus();
  2551. }
  2552. evt.preventDefault();
  2553. return;
  2554. }
  2555. var curElement = document.activeElement || document.querySelector(":focus");
  2556. var curElementTagName = curElement && curElement.tagName.toUpperCase();
  2557. if (curElementTagName === "INPUT" || curElementTagName === "TEXTAREA" || curElementTagName === "SELECT" || curElement && curElement.isContentEditable) {
  2558. if (evt.keyCode !== 27) {
  2559. return;
  2560. }
  2561. }
  2562. if (cmd === 0) {
  2563. var turnPage = 0,
  2564. turnOnlyIfPageFit = false;
  2565. switch (evt.keyCode) {
  2566. case 38:
  2567. case 33:
  2568. if (pdfViewer.isVerticalScrollbarEnabled) {
  2569. turnOnlyIfPageFit = true;
  2570. }
  2571. turnPage = -1;
  2572. break;
  2573. case 8:
  2574. if (!isViewerInPresentationMode) {
  2575. turnOnlyIfPageFit = true;
  2576. }
  2577. turnPage = -1;
  2578. break;
  2579. case 37:
  2580. if (pdfViewer.isHorizontalScrollbarEnabled) {
  2581. turnOnlyIfPageFit = true;
  2582. }
  2583. case 75:
  2584. case 80:
  2585. turnPage = -1;
  2586. break;
  2587. case 27:
  2588. if (PDFViewerApplication.secondaryToolbar.isOpen) {
  2589. PDFViewerApplication.secondaryToolbar.close();
  2590. handled = true;
  2591. }
  2592. if (!PDFViewerApplication.supportsIntegratedFind && PDFViewerApplication.findBar.opened) {
  2593. PDFViewerApplication.findBar.close();
  2594. handled = true;
  2595. }
  2596. break;
  2597. case 40:
  2598. case 34:
  2599. if (pdfViewer.isVerticalScrollbarEnabled) {
  2600. turnOnlyIfPageFit = true;
  2601. }
  2602. turnPage = 1;
  2603. break;
  2604. case 13:
  2605. case 32:
  2606. if (!isViewerInPresentationMode) {
  2607. turnOnlyIfPageFit = true;
  2608. }
  2609. turnPage = 1;
  2610. break;
  2611. case 39:
  2612. if (pdfViewer.isHorizontalScrollbarEnabled) {
  2613. turnOnlyIfPageFit = true;
  2614. }
  2615. case 74:
  2616. case 78:
  2617. turnPage = 1;
  2618. break;
  2619. case 36:
  2620. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  2621. PDFViewerApplication.page = 1;
  2622. handled = true;
  2623. ensureViewerFocused = true;
  2624. }
  2625. break;
  2626. case 35:
  2627. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2628. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2629. handled = true;
  2630. ensureViewerFocused = true;
  2631. }
  2632. break;
  2633. case 83:
  2634. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.SELECT);
  2635. break;
  2636. case 72:
  2637. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.HAND);
  2638. break;
  2639. case 82:
  2640. PDFViewerApplication.rotatePages(90);
  2641. break;
  2642. case 115:
  2643. PDFViewerApplication.pdfSidebar.toggle();
  2644. break;
  2645. }
  2646. if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === "page-fit")) {
  2647. if (turnPage > 0) {
  2648. if (PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2649. PDFViewerApplication.page++;
  2650. }
  2651. } else {
  2652. if (PDFViewerApplication.page > 1) {
  2653. PDFViewerApplication.page--;
  2654. }
  2655. }
  2656. handled = true;
  2657. }
  2658. }
  2659. if (cmd === 4) {
  2660. switch (evt.keyCode) {
  2661. case 13:
  2662. case 32:
  2663. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== "page-fit") {
  2664. break;
  2665. }
  2666. if (PDFViewerApplication.page > 1) {
  2667. PDFViewerApplication.page--;
  2668. }
  2669. handled = true;
  2670. break;
  2671. case 82:
  2672. PDFViewerApplication.rotatePages(-90);
  2673. break;
  2674. }
  2675. }
  2676. if (!handled && !isViewerInPresentationMode) {
  2677. if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !== "BUTTON") {
  2678. ensureViewerFocused = true;
  2679. }
  2680. }
  2681. if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
  2682. pdfViewer.focus();
  2683. }
  2684. if (handled) {
  2685. evt.preventDefault();
  2686. }
  2687. }
  2688. function beforeUnload(evt) {
  2689. evt.preventDefault();
  2690. evt.returnValue = "";
  2691. return false;
  2692. }
  2693. function apiPageLayoutToSpreadMode(layout) {
  2694. switch (layout) {
  2695. case "SinglePage":
  2696. case "OneColumn":
  2697. return _ui_utils.SpreadMode.NONE;
  2698. case "TwoColumnLeft":
  2699. case "TwoPageLeft":
  2700. return _ui_utils.SpreadMode.ODD;
  2701. case "TwoColumnRight":
  2702. case "TwoPageRight":
  2703. return _ui_utils.SpreadMode.EVEN;
  2704. }
  2705. return _ui_utils.SpreadMode.NONE;
  2706. }
  2707. function apiPageModeToSidebarView(mode) {
  2708. switch (mode) {
  2709. case "UseNone":
  2710. return _pdf_sidebar.SidebarView.NONE;
  2711. case "UseThumbs":
  2712. return _pdf_sidebar.SidebarView.THUMBS;
  2713. case "UseOutlines":
  2714. return _pdf_sidebar.SidebarView.OUTLINE;
  2715. case "UseAttachments":
  2716. return _pdf_sidebar.SidebarView.ATTACHMENTS;
  2717. case "UseOC":
  2718. return _pdf_sidebar.SidebarView.LAYERS;
  2719. }
  2720. return _pdf_sidebar.SidebarView.NONE;
  2721. }
  2722. var PDFPrintServiceFactory = {
  2723. instance: {
  2724. supportsPrinting: false,
  2725. createPrintService: function createPrintService() {
  2726. throw new Error("Not implemented: createPrintService");
  2727. }
  2728. }
  2729. };
  2730. exports.PDFPrintServiceFactory = PDFPrintServiceFactory;
  2731. /***/ }),
  2732. /* 2 */
  2733. /***/ (function(module, exports, __webpack_require__) {
  2734. "use strict";
  2735. module.exports = __webpack_require__(3);
  2736. /***/ }),
  2737. /* 3 */
  2738. /***/ (function(module, exports, __webpack_require__) {
  2739. "use strict";
  2740. /* WEBPACK VAR INJECTION */(function(module) {
  2741. 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); }
  2742. var runtime = function (exports) {
  2743. "use strict";
  2744. var Op = Object.prototype;
  2745. var hasOwn = Op.hasOwnProperty;
  2746. var undefined;
  2747. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  2748. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  2749. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  2750. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  2751. function define(obj, key, value) {
  2752. Object.defineProperty(obj, key, {
  2753. value: value,
  2754. enumerable: true,
  2755. configurable: true,
  2756. writable: true
  2757. });
  2758. return obj[key];
  2759. }
  2760. try {
  2761. define({}, "");
  2762. } catch (err) {
  2763. define = function define(obj, key, value) {
  2764. return obj[key] = value;
  2765. };
  2766. }
  2767. function wrap(innerFn, outerFn, self, tryLocsList) {
  2768. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  2769. var generator = Object.create(protoGenerator.prototype);
  2770. var context = new Context(tryLocsList || []);
  2771. generator._invoke = makeInvokeMethod(innerFn, self, context);
  2772. return generator;
  2773. }
  2774. exports.wrap = wrap;
  2775. function tryCatch(fn, obj, arg) {
  2776. try {
  2777. return {
  2778. type: "normal",
  2779. arg: fn.call(obj, arg)
  2780. };
  2781. } catch (err) {
  2782. return {
  2783. type: "throw",
  2784. arg: err
  2785. };
  2786. }
  2787. }
  2788. var GenStateSuspendedStart = "suspendedStart";
  2789. var GenStateSuspendedYield = "suspendedYield";
  2790. var GenStateExecuting = "executing";
  2791. var GenStateCompleted = "completed";
  2792. var ContinueSentinel = {};
  2793. function Generator() {}
  2794. function GeneratorFunction() {}
  2795. function GeneratorFunctionPrototype() {}
  2796. var IteratorPrototype = {};
  2797. IteratorPrototype[iteratorSymbol] = function () {
  2798. return this;
  2799. };
  2800. var getProto = Object.getPrototypeOf;
  2801. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  2802. if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  2803. IteratorPrototype = NativeIteratorPrototype;
  2804. }
  2805. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
  2806. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  2807. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  2808. GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
  2809. function defineIteratorMethods(prototype) {
  2810. ["next", "throw", "return"].forEach(function (method) {
  2811. define(prototype, method, function (arg) {
  2812. return this._invoke(method, arg);
  2813. });
  2814. });
  2815. }
  2816. exports.isGeneratorFunction = function (genFun) {
  2817. var ctor = typeof genFun === "function" && genFun.constructor;
  2818. return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
  2819. };
  2820. exports.mark = function (genFun) {
  2821. if (Object.setPrototypeOf) {
  2822. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  2823. } else {
  2824. genFun.__proto__ = GeneratorFunctionPrototype;
  2825. define(genFun, toStringTagSymbol, "GeneratorFunction");
  2826. }
  2827. genFun.prototype = Object.create(Gp);
  2828. return genFun;
  2829. };
  2830. exports.awrap = function (arg) {
  2831. return {
  2832. __await: arg
  2833. };
  2834. };
  2835. function AsyncIterator(generator, PromiseImpl) {
  2836. function invoke(method, arg, resolve, reject) {
  2837. var record = tryCatch(generator[method], generator, arg);
  2838. if (record.type === "throw") {
  2839. reject(record.arg);
  2840. } else {
  2841. var result = record.arg;
  2842. var value = result.value;
  2843. if (value && _typeof(value) === "object" && hasOwn.call(value, "__await")) {
  2844. return PromiseImpl.resolve(value.__await).then(function (value) {
  2845. invoke("next", value, resolve, reject);
  2846. }, function (err) {
  2847. invoke("throw", err, resolve, reject);
  2848. });
  2849. }
  2850. return PromiseImpl.resolve(value).then(function (unwrapped) {
  2851. result.value = unwrapped;
  2852. resolve(result);
  2853. }, function (error) {
  2854. return invoke("throw", error, resolve, reject);
  2855. });
  2856. }
  2857. }
  2858. var previousPromise;
  2859. function enqueue(method, arg) {
  2860. function callInvokeWithMethodAndArg() {
  2861. return new PromiseImpl(function (resolve, reject) {
  2862. invoke(method, arg, resolve, reject);
  2863. });
  2864. }
  2865. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  2866. }
  2867. this._invoke = enqueue;
  2868. }
  2869. defineIteratorMethods(AsyncIterator.prototype);
  2870. AsyncIterator.prototype[asyncIteratorSymbol] = function () {
  2871. return this;
  2872. };
  2873. exports.AsyncIterator = AsyncIterator;
  2874. exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  2875. if (PromiseImpl === void 0) PromiseImpl = Promise;
  2876. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  2877. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  2878. return result.done ? result.value : iter.next();
  2879. });
  2880. };
  2881. function makeInvokeMethod(innerFn, self, context) {
  2882. var state = GenStateSuspendedStart;
  2883. return function invoke(method, arg) {
  2884. if (state === GenStateExecuting) {
  2885. throw new Error("Generator is already running");
  2886. }
  2887. if (state === GenStateCompleted) {
  2888. if (method === "throw") {
  2889. throw arg;
  2890. }
  2891. return doneResult();
  2892. }
  2893. context.method = method;
  2894. context.arg = arg;
  2895. while (true) {
  2896. var delegate = context.delegate;
  2897. if (delegate) {
  2898. var delegateResult = maybeInvokeDelegate(delegate, context);
  2899. if (delegateResult) {
  2900. if (delegateResult === ContinueSentinel) continue;
  2901. return delegateResult;
  2902. }
  2903. }
  2904. if (context.method === "next") {
  2905. context.sent = context._sent = context.arg;
  2906. } else if (context.method === "throw") {
  2907. if (state === GenStateSuspendedStart) {
  2908. state = GenStateCompleted;
  2909. throw context.arg;
  2910. }
  2911. context.dispatchException(context.arg);
  2912. } else if (context.method === "return") {
  2913. context.abrupt("return", context.arg);
  2914. }
  2915. state = GenStateExecuting;
  2916. var record = tryCatch(innerFn, self, context);
  2917. if (record.type === "normal") {
  2918. state = context.done ? GenStateCompleted : GenStateSuspendedYield;
  2919. if (record.arg === ContinueSentinel) {
  2920. continue;
  2921. }
  2922. return {
  2923. value: record.arg,
  2924. done: context.done
  2925. };
  2926. } else if (record.type === "throw") {
  2927. state = GenStateCompleted;
  2928. context.method = "throw";
  2929. context.arg = record.arg;
  2930. }
  2931. }
  2932. };
  2933. }
  2934. function maybeInvokeDelegate(delegate, context) {
  2935. var method = delegate.iterator[context.method];
  2936. if (method === undefined) {
  2937. context.delegate = null;
  2938. if (context.method === "throw") {
  2939. if (delegate.iterator["return"]) {
  2940. context.method = "return";
  2941. context.arg = undefined;
  2942. maybeInvokeDelegate(delegate, context);
  2943. if (context.method === "throw") {
  2944. return ContinueSentinel;
  2945. }
  2946. }
  2947. context.method = "throw";
  2948. context.arg = new TypeError("The iterator does not provide a 'throw' method");
  2949. }
  2950. return ContinueSentinel;
  2951. }
  2952. var record = tryCatch(method, delegate.iterator, context.arg);
  2953. if (record.type === "throw") {
  2954. context.method = "throw";
  2955. context.arg = record.arg;
  2956. context.delegate = null;
  2957. return ContinueSentinel;
  2958. }
  2959. var info = record.arg;
  2960. if (!info) {
  2961. context.method = "throw";
  2962. context.arg = new TypeError("iterator result is not an object");
  2963. context.delegate = null;
  2964. return ContinueSentinel;
  2965. }
  2966. if (info.done) {
  2967. context[delegate.resultName] = info.value;
  2968. context.next = delegate.nextLoc;
  2969. if (context.method !== "return") {
  2970. context.method = "next";
  2971. context.arg = undefined;
  2972. }
  2973. } else {
  2974. return info;
  2975. }
  2976. context.delegate = null;
  2977. return ContinueSentinel;
  2978. }
  2979. defineIteratorMethods(Gp);
  2980. define(Gp, toStringTagSymbol, "Generator");
  2981. Gp[iteratorSymbol] = function () {
  2982. return this;
  2983. };
  2984. Gp.toString = function () {
  2985. return "[object Generator]";
  2986. };
  2987. function pushTryEntry(locs) {
  2988. var entry = {
  2989. tryLoc: locs[0]
  2990. };
  2991. if (1 in locs) {
  2992. entry.catchLoc = locs[1];
  2993. }
  2994. if (2 in locs) {
  2995. entry.finallyLoc = locs[2];
  2996. entry.afterLoc = locs[3];
  2997. }
  2998. this.tryEntries.push(entry);
  2999. }
  3000. function resetTryEntry(entry) {
  3001. var record = entry.completion || {};
  3002. record.type = "normal";
  3003. delete record.arg;
  3004. entry.completion = record;
  3005. }
  3006. function Context(tryLocsList) {
  3007. this.tryEntries = [{
  3008. tryLoc: "root"
  3009. }];
  3010. tryLocsList.forEach(pushTryEntry, this);
  3011. this.reset(true);
  3012. }
  3013. exports.keys = function (object) {
  3014. var keys = [];
  3015. for (var key in object) {
  3016. keys.push(key);
  3017. }
  3018. keys.reverse();
  3019. return function next() {
  3020. while (keys.length) {
  3021. var key = keys.pop();
  3022. if (key in object) {
  3023. next.value = key;
  3024. next.done = false;
  3025. return next;
  3026. }
  3027. }
  3028. next.done = true;
  3029. return next;
  3030. };
  3031. };
  3032. function values(iterable) {
  3033. if (iterable) {
  3034. var iteratorMethod = iterable[iteratorSymbol];
  3035. if (iteratorMethod) {
  3036. return iteratorMethod.call(iterable);
  3037. }
  3038. if (typeof iterable.next === "function") {
  3039. return iterable;
  3040. }
  3041. if (!isNaN(iterable.length)) {
  3042. var i = -1,
  3043. next = function next() {
  3044. while (++i < iterable.length) {
  3045. if (hasOwn.call(iterable, i)) {
  3046. next.value = iterable[i];
  3047. next.done = false;
  3048. return next;
  3049. }
  3050. }
  3051. next.value = undefined;
  3052. next.done = true;
  3053. return next;
  3054. };
  3055. return next.next = next;
  3056. }
  3057. }
  3058. return {
  3059. next: doneResult
  3060. };
  3061. }
  3062. exports.values = values;
  3063. function doneResult() {
  3064. return {
  3065. value: undefined,
  3066. done: true
  3067. };
  3068. }
  3069. Context.prototype = {
  3070. constructor: Context,
  3071. reset: function reset(skipTempReset) {
  3072. this.prev = 0;
  3073. this.next = 0;
  3074. this.sent = this._sent = undefined;
  3075. this.done = false;
  3076. this.delegate = null;
  3077. this.method = "next";
  3078. this.arg = undefined;
  3079. this.tryEntries.forEach(resetTryEntry);
  3080. if (!skipTempReset) {
  3081. for (var name in this) {
  3082. if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
  3083. this[name] = undefined;
  3084. }
  3085. }
  3086. }
  3087. },
  3088. stop: function stop() {
  3089. this.done = true;
  3090. var rootEntry = this.tryEntries[0];
  3091. var rootRecord = rootEntry.completion;
  3092. if (rootRecord.type === "throw") {
  3093. throw rootRecord.arg;
  3094. }
  3095. return this.rval;
  3096. },
  3097. dispatchException: function dispatchException(exception) {
  3098. if (this.done) {
  3099. throw exception;
  3100. }
  3101. var context = this;
  3102. function handle(loc, caught) {
  3103. record.type = "throw";
  3104. record.arg = exception;
  3105. context.next = loc;
  3106. if (caught) {
  3107. context.method = "next";
  3108. context.arg = undefined;
  3109. }
  3110. return !!caught;
  3111. }
  3112. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3113. var entry = this.tryEntries[i];
  3114. var record = entry.completion;
  3115. if (entry.tryLoc === "root") {
  3116. return handle("end");
  3117. }
  3118. if (entry.tryLoc <= this.prev) {
  3119. var hasCatch = hasOwn.call(entry, "catchLoc");
  3120. var hasFinally = hasOwn.call(entry, "finallyLoc");
  3121. if (hasCatch && hasFinally) {
  3122. if (this.prev < entry.catchLoc) {
  3123. return handle(entry.catchLoc, true);
  3124. } else if (this.prev < entry.finallyLoc) {
  3125. return handle(entry.finallyLoc);
  3126. }
  3127. } else if (hasCatch) {
  3128. if (this.prev < entry.catchLoc) {
  3129. return handle(entry.catchLoc, true);
  3130. }
  3131. } else if (hasFinally) {
  3132. if (this.prev < entry.finallyLoc) {
  3133. return handle(entry.finallyLoc);
  3134. }
  3135. } else {
  3136. throw new Error("try statement without catch or finally");
  3137. }
  3138. }
  3139. }
  3140. },
  3141. abrupt: function abrupt(type, arg) {
  3142. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3143. var entry = this.tryEntries[i];
  3144. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  3145. var finallyEntry = entry;
  3146. break;
  3147. }
  3148. }
  3149. if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
  3150. finallyEntry = null;
  3151. }
  3152. var record = finallyEntry ? finallyEntry.completion : {};
  3153. record.type = type;
  3154. record.arg = arg;
  3155. if (finallyEntry) {
  3156. this.method = "next";
  3157. this.next = finallyEntry.finallyLoc;
  3158. return ContinueSentinel;
  3159. }
  3160. return this.complete(record);
  3161. },
  3162. complete: function complete(record, afterLoc) {
  3163. if (record.type === "throw") {
  3164. throw record.arg;
  3165. }
  3166. if (record.type === "break" || record.type === "continue") {
  3167. this.next = record.arg;
  3168. } else if (record.type === "return") {
  3169. this.rval = this.arg = record.arg;
  3170. this.method = "return";
  3171. this.next = "end";
  3172. } else if (record.type === "normal" && afterLoc) {
  3173. this.next = afterLoc;
  3174. }
  3175. return ContinueSentinel;
  3176. },
  3177. finish: function finish(finallyLoc) {
  3178. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3179. var entry = this.tryEntries[i];
  3180. if (entry.finallyLoc === finallyLoc) {
  3181. this.complete(entry.completion, entry.afterLoc);
  3182. resetTryEntry(entry);
  3183. return ContinueSentinel;
  3184. }
  3185. }
  3186. },
  3187. "catch": function _catch(tryLoc) {
  3188. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  3189. var entry = this.tryEntries[i];
  3190. if (entry.tryLoc === tryLoc) {
  3191. var record = entry.completion;
  3192. if (record.type === "throw") {
  3193. var thrown = record.arg;
  3194. resetTryEntry(entry);
  3195. }
  3196. return thrown;
  3197. }
  3198. }
  3199. throw new Error("illegal catch attempt");
  3200. },
  3201. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  3202. this.delegate = {
  3203. iterator: values(iterable),
  3204. resultName: resultName,
  3205. nextLoc: nextLoc
  3206. };
  3207. if (this.method === "next") {
  3208. this.arg = undefined;
  3209. }
  3210. return ContinueSentinel;
  3211. }
  3212. };
  3213. return exports;
  3214. }(( false ? undefined : _typeof(module)) === "object" ? module.exports : {});
  3215. try {
  3216. regeneratorRuntime = runtime;
  3217. } catch (accidentalStrictMode) {
  3218. Function("r", "regeneratorRuntime = r")(runtime);
  3219. }
  3220. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(4)(module)))
  3221. /***/ }),
  3222. /* 4 */
  3223. /***/ (function(module, exports, __webpack_require__) {
  3224. "use strict";
  3225. module.exports = function (module) {
  3226. if (!module.webpackPolyfill) {
  3227. module.deprecate = function () {};
  3228. module.paths = [];
  3229. if (!module.children) module.children = [];
  3230. Object.defineProperty(module, "loaded", {
  3231. enumerable: true,
  3232. get: function get() {
  3233. return module.l;
  3234. }
  3235. });
  3236. Object.defineProperty(module, "id", {
  3237. enumerable: true,
  3238. get: function get() {
  3239. return module.i;
  3240. }
  3241. });
  3242. module.webpackPolyfill = 1;
  3243. }
  3244. return module;
  3245. };
  3246. /***/ }),
  3247. /* 5 */
  3248. /***/ (function(module, exports, __webpack_require__) {
  3249. "use strict";
  3250. Object.defineProperty(exports, "__esModule", {
  3251. value: true
  3252. });
  3253. exports.isValidRotation = isValidRotation;
  3254. exports.isValidScrollMode = isValidScrollMode;
  3255. exports.isValidSpreadMode = isValidSpreadMode;
  3256. exports.isPortraitOrientation = isPortraitOrientation;
  3257. exports.clamp = clamp;
  3258. exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
  3259. exports.noContextMenuHandler = noContextMenuHandler;
  3260. exports.parseQueryString = parseQueryString;
  3261. exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
  3262. exports.getVisibleElements = getVisibleElements;
  3263. exports.roundToDivide = roundToDivide;
  3264. exports.getPageSizeInches = getPageSizeInches;
  3265. exports.approximateFraction = approximateFraction;
  3266. exports.getOutputScale = getOutputScale;
  3267. exports.scrollIntoView = scrollIntoView;
  3268. exports.watchScroll = watchScroll;
  3269. exports.binarySearchFirstItem = binarySearchFirstItem;
  3270. exports.normalizeWheelEventDirection = normalizeWheelEventDirection;
  3271. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  3272. exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
  3273. exports.moveToEndOfArray = moveToEndOfArray;
  3274. exports.WaitOnType = exports.animationStarted = exports.ProgressBar = exports.EventBus = exports.NullL10n = exports.SpreadMode = exports.ScrollMode = exports.TextLayerMode = exports.RendererType = exports.PresentationModeState = exports.VERTICAL_PADDING = exports.SCROLLBAR_PADDING = exports.MAX_AUTO_SCALE = exports.UNKNOWN_SCALE = exports.MAX_SCALE = exports.MIN_SCALE = exports.DEFAULT_SCALE = exports.DEFAULT_SCALE_VALUE = exports.CSS_UNITS = exports.AutoPrintRegExp = void 0;
  3275. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  3276. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  3277. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3278. 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); } }
  3279. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3280. 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); }
  3281. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  3282. 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."); }
  3283. 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); }
  3284. 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; }
  3285. 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; }
  3286. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  3287. 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); } }
  3288. 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); }); }; }
  3289. var CSS_UNITS = 96.0 / 72.0;
  3290. exports.CSS_UNITS = CSS_UNITS;
  3291. var DEFAULT_SCALE_VALUE = "auto";
  3292. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  3293. var DEFAULT_SCALE = 1.0;
  3294. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  3295. var MIN_SCALE = 0.1;
  3296. exports.MIN_SCALE = MIN_SCALE;
  3297. var MAX_SCALE = 10.0;
  3298. exports.MAX_SCALE = MAX_SCALE;
  3299. var UNKNOWN_SCALE = 0;
  3300. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  3301. var MAX_AUTO_SCALE = 1.25;
  3302. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  3303. var SCROLLBAR_PADDING = 40;
  3304. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  3305. var VERTICAL_PADDING = 5;
  3306. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  3307. var PresentationModeState = {
  3308. UNKNOWN: 0,
  3309. NORMAL: 1,
  3310. CHANGING: 2,
  3311. FULLSCREEN: 3
  3312. };
  3313. exports.PresentationModeState = PresentationModeState;
  3314. var RendererType = {
  3315. CANVAS: "canvas",
  3316. SVG: "svg"
  3317. };
  3318. exports.RendererType = RendererType;
  3319. var TextLayerMode = {
  3320. DISABLE: 0,
  3321. ENABLE: 1,
  3322. ENABLE_ENHANCE: 2
  3323. };
  3324. exports.TextLayerMode = TextLayerMode;
  3325. var ScrollMode = {
  3326. UNKNOWN: -1,
  3327. VERTICAL: 0,
  3328. HORIZONTAL: 1,
  3329. WRAPPED: 2
  3330. };
  3331. exports.ScrollMode = ScrollMode;
  3332. var SpreadMode = {
  3333. UNKNOWN: -1,
  3334. NONE: 0,
  3335. ODD: 1,
  3336. EVEN: 2
  3337. };
  3338. exports.SpreadMode = SpreadMode;
  3339. var AutoPrintRegExp = /\bprint\s*\(/;
  3340. exports.AutoPrintRegExp = AutoPrintRegExp;
  3341. function formatL10nValue(text, args) {
  3342. if (!args) {
  3343. return text;
  3344. }
  3345. return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function (all, name) {
  3346. return name in args ? args[name] : "{{" + name + "}}";
  3347. });
  3348. }
  3349. var NullL10n = {
  3350. getLanguage: function getLanguage() {
  3351. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  3352. return _regenerator["default"].wrap(function _callee$(_context) {
  3353. while (1) {
  3354. switch (_context.prev = _context.next) {
  3355. case 0:
  3356. return _context.abrupt("return", "en-us");
  3357. case 1:
  3358. case "end":
  3359. return _context.stop();
  3360. }
  3361. }
  3362. }, _callee);
  3363. }))();
  3364. },
  3365. getDirection: function getDirection() {
  3366. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  3367. return _regenerator["default"].wrap(function _callee2$(_context2) {
  3368. while (1) {
  3369. switch (_context2.prev = _context2.next) {
  3370. case 0:
  3371. return _context2.abrupt("return", "ltr");
  3372. case 1:
  3373. case "end":
  3374. return _context2.stop();
  3375. }
  3376. }
  3377. }, _callee2);
  3378. }))();
  3379. },
  3380. get: function get(property, args, fallback) {
  3381. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  3382. return _regenerator["default"].wrap(function _callee3$(_context3) {
  3383. while (1) {
  3384. switch (_context3.prev = _context3.next) {
  3385. case 0:
  3386. return _context3.abrupt("return", formatL10nValue(fallback, args));
  3387. case 1:
  3388. case "end":
  3389. return _context3.stop();
  3390. }
  3391. }
  3392. }, _callee3);
  3393. }))();
  3394. },
  3395. translate: function translate(element) {
  3396. return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
  3397. return _regenerator["default"].wrap(function _callee4$(_context4) {
  3398. while (1) {
  3399. switch (_context4.prev = _context4.next) {
  3400. case 0:
  3401. case "end":
  3402. return _context4.stop();
  3403. }
  3404. }
  3405. }, _callee4);
  3406. }))();
  3407. }
  3408. };
  3409. exports.NullL10n = NullL10n;
  3410. function getOutputScale(ctx) {
  3411. var devicePixelRatio = window.devicePixelRatio || 1;
  3412. var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
  3413. var pixelRatio = devicePixelRatio / backingStoreRatio;
  3414. return {
  3415. sx: pixelRatio,
  3416. sy: pixelRatio,
  3417. scaled: pixelRatio !== 1
  3418. };
  3419. }
  3420. function scrollIntoView(element, spot) {
  3421. var skipOverflowHiddenElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  3422. var parent = element.offsetParent;
  3423. if (!parent) {
  3424. console.error("offsetParent is not set -- cannot scroll");
  3425. return;
  3426. }
  3427. var offsetY = element.offsetTop + element.clientTop;
  3428. var offsetX = element.offsetLeft + element.clientLeft;
  3429. while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || skipOverflowHiddenElements && getComputedStyle(parent).overflow === "hidden") {
  3430. if (parent.dataset._scaleY) {
  3431. offsetY /= parent.dataset._scaleY;
  3432. offsetX /= parent.dataset._scaleX;
  3433. }
  3434. offsetY += parent.offsetTop;
  3435. offsetX += parent.offsetLeft;
  3436. parent = parent.offsetParent;
  3437. if (!parent) {
  3438. return;
  3439. }
  3440. }
  3441. if (spot) {
  3442. if (spot.top !== undefined) {
  3443. offsetY += spot.top;
  3444. }
  3445. if (spot.left !== undefined) {
  3446. offsetX += spot.left;
  3447. parent.scrollLeft = offsetX;
  3448. }
  3449. }
  3450. parent.scrollTop = offsetY;
  3451. }
  3452. function watchScroll(viewAreaElement, callback) {
  3453. var debounceScroll = function debounceScroll(evt) {
  3454. if (rAF) {
  3455. return;
  3456. }
  3457. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  3458. rAF = null;
  3459. var currentX = viewAreaElement.scrollLeft;
  3460. var lastX = state.lastX;
  3461. if (currentX !== lastX) {
  3462. state.right = currentX > lastX;
  3463. }
  3464. state.lastX = currentX;
  3465. var currentY = viewAreaElement.scrollTop;
  3466. var lastY = state.lastY;
  3467. if (currentY !== lastY) {
  3468. state.down = currentY > lastY;
  3469. }
  3470. state.lastY = currentY;
  3471. callback(state);
  3472. });
  3473. };
  3474. var state = {
  3475. right: true,
  3476. down: true,
  3477. lastX: viewAreaElement.scrollLeft,
  3478. lastY: viewAreaElement.scrollTop,
  3479. _eventHandler: debounceScroll
  3480. };
  3481. var rAF = null;
  3482. viewAreaElement.addEventListener("scroll", debounceScroll, true);
  3483. return state;
  3484. }
  3485. function parseQueryString(query) {
  3486. var parts = query.split("&");
  3487. var params = Object.create(null);
  3488. for (var i = 0, ii = parts.length; i < ii; ++i) {
  3489. var param = parts[i].split("=");
  3490. var key = param[0].toLowerCase();
  3491. var value = param.length > 1 ? param[1] : null;
  3492. params[decodeURIComponent(key)] = decodeURIComponent(value);
  3493. }
  3494. return params;
  3495. }
  3496. function binarySearchFirstItem(items, condition) {
  3497. var minIndex = 0;
  3498. var maxIndex = items.length - 1;
  3499. if (maxIndex < 0 || !condition(items[maxIndex])) {
  3500. return items.length;
  3501. }
  3502. if (condition(items[minIndex])) {
  3503. return minIndex;
  3504. }
  3505. while (minIndex < maxIndex) {
  3506. var currentIndex = minIndex + maxIndex >> 1;
  3507. var currentItem = items[currentIndex];
  3508. if (condition(currentItem)) {
  3509. maxIndex = currentIndex;
  3510. } else {
  3511. minIndex = currentIndex + 1;
  3512. }
  3513. }
  3514. return minIndex;
  3515. }
  3516. function approximateFraction(x) {
  3517. if (Math.floor(x) === x) {
  3518. return [x, 1];
  3519. }
  3520. var xinv = 1 / x;
  3521. var limit = 8;
  3522. if (xinv > limit) {
  3523. return [1, limit];
  3524. } else if (Math.floor(xinv) === xinv) {
  3525. return [1, xinv];
  3526. }
  3527. var x_ = x > 1 ? xinv : x;
  3528. var a = 0,
  3529. b = 1,
  3530. c = 1,
  3531. d = 1;
  3532. while (true) {
  3533. var p = a + c,
  3534. q = b + d;
  3535. if (q > limit) {
  3536. break;
  3537. }
  3538. if (x_ <= p / q) {
  3539. c = p;
  3540. d = q;
  3541. } else {
  3542. a = p;
  3543. b = q;
  3544. }
  3545. }
  3546. var result;
  3547. if (x_ - a / b < c / d - x_) {
  3548. result = x_ === x ? [a, b] : [b, a];
  3549. } else {
  3550. result = x_ === x ? [c, d] : [d, c];
  3551. }
  3552. return result;
  3553. }
  3554. function roundToDivide(x, div) {
  3555. var r = x % div;
  3556. return r === 0 ? x : Math.round(x - r + div);
  3557. }
  3558. function getPageSizeInches(_ref) {
  3559. var view = _ref.view,
  3560. userUnit = _ref.userUnit,
  3561. rotate = _ref.rotate;
  3562. var _view = _slicedToArray(view, 4),
  3563. x1 = _view[0],
  3564. y1 = _view[1],
  3565. x2 = _view[2],
  3566. y2 = _view[3];
  3567. var changeOrientation = rotate % 180 !== 0;
  3568. var width = (x2 - x1) / 72 * userUnit;
  3569. var height = (y2 - y1) / 72 * userUnit;
  3570. return {
  3571. width: changeOrientation ? height : width,
  3572. height: changeOrientation ? width : height
  3573. };
  3574. }
  3575. function backtrackBeforeAllVisibleElements(index, views, top) {
  3576. if (index < 2) {
  3577. return index;
  3578. }
  3579. var elt = views[index].div;
  3580. var pageTop = elt.offsetTop + elt.clientTop;
  3581. if (pageTop >= top) {
  3582. elt = views[index - 1].div;
  3583. pageTop = elt.offsetTop + elt.clientTop;
  3584. }
  3585. for (var i = index - 2; i >= 0; --i) {
  3586. elt = views[i].div;
  3587. if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
  3588. break;
  3589. }
  3590. index = i;
  3591. }
  3592. return index;
  3593. }
  3594. function getVisibleElements(scrollEl, views) {
  3595. var sortByVisibility = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  3596. var horizontal = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  3597. var top = scrollEl.scrollTop,
  3598. bottom = top + scrollEl.clientHeight;
  3599. var left = scrollEl.scrollLeft,
  3600. right = left + scrollEl.clientWidth;
  3601. function isElementBottomAfterViewTop(view) {
  3602. var element = view.div;
  3603. var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  3604. return elementBottom > top;
  3605. }
  3606. function isElementRightAfterViewLeft(view) {
  3607. var element = view.div;
  3608. var elementRight = element.offsetLeft + element.clientLeft + element.clientWidth;
  3609. return elementRight > left;
  3610. }
  3611. var visible = [],
  3612. numViews = views.length;
  3613. var firstVisibleElementInd = numViews === 0 ? 0 : binarySearchFirstItem(views, horizontal ? isElementRightAfterViewLeft : isElementBottomAfterViewTop);
  3614. if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
  3615. firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
  3616. }
  3617. var lastEdge = horizontal ? right : -1;
  3618. for (var i = firstVisibleElementInd; i < numViews; i++) {
  3619. var view = views[i],
  3620. element = view.div;
  3621. var currentWidth = element.offsetLeft + element.clientLeft;
  3622. var currentHeight = element.offsetTop + element.clientTop;
  3623. var viewWidth = element.clientWidth,
  3624. viewHeight = element.clientHeight;
  3625. var viewRight = currentWidth + viewWidth;
  3626. var viewBottom = currentHeight + viewHeight;
  3627. if (lastEdge === -1) {
  3628. if (viewBottom >= bottom) {
  3629. lastEdge = viewBottom;
  3630. }
  3631. } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
  3632. break;
  3633. }
  3634. if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) {
  3635. continue;
  3636. }
  3637. var hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
  3638. var hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
  3639. var percent = (viewHeight - hiddenHeight) * (viewWidth - hiddenWidth) * 100 / viewHeight / viewWidth | 0;
  3640. visible.push({
  3641. id: view.id,
  3642. x: currentWidth,
  3643. y: currentHeight,
  3644. view: view,
  3645. percent: percent
  3646. });
  3647. }
  3648. var first = visible[0],
  3649. last = visible[visible.length - 1];
  3650. if (sortByVisibility) {
  3651. visible.sort(function (a, b) {
  3652. var pc = a.percent - b.percent;
  3653. if (Math.abs(pc) > 0.001) {
  3654. return -pc;
  3655. }
  3656. return a.id - b.id;
  3657. });
  3658. }
  3659. return {
  3660. first: first,
  3661. last: last,
  3662. views: visible
  3663. };
  3664. }
  3665. function noContextMenuHandler(evt) {
  3666. evt.preventDefault();
  3667. }
  3668. function isDataSchema(url) {
  3669. var i = 0;
  3670. var ii = url.length;
  3671. while (i < ii && url[i].trim() === "") {
  3672. i++;
  3673. }
  3674. return url.substring(i, i + 5).toLowerCase() === "data:";
  3675. }
  3676. function getPDFFileNameFromURL(url) {
  3677. var defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "document.pdf";
  3678. if (typeof url !== "string") {
  3679. return defaultFilename;
  3680. }
  3681. if (isDataSchema(url)) {
  3682. console.warn("getPDFFileNameFromURL: " + 'ignoring "data:" URL for performance reasons.');
  3683. return defaultFilename;
  3684. }
  3685. var reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
  3686. var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
  3687. var splitURI = reURI.exec(url);
  3688. var suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
  3689. if (suggestedFilename) {
  3690. suggestedFilename = suggestedFilename[0];
  3691. if (suggestedFilename.includes("%")) {
  3692. try {
  3693. suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
  3694. } catch (ex) {}
  3695. }
  3696. }
  3697. return suggestedFilename || defaultFilename;
  3698. }
  3699. function normalizeWheelEventDirection(evt) {
  3700. var delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
  3701. var angle = Math.atan2(evt.deltaY, evt.deltaX);
  3702. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  3703. delta = -delta;
  3704. }
  3705. return delta;
  3706. }
  3707. function normalizeWheelEventDelta(evt) {
  3708. var delta = normalizeWheelEventDirection(evt);
  3709. var MOUSE_DOM_DELTA_PIXEL_MODE = 0;
  3710. var MOUSE_DOM_DELTA_LINE_MODE = 1;
  3711. var MOUSE_PIXELS_PER_LINE = 30;
  3712. var MOUSE_LINES_PER_PAGE = 30;
  3713. if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
  3714. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  3715. } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
  3716. delta /= MOUSE_LINES_PER_PAGE;
  3717. }
  3718. return delta;
  3719. }
  3720. function isValidRotation(angle) {
  3721. return Number.isInteger(angle) && angle % 90 === 0;
  3722. }
  3723. function isValidScrollMode(mode) {
  3724. return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN;
  3725. }
  3726. function isValidSpreadMode(mode) {
  3727. return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN;
  3728. }
  3729. function isPortraitOrientation(size) {
  3730. return size.width <= size.height;
  3731. }
  3732. var WaitOnType = {
  3733. EVENT: "event",
  3734. TIMEOUT: "timeout"
  3735. };
  3736. exports.WaitOnType = WaitOnType;
  3737. function waitOnEventOrTimeout(_ref2) {
  3738. var target = _ref2.target,
  3739. name = _ref2.name,
  3740. _ref2$delay = _ref2.delay,
  3741. delay = _ref2$delay === void 0 ? 0 : _ref2$delay;
  3742. return new Promise(function (resolve, reject) {
  3743. if (_typeof(target) !== "object" || !(name && typeof name === "string") || !(Number.isInteger(delay) && delay >= 0)) {
  3744. throw new Error("waitOnEventOrTimeout - invalid parameters.");
  3745. }
  3746. function handler(type) {
  3747. if (target instanceof EventBus) {
  3748. target._off(name, eventHandler);
  3749. } else {
  3750. target.removeEventListener(name, eventHandler);
  3751. }
  3752. if (timeout) {
  3753. clearTimeout(timeout);
  3754. }
  3755. resolve(type);
  3756. }
  3757. var eventHandler = handler.bind(null, WaitOnType.EVENT);
  3758. if (target instanceof EventBus) {
  3759. target._on(name, eventHandler);
  3760. } else {
  3761. target.addEventListener(name, eventHandler);
  3762. }
  3763. var timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
  3764. var timeout = setTimeout(timeoutHandler, delay);
  3765. });
  3766. }
  3767. var animationStarted = new Promise(function (resolve) {
  3768. window.requestAnimationFrame(resolve);
  3769. });
  3770. exports.animationStarted = animationStarted;
  3771. function dispatchDOMEvent(eventName) {
  3772. var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  3773. throw new Error("Not implemented: dispatchDOMEvent");
  3774. }
  3775. var EventBus = /*#__PURE__*/function () {
  3776. function EventBus(options) {
  3777. _classCallCheck(this, EventBus);
  3778. this._listeners = Object.create(null);
  3779. }
  3780. _createClass(EventBus, [{
  3781. key: "on",
  3782. value: function on(eventName, listener) {
  3783. this._on(eventName, listener, {
  3784. external: true
  3785. });
  3786. }
  3787. }, {
  3788. key: "off",
  3789. value: function off(eventName, listener) {
  3790. this._off(eventName, listener, {
  3791. external: true
  3792. });
  3793. }
  3794. }, {
  3795. key: "dispatch",
  3796. value: function dispatch(eventName) {
  3797. var eventListeners = this._listeners[eventName];
  3798. if (!eventListeners || eventListeners.length === 0) {
  3799. return;
  3800. }
  3801. var args = Array.prototype.slice.call(arguments, 1);
  3802. var externalListeners;
  3803. eventListeners.slice(0).forEach(function (_ref3) {
  3804. var listener = _ref3.listener,
  3805. external = _ref3.external;
  3806. if (external) {
  3807. if (!externalListeners) {
  3808. externalListeners = [];
  3809. }
  3810. externalListeners.push(listener);
  3811. return;
  3812. }
  3813. listener.apply(null, args);
  3814. });
  3815. if (externalListeners) {
  3816. externalListeners.forEach(function (listener) {
  3817. listener.apply(null, args);
  3818. });
  3819. externalListeners = null;
  3820. }
  3821. }
  3822. }, {
  3823. key: "_on",
  3824. value: function _on(eventName, listener) {
  3825. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  3826. var eventListeners = this._listeners[eventName];
  3827. if (!eventListeners) {
  3828. this._listeners[eventName] = eventListeners = [];
  3829. }
  3830. eventListeners.push({
  3831. listener: listener,
  3832. external: (options && options.external) === true
  3833. });
  3834. }
  3835. }, {
  3836. key: "_off",
  3837. value: function _off(eventName, listener) {
  3838. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  3839. var eventListeners = this._listeners[eventName];
  3840. if (!eventListeners) {
  3841. return;
  3842. }
  3843. for (var i = 0, ii = eventListeners.length; i < ii; i++) {
  3844. if (eventListeners[i].listener === listener) {
  3845. eventListeners.splice(i, 1);
  3846. return;
  3847. }
  3848. }
  3849. }
  3850. }]);
  3851. return EventBus;
  3852. }();
  3853. exports.EventBus = EventBus;
  3854. function clamp(v, min, max) {
  3855. return Math.min(Math.max(v, min), max);
  3856. }
  3857. var ProgressBar = /*#__PURE__*/function () {
  3858. function ProgressBar(id) {
  3859. var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  3860. height = _ref4.height,
  3861. width = _ref4.width,
  3862. units = _ref4.units;
  3863. _classCallCheck(this, ProgressBar);
  3864. this.visible = true;
  3865. this.div = document.querySelector(id + " .progress");
  3866. this.bar = this.div.parentNode;
  3867. this.height = height || 100;
  3868. this.width = width || 100;
  3869. this.units = units || "%";
  3870. this.div.style.height = this.height + this.units;
  3871. this.percent = 0;
  3872. }
  3873. _createClass(ProgressBar, [{
  3874. key: "_updateBar",
  3875. value: function _updateBar() {
  3876. if (this._indeterminate) {
  3877. this.div.classList.add("indeterminate");
  3878. this.div.style.width = this.width + this.units;
  3879. return;
  3880. }
  3881. this.div.classList.remove("indeterminate");
  3882. var progressSize = this.width * this._percent / 100;
  3883. this.div.style.width = progressSize + this.units;
  3884. }
  3885. }, {
  3886. key: "setWidth",
  3887. value: function setWidth(viewer) {
  3888. if (!viewer) {
  3889. return;
  3890. }
  3891. var container = viewer.parentNode;
  3892. var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  3893. if (scrollbarWidth > 0) {
  3894. this.bar.style.width = "calc(100% - ".concat(scrollbarWidth, "px)");
  3895. }
  3896. }
  3897. }, {
  3898. key: "hide",
  3899. value: function hide() {
  3900. if (!this.visible) {
  3901. return;
  3902. }
  3903. this.visible = false;
  3904. this.bar.classList.add("hidden");
  3905. document.body.classList.remove("loadingInProgress");
  3906. }
  3907. }, {
  3908. key: "show",
  3909. value: function show() {
  3910. if (this.visible) {
  3911. return;
  3912. }
  3913. this.visible = true;
  3914. document.body.classList.add("loadingInProgress");
  3915. this.bar.classList.remove("hidden");
  3916. }
  3917. }, {
  3918. key: "percent",
  3919. get: function get() {
  3920. return this._percent;
  3921. },
  3922. set: function set(val) {
  3923. this._indeterminate = isNaN(val);
  3924. this._percent = clamp(val, 0, 100);
  3925. this._updateBar();
  3926. }
  3927. }]);
  3928. return ProgressBar;
  3929. }();
  3930. exports.ProgressBar = ProgressBar;
  3931. function moveToEndOfArray(arr, condition) {
  3932. var moved = [],
  3933. len = arr.length;
  3934. var write = 0;
  3935. for (var read = 0; read < len; ++read) {
  3936. if (condition(arr[read])) {
  3937. moved.push(arr[read]);
  3938. } else {
  3939. arr[write] = arr[read];
  3940. ++write;
  3941. }
  3942. }
  3943. for (var _read = 0; write < len; ++_read, ++write) {
  3944. arr[write] = moved[_read];
  3945. }
  3946. }
  3947. /***/ }),
  3948. /* 6 */
  3949. /***/ (function(module, exports, __webpack_require__) {
  3950. "use strict";
  3951. Object.defineProperty(exports, "__esModule", {
  3952. value: true
  3953. });
  3954. exports.OptionKind = exports.AppOptions = void 0;
  3955. var _viewer_compatibility = __webpack_require__(7);
  3956. 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); }
  3957. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3958. 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); } }
  3959. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3960. var OptionKind = {
  3961. VIEWER: 0x02,
  3962. API: 0x04,
  3963. WORKER: 0x08,
  3964. PREFERENCE: 0x80
  3965. };
  3966. exports.OptionKind = OptionKind;
  3967. var defaultOptions = {
  3968. cursorToolOnLoad: {
  3969. value: 0,
  3970. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3971. },
  3972. defaultUrl: {
  3973. value: "compressed.tracemonkey-pldi-09.pdf",
  3974. kind: OptionKind.VIEWER
  3975. },
  3976. defaultZoomValue: {
  3977. value: "",
  3978. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3979. },
  3980. disableHistory: {
  3981. value: false,
  3982. kind: OptionKind.VIEWER
  3983. },
  3984. disablePageLabels: {
  3985. value: false,
  3986. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3987. },
  3988. enablePermissions: {
  3989. value: false,
  3990. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3991. },
  3992. enablePrintAutoRotate: {
  3993. value: false,
  3994. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3995. },
  3996. enableWebGL: {
  3997. value: false,
  3998. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  3999. },
  4000. externalLinkRel: {
  4001. value: "noopener noreferrer nofollow",
  4002. kind: OptionKind.VIEWER
  4003. },
  4004. externalLinkTarget: {
  4005. value: 0,
  4006. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4007. },
  4008. historyUpdateUrl: {
  4009. value: false,
  4010. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4011. },
  4012. ignoreDestinationZoom: {
  4013. value: false,
  4014. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4015. },
  4016. imageResourcesPath: {
  4017. value: "./images/",
  4018. kind: OptionKind.VIEWER
  4019. },
  4020. maxCanvasPixels: {
  4021. value: 16777216,
  4022. compatibility: _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels,
  4023. kind: OptionKind.VIEWER
  4024. },
  4025. pdfBugEnabled: {
  4026. value: false,
  4027. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4028. },
  4029. printResolution: {
  4030. value: 150,
  4031. kind: OptionKind.VIEWER
  4032. },
  4033. renderer: {
  4034. value: "canvas",
  4035. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4036. },
  4037. renderInteractiveForms: {
  4038. value: true,
  4039. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4040. },
  4041. sidebarViewOnLoad: {
  4042. value: -1,
  4043. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4044. },
  4045. scrollModeOnLoad: {
  4046. value: -1,
  4047. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4048. },
  4049. spreadModeOnLoad: {
  4050. value: -1,
  4051. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4052. },
  4053. textLayerMode: {
  4054. value: 1,
  4055. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4056. },
  4057. useOnlyCssZoom: {
  4058. value: false,
  4059. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4060. },
  4061. viewOnLoad: {
  4062. value: 0,
  4063. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  4064. },
  4065. cMapPacked: {
  4066. value: true,
  4067. kind: OptionKind.API
  4068. },
  4069. cMapUrl: {
  4070. value: "../web/cmaps/",
  4071. kind: OptionKind.API
  4072. },
  4073. disableAutoFetch: {
  4074. value: false,
  4075. kind: OptionKind.API + OptionKind.PREFERENCE
  4076. },
  4077. disableFontFace: {
  4078. value: false,
  4079. kind: OptionKind.API + OptionKind.PREFERENCE
  4080. },
  4081. disableRange: {
  4082. value: false,
  4083. kind: OptionKind.API + OptionKind.PREFERENCE
  4084. },
  4085. disableStream: {
  4086. value: false,
  4087. kind: OptionKind.API + OptionKind.PREFERENCE
  4088. },
  4089. docBaseUrl: {
  4090. value: "",
  4091. kind: OptionKind.API
  4092. },
  4093. fontExtraProperties: {
  4094. value: false,
  4095. kind: OptionKind.API
  4096. },
  4097. isEvalSupported: {
  4098. value: true,
  4099. kind: OptionKind.API
  4100. },
  4101. maxImageSize: {
  4102. value: -1,
  4103. kind: OptionKind.API
  4104. },
  4105. pdfBug: {
  4106. value: false,
  4107. kind: OptionKind.API
  4108. },
  4109. verbosity: {
  4110. value: 1,
  4111. kind: OptionKind.API
  4112. },
  4113. workerPort: {
  4114. value: null,
  4115. kind: OptionKind.WORKER
  4116. },
  4117. workerSrc: {
  4118. value: "../build/pdf.worker.js",
  4119. kind: OptionKind.WORKER
  4120. }
  4121. };
  4122. {
  4123. defaultOptions.disablePreferences = {
  4124. value: false,
  4125. kind: OptionKind.VIEWER
  4126. };
  4127. defaultOptions.locale = {
  4128. value: typeof navigator !== "undefined" ? navigator.language : "en-US",
  4129. kind: OptionKind.VIEWER
  4130. };
  4131. }
  4132. var userOptions = Object.create(null);
  4133. var AppOptions = /*#__PURE__*/function () {
  4134. function AppOptions() {
  4135. _classCallCheck(this, AppOptions);
  4136. throw new Error("Cannot initialize AppOptions.");
  4137. }
  4138. _createClass(AppOptions, null, [{
  4139. key: "get",
  4140. value: function get(name) {
  4141. var userOption = userOptions[name];
  4142. if (userOption !== undefined) {
  4143. return userOption;
  4144. }
  4145. var defaultOption = defaultOptions[name];
  4146. if (defaultOption !== undefined) {
  4147. return defaultOption.compatibility || defaultOption.value;
  4148. }
  4149. return undefined;
  4150. }
  4151. }, {
  4152. key: "getAll",
  4153. value: function getAll() {
  4154. var kind = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  4155. var options = Object.create(null);
  4156. for (var name in defaultOptions) {
  4157. var defaultOption = defaultOptions[name];
  4158. if (kind) {
  4159. if ((kind & defaultOption.kind) === 0) {
  4160. continue;
  4161. }
  4162. if (kind === OptionKind.PREFERENCE) {
  4163. var value = defaultOption.value,
  4164. valueType = _typeof(value);
  4165. if (valueType === "boolean" || valueType === "string" || valueType === "number" && Number.isInteger(value)) {
  4166. options[name] = value;
  4167. continue;
  4168. }
  4169. throw new Error("Invalid type for preference: ".concat(name));
  4170. }
  4171. }
  4172. var userOption = userOptions[name];
  4173. options[name] = userOption !== undefined ? userOption : defaultOption.compatibility || defaultOption.value;
  4174. }
  4175. return options;
  4176. }
  4177. }, {
  4178. key: "set",
  4179. value: function set(name, value) {
  4180. userOptions[name] = value;
  4181. }
  4182. }, {
  4183. key: "remove",
  4184. value: function remove(name) {
  4185. delete userOptions[name];
  4186. }
  4187. }]);
  4188. return AppOptions;
  4189. }();
  4190. exports.AppOptions = AppOptions;
  4191. /***/ }),
  4192. /* 7 */
  4193. /***/ (function(module, exports, __webpack_require__) {
  4194. "use strict";
  4195. Object.defineProperty(exports, "__esModule", {
  4196. value: true
  4197. });
  4198. exports.viewerCompatibilityParams = void 0;
  4199. var compatibilityParams = Object.create(null);
  4200. {
  4201. var userAgent = typeof navigator !== "undefined" && navigator.userAgent || "";
  4202. var platform = typeof navigator !== "undefined" && navigator.platform || "";
  4203. var maxTouchPoints = typeof navigator !== "undefined" && navigator.maxTouchPoints || 1;
  4204. var isAndroid = /Android/.test(userAgent);
  4205. var isIE = /Trident/.test(userAgent);
  4206. var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" && maxTouchPoints > 1;
  4207. var isIOSChrome = /CriOS/.test(userAgent);
  4208. (function checkOnBlobSupport() {
  4209. if (isIE || isIOSChrome) {
  4210. compatibilityParams.disableCreateObjectURL = true;
  4211. }
  4212. })();
  4213. (function checkCanvasSizeLimitation() {
  4214. if (isIOS || isAndroid) {
  4215. compatibilityParams.maxCanvasPixels = 5242880;
  4216. }
  4217. })();
  4218. }
  4219. var viewerCompatibilityParams = Object.freeze(compatibilityParams);
  4220. exports.viewerCompatibilityParams = viewerCompatibilityParams;
  4221. /***/ }),
  4222. /* 8 */
  4223. /***/ (function(module, exports, __webpack_require__) {
  4224. "use strict";
  4225. var pdfjsLib;
  4226. if (typeof window !== "undefined" && window["pdfjs-dist/build/pdf"]) {
  4227. pdfjsLib = window["pdfjs-dist/build/pdf"];
  4228. } else {
  4229. pdfjsLib = require("../build/pdf.js");
  4230. }
  4231. module.exports = pdfjsLib;
  4232. /***/ }),
  4233. /* 9 */
  4234. /***/ (function(module, exports, __webpack_require__) {
  4235. "use strict";
  4236. Object.defineProperty(exports, "__esModule", {
  4237. value: true
  4238. });
  4239. exports.PDFCursorTools = exports.CursorTool = void 0;
  4240. var _grab_to_pan = __webpack_require__(10);
  4241. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4242. 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); } }
  4243. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4244. var CursorTool = {
  4245. SELECT: 0,
  4246. HAND: 1,
  4247. ZOOM: 2
  4248. };
  4249. exports.CursorTool = CursorTool;
  4250. var PDFCursorTools = /*#__PURE__*/function () {
  4251. function PDFCursorTools(_ref) {
  4252. var _this = this;
  4253. var container = _ref.container,
  4254. eventBus = _ref.eventBus,
  4255. _ref$cursorToolOnLoad = _ref.cursorToolOnLoad,
  4256. cursorToolOnLoad = _ref$cursorToolOnLoad === void 0 ? CursorTool.SELECT : _ref$cursorToolOnLoad;
  4257. _classCallCheck(this, PDFCursorTools);
  4258. this.container = container;
  4259. this.eventBus = eventBus;
  4260. this.active = CursorTool.SELECT;
  4261. this.activeBeforePresentationMode = null;
  4262. this.handTool = new _grab_to_pan.GrabToPan({
  4263. element: this.container
  4264. });
  4265. this._addEventListeners();
  4266. Promise.resolve().then(function () {
  4267. _this.switchTool(cursorToolOnLoad);
  4268. });
  4269. }
  4270. _createClass(PDFCursorTools, [{
  4271. key: "switchTool",
  4272. value: function switchTool(tool) {
  4273. var _this2 = this;
  4274. if (this.activeBeforePresentationMode !== null) {
  4275. return;
  4276. }
  4277. if (tool === this.active) {
  4278. return;
  4279. }
  4280. var disableActiveTool = function disableActiveTool() {
  4281. switch (_this2.active) {
  4282. case CursorTool.SELECT:
  4283. break;
  4284. case CursorTool.HAND:
  4285. _this2.handTool.deactivate();
  4286. break;
  4287. case CursorTool.ZOOM:
  4288. }
  4289. };
  4290. switch (tool) {
  4291. case CursorTool.SELECT:
  4292. disableActiveTool();
  4293. break;
  4294. case CursorTool.HAND:
  4295. disableActiveTool();
  4296. this.handTool.activate();
  4297. break;
  4298. case CursorTool.ZOOM:
  4299. default:
  4300. console.error("switchTool: \"".concat(tool, "\" is an unsupported value."));
  4301. return;
  4302. }
  4303. this.active = tool;
  4304. this._dispatchEvent();
  4305. }
  4306. }, {
  4307. key: "_dispatchEvent",
  4308. value: function _dispatchEvent() {
  4309. this.eventBus.dispatch("cursortoolchanged", {
  4310. source: this,
  4311. tool: this.active
  4312. });
  4313. }
  4314. }, {
  4315. key: "_addEventListeners",
  4316. value: function _addEventListeners() {
  4317. var _this3 = this;
  4318. this.eventBus._on("switchcursortool", function (evt) {
  4319. _this3.switchTool(evt.tool);
  4320. });
  4321. this.eventBus._on("presentationmodechanged", function (evt) {
  4322. if (evt.switchInProgress) {
  4323. return;
  4324. }
  4325. var previouslyActive;
  4326. if (evt.active) {
  4327. previouslyActive = _this3.active;
  4328. _this3.switchTool(CursorTool.SELECT);
  4329. _this3.activeBeforePresentationMode = previouslyActive;
  4330. } else {
  4331. previouslyActive = _this3.activeBeforePresentationMode;
  4332. _this3.activeBeforePresentationMode = null;
  4333. _this3.switchTool(previouslyActive);
  4334. }
  4335. });
  4336. }
  4337. }, {
  4338. key: "activeTool",
  4339. get: function get() {
  4340. return this.active;
  4341. }
  4342. }]);
  4343. return PDFCursorTools;
  4344. }();
  4345. exports.PDFCursorTools = PDFCursorTools;
  4346. /***/ }),
  4347. /* 10 */
  4348. /***/ (function(module, exports, __webpack_require__) {
  4349. "use strict";
  4350. Object.defineProperty(exports, "__esModule", {
  4351. value: true
  4352. });
  4353. exports.GrabToPan = GrabToPan;
  4354. function GrabToPan(options) {
  4355. this.element = options.element;
  4356. this.document = options.element.ownerDocument;
  4357. if (typeof options.ignoreTarget === "function") {
  4358. this.ignoreTarget = options.ignoreTarget;
  4359. }
  4360. this.onActiveChanged = options.onActiveChanged;
  4361. this.activate = this.activate.bind(this);
  4362. this.deactivate = this.deactivate.bind(this);
  4363. this.toggle = this.toggle.bind(this);
  4364. this._onmousedown = this._onmousedown.bind(this);
  4365. this._onmousemove = this._onmousemove.bind(this);
  4366. this._endPan = this._endPan.bind(this);
  4367. var overlay = this.overlay = document.createElement("div");
  4368. overlay.className = "grab-to-pan-grabbing";
  4369. }
  4370. GrabToPan.prototype = {
  4371. CSS_CLASS_GRAB: "grab-to-pan-grab",
  4372. activate: function GrabToPan_activate() {
  4373. if (!this.active) {
  4374. this.active = true;
  4375. this.element.addEventListener("mousedown", this._onmousedown, true);
  4376. this.element.classList.add(this.CSS_CLASS_GRAB);
  4377. if (this.onActiveChanged) {
  4378. this.onActiveChanged(true);
  4379. }
  4380. }
  4381. },
  4382. deactivate: function GrabToPan_deactivate() {
  4383. if (this.active) {
  4384. this.active = false;
  4385. this.element.removeEventListener("mousedown", this._onmousedown, true);
  4386. this._endPan();
  4387. this.element.classList.remove(this.CSS_CLASS_GRAB);
  4388. if (this.onActiveChanged) {
  4389. this.onActiveChanged(false);
  4390. }
  4391. }
  4392. },
  4393. toggle: function GrabToPan_toggle() {
  4394. if (this.active) {
  4395. this.deactivate();
  4396. } else {
  4397. this.activate();
  4398. }
  4399. },
  4400. ignoreTarget: function GrabToPan_ignoreTarget(node) {
  4401. return node[matchesSelector]("a[href], a[href] *, input, textarea, button, button *, select, option");
  4402. },
  4403. _onmousedown: function GrabToPan__onmousedown(event) {
  4404. if (event.button !== 0 || this.ignoreTarget(event.target)) {
  4405. return;
  4406. }
  4407. if (event.originalTarget) {
  4408. try {
  4409. event.originalTarget.tagName;
  4410. } catch (e) {
  4411. return;
  4412. }
  4413. }
  4414. this.scrollLeftStart = this.element.scrollLeft;
  4415. this.scrollTopStart = this.element.scrollTop;
  4416. this.clientXStart = event.clientX;
  4417. this.clientYStart = event.clientY;
  4418. this.document.addEventListener("mousemove", this._onmousemove, true);
  4419. this.document.addEventListener("mouseup", this._endPan, true);
  4420. this.element.addEventListener("scroll", this._endPan, true);
  4421. event.preventDefault();
  4422. event.stopPropagation();
  4423. var focusedElement = document.activeElement;
  4424. if (focusedElement && !focusedElement.contains(event.target)) {
  4425. focusedElement.blur();
  4426. }
  4427. },
  4428. _onmousemove: function GrabToPan__onmousemove(event) {
  4429. this.element.removeEventListener("scroll", this._endPan, true);
  4430. if (isLeftMouseReleased(event)) {
  4431. this._endPan();
  4432. return;
  4433. }
  4434. var xDiff = event.clientX - this.clientXStart;
  4435. var yDiff = event.clientY - this.clientYStart;
  4436. var scrollTop = this.scrollTopStart - yDiff;
  4437. var scrollLeft = this.scrollLeftStart - xDiff;
  4438. if (this.element.scrollTo) {
  4439. this.element.scrollTo({
  4440. top: scrollTop,
  4441. left: scrollLeft,
  4442. behavior: "instant"
  4443. });
  4444. } else {
  4445. this.element.scrollTop = scrollTop;
  4446. this.element.scrollLeft = scrollLeft;
  4447. }
  4448. if (!this.overlay.parentNode) {
  4449. document.body.appendChild(this.overlay);
  4450. }
  4451. },
  4452. _endPan: function GrabToPan__endPan() {
  4453. this.element.removeEventListener("scroll", this._endPan, true);
  4454. this.document.removeEventListener("mousemove", this._onmousemove, true);
  4455. this.document.removeEventListener("mouseup", this._endPan, true);
  4456. this.overlay.remove();
  4457. }
  4458. };
  4459. var matchesSelector;
  4460. ["webkitM", "mozM", "msM", "oM", "m"].some(function (prefix) {
  4461. var name = prefix + "atches";
  4462. if (name in document.documentElement) {
  4463. matchesSelector = name;
  4464. }
  4465. name += "Selector";
  4466. if (name in document.documentElement) {
  4467. matchesSelector = name;
  4468. }
  4469. return matchesSelector;
  4470. });
  4471. var isNotIEorIsIE10plus = !document.documentMode || document.documentMode > 9;
  4472. var chrome = window.chrome;
  4473. var isChrome15OrOpera15plus = chrome && (chrome.webstore || chrome.app);
  4474. var isSafari6plus = /Apple/.test(navigator.vendor) && /Version\/([6-9]\d*|[1-5]\d+)/.test(navigator.userAgent);
  4475. function isLeftMouseReleased(event) {
  4476. if ("buttons" in event && isNotIEorIsIE10plus) {
  4477. return !(event.buttons & 1);
  4478. }
  4479. if (isChrome15OrOpera15plus || isSafari6plus) {
  4480. return event.which === 0;
  4481. }
  4482. return false;
  4483. }
  4484. /***/ }),
  4485. /* 11 */
  4486. /***/ (function(module, exports, __webpack_require__) {
  4487. "use strict";
  4488. Object.defineProperty(exports, "__esModule", {
  4489. value: true
  4490. });
  4491. exports.PDFRenderingQueue = exports.RenderingStates = void 0;
  4492. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4493. 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); } }
  4494. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4495. var CLEANUP_TIMEOUT = 30000;
  4496. var RenderingStates = {
  4497. INITIAL: 0,
  4498. RUNNING: 1,
  4499. PAUSED: 2,
  4500. FINISHED: 3
  4501. };
  4502. exports.RenderingStates = RenderingStates;
  4503. var PDFRenderingQueue = /*#__PURE__*/function () {
  4504. function PDFRenderingQueue() {
  4505. _classCallCheck(this, PDFRenderingQueue);
  4506. this.pdfViewer = null;
  4507. this.pdfThumbnailViewer = null;
  4508. this.onIdle = null;
  4509. this.highestPriorityPage = null;
  4510. this.idleTimeout = null;
  4511. this.printing = false;
  4512. this.isThumbnailViewEnabled = false;
  4513. }
  4514. _createClass(PDFRenderingQueue, [{
  4515. key: "setViewer",
  4516. value: function setViewer(pdfViewer) {
  4517. this.pdfViewer = pdfViewer;
  4518. }
  4519. }, {
  4520. key: "setThumbnailViewer",
  4521. value: function setThumbnailViewer(pdfThumbnailViewer) {
  4522. this.pdfThumbnailViewer = pdfThumbnailViewer;
  4523. }
  4524. }, {
  4525. key: "isHighestPriority",
  4526. value: function isHighestPriority(view) {
  4527. return this.highestPriorityPage === view.renderingId;
  4528. }
  4529. }, {
  4530. key: "renderHighestPriority",
  4531. value: function renderHighestPriority(currentlyVisiblePages) {
  4532. if (this.idleTimeout) {
  4533. clearTimeout(this.idleTimeout);
  4534. this.idleTimeout = null;
  4535. }
  4536. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  4537. return;
  4538. }
  4539. if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
  4540. if (this.pdfThumbnailViewer.forceRendering()) {
  4541. return;
  4542. }
  4543. }
  4544. if (this.printing) {
  4545. return;
  4546. }
  4547. if (this.onIdle) {
  4548. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
  4549. }
  4550. }
  4551. }, {
  4552. key: "getHighestPriority",
  4553. value: function getHighestPriority(visible, views, scrolledDown) {
  4554. var visibleViews = visible.views;
  4555. var numVisible = visibleViews.length;
  4556. if (numVisible === 0) {
  4557. return null;
  4558. }
  4559. for (var i = 0; i < numVisible; ++i) {
  4560. var view = visibleViews[i].view;
  4561. if (!this.isViewFinished(view)) {
  4562. return view;
  4563. }
  4564. }
  4565. if (scrolledDown) {
  4566. var nextPageIndex = visible.last.id;
  4567. if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {
  4568. return views[nextPageIndex];
  4569. }
  4570. } else {
  4571. var previousPageIndex = visible.first.id - 2;
  4572. if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) {
  4573. return views[previousPageIndex];
  4574. }
  4575. }
  4576. return null;
  4577. }
  4578. }, {
  4579. key: "isViewFinished",
  4580. value: function isViewFinished(view) {
  4581. return view.renderingState === RenderingStates.FINISHED;
  4582. }
  4583. }, {
  4584. key: "renderView",
  4585. value: function renderView(view) {
  4586. var _this = this;
  4587. switch (view.renderingState) {
  4588. case RenderingStates.FINISHED:
  4589. return false;
  4590. case RenderingStates.PAUSED:
  4591. this.highestPriorityPage = view.renderingId;
  4592. view.resume();
  4593. break;
  4594. case RenderingStates.RUNNING:
  4595. this.highestPriorityPage = view.renderingId;
  4596. break;
  4597. case RenderingStates.INITIAL:
  4598. this.highestPriorityPage = view.renderingId;
  4599. view.draw()["finally"](function () {
  4600. _this.renderHighestPriority();
  4601. })["catch"](function (reason) {
  4602. console.error("renderView: \"".concat(reason, "\""));
  4603. });
  4604. break;
  4605. }
  4606. return true;
  4607. }
  4608. }]);
  4609. return PDFRenderingQueue;
  4610. }();
  4611. exports.PDFRenderingQueue = PDFRenderingQueue;
  4612. /***/ }),
  4613. /* 12 */
  4614. /***/ (function(module, exports, __webpack_require__) {
  4615. "use strict";
  4616. Object.defineProperty(exports, "__esModule", {
  4617. value: true
  4618. });
  4619. exports.PDFSidebar = exports.SidebarView = void 0;
  4620. var _ui_utils = __webpack_require__(5);
  4621. var _pdf_rendering_queue = __webpack_require__(11);
  4622. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4623. 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); } }
  4624. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4625. var UI_NOTIFICATION_CLASS = "pdfSidebarNotification";
  4626. var SidebarView = {
  4627. UNKNOWN: -1,
  4628. NONE: 0,
  4629. THUMBS: 1,
  4630. OUTLINE: 2,
  4631. ATTACHMENTS: 3,
  4632. LAYERS: 4
  4633. };
  4634. exports.SidebarView = SidebarView;
  4635. var PDFSidebar = /*#__PURE__*/function () {
  4636. function PDFSidebar(_ref) {
  4637. var elements = _ref.elements,
  4638. pdfViewer = _ref.pdfViewer,
  4639. pdfThumbnailViewer = _ref.pdfThumbnailViewer,
  4640. eventBus = _ref.eventBus,
  4641. _ref$l10n = _ref.l10n,
  4642. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n,
  4643. _ref$disableNotificat = _ref.disableNotification,
  4644. disableNotification = _ref$disableNotificat === void 0 ? false : _ref$disableNotificat;
  4645. _classCallCheck(this, PDFSidebar);
  4646. this.isOpen = false;
  4647. this.active = SidebarView.THUMBS;
  4648. this.isInitialViewSet = false;
  4649. this.onToggled = null;
  4650. this.pdfViewer = pdfViewer;
  4651. this.pdfThumbnailViewer = pdfThumbnailViewer;
  4652. this.outerContainer = elements.outerContainer;
  4653. this.viewerContainer = elements.viewerContainer;
  4654. this.toggleButton = elements.toggleButton;
  4655. this.thumbnailButton = elements.thumbnailButton;
  4656. this.outlineButton = elements.outlineButton;
  4657. this.attachmentsButton = elements.attachmentsButton;
  4658. this.layersButton = elements.layersButton;
  4659. this.thumbnailView = elements.thumbnailView;
  4660. this.outlineView = elements.outlineView;
  4661. this.attachmentsView = elements.attachmentsView;
  4662. this.layersView = elements.layersView;
  4663. this.eventBus = eventBus;
  4664. this.l10n = l10n;
  4665. this._disableNotification = disableNotification;
  4666. this._addEventListeners();
  4667. }
  4668. _createClass(PDFSidebar, [{
  4669. key: "reset",
  4670. value: function reset() {
  4671. this.isInitialViewSet = false;
  4672. this._hideUINotification(null);
  4673. this.switchView(SidebarView.THUMBS);
  4674. this.outlineButton.disabled = false;
  4675. this.attachmentsButton.disabled = false;
  4676. this.layersButton.disabled = false;
  4677. }
  4678. }, {
  4679. key: "setInitialView",
  4680. value: function setInitialView() {
  4681. var view = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : SidebarView.NONE;
  4682. if (this.isInitialViewSet) {
  4683. return;
  4684. }
  4685. this.isInitialViewSet = true;
  4686. if (view === SidebarView.NONE || view === SidebarView.UNKNOWN) {
  4687. this._dispatchEvent();
  4688. return;
  4689. }
  4690. if (!this._switchView(view, true)) {
  4691. this._dispatchEvent();
  4692. }
  4693. }
  4694. }, {
  4695. key: "switchView",
  4696. value: function switchView(view) {
  4697. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4698. this._switchView(view, forceOpen);
  4699. }
  4700. }, {
  4701. key: "_switchView",
  4702. value: function _switchView(view) {
  4703. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4704. var isViewChanged = view !== this.active;
  4705. var shouldForceRendering = false;
  4706. switch (view) {
  4707. case SidebarView.NONE:
  4708. if (this.isOpen) {
  4709. this.close();
  4710. return true;
  4711. }
  4712. return false;
  4713. case SidebarView.THUMBS:
  4714. if (this.isOpen && isViewChanged) {
  4715. shouldForceRendering = true;
  4716. }
  4717. break;
  4718. case SidebarView.OUTLINE:
  4719. if (this.outlineButton.disabled) {
  4720. return false;
  4721. }
  4722. break;
  4723. case SidebarView.ATTACHMENTS:
  4724. if (this.attachmentsButton.disabled) {
  4725. return false;
  4726. }
  4727. break;
  4728. case SidebarView.LAYERS:
  4729. if (this.layersButton.disabled) {
  4730. return false;
  4731. }
  4732. break;
  4733. default:
  4734. console.error("PDFSidebar._switchView: \"".concat(view, "\" is not a valid view."));
  4735. return false;
  4736. }
  4737. this.active = view;
  4738. this.thumbnailButton.classList.toggle("toggled", view === SidebarView.THUMBS);
  4739. this.outlineButton.classList.toggle("toggled", view === SidebarView.OUTLINE);
  4740. this.attachmentsButton.classList.toggle("toggled", view === SidebarView.ATTACHMENTS);
  4741. this.layersButton.classList.toggle("toggled", view === SidebarView.LAYERS);
  4742. this.thumbnailView.classList.toggle("hidden", view !== SidebarView.THUMBS);
  4743. this.outlineView.classList.toggle("hidden", view !== SidebarView.OUTLINE);
  4744. this.attachmentsView.classList.toggle("hidden", view !== SidebarView.ATTACHMENTS);
  4745. this.layersView.classList.toggle("hidden", view !== SidebarView.LAYERS);
  4746. if (forceOpen && !this.isOpen) {
  4747. this.open();
  4748. return true;
  4749. }
  4750. if (shouldForceRendering) {
  4751. this._updateThumbnailViewer();
  4752. this._forceRendering();
  4753. }
  4754. if (isViewChanged) {
  4755. this._dispatchEvent();
  4756. }
  4757. this._hideUINotification(this.active);
  4758. return isViewChanged;
  4759. }
  4760. }, {
  4761. key: "open",
  4762. value: function open() {
  4763. if (this.isOpen) {
  4764. return;
  4765. }
  4766. this.isOpen = true;
  4767. this.toggleButton.classList.add("toggled");
  4768. this.outerContainer.classList.add("sidebarMoving", "sidebarOpen");
  4769. if (this.active === SidebarView.THUMBS) {
  4770. this._updateThumbnailViewer();
  4771. }
  4772. this._forceRendering();
  4773. this._dispatchEvent();
  4774. this._hideUINotification(this.active);
  4775. }
  4776. }, {
  4777. key: "close",
  4778. value: function close() {
  4779. if (!this.isOpen) {
  4780. return;
  4781. }
  4782. this.isOpen = false;
  4783. this.toggleButton.classList.remove("toggled");
  4784. this.outerContainer.classList.add("sidebarMoving");
  4785. this.outerContainer.classList.remove("sidebarOpen");
  4786. this._forceRendering();
  4787. this._dispatchEvent();
  4788. }
  4789. }, {
  4790. key: "toggle",
  4791. value: function toggle() {
  4792. if (this.isOpen) {
  4793. this.close();
  4794. } else {
  4795. this.open();
  4796. }
  4797. }
  4798. }, {
  4799. key: "_dispatchEvent",
  4800. value: function _dispatchEvent() {
  4801. this.eventBus.dispatch("sidebarviewchanged", {
  4802. source: this,
  4803. view: this.visibleView
  4804. });
  4805. }
  4806. }, {
  4807. key: "_forceRendering",
  4808. value: function _forceRendering() {
  4809. if (this.onToggled) {
  4810. this.onToggled();
  4811. } else {
  4812. this.pdfViewer.forceRendering();
  4813. this.pdfThumbnailViewer.forceRendering();
  4814. }
  4815. }
  4816. }, {
  4817. key: "_updateThumbnailViewer",
  4818. value: function _updateThumbnailViewer() {
  4819. var pdfViewer = this.pdfViewer,
  4820. pdfThumbnailViewer = this.pdfThumbnailViewer;
  4821. var pagesCount = pdfViewer.pagesCount;
  4822. for (var pageIndex = 0; pageIndex < pagesCount; pageIndex++) {
  4823. var pageView = pdfViewer.getPageView(pageIndex);
  4824. if (pageView && pageView.renderingState === _pdf_rendering_queue.RenderingStates.FINISHED) {
  4825. var thumbnailView = pdfThumbnailViewer.getThumbnail(pageIndex);
  4826. thumbnailView.setImage(pageView);
  4827. }
  4828. }
  4829. pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
  4830. }
  4831. }, {
  4832. key: "_showUINotification",
  4833. value: function _showUINotification(view) {
  4834. var _this = this;
  4835. if (this._disableNotification) {
  4836. return;
  4837. }
  4838. this.l10n.get("toggle_sidebar_notification2.title", null, "Toggle Sidebar (document contains outline/attachments/layers)").then(function (msg) {
  4839. _this.toggleButton.title = msg;
  4840. });
  4841. if (!this.isOpen) {
  4842. this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
  4843. } else if (view === this.active) {
  4844. return;
  4845. }
  4846. switch (view) {
  4847. case SidebarView.OUTLINE:
  4848. this.outlineButton.classList.add(UI_NOTIFICATION_CLASS);
  4849. break;
  4850. case SidebarView.ATTACHMENTS:
  4851. this.attachmentsButton.classList.add(UI_NOTIFICATION_CLASS);
  4852. break;
  4853. case SidebarView.LAYERS:
  4854. this.layersButton.classList.add(UI_NOTIFICATION_CLASS);
  4855. break;
  4856. }
  4857. }
  4858. }, {
  4859. key: "_hideUINotification",
  4860. value: function _hideUINotification(view) {
  4861. var _this2 = this;
  4862. if (this._disableNotification) {
  4863. return;
  4864. }
  4865. var removeNotification = function removeNotification(sidebarView) {
  4866. switch (sidebarView) {
  4867. case SidebarView.OUTLINE:
  4868. _this2.outlineButton.classList.remove(UI_NOTIFICATION_CLASS);
  4869. break;
  4870. case SidebarView.ATTACHMENTS:
  4871. _this2.attachmentsButton.classList.remove(UI_NOTIFICATION_CLASS);
  4872. break;
  4873. case SidebarView.LAYERS:
  4874. _this2.layersButton.classList.remove(UI_NOTIFICATION_CLASS);
  4875. break;
  4876. }
  4877. };
  4878. if (!this.isOpen && view !== null) {
  4879. return;
  4880. }
  4881. this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
  4882. if (view !== null) {
  4883. removeNotification(view);
  4884. return;
  4885. }
  4886. for (view in SidebarView) {
  4887. removeNotification(SidebarView[view]);
  4888. }
  4889. this.l10n.get("toggle_sidebar.title", null, "Toggle Sidebar").then(function (msg) {
  4890. _this2.toggleButton.title = msg;
  4891. });
  4892. }
  4893. }, {
  4894. key: "_addEventListeners",
  4895. value: function _addEventListeners() {
  4896. var _this3 = this;
  4897. this.viewerContainer.addEventListener("transitionend", function (evt) {
  4898. if (evt.target === _this3.viewerContainer) {
  4899. _this3.outerContainer.classList.remove("sidebarMoving");
  4900. }
  4901. });
  4902. this.toggleButton.addEventListener("click", function () {
  4903. _this3.toggle();
  4904. });
  4905. this.thumbnailButton.addEventListener("click", function () {
  4906. _this3.switchView(SidebarView.THUMBS);
  4907. });
  4908. this.outlineButton.addEventListener("click", function () {
  4909. _this3.switchView(SidebarView.OUTLINE);
  4910. });
  4911. this.outlineButton.addEventListener("dblclick", function () {
  4912. _this3.eventBus.dispatch("toggleoutlinetree", {
  4913. source: _this3
  4914. });
  4915. });
  4916. this.attachmentsButton.addEventListener("click", function () {
  4917. _this3.switchView(SidebarView.ATTACHMENTS);
  4918. });
  4919. this.layersButton.addEventListener("click", function () {
  4920. _this3.switchView(SidebarView.LAYERS);
  4921. });
  4922. this.layersButton.addEventListener("dblclick", function () {
  4923. _this3.eventBus.dispatch("resetlayers", {
  4924. source: _this3
  4925. });
  4926. });
  4927. var onTreeLoaded = function onTreeLoaded(count, button, view) {
  4928. button.disabled = !count;
  4929. if (count) {
  4930. _this3._showUINotification(view);
  4931. } else if (_this3.active === view) {
  4932. _this3.switchView(SidebarView.THUMBS);
  4933. }
  4934. };
  4935. this.eventBus._on("outlineloaded", function (evt) {
  4936. onTreeLoaded(evt.outlineCount, _this3.outlineButton, SidebarView.OUTLINE);
  4937. });
  4938. this.eventBus._on("attachmentsloaded", function (evt) {
  4939. onTreeLoaded(evt.attachmentsCount, _this3.attachmentsButton, SidebarView.ATTACHMENTS);
  4940. });
  4941. this.eventBus._on("layersloaded", function (evt) {
  4942. onTreeLoaded(evt.layersCount, _this3.layersButton, SidebarView.LAYERS);
  4943. });
  4944. this.eventBus._on("presentationmodechanged", function (evt) {
  4945. if (!evt.active && !evt.switchInProgress && _this3.isThumbnailViewVisible) {
  4946. _this3._updateThumbnailViewer();
  4947. }
  4948. });
  4949. }
  4950. }, {
  4951. key: "visibleView",
  4952. get: function get() {
  4953. return this.isOpen ? this.active : SidebarView.NONE;
  4954. }
  4955. }, {
  4956. key: "isThumbnailViewVisible",
  4957. get: function get() {
  4958. return this.isOpen && this.active === SidebarView.THUMBS;
  4959. }
  4960. }, {
  4961. key: "isOutlineViewVisible",
  4962. get: function get() {
  4963. return this.isOpen && this.active === SidebarView.OUTLINE;
  4964. }
  4965. }, {
  4966. key: "isAttachmentsViewVisible",
  4967. get: function get() {
  4968. return this.isOpen && this.active === SidebarView.ATTACHMENTS;
  4969. }
  4970. }, {
  4971. key: "isLayersViewVisible",
  4972. get: function get() {
  4973. return this.isOpen && this.active === SidebarView.LAYERS;
  4974. }
  4975. }]);
  4976. return PDFSidebar;
  4977. }();
  4978. exports.PDFSidebar = PDFSidebar;
  4979. /***/ }),
  4980. /* 13 */
  4981. /***/ (function(module, exports, __webpack_require__) {
  4982. "use strict";
  4983. Object.defineProperty(exports, "__esModule", {
  4984. value: true
  4985. });
  4986. exports.OverlayManager = void 0;
  4987. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  4988. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  4989. 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); } }
  4990. 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); }); }; }
  4991. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4992. 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); } }
  4993. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4994. var OverlayManager = /*#__PURE__*/function () {
  4995. function OverlayManager() {
  4996. _classCallCheck(this, OverlayManager);
  4997. this._overlays = {};
  4998. this._active = null;
  4999. this._keyDownBound = this._keyDown.bind(this);
  5000. }
  5001. _createClass(OverlayManager, [{
  5002. key: "register",
  5003. value: function () {
  5004. var _register = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(name, element) {
  5005. var callerCloseMethod,
  5006. canForceClose,
  5007. container,
  5008. _args = arguments;
  5009. return _regenerator["default"].wrap(function _callee$(_context) {
  5010. while (1) {
  5011. switch (_context.prev = _context.next) {
  5012. case 0:
  5013. callerCloseMethod = _args.length > 2 && _args[2] !== undefined ? _args[2] : null;
  5014. canForceClose = _args.length > 3 && _args[3] !== undefined ? _args[3] : false;
  5015. if (!(!name || !element || !(container = element.parentNode))) {
  5016. _context.next = 6;
  5017. break;
  5018. }
  5019. throw new Error("Not enough parameters.");
  5020. case 6:
  5021. if (!this._overlays[name]) {
  5022. _context.next = 8;
  5023. break;
  5024. }
  5025. throw new Error("The overlay is already registered.");
  5026. case 8:
  5027. this._overlays[name] = {
  5028. element: element,
  5029. container: container,
  5030. callerCloseMethod: callerCloseMethod,
  5031. canForceClose: canForceClose
  5032. };
  5033. case 9:
  5034. case "end":
  5035. return _context.stop();
  5036. }
  5037. }
  5038. }, _callee, this);
  5039. }));
  5040. function register(_x, _x2) {
  5041. return _register.apply(this, arguments);
  5042. }
  5043. return register;
  5044. }()
  5045. }, {
  5046. key: "unregister",
  5047. value: function () {
  5048. var _unregister = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(name) {
  5049. return _regenerator["default"].wrap(function _callee2$(_context2) {
  5050. while (1) {
  5051. switch (_context2.prev = _context2.next) {
  5052. case 0:
  5053. if (this._overlays[name]) {
  5054. _context2.next = 4;
  5055. break;
  5056. }
  5057. throw new Error("The overlay does not exist.");
  5058. case 4:
  5059. if (!(this._active === name)) {
  5060. _context2.next = 6;
  5061. break;
  5062. }
  5063. throw new Error("The overlay cannot be removed while it is active.");
  5064. case 6:
  5065. delete this._overlays[name];
  5066. case 7:
  5067. case "end":
  5068. return _context2.stop();
  5069. }
  5070. }
  5071. }, _callee2, this);
  5072. }));
  5073. function unregister(_x3) {
  5074. return _unregister.apply(this, arguments);
  5075. }
  5076. return unregister;
  5077. }()
  5078. }, {
  5079. key: "open",
  5080. value: function () {
  5081. var _open = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(name) {
  5082. return _regenerator["default"].wrap(function _callee3$(_context3) {
  5083. while (1) {
  5084. switch (_context3.prev = _context3.next) {
  5085. case 0:
  5086. if (this._overlays[name]) {
  5087. _context3.next = 4;
  5088. break;
  5089. }
  5090. throw new Error("The overlay does not exist.");
  5091. case 4:
  5092. if (!this._active) {
  5093. _context3.next = 14;
  5094. break;
  5095. }
  5096. if (!this._overlays[name].canForceClose) {
  5097. _context3.next = 9;
  5098. break;
  5099. }
  5100. this._closeThroughCaller();
  5101. _context3.next = 14;
  5102. break;
  5103. case 9:
  5104. if (!(this._active === name)) {
  5105. _context3.next = 13;
  5106. break;
  5107. }
  5108. throw new Error("The overlay is already active.");
  5109. case 13:
  5110. throw new Error("Another overlay is currently active.");
  5111. case 14:
  5112. this._active = name;
  5113. this._overlays[this._active].element.classList.remove("hidden");
  5114. this._overlays[this._active].container.classList.remove("hidden");
  5115. window.addEventListener("keydown", this._keyDownBound);
  5116. case 18:
  5117. case "end":
  5118. return _context3.stop();
  5119. }
  5120. }
  5121. }, _callee3, this);
  5122. }));
  5123. function open(_x4) {
  5124. return _open.apply(this, arguments);
  5125. }
  5126. return open;
  5127. }()
  5128. }, {
  5129. key: "close",
  5130. value: function () {
  5131. var _close = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(name) {
  5132. return _regenerator["default"].wrap(function _callee4$(_context4) {
  5133. while (1) {
  5134. switch (_context4.prev = _context4.next) {
  5135. case 0:
  5136. if (this._overlays[name]) {
  5137. _context4.next = 4;
  5138. break;
  5139. }
  5140. throw new Error("The overlay does not exist.");
  5141. case 4:
  5142. if (this._active) {
  5143. _context4.next = 8;
  5144. break;
  5145. }
  5146. throw new Error("The overlay is currently not active.");
  5147. case 8:
  5148. if (!(this._active !== name)) {
  5149. _context4.next = 10;
  5150. break;
  5151. }
  5152. throw new Error("Another overlay is currently active.");
  5153. case 10:
  5154. this._overlays[this._active].container.classList.add("hidden");
  5155. this._overlays[this._active].element.classList.add("hidden");
  5156. this._active = null;
  5157. window.removeEventListener("keydown", this._keyDownBound);
  5158. case 14:
  5159. case "end":
  5160. return _context4.stop();
  5161. }
  5162. }
  5163. }, _callee4, this);
  5164. }));
  5165. function close(_x5) {
  5166. return _close.apply(this, arguments);
  5167. }
  5168. return close;
  5169. }()
  5170. }, {
  5171. key: "_keyDown",
  5172. value: function _keyDown(evt) {
  5173. if (this._active && evt.keyCode === 27) {
  5174. this._closeThroughCaller();
  5175. evt.preventDefault();
  5176. }
  5177. }
  5178. }, {
  5179. key: "_closeThroughCaller",
  5180. value: function _closeThroughCaller() {
  5181. if (this._overlays[this._active].callerCloseMethod) {
  5182. this._overlays[this._active].callerCloseMethod();
  5183. }
  5184. if (this._active) {
  5185. this.close(this._active);
  5186. }
  5187. }
  5188. }, {
  5189. key: "active",
  5190. get: function get() {
  5191. return this._active;
  5192. }
  5193. }]);
  5194. return OverlayManager;
  5195. }();
  5196. exports.OverlayManager = OverlayManager;
  5197. /***/ }),
  5198. /* 14 */
  5199. /***/ (function(module, exports, __webpack_require__) {
  5200. "use strict";
  5201. Object.defineProperty(exports, "__esModule", {
  5202. value: true
  5203. });
  5204. exports.PasswordPrompt = void 0;
  5205. var _ui_utils = __webpack_require__(5);
  5206. var _pdfjsLib = __webpack_require__(8);
  5207. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5208. 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); } }
  5209. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5210. var PasswordPrompt = /*#__PURE__*/function () {
  5211. function PasswordPrompt(options, overlayManager) {
  5212. var _this = this;
  5213. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  5214. _classCallCheck(this, PasswordPrompt);
  5215. this.overlayName = options.overlayName;
  5216. this.container = options.container;
  5217. this.label = options.label;
  5218. this.input = options.input;
  5219. this.submitButton = options.submitButton;
  5220. this.cancelButton = options.cancelButton;
  5221. this.overlayManager = overlayManager;
  5222. this.l10n = l10n;
  5223. this.updateCallback = null;
  5224. this.reason = null;
  5225. this.submitButton.addEventListener("click", this.verify.bind(this));
  5226. this.cancelButton.addEventListener("click", this.close.bind(this));
  5227. this.input.addEventListener("keydown", function (e) {
  5228. if (e.keyCode === 13) {
  5229. _this.verify();
  5230. }
  5231. });
  5232. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this), true);
  5233. }
  5234. _createClass(PasswordPrompt, [{
  5235. key: "open",
  5236. value: function open() {
  5237. var _this2 = this;
  5238. this.overlayManager.open(this.overlayName).then(function () {
  5239. _this2.input.focus();
  5240. var promptString;
  5241. if (_this2.reason === _pdfjsLib.PasswordResponses.INCORRECT_PASSWORD) {
  5242. promptString = _this2.l10n.get("password_invalid", null, "Invalid password. Please try again.");
  5243. } else {
  5244. promptString = _this2.l10n.get("password_label", null, "Enter the password to open this PDF file.");
  5245. }
  5246. promptString.then(function (msg) {
  5247. _this2.label.textContent = msg;
  5248. });
  5249. });
  5250. }
  5251. }, {
  5252. key: "close",
  5253. value: function close() {
  5254. var _this3 = this;
  5255. this.overlayManager.close(this.overlayName).then(function () {
  5256. _this3.input.value = "";
  5257. });
  5258. }
  5259. }, {
  5260. key: "verify",
  5261. value: function verify() {
  5262. var password = this.input.value;
  5263. if (password && password.length > 0) {
  5264. this.close();
  5265. this.updateCallback(password);
  5266. }
  5267. }
  5268. }, {
  5269. key: "setUpdateCallback",
  5270. value: function setUpdateCallback(updateCallback, reason) {
  5271. this.updateCallback = updateCallback;
  5272. this.reason = reason;
  5273. }
  5274. }]);
  5275. return PasswordPrompt;
  5276. }();
  5277. exports.PasswordPrompt = PasswordPrompt;
  5278. /***/ }),
  5279. /* 15 */
  5280. /***/ (function(module, exports, __webpack_require__) {
  5281. "use strict";
  5282. Object.defineProperty(exports, "__esModule", {
  5283. value: true
  5284. });
  5285. exports.PDFAttachmentViewer = void 0;
  5286. var _pdfjsLib = __webpack_require__(8);
  5287. var _base_tree_viewer = __webpack_require__(16);
  5288. var _viewer_compatibility = __webpack_require__(7);
  5289. 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); }
  5290. 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; } } }; }
  5291. 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); }
  5292. 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; }
  5293. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5294. 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); } }
  5295. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5296. 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); }
  5297. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  5298. 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); }
  5299. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  5300. 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); }; }
  5301. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  5302. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  5303. 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; } }
  5304. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  5305. var PdfFileRegExp = /\.pdf$/i;
  5306. var PDFAttachmentViewer = /*#__PURE__*/function (_BaseTreeViewer) {
  5307. _inherits(PDFAttachmentViewer, _BaseTreeViewer);
  5308. var _super = _createSuper(PDFAttachmentViewer);
  5309. function PDFAttachmentViewer(options) {
  5310. var _this;
  5311. _classCallCheck(this, PDFAttachmentViewer);
  5312. _this = _super.call(this, options);
  5313. _this.downloadManager = options.downloadManager;
  5314. _this.eventBus._on("fileattachmentannotation", _this._appendAttachment.bind(_assertThisInitialized(_this)));
  5315. return _this;
  5316. }
  5317. _createClass(PDFAttachmentViewer, [{
  5318. key: "reset",
  5319. value: function reset() {
  5320. var keepRenderedCapability = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5321. _get(_getPrototypeOf(PDFAttachmentViewer.prototype), "reset", this).call(this);
  5322. this._attachments = null;
  5323. if (!keepRenderedCapability) {
  5324. this._renderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  5325. }
  5326. if (this._pendingDispatchEvent) {
  5327. clearTimeout(this._pendingDispatchEvent);
  5328. }
  5329. this._pendingDispatchEvent = null;
  5330. }
  5331. }, {
  5332. key: "_dispatchEvent",
  5333. value: function _dispatchEvent(attachmentsCount) {
  5334. var _this2 = this;
  5335. this._renderedCapability.resolve();
  5336. if (this._pendingDispatchEvent) {
  5337. clearTimeout(this._pendingDispatchEvent);
  5338. this._pendingDispatchEvent = null;
  5339. }
  5340. if (attachmentsCount === 0) {
  5341. this._pendingDispatchEvent = setTimeout(function () {
  5342. _this2.eventBus.dispatch("attachmentsloaded", {
  5343. source: _this2,
  5344. attachmentsCount: 0
  5345. });
  5346. _this2._pendingDispatchEvent = null;
  5347. });
  5348. return;
  5349. }
  5350. this.eventBus.dispatch("attachmentsloaded", {
  5351. source: this,
  5352. attachmentsCount: attachmentsCount
  5353. });
  5354. }
  5355. }, {
  5356. key: "_bindPdfLink",
  5357. value: function _bindPdfLink(element, _ref) {
  5358. var _this3 = this;
  5359. var content = _ref.content,
  5360. filename = _ref.filename;
  5361. var blobUrl;
  5362. element.onclick = function () {
  5363. if (!blobUrl) {
  5364. blobUrl = URL.createObjectURL(new Blob([content], {
  5365. type: "application/pdf"
  5366. }));
  5367. }
  5368. var viewerUrl;
  5369. viewerUrl = "?file=" + encodeURIComponent(blobUrl + "#" + filename);
  5370. try {
  5371. window.open(viewerUrl);
  5372. } catch (ex) {
  5373. console.error("_bindPdfLink: ".concat(ex));
  5374. URL.revokeObjectURL(blobUrl);
  5375. blobUrl = null;
  5376. _this3.downloadManager.downloadData(content, filename, "application/pdf");
  5377. }
  5378. return false;
  5379. };
  5380. }
  5381. }, {
  5382. key: "_bindLink",
  5383. value: function _bindLink(element, _ref2) {
  5384. var _this4 = this;
  5385. var content = _ref2.content,
  5386. filename = _ref2.filename;
  5387. element.onclick = function () {
  5388. var contentType = PdfFileRegExp.test(filename) ? "application/pdf" : "";
  5389. _this4.downloadManager.downloadData(content, filename, contentType);
  5390. return false;
  5391. };
  5392. }
  5393. }, {
  5394. key: "render",
  5395. value: function render(_ref3) {
  5396. var attachments = _ref3.attachments,
  5397. _ref3$keepRenderedCap = _ref3.keepRenderedCapability,
  5398. keepRenderedCapability = _ref3$keepRenderedCap === void 0 ? false : _ref3$keepRenderedCap;
  5399. if (this._attachments) {
  5400. this.reset(keepRenderedCapability);
  5401. }
  5402. this._attachments = attachments || null;
  5403. if (!attachments) {
  5404. this._dispatchEvent(0);
  5405. return;
  5406. }
  5407. var names = Object.keys(attachments).sort(function (a, b) {
  5408. return a.toLowerCase().localeCompare(b.toLowerCase());
  5409. });
  5410. var fragment = document.createDocumentFragment();
  5411. var attachmentsCount = 0;
  5412. var _iterator = _createForOfIteratorHelper(names),
  5413. _step;
  5414. try {
  5415. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  5416. var name = _step.value;
  5417. var item = attachments[name];
  5418. var filename = (0, _pdfjsLib.getFilenameFromUrl)(item.filename);
  5419. var div = document.createElement("div");
  5420. div.className = "treeItem";
  5421. var element = document.createElement("a");
  5422. if (PdfFileRegExp.test(filename) && !_viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL) {
  5423. this._bindPdfLink(element, {
  5424. content: item.content,
  5425. filename: filename
  5426. });
  5427. } else {
  5428. this._bindLink(element, {
  5429. content: item.content,
  5430. filename: filename
  5431. });
  5432. }
  5433. element.textContent = this._normalizeTextContent(filename);
  5434. div.appendChild(element);
  5435. fragment.appendChild(div);
  5436. attachmentsCount++;
  5437. }
  5438. } catch (err) {
  5439. _iterator.e(err);
  5440. } finally {
  5441. _iterator.f();
  5442. }
  5443. this.container.appendChild(fragment);
  5444. this._dispatchEvent(attachmentsCount);
  5445. }
  5446. }, {
  5447. key: "_appendAttachment",
  5448. value: function _appendAttachment(_ref4) {
  5449. var _this5 = this;
  5450. var id = _ref4.id,
  5451. filename = _ref4.filename,
  5452. content = _ref4.content;
  5453. var renderedPromise = this._renderedCapability.promise;
  5454. renderedPromise.then(function () {
  5455. if (renderedPromise !== _this5._renderedCapability.promise) {
  5456. return;
  5457. }
  5458. var attachments = _this5._attachments;
  5459. if (!attachments) {
  5460. attachments = Object.create(null);
  5461. } else {
  5462. for (var name in attachments) {
  5463. if (id === name) {
  5464. return;
  5465. }
  5466. }
  5467. }
  5468. attachments[id] = {
  5469. filename: filename,
  5470. content: content
  5471. };
  5472. _this5.render({
  5473. attachments: attachments,
  5474. keepRenderedCapability: true
  5475. });
  5476. });
  5477. }
  5478. }]);
  5479. return PDFAttachmentViewer;
  5480. }(_base_tree_viewer.BaseTreeViewer);
  5481. exports.PDFAttachmentViewer = PDFAttachmentViewer;
  5482. /***/ }),
  5483. /* 16 */
  5484. /***/ (function(module, exports, __webpack_require__) {
  5485. "use strict";
  5486. Object.defineProperty(exports, "__esModule", {
  5487. value: true
  5488. });
  5489. exports.BaseTreeViewer = void 0;
  5490. var _pdfjsLib = __webpack_require__(8);
  5491. 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; } } }; }
  5492. 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); }
  5493. 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; }
  5494. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5495. 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); } }
  5496. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5497. var BaseTreeViewer = /*#__PURE__*/function () {
  5498. function BaseTreeViewer(options) {
  5499. _classCallCheck(this, BaseTreeViewer);
  5500. if (this.constructor === BaseTreeViewer) {
  5501. throw new Error("Cannot initialize BaseTreeViewer.");
  5502. }
  5503. this.container = options.container;
  5504. this.eventBus = options.eventBus;
  5505. this.reset();
  5506. }
  5507. _createClass(BaseTreeViewer, [{
  5508. key: "reset",
  5509. value: function reset() {
  5510. this._lastToggleIsShow = true;
  5511. this.container.textContent = "";
  5512. this.container.classList.remove("treeWithDeepNesting");
  5513. }
  5514. }, {
  5515. key: "_dispatchEvent",
  5516. value: function _dispatchEvent(count) {
  5517. throw new Error("Not implemented: _dispatchEvent");
  5518. }
  5519. }, {
  5520. key: "_bindLink",
  5521. value: function _bindLink(element, params) {
  5522. throw new Error("Not implemented: _bindLink");
  5523. }
  5524. }, {
  5525. key: "_normalizeTextContent",
  5526. value: function _normalizeTextContent(str) {
  5527. return (0, _pdfjsLib.removeNullCharacters)(str) || "\u2013";
  5528. }
  5529. }, {
  5530. key: "_addToggleButton",
  5531. value: function _addToggleButton(div) {
  5532. var _this = this;
  5533. var hidden = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  5534. var toggler = document.createElement("div");
  5535. toggler.className = "treeItemToggler";
  5536. if (hidden) {
  5537. toggler.classList.add("treeItemsHidden");
  5538. }
  5539. toggler.onclick = function (evt) {
  5540. evt.stopPropagation();
  5541. toggler.classList.toggle("treeItemsHidden");
  5542. if (evt.shiftKey) {
  5543. var shouldShowAll = !toggler.classList.contains("treeItemsHidden");
  5544. _this._toggleTreeItem(div, shouldShowAll);
  5545. }
  5546. };
  5547. div.insertBefore(toggler, div.firstChild);
  5548. }
  5549. }, {
  5550. key: "_toggleTreeItem",
  5551. value: function _toggleTreeItem(root) {
  5552. var show = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  5553. this._lastToggleIsShow = show;
  5554. var _iterator = _createForOfIteratorHelper(root.querySelectorAll(".treeItemToggler")),
  5555. _step;
  5556. try {
  5557. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  5558. var toggler = _step.value;
  5559. toggler.classList.toggle("treeItemsHidden", !show);
  5560. }
  5561. } catch (err) {
  5562. _iterator.e(err);
  5563. } finally {
  5564. _iterator.f();
  5565. }
  5566. }
  5567. }, {
  5568. key: "_toggleAllTreeItems",
  5569. value: function _toggleAllTreeItems() {
  5570. this._toggleTreeItem(this.container, !this._lastToggleIsShow);
  5571. }
  5572. }, {
  5573. key: "render",
  5574. value: function render(params) {
  5575. throw new Error("Not implemented: render");
  5576. }
  5577. }]);
  5578. return BaseTreeViewer;
  5579. }();
  5580. exports.BaseTreeViewer = BaseTreeViewer;
  5581. /***/ }),
  5582. /* 17 */
  5583. /***/ (function(module, exports, __webpack_require__) {
  5584. "use strict";
  5585. Object.defineProperty(exports, "__esModule", {
  5586. value: true
  5587. });
  5588. exports.PDFDocumentProperties = void 0;
  5589. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  5590. var _pdfjsLib = __webpack_require__(8);
  5591. var _ui_utils = __webpack_require__(5);
  5592. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5593. 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); } }
  5594. 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); }); }; }
  5595. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  5596. 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."); }
  5597. 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); }
  5598. 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; }
  5599. 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; }
  5600. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  5601. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5602. 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); } }
  5603. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5604. var DEFAULT_FIELD_CONTENT = "-";
  5605. var NON_METRIC_LOCALES = ["en-us", "en-lr", "my"];
  5606. var US_PAGE_NAMES = {
  5607. "8.5x11": "Letter",
  5608. "8.5x14": "Legal"
  5609. };
  5610. var METRIC_PAGE_NAMES = {
  5611. "297x420": "A3",
  5612. "210x297": "A4"
  5613. };
  5614. function getPageName(size, isPortrait, pageNames) {
  5615. var width = isPortrait ? size.width : size.height;
  5616. var height = isPortrait ? size.height : size.width;
  5617. return pageNames["".concat(width, "x").concat(height)];
  5618. }
  5619. var PDFDocumentProperties = /*#__PURE__*/function () {
  5620. function PDFDocumentProperties(_ref, overlayManager, eventBus) {
  5621. var _this = this;
  5622. var overlayName = _ref.overlayName,
  5623. fields = _ref.fields,
  5624. container = _ref.container,
  5625. closeButton = _ref.closeButton;
  5626. var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
  5627. _classCallCheck(this, PDFDocumentProperties);
  5628. this.overlayName = overlayName;
  5629. this.fields = fields;
  5630. this.container = container;
  5631. this.overlayManager = overlayManager;
  5632. this.l10n = l10n;
  5633. this._reset();
  5634. closeButton.addEventListener("click", this.close.bind(this));
  5635. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this));
  5636. eventBus._on("pagechanging", function (evt) {
  5637. _this._currentPageNumber = evt.pageNumber;
  5638. });
  5639. eventBus._on("rotationchanging", function (evt) {
  5640. _this._pagesRotation = evt.pagesRotation;
  5641. });
  5642. this._isNonMetricLocale = true;
  5643. l10n.getLanguage().then(function (locale) {
  5644. _this._isNonMetricLocale = NON_METRIC_LOCALES.includes(locale);
  5645. });
  5646. }
  5647. _createClass(PDFDocumentProperties, [{
  5648. key: "open",
  5649. value: function open() {
  5650. var _this2 = this;
  5651. var freezeFieldData = function freezeFieldData(data) {
  5652. Object.defineProperty(_this2, "fieldData", {
  5653. value: Object.freeze(data),
  5654. writable: false,
  5655. enumerable: true,
  5656. configurable: true
  5657. });
  5658. };
  5659. Promise.all([this.overlayManager.open(this.overlayName), this._dataAvailableCapability.promise]).then(function () {
  5660. var currentPageNumber = _this2._currentPageNumber;
  5661. var pagesRotation = _this2._pagesRotation;
  5662. if (_this2.fieldData && currentPageNumber === _this2.fieldData._currentPageNumber && pagesRotation === _this2.fieldData._pagesRotation) {
  5663. _this2._updateUI();
  5664. return;
  5665. }
  5666. _this2.pdfDocument.getMetadata().then(function (_ref2) {
  5667. var info = _ref2.info,
  5668. metadata = _ref2.metadata,
  5669. contentDispositionFilename = _ref2.contentDispositionFilename;
  5670. return Promise.all([info, metadata, contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(_this2.url), _this2._parseFileSize(_this2.maybeFileSize), _this2._parseDate(info.CreationDate), _this2._parseDate(info.ModDate), _this2.pdfDocument.getPage(currentPageNumber).then(function (pdfPage) {
  5671. return _this2._parsePageSize((0, _ui_utils.getPageSizeInches)(pdfPage), pagesRotation);
  5672. }), _this2._parseLinearization(info.IsLinearized)]);
  5673. }).then(function (_ref3) {
  5674. var _ref4 = _slicedToArray(_ref3, 8),
  5675. info = _ref4[0],
  5676. metadata = _ref4[1],
  5677. fileName = _ref4[2],
  5678. fileSize = _ref4[3],
  5679. creationDate = _ref4[4],
  5680. modDate = _ref4[5],
  5681. pageSize = _ref4[6],
  5682. isLinearized = _ref4[7];
  5683. freezeFieldData({
  5684. fileName: fileName,
  5685. fileSize: fileSize,
  5686. title: info.Title,
  5687. author: info.Author,
  5688. subject: info.Subject,
  5689. keywords: info.Keywords,
  5690. creationDate: creationDate,
  5691. modificationDate: modDate,
  5692. creator: info.Creator,
  5693. producer: info.Producer,
  5694. version: info.PDFFormatVersion,
  5695. pageCount: _this2.pdfDocument.numPages,
  5696. pageSize: pageSize,
  5697. linearized: isLinearized,
  5698. _currentPageNumber: currentPageNumber,
  5699. _pagesRotation: pagesRotation
  5700. });
  5701. _this2._updateUI();
  5702. return _this2.pdfDocument.getDownloadInfo();
  5703. }).then(function (_ref5) {
  5704. var length = _ref5.length;
  5705. _this2.maybeFileSize = length;
  5706. return _this2._parseFileSize(length);
  5707. }).then(function (fileSize) {
  5708. if (fileSize === _this2.fieldData.fileSize) {
  5709. return;
  5710. }
  5711. var data = Object.assign(Object.create(null), _this2.fieldData);
  5712. data.fileSize = fileSize;
  5713. freezeFieldData(data);
  5714. _this2._updateUI();
  5715. });
  5716. });
  5717. }
  5718. }, {
  5719. key: "close",
  5720. value: function close() {
  5721. this.overlayManager.close(this.overlayName);
  5722. }
  5723. }, {
  5724. key: "setDocument",
  5725. value: function setDocument(pdfDocument) {
  5726. var url = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  5727. if (this.pdfDocument) {
  5728. this._reset();
  5729. this._updateUI(true);
  5730. }
  5731. if (!pdfDocument) {
  5732. return;
  5733. }
  5734. this.pdfDocument = pdfDocument;
  5735. this.url = url;
  5736. this._dataAvailableCapability.resolve();
  5737. }
  5738. }, {
  5739. key: "setFileSize",
  5740. value: function setFileSize(fileSize) {
  5741. if (Number.isInteger(fileSize) && fileSize > 0) {
  5742. this.maybeFileSize = fileSize;
  5743. }
  5744. }
  5745. }, {
  5746. key: "_reset",
  5747. value: function _reset() {
  5748. this.pdfDocument = null;
  5749. this.url = null;
  5750. this.maybeFileSize = 0;
  5751. delete this.fieldData;
  5752. this._dataAvailableCapability = (0, _pdfjsLib.createPromiseCapability)();
  5753. this._currentPageNumber = 1;
  5754. this._pagesRotation = 0;
  5755. }
  5756. }, {
  5757. key: "_updateUI",
  5758. value: function _updateUI() {
  5759. var reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5760. if (reset || !this.fieldData) {
  5761. for (var id in this.fields) {
  5762. this.fields[id].textContent = DEFAULT_FIELD_CONTENT;
  5763. }
  5764. return;
  5765. }
  5766. if (this.overlayManager.active !== this.overlayName) {
  5767. return;
  5768. }
  5769. for (var _id in this.fields) {
  5770. var content = this.fieldData[_id];
  5771. this.fields[_id].textContent = content || content === 0 ? content : DEFAULT_FIELD_CONTENT;
  5772. }
  5773. }
  5774. }, {
  5775. key: "_parseFileSize",
  5776. value: function () {
  5777. var _parseFileSize2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  5778. var fileSize,
  5779. kb,
  5780. _args = arguments;
  5781. return _regenerator["default"].wrap(function _callee$(_context) {
  5782. while (1) {
  5783. switch (_context.prev = _context.next) {
  5784. case 0:
  5785. fileSize = _args.length > 0 && _args[0] !== undefined ? _args[0] : 0;
  5786. kb = fileSize / 1024;
  5787. if (kb) {
  5788. _context.next = 6;
  5789. break;
  5790. }
  5791. return _context.abrupt("return", undefined);
  5792. case 6:
  5793. if (!(kb < 1024)) {
  5794. _context.next = 8;
  5795. break;
  5796. }
  5797. return _context.abrupt("return", this.l10n.get("document_properties_kb", {
  5798. size_kb: (+kb.toPrecision(3)).toLocaleString(),
  5799. size_b: fileSize.toLocaleString()
  5800. }, "{{size_kb}} KB ({{size_b}} bytes)"));
  5801. case 8:
  5802. return _context.abrupt("return", this.l10n.get("document_properties_mb", {
  5803. size_mb: (+(kb / 1024).toPrecision(3)).toLocaleString(),
  5804. size_b: fileSize.toLocaleString()
  5805. }, "{{size_mb}} MB ({{size_b}} bytes)"));
  5806. case 9:
  5807. case "end":
  5808. return _context.stop();
  5809. }
  5810. }
  5811. }, _callee, this);
  5812. }));
  5813. function _parseFileSize() {
  5814. return _parseFileSize2.apply(this, arguments);
  5815. }
  5816. return _parseFileSize;
  5817. }()
  5818. }, {
  5819. key: "_parsePageSize",
  5820. value: function () {
  5821. var _parsePageSize2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(pageSizeInches, pagesRotation) {
  5822. var _this3 = this;
  5823. var isPortrait, sizeInches, sizeMillimeters, pageName, rawName, exactMillimeters, intMillimeters;
  5824. return _regenerator["default"].wrap(function _callee2$(_context2) {
  5825. while (1) {
  5826. switch (_context2.prev = _context2.next) {
  5827. case 0:
  5828. if (pageSizeInches) {
  5829. _context2.next = 2;
  5830. break;
  5831. }
  5832. return _context2.abrupt("return", undefined);
  5833. case 2:
  5834. if (pagesRotation % 180 !== 0) {
  5835. pageSizeInches = {
  5836. width: pageSizeInches.height,
  5837. height: pageSizeInches.width
  5838. };
  5839. }
  5840. isPortrait = (0, _ui_utils.isPortraitOrientation)(pageSizeInches);
  5841. sizeInches = {
  5842. width: Math.round(pageSizeInches.width * 100) / 100,
  5843. height: Math.round(pageSizeInches.height * 100) / 100
  5844. };
  5845. sizeMillimeters = {
  5846. width: Math.round(pageSizeInches.width * 25.4 * 10) / 10,
  5847. height: Math.round(pageSizeInches.height * 25.4 * 10) / 10
  5848. };
  5849. pageName = null;
  5850. rawName = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES);
  5851. if (!rawName && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(sizeMillimeters.height))) {
  5852. exactMillimeters = {
  5853. width: pageSizeInches.width * 25.4,
  5854. height: pageSizeInches.height * 25.4
  5855. };
  5856. intMillimeters = {
  5857. width: Math.round(sizeMillimeters.width),
  5858. height: Math.round(sizeMillimeters.height)
  5859. };
  5860. if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) {
  5861. rawName = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES);
  5862. if (rawName) {
  5863. sizeInches = {
  5864. width: Math.round(intMillimeters.width / 25.4 * 100) / 100,
  5865. height: Math.round(intMillimeters.height / 25.4 * 100) / 100
  5866. };
  5867. sizeMillimeters = intMillimeters;
  5868. }
  5869. }
  5870. }
  5871. if (rawName) {
  5872. pageName = this.l10n.get("document_properties_page_size_name_" + rawName.toLowerCase(), null, rawName);
  5873. }
  5874. return _context2.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 (_ref6) {
  5875. var _ref7 = _slicedToArray(_ref6, 4),
  5876. _ref7$ = _ref7[0],
  5877. width = _ref7$.width,
  5878. height = _ref7$.height,
  5879. unit = _ref7[1],
  5880. name = _ref7[2],
  5881. orientation = _ref7[3];
  5882. return _this3.l10n.get("document_properties_page_size_dimension_" + (name ? "name_" : "") + "string", {
  5883. width: width.toLocaleString(),
  5884. height: height.toLocaleString(),
  5885. unit: unit,
  5886. name: name,
  5887. orientation: orientation
  5888. }, "{{width}} × {{height}} {{unit}} (" + (name ? "{{name}}, " : "") + "{{orientation}})");
  5889. }));
  5890. case 11:
  5891. case "end":
  5892. return _context2.stop();
  5893. }
  5894. }
  5895. }, _callee2, this);
  5896. }));
  5897. function _parsePageSize(_x, _x2) {
  5898. return _parsePageSize2.apply(this, arguments);
  5899. }
  5900. return _parsePageSize;
  5901. }()
  5902. }, {
  5903. key: "_parseDate",
  5904. value: function () {
  5905. var _parseDate2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(inputDate) {
  5906. var dateObject;
  5907. return _regenerator["default"].wrap(function _callee3$(_context3) {
  5908. while (1) {
  5909. switch (_context3.prev = _context3.next) {
  5910. case 0:
  5911. dateObject = _pdfjsLib.PDFDateString.toDateObject(inputDate);
  5912. if (dateObject) {
  5913. _context3.next = 3;
  5914. break;
  5915. }
  5916. return _context3.abrupt("return", undefined);
  5917. case 3:
  5918. return _context3.abrupt("return", this.l10n.get("document_properties_date_string", {
  5919. date: dateObject.toLocaleDateString(),
  5920. time: dateObject.toLocaleTimeString()
  5921. }, "{{date}}, {{time}}"));
  5922. case 4:
  5923. case "end":
  5924. return _context3.stop();
  5925. }
  5926. }
  5927. }, _callee3, this);
  5928. }));
  5929. function _parseDate(_x3) {
  5930. return _parseDate2.apply(this, arguments);
  5931. }
  5932. return _parseDate;
  5933. }()
  5934. }, {
  5935. key: "_parseLinearization",
  5936. value: function _parseLinearization(isLinearized) {
  5937. return this.l10n.get("document_properties_linearized_" + (isLinearized ? "yes" : "no"), null, isLinearized ? "Yes" : "No");
  5938. }
  5939. }]);
  5940. return PDFDocumentProperties;
  5941. }();
  5942. exports.PDFDocumentProperties = PDFDocumentProperties;
  5943. /***/ }),
  5944. /* 18 */
  5945. /***/ (function(module, exports, __webpack_require__) {
  5946. "use strict";
  5947. Object.defineProperty(exports, "__esModule", {
  5948. value: true
  5949. });
  5950. exports.PDFFindBar = void 0;
  5951. var _pdf_find_controller = __webpack_require__(19);
  5952. var _ui_utils = __webpack_require__(5);
  5953. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5954. 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); } }
  5955. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5956. var MATCHES_COUNT_LIMIT = 1000;
  5957. var PDFFindBar = /*#__PURE__*/function () {
  5958. function PDFFindBar(options, eventBus) {
  5959. var _this = this;
  5960. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  5961. _classCallCheck(this, PDFFindBar);
  5962. this.opened = false;
  5963. this.bar = options.bar || null;
  5964. this.toggleButton = options.toggleButton || null;
  5965. this.findField = options.findField || null;
  5966. this.highlightAll = options.highlightAllCheckbox || null;
  5967. this.caseSensitive = options.caseSensitiveCheckbox || null;
  5968. this.entireWord = options.entireWordCheckbox || null;
  5969. this.findMsg = options.findMsg || null;
  5970. this.findResultsCount = options.findResultsCount || null;
  5971. this.findPreviousButton = options.findPreviousButton || null;
  5972. this.findNextButton = options.findNextButton || null;
  5973. this.eventBus = eventBus;
  5974. this.l10n = l10n;
  5975. this.toggleButton.addEventListener("click", function () {
  5976. _this.toggle();
  5977. });
  5978. this.findField.addEventListener("input", function () {
  5979. _this.dispatchEvent("");
  5980. });
  5981. this.bar.addEventListener("keydown", function (e) {
  5982. switch (e.keyCode) {
  5983. case 13:
  5984. if (e.target === _this.findField) {
  5985. _this.dispatchEvent("again", e.shiftKey);
  5986. }
  5987. break;
  5988. case 27:
  5989. _this.close();
  5990. break;
  5991. }
  5992. });
  5993. this.findPreviousButton.addEventListener("click", function () {
  5994. _this.dispatchEvent("again", true);
  5995. });
  5996. this.findNextButton.addEventListener("click", function () {
  5997. _this.dispatchEvent("again", false);
  5998. });
  5999. this.highlightAll.addEventListener("click", function () {
  6000. _this.dispatchEvent("highlightallchange");
  6001. });
  6002. this.caseSensitive.addEventListener("click", function () {
  6003. _this.dispatchEvent("casesensitivitychange");
  6004. });
  6005. this.entireWord.addEventListener("click", function () {
  6006. _this.dispatchEvent("entirewordchange");
  6007. });
  6008. this.eventBus._on("resize", this._adjustWidth.bind(this));
  6009. }
  6010. _createClass(PDFFindBar, [{
  6011. key: "reset",
  6012. value: function reset() {
  6013. this.updateUIState();
  6014. }
  6015. }, {
  6016. key: "dispatchEvent",
  6017. value: function dispatchEvent(type, findPrev) {
  6018. this.eventBus.dispatch("find", {
  6019. source: this,
  6020. type: type,
  6021. query: this.findField.value,
  6022. phraseSearch: true,
  6023. caseSensitive: this.caseSensitive.checked,
  6024. entireWord: this.entireWord.checked,
  6025. highlightAll: this.highlightAll.checked,
  6026. findPrevious: findPrev
  6027. });
  6028. }
  6029. }, {
  6030. key: "updateUIState",
  6031. value: function updateUIState(state, previous, matchesCount) {
  6032. var _this2 = this;
  6033. var notFound = false;
  6034. var findMsg = "";
  6035. var status = "";
  6036. switch (state) {
  6037. case _pdf_find_controller.FindState.FOUND:
  6038. break;
  6039. case _pdf_find_controller.FindState.PENDING:
  6040. status = "pending";
  6041. break;
  6042. case _pdf_find_controller.FindState.NOT_FOUND:
  6043. findMsg = this.l10n.get("find_not_found", null, "Phrase not found");
  6044. notFound = true;
  6045. break;
  6046. case _pdf_find_controller.FindState.WRAPPED:
  6047. if (previous) {
  6048. findMsg = this.l10n.get("find_reached_top", null, "Reached top of document, continued from bottom");
  6049. } else {
  6050. findMsg = this.l10n.get("find_reached_bottom", null, "Reached end of document, continued from top");
  6051. }
  6052. break;
  6053. }
  6054. this.findField.classList.toggle("notFound", notFound);
  6055. this.findField.setAttribute("data-status", status);
  6056. Promise.resolve(findMsg).then(function (msg) {
  6057. _this2.findMsg.textContent = msg;
  6058. _this2._adjustWidth();
  6059. });
  6060. this.updateResultsCount(matchesCount);
  6061. }
  6062. }, {
  6063. key: "updateResultsCount",
  6064. value: function updateResultsCount() {
  6065. var _this3 = this;
  6066. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  6067. _ref$current = _ref.current,
  6068. current = _ref$current === void 0 ? 0 : _ref$current,
  6069. _ref$total = _ref.total,
  6070. total = _ref$total === void 0 ? 0 : _ref$total;
  6071. if (!this.findResultsCount) {
  6072. return;
  6073. }
  6074. var limit = MATCHES_COUNT_LIMIT;
  6075. var matchesCountMsg = "";
  6076. if (total > 0) {
  6077. if (total > limit) {
  6078. matchesCountMsg = this.l10n.get("find_match_count_limit", {
  6079. limit: limit
  6080. }, "More than {{limit}} match" + (limit !== 1 ? "es" : ""));
  6081. } else {
  6082. matchesCountMsg = this.l10n.get("find_match_count", {
  6083. current: current,
  6084. total: total
  6085. }, "{{current}} of {{total}} match" + (total !== 1 ? "es" : ""));
  6086. }
  6087. }
  6088. Promise.resolve(matchesCountMsg).then(function (msg) {
  6089. _this3.findResultsCount.textContent = msg;
  6090. _this3.findResultsCount.classList.toggle("hidden", !total);
  6091. _this3._adjustWidth();
  6092. });
  6093. }
  6094. }, {
  6095. key: "open",
  6096. value: function open() {
  6097. if (!this.opened) {
  6098. this.opened = true;
  6099. this.toggleButton.classList.add("toggled");
  6100. this.bar.classList.remove("hidden");
  6101. }
  6102. this.findField.select();
  6103. this.findField.focus();
  6104. this._adjustWidth();
  6105. }
  6106. }, {
  6107. key: "close",
  6108. value: function close() {
  6109. if (!this.opened) {
  6110. return;
  6111. }
  6112. this.opened = false;
  6113. this.toggleButton.classList.remove("toggled");
  6114. this.bar.classList.add("hidden");
  6115. this.eventBus.dispatch("findbarclose", {
  6116. source: this
  6117. });
  6118. }
  6119. }, {
  6120. key: "toggle",
  6121. value: function toggle() {
  6122. if (this.opened) {
  6123. this.close();
  6124. } else {
  6125. this.open();
  6126. }
  6127. }
  6128. }, {
  6129. key: "_adjustWidth",
  6130. value: function _adjustWidth() {
  6131. if (!this.opened) {
  6132. return;
  6133. }
  6134. this.bar.classList.remove("wrapContainers");
  6135. var findbarHeight = this.bar.clientHeight;
  6136. var inputContainerHeight = this.bar.firstElementChild.clientHeight;
  6137. if (findbarHeight > inputContainerHeight) {
  6138. this.bar.classList.add("wrapContainers");
  6139. }
  6140. }
  6141. }]);
  6142. return PDFFindBar;
  6143. }();
  6144. exports.PDFFindBar = PDFFindBar;
  6145. /***/ }),
  6146. /* 19 */
  6147. /***/ (function(module, exports, __webpack_require__) {
  6148. "use strict";
  6149. Object.defineProperty(exports, "__esModule", {
  6150. value: true
  6151. });
  6152. exports.PDFFindController = exports.FindState = void 0;
  6153. var _pdfjsLib = __webpack_require__(8);
  6154. var _pdf_find_utils = __webpack_require__(20);
  6155. var _ui_utils = __webpack_require__(5);
  6156. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6157. 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); } }
  6158. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6159. var FindState = {
  6160. FOUND: 0,
  6161. NOT_FOUND: 1,
  6162. WRAPPED: 2,
  6163. PENDING: 3
  6164. };
  6165. exports.FindState = FindState;
  6166. var FIND_TIMEOUT = 250;
  6167. var MATCH_SCROLL_OFFSET_TOP = -50;
  6168. var MATCH_SCROLL_OFFSET_LEFT = -400;
  6169. var CHARACTERS_TO_NORMALIZE = {
  6170. "\u2018": "'",
  6171. "\u2019": "'",
  6172. "\u201A": "'",
  6173. "\u201B": "'",
  6174. "\u201C": '"',
  6175. "\u201D": '"',
  6176. "\u201E": '"',
  6177. "\u201F": '"',
  6178. "\xBC": "1/4",
  6179. "\xBD": "1/2",
  6180. "\xBE": "3/4"
  6181. };
  6182. var normalizationRegex = null;
  6183. function normalize(text) {
  6184. if (!normalizationRegex) {
  6185. var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join("");
  6186. normalizationRegex = new RegExp("[".concat(replace, "]"), "g");
  6187. }
  6188. return text.replace(normalizationRegex, function (ch) {
  6189. return CHARACTERS_TO_NORMALIZE[ch];
  6190. });
  6191. }
  6192. var PDFFindController = /*#__PURE__*/function () {
  6193. function PDFFindController(_ref) {
  6194. var linkService = _ref.linkService,
  6195. eventBus = _ref.eventBus;
  6196. _classCallCheck(this, PDFFindController);
  6197. this._linkService = linkService;
  6198. this._eventBus = eventBus;
  6199. this._reset();
  6200. eventBus._on("findbarclose", this._onFindBarClose.bind(this));
  6201. }
  6202. _createClass(PDFFindController, [{
  6203. key: "setDocument",
  6204. value: function setDocument(pdfDocument) {
  6205. if (this._pdfDocument) {
  6206. this._reset();
  6207. }
  6208. if (!pdfDocument) {
  6209. return;
  6210. }
  6211. this._pdfDocument = pdfDocument;
  6212. this._firstPageCapability.resolve();
  6213. }
  6214. }, {
  6215. key: "executeCommand",
  6216. value: function executeCommand(cmd, state) {
  6217. var _this = this;
  6218. if (!state) {
  6219. return;
  6220. }
  6221. var pdfDocument = this._pdfDocument;
  6222. if (this._state === null || this._shouldDirtyMatch(cmd, state)) {
  6223. this._dirtyMatch = true;
  6224. }
  6225. this._state = state;
  6226. if (cmd !== "findhighlightallchange") {
  6227. this._updateUIState(FindState.PENDING);
  6228. }
  6229. this._firstPageCapability.promise.then(function () {
  6230. if (!_this._pdfDocument || pdfDocument && _this._pdfDocument !== pdfDocument) {
  6231. return;
  6232. }
  6233. _this._extractText();
  6234. var findbarClosed = !_this._highlightMatches;
  6235. var pendingTimeout = !!_this._findTimeout;
  6236. if (_this._findTimeout) {
  6237. clearTimeout(_this._findTimeout);
  6238. _this._findTimeout = null;
  6239. }
  6240. if (cmd === "find") {
  6241. _this._findTimeout = setTimeout(function () {
  6242. _this._nextMatch();
  6243. _this._findTimeout = null;
  6244. }, FIND_TIMEOUT);
  6245. } else if (_this._dirtyMatch) {
  6246. _this._nextMatch();
  6247. } else if (cmd === "findagain") {
  6248. _this._nextMatch();
  6249. if (findbarClosed && _this._state.highlightAll) {
  6250. _this._updateAllPages();
  6251. }
  6252. } else if (cmd === "findhighlightallchange") {
  6253. if (pendingTimeout) {
  6254. _this._nextMatch();
  6255. } else {
  6256. _this._highlightMatches = true;
  6257. }
  6258. _this._updateAllPages();
  6259. } else {
  6260. _this._nextMatch();
  6261. }
  6262. });
  6263. }
  6264. }, {
  6265. key: "scrollMatchIntoView",
  6266. value: function scrollMatchIntoView(_ref2) {
  6267. var _ref2$element = _ref2.element,
  6268. element = _ref2$element === void 0 ? null : _ref2$element,
  6269. _ref2$pageIndex = _ref2.pageIndex,
  6270. pageIndex = _ref2$pageIndex === void 0 ? -1 : _ref2$pageIndex,
  6271. _ref2$matchIndex = _ref2.matchIndex,
  6272. matchIndex = _ref2$matchIndex === void 0 ? -1 : _ref2$matchIndex;
  6273. if (!this._scrollMatches || !element) {
  6274. return;
  6275. } else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) {
  6276. return;
  6277. } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) {
  6278. return;
  6279. }
  6280. this._scrollMatches = false;
  6281. var spot = {
  6282. top: MATCH_SCROLL_OFFSET_TOP,
  6283. left: MATCH_SCROLL_OFFSET_LEFT
  6284. };
  6285. (0, _ui_utils.scrollIntoView)(element, spot, true);
  6286. }
  6287. }, {
  6288. key: "_reset",
  6289. value: function _reset() {
  6290. this._highlightMatches = false;
  6291. this._scrollMatches = false;
  6292. this._pdfDocument = null;
  6293. this._pageMatches = [];
  6294. this._pageMatchesLength = [];
  6295. this._state = null;
  6296. this._selected = {
  6297. pageIdx: -1,
  6298. matchIdx: -1
  6299. };
  6300. this._offset = {
  6301. pageIdx: null,
  6302. matchIdx: null,
  6303. wrapped: false
  6304. };
  6305. this._extractTextPromises = [];
  6306. this._pageContents = [];
  6307. this._matchesCountTotal = 0;
  6308. this._pagesToSearch = null;
  6309. this._pendingFindMatches = Object.create(null);
  6310. this._resumePageIdx = null;
  6311. this._dirtyMatch = false;
  6312. clearTimeout(this._findTimeout);
  6313. this._findTimeout = null;
  6314. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  6315. }
  6316. }, {
  6317. key: "_shouldDirtyMatch",
  6318. value: function _shouldDirtyMatch(cmd, state) {
  6319. if (state.query !== this._state.query) {
  6320. return true;
  6321. }
  6322. switch (cmd) {
  6323. case "findagain":
  6324. var pageNumber = this._selected.pageIdx + 1;
  6325. var linkService = this._linkService;
  6326. if (pageNumber >= 1 && pageNumber <= linkService.pagesCount && pageNumber !== linkService.page && !linkService.isPageVisible(pageNumber)) {
  6327. return true;
  6328. }
  6329. return false;
  6330. case "findhighlightallchange":
  6331. return false;
  6332. }
  6333. return true;
  6334. }
  6335. }, {
  6336. key: "_prepareMatches",
  6337. value: function _prepareMatches(matchesWithLength, matches, matchesLength) {
  6338. function isSubTerm(currentIndex) {
  6339. var currentElem = matchesWithLength[currentIndex];
  6340. var nextElem = matchesWithLength[currentIndex + 1];
  6341. if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {
  6342. currentElem.skipped = true;
  6343. return true;
  6344. }
  6345. for (var i = currentIndex - 1; i >= 0; i--) {
  6346. var prevElem = matchesWithLength[i];
  6347. if (prevElem.skipped) {
  6348. continue;
  6349. }
  6350. if (prevElem.match + prevElem.matchLength < currentElem.match) {
  6351. break;
  6352. }
  6353. if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {
  6354. currentElem.skipped = true;
  6355. return true;
  6356. }
  6357. }
  6358. return false;
  6359. }
  6360. matchesWithLength.sort(function (a, b) {
  6361. return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match;
  6362. });
  6363. for (var i = 0, len = matchesWithLength.length; i < len; i++) {
  6364. if (isSubTerm(i)) {
  6365. continue;
  6366. }
  6367. matches.push(matchesWithLength[i].match);
  6368. matchesLength.push(matchesWithLength[i].matchLength);
  6369. }
  6370. }
  6371. }, {
  6372. key: "_isEntireWord",
  6373. value: function _isEntireWord(content, startIdx, length) {
  6374. if (startIdx > 0) {
  6375. var first = content.charCodeAt(startIdx);
  6376. var limit = content.charCodeAt(startIdx - 1);
  6377. if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils.getCharacterType)(limit)) {
  6378. return false;
  6379. }
  6380. }
  6381. var endIdx = startIdx + length - 1;
  6382. if (endIdx < content.length - 1) {
  6383. var last = content.charCodeAt(endIdx);
  6384. var _limit = content.charCodeAt(endIdx + 1);
  6385. if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils.getCharacterType)(_limit)) {
  6386. return false;
  6387. }
  6388. }
  6389. return true;
  6390. }
  6391. }, {
  6392. key: "_calculatePhraseMatch",
  6393. value: function _calculatePhraseMatch(query, pageIndex, pageContent, entireWord) {
  6394. var matches = [];
  6395. var queryLen = query.length;
  6396. var matchIdx = -queryLen;
  6397. while (true) {
  6398. matchIdx = pageContent.indexOf(query, matchIdx + queryLen);
  6399. if (matchIdx === -1) {
  6400. break;
  6401. }
  6402. if (entireWord && !this._isEntireWord(pageContent, matchIdx, queryLen)) {
  6403. continue;
  6404. }
  6405. matches.push(matchIdx);
  6406. }
  6407. this._pageMatches[pageIndex] = matches;
  6408. }
  6409. }, {
  6410. key: "_calculateWordMatch",
  6411. value: function _calculateWordMatch(query, pageIndex, pageContent, entireWord) {
  6412. var matchesWithLength = [];
  6413. var queryArray = query.match(/\S+/g);
  6414. for (var i = 0, len = queryArray.length; i < len; i++) {
  6415. var subquery = queryArray[i];
  6416. var subqueryLen = subquery.length;
  6417. var matchIdx = -subqueryLen;
  6418. while (true) {
  6419. matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen);
  6420. if (matchIdx === -1) {
  6421. break;
  6422. }
  6423. if (entireWord && !this._isEntireWord(pageContent, matchIdx, subqueryLen)) {
  6424. continue;
  6425. }
  6426. matchesWithLength.push({
  6427. match: matchIdx,
  6428. matchLength: subqueryLen,
  6429. skipped: false
  6430. });
  6431. }
  6432. }
  6433. this._pageMatchesLength[pageIndex] = [];
  6434. this._pageMatches[pageIndex] = [];
  6435. this._prepareMatches(matchesWithLength, this._pageMatches[pageIndex], this._pageMatchesLength[pageIndex]);
  6436. }
  6437. }, {
  6438. key: "_calculateMatch",
  6439. value: function _calculateMatch(pageIndex) {
  6440. var pageContent = this._pageContents[pageIndex];
  6441. var query = this._query;
  6442. var _this$_state = this._state,
  6443. caseSensitive = _this$_state.caseSensitive,
  6444. entireWord = _this$_state.entireWord,
  6445. phraseSearch = _this$_state.phraseSearch;
  6446. if (query.length === 0) {
  6447. return;
  6448. }
  6449. if (!caseSensitive) {
  6450. pageContent = pageContent.toLowerCase();
  6451. query = query.toLowerCase();
  6452. }
  6453. if (phraseSearch) {
  6454. this._calculatePhraseMatch(query, pageIndex, pageContent, entireWord);
  6455. } else {
  6456. this._calculateWordMatch(query, pageIndex, pageContent, entireWord);
  6457. }
  6458. if (this._state.highlightAll) {
  6459. this._updatePage(pageIndex);
  6460. }
  6461. if (this._resumePageIdx === pageIndex) {
  6462. this._resumePageIdx = null;
  6463. this._nextPageMatch();
  6464. }
  6465. var pageMatchesCount = this._pageMatches[pageIndex].length;
  6466. if (pageMatchesCount > 0) {
  6467. this._matchesCountTotal += pageMatchesCount;
  6468. this._updateUIResultsCount();
  6469. }
  6470. }
  6471. }, {
  6472. key: "_extractText",
  6473. value: function _extractText() {
  6474. var _this2 = this;
  6475. if (this._extractTextPromises.length > 0) {
  6476. return;
  6477. }
  6478. var promise = Promise.resolve();
  6479. var _loop = function _loop(i, ii) {
  6480. var extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
  6481. _this2._extractTextPromises[i] = extractTextCapability.promise;
  6482. promise = promise.then(function () {
  6483. return _this2._pdfDocument.getPage(i + 1).then(function (pdfPage) {
  6484. return pdfPage.getTextContent({
  6485. normalizeWhitespace: true
  6486. });
  6487. }).then(function (textContent) {
  6488. var textItems = textContent.items;
  6489. var strBuf = [];
  6490. for (var j = 0, jj = textItems.length; j < jj; j++) {
  6491. strBuf.push(textItems[j].str);
  6492. }
  6493. _this2._pageContents[i] = normalize(strBuf.join(""));
  6494. extractTextCapability.resolve(i);
  6495. }, function (reason) {
  6496. console.error("Unable to get text content for page ".concat(i + 1), reason);
  6497. _this2._pageContents[i] = "";
  6498. extractTextCapability.resolve(i);
  6499. });
  6500. });
  6501. };
  6502. for (var i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
  6503. _loop(i, ii);
  6504. }
  6505. }
  6506. }, {
  6507. key: "_updatePage",
  6508. value: function _updatePage(index) {
  6509. if (this._scrollMatches && this._selected.pageIdx === index) {
  6510. this._linkService.page = index + 1;
  6511. }
  6512. this._eventBus.dispatch("updatetextlayermatches", {
  6513. source: this,
  6514. pageIndex: index
  6515. });
  6516. }
  6517. }, {
  6518. key: "_updateAllPages",
  6519. value: function _updateAllPages() {
  6520. this._eventBus.dispatch("updatetextlayermatches", {
  6521. source: this,
  6522. pageIndex: -1
  6523. });
  6524. }
  6525. }, {
  6526. key: "_nextMatch",
  6527. value: function _nextMatch() {
  6528. var _this3 = this;
  6529. var previous = this._state.findPrevious;
  6530. var currentPageIndex = this._linkService.page - 1;
  6531. var numPages = this._linkService.pagesCount;
  6532. this._highlightMatches = true;
  6533. if (this._dirtyMatch) {
  6534. this._dirtyMatch = false;
  6535. this._selected.pageIdx = this._selected.matchIdx = -1;
  6536. this._offset.pageIdx = currentPageIndex;
  6537. this._offset.matchIdx = null;
  6538. this._offset.wrapped = false;
  6539. this._resumePageIdx = null;
  6540. this._pageMatches.length = 0;
  6541. this._pageMatchesLength.length = 0;
  6542. this._matchesCountTotal = 0;
  6543. this._updateAllPages();
  6544. for (var i = 0; i < numPages; i++) {
  6545. if (this._pendingFindMatches[i] === true) {
  6546. continue;
  6547. }
  6548. this._pendingFindMatches[i] = true;
  6549. this._extractTextPromises[i].then(function (pageIdx) {
  6550. delete _this3._pendingFindMatches[pageIdx];
  6551. _this3._calculateMatch(pageIdx);
  6552. });
  6553. }
  6554. }
  6555. if (this._query === "") {
  6556. this._updateUIState(FindState.FOUND);
  6557. return;
  6558. }
  6559. if (this._resumePageIdx) {
  6560. return;
  6561. }
  6562. var offset = this._offset;
  6563. this._pagesToSearch = numPages;
  6564. if (offset.matchIdx !== null) {
  6565. var numPageMatches = this._pageMatches[offset.pageIdx].length;
  6566. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  6567. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  6568. this._updateMatch(true);
  6569. return;
  6570. }
  6571. this._advanceOffsetPage(previous);
  6572. }
  6573. this._nextPageMatch();
  6574. }
  6575. }, {
  6576. key: "_matchesReady",
  6577. value: function _matchesReady(matches) {
  6578. var offset = this._offset;
  6579. var numMatches = matches.length;
  6580. var previous = this._state.findPrevious;
  6581. if (numMatches) {
  6582. offset.matchIdx = previous ? numMatches - 1 : 0;
  6583. this._updateMatch(true);
  6584. return true;
  6585. }
  6586. this._advanceOffsetPage(previous);
  6587. if (offset.wrapped) {
  6588. offset.matchIdx = null;
  6589. if (this._pagesToSearch < 0) {
  6590. this._updateMatch(false);
  6591. return true;
  6592. }
  6593. }
  6594. return false;
  6595. }
  6596. }, {
  6597. key: "_nextPageMatch",
  6598. value: function _nextPageMatch() {
  6599. if (this._resumePageIdx !== null) {
  6600. console.error("There can only be one pending page.");
  6601. }
  6602. var matches = null;
  6603. do {
  6604. var pageIdx = this._offset.pageIdx;
  6605. matches = this._pageMatches[pageIdx];
  6606. if (!matches) {
  6607. this._resumePageIdx = pageIdx;
  6608. break;
  6609. }
  6610. } while (!this._matchesReady(matches));
  6611. }
  6612. }, {
  6613. key: "_advanceOffsetPage",
  6614. value: function _advanceOffsetPage(previous) {
  6615. var offset = this._offset;
  6616. var numPages = this._linkService.pagesCount;
  6617. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  6618. offset.matchIdx = null;
  6619. this._pagesToSearch--;
  6620. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  6621. offset.pageIdx = previous ? numPages - 1 : 0;
  6622. offset.wrapped = true;
  6623. }
  6624. }
  6625. }, {
  6626. key: "_updateMatch",
  6627. value: function _updateMatch() {
  6628. var found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6629. var state = FindState.NOT_FOUND;
  6630. var wrapped = this._offset.wrapped;
  6631. this._offset.wrapped = false;
  6632. if (found) {
  6633. var previousPage = this._selected.pageIdx;
  6634. this._selected.pageIdx = this._offset.pageIdx;
  6635. this._selected.matchIdx = this._offset.matchIdx;
  6636. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  6637. if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {
  6638. this._updatePage(previousPage);
  6639. }
  6640. }
  6641. this._updateUIState(state, this._state.findPrevious);
  6642. if (this._selected.pageIdx !== -1) {
  6643. this._scrollMatches = true;
  6644. this._updatePage(this._selected.pageIdx);
  6645. }
  6646. }
  6647. }, {
  6648. key: "_onFindBarClose",
  6649. value: function _onFindBarClose(evt) {
  6650. var _this4 = this;
  6651. var pdfDocument = this._pdfDocument;
  6652. this._firstPageCapability.promise.then(function () {
  6653. if (!_this4._pdfDocument || pdfDocument && _this4._pdfDocument !== pdfDocument) {
  6654. return;
  6655. }
  6656. if (_this4._findTimeout) {
  6657. clearTimeout(_this4._findTimeout);
  6658. _this4._findTimeout = null;
  6659. }
  6660. if (_this4._resumePageIdx) {
  6661. _this4._resumePageIdx = null;
  6662. _this4._dirtyMatch = true;
  6663. }
  6664. _this4._updateUIState(FindState.FOUND);
  6665. _this4._highlightMatches = false;
  6666. _this4._updateAllPages();
  6667. });
  6668. }
  6669. }, {
  6670. key: "_requestMatchesCount",
  6671. value: function _requestMatchesCount() {
  6672. var _this$_selected = this._selected,
  6673. pageIdx = _this$_selected.pageIdx,
  6674. matchIdx = _this$_selected.matchIdx;
  6675. var current = 0,
  6676. total = this._matchesCountTotal;
  6677. if (matchIdx !== -1) {
  6678. for (var i = 0; i < pageIdx; i++) {
  6679. current += this._pageMatches[i] && this._pageMatches[i].length || 0;
  6680. }
  6681. current += matchIdx + 1;
  6682. }
  6683. if (current < 1 || current > total) {
  6684. current = total = 0;
  6685. }
  6686. return {
  6687. current: current,
  6688. total: total
  6689. };
  6690. }
  6691. }, {
  6692. key: "_updateUIResultsCount",
  6693. value: function _updateUIResultsCount() {
  6694. this._eventBus.dispatch("updatefindmatchescount", {
  6695. source: this,
  6696. matchesCount: this._requestMatchesCount()
  6697. });
  6698. }
  6699. }, {
  6700. key: "_updateUIState",
  6701. value: function _updateUIState(state, previous) {
  6702. this._eventBus.dispatch("updatefindcontrolstate", {
  6703. source: this,
  6704. state: state,
  6705. previous: previous,
  6706. matchesCount: this._requestMatchesCount(),
  6707. rawQuery: this._state ? this._state.query : null
  6708. });
  6709. }
  6710. }, {
  6711. key: "highlightMatches",
  6712. get: function get() {
  6713. return this._highlightMatches;
  6714. }
  6715. }, {
  6716. key: "pageMatches",
  6717. get: function get() {
  6718. return this._pageMatches;
  6719. }
  6720. }, {
  6721. key: "pageMatchesLength",
  6722. get: function get() {
  6723. return this._pageMatchesLength;
  6724. }
  6725. }, {
  6726. key: "selected",
  6727. get: function get() {
  6728. return this._selected;
  6729. }
  6730. }, {
  6731. key: "state",
  6732. get: function get() {
  6733. return this._state;
  6734. }
  6735. }, {
  6736. key: "_query",
  6737. get: function get() {
  6738. if (this._state.query !== this._rawQuery) {
  6739. this._rawQuery = this._state.query;
  6740. this._normalizedQuery = normalize(this._state.query);
  6741. }
  6742. return this._normalizedQuery;
  6743. }
  6744. }]);
  6745. return PDFFindController;
  6746. }();
  6747. exports.PDFFindController = PDFFindController;
  6748. /***/ }),
  6749. /* 20 */
  6750. /***/ (function(module, exports, __webpack_require__) {
  6751. "use strict";
  6752. Object.defineProperty(exports, "__esModule", {
  6753. value: true
  6754. });
  6755. exports.getCharacterType = getCharacterType;
  6756. exports.CharacterType = void 0;
  6757. var CharacterType = {
  6758. SPACE: 0,
  6759. ALPHA_LETTER: 1,
  6760. PUNCT: 2,
  6761. HAN_LETTER: 3,
  6762. KATAKANA_LETTER: 4,
  6763. HIRAGANA_LETTER: 5,
  6764. HALFWIDTH_KATAKANA_LETTER: 6,
  6765. THAI_LETTER: 7
  6766. };
  6767. exports.CharacterType = CharacterType;
  6768. function isAlphabeticalScript(charCode) {
  6769. return charCode < 0x2e80;
  6770. }
  6771. function isAscii(charCode) {
  6772. return (charCode & 0xff80) === 0;
  6773. }
  6774. function isAsciiAlpha(charCode) {
  6775. return charCode >= 0x61 && charCode <= 0x7a || charCode >= 0x41 && charCode <= 0x5a;
  6776. }
  6777. function isAsciiDigit(charCode) {
  6778. return charCode >= 0x30 && charCode <= 0x39;
  6779. }
  6780. function isAsciiSpace(charCode) {
  6781. return charCode === 0x20 || charCode === 0x09 || charCode === 0x0d || charCode === 0x0a;
  6782. }
  6783. function isHan(charCode) {
  6784. return charCode >= 0x3400 && charCode <= 0x9fff || charCode >= 0xf900 && charCode <= 0xfaff;
  6785. }
  6786. function isKatakana(charCode) {
  6787. return charCode >= 0x30a0 && charCode <= 0x30ff;
  6788. }
  6789. function isHiragana(charCode) {
  6790. return charCode >= 0x3040 && charCode <= 0x309f;
  6791. }
  6792. function isHalfwidthKatakana(charCode) {
  6793. return charCode >= 0xff60 && charCode <= 0xff9f;
  6794. }
  6795. function isThai(charCode) {
  6796. return (charCode & 0xff80) === 0x0e00;
  6797. }
  6798. function getCharacterType(charCode) {
  6799. if (isAlphabeticalScript(charCode)) {
  6800. if (isAscii(charCode)) {
  6801. if (isAsciiSpace(charCode)) {
  6802. return CharacterType.SPACE;
  6803. } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5f) {
  6804. return CharacterType.ALPHA_LETTER;
  6805. }
  6806. return CharacterType.PUNCT;
  6807. } else if (isThai(charCode)) {
  6808. return CharacterType.THAI_LETTER;
  6809. } else if (charCode === 0xa0) {
  6810. return CharacterType.SPACE;
  6811. }
  6812. return CharacterType.ALPHA_LETTER;
  6813. }
  6814. if (isHan(charCode)) {
  6815. return CharacterType.HAN_LETTER;
  6816. } else if (isKatakana(charCode)) {
  6817. return CharacterType.KATAKANA_LETTER;
  6818. } else if (isHiragana(charCode)) {
  6819. return CharacterType.HIRAGANA_LETTER;
  6820. } else if (isHalfwidthKatakana(charCode)) {
  6821. return CharacterType.HALFWIDTH_KATAKANA_LETTER;
  6822. }
  6823. return CharacterType.ALPHA_LETTER;
  6824. }
  6825. /***/ }),
  6826. /* 21 */
  6827. /***/ (function(module, exports, __webpack_require__) {
  6828. "use strict";
  6829. Object.defineProperty(exports, "__esModule", {
  6830. value: true
  6831. });
  6832. exports.isDestHashesEqual = isDestHashesEqual;
  6833. exports.isDestArraysEqual = isDestArraysEqual;
  6834. exports.PDFHistory = void 0;
  6835. var _ui_utils = __webpack_require__(5);
  6836. 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); }
  6837. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  6838. 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."); }
  6839. 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); }
  6840. 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; }
  6841. 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; }
  6842. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  6843. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6844. 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); } }
  6845. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6846. var HASH_CHANGE_TIMEOUT = 1000;
  6847. var POSITION_UPDATED_THRESHOLD = 50;
  6848. var UPDATE_VIEWAREA_TIMEOUT = 1000;
  6849. function getCurrentHash() {
  6850. return document.location.hash;
  6851. }
  6852. var PDFHistory = /*#__PURE__*/function () {
  6853. function PDFHistory(_ref) {
  6854. var _this = this;
  6855. var linkService = _ref.linkService,
  6856. eventBus = _ref.eventBus;
  6857. _classCallCheck(this, PDFHistory);
  6858. this.linkService = linkService;
  6859. this.eventBus = eventBus;
  6860. this._initialized = false;
  6861. this._fingerprint = "";
  6862. this.reset();
  6863. this._boundEvents = null;
  6864. this._isViewerInPresentationMode = false;
  6865. this.eventBus._on("presentationmodechanged", function (evt) {
  6866. _this._isViewerInPresentationMode = evt.active || evt.switchInProgress;
  6867. });
  6868. this.eventBus._on("pagesinit", function () {
  6869. _this._isPagesLoaded = false;
  6870. var onPagesLoaded = function onPagesLoaded(evt) {
  6871. _this.eventBus._off("pagesloaded", onPagesLoaded);
  6872. _this._isPagesLoaded = !!evt.pagesCount;
  6873. };
  6874. _this.eventBus._on("pagesloaded", onPagesLoaded);
  6875. });
  6876. }
  6877. _createClass(PDFHistory, [{
  6878. key: "initialize",
  6879. value: function initialize(_ref2) {
  6880. var fingerprint = _ref2.fingerprint,
  6881. _ref2$resetHistory = _ref2.resetHistory,
  6882. resetHistory = _ref2$resetHistory === void 0 ? false : _ref2$resetHistory,
  6883. _ref2$updateUrl = _ref2.updateUrl,
  6884. updateUrl = _ref2$updateUrl === void 0 ? false : _ref2$updateUrl;
  6885. if (!fingerprint || typeof fingerprint !== "string") {
  6886. console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
  6887. return;
  6888. }
  6889. if (this._initialized) {
  6890. this.reset();
  6891. }
  6892. var reInitialized = this._fingerprint !== "" && this._fingerprint !== fingerprint;
  6893. this._fingerprint = fingerprint;
  6894. this._updateUrl = updateUrl === true;
  6895. this._initialized = true;
  6896. this._bindEvents();
  6897. var state = window.history.state;
  6898. this._popStateInProgress = false;
  6899. this._blockHashChange = 0;
  6900. this._currentHash = getCurrentHash();
  6901. this._numPositionUpdates = 0;
  6902. this._uid = this._maxUid = 0;
  6903. this._destination = null;
  6904. this._position = null;
  6905. if (!this._isValidState(state, true) || resetHistory) {
  6906. var _this$_parseCurrentHa = this._parseCurrentHash(true),
  6907. hash = _this$_parseCurrentHa.hash,
  6908. page = _this$_parseCurrentHa.page,
  6909. rotation = _this$_parseCurrentHa.rotation;
  6910. if (!hash || reInitialized || resetHistory) {
  6911. this._pushOrReplaceState(null, true);
  6912. return;
  6913. }
  6914. this._pushOrReplaceState({
  6915. hash: hash,
  6916. page: page,
  6917. rotation: rotation
  6918. }, true);
  6919. return;
  6920. }
  6921. var destination = state.destination;
  6922. this._updateInternalState(destination, state.uid, true);
  6923. if (this._uid > this._maxUid) {
  6924. this._maxUid = this._uid;
  6925. }
  6926. if (destination.rotation !== undefined) {
  6927. this._initialRotation = destination.rotation;
  6928. }
  6929. if (destination.dest) {
  6930. this._initialBookmark = JSON.stringify(destination.dest);
  6931. this._destination.page = null;
  6932. } else if (destination.hash) {
  6933. this._initialBookmark = destination.hash;
  6934. } else if (destination.page) {
  6935. this._initialBookmark = "page=".concat(destination.page);
  6936. }
  6937. }
  6938. }, {
  6939. key: "reset",
  6940. value: function reset() {
  6941. if (this._initialized) {
  6942. this._pageHide();
  6943. this._initialized = false;
  6944. this._unbindEvents();
  6945. }
  6946. if (this._updateViewareaTimeout) {
  6947. clearTimeout(this._updateViewareaTimeout);
  6948. this._updateViewareaTimeout = null;
  6949. }
  6950. this._initialBookmark = null;
  6951. this._initialRotation = null;
  6952. }
  6953. }, {
  6954. key: "push",
  6955. value: function push(_ref3) {
  6956. var _this2 = this;
  6957. var _ref3$namedDest = _ref3.namedDest,
  6958. namedDest = _ref3$namedDest === void 0 ? null : _ref3$namedDest,
  6959. explicitDest = _ref3.explicitDest,
  6960. pageNumber = _ref3.pageNumber;
  6961. if (!this._initialized) {
  6962. return;
  6963. }
  6964. if (namedDest && typeof namedDest !== "string") {
  6965. console.error("PDFHistory.push: " + "\"".concat(namedDest, "\" is not a valid namedDest parameter."));
  6966. return;
  6967. } else if (!Array.isArray(explicitDest)) {
  6968. console.error("PDFHistory.push: " + "\"".concat(explicitDest, "\" is not a valid explicitDest parameter."));
  6969. return;
  6970. } else if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {
  6971. if (pageNumber !== null || this._destination) {
  6972. console.error("PDFHistory.push: " + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  6973. return;
  6974. }
  6975. }
  6976. var hash = namedDest || JSON.stringify(explicitDest);
  6977. if (!hash) {
  6978. return;
  6979. }
  6980. var forceReplace = false;
  6981. if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
  6982. if (this._destination.page) {
  6983. return;
  6984. }
  6985. forceReplace = true;
  6986. }
  6987. if (this._popStateInProgress && !forceReplace) {
  6988. return;
  6989. }
  6990. this._pushOrReplaceState({
  6991. dest: explicitDest,
  6992. hash: hash,
  6993. page: pageNumber,
  6994. rotation: this.linkService.rotation
  6995. }, forceReplace);
  6996. if (!this._popStateInProgress) {
  6997. this._popStateInProgress = true;
  6998. Promise.resolve().then(function () {
  6999. _this2._popStateInProgress = false;
  7000. });
  7001. }
  7002. }
  7003. }, {
  7004. key: "pushCurrentPosition",
  7005. value: function pushCurrentPosition() {
  7006. if (!this._initialized || this._popStateInProgress) {
  7007. return;
  7008. }
  7009. this._tryPushCurrentPosition();
  7010. }
  7011. }, {
  7012. key: "back",
  7013. value: function back() {
  7014. if (!this._initialized || this._popStateInProgress) {
  7015. return;
  7016. }
  7017. var state = window.history.state;
  7018. if (this._isValidState(state) && state.uid > 0) {
  7019. window.history.back();
  7020. }
  7021. }
  7022. }, {
  7023. key: "forward",
  7024. value: function forward() {
  7025. if (!this._initialized || this._popStateInProgress) {
  7026. return;
  7027. }
  7028. var state = window.history.state;
  7029. if (this._isValidState(state) && state.uid < this._maxUid) {
  7030. window.history.forward();
  7031. }
  7032. }
  7033. }, {
  7034. key: "_pushOrReplaceState",
  7035. value: function _pushOrReplaceState(destination) {
  7036. var forceReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7037. var shouldReplace = forceReplace || !this._destination;
  7038. var newState = {
  7039. fingerprint: this._fingerprint,
  7040. uid: shouldReplace ? this._uid : this._uid + 1,
  7041. destination: destination
  7042. };
  7043. this._updateInternalState(destination, newState.uid);
  7044. var newUrl;
  7045. if (this._updateUrl && destination && destination.hash) {
  7046. var baseUrl = document.location.href.split("#")[0];
  7047. if (!baseUrl.startsWith("file://")) {
  7048. newUrl = "".concat(baseUrl, "#").concat(destination.hash);
  7049. }
  7050. }
  7051. if (shouldReplace) {
  7052. window.history.replaceState(newState, "", newUrl);
  7053. } else {
  7054. this._maxUid = this._uid;
  7055. window.history.pushState(newState, "", newUrl);
  7056. }
  7057. }
  7058. }, {
  7059. key: "_tryPushCurrentPosition",
  7060. value: function _tryPushCurrentPosition() {
  7061. var temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  7062. if (!this._position) {
  7063. return;
  7064. }
  7065. var position = this._position;
  7066. if (temporary) {
  7067. position = Object.assign(Object.create(null), this._position);
  7068. position.temporary = true;
  7069. }
  7070. if (!this._destination) {
  7071. this._pushOrReplaceState(position);
  7072. return;
  7073. }
  7074. if (this._destination.temporary) {
  7075. this._pushOrReplaceState(position, true);
  7076. return;
  7077. }
  7078. if (this._destination.hash === position.hash) {
  7079. return;
  7080. }
  7081. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  7082. return;
  7083. }
  7084. var forceReplace = false;
  7085. if (this._destination.page >= position.first && this._destination.page <= position.page) {
  7086. if (this._destination.dest || !this._destination.first) {
  7087. return;
  7088. }
  7089. forceReplace = true;
  7090. }
  7091. this._pushOrReplaceState(position, forceReplace);
  7092. }
  7093. }, {
  7094. key: "_isValidState",
  7095. value: function _isValidState(state) {
  7096. var checkReload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7097. if (!state) {
  7098. return false;
  7099. }
  7100. if (state.fingerprint !== this._fingerprint) {
  7101. if (checkReload) {
  7102. if (typeof state.fingerprint !== "string" || state.fingerprint.length !== this._fingerprint.length) {
  7103. return false;
  7104. }
  7105. var _performance$getEntri = performance.getEntriesByType("navigation"),
  7106. _performance$getEntri2 = _slicedToArray(_performance$getEntri, 1),
  7107. perfEntry = _performance$getEntri2[0];
  7108. if (!perfEntry || perfEntry.type !== "reload") {
  7109. return false;
  7110. }
  7111. } else {
  7112. return false;
  7113. }
  7114. }
  7115. if (!Number.isInteger(state.uid) || state.uid < 0) {
  7116. return false;
  7117. }
  7118. if (state.destination === null || _typeof(state.destination) !== "object") {
  7119. return false;
  7120. }
  7121. return true;
  7122. }
  7123. }, {
  7124. key: "_updateInternalState",
  7125. value: function _updateInternalState(destination, uid) {
  7126. var removeTemporary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  7127. if (this._updateViewareaTimeout) {
  7128. clearTimeout(this._updateViewareaTimeout);
  7129. this._updateViewareaTimeout = null;
  7130. }
  7131. if (removeTemporary && destination && destination.temporary) {
  7132. delete destination.temporary;
  7133. }
  7134. this._destination = destination;
  7135. this._uid = uid;
  7136. this._numPositionUpdates = 0;
  7137. }
  7138. }, {
  7139. key: "_parseCurrentHash",
  7140. value: function _parseCurrentHash() {
  7141. var checkNameddest = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  7142. var hash = unescape(getCurrentHash()).substring(1);
  7143. var params = (0, _ui_utils.parseQueryString)(hash);
  7144. var nameddest = params.nameddest || "";
  7145. var page = params.page | 0;
  7146. if (!(Number.isInteger(page) && page > 0 && page <= this.linkService.pagesCount) || checkNameddest && nameddest.length > 0) {
  7147. page = null;
  7148. }
  7149. return {
  7150. hash: hash,
  7151. page: page,
  7152. rotation: this.linkService.rotation
  7153. };
  7154. }
  7155. }, {
  7156. key: "_updateViewarea",
  7157. value: function _updateViewarea(_ref4) {
  7158. var _this3 = this;
  7159. var location = _ref4.location;
  7160. if (this._updateViewareaTimeout) {
  7161. clearTimeout(this._updateViewareaTimeout);
  7162. this._updateViewareaTimeout = null;
  7163. }
  7164. this._position = {
  7165. hash: this._isViewerInPresentationMode ? "page=".concat(location.pageNumber) : location.pdfOpenParams.substring(1),
  7166. page: this.linkService.page,
  7167. first: location.pageNumber,
  7168. rotation: location.rotation
  7169. };
  7170. if (this._popStateInProgress) {
  7171. return;
  7172. }
  7173. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
  7174. this._numPositionUpdates++;
  7175. }
  7176. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  7177. this._updateViewareaTimeout = setTimeout(function () {
  7178. if (!_this3._popStateInProgress) {
  7179. _this3._tryPushCurrentPosition(true);
  7180. }
  7181. _this3._updateViewareaTimeout = null;
  7182. }, UPDATE_VIEWAREA_TIMEOUT);
  7183. }
  7184. }
  7185. }, {
  7186. key: "_popState",
  7187. value: function _popState(_ref5) {
  7188. var _this4 = this;
  7189. var state = _ref5.state;
  7190. var newHash = getCurrentHash(),
  7191. hashChanged = this._currentHash !== newHash;
  7192. this._currentHash = newHash;
  7193. if (!state) {
  7194. this._uid++;
  7195. var _this$_parseCurrentHa2 = this._parseCurrentHash(),
  7196. hash = _this$_parseCurrentHa2.hash,
  7197. page = _this$_parseCurrentHa2.page,
  7198. rotation = _this$_parseCurrentHa2.rotation;
  7199. this._pushOrReplaceState({
  7200. hash: hash,
  7201. page: page,
  7202. rotation: rotation
  7203. }, true);
  7204. return;
  7205. }
  7206. if (!this._isValidState(state)) {
  7207. return;
  7208. }
  7209. this._popStateInProgress = true;
  7210. if (hashChanged) {
  7211. this._blockHashChange++;
  7212. (0, _ui_utils.waitOnEventOrTimeout)({
  7213. target: window,
  7214. name: "hashchange",
  7215. delay: HASH_CHANGE_TIMEOUT
  7216. }).then(function () {
  7217. _this4._blockHashChange--;
  7218. });
  7219. }
  7220. var destination = state.destination;
  7221. this._updateInternalState(destination, state.uid, true);
  7222. if (this._uid > this._maxUid) {
  7223. this._maxUid = this._uid;
  7224. }
  7225. if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
  7226. this.linkService.rotation = destination.rotation;
  7227. }
  7228. if (destination.dest) {
  7229. this.linkService.navigateTo(destination.dest);
  7230. } else if (destination.hash) {
  7231. this.linkService.setHash(destination.hash);
  7232. } else if (destination.page) {
  7233. this.linkService.page = destination.page;
  7234. }
  7235. Promise.resolve().then(function () {
  7236. _this4._popStateInProgress = false;
  7237. });
  7238. }
  7239. }, {
  7240. key: "_pageHide",
  7241. value: function _pageHide() {
  7242. if (!this._destination || this._destination.temporary) {
  7243. this._tryPushCurrentPosition();
  7244. }
  7245. }
  7246. }, {
  7247. key: "_bindEvents",
  7248. value: function _bindEvents() {
  7249. if (this._boundEvents) {
  7250. return;
  7251. }
  7252. this._boundEvents = {
  7253. updateViewarea: this._updateViewarea.bind(this),
  7254. popState: this._popState.bind(this),
  7255. pageHide: this._pageHide.bind(this)
  7256. };
  7257. this.eventBus._on("updateviewarea", this._boundEvents.updateViewarea);
  7258. window.addEventListener("popstate", this._boundEvents.popState);
  7259. window.addEventListener("pagehide", this._boundEvents.pageHide);
  7260. }
  7261. }, {
  7262. key: "_unbindEvents",
  7263. value: function _unbindEvents() {
  7264. if (!this._boundEvents) {
  7265. return;
  7266. }
  7267. this.eventBus._off("updateviewarea", this._boundEvents.updateViewarea);
  7268. window.removeEventListener("popstate", this._boundEvents.popState);
  7269. window.removeEventListener("pagehide", this._boundEvents.pageHide);
  7270. this._boundEvents = null;
  7271. }
  7272. }, {
  7273. key: "popStateInProgress",
  7274. get: function get() {
  7275. return this._initialized && (this._popStateInProgress || this._blockHashChange > 0);
  7276. }
  7277. }, {
  7278. key: "initialBookmark",
  7279. get: function get() {
  7280. return this._initialized ? this._initialBookmark : null;
  7281. }
  7282. }, {
  7283. key: "initialRotation",
  7284. get: function get() {
  7285. return this._initialized ? this._initialRotation : null;
  7286. }
  7287. }]);
  7288. return PDFHistory;
  7289. }();
  7290. exports.PDFHistory = PDFHistory;
  7291. function isDestHashesEqual(destHash, pushHash) {
  7292. if (typeof destHash !== "string" || typeof pushHash !== "string") {
  7293. return false;
  7294. }
  7295. if (destHash === pushHash) {
  7296. return true;
  7297. }
  7298. var _parseQueryString = (0, _ui_utils.parseQueryString)(destHash),
  7299. nameddest = _parseQueryString.nameddest;
  7300. if (nameddest === pushHash) {
  7301. return true;
  7302. }
  7303. return false;
  7304. }
  7305. function isDestArraysEqual(firstDest, secondDest) {
  7306. function isEntryEqual(first, second) {
  7307. if (_typeof(first) !== _typeof(second)) {
  7308. return false;
  7309. }
  7310. if (Array.isArray(first) || Array.isArray(second)) {
  7311. return false;
  7312. }
  7313. if (first !== null && _typeof(first) === "object" && second !== null) {
  7314. if (Object.keys(first).length !== Object.keys(second).length) {
  7315. return false;
  7316. }
  7317. for (var key in first) {
  7318. if (!isEntryEqual(first[key], second[key])) {
  7319. return false;
  7320. }
  7321. }
  7322. return true;
  7323. }
  7324. return first === second || Number.isNaN(first) && Number.isNaN(second);
  7325. }
  7326. if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
  7327. return false;
  7328. }
  7329. if (firstDest.length !== secondDest.length) {
  7330. return false;
  7331. }
  7332. for (var i = 0, ii = firstDest.length; i < ii; i++) {
  7333. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  7334. return false;
  7335. }
  7336. }
  7337. return true;
  7338. }
  7339. /***/ }),
  7340. /* 22 */
  7341. /***/ (function(module, exports, __webpack_require__) {
  7342. "use strict";
  7343. Object.defineProperty(exports, "__esModule", {
  7344. value: true
  7345. });
  7346. exports.PDFLayerViewer = void 0;
  7347. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  7348. var _base_tree_viewer = __webpack_require__(16);
  7349. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7350. 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); }
  7351. 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; } } }; }
  7352. 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); }
  7353. 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; }
  7354. 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); } }
  7355. 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); }); }; }
  7356. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7357. 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); } }
  7358. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7359. 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); }
  7360. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  7361. 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); }
  7362. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  7363. 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); }; }
  7364. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  7365. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  7366. 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; } }
  7367. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  7368. var PDFLayerViewer = /*#__PURE__*/function (_BaseTreeViewer) {
  7369. _inherits(PDFLayerViewer, _BaseTreeViewer);
  7370. var _super = _createSuper(PDFLayerViewer);
  7371. function PDFLayerViewer(options) {
  7372. var _this;
  7373. _classCallCheck(this, PDFLayerViewer);
  7374. _this = _super.call(this, options);
  7375. _this.l10n = options.l10n;
  7376. _this.eventBus._on("resetlayers", _this._resetLayers.bind(_assertThisInitialized(_this)));
  7377. _this.eventBus._on("togglelayerstree", _this._toggleAllTreeItems.bind(_assertThisInitialized(_this)));
  7378. return _this;
  7379. }
  7380. _createClass(PDFLayerViewer, [{
  7381. key: "reset",
  7382. value: function reset() {
  7383. _get(_getPrototypeOf(PDFLayerViewer.prototype), "reset", this).call(this);
  7384. this._optionalContentConfig = null;
  7385. this._pdfDocument = null;
  7386. }
  7387. }, {
  7388. key: "_dispatchEvent",
  7389. value: function _dispatchEvent(layersCount) {
  7390. this.eventBus.dispatch("layersloaded", {
  7391. source: this,
  7392. layersCount: layersCount
  7393. });
  7394. }
  7395. }, {
  7396. key: "_bindLink",
  7397. value: function _bindLink(element, _ref) {
  7398. var _this2 = this;
  7399. var groupId = _ref.groupId,
  7400. input = _ref.input;
  7401. var setVisibility = function setVisibility() {
  7402. _this2._optionalContentConfig.setVisibility(groupId, input.checked);
  7403. _this2.eventBus.dispatch("optionalcontentconfig", {
  7404. source: _this2,
  7405. promise: Promise.resolve(_this2._optionalContentConfig)
  7406. });
  7407. };
  7408. element.onclick = function (evt) {
  7409. if (evt.target === input) {
  7410. setVisibility();
  7411. return true;
  7412. } else if (evt.target !== element) {
  7413. return true;
  7414. }
  7415. input.checked = !input.checked;
  7416. setVisibility();
  7417. return false;
  7418. };
  7419. }
  7420. }, {
  7421. key: "_setNestedName",
  7422. value: function () {
  7423. var _setNestedName2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(element, _ref2) {
  7424. var _ref2$name, name;
  7425. return _regenerator["default"].wrap(function _callee$(_context) {
  7426. while (1) {
  7427. switch (_context.prev = _context.next) {
  7428. case 0:
  7429. _ref2$name = _ref2.name, name = _ref2$name === void 0 ? null : _ref2$name;
  7430. if (!(typeof name === "string")) {
  7431. _context.next = 4;
  7432. break;
  7433. }
  7434. element.textContent = this._normalizeTextContent(name);
  7435. return _context.abrupt("return");
  7436. case 4:
  7437. _context.next = 6;
  7438. return this.l10n.get("additional_layers", null, "Additional Layers");
  7439. case 6:
  7440. element.textContent = _context.sent;
  7441. element.style.fontStyle = "italic";
  7442. case 8:
  7443. case "end":
  7444. return _context.stop();
  7445. }
  7446. }
  7447. }, _callee, this);
  7448. }));
  7449. function _setNestedName(_x, _x2) {
  7450. return _setNestedName2.apply(this, arguments);
  7451. }
  7452. return _setNestedName;
  7453. }()
  7454. }, {
  7455. key: "_addToggleButton",
  7456. value: function _addToggleButton(div, _ref3) {
  7457. var _ref3$name = _ref3.name,
  7458. name = _ref3$name === void 0 ? null : _ref3$name;
  7459. _get(_getPrototypeOf(PDFLayerViewer.prototype), "_addToggleButton", this).call(this, div, name === null);
  7460. }
  7461. }, {
  7462. key: "_toggleAllTreeItems",
  7463. value: function _toggleAllTreeItems() {
  7464. if (!this._optionalContentConfig) {
  7465. return;
  7466. }
  7467. _get(_getPrototypeOf(PDFLayerViewer.prototype), "_toggleAllTreeItems", this).call(this);
  7468. }
  7469. }, {
  7470. key: "render",
  7471. value: function render(_ref4) {
  7472. var optionalContentConfig = _ref4.optionalContentConfig,
  7473. pdfDocument = _ref4.pdfDocument;
  7474. if (this._optionalContentConfig) {
  7475. this.reset();
  7476. }
  7477. this._optionalContentConfig = optionalContentConfig || null;
  7478. this._pdfDocument = pdfDocument || null;
  7479. var groups = optionalContentConfig && optionalContentConfig.getOrder();
  7480. if (!groups) {
  7481. this._dispatchEvent(0);
  7482. return;
  7483. }
  7484. var fragment = document.createDocumentFragment(),
  7485. queue = [{
  7486. parent: fragment,
  7487. groups: groups
  7488. }];
  7489. var layersCount = 0,
  7490. hasAnyNesting = false;
  7491. while (queue.length > 0) {
  7492. var levelData = queue.shift();
  7493. var _iterator = _createForOfIteratorHelper(levelData.groups),
  7494. _step;
  7495. try {
  7496. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  7497. var groupId = _step.value;
  7498. var div = document.createElement("div");
  7499. div.className = "treeItem";
  7500. var element = document.createElement("a");
  7501. div.appendChild(element);
  7502. if (_typeof(groupId) === "object") {
  7503. hasAnyNesting = true;
  7504. this._addToggleButton(div, groupId);
  7505. this._setNestedName(element, groupId);
  7506. var itemsDiv = document.createElement("div");
  7507. itemsDiv.className = "treeItems";
  7508. div.appendChild(itemsDiv);
  7509. queue.push({
  7510. parent: itemsDiv,
  7511. groups: groupId.order
  7512. });
  7513. } else {
  7514. var group = optionalContentConfig.getGroup(groupId);
  7515. var input = document.createElement("input");
  7516. this._bindLink(element, {
  7517. groupId: groupId,
  7518. input: input
  7519. });
  7520. input.type = "checkbox";
  7521. input.id = groupId;
  7522. input.checked = group.visible;
  7523. var label = document.createElement("label");
  7524. label.setAttribute("for", groupId);
  7525. label.textContent = this._normalizeTextContent(group.name);
  7526. element.appendChild(input);
  7527. element.appendChild(label);
  7528. layersCount++;
  7529. }
  7530. levelData.parent.appendChild(div);
  7531. }
  7532. } catch (err) {
  7533. _iterator.e(err);
  7534. } finally {
  7535. _iterator.f();
  7536. }
  7537. }
  7538. if (hasAnyNesting) {
  7539. this.container.classList.add("treeWithDeepNesting");
  7540. this._lastToggleIsShow = fragment.querySelectorAll(".treeItemsHidden").length === 0;
  7541. }
  7542. this.container.appendChild(fragment);
  7543. this._dispatchEvent(layersCount);
  7544. }
  7545. }, {
  7546. key: "_resetLayers",
  7547. value: function () {
  7548. var _resetLayers2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  7549. var optionalContentConfig;
  7550. return _regenerator["default"].wrap(function _callee2$(_context2) {
  7551. while (1) {
  7552. switch (_context2.prev = _context2.next) {
  7553. case 0:
  7554. if (this._optionalContentConfig) {
  7555. _context2.next = 2;
  7556. break;
  7557. }
  7558. return _context2.abrupt("return");
  7559. case 2:
  7560. _context2.next = 4;
  7561. return this._pdfDocument.getOptionalContentConfig();
  7562. case 4:
  7563. optionalContentConfig = _context2.sent;
  7564. this.eventBus.dispatch("optionalcontentconfig", {
  7565. source: this,
  7566. promise: Promise.resolve(optionalContentConfig)
  7567. });
  7568. this.render({
  7569. optionalContentConfig: optionalContentConfig,
  7570. pdfDocument: this._pdfDocument
  7571. });
  7572. case 7:
  7573. case "end":
  7574. return _context2.stop();
  7575. }
  7576. }
  7577. }, _callee2, this);
  7578. }));
  7579. function _resetLayers() {
  7580. return _resetLayers2.apply(this, arguments);
  7581. }
  7582. return _resetLayers;
  7583. }()
  7584. }]);
  7585. return PDFLayerViewer;
  7586. }(_base_tree_viewer.BaseTreeViewer);
  7587. exports.PDFLayerViewer = PDFLayerViewer;
  7588. /***/ }),
  7589. /* 23 */
  7590. /***/ (function(module, exports, __webpack_require__) {
  7591. "use strict";
  7592. Object.defineProperty(exports, "__esModule", {
  7593. value: true
  7594. });
  7595. exports.SimpleLinkService = exports.PDFLinkService = void 0;
  7596. var _ui_utils = __webpack_require__(5);
  7597. 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); }
  7598. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7599. 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); } }
  7600. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7601. var PDFLinkService = /*#__PURE__*/function () {
  7602. function PDFLinkService() {
  7603. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  7604. eventBus = _ref.eventBus,
  7605. _ref$externalLinkTarg = _ref.externalLinkTarget,
  7606. externalLinkTarget = _ref$externalLinkTarg === void 0 ? null : _ref$externalLinkTarg,
  7607. _ref$externalLinkRel = _ref.externalLinkRel,
  7608. externalLinkRel = _ref$externalLinkRel === void 0 ? null : _ref$externalLinkRel,
  7609. _ref$externalLinkEnab = _ref.externalLinkEnabled,
  7610. externalLinkEnabled = _ref$externalLinkEnab === void 0 ? true : _ref$externalLinkEnab,
  7611. _ref$ignoreDestinatio = _ref.ignoreDestinationZoom,
  7612. ignoreDestinationZoom = _ref$ignoreDestinatio === void 0 ? false : _ref$ignoreDestinatio;
  7613. _classCallCheck(this, PDFLinkService);
  7614. this.eventBus = eventBus;
  7615. this.externalLinkTarget = externalLinkTarget;
  7616. this.externalLinkRel = externalLinkRel;
  7617. this.externalLinkEnabled = externalLinkEnabled;
  7618. this._ignoreDestinationZoom = ignoreDestinationZoom;
  7619. this.baseUrl = null;
  7620. this.pdfDocument = null;
  7621. this.pdfViewer = null;
  7622. this.pdfHistory = null;
  7623. this._pagesRefCache = null;
  7624. }
  7625. _createClass(PDFLinkService, [{
  7626. key: "setDocument",
  7627. value: function setDocument(pdfDocument) {
  7628. var baseUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  7629. this.baseUrl = baseUrl;
  7630. this.pdfDocument = pdfDocument;
  7631. this._pagesRefCache = Object.create(null);
  7632. }
  7633. }, {
  7634. key: "setViewer",
  7635. value: function setViewer(pdfViewer) {
  7636. this.pdfViewer = pdfViewer;
  7637. }
  7638. }, {
  7639. key: "setHistory",
  7640. value: function setHistory(pdfHistory) {
  7641. this.pdfHistory = pdfHistory;
  7642. }
  7643. }, {
  7644. key: "navigateTo",
  7645. value: function navigateTo(dest) {
  7646. var _this = this;
  7647. var goToDestination = function goToDestination(_ref2) {
  7648. var namedDest = _ref2.namedDest,
  7649. explicitDest = _ref2.explicitDest;
  7650. var destRef = explicitDest[0];
  7651. var pageNumber;
  7652. if (destRef instanceof Object) {
  7653. pageNumber = _this._cachedPageNumber(destRef);
  7654. if (pageNumber === null) {
  7655. _this.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
  7656. _this.cachePageRef(pageIndex + 1, destRef);
  7657. goToDestination({
  7658. namedDest: namedDest,
  7659. explicitDest: explicitDest
  7660. });
  7661. })["catch"](function () {
  7662. console.error("PDFLinkService.navigateTo: \"".concat(destRef, "\" is not ") + "a valid page reference, for dest=\"".concat(dest, "\"."));
  7663. });
  7664. return;
  7665. }
  7666. } else if (Number.isInteger(destRef)) {
  7667. pageNumber = destRef + 1;
  7668. } else {
  7669. console.error("PDFLinkService.navigateTo: \"".concat(destRef, "\" is not ") + "a valid destination reference, for dest=\"".concat(dest, "\"."));
  7670. return;
  7671. }
  7672. if (!pageNumber || pageNumber < 1 || pageNumber > _this.pagesCount) {
  7673. console.error("PDFLinkService.navigateTo: \"".concat(pageNumber, "\" is not ") + "a valid page number, for dest=\"".concat(dest, "\"."));
  7674. return;
  7675. }
  7676. if (_this.pdfHistory) {
  7677. _this.pdfHistory.pushCurrentPosition();
  7678. _this.pdfHistory.push({
  7679. namedDest: namedDest,
  7680. explicitDest: explicitDest,
  7681. pageNumber: pageNumber
  7682. });
  7683. }
  7684. _this.pdfViewer.scrollPageIntoView({
  7685. pageNumber: pageNumber,
  7686. destArray: explicitDest,
  7687. ignoreDestinationZoom: _this._ignoreDestinationZoom
  7688. });
  7689. };
  7690. new Promise(function (resolve, reject) {
  7691. if (typeof dest === "string") {
  7692. _this.pdfDocument.getDestination(dest).then(function (destArray) {
  7693. resolve({
  7694. namedDest: dest,
  7695. explicitDest: destArray
  7696. });
  7697. });
  7698. return;
  7699. }
  7700. resolve({
  7701. namedDest: "",
  7702. explicitDest: dest
  7703. });
  7704. }).then(function (data) {
  7705. if (!Array.isArray(data.explicitDest)) {
  7706. console.error("PDFLinkService.navigateTo: \"".concat(data.explicitDest, "\" is") + " not a valid destination array, for dest=\"".concat(dest, "\"."));
  7707. return;
  7708. }
  7709. goToDestination(data);
  7710. });
  7711. }
  7712. }, {
  7713. key: "getDestinationHash",
  7714. value: function getDestinationHash(dest) {
  7715. if (typeof dest === "string") {
  7716. return this.getAnchorUrl("#" + escape(dest));
  7717. }
  7718. if (Array.isArray(dest)) {
  7719. var str = JSON.stringify(dest);
  7720. return this.getAnchorUrl("#" + escape(str));
  7721. }
  7722. return this.getAnchorUrl("");
  7723. }
  7724. }, {
  7725. key: "getAnchorUrl",
  7726. value: function getAnchorUrl(anchor) {
  7727. return (this.baseUrl || "") + anchor;
  7728. }
  7729. }, {
  7730. key: "setHash",
  7731. value: function setHash(hash) {
  7732. var pageNumber, dest;
  7733. if (hash.includes("=")) {
  7734. var params = (0, _ui_utils.parseQueryString)(hash);
  7735. if ("search" in params) {
  7736. this.eventBus.dispatch("findfromurlhash", {
  7737. source: this,
  7738. query: params.search.replace(/"/g, ""),
  7739. phraseSearch: params.phrase === "true"
  7740. });
  7741. }
  7742. if ("page" in params) {
  7743. pageNumber = params.page | 0 || 1;
  7744. }
  7745. if ("zoom" in params) {
  7746. var zoomArgs = params.zoom.split(",");
  7747. var zoomArg = zoomArgs[0];
  7748. var zoomArgNumber = parseFloat(zoomArg);
  7749. if (!zoomArg.includes("Fit")) {
  7750. dest = [null, {
  7751. name: "XYZ"
  7752. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
  7753. } else {
  7754. if (zoomArg === "Fit" || zoomArg === "FitB") {
  7755. dest = [null, {
  7756. name: zoomArg
  7757. }];
  7758. } else if (zoomArg === "FitH" || zoomArg === "FitBH" || zoomArg === "FitV" || zoomArg === "FitBV") {
  7759. dest = [null, {
  7760. name: zoomArg
  7761. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  7762. } else if (zoomArg === "FitR") {
  7763. if (zoomArgs.length !== 5) {
  7764. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
  7765. } else {
  7766. dest = [null, {
  7767. name: zoomArg
  7768. }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
  7769. }
  7770. } else {
  7771. console.error("PDFLinkService.setHash: \"".concat(zoomArg, "\" is not ") + "a valid zoom value.");
  7772. }
  7773. }
  7774. }
  7775. if (dest) {
  7776. this.pdfViewer.scrollPageIntoView({
  7777. pageNumber: pageNumber || this.page,
  7778. destArray: dest,
  7779. allowNegativeOffset: true
  7780. });
  7781. } else if (pageNumber) {
  7782. this.page = pageNumber;
  7783. }
  7784. if ("pagemode" in params) {
  7785. this.eventBus.dispatch("pagemode", {
  7786. source: this,
  7787. mode: params.pagemode
  7788. });
  7789. }
  7790. if ("nameddest" in params) {
  7791. this.navigateTo(params.nameddest);
  7792. }
  7793. } else {
  7794. dest = unescape(hash);
  7795. try {
  7796. dest = JSON.parse(dest);
  7797. if (!Array.isArray(dest)) {
  7798. dest = dest.toString();
  7799. }
  7800. } catch (ex) {}
  7801. if (typeof dest === "string" || isValidExplicitDestination(dest)) {
  7802. this.navigateTo(dest);
  7803. return;
  7804. }
  7805. console.error("PDFLinkService.setHash: \"".concat(unescape(hash), "\" is not ") + "a valid destination.");
  7806. }
  7807. }
  7808. }, {
  7809. key: "executeNamedAction",
  7810. value: function executeNamedAction(action) {
  7811. switch (action) {
  7812. case "GoBack":
  7813. if (this.pdfHistory) {
  7814. this.pdfHistory.back();
  7815. }
  7816. break;
  7817. case "GoForward":
  7818. if (this.pdfHistory) {
  7819. this.pdfHistory.forward();
  7820. }
  7821. break;
  7822. case "NextPage":
  7823. if (this.page < this.pagesCount) {
  7824. this.page++;
  7825. }
  7826. break;
  7827. case "PrevPage":
  7828. if (this.page > 1) {
  7829. this.page--;
  7830. }
  7831. break;
  7832. case "LastPage":
  7833. this.page = this.pagesCount;
  7834. break;
  7835. case "FirstPage":
  7836. this.page = 1;
  7837. break;
  7838. default:
  7839. break;
  7840. }
  7841. this.eventBus.dispatch("namedaction", {
  7842. source: this,
  7843. action: action
  7844. });
  7845. }
  7846. }, {
  7847. key: "cachePageRef",
  7848. value: function cachePageRef(pageNum, pageRef) {
  7849. if (!pageRef) {
  7850. return;
  7851. }
  7852. var refStr = pageRef.gen === 0 ? "".concat(pageRef.num, "R") : "".concat(pageRef.num, "R").concat(pageRef.gen);
  7853. this._pagesRefCache[refStr] = pageNum;
  7854. }
  7855. }, {
  7856. key: "_cachedPageNumber",
  7857. value: function _cachedPageNumber(pageRef) {
  7858. var refStr = pageRef.gen === 0 ? "".concat(pageRef.num, "R") : "".concat(pageRef.num, "R").concat(pageRef.gen);
  7859. return this._pagesRefCache && this._pagesRefCache[refStr] || null;
  7860. }
  7861. }, {
  7862. key: "isPageVisible",
  7863. value: function isPageVisible(pageNumber) {
  7864. return this.pdfViewer.isPageVisible(pageNumber);
  7865. }
  7866. }, {
  7867. key: "pagesCount",
  7868. get: function get() {
  7869. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  7870. }
  7871. }, {
  7872. key: "page",
  7873. get: function get() {
  7874. return this.pdfViewer.currentPageNumber;
  7875. },
  7876. set: function set(value) {
  7877. this.pdfViewer.currentPageNumber = value;
  7878. }
  7879. }, {
  7880. key: "rotation",
  7881. get: function get() {
  7882. return this.pdfViewer.pagesRotation;
  7883. },
  7884. set: function set(value) {
  7885. this.pdfViewer.pagesRotation = value;
  7886. }
  7887. }]);
  7888. return PDFLinkService;
  7889. }();
  7890. exports.PDFLinkService = PDFLinkService;
  7891. function isValidExplicitDestination(dest) {
  7892. if (!Array.isArray(dest)) {
  7893. return false;
  7894. }
  7895. var destLength = dest.length;
  7896. if (destLength < 2) {
  7897. return false;
  7898. }
  7899. var page = dest[0];
  7900. if (!(_typeof(page) === "object" && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
  7901. return false;
  7902. }
  7903. var zoom = dest[1];
  7904. if (!(_typeof(zoom) === "object" && typeof zoom.name === "string")) {
  7905. return false;
  7906. }
  7907. var allowNull = true;
  7908. switch (zoom.name) {
  7909. case "XYZ":
  7910. if (destLength !== 5) {
  7911. return false;
  7912. }
  7913. break;
  7914. case "Fit":
  7915. case "FitB":
  7916. return destLength === 2;
  7917. case "FitH":
  7918. case "FitBH":
  7919. case "FitV":
  7920. case "FitBV":
  7921. if (destLength !== 3) {
  7922. return false;
  7923. }
  7924. break;
  7925. case "FitR":
  7926. if (destLength !== 6) {
  7927. return false;
  7928. }
  7929. allowNull = false;
  7930. break;
  7931. default:
  7932. return false;
  7933. }
  7934. for (var i = 2; i < destLength; i++) {
  7935. var param = dest[i];
  7936. if (!(typeof param === "number" || allowNull && param === null)) {
  7937. return false;
  7938. }
  7939. }
  7940. return true;
  7941. }
  7942. var SimpleLinkService = /*#__PURE__*/function () {
  7943. function SimpleLinkService() {
  7944. _classCallCheck(this, SimpleLinkService);
  7945. this.externalLinkTarget = null;
  7946. this.externalLinkRel = null;
  7947. this.externalLinkEnabled = true;
  7948. this._ignoreDestinationZoom = false;
  7949. }
  7950. _createClass(SimpleLinkService, [{
  7951. key: "navigateTo",
  7952. value: function navigateTo(dest) {}
  7953. }, {
  7954. key: "getDestinationHash",
  7955. value: function getDestinationHash(dest) {
  7956. return "#";
  7957. }
  7958. }, {
  7959. key: "getAnchorUrl",
  7960. value: function getAnchorUrl(hash) {
  7961. return "#";
  7962. }
  7963. }, {
  7964. key: "setHash",
  7965. value: function setHash(hash) {}
  7966. }, {
  7967. key: "executeNamedAction",
  7968. value: function executeNamedAction(action) {}
  7969. }, {
  7970. key: "cachePageRef",
  7971. value: function cachePageRef(pageNum, pageRef) {}
  7972. }, {
  7973. key: "isPageVisible",
  7974. value: function isPageVisible(pageNumber) {
  7975. return true;
  7976. }
  7977. }, {
  7978. key: "pagesCount",
  7979. get: function get() {
  7980. return 0;
  7981. }
  7982. }, {
  7983. key: "page",
  7984. get: function get() {
  7985. return 0;
  7986. },
  7987. set: function set(value) {}
  7988. }, {
  7989. key: "rotation",
  7990. get: function get() {
  7991. return 0;
  7992. },
  7993. set: function set(value) {}
  7994. }]);
  7995. return SimpleLinkService;
  7996. }();
  7997. exports.SimpleLinkService = SimpleLinkService;
  7998. /***/ }),
  7999. /* 24 */
  8000. /***/ (function(module, exports, __webpack_require__) {
  8001. "use strict";
  8002. Object.defineProperty(exports, "__esModule", {
  8003. value: true
  8004. });
  8005. exports.PDFOutlineViewer = void 0;
  8006. var _pdfjsLib = __webpack_require__(8);
  8007. var _base_tree_viewer = __webpack_require__(16);
  8008. 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); }
  8009. 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; } } }; }
  8010. 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); }
  8011. 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; }
  8012. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8013. 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); } }
  8014. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8015. 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); }
  8016. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  8017. 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); }
  8018. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  8019. 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); }; }
  8020. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  8021. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  8022. 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; } }
  8023. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  8024. var PDFOutlineViewer = /*#__PURE__*/function (_BaseTreeViewer) {
  8025. _inherits(PDFOutlineViewer, _BaseTreeViewer);
  8026. var _super = _createSuper(PDFOutlineViewer);
  8027. function PDFOutlineViewer(options) {
  8028. var _this;
  8029. _classCallCheck(this, PDFOutlineViewer);
  8030. _this = _super.call(this, options);
  8031. _this.linkService = options.linkService;
  8032. _this.eventBus._on("toggleoutlinetree", _this._toggleAllTreeItems.bind(_assertThisInitialized(_this)));
  8033. return _this;
  8034. }
  8035. _createClass(PDFOutlineViewer, [{
  8036. key: "reset",
  8037. value: function reset() {
  8038. _get(_getPrototypeOf(PDFOutlineViewer.prototype), "reset", this).call(this);
  8039. this._outline = null;
  8040. }
  8041. }, {
  8042. key: "_dispatchEvent",
  8043. value: function _dispatchEvent(outlineCount) {
  8044. this.eventBus.dispatch("outlineloaded", {
  8045. source: this,
  8046. outlineCount: outlineCount
  8047. });
  8048. }
  8049. }, {
  8050. key: "_bindLink",
  8051. value: function _bindLink(element, _ref) {
  8052. var url = _ref.url,
  8053. newWindow = _ref.newWindow,
  8054. dest = _ref.dest;
  8055. var linkService = this.linkService;
  8056. if (url) {
  8057. (0, _pdfjsLib.addLinkAttributes)(element, {
  8058. url: url,
  8059. target: newWindow ? _pdfjsLib.LinkTarget.BLANK : linkService.externalLinkTarget,
  8060. rel: linkService.externalLinkRel,
  8061. enabled: linkService.externalLinkEnabled
  8062. });
  8063. return;
  8064. }
  8065. element.href = linkService.getDestinationHash(dest);
  8066. element.onclick = function () {
  8067. if (dest) {
  8068. linkService.navigateTo(dest);
  8069. }
  8070. return false;
  8071. };
  8072. }
  8073. }, {
  8074. key: "_setStyles",
  8075. value: function _setStyles(element, _ref2) {
  8076. var bold = _ref2.bold,
  8077. italic = _ref2.italic;
  8078. if (bold) {
  8079. element.style.fontWeight = "bold";
  8080. }
  8081. if (italic) {
  8082. element.style.fontStyle = "italic";
  8083. }
  8084. }
  8085. }, {
  8086. key: "_addToggleButton",
  8087. value: function _addToggleButton(div, _ref3) {
  8088. var count = _ref3.count,
  8089. items = _ref3.items;
  8090. var hidden = count < 0 && Math.abs(count) === items.length;
  8091. _get(_getPrototypeOf(PDFOutlineViewer.prototype), "_addToggleButton", this).call(this, div, hidden);
  8092. }
  8093. }, {
  8094. key: "_toggleAllTreeItems",
  8095. value: function _toggleAllTreeItems() {
  8096. if (!this._outline) {
  8097. return;
  8098. }
  8099. _get(_getPrototypeOf(PDFOutlineViewer.prototype), "_toggleAllTreeItems", this).call(this);
  8100. }
  8101. }, {
  8102. key: "render",
  8103. value: function render(_ref4) {
  8104. var outline = _ref4.outline;
  8105. if (this._outline) {
  8106. this.reset();
  8107. }
  8108. this._outline = outline || null;
  8109. if (!outline) {
  8110. this._dispatchEvent(0);
  8111. return;
  8112. }
  8113. var fragment = document.createDocumentFragment();
  8114. var queue = [{
  8115. parent: fragment,
  8116. items: outline
  8117. }];
  8118. var outlineCount = 0,
  8119. hasAnyNesting = false;
  8120. while (queue.length > 0) {
  8121. var levelData = queue.shift();
  8122. var _iterator = _createForOfIteratorHelper(levelData.items),
  8123. _step;
  8124. try {
  8125. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  8126. var item = _step.value;
  8127. var div = document.createElement("div");
  8128. div.className = "treeItem";
  8129. var element = document.createElement("a");
  8130. this._bindLink(element, item);
  8131. this._setStyles(element, item);
  8132. element.textContent = this._normalizeTextContent(item.title);
  8133. div.appendChild(element);
  8134. if (item.items.length > 0) {
  8135. hasAnyNesting = true;
  8136. this._addToggleButton(div, item);
  8137. var itemsDiv = document.createElement("div");
  8138. itemsDiv.className = "treeItems";
  8139. div.appendChild(itemsDiv);
  8140. queue.push({
  8141. parent: itemsDiv,
  8142. items: item.items
  8143. });
  8144. }
  8145. levelData.parent.appendChild(div);
  8146. outlineCount++;
  8147. }
  8148. } catch (err) {
  8149. _iterator.e(err);
  8150. } finally {
  8151. _iterator.f();
  8152. }
  8153. }
  8154. if (hasAnyNesting) {
  8155. this.container.classList.add("treeWithDeepNesting");
  8156. this._lastToggleIsShow = fragment.querySelectorAll(".treeItemsHidden").length === 0;
  8157. }
  8158. this.container.appendChild(fragment);
  8159. this._dispatchEvent(outlineCount);
  8160. }
  8161. }]);
  8162. return PDFOutlineViewer;
  8163. }(_base_tree_viewer.BaseTreeViewer);
  8164. exports.PDFOutlineViewer = PDFOutlineViewer;
  8165. /***/ }),
  8166. /* 25 */
  8167. /***/ (function(module, exports, __webpack_require__) {
  8168. "use strict";
  8169. Object.defineProperty(exports, "__esModule", {
  8170. value: true
  8171. });
  8172. exports.PDFPresentationMode = void 0;
  8173. var _ui_utils = __webpack_require__(5);
  8174. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8175. 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); } }
  8176. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8177. var DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1500;
  8178. var DELAY_BEFORE_HIDING_CONTROLS = 3000;
  8179. var ACTIVE_SELECTOR = "pdfPresentationMode";
  8180. var CONTROLS_SELECTOR = "pdfPresentationModeControls";
  8181. var MOUSE_SCROLL_COOLDOWN_TIME = 50;
  8182. var PAGE_SWITCH_THRESHOLD = 0.1;
  8183. var SWIPE_MIN_DISTANCE_THRESHOLD = 50;
  8184. var SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
  8185. var PDFPresentationMode = /*#__PURE__*/function () {
  8186. function PDFPresentationMode(_ref) {
  8187. var _this = this;
  8188. var container = _ref.container,
  8189. pdfViewer = _ref.pdfViewer,
  8190. eventBus = _ref.eventBus,
  8191. _ref$contextMenuItems = _ref.contextMenuItems,
  8192. contextMenuItems = _ref$contextMenuItems === void 0 ? null : _ref$contextMenuItems;
  8193. _classCallCheck(this, PDFPresentationMode);
  8194. this.container = container;
  8195. this.pdfViewer = pdfViewer;
  8196. this.eventBus = eventBus;
  8197. this.active = false;
  8198. this.args = null;
  8199. this.contextMenuOpen = false;
  8200. this.mouseScrollTimeStamp = 0;
  8201. this.mouseScrollDelta = 0;
  8202. this.touchSwipeState = null;
  8203. if (contextMenuItems) {
  8204. contextMenuItems.contextFirstPage.addEventListener("click", function () {
  8205. _this.contextMenuOpen = false;
  8206. _this.eventBus.dispatch("firstpage", {
  8207. source: _this
  8208. });
  8209. });
  8210. contextMenuItems.contextLastPage.addEventListener("click", function () {
  8211. _this.contextMenuOpen = false;
  8212. _this.eventBus.dispatch("lastpage", {
  8213. source: _this
  8214. });
  8215. });
  8216. contextMenuItems.contextPageRotateCw.addEventListener("click", function () {
  8217. _this.contextMenuOpen = false;
  8218. _this.eventBus.dispatch("rotatecw", {
  8219. source: _this
  8220. });
  8221. });
  8222. contextMenuItems.contextPageRotateCcw.addEventListener("click", function () {
  8223. _this.contextMenuOpen = false;
  8224. _this.eventBus.dispatch("rotateccw", {
  8225. source: _this
  8226. });
  8227. });
  8228. }
  8229. }
  8230. _createClass(PDFPresentationMode, [{
  8231. key: "request",
  8232. value: function request() {
  8233. if (this.switchInProgress || this.active || !this.pdfViewer.pagesCount) {
  8234. return false;
  8235. }
  8236. this._addFullscreenChangeListeners();
  8237. this._setSwitchInProgress();
  8238. this._notifyStateChange();
  8239. if (this.container.requestFullscreen) {
  8240. this.container.requestFullscreen();
  8241. } else if (this.container.mozRequestFullScreen) {
  8242. this.container.mozRequestFullScreen();
  8243. } else if (this.container.webkitRequestFullscreen) {
  8244. this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
  8245. } else if (this.container.msRequestFullscreen) {
  8246. this.container.msRequestFullscreen();
  8247. } else {
  8248. return false;
  8249. }
  8250. this.args = {
  8251. page: this.pdfViewer.currentPageNumber,
  8252. previousScale: this.pdfViewer.currentScaleValue
  8253. };
  8254. return true;
  8255. }
  8256. }, {
  8257. key: "_mouseWheel",
  8258. value: function _mouseWheel(evt) {
  8259. if (!this.active) {
  8260. return;
  8261. }
  8262. evt.preventDefault();
  8263. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  8264. var currentTime = new Date().getTime();
  8265. var storedTime = this.mouseScrollTimeStamp;
  8266. if (currentTime > storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {
  8267. return;
  8268. }
  8269. if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) {
  8270. this._resetMouseScrollState();
  8271. }
  8272. this.mouseScrollDelta += delta;
  8273. if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
  8274. var totalDelta = this.mouseScrollDelta;
  8275. this._resetMouseScrollState();
  8276. var success = totalDelta > 0 ? this._goToPreviousPage() : this._goToNextPage();
  8277. if (success) {
  8278. this.mouseScrollTimeStamp = currentTime;
  8279. }
  8280. }
  8281. }
  8282. }, {
  8283. key: "_goToPreviousPage",
  8284. value: function _goToPreviousPage() {
  8285. var page = this.pdfViewer.currentPageNumber;
  8286. if (page <= 1) {
  8287. return false;
  8288. }
  8289. this.pdfViewer.currentPageNumber = page - 1;
  8290. return true;
  8291. }
  8292. }, {
  8293. key: "_goToNextPage",
  8294. value: function _goToNextPage() {
  8295. var page = this.pdfViewer.currentPageNumber;
  8296. if (page >= this.pdfViewer.pagesCount) {
  8297. return false;
  8298. }
  8299. this.pdfViewer.currentPageNumber = page + 1;
  8300. return true;
  8301. }
  8302. }, {
  8303. key: "_notifyStateChange",
  8304. value: function _notifyStateChange() {
  8305. this.eventBus.dispatch("presentationmodechanged", {
  8306. source: this,
  8307. active: this.active,
  8308. switchInProgress: !!this.switchInProgress
  8309. });
  8310. }
  8311. }, {
  8312. key: "_setSwitchInProgress",
  8313. value: function _setSwitchInProgress() {
  8314. var _this2 = this;
  8315. if (this.switchInProgress) {
  8316. clearTimeout(this.switchInProgress);
  8317. }
  8318. this.switchInProgress = setTimeout(function () {
  8319. _this2._removeFullscreenChangeListeners();
  8320. delete _this2.switchInProgress;
  8321. _this2._notifyStateChange();
  8322. }, DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS);
  8323. }
  8324. }, {
  8325. key: "_resetSwitchInProgress",
  8326. value: function _resetSwitchInProgress() {
  8327. if (this.switchInProgress) {
  8328. clearTimeout(this.switchInProgress);
  8329. delete this.switchInProgress;
  8330. }
  8331. }
  8332. }, {
  8333. key: "_enter",
  8334. value: function _enter() {
  8335. var _this3 = this;
  8336. this.active = true;
  8337. this._resetSwitchInProgress();
  8338. this._notifyStateChange();
  8339. this.container.classList.add(ACTIVE_SELECTOR);
  8340. setTimeout(function () {
  8341. _this3.pdfViewer.currentPageNumber = _this3.args.page;
  8342. _this3.pdfViewer.currentScaleValue = "page-fit";
  8343. }, 0);
  8344. this._addWindowListeners();
  8345. this._showControls();
  8346. this.contextMenuOpen = false;
  8347. this.container.setAttribute("contextmenu", "viewerContextMenu");
  8348. window.getSelection().removeAllRanges();
  8349. }
  8350. }, {
  8351. key: "_exit",
  8352. value: function _exit() {
  8353. var _this4 = this;
  8354. var page = this.pdfViewer.currentPageNumber;
  8355. this.container.classList.remove(ACTIVE_SELECTOR);
  8356. setTimeout(function () {
  8357. _this4.active = false;
  8358. _this4._removeFullscreenChangeListeners();
  8359. _this4._notifyStateChange();
  8360. _this4.pdfViewer.currentScaleValue = _this4.args.previousScale;
  8361. _this4.pdfViewer.currentPageNumber = page;
  8362. _this4.args = null;
  8363. }, 0);
  8364. this._removeWindowListeners();
  8365. this._hideControls();
  8366. this._resetMouseScrollState();
  8367. this.container.removeAttribute("contextmenu");
  8368. this.contextMenuOpen = false;
  8369. }
  8370. }, {
  8371. key: "_mouseDown",
  8372. value: function _mouseDown(evt) {
  8373. if (this.contextMenuOpen) {
  8374. this.contextMenuOpen = false;
  8375. evt.preventDefault();
  8376. return;
  8377. }
  8378. if (evt.button === 0) {
  8379. var isInternalLink = evt.target.href && evt.target.classList.contains("internalLink");
  8380. if (!isInternalLink) {
  8381. evt.preventDefault();
  8382. if (evt.shiftKey) {
  8383. this._goToPreviousPage();
  8384. } else {
  8385. this._goToNextPage();
  8386. }
  8387. }
  8388. }
  8389. }
  8390. }, {
  8391. key: "_contextMenu",
  8392. value: function _contextMenu() {
  8393. this.contextMenuOpen = true;
  8394. }
  8395. }, {
  8396. key: "_showControls",
  8397. value: function _showControls() {
  8398. var _this5 = this;
  8399. if (this.controlsTimeout) {
  8400. clearTimeout(this.controlsTimeout);
  8401. } else {
  8402. this.container.classList.add(CONTROLS_SELECTOR);
  8403. }
  8404. this.controlsTimeout = setTimeout(function () {
  8405. _this5.container.classList.remove(CONTROLS_SELECTOR);
  8406. delete _this5.controlsTimeout;
  8407. }, DELAY_BEFORE_HIDING_CONTROLS);
  8408. }
  8409. }, {
  8410. key: "_hideControls",
  8411. value: function _hideControls() {
  8412. if (!this.controlsTimeout) {
  8413. return;
  8414. }
  8415. clearTimeout(this.controlsTimeout);
  8416. this.container.classList.remove(CONTROLS_SELECTOR);
  8417. delete this.controlsTimeout;
  8418. }
  8419. }, {
  8420. key: "_resetMouseScrollState",
  8421. value: function _resetMouseScrollState() {
  8422. this.mouseScrollTimeStamp = 0;
  8423. this.mouseScrollDelta = 0;
  8424. }
  8425. }, {
  8426. key: "_touchSwipe",
  8427. value: function _touchSwipe(evt) {
  8428. if (!this.active) {
  8429. return;
  8430. }
  8431. if (evt.touches.length > 1) {
  8432. this.touchSwipeState = null;
  8433. return;
  8434. }
  8435. switch (evt.type) {
  8436. case "touchstart":
  8437. this.touchSwipeState = {
  8438. startX: evt.touches[0].pageX,
  8439. startY: evt.touches[0].pageY,
  8440. endX: evt.touches[0].pageX,
  8441. endY: evt.touches[0].pageY
  8442. };
  8443. break;
  8444. case "touchmove":
  8445. if (this.touchSwipeState === null) {
  8446. return;
  8447. }
  8448. this.touchSwipeState.endX = evt.touches[0].pageX;
  8449. this.touchSwipeState.endY = evt.touches[0].pageY;
  8450. evt.preventDefault();
  8451. break;
  8452. case "touchend":
  8453. if (this.touchSwipeState === null) {
  8454. return;
  8455. }
  8456. var delta = 0;
  8457. var dx = this.touchSwipeState.endX - this.touchSwipeState.startX;
  8458. var dy = this.touchSwipeState.endY - this.touchSwipeState.startY;
  8459. var absAngle = Math.abs(Math.atan2(dy, dx));
  8460. if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <= SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI - SWIPE_ANGLE_THRESHOLD)) {
  8461. delta = dx;
  8462. } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math.abs(absAngle - Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) {
  8463. delta = dy;
  8464. }
  8465. if (delta > 0) {
  8466. this._goToPreviousPage();
  8467. } else if (delta < 0) {
  8468. this._goToNextPage();
  8469. }
  8470. break;
  8471. }
  8472. }
  8473. }, {
  8474. key: "_addWindowListeners",
  8475. value: function _addWindowListeners() {
  8476. this.showControlsBind = this._showControls.bind(this);
  8477. this.mouseDownBind = this._mouseDown.bind(this);
  8478. this.mouseWheelBind = this._mouseWheel.bind(this);
  8479. this.resetMouseScrollStateBind = this._resetMouseScrollState.bind(this);
  8480. this.contextMenuBind = this._contextMenu.bind(this);
  8481. this.touchSwipeBind = this._touchSwipe.bind(this);
  8482. window.addEventListener("mousemove", this.showControlsBind);
  8483. window.addEventListener("mousedown", this.mouseDownBind);
  8484. window.addEventListener("wheel", this.mouseWheelBind, {
  8485. passive: false
  8486. });
  8487. window.addEventListener("keydown", this.resetMouseScrollStateBind);
  8488. window.addEventListener("contextmenu", this.contextMenuBind);
  8489. window.addEventListener("touchstart", this.touchSwipeBind);
  8490. window.addEventListener("touchmove", this.touchSwipeBind);
  8491. window.addEventListener("touchend", this.touchSwipeBind);
  8492. }
  8493. }, {
  8494. key: "_removeWindowListeners",
  8495. value: function _removeWindowListeners() {
  8496. window.removeEventListener("mousemove", this.showControlsBind);
  8497. window.removeEventListener("mousedown", this.mouseDownBind);
  8498. window.removeEventListener("wheel", this.mouseWheelBind, {
  8499. passive: false
  8500. });
  8501. window.removeEventListener("keydown", this.resetMouseScrollStateBind);
  8502. window.removeEventListener("contextmenu", this.contextMenuBind);
  8503. window.removeEventListener("touchstart", this.touchSwipeBind);
  8504. window.removeEventListener("touchmove", this.touchSwipeBind);
  8505. window.removeEventListener("touchend", this.touchSwipeBind);
  8506. delete this.showControlsBind;
  8507. delete this.mouseDownBind;
  8508. delete this.mouseWheelBind;
  8509. delete this.resetMouseScrollStateBind;
  8510. delete this.contextMenuBind;
  8511. delete this.touchSwipeBind;
  8512. }
  8513. }, {
  8514. key: "_fullscreenChange",
  8515. value: function _fullscreenChange() {
  8516. if (this.isFullscreen) {
  8517. this._enter();
  8518. } else {
  8519. this._exit();
  8520. }
  8521. }
  8522. }, {
  8523. key: "_addFullscreenChangeListeners",
  8524. value: function _addFullscreenChangeListeners() {
  8525. this.fullscreenChangeBind = this._fullscreenChange.bind(this);
  8526. window.addEventListener("fullscreenchange", this.fullscreenChangeBind);
  8527. window.addEventListener("mozfullscreenchange", this.fullscreenChangeBind);
  8528. window.addEventListener("webkitfullscreenchange", this.fullscreenChangeBind);
  8529. window.addEventListener("MSFullscreenChange", this.fullscreenChangeBind);
  8530. }
  8531. }, {
  8532. key: "_removeFullscreenChangeListeners",
  8533. value: function _removeFullscreenChangeListeners() {
  8534. window.removeEventListener("fullscreenchange", this.fullscreenChangeBind);
  8535. window.removeEventListener("mozfullscreenchange", this.fullscreenChangeBind);
  8536. window.removeEventListener("webkitfullscreenchange", this.fullscreenChangeBind);
  8537. window.removeEventListener("MSFullscreenChange", this.fullscreenChangeBind);
  8538. delete this.fullscreenChangeBind;
  8539. }
  8540. }, {
  8541. key: "isFullscreen",
  8542. get: function get() {
  8543. return !!(document.fullscreenElement || document.mozFullScreen || document.webkitIsFullScreen || document.msFullscreenElement);
  8544. }
  8545. }]);
  8546. return PDFPresentationMode;
  8547. }();
  8548. exports.PDFPresentationMode = PDFPresentationMode;
  8549. /***/ }),
  8550. /* 26 */
  8551. /***/ (function(module, exports, __webpack_require__) {
  8552. "use strict";
  8553. Object.defineProperty(exports, "__esModule", {
  8554. value: true
  8555. });
  8556. exports.PDFSidebarResizer = void 0;
  8557. var _ui_utils = __webpack_require__(5);
  8558. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8559. 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); } }
  8560. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8561. var SIDEBAR_WIDTH_VAR = "--sidebar-width";
  8562. var SIDEBAR_MIN_WIDTH = 200;
  8563. var SIDEBAR_RESIZING_CLASS = "sidebarResizing";
  8564. var PDFSidebarResizer = /*#__PURE__*/function () {
  8565. function PDFSidebarResizer(options, eventBus) {
  8566. var _this = this;
  8567. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  8568. _classCallCheck(this, PDFSidebarResizer);
  8569. this.enabled = false;
  8570. this.isRTL = false;
  8571. this.sidebarOpen = false;
  8572. this.doc = document.documentElement;
  8573. this._width = null;
  8574. this._outerContainerWidth = null;
  8575. this._boundEvents = Object.create(null);
  8576. this.outerContainer = options.outerContainer;
  8577. this.resizer = options.resizer;
  8578. this.eventBus = eventBus;
  8579. this.l10n = l10n;
  8580. if (typeof CSS === "undefined" || typeof CSS.supports !== "function" || !CSS.supports(SIDEBAR_WIDTH_VAR, "calc(-1 * ".concat(SIDEBAR_MIN_WIDTH, "px)"))) {
  8581. console.warn("PDFSidebarResizer: " + "The browser does not support resizing of the sidebar.");
  8582. return;
  8583. }
  8584. this.enabled = true;
  8585. this.resizer.classList.remove("hidden");
  8586. this.l10n.getDirection().then(function (dir) {
  8587. _this.isRTL = dir === "rtl";
  8588. });
  8589. this._addEventListeners();
  8590. }
  8591. _createClass(PDFSidebarResizer, [{
  8592. key: "_updateWidth",
  8593. value: function _updateWidth() {
  8594. var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  8595. if (!this.enabled) {
  8596. return false;
  8597. }
  8598. var newWidth = (0, _ui_utils.clamp)(width, SIDEBAR_MIN_WIDTH, Math.floor(this.outerContainerWidth / 2));
  8599. if (newWidth === this._width) {
  8600. return false;
  8601. }
  8602. this._width = newWidth;
  8603. this.doc.style.setProperty(SIDEBAR_WIDTH_VAR, "".concat(newWidth, "px"));
  8604. return true;
  8605. }
  8606. }, {
  8607. key: "_mouseMove",
  8608. value: function _mouseMove(evt) {
  8609. var width = evt.clientX;
  8610. if (this.isRTL) {
  8611. width = this.outerContainerWidth - width;
  8612. }
  8613. this._updateWidth(width);
  8614. }
  8615. }, {
  8616. key: "_mouseUp",
  8617. value: function _mouseUp(evt) {
  8618. this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  8619. this.eventBus.dispatch("resize", {
  8620. source: this
  8621. });
  8622. var _boundEvents = this._boundEvents;
  8623. window.removeEventListener("mousemove", _boundEvents.mouseMove);
  8624. window.removeEventListener("mouseup", _boundEvents.mouseUp);
  8625. }
  8626. }, {
  8627. key: "_addEventListeners",
  8628. value: function _addEventListeners() {
  8629. var _this2 = this;
  8630. if (!this.enabled) {
  8631. return;
  8632. }
  8633. var _boundEvents = this._boundEvents;
  8634. _boundEvents.mouseMove = this._mouseMove.bind(this);
  8635. _boundEvents.mouseUp = this._mouseUp.bind(this);
  8636. this.resizer.addEventListener("mousedown", function (evt) {
  8637. if (evt.button !== 0) {
  8638. return;
  8639. }
  8640. _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  8641. window.addEventListener("mousemove", _boundEvents.mouseMove);
  8642. window.addEventListener("mouseup", _boundEvents.mouseUp);
  8643. });
  8644. this.eventBus._on("sidebarviewchanged", function (evt) {
  8645. _this2.sidebarOpen = !!(evt && evt.view);
  8646. });
  8647. this.eventBus._on("resize", function (evt) {
  8648. if (!evt || evt.source !== window) {
  8649. return;
  8650. }
  8651. _this2._outerContainerWidth = null;
  8652. if (!_this2._width) {
  8653. return;
  8654. }
  8655. if (!_this2.sidebarOpen) {
  8656. _this2._updateWidth(_this2._width);
  8657. return;
  8658. }
  8659. _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  8660. var updated = _this2._updateWidth(_this2._width);
  8661. Promise.resolve().then(function () {
  8662. _this2.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  8663. if (updated) {
  8664. _this2.eventBus.dispatch("resize", {
  8665. source: _this2
  8666. });
  8667. }
  8668. });
  8669. });
  8670. }
  8671. }, {
  8672. key: "outerContainerWidth",
  8673. get: function get() {
  8674. if (!this._outerContainerWidth) {
  8675. this._outerContainerWidth = this.outerContainer.clientWidth;
  8676. }
  8677. return this._outerContainerWidth;
  8678. }
  8679. }]);
  8680. return PDFSidebarResizer;
  8681. }();
  8682. exports.PDFSidebarResizer = PDFSidebarResizer;
  8683. /***/ }),
  8684. /* 27 */
  8685. /***/ (function(module, exports, __webpack_require__) {
  8686. "use strict";
  8687. Object.defineProperty(exports, "__esModule", {
  8688. value: true
  8689. });
  8690. exports.PDFThumbnailViewer = void 0;
  8691. var _ui_utils = __webpack_require__(5);
  8692. var _pdf_thumbnail_view = __webpack_require__(28);
  8693. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8694. 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); } }
  8695. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8696. var THUMBNAIL_SCROLL_MARGIN = -19;
  8697. var THUMBNAIL_SELECTED_CLASS = "selected";
  8698. var PDFThumbnailViewer = /*#__PURE__*/function () {
  8699. function PDFThumbnailViewer(_ref) {
  8700. var _this = this;
  8701. var container = _ref.container,
  8702. eventBus = _ref.eventBus,
  8703. linkService = _ref.linkService,
  8704. renderingQueue = _ref.renderingQueue,
  8705. _ref$l10n = _ref.l10n,
  8706. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  8707. _classCallCheck(this, PDFThumbnailViewer);
  8708. this.container = container;
  8709. this.linkService = linkService;
  8710. this.renderingQueue = renderingQueue;
  8711. this.l10n = l10n;
  8712. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdated.bind(this));
  8713. this._resetView();
  8714. eventBus._on("optionalcontentconfigchanged", function () {
  8715. _this._setImageDisabled = true;
  8716. });
  8717. }
  8718. _createClass(PDFThumbnailViewer, [{
  8719. key: "_scrollUpdated",
  8720. value: function _scrollUpdated() {
  8721. this.renderingQueue.renderHighestPriority();
  8722. }
  8723. }, {
  8724. key: "getThumbnail",
  8725. value: function getThumbnail(index) {
  8726. return this._thumbnails[index];
  8727. }
  8728. }, {
  8729. key: "_getVisibleThumbs",
  8730. value: function _getVisibleThumbs() {
  8731. return (0, _ui_utils.getVisibleElements)(this.container, this._thumbnails);
  8732. }
  8733. }, {
  8734. key: "scrollThumbnailIntoView",
  8735. value: function scrollThumbnailIntoView(pageNumber) {
  8736. if (!this.pdfDocument) {
  8737. return;
  8738. }
  8739. var thumbnailView = this._thumbnails[pageNumber - 1];
  8740. if (!thumbnailView) {
  8741. console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');
  8742. return;
  8743. }
  8744. if (pageNumber !== this._currentPageNumber) {
  8745. var prevThumbnailView = this._thumbnails[this._currentPageNumber - 1];
  8746. prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS);
  8747. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  8748. }
  8749. var visibleThumbs = this._getVisibleThumbs();
  8750. var numVisibleThumbs = visibleThumbs.views.length;
  8751. if (numVisibleThumbs > 0) {
  8752. var first = visibleThumbs.first.id;
  8753. var last = numVisibleThumbs > 1 ? visibleThumbs.last.id : first;
  8754. var shouldScroll = false;
  8755. if (pageNumber <= first || pageNumber >= last) {
  8756. shouldScroll = true;
  8757. } else {
  8758. visibleThumbs.views.some(function (view) {
  8759. if (view.id !== pageNumber) {
  8760. return false;
  8761. }
  8762. shouldScroll = view.percent < 100;
  8763. return true;
  8764. });
  8765. }
  8766. if (shouldScroll) {
  8767. (0, _ui_utils.scrollIntoView)(thumbnailView.div, {
  8768. top: THUMBNAIL_SCROLL_MARGIN
  8769. });
  8770. }
  8771. }
  8772. this._currentPageNumber = pageNumber;
  8773. }
  8774. }, {
  8775. key: "cleanup",
  8776. value: function cleanup() {
  8777. _pdf_thumbnail_view.PDFThumbnailView.cleanup();
  8778. }
  8779. }, {
  8780. key: "_resetView",
  8781. value: function _resetView() {
  8782. this._thumbnails = [];
  8783. this._currentPageNumber = 1;
  8784. this._pageLabels = null;
  8785. this._pagesRotation = 0;
  8786. this._optionalContentConfigPromise = null;
  8787. this._pagesRequests = new WeakMap();
  8788. this._setImageDisabled = false;
  8789. this.container.textContent = "";
  8790. }
  8791. }, {
  8792. key: "setDocument",
  8793. value: function setDocument(pdfDocument) {
  8794. var _this2 = this;
  8795. if (this.pdfDocument) {
  8796. this._cancelRendering();
  8797. this._resetView();
  8798. }
  8799. this.pdfDocument = pdfDocument;
  8800. if (!pdfDocument) {
  8801. return;
  8802. }
  8803. var firstPagePromise = pdfDocument.getPage(1);
  8804. var optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
  8805. firstPagePromise.then(function (firstPdfPage) {
  8806. _this2._optionalContentConfigPromise = optionalContentConfigPromise;
  8807. var pagesCount = pdfDocument.numPages;
  8808. var viewport = firstPdfPage.getViewport({
  8809. scale: 1
  8810. });
  8811. var checkSetImageDisabled = function checkSetImageDisabled() {
  8812. return _this2._setImageDisabled;
  8813. };
  8814. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  8815. var thumbnail = new _pdf_thumbnail_view.PDFThumbnailView({
  8816. container: _this2.container,
  8817. id: pageNum,
  8818. defaultViewport: viewport.clone(),
  8819. optionalContentConfigPromise: optionalContentConfigPromise,
  8820. linkService: _this2.linkService,
  8821. renderingQueue: _this2.renderingQueue,
  8822. checkSetImageDisabled: checkSetImageDisabled,
  8823. disableCanvasToImageConversion: false,
  8824. l10n: _this2.l10n
  8825. });
  8826. _this2._thumbnails.push(thumbnail);
  8827. }
  8828. var firstThumbnailView = _this2._thumbnails[0];
  8829. if (firstThumbnailView) {
  8830. firstThumbnailView.setPdfPage(firstPdfPage);
  8831. }
  8832. var thumbnailView = _this2._thumbnails[_this2._currentPageNumber - 1];
  8833. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  8834. })["catch"](function (reason) {
  8835. console.error("Unable to initialize thumbnail viewer", reason);
  8836. });
  8837. }
  8838. }, {
  8839. key: "_cancelRendering",
  8840. value: function _cancelRendering() {
  8841. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  8842. if (this._thumbnails[i]) {
  8843. this._thumbnails[i].cancelRendering();
  8844. }
  8845. }
  8846. }
  8847. }, {
  8848. key: "setPageLabels",
  8849. value: function setPageLabels(labels) {
  8850. if (!this.pdfDocument) {
  8851. return;
  8852. }
  8853. if (!labels) {
  8854. this._pageLabels = null;
  8855. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  8856. this._pageLabels = null;
  8857. console.error("PDFThumbnailViewer_setPageLabels: Invalid page labels.");
  8858. } else {
  8859. this._pageLabels = labels;
  8860. }
  8861. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  8862. var label = this._pageLabels && this._pageLabels[i];
  8863. this._thumbnails[i].setPageLabel(label);
  8864. }
  8865. }
  8866. }, {
  8867. key: "_ensurePdfPageLoaded",
  8868. value: function _ensurePdfPageLoaded(thumbView) {
  8869. var _this3 = this;
  8870. if (thumbView.pdfPage) {
  8871. return Promise.resolve(thumbView.pdfPage);
  8872. }
  8873. if (this._pagesRequests.has(thumbView)) {
  8874. return this._pagesRequests.get(thumbView);
  8875. }
  8876. var promise = this.pdfDocument.getPage(thumbView.id).then(function (pdfPage) {
  8877. if (!thumbView.pdfPage) {
  8878. thumbView.setPdfPage(pdfPage);
  8879. }
  8880. _this3._pagesRequests["delete"](thumbView);
  8881. return pdfPage;
  8882. })["catch"](function (reason) {
  8883. console.error("Unable to get page for thumb view", reason);
  8884. _this3._pagesRequests["delete"](thumbView);
  8885. });
  8886. this._pagesRequests.set(thumbView, promise);
  8887. return promise;
  8888. }
  8889. }, {
  8890. key: "forceRendering",
  8891. value: function forceRendering() {
  8892. var _this4 = this;
  8893. var visibleThumbs = this._getVisibleThumbs();
  8894. var thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, this.scroll.down);
  8895. if (thumbView) {
  8896. this._ensurePdfPageLoaded(thumbView).then(function () {
  8897. _this4.renderingQueue.renderView(thumbView);
  8898. });
  8899. return true;
  8900. }
  8901. return false;
  8902. }
  8903. }, {
  8904. key: "pagesRotation",
  8905. get: function get() {
  8906. return this._pagesRotation;
  8907. },
  8908. set: function set(rotation) {
  8909. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  8910. throw new Error("Invalid thumbnails rotation angle.");
  8911. }
  8912. if (!this.pdfDocument) {
  8913. return;
  8914. }
  8915. if (this._pagesRotation === rotation) {
  8916. return;
  8917. }
  8918. this._pagesRotation = rotation;
  8919. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  8920. this._thumbnails[i].update(rotation);
  8921. }
  8922. }
  8923. }]);
  8924. return PDFThumbnailViewer;
  8925. }();
  8926. exports.PDFThumbnailViewer = PDFThumbnailViewer;
  8927. /***/ }),
  8928. /* 28 */
  8929. /***/ (function(module, exports, __webpack_require__) {
  8930. "use strict";
  8931. Object.defineProperty(exports, "__esModule", {
  8932. value: true
  8933. });
  8934. exports.PDFThumbnailView = void 0;
  8935. var _pdfjsLib = __webpack_require__(8);
  8936. var _ui_utils = __webpack_require__(5);
  8937. var _pdf_rendering_queue = __webpack_require__(11);
  8938. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8939. 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); } }
  8940. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8941. var MAX_NUM_SCALING_STEPS = 3;
  8942. var THUMBNAIL_CANVAS_BORDER_WIDTH = 1;
  8943. var THUMBNAIL_WIDTH = 98;
  8944. var TempImageFactory = function TempImageFactoryClosure() {
  8945. var tempCanvasCache = null;
  8946. return {
  8947. getCanvas: function getCanvas(width, height) {
  8948. var tempCanvas = tempCanvasCache;
  8949. if (!tempCanvas) {
  8950. tempCanvas = document.createElement("canvas");
  8951. tempCanvasCache = tempCanvas;
  8952. }
  8953. tempCanvas.width = width;
  8954. tempCanvas.height = height;
  8955. tempCanvas.mozOpaque = true;
  8956. var ctx = tempCanvas.getContext("2d", {
  8957. alpha: false
  8958. });
  8959. ctx.save();
  8960. ctx.fillStyle = "rgb(255, 255, 255)";
  8961. ctx.fillRect(0, 0, width, height);
  8962. ctx.restore();
  8963. return tempCanvas;
  8964. },
  8965. destroyCanvas: function destroyCanvas() {
  8966. var tempCanvas = tempCanvasCache;
  8967. if (tempCanvas) {
  8968. tempCanvas.width = 0;
  8969. tempCanvas.height = 0;
  8970. }
  8971. tempCanvasCache = null;
  8972. }
  8973. };
  8974. }();
  8975. var PDFThumbnailView = /*#__PURE__*/function () {
  8976. function PDFThumbnailView(_ref) {
  8977. var container = _ref.container,
  8978. id = _ref.id,
  8979. defaultViewport = _ref.defaultViewport,
  8980. optionalContentConfigPromise = _ref.optionalContentConfigPromise,
  8981. linkService = _ref.linkService,
  8982. renderingQueue = _ref.renderingQueue,
  8983. checkSetImageDisabled = _ref.checkSetImageDisabled,
  8984. _ref$disableCanvasToI = _ref.disableCanvasToImageConversion,
  8985. disableCanvasToImageConversion = _ref$disableCanvasToI === void 0 ? false : _ref$disableCanvasToI,
  8986. _ref$l10n = _ref.l10n,
  8987. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  8988. _classCallCheck(this, PDFThumbnailView);
  8989. this.id = id;
  8990. this.renderingId = "thumbnail" + id;
  8991. this.pageLabel = null;
  8992. this.pdfPage = null;
  8993. this.rotation = 0;
  8994. this.viewport = defaultViewport;
  8995. this.pdfPageRotate = defaultViewport.rotation;
  8996. this._optionalContentConfigPromise = optionalContentConfigPromise || null;
  8997. this.linkService = linkService;
  8998. this.renderingQueue = renderingQueue;
  8999. this.renderTask = null;
  9000. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  9001. this.resume = null;
  9002. this._checkSetImageDisabled = checkSetImageDisabled || function () {
  9003. return false;
  9004. };
  9005. this.disableCanvasToImageConversion = disableCanvasToImageConversion;
  9006. this.pageWidth = this.viewport.width;
  9007. this.pageHeight = this.viewport.height;
  9008. this.pageRatio = this.pageWidth / this.pageHeight;
  9009. this.canvasWidth = THUMBNAIL_WIDTH;
  9010. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  9011. this.scale = this.canvasWidth / this.pageWidth;
  9012. this.l10n = l10n;
  9013. var anchor = document.createElement("a");
  9014. anchor.href = linkService.getAnchorUrl("#page=" + id);
  9015. this._thumbPageTitle.then(function (msg) {
  9016. anchor.title = msg;
  9017. });
  9018. anchor.onclick = function () {
  9019. linkService.page = id;
  9020. return false;
  9021. };
  9022. this.anchor = anchor;
  9023. var div = document.createElement("div");
  9024. div.className = "thumbnail";
  9025. div.setAttribute("data-page-number", this.id);
  9026. this.div = div;
  9027. var ring = document.createElement("div");
  9028. ring.className = "thumbnailSelectionRing";
  9029. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  9030. ring.style.width = this.canvasWidth + borderAdjustment + "px";
  9031. ring.style.height = this.canvasHeight + borderAdjustment + "px";
  9032. this.ring = ring;
  9033. div.appendChild(ring);
  9034. anchor.appendChild(div);
  9035. container.appendChild(anchor);
  9036. }
  9037. _createClass(PDFThumbnailView, [{
  9038. key: "setPdfPage",
  9039. value: function setPdfPage(pdfPage) {
  9040. this.pdfPage = pdfPage;
  9041. this.pdfPageRotate = pdfPage.rotate;
  9042. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  9043. this.viewport = pdfPage.getViewport({
  9044. scale: 1,
  9045. rotation: totalRotation
  9046. });
  9047. this.reset();
  9048. }
  9049. }, {
  9050. key: "reset",
  9051. value: function reset() {
  9052. this.cancelRendering();
  9053. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  9054. this.pageWidth = this.viewport.width;
  9055. this.pageHeight = this.viewport.height;
  9056. this.pageRatio = this.pageWidth / this.pageHeight;
  9057. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  9058. this.scale = this.canvasWidth / this.pageWidth;
  9059. this.div.removeAttribute("data-loaded");
  9060. var ring = this.ring;
  9061. var childNodes = ring.childNodes;
  9062. for (var i = childNodes.length - 1; i >= 0; i--) {
  9063. ring.removeChild(childNodes[i]);
  9064. }
  9065. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  9066. ring.style.width = this.canvasWidth + borderAdjustment + "px";
  9067. ring.style.height = this.canvasHeight + borderAdjustment + "px";
  9068. if (this.canvas) {
  9069. this.canvas.width = 0;
  9070. this.canvas.height = 0;
  9071. delete this.canvas;
  9072. }
  9073. if (this.image) {
  9074. this.image.removeAttribute("src");
  9075. delete this.image;
  9076. }
  9077. }
  9078. }, {
  9079. key: "update",
  9080. value: function update(rotation) {
  9081. if (typeof rotation !== "undefined") {
  9082. this.rotation = rotation;
  9083. }
  9084. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  9085. this.viewport = this.viewport.clone({
  9086. scale: 1,
  9087. rotation: totalRotation
  9088. });
  9089. this.reset();
  9090. }
  9091. }, {
  9092. key: "cancelRendering",
  9093. value: function cancelRendering() {
  9094. if (this.renderTask) {
  9095. this.renderTask.cancel();
  9096. this.renderTask = null;
  9097. }
  9098. this.resume = null;
  9099. }
  9100. }, {
  9101. key: "_getPageDrawContext",
  9102. value: function _getPageDrawContext() {
  9103. var noCtxScale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9104. var canvas = document.createElement("canvas");
  9105. this.canvas = canvas;
  9106. canvas.mozOpaque = true;
  9107. var ctx = canvas.getContext("2d", {
  9108. alpha: false
  9109. });
  9110. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  9111. canvas.width = this.canvasWidth * outputScale.sx | 0;
  9112. canvas.height = this.canvasHeight * outputScale.sy | 0;
  9113. canvas.style.width = this.canvasWidth + "px";
  9114. canvas.style.height = this.canvasHeight + "px";
  9115. if (!noCtxScale && outputScale.scaled) {
  9116. ctx.scale(outputScale.sx, outputScale.sy);
  9117. }
  9118. return ctx;
  9119. }
  9120. }, {
  9121. key: "_convertCanvasToImage",
  9122. value: function _convertCanvasToImage() {
  9123. var _this = this;
  9124. if (!this.canvas) {
  9125. return;
  9126. }
  9127. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  9128. return;
  9129. }
  9130. var className = "thumbnailImage";
  9131. if (this.disableCanvasToImageConversion) {
  9132. this.canvas.className = className;
  9133. this._thumbPageCanvas.then(function (msg) {
  9134. _this.canvas.setAttribute("aria-label", msg);
  9135. });
  9136. this.div.setAttribute("data-loaded", true);
  9137. this.ring.appendChild(this.canvas);
  9138. return;
  9139. }
  9140. var image = document.createElement("img");
  9141. image.className = className;
  9142. this._thumbPageCanvas.then(function (msg) {
  9143. image.setAttribute("aria-label", msg);
  9144. });
  9145. image.style.width = this.canvasWidth + "px";
  9146. image.style.height = this.canvasHeight + "px";
  9147. image.src = this.canvas.toDataURL();
  9148. this.image = image;
  9149. this.div.setAttribute("data-loaded", true);
  9150. this.ring.appendChild(image);
  9151. this.canvas.width = 0;
  9152. this.canvas.height = 0;
  9153. delete this.canvas;
  9154. }
  9155. }, {
  9156. key: "draw",
  9157. value: function draw() {
  9158. var _this2 = this;
  9159. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  9160. console.error("Must be in new state before drawing");
  9161. return Promise.resolve(undefined);
  9162. }
  9163. var pdfPage = this.pdfPage;
  9164. if (!pdfPage) {
  9165. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  9166. return Promise.reject(new Error("pdfPage is not loaded"));
  9167. }
  9168. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  9169. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  9170. var finishRenderTask = function finishRenderTask(error) {
  9171. if (renderTask === _this2.renderTask) {
  9172. _this2.renderTask = null;
  9173. }
  9174. if (error instanceof _pdfjsLib.RenderingCancelledException) {
  9175. renderCapability.resolve(undefined);
  9176. return;
  9177. }
  9178. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  9179. _this2._convertCanvasToImage();
  9180. if (!error) {
  9181. renderCapability.resolve(undefined);
  9182. } else {
  9183. renderCapability.reject(error);
  9184. }
  9185. };
  9186. var ctx = this._getPageDrawContext();
  9187. var drawViewport = this.viewport.clone({
  9188. scale: this.scale
  9189. });
  9190. var renderContinueCallback = function renderContinueCallback(cont) {
  9191. if (!_this2.renderingQueue.isHighestPriority(_this2)) {
  9192. _this2.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  9193. _this2.resume = function () {
  9194. _this2.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  9195. cont();
  9196. };
  9197. return;
  9198. }
  9199. cont();
  9200. };
  9201. var renderContext = {
  9202. canvasContext: ctx,
  9203. viewport: drawViewport,
  9204. optionalContentConfigPromise: this._optionalContentConfigPromise
  9205. };
  9206. var renderTask = this.renderTask = pdfPage.render(renderContext);
  9207. renderTask.onContinue = renderContinueCallback;
  9208. renderTask.promise.then(function () {
  9209. finishRenderTask(null);
  9210. }, function (error) {
  9211. finishRenderTask(error);
  9212. });
  9213. return renderCapability.promise;
  9214. }
  9215. }, {
  9216. key: "setImage",
  9217. value: function setImage(pageView) {
  9218. if (this._checkSetImageDisabled()) {
  9219. return;
  9220. }
  9221. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  9222. return;
  9223. }
  9224. var img = pageView.canvas;
  9225. if (!img) {
  9226. return;
  9227. }
  9228. if (!this.pdfPage) {
  9229. this.setPdfPage(pageView.pdfPage);
  9230. }
  9231. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  9232. var ctx = this._getPageDrawContext(true);
  9233. var canvas = ctx.canvas;
  9234. if (img.width <= 2 * canvas.width) {
  9235. ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height);
  9236. this._convertCanvasToImage();
  9237. return;
  9238. }
  9239. var reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
  9240. var reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
  9241. var reducedImage = TempImageFactory.getCanvas(reducedWidth, reducedHeight);
  9242. var reducedImageCtx = reducedImage.getContext("2d");
  9243. while (reducedWidth > img.width || reducedHeight > img.height) {
  9244. reducedWidth >>= 1;
  9245. reducedHeight >>= 1;
  9246. }
  9247. reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0, reducedWidth, reducedHeight);
  9248. while (reducedWidth > 2 * canvas.width) {
  9249. reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, reducedWidth >> 1, reducedHeight >> 1);
  9250. reducedWidth >>= 1;
  9251. reducedHeight >>= 1;
  9252. }
  9253. ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height);
  9254. this._convertCanvasToImage();
  9255. }
  9256. }, {
  9257. key: "setPageLabel",
  9258. value: function setPageLabel(label) {
  9259. var _this3 = this;
  9260. this.pageLabel = typeof label === "string" ? label : null;
  9261. this._thumbPageTitle.then(function (msg) {
  9262. _this3.anchor.title = msg;
  9263. });
  9264. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  9265. return;
  9266. }
  9267. this._thumbPageCanvas.then(function (msg) {
  9268. if (_this3.image) {
  9269. _this3.image.setAttribute("aria-label", msg);
  9270. } else if (_this3.disableCanvasToImageConversion && _this3.canvas) {
  9271. _this3.canvas.setAttribute("aria-label", msg);
  9272. }
  9273. });
  9274. }
  9275. }, {
  9276. key: "_thumbPageTitle",
  9277. get: function get() {
  9278. var _this$pageLabel;
  9279. return this.l10n.get("thumb_page_title", {
  9280. page: (_this$pageLabel = this.pageLabel) != null ? _this$pageLabel : this.id
  9281. }, "Page {{page}}");
  9282. }
  9283. }, {
  9284. key: "_thumbPageCanvas",
  9285. get: function get() {
  9286. var _this$pageLabel2;
  9287. return this.l10n.get("thumb_page_canvas", {
  9288. page: (_this$pageLabel2 = this.pageLabel) != null ? _this$pageLabel2 : this.id
  9289. }, "Thumbnail of Page {{page}}");
  9290. }
  9291. }], [{
  9292. key: "cleanup",
  9293. value: function cleanup() {
  9294. TempImageFactory.destroyCanvas();
  9295. }
  9296. }]);
  9297. return PDFThumbnailView;
  9298. }();
  9299. exports.PDFThumbnailView = PDFThumbnailView;
  9300. /***/ }),
  9301. /* 29 */
  9302. /***/ (function(module, exports, __webpack_require__) {
  9303. "use strict";
  9304. Object.defineProperty(exports, "__esModule", {
  9305. value: true
  9306. });
  9307. exports.PDFViewer = void 0;
  9308. var _base_viewer = __webpack_require__(30);
  9309. var _pdfjsLib = __webpack_require__(8);
  9310. 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); }
  9311. 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; } } }; }
  9312. 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); }
  9313. 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; }
  9314. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9315. 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); } }
  9316. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9317. 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); }
  9318. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  9319. 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); }
  9320. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  9321. 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); }; }
  9322. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  9323. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  9324. 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; } }
  9325. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  9326. var PDFViewer = /*#__PURE__*/function (_BaseViewer) {
  9327. _inherits(PDFViewer, _BaseViewer);
  9328. var _super = _createSuper(PDFViewer);
  9329. function PDFViewer() {
  9330. _classCallCheck(this, PDFViewer);
  9331. return _super.apply(this, arguments);
  9332. }
  9333. _createClass(PDFViewer, [{
  9334. key: "_scrollIntoView",
  9335. value: function _scrollIntoView(_ref) {
  9336. var pageDiv = _ref.pageDiv,
  9337. _ref$pageSpot = _ref.pageSpot,
  9338. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  9339. _ref$pageNumber = _ref.pageNumber,
  9340. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  9341. if (!pageSpot && !this.isInPresentationMode) {
  9342. var left = pageDiv.offsetLeft + pageDiv.clientLeft;
  9343. var right = left + pageDiv.clientWidth;
  9344. var _this$container = this.container,
  9345. scrollLeft = _this$container.scrollLeft,
  9346. clientWidth = _this$container.clientWidth;
  9347. if (this._isScrollModeHorizontal || left < scrollLeft || right > scrollLeft + clientWidth) {
  9348. pageSpot = {
  9349. left: 0,
  9350. top: 0
  9351. };
  9352. }
  9353. }
  9354. _get(_getPrototypeOf(PDFViewer.prototype), "_scrollIntoView", this).call(this, {
  9355. pageDiv: pageDiv,
  9356. pageSpot: pageSpot,
  9357. pageNumber: pageNumber
  9358. });
  9359. }
  9360. }, {
  9361. key: "_getVisiblePages",
  9362. value: function _getVisiblePages() {
  9363. if (this.isInPresentationMode) {
  9364. return this._getCurrentVisiblePage();
  9365. }
  9366. return _get(_getPrototypeOf(PDFViewer.prototype), "_getVisiblePages", this).call(this);
  9367. }
  9368. }, {
  9369. key: "_updateHelper",
  9370. value: function _updateHelper(visiblePages) {
  9371. if (this.isInPresentationMode) {
  9372. return;
  9373. }
  9374. var currentId = this._currentPageNumber;
  9375. var stillFullyVisible = false;
  9376. var _iterator = _createForOfIteratorHelper(visiblePages),
  9377. _step;
  9378. try {
  9379. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  9380. var page = _step.value;
  9381. if (page.percent < 100) {
  9382. break;
  9383. }
  9384. if (page.id === currentId) {
  9385. stillFullyVisible = true;
  9386. break;
  9387. }
  9388. }
  9389. } catch (err) {
  9390. _iterator.e(err);
  9391. } finally {
  9392. _iterator.f();
  9393. }
  9394. if (!stillFullyVisible) {
  9395. currentId = visiblePages[0].id;
  9396. }
  9397. this._setCurrentPageNumber(currentId);
  9398. }
  9399. }, {
  9400. key: "_viewerElement",
  9401. get: function get() {
  9402. return (0, _pdfjsLib.shadow)(this, "_viewerElement", this.viewer);
  9403. }
  9404. }]);
  9405. return PDFViewer;
  9406. }(_base_viewer.BaseViewer);
  9407. exports.PDFViewer = PDFViewer;
  9408. /***/ }),
  9409. /* 30 */
  9410. /***/ (function(module, exports, __webpack_require__) {
  9411. "use strict";
  9412. Object.defineProperty(exports, "__esModule", {
  9413. value: true
  9414. });
  9415. exports.BaseViewer = void 0;
  9416. var _ui_utils = __webpack_require__(5);
  9417. var _pdf_rendering_queue = __webpack_require__(11);
  9418. var _annotation_layer_builder = __webpack_require__(31);
  9419. var _pdfjsLib = __webpack_require__(8);
  9420. var _pdf_page_view = __webpack_require__(32);
  9421. var _pdf_link_service = __webpack_require__(23);
  9422. var _text_layer_builder = __webpack_require__(33);
  9423. 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; } } }; }
  9424. 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); }
  9425. 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; }
  9426. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9427. 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); } }
  9428. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9429. var DEFAULT_CACHE_SIZE = 10;
  9430. function PDFPageViewBuffer(size) {
  9431. var data = [];
  9432. this.push = function (view) {
  9433. var i = data.indexOf(view);
  9434. if (i >= 0) {
  9435. data.splice(i, 1);
  9436. }
  9437. data.push(view);
  9438. if (data.length > size) {
  9439. data.shift().destroy();
  9440. }
  9441. };
  9442. this.resize = function (newSize, pagesToKeep) {
  9443. size = newSize;
  9444. if (pagesToKeep) {
  9445. var pageIdsToKeep = new Set();
  9446. for (var i = 0, iMax = pagesToKeep.length; i < iMax; ++i) {
  9447. pageIdsToKeep.add(pagesToKeep[i].id);
  9448. }
  9449. (0, _ui_utils.moveToEndOfArray)(data, function (page) {
  9450. return pageIdsToKeep.has(page.id);
  9451. });
  9452. }
  9453. while (data.length > size) {
  9454. data.shift().destroy();
  9455. }
  9456. };
  9457. }
  9458. function isSameScale(oldScale, newScale) {
  9459. if (newScale === oldScale) {
  9460. return true;
  9461. }
  9462. if (Math.abs(newScale - oldScale) < 1e-15) {
  9463. return true;
  9464. }
  9465. return false;
  9466. }
  9467. var BaseViewer = /*#__PURE__*/function () {
  9468. function BaseViewer(options) {
  9469. var _this = this;
  9470. _classCallCheck(this, BaseViewer);
  9471. if (this.constructor === BaseViewer) {
  9472. throw new Error("Cannot initialize BaseViewer.");
  9473. }
  9474. this._name = this.constructor.name;
  9475. this.container = options.container;
  9476. this.viewer = options.viewer || options.container.firstElementChild;
  9477. if (!(this.container instanceof HTMLDivElement && this.viewer instanceof HTMLDivElement)) {
  9478. throw new Error("Invalid `container` and/or `viewer` option.");
  9479. }
  9480. this.eventBus = options.eventBus;
  9481. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  9482. this.downloadManager = options.downloadManager || null;
  9483. this.findController = options.findController || null;
  9484. this.removePageBorders = options.removePageBorders || false;
  9485. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  9486. this.imageResourcesPath = options.imageResourcesPath || "";
  9487. this.renderInteractiveForms = typeof options.renderInteractiveForms === "boolean" ? options.renderInteractiveForms : true;
  9488. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  9489. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  9490. this.enableWebGL = options.enableWebGL || false;
  9491. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  9492. this.maxCanvasPixels = options.maxCanvasPixels;
  9493. this.l10n = options.l10n || _ui_utils.NullL10n;
  9494. this.defaultRenderingQueue = !options.renderingQueue;
  9495. if (this.defaultRenderingQueue) {
  9496. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  9497. this.renderingQueue.setViewer(this);
  9498. } else {
  9499. this.renderingQueue = options.renderingQueue;
  9500. }
  9501. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  9502. this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
  9503. this._onBeforeDraw = this._onAfterDraw = null;
  9504. this._resetView();
  9505. if (this.removePageBorders) {
  9506. this.viewer.classList.add("removePageBorders");
  9507. }
  9508. Promise.resolve().then(function () {
  9509. _this.eventBus.dispatch("baseviewerinit", {
  9510. source: _this
  9511. });
  9512. });
  9513. }
  9514. _createClass(BaseViewer, [{
  9515. key: "getPageView",
  9516. value: function getPageView(index) {
  9517. return this._pages[index];
  9518. }
  9519. }, {
  9520. key: "_setCurrentPageNumber",
  9521. value: function _setCurrentPageNumber(val) {
  9522. var resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9523. if (this._currentPageNumber === val) {
  9524. if (resetCurrentPageView) {
  9525. this._resetCurrentPageView();
  9526. }
  9527. return true;
  9528. }
  9529. if (!(0 < val && val <= this.pagesCount)) {
  9530. return false;
  9531. }
  9532. this._currentPageNumber = val;
  9533. this.eventBus.dispatch("pagechanging", {
  9534. source: this,
  9535. pageNumber: val,
  9536. pageLabel: this._pageLabels && this._pageLabels[val - 1]
  9537. });
  9538. if (resetCurrentPageView) {
  9539. this._resetCurrentPageView();
  9540. }
  9541. return true;
  9542. }
  9543. }, {
  9544. key: "_onePageRenderedOrForceFetch",
  9545. value: function _onePageRenderedOrForceFetch() {
  9546. if (!this.container.offsetParent || this._getVisiblePages().views.length === 0) {
  9547. return Promise.resolve();
  9548. }
  9549. return this._onePageRenderedCapability.promise;
  9550. }
  9551. }, {
  9552. key: "setDocument",
  9553. value: function setDocument(pdfDocument) {
  9554. var _this2 = this;
  9555. if (this.pdfDocument) {
  9556. this._cancelRendering();
  9557. this._resetView();
  9558. if (this.findController) {
  9559. this.findController.setDocument(null);
  9560. }
  9561. }
  9562. this.pdfDocument = pdfDocument;
  9563. if (!pdfDocument) {
  9564. return;
  9565. }
  9566. var pagesCount = pdfDocument.numPages;
  9567. var firstPagePromise = pdfDocument.getPage(1);
  9568. var annotationStorage = pdfDocument.annotationStorage;
  9569. var optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
  9570. this._pagesCapability.promise.then(function () {
  9571. _this2.eventBus.dispatch("pagesloaded", {
  9572. source: _this2,
  9573. pagesCount: pagesCount
  9574. });
  9575. });
  9576. this._onBeforeDraw = function (evt) {
  9577. var pageView = _this2._pages[evt.pageNumber - 1];
  9578. if (!pageView) {
  9579. return;
  9580. }
  9581. _this2._buffer.push(pageView);
  9582. };
  9583. this.eventBus._on("pagerender", this._onBeforeDraw);
  9584. this._onAfterDraw = function (evt) {
  9585. if (evt.cssTransform || _this2._onePageRenderedCapability.settled) {
  9586. return;
  9587. }
  9588. _this2._onePageRenderedCapability.resolve();
  9589. _this2.eventBus._off("pagerendered", _this2._onAfterDraw);
  9590. _this2._onAfterDraw = null;
  9591. };
  9592. this.eventBus._on("pagerendered", this._onAfterDraw);
  9593. firstPagePromise.then(function (firstPdfPage) {
  9594. _this2._firstPageCapability.resolve(firstPdfPage);
  9595. _this2._optionalContentConfigPromise = optionalContentConfigPromise;
  9596. var scale = _this2.currentScale;
  9597. var viewport = firstPdfPage.getViewport({
  9598. scale: scale * _ui_utils.CSS_UNITS
  9599. });
  9600. var textLayerFactory = _this2.textLayerMode !== _ui_utils.TextLayerMode.DISABLE ? _this2 : null;
  9601. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  9602. var pageView = new _pdf_page_view.PDFPageView({
  9603. container: _this2._viewerElement,
  9604. eventBus: _this2.eventBus,
  9605. id: pageNum,
  9606. scale: scale,
  9607. defaultViewport: viewport.clone(),
  9608. annotationStorage: annotationStorage,
  9609. optionalContentConfigPromise: optionalContentConfigPromise,
  9610. renderingQueue: _this2.renderingQueue,
  9611. textLayerFactory: textLayerFactory,
  9612. textLayerMode: _this2.textLayerMode,
  9613. annotationLayerFactory: _this2,
  9614. imageResourcesPath: _this2.imageResourcesPath,
  9615. renderInteractiveForms: _this2.renderInteractiveForms,
  9616. renderer: _this2.renderer,
  9617. enableWebGL: _this2.enableWebGL,
  9618. useOnlyCssZoom: _this2.useOnlyCssZoom,
  9619. maxCanvasPixels: _this2.maxCanvasPixels,
  9620. l10n: _this2.l10n
  9621. });
  9622. _this2._pages.push(pageView);
  9623. }
  9624. var firstPageView = _this2._pages[0];
  9625. if (firstPageView) {
  9626. firstPageView.setPdfPage(firstPdfPage);
  9627. _this2.linkService.cachePageRef(1, firstPdfPage.ref);
  9628. }
  9629. if (_this2._spreadMode !== _ui_utils.SpreadMode.NONE) {
  9630. _this2._updateSpreadMode();
  9631. }
  9632. _this2._onePageRenderedOrForceFetch().then(function () {
  9633. if (_this2.findController) {
  9634. _this2.findController.setDocument(pdfDocument);
  9635. }
  9636. if (pdfDocument.loadingParams.disableAutoFetch || pagesCount > 7500) {
  9637. _this2._pagesCapability.resolve();
  9638. return;
  9639. }
  9640. var getPagesLeft = pagesCount - 1;
  9641. if (getPagesLeft <= 0) {
  9642. _this2._pagesCapability.resolve();
  9643. return;
  9644. }
  9645. var _loop = function _loop(_pageNum) {
  9646. pdfDocument.getPage(_pageNum).then(function (pdfPage) {
  9647. var pageView = _this2._pages[_pageNum - 1];
  9648. if (!pageView.pdfPage) {
  9649. pageView.setPdfPage(pdfPage);
  9650. }
  9651. _this2.linkService.cachePageRef(_pageNum, pdfPage.ref);
  9652. if (--getPagesLeft === 0) {
  9653. _this2._pagesCapability.resolve();
  9654. }
  9655. }, function (reason) {
  9656. console.error("Unable to get page ".concat(_pageNum, " to initialize viewer"), reason);
  9657. if (--getPagesLeft === 0) {
  9658. _this2._pagesCapability.resolve();
  9659. }
  9660. });
  9661. };
  9662. for (var _pageNum = 2; _pageNum <= pagesCount; ++_pageNum) {
  9663. _loop(_pageNum);
  9664. }
  9665. });
  9666. _this2.eventBus.dispatch("pagesinit", {
  9667. source: _this2
  9668. });
  9669. if (_this2.defaultRenderingQueue) {
  9670. _this2.update();
  9671. }
  9672. })["catch"](function (reason) {
  9673. console.error("Unable to initialize viewer", reason);
  9674. });
  9675. }
  9676. }, {
  9677. key: "setPageLabels",
  9678. value: function setPageLabels(labels) {
  9679. if (!this.pdfDocument) {
  9680. return;
  9681. }
  9682. if (!labels) {
  9683. this._pageLabels = null;
  9684. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  9685. this._pageLabels = null;
  9686. console.error("".concat(this._name, ".setPageLabels: Invalid page labels."));
  9687. } else {
  9688. this._pageLabels = labels;
  9689. }
  9690. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  9691. var pageView = this._pages[i];
  9692. var label = this._pageLabels && this._pageLabels[i];
  9693. pageView.setPageLabel(label);
  9694. }
  9695. }
  9696. }, {
  9697. key: "_resetView",
  9698. value: function _resetView() {
  9699. this._pages = [];
  9700. this._currentPageNumber = 1;
  9701. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  9702. this._currentScaleValue = null;
  9703. this._pageLabels = null;
  9704. this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  9705. this._location = null;
  9706. this._pagesRotation = 0;
  9707. this._optionalContentConfigPromise = null;
  9708. this._pagesRequests = new WeakMap();
  9709. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  9710. this._onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  9711. this._pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
  9712. this._scrollMode = _ui_utils.ScrollMode.VERTICAL;
  9713. this._spreadMode = _ui_utils.SpreadMode.NONE;
  9714. if (this._onBeforeDraw) {
  9715. this.eventBus._off("pagerender", this._onBeforeDraw);
  9716. this._onBeforeDraw = null;
  9717. }
  9718. if (this._onAfterDraw) {
  9719. this.eventBus._off("pagerendered", this._onAfterDraw);
  9720. this._onAfterDraw = null;
  9721. }
  9722. this.viewer.textContent = "";
  9723. this._updateScrollMode();
  9724. }
  9725. }, {
  9726. key: "_scrollUpdate",
  9727. value: function _scrollUpdate() {
  9728. if (this.pagesCount === 0) {
  9729. return;
  9730. }
  9731. this.update();
  9732. }
  9733. }, {
  9734. key: "_scrollIntoView",
  9735. value: function _scrollIntoView(_ref) {
  9736. var pageDiv = _ref.pageDiv,
  9737. _ref$pageSpot = _ref.pageSpot,
  9738. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  9739. _ref$pageNumber = _ref.pageNumber,
  9740. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  9741. (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
  9742. }
  9743. }, {
  9744. key: "_setScaleUpdatePages",
  9745. value: function _setScaleUpdatePages(newScale, newValue) {
  9746. var noScroll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  9747. var preset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9748. this._currentScaleValue = newValue.toString();
  9749. if (isSameScale(this._currentScale, newScale)) {
  9750. if (preset) {
  9751. this.eventBus.dispatch("scalechanging", {
  9752. source: this,
  9753. scale: newScale,
  9754. presetValue: newValue
  9755. });
  9756. }
  9757. return;
  9758. }
  9759. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  9760. this._pages[i].update(newScale);
  9761. }
  9762. this._currentScale = newScale;
  9763. if (!noScroll) {
  9764. var page = this._currentPageNumber,
  9765. dest;
  9766. if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  9767. page = this._location.pageNumber;
  9768. dest = [null, {
  9769. name: "XYZ"
  9770. }, this._location.left, this._location.top, null];
  9771. }
  9772. this.scrollPageIntoView({
  9773. pageNumber: page,
  9774. destArray: dest,
  9775. allowNegativeOffset: true
  9776. });
  9777. }
  9778. this.eventBus.dispatch("scalechanging", {
  9779. source: this,
  9780. scale: newScale,
  9781. presetValue: preset ? newValue : undefined
  9782. });
  9783. if (this.defaultRenderingQueue) {
  9784. this.update();
  9785. }
  9786. }
  9787. }, {
  9788. key: "_setScale",
  9789. value: function _setScale(value) {
  9790. var noScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9791. var scale = parseFloat(value);
  9792. if (scale > 0) {
  9793. this._setScaleUpdatePages(scale, value, noScroll, false);
  9794. } else {
  9795. var currentPage = this._pages[this._currentPageNumber - 1];
  9796. if (!currentPage) {
  9797. return;
  9798. }
  9799. var noPadding = this.isInPresentationMode || this.removePageBorders;
  9800. var hPadding = noPadding ? 0 : _ui_utils.SCROLLBAR_PADDING;
  9801. var vPadding = noPadding ? 0 : _ui_utils.VERTICAL_PADDING;
  9802. if (!noPadding && this._isScrollModeHorizontal) {
  9803. var _ref2 = [vPadding, hPadding];
  9804. hPadding = _ref2[0];
  9805. vPadding = _ref2[1];
  9806. }
  9807. var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale;
  9808. var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  9809. switch (value) {
  9810. case "page-actual":
  9811. scale = 1;
  9812. break;
  9813. case "page-width":
  9814. scale = pageWidthScale;
  9815. break;
  9816. case "page-height":
  9817. scale = pageHeightScale;
  9818. break;
  9819. case "page-fit":
  9820. scale = Math.min(pageWidthScale, pageHeightScale);
  9821. break;
  9822. case "auto":
  9823. var horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
  9824. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  9825. break;
  9826. default:
  9827. console.error("".concat(this._name, "._setScale: \"").concat(value, "\" is an unknown zoom value."));
  9828. return;
  9829. }
  9830. this._setScaleUpdatePages(scale, value, noScroll, true);
  9831. }
  9832. }
  9833. }, {
  9834. key: "_resetCurrentPageView",
  9835. value: function _resetCurrentPageView() {
  9836. if (this.isInPresentationMode) {
  9837. this._setScale(this._currentScaleValue, true);
  9838. }
  9839. var pageView = this._pages[this._currentPageNumber - 1];
  9840. this._scrollIntoView({
  9841. pageDiv: pageView.div
  9842. });
  9843. }
  9844. }, {
  9845. key: "scrollPageIntoView",
  9846. value: function scrollPageIntoView(_ref3) {
  9847. var pageNumber = _ref3.pageNumber,
  9848. _ref3$destArray = _ref3.destArray,
  9849. destArray = _ref3$destArray === void 0 ? null : _ref3$destArray,
  9850. _ref3$allowNegativeOf = _ref3.allowNegativeOffset,
  9851. allowNegativeOffset = _ref3$allowNegativeOf === void 0 ? false : _ref3$allowNegativeOf,
  9852. _ref3$ignoreDestinati = _ref3.ignoreDestinationZoom,
  9853. ignoreDestinationZoom = _ref3$ignoreDestinati === void 0 ? false : _ref3$ignoreDestinati;
  9854. if (!this.pdfDocument) {
  9855. return;
  9856. }
  9857. var pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1];
  9858. if (!pageView) {
  9859. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  9860. return;
  9861. }
  9862. if (this.isInPresentationMode || !destArray) {
  9863. this._setCurrentPageNumber(pageNumber, true);
  9864. return;
  9865. }
  9866. var x = 0,
  9867. y = 0;
  9868. var width = 0,
  9869. height = 0,
  9870. widthScale,
  9871. heightScale;
  9872. var changeOrientation = pageView.rotation % 180 !== 0;
  9873. var pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;
  9874. var pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;
  9875. var scale = 0;
  9876. switch (destArray[1].name) {
  9877. case "XYZ":
  9878. x = destArray[2];
  9879. y = destArray[3];
  9880. scale = destArray[4];
  9881. x = x !== null ? x : 0;
  9882. y = y !== null ? y : pageHeight;
  9883. break;
  9884. case "Fit":
  9885. case "FitB":
  9886. scale = "page-fit";
  9887. break;
  9888. case "FitH":
  9889. case "FitBH":
  9890. y = destArray[2];
  9891. scale = "page-width";
  9892. if (y === null && this._location) {
  9893. x = this._location.left;
  9894. y = this._location.top;
  9895. }
  9896. break;
  9897. case "FitV":
  9898. case "FitBV":
  9899. x = destArray[2];
  9900. width = pageWidth;
  9901. height = pageHeight;
  9902. scale = "page-height";
  9903. break;
  9904. case "FitR":
  9905. x = destArray[2];
  9906. y = destArray[3];
  9907. width = destArray[4] - x;
  9908. height = destArray[5] - y;
  9909. var hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  9910. var vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  9911. widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;
  9912. heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;
  9913. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  9914. break;
  9915. default:
  9916. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(destArray[1].name, "\" is not a valid destination type."));
  9917. return;
  9918. }
  9919. if (!ignoreDestinationZoom) {
  9920. if (scale && scale !== this._currentScale) {
  9921. this.currentScaleValue = scale;
  9922. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  9923. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  9924. }
  9925. }
  9926. if (scale === "page-fit" && !destArray[4]) {
  9927. this._scrollIntoView({
  9928. pageDiv: pageView.div,
  9929. pageNumber: pageNumber
  9930. });
  9931. return;
  9932. }
  9933. var boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  9934. var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  9935. var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  9936. if (!allowNegativeOffset) {
  9937. left = Math.max(left, 0);
  9938. top = Math.max(top, 0);
  9939. }
  9940. this._scrollIntoView({
  9941. pageDiv: pageView.div,
  9942. pageSpot: {
  9943. left: left,
  9944. top: top
  9945. },
  9946. pageNumber: pageNumber
  9947. });
  9948. }
  9949. }, {
  9950. key: "_updateLocation",
  9951. value: function _updateLocation(firstPage) {
  9952. var currentScale = this._currentScale;
  9953. var currentScaleValue = this._currentScaleValue;
  9954. var normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  9955. var pageNumber = firstPage.id;
  9956. var pdfOpenParams = "#page=" + pageNumber;
  9957. pdfOpenParams += "&zoom=" + normalizedScaleValue;
  9958. var currentPageView = this._pages[pageNumber - 1];
  9959. var container = this.container;
  9960. var topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  9961. var intLeft = Math.round(topLeft[0]);
  9962. var intTop = Math.round(topLeft[1]);
  9963. pdfOpenParams += "," + intLeft + "," + intTop;
  9964. this._location = {
  9965. pageNumber: pageNumber,
  9966. scale: normalizedScaleValue,
  9967. top: intTop,
  9968. left: intLeft,
  9969. rotation: this._pagesRotation,
  9970. pdfOpenParams: pdfOpenParams
  9971. };
  9972. }
  9973. }, {
  9974. key: "_updateHelper",
  9975. value: function _updateHelper(visiblePages) {
  9976. throw new Error("Not implemented: _updateHelper");
  9977. }
  9978. }, {
  9979. key: "update",
  9980. value: function update() {
  9981. var visible = this._getVisiblePages();
  9982. var visiblePages = visible.views,
  9983. numVisiblePages = visiblePages.length;
  9984. if (numVisiblePages === 0) {
  9985. return;
  9986. }
  9987. var newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
  9988. this._buffer.resize(newCacheSize, visiblePages);
  9989. this.renderingQueue.renderHighestPriority(visible);
  9990. this._updateHelper(visiblePages);
  9991. this._updateLocation(visible.first);
  9992. this.eventBus.dispatch("updateviewarea", {
  9993. source: this,
  9994. location: this._location
  9995. });
  9996. }
  9997. }, {
  9998. key: "containsElement",
  9999. value: function containsElement(element) {
  10000. return this.container.contains(element);
  10001. }
  10002. }, {
  10003. key: "focus",
  10004. value: function focus() {
  10005. this.container.focus();
  10006. }
  10007. }, {
  10008. key: "_getCurrentVisiblePage",
  10009. value: function _getCurrentVisiblePage() {
  10010. if (!this.pagesCount) {
  10011. return {
  10012. views: []
  10013. };
  10014. }
  10015. var pageView = this._pages[this._currentPageNumber - 1];
  10016. var element = pageView.div;
  10017. var view = {
  10018. id: pageView.id,
  10019. x: element.offsetLeft + element.clientLeft,
  10020. y: element.offsetTop + element.clientTop,
  10021. view: pageView
  10022. };
  10023. return {
  10024. first: view,
  10025. last: view,
  10026. views: [view]
  10027. };
  10028. }
  10029. }, {
  10030. key: "_getVisiblePages",
  10031. value: function _getVisiblePages() {
  10032. return (0, _ui_utils.getVisibleElements)(this.container, this._pages, true, this._isScrollModeHorizontal);
  10033. }
  10034. }, {
  10035. key: "isPageVisible",
  10036. value: function isPageVisible(pageNumber) {
  10037. if (!this.pdfDocument) {
  10038. return false;
  10039. }
  10040. if (pageNumber < 1 || pageNumber > this.pagesCount) {
  10041. console.error("".concat(this._name, ".isPageVisible: \"").concat(pageNumber, "\" is out of bounds."));
  10042. return false;
  10043. }
  10044. return this._getVisiblePages().views.some(function (view) {
  10045. return view.id === pageNumber;
  10046. });
  10047. }
  10048. }, {
  10049. key: "cleanup",
  10050. value: function cleanup() {
  10051. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  10052. if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  10053. this._pages[i].reset();
  10054. }
  10055. }
  10056. }
  10057. }, {
  10058. key: "_cancelRendering",
  10059. value: function _cancelRendering() {
  10060. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  10061. if (this._pages[i]) {
  10062. this._pages[i].cancelRendering();
  10063. }
  10064. }
  10065. }
  10066. }, {
  10067. key: "_ensurePdfPageLoaded",
  10068. value: function _ensurePdfPageLoaded(pageView) {
  10069. var _this3 = this;
  10070. if (pageView.pdfPage) {
  10071. return Promise.resolve(pageView.pdfPage);
  10072. }
  10073. if (this._pagesRequests.has(pageView)) {
  10074. return this._pagesRequests.get(pageView);
  10075. }
  10076. var promise = this.pdfDocument.getPage(pageView.id).then(function (pdfPage) {
  10077. if (!pageView.pdfPage) {
  10078. pageView.setPdfPage(pdfPage);
  10079. }
  10080. _this3._pagesRequests["delete"](pageView);
  10081. return pdfPage;
  10082. })["catch"](function (reason) {
  10083. console.error("Unable to get page for page view", reason);
  10084. _this3._pagesRequests["delete"](pageView);
  10085. });
  10086. this._pagesRequests.set(pageView, promise);
  10087. return promise;
  10088. }
  10089. }, {
  10090. key: "forceRendering",
  10091. value: function forceRendering(currentlyVisiblePages) {
  10092. var _this4 = this;
  10093. var visiblePages = currentlyVisiblePages || this._getVisiblePages();
  10094. var scrollAhead = this._isScrollModeHorizontal ? this.scroll.right : this.scroll.down;
  10095. var pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead);
  10096. if (pageView) {
  10097. this._ensurePdfPageLoaded(pageView).then(function () {
  10098. _this4.renderingQueue.renderView(pageView);
  10099. });
  10100. return true;
  10101. }
  10102. return false;
  10103. }
  10104. }, {
  10105. key: "createTextLayerBuilder",
  10106. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  10107. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  10108. var eventBus = arguments.length > 4 ? arguments[4] : undefined;
  10109. return new _text_layer_builder.TextLayerBuilder({
  10110. textLayerDiv: textLayerDiv,
  10111. eventBus: eventBus,
  10112. pageIndex: pageIndex,
  10113. viewport: viewport,
  10114. findController: this.isInPresentationMode ? null : this.findController,
  10115. enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection
  10116. });
  10117. }
  10118. }, {
  10119. key: "createAnnotationLayerBuilder",
  10120. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  10121. var annotationStorage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  10122. var imageResourcesPath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "";
  10123. var renderInteractiveForms = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  10124. var l10n = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : _ui_utils.NullL10n;
  10125. return new _annotation_layer_builder.AnnotationLayerBuilder({
  10126. pageDiv: pageDiv,
  10127. pdfPage: pdfPage,
  10128. annotationStorage: annotationStorage,
  10129. imageResourcesPath: imageResourcesPath,
  10130. renderInteractiveForms: renderInteractiveForms,
  10131. linkService: this.linkService,
  10132. downloadManager: this.downloadManager,
  10133. l10n: l10n
  10134. });
  10135. }
  10136. }, {
  10137. key: "getPagesOverview",
  10138. value: function getPagesOverview() {
  10139. var pagesOverview = this._pages.map(function (pageView) {
  10140. var viewport = pageView.pdfPage.getViewport({
  10141. scale: 1
  10142. });
  10143. return {
  10144. width: viewport.width,
  10145. height: viewport.height,
  10146. rotation: viewport.rotation
  10147. };
  10148. });
  10149. if (!this.enablePrintAutoRotate) {
  10150. return pagesOverview;
  10151. }
  10152. return pagesOverview.map(function (size) {
  10153. if ((0, _ui_utils.isPortraitOrientation)(size)) {
  10154. return size;
  10155. }
  10156. return {
  10157. width: size.height,
  10158. height: size.width,
  10159. rotation: (size.rotation + 90) % 360
  10160. };
  10161. });
  10162. }
  10163. }, {
  10164. key: "_updateScrollMode",
  10165. value: function _updateScrollMode() {
  10166. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  10167. var scrollMode = this._scrollMode,
  10168. viewer = this.viewer;
  10169. viewer.classList.toggle("scrollHorizontal", scrollMode === _ui_utils.ScrollMode.HORIZONTAL);
  10170. viewer.classList.toggle("scrollWrapped", scrollMode === _ui_utils.ScrollMode.WRAPPED);
  10171. if (!this.pdfDocument || !pageNumber) {
  10172. return;
  10173. }
  10174. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  10175. this._setScale(this._currentScaleValue, true);
  10176. }
  10177. this._setCurrentPageNumber(pageNumber, true);
  10178. this.update();
  10179. }
  10180. }, {
  10181. key: "_updateSpreadMode",
  10182. value: function _updateSpreadMode() {
  10183. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  10184. if (!this.pdfDocument) {
  10185. return;
  10186. }
  10187. var viewer = this.viewer,
  10188. pages = this._pages;
  10189. viewer.textContent = "";
  10190. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  10191. for (var i = 0, iMax = pages.length; i < iMax; ++i) {
  10192. viewer.appendChild(pages[i].div);
  10193. }
  10194. } else {
  10195. var parity = this._spreadMode - 1;
  10196. var spread = null;
  10197. for (var _i = 0, _iMax = pages.length; _i < _iMax; ++_i) {
  10198. if (spread === null) {
  10199. spread = document.createElement("div");
  10200. spread.className = "spread";
  10201. viewer.appendChild(spread);
  10202. } else if (_i % 2 === parity) {
  10203. spread = spread.cloneNode(false);
  10204. viewer.appendChild(spread);
  10205. }
  10206. spread.appendChild(pages[_i].div);
  10207. }
  10208. }
  10209. if (!pageNumber) {
  10210. return;
  10211. }
  10212. this._setCurrentPageNumber(pageNumber, true);
  10213. this.update();
  10214. }
  10215. }, {
  10216. key: "pagesCount",
  10217. get: function get() {
  10218. return this._pages.length;
  10219. }
  10220. }, {
  10221. key: "pageViewsReady",
  10222. get: function get() {
  10223. if (!this._pagesCapability.settled) {
  10224. return false;
  10225. }
  10226. return this._pages.every(function (pageView) {
  10227. return pageView && pageView.pdfPage;
  10228. });
  10229. }
  10230. }, {
  10231. key: "currentPageNumber",
  10232. get: function get() {
  10233. return this._currentPageNumber;
  10234. },
  10235. set: function set(val) {
  10236. if (!Number.isInteger(val)) {
  10237. throw new Error("Invalid page number.");
  10238. }
  10239. if (!this.pdfDocument) {
  10240. return;
  10241. }
  10242. if (!this._setCurrentPageNumber(val, true)) {
  10243. console.error("".concat(this._name, ".currentPageNumber: \"").concat(val, "\" is not a valid page."));
  10244. }
  10245. }
  10246. }, {
  10247. key: "currentPageLabel",
  10248. get: function get() {
  10249. return this._pageLabels && this._pageLabels[this._currentPageNumber - 1];
  10250. },
  10251. set: function set(val) {
  10252. if (!this.pdfDocument) {
  10253. return;
  10254. }
  10255. var page = val | 0;
  10256. if (this._pageLabels) {
  10257. var i = this._pageLabels.indexOf(val);
  10258. if (i >= 0) {
  10259. page = i + 1;
  10260. }
  10261. }
  10262. if (!this._setCurrentPageNumber(page, true)) {
  10263. console.error("".concat(this._name, ".currentPageLabel: \"").concat(val, "\" is not a valid page."));
  10264. }
  10265. }
  10266. }, {
  10267. key: "currentScale",
  10268. get: function get() {
  10269. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
  10270. },
  10271. set: function set(val) {
  10272. if (isNaN(val)) {
  10273. throw new Error("Invalid numeric scale.");
  10274. }
  10275. if (!this.pdfDocument) {
  10276. return;
  10277. }
  10278. this._setScale(val, false);
  10279. }
  10280. }, {
  10281. key: "currentScaleValue",
  10282. get: function get() {
  10283. return this._currentScaleValue;
  10284. },
  10285. set: function set(val) {
  10286. if (!this.pdfDocument) {
  10287. return;
  10288. }
  10289. this._setScale(val, false);
  10290. }
  10291. }, {
  10292. key: "pagesRotation",
  10293. get: function get() {
  10294. return this._pagesRotation;
  10295. },
  10296. set: function set(rotation) {
  10297. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  10298. throw new Error("Invalid pages rotation angle.");
  10299. }
  10300. if (!this.pdfDocument) {
  10301. return;
  10302. }
  10303. if (this._pagesRotation === rotation) {
  10304. return;
  10305. }
  10306. this._pagesRotation = rotation;
  10307. var pageNumber = this._currentPageNumber;
  10308. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  10309. var pageView = this._pages[i];
  10310. pageView.update(pageView.scale, rotation);
  10311. }
  10312. if (this._currentScaleValue) {
  10313. this._setScale(this._currentScaleValue, true);
  10314. }
  10315. this.eventBus.dispatch("rotationchanging", {
  10316. source: this,
  10317. pagesRotation: rotation,
  10318. pageNumber: pageNumber
  10319. });
  10320. if (this.defaultRenderingQueue) {
  10321. this.update();
  10322. }
  10323. }
  10324. }, {
  10325. key: "firstPagePromise",
  10326. get: function get() {
  10327. return this.pdfDocument ? this._firstPageCapability.promise : null;
  10328. }
  10329. }, {
  10330. key: "onePageRendered",
  10331. get: function get() {
  10332. return this.pdfDocument ? this._onePageRenderedCapability.promise : null;
  10333. }
  10334. }, {
  10335. key: "pagesPromise",
  10336. get: function get() {
  10337. return this.pdfDocument ? this._pagesCapability.promise : null;
  10338. }
  10339. }, {
  10340. key: "_viewerElement",
  10341. get: function get() {
  10342. throw new Error("Not implemented: _viewerElement");
  10343. }
  10344. }, {
  10345. key: "_isScrollModeHorizontal",
  10346. get: function get() {
  10347. return this.isInPresentationMode ? false : this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL;
  10348. }
  10349. }, {
  10350. key: "isInPresentationMode",
  10351. get: function get() {
  10352. return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
  10353. }
  10354. }, {
  10355. key: "isChangingPresentationMode",
  10356. get: function get() {
  10357. return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
  10358. }
  10359. }, {
  10360. key: "isHorizontalScrollbarEnabled",
  10361. get: function get() {
  10362. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  10363. }
  10364. }, {
  10365. key: "isVerticalScrollbarEnabled",
  10366. get: function get() {
  10367. return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight;
  10368. }
  10369. }, {
  10370. key: "hasEqualPageSizes",
  10371. get: function get() {
  10372. var firstPageView = this._pages[0];
  10373. for (var i = 1, ii = this._pages.length; i < ii; ++i) {
  10374. var pageView = this._pages[i];
  10375. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  10376. return false;
  10377. }
  10378. }
  10379. return true;
  10380. }
  10381. }, {
  10382. key: "optionalContentConfigPromise",
  10383. get: function get() {
  10384. if (!this.pdfDocument) {
  10385. return Promise.resolve(null);
  10386. }
  10387. if (!this._optionalContentConfigPromise) {
  10388. return this.pdfDocument.getOptionalContentConfig();
  10389. }
  10390. return this._optionalContentConfigPromise;
  10391. },
  10392. set: function set(promise) {
  10393. if (!(promise instanceof Promise)) {
  10394. throw new Error("Invalid optionalContentConfigPromise: ".concat(promise));
  10395. }
  10396. if (!this.pdfDocument) {
  10397. return;
  10398. }
  10399. if (!this._optionalContentConfigPromise) {
  10400. return;
  10401. }
  10402. this._optionalContentConfigPromise = promise;
  10403. var _iterator = _createForOfIteratorHelper(this._pages),
  10404. _step;
  10405. try {
  10406. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  10407. var pageView = _step.value;
  10408. pageView.update(pageView.scale, pageView.rotation, promise);
  10409. }
  10410. } catch (err) {
  10411. _iterator.e(err);
  10412. } finally {
  10413. _iterator.f();
  10414. }
  10415. this.update();
  10416. this.eventBus.dispatch("optionalcontentconfigchanged", {
  10417. source: this,
  10418. promise: promise
  10419. });
  10420. }
  10421. }, {
  10422. key: "scrollMode",
  10423. get: function get() {
  10424. return this._scrollMode;
  10425. },
  10426. set: function set(mode) {
  10427. if (this._scrollMode === mode) {
  10428. return;
  10429. }
  10430. if (!(0, _ui_utils.isValidScrollMode)(mode)) {
  10431. throw new Error("Invalid scroll mode: ".concat(mode));
  10432. }
  10433. this._scrollMode = mode;
  10434. this.eventBus.dispatch("scrollmodechanged", {
  10435. source: this,
  10436. mode: mode
  10437. });
  10438. this._updateScrollMode(this._currentPageNumber);
  10439. }
  10440. }, {
  10441. key: "spreadMode",
  10442. get: function get() {
  10443. return this._spreadMode;
  10444. },
  10445. set: function set(mode) {
  10446. if (this._spreadMode === mode) {
  10447. return;
  10448. }
  10449. if (!(0, _ui_utils.isValidSpreadMode)(mode)) {
  10450. throw new Error("Invalid spread mode: ".concat(mode));
  10451. }
  10452. this._spreadMode = mode;
  10453. this.eventBus.dispatch("spreadmodechanged", {
  10454. source: this,
  10455. mode: mode
  10456. });
  10457. this._updateSpreadMode(this._currentPageNumber);
  10458. }
  10459. }]);
  10460. return BaseViewer;
  10461. }();
  10462. exports.BaseViewer = BaseViewer;
  10463. /***/ }),
  10464. /* 31 */
  10465. /***/ (function(module, exports, __webpack_require__) {
  10466. "use strict";
  10467. Object.defineProperty(exports, "__esModule", {
  10468. value: true
  10469. });
  10470. exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = void 0;
  10471. var _pdfjsLib = __webpack_require__(8);
  10472. var _ui_utils = __webpack_require__(5);
  10473. var _pdf_link_service = __webpack_require__(23);
  10474. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10475. 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); } }
  10476. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10477. var AnnotationLayerBuilder = /*#__PURE__*/function () {
  10478. function AnnotationLayerBuilder(_ref) {
  10479. var pageDiv = _ref.pageDiv,
  10480. pdfPage = _ref.pdfPage,
  10481. linkService = _ref.linkService,
  10482. downloadManager = _ref.downloadManager,
  10483. _ref$annotationStorag = _ref.annotationStorage,
  10484. annotationStorage = _ref$annotationStorag === void 0 ? null : _ref$annotationStorag,
  10485. _ref$imageResourcesPa = _ref.imageResourcesPath,
  10486. imageResourcesPath = _ref$imageResourcesPa === void 0 ? "" : _ref$imageResourcesPa,
  10487. _ref$renderInteractiv = _ref.renderInteractiveForms,
  10488. renderInteractiveForms = _ref$renderInteractiv === void 0 ? true : _ref$renderInteractiv,
  10489. _ref$l10n = _ref.l10n,
  10490. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  10491. _classCallCheck(this, AnnotationLayerBuilder);
  10492. this.pageDiv = pageDiv;
  10493. this.pdfPage = pdfPage;
  10494. this.linkService = linkService;
  10495. this.downloadManager = downloadManager;
  10496. this.imageResourcesPath = imageResourcesPath;
  10497. this.renderInteractiveForms = renderInteractiveForms;
  10498. this.l10n = l10n;
  10499. this.annotationStorage = annotationStorage;
  10500. this.div = null;
  10501. this._cancelled = false;
  10502. }
  10503. _createClass(AnnotationLayerBuilder, [{
  10504. key: "render",
  10505. value: function render(viewport) {
  10506. var _this = this;
  10507. var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "display";
  10508. return this.pdfPage.getAnnotations({
  10509. intent: intent
  10510. }).then(function (annotations) {
  10511. if (_this._cancelled) {
  10512. return;
  10513. }
  10514. if (annotations.length === 0) {
  10515. return;
  10516. }
  10517. var parameters = {
  10518. viewport: viewport.clone({
  10519. dontFlip: true
  10520. }),
  10521. div: _this.div,
  10522. annotations: annotations,
  10523. page: _this.pdfPage,
  10524. imageResourcesPath: _this.imageResourcesPath,
  10525. renderInteractiveForms: _this.renderInteractiveForms,
  10526. linkService: _this.linkService,
  10527. downloadManager: _this.downloadManager,
  10528. annotationStorage: _this.annotationStorage
  10529. };
  10530. if (_this.div) {
  10531. _pdfjsLib.AnnotationLayer.update(parameters);
  10532. } else {
  10533. _this.div = document.createElement("div");
  10534. _this.div.className = "annotationLayer";
  10535. _this.pageDiv.appendChild(_this.div);
  10536. parameters.div = _this.div;
  10537. _pdfjsLib.AnnotationLayer.render(parameters);
  10538. _this.l10n.translate(_this.div);
  10539. }
  10540. });
  10541. }
  10542. }, {
  10543. key: "cancel",
  10544. value: function cancel() {
  10545. this._cancelled = true;
  10546. }
  10547. }, {
  10548. key: "hide",
  10549. value: function hide() {
  10550. if (!this.div) {
  10551. return;
  10552. }
  10553. this.div.setAttribute("hidden", "true");
  10554. }
  10555. }]);
  10556. return AnnotationLayerBuilder;
  10557. }();
  10558. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  10559. var DefaultAnnotationLayerFactory = /*#__PURE__*/function () {
  10560. function DefaultAnnotationLayerFactory() {
  10561. _classCallCheck(this, DefaultAnnotationLayerFactory);
  10562. }
  10563. _createClass(DefaultAnnotationLayerFactory, [{
  10564. key: "createAnnotationLayerBuilder",
  10565. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  10566. var annotationStorage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  10567. var imageResourcesPath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "";
  10568. var renderInteractiveForms = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
  10569. var l10n = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : _ui_utils.NullL10n;
  10570. return new AnnotationLayerBuilder({
  10571. pageDiv: pageDiv,
  10572. pdfPage: pdfPage,
  10573. imageResourcesPath: imageResourcesPath,
  10574. renderInteractiveForms: renderInteractiveForms,
  10575. linkService: new _pdf_link_service.SimpleLinkService(),
  10576. l10n: l10n,
  10577. annotationStorage: annotationStorage
  10578. });
  10579. }
  10580. }]);
  10581. return DefaultAnnotationLayerFactory;
  10582. }();
  10583. exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
  10584. /***/ }),
  10585. /* 32 */
  10586. /***/ (function(module, exports, __webpack_require__) {
  10587. "use strict";
  10588. Object.defineProperty(exports, "__esModule", {
  10589. value: true
  10590. });
  10591. exports.PDFPageView = void 0;
  10592. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  10593. var _ui_utils = __webpack_require__(5);
  10594. var _pdfjsLib = __webpack_require__(8);
  10595. var _pdf_rendering_queue = __webpack_require__(11);
  10596. var _viewer_compatibility = __webpack_require__(7);
  10597. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  10598. 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); } }
  10599. 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); }); }; }
  10600. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10601. 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); } }
  10602. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10603. var MAX_CANVAS_PIXELS = _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216;
  10604. var PDFPageView = /*#__PURE__*/function () {
  10605. function PDFPageView(options) {
  10606. _classCallCheck(this, PDFPageView);
  10607. var container = options.container;
  10608. var defaultViewport = options.defaultViewport;
  10609. this.id = options.id;
  10610. this.renderingId = "page" + this.id;
  10611. this.pdfPage = null;
  10612. this.pageLabel = null;
  10613. this.rotation = 0;
  10614. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  10615. this.viewport = defaultViewport;
  10616. this.pdfPageRotate = defaultViewport.rotation;
  10617. this._annotationStorage = options.annotationStorage || null;
  10618. this._optionalContentConfigPromise = options.optionalContentConfigPromise || null;
  10619. this.hasRestrictedScaling = false;
  10620. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  10621. this.imageResourcesPath = options.imageResourcesPath || "";
  10622. this.renderInteractiveForms = typeof options.renderInteractiveForms === "boolean" ? options.renderInteractiveForms : true;
  10623. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  10624. this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
  10625. this.eventBus = options.eventBus;
  10626. this.renderingQueue = options.renderingQueue;
  10627. this.textLayerFactory = options.textLayerFactory;
  10628. this.annotationLayerFactory = options.annotationLayerFactory;
  10629. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  10630. this.enableWebGL = options.enableWebGL || false;
  10631. this.l10n = options.l10n || _ui_utils.NullL10n;
  10632. this.paintTask = null;
  10633. this.paintedViewportMap = new WeakMap();
  10634. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  10635. this.resume = null;
  10636. this.error = null;
  10637. this.annotationLayer = null;
  10638. this.textLayer = null;
  10639. this.zoomLayer = null;
  10640. var div = document.createElement("div");
  10641. div.className = "page";
  10642. div.style.width = Math.floor(this.viewport.width) + "px";
  10643. div.style.height = Math.floor(this.viewport.height) + "px";
  10644. div.setAttribute("data-page-number", this.id);
  10645. this.div = div;
  10646. container.appendChild(div);
  10647. }
  10648. _createClass(PDFPageView, [{
  10649. key: "setPdfPage",
  10650. value: function setPdfPage(pdfPage) {
  10651. this.pdfPage = pdfPage;
  10652. this.pdfPageRotate = pdfPage.rotate;
  10653. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  10654. this.viewport = pdfPage.getViewport({
  10655. scale: this.scale * _ui_utils.CSS_UNITS,
  10656. rotation: totalRotation
  10657. });
  10658. this.stats = pdfPage.stats;
  10659. this.reset();
  10660. }
  10661. }, {
  10662. key: "destroy",
  10663. value: function destroy() {
  10664. this.reset();
  10665. if (this.pdfPage) {
  10666. this.pdfPage.cleanup();
  10667. }
  10668. }
  10669. }, {
  10670. key: "_renderAnnotationLayer",
  10671. value: function () {
  10672. var _renderAnnotationLayer2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  10673. var error;
  10674. return _regenerator["default"].wrap(function _callee$(_context) {
  10675. while (1) {
  10676. switch (_context.prev = _context.next) {
  10677. case 0:
  10678. error = null;
  10679. _context.prev = 1;
  10680. _context.next = 4;
  10681. return this.annotationLayer.render(this.viewport, "display");
  10682. case 4:
  10683. _context.next = 9;
  10684. break;
  10685. case 6:
  10686. _context.prev = 6;
  10687. _context.t0 = _context["catch"](1);
  10688. error = _context.t0;
  10689. case 9:
  10690. _context.prev = 9;
  10691. this.eventBus.dispatch("annotationlayerrendered", {
  10692. source: this,
  10693. pageNumber: this.id,
  10694. error: error
  10695. });
  10696. return _context.finish(9);
  10697. case 12:
  10698. case "end":
  10699. return _context.stop();
  10700. }
  10701. }
  10702. }, _callee, this, [[1, 6, 9, 12]]);
  10703. }));
  10704. function _renderAnnotationLayer() {
  10705. return _renderAnnotationLayer2.apply(this, arguments);
  10706. }
  10707. return _renderAnnotationLayer;
  10708. }()
  10709. }, {
  10710. key: "_resetZoomLayer",
  10711. value: function _resetZoomLayer() {
  10712. var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  10713. if (!this.zoomLayer) {
  10714. return;
  10715. }
  10716. var zoomLayerCanvas = this.zoomLayer.firstChild;
  10717. this.paintedViewportMap["delete"](zoomLayerCanvas);
  10718. zoomLayerCanvas.width = 0;
  10719. zoomLayerCanvas.height = 0;
  10720. if (removeFromDOM) {
  10721. this.zoomLayer.remove();
  10722. }
  10723. this.zoomLayer = null;
  10724. }
  10725. }, {
  10726. key: "reset",
  10727. value: function reset() {
  10728. var keepZoomLayer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  10729. var keepAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  10730. this.cancelRendering(keepAnnotations);
  10731. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  10732. var div = this.div;
  10733. div.style.width = Math.floor(this.viewport.width) + "px";
  10734. div.style.height = Math.floor(this.viewport.height) + "px";
  10735. var childNodes = div.childNodes;
  10736. var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
  10737. var currentAnnotationNode = keepAnnotations && this.annotationLayer && this.annotationLayer.div || null;
  10738. for (var i = childNodes.length - 1; i >= 0; i--) {
  10739. var node = childNodes[i];
  10740. if (currentZoomLayerNode === node || currentAnnotationNode === node) {
  10741. continue;
  10742. }
  10743. div.removeChild(node);
  10744. }
  10745. div.removeAttribute("data-loaded");
  10746. if (currentAnnotationNode) {
  10747. this.annotationLayer.hide();
  10748. } else if (this.annotationLayer) {
  10749. this.annotationLayer.cancel();
  10750. this.annotationLayer = null;
  10751. }
  10752. if (!currentZoomLayerNode) {
  10753. if (this.canvas) {
  10754. this.paintedViewportMap["delete"](this.canvas);
  10755. this.canvas.width = 0;
  10756. this.canvas.height = 0;
  10757. delete this.canvas;
  10758. }
  10759. this._resetZoomLayer();
  10760. }
  10761. if (this.svg) {
  10762. this.paintedViewportMap["delete"](this.svg);
  10763. delete this.svg;
  10764. }
  10765. this.loadingIconDiv = document.createElement("div");
  10766. this.loadingIconDiv.className = "loadingIcon";
  10767. div.appendChild(this.loadingIconDiv);
  10768. }
  10769. }, {
  10770. key: "update",
  10771. value: function update(scale, rotation) {
  10772. var optionalContentConfigPromise = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  10773. this.scale = scale || this.scale;
  10774. if (typeof rotation !== "undefined") {
  10775. this.rotation = rotation;
  10776. }
  10777. if (optionalContentConfigPromise instanceof Promise) {
  10778. this._optionalContentConfigPromise = optionalContentConfigPromise;
  10779. }
  10780. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  10781. this.viewport = this.viewport.clone({
  10782. scale: this.scale * _ui_utils.CSS_UNITS,
  10783. rotation: totalRotation
  10784. });
  10785. if (this.svg) {
  10786. this.cssTransform(this.svg, true);
  10787. this.eventBus.dispatch("pagerendered", {
  10788. source: this,
  10789. pageNumber: this.id,
  10790. cssTransform: true,
  10791. timestamp: performance.now()
  10792. });
  10793. return;
  10794. }
  10795. var isScalingRestricted = false;
  10796. if (this.canvas && this.maxCanvasPixels > 0) {
  10797. var outputScale = this.outputScale;
  10798. if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > this.maxCanvasPixels) {
  10799. isScalingRestricted = true;
  10800. }
  10801. }
  10802. if (this.canvas) {
  10803. if (this.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
  10804. this.cssTransform(this.canvas, true);
  10805. this.eventBus.dispatch("pagerendered", {
  10806. source: this,
  10807. pageNumber: this.id,
  10808. cssTransform: true,
  10809. timestamp: performance.now()
  10810. });
  10811. return;
  10812. }
  10813. if (!this.zoomLayer && !this.canvas.hasAttribute("hidden")) {
  10814. this.zoomLayer = this.canvas.parentNode;
  10815. this.zoomLayer.style.position = "absolute";
  10816. }
  10817. }
  10818. if (this.zoomLayer) {
  10819. this.cssTransform(this.zoomLayer.firstChild);
  10820. }
  10821. this.reset(true, true);
  10822. }
  10823. }, {
  10824. key: "cancelRendering",
  10825. value: function cancelRendering() {
  10826. var keepAnnotations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  10827. if (this.paintTask) {
  10828. this.paintTask.cancel();
  10829. this.paintTask = null;
  10830. }
  10831. this.resume = null;
  10832. if (this.textLayer) {
  10833. this.textLayer.cancel();
  10834. this.textLayer = null;
  10835. }
  10836. if (!keepAnnotations && this.annotationLayer) {
  10837. this.annotationLayer.cancel();
  10838. this.annotationLayer = null;
  10839. }
  10840. }
  10841. }, {
  10842. key: "cssTransform",
  10843. value: function cssTransform(target) {
  10844. var redrawAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  10845. var width = this.viewport.width;
  10846. var height = this.viewport.height;
  10847. var div = this.div;
  10848. target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + "px";
  10849. target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + "px";
  10850. var relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
  10851. var absRotation = Math.abs(relativeRotation);
  10852. var scaleX = 1,
  10853. scaleY = 1;
  10854. if (absRotation === 90 || absRotation === 270) {
  10855. scaleX = height / width;
  10856. scaleY = width / height;
  10857. }
  10858. var cssTransform = "rotate(" + relativeRotation + "deg) " + "scale(" + scaleX + "," + scaleY + ")";
  10859. target.style.transform = cssTransform;
  10860. if (this.textLayer) {
  10861. var textLayerViewport = this.textLayer.viewport;
  10862. var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
  10863. var textAbsRotation = Math.abs(textRelativeRotation);
  10864. var scale = width / textLayerViewport.width;
  10865. if (textAbsRotation === 90 || textAbsRotation === 270) {
  10866. scale = width / textLayerViewport.height;
  10867. }
  10868. var textLayerDiv = this.textLayer.textLayerDiv;
  10869. var transX, transY;
  10870. switch (textAbsRotation) {
  10871. case 0:
  10872. transX = transY = 0;
  10873. break;
  10874. case 90:
  10875. transX = 0;
  10876. transY = "-" + textLayerDiv.style.height;
  10877. break;
  10878. case 180:
  10879. transX = "-" + textLayerDiv.style.width;
  10880. transY = "-" + textLayerDiv.style.height;
  10881. break;
  10882. case 270:
  10883. transX = "-" + textLayerDiv.style.width;
  10884. transY = 0;
  10885. break;
  10886. default:
  10887. console.error("Bad rotation value.");
  10888. break;
  10889. }
  10890. textLayerDiv.style.transform = "rotate(" + textAbsRotation + "deg) " + "scale(" + scale + ", " + scale + ") " + "translate(" + transX + ", " + transY + ")";
  10891. textLayerDiv.style.transformOrigin = "0% 0%";
  10892. }
  10893. if (redrawAnnotations && this.annotationLayer) {
  10894. this._renderAnnotationLayer();
  10895. }
  10896. }
  10897. }, {
  10898. key: "getPagePoint",
  10899. value: function getPagePoint(x, y) {
  10900. return this.viewport.convertToPdfPoint(x, y);
  10901. }
  10902. }, {
  10903. key: "draw",
  10904. value: function draw() {
  10905. var _this = this;
  10906. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  10907. console.error("Must be in new state before drawing");
  10908. this.reset();
  10909. }
  10910. var div = this.div,
  10911. pdfPage = this.pdfPage;
  10912. if (!pdfPage) {
  10913. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  10914. if (this.loadingIconDiv) {
  10915. div.removeChild(this.loadingIconDiv);
  10916. delete this.loadingIconDiv;
  10917. }
  10918. return Promise.reject(new Error("pdfPage is not loaded"));
  10919. }
  10920. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  10921. var canvasWrapper = document.createElement("div");
  10922. canvasWrapper.style.width = div.style.width;
  10923. canvasWrapper.style.height = div.style.height;
  10924. canvasWrapper.classList.add("canvasWrapper");
  10925. if (this.annotationLayer && this.annotationLayer.div) {
  10926. div.insertBefore(canvasWrapper, this.annotationLayer.div);
  10927. } else {
  10928. div.appendChild(canvasWrapper);
  10929. }
  10930. var textLayer = null;
  10931. if (this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && this.textLayerFactory) {
  10932. var textLayerDiv = document.createElement("div");
  10933. textLayerDiv.className = "textLayer";
  10934. textLayerDiv.style.width = canvasWrapper.style.width;
  10935. textLayerDiv.style.height = canvasWrapper.style.height;
  10936. if (this.annotationLayer && this.annotationLayer.div) {
  10937. div.insertBefore(textLayerDiv, this.annotationLayer.div);
  10938. } else {
  10939. div.appendChild(textLayerDiv);
  10940. }
  10941. textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.textLayerMode === _ui_utils.TextLayerMode.ENABLE_ENHANCE, this.eventBus);
  10942. }
  10943. this.textLayer = textLayer;
  10944. var renderContinueCallback = null;
  10945. if (this.renderingQueue) {
  10946. renderContinueCallback = function renderContinueCallback(cont) {
  10947. if (!_this.renderingQueue.isHighestPriority(_this)) {
  10948. _this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  10949. _this.resume = function () {
  10950. _this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  10951. cont();
  10952. };
  10953. return;
  10954. }
  10955. cont();
  10956. };
  10957. }
  10958. var finishPaintTask = /*#__PURE__*/function () {
  10959. var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(error) {
  10960. return _regenerator["default"].wrap(function _callee2$(_context2) {
  10961. while (1) {
  10962. switch (_context2.prev = _context2.next) {
  10963. case 0:
  10964. if (paintTask === _this.paintTask) {
  10965. _this.paintTask = null;
  10966. }
  10967. if (!(error instanceof _pdfjsLib.RenderingCancelledException)) {
  10968. _context2.next = 4;
  10969. break;
  10970. }
  10971. _this.error = null;
  10972. return _context2.abrupt("return");
  10973. case 4:
  10974. _this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  10975. if (_this.loadingIconDiv) {
  10976. div.removeChild(_this.loadingIconDiv);
  10977. delete _this.loadingIconDiv;
  10978. }
  10979. _this._resetZoomLayer(true);
  10980. _this.error = error;
  10981. _this.stats = pdfPage.stats;
  10982. _this.eventBus.dispatch("pagerendered", {
  10983. source: _this,
  10984. pageNumber: _this.id,
  10985. cssTransform: false,
  10986. timestamp: performance.now()
  10987. });
  10988. if (!error) {
  10989. _context2.next = 12;
  10990. break;
  10991. }
  10992. throw error;
  10993. case 12:
  10994. case "end":
  10995. return _context2.stop();
  10996. }
  10997. }
  10998. }, _callee2);
  10999. }));
  11000. return function finishPaintTask(_x) {
  11001. return _ref.apply(this, arguments);
  11002. };
  11003. }();
  11004. var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
  11005. paintTask.onRenderContinue = renderContinueCallback;
  11006. this.paintTask = paintTask;
  11007. var resultPromise = paintTask.promise.then(function () {
  11008. return finishPaintTask(null).then(function () {
  11009. if (textLayer) {
  11010. var readableStream = pdfPage.streamTextContent({
  11011. normalizeWhitespace: true
  11012. });
  11013. textLayer.setTextContentStream(readableStream);
  11014. textLayer.render();
  11015. }
  11016. });
  11017. }, function (reason) {
  11018. return finishPaintTask(reason);
  11019. });
  11020. if (this.annotationLayerFactory) {
  11021. if (!this.annotationLayer) {
  11022. this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this._annotationStorage, this.imageResourcesPath, this.renderInteractiveForms, this.l10n);
  11023. }
  11024. this._renderAnnotationLayer();
  11025. }
  11026. div.setAttribute("data-loaded", true);
  11027. this.eventBus.dispatch("pagerender", {
  11028. source: this,
  11029. pageNumber: this.id
  11030. });
  11031. return resultPromise;
  11032. }
  11033. }, {
  11034. key: "paintOnCanvas",
  11035. value: function paintOnCanvas(canvasWrapper) {
  11036. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  11037. var result = {
  11038. promise: renderCapability.promise,
  11039. onRenderContinue: function onRenderContinue(cont) {
  11040. cont();
  11041. },
  11042. cancel: function cancel() {
  11043. renderTask.cancel();
  11044. }
  11045. };
  11046. var viewport = this.viewport;
  11047. var canvas = document.createElement("canvas");
  11048. this.l10n.get("page_canvas", {
  11049. page: this.id
  11050. }, "Page {{page}}").then(function (msg) {
  11051. canvas.setAttribute("aria-label", msg);
  11052. });
  11053. canvas.setAttribute("hidden", "hidden");
  11054. var isCanvasHidden = true;
  11055. var showCanvas = function showCanvas() {
  11056. if (isCanvasHidden) {
  11057. canvas.removeAttribute("hidden");
  11058. isCanvasHidden = false;
  11059. }
  11060. };
  11061. canvasWrapper.appendChild(canvas);
  11062. this.canvas = canvas;
  11063. canvas.mozOpaque = true;
  11064. var ctx = canvas.getContext("2d", {
  11065. alpha: false
  11066. });
  11067. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  11068. this.outputScale = outputScale;
  11069. if (this.useOnlyCssZoom) {
  11070. var actualSizeViewport = viewport.clone({
  11071. scale: _ui_utils.CSS_UNITS
  11072. });
  11073. outputScale.sx *= actualSizeViewport.width / viewport.width;
  11074. outputScale.sy *= actualSizeViewport.height / viewport.height;
  11075. outputScale.scaled = true;
  11076. }
  11077. if (this.maxCanvasPixels > 0) {
  11078. var pixelsInViewport = viewport.width * viewport.height;
  11079. var maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
  11080. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  11081. outputScale.sx = maxScale;
  11082. outputScale.sy = maxScale;
  11083. outputScale.scaled = true;
  11084. this.hasRestrictedScaling = true;
  11085. } else {
  11086. this.hasRestrictedScaling = false;
  11087. }
  11088. }
  11089. var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  11090. var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  11091. canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
  11092. canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
  11093. canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + "px";
  11094. canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + "px";
  11095. this.paintedViewportMap.set(canvas, viewport);
  11096. var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
  11097. var renderContext = {
  11098. canvasContext: ctx,
  11099. transform: transform,
  11100. viewport: this.viewport,
  11101. enableWebGL: this.enableWebGL,
  11102. renderInteractiveForms: this.renderInteractiveForms,
  11103. optionalContentConfigPromise: this._optionalContentConfigPromise
  11104. };
  11105. var renderTask = this.pdfPage.render(renderContext);
  11106. renderTask.onContinue = function (cont) {
  11107. showCanvas();
  11108. if (result.onRenderContinue) {
  11109. result.onRenderContinue(cont);
  11110. } else {
  11111. cont();
  11112. }
  11113. };
  11114. renderTask.promise.then(function () {
  11115. showCanvas();
  11116. renderCapability.resolve(undefined);
  11117. }, function (error) {
  11118. showCanvas();
  11119. renderCapability.reject(error);
  11120. });
  11121. return result;
  11122. }
  11123. }, {
  11124. key: "paintOnSvg",
  11125. value: function paintOnSvg(wrapper) {
  11126. var _this2 = this;
  11127. var cancelled = false;
  11128. var ensureNotCancelled = function ensureNotCancelled() {
  11129. if (cancelled) {
  11130. throw new _pdfjsLib.RenderingCancelledException("Rendering cancelled, page ".concat(_this2.id), "svg");
  11131. }
  11132. };
  11133. var pdfPage = this.pdfPage;
  11134. var actualSizeViewport = this.viewport.clone({
  11135. scale: _ui_utils.CSS_UNITS
  11136. });
  11137. var promise = pdfPage.getOperatorList().then(function (opList) {
  11138. ensureNotCancelled();
  11139. var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
  11140. return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {
  11141. ensureNotCancelled();
  11142. _this2.svg = svg;
  11143. _this2.paintedViewportMap.set(svg, actualSizeViewport);
  11144. svg.style.width = wrapper.style.width;
  11145. svg.style.height = wrapper.style.height;
  11146. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  11147. wrapper.appendChild(svg);
  11148. });
  11149. });
  11150. return {
  11151. promise: promise,
  11152. onRenderContinue: function onRenderContinue(cont) {
  11153. cont();
  11154. },
  11155. cancel: function cancel() {
  11156. cancelled = true;
  11157. }
  11158. };
  11159. }
  11160. }, {
  11161. key: "setPageLabel",
  11162. value: function setPageLabel(label) {
  11163. this.pageLabel = typeof label === "string" ? label : null;
  11164. if (this.pageLabel !== null) {
  11165. this.div.setAttribute("data-page-label", this.pageLabel);
  11166. } else {
  11167. this.div.removeAttribute("data-page-label");
  11168. }
  11169. }
  11170. }, {
  11171. key: "width",
  11172. get: function get() {
  11173. return this.viewport.width;
  11174. }
  11175. }, {
  11176. key: "height",
  11177. get: function get() {
  11178. return this.viewport.height;
  11179. }
  11180. }]);
  11181. return PDFPageView;
  11182. }();
  11183. exports.PDFPageView = PDFPageView;
  11184. /***/ }),
  11185. /* 33 */
  11186. /***/ (function(module, exports, __webpack_require__) {
  11187. "use strict";
  11188. Object.defineProperty(exports, "__esModule", {
  11189. value: true
  11190. });
  11191. exports.DefaultTextLayerFactory = exports.TextLayerBuilder = void 0;
  11192. var _pdfjsLib = __webpack_require__(8);
  11193. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11194. 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); } }
  11195. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11196. var EXPAND_DIVS_TIMEOUT = 300;
  11197. var TextLayerBuilder = /*#__PURE__*/function () {
  11198. function TextLayerBuilder(_ref) {
  11199. var textLayerDiv = _ref.textLayerDiv,
  11200. eventBus = _ref.eventBus,
  11201. pageIndex = _ref.pageIndex,
  11202. viewport = _ref.viewport,
  11203. _ref$findController = _ref.findController,
  11204. findController = _ref$findController === void 0 ? null : _ref$findController,
  11205. _ref$enhanceTextSelec = _ref.enhanceTextSelection,
  11206. enhanceTextSelection = _ref$enhanceTextSelec === void 0 ? false : _ref$enhanceTextSelec;
  11207. _classCallCheck(this, TextLayerBuilder);
  11208. this.textLayerDiv = textLayerDiv;
  11209. this.eventBus = eventBus;
  11210. this.textContent = null;
  11211. this.textContentItemsStr = [];
  11212. this.textContentStream = null;
  11213. this.renderingDone = false;
  11214. this.pageIdx = pageIndex;
  11215. this.pageNumber = this.pageIdx + 1;
  11216. this.matches = [];
  11217. this.viewport = viewport;
  11218. this.textDivs = [];
  11219. this.findController = findController;
  11220. this.textLayerRenderTask = null;
  11221. this.enhanceTextSelection = enhanceTextSelection;
  11222. this._onUpdateTextLayerMatches = null;
  11223. this._bindMouse();
  11224. }
  11225. _createClass(TextLayerBuilder, [{
  11226. key: "_finishRendering",
  11227. value: function _finishRendering() {
  11228. this.renderingDone = true;
  11229. if (!this.enhanceTextSelection) {
  11230. var endOfContent = document.createElement("div");
  11231. endOfContent.className = "endOfContent";
  11232. this.textLayerDiv.appendChild(endOfContent);
  11233. }
  11234. this.eventBus.dispatch("textlayerrendered", {
  11235. source: this,
  11236. pageNumber: this.pageNumber,
  11237. numTextDivs: this.textDivs.length
  11238. });
  11239. }
  11240. }, {
  11241. key: "render",
  11242. value: function render() {
  11243. var _this = this;
  11244. var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  11245. if (!(this.textContent || this.textContentStream) || this.renderingDone) {
  11246. return;
  11247. }
  11248. this.cancel();
  11249. this.textDivs = [];
  11250. var textLayerFrag = document.createDocumentFragment();
  11251. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  11252. textContent: this.textContent,
  11253. textContentStream: this.textContentStream,
  11254. container: textLayerFrag,
  11255. viewport: this.viewport,
  11256. textDivs: this.textDivs,
  11257. textContentItemsStr: this.textContentItemsStr,
  11258. timeout: timeout,
  11259. enhanceTextSelection: this.enhanceTextSelection
  11260. });
  11261. this.textLayerRenderTask.promise.then(function () {
  11262. _this.textLayerDiv.appendChild(textLayerFrag);
  11263. _this._finishRendering();
  11264. _this._updateMatches();
  11265. }, function (reason) {});
  11266. if (!this._onUpdateTextLayerMatches) {
  11267. this._onUpdateTextLayerMatches = function (evt) {
  11268. if (evt.pageIndex === _this.pageIdx || evt.pageIndex === -1) {
  11269. _this._updateMatches();
  11270. }
  11271. };
  11272. this.eventBus._on("updatetextlayermatches", this._onUpdateTextLayerMatches);
  11273. }
  11274. }
  11275. }, {
  11276. key: "cancel",
  11277. value: function cancel() {
  11278. if (this.textLayerRenderTask) {
  11279. this.textLayerRenderTask.cancel();
  11280. this.textLayerRenderTask = null;
  11281. }
  11282. if (this._onUpdateTextLayerMatches) {
  11283. this.eventBus._off("updatetextlayermatches", this._onUpdateTextLayerMatches);
  11284. this._onUpdateTextLayerMatches = null;
  11285. }
  11286. }
  11287. }, {
  11288. key: "setTextContentStream",
  11289. value: function setTextContentStream(readableStream) {
  11290. this.cancel();
  11291. this.textContentStream = readableStream;
  11292. }
  11293. }, {
  11294. key: "setTextContent",
  11295. value: function setTextContent(textContent) {
  11296. this.cancel();
  11297. this.textContent = textContent;
  11298. }
  11299. }, {
  11300. key: "_convertMatches",
  11301. value: function _convertMatches(matches, matchesLength) {
  11302. if (!matches) {
  11303. return [];
  11304. }
  11305. var findController = this.findController,
  11306. textContentItemsStr = this.textContentItemsStr;
  11307. var i = 0,
  11308. iIndex = 0;
  11309. var end = textContentItemsStr.length - 1;
  11310. var queryLen = findController.state.query.length;
  11311. var result = [];
  11312. for (var m = 0, mm = matches.length; m < mm; m++) {
  11313. var matchIdx = matches[m];
  11314. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  11315. iIndex += textContentItemsStr[i].length;
  11316. i++;
  11317. }
  11318. if (i === textContentItemsStr.length) {
  11319. console.error("Could not find a matching mapping");
  11320. }
  11321. var match = {
  11322. begin: {
  11323. divIdx: i,
  11324. offset: matchIdx - iIndex
  11325. }
  11326. };
  11327. if (matchesLength) {
  11328. matchIdx += matchesLength[m];
  11329. } else {
  11330. matchIdx += queryLen;
  11331. }
  11332. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  11333. iIndex += textContentItemsStr[i].length;
  11334. i++;
  11335. }
  11336. match.end = {
  11337. divIdx: i,
  11338. offset: matchIdx - iIndex
  11339. };
  11340. result.push(match);
  11341. }
  11342. return result;
  11343. }
  11344. }, {
  11345. key: "_renderMatches",
  11346. value: function _renderMatches(matches) {
  11347. if (matches.length === 0) {
  11348. return;
  11349. }
  11350. var findController = this.findController,
  11351. pageIdx = this.pageIdx,
  11352. textContentItemsStr = this.textContentItemsStr,
  11353. textDivs = this.textDivs;
  11354. var isSelectedPage = pageIdx === findController.selected.pageIdx;
  11355. var selectedMatchIdx = findController.selected.matchIdx;
  11356. var highlightAll = findController.state.highlightAll;
  11357. var prevEnd = null;
  11358. var infinity = {
  11359. divIdx: -1,
  11360. offset: undefined
  11361. };
  11362. function beginText(begin, className) {
  11363. var divIdx = begin.divIdx;
  11364. textDivs[divIdx].textContent = "";
  11365. appendTextToDiv(divIdx, 0, begin.offset, className);
  11366. }
  11367. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  11368. var div = textDivs[divIdx];
  11369. var content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  11370. var node = document.createTextNode(content);
  11371. if (className) {
  11372. var span = document.createElement("span");
  11373. span.className = className;
  11374. span.appendChild(node);
  11375. div.appendChild(span);
  11376. return;
  11377. }
  11378. div.appendChild(node);
  11379. }
  11380. var i0 = selectedMatchIdx,
  11381. i1 = i0 + 1;
  11382. if (highlightAll) {
  11383. i0 = 0;
  11384. i1 = matches.length;
  11385. } else if (!isSelectedPage) {
  11386. return;
  11387. }
  11388. for (var i = i0; i < i1; i++) {
  11389. var match = matches[i];
  11390. var begin = match.begin;
  11391. var end = match.end;
  11392. var isSelected = isSelectedPage && i === selectedMatchIdx;
  11393. var highlightSuffix = isSelected ? " selected" : "";
  11394. if (isSelected) {
  11395. findController.scrollMatchIntoView({
  11396. element: textDivs[begin.divIdx],
  11397. pageIndex: pageIdx,
  11398. matchIndex: selectedMatchIdx
  11399. });
  11400. }
  11401. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  11402. if (prevEnd !== null) {
  11403. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  11404. }
  11405. beginText(begin);
  11406. } else {
  11407. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  11408. }
  11409. if (begin.divIdx === end.divIdx) {
  11410. appendTextToDiv(begin.divIdx, begin.offset, end.offset, "highlight" + highlightSuffix);
  11411. } else {
  11412. appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, "highlight begin" + highlightSuffix);
  11413. for (var n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  11414. textDivs[n0].className = "highlight middle" + highlightSuffix;
  11415. }
  11416. beginText(end, "highlight end" + highlightSuffix);
  11417. }
  11418. prevEnd = end;
  11419. }
  11420. if (prevEnd) {
  11421. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  11422. }
  11423. }
  11424. }, {
  11425. key: "_updateMatches",
  11426. value: function _updateMatches() {
  11427. if (!this.renderingDone) {
  11428. return;
  11429. }
  11430. var findController = this.findController,
  11431. matches = this.matches,
  11432. pageIdx = this.pageIdx,
  11433. textContentItemsStr = this.textContentItemsStr,
  11434. textDivs = this.textDivs;
  11435. var clearedUntilDivIdx = -1;
  11436. for (var i = 0, ii = matches.length; i < ii; i++) {
  11437. var match = matches[i];
  11438. var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  11439. for (var n = begin, end = match.end.divIdx; n <= end; n++) {
  11440. var div = textDivs[n];
  11441. div.textContent = textContentItemsStr[n];
  11442. div.className = "";
  11443. }
  11444. clearedUntilDivIdx = match.end.divIdx + 1;
  11445. }
  11446. if (!findController || !findController.highlightMatches) {
  11447. return;
  11448. }
  11449. var pageMatches = findController.pageMatches[pageIdx] || null;
  11450. var pageMatchesLength = findController.pageMatchesLength[pageIdx] || null;
  11451. this.matches = this._convertMatches(pageMatches, pageMatchesLength);
  11452. this._renderMatches(this.matches);
  11453. }
  11454. }, {
  11455. key: "_bindMouse",
  11456. value: function _bindMouse() {
  11457. var _this2 = this;
  11458. var div = this.textLayerDiv;
  11459. var expandDivsTimer = null;
  11460. div.addEventListener("mousedown", function (evt) {
  11461. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  11462. _this2.textLayerRenderTask.expandTextDivs(true);
  11463. if (expandDivsTimer) {
  11464. clearTimeout(expandDivsTimer);
  11465. expandDivsTimer = null;
  11466. }
  11467. return;
  11468. }
  11469. var end = div.querySelector(".endOfContent");
  11470. if (!end) {
  11471. return;
  11472. }
  11473. var adjustTop = evt.target !== div;
  11474. adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue("-moz-user-select") !== "none";
  11475. if (adjustTop) {
  11476. var divBounds = div.getBoundingClientRect();
  11477. var r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  11478. end.style.top = (r * 100).toFixed(2) + "%";
  11479. }
  11480. end.classList.add("active");
  11481. });
  11482. div.addEventListener("mouseup", function () {
  11483. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  11484. expandDivsTimer = setTimeout(function () {
  11485. if (_this2.textLayerRenderTask) {
  11486. _this2.textLayerRenderTask.expandTextDivs(false);
  11487. }
  11488. expandDivsTimer = null;
  11489. }, EXPAND_DIVS_TIMEOUT);
  11490. return;
  11491. }
  11492. var end = div.querySelector(".endOfContent");
  11493. if (!end) {
  11494. return;
  11495. }
  11496. end.style.top = "";
  11497. end.classList.remove("active");
  11498. });
  11499. }
  11500. }]);
  11501. return TextLayerBuilder;
  11502. }();
  11503. exports.TextLayerBuilder = TextLayerBuilder;
  11504. var DefaultTextLayerFactory = /*#__PURE__*/function () {
  11505. function DefaultTextLayerFactory() {
  11506. _classCallCheck(this, DefaultTextLayerFactory);
  11507. }
  11508. _createClass(DefaultTextLayerFactory, [{
  11509. key: "createTextLayerBuilder",
  11510. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  11511. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  11512. var eventBus = arguments.length > 4 ? arguments[4] : undefined;
  11513. return new TextLayerBuilder({
  11514. textLayerDiv: textLayerDiv,
  11515. pageIndex: pageIndex,
  11516. viewport: viewport,
  11517. enhanceTextSelection: enhanceTextSelection,
  11518. eventBus: eventBus
  11519. });
  11520. }
  11521. }]);
  11522. return DefaultTextLayerFactory;
  11523. }();
  11524. exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
  11525. /***/ }),
  11526. /* 34 */
  11527. /***/ (function(module, exports, __webpack_require__) {
  11528. "use strict";
  11529. Object.defineProperty(exports, "__esModule", {
  11530. value: true
  11531. });
  11532. exports.SecondaryToolbar = void 0;
  11533. var _ui_utils = __webpack_require__(5);
  11534. var _pdf_cursor_tools = __webpack_require__(9);
  11535. var _pdf_single_page_viewer = __webpack_require__(35);
  11536. 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; } } }; }
  11537. 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); }
  11538. 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; }
  11539. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11540. 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); } }
  11541. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11542. var SecondaryToolbar = /*#__PURE__*/function () {
  11543. function SecondaryToolbar(options, mainContainer, eventBus) {
  11544. var _this = this;
  11545. _classCallCheck(this, SecondaryToolbar);
  11546. this.toolbar = options.toolbar;
  11547. this.toggleButton = options.toggleButton;
  11548. this.toolbarButtonContainer = options.toolbarButtonContainer;
  11549. this.buttons = [{
  11550. element: options.presentationModeButton,
  11551. eventName: "presentationmode",
  11552. close: true
  11553. }, {
  11554. element: options.openFileButton,
  11555. eventName: "openfile",
  11556. close: true
  11557. }, {
  11558. element: options.printButton,
  11559. eventName: "print",
  11560. close: true
  11561. }, {
  11562. element: options.downloadButton,
  11563. eventName: "download",
  11564. close: true
  11565. }, {
  11566. element: options.viewBookmarkButton,
  11567. eventName: null,
  11568. close: true
  11569. }, {
  11570. element: options.firstPageButton,
  11571. eventName: "firstpage",
  11572. close: true
  11573. }, {
  11574. element: options.lastPageButton,
  11575. eventName: "lastpage",
  11576. close: true
  11577. }, {
  11578. element: options.pageRotateCwButton,
  11579. eventName: "rotatecw",
  11580. close: false
  11581. }, {
  11582. element: options.pageRotateCcwButton,
  11583. eventName: "rotateccw",
  11584. close: false
  11585. }, {
  11586. element: options.cursorSelectToolButton,
  11587. eventName: "switchcursortool",
  11588. eventDetails: {
  11589. tool: _pdf_cursor_tools.CursorTool.SELECT
  11590. },
  11591. close: true
  11592. }, {
  11593. element: options.cursorHandToolButton,
  11594. eventName: "switchcursortool",
  11595. eventDetails: {
  11596. tool: _pdf_cursor_tools.CursorTool.HAND
  11597. },
  11598. close: true
  11599. }, {
  11600. element: options.scrollVerticalButton,
  11601. eventName: "switchscrollmode",
  11602. eventDetails: {
  11603. mode: _ui_utils.ScrollMode.VERTICAL
  11604. },
  11605. close: true
  11606. }, {
  11607. element: options.scrollHorizontalButton,
  11608. eventName: "switchscrollmode",
  11609. eventDetails: {
  11610. mode: _ui_utils.ScrollMode.HORIZONTAL
  11611. },
  11612. close: true
  11613. }, {
  11614. element: options.scrollWrappedButton,
  11615. eventName: "switchscrollmode",
  11616. eventDetails: {
  11617. mode: _ui_utils.ScrollMode.WRAPPED
  11618. },
  11619. close: true
  11620. }, {
  11621. element: options.spreadNoneButton,
  11622. eventName: "switchspreadmode",
  11623. eventDetails: {
  11624. mode: _ui_utils.SpreadMode.NONE
  11625. },
  11626. close: true
  11627. }, {
  11628. element: options.spreadOddButton,
  11629. eventName: "switchspreadmode",
  11630. eventDetails: {
  11631. mode: _ui_utils.SpreadMode.ODD
  11632. },
  11633. close: true
  11634. }, {
  11635. element: options.spreadEvenButton,
  11636. eventName: "switchspreadmode",
  11637. eventDetails: {
  11638. mode: _ui_utils.SpreadMode.EVEN
  11639. },
  11640. close: true
  11641. }, {
  11642. element: options.documentPropertiesButton,
  11643. eventName: "documentproperties",
  11644. close: true
  11645. }];
  11646. this.items = {
  11647. firstPage: options.firstPageButton,
  11648. lastPage: options.lastPageButton,
  11649. pageRotateCw: options.pageRotateCwButton,
  11650. pageRotateCcw: options.pageRotateCcwButton
  11651. };
  11652. this.mainContainer = mainContainer;
  11653. this.eventBus = eventBus;
  11654. this.opened = false;
  11655. this.containerHeight = null;
  11656. this.previousContainerHeight = null;
  11657. this.reset();
  11658. this._bindClickListeners();
  11659. this._bindCursorToolsListener(options);
  11660. this._bindScrollModeListener(options);
  11661. this._bindSpreadModeListener(options);
  11662. this.eventBus._on("resize", this._setMaxHeight.bind(this));
  11663. this.eventBus._on("baseviewerinit", function (evt) {
  11664. if (evt.source instanceof _pdf_single_page_viewer.PDFSinglePageViewer) {
  11665. _this.toolbarButtonContainer.classList.add("hiddenScrollModeButtons", "hiddenSpreadModeButtons");
  11666. } else {
  11667. _this.toolbarButtonContainer.classList.remove("hiddenScrollModeButtons", "hiddenSpreadModeButtons");
  11668. }
  11669. });
  11670. }
  11671. _createClass(SecondaryToolbar, [{
  11672. key: "setPageNumber",
  11673. value: function setPageNumber(pageNumber) {
  11674. this.pageNumber = pageNumber;
  11675. this._updateUIState();
  11676. }
  11677. }, {
  11678. key: "setPagesCount",
  11679. value: function setPagesCount(pagesCount) {
  11680. this.pagesCount = pagesCount;
  11681. this._updateUIState();
  11682. }
  11683. }, {
  11684. key: "reset",
  11685. value: function reset() {
  11686. this.pageNumber = 0;
  11687. this.pagesCount = 0;
  11688. this._updateUIState();
  11689. this.eventBus.dispatch("secondarytoolbarreset", {
  11690. source: this
  11691. });
  11692. }
  11693. }, {
  11694. key: "_updateUIState",
  11695. value: function _updateUIState() {
  11696. this.items.firstPage.disabled = this.pageNumber <= 1;
  11697. this.items.lastPage.disabled = this.pageNumber >= this.pagesCount;
  11698. this.items.pageRotateCw.disabled = this.pagesCount === 0;
  11699. this.items.pageRotateCcw.disabled = this.pagesCount === 0;
  11700. }
  11701. }, {
  11702. key: "_bindClickListeners",
  11703. value: function _bindClickListeners() {
  11704. var _this2 = this;
  11705. this.toggleButton.addEventListener("click", this.toggle.bind(this));
  11706. var _iterator = _createForOfIteratorHelper(this.buttons),
  11707. _step;
  11708. try {
  11709. var _loop = function _loop() {
  11710. var _step$value = _step.value,
  11711. element = _step$value.element,
  11712. eventName = _step$value.eventName,
  11713. close = _step$value.close,
  11714. eventDetails = _step$value.eventDetails;
  11715. element.addEventListener("click", function (evt) {
  11716. if (eventName !== null) {
  11717. var details = {
  11718. source: _this2
  11719. };
  11720. for (var property in eventDetails) {
  11721. details[property] = eventDetails[property];
  11722. }
  11723. _this2.eventBus.dispatch(eventName, details);
  11724. }
  11725. if (close) {
  11726. _this2.close();
  11727. }
  11728. });
  11729. };
  11730. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  11731. _loop();
  11732. }
  11733. } catch (err) {
  11734. _iterator.e(err);
  11735. } finally {
  11736. _iterator.f();
  11737. }
  11738. }
  11739. }, {
  11740. key: "_bindCursorToolsListener",
  11741. value: function _bindCursorToolsListener(buttons) {
  11742. this.eventBus._on("cursortoolchanged", function (_ref) {
  11743. var tool = _ref.tool;
  11744. buttons.cursorSelectToolButton.classList.toggle("toggled", tool === _pdf_cursor_tools.CursorTool.SELECT);
  11745. buttons.cursorHandToolButton.classList.toggle("toggled", tool === _pdf_cursor_tools.CursorTool.HAND);
  11746. });
  11747. }
  11748. }, {
  11749. key: "_bindScrollModeListener",
  11750. value: function _bindScrollModeListener(buttons) {
  11751. var _this3 = this;
  11752. function scrollModeChanged(_ref2) {
  11753. var mode = _ref2.mode;
  11754. buttons.scrollVerticalButton.classList.toggle("toggled", mode === _ui_utils.ScrollMode.VERTICAL);
  11755. buttons.scrollHorizontalButton.classList.toggle("toggled", mode === _ui_utils.ScrollMode.HORIZONTAL);
  11756. buttons.scrollWrappedButton.classList.toggle("toggled", mode === _ui_utils.ScrollMode.WRAPPED);
  11757. var isScrollModeHorizontal = mode === _ui_utils.ScrollMode.HORIZONTAL;
  11758. buttons.spreadNoneButton.disabled = isScrollModeHorizontal;
  11759. buttons.spreadOddButton.disabled = isScrollModeHorizontal;
  11760. buttons.spreadEvenButton.disabled = isScrollModeHorizontal;
  11761. }
  11762. this.eventBus._on("scrollmodechanged", scrollModeChanged);
  11763. this.eventBus._on("secondarytoolbarreset", function (evt) {
  11764. if (evt.source === _this3) {
  11765. scrollModeChanged({
  11766. mode: _ui_utils.ScrollMode.VERTICAL
  11767. });
  11768. }
  11769. });
  11770. }
  11771. }, {
  11772. key: "_bindSpreadModeListener",
  11773. value: function _bindSpreadModeListener(buttons) {
  11774. var _this4 = this;
  11775. function spreadModeChanged(_ref3) {
  11776. var mode = _ref3.mode;
  11777. buttons.spreadNoneButton.classList.toggle("toggled", mode === _ui_utils.SpreadMode.NONE);
  11778. buttons.spreadOddButton.classList.toggle("toggled", mode === _ui_utils.SpreadMode.ODD);
  11779. buttons.spreadEvenButton.classList.toggle("toggled", mode === _ui_utils.SpreadMode.EVEN);
  11780. }
  11781. this.eventBus._on("spreadmodechanged", spreadModeChanged);
  11782. this.eventBus._on("secondarytoolbarreset", function (evt) {
  11783. if (evt.source === _this4) {
  11784. spreadModeChanged({
  11785. mode: _ui_utils.SpreadMode.NONE
  11786. });
  11787. }
  11788. });
  11789. }
  11790. }, {
  11791. key: "open",
  11792. value: function open() {
  11793. if (this.opened) {
  11794. return;
  11795. }
  11796. this.opened = true;
  11797. this._setMaxHeight();
  11798. this.toggleButton.classList.add("toggled");
  11799. this.toolbar.classList.remove("hidden");
  11800. }
  11801. }, {
  11802. key: "close",
  11803. value: function close() {
  11804. if (!this.opened) {
  11805. return;
  11806. }
  11807. this.opened = false;
  11808. this.toolbar.classList.add("hidden");
  11809. this.toggleButton.classList.remove("toggled");
  11810. }
  11811. }, {
  11812. key: "toggle",
  11813. value: function toggle() {
  11814. if (this.opened) {
  11815. this.close();
  11816. } else {
  11817. this.open();
  11818. }
  11819. }
  11820. }, {
  11821. key: "_setMaxHeight",
  11822. value: function _setMaxHeight() {
  11823. if (!this.opened) {
  11824. return;
  11825. }
  11826. this.containerHeight = this.mainContainer.clientHeight;
  11827. if (this.containerHeight === this.previousContainerHeight) {
  11828. return;
  11829. }
  11830. this.toolbarButtonContainer.style.maxHeight = "".concat(this.containerHeight - _ui_utils.SCROLLBAR_PADDING, "px");
  11831. this.previousContainerHeight = this.containerHeight;
  11832. }
  11833. }, {
  11834. key: "isOpen",
  11835. get: function get() {
  11836. return this.opened;
  11837. }
  11838. }]);
  11839. return SecondaryToolbar;
  11840. }();
  11841. exports.SecondaryToolbar = SecondaryToolbar;
  11842. /***/ }),
  11843. /* 35 */
  11844. /***/ (function(module, exports, __webpack_require__) {
  11845. "use strict";
  11846. Object.defineProperty(exports, "__esModule", {
  11847. value: true
  11848. });
  11849. exports.PDFSinglePageViewer = void 0;
  11850. var _base_viewer = __webpack_require__(30);
  11851. var _pdfjsLib = __webpack_require__(8);
  11852. 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); }
  11853. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11854. 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); } }
  11855. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11856. 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); }
  11857. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  11858. 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); }
  11859. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  11860. 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); }; }
  11861. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  11862. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  11863. 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; } }
  11864. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  11865. var PDFSinglePageViewer = /*#__PURE__*/function (_BaseViewer) {
  11866. _inherits(PDFSinglePageViewer, _BaseViewer);
  11867. var _super = _createSuper(PDFSinglePageViewer);
  11868. function PDFSinglePageViewer(options) {
  11869. var _this;
  11870. _classCallCheck(this, PDFSinglePageViewer);
  11871. _this = _super.call(this, options);
  11872. _this.eventBus._on("pagesinit", function (evt) {
  11873. _this._ensurePageViewVisible();
  11874. });
  11875. return _this;
  11876. }
  11877. _createClass(PDFSinglePageViewer, [{
  11878. key: "_resetView",
  11879. value: function _resetView() {
  11880. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_resetView", this).call(this);
  11881. this._previousPageNumber = 1;
  11882. this._shadowViewer = document.createDocumentFragment();
  11883. this._updateScrollDown = null;
  11884. }
  11885. }, {
  11886. key: "_ensurePageViewVisible",
  11887. value: function _ensurePageViewVisible() {
  11888. var pageView = this._pages[this._currentPageNumber - 1];
  11889. var previousPageView = this._pages[this._previousPageNumber - 1];
  11890. var viewerNodes = this.viewer.childNodes;
  11891. switch (viewerNodes.length) {
  11892. case 0:
  11893. this.viewer.appendChild(pageView.div);
  11894. break;
  11895. case 1:
  11896. if (viewerNodes[0] !== previousPageView.div) {
  11897. throw new Error("_ensurePageViewVisible: Unexpected previously visible page.");
  11898. }
  11899. if (pageView === previousPageView) {
  11900. break;
  11901. }
  11902. this._shadowViewer.appendChild(previousPageView.div);
  11903. this.viewer.appendChild(pageView.div);
  11904. this.container.scrollTop = 0;
  11905. break;
  11906. default:
  11907. throw new Error("_ensurePageViewVisible: Only one page should be visible at a time.");
  11908. }
  11909. this._previousPageNumber = this._currentPageNumber;
  11910. }
  11911. }, {
  11912. key: "_scrollUpdate",
  11913. value: function _scrollUpdate() {
  11914. if (this._updateScrollDown) {
  11915. this._updateScrollDown();
  11916. }
  11917. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollUpdate", this).call(this);
  11918. }
  11919. }, {
  11920. key: "_scrollIntoView",
  11921. value: function _scrollIntoView(_ref) {
  11922. var _this2 = this;
  11923. var pageDiv = _ref.pageDiv,
  11924. _ref$pageSpot = _ref.pageSpot,
  11925. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  11926. _ref$pageNumber = _ref.pageNumber,
  11927. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  11928. if (pageNumber) {
  11929. this._setCurrentPageNumber(pageNumber);
  11930. }
  11931. var scrolledDown = this._currentPageNumber >= this._previousPageNumber;
  11932. this._ensurePageViewVisible();
  11933. this.update();
  11934. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollIntoView", this).call(this, {
  11935. pageDiv: pageDiv,
  11936. pageSpot: pageSpot,
  11937. pageNumber: pageNumber
  11938. });
  11939. this._updateScrollDown = function () {
  11940. _this2.scroll.down = scrolledDown;
  11941. _this2._updateScrollDown = null;
  11942. };
  11943. }
  11944. }, {
  11945. key: "_getVisiblePages",
  11946. value: function _getVisiblePages() {
  11947. return this._getCurrentVisiblePage();
  11948. }
  11949. }, {
  11950. key: "_updateHelper",
  11951. value: function _updateHelper(visiblePages) {}
  11952. }, {
  11953. key: "_updateScrollMode",
  11954. value: function _updateScrollMode() {}
  11955. }, {
  11956. key: "_updateSpreadMode",
  11957. value: function _updateSpreadMode() {}
  11958. }, {
  11959. key: "_viewerElement",
  11960. get: function get() {
  11961. return (0, _pdfjsLib.shadow)(this, "_viewerElement", this._shadowViewer);
  11962. }
  11963. }, {
  11964. key: "_isScrollModeHorizontal",
  11965. get: function get() {
  11966. return (0, _pdfjsLib.shadow)(this, "_isScrollModeHorizontal", false);
  11967. }
  11968. }]);
  11969. return PDFSinglePageViewer;
  11970. }(_base_viewer.BaseViewer);
  11971. exports.PDFSinglePageViewer = PDFSinglePageViewer;
  11972. /***/ }),
  11973. /* 36 */
  11974. /***/ (function(module, exports, __webpack_require__) {
  11975. "use strict";
  11976. Object.defineProperty(exports, "__esModule", {
  11977. value: true
  11978. });
  11979. exports.Toolbar = void 0;
  11980. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  11981. var _ui_utils = __webpack_require__(5);
  11982. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11983. 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); } }
  11984. 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); }); }; }
  11985. 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; } } }; }
  11986. 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); }
  11987. 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; }
  11988. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11989. 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); } }
  11990. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11991. var PAGE_NUMBER_LOADING_INDICATOR = "visiblePageIsLoading";
  11992. var SCALE_SELECT_CONTAINER_WIDTH = 140;
  11993. var SCALE_SELECT_WIDTH = 162;
  11994. var Toolbar = /*#__PURE__*/function () {
  11995. function Toolbar(options, eventBus) {
  11996. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  11997. _classCallCheck(this, Toolbar);
  11998. this.toolbar = options.container;
  11999. this.eventBus = eventBus;
  12000. this.l10n = l10n;
  12001. this.buttons = [{
  12002. element: options.previous,
  12003. eventName: "previouspage"
  12004. }, {
  12005. element: options.next,
  12006. eventName: "nextpage"
  12007. }, {
  12008. element: options.zoomIn,
  12009. eventName: "zoomin"
  12010. }, {
  12011. element: options.zoomOut,
  12012. eventName: "zoomout"
  12013. }, {
  12014. element: options.openFile,
  12015. eventName: "openfile"
  12016. }, {
  12017. element: options.print,
  12018. eventName: "print"
  12019. }, {
  12020. element: options.presentationModeButton,
  12021. eventName: "presentationmode"
  12022. }, {
  12023. element: options.download,
  12024. eventName: "download"
  12025. }, {
  12026. element: options.viewBookmark,
  12027. eventName: null
  12028. }];
  12029. this.items = {
  12030. numPages: options.numPages,
  12031. pageNumber: options.pageNumber,
  12032. scaleSelectContainer: options.scaleSelectContainer,
  12033. scaleSelect: options.scaleSelect,
  12034. customScaleOption: options.customScaleOption,
  12035. previous: options.previous,
  12036. next: options.next,
  12037. zoomIn: options.zoomIn,
  12038. zoomOut: options.zoomOut
  12039. };
  12040. this._wasLocalized = false;
  12041. this.reset();
  12042. this._bindListeners();
  12043. }
  12044. _createClass(Toolbar, [{
  12045. key: "setPageNumber",
  12046. value: function setPageNumber(pageNumber, pageLabel) {
  12047. this.pageNumber = pageNumber;
  12048. this.pageLabel = pageLabel;
  12049. this._updateUIState(false);
  12050. }
  12051. }, {
  12052. key: "setPagesCount",
  12053. value: function setPagesCount(pagesCount, hasPageLabels) {
  12054. this.pagesCount = pagesCount;
  12055. this.hasPageLabels = hasPageLabels;
  12056. this._updateUIState(true);
  12057. }
  12058. }, {
  12059. key: "setPageScale",
  12060. value: function setPageScale(pageScaleValue, pageScale) {
  12061. this.pageScaleValue = (pageScaleValue || pageScale).toString();
  12062. this.pageScale = pageScale;
  12063. this._updateUIState(false);
  12064. }
  12065. }, {
  12066. key: "reset",
  12067. value: function reset() {
  12068. this.pageNumber = 0;
  12069. this.pageLabel = null;
  12070. this.hasPageLabels = false;
  12071. this.pagesCount = 0;
  12072. this.pageScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  12073. this.pageScale = _ui_utils.DEFAULT_SCALE;
  12074. this._updateUIState(true);
  12075. this.updateLoadingIndicatorState();
  12076. }
  12077. }, {
  12078. key: "_bindListeners",
  12079. value: function _bindListeners() {
  12080. var _this = this;
  12081. var _this$items = this.items,
  12082. pageNumber = _this$items.pageNumber,
  12083. scaleSelect = _this$items.scaleSelect;
  12084. var self = this;
  12085. var _iterator = _createForOfIteratorHelper(this.buttons),
  12086. _step;
  12087. try {
  12088. var _loop = function _loop() {
  12089. var _step$value = _step.value,
  12090. element = _step$value.element,
  12091. eventName = _step$value.eventName;
  12092. element.addEventListener("click", function (evt) {
  12093. if (eventName !== null) {
  12094. _this.eventBus.dispatch(eventName, {
  12095. source: _this
  12096. });
  12097. }
  12098. });
  12099. };
  12100. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  12101. _loop();
  12102. }
  12103. } catch (err) {
  12104. _iterator.e(err);
  12105. } finally {
  12106. _iterator.f();
  12107. }
  12108. pageNumber.addEventListener("click", function () {
  12109. this.select();
  12110. });
  12111. pageNumber.addEventListener("change", function () {
  12112. self.eventBus.dispatch("pagenumberchanged", {
  12113. source: self,
  12114. value: this.value
  12115. });
  12116. });
  12117. scaleSelect.addEventListener("change", function () {
  12118. if (this.value === "custom") {
  12119. return;
  12120. }
  12121. self.eventBus.dispatch("scalechanged", {
  12122. source: self,
  12123. value: this.value
  12124. });
  12125. });
  12126. scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler;
  12127. this.eventBus._on("localized", function () {
  12128. _this._wasLocalized = true;
  12129. _this._adjustScaleWidth();
  12130. _this._updateUIState(true);
  12131. });
  12132. }
  12133. }, {
  12134. key: "_updateUIState",
  12135. value: function _updateUIState() {
  12136. var resetNumPages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  12137. if (!this._wasLocalized) {
  12138. return;
  12139. }
  12140. var pageNumber = this.pageNumber,
  12141. pagesCount = this.pagesCount,
  12142. pageScaleValue = this.pageScaleValue,
  12143. pageScale = this.pageScale,
  12144. items = this.items;
  12145. if (resetNumPages) {
  12146. if (this.hasPageLabels) {
  12147. items.pageNumber.type = "text";
  12148. } else {
  12149. items.pageNumber.type = "number";
  12150. this.l10n.get("of_pages", {
  12151. pagesCount: pagesCount
  12152. }, "of {{pagesCount}}").then(function (msg) {
  12153. items.numPages.textContent = msg;
  12154. });
  12155. }
  12156. items.pageNumber.max = pagesCount;
  12157. }
  12158. if (this.hasPageLabels) {
  12159. items.pageNumber.value = this.pageLabel;
  12160. this.l10n.get("page_of_pages", {
  12161. pageNumber: pageNumber,
  12162. pagesCount: pagesCount
  12163. }, "({{pageNumber}} of {{pagesCount}})").then(function (msg) {
  12164. items.numPages.textContent = msg;
  12165. });
  12166. } else {
  12167. items.pageNumber.value = pageNumber;
  12168. }
  12169. items.previous.disabled = pageNumber <= 1;
  12170. items.next.disabled = pageNumber >= pagesCount;
  12171. items.zoomOut.disabled = pageScale <= _ui_utils.MIN_SCALE;
  12172. items.zoomIn.disabled = pageScale >= _ui_utils.MAX_SCALE;
  12173. var customScale = Math.round(pageScale * 10000) / 100;
  12174. this.l10n.get("page_scale_percent", {
  12175. scale: customScale
  12176. }, "{{scale}}%").then(function (msg) {
  12177. var predefinedValueFound = false;
  12178. var _iterator2 = _createForOfIteratorHelper(items.scaleSelect.options),
  12179. _step2;
  12180. try {
  12181. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  12182. var option = _step2.value;
  12183. if (option.value !== pageScaleValue) {
  12184. option.selected = false;
  12185. continue;
  12186. }
  12187. option.selected = true;
  12188. predefinedValueFound = true;
  12189. }
  12190. } catch (err) {
  12191. _iterator2.e(err);
  12192. } finally {
  12193. _iterator2.f();
  12194. }
  12195. if (!predefinedValueFound) {
  12196. items.customScaleOption.textContent = msg;
  12197. items.customScaleOption.selected = true;
  12198. }
  12199. });
  12200. }
  12201. }, {
  12202. key: "updateLoadingIndicatorState",
  12203. value: function updateLoadingIndicatorState() {
  12204. var loading = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  12205. var pageNumberInput = this.items.pageNumber;
  12206. pageNumberInput.classList.toggle(PAGE_NUMBER_LOADING_INDICATOR, loading);
  12207. }
  12208. }, {
  12209. key: "_adjustScaleWidth",
  12210. value: function () {
  12211. var _adjustScaleWidth2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  12212. var items, l10n, predefinedValuesPromise, canvas, ctx, _getComputedStyle, fontSize, fontFamily, maxWidth, _iterator3, _step3, predefinedValue, _ctx$measureText, width, overflow;
  12213. return _regenerator["default"].wrap(function _callee$(_context) {
  12214. while (1) {
  12215. switch (_context.prev = _context.next) {
  12216. case 0:
  12217. items = this.items, l10n = this.l10n;
  12218. 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")]);
  12219. canvas = document.createElement("canvas");
  12220. canvas.mozOpaque = true;
  12221. ctx = canvas.getContext("2d", {
  12222. alpha: false
  12223. });
  12224. _context.next = 7;
  12225. return _ui_utils.animationStarted;
  12226. case 7:
  12227. _getComputedStyle = getComputedStyle(items.scaleSelect), fontSize = _getComputedStyle.fontSize, fontFamily = _getComputedStyle.fontFamily;
  12228. ctx.font = "".concat(fontSize, " ").concat(fontFamily);
  12229. maxWidth = 0;
  12230. _context.t0 = _createForOfIteratorHelper;
  12231. _context.next = 13;
  12232. return predefinedValuesPromise;
  12233. case 13:
  12234. _context.t1 = _context.sent;
  12235. _iterator3 = (0, _context.t0)(_context.t1);
  12236. try {
  12237. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  12238. predefinedValue = _step3.value;
  12239. _ctx$measureText = ctx.measureText(predefinedValue), width = _ctx$measureText.width;
  12240. if (width > maxWidth) {
  12241. maxWidth = width;
  12242. }
  12243. }
  12244. } catch (err) {
  12245. _iterator3.e(err);
  12246. } finally {
  12247. _iterator3.f();
  12248. }
  12249. overflow = SCALE_SELECT_WIDTH - SCALE_SELECT_CONTAINER_WIDTH;
  12250. maxWidth += 2 * overflow;
  12251. if (maxWidth > SCALE_SELECT_CONTAINER_WIDTH) {
  12252. items.scaleSelect.style.width = "".concat(maxWidth + overflow, "px");
  12253. items.scaleSelectContainer.style.width = "".concat(maxWidth, "px");
  12254. }
  12255. canvas.width = 0;
  12256. canvas.height = 0;
  12257. canvas = ctx = null;
  12258. case 22:
  12259. case "end":
  12260. return _context.stop();
  12261. }
  12262. }
  12263. }, _callee, this);
  12264. }));
  12265. function _adjustScaleWidth() {
  12266. return _adjustScaleWidth2.apply(this, arguments);
  12267. }
  12268. return _adjustScaleWidth;
  12269. }()
  12270. }]);
  12271. return Toolbar;
  12272. }();
  12273. exports.Toolbar = Toolbar;
  12274. /***/ }),
  12275. /* 37 */
  12276. /***/ (function(module, exports, __webpack_require__) {
  12277. "use strict";
  12278. Object.defineProperty(exports, "__esModule", {
  12279. value: true
  12280. });
  12281. exports.ViewHistory = void 0;
  12282. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  12283. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  12284. 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); } }
  12285. 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); }); }; }
  12286. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12287. 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); } }
  12288. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12289. var DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
  12290. var ViewHistory = /*#__PURE__*/function () {
  12291. function ViewHistory(fingerprint) {
  12292. var _this = this;
  12293. var cacheSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_VIEW_HISTORY_CACHE_SIZE;
  12294. _classCallCheck(this, ViewHistory);
  12295. this.fingerprint = fingerprint;
  12296. this.cacheSize = cacheSize;
  12297. this._initializedPromise = this._readFromStorage().then(function (databaseStr) {
  12298. var database = JSON.parse(databaseStr || "{}");
  12299. var index = -1;
  12300. if (!Array.isArray(database.files)) {
  12301. database.files = [];
  12302. } else {
  12303. while (database.files.length >= _this.cacheSize) {
  12304. database.files.shift();
  12305. }
  12306. for (var i = 0, ii = database.files.length; i < ii; i++) {
  12307. var branch = database.files[i];
  12308. if (branch.fingerprint === _this.fingerprint) {
  12309. index = i;
  12310. break;
  12311. }
  12312. }
  12313. }
  12314. if (index === -1) {
  12315. index = database.files.push({
  12316. fingerprint: _this.fingerprint
  12317. }) - 1;
  12318. }
  12319. _this.file = database.files[index];
  12320. _this.database = database;
  12321. });
  12322. }
  12323. _createClass(ViewHistory, [{
  12324. key: "_writeToStorage",
  12325. value: function () {
  12326. var _writeToStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  12327. var databaseStr;
  12328. return _regenerator["default"].wrap(function _callee$(_context) {
  12329. while (1) {
  12330. switch (_context.prev = _context.next) {
  12331. case 0:
  12332. databaseStr = JSON.stringify(this.database);
  12333. localStorage.setItem("pdfjs.history", databaseStr);
  12334. case 2:
  12335. case "end":
  12336. return _context.stop();
  12337. }
  12338. }
  12339. }, _callee, this);
  12340. }));
  12341. function _writeToStorage() {
  12342. return _writeToStorage2.apply(this, arguments);
  12343. }
  12344. return _writeToStorage;
  12345. }()
  12346. }, {
  12347. key: "_readFromStorage",
  12348. value: function () {
  12349. var _readFromStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  12350. return _regenerator["default"].wrap(function _callee2$(_context2) {
  12351. while (1) {
  12352. switch (_context2.prev = _context2.next) {
  12353. case 0:
  12354. return _context2.abrupt("return", localStorage.getItem("pdfjs.history"));
  12355. case 1:
  12356. case "end":
  12357. return _context2.stop();
  12358. }
  12359. }
  12360. }, _callee2);
  12361. }));
  12362. function _readFromStorage() {
  12363. return _readFromStorage2.apply(this, arguments);
  12364. }
  12365. return _readFromStorage;
  12366. }()
  12367. }, {
  12368. key: "set",
  12369. value: function () {
  12370. var _set = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(name, val) {
  12371. return _regenerator["default"].wrap(function _callee3$(_context3) {
  12372. while (1) {
  12373. switch (_context3.prev = _context3.next) {
  12374. case 0:
  12375. _context3.next = 2;
  12376. return this._initializedPromise;
  12377. case 2:
  12378. this.file[name] = val;
  12379. return _context3.abrupt("return", this._writeToStorage());
  12380. case 4:
  12381. case "end":
  12382. return _context3.stop();
  12383. }
  12384. }
  12385. }, _callee3, this);
  12386. }));
  12387. function set(_x, _x2) {
  12388. return _set.apply(this, arguments);
  12389. }
  12390. return set;
  12391. }()
  12392. }, {
  12393. key: "setMultiple",
  12394. value: function () {
  12395. var _setMultiple = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(properties) {
  12396. var name;
  12397. return _regenerator["default"].wrap(function _callee4$(_context4) {
  12398. while (1) {
  12399. switch (_context4.prev = _context4.next) {
  12400. case 0:
  12401. _context4.next = 2;
  12402. return this._initializedPromise;
  12403. case 2:
  12404. for (name in properties) {
  12405. this.file[name] = properties[name];
  12406. }
  12407. return _context4.abrupt("return", this._writeToStorage());
  12408. case 4:
  12409. case "end":
  12410. return _context4.stop();
  12411. }
  12412. }
  12413. }, _callee4, this);
  12414. }));
  12415. function setMultiple(_x3) {
  12416. return _setMultiple.apply(this, arguments);
  12417. }
  12418. return setMultiple;
  12419. }()
  12420. }, {
  12421. key: "get",
  12422. value: function () {
  12423. var _get = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5(name, defaultValue) {
  12424. var val;
  12425. return _regenerator["default"].wrap(function _callee5$(_context5) {
  12426. while (1) {
  12427. switch (_context5.prev = _context5.next) {
  12428. case 0:
  12429. _context5.next = 2;
  12430. return this._initializedPromise;
  12431. case 2:
  12432. val = this.file[name];
  12433. return _context5.abrupt("return", val !== undefined ? val : defaultValue);
  12434. case 4:
  12435. case "end":
  12436. return _context5.stop();
  12437. }
  12438. }
  12439. }, _callee5, this);
  12440. }));
  12441. function get(_x4, _x5) {
  12442. return _get.apply(this, arguments);
  12443. }
  12444. return get;
  12445. }()
  12446. }, {
  12447. key: "getMultiple",
  12448. value: function () {
  12449. var _getMultiple = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6(properties) {
  12450. var values, name, val;
  12451. return _regenerator["default"].wrap(function _callee6$(_context6) {
  12452. while (1) {
  12453. switch (_context6.prev = _context6.next) {
  12454. case 0:
  12455. _context6.next = 2;
  12456. return this._initializedPromise;
  12457. case 2:
  12458. values = Object.create(null);
  12459. for (name in properties) {
  12460. val = this.file[name];
  12461. values[name] = val !== undefined ? val : properties[name];
  12462. }
  12463. return _context6.abrupt("return", values);
  12464. case 5:
  12465. case "end":
  12466. return _context6.stop();
  12467. }
  12468. }
  12469. }, _callee6, this);
  12470. }));
  12471. function getMultiple(_x6) {
  12472. return _getMultiple.apply(this, arguments);
  12473. }
  12474. return getMultiple;
  12475. }()
  12476. }]);
  12477. return ViewHistory;
  12478. }();
  12479. exports.ViewHistory = ViewHistory;
  12480. /***/ }),
  12481. /* 38 */
  12482. /***/ (function(module, exports, __webpack_require__) {
  12483. "use strict";
  12484. Object.defineProperty(exports, "__esModule", {
  12485. value: true
  12486. });
  12487. exports.GenericCom = void 0;
  12488. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  12489. var _app = __webpack_require__(1);
  12490. var _preferences = __webpack_require__(39);
  12491. var _download_manager = __webpack_require__(40);
  12492. var _genericl10n = __webpack_require__(41);
  12493. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  12494. 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); }
  12495. 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); } }
  12496. 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); }); }; }
  12497. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12498. 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); } }
  12499. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12500. 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); }
  12501. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  12502. 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); }; }
  12503. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  12504. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  12505. 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; } }
  12506. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  12507. ;
  12508. var GenericCom = {};
  12509. exports.GenericCom = GenericCom;
  12510. var GenericPreferences = /*#__PURE__*/function (_BasePreferences) {
  12511. _inherits(GenericPreferences, _BasePreferences);
  12512. var _super = _createSuper(GenericPreferences);
  12513. function GenericPreferences() {
  12514. _classCallCheck(this, GenericPreferences);
  12515. return _super.apply(this, arguments);
  12516. }
  12517. _createClass(GenericPreferences, [{
  12518. key: "_writeToStorage",
  12519. value: function () {
  12520. var _writeToStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(prefObj) {
  12521. return _regenerator["default"].wrap(function _callee$(_context) {
  12522. while (1) {
  12523. switch (_context.prev = _context.next) {
  12524. case 0:
  12525. localStorage.setItem("pdfjs.preferences", JSON.stringify(prefObj));
  12526. case 1:
  12527. case "end":
  12528. return _context.stop();
  12529. }
  12530. }
  12531. }, _callee);
  12532. }));
  12533. function _writeToStorage(_x) {
  12534. return _writeToStorage2.apply(this, arguments);
  12535. }
  12536. return _writeToStorage;
  12537. }()
  12538. }, {
  12539. key: "_readFromStorage",
  12540. value: function () {
  12541. var _readFromStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(prefObj) {
  12542. return _regenerator["default"].wrap(function _callee2$(_context2) {
  12543. while (1) {
  12544. switch (_context2.prev = _context2.next) {
  12545. case 0:
  12546. return _context2.abrupt("return", JSON.parse(localStorage.getItem("pdfjs.preferences")));
  12547. case 1:
  12548. case "end":
  12549. return _context2.stop();
  12550. }
  12551. }
  12552. }, _callee2);
  12553. }));
  12554. function _readFromStorage(_x2) {
  12555. return _readFromStorage2.apply(this, arguments);
  12556. }
  12557. return _readFromStorage;
  12558. }()
  12559. }]);
  12560. return GenericPreferences;
  12561. }(_preferences.BasePreferences);
  12562. var GenericExternalServices = /*#__PURE__*/function (_DefaultExternalServi) {
  12563. _inherits(GenericExternalServices, _DefaultExternalServi);
  12564. var _super2 = _createSuper(GenericExternalServices);
  12565. function GenericExternalServices() {
  12566. _classCallCheck(this, GenericExternalServices);
  12567. return _super2.apply(this, arguments);
  12568. }
  12569. _createClass(GenericExternalServices, null, [{
  12570. key: "createDownloadManager",
  12571. value: function createDownloadManager(options) {
  12572. return new _download_manager.DownloadManager(options);
  12573. }
  12574. }, {
  12575. key: "createPreferences",
  12576. value: function createPreferences() {
  12577. return new GenericPreferences();
  12578. }
  12579. }, {
  12580. key: "createL10n",
  12581. value: function createL10n(_ref) {
  12582. var _ref$locale = _ref.locale,
  12583. locale = _ref$locale === void 0 ? "en-US" : _ref$locale;
  12584. return new _genericl10n.GenericL10n(locale);
  12585. }
  12586. }]);
  12587. return GenericExternalServices;
  12588. }(_app.DefaultExternalServices);
  12589. _app.PDFViewerApplication.externalServices = GenericExternalServices;
  12590. /***/ }),
  12591. /* 39 */
  12592. /***/ (function(module, exports, __webpack_require__) {
  12593. "use strict";
  12594. Object.defineProperty(exports, "__esModule", {
  12595. value: true
  12596. });
  12597. exports.BasePreferences = void 0;
  12598. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  12599. var _app_options = __webpack_require__(6);
  12600. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  12601. 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); } }
  12602. 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); }); }; }
  12603. 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); }
  12604. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12605. 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); } }
  12606. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12607. var defaultPreferences = null;
  12608. function getDefaultPreferences() {
  12609. if (!defaultPreferences) {
  12610. defaultPreferences = Promise.resolve({
  12611. "cursorToolOnLoad": 0,
  12612. "defaultZoomValue": "",
  12613. "disablePageLabels": false,
  12614. "enablePermissions": false,
  12615. "enablePrintAutoRotate": false,
  12616. "enableWebGL": false,
  12617. "externalLinkTarget": 0,
  12618. "historyUpdateUrl": false,
  12619. "ignoreDestinationZoom": false,
  12620. "pdfBugEnabled": false,
  12621. "renderer": "canvas",
  12622. "renderInteractiveForms": true,
  12623. "sidebarViewOnLoad": -1,
  12624. "scrollModeOnLoad": -1,
  12625. "spreadModeOnLoad": -1,
  12626. "textLayerMode": 1,
  12627. "useOnlyCssZoom": false,
  12628. "viewOnLoad": 0,
  12629. "disableAutoFetch": false,
  12630. "disableFontFace": false,
  12631. "disableRange": false,
  12632. "disableStream": false
  12633. });
  12634. }
  12635. return defaultPreferences;
  12636. }
  12637. var BasePreferences = /*#__PURE__*/function () {
  12638. function BasePreferences() {
  12639. var _this = this;
  12640. _classCallCheck(this, BasePreferences);
  12641. if (this.constructor === BasePreferences) {
  12642. throw new Error("Cannot initialize BasePreferences.");
  12643. }
  12644. this.prefs = null;
  12645. this._initializedPromise = getDefaultPreferences().then(function (defaults) {
  12646. Object.defineProperty(_this, "defaults", {
  12647. value: Object.freeze(defaults),
  12648. writable: false,
  12649. enumerable: true,
  12650. configurable: false
  12651. });
  12652. _this.prefs = Object.assign(Object.create(null), defaults);
  12653. return _this._readFromStorage(defaults);
  12654. }).then(function (prefs) {
  12655. if (!prefs) {
  12656. return;
  12657. }
  12658. for (var name in prefs) {
  12659. var defaultValue = _this.defaults[name],
  12660. prefValue = prefs[name];
  12661. if (defaultValue === undefined || _typeof(prefValue) !== _typeof(defaultValue)) {
  12662. continue;
  12663. }
  12664. _this.prefs[name] = prefValue;
  12665. }
  12666. });
  12667. }
  12668. _createClass(BasePreferences, [{
  12669. key: "_writeToStorage",
  12670. value: function () {
  12671. var _writeToStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(prefObj) {
  12672. return _regenerator["default"].wrap(function _callee$(_context) {
  12673. while (1) {
  12674. switch (_context.prev = _context.next) {
  12675. case 0:
  12676. throw new Error("Not implemented: _writeToStorage");
  12677. case 1:
  12678. case "end":
  12679. return _context.stop();
  12680. }
  12681. }
  12682. }, _callee);
  12683. }));
  12684. function _writeToStorage(_x) {
  12685. return _writeToStorage2.apply(this, arguments);
  12686. }
  12687. return _writeToStorage;
  12688. }()
  12689. }, {
  12690. key: "_readFromStorage",
  12691. value: function () {
  12692. var _readFromStorage2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(prefObj) {
  12693. return _regenerator["default"].wrap(function _callee2$(_context2) {
  12694. while (1) {
  12695. switch (_context2.prev = _context2.next) {
  12696. case 0:
  12697. throw new Error("Not implemented: _readFromStorage");
  12698. case 1:
  12699. case "end":
  12700. return _context2.stop();
  12701. }
  12702. }
  12703. }, _callee2);
  12704. }));
  12705. function _readFromStorage(_x2) {
  12706. return _readFromStorage2.apply(this, arguments);
  12707. }
  12708. return _readFromStorage;
  12709. }()
  12710. }, {
  12711. key: "reset",
  12712. value: function () {
  12713. var _reset = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
  12714. return _regenerator["default"].wrap(function _callee3$(_context3) {
  12715. while (1) {
  12716. switch (_context3.prev = _context3.next) {
  12717. case 0:
  12718. _context3.next = 2;
  12719. return this._initializedPromise;
  12720. case 2:
  12721. this.prefs = Object.assign(Object.create(null), this.defaults);
  12722. return _context3.abrupt("return", this._writeToStorage(this.defaults));
  12723. case 4:
  12724. case "end":
  12725. return _context3.stop();
  12726. }
  12727. }
  12728. }, _callee3, this);
  12729. }));
  12730. function reset() {
  12731. return _reset.apply(this, arguments);
  12732. }
  12733. return reset;
  12734. }()
  12735. }, {
  12736. key: "set",
  12737. value: function () {
  12738. var _set = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(name, value) {
  12739. var defaultValue, valueType, defaultType;
  12740. return _regenerator["default"].wrap(function _callee4$(_context4) {
  12741. while (1) {
  12742. switch (_context4.prev = _context4.next) {
  12743. case 0:
  12744. _context4.next = 2;
  12745. return this._initializedPromise;
  12746. case 2:
  12747. defaultValue = this.defaults[name];
  12748. if (!(defaultValue === undefined)) {
  12749. _context4.next = 7;
  12750. break;
  12751. }
  12752. throw new Error("Set preference: \"".concat(name, "\" is undefined."));
  12753. case 7:
  12754. if (!(value === undefined)) {
  12755. _context4.next = 9;
  12756. break;
  12757. }
  12758. throw new Error("Set preference: no value is specified.");
  12759. case 9:
  12760. valueType = _typeof(value);
  12761. defaultType = _typeof(defaultValue);
  12762. if (!(valueType !== defaultType)) {
  12763. _context4.next = 19;
  12764. break;
  12765. }
  12766. if (!(valueType === "number" && defaultType === "string")) {
  12767. _context4.next = 16;
  12768. break;
  12769. }
  12770. value = value.toString();
  12771. _context4.next = 17;
  12772. break;
  12773. case 16:
  12774. throw new Error("Set preference: \"".concat(value, "\" is a ").concat(valueType, ", ") + "expected a ".concat(defaultType, "."));
  12775. case 17:
  12776. _context4.next = 21;
  12777. break;
  12778. case 19:
  12779. if (!(valueType === "number" && !Number.isInteger(value))) {
  12780. _context4.next = 21;
  12781. break;
  12782. }
  12783. throw new Error("Set preference: \"".concat(value, "\" must be an integer."));
  12784. case 21:
  12785. this.prefs[name] = value;
  12786. return _context4.abrupt("return", this._writeToStorage(this.prefs));
  12787. case 23:
  12788. case "end":
  12789. return _context4.stop();
  12790. }
  12791. }
  12792. }, _callee4, this);
  12793. }));
  12794. function set(_x3, _x4) {
  12795. return _set.apply(this, arguments);
  12796. }
  12797. return set;
  12798. }()
  12799. }, {
  12800. key: "get",
  12801. value: function () {
  12802. var _get = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5(name) {
  12803. var defaultValue, prefValue;
  12804. return _regenerator["default"].wrap(function _callee5$(_context5) {
  12805. while (1) {
  12806. switch (_context5.prev = _context5.next) {
  12807. case 0:
  12808. _context5.next = 2;
  12809. return this._initializedPromise;
  12810. case 2:
  12811. defaultValue = this.defaults[name];
  12812. if (!(defaultValue === undefined)) {
  12813. _context5.next = 7;
  12814. break;
  12815. }
  12816. throw new Error("Get preference: \"".concat(name, "\" is undefined."));
  12817. case 7:
  12818. prefValue = this.prefs[name];
  12819. if (!(prefValue !== undefined)) {
  12820. _context5.next = 10;
  12821. break;
  12822. }
  12823. return _context5.abrupt("return", prefValue);
  12824. case 10:
  12825. return _context5.abrupt("return", defaultValue);
  12826. case 11:
  12827. case "end":
  12828. return _context5.stop();
  12829. }
  12830. }
  12831. }, _callee5, this);
  12832. }));
  12833. function get(_x5) {
  12834. return _get.apply(this, arguments);
  12835. }
  12836. return get;
  12837. }()
  12838. }, {
  12839. key: "getAll",
  12840. value: function () {
  12841. var _getAll = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
  12842. return _regenerator["default"].wrap(function _callee6$(_context6) {
  12843. while (1) {
  12844. switch (_context6.prev = _context6.next) {
  12845. case 0:
  12846. _context6.next = 2;
  12847. return this._initializedPromise;
  12848. case 2:
  12849. return _context6.abrupt("return", Object.assign(Object.create(null), this.defaults, this.prefs));
  12850. case 3:
  12851. case "end":
  12852. return _context6.stop();
  12853. }
  12854. }
  12855. }, _callee6, this);
  12856. }));
  12857. function getAll() {
  12858. return _getAll.apply(this, arguments);
  12859. }
  12860. return getAll;
  12861. }()
  12862. }]);
  12863. return BasePreferences;
  12864. }();
  12865. exports.BasePreferences = BasePreferences;
  12866. /***/ }),
  12867. /* 40 */
  12868. /***/ (function(module, exports, __webpack_require__) {
  12869. "use strict";
  12870. Object.defineProperty(exports, "__esModule", {
  12871. value: true
  12872. });
  12873. exports.DownloadManager = void 0;
  12874. var _pdfjsLib = __webpack_require__(8);
  12875. var _viewer_compatibility = __webpack_require__(7);
  12876. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12877. 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); } }
  12878. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12879. ;
  12880. function _download(blobUrl, filename) {
  12881. var a = document.createElement("a");
  12882. if (!a.click) {
  12883. throw new Error('DownloadManager: "a.click()" is not supported.');
  12884. }
  12885. a.href = blobUrl;
  12886. a.target = "_parent";
  12887. if ("download" in a) {
  12888. a.download = filename;
  12889. }
  12890. (document.body || document.documentElement).appendChild(a);
  12891. a.click();
  12892. a.remove();
  12893. }
  12894. var DownloadManager = /*#__PURE__*/function () {
  12895. function DownloadManager() {
  12896. _classCallCheck(this, DownloadManager);
  12897. }
  12898. _createClass(DownloadManager, [{
  12899. key: "downloadUrl",
  12900. value: function downloadUrl(url, filename) {
  12901. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, "http://example.com")) {
  12902. return;
  12903. }
  12904. _download(url + "#pdfjs.action=download", filename);
  12905. }
  12906. }, {
  12907. key: "downloadData",
  12908. value: function downloadData(data, filename, contentType) {
  12909. if (navigator.msSaveBlob) {
  12910. navigator.msSaveBlob(new Blob([data], {
  12911. type: contentType
  12912. }), filename);
  12913. return;
  12914. }
  12915. var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, _viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL);
  12916. _download(blobUrl, filename);
  12917. }
  12918. }, {
  12919. key: "download",
  12920. value: function download(blob, url, filename) {
  12921. var sourceEventType = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "download";
  12922. if (navigator.msSaveBlob) {
  12923. if (!navigator.msSaveBlob(blob, filename)) {
  12924. this.downloadUrl(url, filename);
  12925. }
  12926. return;
  12927. }
  12928. if (_viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL) {
  12929. this.downloadUrl(url, filename);
  12930. return;
  12931. }
  12932. var blobUrl = URL.createObjectURL(blob);
  12933. _download(blobUrl, filename);
  12934. }
  12935. }]);
  12936. return DownloadManager;
  12937. }();
  12938. exports.DownloadManager = DownloadManager;
  12939. /***/ }),
  12940. /* 41 */
  12941. /***/ (function(module, exports, __webpack_require__) {
  12942. "use strict";
  12943. Object.defineProperty(exports, "__esModule", {
  12944. value: true
  12945. });
  12946. exports.GenericL10n = void 0;
  12947. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  12948. __webpack_require__(42);
  12949. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  12950. 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); } }
  12951. 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); }); }; }
  12952. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12953. 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); } }
  12954. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12955. var webL10n = document.webL10n;
  12956. var GenericL10n = /*#__PURE__*/function () {
  12957. function GenericL10n(lang) {
  12958. _classCallCheck(this, GenericL10n);
  12959. this._lang = lang;
  12960. this._ready = new Promise(function (resolve, reject) {
  12961. webL10n.setLanguage(lang, function () {
  12962. resolve(webL10n);
  12963. });
  12964. });
  12965. }
  12966. _createClass(GenericL10n, [{
  12967. key: "getLanguage",
  12968. value: function () {
  12969. var _getLanguage = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
  12970. var l10n;
  12971. return _regenerator["default"].wrap(function _callee$(_context) {
  12972. while (1) {
  12973. switch (_context.prev = _context.next) {
  12974. case 0:
  12975. _context.next = 2;
  12976. return this._ready;
  12977. case 2:
  12978. l10n = _context.sent;
  12979. return _context.abrupt("return", l10n.getLanguage());
  12980. case 4:
  12981. case "end":
  12982. return _context.stop();
  12983. }
  12984. }
  12985. }, _callee, this);
  12986. }));
  12987. function getLanguage() {
  12988. return _getLanguage.apply(this, arguments);
  12989. }
  12990. return getLanguage;
  12991. }()
  12992. }, {
  12993. key: "getDirection",
  12994. value: function () {
  12995. var _getDirection = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
  12996. var l10n;
  12997. return _regenerator["default"].wrap(function _callee2$(_context2) {
  12998. while (1) {
  12999. switch (_context2.prev = _context2.next) {
  13000. case 0:
  13001. _context2.next = 2;
  13002. return this._ready;
  13003. case 2:
  13004. l10n = _context2.sent;
  13005. return _context2.abrupt("return", l10n.getDirection());
  13006. case 4:
  13007. case "end":
  13008. return _context2.stop();
  13009. }
  13010. }
  13011. }, _callee2, this);
  13012. }));
  13013. function getDirection() {
  13014. return _getDirection.apply(this, arguments);
  13015. }
  13016. return getDirection;
  13017. }()
  13018. }, {
  13019. key: "get",
  13020. value: function () {
  13021. var _get = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(property, args, fallback) {
  13022. var l10n;
  13023. return _regenerator["default"].wrap(function _callee3$(_context3) {
  13024. while (1) {
  13025. switch (_context3.prev = _context3.next) {
  13026. case 0:
  13027. _context3.next = 2;
  13028. return this._ready;
  13029. case 2:
  13030. l10n = _context3.sent;
  13031. return _context3.abrupt("return", l10n.get(property, args, fallback));
  13032. case 4:
  13033. case "end":
  13034. return _context3.stop();
  13035. }
  13036. }
  13037. }, _callee3, this);
  13038. }));
  13039. function get(_x, _x2, _x3) {
  13040. return _get.apply(this, arguments);
  13041. }
  13042. return get;
  13043. }()
  13044. }, {
  13045. key: "translate",
  13046. value: function () {
  13047. var _translate = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(element) {
  13048. var l10n;
  13049. return _regenerator["default"].wrap(function _callee4$(_context4) {
  13050. while (1) {
  13051. switch (_context4.prev = _context4.next) {
  13052. case 0:
  13053. _context4.next = 2;
  13054. return this._ready;
  13055. case 2:
  13056. l10n = _context4.sent;
  13057. return _context4.abrupt("return", l10n.translate(element));
  13058. case 4:
  13059. case "end":
  13060. return _context4.stop();
  13061. }
  13062. }
  13063. }, _callee4, this);
  13064. }));
  13065. function translate(_x4) {
  13066. return _translate.apply(this, arguments);
  13067. }
  13068. return translate;
  13069. }()
  13070. }]);
  13071. return GenericL10n;
  13072. }();
  13073. exports.GenericL10n = GenericL10n;
  13074. /***/ }),
  13075. /* 42 */
  13076. /***/ (function(module, exports, __webpack_require__) {
  13077. "use strict";
  13078. document.webL10n = function (window, document, undefined) {
  13079. var gL10nData = {};
  13080. var gTextData = '';
  13081. var gTextProp = 'textContent';
  13082. var gLanguage = '';
  13083. var gMacros = {};
  13084. var gReadyState = 'loading';
  13085. var gAsyncResourceLoading = true;
  13086. function getL10nResourceLinks() {
  13087. return document.querySelectorAll('link[type="application/l10n"]');
  13088. }
  13089. function getL10nDictionary() {
  13090. var script = document.querySelector('script[type="application/l10n"]');
  13091. return script ? JSON.parse(script.innerHTML) : null;
  13092. }
  13093. function getTranslatableChildren(element) {
  13094. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  13095. }
  13096. function getL10nAttributes(element) {
  13097. if (!element) return {};
  13098. var l10nId = element.getAttribute('data-l10n-id');
  13099. var l10nArgs = element.getAttribute('data-l10n-args');
  13100. var args = {};
  13101. if (l10nArgs) {
  13102. try {
  13103. args = JSON.parse(l10nArgs);
  13104. } catch (e) {
  13105. console.warn('could not parse arguments for #' + l10nId);
  13106. }
  13107. }
  13108. return {
  13109. id: l10nId,
  13110. args: args
  13111. };
  13112. }
  13113. function xhrLoadText(url, onSuccess, onFailure) {
  13114. onSuccess = onSuccess || function _onSuccess(data) {};
  13115. onFailure = onFailure || function _onFailure() {};
  13116. var xhr = new XMLHttpRequest();
  13117. xhr.open('GET', url, gAsyncResourceLoading);
  13118. if (xhr.overrideMimeType) {
  13119. xhr.overrideMimeType('text/plain; charset=utf-8');
  13120. }
  13121. xhr.onreadystatechange = function () {
  13122. if (xhr.readyState == 4) {
  13123. if (xhr.status == 200 || xhr.status === 0) {
  13124. onSuccess(xhr.responseText);
  13125. } else {
  13126. onFailure();
  13127. }
  13128. }
  13129. };
  13130. xhr.onerror = onFailure;
  13131. xhr.ontimeout = onFailure;
  13132. try {
  13133. xhr.send(null);
  13134. } catch (e) {
  13135. onFailure();
  13136. }
  13137. }
  13138. function parseResource(href, lang, successCallback, failureCallback) {
  13139. var baseURL = href.replace(/[^\/]*$/, '') || './';
  13140. function evalString(text) {
  13141. if (text.lastIndexOf('\\') < 0) return text;
  13142. 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, "'");
  13143. }
  13144. function parseProperties(text, parsedPropertiesCallback) {
  13145. var dictionary = {};
  13146. var reBlank = /^\s*|\s*$/;
  13147. var reComment = /^\s*#|^\s*$/;
  13148. var reSection = /^\s*\[(.*)\]\s*$/;
  13149. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  13150. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  13151. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  13152. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  13153. var currentLang = '*';
  13154. var genericLang = lang.split('-', 1)[0];
  13155. var skipLang = false;
  13156. var match = '';
  13157. function nextEntry() {
  13158. while (true) {
  13159. if (!entries.length) {
  13160. parsedRawLinesCallback();
  13161. return;
  13162. }
  13163. var line = entries.shift();
  13164. if (reComment.test(line)) continue;
  13165. if (extendedSyntax) {
  13166. match = reSection.exec(line);
  13167. if (match) {
  13168. currentLang = match[1].toLowerCase();
  13169. skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
  13170. continue;
  13171. } else if (skipLang) {
  13172. continue;
  13173. }
  13174. match = reImport.exec(line);
  13175. if (match) {
  13176. loadImport(baseURL + match[1], nextEntry);
  13177. return;
  13178. }
  13179. }
  13180. var tmp = line.match(reSplit);
  13181. if (tmp && tmp.length == 3) {
  13182. dictionary[tmp[1]] = evalString(tmp[2]);
  13183. }
  13184. }
  13185. }
  13186. nextEntry();
  13187. }
  13188. function loadImport(url, callback) {
  13189. xhrLoadText(url, function (content) {
  13190. parseRawLines(content, false, callback);
  13191. }, function () {
  13192. console.warn(url + ' not found.');
  13193. callback();
  13194. });
  13195. }
  13196. parseRawLines(text, true, function () {
  13197. parsedPropertiesCallback(dictionary);
  13198. });
  13199. }
  13200. xhrLoadText(href, function (response) {
  13201. gTextData += response;
  13202. parseProperties(response, function (data) {
  13203. for (var key in data) {
  13204. var id,
  13205. prop,
  13206. index = key.lastIndexOf('.');
  13207. if (index > 0) {
  13208. id = key.substring(0, index);
  13209. prop = key.substring(index + 1);
  13210. } else {
  13211. id = key;
  13212. prop = gTextProp;
  13213. }
  13214. if (!gL10nData[id]) {
  13215. gL10nData[id] = {};
  13216. }
  13217. gL10nData[id][prop] = data[key];
  13218. }
  13219. if (successCallback) {
  13220. successCallback();
  13221. }
  13222. });
  13223. }, failureCallback);
  13224. }
  13225. function loadLocale(lang, callback) {
  13226. if (lang) {
  13227. lang = lang.toLowerCase();
  13228. }
  13229. callback = callback || function _callback() {};
  13230. clear();
  13231. gLanguage = lang;
  13232. var langLinks = getL10nResourceLinks();
  13233. var langCount = langLinks.length;
  13234. if (langCount === 0) {
  13235. var dict = getL10nDictionary();
  13236. if (dict && dict.locales && dict.default_locale) {
  13237. console.log('using the embedded JSON directory, early way out');
  13238. gL10nData = dict.locales[lang];
  13239. if (!gL10nData) {
  13240. var defaultLocale = dict.default_locale.toLowerCase();
  13241. for (var anyCaseLang in dict.locales) {
  13242. anyCaseLang = anyCaseLang.toLowerCase();
  13243. if (anyCaseLang === lang) {
  13244. gL10nData = dict.locales[lang];
  13245. break;
  13246. } else if (anyCaseLang === defaultLocale) {
  13247. gL10nData = dict.locales[defaultLocale];
  13248. }
  13249. }
  13250. }
  13251. callback();
  13252. } else {
  13253. console.log('no resource to load, early way out');
  13254. }
  13255. gReadyState = 'complete';
  13256. return;
  13257. }
  13258. var onResourceLoaded = null;
  13259. var gResourceCount = 0;
  13260. onResourceLoaded = function onResourceLoaded() {
  13261. gResourceCount++;
  13262. if (gResourceCount >= langCount) {
  13263. callback();
  13264. gReadyState = 'complete';
  13265. }
  13266. };
  13267. function L10nResourceLink(link) {
  13268. var href = link.href;
  13269. this.load = function (lang, callback) {
  13270. parseResource(href, lang, callback, function () {
  13271. console.warn(href + ' not found.');
  13272. console.warn('"' + lang + '" resource not found');
  13273. gLanguage = '';
  13274. callback();
  13275. });
  13276. };
  13277. }
  13278. for (var i = 0; i < langCount; i++) {
  13279. var resource = new L10nResourceLink(langLinks[i]);
  13280. resource.load(lang, onResourceLoaded);
  13281. }
  13282. }
  13283. function clear() {
  13284. gL10nData = {};
  13285. gTextData = '';
  13286. gLanguage = '';
  13287. }
  13288. function getPluralRules(lang) {
  13289. var locales2rules = {
  13290. 'af': 3,
  13291. 'ak': 4,
  13292. 'am': 4,
  13293. 'ar': 1,
  13294. 'asa': 3,
  13295. 'az': 0,
  13296. 'be': 11,
  13297. 'bem': 3,
  13298. 'bez': 3,
  13299. 'bg': 3,
  13300. 'bh': 4,
  13301. 'bm': 0,
  13302. 'bn': 3,
  13303. 'bo': 0,
  13304. 'br': 20,
  13305. 'brx': 3,
  13306. 'bs': 11,
  13307. 'ca': 3,
  13308. 'cgg': 3,
  13309. 'chr': 3,
  13310. 'cs': 12,
  13311. 'cy': 17,
  13312. 'da': 3,
  13313. 'de': 3,
  13314. 'dv': 3,
  13315. 'dz': 0,
  13316. 'ee': 3,
  13317. 'el': 3,
  13318. 'en': 3,
  13319. 'eo': 3,
  13320. 'es': 3,
  13321. 'et': 3,
  13322. 'eu': 3,
  13323. 'fa': 0,
  13324. 'ff': 5,
  13325. 'fi': 3,
  13326. 'fil': 4,
  13327. 'fo': 3,
  13328. 'fr': 5,
  13329. 'fur': 3,
  13330. 'fy': 3,
  13331. 'ga': 8,
  13332. 'gd': 24,
  13333. 'gl': 3,
  13334. 'gsw': 3,
  13335. 'gu': 3,
  13336. 'guw': 4,
  13337. 'gv': 23,
  13338. 'ha': 3,
  13339. 'haw': 3,
  13340. 'he': 2,
  13341. 'hi': 4,
  13342. 'hr': 11,
  13343. 'hu': 0,
  13344. 'id': 0,
  13345. 'ig': 0,
  13346. 'ii': 0,
  13347. 'is': 3,
  13348. 'it': 3,
  13349. 'iu': 7,
  13350. 'ja': 0,
  13351. 'jmc': 3,
  13352. 'jv': 0,
  13353. 'ka': 0,
  13354. 'kab': 5,
  13355. 'kaj': 3,
  13356. 'kcg': 3,
  13357. 'kde': 0,
  13358. 'kea': 0,
  13359. 'kk': 3,
  13360. 'kl': 3,
  13361. 'km': 0,
  13362. 'kn': 0,
  13363. 'ko': 0,
  13364. 'ksb': 3,
  13365. 'ksh': 21,
  13366. 'ku': 3,
  13367. 'kw': 7,
  13368. 'lag': 18,
  13369. 'lb': 3,
  13370. 'lg': 3,
  13371. 'ln': 4,
  13372. 'lo': 0,
  13373. 'lt': 10,
  13374. 'lv': 6,
  13375. 'mas': 3,
  13376. 'mg': 4,
  13377. 'mk': 16,
  13378. 'ml': 3,
  13379. 'mn': 3,
  13380. 'mo': 9,
  13381. 'mr': 3,
  13382. 'ms': 0,
  13383. 'mt': 15,
  13384. 'my': 0,
  13385. 'nah': 3,
  13386. 'naq': 7,
  13387. 'nb': 3,
  13388. 'nd': 3,
  13389. 'ne': 3,
  13390. 'nl': 3,
  13391. 'nn': 3,
  13392. 'no': 3,
  13393. 'nr': 3,
  13394. 'nso': 4,
  13395. 'ny': 3,
  13396. 'nyn': 3,
  13397. 'om': 3,
  13398. 'or': 3,
  13399. 'pa': 3,
  13400. 'pap': 3,
  13401. 'pl': 13,
  13402. 'ps': 3,
  13403. 'pt': 3,
  13404. 'rm': 3,
  13405. 'ro': 9,
  13406. 'rof': 3,
  13407. 'ru': 11,
  13408. 'rwk': 3,
  13409. 'sah': 0,
  13410. 'saq': 3,
  13411. 'se': 7,
  13412. 'seh': 3,
  13413. 'ses': 0,
  13414. 'sg': 0,
  13415. 'sh': 11,
  13416. 'shi': 19,
  13417. 'sk': 12,
  13418. 'sl': 14,
  13419. 'sma': 7,
  13420. 'smi': 7,
  13421. 'smj': 7,
  13422. 'smn': 7,
  13423. 'sms': 7,
  13424. 'sn': 3,
  13425. 'so': 3,
  13426. 'sq': 3,
  13427. 'sr': 11,
  13428. 'ss': 3,
  13429. 'ssy': 3,
  13430. 'st': 3,
  13431. 'sv': 3,
  13432. 'sw': 3,
  13433. 'syr': 3,
  13434. 'ta': 3,
  13435. 'te': 3,
  13436. 'teo': 3,
  13437. 'th': 0,
  13438. 'ti': 4,
  13439. 'tig': 3,
  13440. 'tk': 3,
  13441. 'tl': 4,
  13442. 'tn': 3,
  13443. 'to': 0,
  13444. 'tr': 0,
  13445. 'ts': 3,
  13446. 'tzm': 22,
  13447. 'uk': 11,
  13448. 'ur': 3,
  13449. 've': 3,
  13450. 'vi': 0,
  13451. 'vun': 3,
  13452. 'wa': 4,
  13453. 'wae': 3,
  13454. 'wo': 0,
  13455. 'xh': 3,
  13456. 'xog': 3,
  13457. 'yo': 0,
  13458. 'zh': 0,
  13459. 'zu': 3
  13460. };
  13461. function isIn(n, list) {
  13462. return list.indexOf(n) !== -1;
  13463. }
  13464. function isBetween(n, start, end) {
  13465. return start <= n && n <= end;
  13466. }
  13467. var pluralRules = {
  13468. '0': function _(n) {
  13469. return 'other';
  13470. },
  13471. '1': function _(n) {
  13472. if (isBetween(n % 100, 3, 10)) return 'few';
  13473. if (n === 0) return 'zero';
  13474. if (isBetween(n % 100, 11, 99)) return 'many';
  13475. if (n == 2) return 'two';
  13476. if (n == 1) return 'one';
  13477. return 'other';
  13478. },
  13479. '2': function _(n) {
  13480. if (n !== 0 && n % 10 === 0) return 'many';
  13481. if (n == 2) return 'two';
  13482. if (n == 1) return 'one';
  13483. return 'other';
  13484. },
  13485. '3': function _(n) {
  13486. if (n == 1) return 'one';
  13487. return 'other';
  13488. },
  13489. '4': function _(n) {
  13490. if (isBetween(n, 0, 1)) return 'one';
  13491. return 'other';
  13492. },
  13493. '5': function _(n) {
  13494. if (isBetween(n, 0, 2) && n != 2) return 'one';
  13495. return 'other';
  13496. },
  13497. '6': function _(n) {
  13498. if (n === 0) return 'zero';
  13499. if (n % 10 == 1 && n % 100 != 11) return 'one';
  13500. return 'other';
  13501. },
  13502. '7': function _(n) {
  13503. if (n == 2) return 'two';
  13504. if (n == 1) return 'one';
  13505. return 'other';
  13506. },
  13507. '8': function _(n) {
  13508. if (isBetween(n, 3, 6)) return 'few';
  13509. if (isBetween(n, 7, 10)) return 'many';
  13510. if (n == 2) return 'two';
  13511. if (n == 1) return 'one';
  13512. return 'other';
  13513. },
  13514. '9': function _(n) {
  13515. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  13516. if (n == 1) return 'one';
  13517. return 'other';
  13518. },
  13519. '10': function _(n) {
  13520. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  13521. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  13522. return 'other';
  13523. },
  13524. '11': function _(n) {
  13525. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  13526. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
  13527. if (n % 10 == 1 && n % 100 != 11) return 'one';
  13528. return 'other';
  13529. },
  13530. '12': function _(n) {
  13531. if (isBetween(n, 2, 4)) return 'few';
  13532. if (n == 1) return 'one';
  13533. return 'other';
  13534. },
  13535. '13': function _(n) {
  13536. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  13537. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
  13538. if (n == 1) return 'one';
  13539. return 'other';
  13540. },
  13541. '14': function _(n) {
  13542. if (isBetween(n % 100, 3, 4)) return 'few';
  13543. if (n % 100 == 2) return 'two';
  13544. if (n % 100 == 1) return 'one';
  13545. return 'other';
  13546. },
  13547. '15': function _(n) {
  13548. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  13549. if (isBetween(n % 100, 11, 19)) return 'many';
  13550. if (n == 1) return 'one';
  13551. return 'other';
  13552. },
  13553. '16': function _(n) {
  13554. if (n % 10 == 1 && n != 11) return 'one';
  13555. return 'other';
  13556. },
  13557. '17': function _(n) {
  13558. if (n == 3) return 'few';
  13559. if (n === 0) return 'zero';
  13560. if (n == 6) return 'many';
  13561. if (n == 2) return 'two';
  13562. if (n == 1) return 'one';
  13563. return 'other';
  13564. },
  13565. '18': function _(n) {
  13566. if (n === 0) return 'zero';
  13567. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  13568. return 'other';
  13569. },
  13570. '19': function _(n) {
  13571. if (isBetween(n, 2, 10)) return 'few';
  13572. if (isBetween(n, 0, 1)) return 'one';
  13573. return 'other';
  13574. },
  13575. '20': function _(n) {
  13576. 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';
  13577. if (n % 1000000 === 0 && n !== 0) return 'many';
  13578. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  13579. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  13580. return 'other';
  13581. },
  13582. '21': function _(n) {
  13583. if (n === 0) return 'zero';
  13584. if (n == 1) return 'one';
  13585. return 'other';
  13586. },
  13587. '22': function _(n) {
  13588. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  13589. return 'other';
  13590. },
  13591. '23': function _(n) {
  13592. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  13593. return 'other';
  13594. },
  13595. '24': function _(n) {
  13596. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  13597. if (isIn(n, [2, 12])) return 'two';
  13598. if (isIn(n, [1, 11])) return 'one';
  13599. return 'other';
  13600. }
  13601. };
  13602. var index = locales2rules[lang.replace(/-.*$/, '')];
  13603. if (!(index in pluralRules)) {
  13604. console.warn('plural form unknown for [' + lang + ']');
  13605. return function () {
  13606. return 'other';
  13607. };
  13608. }
  13609. return pluralRules[index];
  13610. }
  13611. gMacros.plural = function (str, param, key, prop) {
  13612. var n = parseFloat(param);
  13613. if (isNaN(n)) return str;
  13614. if (prop != gTextProp) return str;
  13615. if (!gMacros._pluralRules) {
  13616. gMacros._pluralRules = getPluralRules(gLanguage);
  13617. }
  13618. var index = '[' + gMacros._pluralRules(n) + ']';
  13619. if (n === 0 && key + '[zero]' in gL10nData) {
  13620. str = gL10nData[key + '[zero]'][prop];
  13621. } else if (n == 1 && key + '[one]' in gL10nData) {
  13622. str = gL10nData[key + '[one]'][prop];
  13623. } else if (n == 2 && key + '[two]' in gL10nData) {
  13624. str = gL10nData[key + '[two]'][prop];
  13625. } else if (key + index in gL10nData) {
  13626. str = gL10nData[key + index][prop];
  13627. } else if (key + '[other]' in gL10nData) {
  13628. str = gL10nData[key + '[other]'][prop];
  13629. }
  13630. return str;
  13631. };
  13632. function getL10nData(key, args, fallback) {
  13633. var data = gL10nData[key];
  13634. if (!data) {
  13635. console.warn('#' + key + ' is undefined.');
  13636. if (!fallback) {
  13637. return null;
  13638. }
  13639. data = fallback;
  13640. }
  13641. var rv = {};
  13642. for (var prop in data) {
  13643. var str = data[prop];
  13644. str = substIndexes(str, args, key, prop);
  13645. str = substArguments(str, args, key);
  13646. rv[prop] = str;
  13647. }
  13648. return rv;
  13649. }
  13650. function substIndexes(str, args, key, prop) {
  13651. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  13652. var reMatch = reIndex.exec(str);
  13653. if (!reMatch || !reMatch.length) return str;
  13654. var macroName = reMatch[1];
  13655. var paramName = reMatch[2];
  13656. var param;
  13657. if (args && paramName in args) {
  13658. param = args[paramName];
  13659. } else if (paramName in gL10nData) {
  13660. param = gL10nData[paramName];
  13661. }
  13662. if (macroName in gMacros) {
  13663. var macro = gMacros[macroName];
  13664. str = macro(str, param, key, prop);
  13665. }
  13666. return str;
  13667. }
  13668. function substArguments(str, args, key) {
  13669. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  13670. return str.replace(reArgs, function (matched_text, arg) {
  13671. if (args && arg in args) {
  13672. return args[arg];
  13673. }
  13674. if (arg in gL10nData) {
  13675. return gL10nData[arg];
  13676. }
  13677. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  13678. return matched_text;
  13679. });
  13680. }
  13681. function translateElement(element) {
  13682. var l10n = getL10nAttributes(element);
  13683. if (!l10n.id) return;
  13684. var data = getL10nData(l10n.id, l10n.args);
  13685. if (!data) {
  13686. console.warn('#' + l10n.id + ' is undefined.');
  13687. return;
  13688. }
  13689. if (data[gTextProp]) {
  13690. if (getChildElementCount(element) === 0) {
  13691. element[gTextProp] = data[gTextProp];
  13692. } else {
  13693. var children = element.childNodes;
  13694. var found = false;
  13695. for (var i = 0, l = children.length; i < l; i++) {
  13696. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  13697. if (found) {
  13698. children[i].nodeValue = '';
  13699. } else {
  13700. children[i].nodeValue = data[gTextProp];
  13701. found = true;
  13702. }
  13703. }
  13704. }
  13705. if (!found) {
  13706. var textNode = document.createTextNode(data[gTextProp]);
  13707. element.insertBefore(textNode, element.firstChild);
  13708. }
  13709. }
  13710. delete data[gTextProp];
  13711. }
  13712. for (var k in data) {
  13713. element[k] = data[k];
  13714. }
  13715. }
  13716. function getChildElementCount(element) {
  13717. if (element.children) {
  13718. return element.children.length;
  13719. }
  13720. if (typeof element.childElementCount !== 'undefined') {
  13721. return element.childElementCount;
  13722. }
  13723. var count = 0;
  13724. for (var i = 0; i < element.childNodes.length; i++) {
  13725. count += element.nodeType === 1 ? 1 : 0;
  13726. }
  13727. return count;
  13728. }
  13729. function translateFragment(element) {
  13730. element = element || document.documentElement;
  13731. var children = getTranslatableChildren(element);
  13732. var elementCount = children.length;
  13733. for (var i = 0; i < elementCount; i++) {
  13734. translateElement(children[i]);
  13735. }
  13736. translateElement(element);
  13737. }
  13738. return {
  13739. get: function get(key, args, fallbackString) {
  13740. var index = key.lastIndexOf('.');
  13741. var prop = gTextProp;
  13742. if (index > 0) {
  13743. prop = key.substring(index + 1);
  13744. key = key.substring(0, index);
  13745. }
  13746. var fallback;
  13747. if (fallbackString) {
  13748. fallback = {};
  13749. fallback[prop] = fallbackString;
  13750. }
  13751. var data = getL10nData(key, args, fallback);
  13752. if (data && prop in data) {
  13753. return data[prop];
  13754. }
  13755. return '{{' + key + '}}';
  13756. },
  13757. getData: function getData() {
  13758. return gL10nData;
  13759. },
  13760. getText: function getText() {
  13761. return gTextData;
  13762. },
  13763. getLanguage: function getLanguage() {
  13764. return gLanguage;
  13765. },
  13766. setLanguage: function setLanguage(lang, callback) {
  13767. loadLocale(lang, function () {
  13768. if (callback) callback();
  13769. });
  13770. },
  13771. getDirection: function getDirection() {
  13772. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  13773. var shortCode = gLanguage.split('-', 1)[0];
  13774. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  13775. },
  13776. translate: translateFragment,
  13777. getReadyState: function getReadyState() {
  13778. return gReadyState;
  13779. },
  13780. ready: function ready(callback) {
  13781. if (!callback) {
  13782. return;
  13783. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  13784. window.setTimeout(function () {
  13785. callback();
  13786. });
  13787. } else if (document.addEventListener) {
  13788. document.addEventListener('localized', function once() {
  13789. document.removeEventListener('localized', once);
  13790. callback();
  13791. });
  13792. }
  13793. }
  13794. };
  13795. }(window, document);
  13796. /***/ }),
  13797. /* 43 */
  13798. /***/ (function(module, exports, __webpack_require__) {
  13799. "use strict";
  13800. Object.defineProperty(exports, "__esModule", {
  13801. value: true
  13802. });
  13803. exports.PDFPrintService = PDFPrintService;
  13804. var _ui_utils = __webpack_require__(5);
  13805. var _app = __webpack_require__(1);
  13806. var _viewer_compatibility = __webpack_require__(7);
  13807. var activeService = null;
  13808. var overlayManager = null;
  13809. function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size, printResolution, optionalContentConfigPromise) {
  13810. var scratchCanvas = activeService.scratchCanvas;
  13811. var PRINT_UNITS = printResolution / 72.0;
  13812. scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
  13813. scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
  13814. var width = Math.floor(size.width * _ui_utils.CSS_UNITS) + "px";
  13815. var height = Math.floor(size.height * _ui_utils.CSS_UNITS) + "px";
  13816. var ctx = scratchCanvas.getContext("2d");
  13817. ctx.save();
  13818. ctx.fillStyle = "rgb(255, 255, 255)";
  13819. ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height);
  13820. ctx.restore();
  13821. return pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  13822. var renderContext = {
  13823. canvasContext: ctx,
  13824. transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
  13825. viewport: pdfPage.getViewport({
  13826. scale: 1,
  13827. rotation: size.rotation
  13828. }),
  13829. intent: "print",
  13830. annotationStorage: pdfDocument.annotationStorage,
  13831. optionalContentConfigPromise: optionalContentConfigPromise
  13832. };
  13833. return pdfPage.render(renderContext).promise;
  13834. }).then(function () {
  13835. return {
  13836. width: width,
  13837. height: height
  13838. };
  13839. });
  13840. }
  13841. function PDFPrintService(pdfDocument, pagesOverview, printContainer, printResolution) {
  13842. var optionalContentConfigPromise = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
  13843. var l10n = arguments.length > 5 ? arguments[5] : undefined;
  13844. this.pdfDocument = pdfDocument;
  13845. this.pagesOverview = pagesOverview;
  13846. this.printContainer = printContainer;
  13847. this._printResolution = printResolution || 150;
  13848. this._optionalContentConfigPromise = optionalContentConfigPromise || pdfDocument.getOptionalContentConfig();
  13849. this.l10n = l10n || _ui_utils.NullL10n;
  13850. this.currentPage = -1;
  13851. this.scratchCanvas = document.createElement("canvas");
  13852. }
  13853. PDFPrintService.prototype = {
  13854. layout: function layout() {
  13855. this.throwIfInactive();
  13856. var body = document.querySelector("body");
  13857. body.setAttribute("data-pdfjsprinting", true);
  13858. var hasEqualPageSizes = this.pagesOverview.every(function (size) {
  13859. return size.width === this.pagesOverview[0].width && size.height === this.pagesOverview[0].height;
  13860. }, this);
  13861. if (!hasEqualPageSizes) {
  13862. console.warn("Not all pages have the same size. The printed " + "result may be incorrect!");
  13863. }
  13864. this.pageStyleSheet = document.createElement("style");
  13865. var pageSize = this.pagesOverview[0];
  13866. this.pageStyleSheet.textContent = "@supports ((size:A4) and (size:1pt 1pt)) {" + "@page { size: " + pageSize.width + "pt " + pageSize.height + "pt;}" + "}";
  13867. body.appendChild(this.pageStyleSheet);
  13868. },
  13869. destroy: function destroy() {
  13870. if (activeService !== this) {
  13871. return;
  13872. }
  13873. this.printContainer.textContent = "";
  13874. var body = document.querySelector("body");
  13875. body.removeAttribute("data-pdfjsprinting");
  13876. if (this.pageStyleSheet) {
  13877. this.pageStyleSheet.remove();
  13878. this.pageStyleSheet = null;
  13879. }
  13880. this.scratchCanvas.width = this.scratchCanvas.height = 0;
  13881. this.scratchCanvas = null;
  13882. activeService = null;
  13883. ensureOverlay().then(function () {
  13884. if (overlayManager.active !== "printServiceOverlay") {
  13885. return;
  13886. }
  13887. overlayManager.close("printServiceOverlay");
  13888. });
  13889. },
  13890. renderPages: function renderPages() {
  13891. var _this = this;
  13892. var pageCount = this.pagesOverview.length;
  13893. var renderNextPage = function renderNextPage(resolve, reject) {
  13894. _this.throwIfInactive();
  13895. if (++_this.currentPage >= pageCount) {
  13896. renderProgress(pageCount, pageCount, _this.l10n);
  13897. resolve();
  13898. return;
  13899. }
  13900. var index = _this.currentPage;
  13901. renderProgress(index, pageCount, _this.l10n);
  13902. renderPage(_this, _this.pdfDocument, index + 1, _this.pagesOverview[index], _this._printResolution, _this._optionalContentConfigPromise).then(_this.useRenderedPage.bind(_this)).then(function () {
  13903. renderNextPage(resolve, reject);
  13904. }, reject);
  13905. };
  13906. return new Promise(renderNextPage);
  13907. },
  13908. useRenderedPage: function useRenderedPage(printItem) {
  13909. this.throwIfInactive();
  13910. var img = document.createElement("img");
  13911. img.style.width = printItem.width;
  13912. img.style.height = printItem.height;
  13913. var scratchCanvas = this.scratchCanvas;
  13914. if ("toBlob" in scratchCanvas && !_viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL) {
  13915. scratchCanvas.toBlob(function (blob) {
  13916. img.src = URL.createObjectURL(blob);
  13917. });
  13918. } else {
  13919. img.src = scratchCanvas.toDataURL();
  13920. }
  13921. var wrapper = document.createElement("div");
  13922. wrapper.appendChild(img);
  13923. this.printContainer.appendChild(wrapper);
  13924. return new Promise(function (resolve, reject) {
  13925. img.onload = resolve;
  13926. img.onerror = reject;
  13927. });
  13928. },
  13929. performPrint: function performPrint() {
  13930. var _this2 = this;
  13931. this.throwIfInactive();
  13932. return new Promise(function (resolve) {
  13933. setTimeout(function () {
  13934. if (!_this2.active) {
  13935. resolve();
  13936. return;
  13937. }
  13938. print.call(window);
  13939. setTimeout(resolve, 20);
  13940. }, 0);
  13941. });
  13942. },
  13943. get active() {
  13944. return this === activeService;
  13945. },
  13946. throwIfInactive: function throwIfInactive() {
  13947. if (!this.active) {
  13948. throw new Error("This print request was cancelled or completed.");
  13949. }
  13950. }
  13951. };
  13952. var print = window.print;
  13953. window.print = function () {
  13954. if (activeService) {
  13955. console.warn("Ignored window.print() because of a pending print job.");
  13956. return;
  13957. }
  13958. ensureOverlay().then(function () {
  13959. if (activeService) {
  13960. overlayManager.open("printServiceOverlay");
  13961. }
  13962. });
  13963. try {
  13964. dispatchEvent("beforeprint");
  13965. } finally {
  13966. if (!activeService) {
  13967. console.error("Expected print service to be initialized.");
  13968. ensureOverlay().then(function () {
  13969. if (overlayManager.active === "printServiceOverlay") {
  13970. overlayManager.close("printServiceOverlay");
  13971. }
  13972. });
  13973. return;
  13974. }
  13975. var activeServiceOnEntry = activeService;
  13976. activeService.renderPages().then(function () {
  13977. return activeServiceOnEntry.performPrint();
  13978. })["catch"](function () {}).then(function () {
  13979. if (activeServiceOnEntry.active) {
  13980. abort();
  13981. }
  13982. });
  13983. }
  13984. };
  13985. function dispatchEvent(eventType) {
  13986. var event = document.createEvent("CustomEvent");
  13987. event.initCustomEvent(eventType, false, false, "custom");
  13988. window.dispatchEvent(event);
  13989. }
  13990. function abort() {
  13991. if (activeService) {
  13992. activeService.destroy();
  13993. dispatchEvent("afterprint");
  13994. }
  13995. }
  13996. function renderProgress(index, total, l10n) {
  13997. var progressContainer = document.getElementById("printServiceOverlay");
  13998. var progress = Math.round(100 * index / total);
  13999. var progressBar = progressContainer.querySelector("progress");
  14000. var progressPerc = progressContainer.querySelector(".relative-progress");
  14001. progressBar.value = progress;
  14002. l10n.get("print_progress_percent", {
  14003. progress: progress
  14004. }, progress + "%").then(function (msg) {
  14005. progressPerc.textContent = msg;
  14006. });
  14007. }
  14008. window.addEventListener("keydown", function (event) {
  14009. if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
  14010. window.print();
  14011. event.preventDefault();
  14012. if (event.stopImmediatePropagation) {
  14013. event.stopImmediatePropagation();
  14014. } else {
  14015. event.stopPropagation();
  14016. }
  14017. }
  14018. }, true);
  14019. if ("onbeforeprint" in window) {
  14020. var stopPropagationIfNeeded = function stopPropagationIfNeeded(event) {
  14021. if (event.detail !== "custom" && event.stopImmediatePropagation) {
  14022. event.stopImmediatePropagation();
  14023. }
  14024. };
  14025. window.addEventListener("beforeprint", stopPropagationIfNeeded);
  14026. window.addEventListener("afterprint", stopPropagationIfNeeded);
  14027. }
  14028. var overlayPromise;
  14029. function ensureOverlay() {
  14030. if (!overlayPromise) {
  14031. overlayManager = _app.PDFViewerApplication.overlayManager;
  14032. if (!overlayManager) {
  14033. throw new Error("The overlay manager has not yet been initialized.");
  14034. }
  14035. overlayPromise = overlayManager.register("printServiceOverlay", document.getElementById("printServiceOverlay"), abort, true);
  14036. document.getElementById("printCancel").onclick = abort;
  14037. }
  14038. return overlayPromise;
  14039. }
  14040. _app.PDFPrintServiceFactory.instance = {
  14041. supportsPrinting: true,
  14042. createPrintService: function createPrintService(pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, l10n) {
  14043. if (activeService) {
  14044. throw new Error("The print service is created and active.");
  14045. }
  14046. activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer, printResolution, optionalContentConfigPromise, l10n);
  14047. return activeService;
  14048. }
  14049. };
  14050. /***/ })
  14051. /******/ ]);
  14052. //# sourceMappingURL=viewer.js.map