viewer.js 544 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2018 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. var DEFAULT_URL = "";
  23. /*******************netca 2021/01/06 zsm************************/
  24. var globalPDFViewerApplication = {};
  25. /******************netca 2021/01/06 zsm*************************/
  26. /******/ (function(modules) { // webpackBootstrap
  27. /******/ // The module cache
  28. /******/ var installedModules = {};
  29. /******/
  30. /******/ // The require function
  31. /******/ function __webpack_require__(moduleId) {
  32. /******/
  33. /******/ // Check if module is in cache检查模块是否缓存中
  34. /******/ if(installedModules[moduleId]) {
  35. /******/ return installedModules[moduleId].exports;
  36. /******/ }
  37. /******/ // Create a new module (and put it into the cache)创建一个新的模块,并放入缓存中
  38. /******/ var module = installedModules[moduleId] = {
  39. /******/ i: moduleId,
  40. /******/ l: false,
  41. /******/ exports: {}
  42. /******/ };
  43. /******/
  44. /******/ // Execute the module function 执行模块放法
  45. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  46. /******/
  47. /******/ // Flag the module as loaded 将模块标记为已加载
  48. /******/ module.l = true;
  49. /******/
  50. /******/ // Return the exports of the module 返回模块的导出
  51. /******/ return module.exports;
  52. /******/ }
  53. /******/
  54. /******/ // require静态放法
  55. /******/ // expose the modules object (__webpack_modules__)
  56. /******/ __webpack_require__.m = modules;//获取模块列表
  57. /******/
  58. /******/ // expose the module cache
  59. /******/ __webpack_require__.c = installedModules;//获取缓存模块列表
  60. /******/
  61. /******/ // define getter function for harmony exports 检查exports对象上有没有挂载name属性,没有就挂载一个
  62. /******/ __webpack_require__.d = function(exports, name, getter) {//定义一个getter方法
  63. /******/ if(!__webpack_require__.o(exports, name)) {
  64. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  65. /******/ }
  66. /******/ };
  67. /******/
  68. /******/ // define __esModule on exports
  69. /******/ __webpack_require__.r = function(exports) {
  70. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  71. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  72. /******/ }
  73. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  74. /******/ };
  75. /******/
  76. /******/ // create a fake namespace object 创建一个伪命名空间对象
  77. /******/ // mode & 1: value is a module id, require it value 是一个模块id,require(value)加载模块
  78. /******/ // mode & 2: merge all properties of value into the ns 将value的所有属性合并到ns对象当中
  79. /******/ // mode & 4: return value when already ns object 返回已经是nsobject到value
  80. /******/ // mode & 8|1: behave like require 绑定getter方法
  81. /******/ __webpack_require__.t = function(value, mode) {
  82. /******/ if(mode & 1) value = __webpack_require__(value);
  83. /******/ if(mode & 8) return value;
  84. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  85. /******/ var ns = Object.create(null);
  86. /******/ __webpack_require__.r(ns);
  87. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  88. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  89. /******/ return ns;
  90. /******/ };
  91. /******/
  92. /******/ // getDefaultExport function for compatibility with non-harmony modules兼容模块对象,给模块对象绑定getter方法
  93. /******/ __webpack_require__.n = function(module) {
  94. /******/ var getter = module && module.__esModule ?
  95. /******/ function getDefault() { return module['default']; } :
  96. /******/ function getModuleExports() { return module; };
  97. /******/ __webpack_require__.d(getter, 'a', getter);
  98. /******/ return getter;
  99. /******/ };
  100. /******/
  101. /******/ // Object.prototype.hasOwnProperty.call判断对象有没有某个属性
  102. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  103. /******/
  104. /******/ // __webpack_public_path__
  105. /******/ __webpack_require__.p = "";
  106. /******/
  107. /******/
  108. /******/ // Load entry module and return exports
  109. /******/ return __webpack_require__(__webpack_require__.s = 0);
  110. /******/ })
  111. /************************************************************************/
  112. /******/ ([
  113. /* 0 */
  114. /***/ (function(module, exports, __webpack_require__) {
  115. "use strict";
  116. ;
  117. var pdfjsWebApp, pdfjsWebAppOptions;
  118. {
  119. pdfjsWebApp = __webpack_require__(1);
  120. pdfjsWebAppOptions = __webpack_require__(12);
  121. }
  122. ;
  123. {
  124. __webpack_require__(37);
  125. }
  126. ;
  127. {
  128. __webpack_require__(42);
  129. }
  130. function getViewerConfiguration() {
  131. return {
  132. appContainer: document.body,
  133. mainContainer: document.getElementById('viewerContainer'),
  134. viewerContainer: document.getElementById('viewer'),
  135. eventBus: null,
  136. toolbar: {
  137. container: document.getElementById('toolbarViewer'),
  138. numPages: document.getElementById('numPages'),
  139. pageNumber: document.getElementById('pageNumber'),
  140. scaleSelectContainer: document.getElementById('scaleSelectContainer'),
  141. scaleSelect: document.getElementById('scaleSelect'),
  142. customScaleOption: document.getElementById('customScaleOption'),
  143. previous: document.getElementById('previous'),
  144. next: document.getElementById('next'),
  145. zoomIn: document.getElementById('zoomIn'),
  146. zoomOut: document.getElementById('zoomOut'),
  147. viewFind: document.getElementById('viewFind'),
  148. openFile: document.getElementById('openFile'),
  149. print: document.getElementById('print'),
  150. presentationModeButton: document.getElementById('presentationMode'),
  151. download: document.getElementById('download'),
  152. viewBookmark: document.getElementById('viewBookmark')
  153. },
  154. secondaryToolbar: {
  155. toolbar: document.getElementById('secondaryToolbar'),
  156. toggleButton: document.getElementById('secondaryToolbarToggle'),
  157. toolbarButtonContainer: document.getElementById('secondaryToolbarButtonContainer'),
  158. presentationModeButton: document.getElementById('secondaryPresentationMode'),
  159. openFileButton: document.getElementById('secondaryOpenFile'),
  160. printButton: document.getElementById('secondaryPrint'),
  161. downloadButton: document.getElementById('secondaryDownload'),
  162. viewBookmarkButton: document.getElementById('secondaryViewBookmark'),
  163. firstPageButton: document.getElementById('firstPage'),
  164. lastPageButton: document.getElementById('lastPage'),
  165. pageRotateCwButton: document.getElementById('pageRotateCw'),
  166. pageRotateCcwButton: document.getElementById('pageRotateCcw'),
  167. cursorSelectToolButton: document.getElementById('cursorSelectTool'),
  168. cursorHandToolButton: document.getElementById('cursorHandTool'),
  169. scrollVerticalButton: document.getElementById('scrollVertical'),
  170. scrollHorizontalButton: document.getElementById('scrollHorizontal'),
  171. scrollWrappedButton: document.getElementById('scrollWrapped'),
  172. spreadNoneButton: document.getElementById('spreadNone'),
  173. spreadOddButton: document.getElementById('spreadOdd'),
  174. spreadEvenButton: document.getElementById('spreadEven'),
  175. documentPropertiesButton: document.getElementById('documentProperties')
  176. },
  177. fullscreen: {
  178. contextFirstPage: document.getElementById('contextFirstPage'),
  179. contextLastPage: document.getElementById('contextLastPage'),
  180. contextPageRotateCw: document.getElementById('contextPageRotateCw'),
  181. contextPageRotateCcw: document.getElementById('contextPageRotateCcw')
  182. },
  183. sidebar: {
  184. outerContainer: document.getElementById('outerContainer'),
  185. viewerContainer: document.getElementById('viewerContainer'),
  186. toggleButton: document.getElementById('sidebarToggle'),
  187. thumbnailButton: document.getElementById('viewThumbnail'),
  188. outlineButton: document.getElementById('viewOutline'),
  189. attachmentsButton: document.getElementById('viewAttachments'),
  190. thumbnailView: document.getElementById('thumbnailView'),
  191. outlineView: document.getElementById('outlineView'),
  192. attachmentsView: document.getElementById('attachmentsView')
  193. },
  194. sidebarResizer: {
  195. outerContainer: document.getElementById('outerContainer'),
  196. resizer: document.getElementById('sidebarResizer')
  197. },
  198. findBar: {
  199. bar: document.getElementById('findbar'),
  200. toggleButton: document.getElementById('viewFind'),
  201. findField: document.getElementById('findInput'),
  202. highlightAllCheckbox: document.getElementById('findHighlightAll'),
  203. caseSensitiveCheckbox: document.getElementById('findMatchCase'),
  204. entireWordCheckbox: document.getElementById('findEntireWord'),
  205. findMsg: document.getElementById('findMsg'),
  206. findResultsCount: document.getElementById('findResultsCount'),
  207. findPreviousButton: document.getElementById('findPrevious'),
  208. findNextButton: document.getElementById('findNext')
  209. },
  210. passwordOverlay: {
  211. overlayName: 'passwordOverlay',
  212. container: document.getElementById('passwordOverlay'),
  213. label: document.getElementById('passwordText'),
  214. input: document.getElementById('password'),
  215. submitButton: document.getElementById('passwordSubmit'),
  216. cancelButton: document.getElementById('passwordCancel')
  217. },
  218. documentProperties: {
  219. overlayName: 'documentPropertiesOverlay',
  220. container: document.getElementById('documentPropertiesOverlay'),
  221. closeButton: document.getElementById('documentPropertiesClose'),
  222. fields: {
  223. 'fileName': document.getElementById('fileNameField'),
  224. 'fileSize': document.getElementById('fileSizeField'),
  225. 'title': document.getElementById('titleField'),
  226. 'author': document.getElementById('authorField'),
  227. 'subject': document.getElementById('subjectField'),
  228. 'keywords': document.getElementById('keywordsField'),
  229. 'creationDate': document.getElementById('creationDateField'),
  230. 'modificationDate': document.getElementById('modificationDateField'),
  231. 'creator': document.getElementById('creatorField'),
  232. 'producer': document.getElementById('producerField'),
  233. 'version': document.getElementById('versionField'),
  234. 'pageCount': document.getElementById('pageCountField'),
  235. 'pageSize': document.getElementById('pageSizeField'),
  236. 'linearized': document.getElementById('linearizedField')
  237. }
  238. },
  239. errorWrapper: {
  240. container: document.getElementById('errorWrapper'),
  241. errorMessage: document.getElementById('errorMessage'),
  242. closeButton: document.getElementById('errorClose'),
  243. errorMoreInfo: document.getElementById('errorMoreInfo'),
  244. moreInfoButton: document.getElementById('errorShowMore'),
  245. lessInfoButton: document.getElementById('errorShowLess')
  246. },
  247. printContainer: document.getElementById('printContainer'),
  248. openFileInputName: 'fileInput',
  249. debuggerScriptPath: './js/debugger.js'
  250. };
  251. }
  252. function webViewerLoad() {
  253. var config = getViewerConfiguration();
  254. window.PDFViewerApplication = pdfjsWebApp.PDFViewerApplication;
  255. window.PDFViewerApplicationOptions = pdfjsWebAppOptions.AppOptions;
  256. var event = document.createEvent('CustomEvent');
  257. event.initCustomEvent('webviewerloaded', true, true, {});
  258. document.dispatchEvent(event);
  259. pdfjsWebApp.PDFViewerApplication.run(config);
  260. }
  261. //interactive:文档已被解析,"正在加载"状态结束,但是诸如图像,样式表和框架之类的子资源仍在加载。
  262. //complete:文档和所有子资源已完成加载。表示 load 状态的事件即将被触发。
  263. if (document.readyState === 'interactive' || document.readyState === 'complete') {
  264. webViewerLoad();
  265. } else {
  266. document.addEventListener('DOMContentLoaded', webViewerLoad, true);
  267. }
  268. /***/ }),
  269. /* 1 */
  270. /***/ (function(module, exports, __webpack_require__) {
  271. "use strict";
  272. Object.defineProperty(exports, "__esModule", {
  273. value: true
  274. });
  275. exports.PDFPrintServiceFactory = exports.DefaultExternalServices = exports.PDFViewerApplication = void 0;
  276. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  277. var _ui_utils = __webpack_require__(6);
  278. var _pdfjsLib = __webpack_require__(7);
  279. var _pdf_cursor_tools = __webpack_require__(8);
  280. var _pdf_rendering_queue = __webpack_require__(10);
  281. var _pdf_sidebar = __webpack_require__(11);
  282. var _app_options = __webpack_require__(12);
  283. var _overlay_manager = __webpack_require__(14);
  284. var _password_prompt = __webpack_require__(15);
  285. var _pdf_attachment_viewer = __webpack_require__(16);
  286. var _pdf_document_properties = __webpack_require__(17);
  287. var _pdf_find_bar = __webpack_require__(18);
  288. var _pdf_find_controller = __webpack_require__(19);
  289. var _pdf_history = __webpack_require__(21);
  290. var _pdf_link_service = __webpack_require__(22);
  291. var _pdf_outline_viewer = __webpack_require__(23);
  292. var _pdf_presentation_mode = __webpack_require__(24);
  293. var _pdf_sidebar_resizer = __webpack_require__(25);
  294. var _pdf_thumbnail_viewer = __webpack_require__(26);
  295. var _pdf_viewer = __webpack_require__(28);
  296. var _secondary_toolbar = __webpack_require__(33);
  297. var _toolbar = __webpack_require__(35);
  298. var _view_history = __webpack_require__(36);
  299. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  300. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
  301. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
  302. function _iterableToArrayLimit(arr, i) { 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; }
  303. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  304. 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); } }
  305. 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); }); }; }
  306. var DEFAULT_SCALE_DELTA = 1.1;
  307. var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
  308. var FORCE_PAGES_LOADED_TIMEOUT = 10000;
  309. var WHEEL_ZOOM_DISABLED_TIMEOUT = 1000;
  310. var ViewOnLoad = {
  311. UNKNOWN: -1,
  312. PREVIOUS: 0,
  313. INITIAL: 1
  314. };
  315. var DefaultExternalServices = {
  316. updateFindControlState: function updateFindControlState(data) {},
  317. updateFindMatchesCount: function updateFindMatchesCount(data) {},
  318. initPassiveLoading: function initPassiveLoading(callbacks) {},
  319. fallback: function fallback(data, callback) {},
  320. reportTelemetry: function reportTelemetry(data) {},
  321. createDownloadManager: function createDownloadManager(options) {
  322. throw new Error('Not implemented: createDownloadManager');
  323. },
  324. createPreferences: function createPreferences() {
  325. throw new Error('Not implemented: createPreferences');
  326. },
  327. createL10n: function createL10n(options) {
  328. throw new Error('Not implemented: createL10n');
  329. },
  330. supportsIntegratedFind: false,
  331. supportsDocumentFonts: true,
  332. supportsDocumentColors: true,
  333. supportedMouseWheelZoomModifierKeys: {
  334. ctrlKey: true,
  335. metaKey: true
  336. }
  337. };
  338. exports.DefaultExternalServices = DefaultExternalServices;
  339. var PDFViewerApplication = {
  340. initialBookmark: document.location.hash.substring(1),
  341. initialized: false,
  342. fellback: false,
  343. appConfig: null,
  344. pdfDocument: null,
  345. pdfLoadingTask: null,
  346. printService: null,
  347. pdfViewer: null,
  348. pdfThumbnailViewer: null,
  349. pdfRenderingQueue: null,
  350. pdfPresentationMode: null,
  351. pdfDocumentProperties: null,
  352. pdfLinkService: null,
  353. pdfHistory: null,
  354. pdfSidebar: null,
  355. pdfSidebarResizer: null,
  356. pdfOutlineViewer: null,
  357. pdfAttachmentViewer: null,
  358. pdfCursorTools: null,
  359. store: null,
  360. downloadManager: null,
  361. overlayManager: null,
  362. preferences: null,
  363. toolbar: null,
  364. secondaryToolbar: null,
  365. eventBus: null,
  366. l10n: null,
  367. isInitialViewSet: false,
  368. downloadComplete: false,
  369. isViewerEmbedded: window.parent !== window,
  370. url: '',
  371. baseUrl: '',
  372. externalServices: DefaultExternalServices,
  373. _boundEvents: {},
  374. contentDispositionFilename: null,
  375. initialize: function () {
  376. var _initialize = _asyncToGenerator(
  377. /*#__PURE__*/
  378. _regenerator.default.mark(function _callee(appConfig) {
  379. var _this = this;
  380. var appContainer;
  381. return _regenerator.default.wrap(function _callee$(_context) {
  382. while (1) {
  383. switch (_context.prev = _context.next) {
  384. case 0:
  385. this.preferences = this.externalServices.createPreferences();
  386. this.appConfig = appConfig;
  387. _context.next = 4;
  388. return this._readPreferences();
  389. case 4:
  390. _context.next = 6;
  391. return this._parseHashParameters();
  392. case 6:
  393. _context.next = 8;
  394. return this._initializeL10n();
  395. case 8:
  396. if (this.isViewerEmbedded && _app_options.AppOptions.get('externalLinkTarget') === _pdfjsLib.LinkTarget.NONE) {
  397. _app_options.AppOptions.set('externalLinkTarget', _pdfjsLib.LinkTarget.TOP);
  398. }
  399. _context.next = 11;
  400. return this._initializeViewerComponents();
  401. case 11:
  402. this.bindEvents();
  403. this.bindWindowEvents();
  404. appContainer = appConfig.appContainer || document.documentElement;
  405. this.l10n.translate(appContainer).then(function () {
  406. _this.eventBus.dispatch('localized', {
  407. source: _this
  408. });
  409. });
  410. this.initialized = true;
  411. case 16:
  412. case "end":
  413. return _context.stop();
  414. }
  415. }
  416. }, _callee, this);
  417. }));
  418. function initialize(_x) {
  419. return _initialize.apply(this, arguments);
  420. }
  421. return initialize;
  422. }(),
  423. _readPreferences: function () {
  424. var _readPreferences2 = _asyncToGenerator(
  425. /*#__PURE__*/
  426. _regenerator.default.mark(function _callee2() {
  427. var prefs, name;
  428. return _regenerator.default.wrap(function _callee2$(_context2) {
  429. while (1) {
  430. switch (_context2.prev = _context2.next) {
  431. case 0:
  432. if (!(_app_options.AppOptions.get('disablePreferences') === true)) {
  433. _context2.next = 2;
  434. break;
  435. }
  436. return _context2.abrupt("return");
  437. case 2:
  438. _context2.prev = 2;
  439. _context2.next = 5;
  440. return this.preferences.getAll();
  441. case 5:
  442. prefs = _context2.sent;
  443. for (name in prefs) {
  444. _app_options.AppOptions.set(name, prefs[name]);
  445. }
  446. _context2.next = 11;
  447. break;
  448. case 9:
  449. _context2.prev = 9;
  450. _context2.t0 = _context2["catch"](2);
  451. case 11:
  452. case "end":
  453. return _context2.stop();
  454. }
  455. }
  456. }, _callee2, this, [[2, 9]]);
  457. }));
  458. function _readPreferences() {
  459. return _readPreferences2.apply(this, arguments);
  460. }
  461. return _readPreferences;
  462. }(),
  463. _parseHashParameters: function () {
  464. var _parseHashParameters2 = _asyncToGenerator(
  465. /*#__PURE__*/
  466. _regenerator.default.mark(function _callee3() {
  467. var waitOn, hash, hashParams, viewer, enabled;
  468. return _regenerator.default.wrap(function _callee3$(_context3) {
  469. while (1) {
  470. switch (_context3.prev = _context3.next) {
  471. case 0:
  472. if (_app_options.AppOptions.get('pdfBugEnabled')) {
  473. _context3.next = 2;
  474. break;
  475. }
  476. return _context3.abrupt("return");
  477. case 2:
  478. waitOn = [];
  479. hash = document.location.hash.substring(1);
  480. hashParams = (0, _ui_utils.parseQueryString)(hash);
  481. if ('disableworker' in hashParams && hashParams['disableworker'] === 'true') {
  482. waitOn.push(loadFakeWorker());
  483. }
  484. if ('disablerange' in hashParams) {
  485. _app_options.AppOptions.set('disableRange', hashParams['disablerange'] === 'true');
  486. }
  487. if ('disablestream' in hashParams) {
  488. _app_options.AppOptions.set('disableStream', hashParams['disablestream'] === 'true');
  489. }
  490. if ('disableautofetch' in hashParams) {
  491. _app_options.AppOptions.set('disableAutoFetch', hashParams['disableautofetch'] === 'true');
  492. }
  493. if ('disablefontface' in hashParams) {
  494. _app_options.AppOptions.set('disableFontFace', hashParams['disablefontface'] === 'true');
  495. }
  496. if ('disablehistory' in hashParams) {
  497. _app_options.AppOptions.set('disableHistory', hashParams['disablehistory'] === 'true');
  498. }
  499. if ('webgl' in hashParams) {
  500. _app_options.AppOptions.set('enableWebGL', hashParams['webgl'] === 'true');
  501. }
  502. if ('useonlycsszoom' in hashParams) {
  503. _app_options.AppOptions.set('useOnlyCssZoom', hashParams['useonlycsszoom'] === 'true');
  504. }
  505. if ('verbosity' in hashParams) {
  506. _app_options.AppOptions.set('verbosity', hashParams['verbosity'] | 0);
  507. }
  508. if (!('textlayer' in hashParams)) {
  509. _context3.next = 23;
  510. break;
  511. }
  512. _context3.t0 = hashParams['textlayer'];
  513. _context3.next = _context3.t0 === 'off' ? 18 : _context3.t0 === 'visible' ? 20 : _context3.t0 === 'shadow' ? 20 : _context3.t0 === 'hover' ? 20 : 23;
  514. break;
  515. case 18:
  516. _app_options.AppOptions.set('textLayerMode', _ui_utils.TextLayerMode.DISABLE);
  517. return _context3.abrupt("break", 23);
  518. case 20:
  519. viewer = this.appConfig.viewerContainer;
  520. viewer.classList.add('textLayer-' + hashParams['textlayer']);
  521. return _context3.abrupt("break", 23);
  522. case 23:
  523. if ('pdfbug' in hashParams) {
  524. _app_options.AppOptions.set('pdfBug', true);
  525. enabled = hashParams['pdfbug'].split(',');
  526. waitOn.push(loadAndEnablePDFBug(enabled));
  527. }
  528. if ('locale' in hashParams) {
  529. _app_options.AppOptions.set('locale', hashParams['locale']);
  530. }
  531. return _context3.abrupt("return", Promise.all(waitOn).catch(function (reason) {
  532. console.error("_parseHashParameters: \"".concat(reason.message, "\"."));
  533. }));
  534. case 26:
  535. case "end":
  536. return _context3.stop();
  537. }
  538. }
  539. }, _callee3, this);
  540. }));
  541. function _parseHashParameters() {
  542. return _parseHashParameters2.apply(this, arguments);
  543. }
  544. return _parseHashParameters;
  545. }(),
  546. _initializeL10n: function () {
  547. var _initializeL10n2 = _asyncToGenerator(
  548. /*#__PURE__*/
  549. _regenerator.default.mark(function _callee4() {
  550. var dir;
  551. return _regenerator.default.wrap(function _callee4$(_context4) {
  552. while (1) {
  553. switch (_context4.prev = _context4.next) {
  554. case 0:
  555. this.l10n = this.externalServices.createL10n({
  556. locale: _app_options.AppOptions.get('locale')
  557. });
  558. _context4.next = 3;
  559. return this.l10n.getDirection();
  560. case 3:
  561. dir = _context4.sent;
  562. document.getElementsByTagName('html')[0].dir = dir;
  563. case 5:
  564. case "end":
  565. return _context4.stop();
  566. }
  567. }
  568. }, _callee4, this);
  569. }));
  570. function _initializeL10n() {
  571. return _initializeL10n2.apply(this, arguments);
  572. }
  573. return _initializeL10n;
  574. }(),
  575. _initializeViewerComponents: function () {
  576. var _initializeViewerComponents2 = _asyncToGenerator(
  577. /*#__PURE__*/
  578. _regenerator.default.mark(function _callee5() {
  579. var appConfig, dispatchToDOM, eventBus, pdfRenderingQueue, pdfLinkService, downloadManager, findController, container, viewer, thumbnailContainer, sidebarConfig;
  580. return _regenerator.default.wrap(function _callee5$(_context5) {
  581. while (1) {
  582. switch (_context5.prev = _context5.next) {
  583. case 0:
  584. appConfig = this.appConfig;
  585. this.overlayManager = new _overlay_manager.OverlayManager();
  586. dispatchToDOM = _app_options.AppOptions.get('eventBusDispatchToDOM');
  587. eventBus = appConfig.eventBus || (0, _ui_utils.getGlobalEventBus)(dispatchToDOM);
  588. this.eventBus = eventBus;
  589. pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  590. pdfRenderingQueue.onIdle = this.cleanup.bind(this);
  591. this.pdfRenderingQueue = pdfRenderingQueue;
  592. pdfLinkService = new _pdf_link_service.PDFLinkService({
  593. eventBus: eventBus,
  594. externalLinkTarget: _app_options.AppOptions.get('externalLinkTarget'),
  595. externalLinkRel: _app_options.AppOptions.get('externalLinkRel')
  596. });
  597. this.pdfLinkService = pdfLinkService;
  598. downloadManager = this.externalServices.createDownloadManager({
  599. disableCreateObjectURL: _app_options.AppOptions.get('disableCreateObjectURL')
  600. });
  601. this.downloadManager = downloadManager;
  602. findController = new _pdf_find_controller.PDFFindController({
  603. linkService: pdfLinkService,
  604. eventBus: eventBus
  605. });
  606. this.findController = findController;
  607. container = appConfig.mainContainer;
  608. viewer = appConfig.viewerContainer;
  609. this.pdfViewer = new _pdf_viewer.PDFViewer({
  610. container: container,
  611. viewer: viewer,
  612. eventBus: eventBus,
  613. renderingQueue: pdfRenderingQueue,
  614. linkService: pdfLinkService,
  615. downloadManager: downloadManager,
  616. findController: findController,
  617. renderer: _app_options.AppOptions.get('renderer'),
  618. enableWebGL: _app_options.AppOptions.get('enableWebGL'),
  619. l10n: this.l10n,
  620. textLayerMode: _app_options.AppOptions.get('textLayerMode'),
  621. imageResourcesPath: _app_options.AppOptions.get('imageResourcesPath'),
  622. renderInteractiveForms: _app_options.AppOptions.get('renderInteractiveForms'),
  623. enablePrintAutoRotate: _app_options.AppOptions.get('enablePrintAutoRotate'),
  624. useOnlyCssZoom: _app_options.AppOptions.get('useOnlyCssZoom'),
  625. maxCanvasPixels: _app_options.AppOptions.get('maxCanvasPixels')
  626. });
  627. pdfRenderingQueue.setViewer(this.pdfViewer);
  628. pdfLinkService.setViewer(this.pdfViewer);
  629. thumbnailContainer = appConfig.sidebar.thumbnailView;
  630. this.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({
  631. container: thumbnailContainer,
  632. renderingQueue: pdfRenderingQueue,
  633. linkService: pdfLinkService,
  634. l10n: this.l10n
  635. });
  636. pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer);
  637. this.pdfHistory = new _pdf_history.PDFHistory({
  638. linkService: pdfLinkService,
  639. eventBus: eventBus
  640. });
  641. pdfLinkService.setHistory(this.pdfHistory);
  642. this.findBar = new _pdf_find_bar.PDFFindBar(appConfig.findBar, eventBus, this.l10n);
  643. this.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, this.overlayManager, eventBus, this.l10n);
  644. this.pdfCursorTools = new _pdf_cursor_tools.PDFCursorTools({
  645. container: container,
  646. eventBus: eventBus,
  647. cursorToolOnLoad: _app_options.AppOptions.get('cursorToolOnLoad')
  648. });
  649. this.toolbar = new _toolbar.Toolbar(appConfig.toolbar, eventBus, this.l10n);
  650. this.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus);
  651. if (this.supportsFullscreen) {
  652. this.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({
  653. container: container,
  654. viewer: viewer,
  655. pdfViewer: this.pdfViewer,
  656. eventBus: eventBus,
  657. contextMenuItems: appConfig.fullscreen
  658. });
  659. }
  660. this.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, this.overlayManager, this.l10n);
  661. this.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({
  662. container: appConfig.sidebar.outlineView,
  663. eventBus: eventBus,
  664. linkService: pdfLinkService
  665. });
  666. this.pdfAttachmentViewer = new _pdf_attachment_viewer.PDFAttachmentViewer({
  667. container: appConfig.sidebar.attachmentsView,
  668. eventBus: eventBus,
  669. downloadManager: downloadManager
  670. });
  671. sidebarConfig = Object.create(appConfig.sidebar);
  672. sidebarConfig.pdfViewer = this.pdfViewer;
  673. sidebarConfig.pdfThumbnailViewer = this.pdfThumbnailViewer;
  674. this.pdfSidebar = new _pdf_sidebar.PDFSidebar(sidebarConfig, eventBus, this.l10n);
  675. this.pdfSidebar.onToggled = this.forceRendering.bind(this);
  676. this.pdfSidebarResizer = new _pdf_sidebar_resizer.PDFSidebarResizer(appConfig.sidebarResizer, eventBus, this.l10n);
  677. case 39:
  678. case "end":
  679. return _context5.stop();
  680. }
  681. }
  682. }, _callee5, this);
  683. }));
  684. function _initializeViewerComponents() {
  685. return _initializeViewerComponents2.apply(this, arguments);
  686. }
  687. return _initializeViewerComponents;
  688. }(),
  689. run: function run(config) {
  690. this.initialize(config).then(webViewerInitialized);
  691. },
  692. getCurrentScale: function getCurrentScale() {
  693. return this.pdfViewer.currentScale;
  694. },
  695. zoomIn: function zoomIn(ticks) {
  696. var newScale = this.pdfViewer.currentScale;
  697. do {
  698. newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2);
  699. newScale = Math.ceil(newScale * 10) / 10;
  700. newScale = Math.min(_ui_utils.MAX_SCALE, newScale);
  701. } while (--ticks > 0 && newScale < _ui_utils.MAX_SCALE);
  702. this.pdfViewer.currentScaleValue = newScale;
  703. },
  704. zoomOut: function zoomOut(ticks) {
  705. var newScale = this.pdfViewer.currentScale;
  706. do {
  707. newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2);
  708. newScale = Math.floor(newScale * 10) / 10;
  709. newScale = Math.max(_ui_utils.MIN_SCALE, newScale);
  710. } while (--ticks > 0 && newScale > _ui_utils.MIN_SCALE);
  711. this.pdfViewer.currentScaleValue = newScale;
  712. },
  713. get pagesCount() {
  714. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  715. },
  716. set page(val) {
  717. this.pdfViewer.currentPageNumber = val;
  718. },
  719. get page() {
  720. return this.pdfViewer.currentPageNumber;
  721. },
  722. get printing() {
  723. return !!this.printService;
  724. },
  725. get supportsPrinting() {
  726. return PDFPrintServiceFactory.instance.supportsPrinting;
  727. },
  728. get supportsFullscreen() {
  729. var support;
  730. var doc = document.documentElement;
  731. support = !!(doc.requestFullscreen || doc.mozRequestFullScreen || doc.webkitRequestFullScreen || doc.msRequestFullscreen);
  732. if (document.fullscreenEnabled === false || document.mozFullScreenEnabled === false || document.webkitFullscreenEnabled === false || document.msFullscreenEnabled === false) {
  733. support = false;
  734. }
  735. return (0, _pdfjsLib.shadow)(this, 'supportsFullscreen', support);
  736. },
  737. get supportsIntegratedFind() {
  738. return this.externalServices.supportsIntegratedFind;
  739. },
  740. get supportsDocumentFonts() {
  741. return this.externalServices.supportsDocumentFonts;
  742. },
  743. get supportsDocumentColors() {
  744. return this.externalServices.supportsDocumentColors;
  745. },
  746. get loadingBar() {
  747. var bar = new _ui_utils.ProgressBar('#loadingBar');
  748. return (0, _pdfjsLib.shadow)(this, 'loadingBar', bar);
  749. },
  750. get supportedMouseWheelZoomModifierKeys() {
  751. return this.externalServices.supportedMouseWheelZoomModifierKeys;
  752. },
  753. initPassiveLoading: function initPassiveLoading() {
  754. throw new Error('Not implemented: initPassiveLoading');
  755. },
  756. setTitleUsingUrl: function setTitleUsingUrl() {
  757. var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  758. this.url = url;
  759. this.baseUrl = url.split('#')[0];
  760. var title = (0, _ui_utils.getPDFFileNameFromURL)(url, '');
  761. if (!title) {
  762. try {
  763. title = decodeURIComponent((0, _pdfjsLib.getFilenameFromUrl)(url)) || url;
  764. } catch (ex) {
  765. title = url;
  766. }
  767. }
  768. this.setTitle(title);
  769. },
  770. setTitle: function setTitle(title) {
  771. if (this.isViewerEmbedded) {
  772. return;
  773. }
  774. document.title = title;
  775. },
  776. close: function () {
  777. var _close = _asyncToGenerator(
  778. /*#__PURE__*/
  779. _regenerator.default.mark(function _callee6() {
  780. var errorWrapper, promise;
  781. return _regenerator.default.wrap(function _callee6$(_context6) {
  782. while (1) {
  783. switch (_context6.prev = _context6.next) {
  784. case 0:
  785. errorWrapper = this.appConfig.errorWrapper.container;
  786. errorWrapper.setAttribute('hidden', 'true');
  787. if (this.pdfLoadingTask) {
  788. _context6.next = 4;
  789. break;
  790. }
  791. return _context6.abrupt("return");
  792. case 4:
  793. promise = this.pdfLoadingTask.destroy();
  794. this.pdfLoadingTask = null;
  795. if (this.pdfDocument) {
  796. this.pdfDocument = null;
  797. this.pdfThumbnailViewer.setDocument(null);
  798. this.pdfViewer.setDocument(null);
  799. this.pdfLinkService.setDocument(null);
  800. this.pdfDocumentProperties.setDocument(null);
  801. }
  802. this.store = null;
  803. this.isInitialViewSet = false;
  804. this.downloadComplete = false;
  805. this.url = '';
  806. this.baseUrl = '';
  807. this.contentDispositionFilename = null;
  808. this.pdfSidebar.reset();
  809. this.pdfOutlineViewer.reset();
  810. this.pdfAttachmentViewer.reset();
  811. this.findBar.reset();
  812. this.toolbar.reset();
  813. this.secondaryToolbar.reset();
  814. if (typeof PDFBug !== 'undefined') {
  815. PDFBug.cleanup();
  816. }
  817. return _context6.abrupt("return", promise);
  818. case 21:
  819. case "end":
  820. return _context6.stop();
  821. }
  822. }
  823. }, _callee6, this);
  824. }));
  825. function close() {
  826. return _close.apply(this, arguments);
  827. }
  828. return close;
  829. }(),
  830. open: function () {
  831. var _open = _asyncToGenerator(
  832. /*#__PURE__*/
  833. _regenerator.default.mark(function _callee7(file, args) {
  834. var _this2 = this;
  835. var workerParameters, key, parameters, apiParameters, _key, prop, loadingTask;
  836. return _regenerator.default.wrap(function _callee7$(_context7) {
  837. while (1) {
  838. switch (_context7.prev = _context7.next) {
  839. case 0:
  840. if (!this.pdfLoadingTask) {
  841. _context7.next = 3;
  842. break;
  843. }
  844. _context7.next = 3;
  845. return this.close();
  846. case 3:
  847. workerParameters = _app_options.AppOptions.getAll('worker');
  848. for (key in workerParameters) {
  849. _pdfjsLib.GlobalWorkerOptions[key] = workerParameters[key];
  850. }
  851. parameters = Object.create(null);
  852. if (typeof file === 'string') {
  853. this.setTitleUsingUrl(file);
  854. parameters.url = file;
  855. } else if (file && 'byteLength' in file) {
  856. parameters.data = file;
  857. } else if (file.url && file.originalUrl) {
  858. this.setTitleUsingUrl(file.originalUrl);
  859. parameters.url = file.url;
  860. }
  861. apiParameters = _app_options.AppOptions.getAll('api');
  862. for (_key in apiParameters) {
  863. parameters[_key] = apiParameters[_key];
  864. }
  865. if (args) {
  866. for (prop in args) {
  867. if (prop === 'length') {
  868. this.pdfDocumentProperties.setFileSize(args[prop]);
  869. }
  870. parameters[prop] = args[prop];
  871. }
  872. }
  873. loadingTask = (0, _pdfjsLib.getDocument)(parameters);
  874. this.pdfLoadingTask = loadingTask;
  875. loadingTask.onPassword = function (updateCallback, reason) {
  876. _this2.passwordPrompt.setUpdateCallback(updateCallback, reason);
  877. _this2.passwordPrompt.open();
  878. };
  879. loadingTask.onProgress = function (_ref) {
  880. var loaded = _ref.loaded,
  881. total = _ref.total;
  882. _this2.progress(loaded / total);
  883. };
  884. loadingTask.onUnsupportedFeature = this.fallback.bind(this);
  885. return _context7.abrupt("return", loadingTask.promise.then(function (pdfDocument) {
  886. _this2.load(pdfDocument);
  887. }, function (exception) {
  888. if (loadingTask !== _this2.pdfLoadingTask) {
  889. return;
  890. }
  891. var message = exception && exception.message;
  892. var loadingErrorMessage;
  893. if (exception instanceof _pdfjsLib.InvalidPDFException) {
  894. loadingErrorMessage = _this2.l10n.get('invalid_file_error', null, 'Invalid or corrupted PDF file.');
  895. } else if (exception instanceof _pdfjsLib.MissingPDFException) {
  896. loadingErrorMessage = _this2.l10n.get('missing_file_error', null, 'Missing PDF file.');
  897. } else if (exception instanceof _pdfjsLib.UnexpectedResponseException) {
  898. loadingErrorMessage = _this2.l10n.get('unexpected_response_error', null, 'Unexpected server response.');
  899. } else {
  900. loadingErrorMessage = _this2.l10n.get('loading_error', null, 'An error occurred while loading the PDF.');
  901. }
  902. return loadingErrorMessage.then(function (msg) {
  903. _this2.error(msg, {
  904. message: message
  905. });
  906. alert(msg);//抛出问题
  907. throw new Error(msg);
  908. });
  909. }));
  910. case 16:
  911. case "end":
  912. return _context7.stop();
  913. }
  914. }
  915. }, _callee7, this);
  916. }));
  917. function open(_x2, _x3) {
  918. return _open.apply(this, arguments);
  919. }
  920. return open;
  921. }(),
  922. download: function download() {
  923. var _this3 = this;
  924. function downloadByUrl() {
  925. downloadManager.downloadUrl(url, filename);
  926. }
  927. var url = this.baseUrl;
  928. var filename = this.contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(this.url);
  929. var downloadManager = this.downloadManager;
  930. downloadManager.onerror = function (err) {
  931. _this3.error("PDF failed to download: ".concat(err));
  932. };
  933. if (!this.pdfDocument || !this.downloadComplete) {
  934. downloadByUrl();
  935. return;
  936. }
  937. this.pdfDocument.getData().then(function (data) {
  938. var blob = new Blob([data], {
  939. type: 'application/pdf'
  940. });
  941. downloadManager.download(blob, url, filename);
  942. }).catch(downloadByUrl);
  943. },
  944. fallback: function fallback(featureId) {},
  945. error: function error(message, moreInfo) {
  946. var moreInfoText = [this.l10n.get('error_version_info', {
  947. version: _pdfjsLib.version || '?',
  948. build: _pdfjsLib.build || '?'
  949. }, 'PDF.js v{{version}} (build: {{build}})')];
  950. if (moreInfo) {
  951. moreInfoText.push(this.l10n.get('error_message', {
  952. message: moreInfo.message
  953. }, 'Message: {{message}}'));
  954. if (moreInfo.stack) {
  955. moreInfoText.push(this.l10n.get('error_stack', {
  956. stack: moreInfo.stack
  957. }, 'Stack: {{stack}}'));
  958. } else {
  959. if (moreInfo.filename) {
  960. moreInfoText.push(this.l10n.get('error_file', {
  961. file: moreInfo.filename
  962. }, 'File: {{file}}'));
  963. }
  964. if (moreInfo.lineNumber) {
  965. moreInfoText.push(this.l10n.get('error_line', {
  966. line: moreInfo.lineNumber
  967. }, 'Line: {{line}}'));
  968. }
  969. }
  970. }
  971. var errorWrapperConfig = this.appConfig.errorWrapper;
  972. var errorWrapper = errorWrapperConfig.container;
  973. errorWrapper.removeAttribute('hidden');
  974. var errorMessage = errorWrapperConfig.errorMessage;
  975. errorMessage.textContent = message;
  976. var closeButton = errorWrapperConfig.closeButton;
  977. closeButton.onclick = function () {
  978. errorWrapper.setAttribute('hidden', 'true');
  979. };
  980. var errorMoreInfo = errorWrapperConfig.errorMoreInfo;
  981. var moreInfoButton = errorWrapperConfig.moreInfoButton;
  982. var lessInfoButton = errorWrapperConfig.lessInfoButton;
  983. moreInfoButton.onclick = function () {
  984. errorMoreInfo.removeAttribute('hidden');
  985. moreInfoButton.setAttribute('hidden', 'true');
  986. lessInfoButton.removeAttribute('hidden');
  987. errorMoreInfo.style.height = errorMoreInfo.scrollHeight + 'px';
  988. };
  989. lessInfoButton.onclick = function () {
  990. errorMoreInfo.setAttribute('hidden', 'true');
  991. moreInfoButton.removeAttribute('hidden');
  992. lessInfoButton.setAttribute('hidden', 'true');
  993. };
  994. moreInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  995. lessInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  996. closeButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  997. moreInfoButton.removeAttribute('hidden');
  998. lessInfoButton.setAttribute('hidden', 'true');
  999. Promise.all(moreInfoText).then(function (parts) {
  1000. errorMoreInfo.value = parts.join('\n');
  1001. });
  1002. },
  1003. progress: function progress(level) {
  1004. var _this4 = this;
  1005. if (this.downloadComplete) {
  1006. return;
  1007. }
  1008. var percent = Math.round(level * 100);
  1009. if (percent > this.loadingBar.percent || isNaN(percent)) {
  1010. this.loadingBar.percent = percent;
  1011. var disableAutoFetch = this.pdfDocument ? this.pdfDocument.loadingParams['disableAutoFetch'] : _app_options.AppOptions.get('disableAutoFetch');
  1012. if (disableAutoFetch && percent) {
  1013. if (this.disableAutoFetchLoadingBarTimeout) {
  1014. clearTimeout(this.disableAutoFetchLoadingBarTimeout);
  1015. this.disableAutoFetchLoadingBarTimeout = null;
  1016. }
  1017. this.loadingBar.show();
  1018. this.disableAutoFetchLoadingBarTimeout = setTimeout(function () {
  1019. _this4.loadingBar.hide();
  1020. _this4.disableAutoFetchLoadingBarTimeout = null;
  1021. }, DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT);
  1022. }
  1023. }
  1024. },
  1025. load: function load(pdfDocument) {
  1026. var _this5 = this;
  1027. this.pdfDocument = pdfDocument;
  1028. pdfDocument.getDownloadInfo().then(function () {
  1029. _this5.downloadComplete = true;
  1030. _this5.loadingBar.hide();
  1031. firstPagePromise.then(function () {
  1032. _this5.eventBus.dispatch('documentloaded', {
  1033. source: _this5
  1034. });
  1035. });
  1036. });
  1037. var pageModePromise = pdfDocument.getPageMode().catch(function () {});
  1038. var openActionDestPromise = pdfDocument.getOpenActionDestination().catch(function () {});
  1039. this.toolbar.setPagesCount(pdfDocument.numPages, false);
  1040. this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
  1041. var store = this.store = new _view_history.ViewHistory(pdfDocument.fingerprint);
  1042. var baseDocumentUrl;
  1043. baseDocumentUrl = null;
  1044. this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
  1045. this.pdfDocumentProperties.setDocument(pdfDocument, this.url);
  1046. var pdfViewer = this.pdfViewer;
  1047. pdfViewer.setDocument(pdfDocument);
  1048. var firstPagePromise = pdfViewer.firstPagePromise;
  1049. var pagesPromise = pdfViewer.pagesPromise;
  1050. var onePageRendered = pdfViewer.onePageRendered;
  1051. var pdfThumbnailViewer = this.pdfThumbnailViewer;
  1052. pdfThumbnailViewer.setDocument(pdfDocument);
  1053. firstPagePromise.then(function (pdfPage) {
  1054. _this5.loadingBar.setWidth(_this5.appConfig.viewerContainer);
  1055. var storePromise = store.getMultiple({
  1056. page: null,
  1057. zoom: _ui_utils.DEFAULT_SCALE_VALUE,
  1058. scrollLeft: '0',
  1059. scrollTop: '0',
  1060. rotation: null,
  1061. sidebarView: _pdf_sidebar.SidebarView.UNKNOWN,
  1062. scrollMode: _ui_utils.ScrollMode.UNKNOWN,
  1063. spreadMode: _ui_utils.SpreadMode.UNKNOWN
  1064. }).catch(function () {});
  1065. Promise.all([storePromise, pageModePromise, openActionDestPromise]).then(
  1066. /*#__PURE__*/
  1067. function () {
  1068. var _ref3 = _asyncToGenerator(
  1069. /*#__PURE__*/
  1070. _regenerator.default.mark(function _callee8(_ref2) {
  1071. var _ref4, _ref4$, values, pageMode, openActionDest, viewOnLoad, initialBookmark, zoom, hash, rotation, sidebarView, scrollMode, spreadMode;
  1072. return _regenerator.default.wrap(function _callee8$(_context8) {
  1073. while (1) {
  1074. switch (_context8.prev = _context8.next) {
  1075. case 0:
  1076. _ref4 = _slicedToArray(_ref2, 3), _ref4$ = _ref4[0], values = _ref4$ === void 0 ? {} : _ref4$, pageMode = _ref4[1], openActionDest = _ref4[2];
  1077. viewOnLoad = _app_options.AppOptions.get('viewOnLoad');
  1078. _this5._initializePdfHistory({
  1079. fingerprint: pdfDocument.fingerprint,
  1080. viewOnLoad: viewOnLoad,
  1081. initialDest: openActionDest
  1082. });
  1083. initialBookmark = _this5.initialBookmark;
  1084. zoom = _app_options.AppOptions.get('defaultZoomValue');
  1085. hash = zoom ? "zoom=".concat(zoom) : null;
  1086. rotation = null;
  1087. sidebarView = _app_options.AppOptions.get('sidebarViewOnLoad');
  1088. scrollMode = _app_options.AppOptions.get('scrollModeOnLoad');
  1089. spreadMode = _app_options.AppOptions.get('spreadModeOnLoad');
  1090. if (values.page && viewOnLoad !== ViewOnLoad.INITIAL) {
  1091. hash = "page=".concat(values.page, "&zoom=").concat(zoom || values.zoom, ",") + "".concat(values.scrollLeft, ",").concat(values.scrollTop);
  1092. rotation = parseInt(values.rotation, 10);
  1093. if (sidebarView === _pdf_sidebar.SidebarView.UNKNOWN) {
  1094. sidebarView = values.sidebarView | 0;
  1095. }
  1096. if (scrollMode === _ui_utils.ScrollMode.UNKNOWN) {
  1097. scrollMode = values.scrollMode | 0;
  1098. }
  1099. if (spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
  1100. spreadMode = values.spreadMode | 0;
  1101. }
  1102. }
  1103. if (pageMode && sidebarView === _pdf_sidebar.SidebarView.UNKNOWN) {
  1104. sidebarView = apiPageModeToSidebarView(pageMode);
  1105. }
  1106. _this5.setInitialView(hash, {
  1107. rotation: rotation,
  1108. sidebarView: sidebarView,
  1109. scrollMode: scrollMode,
  1110. spreadMode: spreadMode
  1111. });
  1112. _this5.eventBus.dispatch('documentinit', {
  1113. source: _this5
  1114. });
  1115. if (!_this5.isViewerEmbedded) {
  1116. pdfViewer.focus();
  1117. }
  1118. _context8.next = 17;
  1119. return Promise.race([pagesPromise, new Promise(function (resolve) {
  1120. setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT);
  1121. })]);
  1122. case 17:
  1123. if (!(!initialBookmark && !hash)) {
  1124. _context8.next = 19;
  1125. break;
  1126. }
  1127. return _context8.abrupt("return");
  1128. case 19:
  1129. if (!pdfViewer.hasEqualPageSizes) {
  1130. _context8.next = 21;
  1131. break;
  1132. }
  1133. return _context8.abrupt("return");
  1134. case 21:
  1135. _this5.initialBookmark = initialBookmark;
  1136. pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;
  1137. _this5.setInitialView(hash);
  1138. case 24:
  1139. case "end":
  1140. return _context8.stop();
  1141. }
  1142. }
  1143. }, _callee8, this);
  1144. }));
  1145. return function (_x4) {
  1146. return _ref3.apply(this, arguments);
  1147. };
  1148. }()).catch(function () {
  1149. _this5.setInitialView();
  1150. }).then(function () {
  1151. pdfViewer.update();
  1152. });
  1153. });
  1154. pdfDocument.getPageLabels().then(function (labels) {
  1155. if (!labels || _app_options.AppOptions.get('disablePageLabels')) {
  1156. return;
  1157. }
  1158. var i = 0,
  1159. numLabels = labels.length;
  1160. if (numLabels !== _this5.pagesCount) {
  1161. console.error('The number of Page Labels does not match ' + 'the number of pages in the document.');
  1162. return;
  1163. }
  1164. while (i < numLabels && labels[i] === (i + 1).toString()) {
  1165. i++;
  1166. }
  1167. if (i === numLabels) {
  1168. return;
  1169. }
  1170. pdfViewer.setPageLabels(labels);
  1171. pdfThumbnailViewer.setPageLabels(labels);
  1172. _this5.toolbar.setPagesCount(pdfDocument.numPages, true);
  1173. _this5.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  1174. });
  1175. pagesPromise.then(function () {
  1176. if (!_this5.supportsPrinting) {
  1177. return;
  1178. }
  1179. pdfDocument.getJavaScript().then(function (javaScript) {
  1180. if (!javaScript) {
  1181. return;
  1182. }
  1183. javaScript.some(function (js) {
  1184. if (!js) {
  1185. return false;
  1186. }
  1187. console.warn('Warning: JavaScript is not supported');
  1188. _this5.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.javaScript);
  1189. return true;
  1190. });
  1191. var regex = /\bprint\s*\(/;
  1192. for (var i = 0, ii = javaScript.length; i < ii; i++) {
  1193. var js = javaScript[i];
  1194. if (js && regex.test(js)) {
  1195. setTimeout(function () {
  1196. window.print();
  1197. });
  1198. return;
  1199. }
  1200. }
  1201. });
  1202. });
  1203. Promise.all([onePageRendered, _ui_utils.animationStarted]).then(function () {
  1204. pdfDocument.getOutline().then(function (outline) {
  1205. _this5.pdfOutlineViewer.render({
  1206. outline: outline
  1207. });
  1208. });
  1209. pdfDocument.getAttachments().then(function (attachments) {
  1210. _this5.pdfAttachmentViewer.render({
  1211. attachments: attachments
  1212. });
  1213. });
  1214. });
  1215. pdfDocument.getMetadata().then(function (_ref5) {
  1216. var info = _ref5.info,
  1217. metadata = _ref5.metadata,
  1218. contentDispositionFilename = _ref5.contentDispositionFilename;
  1219. _this5.documentInfo = info;
  1220. _this5.metadata = metadata;
  1221. _this5.contentDispositionFilename = contentDispositionFilename;
  1222. console.log('PDF ' + pdfDocument.fingerprint + ' [' + info.PDFFormatVersion + ' ' + (info.Producer || '-').trim() + ' / ' + (info.Creator || '-').trim() + ']' + ' (PDF.js: ' + (_pdfjsLib.version || '-') + (_app_options.AppOptions.get('enableWebGL') ? ' [WebGL]' : '') + ')');
  1223. var pdfTitle;
  1224. if (metadata && metadata.has('dc:title')) {
  1225. var title = metadata.get('dc:title');
  1226. if (title !== 'Untitled') {
  1227. pdfTitle = title;
  1228. }
  1229. }
  1230. if (!pdfTitle && info && info['Title']) {
  1231. pdfTitle = info['Title'];
  1232. }
  1233. if (pdfTitle) {
  1234. _this5.setTitle("".concat(pdfTitle, " - ").concat(contentDispositionFilename || document.title));
  1235. } else if (contentDispositionFilename) {
  1236. _this5.setTitle(contentDispositionFilename);
  1237. }
  1238. if (info.IsAcroFormPresent) {
  1239. console.warn('Warning: AcroForm/XFA is not supported');
  1240. _this5.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms);
  1241. }
  1242. });
  1243. },
  1244. _initializePdfHistory: function _initializePdfHistory(_ref6) {
  1245. var fingerprint = _ref6.fingerprint,
  1246. viewOnLoad = _ref6.viewOnLoad,
  1247. _ref6$initialDest = _ref6.initialDest,
  1248. initialDest = _ref6$initialDest === void 0 ? null : _ref6$initialDest;
  1249. if (_app_options.AppOptions.get('disableHistory') || this.isViewerEmbedded) {
  1250. return;
  1251. }
  1252. this.pdfHistory.initialize({
  1253. fingerprint: fingerprint,
  1254. resetHistory: viewOnLoad === ViewOnLoad.INITIAL,
  1255. updateUrl: _app_options.AppOptions.get('historyUpdateUrl')
  1256. });
  1257. if (this.pdfHistory.initialBookmark) {
  1258. this.initialBookmark = this.pdfHistory.initialBookmark;
  1259. this.initialRotation = this.pdfHistory.initialRotation;
  1260. }
  1261. if (initialDest && !this.initialBookmark && viewOnLoad === ViewOnLoad.UNKNOWN) {
  1262. this.initialBookmark = JSON.stringify(initialDest);
  1263. this.pdfHistory.push({
  1264. explicitDest: initialDest,
  1265. pageNumber: null
  1266. });
  1267. }
  1268. },
  1269. setInitialView: function setInitialView(storedHash) {
  1270. var _this6 = this;
  1271. var _ref7 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  1272. rotation = _ref7.rotation,
  1273. sidebarView = _ref7.sidebarView,
  1274. scrollMode = _ref7.scrollMode,
  1275. spreadMode = _ref7.spreadMode;
  1276. var setRotation = function setRotation(angle) {
  1277. if ((0, _ui_utils.isValidRotation)(angle)) {
  1278. _this6.pdfViewer.pagesRotation = angle;
  1279. }
  1280. };
  1281. var setViewerModes = function setViewerModes(scroll, spread) {
  1282. if ((0, _ui_utils.isValidScrollMode)(scroll)) {
  1283. _this6.pdfViewer.scrollMode = scroll;
  1284. }
  1285. if ((0, _ui_utils.isValidSpreadMode)(spread)) {
  1286. _this6.pdfViewer.spreadMode = spread;
  1287. }
  1288. };
  1289. this.isInitialViewSet = true;
  1290. this.pdfSidebar.setInitialView(sidebarView);
  1291. setViewerModes(scrollMode, spreadMode);
  1292. if (this.initialBookmark) {
  1293. setRotation(this.initialRotation);
  1294. delete this.initialRotation;
  1295. this.pdfLinkService.setHash(this.initialBookmark);
  1296. this.initialBookmark = null;
  1297. } else if (storedHash) {
  1298. setRotation(rotation);
  1299. this.pdfLinkService.setHash(storedHash);
  1300. }
  1301. this.toolbar.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel);
  1302. this.secondaryToolbar.setPageNumber(this.pdfViewer.currentPageNumber);
  1303. if (!this.pdfViewer.currentScaleValue) {
  1304. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  1305. }
  1306. },
  1307. cleanup: function cleanup() {
  1308. if (!this.pdfDocument) {
  1309. return;
  1310. }
  1311. this.pdfViewer.cleanup();
  1312. this.pdfThumbnailViewer.cleanup();
  1313. if (this.pdfViewer.renderer !== _ui_utils.RendererType.SVG) {
  1314. this.pdfDocument.cleanup();
  1315. }
  1316. },
  1317. forceRendering: function forceRendering() {
  1318. this.pdfRenderingQueue.printing = this.printing;
  1319. this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar.isThumbnailViewVisible;
  1320. this.pdfRenderingQueue.renderHighestPriority();
  1321. },
  1322. beforePrint: function beforePrint() {
  1323. var _this7 = this;
  1324. if (this.printService) {
  1325. return;
  1326. }
  1327. if (!this.supportsPrinting) {
  1328. this.l10n.get('printing_not_supported', null, 'Warning: Printing is not fully supported by ' + 'this browser.').then(function (printMessage) {
  1329. _this7.error(printMessage);
  1330. });
  1331. return;
  1332. }
  1333. if (!this.pdfViewer.pageViewsReady) {
  1334. this.l10n.get('printing_not_ready', null, 'Warning: The PDF is not fully loaded for printing.').then(function (notReadyMessage) {
  1335. window.alert(notReadyMessage);
  1336. });
  1337. return;
  1338. }
  1339. var pagesOverview = this.pdfViewer.getPagesOverview();
  1340. var printContainer = this.appConfig.printContainer;
  1341. var printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument, pagesOverview, printContainer, this.l10n);
  1342. this.printService = printService;
  1343. this.forceRendering();
  1344. printService.layout();
  1345. },
  1346. afterPrint: function pdfViewSetupAfterPrint() {
  1347. if (this.printService) {
  1348. this.printService.destroy();
  1349. this.printService = null;
  1350. }
  1351. this.forceRendering();
  1352. },
  1353. rotatePages: function rotatePages(delta) {
  1354. if (!this.pdfDocument) {
  1355. return;
  1356. }
  1357. var newRotation = (this.pdfViewer.pagesRotation + 360 + delta) % 360;
  1358. this.pdfViewer.pagesRotation = newRotation;
  1359. },
  1360. requestPresentationMode: function requestPresentationMode() {
  1361. if (!this.pdfPresentationMode) {
  1362. return;
  1363. }
  1364. this.pdfPresentationMode.request();
  1365. },
  1366. bindEvents: function bindEvents() {
  1367. var eventBus = this.eventBus,
  1368. _boundEvents = this._boundEvents;
  1369. _boundEvents.beforePrint = this.beforePrint.bind(this);
  1370. _boundEvents.afterPrint = this.afterPrint.bind(this);
  1371. eventBus.on('resize', webViewerResize);
  1372. eventBus.on('hashchange', webViewerHashchange);
  1373. eventBus.on('beforeprint', _boundEvents.beforePrint);
  1374. eventBus.on('afterprint', _boundEvents.afterPrint);
  1375. eventBus.on('pagerendered', webViewerPageRendered);
  1376. eventBus.on('textlayerrendered', webViewerTextLayerRendered);
  1377. eventBus.on('updateviewarea', webViewerUpdateViewarea);
  1378. eventBus.on('pagechanging', webViewerPageChanging);
  1379. eventBus.on('scalechanging', webViewerScaleChanging);
  1380. eventBus.on('rotationchanging', webViewerRotationChanging);
  1381. eventBus.on('sidebarviewchanged', webViewerSidebarViewChanged);
  1382. eventBus.on('pagemode', webViewerPageMode);
  1383. eventBus.on('namedaction', webViewerNamedAction);
  1384. eventBus.on('presentationmodechanged', webViewerPresentationModeChanged);
  1385. eventBus.on('presentationmode', webViewerPresentationMode);
  1386. // eventBus.on('openfile', webViewerOpenFile);
  1387. eventBus.on('print', webViewerPrint);
  1388. eventBus.on('download', webViewerDownload);
  1389. eventBus.on('firstpage', webViewerFirstPage);
  1390. eventBus.on('lastpage', webViewerLastPage);
  1391. eventBus.on('nextpage', webViewerNextPage);
  1392. eventBus.on('previouspage', webViewerPreviousPage);
  1393. eventBus.on('zoomin', webViewerZoomIn);
  1394. eventBus.on('zoomout', webViewerZoomOut);
  1395. eventBus.on('pagenumberchanged', webViewerPageNumberChanged);
  1396. eventBus.on('scalechanged', webViewerScaleChanged);
  1397. eventBus.on('rotatecw', webViewerRotateCw);
  1398. eventBus.on('rotateccw', webViewerRotateCcw);
  1399. eventBus.on('switchscrollmode', webViewerSwitchScrollMode);
  1400. eventBus.on('scrollmodechanged', webViewerScrollModeChanged);
  1401. eventBus.on('switchspreadmode', webViewerSwitchSpreadMode);
  1402. eventBus.on('spreadmodechanged', webViewerSpreadModeChanged);
  1403. eventBus.on('documentproperties', webViewerDocumentProperties);
  1404. eventBus.on('find', webViewerFind);
  1405. eventBus.on('findfromurlhash', webViewerFindFromUrlHash);
  1406. eventBus.on('updatefindmatchescount', webViewerUpdateFindMatchesCount);
  1407. eventBus.on('updatefindcontrolstate', webViewerUpdateFindControlState);
  1408. eventBus.on('fileinputchange', webViewerFileInputChange);
  1409. },
  1410. bindWindowEvents: function bindWindowEvents() {
  1411. var eventBus = this.eventBus,
  1412. _boundEvents = this._boundEvents;
  1413. _boundEvents.windowResize = function () {
  1414. eventBus.dispatch('resize', {
  1415. source: window
  1416. });
  1417. };
  1418. _boundEvents.windowHashChange = function () {
  1419. eventBus.dispatch('hashchange', {
  1420. source: window,
  1421. hash: document.location.hash.substring(1)
  1422. });
  1423. };
  1424. _boundEvents.windowBeforePrint = function () {
  1425. eventBus.dispatch('beforeprint', {
  1426. source: window
  1427. });
  1428. };
  1429. _boundEvents.windowAfterPrint = function () {
  1430. eventBus.dispatch('afterprint', {
  1431. source: window
  1432. });
  1433. };
  1434. window.addEventListener('visibilitychange', webViewerVisibilityChange);
  1435. window.addEventListener('wheel', webViewerWheel);
  1436. window.addEventListener('click', webViewerClick);
  1437. window.addEventListener('keydown', webViewerKeyDown);
  1438. window.addEventListener('resize', _boundEvents.windowResize);
  1439. window.addEventListener('hashchange', _boundEvents.windowHashChange);
  1440. window.addEventListener('beforeprint', _boundEvents.windowBeforePrint);
  1441. window.addEventListener('afterprint', _boundEvents.windowAfterPrint);
  1442. },
  1443. unbindEvents: function unbindEvents() {
  1444. var eventBus = this.eventBus,
  1445. _boundEvents = this._boundEvents;
  1446. eventBus.off('resize', webViewerResize);
  1447. eventBus.off('hashchange', webViewerHashchange);
  1448. eventBus.off('beforeprint', _boundEvents.beforePrint);
  1449. eventBus.off('afterprint', _boundEvents.afterPrint);
  1450. eventBus.off('pagerendered', webViewerPageRendered);
  1451. eventBus.off('textlayerrendered', webViewerTextLayerRendered);
  1452. eventBus.off('updateviewarea', webViewerUpdateViewarea);
  1453. eventBus.off('pagechanging', webViewerPageChanging);
  1454. eventBus.off('scalechanging', webViewerScaleChanging);
  1455. eventBus.off('rotationchanging', webViewerRotationChanging);
  1456. eventBus.off('sidebarviewchanged', webViewerSidebarViewChanged);
  1457. eventBus.off('pagemode', webViewerPageMode);
  1458. eventBus.off('namedaction', webViewerNamedAction);
  1459. eventBus.off('presentationmodechanged', webViewerPresentationModeChanged);
  1460. eventBus.off('presentationmode', webViewerPresentationMode);
  1461. eventBus.off('openfile', webViewerOpenFile);
  1462. eventBus.off('print', webViewerPrint);
  1463. eventBus.off('download', webViewerDownload);
  1464. eventBus.off('firstpage', webViewerFirstPage);
  1465. eventBus.off('lastpage', webViewerLastPage);
  1466. eventBus.off('nextpage', webViewerNextPage);
  1467. eventBus.off('previouspage', webViewerPreviousPage);
  1468. eventBus.off('zoomin', webViewerZoomIn);
  1469. eventBus.off('zoomout', webViewerZoomOut);
  1470. eventBus.off('pagenumberchanged', webViewerPageNumberChanged);
  1471. eventBus.off('scalechanged', webViewerScaleChanged);
  1472. eventBus.off('rotatecw', webViewerRotateCw);
  1473. eventBus.off('rotateccw', webViewerRotateCcw);
  1474. eventBus.off('switchscrollmode', webViewerSwitchScrollMode);
  1475. eventBus.off('scrollmodechanged', webViewerScrollModeChanged);
  1476. eventBus.off('switchspreadmode', webViewerSwitchSpreadMode);
  1477. eventBus.off('spreadmodechanged', webViewerSpreadModeChanged);
  1478. eventBus.off('documentproperties', webViewerDocumentProperties);
  1479. eventBus.off('find', webViewerFind);
  1480. eventBus.off('findfromurlhash', webViewerFindFromUrlHash);
  1481. eventBus.off('updatefindmatchescount', webViewerUpdateFindMatchesCount);
  1482. eventBus.off('updatefindcontrolstate', webViewerUpdateFindControlState);
  1483. eventBus.off('fileinputchange', webViewerFileInputChange);
  1484. _boundEvents.beforePrint = null;
  1485. _boundEvents.afterPrint = null;
  1486. },
  1487. unbindWindowEvents: function unbindWindowEvents() {
  1488. var _boundEvents = this._boundEvents;
  1489. window.removeEventListener('visibilitychange', webViewerVisibilityChange);
  1490. window.removeEventListener('wheel', webViewerWheel);
  1491. window.removeEventListener('click', webViewerClick);
  1492. window.removeEventListener('keydown', webViewerKeyDown);
  1493. window.removeEventListener('resize', _boundEvents.windowResize);
  1494. window.removeEventListener('hashchange', _boundEvents.windowHashChange);
  1495. window.removeEventListener('beforeprint', _boundEvents.windowBeforePrint);
  1496. window.removeEventListener('afterprint', _boundEvents.windowAfterPrint);
  1497. _boundEvents.windowResize = null;
  1498. _boundEvents.windowHashChange = null;
  1499. _boundEvents.windowBeforePrint = null;
  1500. _boundEvents.windowAfterPrint = null;
  1501. }
  1502. };
  1503. exports.PDFViewerApplication = PDFViewerApplication;
  1504. /*******************netca 2021/01/06 zsm************************/
  1505. globalPDFViewerApplication = PDFViewerApplication;
  1506. /*******************netca 2021/01/06 zsm************************/
  1507. var validateFileURL;
  1508. {
  1509. var HOSTED_VIEWER_ORIGINS = ['null', 'http://mozilla.github.io', 'https://mozilla.github.io'];
  1510. validateFileURL = function validateFileURL(file) {
  1511. if (file === undefined) {
  1512. return;
  1513. }
  1514. try {
  1515. var viewerOrigin = new _pdfjsLib.URL(window.location.href).origin || 'null';
  1516. if (HOSTED_VIEWER_ORIGINS.includes(viewerOrigin)) {
  1517. return;
  1518. }
  1519. var _ref8 = new _pdfjsLib.URL(file, window.location.href);
  1520. var origin = _ref8.origin;
  1521. var protocol = _ref8.protocol;
  1522. // if (origin !== viewerOrigin && protocol !== 'blob:') {
  1523. // throw new Error('file origin does not match viewer\'s');
  1524. // }
  1525. //当我们直接打开base64时,file是个对象,而不是string类型的url,所以此处我们需要判断
  1526. if (file && typeof file =='string') {
  1527. var fileOrigin = new URL(file, window.location.href).origin;
  1528. }
  1529. } catch (ex) {
  1530. var message = ex && ex.message;
  1531. PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.').then(function (loadingErrorMessage) {
  1532. PDFViewerApplication.error(loadingErrorMessage, {
  1533. message: message
  1534. });
  1535. });
  1536. throw ex;
  1537. }
  1538. };
  1539. }
  1540. function loadFakeWorker() {
  1541. if (!_pdfjsLib.GlobalWorkerOptions.workerSrc) {
  1542. _pdfjsLib.GlobalWorkerOptions.workerSrc = _app_options.AppOptions.get('workerSrc');
  1543. }
  1544. return (0, _pdfjsLib.loadScript)(_pdfjsLib.PDFWorker.getWorkerSrc());
  1545. }
  1546. function loadAndEnablePDFBug(enabledTabs) {
  1547. var appConfig = PDFViewerApplication.appConfig;
  1548. return (0, _pdfjsLib.loadScript)(appConfig.debuggerScriptPath).then(function () {
  1549. PDFBug.enable(enabledTabs);
  1550. PDFBug.init({
  1551. OPS: _pdfjsLib.OPS,
  1552. createObjectURL: _pdfjsLib.createObjectURL
  1553. }, appConfig.mainContainer);
  1554. });
  1555. }
  1556. function webViewerInitialized() {
  1557. var appConfig = PDFViewerApplication.appConfig;
  1558. var file;
  1559. var queryString = document.location.search.substring(1);
  1560. var params = (0, _ui_utils.parseQueryString)(queryString);
  1561. file = 'file' in params ? params.file : _app_options.AppOptions.get('defaultUrl');
  1562. validateFileURL(file);
  1563. var fileInput = document.createElement('input');
  1564. fileInput.id = appConfig.openFileInputName;
  1565. fileInput.className = 'fileInput';
  1566. fileInput.setAttribute('type', 'file');
  1567. fileInput.oncontextmenu = _ui_utils.noContextMenuHandler;
  1568. document.body.appendChild(fileInput);
  1569. if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
  1570. appConfig.toolbar.openFile.setAttribute('hidden', 'true');
  1571. appConfig.secondaryToolbar.openFileButton.setAttribute('hidden', 'true');
  1572. } else {
  1573. fileInput.value = null;
  1574. }
  1575. fileInput.addEventListener('change', function (evt) {
  1576. var files = evt.target.files;
  1577. if (!files || files.length === 0) {
  1578. return;
  1579. }
  1580. PDFViewerApplication.eventBus.dispatch('fileinputchange', {
  1581. source: this,
  1582. fileInput: evt.target
  1583. });
  1584. });
  1585. appConfig.mainContainer.addEventListener('dragover', function (evt) {
  1586. evt.preventDefault();
  1587. evt.dataTransfer.dropEffect = 'move';
  1588. });
  1589. appConfig.mainContainer.addEventListener('drop', function (evt) {
  1590. evt.preventDefault();
  1591. var files = evt.dataTransfer.files;
  1592. if (!files || files.length === 0) {
  1593. return;
  1594. }
  1595. PDFViewerApplication.eventBus.dispatch('fileinputchange', {
  1596. source: this,
  1597. fileInput: evt.dataTransfer
  1598. });
  1599. });
  1600. if (!PDFViewerApplication.supportsPrinting) {
  1601. appConfig.toolbar.print.classList.add('hidden');
  1602. appConfig.secondaryToolbar.printButton.classList.add('hidden');
  1603. }
  1604. if (!PDFViewerApplication.supportsFullscreen) {
  1605. appConfig.toolbar.presentationModeButton.classList.add('hidden');
  1606. appConfig.secondaryToolbar.presentationModeButton.classList.add('hidden');
  1607. }
  1608. if (PDFViewerApplication.supportsIntegratedFind) {
  1609. appConfig.toolbar.viewFind.classList.add('hidden');
  1610. }
  1611. appConfig.mainContainer.addEventListener('transitionend', function (evt) {
  1612. if (evt.target === this) {
  1613. PDFViewerApplication.eventBus.dispatch('resize', {
  1614. source: this
  1615. });
  1616. }
  1617. }, true);
  1618. appConfig.sidebar.toggleButton.addEventListener('click', function () {
  1619. PDFViewerApplication.pdfSidebar.toggle();
  1620. });
  1621. try {
  1622. webViewerOpenFileViaURL(file);
  1623. } catch (reason) {
  1624. PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.').then(function (msg) {
  1625. PDFViewerApplication.error(msg, reason);
  1626. });
  1627. }
  1628. }
  1629. var webViewerOpenFileViaURL;
  1630. {
  1631. webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) {
  1632. if (file && typeof file=='string' && file.lastIndexOf('file:', 0) === 0) {
  1633. PDFViewerApplication.setTitleUsingUrl(file);
  1634. var xhr = new XMLHttpRequest();
  1635. xhr.onload = function () {
  1636. PDFViewerApplication.open(new Uint8Array(xhr.response));
  1637. };
  1638. xhr.open('GET', file);
  1639. xhr.responseType = 'arraybuffer';
  1640. xhr.send();
  1641. return;
  1642. }
  1643. if (file) {
  1644. PDFViewerApplication.open(file);
  1645. }
  1646. };
  1647. }
  1648. function webViewerPageRendered(evt) {
  1649. var pageNumber = evt.pageNumber;
  1650. var pageIndex = pageNumber - 1;
  1651. var pageView = PDFViewerApplication.pdfViewer.getPageView(pageIndex);
  1652. if (pageNumber === PDFViewerApplication.page) {
  1653. PDFViewerApplication.toolbar.updateLoadingIndicatorState(false);
  1654. }
  1655. if (!pageView) {
  1656. return;
  1657. }
  1658. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  1659. var thumbnailView = PDFViewerApplication.pdfThumbnailViewer.getThumbnail(pageIndex);
  1660. thumbnailView.setImage(pageView);
  1661. }
  1662. if (typeof Stats !== 'undefined' && Stats.enabled && pageView.stats) {
  1663. Stats.add(pageNumber, pageView.stats);
  1664. }
  1665. if (pageView.error) {
  1666. PDFViewerApplication.l10n.get('rendering_error', null, 'An error occurred while rendering the page.').then(function (msg) {
  1667. PDFViewerApplication.error(msg, pageView.error);
  1668. });
  1669. }
  1670. }
  1671. function webViewerTextLayerRendered(evt) {}
  1672. function webViewerPageMode(evt) {
  1673. var mode = evt.mode,
  1674. view;
  1675. switch (mode) {
  1676. case 'thumbs':
  1677. view = _pdf_sidebar.SidebarView.THUMBS;
  1678. break;
  1679. case 'bookmarks':
  1680. case 'outline':
  1681. view = _pdf_sidebar.SidebarView.OUTLINE;
  1682. break;
  1683. case 'attachments':
  1684. view = _pdf_sidebar.SidebarView.ATTACHMENTS;
  1685. break;
  1686. case 'none':
  1687. view = _pdf_sidebar.SidebarView.NONE;
  1688. break;
  1689. default:
  1690. console.error('Invalid "pagemode" hash parameter: ' + mode);
  1691. return;
  1692. }
  1693. PDFViewerApplication.pdfSidebar.switchView(view, true);
  1694. }
  1695. function webViewerNamedAction(evt) {
  1696. var action = evt.action;
  1697. switch (action) {
  1698. case 'GoToPage':
  1699. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  1700. break;
  1701. case 'Find':
  1702. if (!PDFViewerApplication.supportsIntegratedFind) {
  1703. PDFViewerApplication.findBar.toggle();
  1704. }
  1705. break;
  1706. }
  1707. }
  1708. function webViewerPresentationModeChanged(evt) {
  1709. var active = evt.active,
  1710. switchInProgress = evt.switchInProgress;
  1711. PDFViewerApplication.pdfViewer.presentationModeState = switchInProgress ? _ui_utils.PresentationModeState.CHANGING : active ? _ui_utils.PresentationModeState.FULLSCREEN : _ui_utils.PresentationModeState.NORMAL;
  1712. }
  1713. function webViewerSidebarViewChanged(evt) {
  1714. PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = PDFViewerApplication.pdfSidebar.isThumbnailViewVisible;
  1715. var store = PDFViewerApplication.store;
  1716. if (store && PDFViewerApplication.isInitialViewSet) {
  1717. store.set('sidebarView', evt.view).catch(function () {});
  1718. }
  1719. }
  1720. function webViewerUpdateViewarea(evt) {
  1721. var location = evt.location,
  1722. store = PDFViewerApplication.store;
  1723. if (store && PDFViewerApplication.isInitialViewSet) {
  1724. store.setMultiple({
  1725. 'page': location.pageNumber,
  1726. 'zoom': location.scale,
  1727. 'scrollLeft': location.left,
  1728. 'scrollTop': location.top,
  1729. 'rotation': location.rotation
  1730. }).catch(function () {});
  1731. }
  1732. var href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
  1733. PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href;
  1734. PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
  1735. var currentPage = PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page - 1);
  1736. var loading = currentPage.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED;
  1737. PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading);
  1738. }
  1739. function webViewerScrollModeChanged(evt) {
  1740. var store = PDFViewerApplication.store;
  1741. if (store && PDFViewerApplication.isInitialViewSet) {
  1742. store.set('scrollMode', evt.mode).catch(function () {});
  1743. }
  1744. }
  1745. function webViewerSpreadModeChanged(evt) {
  1746. var store = PDFViewerApplication.store;
  1747. if (store && PDFViewerApplication.isInitialViewSet) {
  1748. store.set('spreadMode', evt.mode).catch(function () {});
  1749. }
  1750. }
  1751. function webViewerResize() {
  1752. var pdfDocument = PDFViewerApplication.pdfDocument,
  1753. pdfViewer = PDFViewerApplication.pdfViewer;
  1754. if (!pdfDocument) {
  1755. return;
  1756. }
  1757. var currentScaleValue = pdfViewer.currentScaleValue;
  1758. if (currentScaleValue === 'auto' || currentScaleValue === 'page-fit' || currentScaleValue === 'page-width') {
  1759. pdfViewer.currentScaleValue = currentScaleValue;
  1760. }
  1761. pdfViewer.update();
  1762. }
  1763. function webViewerHashchange(evt) {
  1764. var hash = evt.hash;
  1765. if (!hash) {
  1766. return;
  1767. }
  1768. if (!PDFViewerApplication.isInitialViewSet) {
  1769. PDFViewerApplication.initialBookmark = hash;
  1770. } else if (!PDFViewerApplication.pdfHistory.popStateInProgress) {
  1771. PDFViewerApplication.pdfLinkService.setHash(hash);
  1772. }
  1773. }
  1774. var webViewerFileInputChange;
  1775. {
  1776. webViewerFileInputChange = function webViewerFileInputChange(evt) {
  1777. if (PDFViewerApplication.pdfViewer && PDFViewerApplication.pdfViewer.isInPresentationMode) {
  1778. return;
  1779. }
  1780. var file = evt.fileInput.files[0];
  1781. if (_pdfjsLib.URL.createObjectURL && !_app_options.AppOptions.get('disableCreateObjectURL')) {
  1782. var url = _pdfjsLib.URL.createObjectURL(file);
  1783. if (file.name) {
  1784. url = {
  1785. url: url,
  1786. originalUrl: file.name
  1787. };
  1788. }
  1789. PDFViewerApplication.open(url);
  1790. } else {
  1791. PDFViewerApplication.setTitleUsingUrl(file.name);
  1792. var fileReader = new FileReader();
  1793. fileReader.onload = function webViewerChangeFileReaderOnload(evt) {
  1794. var buffer = evt.target.result;
  1795. PDFViewerApplication.open(new Uint8Array(buffer));
  1796. };
  1797. fileReader.readAsArrayBuffer(file);
  1798. }
  1799. var appConfig = PDFViewerApplication.appConfig;
  1800. appConfig.toolbar.viewBookmark.setAttribute('hidden', 'true');
  1801. appConfig.secondaryToolbar.viewBookmarkButton.setAttribute('hidden', 'true');
  1802. appConfig.toolbar.download.setAttribute('hidden', 'true');
  1803. appConfig.secondaryToolbar.downloadButton.setAttribute('hidden', 'true');
  1804. };
  1805. }
  1806. function webViewerPresentationMode() {
  1807. PDFViewerApplication.requestPresentationMode();
  1808. }
  1809. function webViewerOpenFile() {
  1810. var openFileInputName = PDFViewerApplication.appConfig.openFileInputName;
  1811. document.getElementById(openFileInputName).click();
  1812. }
  1813. function webViewerPrint() {
  1814. // window.print();
  1815. }
  1816. function webViewerDownload() {
  1817. PDFViewerApplication.download();
  1818. }
  1819. function webViewerFirstPage() {
  1820. if (PDFViewerApplication.pdfDocument) {
  1821. PDFViewerApplication.page = 1;
  1822. }
  1823. }
  1824. function webViewerLastPage() {
  1825. if (PDFViewerApplication.pdfDocument) {
  1826. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  1827. }
  1828. }
  1829. function webViewerNextPage() {
  1830. PDFViewerApplication.page++;
  1831. }
  1832. function webViewerPreviousPage() {
  1833. PDFViewerApplication.page--;
  1834. }
  1835. function webViewerZoomIn() {
  1836. PDFViewerApplication.zoomIn();
  1837. }
  1838. function webViewerZoomOut() {
  1839. PDFViewerApplication.zoomOut();
  1840. }
  1841. function webViewerPageNumberChanged(evt) {
  1842. var pdfViewer = PDFViewerApplication.pdfViewer;
  1843. if (evt.value !== '') {
  1844. pdfViewer.currentPageLabel = evt.value;
  1845. }
  1846. if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) {
  1847. PDFViewerApplication.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
  1848. }
  1849. }
  1850. function webViewerScaleChanged(evt) {
  1851. PDFViewerApplication.pdfViewer.currentScaleValue = evt.value;
  1852. }
  1853. function webViewerRotateCw() {
  1854. PDFViewerApplication.rotatePages(90);
  1855. }
  1856. function webViewerRotateCcw() {
  1857. PDFViewerApplication.rotatePages(-90);
  1858. }
  1859. function webViewerSwitchScrollMode(evt) {
  1860. PDFViewerApplication.pdfViewer.scrollMode = evt.mode;
  1861. }
  1862. function webViewerSwitchSpreadMode(evt) {
  1863. PDFViewerApplication.pdfViewer.spreadMode = evt.mode;
  1864. }
  1865. function webViewerDocumentProperties() {
  1866. PDFViewerApplication.pdfDocumentProperties.open();
  1867. }
  1868. function webViewerFind(evt) {
  1869. PDFViewerApplication.findController.executeCommand('find' + evt.type, {
  1870. query: evt.query,
  1871. phraseSearch: evt.phraseSearch,
  1872. caseSensitive: evt.caseSensitive,
  1873. entireWord: evt.entireWord,
  1874. highlightAll: evt.highlightAll,
  1875. findPrevious: evt.findPrevious
  1876. });
  1877. }
  1878. function webViewerFindFromUrlHash(evt) {
  1879. PDFViewerApplication.findController.executeCommand('find', {
  1880. query: evt.query,
  1881. phraseSearch: evt.phraseSearch,
  1882. caseSensitive: false,
  1883. entireWord: false,
  1884. highlightAll: true,
  1885. findPrevious: false
  1886. });
  1887. }
  1888. function webViewerUpdateFindMatchesCount(_ref9) {
  1889. var matchesCount = _ref9.matchesCount;
  1890. if (PDFViewerApplication.supportsIntegratedFind) {
  1891. PDFViewerApplication.externalServices.updateFindMatchesCount(matchesCount);
  1892. } else {
  1893. PDFViewerApplication.findBar.updateResultsCount(matchesCount);
  1894. }
  1895. }
  1896. function webViewerUpdateFindControlState(_ref10) {
  1897. var state = _ref10.state,
  1898. previous = _ref10.previous,
  1899. matchesCount = _ref10.matchesCount;
  1900. if (PDFViewerApplication.supportsIntegratedFind) {
  1901. PDFViewerApplication.externalServices.updateFindControlState({
  1902. result: state,
  1903. findPrevious: previous,
  1904. matchesCount: matchesCount
  1905. });
  1906. } else {
  1907. PDFViewerApplication.findBar.updateUIState(state, previous, matchesCount);
  1908. }
  1909. }
  1910. function webViewerScaleChanging(evt) {
  1911. PDFViewerApplication.toolbar.setPageScale(evt.presetValue, evt.scale);
  1912. PDFViewerApplication.pdfViewer.update();
  1913. }
  1914. function webViewerRotationChanging(evt) {
  1915. PDFViewerApplication.pdfThumbnailViewer.pagesRotation = evt.pagesRotation;
  1916. PDFViewerApplication.forceRendering();
  1917. PDFViewerApplication.pdfViewer.currentPageNumber = evt.pageNumber;
  1918. }
  1919. function webViewerPageChanging(evt) {
  1920. var page = evt.pageNumber;
  1921. PDFViewerApplication.toolbar.setPageNumber(page, evt.pageLabel || null);
  1922. PDFViewerApplication.secondaryToolbar.setPageNumber(page);
  1923. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  1924. PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(page);
  1925. }
  1926. if (typeof Stats !== 'undefined' && Stats.enabled) {
  1927. var pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1);
  1928. if (pageView && pageView.stats) {
  1929. Stats.add(page, pageView.stats);
  1930. }
  1931. }
  1932. }
  1933. function webViewerVisibilityChange(evt) {
  1934. if (document.visibilityState === 'visible') {
  1935. setZoomDisabledTimeout();
  1936. }
  1937. }
  1938. var zoomDisabledTimeout = null;
  1939. function setZoomDisabledTimeout() {
  1940. if (zoomDisabledTimeout) {
  1941. clearTimeout(zoomDisabledTimeout);
  1942. }
  1943. zoomDisabledTimeout = setTimeout(function () {
  1944. zoomDisabledTimeout = null;
  1945. }, WHEEL_ZOOM_DISABLED_TIMEOUT);
  1946. }
  1947. function webViewerWheel(evt) {
  1948. var pdfViewer = PDFViewerApplication.pdfViewer;
  1949. if (pdfViewer.isInPresentationMode) {
  1950. return;
  1951. }
  1952. if (evt.ctrlKey || evt.metaKey) {
  1953. var support = PDFViewerApplication.supportedMouseWheelZoomModifierKeys;
  1954. if (evt.ctrlKey && !support.ctrlKey || evt.metaKey && !support.metaKey) {
  1955. return;
  1956. }
  1957. evt.preventDefault();
  1958. if (zoomDisabledTimeout || document.visibilityState === 'hidden') {
  1959. return;
  1960. }
  1961. var previousScale = pdfViewer.currentScale;
  1962. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  1963. var MOUSE_WHEEL_DELTA_PER_PAGE_SCALE = 3.0;
  1964. var ticks = delta * MOUSE_WHEEL_DELTA_PER_PAGE_SCALE;
  1965. if (ticks < 0) {
  1966. PDFViewerApplication.zoomOut(-ticks);
  1967. } else {
  1968. PDFViewerApplication.zoomIn(ticks);
  1969. }
  1970. var currentScale = pdfViewer.currentScale;
  1971. if (previousScale !== currentScale) {
  1972. var scaleCorrectionFactor = currentScale / previousScale - 1;
  1973. var rect = pdfViewer.container.getBoundingClientRect();
  1974. var dx = evt.clientX - rect.left;
  1975. var dy = evt.clientY - rect.top;
  1976. pdfViewer.container.scrollLeft += dx * scaleCorrectionFactor;
  1977. pdfViewer.container.scrollTop += dy * scaleCorrectionFactor;
  1978. }
  1979. } else {
  1980. setZoomDisabledTimeout();
  1981. }
  1982. }
  1983. function webViewerClick(evt) {
  1984. if (!PDFViewerApplication.secondaryToolbar.isOpen) {
  1985. return;
  1986. }
  1987. var appConfig = PDFViewerApplication.appConfig;
  1988. if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar.container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar.toggleButton) {
  1989. PDFViewerApplication.secondaryToolbar.close();
  1990. }
  1991. }
  1992. function webViewerKeyDown(evt) {
  1993. if (PDFViewerApplication.overlayManager.active) {
  1994. return;
  1995. }
  1996. var handled = false,
  1997. ensureViewerFocused = false;
  1998. var cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0);
  1999. var pdfViewer = PDFViewerApplication.pdfViewer;
  2000. var isViewerInPresentationMode = pdfViewer && pdfViewer.isInPresentationMode;
  2001. if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
  2002. switch (evt.keyCode) {
  2003. case 70:
  2004. if (!PDFViewerApplication.supportsIntegratedFind) {
  2005. PDFViewerApplication.findBar.open();
  2006. handled = true;
  2007. }
  2008. break;
  2009. case 71:
  2010. if (!PDFViewerApplication.supportsIntegratedFind) {
  2011. var findState = PDFViewerApplication.findController.state;
  2012. if (findState) {
  2013. PDFViewerApplication.findController.executeCommand('findagain', {
  2014. query: findState.query,
  2015. phraseSearch: findState.phraseSearch,
  2016. caseSensitive: findState.caseSensitive,
  2017. entireWord: findState.entireWord,
  2018. highlightAll: findState.highlightAll,
  2019. findPrevious: cmd === 5 || cmd === 12
  2020. });
  2021. }
  2022. handled = true;
  2023. }
  2024. break;
  2025. case 61:
  2026. case 107:
  2027. case 187:
  2028. case 171:
  2029. if (!isViewerInPresentationMode) {
  2030. PDFViewerApplication.zoomIn();
  2031. }
  2032. handled = true;
  2033. break;
  2034. case 173:
  2035. case 109:
  2036. case 189:
  2037. if (!isViewerInPresentationMode) {
  2038. PDFViewerApplication.zoomOut();
  2039. }
  2040. handled = true;
  2041. break;
  2042. case 48:
  2043. case 96:
  2044. if (!isViewerInPresentationMode) {
  2045. setTimeout(function () {
  2046. pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  2047. });
  2048. handled = false;
  2049. }
  2050. break;
  2051. case 38:
  2052. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  2053. PDFViewerApplication.page = 1;
  2054. handled = true;
  2055. ensureViewerFocused = true;
  2056. }
  2057. break;
  2058. case 40:
  2059. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2060. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2061. handled = true;
  2062. ensureViewerFocused = true;
  2063. }
  2064. break;
  2065. }
  2066. }
  2067. if (cmd === 1 || cmd === 8) {
  2068. switch (evt.keyCode) {
  2069. case 83:
  2070. PDFViewerApplication.download();
  2071. handled = true;
  2072. break;
  2073. }
  2074. }
  2075. if (cmd === 3 || cmd === 10) {
  2076. switch (evt.keyCode) {
  2077. case 80:
  2078. PDFViewerApplication.requestPresentationMode();
  2079. handled = true;
  2080. break;
  2081. case 71:
  2082. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  2083. handled = true;
  2084. break;
  2085. }
  2086. }
  2087. if (handled) {
  2088. if (ensureViewerFocused && !isViewerInPresentationMode) {
  2089. pdfViewer.focus();
  2090. }
  2091. evt.preventDefault();
  2092. return;
  2093. }
  2094. var curElement = document.activeElement || document.querySelector(':focus');
  2095. var curElementTagName = curElement && curElement.tagName.toUpperCase();
  2096. if (curElementTagName === 'INPUT' || curElementTagName === 'TEXTAREA' || curElementTagName === 'SELECT') {
  2097. if (evt.keyCode !== 27) {
  2098. return;
  2099. }
  2100. }
  2101. if (cmd === 0) {
  2102. var turnPage = 0,
  2103. turnOnlyIfPageFit = false;
  2104. switch (evt.keyCode) {
  2105. case 38:
  2106. case 33:
  2107. if (pdfViewer.isVerticalScrollbarEnabled) {
  2108. turnOnlyIfPageFit = true;
  2109. }
  2110. turnPage = -1;
  2111. break;
  2112. case 8:
  2113. if (!isViewerInPresentationMode) {
  2114. turnOnlyIfPageFit = true;
  2115. }
  2116. turnPage = -1;
  2117. break;
  2118. case 37:
  2119. if (pdfViewer.isHorizontalScrollbarEnabled) {
  2120. turnOnlyIfPageFit = true;
  2121. }
  2122. case 75:
  2123. case 80:
  2124. turnPage = -1;
  2125. break;
  2126. case 27:
  2127. if (PDFViewerApplication.secondaryToolbar.isOpen) {
  2128. PDFViewerApplication.secondaryToolbar.close();
  2129. handled = true;
  2130. }
  2131. if (!PDFViewerApplication.supportsIntegratedFind && PDFViewerApplication.findBar.opened) {
  2132. PDFViewerApplication.findBar.close();
  2133. handled = true;
  2134. }
  2135. break;
  2136. case 40:
  2137. case 34:
  2138. if (pdfViewer.isVerticalScrollbarEnabled) {
  2139. turnOnlyIfPageFit = true;
  2140. }
  2141. turnPage = 1;
  2142. break;
  2143. case 13:
  2144. case 32:
  2145. if (!isViewerInPresentationMode) {
  2146. turnOnlyIfPageFit = true;
  2147. }
  2148. turnPage = 1;
  2149. break;
  2150. case 39:
  2151. if (pdfViewer.isHorizontalScrollbarEnabled) {
  2152. turnOnlyIfPageFit = true;
  2153. }
  2154. case 74:
  2155. case 78:
  2156. turnPage = 1;
  2157. break;
  2158. case 36:
  2159. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  2160. PDFViewerApplication.page = 1;
  2161. handled = true;
  2162. ensureViewerFocused = true;
  2163. }
  2164. break;
  2165. case 35:
  2166. if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2167. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  2168. handled = true;
  2169. ensureViewerFocused = true;
  2170. }
  2171. break;
  2172. case 83:
  2173. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.SELECT);
  2174. break;
  2175. case 72:
  2176. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.HAND);
  2177. break;
  2178. case 82:
  2179. PDFViewerApplication.rotatePages(90);
  2180. break;
  2181. case 115:
  2182. PDFViewerApplication.pdfSidebar.toggle();
  2183. break;
  2184. }
  2185. if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === 'page-fit')) {
  2186. if (turnPage > 0) {
  2187. if (PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
  2188. PDFViewerApplication.page++;
  2189. }
  2190. } else {
  2191. if (PDFViewerApplication.page > 1) {
  2192. PDFViewerApplication.page--;
  2193. }
  2194. }
  2195. handled = true;
  2196. }
  2197. }
  2198. if (cmd === 4) {
  2199. switch (evt.keyCode) {
  2200. case 13:
  2201. case 32:
  2202. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== 'page-fit') {
  2203. break;
  2204. }
  2205. if (PDFViewerApplication.page > 1) {
  2206. PDFViewerApplication.page--;
  2207. }
  2208. handled = true;
  2209. break;
  2210. case 82:
  2211. PDFViewerApplication.rotatePages(-90);
  2212. break;
  2213. }
  2214. }
  2215. if (!handled && !isViewerInPresentationMode) {
  2216. if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !== 'BUTTON') {
  2217. ensureViewerFocused = true;
  2218. }
  2219. }
  2220. if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
  2221. pdfViewer.focus();
  2222. }
  2223. if (handled) {
  2224. evt.preventDefault();
  2225. }
  2226. }
  2227. function apiPageModeToSidebarView(mode) {
  2228. switch (mode) {
  2229. case 'UseNone':
  2230. return _pdf_sidebar.SidebarView.NONE;
  2231. case 'UseThumbs':
  2232. return _pdf_sidebar.SidebarView.THUMBS;
  2233. case 'UseOutlines':
  2234. return _pdf_sidebar.SidebarView.OUTLINE;
  2235. case 'UseAttachments':
  2236. return _pdf_sidebar.SidebarView.ATTACHMENTS;
  2237. case 'UseOC':
  2238. }
  2239. return _pdf_sidebar.SidebarView.NONE;
  2240. }
  2241. var PDFPrintServiceFactory = {
  2242. instance: {
  2243. supportsPrinting: false,
  2244. createPrintService: function createPrintService() {
  2245. throw new Error('Not implemented: createPrintService');
  2246. }
  2247. }
  2248. };
  2249. exports.PDFPrintServiceFactory = PDFPrintServiceFactory;
  2250. /***/ }),
  2251. /* 2 */
  2252. /***/ (function(module, exports, __webpack_require__) {
  2253. "use strict";
  2254. module.exports = __webpack_require__(3);
  2255. /***/ }),
  2256. /* 3 */
  2257. /***/ (function(module, exports, __webpack_require__) {
  2258. "use strict";
  2259. function _typeof(obj) { 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); }
  2260. var g = function () {
  2261. return this || (typeof self === "undefined" ? "undefined" : _typeof(self)) === "object" && self;
  2262. }() || Function("return this")();
  2263. var hadRuntime = g.regeneratorRuntime && Object.getOwnPropertyNames(g).indexOf("regeneratorRuntime") >= 0;
  2264. var oldRuntime = hadRuntime && g.regeneratorRuntime;
  2265. g.regeneratorRuntime = undefined;
  2266. module.exports = __webpack_require__(4);
  2267. if (hadRuntime) {
  2268. g.regeneratorRuntime = oldRuntime;
  2269. } else {
  2270. try {
  2271. delete g.regeneratorRuntime;
  2272. } catch (e) {
  2273. g.regeneratorRuntime = undefined;
  2274. }
  2275. }
  2276. /***/ }),
  2277. /* 4 */
  2278. /***/ (function(module, exports, __webpack_require__) {
  2279. "use strict";
  2280. /* WEBPACK VAR INJECTION */(function(module) {
  2281. function _typeof(obj) { 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); }
  2282. !function (global) {
  2283. "use strict";
  2284. var Op = Object.prototype;
  2285. var hasOwn = Op.hasOwnProperty;
  2286. var undefined;
  2287. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  2288. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  2289. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  2290. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  2291. var inModule = ( false ? undefined : _typeof(module)) === "object";
  2292. var runtime = global.regeneratorRuntime;
  2293. if (runtime) {
  2294. if (inModule) {
  2295. module.exports = runtime;
  2296. }
  2297. return;
  2298. }
  2299. runtime = global.regeneratorRuntime = inModule ? module.exports : {};
  2300. function wrap(innerFn, outerFn, self, tryLocsList) {
  2301. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  2302. var generator = Object.create(protoGenerator.prototype);
  2303. var context = new Context(tryLocsList || []);
  2304. generator._invoke = makeInvokeMethod(innerFn, self, context);
  2305. return generator;
  2306. }
  2307. runtime.wrap = wrap;
  2308. function tryCatch(fn, obj, arg) {
  2309. try {
  2310. return {
  2311. type: "normal",
  2312. arg: fn.call(obj, arg)
  2313. };
  2314. } catch (err) {
  2315. return {
  2316. type: "throw",
  2317. arg: err
  2318. };
  2319. }
  2320. }
  2321. var GenStateSuspendedStart = "suspendedStart";
  2322. var GenStateSuspendedYield = "suspendedYield";
  2323. var GenStateExecuting = "executing";
  2324. var GenStateCompleted = "completed";
  2325. var ContinueSentinel = {};
  2326. function Generator() {}
  2327. function GeneratorFunction() {}
  2328. function GeneratorFunctionPrototype() {}
  2329. var IteratorPrototype = {};
  2330. IteratorPrototype[iteratorSymbol] = function () {
  2331. return this;
  2332. };
  2333. var getProto = Object.getPrototypeOf;
  2334. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  2335. if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  2336. IteratorPrototype = NativeIteratorPrototype;
  2337. }
  2338. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
  2339. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  2340. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  2341. GeneratorFunctionPrototype[toStringTagSymbol] = GeneratorFunction.displayName = "GeneratorFunction";
  2342. function defineIteratorMethods(prototype) {
  2343. ["next", "throw", "return"].forEach(function (method) {
  2344. prototype[method] = function (arg) {
  2345. return this._invoke(method, arg);
  2346. };
  2347. });
  2348. }
  2349. runtime.isGeneratorFunction = function (genFun) {
  2350. var ctor = typeof genFun === "function" && genFun.constructor;
  2351. return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
  2352. };
  2353. runtime.mark = function (genFun) {
  2354. if (Object.setPrototypeOf) {
  2355. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  2356. } else {
  2357. genFun.__proto__ = GeneratorFunctionPrototype;
  2358. if (!(toStringTagSymbol in genFun)) {
  2359. genFun[toStringTagSymbol] = "GeneratorFunction";
  2360. }
  2361. }
  2362. genFun.prototype = Object.create(Gp);
  2363. return genFun;
  2364. };
  2365. runtime.awrap = function (arg) {
  2366. return {
  2367. __await: arg
  2368. };
  2369. };
  2370. function AsyncIterator(generator) {
  2371. function invoke(method, arg, resolve, reject) {
  2372. var record = tryCatch(generator[method], generator, arg);
  2373. if (record.type === "throw") {
  2374. reject(record.arg);
  2375. } else {
  2376. var result = record.arg;
  2377. var value = result.value;
  2378. if (value && _typeof(value) === "object" && hasOwn.call(value, "__await")) {
  2379. return Promise.resolve(value.__await).then(function (value) {
  2380. invoke("next", value, resolve, reject);
  2381. }, function (err) {
  2382. invoke("throw", err, resolve, reject);
  2383. });
  2384. }
  2385. return Promise.resolve(value).then(function (unwrapped) {
  2386. result.value = unwrapped;
  2387. resolve(result);
  2388. }, function (error) {
  2389. return invoke("throw", error, resolve, reject);
  2390. });
  2391. }
  2392. }
  2393. var previousPromise;
  2394. function enqueue(method, arg) {
  2395. function callInvokeWithMethodAndArg() {
  2396. return new Promise(function (resolve, reject) {
  2397. invoke(method, arg, resolve, reject);
  2398. });
  2399. }
  2400. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  2401. }
  2402. this._invoke = enqueue;
  2403. }
  2404. defineIteratorMethods(AsyncIterator.prototype);
  2405. AsyncIterator.prototype[asyncIteratorSymbol] = function () {
  2406. return this;
  2407. };
  2408. runtime.AsyncIterator = AsyncIterator;
  2409. runtime.async = function (innerFn, outerFn, self, tryLocsList) {
  2410. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList));
  2411. return runtime.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  2412. return result.done ? result.value : iter.next();
  2413. });
  2414. };
  2415. function makeInvokeMethod(innerFn, self, context) {
  2416. var state = GenStateSuspendedStart;
  2417. return function invoke(method, arg) {
  2418. if (state === GenStateExecuting) {
  2419. throw new Error("Generator is already running");
  2420. }
  2421. if (state === GenStateCompleted) {
  2422. if (method === "throw") {
  2423. throw arg;
  2424. }
  2425. return doneResult();
  2426. }
  2427. context.method = method;
  2428. context.arg = arg;
  2429. while (true) {
  2430. var delegate = context.delegate;
  2431. if (delegate) {
  2432. var delegateResult = maybeInvokeDelegate(delegate, context);
  2433. if (delegateResult) {
  2434. if (delegateResult === ContinueSentinel) continue;
  2435. return delegateResult;
  2436. }
  2437. }
  2438. if (context.method === "next") {
  2439. context.sent = context._sent = context.arg;
  2440. } else if (context.method === "throw") {
  2441. if (state === GenStateSuspendedStart) {
  2442. state = GenStateCompleted;
  2443. throw context.arg;
  2444. }
  2445. context.dispatchException(context.arg);
  2446. } else if (context.method === "return") {
  2447. context.abrupt("return", context.arg);
  2448. }
  2449. state = GenStateExecuting;
  2450. var record = tryCatch(innerFn, self, context);
  2451. if (record.type === "normal") {
  2452. state = context.done ? GenStateCompleted : GenStateSuspendedYield;
  2453. if (record.arg === ContinueSentinel) {
  2454. continue;
  2455. }
  2456. return {
  2457. value: record.arg,
  2458. done: context.done
  2459. };
  2460. } else if (record.type === "throw") {
  2461. state = GenStateCompleted;
  2462. context.method = "throw";
  2463. context.arg = record.arg;
  2464. }
  2465. }
  2466. };
  2467. }
  2468. function maybeInvokeDelegate(delegate, context) {
  2469. var method = delegate.iterator[context.method];
  2470. if (method === undefined) {
  2471. context.delegate = null;
  2472. if (context.method === "throw") {
  2473. if (delegate.iterator.return) {
  2474. context.method = "return";
  2475. context.arg = undefined;
  2476. maybeInvokeDelegate(delegate, context);
  2477. if (context.method === "throw") {
  2478. return ContinueSentinel;
  2479. }
  2480. }
  2481. context.method = "throw";
  2482. context.arg = new TypeError("The iterator does not provide a 'throw' method");
  2483. }
  2484. return ContinueSentinel;
  2485. }
  2486. var record = tryCatch(method, delegate.iterator, context.arg);
  2487. if (record.type === "throw") {
  2488. context.method = "throw";
  2489. context.arg = record.arg;
  2490. context.delegate = null;
  2491. return ContinueSentinel;
  2492. }
  2493. var info = record.arg;
  2494. if (!info) {
  2495. context.method = "throw";
  2496. context.arg = new TypeError("iterator result is not an object");
  2497. context.delegate = null;
  2498. return ContinueSentinel;
  2499. }
  2500. if (info.done) {
  2501. context[delegate.resultName] = info.value;
  2502. context.next = delegate.nextLoc;
  2503. if (context.method !== "return") {
  2504. context.method = "next";
  2505. context.arg = undefined;
  2506. }
  2507. } else {
  2508. return info;
  2509. }
  2510. context.delegate = null;
  2511. return ContinueSentinel;
  2512. }
  2513. defineIteratorMethods(Gp);
  2514. Gp[toStringTagSymbol] = "Generator";
  2515. Gp[iteratorSymbol] = function () {
  2516. return this;
  2517. };
  2518. Gp.toString = function () {
  2519. return "[object Generator]";
  2520. };
  2521. function pushTryEntry(locs) {
  2522. var entry = {
  2523. tryLoc: locs[0]
  2524. };
  2525. if (1 in locs) {
  2526. entry.catchLoc = locs[1];
  2527. }
  2528. if (2 in locs) {
  2529. entry.finallyLoc = locs[2];
  2530. entry.afterLoc = locs[3];
  2531. }
  2532. this.tryEntries.push(entry);
  2533. }
  2534. function resetTryEntry(entry) {
  2535. var record = entry.completion || {};
  2536. record.type = "normal";
  2537. delete record.arg;
  2538. entry.completion = record;
  2539. }
  2540. function Context(tryLocsList) {
  2541. this.tryEntries = [{
  2542. tryLoc: "root"
  2543. }];
  2544. tryLocsList.forEach(pushTryEntry, this);
  2545. this.reset(true);
  2546. }
  2547. runtime.keys = function (object) {
  2548. var keys = [];
  2549. for (var key in object) {
  2550. keys.push(key);
  2551. }
  2552. keys.reverse();
  2553. return function next() {
  2554. while (keys.length) {
  2555. var key = keys.pop();
  2556. if (key in object) {
  2557. next.value = key;
  2558. next.done = false;
  2559. return next;
  2560. }
  2561. }
  2562. next.done = true;
  2563. return next;
  2564. };
  2565. };
  2566. function values(iterable) {
  2567. if (iterable) {
  2568. var iteratorMethod = iterable[iteratorSymbol];
  2569. if (iteratorMethod) {
  2570. return iteratorMethod.call(iterable);
  2571. }
  2572. if (typeof iterable.next === "function") {
  2573. return iterable;
  2574. }
  2575. if (!isNaN(iterable.length)) {
  2576. var i = -1,
  2577. next = function next() {
  2578. while (++i < iterable.length) {
  2579. if (hasOwn.call(iterable, i)) {
  2580. next.value = iterable[i];
  2581. next.done = false;
  2582. return next;
  2583. }
  2584. }
  2585. next.value = undefined;
  2586. next.done = true;
  2587. return next;
  2588. };
  2589. return next.next = next;
  2590. }
  2591. }
  2592. return {
  2593. next: doneResult
  2594. };
  2595. }
  2596. runtime.values = values;
  2597. function doneResult() {
  2598. return {
  2599. value: undefined,
  2600. done: true
  2601. };
  2602. }
  2603. Context.prototype = {
  2604. constructor: Context,
  2605. reset: function reset(skipTempReset) {
  2606. this.prev = 0;
  2607. this.next = 0;
  2608. this.sent = this._sent = undefined;
  2609. this.done = false;
  2610. this.delegate = null;
  2611. this.method = "next";
  2612. this.arg = undefined;
  2613. this.tryEntries.forEach(resetTryEntry);
  2614. if (!skipTempReset) {
  2615. for (var name in this) {
  2616. if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
  2617. this[name] = undefined;
  2618. }
  2619. }
  2620. }
  2621. },
  2622. stop: function stop() {
  2623. this.done = true;
  2624. var rootEntry = this.tryEntries[0];
  2625. var rootRecord = rootEntry.completion;
  2626. if (rootRecord.type === "throw") {
  2627. throw rootRecord.arg;
  2628. }
  2629. return this.rval;
  2630. },
  2631. dispatchException: function dispatchException(exception) {
  2632. if (this.done) {
  2633. throw exception;
  2634. }
  2635. var context = this;
  2636. function handle(loc, caught) {
  2637. record.type = "throw";
  2638. record.arg = exception;
  2639. context.next = loc;
  2640. if (caught) {
  2641. context.method = "next";
  2642. context.arg = undefined;
  2643. }
  2644. return !!caught;
  2645. }
  2646. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  2647. var entry = this.tryEntries[i];
  2648. var record = entry.completion;
  2649. if (entry.tryLoc === "root") {
  2650. return handle("end");
  2651. }
  2652. if (entry.tryLoc <= this.prev) {
  2653. var hasCatch = hasOwn.call(entry, "catchLoc");
  2654. var hasFinally = hasOwn.call(entry, "finallyLoc");
  2655. if (hasCatch && hasFinally) {
  2656. if (this.prev < entry.catchLoc) {
  2657. return handle(entry.catchLoc, true);
  2658. } else if (this.prev < entry.finallyLoc) {
  2659. return handle(entry.finallyLoc);
  2660. }
  2661. } else if (hasCatch) {
  2662. if (this.prev < entry.catchLoc) {
  2663. return handle(entry.catchLoc, true);
  2664. }
  2665. } else if (hasFinally) {
  2666. if (this.prev < entry.finallyLoc) {
  2667. return handle(entry.finallyLoc);
  2668. }
  2669. } else {
  2670. throw new Error("try statement without catch or finally");
  2671. }
  2672. }
  2673. }
  2674. },
  2675. abrupt: function abrupt(type, arg) {
  2676. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  2677. var entry = this.tryEntries[i];
  2678. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  2679. var finallyEntry = entry;
  2680. break;
  2681. }
  2682. }
  2683. if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
  2684. finallyEntry = null;
  2685. }
  2686. var record = finallyEntry ? finallyEntry.completion : {};
  2687. record.type = type;
  2688. record.arg = arg;
  2689. if (finallyEntry) {
  2690. this.method = "next";
  2691. this.next = finallyEntry.finallyLoc;
  2692. return ContinueSentinel;
  2693. }
  2694. return this.complete(record);
  2695. },
  2696. complete: function complete(record, afterLoc) {
  2697. if (record.type === "throw") {
  2698. throw record.arg;
  2699. }
  2700. if (record.type === "break" || record.type === "continue") {
  2701. this.next = record.arg;
  2702. } else if (record.type === "return") {
  2703. this.rval = this.arg = record.arg;
  2704. this.method = "return";
  2705. this.next = "end";
  2706. } else if (record.type === "normal" && afterLoc) {
  2707. this.next = afterLoc;
  2708. }
  2709. return ContinueSentinel;
  2710. },
  2711. finish: function finish(finallyLoc) {
  2712. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  2713. var entry = this.tryEntries[i];
  2714. if (entry.finallyLoc === finallyLoc) {
  2715. this.complete(entry.completion, entry.afterLoc);
  2716. resetTryEntry(entry);
  2717. return ContinueSentinel;
  2718. }
  2719. }
  2720. },
  2721. "catch": function _catch(tryLoc) {
  2722. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  2723. var entry = this.tryEntries[i];
  2724. if (entry.tryLoc === tryLoc) {
  2725. var record = entry.completion;
  2726. if (record.type === "throw") {
  2727. var thrown = record.arg;
  2728. resetTryEntry(entry);
  2729. }
  2730. return thrown;
  2731. }
  2732. }
  2733. throw new Error("illegal catch attempt");
  2734. },
  2735. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  2736. this.delegate = {
  2737. iterator: values(iterable),
  2738. resultName: resultName,
  2739. nextLoc: nextLoc
  2740. };
  2741. if (this.method === "next") {
  2742. this.arg = undefined;
  2743. }
  2744. return ContinueSentinel;
  2745. }
  2746. };
  2747. }(function () {
  2748. return this || (typeof self === "undefined" ? "undefined" : _typeof(self)) === "object" && self;
  2749. }() || Function("return this")());
  2750. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(5)(module)))
  2751. /***/ }),
  2752. /* 5 */
  2753. /***/ (function(module, exports, __webpack_require__) {
  2754. "use strict";
  2755. module.exports = function (module) {
  2756. if (!module.webpackPolyfill) {
  2757. module.deprecate = function () {};
  2758. module.paths = [];
  2759. if (!module.children) module.children = [];
  2760. Object.defineProperty(module, "loaded", {
  2761. enumerable: true,
  2762. get: function get() {
  2763. return module.l;
  2764. }
  2765. });
  2766. Object.defineProperty(module, "id", {
  2767. enumerable: true,
  2768. get: function get() {
  2769. return module.i;
  2770. }
  2771. });
  2772. module.webpackPolyfill = 1;
  2773. }
  2774. return module;
  2775. };
  2776. /***/ }),
  2777. /* 6 */
  2778. /***/ (function(module, exports, __webpack_require__) {
  2779. "use strict";
  2780. Object.defineProperty(exports, "__esModule", {
  2781. value: true
  2782. });
  2783. exports.isValidRotation = isValidRotation;
  2784. exports.isValidScrollMode = isValidScrollMode;
  2785. exports.isValidSpreadMode = isValidSpreadMode;
  2786. exports.isPortraitOrientation = isPortraitOrientation;
  2787. exports.getGlobalEventBus = getGlobalEventBus;
  2788. exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
  2789. exports.noContextMenuHandler = noContextMenuHandler;
  2790. exports.parseQueryString = parseQueryString;
  2791. exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
  2792. exports.getVisibleElements = getVisibleElements;
  2793. exports.roundToDivide = roundToDivide;
  2794. exports.getPageSizeInches = getPageSizeInches;
  2795. exports.approximateFraction = approximateFraction;
  2796. exports.getOutputScale = getOutputScale;
  2797. exports.scrollIntoView = scrollIntoView;
  2798. exports.watchScroll = watchScroll;
  2799. exports.binarySearchFirstItem = binarySearchFirstItem;
  2800. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  2801. exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
  2802. exports.moveToEndOfArray = moveToEndOfArray;
  2803. 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 = void 0;
  2804. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  2805. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2806. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2807. 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); } }
  2808. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  2809. function _typeof(obj) { 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); }
  2810. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
  2811. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
  2812. function _iterableToArrayLimit(arr, i) { 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; }
  2813. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  2814. 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); } }
  2815. 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); }); }; }
  2816. var CSS_UNITS = 96.0 / 72.0;
  2817. exports.CSS_UNITS = CSS_UNITS;
  2818. var DEFAULT_SCALE_VALUE = 'auto';
  2819. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  2820. var DEFAULT_SCALE = 1.0;
  2821. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  2822. var MIN_SCALE = 0.10;
  2823. exports.MIN_SCALE = MIN_SCALE;
  2824. var MAX_SCALE = 10.0;
  2825. exports.MAX_SCALE = MAX_SCALE;
  2826. var UNKNOWN_SCALE = 0;
  2827. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  2828. var MAX_AUTO_SCALE = 1.25;
  2829. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  2830. var SCROLLBAR_PADDING = 40;
  2831. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  2832. var VERTICAL_PADDING = 5;
  2833. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  2834. var PresentationModeState = {
  2835. UNKNOWN: 0,
  2836. NORMAL: 1,
  2837. CHANGING: 2,
  2838. FULLSCREEN: 3
  2839. };
  2840. exports.PresentationModeState = PresentationModeState;
  2841. var RendererType = {
  2842. CANVAS: 'canvas',
  2843. SVG: 'svg'
  2844. };
  2845. exports.RendererType = RendererType;
  2846. var TextLayerMode = {
  2847. DISABLE: 0,
  2848. ENABLE: 1,
  2849. ENABLE_ENHANCE: 2
  2850. };
  2851. exports.TextLayerMode = TextLayerMode;
  2852. var ScrollMode = {
  2853. UNKNOWN: -1,
  2854. VERTICAL: 0,
  2855. HORIZONTAL: 1,
  2856. WRAPPED: 2
  2857. };
  2858. exports.ScrollMode = ScrollMode;
  2859. var SpreadMode = {
  2860. UNKNOWN: -1,
  2861. NONE: 0,
  2862. ODD: 1,
  2863. EVEN: 2
  2864. };
  2865. exports.SpreadMode = SpreadMode;
  2866. function formatL10nValue(text, args) {
  2867. if (!args) {
  2868. return text;
  2869. }
  2870. return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function (all, name) {
  2871. return name in args ? args[name] : '{{' + name + '}}';
  2872. });
  2873. }
  2874. var NullL10n = {
  2875. getLanguage: function () {
  2876. var _getLanguage = _asyncToGenerator(
  2877. /*#__PURE__*/
  2878. _regenerator.default.mark(function _callee() {
  2879. return _regenerator.default.wrap(function _callee$(_context) {
  2880. while (1) {
  2881. switch (_context.prev = _context.next) {
  2882. case 0:
  2883. return _context.abrupt("return", 'en-us');
  2884. case 1:
  2885. case "end":
  2886. return _context.stop();
  2887. }
  2888. }
  2889. }, _callee, this);
  2890. }));
  2891. function getLanguage() {
  2892. return _getLanguage.apply(this, arguments);
  2893. }
  2894. return getLanguage;
  2895. }(),
  2896. getDirection: function () {
  2897. var _getDirection = _asyncToGenerator(
  2898. /*#__PURE__*/
  2899. _regenerator.default.mark(function _callee2() {
  2900. return _regenerator.default.wrap(function _callee2$(_context2) {
  2901. while (1) {
  2902. switch (_context2.prev = _context2.next) {
  2903. case 0:
  2904. return _context2.abrupt("return", 'ltr');
  2905. case 1:
  2906. case "end":
  2907. return _context2.stop();
  2908. }
  2909. }
  2910. }, _callee2, this);
  2911. }));
  2912. function getDirection() {
  2913. return _getDirection.apply(this, arguments);
  2914. }
  2915. return getDirection;
  2916. }(),
  2917. get: function () {
  2918. var _get = _asyncToGenerator(
  2919. /*#__PURE__*/
  2920. _regenerator.default.mark(function _callee3(property, args, fallback) {
  2921. return _regenerator.default.wrap(function _callee3$(_context3) {
  2922. while (1) {
  2923. switch (_context3.prev = _context3.next) {
  2924. case 0:
  2925. return _context3.abrupt("return", formatL10nValue(fallback, args));
  2926. case 1:
  2927. case "end":
  2928. return _context3.stop();
  2929. }
  2930. }
  2931. }, _callee3, this);
  2932. }));
  2933. function get(_x, _x2, _x3) {
  2934. return _get.apply(this, arguments);
  2935. }
  2936. return get;
  2937. }(),
  2938. translate: function () {
  2939. var _translate = _asyncToGenerator(
  2940. /*#__PURE__*/
  2941. _regenerator.default.mark(function _callee4(element) {
  2942. return _regenerator.default.wrap(function _callee4$(_context4) {
  2943. while (1) {
  2944. switch (_context4.prev = _context4.next) {
  2945. case 0:
  2946. case "end":
  2947. return _context4.stop();
  2948. }
  2949. }
  2950. }, _callee4, this);
  2951. }));
  2952. function translate(_x4) {
  2953. return _translate.apply(this, arguments);
  2954. }
  2955. return translate;
  2956. }()
  2957. };
  2958. exports.NullL10n = NullL10n;
  2959. function getOutputScale(ctx) {
  2960. var devicePixelRatio = window.devicePixelRatio || 1;
  2961. var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
  2962. var pixelRatio = devicePixelRatio / backingStoreRatio;
  2963. return {
  2964. sx: pixelRatio,
  2965. sy: pixelRatio,
  2966. scaled: pixelRatio !== 1
  2967. };
  2968. }
  2969. function scrollIntoView(element, spot) {
  2970. var skipOverflowHiddenElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  2971. var parent = element.offsetParent;
  2972. if (!parent) {
  2973. console.error('offsetParent is not set -- cannot scroll');
  2974. return;
  2975. }
  2976. var offsetY = element.offsetTop + element.clientTop;
  2977. var offsetX = element.offsetLeft + element.clientLeft;
  2978. while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || skipOverflowHiddenElements && getComputedStyle(parent).overflow === 'hidden') {
  2979. if (parent.dataset._scaleY) {
  2980. offsetY /= parent.dataset._scaleY;
  2981. offsetX /= parent.dataset._scaleX;
  2982. }
  2983. offsetY += parent.offsetTop;
  2984. offsetX += parent.offsetLeft;
  2985. parent = parent.offsetParent;
  2986. if (!parent) {
  2987. return;
  2988. }
  2989. }
  2990. if (spot) {
  2991. if (spot.top !== undefined) {
  2992. offsetY += spot.top;
  2993. }
  2994. if (spot.left !== undefined) {
  2995. offsetX += spot.left;
  2996. parent.scrollLeft = offsetX;
  2997. }
  2998. }
  2999. parent.scrollTop = offsetY;
  3000. }
  3001. function watchScroll(viewAreaElement, callback) {
  3002. var debounceScroll = function debounceScroll(evt) {
  3003. if (rAF) {
  3004. return;
  3005. }
  3006. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  3007. rAF = null;
  3008. var currentX = viewAreaElement.scrollLeft;
  3009. var lastX = state.lastX;
  3010. if (currentX !== lastX) {
  3011. state.right = currentX > lastX;
  3012. }
  3013. state.lastX = currentX;
  3014. var currentY = viewAreaElement.scrollTop;
  3015. var lastY = state.lastY;
  3016. if (currentY !== lastY) {
  3017. state.down = currentY > lastY;
  3018. }
  3019. state.lastY = currentY;
  3020. callback(state);
  3021. });
  3022. };
  3023. var state = {
  3024. right: true,
  3025. down: true,
  3026. lastX: viewAreaElement.scrollLeft,
  3027. lastY: viewAreaElement.scrollTop,
  3028. _eventHandler: debounceScroll
  3029. };
  3030. var rAF = null;
  3031. viewAreaElement.addEventListener('scroll', debounceScroll, true);
  3032. return state;
  3033. }
  3034. function parseQueryString(query) {
  3035. var parts = query.split('&');
  3036. var params = Object.create(null);
  3037. for (var i = 0, ii = parts.length; i < ii; ++i) {
  3038. var param = parts[i].split('=');
  3039. var key = param[0].toLowerCase();
  3040. var value = param.length > 1 ? param[1] : null;
  3041. params[decodeURIComponent(key)] = decodeURIComponent(value);
  3042. }
  3043. return params;
  3044. }
  3045. function binarySearchFirstItem(items, condition) {
  3046. var minIndex = 0;
  3047. var maxIndex = items.length - 1;
  3048. if (items.length === 0 || !condition(items[maxIndex])) {
  3049. return items.length;
  3050. }
  3051. if (condition(items[minIndex])) {
  3052. return minIndex;
  3053. }
  3054. while (minIndex < maxIndex) {
  3055. var currentIndex = minIndex + maxIndex >> 1;
  3056. var currentItem = items[currentIndex];
  3057. if (condition(currentItem)) {
  3058. maxIndex = currentIndex;
  3059. } else {
  3060. minIndex = currentIndex + 1;
  3061. }
  3062. }
  3063. return minIndex;
  3064. }
  3065. function approximateFraction(x) {
  3066. if (Math.floor(x) === x) {
  3067. return [x, 1];
  3068. }
  3069. var xinv = 1 / x;
  3070. var limit = 8;
  3071. if (xinv > limit) {
  3072. return [1, limit];
  3073. } else if (Math.floor(xinv) === xinv) {
  3074. return [1, xinv];
  3075. }
  3076. var x_ = x > 1 ? xinv : x;
  3077. var a = 0,
  3078. b = 1,
  3079. c = 1,
  3080. d = 1;
  3081. while (true) {
  3082. var p = a + c,
  3083. q = b + d;
  3084. if (q > limit) {
  3085. break;
  3086. }
  3087. if (x_ <= p / q) {
  3088. c = p;
  3089. d = q;
  3090. } else {
  3091. a = p;
  3092. b = q;
  3093. }
  3094. }
  3095. var result;
  3096. if (x_ - a / b < c / d - x_) {
  3097. result = x_ === x ? [a, b] : [b, a];
  3098. } else {
  3099. result = x_ === x ? [c, d] : [d, c];
  3100. }
  3101. return result;
  3102. }
  3103. function roundToDivide(x, div) {
  3104. var r = x % div;
  3105. return r === 0 ? x : Math.round(x - r + div);
  3106. }
  3107. function getPageSizeInches(_ref) {
  3108. var view = _ref.view,
  3109. userUnit = _ref.userUnit,
  3110. rotate = _ref.rotate;
  3111. var _view = _slicedToArray(view, 4),
  3112. x1 = _view[0],
  3113. y1 = _view[1],
  3114. x2 = _view[2],
  3115. y2 = _view[3];
  3116. var changeOrientation = rotate % 180 !== 0;
  3117. var width = (x2 - x1) / 72 * userUnit;
  3118. var height = (y2 - y1) / 72 * userUnit;
  3119. return {
  3120. width: changeOrientation ? height : width,
  3121. height: changeOrientation ? width : height
  3122. };
  3123. }
  3124. function backtrackBeforeAllVisibleElements(index, views, top) {
  3125. if (index < 2) {
  3126. return index;
  3127. }
  3128. var elt = views[index].div;
  3129. var pageTop = elt.offsetTop + elt.clientTop;
  3130. if (pageTop >= top) {
  3131. elt = views[index - 1].div;
  3132. pageTop = elt.offsetTop + elt.clientTop;
  3133. }
  3134. for (var i = index - 2; i >= 0; --i) {
  3135. elt = views[i].div;
  3136. if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
  3137. break;
  3138. }
  3139. index = i;
  3140. }
  3141. return index;
  3142. }
  3143. function getVisibleElements(scrollEl, views) {
  3144. var sortByVisibility = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  3145. var horizontal = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  3146. var top = scrollEl.scrollTop,
  3147. bottom = top + scrollEl.clientHeight;
  3148. var left = scrollEl.scrollLeft,
  3149. right = left + scrollEl.clientWidth;
  3150. function isElementBottomAfterViewTop(view) {
  3151. var element = view.div;
  3152. var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  3153. return elementBottom > top;
  3154. }
  3155. function isElementRightAfterViewLeft(view) {
  3156. var element = view.div;
  3157. var elementRight = element.offsetLeft + element.clientLeft + element.clientWidth;
  3158. return elementRight > left;
  3159. }
  3160. var visible = [],
  3161. numViews = views.length;
  3162. var firstVisibleElementInd = numViews === 0 ? 0 : binarySearchFirstItem(views, horizontal ? isElementRightAfterViewLeft : isElementBottomAfterViewTop);
  3163. if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
  3164. firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
  3165. }
  3166. var lastEdge = horizontal ? right : -1;
  3167. for (var i = firstVisibleElementInd; i < numViews; i++) {
  3168. var view = views[i],
  3169. element = view.div;
  3170. var currentWidth = element.offsetLeft + element.clientLeft;
  3171. var currentHeight = element.offsetTop + element.clientTop;
  3172. var viewWidth = element.clientWidth,
  3173. viewHeight = element.clientHeight;
  3174. var viewRight = currentWidth + viewWidth;
  3175. var viewBottom = currentHeight + viewHeight;
  3176. if (lastEdge === -1) {
  3177. if (viewBottom >= bottom) {
  3178. lastEdge = viewBottom;
  3179. }
  3180. } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
  3181. break;
  3182. }
  3183. if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) {
  3184. continue;
  3185. }
  3186. var hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
  3187. var hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
  3188. var percent = (viewHeight - hiddenHeight) * (viewWidth - hiddenWidth) * 100 / viewHeight / viewWidth | 0;
  3189. visible.push({
  3190. id: view.id,
  3191. x: currentWidth,
  3192. y: currentHeight,
  3193. view: view,
  3194. percent: percent
  3195. });
  3196. }
  3197. var first = visible[0],
  3198. last = visible[visible.length - 1];
  3199. if (sortByVisibility) {
  3200. visible.sort(function (a, b) {
  3201. var pc = a.percent - b.percent;
  3202. if (Math.abs(pc) > 0.001) {
  3203. return -pc;
  3204. }
  3205. return a.id - b.id;
  3206. });
  3207. }
  3208. return {
  3209. first: first,
  3210. last: last,
  3211. views: visible
  3212. };
  3213. }
  3214. function noContextMenuHandler(evt) {
  3215. evt.preventDefault();
  3216. }
  3217. function isDataSchema(url) {
  3218. var i = 0,
  3219. ii = url.length;
  3220. while (i < ii && url[i].trim() === '') {
  3221. i++;
  3222. }
  3223. return url.substring(i, i + 5).toLowerCase() === 'data:';
  3224. }
  3225. function getPDFFileNameFromURL(url) {
  3226. var defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'document.pdf';
  3227. if (typeof url !== 'string') {
  3228. return defaultFilename;
  3229. }
  3230. if (isDataSchema(url)) {
  3231. console.warn('getPDFFileNameFromURL: ' + 'ignoring "data:" URL for performance reasons.');
  3232. return defaultFilename;
  3233. }
  3234. var reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
  3235. var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
  3236. var splitURI = reURI.exec(url);
  3237. var suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
  3238. if (suggestedFilename) {
  3239. suggestedFilename = suggestedFilename[0];
  3240. if (suggestedFilename.includes('%')) {
  3241. try {
  3242. suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
  3243. } catch (ex) {}
  3244. }
  3245. }
  3246. return suggestedFilename || defaultFilename;
  3247. }
  3248. function normalizeWheelEventDelta(evt) {
  3249. var delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
  3250. var angle = Math.atan2(evt.deltaY, evt.deltaX);
  3251. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  3252. delta = -delta;
  3253. }
  3254. var MOUSE_DOM_DELTA_PIXEL_MODE = 0;
  3255. var MOUSE_DOM_DELTA_LINE_MODE = 1;
  3256. var MOUSE_PIXELS_PER_LINE = 30;
  3257. var MOUSE_LINES_PER_PAGE = 30;
  3258. if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
  3259. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  3260. } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
  3261. delta /= MOUSE_LINES_PER_PAGE;
  3262. }
  3263. return delta;
  3264. }
  3265. function isValidRotation(angle) {
  3266. return Number.isInteger(angle) && angle % 90 === 0;
  3267. }
  3268. function isValidScrollMode(mode) {
  3269. return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN;
  3270. }
  3271. function isValidSpreadMode(mode) {
  3272. return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN;
  3273. }
  3274. function isPortraitOrientation(size) {
  3275. return size.width <= size.height;
  3276. }
  3277. var WaitOnType = {
  3278. EVENT: 'event',
  3279. TIMEOUT: 'timeout'
  3280. };
  3281. exports.WaitOnType = WaitOnType;
  3282. function waitOnEventOrTimeout(_ref2) {
  3283. var target = _ref2.target,
  3284. name = _ref2.name,
  3285. _ref2$delay = _ref2.delay,
  3286. delay = _ref2$delay === void 0 ? 0 : _ref2$delay;
  3287. return new Promise(function (resolve, reject) {
  3288. if (_typeof(target) !== 'object' || !(name && typeof name === 'string') || !(Number.isInteger(delay) && delay >= 0)) {
  3289. throw new Error('waitOnEventOrTimeout - invalid parameters.');
  3290. }
  3291. function handler(type) {
  3292. if (target instanceof EventBus) {
  3293. target.off(name, eventHandler);
  3294. } else {
  3295. target.removeEventListener(name, eventHandler);
  3296. }
  3297. if (timeout) {
  3298. clearTimeout(timeout);
  3299. }
  3300. resolve(type);
  3301. }
  3302. var eventHandler = handler.bind(null, WaitOnType.EVENT);
  3303. if (target instanceof EventBus) {
  3304. target.on(name, eventHandler);
  3305. } else {
  3306. target.addEventListener(name, eventHandler);
  3307. }
  3308. var timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
  3309. var timeout = setTimeout(timeoutHandler, delay);
  3310. });
  3311. }
  3312. var animationStarted = new Promise(function (resolve) {
  3313. window.requestAnimationFrame(resolve);
  3314. });
  3315. exports.animationStarted = animationStarted;
  3316. var EventBus =
  3317. /*#__PURE__*/
  3318. function () {
  3319. function EventBus() {
  3320. var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  3321. _ref3$dispatchToDOM = _ref3.dispatchToDOM,
  3322. dispatchToDOM = _ref3$dispatchToDOM === void 0 ? false : _ref3$dispatchToDOM;
  3323. _classCallCheck(this, EventBus);
  3324. this._listeners = Object.create(null);
  3325. this._dispatchToDOM = dispatchToDOM === true;
  3326. }
  3327. _createClass(EventBus, [{
  3328. key: "on",
  3329. value: function on(eventName, listener) {
  3330. var eventListeners = this._listeners[eventName];
  3331. if (!eventListeners) {
  3332. eventListeners = [];
  3333. this._listeners[eventName] = eventListeners;
  3334. }
  3335. eventListeners.push(listener);
  3336. }
  3337. }, {
  3338. key: "off",
  3339. value: function off(eventName, listener) {
  3340. var eventListeners = this._listeners[eventName];
  3341. var i;
  3342. if (!eventListeners || (i = eventListeners.indexOf(listener)) < 0) {
  3343. return;
  3344. }
  3345. eventListeners.splice(i, 1);
  3346. }
  3347. }, {
  3348. key: "dispatch",
  3349. value: function dispatch(eventName) {
  3350. var eventListeners = this._listeners[eventName];
  3351. if (!eventListeners || eventListeners.length === 0) {
  3352. if (this._dispatchToDOM) {
  3353. var _args5 = Array.prototype.slice.call(arguments, 1);
  3354. this._dispatchDOMEvent(eventName, _args5);
  3355. }
  3356. return;
  3357. }
  3358. var args = Array.prototype.slice.call(arguments, 1);
  3359. eventListeners.slice(0).forEach(function (listener) {
  3360. listener.apply(null, args);
  3361. });
  3362. if (this._dispatchToDOM) {
  3363. this._dispatchDOMEvent(eventName, args);
  3364. }
  3365. }
  3366. }, {
  3367. key: "_dispatchDOMEvent",
  3368. value: function _dispatchDOMEvent(eventName) {
  3369. var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  3370. var details = Object.create(null);
  3371. if (args && args.length > 0) {
  3372. var obj = args[0];
  3373. for (var key in obj) {
  3374. var value = obj[key];
  3375. if (key === 'source') {
  3376. if (value === window || value === document) {
  3377. return;
  3378. }
  3379. continue;
  3380. }
  3381. details[key] = value;
  3382. }
  3383. }
  3384. var event = document.createEvent('CustomEvent');
  3385. event.initCustomEvent(eventName, true, true, details);
  3386. document.dispatchEvent(event);
  3387. }
  3388. }]);
  3389. return EventBus;
  3390. }();
  3391. exports.EventBus = EventBus;
  3392. var globalEventBus = null;
  3393. function getGlobalEventBus() {
  3394. var dispatchToDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  3395. if (!globalEventBus) {
  3396. globalEventBus = new EventBus({
  3397. dispatchToDOM: dispatchToDOM
  3398. });
  3399. }
  3400. return globalEventBus;
  3401. }
  3402. function clamp(v, min, max) {
  3403. return Math.min(Math.max(v, min), max);
  3404. }
  3405. var ProgressBar =
  3406. /*#__PURE__*/
  3407. function () {
  3408. function ProgressBar(id) {
  3409. var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  3410. height = _ref4.height,
  3411. width = _ref4.width,
  3412. units = _ref4.units;
  3413. _classCallCheck(this, ProgressBar);
  3414. this.visible = true;
  3415. this.div = document.querySelector(id + ' .progress');
  3416. this.bar = this.div.parentNode;
  3417. this.height = height || 100;
  3418. this.width = width || 100;
  3419. this.units = units || '%';
  3420. this.div.style.height = this.height + this.units;
  3421. this.percent = 0;
  3422. }
  3423. _createClass(ProgressBar, [{
  3424. key: "_updateBar",
  3425. value: function _updateBar() {
  3426. if (this._indeterminate) {
  3427. this.div.classList.add('indeterminate');
  3428. this.div.style.width = this.width + this.units;
  3429. return;
  3430. }
  3431. this.div.classList.remove('indeterminate');
  3432. var progressSize = this.width * this._percent / 100;
  3433. this.div.style.width = progressSize + this.units;
  3434. }
  3435. }, {
  3436. key: "setWidth",
  3437. value: function setWidth(viewer) {
  3438. if (!viewer) {
  3439. return;
  3440. }
  3441. var container = viewer.parentNode;
  3442. var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  3443. if (scrollbarWidth > 0) {
  3444. this.bar.setAttribute('style', 'width: calc(100% - ' + scrollbarWidth + 'px);');
  3445. }
  3446. }
  3447. }, {
  3448. key: "hide",
  3449. value: function hide() {
  3450. if (!this.visible) {
  3451. return;
  3452. }
  3453. this.visible = false;
  3454. this.bar.classList.add('hidden');
  3455. document.body.classList.remove('loadingInProgress');
  3456. }
  3457. }, {
  3458. key: "show",
  3459. value: function show() {
  3460. if (this.visible) {
  3461. return;
  3462. }
  3463. this.visible = true;
  3464. document.body.classList.add('loadingInProgress');
  3465. this.bar.classList.remove('hidden');
  3466. }
  3467. }, {
  3468. key: "percent",
  3469. get: function get() {
  3470. return this._percent;
  3471. },
  3472. set: function set(val) {
  3473. this._indeterminate = isNaN(val);
  3474. this._percent = clamp(val, 0, 100);
  3475. this._updateBar();
  3476. }
  3477. }]);
  3478. return ProgressBar;
  3479. }();
  3480. exports.ProgressBar = ProgressBar;
  3481. function moveToEndOfArray(arr, condition) {
  3482. var moved = [],
  3483. len = arr.length;
  3484. var write = 0;
  3485. for (var read = 0; read < len; ++read) {
  3486. if (condition(arr[read])) {
  3487. moved.push(arr[read]);
  3488. } else {
  3489. arr[write] = arr[read];
  3490. ++write;
  3491. }
  3492. }
  3493. for (var _read = 0; write < len; ++_read, ++write) {
  3494. arr[write] = moved[_read];
  3495. }
  3496. }
  3497. /***/ }),
  3498. /* 7 */
  3499. /***/ (function(module, exports, __webpack_require__) {
  3500. "use strict";
  3501. var pdfjsLib;
  3502. if (typeof window !== 'undefined' && window['pdfjs-dist/build/pdf']) {
  3503. pdfjsLib = window['pdfjs-dist/build/pdf'];
  3504. } else {
  3505. pdfjsLib = require('./pdf.js');
  3506. }
  3507. module.exports = pdfjsLib;
  3508. /***/ }),
  3509. /* 8 */
  3510. /***/ (function(module, exports, __webpack_require__) {
  3511. "use strict";
  3512. Object.defineProperty(exports, "__esModule", {
  3513. value: true
  3514. });
  3515. exports.PDFCursorTools = exports.CursorTool = void 0;
  3516. var _grab_to_pan = __webpack_require__(9);
  3517. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3518. 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); } }
  3519. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3520. var CursorTool = {
  3521. SELECT: 0,
  3522. HAND: 1,
  3523. ZOOM: 2
  3524. };
  3525. exports.CursorTool = CursorTool;
  3526. var PDFCursorTools =
  3527. /*#__PURE__*/
  3528. function () {
  3529. function PDFCursorTools(_ref) {
  3530. var _this = this;
  3531. var container = _ref.container,
  3532. eventBus = _ref.eventBus,
  3533. _ref$cursorToolOnLoad = _ref.cursorToolOnLoad,
  3534. cursorToolOnLoad = _ref$cursorToolOnLoad === void 0 ? CursorTool.SELECT : _ref$cursorToolOnLoad;
  3535. _classCallCheck(this, PDFCursorTools);
  3536. this.container = container;
  3537. this.eventBus = eventBus;
  3538. this.active = CursorTool.SELECT;
  3539. this.activeBeforePresentationMode = null;
  3540. this.handTool = new _grab_to_pan.GrabToPan({
  3541. element: this.container
  3542. });
  3543. this._addEventListeners();
  3544. Promise.resolve().then(function () {
  3545. _this.switchTool(cursorToolOnLoad);
  3546. });
  3547. }
  3548. _createClass(PDFCursorTools, [{
  3549. key: "switchTool",
  3550. value: function switchTool(tool) {
  3551. var _this2 = this;
  3552. if (this.activeBeforePresentationMode !== null) {
  3553. return;
  3554. }
  3555. if (tool === this.active) {
  3556. return;
  3557. }
  3558. var disableActiveTool = function disableActiveTool() {
  3559. switch (_this2.active) {
  3560. case CursorTool.SELECT:
  3561. break;
  3562. case CursorTool.HAND:
  3563. _this2.handTool.deactivate();
  3564. break;
  3565. case CursorTool.ZOOM:
  3566. }
  3567. };
  3568. switch (tool) {
  3569. case CursorTool.SELECT:
  3570. disableActiveTool();
  3571. break;
  3572. case CursorTool.HAND:
  3573. disableActiveTool();
  3574. this.handTool.activate();
  3575. break;
  3576. case CursorTool.ZOOM:
  3577. default:
  3578. console.error("switchTool: \"".concat(tool, "\" is an unsupported value."));
  3579. return;
  3580. }
  3581. this.active = tool;
  3582. this._dispatchEvent();
  3583. }
  3584. }, {
  3585. key: "_dispatchEvent",
  3586. value: function _dispatchEvent() {
  3587. this.eventBus.dispatch('cursortoolchanged', {
  3588. source: this,
  3589. tool: this.active
  3590. });
  3591. }
  3592. }, {
  3593. key: "_addEventListeners",
  3594. value: function _addEventListeners() {
  3595. var _this3 = this;
  3596. this.eventBus.on('switchcursortool', function (evt) {
  3597. _this3.switchTool(evt.tool);
  3598. });
  3599. this.eventBus.on('presentationmodechanged', function (evt) {
  3600. if (evt.switchInProgress) {
  3601. return;
  3602. }
  3603. var previouslyActive;
  3604. if (evt.active) {
  3605. previouslyActive = _this3.active;
  3606. _this3.switchTool(CursorTool.SELECT);
  3607. _this3.activeBeforePresentationMode = previouslyActive;
  3608. } else {
  3609. previouslyActive = _this3.activeBeforePresentationMode;
  3610. _this3.activeBeforePresentationMode = null;
  3611. _this3.switchTool(previouslyActive);
  3612. }
  3613. });
  3614. }
  3615. }, {
  3616. key: "activeTool",
  3617. get: function get() {
  3618. return this.active;
  3619. }
  3620. }]);
  3621. return PDFCursorTools;
  3622. }();
  3623. exports.PDFCursorTools = PDFCursorTools;
  3624. /***/ }),
  3625. /* 9 */
  3626. /***/ (function(module, exports, __webpack_require__) {
  3627. "use strict";
  3628. Object.defineProperty(exports, "__esModule", {
  3629. value: true
  3630. });
  3631. exports.GrabToPan = GrabToPan;
  3632. function GrabToPan(options) {
  3633. this.element = options.element;
  3634. this.document = options.element.ownerDocument;
  3635. if (typeof options.ignoreTarget === 'function') {
  3636. this.ignoreTarget = options.ignoreTarget;
  3637. }
  3638. this.onActiveChanged = options.onActiveChanged;
  3639. this.activate = this.activate.bind(this);
  3640. this.deactivate = this.deactivate.bind(this);
  3641. this.toggle = this.toggle.bind(this);
  3642. this._onmousedown = this._onmousedown.bind(this);
  3643. this._onmousemove = this._onmousemove.bind(this);
  3644. this._endPan = this._endPan.bind(this);
  3645. var overlay = this.overlay = document.createElement('div');
  3646. overlay.className = 'grab-to-pan-grabbing';
  3647. }
  3648. GrabToPan.prototype = {
  3649. CSS_CLASS_GRAB: 'grab-to-pan-grab',
  3650. activate: function GrabToPan_activate() {
  3651. if (!this.active) {
  3652. this.active = true;
  3653. this.element.addEventListener('mousedown', this._onmousedown, true);
  3654. this.element.classList.add(this.CSS_CLASS_GRAB);
  3655. if (this.onActiveChanged) {
  3656. this.onActiveChanged(true);
  3657. }
  3658. }
  3659. },
  3660. deactivate: function GrabToPan_deactivate() {
  3661. if (this.active) {
  3662. this.active = false;
  3663. this.element.removeEventListener('mousedown', this._onmousedown, true);
  3664. this._endPan();
  3665. this.element.classList.remove(this.CSS_CLASS_GRAB);
  3666. if (this.onActiveChanged) {
  3667. this.onActiveChanged(false);
  3668. }
  3669. }
  3670. },
  3671. toggle: function GrabToPan_toggle() {
  3672. if (this.active) {
  3673. this.deactivate();
  3674. } else {
  3675. this.activate();
  3676. }
  3677. },
  3678. ignoreTarget: function GrabToPan_ignoreTarget(node) {
  3679. return node[matchesSelector]('a[href], a[href] *, input, textarea, button, button *, select, option');
  3680. },
  3681. _onmousedown: function GrabToPan__onmousedown(event) {
  3682. if (event.button !== 0 || this.ignoreTarget(event.target)) {
  3683. return;
  3684. }
  3685. if (event.originalTarget) {
  3686. try {
  3687. event.originalTarget.tagName;
  3688. } catch (e) {
  3689. return;
  3690. }
  3691. }
  3692. this.scrollLeftStart = this.element.scrollLeft;
  3693. this.scrollTopStart = this.element.scrollTop;
  3694. this.clientXStart = event.clientX;
  3695. this.clientYStart = event.clientY;
  3696. this.document.addEventListener('mousemove', this._onmousemove, true);
  3697. this.document.addEventListener('mouseup', this._endPan, true);
  3698. this.element.addEventListener('scroll', this._endPan, true);
  3699. event.preventDefault();
  3700. event.stopPropagation();
  3701. var focusedElement = document.activeElement;
  3702. if (focusedElement && !focusedElement.contains(event.target)) {
  3703. focusedElement.blur();
  3704. }
  3705. },
  3706. _onmousemove: function GrabToPan__onmousemove(event) {
  3707. this.element.removeEventListener('scroll', this._endPan, true);
  3708. if (isLeftMouseReleased(event)) {
  3709. this._endPan();
  3710. return;
  3711. }
  3712. var xDiff = event.clientX - this.clientXStart;
  3713. var yDiff = event.clientY - this.clientYStart;
  3714. var scrollTop = this.scrollTopStart - yDiff;
  3715. var scrollLeft = this.scrollLeftStart - xDiff;
  3716. if (this.element.scrollTo) {
  3717. this.element.scrollTo({
  3718. top: scrollTop,
  3719. left: scrollLeft,
  3720. behavior: 'instant'
  3721. });
  3722. } else {
  3723. this.element.scrollTop = scrollTop;
  3724. this.element.scrollLeft = scrollLeft;
  3725. }
  3726. if (!this.overlay.parentNode) {
  3727. document.body.appendChild(this.overlay);
  3728. }
  3729. },
  3730. _endPan: function GrabToPan__endPan() {
  3731. this.element.removeEventListener('scroll', this._endPan, true);
  3732. this.document.removeEventListener('mousemove', this._onmousemove, true);
  3733. this.document.removeEventListener('mouseup', this._endPan, true);
  3734. this.overlay.remove();
  3735. }
  3736. };
  3737. var matchesSelector;
  3738. ['webkitM', 'mozM', 'msM', 'oM', 'm'].some(function (prefix) {
  3739. var name = prefix + 'atches';
  3740. if (name in document.documentElement) {
  3741. matchesSelector = name;
  3742. }
  3743. name += 'Selector';
  3744. if (name in document.documentElement) {
  3745. matchesSelector = name;
  3746. }
  3747. return matchesSelector;
  3748. });
  3749. var isNotIEorIsIE10plus = !document.documentMode || document.documentMode > 9;
  3750. var chrome = window.chrome;
  3751. var isChrome15OrOpera15plus = chrome && (chrome.webstore || chrome.app);
  3752. var isSafari6plus = /Apple/.test(navigator.vendor) && /Version\/([6-9]\d*|[1-5]\d+)/.test(navigator.userAgent);
  3753. function isLeftMouseReleased(event) {
  3754. if ('buttons' in event && isNotIEorIsIE10plus) {
  3755. return !(event.buttons & 1);
  3756. }
  3757. if (isChrome15OrOpera15plus || isSafari6plus) {
  3758. return event.which === 0;
  3759. }
  3760. }
  3761. /***/ }),
  3762. /* 10 */
  3763. /***/ (function(module, exports, __webpack_require__) {
  3764. "use strict";
  3765. Object.defineProperty(exports, "__esModule", {
  3766. value: true
  3767. });
  3768. exports.PDFRenderingQueue = exports.RenderingStates = void 0;
  3769. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3770. 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); } }
  3771. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3772. var CLEANUP_TIMEOUT = 30000;
  3773. var RenderingStates = {
  3774. INITIAL: 0,
  3775. RUNNING: 1,
  3776. PAUSED: 2,
  3777. FINISHED: 3
  3778. };
  3779. exports.RenderingStates = RenderingStates;
  3780. var PDFRenderingQueue =
  3781. /*#__PURE__*/
  3782. function () {
  3783. function PDFRenderingQueue() {
  3784. _classCallCheck(this, PDFRenderingQueue);
  3785. this.pdfViewer = null;
  3786. this.pdfThumbnailViewer = null;
  3787. this.onIdle = null;
  3788. this.highestPriorityPage = null;
  3789. this.idleTimeout = null;
  3790. this.printing = false;
  3791. this.isThumbnailViewEnabled = false;
  3792. }
  3793. _createClass(PDFRenderingQueue, [{
  3794. key: "setViewer",
  3795. value: function setViewer(pdfViewer) {
  3796. this.pdfViewer = pdfViewer;
  3797. }
  3798. }, {
  3799. key: "setThumbnailViewer",
  3800. value: function setThumbnailViewer(pdfThumbnailViewer) {
  3801. this.pdfThumbnailViewer = pdfThumbnailViewer;
  3802. }
  3803. }, {
  3804. key: "isHighestPriority",
  3805. value: function isHighestPriority(view) {
  3806. return this.highestPriorityPage === view.renderingId;
  3807. }
  3808. }, {
  3809. key: "renderHighestPriority",
  3810. value: function renderHighestPriority(currentlyVisiblePages) {
  3811. if (this.idleTimeout) {
  3812. clearTimeout(this.idleTimeout);
  3813. this.idleTimeout = null;
  3814. }
  3815. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  3816. return;
  3817. }
  3818. if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
  3819. if (this.pdfThumbnailViewer.forceRendering()) {
  3820. return;
  3821. }
  3822. }
  3823. if (this.printing) {
  3824. return;
  3825. }
  3826. if (this.onIdle) {
  3827. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
  3828. }
  3829. }
  3830. }, {
  3831. key: "getHighestPriority",
  3832. value: function getHighestPriority(visible, views, scrolledDown) {
  3833. var visibleViews = visible.views;
  3834. var numVisible = visibleViews.length;
  3835. if (numVisible === 0) {
  3836. return false;
  3837. }
  3838. for (var i = 0; i < numVisible; ++i) {
  3839. var view = visibleViews[i].view;
  3840. if (!this.isViewFinished(view)) {
  3841. return view;
  3842. }
  3843. }
  3844. if (scrolledDown) {
  3845. var nextPageIndex = visible.last.id;
  3846. if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {
  3847. return views[nextPageIndex];
  3848. }
  3849. } else {
  3850. var previousPageIndex = visible.first.id - 2;
  3851. if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) {
  3852. return views[previousPageIndex];
  3853. }
  3854. }
  3855. return null;
  3856. }
  3857. }, {
  3858. key: "isViewFinished",
  3859. value: function isViewFinished(view) {
  3860. return view.renderingState === RenderingStates.FINISHED;
  3861. }
  3862. }, {
  3863. key: "renderView",
  3864. value: function renderView(view) {
  3865. var _this = this;
  3866. switch (view.renderingState) {
  3867. case RenderingStates.FINISHED:
  3868. return false;
  3869. case RenderingStates.PAUSED:
  3870. this.highestPriorityPage = view.renderingId;
  3871. view.resume();
  3872. break;
  3873. case RenderingStates.RUNNING:
  3874. this.highestPriorityPage = view.renderingId;
  3875. break;
  3876. case RenderingStates.INITIAL:
  3877. this.highestPriorityPage = view.renderingId;
  3878. var continueRendering = function continueRendering() {
  3879. _this.renderHighestPriority();
  3880. };
  3881. view.draw().then(continueRendering, continueRendering);
  3882. break;
  3883. }
  3884. return true;
  3885. }
  3886. }]);
  3887. return PDFRenderingQueue;
  3888. }();
  3889. exports.PDFRenderingQueue = PDFRenderingQueue;
  3890. /***/ }),
  3891. /* 11 */
  3892. /***/ (function(module, exports, __webpack_require__) {
  3893. "use strict";
  3894. Object.defineProperty(exports, "__esModule", {
  3895. value: true
  3896. });
  3897. exports.PDFSidebar = exports.SidebarView = void 0;
  3898. var _ui_utils = __webpack_require__(6);
  3899. var _pdf_rendering_queue = __webpack_require__(10);
  3900. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3901. 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); } }
  3902. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3903. var UI_NOTIFICATION_CLASS = 'pdfSidebarNotification';
  3904. var SidebarView = {
  3905. UNKNOWN: -1,
  3906. NONE: 0,
  3907. THUMBS: 1,
  3908. OUTLINE: 2,
  3909. ATTACHMENTS: 3,
  3910. LAYERS: 4
  3911. };
  3912. exports.SidebarView = SidebarView;
  3913. var PDFSidebar =
  3914. /*#__PURE__*/
  3915. function () {
  3916. function PDFSidebar(options, eventBus) {
  3917. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  3918. _classCallCheck(this, PDFSidebar);
  3919. this.isOpen = false;
  3920. this.active = SidebarView.THUMBS;
  3921. this.isInitialViewSet = false;
  3922. this.onToggled = null;
  3923. this.pdfViewer = options.pdfViewer;
  3924. this.pdfThumbnailViewer = options.pdfThumbnailViewer;
  3925. this.outerContainer = options.outerContainer;
  3926. this.viewerContainer = options.viewerContainer;
  3927. this.toggleButton = options.toggleButton;
  3928. this.thumbnailButton = options.thumbnailButton;
  3929. this.outlineButton = options.outlineButton;
  3930. this.attachmentsButton = options.attachmentsButton;
  3931. this.thumbnailView = options.thumbnailView;
  3932. this.outlineView = options.outlineView;
  3933. this.attachmentsView = options.attachmentsView;
  3934. this.disableNotification = options.disableNotification || false;
  3935. this.eventBus = eventBus;
  3936. this.l10n = l10n;
  3937. this._addEventListeners();
  3938. }
  3939. _createClass(PDFSidebar, [{
  3940. key: "reset",
  3941. value: function reset() {
  3942. this.isInitialViewSet = false;
  3943. this._hideUINotification(null);
  3944. this.switchView(SidebarView.THUMBS);
  3945. this.outlineButton.disabled = false;
  3946. this.attachmentsButton.disabled = false;
  3947. }
  3948. }, {
  3949. key: "setInitialView",
  3950. value: function setInitialView() {
  3951. var view = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : SidebarView.NONE;
  3952. if (this.isInitialViewSet) {
  3953. return;
  3954. }
  3955. this.isInitialViewSet = true;
  3956. if (view === SidebarView.NONE || view === SidebarView.UNKNOWN) {
  3957. this._dispatchEvent();
  3958. return;
  3959. }
  3960. if (!this._switchView(view, true)) {
  3961. this._dispatchEvent();
  3962. }
  3963. }
  3964. }, {
  3965. key: "switchView",
  3966. value: function switchView(view) {
  3967. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  3968. this._switchView(view, forceOpen);
  3969. }
  3970. }, {
  3971. key: "_switchView",
  3972. value: function _switchView(view) {
  3973. var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  3974. var isViewChanged = view !== this.active;
  3975. var shouldForceRendering = false;
  3976. switch (view) {
  3977. case SidebarView.NONE:
  3978. if (this.isOpen) {
  3979. this.close();
  3980. return true;
  3981. }
  3982. return false;
  3983. case SidebarView.THUMBS:
  3984. if (this.isOpen && isViewChanged) {
  3985. shouldForceRendering = true;
  3986. }
  3987. break;
  3988. case SidebarView.OUTLINE:
  3989. if (this.outlineButton.disabled) {
  3990. return false;
  3991. }
  3992. break;
  3993. case SidebarView.ATTACHMENTS:
  3994. if (this.attachmentsButton.disabled) {
  3995. return false;
  3996. }
  3997. break;
  3998. default:
  3999. console.error("PDFSidebar._switchView: \"".concat(view, "\" is not a valid view."));
  4000. return false;
  4001. }
  4002. this.active = view;
  4003. this.thumbnailButton.classList.toggle('toggled', view === SidebarView.THUMBS);
  4004. this.outlineButton.classList.toggle('toggled', view === SidebarView.OUTLINE);
  4005. this.attachmentsButton.classList.toggle('toggled', view === SidebarView.ATTACHMENTS);
  4006. this.thumbnailView.classList.toggle('hidden', view !== SidebarView.THUMBS);
  4007. this.outlineView.classList.toggle('hidden', view !== SidebarView.OUTLINE);
  4008. this.attachmentsView.classList.toggle('hidden', view !== SidebarView.ATTACHMENTS);
  4009. if (forceOpen && !this.isOpen) {
  4010. this.open();
  4011. return true;
  4012. }
  4013. if (shouldForceRendering) {
  4014. this._updateThumbnailViewer();
  4015. this._forceRendering();
  4016. }
  4017. if (isViewChanged) {
  4018. this._dispatchEvent();
  4019. }
  4020. this._hideUINotification(this.active);
  4021. return isViewChanged;
  4022. }
  4023. }, {
  4024. key: "open",
  4025. value: function open() {
  4026. if (this.isOpen) {
  4027. return;
  4028. }
  4029. this.isOpen = true;
  4030. this.toggleButton.classList.add('toggled');
  4031. this.outerContainer.classList.add('sidebarMoving', 'sidebarOpen');
  4032. if (this.active === SidebarView.THUMBS) {
  4033. this._updateThumbnailViewer();
  4034. }
  4035. this._forceRendering();
  4036. this._dispatchEvent();
  4037. this._hideUINotification(this.active);
  4038. }
  4039. }, {
  4040. key: "close",
  4041. value: function close() {
  4042. if (!this.isOpen) {
  4043. return;
  4044. }
  4045. this.isOpen = false;
  4046. this.toggleButton.classList.remove('toggled');
  4047. this.outerContainer.classList.add('sidebarMoving');
  4048. this.outerContainer.classList.remove('sidebarOpen');
  4049. this._forceRendering();
  4050. this._dispatchEvent();
  4051. }
  4052. }, {
  4053. key: "toggle",
  4054. value: function toggle() {
  4055. if (this.isOpen) {
  4056. this.close();
  4057. } else {
  4058. this.open();
  4059. }
  4060. }
  4061. }, {
  4062. key: "_dispatchEvent",
  4063. value: function _dispatchEvent() {
  4064. this.eventBus.dispatch('sidebarviewchanged', {
  4065. source: this,
  4066. view: this.visibleView
  4067. });
  4068. }
  4069. }, {
  4070. key: "_forceRendering",
  4071. value: function _forceRendering() {
  4072. if (this.onToggled) {
  4073. this.onToggled();
  4074. } else {
  4075. this.pdfViewer.forceRendering();
  4076. this.pdfThumbnailViewer.forceRendering();
  4077. }
  4078. }
  4079. }, {
  4080. key: "_updateThumbnailViewer",
  4081. value: function _updateThumbnailViewer() {
  4082. var pdfViewer = this.pdfViewer,
  4083. pdfThumbnailViewer = this.pdfThumbnailViewer;
  4084. var pagesCount = pdfViewer.pagesCount;
  4085. for (var pageIndex = 0; pageIndex < pagesCount; pageIndex++) {
  4086. var pageView = pdfViewer.getPageView(pageIndex);
  4087. if (pageView && pageView.renderingState === _pdf_rendering_queue.RenderingStates.FINISHED) {
  4088. var thumbnailView = pdfThumbnailViewer.getThumbnail(pageIndex);
  4089. thumbnailView.setImage(pageView);
  4090. }
  4091. }
  4092. pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
  4093. }
  4094. }, {
  4095. key: "_showUINotification",
  4096. value: function _showUINotification(view) {
  4097. var _this = this;
  4098. if (this.disableNotification) {
  4099. return;
  4100. }
  4101. this.l10n.get('toggle_sidebar_notification.title', null, 'Toggle Sidebar (document contains outline/attachments)').then(function (msg) {
  4102. _this.toggleButton.title = msg;
  4103. });
  4104. if (!this.isOpen) {
  4105. this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
  4106. } else if (view === this.active) {
  4107. return;
  4108. }
  4109. switch (view) {
  4110. case SidebarView.OUTLINE:
  4111. this.outlineButton.classList.add(UI_NOTIFICATION_CLASS);
  4112. break;
  4113. case SidebarView.ATTACHMENTS:
  4114. this.attachmentsButton.classList.add(UI_NOTIFICATION_CLASS);
  4115. break;
  4116. }
  4117. }
  4118. }, {
  4119. key: "_hideUINotification",
  4120. value: function _hideUINotification(view) {
  4121. var _this2 = this;
  4122. if (this.disableNotification) {
  4123. return;
  4124. }
  4125. var removeNotification = function removeNotification(view) {
  4126. switch (view) {
  4127. case SidebarView.OUTLINE:
  4128. _this2.outlineButton.classList.remove(UI_NOTIFICATION_CLASS);
  4129. break;
  4130. case SidebarView.ATTACHMENTS:
  4131. _this2.attachmentsButton.classList.remove(UI_NOTIFICATION_CLASS);
  4132. break;
  4133. }
  4134. };
  4135. if (!this.isOpen && view !== null) {
  4136. return;
  4137. }
  4138. this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
  4139. if (view !== null) {
  4140. removeNotification(view);
  4141. return;
  4142. }
  4143. for (view in SidebarView) {
  4144. removeNotification(SidebarView[view]);
  4145. }
  4146. this.l10n.get('toggle_sidebar.title', null, 'Toggle Sidebar').then(function (msg) {
  4147. _this2.toggleButton.title = msg;
  4148. });
  4149. }
  4150. }, {
  4151. key: "_addEventListeners",
  4152. value: function _addEventListeners() {
  4153. var _this3 = this;
  4154. this.viewerContainer.addEventListener('transitionend', function (evt) {
  4155. if (evt.target === _this3.viewerContainer) {
  4156. _this3.outerContainer.classList.remove('sidebarMoving');
  4157. }
  4158. });
  4159. this.thumbnailButton.addEventListener('click', function () {
  4160. _this3.switchView(SidebarView.THUMBS);
  4161. });
  4162. this.outlineButton.addEventListener('click', function () {
  4163. _this3.switchView(SidebarView.OUTLINE);
  4164. });
  4165. this.outlineButton.addEventListener('dblclick', function () {
  4166. _this3.eventBus.dispatch('toggleoutlinetree', {
  4167. source: _this3
  4168. });
  4169. });
  4170. this.attachmentsButton.addEventListener('click', function () {
  4171. _this3.switchView(SidebarView.ATTACHMENTS);
  4172. });
  4173. this.eventBus.on('outlineloaded', function (evt) {
  4174. var outlineCount = evt.outlineCount;
  4175. _this3.outlineButton.disabled = !outlineCount;
  4176. if (outlineCount) {
  4177. _this3._showUINotification(SidebarView.OUTLINE);
  4178. } else if (_this3.active === SidebarView.OUTLINE) {
  4179. _this3.switchView(SidebarView.THUMBS);
  4180. }
  4181. });
  4182. this.eventBus.on('attachmentsloaded', function (evt) {
  4183. if (evt.attachmentsCount) {
  4184. _this3.attachmentsButton.disabled = false;
  4185. _this3._showUINotification(SidebarView.ATTACHMENTS);
  4186. return;
  4187. }
  4188. Promise.resolve().then(function () {
  4189. if (_this3.attachmentsView.hasChildNodes()) {
  4190. return;
  4191. }
  4192. _this3.attachmentsButton.disabled = true;
  4193. if (_this3.active === SidebarView.ATTACHMENTS) {
  4194. _this3.switchView(SidebarView.THUMBS);
  4195. }
  4196. });
  4197. });
  4198. this.eventBus.on('presentationmodechanged', function (evt) {
  4199. if (!evt.active && !evt.switchInProgress && _this3.isThumbnailViewVisible) {
  4200. _this3._updateThumbnailViewer();
  4201. }
  4202. });
  4203. }
  4204. }, {
  4205. key: "visibleView",
  4206. get: function get() {
  4207. return this.isOpen ? this.active : SidebarView.NONE;
  4208. }
  4209. }, {
  4210. key: "isThumbnailViewVisible",
  4211. get: function get() {
  4212. return this.isOpen && this.active === SidebarView.THUMBS;
  4213. }
  4214. }, {
  4215. key: "isOutlineViewVisible",
  4216. get: function get() {
  4217. return this.isOpen && this.active === SidebarView.OUTLINE;
  4218. }
  4219. }, {
  4220. key: "isAttachmentsViewVisible",
  4221. get: function get() {
  4222. return this.isOpen && this.active === SidebarView.ATTACHMENTS;
  4223. }
  4224. }]);
  4225. return PDFSidebar;
  4226. }();
  4227. exports.PDFSidebar = PDFSidebar;
  4228. /***/ }),
  4229. /* 12 */
  4230. /***/ (function(module, exports, __webpack_require__) {
  4231. "use strict";
  4232. Object.defineProperty(exports, "__esModule", {
  4233. value: true
  4234. });
  4235. exports.OptionKind = exports.AppOptions = void 0;
  4236. var _pdfjsLib = __webpack_require__(7);
  4237. var _viewer_compatibility = __webpack_require__(13);
  4238. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4239. 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); } }
  4240. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4241. var OptionKind = {
  4242. VIEWER: 'viewer',
  4243. API: 'api',
  4244. WORKER: 'worker'
  4245. };
  4246. exports.OptionKind = OptionKind;
  4247. var defaultOptions = {
  4248. cursorToolOnLoad: {
  4249. value: 0,
  4250. kind: OptionKind.VIEWER
  4251. },
  4252. defaultUrl: {
  4253. value: DEFAULT_URL,
  4254. kind: OptionKind.VIEWER
  4255. },
  4256. defaultZoomValue: {
  4257. value: '',
  4258. kind: OptionKind.VIEWER
  4259. },
  4260. disableHistory: {
  4261. value: false,
  4262. kind: OptionKind.VIEWER
  4263. },
  4264. disablePageLabels: {
  4265. value: false,
  4266. kind: OptionKind.VIEWER
  4267. },
  4268. enablePrintAutoRotate: {
  4269. value: false,
  4270. kind: OptionKind.VIEWER
  4271. },
  4272. enableWebGL: {
  4273. value: false,
  4274. kind: OptionKind.VIEWER
  4275. },
  4276. eventBusDispatchToDOM: {
  4277. value: false,
  4278. kind: OptionKind.VIEWER
  4279. },
  4280. externalLinkRel: {
  4281. value: 'noopener noreferrer nofollow',
  4282. kind: OptionKind.VIEWER
  4283. },
  4284. externalLinkTarget: {
  4285. value: 0,
  4286. kind: OptionKind.VIEWER
  4287. },
  4288. historyUpdateUrl: {
  4289. value: false,
  4290. kind: OptionKind.VIEWER
  4291. },
  4292. imageResourcesPath: {
  4293. value: './images/',
  4294. kind: OptionKind.VIEWER
  4295. },
  4296. maxCanvasPixels: {
  4297. value: 16777216,
  4298. compatibility: _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels,
  4299. kind: OptionKind.VIEWER
  4300. },
  4301. pdfBugEnabled: {
  4302. value: false,
  4303. kind: OptionKind.VIEWER
  4304. },
  4305. renderer: {
  4306. value: 'canvas',
  4307. kind: OptionKind.VIEWER
  4308. },
  4309. renderInteractiveForms: {
  4310. value: false,
  4311. kind: OptionKind.VIEWER
  4312. },
  4313. sidebarViewOnLoad: {
  4314. value: -1,
  4315. kind: OptionKind.VIEWER
  4316. },
  4317. scrollModeOnLoad: {
  4318. value: -1,
  4319. kind: OptionKind.VIEWER
  4320. },
  4321. spreadModeOnLoad: {
  4322. value: -1,
  4323. kind: OptionKind.VIEWER
  4324. },
  4325. textLayerMode: {
  4326. value: 1,
  4327. kind: OptionKind.VIEWER
  4328. },
  4329. useOnlyCssZoom: {
  4330. value: false,
  4331. kind: OptionKind.VIEWER
  4332. },
  4333. viewOnLoad: {
  4334. value: 0,
  4335. kind: OptionKind.VIEWER
  4336. },
  4337. cMapPacked: {
  4338. value: true,
  4339. kind: OptionKind.API
  4340. },
  4341. cMapUrl: {
  4342. value: './ui/cmaps/',
  4343. kind: OptionKind.API
  4344. },
  4345. disableAutoFetch: {
  4346. value: false,
  4347. kind: OptionKind.API
  4348. },
  4349. disableCreateObjectURL: {
  4350. value: false,
  4351. compatibility: _pdfjsLib.apiCompatibilityParams.disableCreateObjectURL,
  4352. kind: OptionKind.API
  4353. },
  4354. disableFontFace: {
  4355. value: false,
  4356. kind: OptionKind.API
  4357. },
  4358. disableRange: {
  4359. value: false,
  4360. kind: OptionKind.API
  4361. },
  4362. disableStream: {
  4363. value: false,
  4364. kind: OptionKind.API
  4365. },
  4366. isEvalSupported: {
  4367. value: true,
  4368. kind: OptionKind.API
  4369. },
  4370. maxImageSize: {
  4371. value: -1,
  4372. kind: OptionKind.API
  4373. },
  4374. pdfBug: {
  4375. value: false,
  4376. kind: OptionKind.API
  4377. },
  4378. postMessageTransfers: {
  4379. value: true,
  4380. kind: OptionKind.API
  4381. },
  4382. verbosity: {
  4383. value: 1,
  4384. kind: OptionKind.API
  4385. },
  4386. workerPort: {
  4387. value: null,
  4388. kind: OptionKind.WORKER
  4389. },
  4390. workerSrc: {
  4391. value: '/public/netcasign/js/pdf.worker.js',
  4392. kind: OptionKind.WORKER
  4393. }
  4394. };
  4395. {
  4396. defaultOptions.disablePreferences = {
  4397. value: false,
  4398. kind: OptionKind.VIEWER
  4399. };
  4400. defaultOptions.locale = {
  4401. value: typeof navigator !== 'undefined' ? navigator.language : 'en-US',
  4402. kind: OptionKind.VIEWER
  4403. };
  4404. }
  4405. var userOptions = Object.create(null);
  4406. var AppOptions =
  4407. /*#__PURE__*/
  4408. function () {
  4409. function AppOptions() {
  4410. _classCallCheck(this, AppOptions);
  4411. throw new Error('Cannot initialize AppOptions.');
  4412. }
  4413. _createClass(AppOptions, null, [{
  4414. key: "get",
  4415. value: function get(name) {
  4416. var userOption = userOptions[name];
  4417. if (userOption !== undefined) {
  4418. return userOption;
  4419. }
  4420. var defaultOption = defaultOptions[name];
  4421. if (defaultOption !== undefined) {
  4422. return defaultOption.compatibility || defaultOption.value;
  4423. }
  4424. return undefined;
  4425. }
  4426. }, {
  4427. key: "getAll",
  4428. value: function getAll() {
  4429. var kind = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  4430. var options = Object.create(null);
  4431. for (var name in defaultOptions) {
  4432. var defaultOption = defaultOptions[name];
  4433. if (kind && kind !== defaultOption.kind) {
  4434. continue;
  4435. }
  4436. var userOption = userOptions[name];
  4437. options[name] = userOption !== undefined ? userOption : defaultOption.compatibility || defaultOption.value;
  4438. }
  4439. return options;
  4440. }
  4441. }, {
  4442. key: "set",
  4443. value: function set(name, value) {
  4444. userOptions[name] = value;
  4445. }
  4446. }, {
  4447. key: "remove",
  4448. value: function remove(name) {
  4449. delete userOptions[name];
  4450. }
  4451. }]);
  4452. return AppOptions;
  4453. }();
  4454. exports.AppOptions = AppOptions;
  4455. /***/ }),
  4456. /* 13 */
  4457. /***/ (function(module, exports, __webpack_require__) {
  4458. "use strict";
  4459. var compatibilityParams = Object.create(null);
  4460. {
  4461. var userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
  4462. var isAndroid = /Android/.test(userAgent);
  4463. var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent);
  4464. (function checkCanvasSizeLimitation() {
  4465. if (isIOS || isAndroid) {
  4466. compatibilityParams.maxCanvasPixels = 5242880;
  4467. }
  4468. })();
  4469. }
  4470. exports.viewerCompatibilityParams = Object.freeze(compatibilityParams);
  4471. /***/ }),
  4472. /* 14 */
  4473. /***/ (function(module, exports, __webpack_require__) {
  4474. "use strict";
  4475. Object.defineProperty(exports, "__esModule", {
  4476. value: true
  4477. });
  4478. exports.OverlayManager = void 0;
  4479. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  4480. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4481. 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); } }
  4482. 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); }); }; }
  4483. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4484. 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); } }
  4485. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4486. var OverlayManager =
  4487. /*#__PURE__*/
  4488. function () {
  4489. function OverlayManager() {
  4490. _classCallCheck(this, OverlayManager);
  4491. this._overlays = {};
  4492. this._active = null;
  4493. this._keyDownBound = this._keyDown.bind(this);
  4494. }
  4495. _createClass(OverlayManager, [{
  4496. key: "register",
  4497. value: function () {
  4498. var _register = _asyncToGenerator(
  4499. /*#__PURE__*/
  4500. _regenerator.default.mark(function _callee(name, element) {
  4501. var callerCloseMethod,
  4502. canForceClose,
  4503. container,
  4504. _args = arguments;
  4505. return _regenerator.default.wrap(function _callee$(_context) {
  4506. while (1) {
  4507. switch (_context.prev = _context.next) {
  4508. case 0:
  4509. callerCloseMethod = _args.length > 2 && _args[2] !== undefined ? _args[2] : null;
  4510. canForceClose = _args.length > 3 && _args[3] !== undefined ? _args[3] : false;
  4511. if (!(!name || !element || !(container = element.parentNode))) {
  4512. _context.next = 6;
  4513. break;
  4514. }
  4515. throw new Error('Not enough parameters.');
  4516. case 6:
  4517. if (!this._overlays[name]) {
  4518. _context.next = 8;
  4519. break;
  4520. }
  4521. throw new Error('The overlay is already registered.');
  4522. case 8:
  4523. this._overlays[name] = {
  4524. element: element,
  4525. container: container,
  4526. callerCloseMethod: callerCloseMethod,
  4527. canForceClose: canForceClose
  4528. };
  4529. case 9:
  4530. case "end":
  4531. return _context.stop();
  4532. }
  4533. }
  4534. }, _callee, this);
  4535. }));
  4536. function register(_x, _x2) {
  4537. return _register.apply(this, arguments);
  4538. }
  4539. return register;
  4540. }()
  4541. }, {
  4542. key: "unregister",
  4543. value: function () {
  4544. var _unregister = _asyncToGenerator(
  4545. /*#__PURE__*/
  4546. _regenerator.default.mark(function _callee2(name) {
  4547. return _regenerator.default.wrap(function _callee2$(_context2) {
  4548. while (1) {
  4549. switch (_context2.prev = _context2.next) {
  4550. case 0:
  4551. if (this._overlays[name]) {
  4552. _context2.next = 4;
  4553. break;
  4554. }
  4555. throw new Error('The overlay does not exist.');
  4556. case 4:
  4557. if (!(this._active === name)) {
  4558. _context2.next = 6;
  4559. break;
  4560. }
  4561. throw new Error('The overlay cannot be removed while it is active.');
  4562. case 6:
  4563. delete this._overlays[name];
  4564. case 7:
  4565. case "end":
  4566. return _context2.stop();
  4567. }
  4568. }
  4569. }, _callee2, this);
  4570. }));
  4571. function unregister(_x3) {
  4572. return _unregister.apply(this, arguments);
  4573. }
  4574. return unregister;
  4575. }()
  4576. }, {
  4577. key: "open",
  4578. value: function () {
  4579. var _open = _asyncToGenerator(
  4580. /*#__PURE__*/
  4581. _regenerator.default.mark(function _callee3(name) {
  4582. return _regenerator.default.wrap(function _callee3$(_context3) {
  4583. while (1) {
  4584. switch (_context3.prev = _context3.next) {
  4585. case 0:
  4586. if (this._overlays[name]) {
  4587. _context3.next = 4;
  4588. break;
  4589. }
  4590. throw new Error('The overlay does not exist.');
  4591. case 4:
  4592. if (!this._active) {
  4593. _context3.next = 14;
  4594. break;
  4595. }
  4596. if (!this._overlays[name].canForceClose) {
  4597. _context3.next = 9;
  4598. break;
  4599. }
  4600. this._closeThroughCaller();
  4601. _context3.next = 14;
  4602. break;
  4603. case 9:
  4604. if (!(this._active === name)) {
  4605. _context3.next = 13;
  4606. break;
  4607. }
  4608. throw new Error('The overlay is already active.');
  4609. case 13:
  4610. throw new Error('Another overlay is currently active.');
  4611. case 14:
  4612. this._active = name;
  4613. this._overlays[this._active].element.classList.remove('hidden');
  4614. this._overlays[this._active].container.classList.remove('hidden');
  4615. window.addEventListener('keydown', this._keyDownBound);
  4616. case 18:
  4617. case "end":
  4618. return _context3.stop();
  4619. }
  4620. }
  4621. }, _callee3, this);
  4622. }));
  4623. function open(_x4) {
  4624. return _open.apply(this, arguments);
  4625. }
  4626. return open;
  4627. }()
  4628. }, {
  4629. key: "close",
  4630. value: function () {
  4631. var _close = _asyncToGenerator(
  4632. /*#__PURE__*/
  4633. _regenerator.default.mark(function _callee4(name) {
  4634. return _regenerator.default.wrap(function _callee4$(_context4) {
  4635. while (1) {
  4636. switch (_context4.prev = _context4.next) {
  4637. case 0:
  4638. if (this._overlays[name]) {
  4639. _context4.next = 4;
  4640. break;
  4641. }
  4642. throw new Error('The overlay does not exist.');
  4643. case 4:
  4644. if (this._active) {
  4645. _context4.next = 8;
  4646. break;
  4647. }
  4648. throw new Error('The overlay is currently not active.');
  4649. case 8:
  4650. if (!(this._active !== name)) {
  4651. _context4.next = 10;
  4652. break;
  4653. }
  4654. throw new Error('Another overlay is currently active.');
  4655. case 10:
  4656. this._overlays[this._active].container.classList.add('hidden');
  4657. this._overlays[this._active].element.classList.add('hidden');
  4658. this._active = null;
  4659. window.removeEventListener('keydown', this._keyDownBound);
  4660. case 14:
  4661. case "end":
  4662. return _context4.stop();
  4663. }
  4664. }
  4665. }, _callee4, this);
  4666. }));
  4667. function close(_x5) {
  4668. return _close.apply(this, arguments);
  4669. }
  4670. return close;
  4671. }()
  4672. }, {
  4673. key: "_keyDown",
  4674. value: function _keyDown(evt) {
  4675. if (this._active && evt.keyCode === 27) {
  4676. this._closeThroughCaller();
  4677. evt.preventDefault();
  4678. }
  4679. }
  4680. }, {
  4681. key: "_closeThroughCaller",
  4682. value: function _closeThroughCaller() {
  4683. if (this._overlays[this._active].callerCloseMethod) {
  4684. this._overlays[this._active].callerCloseMethod();
  4685. }
  4686. if (this._active) {
  4687. this.close(this._active);
  4688. }
  4689. }
  4690. }, {
  4691. key: "active",
  4692. get: function get() {
  4693. return this._active;
  4694. }
  4695. }]);
  4696. return OverlayManager;
  4697. }();
  4698. exports.OverlayManager = OverlayManager;
  4699. /***/ }),
  4700. /* 15 */
  4701. /***/ (function(module, exports, __webpack_require__) {
  4702. "use strict";
  4703. Object.defineProperty(exports, "__esModule", {
  4704. value: true
  4705. });
  4706. exports.PasswordPrompt = void 0;
  4707. var _ui_utils = __webpack_require__(6);
  4708. var _pdfjsLib = __webpack_require__(7);
  4709. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4710. 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); } }
  4711. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4712. var PasswordPrompt =
  4713. /*#__PURE__*/
  4714. function () {
  4715. function PasswordPrompt(options, overlayManager) {
  4716. var _this = this;
  4717. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  4718. _classCallCheck(this, PasswordPrompt);
  4719. this.overlayName = options.overlayName;
  4720. this.container = options.container;
  4721. this.label = options.label;
  4722. this.input = options.input;
  4723. this.submitButton = options.submitButton;
  4724. this.cancelButton = options.cancelButton;
  4725. this.overlayManager = overlayManager;
  4726. this.l10n = l10n;
  4727. this.updateCallback = null;
  4728. this.reason = null;
  4729. this.submitButton.addEventListener('click', this.verify.bind(this));
  4730. this.cancelButton.addEventListener('click', this.close.bind(this));
  4731. this.input.addEventListener('keydown', function (e) {
  4732. if (e.keyCode === 13) {
  4733. _this.verify();
  4734. }
  4735. });
  4736. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this), true);
  4737. }
  4738. _createClass(PasswordPrompt, [{
  4739. key: "open",
  4740. value: function open() {
  4741. var _this2 = this;
  4742. this.overlayManager.open(this.overlayName).then(function () {
  4743. _this2.input.focus();
  4744. var promptString;
  4745. if (_this2.reason === _pdfjsLib.PasswordResponses.INCORRECT_PASSWORD) {
  4746. promptString = _this2.l10n.get('password_invalid', null, 'Invalid password. Please try again.');
  4747. } else {
  4748. promptString = _this2.l10n.get('password_label', null, 'Enter the password to open this PDF file.');
  4749. }
  4750. promptString.then(function (msg) {
  4751. _this2.label.textContent = msg;
  4752. });
  4753. });
  4754. }
  4755. }, {
  4756. key: "close",
  4757. value: function close() {
  4758. var _this3 = this;
  4759. this.overlayManager.close(this.overlayName).then(function () {
  4760. _this3.input.value = '';
  4761. });
  4762. }
  4763. }, {
  4764. key: "verify",
  4765. value: function verify() {
  4766. var password = this.input.value;
  4767. if (password && password.length > 0) {
  4768. this.close();
  4769. return this.updateCallback(password);
  4770. }
  4771. }
  4772. }, {
  4773. key: "setUpdateCallback",
  4774. value: function setUpdateCallback(updateCallback, reason) {
  4775. this.updateCallback = updateCallback;
  4776. this.reason = reason;
  4777. }
  4778. }]);
  4779. return PasswordPrompt;
  4780. }();
  4781. exports.PasswordPrompt = PasswordPrompt;
  4782. /***/ }),
  4783. /* 16 */
  4784. /***/ (function(module, exports, __webpack_require__) {
  4785. "use strict";
  4786. Object.defineProperty(exports, "__esModule", {
  4787. value: true
  4788. });
  4789. exports.PDFAttachmentViewer = void 0;
  4790. var _pdfjsLib = __webpack_require__(7);
  4791. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4792. 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); } }
  4793. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4794. var PDFAttachmentViewer =
  4795. /*#__PURE__*/
  4796. function () {
  4797. function PDFAttachmentViewer(_ref) {
  4798. var container = _ref.container,
  4799. eventBus = _ref.eventBus,
  4800. downloadManager = _ref.downloadManager;
  4801. _classCallCheck(this, PDFAttachmentViewer);
  4802. this.container = container;
  4803. this.eventBus = eventBus;
  4804. this.downloadManager = downloadManager;
  4805. this.reset();
  4806. this.eventBus.on('fileattachmentannotation', this._appendAttachment.bind(this));
  4807. }
  4808. _createClass(PDFAttachmentViewer, [{
  4809. key: "reset",
  4810. value: function reset() {
  4811. var keepRenderedCapability = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4812. this.attachments = null;
  4813. this.container.textContent = '';
  4814. if (!keepRenderedCapability) {
  4815. this._renderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  4816. }
  4817. }
  4818. }, {
  4819. key: "_dispatchEvent",
  4820. value: function _dispatchEvent(attachmentsCount) {
  4821. this._renderedCapability.resolve();
  4822. this.eventBus.dispatch('attachmentsloaded', {
  4823. source: this,
  4824. attachmentsCount: attachmentsCount
  4825. });
  4826. }
  4827. }, {
  4828. key: "_bindPdfLink",
  4829. value: function _bindPdfLink(button, content, filename) {
  4830. if (this.downloadManager.disableCreateObjectURL) {
  4831. throw new Error('bindPdfLink: Unsupported "disableCreateObjectURL" value.');
  4832. }
  4833. var blobUrl;
  4834. button.onclick = function () {
  4835. if (!blobUrl) {
  4836. blobUrl = (0, _pdfjsLib.createObjectURL)(content, 'application/pdf');
  4837. }
  4838. var viewerUrl;
  4839. viewerUrl = '?file=' + encodeURIComponent(blobUrl + '#' + filename);
  4840. window.open(viewerUrl);
  4841. return false;
  4842. };
  4843. }
  4844. }, {
  4845. key: "_bindLink",
  4846. value: function _bindLink(button, content, filename) {
  4847. var _this = this;
  4848. button.onclick = function () {
  4849. _this.downloadManager.downloadData(content, filename, '');
  4850. return false;
  4851. };
  4852. }
  4853. }, {
  4854. key: "render",
  4855. value: function render(_ref2) {
  4856. var attachments = _ref2.attachments,
  4857. _ref2$keepRenderedCap = _ref2.keepRenderedCapability,
  4858. keepRenderedCapability = _ref2$keepRenderedCap === void 0 ? false : _ref2$keepRenderedCap;
  4859. var attachmentsCount = 0;
  4860. if (this.attachments) {
  4861. this.reset(keepRenderedCapability === true);
  4862. }
  4863. this.attachments = attachments || null;
  4864. if (!attachments) {
  4865. this._dispatchEvent(attachmentsCount);
  4866. return;
  4867. }
  4868. var names = Object.keys(attachments).sort(function (a, b) {
  4869. return a.toLowerCase().localeCompare(b.toLowerCase());
  4870. });
  4871. attachmentsCount = names.length;
  4872. for (var i = 0; i < attachmentsCount; i++) {
  4873. var item = attachments[names[i]];
  4874. var filename = (0, _pdfjsLib.removeNullCharacters)((0, _pdfjsLib.getFilenameFromUrl)(item.filename));
  4875. var div = document.createElement('div');
  4876. div.className = 'attachmentsItem';
  4877. var button = document.createElement('button');
  4878. button.textContent = filename;
  4879. if (/\.pdf$/i.test(filename) && !this.downloadManager.disableCreateObjectURL) {
  4880. this._bindPdfLink(button, item.content, filename);
  4881. } else {
  4882. this._bindLink(button, item.content, filename);
  4883. }
  4884. div.appendChild(button);
  4885. this.container.appendChild(div);
  4886. }
  4887. this._dispatchEvent(attachmentsCount);
  4888. }
  4889. }, {
  4890. key: "_appendAttachment",
  4891. value: function _appendAttachment(_ref3) {
  4892. var _this2 = this;
  4893. var id = _ref3.id,
  4894. filename = _ref3.filename,
  4895. content = _ref3.content;
  4896. this._renderedCapability.promise.then(function () {
  4897. var attachments = _this2.attachments;
  4898. if (!attachments) {
  4899. attachments = Object.create(null);
  4900. } else {
  4901. for (var name in attachments) {
  4902. if (id === name) {
  4903. return;
  4904. }
  4905. }
  4906. }
  4907. attachments[id] = {
  4908. filename: filename,
  4909. content: content
  4910. };
  4911. _this2.render({
  4912. attachments: attachments,
  4913. keepRenderedCapability: true
  4914. });
  4915. });
  4916. }
  4917. }]);
  4918. return PDFAttachmentViewer;
  4919. }();
  4920. exports.PDFAttachmentViewer = PDFAttachmentViewer;
  4921. /***/ }),
  4922. /* 17 */
  4923. /***/ (function(module, exports, __webpack_require__) {
  4924. "use strict";
  4925. Object.defineProperty(exports, "__esModule", {
  4926. value: true
  4927. });
  4928. exports.PDFDocumentProperties = void 0;
  4929. var _ui_utils = __webpack_require__(6);
  4930. var _pdfjsLib = __webpack_require__(7);
  4931. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
  4932. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
  4933. function _iterableToArrayLimit(arr, i) { 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; }
  4934. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  4935. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4936. 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); } }
  4937. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  4938. var DEFAULT_FIELD_CONTENT = '-';
  4939. var NON_METRIC_LOCALES = ['en-us', 'en-lr', 'my'];
  4940. var US_PAGE_NAMES = {
  4941. '8.5x11': 'Letter',
  4942. '8.5x14': 'Legal'
  4943. };
  4944. var METRIC_PAGE_NAMES = {
  4945. '297x420': 'A3',
  4946. '210x297': 'A4'
  4947. };
  4948. function getPageName(size, isPortrait, pageNames) {
  4949. var width = isPortrait ? size.width : size.height;
  4950. var height = isPortrait ? size.height : size.width;
  4951. return pageNames["".concat(width, "x").concat(height)];
  4952. }
  4953. var PDFDocumentProperties =
  4954. /*#__PURE__*/
  4955. function () {
  4956. function PDFDocumentProperties(_ref, overlayManager, eventBus) {
  4957. var _this = this;
  4958. var overlayName = _ref.overlayName,
  4959. fields = _ref.fields,
  4960. container = _ref.container,
  4961. closeButton = _ref.closeButton;
  4962. var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
  4963. _classCallCheck(this, PDFDocumentProperties);
  4964. this.overlayName = overlayName;
  4965. this.fields = fields;
  4966. this.container = container;
  4967. this.overlayManager = overlayManager;
  4968. this.l10n = l10n;
  4969. this._reset();
  4970. if (closeButton) {
  4971. closeButton.addEventListener('click', this.close.bind(this));
  4972. }
  4973. this.overlayManager.register(this.overlayName, this.container, this.close.bind(this));
  4974. if (eventBus) {
  4975. eventBus.on('pagechanging', function (evt) {
  4976. _this._currentPageNumber = evt.pageNumber;
  4977. });
  4978. eventBus.on('rotationchanging', function (evt) {
  4979. _this._pagesRotation = evt.pagesRotation;
  4980. });
  4981. }
  4982. this._isNonMetricLocale = true;
  4983. l10n.getLanguage().then(function (locale) {
  4984. _this._isNonMetricLocale = NON_METRIC_LOCALES.includes(locale);
  4985. });
  4986. }
  4987. _createClass(PDFDocumentProperties, [{
  4988. key: "open",
  4989. value: function open() {
  4990. var _this2 = this;
  4991. var freezeFieldData = function freezeFieldData(data) {
  4992. Object.defineProperty(_this2, 'fieldData', {
  4993. value: Object.freeze(data),
  4994. writable: false,
  4995. enumerable: true,
  4996. configurable: true
  4997. });
  4998. };
  4999. Promise.all([this.overlayManager.open(this.overlayName), this._dataAvailableCapability.promise]).then(function () {
  5000. var currentPageNumber = _this2._currentPageNumber;
  5001. var pagesRotation = _this2._pagesRotation;
  5002. if (_this2.fieldData && currentPageNumber === _this2.fieldData['_currentPageNumber'] && pagesRotation === _this2.fieldData['_pagesRotation']) {
  5003. _this2._updateUI();
  5004. return;
  5005. }
  5006. _this2.pdfDocument.getMetadata().then(function (_ref2) {
  5007. var info = _ref2.info,
  5008. metadata = _ref2.metadata,
  5009. contentDispositionFilename = _ref2.contentDispositionFilename;
  5010. 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) {
  5011. return _this2._parsePageSize((0, _ui_utils.getPageSizeInches)(pdfPage), pagesRotation);
  5012. }), _this2._parseLinearization(info.IsLinearized)]);
  5013. }).then(function (_ref3) {
  5014. var _ref4 = _slicedToArray(_ref3, 8),
  5015. info = _ref4[0],
  5016. metadata = _ref4[1],
  5017. fileName = _ref4[2],
  5018. fileSize = _ref4[3],
  5019. creationDate = _ref4[4],
  5020. modDate = _ref4[5],
  5021. pageSize = _ref4[6],
  5022. isLinearized = _ref4[7];
  5023. freezeFieldData({
  5024. 'fileName': fileName,
  5025. 'fileSize': fileSize,
  5026. 'title': info.Title,
  5027. 'author': info.Author,
  5028. 'subject': info.Subject,
  5029. 'keywords': info.Keywords,
  5030. 'creationDate': creationDate,
  5031. 'modificationDate': modDate,
  5032. 'creator': info.Creator,
  5033. 'producer': info.Producer,
  5034. 'version': info.PDFFormatVersion,
  5035. 'pageCount': _this2.pdfDocument.numPages,
  5036. 'pageSize': pageSize,
  5037. 'linearized': isLinearized,
  5038. '_currentPageNumber': currentPageNumber,
  5039. '_pagesRotation': pagesRotation
  5040. });
  5041. _this2._updateUI();
  5042. return _this2.pdfDocument.getDownloadInfo();
  5043. }).then(function (_ref5) {
  5044. var length = _ref5.length;
  5045. _this2.maybeFileSize = length;
  5046. return _this2._parseFileSize(length);
  5047. }).then(function (fileSize) {
  5048. if (fileSize === _this2.fieldData['fileSize']) {
  5049. return;
  5050. }
  5051. var data = Object.assign(Object.create(null), _this2.fieldData);
  5052. data['fileSize'] = fileSize;
  5053. freezeFieldData(data);
  5054. _this2._updateUI();
  5055. });
  5056. });
  5057. }
  5058. }, {
  5059. key: "close",
  5060. value: function close() {
  5061. this.overlayManager.close(this.overlayName);
  5062. }
  5063. }, {
  5064. key: "setDocument",
  5065. value: function setDocument(pdfDocument) {
  5066. var url = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  5067. if (this.pdfDocument) {
  5068. this._reset();
  5069. this._updateUI(true);
  5070. }
  5071. if (!pdfDocument) {
  5072. return;
  5073. }
  5074. this.pdfDocument = pdfDocument;
  5075. this.url = url;
  5076. this._dataAvailableCapability.resolve();
  5077. }
  5078. }, {
  5079. key: "setFileSize",
  5080. value: function setFileSize(fileSize) {
  5081. if (Number.isInteger(fileSize) && fileSize > 0) {
  5082. this.maybeFileSize = fileSize;
  5083. }
  5084. }
  5085. }, {
  5086. key: "_reset",
  5087. value: function _reset() {
  5088. this.pdfDocument = null;
  5089. this.url = null;
  5090. this.maybeFileSize = 0;
  5091. delete this.fieldData;
  5092. this._dataAvailableCapability = (0, _pdfjsLib.createPromiseCapability)();
  5093. this._currentPageNumber = 1;
  5094. this._pagesRotation = 0;
  5095. }
  5096. }, {
  5097. key: "_updateUI",
  5098. value: function _updateUI() {
  5099. var reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5100. if (reset || !this.fieldData) {
  5101. for (var id in this.fields) {
  5102. this.fields[id].textContent = DEFAULT_FIELD_CONTENT;
  5103. }
  5104. return;
  5105. }
  5106. if (this.overlayManager.active !== this.overlayName) {
  5107. return;
  5108. }
  5109. for (var _id in this.fields) {
  5110. var content = this.fieldData[_id];
  5111. this.fields[_id].textContent = content || content === 0 ? content : DEFAULT_FIELD_CONTENT;
  5112. }
  5113. }
  5114. }, {
  5115. key: "_parseFileSize",
  5116. value: function _parseFileSize() {
  5117. var fileSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  5118. var kb = fileSize / 1024;
  5119. if (!kb) {
  5120. return Promise.resolve(undefined);
  5121. } else if (kb < 1024) {
  5122. return this.l10n.get('document_properties_kb', {
  5123. size_kb: (+kb.toPrecision(3)).toLocaleString(),
  5124. size_b: fileSize.toLocaleString()
  5125. }, '{{size_kb}} KB ({{size_b}} bytes)');
  5126. }
  5127. return this.l10n.get('document_properties_mb', {
  5128. size_mb: (+(kb / 1024).toPrecision(3)).toLocaleString(),
  5129. size_b: fileSize.toLocaleString()
  5130. }, '{{size_mb}} MB ({{size_b}} bytes)');
  5131. }
  5132. }, {
  5133. key: "_parsePageSize",
  5134. value: function _parsePageSize(pageSizeInches, pagesRotation) {
  5135. var _this3 = this;
  5136. if (!pageSizeInches) {
  5137. return Promise.resolve(undefined);
  5138. }
  5139. if (pagesRotation % 180 !== 0) {
  5140. pageSizeInches = {
  5141. width: pageSizeInches.height,
  5142. height: pageSizeInches.width
  5143. };
  5144. }
  5145. var isPortrait = (0, _ui_utils.isPortraitOrientation)(pageSizeInches);
  5146. var sizeInches = {
  5147. width: Math.round(pageSizeInches.width * 100) / 100,
  5148. height: Math.round(pageSizeInches.height * 100) / 100
  5149. };
  5150. var sizeMillimeters = {
  5151. width: Math.round(pageSizeInches.width * 25.4 * 10) / 10,
  5152. height: Math.round(pageSizeInches.height * 25.4 * 10) / 10
  5153. };
  5154. var pageName = null;
  5155. var name = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES);
  5156. if (!name && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(sizeMillimeters.height))) {
  5157. var exactMillimeters = {
  5158. width: pageSizeInches.width * 25.4,
  5159. height: pageSizeInches.height * 25.4
  5160. };
  5161. var intMillimeters = {
  5162. width: Math.round(sizeMillimeters.width),
  5163. height: Math.round(sizeMillimeters.height)
  5164. };
  5165. if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) {
  5166. name = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES);
  5167. if (name) {
  5168. sizeInches = {
  5169. width: Math.round(intMillimeters.width / 25.4 * 100) / 100,
  5170. height: Math.round(intMillimeters.height / 25.4 * 100) / 100
  5171. };
  5172. sizeMillimeters = intMillimeters;
  5173. }
  5174. }
  5175. }
  5176. if (name) {
  5177. pageName = this.l10n.get('document_properties_page_size_name_' + name.toLowerCase(), null, name);
  5178. }
  5179. 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) {
  5180. var _ref7 = _slicedToArray(_ref6, 4),
  5181. _ref7$ = _ref7[0],
  5182. width = _ref7$.width,
  5183. height = _ref7$.height,
  5184. unit = _ref7[1],
  5185. name = _ref7[2],
  5186. orientation = _ref7[3];
  5187. return _this3.l10n.get('document_properties_page_size_dimension_' + (name ? 'name_' : '') + 'string', {
  5188. width: width.toLocaleString(),
  5189. height: height.toLocaleString(),
  5190. unit: unit,
  5191. name: name,
  5192. orientation: orientation
  5193. }, '{{width}} × {{height}} {{unit}} (' + (name ? '{{name}}, ' : '') + '{{orientation}})');
  5194. });
  5195. }
  5196. }, {
  5197. key: "_parseDate",
  5198. value: function _parseDate(inputDate) {
  5199. if (!inputDate) {
  5200. return;
  5201. }
  5202. var dateToParse = inputDate;
  5203. if (dateToParse.substring(0, 2) === 'D:') {
  5204. dateToParse = dateToParse.substring(2);
  5205. }
  5206. var year = parseInt(dateToParse.substring(0, 4), 10);
  5207. var month = parseInt(dateToParse.substring(4, 6), 10) - 1;
  5208. var day = parseInt(dateToParse.substring(6, 8), 10);
  5209. var hours = parseInt(dateToParse.substring(8, 10), 10);
  5210. var minutes = parseInt(dateToParse.substring(10, 12), 10);
  5211. var seconds = parseInt(dateToParse.substring(12, 14), 10);
  5212. var utRel = dateToParse.substring(14, 15);
  5213. var offsetHours = parseInt(dateToParse.substring(15, 17), 10);
  5214. var offsetMinutes = parseInt(dateToParse.substring(18, 20), 10);
  5215. if (utRel === '-') {
  5216. hours += offsetHours;
  5217. minutes += offsetMinutes;
  5218. } else if (utRel === '+') {
  5219. hours -= offsetHours;
  5220. minutes -= offsetMinutes;
  5221. }
  5222. var date = new Date(Date.UTC(year, month, day, hours, minutes, seconds));
  5223. var dateString = date.toLocaleDateString();
  5224. var timeString = date.toLocaleTimeString();
  5225. return this.l10n.get('document_properties_date_string', {
  5226. date: dateString,
  5227. time: timeString
  5228. }, '{{date}}, {{time}}');
  5229. }
  5230. }, {
  5231. key: "_parseLinearization",
  5232. value: function _parseLinearization(isLinearized) {
  5233. return this.l10n.get('document_properties_linearized_' + (isLinearized ? 'yes' : 'no'), null, isLinearized ? 'Yes' : 'No');
  5234. }
  5235. }]);
  5236. return PDFDocumentProperties;
  5237. }();
  5238. exports.PDFDocumentProperties = PDFDocumentProperties;
  5239. /***/ }),
  5240. /* 18 */
  5241. /***/ (function(module, exports, __webpack_require__) {
  5242. "use strict";
  5243. Object.defineProperty(exports, "__esModule", {
  5244. value: true
  5245. });
  5246. exports.PDFFindBar = void 0;
  5247. var _ui_utils = __webpack_require__(6);
  5248. var _pdf_find_controller = __webpack_require__(19);
  5249. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5250. 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); } }
  5251. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5252. var MATCHES_COUNT_LIMIT = 1000;
  5253. var PDFFindBar =
  5254. /*#__PURE__*/
  5255. function () {
  5256. function PDFFindBar(options) {
  5257. var _this = this;
  5258. var eventBus = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (0, _ui_utils.getGlobalEventBus)();
  5259. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  5260. _classCallCheck(this, PDFFindBar);
  5261. this.opened = false;
  5262. this.bar = options.bar || null;
  5263. this.toggleButton = options.toggleButton || null;
  5264. this.findField = options.findField || null;
  5265. this.highlightAll = options.highlightAllCheckbox || null;
  5266. this.caseSensitive = options.caseSensitiveCheckbox || null;
  5267. this.entireWord = options.entireWordCheckbox || null;
  5268. this.findMsg = options.findMsg || null;
  5269. this.findResultsCount = options.findResultsCount || null;
  5270. this.findPreviousButton = options.findPreviousButton || null;
  5271. this.findNextButton = options.findNextButton || null;
  5272. this.eventBus = eventBus;
  5273. this.l10n = l10n;
  5274. this.toggleButton.addEventListener('click', function () {
  5275. _this.toggle();
  5276. });
  5277. this.findField.addEventListener('input', function () {
  5278. _this.dispatchEvent('');
  5279. });
  5280. this.bar.addEventListener('keydown', function (e) {
  5281. switch (e.keyCode) {
  5282. case 13:
  5283. if (e.target === _this.findField) {
  5284. _this.dispatchEvent('again', e.shiftKey);
  5285. }
  5286. break;
  5287. case 27:
  5288. _this.close();
  5289. break;
  5290. }
  5291. });
  5292. this.findPreviousButton.addEventListener('click', function () {
  5293. _this.dispatchEvent('again', true);
  5294. });
  5295. this.findNextButton.addEventListener('click', function () {
  5296. _this.dispatchEvent('again', false);
  5297. });
  5298. this.highlightAll.addEventListener('click', function () {
  5299. _this.dispatchEvent('highlightallchange');
  5300. });
  5301. this.caseSensitive.addEventListener('click', function () {
  5302. _this.dispatchEvent('casesensitivitychange');
  5303. });
  5304. this.entireWord.addEventListener('click', function () {
  5305. _this.dispatchEvent('entirewordchange');
  5306. });
  5307. this.eventBus.on('resize', this._adjustWidth.bind(this));
  5308. }
  5309. _createClass(PDFFindBar, [{
  5310. key: "reset",
  5311. value: function reset() {
  5312. this.updateUIState();
  5313. }
  5314. }, {
  5315. key: "dispatchEvent",
  5316. value: function dispatchEvent(type, findPrev) {
  5317. this.eventBus.dispatch('find', {
  5318. source: this,
  5319. type: type,
  5320. query: this.findField.value,
  5321. phraseSearch: true,
  5322. caseSensitive: this.caseSensitive.checked,
  5323. entireWord: this.entireWord.checked,
  5324. highlightAll: this.highlightAll.checked,
  5325. findPrevious: findPrev
  5326. });
  5327. }
  5328. }, {
  5329. key: "updateUIState",
  5330. value: function updateUIState(state, previous, matchesCount) {
  5331. var _this2 = this;
  5332. var notFound = false;
  5333. var findMsg = '';
  5334. var status = '';
  5335. switch (state) {
  5336. case _pdf_find_controller.FindState.FOUND:
  5337. break;
  5338. case _pdf_find_controller.FindState.PENDING:
  5339. status = 'pending';
  5340. break;
  5341. case _pdf_find_controller.FindState.NOT_FOUND:
  5342. findMsg = this.l10n.get('find_not_found', null, 'Phrase not found');
  5343. notFound = true;
  5344. break;
  5345. case _pdf_find_controller.FindState.WRAPPED:
  5346. if (previous) {
  5347. findMsg = this.l10n.get('find_reached_top', null, 'Reached top of document, continued from bottom');
  5348. } else {
  5349. findMsg = this.l10n.get('find_reached_bottom', null, 'Reached end of document, continued from top');
  5350. }
  5351. break;
  5352. }
  5353. this.findField.classList.toggle('notFound', notFound);
  5354. this.findField.setAttribute('data-status', status);
  5355. Promise.resolve(findMsg).then(function (msg) {
  5356. _this2.findMsg.textContent = msg;
  5357. _this2._adjustWidth();
  5358. });
  5359. this.updateResultsCount(matchesCount);
  5360. }
  5361. }, {
  5362. key: "updateResultsCount",
  5363. value: function updateResultsCount() {
  5364. var _this3 = this;
  5365. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  5366. _ref$current = _ref.current,
  5367. current = _ref$current === void 0 ? 0 : _ref$current,
  5368. _ref$total = _ref.total,
  5369. total = _ref$total === void 0 ? 0 : _ref$total;
  5370. if (!this.findResultsCount) {
  5371. return;
  5372. }
  5373. var matchesCountMsg = '',
  5374. limit = MATCHES_COUNT_LIMIT;
  5375. if (total > 0) {
  5376. if (total > limit) {
  5377. matchesCountMsg = this.l10n.get('find_match_count_limit', {
  5378. limit: limit
  5379. }, 'More than {{limit}} match' + (limit !== 1 ? 'es' : ''));
  5380. } else {
  5381. matchesCountMsg = this.l10n.get('find_match_count', {
  5382. current: current,
  5383. total: total
  5384. }, '{{current}} of {{total}} match' + (total !== 1 ? 'es' : ''));
  5385. }
  5386. }
  5387. Promise.resolve(matchesCountMsg).then(function (msg) {
  5388. _this3.findResultsCount.textContent = msg;
  5389. _this3.findResultsCount.classList.toggle('hidden', !total);
  5390. _this3._adjustWidth();
  5391. });
  5392. }
  5393. }, {
  5394. key: "open",
  5395. value: function open() {
  5396. if (!this.opened) {
  5397. this.opened = true;
  5398. this.toggleButton.classList.add('toggled');
  5399. this.bar.classList.remove('hidden');
  5400. }
  5401. this.findField.select();
  5402. this.findField.focus();
  5403. this._adjustWidth();
  5404. }
  5405. }, {
  5406. key: "close",
  5407. value: function close() {
  5408. if (!this.opened) {
  5409. return;
  5410. }
  5411. this.opened = false;
  5412. this.toggleButton.classList.remove('toggled');
  5413. this.bar.classList.add('hidden');
  5414. this.eventBus.dispatch('findbarclose', {
  5415. source: this
  5416. });
  5417. }
  5418. }, {
  5419. key: "toggle",
  5420. value: function toggle() {
  5421. if (this.opened) {
  5422. this.close();
  5423. } else {
  5424. this.open();
  5425. }
  5426. }
  5427. }, {
  5428. key: "_adjustWidth",
  5429. value: function _adjustWidth() {
  5430. if (!this.opened) {
  5431. return;
  5432. }
  5433. this.bar.classList.remove('wrapContainers');
  5434. var findbarHeight = this.bar.clientHeight;
  5435. var inputContainerHeight = this.bar.firstElementChild.clientHeight;
  5436. if (findbarHeight > inputContainerHeight) {
  5437. this.bar.classList.add('wrapContainers');
  5438. }
  5439. }
  5440. }]);
  5441. return PDFFindBar;
  5442. }();
  5443. exports.PDFFindBar = PDFFindBar;
  5444. /***/ }),
  5445. /* 19 */
  5446. /***/ (function(module, exports, __webpack_require__) {
  5447. "use strict";
  5448. Object.defineProperty(exports, "__esModule", {
  5449. value: true
  5450. });
  5451. exports.PDFFindController = exports.FindState = void 0;
  5452. var _ui_utils = __webpack_require__(6);
  5453. var _pdfjsLib = __webpack_require__(7);
  5454. var _pdf_find_utils = __webpack_require__(20);
  5455. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5456. 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); } }
  5457. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  5458. var FindState = {
  5459. FOUND: 0,
  5460. NOT_FOUND: 1,
  5461. WRAPPED: 2,
  5462. PENDING: 3
  5463. };
  5464. exports.FindState = FindState;
  5465. var FIND_TIMEOUT = 250;
  5466. var MATCH_SCROLL_OFFSET_TOP = -50;
  5467. var MATCH_SCROLL_OFFSET_LEFT = -400;
  5468. var CHARACTERS_TO_NORMALIZE = {
  5469. "\u2018": '\'',
  5470. "\u2019": '\'',
  5471. "\u201A": '\'',
  5472. "\u201B": '\'',
  5473. "\u201C": '"',
  5474. "\u201D": '"',
  5475. "\u201E": '"',
  5476. "\u201F": '"',
  5477. "\xBC": '1/4',
  5478. "\xBD": '1/2',
  5479. "\xBE": '3/4'
  5480. };
  5481. var normalizationRegex = null;
  5482. function normalize(text) {
  5483. if (!normalizationRegex) {
  5484. var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join('');
  5485. normalizationRegex = new RegExp("[".concat(replace, "]"), 'g');
  5486. }
  5487. return text.replace(normalizationRegex, function (ch) {
  5488. return CHARACTERS_TO_NORMALIZE[ch];
  5489. });
  5490. }
  5491. var PDFFindController =
  5492. /*#__PURE__*/
  5493. function () {
  5494. function PDFFindController(_ref) {
  5495. var linkService = _ref.linkService,
  5496. _ref$eventBus = _ref.eventBus,
  5497. eventBus = _ref$eventBus === void 0 ? (0, _ui_utils.getGlobalEventBus)() : _ref$eventBus;
  5498. _classCallCheck(this, PDFFindController);
  5499. this._linkService = linkService;
  5500. this._eventBus = eventBus;
  5501. this._reset();
  5502. eventBus.on('findbarclose', this._onFindBarClose.bind(this));
  5503. }
  5504. _createClass(PDFFindController, [{
  5505. key: "setDocument",
  5506. value: function setDocument(pdfDocument) {
  5507. if (this._pdfDocument) {
  5508. this._reset();
  5509. }
  5510. if (!pdfDocument) {
  5511. return;
  5512. }
  5513. this._pdfDocument = pdfDocument;
  5514. this._firstPageCapability.resolve();
  5515. }
  5516. }, {
  5517. key: "executeCommand",
  5518. value: function executeCommand(cmd, state) {
  5519. var _this = this;
  5520. if (!state) {
  5521. return;
  5522. }
  5523. var pdfDocument = this._pdfDocument;
  5524. if (this._state === null || this._shouldDirtyMatch(cmd, state)) {
  5525. this._dirtyMatch = true;
  5526. }
  5527. this._state = state;
  5528. if (cmd !== 'findhighlightallchange') {
  5529. this._updateUIState(FindState.PENDING);
  5530. }
  5531. this._firstPageCapability.promise.then(function () {
  5532. if (!_this._pdfDocument || pdfDocument && _this._pdfDocument !== pdfDocument) {
  5533. return;
  5534. }
  5535. _this._extractText();
  5536. var findbarClosed = !_this._highlightMatches;
  5537. var pendingTimeout = !!_this._findTimeout;
  5538. if (_this._findTimeout) {
  5539. clearTimeout(_this._findTimeout);
  5540. _this._findTimeout = null;
  5541. }
  5542. if (cmd === 'find') {
  5543. _this._findTimeout = setTimeout(function () {
  5544. _this._nextMatch();
  5545. _this._findTimeout = null;
  5546. }, FIND_TIMEOUT);
  5547. } else if (_this._dirtyMatch) {
  5548. _this._nextMatch();
  5549. } else if (cmd === 'findagain') {
  5550. _this._nextMatch();
  5551. if (findbarClosed && _this._state.highlightAll) {
  5552. _this._updateAllPages();
  5553. }
  5554. } else if (cmd === 'findhighlightallchange') {
  5555. if (pendingTimeout) {
  5556. _this._nextMatch();
  5557. } else {
  5558. _this._highlightMatches = true;
  5559. }
  5560. _this._updateAllPages();
  5561. } else {
  5562. _this._nextMatch();
  5563. }
  5564. });
  5565. }
  5566. }, {
  5567. key: "scrollMatchIntoView",
  5568. value: function scrollMatchIntoView(_ref2) {
  5569. var _ref2$element = _ref2.element,
  5570. element = _ref2$element === void 0 ? null : _ref2$element,
  5571. _ref2$pageIndex = _ref2.pageIndex,
  5572. pageIndex = _ref2$pageIndex === void 0 ? -1 : _ref2$pageIndex,
  5573. _ref2$matchIndex = _ref2.matchIndex,
  5574. matchIndex = _ref2$matchIndex === void 0 ? -1 : _ref2$matchIndex;
  5575. if (!this._scrollMatches || !element) {
  5576. return;
  5577. } else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) {
  5578. return;
  5579. } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) {
  5580. return;
  5581. }
  5582. this._scrollMatches = false;
  5583. var spot = {
  5584. top: MATCH_SCROLL_OFFSET_TOP,
  5585. left: MATCH_SCROLL_OFFSET_LEFT
  5586. };
  5587. (0, _ui_utils.scrollIntoView)(element, spot, true);
  5588. }
  5589. }, {
  5590. key: "_reset",
  5591. value: function _reset() {
  5592. this._highlightMatches = false;
  5593. this._scrollMatches = false;
  5594. this._pdfDocument = null;
  5595. this._pageMatches = [];
  5596. this._pageMatchesLength = [];
  5597. this._state = null;
  5598. this._selected = {
  5599. pageIdx: -1,
  5600. matchIdx: -1
  5601. };
  5602. this._offset = {
  5603. pageIdx: null,
  5604. matchIdx: null,
  5605. wrapped: false
  5606. };
  5607. this._extractTextPromises = [];
  5608. this._pageContents = [];
  5609. this._matchesCountTotal = 0;
  5610. this._pagesToSearch = null;
  5611. this._pendingFindMatches = Object.create(null);
  5612. this._resumePageIdx = null;
  5613. this._dirtyMatch = false;
  5614. clearTimeout(this._findTimeout);
  5615. this._findTimeout = null;
  5616. this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
  5617. }
  5618. }, {
  5619. key: "_shouldDirtyMatch",
  5620. value: function _shouldDirtyMatch(cmd, state) {
  5621. if (state.query !== this._state.query) {
  5622. return true;
  5623. }
  5624. switch (cmd) {
  5625. case 'findagain':
  5626. var pageNumber = this._selected.pageIdx + 1;
  5627. var linkService = this._linkService;
  5628. if (pageNumber >= 1 && pageNumber <= linkService.pagesCount && linkService.page !== pageNumber && linkService.isPageVisible && !linkService.isPageVisible(pageNumber)) {
  5629. break;
  5630. }
  5631. return false;
  5632. case 'findhighlightallchange':
  5633. return false;
  5634. }
  5635. return true;
  5636. }
  5637. }, {
  5638. key: "_prepareMatches",
  5639. value: function _prepareMatches(matchesWithLength, matches, matchesLength) {
  5640. function isSubTerm(matchesWithLength, currentIndex) {
  5641. var currentElem = matchesWithLength[currentIndex];
  5642. var nextElem = matchesWithLength[currentIndex + 1];
  5643. if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {
  5644. currentElem.skipped = true;
  5645. return true;
  5646. }
  5647. for (var i = currentIndex - 1; i >= 0; i--) {
  5648. var prevElem = matchesWithLength[i];
  5649. if (prevElem.skipped) {
  5650. continue;
  5651. }
  5652. if (prevElem.match + prevElem.matchLength < currentElem.match) {
  5653. break;
  5654. }
  5655. if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {
  5656. currentElem.skipped = true;
  5657. return true;
  5658. }
  5659. }
  5660. return false;
  5661. }
  5662. matchesWithLength.sort(function (a, b) {
  5663. return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match;
  5664. });
  5665. for (var i = 0, len = matchesWithLength.length; i < len; i++) {
  5666. if (isSubTerm(matchesWithLength, i)) {
  5667. continue;
  5668. }
  5669. matches.push(matchesWithLength[i].match);
  5670. matchesLength.push(matchesWithLength[i].matchLength);
  5671. }
  5672. }
  5673. }, {
  5674. key: "_isEntireWord",
  5675. value: function _isEntireWord(content, startIdx, length) {
  5676. if (startIdx > 0) {
  5677. var first = content.charCodeAt(startIdx);
  5678. var limit = content.charCodeAt(startIdx - 1);
  5679. if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils.getCharacterType)(limit)) {
  5680. return false;
  5681. }
  5682. }
  5683. var endIdx = startIdx + length - 1;
  5684. if (endIdx < content.length - 1) {
  5685. var last = content.charCodeAt(endIdx);
  5686. var _limit = content.charCodeAt(endIdx + 1);
  5687. if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils.getCharacterType)(_limit)) {
  5688. return false;
  5689. }
  5690. }
  5691. return true;
  5692. }
  5693. }, {
  5694. key: "_calculatePhraseMatch",
  5695. value: function _calculatePhraseMatch(query, pageIndex, pageContent, entireWord) {
  5696. var matches = [];
  5697. var queryLen = query.length;
  5698. var matchIdx = -queryLen;
  5699. while (true) {
  5700. matchIdx = pageContent.indexOf(query, matchIdx + queryLen);
  5701. if (matchIdx === -1) {
  5702. break;
  5703. }
  5704. if (entireWord && !this._isEntireWord(pageContent, matchIdx, queryLen)) {
  5705. continue;
  5706. }
  5707. matches.push(matchIdx);
  5708. }
  5709. this._pageMatches[pageIndex] = matches;
  5710. }
  5711. }, {
  5712. key: "_calculateWordMatch",
  5713. value: function _calculateWordMatch(query, pageIndex, pageContent, entireWord) {
  5714. var matchesWithLength = [];
  5715. var queryArray = query.match(/\S+/g);
  5716. for (var i = 0, len = queryArray.length; i < len; i++) {
  5717. var subquery = queryArray[i];
  5718. var subqueryLen = subquery.length;
  5719. var matchIdx = -subqueryLen;
  5720. while (true) {
  5721. matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen);
  5722. if (matchIdx === -1) {
  5723. break;
  5724. }
  5725. if (entireWord && !this._isEntireWord(pageContent, matchIdx, subqueryLen)) {
  5726. continue;
  5727. }
  5728. matchesWithLength.push({
  5729. match: matchIdx,
  5730. matchLength: subqueryLen,
  5731. skipped: false
  5732. });
  5733. }
  5734. }
  5735. this._pageMatchesLength[pageIndex] = [];
  5736. this._pageMatches[pageIndex] = [];
  5737. this._prepareMatches(matchesWithLength, this._pageMatches[pageIndex], this._pageMatchesLength[pageIndex]);
  5738. }
  5739. }, {
  5740. key: "_calculateMatch",
  5741. value: function _calculateMatch(pageIndex) {
  5742. var pageContent = this._pageContents[pageIndex];
  5743. var query = this._query;
  5744. var _this$_state = this._state,
  5745. caseSensitive = _this$_state.caseSensitive,
  5746. entireWord = _this$_state.entireWord,
  5747. phraseSearch = _this$_state.phraseSearch;
  5748. if (query.length === 0) {
  5749. return;
  5750. }
  5751. if (!caseSensitive) {
  5752. pageContent = pageContent.toLowerCase();
  5753. query = query.toLowerCase();
  5754. }
  5755. if (phraseSearch) {
  5756. this._calculatePhraseMatch(query, pageIndex, pageContent, entireWord);
  5757. } else {
  5758. this._calculateWordMatch(query, pageIndex, pageContent, entireWord);
  5759. }
  5760. if (this._state.highlightAll) {
  5761. this._updatePage(pageIndex);
  5762. }
  5763. if (this._resumePageIdx === pageIndex) {
  5764. this._resumePageIdx = null;
  5765. this._nextPageMatch();
  5766. }
  5767. var pageMatchesCount = this._pageMatches[pageIndex].length;
  5768. if (pageMatchesCount > 0) {
  5769. this._matchesCountTotal += pageMatchesCount;
  5770. this._updateUIResultsCount();
  5771. }
  5772. }
  5773. }, {
  5774. key: "_extractText",
  5775. value: function _extractText() {
  5776. var _this2 = this;
  5777. if (this._extractTextPromises.length > 0) {
  5778. return;
  5779. }
  5780. var promise = Promise.resolve();
  5781. var _loop = function _loop(i, ii) {
  5782. var extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
  5783. _this2._extractTextPromises[i] = extractTextCapability.promise;
  5784. promise = promise.then(function () {
  5785. return _this2._pdfDocument.getPage(i + 1).then(function (pdfPage) {
  5786. return pdfPage.getTextContent({
  5787. normalizeWhitespace: true
  5788. });
  5789. }).then(function (textContent) {
  5790. var textItems = textContent.items;
  5791. var strBuf = [];
  5792. for (var j = 0, jj = textItems.length; j < jj; j++) {
  5793. strBuf.push(textItems[j].str);
  5794. }
  5795. _this2._pageContents[i] = normalize(strBuf.join(''));
  5796. extractTextCapability.resolve(i);
  5797. }, function (reason) {
  5798. console.error("Unable to get text content for page ".concat(i + 1), reason);
  5799. _this2._pageContents[i] = '';
  5800. extractTextCapability.resolve(i);
  5801. });
  5802. });
  5803. };
  5804. for (var i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
  5805. _loop(i, ii);
  5806. }
  5807. }
  5808. }, {
  5809. key: "_updatePage",
  5810. value: function _updatePage(index) {
  5811. if (this._scrollMatches && this._selected.pageIdx === index) {
  5812. this._linkService.page = index + 1;
  5813. }
  5814. this._eventBus.dispatch('updatetextlayermatches', {
  5815. source: this,
  5816. pageIndex: index
  5817. });
  5818. }
  5819. }, {
  5820. key: "_updateAllPages",
  5821. value: function _updateAllPages() {
  5822. this._eventBus.dispatch('updatetextlayermatches', {
  5823. source: this,
  5824. pageIndex: -1
  5825. });
  5826. }
  5827. }, {
  5828. key: "_nextMatch",
  5829. value: function _nextMatch() {
  5830. var _this3 = this;
  5831. var previous = this._state.findPrevious;
  5832. var currentPageIndex = this._linkService.page - 1;
  5833. var numPages = this._linkService.pagesCount;
  5834. this._highlightMatches = true;
  5835. if (this._dirtyMatch) {
  5836. this._dirtyMatch = false;
  5837. this._selected.pageIdx = this._selected.matchIdx = -1;
  5838. this._offset.pageIdx = currentPageIndex;
  5839. this._offset.matchIdx = null;
  5840. this._offset.wrapped = false;
  5841. this._resumePageIdx = null;
  5842. this._pageMatches.length = 0;
  5843. this._pageMatchesLength.length = 0;
  5844. this._matchesCountTotal = 0;
  5845. this._updateAllPages();
  5846. for (var i = 0; i < numPages; i++) {
  5847. if (this._pendingFindMatches[i] === true) {
  5848. continue;
  5849. }
  5850. this._pendingFindMatches[i] = true;
  5851. this._extractTextPromises[i].then(function (pageIdx) {
  5852. delete _this3._pendingFindMatches[pageIdx];
  5853. _this3._calculateMatch(pageIdx);
  5854. });
  5855. }
  5856. }
  5857. if (this._query === '') {
  5858. this._updateUIState(FindState.FOUND);
  5859. return;
  5860. }
  5861. if (this._resumePageIdx) {
  5862. return;
  5863. }
  5864. var offset = this._offset;
  5865. this._pagesToSearch = numPages;
  5866. if (offset.matchIdx !== null) {
  5867. var numPageMatches = this._pageMatches[offset.pageIdx].length;
  5868. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  5869. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  5870. this._updateMatch(true);
  5871. return;
  5872. }
  5873. this._advanceOffsetPage(previous);
  5874. }
  5875. this._nextPageMatch();
  5876. }
  5877. }, {
  5878. key: "_matchesReady",
  5879. value: function _matchesReady(matches) {
  5880. var offset = this._offset;
  5881. var numMatches = matches.length;
  5882. var previous = this._state.findPrevious;
  5883. if (numMatches) {
  5884. offset.matchIdx = previous ? numMatches - 1 : 0;
  5885. this._updateMatch(true);
  5886. return true;
  5887. }
  5888. this._advanceOffsetPage(previous);
  5889. if (offset.wrapped) {
  5890. offset.matchIdx = null;
  5891. if (this._pagesToSearch < 0) {
  5892. this._updateMatch(false);
  5893. return true;
  5894. }
  5895. }
  5896. return false;
  5897. }
  5898. }, {
  5899. key: "_nextPageMatch",
  5900. value: function _nextPageMatch() {
  5901. if (this._resumePageIdx !== null) {
  5902. console.error('There can only be one pending page.');
  5903. }
  5904. var matches = null;
  5905. do {
  5906. var pageIdx = this._offset.pageIdx;
  5907. matches = this._pageMatches[pageIdx];
  5908. if (!matches) {
  5909. this._resumePageIdx = pageIdx;
  5910. break;
  5911. }
  5912. } while (!this._matchesReady(matches));
  5913. }
  5914. }, {
  5915. key: "_advanceOffsetPage",
  5916. value: function _advanceOffsetPage(previous) {
  5917. var offset = this._offset;
  5918. var numPages = this._linkService.pagesCount;
  5919. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  5920. offset.matchIdx = null;
  5921. this._pagesToSearch--;
  5922. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  5923. offset.pageIdx = previous ? numPages - 1 : 0;
  5924. offset.wrapped = true;
  5925. }
  5926. }
  5927. }, {
  5928. key: "_updateMatch",
  5929. value: function _updateMatch() {
  5930. var found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5931. var state = FindState.NOT_FOUND;
  5932. var wrapped = this._offset.wrapped;
  5933. this._offset.wrapped = false;
  5934. if (found) {
  5935. var previousPage = this._selected.pageIdx;
  5936. this._selected.pageIdx = this._offset.pageIdx;
  5937. this._selected.matchIdx = this._offset.matchIdx;
  5938. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  5939. if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {
  5940. this._updatePage(previousPage);
  5941. }
  5942. }
  5943. this._updateUIState(state, this._state.findPrevious);
  5944. if (this._selected.pageIdx !== -1) {
  5945. this._scrollMatches = true;
  5946. this._updatePage(this._selected.pageIdx);
  5947. }
  5948. }
  5949. }, {
  5950. key: "_onFindBarClose",
  5951. value: function _onFindBarClose(evt) {
  5952. var _this4 = this;
  5953. var pdfDocument = this._pdfDocument;
  5954. this._firstPageCapability.promise.then(function () {
  5955. if (!_this4._pdfDocument || pdfDocument && _this4._pdfDocument !== pdfDocument) {
  5956. return;
  5957. }
  5958. if (_this4._findTimeout) {
  5959. clearTimeout(_this4._findTimeout);
  5960. _this4._findTimeout = null;
  5961. }
  5962. if (_this4._resumePageIdx) {
  5963. _this4._resumePageIdx = null;
  5964. _this4._dirtyMatch = true;
  5965. }
  5966. _this4._updateUIState(FindState.FOUND);
  5967. _this4._highlightMatches = false;
  5968. _this4._updateAllPages();
  5969. });
  5970. }
  5971. }, {
  5972. key: "_requestMatchesCount",
  5973. value: function _requestMatchesCount() {
  5974. var _this$_selected = this._selected,
  5975. pageIdx = _this$_selected.pageIdx,
  5976. matchIdx = _this$_selected.matchIdx;
  5977. var current = 0,
  5978. total = this._matchesCountTotal;
  5979. if (matchIdx !== -1) {
  5980. for (var i = 0; i < pageIdx; i++) {
  5981. current += this._pageMatches[i] && this._pageMatches[i].length || 0;
  5982. }
  5983. current += matchIdx + 1;
  5984. }
  5985. if (current < 1 || current > total) {
  5986. current = total = 0;
  5987. }
  5988. return {
  5989. current: current,
  5990. total: total
  5991. };
  5992. }
  5993. }, {
  5994. key: "_updateUIResultsCount",
  5995. value: function _updateUIResultsCount() {
  5996. this._eventBus.dispatch('updatefindmatchescount', {
  5997. source: this,
  5998. matchesCount: this._requestMatchesCount()
  5999. });
  6000. }
  6001. }, {
  6002. key: "_updateUIState",
  6003. value: function _updateUIState(state, previous) {
  6004. this._eventBus.dispatch('updatefindcontrolstate', {
  6005. source: this,
  6006. state: state,
  6007. previous: previous,
  6008. matchesCount: this._requestMatchesCount()
  6009. });
  6010. }
  6011. }, {
  6012. key: "highlightMatches",
  6013. get: function get() {
  6014. return this._highlightMatches;
  6015. }
  6016. }, {
  6017. key: "pageMatches",
  6018. get: function get() {
  6019. return this._pageMatches;
  6020. }
  6021. }, {
  6022. key: "pageMatchesLength",
  6023. get: function get() {
  6024. return this._pageMatchesLength;
  6025. }
  6026. }, {
  6027. key: "selected",
  6028. get: function get() {
  6029. return this._selected;
  6030. }
  6031. }, {
  6032. key: "state",
  6033. get: function get() {
  6034. return this._state;
  6035. }
  6036. }, {
  6037. key: "_query",
  6038. get: function get() {
  6039. if (this._state.query !== this._rawQuery) {
  6040. this._rawQuery = this._state.query;
  6041. this._normalizedQuery = normalize(this._state.query);
  6042. }
  6043. return this._normalizedQuery;
  6044. }
  6045. }]);
  6046. return PDFFindController;
  6047. }();
  6048. exports.PDFFindController = PDFFindController;
  6049. /***/ }),
  6050. /* 20 */
  6051. /***/ (function(module, exports, __webpack_require__) {
  6052. "use strict";
  6053. Object.defineProperty(exports, "__esModule", {
  6054. value: true
  6055. });
  6056. exports.getCharacterType = getCharacterType;
  6057. exports.CharacterType = void 0;
  6058. var CharacterType = {
  6059. SPACE: 0,
  6060. ALPHA_LETTER: 1,
  6061. PUNCT: 2,
  6062. HAN_LETTER: 3,
  6063. KATAKANA_LETTER: 4,
  6064. HIRAGANA_LETTER: 5,
  6065. HALFWIDTH_KATAKANA_LETTER: 6,
  6066. THAI_LETTER: 7
  6067. };
  6068. exports.CharacterType = CharacterType;
  6069. function isAlphabeticalScript(charCode) {
  6070. return charCode < 0x2E80;
  6071. }
  6072. function isAscii(charCode) {
  6073. return (charCode & 0xFF80) === 0;
  6074. }
  6075. function isAsciiAlpha(charCode) {
  6076. return charCode >= 0x61 && charCode <= 0x7A || charCode >= 0x41 && charCode <= 0x5A;
  6077. }
  6078. function isAsciiDigit(charCode) {
  6079. return charCode >= 0x30 && charCode <= 0x39;
  6080. }
  6081. function isAsciiSpace(charCode) {
  6082. return charCode === 0x20 || charCode === 0x09 || charCode === 0x0D || charCode === 0x0A;
  6083. }
  6084. function isHan(charCode) {
  6085. return charCode >= 0x3400 && charCode <= 0x9FFF || charCode >= 0xF900 && charCode <= 0xFAFF;
  6086. }
  6087. function isKatakana(charCode) {
  6088. return charCode >= 0x30A0 && charCode <= 0x30FF;
  6089. }
  6090. function isHiragana(charCode) {
  6091. return charCode >= 0x3040 && charCode <= 0x309F;
  6092. }
  6093. function isHalfwidthKatakana(charCode) {
  6094. return charCode >= 0xFF60 && charCode <= 0xFF9F;
  6095. }
  6096. function isThai(charCode) {
  6097. return (charCode & 0xFF80) === 0x0E00;
  6098. }
  6099. function getCharacterType(charCode) {
  6100. if (isAlphabeticalScript(charCode)) {
  6101. if (isAscii(charCode)) {
  6102. if (isAsciiSpace(charCode)) {
  6103. return CharacterType.SPACE;
  6104. } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5F) {
  6105. return CharacterType.ALPHA_LETTER;
  6106. }
  6107. return CharacterType.PUNCT;
  6108. } else if (isThai(charCode)) {
  6109. return CharacterType.THAI_LETTER;
  6110. } else if (charCode === 0xA0) {
  6111. return CharacterType.SPACE;
  6112. }
  6113. return CharacterType.ALPHA_LETTER;
  6114. }
  6115. if (isHan(charCode)) {
  6116. return CharacterType.HAN_LETTER;
  6117. } else if (isKatakana(charCode)) {
  6118. return CharacterType.KATAKANA_LETTER;
  6119. } else if (isHiragana(charCode)) {
  6120. return CharacterType.HIRAGANA_LETTER;
  6121. } else if (isHalfwidthKatakana(charCode)) {
  6122. return CharacterType.HALFWIDTH_KATAKANA_LETTER;
  6123. }
  6124. return CharacterType.ALPHA_LETTER;
  6125. }
  6126. /***/ }),
  6127. /* 21 */
  6128. /***/ (function(module, exports, __webpack_require__) {
  6129. "use strict";
  6130. Object.defineProperty(exports, "__esModule", {
  6131. value: true
  6132. });
  6133. exports.isDestHashesEqual = isDestHashesEqual;
  6134. exports.isDestArraysEqual = isDestArraysEqual;
  6135. exports.PDFHistory = void 0;
  6136. var _ui_utils = __webpack_require__(6);
  6137. function _typeof(obj) { 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); }
  6138. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
  6139. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
  6140. function _iterableToArrayLimit(arr, i) { 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; }
  6141. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  6142. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6143. 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); } }
  6144. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6145. var HASH_CHANGE_TIMEOUT = 1000;
  6146. var POSITION_UPDATED_THRESHOLD = 50;
  6147. var UPDATE_VIEWAREA_TIMEOUT = 1000;
  6148. function getCurrentHash() {
  6149. return document.location.hash;
  6150. }
  6151. function parseCurrentHash(linkService) {
  6152. var hash = unescape(getCurrentHash()).substring(1);
  6153. var params = (0, _ui_utils.parseQueryString)(hash);
  6154. var page = params.page | 0;
  6155. if (!(Number.isInteger(page) && page > 0 && page <= linkService.pagesCount)) {
  6156. page = null;
  6157. }
  6158. return {
  6159. hash: hash,
  6160. page: page,
  6161. rotation: linkService.rotation
  6162. };
  6163. }
  6164. var PDFHistory =
  6165. /*#__PURE__*/
  6166. function () {
  6167. function PDFHistory(_ref) {
  6168. var _this = this;
  6169. var linkService = _ref.linkService,
  6170. eventBus = _ref.eventBus;
  6171. _classCallCheck(this, PDFHistory);
  6172. this.linkService = linkService;
  6173. this.eventBus = eventBus || (0, _ui_utils.getGlobalEventBus)();
  6174. this.initialized = false;
  6175. this.initialBookmark = null;
  6176. this.initialRotation = null;
  6177. this._boundEvents = Object.create(null);
  6178. this._isViewerInPresentationMode = false;
  6179. this._isPagesLoaded = false;
  6180. this.eventBus.on('presentationmodechanged', function (evt) {
  6181. _this._isViewerInPresentationMode = evt.active || evt.switchInProgress;
  6182. });
  6183. this.eventBus.on('pagesloaded', function (evt) {
  6184. _this._isPagesLoaded = !!evt.pagesCount;
  6185. });
  6186. }
  6187. _createClass(PDFHistory, [{
  6188. key: "initialize",
  6189. value: function initialize(_ref2) {
  6190. var fingerprint = _ref2.fingerprint,
  6191. _ref2$resetHistory = _ref2.resetHistory,
  6192. resetHistory = _ref2$resetHistory === void 0 ? false : _ref2$resetHistory,
  6193. _ref2$updateUrl = _ref2.updateUrl,
  6194. updateUrl = _ref2$updateUrl === void 0 ? false : _ref2$updateUrl;
  6195. if (!fingerprint || typeof fingerprint !== 'string') {
  6196. console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
  6197. return;
  6198. }
  6199. var reInitialized = this.initialized && this.fingerprint !== fingerprint;
  6200. this.fingerprint = fingerprint;
  6201. this._updateUrl = updateUrl === true;
  6202. if (!this.initialized) {
  6203. this._bindEvents();
  6204. }
  6205. var state = window.history.state;
  6206. this.initialized = true;
  6207. this.initialBookmark = null;
  6208. this.initialRotation = null;
  6209. this._popStateInProgress = false;
  6210. this._blockHashChange = 0;
  6211. this._currentHash = getCurrentHash();
  6212. this._numPositionUpdates = 0;
  6213. this._uid = this._maxUid = 0;
  6214. this._destination = null;
  6215. this._position = null;
  6216. if (!this._isValidState(state, true) || resetHistory) {
  6217. var _parseCurrentHash = parseCurrentHash(this.linkService),
  6218. hash = _parseCurrentHash.hash,
  6219. page = _parseCurrentHash.page,
  6220. rotation = _parseCurrentHash.rotation;
  6221. if (!hash || reInitialized || resetHistory) {
  6222. this._pushOrReplaceState(null, true);
  6223. return;
  6224. }
  6225. this._pushOrReplaceState({
  6226. hash: hash,
  6227. page: page,
  6228. rotation: rotation
  6229. }, true);
  6230. return;
  6231. }
  6232. var destination = state.destination;
  6233. this._updateInternalState(destination, state.uid, true);
  6234. if (this._uid > this._maxUid) {
  6235. this._maxUid = this._uid;
  6236. }
  6237. if (destination.rotation !== undefined) {
  6238. this.initialRotation = destination.rotation;
  6239. }
  6240. if (destination.dest) {
  6241. this.initialBookmark = JSON.stringify(destination.dest);
  6242. this._destination.page = null;
  6243. } else if (destination.hash) {
  6244. this.initialBookmark = destination.hash;
  6245. } else if (destination.page) {
  6246. this.initialBookmark = "page=".concat(destination.page);
  6247. }
  6248. }
  6249. }, {
  6250. key: "push",
  6251. value: function push(_ref3) {
  6252. var _this2 = this;
  6253. var _ref3$namedDest = _ref3.namedDest,
  6254. namedDest = _ref3$namedDest === void 0 ? null : _ref3$namedDest,
  6255. explicitDest = _ref3.explicitDest,
  6256. pageNumber = _ref3.pageNumber;
  6257. if (!this.initialized) {
  6258. return;
  6259. }
  6260. if (namedDest && typeof namedDest !== 'string') {
  6261. console.error('PDFHistory.push: ' + "\"".concat(namedDest, "\" is not a valid namedDest parameter."));
  6262. return;
  6263. } else if (!Array.isArray(explicitDest)) {
  6264. console.error('PDFHistory.push: ' + "\"".concat(explicitDest, "\" is not a valid explicitDest parameter."));
  6265. return;
  6266. } else if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {
  6267. if (pageNumber !== null || this._destination) {
  6268. console.error('PDFHistory.push: ' + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  6269. return;
  6270. }
  6271. }
  6272. var hash = namedDest || JSON.stringify(explicitDest);
  6273. if (!hash) {
  6274. return;
  6275. }
  6276. var forceReplace = false;
  6277. if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
  6278. if (this._destination.page) {
  6279. return;
  6280. }
  6281. forceReplace = true;
  6282. }
  6283. if (this._popStateInProgress && !forceReplace) {
  6284. return;
  6285. }
  6286. this._pushOrReplaceState({
  6287. dest: explicitDest,
  6288. hash: hash,
  6289. page: pageNumber,
  6290. rotation: this.linkService.rotation
  6291. }, forceReplace);
  6292. if (!this._popStateInProgress) {
  6293. this._popStateInProgress = true;
  6294. Promise.resolve().then(function () {
  6295. _this2._popStateInProgress = false;
  6296. });
  6297. }
  6298. }
  6299. }, {
  6300. key: "pushCurrentPosition",
  6301. value: function pushCurrentPosition() {
  6302. if (!this.initialized || this._popStateInProgress) {
  6303. return;
  6304. }
  6305. this._tryPushCurrentPosition();
  6306. }
  6307. }, {
  6308. key: "back",
  6309. value: function back() {
  6310. if (!this.initialized || this._popStateInProgress) {
  6311. return;
  6312. }
  6313. var state = window.history.state;
  6314. if (this._isValidState(state) && state.uid > 0) {
  6315. window.history.back();
  6316. }
  6317. }
  6318. }, {
  6319. key: "forward",
  6320. value: function forward() {
  6321. if (!this.initialized || this._popStateInProgress) {
  6322. return;
  6323. }
  6324. var state = window.history.state;
  6325. if (this._isValidState(state) && state.uid < this._maxUid) {
  6326. window.history.forward();
  6327. }
  6328. }
  6329. }, {
  6330. key: "_pushOrReplaceState",
  6331. value: function _pushOrReplaceState(destination) {
  6332. var forceReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6333. var shouldReplace = forceReplace || !this._destination;
  6334. var newState = {
  6335. fingerprint: this.fingerprint,
  6336. uid: shouldReplace ? this._uid : this._uid + 1,
  6337. destination: destination
  6338. };
  6339. this._updateInternalState(destination, newState.uid);
  6340. var newUrl;
  6341. if (this._updateUrl && destination && destination.hash) {
  6342. var baseUrl = document.location.href.split('#')[0];
  6343. if (!baseUrl.startsWith('file://')) {
  6344. newUrl = "".concat(baseUrl, "#").concat(destination.hash);
  6345. }
  6346. }
  6347. if (shouldReplace) {
  6348. if (newUrl) {
  6349. window.history.replaceState(newState, '', newUrl);
  6350. } else {
  6351. window.history.replaceState(newState, '');
  6352. }
  6353. } else {
  6354. this._maxUid = this._uid;
  6355. if (newUrl) {
  6356. window.history.pushState(newState, '', newUrl);
  6357. } else {
  6358. window.history.pushState(newState, '');
  6359. }
  6360. }
  6361. }
  6362. }, {
  6363. key: "_tryPushCurrentPosition",
  6364. value: function _tryPushCurrentPosition() {
  6365. var temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  6366. if (!this._position) {
  6367. return;
  6368. }
  6369. var position = this._position;
  6370. if (temporary) {
  6371. position = Object.assign(Object.create(null), this._position);
  6372. position.temporary = true;
  6373. }
  6374. if (!this._destination) {
  6375. this._pushOrReplaceState(position);
  6376. return;
  6377. }
  6378. if (this._destination.temporary) {
  6379. this._pushOrReplaceState(position, true);
  6380. return;
  6381. }
  6382. if (this._destination.hash === position.hash) {
  6383. return;
  6384. }
  6385. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  6386. return;
  6387. }
  6388. var forceReplace = false;
  6389. if (this._destination.page >= position.first && this._destination.page <= position.page) {
  6390. if (this._destination.dest || !this._destination.first) {
  6391. return;
  6392. }
  6393. forceReplace = true;
  6394. }
  6395. this._pushOrReplaceState(position, forceReplace);
  6396. }
  6397. }, {
  6398. key: "_isValidState",
  6399. value: function _isValidState(state) {
  6400. var checkReload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  6401. if (!state) {
  6402. return false;
  6403. }
  6404. if (state.fingerprint !== this.fingerprint) {
  6405. if (checkReload) {
  6406. if (typeof state.fingerprint !== 'string' || state.fingerprint.length !== this.fingerprint.length) {
  6407. return false;
  6408. }
  6409. var _performance$getEntri = performance.getEntriesByType('navigation'),
  6410. _performance$getEntri2 = _slicedToArray(_performance$getEntri, 1),
  6411. perfEntry = _performance$getEntri2[0];
  6412. if (!perfEntry || perfEntry.type !== 'reload') {
  6413. return false;
  6414. }
  6415. } else {
  6416. return false;
  6417. }
  6418. }
  6419. if (!Number.isInteger(state.uid) || state.uid < 0) {
  6420. return false;
  6421. }
  6422. if (state.destination === null || _typeof(state.destination) !== 'object') {
  6423. return false;
  6424. }
  6425. return true;
  6426. }
  6427. }, {
  6428. key: "_updateInternalState",
  6429. value: function _updateInternalState(destination, uid) {
  6430. var removeTemporary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  6431. if (this._updateViewareaTimeout) {
  6432. clearTimeout(this._updateViewareaTimeout);
  6433. this._updateViewareaTimeout = null;
  6434. }
  6435. if (removeTemporary && destination && destination.temporary) {
  6436. delete destination.temporary;
  6437. }
  6438. this._destination = destination;
  6439. this._uid = uid;
  6440. this._numPositionUpdates = 0;
  6441. }
  6442. }, {
  6443. key: "_updateViewarea",
  6444. value: function _updateViewarea(_ref4) {
  6445. var _this3 = this;
  6446. var location = _ref4.location;
  6447. if (this._updateViewareaTimeout) {
  6448. clearTimeout(this._updateViewareaTimeout);
  6449. this._updateViewareaTimeout = null;
  6450. }
  6451. this._position = {
  6452. hash: this._isViewerInPresentationMode ? "page=".concat(location.pageNumber) : location.pdfOpenParams.substring(1),
  6453. page: this.linkService.page,
  6454. first: location.pageNumber,
  6455. rotation: location.rotation
  6456. };
  6457. if (this._popStateInProgress) {
  6458. return;
  6459. }
  6460. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
  6461. this._numPositionUpdates++;
  6462. }
  6463. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  6464. this._updateViewareaTimeout = setTimeout(function () {
  6465. if (!_this3._popStateInProgress) {
  6466. _this3._tryPushCurrentPosition(true);
  6467. }
  6468. _this3._updateViewareaTimeout = null;
  6469. }, UPDATE_VIEWAREA_TIMEOUT);
  6470. }
  6471. }
  6472. }, {
  6473. key: "_popState",
  6474. value: function _popState(_ref5) {
  6475. var _this4 = this;
  6476. var state = _ref5.state;
  6477. var newHash = getCurrentHash(),
  6478. hashChanged = this._currentHash !== newHash;
  6479. this._currentHash = newHash;
  6480. if (!state || false) {
  6481. this._uid++;
  6482. var _parseCurrentHash2 = parseCurrentHash(this.linkService),
  6483. hash = _parseCurrentHash2.hash,
  6484. page = _parseCurrentHash2.page,
  6485. rotation = _parseCurrentHash2.rotation;
  6486. this._pushOrReplaceState({
  6487. hash: hash,
  6488. page: page,
  6489. rotation: rotation
  6490. }, true);
  6491. return;
  6492. }
  6493. if (!this._isValidState(state)) {
  6494. return;
  6495. }
  6496. this._popStateInProgress = true;
  6497. if (hashChanged) {
  6498. this._blockHashChange++;
  6499. (0, _ui_utils.waitOnEventOrTimeout)({
  6500. target: window,
  6501. name: 'hashchange',
  6502. delay: HASH_CHANGE_TIMEOUT
  6503. }).then(function () {
  6504. _this4._blockHashChange--;
  6505. });
  6506. }
  6507. var destination = state.destination;
  6508. this._updateInternalState(destination, state.uid, true);
  6509. if (this._uid > this._maxUid) {
  6510. this._maxUid = this._uid;
  6511. }
  6512. if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
  6513. this.linkService.rotation = destination.rotation;
  6514. }
  6515. if (destination.dest) {
  6516. this.linkService.navigateTo(destination.dest);
  6517. } else if (destination.hash) {
  6518. this.linkService.setHash(destination.hash);
  6519. } else if (destination.page) {
  6520. this.linkService.page = destination.page;
  6521. }
  6522. Promise.resolve().then(function () {
  6523. _this4._popStateInProgress = false;
  6524. });
  6525. }
  6526. }, {
  6527. key: "_bindEvents",
  6528. value: function _bindEvents() {
  6529. var _this5 = this;
  6530. var _boundEvents = this._boundEvents,
  6531. eventBus = this.eventBus;
  6532. _boundEvents.updateViewarea = this._updateViewarea.bind(this);
  6533. _boundEvents.popState = this._popState.bind(this);
  6534. _boundEvents.pageHide = function (evt) {
  6535. if (!_this5._destination || _this5._destination.temporary) {
  6536. _this5._tryPushCurrentPosition();
  6537. }
  6538. };
  6539. eventBus.on('updateviewarea', _boundEvents.updateViewarea);
  6540. window.addEventListener('popstate', _boundEvents.popState);
  6541. window.addEventListener('pagehide', _boundEvents.pageHide);
  6542. }
  6543. }, {
  6544. key: "popStateInProgress",
  6545. get: function get() {
  6546. return this.initialized && (this._popStateInProgress || this._blockHashChange > 0);
  6547. }
  6548. }]);
  6549. return PDFHistory;
  6550. }();
  6551. exports.PDFHistory = PDFHistory;
  6552. function isDestHashesEqual(destHash, pushHash) {
  6553. if (typeof destHash !== 'string' || typeof pushHash !== 'string') {
  6554. return false;
  6555. }
  6556. if (destHash === pushHash) {
  6557. return true;
  6558. }
  6559. var _parseQueryString = (0, _ui_utils.parseQueryString)(destHash),
  6560. nameddest = _parseQueryString.nameddest;
  6561. if (nameddest === pushHash) {
  6562. return true;
  6563. }
  6564. return false;
  6565. }
  6566. function isDestArraysEqual(firstDest, secondDest) {
  6567. function isEntryEqual(first, second) {
  6568. if (_typeof(first) !== _typeof(second)) {
  6569. return false;
  6570. }
  6571. if (Array.isArray(first) || Array.isArray(second)) {
  6572. return false;
  6573. }
  6574. if (first !== null && _typeof(first) === 'object' && second !== null) {
  6575. if (Object.keys(first).length !== Object.keys(second).length) {
  6576. return false;
  6577. }
  6578. for (var key in first) {
  6579. if (!isEntryEqual(first[key], second[key])) {
  6580. return false;
  6581. }
  6582. }
  6583. return true;
  6584. }
  6585. return first === second || Number.isNaN(first) && Number.isNaN(second);
  6586. }
  6587. if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
  6588. return false;
  6589. }
  6590. if (firstDest.length !== secondDest.length) {
  6591. return false;
  6592. }
  6593. for (var i = 0, ii = firstDest.length; i < ii; i++) {
  6594. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  6595. return false;
  6596. }
  6597. }
  6598. return true;
  6599. }
  6600. /***/ }),
  6601. /* 22 */
  6602. /***/ (function(module, exports, __webpack_require__) {
  6603. "use strict";
  6604. Object.defineProperty(exports, "__esModule", {
  6605. value: true
  6606. });
  6607. exports.SimpleLinkService = exports.PDFLinkService = void 0;
  6608. var _ui_utils = __webpack_require__(6);
  6609. function _typeof(obj) { 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); }
  6610. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6611. 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); } }
  6612. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  6613. var PDFLinkService =
  6614. /*#__PURE__*/
  6615. function () {
  6616. function PDFLinkService() {
  6617. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  6618. eventBus = _ref.eventBus,
  6619. _ref$externalLinkTarg = _ref.externalLinkTarget,
  6620. externalLinkTarget = _ref$externalLinkTarg === void 0 ? null : _ref$externalLinkTarg,
  6621. _ref$externalLinkRel = _ref.externalLinkRel,
  6622. externalLinkRel = _ref$externalLinkRel === void 0 ? null : _ref$externalLinkRel;
  6623. _classCallCheck(this, PDFLinkService);
  6624. this.eventBus = eventBus || (0, _ui_utils.getGlobalEventBus)();
  6625. this.externalLinkTarget = externalLinkTarget;
  6626. this.externalLinkRel = externalLinkRel;
  6627. this.baseUrl = null;
  6628. this.pdfDocument = null;
  6629. this.pdfViewer = null;
  6630. this.pdfHistory = null;
  6631. this._pagesRefCache = null;
  6632. }
  6633. _createClass(PDFLinkService, [{
  6634. key: "setDocument",
  6635. value: function setDocument(pdfDocument) {
  6636. var baseUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  6637. this.baseUrl = baseUrl;
  6638. this.pdfDocument = pdfDocument;
  6639. this._pagesRefCache = Object.create(null);
  6640. }
  6641. }, {
  6642. key: "setViewer",
  6643. value: function setViewer(pdfViewer) {
  6644. this.pdfViewer = pdfViewer;
  6645. }
  6646. }, {
  6647. key: "setHistory",
  6648. value: function setHistory(pdfHistory) {
  6649. this.pdfHistory = pdfHistory;
  6650. }
  6651. }, {
  6652. key: "navigateTo",
  6653. value: function navigateTo(dest) {
  6654. var _this = this;
  6655. var goToDestination = function goToDestination(_ref2) {
  6656. var namedDest = _ref2.namedDest,
  6657. explicitDest = _ref2.explicitDest;
  6658. var destRef = explicitDest[0],
  6659. pageNumber;
  6660. if (destRef instanceof Object) {
  6661. pageNumber = _this._cachedPageNumber(destRef);
  6662. if (pageNumber === null) {
  6663. _this.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
  6664. _this.cachePageRef(pageIndex + 1, destRef);
  6665. goToDestination({
  6666. namedDest: namedDest,
  6667. explicitDest: explicitDest
  6668. });
  6669. }).catch(function () {
  6670. console.error("PDFLinkService.navigateTo: \"".concat(destRef, "\" is not ") + "a valid page reference, for dest=\"".concat(dest, "\"."));
  6671. });
  6672. return;
  6673. }
  6674. } else if (Number.isInteger(destRef)) {
  6675. pageNumber = destRef + 1;
  6676. } else {
  6677. console.error("PDFLinkService.navigateTo: \"".concat(destRef, "\" is not ") + "a valid destination reference, for dest=\"".concat(dest, "\"."));
  6678. return;
  6679. }
  6680. if (!pageNumber || pageNumber < 1 || pageNumber > _this.pagesCount) {
  6681. console.error("PDFLinkService.navigateTo: \"".concat(pageNumber, "\" is not ") + "a valid page number, for dest=\"".concat(dest, "\"."));
  6682. return;
  6683. }
  6684. if (_this.pdfHistory) {
  6685. _this.pdfHistory.pushCurrentPosition();
  6686. _this.pdfHistory.push({
  6687. namedDest: namedDest,
  6688. explicitDest: explicitDest,
  6689. pageNumber: pageNumber
  6690. });
  6691. }
  6692. _this.pdfViewer.scrollPageIntoView({
  6693. pageNumber: pageNumber,
  6694. destArray: explicitDest
  6695. });
  6696. };
  6697. new Promise(function (resolve, reject) {
  6698. if (typeof dest === 'string') {
  6699. _this.pdfDocument.getDestination(dest).then(function (destArray) {
  6700. resolve({
  6701. namedDest: dest,
  6702. explicitDest: destArray
  6703. });
  6704. });
  6705. return;
  6706. }
  6707. resolve({
  6708. namedDest: '',
  6709. explicitDest: dest
  6710. });
  6711. }).then(function (data) {
  6712. if (!Array.isArray(data.explicitDest)) {
  6713. console.error("PDFLinkService.navigateTo: \"".concat(data.explicitDest, "\" is") + " not a valid destination array, for dest=\"".concat(dest, "\"."));
  6714. return;
  6715. }
  6716. goToDestination(data);
  6717. });
  6718. }
  6719. }, {
  6720. key: "getDestinationHash",
  6721. value: function getDestinationHash(dest) {
  6722. if (typeof dest === 'string') {
  6723. return this.getAnchorUrl('#' + escape(dest));
  6724. }
  6725. if (Array.isArray(dest)) {
  6726. var str = JSON.stringify(dest);
  6727. return this.getAnchorUrl('#' + escape(str));
  6728. }
  6729. return this.getAnchorUrl('');
  6730. }
  6731. }, {
  6732. key: "getAnchorUrl",
  6733. value: function getAnchorUrl(anchor) {
  6734. return (this.baseUrl || '') + anchor;
  6735. }
  6736. }, {
  6737. key: "setHash",
  6738. value: function setHash(hash) {
  6739. var pageNumber, dest;
  6740. if (hash.includes('=')) {
  6741. var params = (0, _ui_utils.parseQueryString)(hash);
  6742. if ('search' in params) {
  6743. this.eventBus.dispatch('findfromurlhash', {
  6744. source: this,
  6745. query: params['search'].replace(/"/g, ''),
  6746. phraseSearch: params['phrase'] === 'true'
  6747. });
  6748. }
  6749. if ('nameddest' in params) {
  6750. this.navigateTo(params.nameddest);
  6751. return;
  6752. }
  6753. if ('page' in params) {
  6754. pageNumber = params.page | 0 || 1;
  6755. }
  6756. if ('zoom' in params) {
  6757. var zoomArgs = params.zoom.split(',');
  6758. var zoomArg = zoomArgs[0];
  6759. var zoomArgNumber = parseFloat(zoomArg);
  6760. if (!zoomArg.includes('Fit')) {
  6761. dest = [null, {
  6762. name: 'XYZ'
  6763. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
  6764. } else {
  6765. if (zoomArg === 'Fit' || zoomArg === 'FitB') {
  6766. dest = [null, {
  6767. name: zoomArg
  6768. }];
  6769. } else if (zoomArg === 'FitH' || zoomArg === 'FitBH' || zoomArg === 'FitV' || zoomArg === 'FitBV') {
  6770. dest = [null, {
  6771. name: zoomArg
  6772. }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  6773. } else if (zoomArg === 'FitR') {
  6774. if (zoomArgs.length !== 5) {
  6775. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
  6776. } else {
  6777. dest = [null, {
  6778. name: zoomArg
  6779. }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
  6780. }
  6781. } else {
  6782. console.error("PDFLinkService.setHash: \"".concat(zoomArg, "\" is not ") + 'a valid zoom value.');
  6783. }
  6784. }
  6785. }
  6786. if (dest) {
  6787. this.pdfViewer.scrollPageIntoView({
  6788. pageNumber: pageNumber || this.page,
  6789. destArray: dest,
  6790. allowNegativeOffset: true
  6791. });
  6792. } else if (pageNumber) {
  6793. this.page = pageNumber;
  6794. }
  6795. if ('pagemode' in params) {
  6796. this.eventBus.dispatch('pagemode', {
  6797. source: this,
  6798. mode: params.pagemode
  6799. });
  6800. }
  6801. } else {
  6802. dest = unescape(hash);
  6803. try {
  6804. dest = JSON.parse(dest);
  6805. if (!Array.isArray(dest)) {
  6806. dest = dest.toString();
  6807. }
  6808. } catch (ex) {}
  6809. if (typeof dest === 'string' || isValidExplicitDestination(dest)) {
  6810. this.navigateTo(dest);
  6811. return;
  6812. }
  6813. console.error("PDFLinkService.setHash: \"".concat(unescape(hash), "\" is not ") + 'a valid destination.');
  6814. }
  6815. }
  6816. }, {
  6817. key: "executeNamedAction",
  6818. value: function executeNamedAction(action) {
  6819. switch (action) {
  6820. case 'GoBack':
  6821. if (this.pdfHistory) {
  6822. this.pdfHistory.back();
  6823. }
  6824. break;
  6825. case 'GoForward':
  6826. if (this.pdfHistory) {
  6827. this.pdfHistory.forward();
  6828. }
  6829. break;
  6830. case 'NextPage':
  6831. if (this.page < this.pagesCount) {
  6832. this.page++;
  6833. }
  6834. break;
  6835. case 'PrevPage':
  6836. if (this.page > 1) {
  6837. this.page--;
  6838. }
  6839. break;
  6840. case 'LastPage':
  6841. this.page = this.pagesCount;
  6842. break;
  6843. case 'FirstPage':
  6844. this.page = 1;
  6845. break;
  6846. default:
  6847. break;
  6848. }
  6849. this.eventBus.dispatch('namedaction', {
  6850. source: this,
  6851. action: action
  6852. });
  6853. }
  6854. }, {
  6855. key: "cachePageRef",
  6856. value: function cachePageRef(pageNum, pageRef) {
  6857. if (!pageRef) {
  6858. return;
  6859. }
  6860. var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
  6861. this._pagesRefCache[refStr] = pageNum;
  6862. }
  6863. }, {
  6864. key: "_cachedPageNumber",
  6865. value: function _cachedPageNumber(pageRef) {
  6866. var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
  6867. return this._pagesRefCache && this._pagesRefCache[refStr] || null;
  6868. }
  6869. }, {
  6870. key: "isPageVisible",
  6871. value: function isPageVisible(pageNumber) {
  6872. return this.pdfViewer.isPageVisible(pageNumber);
  6873. }
  6874. }, {
  6875. key: "pagesCount",
  6876. get: function get() {
  6877. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  6878. }
  6879. }, {
  6880. key: "page",
  6881. get: function get() {
  6882. return this.pdfViewer.currentPageNumber;
  6883. },
  6884. set: function set(value) {
  6885. this.pdfViewer.currentPageNumber = value;
  6886. }
  6887. }, {
  6888. key: "rotation",
  6889. get: function get() {
  6890. return this.pdfViewer.pagesRotation;
  6891. },
  6892. set: function set(value) {
  6893. this.pdfViewer.pagesRotation = value;
  6894. }
  6895. }]);
  6896. return PDFLinkService;
  6897. }();
  6898. exports.PDFLinkService = PDFLinkService;
  6899. function isValidExplicitDestination(dest) {
  6900. if (!Array.isArray(dest)) {
  6901. return false;
  6902. }
  6903. var destLength = dest.length,
  6904. allowNull = true;
  6905. if (destLength < 2) {
  6906. return false;
  6907. }
  6908. var page = dest[0];
  6909. if (!(_typeof(page) === 'object' && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
  6910. return false;
  6911. }
  6912. var zoom = dest[1];
  6913. if (!(_typeof(zoom) === 'object' && typeof zoom.name === 'string')) {
  6914. return false;
  6915. }
  6916. switch (zoom.name) {
  6917. case 'XYZ':
  6918. if (destLength !== 5) {
  6919. return false;
  6920. }
  6921. break;
  6922. case 'Fit':
  6923. case 'FitB':
  6924. return destLength === 2;
  6925. case 'FitH':
  6926. case 'FitBH':
  6927. case 'FitV':
  6928. case 'FitBV':
  6929. if (destLength !== 3) {
  6930. return false;
  6931. }
  6932. break;
  6933. case 'FitR':
  6934. if (destLength !== 6) {
  6935. return false;
  6936. }
  6937. allowNull = false;
  6938. break;
  6939. default:
  6940. return false;
  6941. }
  6942. for (var i = 2; i < destLength; i++) {
  6943. var param = dest[i];
  6944. if (!(typeof param === 'number' || allowNull && param === null)) {
  6945. return false;
  6946. }
  6947. }
  6948. return true;
  6949. }
  6950. var SimpleLinkService =
  6951. /*#__PURE__*/
  6952. function () {
  6953. function SimpleLinkService() {
  6954. _classCallCheck(this, SimpleLinkService);
  6955. this.externalLinkTarget = null;
  6956. this.externalLinkRel = null;
  6957. }
  6958. _createClass(SimpleLinkService, [{
  6959. key: "navigateTo",
  6960. value: function navigateTo(dest) {}
  6961. }, {
  6962. key: "getDestinationHash",
  6963. value: function getDestinationHash(dest) {
  6964. return '#';
  6965. }
  6966. }, {
  6967. key: "getAnchorUrl",
  6968. value: function getAnchorUrl(hash) {
  6969. return '#';
  6970. }
  6971. }, {
  6972. key: "setHash",
  6973. value: function setHash(hash) {}
  6974. }, {
  6975. key: "executeNamedAction",
  6976. value: function executeNamedAction(action) {}
  6977. }, {
  6978. key: "cachePageRef",
  6979. value: function cachePageRef(pageNum, pageRef) {}
  6980. }, {
  6981. key: "isPageVisible",
  6982. value: function isPageVisible(pageNumber) {
  6983. return true;
  6984. }
  6985. }, {
  6986. key: "pagesCount",
  6987. get: function get() {
  6988. return 0;
  6989. }
  6990. }, {
  6991. key: "page",
  6992. get: function get() {
  6993. return 0;
  6994. },
  6995. set: function set(value) {}
  6996. }, {
  6997. key: "rotation",
  6998. get: function get() {
  6999. return 0;
  7000. },
  7001. set: function set(value) {}
  7002. }]);
  7003. return SimpleLinkService;
  7004. }();
  7005. exports.SimpleLinkService = SimpleLinkService;
  7006. /***/ }),
  7007. /* 23 */
  7008. /***/ (function(module, exports, __webpack_require__) {
  7009. "use strict";
  7010. Object.defineProperty(exports, "__esModule", {
  7011. value: true
  7012. });
  7013. exports.PDFOutlineViewer = void 0;
  7014. var _pdfjsLib = __webpack_require__(7);
  7015. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7016. 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); } }
  7017. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7018. var DEFAULT_TITLE = "\u2013";
  7019. var PDFOutlineViewer =
  7020. /*#__PURE__*/
  7021. function () {
  7022. function PDFOutlineViewer(_ref) {
  7023. var container = _ref.container,
  7024. linkService = _ref.linkService,
  7025. eventBus = _ref.eventBus;
  7026. _classCallCheck(this, PDFOutlineViewer);
  7027. this.container = container;
  7028. this.linkService = linkService;
  7029. this.eventBus = eventBus;
  7030. this.reset();
  7031. eventBus.on('toggleoutlinetree', this.toggleOutlineTree.bind(this));
  7032. }
  7033. _createClass(PDFOutlineViewer, [{
  7034. key: "reset",
  7035. value: function reset() {
  7036. this.outline = null;
  7037. this.lastToggleIsShow = true;
  7038. this.container.textContent = '';
  7039. this.container.classList.remove('outlineWithDeepNesting');
  7040. }
  7041. }, {
  7042. key: "_dispatchEvent",
  7043. value: function _dispatchEvent(outlineCount) {
  7044. this.eventBus.dispatch('outlineloaded', {
  7045. source: this,
  7046. outlineCount: outlineCount
  7047. });
  7048. }
  7049. }, {
  7050. key: "_bindLink",
  7051. value: function _bindLink(element, _ref2) {
  7052. var url = _ref2.url,
  7053. newWindow = _ref2.newWindow,
  7054. dest = _ref2.dest;
  7055. var linkService = this.linkService;
  7056. if (url) {
  7057. (0, _pdfjsLib.addLinkAttributes)(element, {
  7058. url: url,
  7059. target: newWindow ? _pdfjsLib.LinkTarget.BLANK : linkService.externalLinkTarget,
  7060. rel: linkService.externalLinkRel
  7061. });
  7062. return;
  7063. }
  7064. element.href = linkService.getDestinationHash(dest);
  7065. element.onclick = function () {
  7066. if (dest) {
  7067. linkService.navigateTo(dest);
  7068. }
  7069. return false;
  7070. };
  7071. }
  7072. }, {
  7073. key: "_setStyles",
  7074. value: function _setStyles(element, _ref3) {
  7075. var bold = _ref3.bold,
  7076. italic = _ref3.italic;
  7077. var styleStr = '';
  7078. if (bold) {
  7079. styleStr += 'font-weight: bold;';
  7080. }
  7081. if (italic) {
  7082. styleStr += 'font-style: italic;';
  7083. }
  7084. if (styleStr) {
  7085. element.setAttribute('style', styleStr);
  7086. }
  7087. }
  7088. }, {
  7089. key: "_addToggleButton",
  7090. value: function _addToggleButton(div) {
  7091. var _this = this;
  7092. var toggler = document.createElement('div');
  7093. toggler.className = 'outlineItemToggler';
  7094. toggler.onclick = function (evt) {
  7095. evt.stopPropagation();
  7096. toggler.classList.toggle('outlineItemsHidden');
  7097. if (evt.shiftKey) {
  7098. var shouldShowAll = !toggler.classList.contains('outlineItemsHidden');
  7099. _this._toggleOutlineItem(div, shouldShowAll);
  7100. }
  7101. };
  7102. div.insertBefore(toggler, div.firstChild);
  7103. }
  7104. }, {
  7105. key: "_toggleOutlineItem",
  7106. value: function _toggleOutlineItem(root) {
  7107. var show = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7108. this.lastToggleIsShow = show;
  7109. var _iteratorNormalCompletion = true;
  7110. var _didIteratorError = false;
  7111. var _iteratorError = undefined;
  7112. try {
  7113. for (var _iterator = root.querySelectorAll('.outlineItemToggler')[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  7114. var toggler = _step.value;
  7115. toggler.classList.toggle('outlineItemsHidden', !show);
  7116. }
  7117. } catch (err) {
  7118. _didIteratorError = true;
  7119. _iteratorError = err;
  7120. } finally {
  7121. try {
  7122. if (!_iteratorNormalCompletion && _iterator.return != null) {
  7123. _iterator.return();
  7124. }
  7125. } finally {
  7126. if (_didIteratorError) {
  7127. throw _iteratorError;
  7128. }
  7129. }
  7130. }
  7131. }
  7132. }, {
  7133. key: "toggleOutlineTree",
  7134. value: function toggleOutlineTree() {
  7135. if (!this.outline) {
  7136. return;
  7137. }
  7138. this._toggleOutlineItem(this.container, !this.lastToggleIsShow);
  7139. }
  7140. }, {
  7141. key: "render",
  7142. value: function render(_ref4) {
  7143. var outline = _ref4.outline;
  7144. var outlineCount = 0;
  7145. if (this.outline) {
  7146. this.reset();
  7147. }
  7148. this.outline = outline || null;
  7149. if (!outline) {
  7150. this._dispatchEvent(outlineCount);
  7151. return;
  7152. }
  7153. var fragment = document.createDocumentFragment();
  7154. var queue = [{
  7155. parent: fragment,
  7156. items: this.outline
  7157. }];
  7158. var hasAnyNesting = false;
  7159. while (queue.length > 0) {
  7160. var levelData = queue.shift();
  7161. for (var i = 0, len = levelData.items.length; i < len; i++) {
  7162. var item = levelData.items[i];
  7163. var div = document.createElement('div');
  7164. div.className = 'outlineItem';
  7165. var element = document.createElement('a');
  7166. this._bindLink(element, item);
  7167. this._setStyles(element, item);
  7168. element.textContent = (0, _pdfjsLib.removeNullCharacters)(item.title) || DEFAULT_TITLE;
  7169. div.appendChild(element);
  7170. if (item.items.length > 0) {
  7171. hasAnyNesting = true;
  7172. this._addToggleButton(div);
  7173. var itemsDiv = document.createElement('div');
  7174. itemsDiv.className = 'outlineItems';
  7175. div.appendChild(itemsDiv);
  7176. queue.push({
  7177. parent: itemsDiv,
  7178. items: item.items
  7179. });
  7180. }
  7181. levelData.parent.appendChild(div);
  7182. outlineCount++;
  7183. }
  7184. }
  7185. if (hasAnyNesting) {
  7186. this.container.classList.add('outlineWithDeepNesting');
  7187. }
  7188. this.container.appendChild(fragment);
  7189. this._dispatchEvent(outlineCount);
  7190. }
  7191. }]);
  7192. return PDFOutlineViewer;
  7193. }();
  7194. exports.PDFOutlineViewer = PDFOutlineViewer;
  7195. /***/ }),
  7196. /* 24 */
  7197. /***/ (function(module, exports, __webpack_require__) {
  7198. "use strict";
  7199. Object.defineProperty(exports, "__esModule", {
  7200. value: true
  7201. });
  7202. exports.PDFPresentationMode = void 0;
  7203. var _ui_utils = __webpack_require__(6);
  7204. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7205. 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); } }
  7206. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7207. var DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1500;
  7208. var DELAY_BEFORE_HIDING_CONTROLS = 3000;
  7209. var ACTIVE_SELECTOR = 'pdfPresentationMode';
  7210. var CONTROLS_SELECTOR = 'pdfPresentationModeControls';
  7211. var MOUSE_SCROLL_COOLDOWN_TIME = 50;
  7212. var PAGE_SWITCH_THRESHOLD = 0.1;
  7213. var SWIPE_MIN_DISTANCE_THRESHOLD = 50;
  7214. var SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
  7215. var PDFPresentationMode =
  7216. /*#__PURE__*/
  7217. function () {
  7218. function PDFPresentationMode(_ref) {
  7219. var _this = this;
  7220. var container = _ref.container,
  7221. _ref$viewer = _ref.viewer,
  7222. viewer = _ref$viewer === void 0 ? null : _ref$viewer,
  7223. pdfViewer = _ref.pdfViewer,
  7224. eventBus = _ref.eventBus,
  7225. _ref$contextMenuItems = _ref.contextMenuItems,
  7226. contextMenuItems = _ref$contextMenuItems === void 0 ? null : _ref$contextMenuItems;
  7227. _classCallCheck(this, PDFPresentationMode);
  7228. this.container = container;
  7229. this.viewer = viewer || container.firstElementChild;
  7230. this.pdfViewer = pdfViewer;
  7231. this.eventBus = eventBus;
  7232. this.active = false;
  7233. this.args = null;
  7234. this.contextMenuOpen = false;
  7235. this.mouseScrollTimeStamp = 0;
  7236. this.mouseScrollDelta = 0;
  7237. this.touchSwipeState = null;
  7238. if (contextMenuItems) {
  7239. contextMenuItems.contextFirstPage.addEventListener('click', function () {
  7240. _this.contextMenuOpen = false;
  7241. _this.eventBus.dispatch('firstpage', {
  7242. source: _this
  7243. });
  7244. });
  7245. contextMenuItems.contextLastPage.addEventListener('click', function () {
  7246. _this.contextMenuOpen = false;
  7247. _this.eventBus.dispatch('lastpage', {
  7248. source: _this
  7249. });
  7250. });
  7251. contextMenuItems.contextPageRotateCw.addEventListener('click', function () {
  7252. _this.contextMenuOpen = false;
  7253. _this.eventBus.dispatch('rotatecw', {
  7254. source: _this
  7255. });
  7256. });
  7257. contextMenuItems.contextPageRotateCcw.addEventListener('click', function () {
  7258. _this.contextMenuOpen = false;
  7259. _this.eventBus.dispatch('rotateccw', {
  7260. source: _this
  7261. });
  7262. });
  7263. }
  7264. }
  7265. _createClass(PDFPresentationMode, [{
  7266. key: "request",
  7267. value: function request() {
  7268. if (this.switchInProgress || this.active || !this.viewer.hasChildNodes()) {
  7269. return false;
  7270. }
  7271. this._addFullscreenChangeListeners();
  7272. this._setSwitchInProgress();
  7273. this._notifyStateChange();
  7274. if (this.container.requestFullscreen) {
  7275. this.container.requestFullscreen();
  7276. } else if (this.container.mozRequestFullScreen) {
  7277. this.container.mozRequestFullScreen();
  7278. } else if (this.container.webkitRequestFullscreen) {
  7279. this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
  7280. } else if (this.container.msRequestFullscreen) {
  7281. this.container.msRequestFullscreen();
  7282. } else {
  7283. return false;
  7284. }
  7285. this.args = {
  7286. page: this.pdfViewer.currentPageNumber,
  7287. previousScale: this.pdfViewer.currentScaleValue
  7288. };
  7289. return true;
  7290. }
  7291. }, {
  7292. key: "_mouseWheel",
  7293. value: function _mouseWheel(evt) {
  7294. if (!this.active) {
  7295. return;
  7296. }
  7297. evt.preventDefault();
  7298. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  7299. var currentTime = new Date().getTime();
  7300. var storedTime = this.mouseScrollTimeStamp;
  7301. if (currentTime > storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {
  7302. return;
  7303. }
  7304. if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) {
  7305. this._resetMouseScrollState();
  7306. }
  7307. this.mouseScrollDelta += delta;
  7308. if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
  7309. var totalDelta = this.mouseScrollDelta;
  7310. this._resetMouseScrollState();
  7311. var success = totalDelta > 0 ? this._goToPreviousPage() : this._goToNextPage();
  7312. if (success) {
  7313. this.mouseScrollTimeStamp = currentTime;
  7314. }
  7315. }
  7316. }
  7317. }, {
  7318. key: "_goToPreviousPage",
  7319. value: function _goToPreviousPage() {
  7320. var page = this.pdfViewer.currentPageNumber;
  7321. if (page <= 1) {
  7322. return false;
  7323. }
  7324. this.pdfViewer.currentPageNumber = page - 1;
  7325. return true;
  7326. }
  7327. }, {
  7328. key: "_goToNextPage",
  7329. value: function _goToNextPage() {
  7330. var page = this.pdfViewer.currentPageNumber;
  7331. if (page >= this.pdfViewer.pagesCount) {
  7332. return false;
  7333. }
  7334. this.pdfViewer.currentPageNumber = page + 1;
  7335. return true;
  7336. }
  7337. }, {
  7338. key: "_notifyStateChange",
  7339. value: function _notifyStateChange() {
  7340. this.eventBus.dispatch('presentationmodechanged', {
  7341. source: this,
  7342. active: this.active,
  7343. switchInProgress: !!this.switchInProgress
  7344. });
  7345. }
  7346. }, {
  7347. key: "_setSwitchInProgress",
  7348. value: function _setSwitchInProgress() {
  7349. var _this2 = this;
  7350. if (this.switchInProgress) {
  7351. clearTimeout(this.switchInProgress);
  7352. }
  7353. this.switchInProgress = setTimeout(function () {
  7354. _this2._removeFullscreenChangeListeners();
  7355. delete _this2.switchInProgress;
  7356. _this2._notifyStateChange();
  7357. }, DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS);
  7358. }
  7359. }, {
  7360. key: "_resetSwitchInProgress",
  7361. value: function _resetSwitchInProgress() {
  7362. if (this.switchInProgress) {
  7363. clearTimeout(this.switchInProgress);
  7364. delete this.switchInProgress;
  7365. }
  7366. }
  7367. }, {
  7368. key: "_enter",
  7369. value: function _enter() {
  7370. var _this3 = this;
  7371. this.active = true;
  7372. this._resetSwitchInProgress();
  7373. this._notifyStateChange();
  7374. this.container.classList.add(ACTIVE_SELECTOR);
  7375. setTimeout(function () {
  7376. _this3.pdfViewer.currentPageNumber = _this3.args.page;
  7377. _this3.pdfViewer.currentScaleValue = 'page-fit';
  7378. }, 0);
  7379. this._addWindowListeners();
  7380. this._showControls();
  7381. this.contextMenuOpen = false;
  7382. this.container.setAttribute('contextmenu', 'viewerContextMenu');
  7383. window.getSelection().removeAllRanges();
  7384. }
  7385. }, {
  7386. key: "_exit",
  7387. value: function _exit() {
  7388. var _this4 = this;
  7389. var page = this.pdfViewer.currentPageNumber;
  7390. this.container.classList.remove(ACTIVE_SELECTOR);
  7391. setTimeout(function () {
  7392. _this4.active = false;
  7393. _this4._removeFullscreenChangeListeners();
  7394. _this4._notifyStateChange();
  7395. _this4.pdfViewer.currentScaleValue = _this4.args.previousScale;
  7396. _this4.pdfViewer.currentPageNumber = page;
  7397. _this4.args = null;
  7398. }, 0);
  7399. this._removeWindowListeners();
  7400. this._hideControls();
  7401. this._resetMouseScrollState();
  7402. this.container.removeAttribute('contextmenu');
  7403. this.contextMenuOpen = false;
  7404. }
  7405. }, {
  7406. key: "_mouseDown",
  7407. value: function _mouseDown(evt) {
  7408. if (this.contextMenuOpen) {
  7409. this.contextMenuOpen = false;
  7410. evt.preventDefault();
  7411. return;
  7412. }
  7413. if (evt.button === 0) {
  7414. var isInternalLink = evt.target.href && evt.target.classList.contains('internalLink');
  7415. if (!isInternalLink) {
  7416. evt.preventDefault();
  7417. if (evt.shiftKey) {
  7418. this._goToPreviousPage();
  7419. } else {
  7420. this._goToNextPage();
  7421. }
  7422. }
  7423. }
  7424. }
  7425. }, {
  7426. key: "_contextMenu",
  7427. value: function _contextMenu() {
  7428. this.contextMenuOpen = true;
  7429. }
  7430. }, {
  7431. key: "_showControls",
  7432. value: function _showControls() {
  7433. var _this5 = this;
  7434. if (this.controlsTimeout) {
  7435. clearTimeout(this.controlsTimeout);
  7436. } else {
  7437. this.container.classList.add(CONTROLS_SELECTOR);
  7438. }
  7439. this.controlsTimeout = setTimeout(function () {
  7440. _this5.container.classList.remove(CONTROLS_SELECTOR);
  7441. delete _this5.controlsTimeout;
  7442. }, DELAY_BEFORE_HIDING_CONTROLS);
  7443. }
  7444. }, {
  7445. key: "_hideControls",
  7446. value: function _hideControls() {
  7447. if (!this.controlsTimeout) {
  7448. return;
  7449. }
  7450. clearTimeout(this.controlsTimeout);
  7451. this.container.classList.remove(CONTROLS_SELECTOR);
  7452. delete this.controlsTimeout;
  7453. }
  7454. }, {
  7455. key: "_resetMouseScrollState",
  7456. value: function _resetMouseScrollState() {
  7457. this.mouseScrollTimeStamp = 0;
  7458. this.mouseScrollDelta = 0;
  7459. }
  7460. }, {
  7461. key: "_touchSwipe",
  7462. value: function _touchSwipe(evt) {
  7463. if (!this.active) {
  7464. return;
  7465. }
  7466. if (evt.touches.length > 1) {
  7467. this.touchSwipeState = null;
  7468. return;
  7469. }
  7470. switch (evt.type) {
  7471. case 'touchstart':
  7472. this.touchSwipeState = {
  7473. startX: evt.touches[0].pageX,
  7474. startY: evt.touches[0].pageY,
  7475. endX: evt.touches[0].pageX,
  7476. endY: evt.touches[0].pageY
  7477. };
  7478. break;
  7479. case 'touchmove':
  7480. if (this.touchSwipeState === null) {
  7481. return;
  7482. }
  7483. this.touchSwipeState.endX = evt.touches[0].pageX;
  7484. this.touchSwipeState.endY = evt.touches[0].pageY;
  7485. evt.preventDefault();
  7486. break;
  7487. case 'touchend':
  7488. if (this.touchSwipeState === null) {
  7489. return;
  7490. }
  7491. var delta = 0;
  7492. var dx = this.touchSwipeState.endX - this.touchSwipeState.startX;
  7493. var dy = this.touchSwipeState.endY - this.touchSwipeState.startY;
  7494. var absAngle = Math.abs(Math.atan2(dy, dx));
  7495. if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <= SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI - SWIPE_ANGLE_THRESHOLD)) {
  7496. delta = dx;
  7497. } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math.abs(absAngle - Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) {
  7498. delta = dy;
  7499. }
  7500. if (delta > 0) {
  7501. this._goToPreviousPage();
  7502. } else if (delta < 0) {
  7503. this._goToNextPage();
  7504. }
  7505. break;
  7506. }
  7507. }
  7508. }, {
  7509. key: "_addWindowListeners",
  7510. value: function _addWindowListeners() {
  7511. this.showControlsBind = this._showControls.bind(this);
  7512. this.mouseDownBind = this._mouseDown.bind(this);
  7513. this.mouseWheelBind = this._mouseWheel.bind(this);
  7514. this.resetMouseScrollStateBind = this._resetMouseScrollState.bind(this);
  7515. this.contextMenuBind = this._contextMenu.bind(this);
  7516. this.touchSwipeBind = this._touchSwipe.bind(this);
  7517. window.addEventListener('mousemove', this.showControlsBind);
  7518. window.addEventListener('mousedown', this.mouseDownBind);
  7519. window.addEventListener('wheel', this.mouseWheelBind);
  7520. window.addEventListener('keydown', this.resetMouseScrollStateBind);
  7521. window.addEventListener('contextmenu', this.contextMenuBind);
  7522. window.addEventListener('touchstart', this.touchSwipeBind);
  7523. window.addEventListener('touchmove', this.touchSwipeBind);
  7524. window.addEventListener('touchend', this.touchSwipeBind);
  7525. }
  7526. }, {
  7527. key: "_removeWindowListeners",
  7528. value: function _removeWindowListeners() {
  7529. window.removeEventListener('mousemove', this.showControlsBind);
  7530. window.removeEventListener('mousedown', this.mouseDownBind);
  7531. window.removeEventListener('wheel', this.mouseWheelBind);
  7532. window.removeEventListener('keydown', this.resetMouseScrollStateBind);
  7533. window.removeEventListener('contextmenu', this.contextMenuBind);
  7534. window.removeEventListener('touchstart', this.touchSwipeBind);
  7535. window.removeEventListener('touchmove', this.touchSwipeBind);
  7536. window.removeEventListener('touchend', this.touchSwipeBind);
  7537. delete this.showControlsBind;
  7538. delete this.mouseDownBind;
  7539. delete this.mouseWheelBind;
  7540. delete this.resetMouseScrollStateBind;
  7541. delete this.contextMenuBind;
  7542. delete this.touchSwipeBind;
  7543. }
  7544. }, {
  7545. key: "_fullscreenChange",
  7546. value: function _fullscreenChange() {
  7547. if (this.isFullscreen) {
  7548. this._enter();
  7549. } else {
  7550. this._exit();
  7551. }
  7552. }
  7553. }, {
  7554. key: "_addFullscreenChangeListeners",
  7555. value: function _addFullscreenChangeListeners() {
  7556. this.fullscreenChangeBind = this._fullscreenChange.bind(this);
  7557. window.addEventListener('fullscreenchange', this.fullscreenChangeBind);
  7558. window.addEventListener('mozfullscreenchange', this.fullscreenChangeBind);
  7559. window.addEventListener('webkitfullscreenchange', this.fullscreenChangeBind);
  7560. window.addEventListener('MSFullscreenChange', this.fullscreenChangeBind);
  7561. }
  7562. }, {
  7563. key: "_removeFullscreenChangeListeners",
  7564. value: function _removeFullscreenChangeListeners() {
  7565. window.removeEventListener('fullscreenchange', this.fullscreenChangeBind);
  7566. window.removeEventListener('mozfullscreenchange', this.fullscreenChangeBind);
  7567. window.removeEventListener('webkitfullscreenchange', this.fullscreenChangeBind);
  7568. window.removeEventListener('MSFullscreenChange', this.fullscreenChangeBind);
  7569. delete this.fullscreenChangeBind;
  7570. }
  7571. }, {
  7572. key: "isFullscreen",
  7573. get: function get() {
  7574. return !!(document.fullscreenElement || document.mozFullScreen || document.webkitIsFullScreen || document.msFullscreenElement);
  7575. }
  7576. }]);
  7577. return PDFPresentationMode;
  7578. }();
  7579. exports.PDFPresentationMode = PDFPresentationMode;
  7580. /***/ }),
  7581. /* 25 */
  7582. /***/ (function(module, exports, __webpack_require__) {
  7583. "use strict";
  7584. Object.defineProperty(exports, "__esModule", {
  7585. value: true
  7586. });
  7587. exports.PDFSidebarResizer = void 0;
  7588. var _ui_utils = __webpack_require__(6);
  7589. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7590. 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); } }
  7591. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7592. var SIDEBAR_WIDTH_VAR = '--sidebar-width';
  7593. var SIDEBAR_MIN_WIDTH = 200;
  7594. var SIDEBAR_RESIZING_CLASS = 'sidebarResizing';
  7595. var PDFSidebarResizer =
  7596. /*#__PURE__*/
  7597. function () {
  7598. function PDFSidebarResizer(options, eventBus) {
  7599. var _this = this;
  7600. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  7601. _classCallCheck(this, PDFSidebarResizer);
  7602. this.enabled = false;
  7603. this.isRTL = false;
  7604. this.sidebarOpen = false;
  7605. this.doc = document.documentElement;
  7606. this._width = null;
  7607. this._outerContainerWidth = null;
  7608. this._boundEvents = Object.create(null);
  7609. this.outerContainer = options.outerContainer;
  7610. this.resizer = options.resizer;
  7611. this.eventBus = eventBus;
  7612. this.l10n = l10n;
  7613. if (typeof CSS === 'undefined' || typeof CSS.supports !== 'function' || !CSS.supports(SIDEBAR_WIDTH_VAR, "calc(-1 * ".concat(SIDEBAR_MIN_WIDTH, "px)"))) {
  7614. console.warn('PDFSidebarResizer: ' + 'The browser does not support resizing of the sidebar.');
  7615. return;
  7616. }
  7617. this.enabled = true;
  7618. this.resizer.classList.remove('hidden');
  7619. this.l10n.getDirection().then(function (dir) {
  7620. _this.isRTL = dir === 'rtl';
  7621. });
  7622. this._addEventListeners();
  7623. }
  7624. _createClass(PDFSidebarResizer, [{
  7625. key: "_updateWidth",
  7626. value: function _updateWidth() {
  7627. var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  7628. if (!this.enabled) {
  7629. return false;
  7630. }
  7631. var maxWidth = Math.floor(this.outerContainerWidth / 2);
  7632. if (width > maxWidth) {
  7633. width = maxWidth;
  7634. }
  7635. if (width < SIDEBAR_MIN_WIDTH) {
  7636. width = SIDEBAR_MIN_WIDTH;
  7637. }
  7638. if (width === this._width) {
  7639. return false;
  7640. }
  7641. this._width = width;
  7642. this.doc.style.setProperty(SIDEBAR_WIDTH_VAR, "".concat(width, "px"));
  7643. return true;
  7644. }
  7645. }, {
  7646. key: "_mouseMove",
  7647. value: function _mouseMove(evt) {
  7648. var width = evt.clientX;
  7649. if (this.isRTL) {
  7650. width = this.outerContainerWidth - width;
  7651. }
  7652. this._updateWidth(width);
  7653. }
  7654. }, {
  7655. key: "_mouseUp",
  7656. value: function _mouseUp(evt) {
  7657. this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  7658. this.eventBus.dispatch('resize', {
  7659. source: this
  7660. });
  7661. var _boundEvents = this._boundEvents;
  7662. window.removeEventListener('mousemove', _boundEvents.mouseMove);
  7663. window.removeEventListener('mouseup', _boundEvents.mouseUp);
  7664. }
  7665. }, {
  7666. key: "_addEventListeners",
  7667. value: function _addEventListeners() {
  7668. var _this2 = this;
  7669. if (!this.enabled) {
  7670. return;
  7671. }
  7672. var _boundEvents = this._boundEvents;
  7673. _boundEvents.mouseMove = this._mouseMove.bind(this);
  7674. _boundEvents.mouseUp = this._mouseUp.bind(this);
  7675. this.resizer.addEventListener('mousedown', function (evt) {
  7676. if (evt.button !== 0) {
  7677. return;
  7678. }
  7679. _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  7680. window.addEventListener('mousemove', _boundEvents.mouseMove);
  7681. window.addEventListener('mouseup', _boundEvents.mouseUp);
  7682. });
  7683. this.eventBus.on('sidebarviewchanged', function (evt) {
  7684. _this2.sidebarOpen = !!(evt && evt.view);
  7685. });
  7686. this.eventBus.on('resize', function (evt) {
  7687. if (evt && evt.source === window) {
  7688. _this2._outerContainerWidth = null;
  7689. if (_this2._width) {
  7690. if (_this2.sidebarOpen) {
  7691. _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
  7692. var updated = _this2._updateWidth(_this2._width);
  7693. Promise.resolve().then(function () {
  7694. _this2.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
  7695. if (updated) {
  7696. _this2.eventBus.dispatch('resize', {
  7697. source: _this2
  7698. });
  7699. }
  7700. });
  7701. } else {
  7702. _this2._updateWidth(_this2._width);
  7703. }
  7704. }
  7705. }
  7706. });
  7707. }
  7708. }, {
  7709. key: "outerContainerWidth",
  7710. get: function get() {
  7711. if (!this._outerContainerWidth) {
  7712. this._outerContainerWidth = this.outerContainer.clientWidth;
  7713. }
  7714. return this._outerContainerWidth;
  7715. }
  7716. }]);
  7717. return PDFSidebarResizer;
  7718. }();
  7719. exports.PDFSidebarResizer = PDFSidebarResizer;
  7720. /***/ }),
  7721. /* 26 */
  7722. /***/ (function(module, exports, __webpack_require__) {
  7723. "use strict";
  7724. Object.defineProperty(exports, "__esModule", {
  7725. value: true
  7726. });
  7727. exports.PDFThumbnailViewer = void 0;
  7728. var _ui_utils = __webpack_require__(6);
  7729. var _pdf_thumbnail_view = __webpack_require__(27);
  7730. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7731. 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); } }
  7732. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7733. var THUMBNAIL_SCROLL_MARGIN = -19;
  7734. var THUMBNAIL_SELECTED_CLASS = 'selected';
  7735. var PDFThumbnailViewer =
  7736. /*#__PURE__*/
  7737. function () {
  7738. function PDFThumbnailViewer(_ref) {
  7739. var container = _ref.container,
  7740. linkService = _ref.linkService,
  7741. renderingQueue = _ref.renderingQueue,
  7742. _ref$l10n = _ref.l10n,
  7743. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  7744. _classCallCheck(this, PDFThumbnailViewer);
  7745. this.container = container;
  7746. this.linkService = linkService;
  7747. this.renderingQueue = renderingQueue;
  7748. this.l10n = l10n;
  7749. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdated.bind(this));
  7750. this._resetView();
  7751. }
  7752. _createClass(PDFThumbnailViewer, [{
  7753. key: "_scrollUpdated",
  7754. value: function _scrollUpdated() {
  7755. this.renderingQueue.renderHighestPriority();
  7756. }
  7757. }, {
  7758. key: "getThumbnail",
  7759. value: function getThumbnail(index) {
  7760. return this._thumbnails[index];
  7761. }
  7762. }, {
  7763. key: "_getVisibleThumbs",
  7764. value: function _getVisibleThumbs() {
  7765. return (0, _ui_utils.getVisibleElements)(this.container, this._thumbnails);
  7766. }
  7767. }, {
  7768. key: "scrollThumbnailIntoView",
  7769. value: function scrollThumbnailIntoView(pageNumber) {
  7770. if (!this.pdfDocument) {
  7771. return;
  7772. }
  7773. var thumbnailView = this._thumbnails[pageNumber - 1];
  7774. if (!thumbnailView) {
  7775. console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');
  7776. return;
  7777. }
  7778. if (pageNumber !== this._currentPageNumber) {
  7779. var prevThumbnailView = this._thumbnails[this._currentPageNumber - 1];
  7780. prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS);
  7781. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  7782. }
  7783. var visibleThumbs = this._getVisibleThumbs();
  7784. var numVisibleThumbs = visibleThumbs.views.length;
  7785. if (numVisibleThumbs > 0) {
  7786. var first = visibleThumbs.first.id;
  7787. var last = numVisibleThumbs > 1 ? visibleThumbs.last.id : first;
  7788. var shouldScroll = false;
  7789. if (pageNumber <= first || pageNumber >= last) {
  7790. shouldScroll = true;
  7791. } else {
  7792. visibleThumbs.views.some(function (view) {
  7793. if (view.id !== pageNumber) {
  7794. return false;
  7795. }
  7796. shouldScroll = view.percent < 100;
  7797. return true;
  7798. });
  7799. }
  7800. if (shouldScroll) {
  7801. (0, _ui_utils.scrollIntoView)(thumbnailView.div, {
  7802. top: THUMBNAIL_SCROLL_MARGIN
  7803. });
  7804. }
  7805. }
  7806. this._currentPageNumber = pageNumber;
  7807. }
  7808. }, {
  7809. key: "cleanup",
  7810. value: function cleanup() {
  7811. _pdf_thumbnail_view.PDFThumbnailView.cleanup();
  7812. }
  7813. }, {
  7814. key: "_resetView",
  7815. value: function _resetView() {
  7816. this._thumbnails = [];
  7817. this._currentPageNumber = 1;
  7818. this._pageLabels = null;
  7819. this._pagesRotation = 0;
  7820. this._pagesRequests = [];
  7821. this.container.textContent = '';
  7822. }
  7823. }, {
  7824. key: "setDocument",
  7825. value: function setDocument(pdfDocument) {
  7826. var _this = this;
  7827. if (this.pdfDocument) {
  7828. this._cancelRendering();
  7829. this._resetView();
  7830. }
  7831. this.pdfDocument = pdfDocument;
  7832. if (!pdfDocument) {
  7833. return;
  7834. }
  7835. pdfDocument.getPage(1).then(function (firstPage) {
  7836. var pagesCount = pdfDocument.numPages;
  7837. var viewport = firstPage.getViewport({
  7838. scale: 1
  7839. });
  7840. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  7841. var thumbnail = new _pdf_thumbnail_view.PDFThumbnailView({
  7842. container: _this.container,
  7843. id: pageNum,
  7844. defaultViewport: viewport.clone(),
  7845. linkService: _this.linkService,
  7846. renderingQueue: _this.renderingQueue,
  7847. disableCanvasToImageConversion: false,
  7848. l10n: _this.l10n
  7849. });
  7850. _this._thumbnails.push(thumbnail);
  7851. }
  7852. var thumbnailView = _this._thumbnails[_this._currentPageNumber - 1];
  7853. thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
  7854. }).catch(function (reason) {
  7855. console.error('Unable to initialize thumbnail viewer', reason);
  7856. });
  7857. }
  7858. }, {
  7859. key: "_cancelRendering",
  7860. value: function _cancelRendering() {
  7861. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  7862. if (this._thumbnails[i]) {
  7863. this._thumbnails[i].cancelRendering();
  7864. }
  7865. }
  7866. }
  7867. }, {
  7868. key: "setPageLabels",
  7869. value: function setPageLabels(labels) {
  7870. if (!this.pdfDocument) {
  7871. return;
  7872. }
  7873. if (!labels) {
  7874. this._pageLabels = null;
  7875. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  7876. this._pageLabels = null;
  7877. console.error('PDFThumbnailViewer_setPageLabels: Invalid page labels.');
  7878. } else {
  7879. this._pageLabels = labels;
  7880. }
  7881. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  7882. var label = this._pageLabels && this._pageLabels[i];
  7883. this._thumbnails[i].setPageLabel(label);
  7884. }
  7885. }
  7886. }, {
  7887. key: "_ensurePdfPageLoaded",
  7888. value: function _ensurePdfPageLoaded(thumbView) {
  7889. var _this2 = this;
  7890. if (thumbView.pdfPage) {
  7891. return Promise.resolve(thumbView.pdfPage);
  7892. }
  7893. var pageNumber = thumbView.id;
  7894. if (this._pagesRequests[pageNumber]) {
  7895. return this._pagesRequests[pageNumber];
  7896. }
  7897. var promise = this.pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  7898. thumbView.setPdfPage(pdfPage);
  7899. _this2._pagesRequests[pageNumber] = null;
  7900. return pdfPage;
  7901. }).catch(function (reason) {
  7902. console.error('Unable to get page for thumb view', reason);
  7903. _this2._pagesRequests[pageNumber] = null;
  7904. });
  7905. this._pagesRequests[pageNumber] = promise;
  7906. return promise;
  7907. }
  7908. }, {
  7909. key: "forceRendering",
  7910. value: function forceRendering() {
  7911. var _this3 = this;
  7912. var visibleThumbs = this._getVisibleThumbs();
  7913. var thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, this.scroll.down);
  7914. if (thumbView) {
  7915. this._ensurePdfPageLoaded(thumbView).then(function () {
  7916. _this3.renderingQueue.renderView(thumbView);
  7917. });
  7918. return true;
  7919. }
  7920. return false;
  7921. }
  7922. }, {
  7923. key: "pagesRotation",
  7924. get: function get() {
  7925. return this._pagesRotation;
  7926. },
  7927. set: function set(rotation) {
  7928. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  7929. throw new Error('Invalid thumbnails rotation angle.');
  7930. }
  7931. if (!this.pdfDocument) {
  7932. return;
  7933. }
  7934. if (this._pagesRotation === rotation) {
  7935. return;
  7936. }
  7937. this._pagesRotation = rotation;
  7938. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  7939. this._thumbnails[i].update(rotation);
  7940. }
  7941. }
  7942. }]);
  7943. return PDFThumbnailViewer;
  7944. }();
  7945. exports.PDFThumbnailViewer = PDFThumbnailViewer;
  7946. /***/ }),
  7947. /* 27 */
  7948. /***/ (function(module, exports, __webpack_require__) {
  7949. "use strict";
  7950. Object.defineProperty(exports, "__esModule", {
  7951. value: true
  7952. });
  7953. exports.PDFThumbnailView = void 0;
  7954. var _pdfjsLib = __webpack_require__(7);
  7955. var _ui_utils = __webpack_require__(6);
  7956. var _pdf_rendering_queue = __webpack_require__(10);
  7957. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7958. 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); } }
  7959. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7960. var MAX_NUM_SCALING_STEPS = 3;
  7961. var THUMBNAIL_CANVAS_BORDER_WIDTH = 1;
  7962. var THUMBNAIL_WIDTH = 98;
  7963. var TempImageFactory = function TempImageFactoryClosure() {
  7964. var tempCanvasCache = null;
  7965. return {
  7966. getCanvas: function getCanvas(width, height) {
  7967. var tempCanvas = tempCanvasCache;
  7968. if (!tempCanvas) {
  7969. tempCanvas = document.createElement('canvas');
  7970. tempCanvasCache = tempCanvas;
  7971. }
  7972. tempCanvas.width = width;
  7973. tempCanvas.height = height;
  7974. tempCanvas.mozOpaque = true;
  7975. var ctx = tempCanvas.getContext('2d', {
  7976. alpha: false
  7977. });
  7978. ctx.save();
  7979. ctx.fillStyle = 'rgb(255, 255, 255)';
  7980. ctx.fillRect(0, 0, width, height);
  7981. ctx.restore();
  7982. return tempCanvas;
  7983. },
  7984. destroyCanvas: function destroyCanvas() {
  7985. var tempCanvas = tempCanvasCache;
  7986. if (tempCanvas) {
  7987. tempCanvas.width = 0;
  7988. tempCanvas.height = 0;
  7989. }
  7990. tempCanvasCache = null;
  7991. }
  7992. };
  7993. }();
  7994. var PDFThumbnailView =
  7995. /*#__PURE__*/
  7996. function () {
  7997. function PDFThumbnailView(_ref) {
  7998. var container = _ref.container,
  7999. id = _ref.id,
  8000. defaultViewport = _ref.defaultViewport,
  8001. linkService = _ref.linkService,
  8002. renderingQueue = _ref.renderingQueue,
  8003. _ref$disableCanvasToI = _ref.disableCanvasToImageConversion,
  8004. disableCanvasToImageConversion = _ref$disableCanvasToI === void 0 ? false : _ref$disableCanvasToI,
  8005. _ref$l10n = _ref.l10n,
  8006. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  8007. _classCallCheck(this, PDFThumbnailView);
  8008. this.id = id;
  8009. this.renderingId = 'thumbnail' + id;
  8010. this.pageLabel = null;
  8011. this.pdfPage = null;
  8012. this.rotation = 0;
  8013. this.viewport = defaultViewport;
  8014. this.pdfPageRotate = defaultViewport.rotation;
  8015. this.linkService = linkService;
  8016. this.renderingQueue = renderingQueue;
  8017. this.renderTask = null;
  8018. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  8019. this.resume = null;
  8020. this.disableCanvasToImageConversion = disableCanvasToImageConversion;
  8021. this.pageWidth = this.viewport.width;
  8022. this.pageHeight = this.viewport.height;
  8023. this.pageRatio = this.pageWidth / this.pageHeight;
  8024. this.canvasWidth = THUMBNAIL_WIDTH;
  8025. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  8026. this.scale = this.canvasWidth / this.pageWidth;
  8027. this.l10n = l10n;
  8028. var anchor = document.createElement('a');
  8029. anchor.href = linkService.getAnchorUrl('#page=' + id);
  8030. this.l10n.get('thumb_page_title', {
  8031. page: id
  8032. }, 'Page {{page}}').then(function (msg) {
  8033. anchor.title = msg;
  8034. });
  8035. anchor.onclick = function () {
  8036. linkService.page = id;
  8037. return false;
  8038. };
  8039. this.anchor = anchor;
  8040. var div = document.createElement('div');
  8041. div.className = 'thumbnail';
  8042. div.setAttribute('data-page-number', this.id);
  8043. this.div = div;
  8044. var ring = document.createElement('div');
  8045. ring.className = 'thumbnailSelectionRing';
  8046. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  8047. ring.style.width = this.canvasWidth + borderAdjustment + 'px';
  8048. ring.style.height = this.canvasHeight + borderAdjustment + 'px';
  8049. this.ring = ring;
  8050. div.appendChild(ring);
  8051. anchor.appendChild(div);
  8052. container.appendChild(anchor);
  8053. }
  8054. _createClass(PDFThumbnailView, [{
  8055. key: "setPdfPage",
  8056. value: function setPdfPage(pdfPage) {
  8057. this.pdfPage = pdfPage;
  8058. this.pdfPageRotate = pdfPage.rotate;
  8059. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  8060. this.viewport = pdfPage.getViewport({
  8061. scale: 1,
  8062. rotation: totalRotation
  8063. });
  8064. this.reset();
  8065. }
  8066. }, {
  8067. key: "reset",
  8068. value: function reset() {
  8069. this.cancelRendering();
  8070. this.pageWidth = this.viewport.width;
  8071. this.pageHeight = this.viewport.height;
  8072. this.pageRatio = this.pageWidth / this.pageHeight;
  8073. this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
  8074. this.scale = this.canvasWidth / this.pageWidth;
  8075. this.div.removeAttribute('data-loaded');
  8076. var ring = this.ring;
  8077. var childNodes = ring.childNodes;
  8078. for (var i = childNodes.length - 1; i >= 0; i--) {
  8079. ring.removeChild(childNodes[i]);
  8080. }
  8081. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  8082. ring.style.width = this.canvasWidth + borderAdjustment + 'px';
  8083. ring.style.height = this.canvasHeight + borderAdjustment + 'px';
  8084. if (this.canvas) {
  8085. this.canvas.width = 0;
  8086. this.canvas.height = 0;
  8087. delete this.canvas;
  8088. }
  8089. if (this.image) {
  8090. this.image.removeAttribute('src');
  8091. delete this.image;
  8092. }
  8093. }
  8094. }, {
  8095. key: "update",
  8096. value: function update(rotation) {
  8097. if (typeof rotation !== 'undefined') {
  8098. this.rotation = rotation;
  8099. }
  8100. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  8101. this.viewport = this.viewport.clone({
  8102. scale: 1,
  8103. rotation: totalRotation
  8104. });
  8105. this.reset();
  8106. }
  8107. }, {
  8108. key: "cancelRendering",
  8109. value: function cancelRendering() {
  8110. if (this.renderTask) {
  8111. this.renderTask.cancel();
  8112. this.renderTask = null;
  8113. }
  8114. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  8115. this.resume = null;
  8116. }
  8117. }, {
  8118. key: "_getPageDrawContext",
  8119. value: function _getPageDrawContext() {
  8120. var noCtxScale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  8121. var canvas = document.createElement('canvas');
  8122. this.canvas = canvas;
  8123. canvas.mozOpaque = true;
  8124. var ctx = canvas.getContext('2d', {
  8125. alpha: false
  8126. });
  8127. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  8128. canvas.width = this.canvasWidth * outputScale.sx | 0;
  8129. canvas.height = this.canvasHeight * outputScale.sy | 0;
  8130. canvas.style.width = this.canvasWidth + 'px';
  8131. canvas.style.height = this.canvasHeight + 'px';
  8132. if (!noCtxScale && outputScale.scaled) {
  8133. ctx.scale(outputScale.sx, outputScale.sy);
  8134. }
  8135. return ctx;
  8136. }
  8137. }, {
  8138. key: "_convertCanvasToImage",
  8139. value: function _convertCanvasToImage() {
  8140. var _this = this;
  8141. if (!this.canvas) {
  8142. return;
  8143. }
  8144. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  8145. return;
  8146. }
  8147. var id = this.renderingId;
  8148. var className = 'thumbnailImage';
  8149. if (this.disableCanvasToImageConversion) {
  8150. this.canvas.id = id;
  8151. this.canvas.className = className;
  8152. this.l10n.get('thumb_page_canvas', {
  8153. page: this.pageId
  8154. }, 'Thumbnail of Page {{page}}').then(function (msg) {
  8155. _this.canvas.setAttribute('aria-label', msg);
  8156. });
  8157. this.div.setAttribute('data-loaded', true);
  8158. this.ring.appendChild(this.canvas);
  8159. return;
  8160. }
  8161. var image = document.createElement('img');
  8162. image.id = id;
  8163. image.className = className;
  8164. this.l10n.get('thumb_page_canvas', {
  8165. page: this.pageId
  8166. }, 'Thumbnail of Page {{page}}').then(function (msg) {
  8167. image.setAttribute('aria-label', msg);
  8168. });
  8169. image.style.width = this.canvasWidth + 'px';
  8170. image.style.height = this.canvasHeight + 'px';
  8171. image.src = this.canvas.toDataURL();
  8172. this.image = image;
  8173. this.div.setAttribute('data-loaded', true);
  8174. this.ring.appendChild(image);
  8175. this.canvas.width = 0;
  8176. this.canvas.height = 0;
  8177. delete this.canvas;
  8178. }
  8179. }, {
  8180. key: "draw",
  8181. value: function draw() {
  8182. var _this2 = this;
  8183. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  8184. console.error('Must be in new state before drawing');
  8185. return Promise.resolve(undefined);
  8186. }
  8187. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  8188. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  8189. var finishRenderTask = function finishRenderTask(error) {
  8190. if (renderTask === _this2.renderTask) {
  8191. _this2.renderTask = null;
  8192. }
  8193. if (error instanceof _pdfjsLib.RenderingCancelledException) {
  8194. renderCapability.resolve(undefined);
  8195. return;
  8196. }
  8197. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  8198. _this2._convertCanvasToImage();
  8199. if (!error) {
  8200. renderCapability.resolve(undefined);
  8201. } else {
  8202. renderCapability.reject(error);
  8203. }
  8204. };
  8205. var ctx = this._getPageDrawContext();
  8206. var drawViewport = this.viewport.clone({
  8207. scale: this.scale
  8208. });
  8209. var renderContinueCallback = function renderContinueCallback(cont) {
  8210. if (!_this2.renderingQueue.isHighestPriority(_this2)) {
  8211. _this2.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  8212. _this2.resume = function () {
  8213. _this2.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  8214. cont();
  8215. };
  8216. return;
  8217. }
  8218. cont();
  8219. };
  8220. var renderContext = {
  8221. canvasContext: ctx,
  8222. viewport: drawViewport
  8223. };
  8224. var renderTask = this.renderTask = this.pdfPage.render(renderContext);
  8225. renderTask.onContinue = renderContinueCallback;
  8226. renderTask.promise.then(function () {
  8227. finishRenderTask(null);
  8228. }, function (error) {
  8229. finishRenderTask(error);
  8230. });
  8231. return renderCapability.promise;
  8232. }
  8233. }, {
  8234. key: "setImage",
  8235. value: function setImage(pageView) {
  8236. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  8237. return;
  8238. }
  8239. var img = pageView.canvas;
  8240. if (!img) {
  8241. return;
  8242. }
  8243. if (!this.pdfPage) {
  8244. this.setPdfPage(pageView.pdfPage);
  8245. }
  8246. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  8247. var ctx = this._getPageDrawContext(true);
  8248. var canvas = ctx.canvas;
  8249. if (img.width <= 2 * canvas.width) {
  8250. ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height);
  8251. this._convertCanvasToImage();
  8252. return;
  8253. }
  8254. var reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
  8255. var reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
  8256. var reducedImage = TempImageFactory.getCanvas(reducedWidth, reducedHeight);
  8257. var reducedImageCtx = reducedImage.getContext('2d');
  8258. while (reducedWidth > img.width || reducedHeight > img.height) {
  8259. reducedWidth >>= 1;
  8260. reducedHeight >>= 1;
  8261. }
  8262. reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0, reducedWidth, reducedHeight);
  8263. while (reducedWidth > 2 * canvas.width) {
  8264. reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, reducedWidth >> 1, reducedHeight >> 1);
  8265. reducedWidth >>= 1;
  8266. reducedHeight >>= 1;
  8267. }
  8268. ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height);
  8269. this._convertCanvasToImage();
  8270. }
  8271. }, {
  8272. key: "setPageLabel",
  8273. value: function setPageLabel(label) {
  8274. var _this3 = this;
  8275. this.pageLabel = typeof label === 'string' ? label : null;
  8276. this.l10n.get('thumb_page_title', {
  8277. page: this.pageId
  8278. }, 'Page {{page}}').then(function (msg) {
  8279. _this3.anchor.title = msg;
  8280. });
  8281. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  8282. return;
  8283. }
  8284. this.l10n.get('thumb_page_canvas', {
  8285. page: this.pageId
  8286. }, 'Thumbnail of Page {{page}}').then(function (ariaLabel) {
  8287. if (_this3.image) {
  8288. _this3.image.setAttribute('aria-label', ariaLabel);
  8289. } else if (_this3.disableCanvasToImageConversion && _this3.canvas) {
  8290. _this3.canvas.setAttribute('aria-label', ariaLabel);
  8291. }
  8292. });
  8293. }
  8294. }, {
  8295. key: "pageId",
  8296. get: function get() {
  8297. return this.pageLabel !== null ? this.pageLabel : this.id;
  8298. }
  8299. }], [{
  8300. key: "cleanup",
  8301. value: function cleanup() {
  8302. TempImageFactory.destroyCanvas();
  8303. }
  8304. }]);
  8305. return PDFThumbnailView;
  8306. }();
  8307. exports.PDFThumbnailView = PDFThumbnailView;
  8308. /***/ }),
  8309. /* 28 */
  8310. /***/ (function(module, exports, __webpack_require__) {
  8311. "use strict";
  8312. Object.defineProperty(exports, "__esModule", {
  8313. value: true
  8314. });
  8315. exports.PDFViewer = void 0;
  8316. var _base_viewer = __webpack_require__(29);
  8317. var _pdfjsLib = __webpack_require__(7);
  8318. function _typeof(obj) { 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); }
  8319. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8320. 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); } }
  8321. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8322. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  8323. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  8324. 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); }
  8325. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  8326. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  8327. 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); }
  8328. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  8329. var PDFViewer =
  8330. /*#__PURE__*/
  8331. function (_BaseViewer) {
  8332. _inherits(PDFViewer, _BaseViewer);
  8333. function PDFViewer() {
  8334. _classCallCheck(this, PDFViewer);
  8335. return _possibleConstructorReturn(this, _getPrototypeOf(PDFViewer).apply(this, arguments));
  8336. }
  8337. _createClass(PDFViewer, [{
  8338. key: "_scrollIntoView",
  8339. value: function _scrollIntoView(_ref) {
  8340. var pageDiv = _ref.pageDiv,
  8341. _ref$pageSpot = _ref.pageSpot,
  8342. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  8343. _ref$pageNumber = _ref.pageNumber,
  8344. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  8345. if (!pageSpot && !this.isInPresentationMode) {
  8346. var left = pageDiv.offsetLeft + pageDiv.clientLeft;
  8347. var right = left + pageDiv.clientWidth;
  8348. var _this$container = this.container,
  8349. scrollLeft = _this$container.scrollLeft,
  8350. clientWidth = _this$container.clientWidth;
  8351. if (this._isScrollModeHorizontal || left < scrollLeft || right > scrollLeft + clientWidth) {
  8352. pageSpot = {
  8353. left: 0,
  8354. top: 0
  8355. };
  8356. }
  8357. }
  8358. _get(_getPrototypeOf(PDFViewer.prototype), "_scrollIntoView", this).call(this, {
  8359. pageDiv: pageDiv,
  8360. pageSpot: pageSpot,
  8361. pageNumber: pageNumber
  8362. });
  8363. }
  8364. }, {
  8365. key: "_getVisiblePages",
  8366. value: function _getVisiblePages() {
  8367. if (this.isInPresentationMode) {
  8368. return this._getCurrentVisiblePage();
  8369. }
  8370. return _get(_getPrototypeOf(PDFViewer.prototype), "_getVisiblePages", this).call(this);
  8371. }
  8372. }, {
  8373. key: "_updateHelper",
  8374. value: function _updateHelper(visiblePages) {
  8375. if (this.isInPresentationMode) {
  8376. return;
  8377. }
  8378. var currentId = this._currentPageNumber;
  8379. var stillFullyVisible = false;
  8380. var _iteratorNormalCompletion = true;
  8381. var _didIteratorError = false;
  8382. var _iteratorError = undefined;
  8383. try {
  8384. for (var _iterator = visiblePages[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  8385. var page = _step.value;
  8386. if (page.percent < 100) {
  8387. break;
  8388. }
  8389. if (page.id === currentId) {
  8390. stillFullyVisible = true;
  8391. break;
  8392. }
  8393. }
  8394. } catch (err) {
  8395. _didIteratorError = true;
  8396. _iteratorError = err;
  8397. } finally {
  8398. try {
  8399. if (!_iteratorNormalCompletion && _iterator.return != null) {
  8400. _iterator.return();
  8401. }
  8402. } finally {
  8403. if (_didIteratorError) {
  8404. throw _iteratorError;
  8405. }
  8406. }
  8407. }
  8408. if (!stillFullyVisible) {
  8409. currentId = visiblePages[0].id;
  8410. }
  8411. this._setCurrentPageNumber(currentId);
  8412. }
  8413. }, {
  8414. key: "_setDocumentViewerElement",
  8415. get: function get() {
  8416. return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this.viewer);
  8417. }
  8418. }]);
  8419. return PDFViewer;
  8420. }(_base_viewer.BaseViewer);
  8421. exports.PDFViewer = PDFViewer;
  8422. /***/ }),
  8423. /* 29 */
  8424. /***/ (function(module, exports, __webpack_require__) {
  8425. "use strict";
  8426. Object.defineProperty(exports, "__esModule", {
  8427. value: true
  8428. });
  8429. exports.BaseViewer = void 0;
  8430. var _ui_utils = __webpack_require__(6);
  8431. var _pdf_rendering_queue = __webpack_require__(10);
  8432. var _annotation_layer_builder = __webpack_require__(30);
  8433. var _pdfjsLib = __webpack_require__(7);
  8434. var _pdf_page_view = __webpack_require__(31);
  8435. var _pdf_link_service = __webpack_require__(22);
  8436. var _text_layer_builder = __webpack_require__(32);
  8437. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  8438. 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); } }
  8439. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  8440. var DEFAULT_CACHE_SIZE = 10;
  8441. function PDFPageViewBuffer(size) {
  8442. var data = [];
  8443. this.push = function (view) {
  8444. var i = data.indexOf(view);
  8445. if (i >= 0) {
  8446. data.splice(i, 1);
  8447. }
  8448. data.push(view);
  8449. if (data.length > size) {
  8450. data.shift().destroy();
  8451. }
  8452. };
  8453. this.resize = function (newSize, pagesToKeep) {
  8454. size = newSize;
  8455. if (pagesToKeep) {
  8456. var pageIdsToKeep = new Set();
  8457. for (var i = 0, iMax = pagesToKeep.length; i < iMax; ++i) {
  8458. pageIdsToKeep.add(pagesToKeep[i].id);
  8459. }
  8460. (0, _ui_utils.moveToEndOfArray)(data, function (page) {
  8461. return pageIdsToKeep.has(page.id);
  8462. });
  8463. }
  8464. while (data.length > size) {
  8465. data.shift().destroy();
  8466. }
  8467. };
  8468. }
  8469. function isSameScale(oldScale, newScale) {
  8470. if (newScale === oldScale) {
  8471. return true;
  8472. }
  8473. if (Math.abs(newScale - oldScale) < 1e-15) {
  8474. return true;
  8475. }
  8476. return false;
  8477. }
  8478. var BaseViewer =
  8479. /*#__PURE__*/
  8480. function () {
  8481. function BaseViewer(options) {
  8482. var _this = this;
  8483. _classCallCheck(this, BaseViewer);
  8484. if (this.constructor === BaseViewer) {
  8485. throw new Error('Cannot initialize BaseViewer.');
  8486. }
  8487. this._name = this.constructor.name;
  8488. this.container = options.container;
  8489. this.viewer = options.viewer || options.container.firstElementChild;
  8490. this.eventBus = options.eventBus || (0, _ui_utils.getGlobalEventBus)();
  8491. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  8492. this.downloadManager = options.downloadManager || null;
  8493. this.findController = options.findController || null;
  8494. this.removePageBorders = options.removePageBorders || false;
  8495. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  8496. this.imageResourcesPath = options.imageResourcesPath || '';
  8497. this.renderInteractiveForms = options.renderInteractiveForms || false;
  8498. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  8499. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  8500. this.enableWebGL = options.enableWebGL || false;
  8501. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  8502. this.maxCanvasPixels = options.maxCanvasPixels;
  8503. this.l10n = options.l10n || _ui_utils.NullL10n;
  8504. this.defaultRenderingQueue = !options.renderingQueue;
  8505. if (this.defaultRenderingQueue) {
  8506. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  8507. this.renderingQueue.setViewer(this);
  8508. } else {
  8509. this.renderingQueue = options.renderingQueue;
  8510. }
  8511. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  8512. this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
  8513. this._resetView();
  8514. if (this.removePageBorders) {
  8515. this.viewer.classList.add('removePageBorders');
  8516. }
  8517. Promise.resolve().then(function () {
  8518. _this.eventBus.dispatch('baseviewerinit', {
  8519. source: _this
  8520. });
  8521. });
  8522. }
  8523. _createClass(BaseViewer, [{
  8524. key: "getPageView",
  8525. value: function getPageView(index) {
  8526. return this._pages[index];
  8527. }
  8528. }, {
  8529. key: "_setCurrentPageNumber",
  8530. value: function _setCurrentPageNumber(val) {
  8531. var resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  8532. if (this._currentPageNumber === val) {
  8533. if (resetCurrentPageView) {
  8534. this._resetCurrentPageView();
  8535. }
  8536. return true;
  8537. }
  8538. if (!(0 < val && val <= this.pagesCount)) {
  8539. return false;
  8540. }
  8541. this._currentPageNumber = val;
  8542. this.eventBus.dispatch('pagechanging', {
  8543. source: this,
  8544. pageNumber: val,
  8545. pageLabel: this._pageLabels && this._pageLabels[val - 1]
  8546. });
  8547. if (resetCurrentPageView) {
  8548. this._resetCurrentPageView();
  8549. }
  8550. return true;
  8551. }
  8552. }, {
  8553. key: "setDocument",
  8554. value: function setDocument(pdfDocument) {
  8555. var _this2 = this;
  8556. if (this.pdfDocument) {
  8557. this._cancelRendering();
  8558. this._resetView();
  8559. if (this.findController) {
  8560. this.findController.setDocument(null);
  8561. }
  8562. }
  8563. this.pdfDocument = pdfDocument;
  8564. if (!pdfDocument) {
  8565. return;
  8566. }
  8567. var pagesCount = pdfDocument.numPages;
  8568. var pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
  8569. this.pagesPromise = pagesCapability.promise;
  8570. pagesCapability.promise.then(function () {
  8571. _this2._pageViewsReady = true;
  8572. _this2.eventBus.dispatch('pagesloaded', {
  8573. source: _this2,
  8574. pagesCount: pagesCount
  8575. });
  8576. });
  8577. var onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  8578. this.onePageRendered = onePageRenderedCapability.promise;
  8579. var bindOnAfterAndBeforeDraw = function bindOnAfterAndBeforeDraw(pageView) {
  8580. pageView.onBeforeDraw = function () {
  8581. _this2._buffer.push(pageView);
  8582. };
  8583. pageView.onAfterDraw = function () {
  8584. if (!onePageRenderedCapability.settled) {
  8585. onePageRenderedCapability.resolve();
  8586. }
  8587. };
  8588. };
  8589. var firstPagePromise = pdfDocument.getPage(1);
  8590. this.firstPagePromise = firstPagePromise;
  8591. firstPagePromise.then(function (pdfPage) {
  8592. var scale = _this2.currentScale;
  8593. var viewport = pdfPage.getViewport({
  8594. scale: scale * _ui_utils.CSS_UNITS
  8595. });
  8596. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  8597. var textLayerFactory = null;
  8598. if (_this2.textLayerMode !== _ui_utils.TextLayerMode.DISABLE) {
  8599. textLayerFactory = _this2;
  8600. }
  8601. var pageView = new _pdf_page_view.PDFPageView({
  8602. container: _this2._setDocumentViewerElement,
  8603. eventBus: _this2.eventBus,
  8604. id: pageNum,
  8605. scale: scale,
  8606. defaultViewport: viewport.clone(),
  8607. renderingQueue: _this2.renderingQueue,
  8608. textLayerFactory: textLayerFactory,
  8609. textLayerMode: _this2.textLayerMode,
  8610. annotationLayerFactory: _this2,
  8611. imageResourcesPath: _this2.imageResourcesPath,
  8612. renderInteractiveForms: _this2.renderInteractiveForms,
  8613. renderer: _this2.renderer,
  8614. enableWebGL: _this2.enableWebGL,
  8615. useOnlyCssZoom: _this2.useOnlyCssZoom,
  8616. maxCanvasPixels: _this2.maxCanvasPixels,
  8617. l10n: _this2.l10n
  8618. });
  8619. bindOnAfterAndBeforeDraw(pageView);
  8620. _this2._pages.push(pageView);
  8621. }
  8622. if (_this2._spreadMode !== _ui_utils.SpreadMode.NONE) {
  8623. _this2._updateSpreadMode();
  8624. }
  8625. onePageRenderedCapability.promise.then(function () {
  8626. if (pdfDocument.loadingParams['disableAutoFetch']) {
  8627. pagesCapability.resolve();
  8628. return;
  8629. }
  8630. var getPagesLeft = pagesCount;
  8631. var _loop = function _loop(_pageNum) {
  8632. pdfDocument.getPage(_pageNum).then(function (pdfPage) {
  8633. var pageView = _this2._pages[_pageNum - 1];
  8634. if (!pageView.pdfPage) {
  8635. pageView.setPdfPage(pdfPage);
  8636. }
  8637. _this2.linkService.cachePageRef(_pageNum, pdfPage.ref);
  8638. if (--getPagesLeft === 0) {
  8639. pagesCapability.resolve();
  8640. }
  8641. }, function (reason) {
  8642. console.error("Unable to get page ".concat(_pageNum, " to initialize viewer"), reason);
  8643. if (--getPagesLeft === 0) {
  8644. pagesCapability.resolve();
  8645. }
  8646. });
  8647. };
  8648. for (var _pageNum = 1; _pageNum <= pagesCount; ++_pageNum) {
  8649. _loop(_pageNum);
  8650. }
  8651. });
  8652. _this2.eventBus.dispatch('pagesinit', {
  8653. source: _this2
  8654. });
  8655. if (_this2.findController) {
  8656. _this2.findController.setDocument(pdfDocument);
  8657. }
  8658. if (_this2.defaultRenderingQueue) {
  8659. _this2.update();
  8660. }
  8661. }).catch(function (reason) {
  8662. console.error('Unable to initialize viewer', reason);
  8663. });
  8664. }
  8665. }, {
  8666. key: "setPageLabels",
  8667. value: function setPageLabels(labels) {
  8668. if (!this.pdfDocument) {
  8669. return;
  8670. }
  8671. if (!labels) {
  8672. this._pageLabels = null;
  8673. } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
  8674. this._pageLabels = null;
  8675. console.error("".concat(this._name, ".setPageLabels: Invalid page labels."));
  8676. } else {
  8677. this._pageLabels = labels;
  8678. }
  8679. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  8680. var pageView = this._pages[i];
  8681. var label = this._pageLabels && this._pageLabels[i];
  8682. pageView.setPageLabel(label);
  8683. }
  8684. }
  8685. }, {
  8686. key: "_resetView",
  8687. value: function _resetView() {
  8688. this._pages = [];
  8689. this._currentPageNumber = 1;
  8690. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  8691. this._currentScaleValue = null;
  8692. this._pageLabels = null;
  8693. this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  8694. this._location = null;
  8695. this._pagesRotation = 0;
  8696. this._pagesRequests = [];
  8697. this._pageViewsReady = false;
  8698. this._scrollMode = _ui_utils.ScrollMode.VERTICAL;
  8699. this._spreadMode = _ui_utils.SpreadMode.NONE;
  8700. this.viewer.textContent = '';
  8701. this._updateScrollMode();
  8702. }
  8703. }, {
  8704. key: "_scrollUpdate",
  8705. value: function _scrollUpdate() {
  8706. if (this.pagesCount === 0) {
  8707. return;
  8708. }
  8709. this.update();
  8710. }
  8711. }, {
  8712. key: "_scrollIntoView",
  8713. value: function _scrollIntoView(_ref) {
  8714. var pageDiv = _ref.pageDiv,
  8715. _ref$pageSpot = _ref.pageSpot,
  8716. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  8717. _ref$pageNumber = _ref.pageNumber,
  8718. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  8719. (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
  8720. }
  8721. }, {
  8722. key: "_setScaleUpdatePages",
  8723. value: function _setScaleUpdatePages(newScale, newValue) {
  8724. var noScroll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  8725. var preset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  8726. this._currentScaleValue = newValue.toString();
  8727. if (isSameScale(this._currentScale, newScale)) {
  8728. if (preset) {
  8729. this.eventBus.dispatch('scalechanging', {
  8730. source: this,
  8731. scale: newScale,
  8732. presetValue: newValue
  8733. });
  8734. }
  8735. return;
  8736. }
  8737. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  8738. this._pages[i].update(newScale);
  8739. }
  8740. this._currentScale = newScale;
  8741. if (!noScroll) {
  8742. var page = this._currentPageNumber,
  8743. dest;
  8744. if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  8745. page = this._location.pageNumber;
  8746. dest = [null, {
  8747. name: 'XYZ'
  8748. }, this._location.left, this._location.top, null];
  8749. }
  8750. this.scrollPageIntoView({
  8751. pageNumber: page,
  8752. destArray: dest,
  8753. allowNegativeOffset: true
  8754. });
  8755. }
  8756. this.eventBus.dispatch('scalechanging', {
  8757. source: this,
  8758. scale: newScale,
  8759. presetValue: preset ? newValue : undefined
  8760. });
  8761. if (this.defaultRenderingQueue) {
  8762. this.update();
  8763. }
  8764. }
  8765. }, {
  8766. key: "_setScale",
  8767. value: function _setScale(value) {
  8768. var noScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  8769. var scale = parseFloat(value);
  8770. if (scale > 0) {
  8771. this._setScaleUpdatePages(scale, value, noScroll, false);
  8772. } else {
  8773. var currentPage = this._pages[this._currentPageNumber - 1];
  8774. if (!currentPage) {
  8775. return;
  8776. }
  8777. var noPadding = this.isInPresentationMode || this.removePageBorders;
  8778. var hPadding = noPadding ? 0 : _ui_utils.SCROLLBAR_PADDING;
  8779. var vPadding = noPadding ? 0 : _ui_utils.VERTICAL_PADDING;
  8780. if (!noPadding && this._isScrollModeHorizontal) {
  8781. var _ref2 = [vPadding, hPadding];
  8782. hPadding = _ref2[0];
  8783. vPadding = _ref2[1];
  8784. }
  8785. var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale;
  8786. var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  8787. switch (value) {
  8788. case 'page-actual':
  8789. scale = 1;
  8790. break;
  8791. case 'page-width':
  8792. scale = pageWidthScale;
  8793. break;
  8794. case 'page-height':
  8795. scale = pageHeightScale;
  8796. break;
  8797. case 'page-fit':
  8798. scale = Math.min(pageWidthScale, pageHeightScale);
  8799. break;
  8800. case 'auto':
  8801. var horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
  8802. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  8803. break;
  8804. default:
  8805. console.error("".concat(this._name, "._setScale: \"").concat(value, "\" is an unknown zoom value."));
  8806. return;
  8807. }
  8808. this._setScaleUpdatePages(scale, value, noScroll, true);
  8809. }
  8810. }
  8811. }, {
  8812. key: "_resetCurrentPageView",
  8813. value: function _resetCurrentPageView() {
  8814. if (this.isInPresentationMode) {
  8815. this._setScale(this._currentScaleValue, true);
  8816. }
  8817. var pageView = this._pages[this._currentPageNumber - 1];
  8818. this._scrollIntoView({
  8819. pageDiv: pageView.div
  8820. });
  8821. }
  8822. }, {
  8823. key: "scrollPageIntoView",
  8824. value: function scrollPageIntoView(_ref3) {
  8825. var pageNumber = _ref3.pageNumber,
  8826. _ref3$destArray = _ref3.destArray,
  8827. destArray = _ref3$destArray === void 0 ? null : _ref3$destArray,
  8828. _ref3$allowNegativeOf = _ref3.allowNegativeOffset,
  8829. allowNegativeOffset = _ref3$allowNegativeOf === void 0 ? false : _ref3$allowNegativeOf;
  8830. if (!this.pdfDocument) {
  8831. return;
  8832. }
  8833. var pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1];
  8834. if (!pageView) {
  8835. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
  8836. return;
  8837. }
  8838. if (this.isInPresentationMode || !destArray) {
  8839. this._setCurrentPageNumber(pageNumber, true);
  8840. return;
  8841. }
  8842. var x = 0,
  8843. y = 0;
  8844. var width = 0,
  8845. height = 0,
  8846. widthScale,
  8847. heightScale;
  8848. var changeOrientation = pageView.rotation % 180 === 0 ? false : true;
  8849. var pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;
  8850. var pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;
  8851. var scale = 0;
  8852. switch (destArray[1].name) {
  8853. case 'XYZ':
  8854. x = destArray[2];
  8855. y = destArray[3];
  8856. scale = destArray[4];
  8857. x = x !== null ? x : 0;
  8858. y = y !== null ? y : pageHeight;
  8859. break;
  8860. case 'Fit':
  8861. case 'FitB':
  8862. scale = 'page-fit';
  8863. break;
  8864. case 'FitH':
  8865. case 'FitBH':
  8866. y = destArray[2];
  8867. scale = 'page-width';
  8868. if (y === null && this._location) {
  8869. x = this._location.left;
  8870. y = this._location.top;
  8871. }
  8872. break;
  8873. case 'FitV':
  8874. case 'FitBV':
  8875. x = destArray[2];
  8876. width = pageWidth;
  8877. height = pageHeight;
  8878. scale = 'page-height';
  8879. break;
  8880. case 'FitR':
  8881. x = destArray[2];
  8882. y = destArray[3];
  8883. width = destArray[4] - x;
  8884. height = destArray[5] - y;
  8885. var hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  8886. var vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  8887. widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;
  8888. heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;
  8889. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  8890. break;
  8891. default:
  8892. console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(destArray[1].name, "\" is not a valid destination type."));
  8893. return;
  8894. }
  8895. if (scale && scale !== this._currentScale) {
  8896. this.currentScaleValue = scale;
  8897. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  8898. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  8899. }
  8900. if (scale === 'page-fit' && !destArray[4]) {
  8901. this._scrollIntoView({
  8902. pageDiv: pageView.div,
  8903. pageNumber: pageNumber
  8904. });
  8905. return;
  8906. }
  8907. var boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  8908. var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  8909. var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  8910. if (!allowNegativeOffset) {
  8911. left = Math.max(left, 0);
  8912. top = Math.max(top, 0);
  8913. }
  8914. this._scrollIntoView({
  8915. pageDiv: pageView.div,
  8916. pageSpot: {
  8917. left: left,
  8918. top: top
  8919. },
  8920. pageNumber: pageNumber
  8921. });
  8922. }
  8923. }, {
  8924. key: "_updateLocation",
  8925. value: function _updateLocation(firstPage) {
  8926. var currentScale = this._currentScale;
  8927. var currentScaleValue = this._currentScaleValue;
  8928. var normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  8929. var pageNumber = firstPage.id;
  8930. var pdfOpenParams = '#page=' + pageNumber;
  8931. pdfOpenParams += '&zoom=' + normalizedScaleValue;
  8932. var currentPageView = this._pages[pageNumber - 1];
  8933. var container = this.container;
  8934. var topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  8935. var intLeft = Math.round(topLeft[0]);
  8936. var intTop = Math.round(topLeft[1]);
  8937. pdfOpenParams += ',' + intLeft + ',' + intTop;
  8938. this._location = {
  8939. pageNumber: pageNumber,
  8940. scale: normalizedScaleValue,
  8941. top: intTop,
  8942. left: intLeft,
  8943. rotation: this._pagesRotation,
  8944. pdfOpenParams: pdfOpenParams
  8945. };
  8946. }
  8947. }, {
  8948. key: "_updateHelper",
  8949. value: function _updateHelper(visiblePages) {
  8950. throw new Error('Not implemented: _updateHelper');
  8951. }
  8952. }, {
  8953. key: "update",
  8954. value: function update() {
  8955. var visible = this._getVisiblePages();
  8956. var visiblePages = visible.views,
  8957. numVisiblePages = visiblePages.length;
  8958. if (numVisiblePages === 0) {
  8959. return;
  8960. }
  8961. var newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
  8962. this._buffer.resize(newCacheSize, visiblePages);
  8963. this.renderingQueue.renderHighestPriority(visible);
  8964. this._updateHelper(visiblePages);
  8965. this._updateLocation(visible.first);
  8966. this.eventBus.dispatch('updateviewarea', {
  8967. source: this,
  8968. location: this._location
  8969. });
  8970. }
  8971. }, {
  8972. key: "containsElement",
  8973. value: function containsElement(element) {
  8974. return this.container.contains(element);
  8975. }
  8976. }, {
  8977. key: "focus",
  8978. value: function focus() {
  8979. this.container.focus();
  8980. }
  8981. }, {
  8982. key: "_getCurrentVisiblePage",
  8983. value: function _getCurrentVisiblePage() {
  8984. if (!this.pagesCount) {
  8985. return {
  8986. views: []
  8987. };
  8988. }
  8989. var pageView = this._pages[this._currentPageNumber - 1];
  8990. var element = pageView.div;
  8991. var view = {
  8992. id: pageView.id,
  8993. x: element.offsetLeft + element.clientLeft,
  8994. y: element.offsetTop + element.clientTop,
  8995. view: pageView
  8996. };
  8997. return {
  8998. first: view,
  8999. last: view,
  9000. views: [view]
  9001. };
  9002. }
  9003. }, {
  9004. key: "_getVisiblePages",
  9005. value: function _getVisiblePages() {
  9006. return (0, _ui_utils.getVisibleElements)(this.container, this._pages, true, this._isScrollModeHorizontal);
  9007. }
  9008. }, {
  9009. key: "isPageVisible",
  9010. value: function isPageVisible(pageNumber) {
  9011. if (!this.pdfDocument) {
  9012. return false;
  9013. }
  9014. if (this.pageNumber < 1 || pageNumber > this.pagesCount) {
  9015. console.error("".concat(this._name, ".isPageVisible: \"").concat(pageNumber, "\" is out of bounds."));
  9016. return false;
  9017. }
  9018. return this._getVisiblePages().views.some(function (view) {
  9019. return view.id === pageNumber;
  9020. });
  9021. }
  9022. }, {
  9023. key: "cleanup",
  9024. value: function cleanup() {
  9025. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  9026. if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  9027. this._pages[i].reset();
  9028. }
  9029. }
  9030. }
  9031. }, {
  9032. key: "_cancelRendering",
  9033. value: function _cancelRendering() {
  9034. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  9035. if (this._pages[i]) {
  9036. this._pages[i].cancelRendering();
  9037. }
  9038. }
  9039. }
  9040. }, {
  9041. key: "_ensurePdfPageLoaded",
  9042. value: function _ensurePdfPageLoaded(pageView) {
  9043. var _this3 = this;
  9044. if (pageView.pdfPage) {
  9045. return Promise.resolve(pageView.pdfPage);
  9046. }
  9047. var pageNumber = pageView.id;
  9048. if (this._pagesRequests[pageNumber]) {
  9049. return this._pagesRequests[pageNumber];
  9050. }
  9051. var promise = this.pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  9052. if (!pageView.pdfPage) {
  9053. pageView.setPdfPage(pdfPage);
  9054. }
  9055. _this3._pagesRequests[pageNumber] = null;
  9056. return pdfPage;
  9057. }).catch(function (reason) {
  9058. console.error('Unable to get page for page view', reason);
  9059. _this3._pagesRequests[pageNumber] = null;
  9060. });
  9061. this._pagesRequests[pageNumber] = promise;
  9062. return promise;
  9063. }
  9064. }, {
  9065. key: "forceRendering",
  9066. value: function forceRendering(currentlyVisiblePages) {
  9067. var _this4 = this;
  9068. var visiblePages = currentlyVisiblePages || this._getVisiblePages();
  9069. var scrollAhead = this._isScrollModeHorizontal ? this.scroll.right : this.scroll.down;
  9070. var pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead);
  9071. if (pageView) {
  9072. this._ensurePdfPageLoaded(pageView).then(function () {
  9073. _this4.renderingQueue.renderView(pageView);
  9074. });
  9075. return true;
  9076. }
  9077. return false;
  9078. }
  9079. }, {
  9080. key: "createTextLayerBuilder",
  9081. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  9082. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9083. return new _text_layer_builder.TextLayerBuilder({
  9084. textLayerDiv: textLayerDiv,
  9085. eventBus: this.eventBus,
  9086. pageIndex: pageIndex,
  9087. viewport: viewport,
  9088. findController: this.isInPresentationMode ? null : this.findController,
  9089. enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection
  9090. });
  9091. }
  9092. }, {
  9093. key: "createAnnotationLayerBuilder",
  9094. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  9095. var imageResourcesPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  9096. var renderInteractiveForms = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9097. var l10n = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _ui_utils.NullL10n;
  9098. return new _annotation_layer_builder.AnnotationLayerBuilder({
  9099. pageDiv: pageDiv,
  9100. pdfPage: pdfPage,
  9101. imageResourcesPath: imageResourcesPath,
  9102. renderInteractiveForms: renderInteractiveForms,
  9103. linkService: this.linkService,
  9104. downloadManager: this.downloadManager,
  9105. l10n: l10n
  9106. });
  9107. }
  9108. }, {
  9109. key: "getPagesOverview",
  9110. value: function getPagesOverview() {
  9111. var pagesOverview = this._pages.map(function (pageView) {
  9112. var viewport = pageView.pdfPage.getViewport({
  9113. scale: 1
  9114. });
  9115. return {
  9116. width: viewport.width,
  9117. height: viewport.height,
  9118. rotation: viewport.rotation
  9119. };
  9120. });
  9121. if (!this.enablePrintAutoRotate) {
  9122. return pagesOverview;
  9123. }
  9124. var isFirstPagePortrait = (0, _ui_utils.isPortraitOrientation)(pagesOverview[0]);
  9125. return pagesOverview.map(function (size) {
  9126. if (isFirstPagePortrait === (0, _ui_utils.isPortraitOrientation)(size)) {
  9127. return size;
  9128. }
  9129. return {
  9130. width: size.height,
  9131. height: size.width,
  9132. rotation: (size.rotation + 90) % 360
  9133. };
  9134. });
  9135. }
  9136. }, {
  9137. key: "_updateScrollMode",
  9138. value: function _updateScrollMode() {
  9139. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  9140. var scrollMode = this._scrollMode,
  9141. viewer = this.viewer;
  9142. viewer.classList.toggle('scrollHorizontal', scrollMode === _ui_utils.ScrollMode.HORIZONTAL);
  9143. viewer.classList.toggle('scrollWrapped', scrollMode === _ui_utils.ScrollMode.WRAPPED);
  9144. if (!this.pdfDocument || !pageNumber) {
  9145. return;
  9146. }
  9147. if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
  9148. this._setScale(this._currentScaleValue, true);
  9149. }
  9150. this._setCurrentPageNumber(pageNumber, true);
  9151. this.update();
  9152. }
  9153. }, {
  9154. key: "_updateSpreadMode",
  9155. value: function _updateSpreadMode() {
  9156. var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  9157. if (!this.pdfDocument) {
  9158. return;
  9159. }
  9160. var viewer = this.viewer,
  9161. pages = this._pages;
  9162. viewer.textContent = '';
  9163. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  9164. for (var i = 0, iMax = pages.length; i < iMax; ++i) {
  9165. viewer.appendChild(pages[i].div);
  9166. }
  9167. } else {
  9168. var parity = this._spreadMode - 1;
  9169. var spread = null;
  9170. for (var _i = 0, _iMax = pages.length; _i < _iMax; ++_i) {
  9171. if (spread === null) {
  9172. spread = document.createElement('div');
  9173. spread.className = 'spread';
  9174. viewer.appendChild(spread);
  9175. } else if (_i % 2 === parity) {
  9176. spread = spread.cloneNode(false);
  9177. viewer.appendChild(spread);
  9178. }
  9179. spread.appendChild(pages[_i].div);
  9180. }
  9181. }
  9182. if (!pageNumber) {
  9183. return;
  9184. }
  9185. this._setCurrentPageNumber(pageNumber, true);
  9186. this.update();
  9187. }
  9188. }, {
  9189. key: "pagesCount",
  9190. get: function get() {
  9191. return this._pages.length;
  9192. }
  9193. }, {
  9194. key: "pageViewsReady",
  9195. get: function get() {
  9196. return this._pageViewsReady;
  9197. }
  9198. }, {
  9199. key: "currentPageNumber",
  9200. get: function get() {
  9201. return this._currentPageNumber;
  9202. },
  9203. set: function set(val) {
  9204. if (!Number.isInteger(val)) {
  9205. throw new Error('Invalid page number.');
  9206. }
  9207. if (!this.pdfDocument) {
  9208. return;
  9209. }
  9210. if (!this._setCurrentPageNumber(val, true)) {
  9211. console.error("".concat(this._name, ".currentPageNumber: \"").concat(val, "\" is not a valid page."));
  9212. }
  9213. }
  9214. }, {
  9215. key: "currentPageLabel",
  9216. get: function get() {
  9217. return this._pageLabels && this._pageLabels[this._currentPageNumber - 1];
  9218. },
  9219. set: function set(val) {
  9220. if (!this.pdfDocument) {
  9221. return;
  9222. }
  9223. var page = val | 0;
  9224. if (this._pageLabels) {
  9225. var i = this._pageLabels.indexOf(val);
  9226. if (i >= 0) {
  9227. page = i + 1;
  9228. }
  9229. }
  9230. if (!this._setCurrentPageNumber(page, true)) {
  9231. console.error("".concat(this._name, ".currentPageLabel: \"").concat(val, "\" is not a valid page."));
  9232. }
  9233. }
  9234. }, {
  9235. key: "currentScale",
  9236. get: function get() {
  9237. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
  9238. },
  9239. set: function set(val) {
  9240. if (isNaN(val)) {
  9241. throw new Error('Invalid numeric scale.');
  9242. }
  9243. if (!this.pdfDocument) {
  9244. return;
  9245. }
  9246. this._setScale(val, false);
  9247. }
  9248. }, {
  9249. key: "currentScaleValue",
  9250. get: function get() {
  9251. return this._currentScaleValue;
  9252. },
  9253. set: function set(val) {
  9254. if (!this.pdfDocument) {
  9255. return;
  9256. }
  9257. this._setScale(val, false);
  9258. }
  9259. }, {
  9260. key: "pagesRotation",
  9261. get: function get() {
  9262. return this._pagesRotation;
  9263. },
  9264. set: function set(rotation) {
  9265. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  9266. throw new Error('Invalid pages rotation angle.');
  9267. }
  9268. if (!this.pdfDocument) {
  9269. return;
  9270. }
  9271. if (this._pagesRotation === rotation) {
  9272. return;
  9273. }
  9274. this._pagesRotation = rotation;
  9275. var pageNumber = this._currentPageNumber;
  9276. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  9277. var pageView = this._pages[i];
  9278. pageView.update(pageView.scale, rotation);
  9279. }
  9280. if (this._currentScaleValue) {
  9281. this._setScale(this._currentScaleValue, true);
  9282. }
  9283. this.eventBus.dispatch('rotationchanging', {
  9284. source: this,
  9285. pagesRotation: rotation,
  9286. pageNumber: pageNumber
  9287. });
  9288. if (this.defaultRenderingQueue) {
  9289. this.update();
  9290. }
  9291. }
  9292. }, {
  9293. key: "_setDocumentViewerElement",
  9294. get: function get() {
  9295. throw new Error('Not implemented: _setDocumentViewerElement');
  9296. }
  9297. }, {
  9298. key: "_isScrollModeHorizontal",
  9299. get: function get() {
  9300. return this.isInPresentationMode ? false : this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL;
  9301. }
  9302. }, {
  9303. key: "isInPresentationMode",
  9304. get: function get() {
  9305. return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
  9306. }
  9307. }, {
  9308. key: "isChangingPresentationMode",
  9309. get: function get() {
  9310. return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
  9311. }
  9312. }, {
  9313. key: "isHorizontalScrollbarEnabled",
  9314. get: function get() {
  9315. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  9316. }
  9317. }, {
  9318. key: "isVerticalScrollbarEnabled",
  9319. get: function get() {
  9320. return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight;
  9321. }
  9322. }, {
  9323. key: "hasEqualPageSizes",
  9324. get: function get() {
  9325. var firstPageView = this._pages[0];
  9326. for (var i = 1, ii = this._pages.length; i < ii; ++i) {
  9327. var pageView = this._pages[i];
  9328. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  9329. return false;
  9330. }
  9331. }
  9332. return true;
  9333. }
  9334. }, {
  9335. key: "scrollMode",
  9336. get: function get() {
  9337. return this._scrollMode;
  9338. },
  9339. set: function set(mode) {
  9340. if (this._scrollMode === mode) {
  9341. return;
  9342. }
  9343. if (!(0, _ui_utils.isValidScrollMode)(mode)) {
  9344. throw new Error("Invalid scroll mode: ".concat(mode));
  9345. }
  9346. this._scrollMode = mode;
  9347. this.eventBus.dispatch('scrollmodechanged', {
  9348. source: this,
  9349. mode: mode
  9350. });
  9351. this._updateScrollMode(this._currentPageNumber);
  9352. }
  9353. }, {
  9354. key: "spreadMode",
  9355. get: function get() {
  9356. return this._spreadMode;
  9357. },
  9358. set: function set(mode) {
  9359. if (this._spreadMode === mode) {
  9360. return;
  9361. }
  9362. if (!(0, _ui_utils.isValidSpreadMode)(mode)) {
  9363. throw new Error("Invalid spread mode: ".concat(mode));
  9364. }
  9365. this._spreadMode = mode;
  9366. this.eventBus.dispatch('spreadmodechanged', {
  9367. source: this,
  9368. mode: mode
  9369. });
  9370. this._updateSpreadMode(this._currentPageNumber);
  9371. }
  9372. }]);
  9373. return BaseViewer;
  9374. }();
  9375. exports.BaseViewer = BaseViewer;
  9376. /***/ }),
  9377. /* 30 */
  9378. /***/ (function(module, exports, __webpack_require__) {
  9379. "use strict";
  9380. Object.defineProperty(exports, "__esModule", {
  9381. value: true
  9382. });
  9383. exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = void 0;
  9384. var _pdfjsLib = __webpack_require__(7);
  9385. var _ui_utils = __webpack_require__(6);
  9386. var _pdf_link_service = __webpack_require__(22);
  9387. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9388. 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); } }
  9389. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9390. var AnnotationLayerBuilder =
  9391. /*#__PURE__*/
  9392. function () {
  9393. function AnnotationLayerBuilder(_ref) {
  9394. var pageDiv = _ref.pageDiv,
  9395. pdfPage = _ref.pdfPage,
  9396. linkService = _ref.linkService,
  9397. downloadManager = _ref.downloadManager,
  9398. _ref$imageResourcesPa = _ref.imageResourcesPath,
  9399. imageResourcesPath = _ref$imageResourcesPa === void 0 ? '' : _ref$imageResourcesPa,
  9400. _ref$renderInteractiv = _ref.renderInteractiveForms,
  9401. renderInteractiveForms = _ref$renderInteractiv === void 0 ? false : _ref$renderInteractiv,
  9402. _ref$l10n = _ref.l10n,
  9403. l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
  9404. _classCallCheck(this, AnnotationLayerBuilder);
  9405. this.pageDiv = pageDiv;
  9406. this.pdfPage = pdfPage;
  9407. this.linkService = linkService;
  9408. this.downloadManager = downloadManager;
  9409. this.imageResourcesPath = imageResourcesPath;
  9410. this.renderInteractiveForms = renderInteractiveForms;
  9411. this.l10n = l10n;
  9412. this.div = null;
  9413. this._cancelled = false;
  9414. }
  9415. _createClass(AnnotationLayerBuilder, [{
  9416. key: "render",
  9417. value: function render(viewport) {
  9418. var _this = this;
  9419. var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'display';
  9420. this.pdfPage.getAnnotations({
  9421. intent: intent
  9422. }).then(function (annotations) {
  9423. if (_this._cancelled) {
  9424. return;
  9425. }
  9426. var parameters = {
  9427. viewport: viewport.clone({
  9428. dontFlip: true
  9429. }),
  9430. div: _this.div,
  9431. annotations: annotations,
  9432. page: _this.pdfPage,
  9433. imageResourcesPath: _this.imageResourcesPath,
  9434. renderInteractiveForms: _this.renderInteractiveForms,
  9435. linkService: _this.linkService,
  9436. downloadManager: _this.downloadManager
  9437. };
  9438. if (_this.div) {
  9439. _pdfjsLib.AnnotationLayer.update(parameters);
  9440. } else {
  9441. if (annotations.length === 0) {
  9442. return;
  9443. }
  9444. _this.div = document.createElement('div');
  9445. _this.div.className = 'annotationLayer';
  9446. _this.pageDiv.appendChild(_this.div);
  9447. parameters.div = _this.div;
  9448. _pdfjsLib.AnnotationLayer.render(parameters);
  9449. _this.l10n.translate(_this.div);
  9450. }
  9451. });
  9452. }
  9453. }, {
  9454. key: "cancel",
  9455. value: function cancel() {
  9456. this._cancelled = true;
  9457. }
  9458. }, {
  9459. key: "hide",
  9460. value: function hide() {
  9461. if (!this.div) {
  9462. return;
  9463. }
  9464. this.div.setAttribute('hidden', 'true');
  9465. }
  9466. }]);
  9467. return AnnotationLayerBuilder;
  9468. }();
  9469. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  9470. var DefaultAnnotationLayerFactory =
  9471. /*#__PURE__*/
  9472. function () {
  9473. function DefaultAnnotationLayerFactory() {
  9474. _classCallCheck(this, DefaultAnnotationLayerFactory);
  9475. }
  9476. _createClass(DefaultAnnotationLayerFactory, [{
  9477. key: "createAnnotationLayerBuilder",
  9478. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  9479. var imageResourcesPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  9480. var renderInteractiveForms = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9481. var l10n = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _ui_utils.NullL10n;
  9482. return new AnnotationLayerBuilder({
  9483. pageDiv: pageDiv,
  9484. pdfPage: pdfPage,
  9485. imageResourcesPath: imageResourcesPath,
  9486. renderInteractiveForms: renderInteractiveForms,
  9487. linkService: new _pdf_link_service.SimpleLinkService(),
  9488. l10n: l10n
  9489. });
  9490. }
  9491. }]);
  9492. return DefaultAnnotationLayerFactory;
  9493. }();
  9494. exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
  9495. /***/ }),
  9496. /* 31 */
  9497. /***/ (function(module, exports, __webpack_require__) {
  9498. "use strict";
  9499. Object.defineProperty(exports, "__esModule", {
  9500. value: true
  9501. });
  9502. exports.PDFPageView = void 0;
  9503. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  9504. var _ui_utils = __webpack_require__(6);
  9505. var _pdfjsLib = __webpack_require__(7);
  9506. var _pdf_rendering_queue = __webpack_require__(10);
  9507. var _viewer_compatibility = __webpack_require__(13);
  9508. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9509. 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); } }
  9510. 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); }); }; }
  9511. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9512. 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); } }
  9513. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9514. var MAX_CANVAS_PIXELS = _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216;
  9515. var PDFPageView =
  9516. /*#__PURE__*/
  9517. function () {
  9518. function PDFPageView(options) {
  9519. _classCallCheck(this, PDFPageView);
  9520. var container = options.container;
  9521. var defaultViewport = options.defaultViewport;
  9522. this.id = options.id;
  9523. this.renderingId = 'page' + this.id;
  9524. this.pdfPage = null;
  9525. this.pageLabel = null;
  9526. this.rotation = 0;
  9527. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  9528. this.viewport = defaultViewport;
  9529. this.pdfPageRotate = defaultViewport.rotation;
  9530. this.hasRestrictedScaling = false;
  9531. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  9532. this.imageResourcesPath = options.imageResourcesPath || '';
  9533. this.renderInteractiveForms = options.renderInteractiveForms || false;
  9534. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  9535. this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
  9536. this.eventBus = options.eventBus || (0, _ui_utils.getGlobalEventBus)();
  9537. this.renderingQueue = options.renderingQueue;
  9538. this.textLayerFactory = options.textLayerFactory;
  9539. this.annotationLayerFactory = options.annotationLayerFactory;
  9540. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  9541. this.enableWebGL = options.enableWebGL || false;
  9542. this.l10n = options.l10n || _ui_utils.NullL10n;
  9543. this.paintTask = null;
  9544. this.paintedViewportMap = new WeakMap();
  9545. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  9546. this.resume = null;
  9547. this.error = null;
  9548. this.onBeforeDraw = null;
  9549. this.onAfterDraw = null;
  9550. this.annotationLayer = null;
  9551. this.textLayer = null;
  9552. this.zoomLayer = null;
  9553. var div = document.createElement('div');
  9554. div.className = 'page';
  9555. div.style.width = Math.floor(this.viewport.width) + 'px';
  9556. div.style.height = Math.floor(this.viewport.height) + 'px';
  9557. div.setAttribute('data-page-number', this.id);
  9558. this.div = div;
  9559. container.appendChild(div);
  9560. }
  9561. _createClass(PDFPageView, [{
  9562. key: "setPdfPage",
  9563. value: function setPdfPage(pdfPage) {
  9564. this.pdfPage = pdfPage;
  9565. this.pdfPageRotate = pdfPage.rotate;
  9566. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  9567. this.viewport = pdfPage.getViewport({
  9568. scale: this.scale * _ui_utils.CSS_UNITS,
  9569. rotation: totalRotation
  9570. });
  9571. this.stats = pdfPage.stats;
  9572. this.reset();
  9573. }
  9574. }, {
  9575. key: "destroy",
  9576. value: function destroy() {
  9577. this.reset();
  9578. if (this.pdfPage) {
  9579. this.pdfPage.cleanup();
  9580. }
  9581. }
  9582. }, {
  9583. key: "_resetZoomLayer",
  9584. value: function _resetZoomLayer() {
  9585. var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9586. if (!this.zoomLayer) {
  9587. return;
  9588. }
  9589. var zoomLayerCanvas = this.zoomLayer.firstChild;
  9590. this.paintedViewportMap.delete(zoomLayerCanvas);
  9591. zoomLayerCanvas.width = 0;
  9592. zoomLayerCanvas.height = 0;
  9593. if (removeFromDOM) {
  9594. this.zoomLayer.remove();
  9595. }
  9596. this.zoomLayer = null;
  9597. }
  9598. }, {
  9599. key: "reset",
  9600. value: function reset() {
  9601. var keepZoomLayer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9602. var keepAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9603. this.cancelRendering(keepAnnotations);
  9604. var div = this.div;
  9605. div.style.width = Math.floor(this.viewport.width) + 'px';
  9606. div.style.height = Math.floor(this.viewport.height) + 'px';
  9607. var childNodes = div.childNodes;
  9608. var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
  9609. var currentAnnotationNode = keepAnnotations && this.annotationLayer && this.annotationLayer.div || null;
  9610. for (var i = childNodes.length - 1; i >= 0; i--) {
  9611. var node = childNodes[i];
  9612. if (currentZoomLayerNode === node || currentAnnotationNode === node) {
  9613. continue;
  9614. }
  9615. div.removeChild(node);
  9616. }
  9617. div.removeAttribute('data-loaded');
  9618. if (currentAnnotationNode) {
  9619. this.annotationLayer.hide();
  9620. } else if (this.annotationLayer) {
  9621. this.annotationLayer.cancel();
  9622. this.annotationLayer = null;
  9623. }
  9624. if (!currentZoomLayerNode) {
  9625. if (this.canvas) {
  9626. this.paintedViewportMap.delete(this.canvas);
  9627. this.canvas.width = 0;
  9628. this.canvas.height = 0;
  9629. delete this.canvas;
  9630. }
  9631. this._resetZoomLayer();
  9632. }
  9633. if (this.svg) {
  9634. this.paintedViewportMap.delete(this.svg);
  9635. delete this.svg;
  9636. }
  9637. this.loadingIconDiv = document.createElement('div');
  9638. this.loadingIconDiv.className = 'loadingIcon';
  9639. div.appendChild(this.loadingIconDiv);
  9640. }
  9641. }, {
  9642. key: "update",
  9643. value: function update(scale, rotation) {
  9644. this.scale = scale || this.scale;
  9645. if (typeof rotation !== 'undefined') {
  9646. this.rotation = rotation;
  9647. }
  9648. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  9649. this.viewport = this.viewport.clone({
  9650. scale: this.scale * _ui_utils.CSS_UNITS,
  9651. rotation: totalRotation
  9652. });
  9653. if (this.svg) {
  9654. this.cssTransform(this.svg, true);
  9655. this.eventBus.dispatch('pagerendered', {
  9656. source: this,
  9657. pageNumber: this.id,
  9658. cssTransform: true
  9659. });
  9660. return;
  9661. }
  9662. var isScalingRestricted = false;
  9663. if (this.canvas && this.maxCanvasPixels > 0) {
  9664. var outputScale = this.outputScale;
  9665. if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > this.maxCanvasPixels) {
  9666. isScalingRestricted = true;
  9667. }
  9668. }
  9669. if (this.canvas) {
  9670. if (this.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
  9671. this.cssTransform(this.canvas, true);
  9672. this.eventBus.dispatch('pagerendered', {
  9673. source: this,
  9674. pageNumber: this.id,
  9675. cssTransform: true
  9676. });
  9677. return;
  9678. }
  9679. if (!this.zoomLayer && !this.canvas.hasAttribute('hidden')) {
  9680. this.zoomLayer = this.canvas.parentNode;
  9681. this.zoomLayer.style.position = 'absolute';
  9682. }
  9683. }
  9684. if (this.zoomLayer) {
  9685. this.cssTransform(this.zoomLayer.firstChild);
  9686. }
  9687. this.reset(true, true);
  9688. }
  9689. }, {
  9690. key: "cancelRendering",
  9691. value: function cancelRendering() {
  9692. var keepAnnotations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9693. var renderingState = this.renderingState;
  9694. if (this.paintTask) {
  9695. this.paintTask.cancel();
  9696. this.paintTask = null;
  9697. }
  9698. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  9699. this.resume = null;
  9700. if (this.textLayer) {
  9701. this.textLayer.cancel();
  9702. this.textLayer = null;
  9703. }
  9704. if (!keepAnnotations && this.annotationLayer) {
  9705. this.annotationLayer.cancel();
  9706. this.annotationLayer = null;
  9707. }
  9708. if (renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  9709. this.eventBus.dispatch('pagecancelled', {
  9710. source: this,
  9711. pageNumber: this.id,
  9712. renderingState: renderingState
  9713. });
  9714. }
  9715. }
  9716. }, {
  9717. key: "cssTransform",
  9718. value: function cssTransform(target) {
  9719. var redrawAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  9720. var width = this.viewport.width;
  9721. var height = this.viewport.height;
  9722. var div = this.div;
  9723. target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + 'px';
  9724. target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + 'px';
  9725. var relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
  9726. var absRotation = Math.abs(relativeRotation);
  9727. var scaleX = 1,
  9728. scaleY = 1;
  9729. if (absRotation === 90 || absRotation === 270) {
  9730. scaleX = height / width;
  9731. scaleY = width / height;
  9732. }
  9733. var cssTransform = 'rotate(' + relativeRotation + 'deg) ' + 'scale(' + scaleX + ',' + scaleY + ')';
  9734. target.style.transform = cssTransform;
  9735. if (this.textLayer) {
  9736. var textLayerViewport = this.textLayer.viewport;
  9737. var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
  9738. var textAbsRotation = Math.abs(textRelativeRotation);
  9739. var scale = width / textLayerViewport.width;
  9740. if (textAbsRotation === 90 || textAbsRotation === 270) {
  9741. scale = width / textLayerViewport.height;
  9742. }
  9743. var textLayerDiv = this.textLayer.textLayerDiv;
  9744. var transX, transY;
  9745. switch (textAbsRotation) {
  9746. case 0:
  9747. transX = transY = 0;
  9748. break;
  9749. case 90:
  9750. transX = 0;
  9751. transY = '-' + textLayerDiv.style.height;
  9752. break;
  9753. case 180:
  9754. transX = '-' + textLayerDiv.style.width;
  9755. transY = '-' + textLayerDiv.style.height;
  9756. break;
  9757. case 270:
  9758. transX = '-' + textLayerDiv.style.width;
  9759. transY = 0;
  9760. break;
  9761. default:
  9762. console.error('Bad rotation value.');
  9763. break;
  9764. }
  9765. textLayerDiv.style.transform = 'rotate(' + textAbsRotation + 'deg) ' + 'scale(' + scale + ', ' + scale + ') ' + 'translate(' + transX + ', ' + transY + ')';
  9766. textLayerDiv.style.transformOrigin = '0% 0%';
  9767. }
  9768. if (redrawAnnotations && this.annotationLayer) {
  9769. this.annotationLayer.render(this.viewport, 'display');
  9770. }
  9771. }
  9772. }, {
  9773. key: "getPagePoint",
  9774. value: function getPagePoint(x, y) {
  9775. return this.viewport.convertToPdfPoint(x, y);
  9776. }
  9777. }, {
  9778. key: "draw",
  9779. value: function draw() {
  9780. var _this = this;
  9781. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  9782. console.error('Must be in new state before drawing');
  9783. this.reset();
  9784. }
  9785. if (!this.pdfPage) {
  9786. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  9787. return Promise.reject(new Error('Page is not loaded'));
  9788. }
  9789. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  9790. var pdfPage = this.pdfPage;
  9791. var div = this.div;
  9792. var canvasWrapper = document.createElement('div');
  9793. canvasWrapper.style.width = div.style.width;
  9794. canvasWrapper.style.height = div.style.height;
  9795. canvasWrapper.classList.add('canvasWrapper');
  9796. if (this.annotationLayer && this.annotationLayer.div) {
  9797. div.insertBefore(canvasWrapper, this.annotationLayer.div);
  9798. } else {
  9799. div.appendChild(canvasWrapper);
  9800. }
  9801. var textLayer = null;
  9802. if (this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && this.textLayerFactory) {
  9803. var textLayerDiv = document.createElement('div');
  9804. textLayerDiv.className = 'textLayer';
  9805. textLayerDiv.style.width = canvasWrapper.style.width;
  9806. textLayerDiv.style.height = canvasWrapper.style.height;
  9807. if (this.annotationLayer && this.annotationLayer.div) {
  9808. div.insertBefore(textLayerDiv, this.annotationLayer.div);
  9809. } else {
  9810. div.appendChild(textLayerDiv);
  9811. }
  9812. textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.textLayerMode === _ui_utils.TextLayerMode.ENABLE_ENHANCE);
  9813. }
  9814. this.textLayer = textLayer;
  9815. var renderContinueCallback = null;
  9816. if (this.renderingQueue) {
  9817. renderContinueCallback = function renderContinueCallback(cont) {
  9818. if (!_this.renderingQueue.isHighestPriority(_this)) {
  9819. _this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  9820. _this.resume = function () {
  9821. _this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  9822. cont();
  9823. };
  9824. return;
  9825. }
  9826. cont();
  9827. };
  9828. }
  9829. var finishPaintTask =
  9830. /*#__PURE__*/
  9831. function () {
  9832. var _ref = _asyncToGenerator(
  9833. /*#__PURE__*/
  9834. _regenerator.default.mark(function _callee(error) {
  9835. return _regenerator.default.wrap(function _callee$(_context) {
  9836. while (1) {
  9837. switch (_context.prev = _context.next) {
  9838. case 0:
  9839. if (paintTask === _this.paintTask) {
  9840. _this.paintTask = null;
  9841. }
  9842. if (!(error instanceof _pdfjsLib.RenderingCancelledException)) {
  9843. _context.next = 4;
  9844. break;
  9845. }
  9846. _this.error = null;
  9847. return _context.abrupt("return");
  9848. case 4:
  9849. _this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  9850. if (_this.loadingIconDiv) {
  9851. div.removeChild(_this.loadingIconDiv);
  9852. delete _this.loadingIconDiv;
  9853. }
  9854. _this._resetZoomLayer(true);
  9855. _this.error = error;
  9856. _this.stats = pdfPage.stats;
  9857. if (_this.onAfterDraw) {
  9858. _this.onAfterDraw();
  9859. }
  9860. _this.eventBus.dispatch('pagerendered', {
  9861. source: _this,
  9862. pageNumber: _this.id,
  9863. cssTransform: false
  9864. });
  9865. if (!error) {
  9866. _context.next = 13;
  9867. break;
  9868. }
  9869. throw error;
  9870. case 13:
  9871. case "end":
  9872. return _context.stop();
  9873. }
  9874. }
  9875. }, _callee, this);
  9876. }));
  9877. return function finishPaintTask(_x) {
  9878. return _ref.apply(this, arguments);
  9879. };
  9880. }();
  9881. var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
  9882. paintTask.onRenderContinue = renderContinueCallback;
  9883. this.paintTask = paintTask;
  9884. var resultPromise = paintTask.promise.then(function () {
  9885. return finishPaintTask(null).then(function () {
  9886. if (textLayer) {
  9887. var readableStream = pdfPage.streamTextContent({
  9888. normalizeWhitespace: true
  9889. });
  9890. textLayer.setTextContentStream(readableStream);
  9891. textLayer.render();
  9892. }
  9893. });
  9894. }, function (reason) {
  9895. return finishPaintTask(reason);
  9896. });
  9897. if (this.annotationLayerFactory) {
  9898. if (!this.annotationLayer) {
  9899. this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this.imageResourcesPath, this.renderInteractiveForms, this.l10n);
  9900. }
  9901. this.annotationLayer.render(this.viewport, 'display');
  9902. }
  9903. div.setAttribute('data-loaded', true);
  9904. if (this.onBeforeDraw) {
  9905. this.onBeforeDraw();
  9906. }
  9907. return resultPromise;
  9908. }
  9909. }, {
  9910. key: "paintOnCanvas",
  9911. value: function paintOnCanvas(canvasWrapper) {
  9912. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  9913. var result = {
  9914. promise: renderCapability.promise,
  9915. onRenderContinue: function onRenderContinue(cont) {
  9916. cont();
  9917. },
  9918. cancel: function cancel() {
  9919. renderTask.cancel();
  9920. }
  9921. };
  9922. var viewport = this.viewport;
  9923. var canvas = document.createElement('canvas');
  9924. canvas.id = this.renderingId;
  9925. canvas.setAttribute('hidden', 'hidden');
  9926. var isCanvasHidden = true;
  9927. var showCanvas = function showCanvas() {
  9928. if (isCanvasHidden) {
  9929. canvas.removeAttribute('hidden');
  9930. isCanvasHidden = false;
  9931. }
  9932. };
  9933. canvasWrapper.appendChild(canvas);
  9934. this.canvas = canvas;
  9935. canvas.mozOpaque = true;
  9936. var ctx = canvas.getContext('2d', {
  9937. alpha: false
  9938. });
  9939. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  9940. this.outputScale = outputScale;
  9941. if (this.useOnlyCssZoom) {
  9942. var actualSizeViewport = viewport.clone({
  9943. scale: _ui_utils.CSS_UNITS
  9944. });
  9945. outputScale.sx *= actualSizeViewport.width / viewport.width;
  9946. outputScale.sy *= actualSizeViewport.height / viewport.height;
  9947. outputScale.scaled = true;
  9948. }
  9949. if (this.maxCanvasPixels > 0) {
  9950. var pixelsInViewport = viewport.width * viewport.height;
  9951. var maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
  9952. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  9953. outputScale.sx = maxScale;
  9954. outputScale.sy = maxScale;
  9955. outputScale.scaled = true;
  9956. this.hasRestrictedScaling = true;
  9957. } else {
  9958. this.hasRestrictedScaling = false;
  9959. }
  9960. }
  9961. var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  9962. var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  9963. canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
  9964. canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
  9965. canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + 'px';
  9966. canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + 'px';
  9967. this.paintedViewportMap.set(canvas, viewport);
  9968. var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
  9969. var renderContext = {
  9970. canvasContext: ctx,
  9971. transform: transform,
  9972. viewport: this.viewport,
  9973. enableWebGL: this.enableWebGL,
  9974. renderInteractiveForms: this.renderInteractiveForms
  9975. };
  9976. var renderTask = this.pdfPage.render(renderContext);
  9977. renderTask.onContinue = function (cont) {
  9978. showCanvas();
  9979. if (result.onRenderContinue) {
  9980. result.onRenderContinue(cont);
  9981. } else {
  9982. cont();
  9983. }
  9984. };
  9985. renderTask.promise.then(function () {
  9986. showCanvas();
  9987. renderCapability.resolve(undefined);
  9988. }, function (error) {
  9989. showCanvas();
  9990. renderCapability.reject(error);
  9991. });
  9992. return result;
  9993. }
  9994. }, {
  9995. key: "paintOnSvg",
  9996. value: function paintOnSvg(wrapper) {
  9997. var _this2 = this;
  9998. var cancelled = false;
  9999. var ensureNotCancelled = function ensureNotCancelled() {
  10000. if (cancelled) {
  10001. throw new _pdfjsLib.RenderingCancelledException('Rendering cancelled, page ' + _this2.id, 'svg');
  10002. }
  10003. };
  10004. var pdfPage = this.pdfPage;
  10005. var actualSizeViewport = this.viewport.clone({
  10006. scale: _ui_utils.CSS_UNITS
  10007. });
  10008. var promise = pdfPage.getOperatorList().then(function (opList) {
  10009. ensureNotCancelled();
  10010. var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
  10011. return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {
  10012. ensureNotCancelled();
  10013. _this2.svg = svg;
  10014. _this2.paintedViewportMap.set(svg, actualSizeViewport);
  10015. svg.style.width = wrapper.style.width;
  10016. svg.style.height = wrapper.style.height;
  10017. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  10018. wrapper.appendChild(svg);
  10019. });
  10020. });
  10021. return {
  10022. promise: promise,
  10023. onRenderContinue: function onRenderContinue(cont) {
  10024. cont();
  10025. },
  10026. cancel: function cancel() {
  10027. cancelled = true;
  10028. }
  10029. };
  10030. }
  10031. }, {
  10032. key: "setPageLabel",
  10033. value: function setPageLabel(label) {
  10034. this.pageLabel = typeof label === 'string' ? label : null;
  10035. if (this.pageLabel !== null) {
  10036. this.div.setAttribute('data-page-label', this.pageLabel);
  10037. } else {
  10038. this.div.removeAttribute('data-page-label');
  10039. }
  10040. }
  10041. }, {
  10042. key: "width",
  10043. get: function get() {
  10044. return this.viewport.width;
  10045. }
  10046. }, {
  10047. key: "height",
  10048. get: function get() {
  10049. return this.viewport.height;
  10050. }
  10051. }]);
  10052. return PDFPageView;
  10053. }();
  10054. exports.PDFPageView = PDFPageView;
  10055. /***/ }),
  10056. /* 32 */
  10057. /***/ (function(module, exports, __webpack_require__) {
  10058. "use strict";
  10059. Object.defineProperty(exports, "__esModule", {
  10060. value: true
  10061. });
  10062. exports.DefaultTextLayerFactory = exports.TextLayerBuilder = void 0;
  10063. var _ui_utils = __webpack_require__(6);
  10064. var _pdfjsLib = __webpack_require__(7);
  10065. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10066. 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); } }
  10067. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10068. var EXPAND_DIVS_TIMEOUT = 300;
  10069. var TextLayerBuilder =
  10070. /*#__PURE__*/
  10071. function () {
  10072. function TextLayerBuilder(_ref) {
  10073. var textLayerDiv = _ref.textLayerDiv,
  10074. eventBus = _ref.eventBus,
  10075. pageIndex = _ref.pageIndex,
  10076. viewport = _ref.viewport,
  10077. _ref$findController = _ref.findController,
  10078. findController = _ref$findController === void 0 ? null : _ref$findController,
  10079. _ref$enhanceTextSelec = _ref.enhanceTextSelection,
  10080. enhanceTextSelection = _ref$enhanceTextSelec === void 0 ? false : _ref$enhanceTextSelec;
  10081. _classCallCheck(this, TextLayerBuilder);
  10082. this.textLayerDiv = textLayerDiv;
  10083. this.eventBus = eventBus || (0, _ui_utils.getGlobalEventBus)();
  10084. this.textContent = null;
  10085. this.textContentItemsStr = [];
  10086. this.textContentStream = null;
  10087. this.renderingDone = false;
  10088. this.pageIdx = pageIndex;
  10089. this.pageNumber = this.pageIdx + 1;
  10090. this.matches = [];
  10091. this.viewport = viewport;
  10092. this.textDivs = [];
  10093. this.findController = findController;
  10094. this.textLayerRenderTask = null;
  10095. this.enhanceTextSelection = enhanceTextSelection;
  10096. this._boundEvents = Object.create(null);
  10097. this._bindEvents();
  10098. this._bindMouse();
  10099. }
  10100. _createClass(TextLayerBuilder, [{
  10101. key: "_finishRendering",
  10102. value: function _finishRendering() {
  10103. this.renderingDone = true;
  10104. if (!this.enhanceTextSelection) {
  10105. var endOfContent = document.createElement('div');
  10106. endOfContent.className = 'endOfContent';
  10107. this.textLayerDiv.appendChild(endOfContent);
  10108. }
  10109. this.eventBus.dispatch('textlayerrendered', {
  10110. source: this,
  10111. pageNumber: this.pageNumber,
  10112. numTextDivs: this.textDivs.length
  10113. });
  10114. }
  10115. }, {
  10116. key: "render",
  10117. value: function render() {
  10118. var _this = this;
  10119. var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  10120. if (!(this.textContent || this.textContentStream) || this.renderingDone) {
  10121. return;
  10122. }
  10123. this.cancel();
  10124. this.textDivs = [];
  10125. var textLayerFrag = document.createDocumentFragment();
  10126. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  10127. textContent: this.textContent,
  10128. textContentStream: this.textContentStream,
  10129. container: textLayerFrag,
  10130. viewport: this.viewport,
  10131. textDivs: this.textDivs,
  10132. textContentItemsStr: this.textContentItemsStr,
  10133. timeout: timeout,
  10134. enhanceTextSelection: this.enhanceTextSelection
  10135. });
  10136. this.textLayerRenderTask.promise.then(function () {
  10137. _this.textLayerDiv.appendChild(textLayerFrag);
  10138. _this._finishRendering();
  10139. _this._updateMatches();
  10140. }, function (reason) {});
  10141. }
  10142. }, {
  10143. key: "cancel",
  10144. value: function cancel() {
  10145. if (this.textLayerRenderTask) {
  10146. this.textLayerRenderTask.cancel();
  10147. this.textLayerRenderTask = null;
  10148. }
  10149. }
  10150. }, {
  10151. key: "setTextContentStream",
  10152. value: function setTextContentStream(readableStream) {
  10153. this.cancel();
  10154. this.textContentStream = readableStream;
  10155. }
  10156. }, {
  10157. key: "setTextContent",
  10158. value: function setTextContent(textContent) {
  10159. this.cancel();
  10160. this.textContent = textContent;
  10161. }
  10162. }, {
  10163. key: "_convertMatches",
  10164. value: function _convertMatches(matches, matchesLength) {
  10165. if (!matches) {
  10166. return [];
  10167. }
  10168. var findController = this.findController,
  10169. textContentItemsStr = this.textContentItemsStr;
  10170. var i = 0,
  10171. iIndex = 0;
  10172. var end = textContentItemsStr.length - 1;
  10173. var queryLen = findController.state.query.length;
  10174. var result = [];
  10175. for (var m = 0, mm = matches.length; m < mm; m++) {
  10176. var matchIdx = matches[m];
  10177. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  10178. iIndex += textContentItemsStr[i].length;
  10179. i++;
  10180. }
  10181. if (i === textContentItemsStr.length) {
  10182. console.error('Could not find a matching mapping');
  10183. }
  10184. var match = {
  10185. begin: {
  10186. divIdx: i,
  10187. offset: matchIdx - iIndex
  10188. }
  10189. };
  10190. if (matchesLength) {
  10191. matchIdx += matchesLength[m];
  10192. } else {
  10193. matchIdx += queryLen;
  10194. }
  10195. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  10196. iIndex += textContentItemsStr[i].length;
  10197. i++;
  10198. }
  10199. match.end = {
  10200. divIdx: i,
  10201. offset: matchIdx - iIndex
  10202. };
  10203. result.push(match);
  10204. }
  10205. return result;
  10206. }
  10207. }, {
  10208. key: "_renderMatches",
  10209. value: function _renderMatches(matches) {
  10210. if (matches.length === 0) {
  10211. return;
  10212. }
  10213. var findController = this.findController,
  10214. pageIdx = this.pageIdx,
  10215. textContentItemsStr = this.textContentItemsStr,
  10216. textDivs = this.textDivs;
  10217. var isSelectedPage = pageIdx === findController.selected.pageIdx;
  10218. var selectedMatchIdx = findController.selected.matchIdx;
  10219. var highlightAll = findController.state.highlightAll;
  10220. var prevEnd = null;
  10221. var infinity = {
  10222. divIdx: -1,
  10223. offset: undefined
  10224. };
  10225. function beginText(begin, className) {
  10226. var divIdx = begin.divIdx;
  10227. textDivs[divIdx].textContent = '';
  10228. appendTextToDiv(divIdx, 0, begin.offset, className);
  10229. }
  10230. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  10231. var div = textDivs[divIdx];
  10232. var content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  10233. var node = document.createTextNode(content);
  10234. if (className) {
  10235. var span = document.createElement('span');
  10236. span.className = className;
  10237. span.appendChild(node);
  10238. div.appendChild(span);
  10239. return;
  10240. }
  10241. div.appendChild(node);
  10242. }
  10243. var i0 = selectedMatchIdx,
  10244. i1 = i0 + 1;
  10245. if (highlightAll) {
  10246. i0 = 0;
  10247. i1 = matches.length;
  10248. } else if (!isSelectedPage) {
  10249. return;
  10250. }
  10251. for (var i = i0; i < i1; i++) {
  10252. var match = matches[i];
  10253. var begin = match.begin;
  10254. var end = match.end;
  10255. var isSelected = isSelectedPage && i === selectedMatchIdx;
  10256. var highlightSuffix = isSelected ? ' selected' : '';
  10257. if (isSelected) {
  10258. findController.scrollMatchIntoView({
  10259. element: textDivs[begin.divIdx],
  10260. pageIndex: pageIdx,
  10261. matchIndex: selectedMatchIdx
  10262. });
  10263. }
  10264. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  10265. if (prevEnd !== null) {
  10266. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  10267. }
  10268. beginText(begin);
  10269. } else {
  10270. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  10271. }
  10272. if (begin.divIdx === end.divIdx) {
  10273. appendTextToDiv(begin.divIdx, begin.offset, end.offset, 'highlight' + highlightSuffix);
  10274. } else {
  10275. appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, 'highlight begin' + highlightSuffix);
  10276. for (var n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  10277. textDivs[n0].className = 'highlight middle' + highlightSuffix;
  10278. }
  10279. beginText(end, 'highlight end' + highlightSuffix);
  10280. }
  10281. prevEnd = end;
  10282. }
  10283. if (prevEnd) {
  10284. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  10285. }
  10286. }
  10287. }, {
  10288. key: "_updateMatches",
  10289. value: function _updateMatches() {
  10290. if (!this.renderingDone) {
  10291. return;
  10292. }
  10293. var findController = this.findController,
  10294. matches = this.matches,
  10295. pageIdx = this.pageIdx,
  10296. textContentItemsStr = this.textContentItemsStr,
  10297. textDivs = this.textDivs;
  10298. var clearedUntilDivIdx = -1;
  10299. for (var i = 0, ii = matches.length; i < ii; i++) {
  10300. var match = matches[i];
  10301. var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  10302. for (var n = begin, end = match.end.divIdx; n <= end; n++) {
  10303. var div = textDivs[n];
  10304. div.textContent = textContentItemsStr[n];
  10305. div.className = '';
  10306. }
  10307. clearedUntilDivIdx = match.end.divIdx + 1;
  10308. }
  10309. if (!findController || !findController.highlightMatches) {
  10310. return;
  10311. }
  10312. var pageMatches = findController.pageMatches[pageIdx] || null;
  10313. var pageMatchesLength = findController.pageMatchesLength[pageIdx] || null;
  10314. this.matches = this._convertMatches(pageMatches, pageMatchesLength);
  10315. this._renderMatches(this.matches);
  10316. }
  10317. }, {
  10318. key: "_bindEvents",
  10319. value: function _bindEvents() {
  10320. var _this2 = this;
  10321. var eventBus = this.eventBus,
  10322. _boundEvents = this._boundEvents;
  10323. _boundEvents.pageCancelled = function (evt) {
  10324. if (evt.pageNumber !== _this2.pageNumber) {
  10325. return;
  10326. }
  10327. if (_this2.textLayerRenderTask) {
  10328. console.error('TextLayerBuilder._bindEvents: `this.cancel()` should ' + 'have been called when the page was reset, or rendering cancelled.');
  10329. return;
  10330. }
  10331. for (var name in _boundEvents) {
  10332. eventBus.off(name.toLowerCase(), _boundEvents[name]);
  10333. delete _boundEvents[name];
  10334. }
  10335. };
  10336. _boundEvents.updateTextLayerMatches = function (evt) {
  10337. if (evt.pageIndex !== _this2.pageIdx && evt.pageIndex !== -1) {
  10338. return;
  10339. }
  10340. _this2._updateMatches();
  10341. };
  10342. eventBus.on('pagecancelled', _boundEvents.pageCancelled);
  10343. eventBus.on('updatetextlayermatches', _boundEvents.updateTextLayerMatches);
  10344. }
  10345. }, {
  10346. key: "_bindMouse",
  10347. value: function _bindMouse() {
  10348. var _this3 = this;
  10349. var div = this.textLayerDiv;
  10350. var expandDivsTimer = null;
  10351. div.addEventListener('mousedown', function (evt) {
  10352. if (_this3.enhanceTextSelection && _this3.textLayerRenderTask) {
  10353. _this3.textLayerRenderTask.expandTextDivs(true);
  10354. if (expandDivsTimer) {
  10355. clearTimeout(expandDivsTimer);
  10356. expandDivsTimer = null;
  10357. }
  10358. return;
  10359. }
  10360. var end = div.querySelector('.endOfContent');
  10361. if (!end) {
  10362. return;
  10363. }
  10364. var adjustTop = evt.target !== div;
  10365. adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue('-moz-user-select') !== 'none';
  10366. if (adjustTop) {
  10367. var divBounds = div.getBoundingClientRect();
  10368. var r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  10369. end.style.top = (r * 100).toFixed(2) + '%';
  10370. }
  10371. end.classList.add('active');
  10372. });
  10373. div.addEventListener('mouseup', function () {
  10374. if (_this3.enhanceTextSelection && _this3.textLayerRenderTask) {
  10375. expandDivsTimer = setTimeout(function () {
  10376. if (_this3.textLayerRenderTask) {
  10377. _this3.textLayerRenderTask.expandTextDivs(false);
  10378. }
  10379. expandDivsTimer = null;
  10380. }, EXPAND_DIVS_TIMEOUT);
  10381. return;
  10382. }
  10383. var end = div.querySelector('.endOfContent');
  10384. if (!end) {
  10385. return;
  10386. }
  10387. end.style.top = '';
  10388. end.classList.remove('active');
  10389. });
  10390. }
  10391. }]);
  10392. return TextLayerBuilder;
  10393. }();
  10394. exports.TextLayerBuilder = TextLayerBuilder;
  10395. var DefaultTextLayerFactory =
  10396. /*#__PURE__*/
  10397. function () {
  10398. function DefaultTextLayerFactory() {
  10399. _classCallCheck(this, DefaultTextLayerFactory);
  10400. }
  10401. _createClass(DefaultTextLayerFactory, [{
  10402. key: "createTextLayerBuilder",
  10403. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  10404. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  10405. return new TextLayerBuilder({
  10406. textLayerDiv: textLayerDiv,
  10407. pageIndex: pageIndex,
  10408. viewport: viewport,
  10409. enhanceTextSelection: enhanceTextSelection
  10410. });
  10411. }
  10412. }]);
  10413. return DefaultTextLayerFactory;
  10414. }();
  10415. exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
  10416. /***/ }),
  10417. /* 33 */
  10418. /***/ (function(module, exports, __webpack_require__) {
  10419. "use strict";
  10420. Object.defineProperty(exports, "__esModule", {
  10421. value: true
  10422. });
  10423. exports.SecondaryToolbar = void 0;
  10424. var _ui_utils = __webpack_require__(6);
  10425. var _pdf_cursor_tools = __webpack_require__(8);
  10426. var _pdf_single_page_viewer = __webpack_require__(34);
  10427. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10428. 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); } }
  10429. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10430. var SecondaryToolbar =
  10431. /*#__PURE__*/
  10432. function () {
  10433. function SecondaryToolbar(options, mainContainer, eventBus) {
  10434. var _this = this;
  10435. _classCallCheck(this, SecondaryToolbar);
  10436. this.toolbar = options.toolbar;
  10437. this.toggleButton = options.toggleButton;
  10438. this.toolbarButtonContainer = options.toolbarButtonContainer;
  10439. this.buttons = [{
  10440. element: options.presentationModeButton,
  10441. eventName: 'presentationmode',
  10442. close: true
  10443. }, {
  10444. element: options.openFileButton,
  10445. eventName: 'openfile',
  10446. close: true
  10447. }, {
  10448. element: options.printButton,
  10449. eventName: 'print',
  10450. close: true
  10451. }, {
  10452. element: options.downloadButton,
  10453. eventName: 'download',
  10454. close: true
  10455. }, {
  10456. element: options.viewBookmarkButton,
  10457. eventName: null,
  10458. close: true
  10459. }, {
  10460. element: options.firstPageButton,
  10461. eventName: 'firstpage',
  10462. close: true
  10463. }, {
  10464. element: options.lastPageButton,
  10465. eventName: 'lastpage',
  10466. close: true
  10467. }, {
  10468. element: options.pageRotateCwButton,
  10469. eventName: 'rotatecw',
  10470. close: false
  10471. }, {
  10472. element: options.pageRotateCcwButton,
  10473. eventName: 'rotateccw',
  10474. close: false
  10475. }, {
  10476. element: options.cursorSelectToolButton,
  10477. eventName: 'switchcursortool',
  10478. eventDetails: {
  10479. tool: _pdf_cursor_tools.CursorTool.SELECT
  10480. },
  10481. close: true
  10482. }, {
  10483. element: options.cursorHandToolButton,
  10484. eventName: 'switchcursortool',
  10485. eventDetails: {
  10486. tool: _pdf_cursor_tools.CursorTool.HAND
  10487. },
  10488. close: true
  10489. }, {
  10490. element: options.scrollVerticalButton,
  10491. eventName: 'switchscrollmode',
  10492. eventDetails: {
  10493. mode: _ui_utils.ScrollMode.VERTICAL
  10494. },
  10495. close: true
  10496. }, {
  10497. element: options.scrollHorizontalButton,
  10498. eventName: 'switchscrollmode',
  10499. eventDetails: {
  10500. mode: _ui_utils.ScrollMode.HORIZONTAL
  10501. },
  10502. close: true
  10503. }, {
  10504. element: options.scrollWrappedButton,
  10505. eventName: 'switchscrollmode',
  10506. eventDetails: {
  10507. mode: _ui_utils.ScrollMode.WRAPPED
  10508. },
  10509. close: true
  10510. }, {
  10511. element: options.spreadNoneButton,
  10512. eventName: 'switchspreadmode',
  10513. eventDetails: {
  10514. mode: _ui_utils.SpreadMode.NONE
  10515. },
  10516. close: true
  10517. }, {
  10518. element: options.spreadOddButton,
  10519. eventName: 'switchspreadmode',
  10520. eventDetails: {
  10521. mode: _ui_utils.SpreadMode.ODD
  10522. },
  10523. close: true
  10524. }, {
  10525. element: options.spreadEvenButton,
  10526. eventName: 'switchspreadmode',
  10527. eventDetails: {
  10528. mode: _ui_utils.SpreadMode.EVEN
  10529. },
  10530. close: true
  10531. }, {
  10532. element: options.documentPropertiesButton,
  10533. eventName: 'documentproperties',
  10534. close: true
  10535. }];
  10536. this.items = {
  10537. firstPage: options.firstPageButton,
  10538. lastPage: options.lastPageButton,
  10539. pageRotateCw: options.pageRotateCwButton,
  10540. pageRotateCcw: options.pageRotateCcwButton
  10541. };
  10542. this.mainContainer = mainContainer;
  10543. this.eventBus = eventBus;
  10544. this.opened = false;
  10545. this.containerHeight = null;
  10546. this.previousContainerHeight = null;
  10547. this.reset();
  10548. this._bindClickListeners();
  10549. this._bindCursorToolsListener(options);
  10550. this._bindScrollModeListener(options);
  10551. this._bindSpreadModeListener(options);
  10552. this.eventBus.on('resize', this._setMaxHeight.bind(this));
  10553. this.eventBus.on('baseviewerinit', function (evt) {
  10554. if (evt.source instanceof _pdf_single_page_viewer.PDFSinglePageViewer) {
  10555. _this.toolbarButtonContainer.classList.add('hiddenScrollModeButtons', 'hiddenSpreadModeButtons');
  10556. } else {
  10557. _this.toolbarButtonContainer.classList.remove('hiddenScrollModeButtons', 'hiddenSpreadModeButtons');
  10558. }
  10559. });
  10560. }
  10561. _createClass(SecondaryToolbar, [{
  10562. key: "setPageNumber",
  10563. value: function setPageNumber(pageNumber) {
  10564. this.pageNumber = pageNumber;
  10565. this._updateUIState();
  10566. }
  10567. }, {
  10568. key: "setPagesCount",
  10569. value: function setPagesCount(pagesCount) {
  10570. this.pagesCount = pagesCount;
  10571. this._updateUIState();
  10572. }
  10573. }, {
  10574. key: "reset",
  10575. value: function reset() {
  10576. this.pageNumber = 0;
  10577. this.pagesCount = 0;
  10578. this._updateUIState();
  10579. this.eventBus.dispatch('secondarytoolbarreset', {
  10580. source: this
  10581. });
  10582. }
  10583. }, {
  10584. key: "_updateUIState",
  10585. value: function _updateUIState() {
  10586. this.items.firstPage.disabled = this.pageNumber <= 1;
  10587. this.items.lastPage.disabled = this.pageNumber >= this.pagesCount;
  10588. this.items.pageRotateCw.disabled = this.pagesCount === 0;
  10589. this.items.pageRotateCcw.disabled = this.pagesCount === 0;
  10590. }
  10591. }, {
  10592. key: "_bindClickListeners",
  10593. value: function _bindClickListeners() {
  10594. var _this2 = this;
  10595. this.toggleButton.addEventListener('click', this.toggle.bind(this));
  10596. var _loop = function _loop(button) {
  10597. var _this2$buttons$button = _this2.buttons[button],
  10598. element = _this2$buttons$button.element,
  10599. eventName = _this2$buttons$button.eventName,
  10600. close = _this2$buttons$button.close,
  10601. eventDetails = _this2$buttons$button.eventDetails;
  10602. element.addEventListener('click', function (evt) {
  10603. if (eventName !== null) {
  10604. var details = {
  10605. source: _this2
  10606. };
  10607. for (var property in eventDetails) {
  10608. details[property] = eventDetails[property];
  10609. }
  10610. _this2.eventBus.dispatch(eventName, details);
  10611. }
  10612. if (close) {
  10613. _this2.close();
  10614. }
  10615. });
  10616. };
  10617. for (var button in this.buttons) {
  10618. _loop(button);
  10619. }
  10620. }
  10621. }, {
  10622. key: "_bindCursorToolsListener",
  10623. value: function _bindCursorToolsListener(buttons) {
  10624. this.eventBus.on('cursortoolchanged', function (_ref) {
  10625. var tool = _ref.tool;
  10626. buttons.cursorSelectToolButton.classList.toggle('toggled', tool === _pdf_cursor_tools.CursorTool.SELECT);
  10627. buttons.cursorHandToolButton.classList.toggle('toggled', tool === _pdf_cursor_tools.CursorTool.HAND);
  10628. });
  10629. }
  10630. }, {
  10631. key: "_bindScrollModeListener",
  10632. value: function _bindScrollModeListener(buttons) {
  10633. var _this3 = this;
  10634. function scrollModeChanged(_ref2) {
  10635. var mode = _ref2.mode;
  10636. buttons.scrollVerticalButton.classList.toggle('toggled', mode === _ui_utils.ScrollMode.VERTICAL);
  10637. buttons.scrollHorizontalButton.classList.toggle('toggled', mode === _ui_utils.ScrollMode.HORIZONTAL);
  10638. buttons.scrollWrappedButton.classList.toggle('toggled', mode === _ui_utils.ScrollMode.WRAPPED);
  10639. var isScrollModeHorizontal = mode === _ui_utils.ScrollMode.HORIZONTAL;
  10640. buttons.spreadNoneButton.disabled = isScrollModeHorizontal;
  10641. buttons.spreadOddButton.disabled = isScrollModeHorizontal;
  10642. buttons.spreadEvenButton.disabled = isScrollModeHorizontal;
  10643. }
  10644. this.eventBus.on('scrollmodechanged', scrollModeChanged);
  10645. this.eventBus.on('secondarytoolbarreset', function (evt) {
  10646. if (evt.source === _this3) {
  10647. scrollModeChanged({
  10648. mode: _ui_utils.ScrollMode.VERTICAL
  10649. });
  10650. }
  10651. });
  10652. }
  10653. }, {
  10654. key: "_bindSpreadModeListener",
  10655. value: function _bindSpreadModeListener(buttons) {
  10656. var _this4 = this;
  10657. function spreadModeChanged(_ref3) {
  10658. var mode = _ref3.mode;
  10659. buttons.spreadNoneButton.classList.toggle('toggled', mode === _ui_utils.SpreadMode.NONE);
  10660. buttons.spreadOddButton.classList.toggle('toggled', mode === _ui_utils.SpreadMode.ODD);
  10661. buttons.spreadEvenButton.classList.toggle('toggled', mode === _ui_utils.SpreadMode.EVEN);
  10662. }
  10663. this.eventBus.on('spreadmodechanged', spreadModeChanged);
  10664. this.eventBus.on('secondarytoolbarreset', function (evt) {
  10665. if (evt.source === _this4) {
  10666. spreadModeChanged({
  10667. mode: _ui_utils.SpreadMode.NONE
  10668. });
  10669. }
  10670. });
  10671. }
  10672. }, {
  10673. key: "open",
  10674. value: function open() {
  10675. if (this.opened) {
  10676. return;
  10677. }
  10678. this.opened = true;
  10679. this._setMaxHeight();
  10680. this.toggleButton.classList.add('toggled');
  10681. this.toolbar.classList.remove('hidden');
  10682. }
  10683. }, {
  10684. key: "close",
  10685. value: function close() {
  10686. if (!this.opened) {
  10687. return;
  10688. }
  10689. this.opened = false;
  10690. this.toolbar.classList.add('hidden');
  10691. this.toggleButton.classList.remove('toggled');
  10692. }
  10693. }, {
  10694. key: "toggle",
  10695. value: function toggle() {
  10696. if (this.opened) {
  10697. this.close();
  10698. } else {
  10699. this.open();
  10700. }
  10701. }
  10702. }, {
  10703. key: "_setMaxHeight",
  10704. value: function _setMaxHeight() {
  10705. if (!this.opened) {
  10706. return;
  10707. }
  10708. this.containerHeight = this.mainContainer.clientHeight;
  10709. if (this.containerHeight === this.previousContainerHeight) {
  10710. return;
  10711. }
  10712. this.toolbarButtonContainer.setAttribute('style', 'max-height: ' + (this.containerHeight - _ui_utils.SCROLLBAR_PADDING) + 'px;');
  10713. this.previousContainerHeight = this.containerHeight;
  10714. }
  10715. }, {
  10716. key: "isOpen",
  10717. get: function get() {
  10718. return this.opened;
  10719. }
  10720. }]);
  10721. return SecondaryToolbar;
  10722. }();
  10723. exports.SecondaryToolbar = SecondaryToolbar;
  10724. /***/ }),
  10725. /* 34 */
  10726. /***/ (function(module, exports, __webpack_require__) {
  10727. "use strict";
  10728. Object.defineProperty(exports, "__esModule", {
  10729. value: true
  10730. });
  10731. exports.PDFSinglePageViewer = void 0;
  10732. var _base_viewer = __webpack_require__(29);
  10733. var _pdfjsLib = __webpack_require__(7);
  10734. function _typeof(obj) { 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); }
  10735. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10736. 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); } }
  10737. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10738. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  10739. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  10740. 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); }
  10741. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  10742. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  10743. 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); }
  10744. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  10745. var PDFSinglePageViewer =
  10746. /*#__PURE__*/
  10747. function (_BaseViewer) {
  10748. _inherits(PDFSinglePageViewer, _BaseViewer);
  10749. function PDFSinglePageViewer(options) {
  10750. var _this;
  10751. _classCallCheck(this, PDFSinglePageViewer);
  10752. _this = _possibleConstructorReturn(this, _getPrototypeOf(PDFSinglePageViewer).call(this, options));
  10753. _this.eventBus.on('pagesinit', function (evt) {
  10754. _this._ensurePageViewVisible();
  10755. });
  10756. return _this;
  10757. }
  10758. _createClass(PDFSinglePageViewer, [{
  10759. key: "_resetView",
  10760. value: function _resetView() {
  10761. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_resetView", this).call(this);
  10762. this._previousPageNumber = 1;
  10763. this._shadowViewer = document.createDocumentFragment();
  10764. this._updateScrollDown = null;
  10765. }
  10766. }, {
  10767. key: "_ensurePageViewVisible",
  10768. value: function _ensurePageViewVisible() {
  10769. var pageView = this._pages[this._currentPageNumber - 1];
  10770. var previousPageView = this._pages[this._previousPageNumber - 1];
  10771. var viewerNodes = this.viewer.childNodes;
  10772. switch (viewerNodes.length) {
  10773. case 0:
  10774. this.viewer.appendChild(pageView.div);
  10775. break;
  10776. case 1:
  10777. if (viewerNodes[0] !== previousPageView.div) {
  10778. throw new Error('_ensurePageViewVisible: Unexpected previously visible page.');
  10779. }
  10780. if (pageView === previousPageView) {
  10781. break;
  10782. }
  10783. this._shadowViewer.appendChild(previousPageView.div);
  10784. this.viewer.appendChild(pageView.div);
  10785. this.container.scrollTop = 0;
  10786. break;
  10787. default:
  10788. throw new Error('_ensurePageViewVisible: Only one page should be visible at a time.');
  10789. }
  10790. this._previousPageNumber = this._currentPageNumber;
  10791. }
  10792. }, {
  10793. key: "_scrollUpdate",
  10794. value: function _scrollUpdate() {
  10795. if (this._updateScrollDown) {
  10796. this._updateScrollDown();
  10797. }
  10798. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollUpdate", this).call(this);
  10799. }
  10800. }, {
  10801. key: "_scrollIntoView",
  10802. value: function _scrollIntoView(_ref) {
  10803. var _this2 = this;
  10804. var pageDiv = _ref.pageDiv,
  10805. _ref$pageSpot = _ref.pageSpot,
  10806. pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
  10807. _ref$pageNumber = _ref.pageNumber,
  10808. pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
  10809. if (pageNumber) {
  10810. this._setCurrentPageNumber(pageNumber);
  10811. }
  10812. var scrolledDown = this._currentPageNumber >= this._previousPageNumber;
  10813. this._ensurePageViewVisible();
  10814. this.update();
  10815. _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollIntoView", this).call(this, {
  10816. pageDiv: pageDiv,
  10817. pageSpot: pageSpot,
  10818. pageNumber: pageNumber
  10819. });
  10820. this._updateScrollDown = function () {
  10821. _this2.scroll.down = scrolledDown;
  10822. _this2._updateScrollDown = null;
  10823. };
  10824. }
  10825. }, {
  10826. key: "_getVisiblePages",
  10827. value: function _getVisiblePages() {
  10828. return this._getCurrentVisiblePage();
  10829. }
  10830. }, {
  10831. key: "_updateHelper",
  10832. value: function _updateHelper(visiblePages) {}
  10833. }, {
  10834. key: "_updateScrollMode",
  10835. value: function _updateScrollMode() {}
  10836. }, {
  10837. key: "_updateSpreadMode",
  10838. value: function _updateSpreadMode() {}
  10839. }, {
  10840. key: "_setDocumentViewerElement",
  10841. get: function get() {
  10842. return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this._shadowViewer);
  10843. }
  10844. }, {
  10845. key: "_isScrollModeHorizontal",
  10846. get: function get() {
  10847. return (0, _pdfjsLib.shadow)(this, '_isScrollModeHorizontal', false);
  10848. }
  10849. }]);
  10850. return PDFSinglePageViewer;
  10851. }(_base_viewer.BaseViewer);
  10852. exports.PDFSinglePageViewer = PDFSinglePageViewer;
  10853. /***/ }),
  10854. /* 35 */
  10855. /***/ (function(module, exports, __webpack_require__) {
  10856. "use strict";
  10857. Object.defineProperty(exports, "__esModule", {
  10858. value: true
  10859. });
  10860. exports.Toolbar = void 0;
  10861. var _ui_utils = __webpack_require__(6);
  10862. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10863. 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); } }
  10864. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10865. var PAGE_NUMBER_LOADING_INDICATOR = 'visiblePageIsLoading';
  10866. var SCALE_SELECT_CONTAINER_PADDING = 8;
  10867. var SCALE_SELECT_PADDING = 22;
  10868. var Toolbar =
  10869. /*#__PURE__*/
  10870. function () {
  10871. function Toolbar(options, eventBus) {
  10872. var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
  10873. _classCallCheck(this, Toolbar);
  10874. this.toolbar = options.container;
  10875. this.eventBus = eventBus;
  10876. this.l10n = l10n;
  10877. this.items = options;
  10878. this._wasLocalized = false;
  10879. this.reset();
  10880. this._bindListeners();
  10881. }
  10882. _createClass(Toolbar, [{
  10883. key: "setPageNumber",
  10884. value: function setPageNumber(pageNumber, pageLabel) {
  10885. this.pageNumber = pageNumber;
  10886. this.pageLabel = pageLabel;
  10887. this._updateUIState(false);
  10888. }
  10889. }, {
  10890. key: "setPagesCount",
  10891. value: function setPagesCount(pagesCount, hasPageLabels) {
  10892. this.pagesCount = pagesCount;
  10893. this.hasPageLabels = hasPageLabels;
  10894. this._updateUIState(true);
  10895. }
  10896. }, {
  10897. key: "setPageScale",
  10898. value: function setPageScale(pageScaleValue, pageScale) {
  10899. this.pageScaleValue = (pageScaleValue || pageScale).toString();
  10900. this.pageScale = pageScale;
  10901. this._updateUIState(false);
  10902. }
  10903. }, {
  10904. key: "reset",
  10905. value: function reset() {
  10906. this.pageNumber = 0;
  10907. this.pageLabel = null;
  10908. this.hasPageLabels = false;
  10909. this.pagesCount = 0;
  10910. this.pageScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  10911. this.pageScale = _ui_utils.DEFAULT_SCALE;
  10912. this._updateUIState(true);
  10913. }
  10914. }, {
  10915. key: "_bindListeners",
  10916. value: function _bindListeners() {
  10917. var _this = this;
  10918. var eventBus = this.eventBus,
  10919. items = this.items;
  10920. var self = this;
  10921. items.previous.addEventListener('click', function () {
  10922. eventBus.dispatch('previouspage', {
  10923. source: self
  10924. });
  10925. });
  10926. items.next.addEventListener('click', function () {
  10927. eventBus.dispatch('nextpage', {
  10928. source: self
  10929. });
  10930. });
  10931. items.zoomIn.addEventListener('click', function () {
  10932. eventBus.dispatch('zoomin', {
  10933. source: self
  10934. });
  10935. });
  10936. items.zoomOut.addEventListener('click', function () {
  10937. eventBus.dispatch('zoomout', {
  10938. source: self
  10939. });
  10940. });
  10941. items.pageNumber.addEventListener('click', function () {
  10942. this.select();
  10943. });
  10944. items.pageNumber.addEventListener('change', function () {
  10945. eventBus.dispatch('pagenumberchanged', {
  10946. source: self,
  10947. value: this.value
  10948. });
  10949. });
  10950. items.scaleSelect.addEventListener('change', function () {
  10951. if (this.value === 'custom') {
  10952. return;
  10953. }
  10954. eventBus.dispatch('scalechanged', {
  10955. source: self,
  10956. value: this.value
  10957. });
  10958. });
  10959. items.presentationModeButton.addEventListener('click', function () {
  10960. eventBus.dispatch('presentationmode', {
  10961. source: self
  10962. });
  10963. });
  10964. items.openFile.addEventListener('click', function () {
  10965. eventBus.dispatch('openfile', {
  10966. source: self
  10967. });
  10968. });
  10969. items.print.addEventListener('click', function () {
  10970. eventBus.dispatch('print', {
  10971. source: self
  10972. });
  10973. });
  10974. items.download.addEventListener('click', function () {
  10975. eventBus.dispatch('download', {
  10976. source: self
  10977. });
  10978. });
  10979. items.scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler;
  10980. eventBus.on('localized', function () {
  10981. _this._localized();
  10982. });
  10983. }
  10984. }, {
  10985. key: "_localized",
  10986. value: function _localized() {
  10987. this._wasLocalized = true;
  10988. this._adjustScaleWidth();
  10989. this._updateUIState(true);
  10990. }
  10991. }, {
  10992. key: "_updateUIState",
  10993. value: function _updateUIState() {
  10994. var resetNumPages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  10995. if (!this._wasLocalized) {
  10996. return;
  10997. }
  10998. var pageNumber = this.pageNumber,
  10999. pagesCount = this.pagesCount,
  11000. pageScaleValue = this.pageScaleValue,
  11001. pageScale = this.pageScale,
  11002. items = this.items;
  11003. if (resetNumPages) {
  11004. if (this.hasPageLabels) {
  11005. items.pageNumber.type = 'text';
  11006. } else {
  11007. items.pageNumber.type = 'number';
  11008. this.l10n.get('of_pages', {
  11009. pagesCount: pagesCount
  11010. }, 'of {{pagesCount}}').then(function (msg) {
  11011. items.numPages.textContent = msg;
  11012. });
  11013. }
  11014. items.pageNumber.max = pagesCount;
  11015. }
  11016. if (this.hasPageLabels) {
  11017. items.pageNumber.value = this.pageLabel;
  11018. this.l10n.get('page_of_pages', {
  11019. pageNumber: pageNumber,
  11020. pagesCount: pagesCount
  11021. }, '({{pageNumber}} of {{pagesCount}})').then(function (msg) {
  11022. items.numPages.textContent = msg;
  11023. });
  11024. } else {
  11025. items.pageNumber.value = pageNumber;
  11026. }
  11027. items.previous.disabled = pageNumber <= 1;
  11028. items.next.disabled = pageNumber >= pagesCount;
  11029. items.zoomOut.disabled = pageScale <= _ui_utils.MIN_SCALE;
  11030. items.zoomIn.disabled = pageScale >= _ui_utils.MAX_SCALE;
  11031. var customScale = Math.round(pageScale * 10000) / 100;
  11032. this.l10n.get('page_scale_percent', {
  11033. scale: customScale
  11034. }, '{{scale}}%').then(function (msg) {
  11035. var options = items.scaleSelect.options;
  11036. var predefinedValueFound = false;
  11037. for (var i = 0, ii = options.length; i < ii; i++) {
  11038. var option = options[i];
  11039. if (option.value !== pageScaleValue) {
  11040. option.selected = false;
  11041. continue;
  11042. }
  11043. option.selected = true;
  11044. predefinedValueFound = true;
  11045. }
  11046. if (!predefinedValueFound) {
  11047. items.customScaleOption.textContent = msg;
  11048. items.customScaleOption.selected = true;
  11049. }
  11050. });
  11051. }
  11052. }, {
  11053. key: "updateLoadingIndicatorState",
  11054. value: function updateLoadingIndicatorState() {
  11055. var loading = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  11056. var pageNumberInput = this.items.pageNumber;
  11057. pageNumberInput.classList.toggle(PAGE_NUMBER_LOADING_INDICATOR, loading);
  11058. }
  11059. }, {
  11060. key: "_adjustScaleWidth",
  11061. value: function _adjustScaleWidth() {
  11062. var container = this.items.scaleSelectContainer;
  11063. var select = this.items.scaleSelect;
  11064. _ui_utils.animationStarted.then(function () {
  11065. if (container.clientWidth === 0) {
  11066. container.setAttribute('style', 'display: inherit;');
  11067. }
  11068. if (container.clientWidth > 0) {
  11069. select.setAttribute('style', 'min-width: inherit;');
  11070. var width = select.clientWidth + SCALE_SELECT_CONTAINER_PADDING;
  11071. select.setAttribute('style', 'min-width: ' + (width + SCALE_SELECT_PADDING) + 'px;');
  11072. container.setAttribute('style', 'min-width: ' + width + 'px; ' + 'max-width: ' + width + 'px;');
  11073. }
  11074. });
  11075. }
  11076. }]);
  11077. return Toolbar;
  11078. }();
  11079. exports.Toolbar = Toolbar;
  11080. /***/ }),
  11081. /* 36 */
  11082. /***/ (function(module, exports, __webpack_require__) {
  11083. "use strict";
  11084. Object.defineProperty(exports, "__esModule", {
  11085. value: true
  11086. });
  11087. exports.ViewHistory = void 0;
  11088. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  11089. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11090. 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); } }
  11091. 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); }); }; }
  11092. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11093. 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); } }
  11094. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11095. var DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
  11096. var ViewHistory =
  11097. /*#__PURE__*/
  11098. function () {
  11099. function ViewHistory(fingerprint) {
  11100. var _this = this;
  11101. var cacheSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_VIEW_HISTORY_CACHE_SIZE;
  11102. _classCallCheck(this, ViewHistory);
  11103. this.fingerprint = fingerprint;
  11104. this.cacheSize = cacheSize;
  11105. this._initializedPromise = this._readFromStorage().then(function (databaseStr) {
  11106. var database = JSON.parse(databaseStr || '{}');
  11107. if (!('files' in database)) {
  11108. database.files = [];
  11109. } else {
  11110. while (database.files.length >= _this.cacheSize) {
  11111. database.files.shift();
  11112. }
  11113. }
  11114. var index = -1;
  11115. for (var i = 0, length = database.files.length; i < length; i++) {
  11116. var branch = database.files[i];
  11117. if (branch.fingerprint === _this.fingerprint) {
  11118. index = i;
  11119. break;
  11120. }
  11121. }
  11122. if (index === -1) {
  11123. index = database.files.push({
  11124. fingerprint: _this.fingerprint
  11125. }) - 1;
  11126. }
  11127. _this.file = database.files[index];
  11128. _this.database = database;
  11129. });
  11130. }
  11131. _createClass(ViewHistory, [{
  11132. key: "_writeToStorage",
  11133. value: function () {
  11134. var _writeToStorage2 = _asyncToGenerator(
  11135. /*#__PURE__*/
  11136. _regenerator.default.mark(function _callee() {
  11137. var databaseStr;
  11138. return _regenerator.default.wrap(function _callee$(_context) {
  11139. while (1) {
  11140. switch (_context.prev = _context.next) {
  11141. case 0:
  11142. databaseStr = JSON.stringify(this.database);
  11143. localStorage.setItem('pdfjs.history', databaseStr);
  11144. case 2:
  11145. case "end":
  11146. return _context.stop();
  11147. }
  11148. }
  11149. }, _callee, this);
  11150. }));
  11151. function _writeToStorage() {
  11152. return _writeToStorage2.apply(this, arguments);
  11153. }
  11154. return _writeToStorage;
  11155. }()
  11156. }, {
  11157. key: "_readFromStorage",
  11158. value: function () {
  11159. var _readFromStorage2 = _asyncToGenerator(
  11160. /*#__PURE__*/
  11161. _regenerator.default.mark(function _callee2() {
  11162. return _regenerator.default.wrap(function _callee2$(_context2) {
  11163. while (1) {
  11164. switch (_context2.prev = _context2.next) {
  11165. case 0:
  11166. return _context2.abrupt("return", localStorage.getItem('pdfjs.history'));
  11167. case 1:
  11168. case "end":
  11169. return _context2.stop();
  11170. }
  11171. }
  11172. }, _callee2, this);
  11173. }));
  11174. function _readFromStorage() {
  11175. return _readFromStorage2.apply(this, arguments);
  11176. }
  11177. return _readFromStorage;
  11178. }()
  11179. }, {
  11180. key: "set",
  11181. value: function () {
  11182. var _set = _asyncToGenerator(
  11183. /*#__PURE__*/
  11184. _regenerator.default.mark(function _callee3(name, val) {
  11185. return _regenerator.default.wrap(function _callee3$(_context3) {
  11186. while (1) {
  11187. switch (_context3.prev = _context3.next) {
  11188. case 0:
  11189. _context3.next = 2;
  11190. return this._initializedPromise;
  11191. case 2:
  11192. this.file[name] = val;
  11193. return _context3.abrupt("return", this._writeToStorage());
  11194. case 4:
  11195. case "end":
  11196. return _context3.stop();
  11197. }
  11198. }
  11199. }, _callee3, this);
  11200. }));
  11201. function set(_x, _x2) {
  11202. return _set.apply(this, arguments);
  11203. }
  11204. return set;
  11205. }()
  11206. }, {
  11207. key: "setMultiple",
  11208. value: function () {
  11209. var _setMultiple = _asyncToGenerator(
  11210. /*#__PURE__*/
  11211. _regenerator.default.mark(function _callee4(properties) {
  11212. var name;
  11213. return _regenerator.default.wrap(function _callee4$(_context4) {
  11214. while (1) {
  11215. switch (_context4.prev = _context4.next) {
  11216. case 0:
  11217. _context4.next = 2;
  11218. return this._initializedPromise;
  11219. case 2:
  11220. for (name in properties) {
  11221. this.file[name] = properties[name];
  11222. }
  11223. return _context4.abrupt("return", this._writeToStorage());
  11224. case 4:
  11225. case "end":
  11226. return _context4.stop();
  11227. }
  11228. }
  11229. }, _callee4, this);
  11230. }));
  11231. function setMultiple(_x3) {
  11232. return _setMultiple.apply(this, arguments);
  11233. }
  11234. return setMultiple;
  11235. }()
  11236. }, {
  11237. key: "get",
  11238. value: function () {
  11239. var _get = _asyncToGenerator(
  11240. /*#__PURE__*/
  11241. _regenerator.default.mark(function _callee5(name, defaultValue) {
  11242. var val;
  11243. return _regenerator.default.wrap(function _callee5$(_context5) {
  11244. while (1) {
  11245. switch (_context5.prev = _context5.next) {
  11246. case 0:
  11247. _context5.next = 2;
  11248. return this._initializedPromise;
  11249. case 2:
  11250. val = this.file[name];
  11251. return _context5.abrupt("return", val !== undefined ? val : defaultValue);
  11252. case 4:
  11253. case "end":
  11254. return _context5.stop();
  11255. }
  11256. }
  11257. }, _callee5, this);
  11258. }));
  11259. function get(_x4, _x5) {
  11260. return _get.apply(this, arguments);
  11261. }
  11262. return get;
  11263. }()
  11264. }, {
  11265. key: "getMultiple",
  11266. value: function () {
  11267. var _getMultiple = _asyncToGenerator(
  11268. /*#__PURE__*/
  11269. _regenerator.default.mark(function _callee6(properties) {
  11270. var values, name, val;
  11271. return _regenerator.default.wrap(function _callee6$(_context6) {
  11272. while (1) {
  11273. switch (_context6.prev = _context6.next) {
  11274. case 0:
  11275. _context6.next = 2;
  11276. return this._initializedPromise;
  11277. case 2:
  11278. values = Object.create(null);
  11279. for (name in properties) {
  11280. val = this.file[name];
  11281. values[name] = val !== undefined ? val : properties[name];
  11282. }
  11283. return _context6.abrupt("return", values);
  11284. case 5:
  11285. case "end":
  11286. return _context6.stop();
  11287. }
  11288. }
  11289. }, _callee6, this);
  11290. }));
  11291. function getMultiple(_x6) {
  11292. return _getMultiple.apply(this, arguments);
  11293. }
  11294. return getMultiple;
  11295. }()
  11296. }]);
  11297. return ViewHistory;
  11298. }();
  11299. exports.ViewHistory = ViewHistory;
  11300. /***/ }),
  11301. /* 37 */
  11302. /***/ (function(module, exports, __webpack_require__) {
  11303. "use strict";
  11304. Object.defineProperty(exports, "__esModule", {
  11305. value: true
  11306. });
  11307. exports.GenericCom = void 0;
  11308. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  11309. var _app = __webpack_require__(1);
  11310. var _preferences = __webpack_require__(38);
  11311. var _download_manager = __webpack_require__(39);
  11312. var _genericl10n = __webpack_require__(40);
  11313. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11314. function _typeof(obj) { 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); }
  11315. 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); } }
  11316. 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); }); }; }
  11317. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11318. 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); } }
  11319. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11320. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  11321. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  11322. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  11323. 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); }
  11324. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  11325. ;
  11326. var GenericCom = {};
  11327. exports.GenericCom = GenericCom;
  11328. var GenericPreferences =
  11329. /*#__PURE__*/
  11330. function (_BasePreferences) {
  11331. _inherits(GenericPreferences, _BasePreferences);
  11332. function GenericPreferences() {
  11333. _classCallCheck(this, GenericPreferences);
  11334. return _possibleConstructorReturn(this, _getPrototypeOf(GenericPreferences).apply(this, arguments));
  11335. }
  11336. _createClass(GenericPreferences, [{
  11337. key: "_writeToStorage",
  11338. value: function () {
  11339. var _writeToStorage2 = _asyncToGenerator(
  11340. /*#__PURE__*/
  11341. _regenerator.default.mark(function _callee(prefObj) {
  11342. return _regenerator.default.wrap(function _callee$(_context) {
  11343. while (1) {
  11344. switch (_context.prev = _context.next) {
  11345. case 0:
  11346. localStorage.setItem('pdfjs.preferences', JSON.stringify(prefObj));
  11347. case 1:
  11348. case "end":
  11349. return _context.stop();
  11350. }
  11351. }
  11352. }, _callee, this);
  11353. }));
  11354. function _writeToStorage(_x) {
  11355. return _writeToStorage2.apply(this, arguments);
  11356. }
  11357. return _writeToStorage;
  11358. }()
  11359. }, {
  11360. key: "_readFromStorage",
  11361. value: function () {
  11362. var _readFromStorage2 = _asyncToGenerator(
  11363. /*#__PURE__*/
  11364. _regenerator.default.mark(function _callee2(prefObj) {
  11365. return _regenerator.default.wrap(function _callee2$(_context2) {
  11366. while (1) {
  11367. switch (_context2.prev = _context2.next) {
  11368. case 0:
  11369. return _context2.abrupt("return", JSON.parse(localStorage.getItem('pdfjs.preferences')));
  11370. case 1:
  11371. case "end":
  11372. return _context2.stop();
  11373. }
  11374. }
  11375. }, _callee2, this);
  11376. }));
  11377. function _readFromStorage(_x2) {
  11378. return _readFromStorage2.apply(this, arguments);
  11379. }
  11380. return _readFromStorage;
  11381. }()
  11382. }]);
  11383. return GenericPreferences;
  11384. }(_preferences.BasePreferences);
  11385. var GenericExternalServices = Object.create(_app.DefaultExternalServices);
  11386. GenericExternalServices.createDownloadManager = function (options) {
  11387. return new _download_manager.DownloadManager(options);
  11388. };
  11389. GenericExternalServices.createPreferences = function () {
  11390. return new GenericPreferences();
  11391. };
  11392. GenericExternalServices.createL10n = function (_ref) {
  11393. var _ref$locale = _ref.locale,
  11394. locale = _ref$locale === void 0 ? 'en-US' : _ref$locale;
  11395. return new _genericl10n.GenericL10n(locale);
  11396. };
  11397. _app.PDFViewerApplication.externalServices = GenericExternalServices;
  11398. /***/ }),
  11399. /* 38 */
  11400. /***/ (function(module, exports, __webpack_require__) {
  11401. "use strict";
  11402. Object.defineProperty(exports, "__esModule", {
  11403. value: true
  11404. });
  11405. exports.BasePreferences = void 0;
  11406. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  11407. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11408. 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); } }
  11409. 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); }); }; }
  11410. function _typeof(obj) { 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); }
  11411. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11412. 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); } }
  11413. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11414. var defaultPreferences = null;
  11415. function getDefaultPreferences() {
  11416. if (!defaultPreferences) {
  11417. defaultPreferences = Promise.resolve({
  11418. "viewOnLoad": 0,
  11419. "defaultZoomValue": "",
  11420. "sidebarViewOnLoad": -1,
  11421. "cursorToolOnLoad": 0,
  11422. "enableWebGL": false,
  11423. "eventBusDispatchToDOM": false,
  11424. "pdfBugEnabled": false,
  11425. "disableRange": false,
  11426. "disableStream": false,
  11427. "disableAutoFetch": false,
  11428. "disableFontFace": false,
  11429. "textLayerMode": 1,
  11430. "useOnlyCssZoom": false,
  11431. "externalLinkTarget": 0,
  11432. "renderer": "canvas",
  11433. "renderInteractiveForms": false,
  11434. "enablePrintAutoRotate": false,
  11435. "disablePageLabels": false,
  11436. "historyUpdateUrl": false,
  11437. "scrollModeOnLoad": -1,
  11438. "spreadModeOnLoad": -1
  11439. });
  11440. }
  11441. return defaultPreferences;
  11442. }
  11443. var BasePreferences =
  11444. /*#__PURE__*/
  11445. function () {
  11446. function BasePreferences() {
  11447. var _this = this;
  11448. _classCallCheck(this, BasePreferences);
  11449. if (this.constructor === BasePreferences) {
  11450. throw new Error('Cannot initialize BasePreferences.');
  11451. }
  11452. this.prefs = null;
  11453. this._initializedPromise = getDefaultPreferences().then(function (defaults) {
  11454. Object.defineProperty(_this, 'defaults', {
  11455. value: Object.freeze(defaults),
  11456. writable: false,
  11457. enumerable: true,
  11458. configurable: false
  11459. });
  11460. _this.prefs = Object.assign(Object.create(null), defaults);
  11461. return _this._readFromStorage(defaults);
  11462. }).then(function (prefs) {
  11463. if (!prefs) {
  11464. return;
  11465. }
  11466. for (var name in prefs) {
  11467. var defaultValue = _this.defaults[name],
  11468. prefValue = prefs[name];
  11469. if (defaultValue === undefined || _typeof(prefValue) !== _typeof(defaultValue)) {
  11470. continue;
  11471. }
  11472. _this.prefs[name] = prefValue;
  11473. }
  11474. });
  11475. }
  11476. _createClass(BasePreferences, [{
  11477. key: "_writeToStorage",
  11478. value: function () {
  11479. var _writeToStorage2 = _asyncToGenerator(
  11480. /*#__PURE__*/
  11481. _regenerator.default.mark(function _callee(prefObj) {
  11482. return _regenerator.default.wrap(function _callee$(_context) {
  11483. while (1) {
  11484. switch (_context.prev = _context.next) {
  11485. case 0:
  11486. throw new Error('Not implemented: _writeToStorage');
  11487. case 1:
  11488. case "end":
  11489. return _context.stop();
  11490. }
  11491. }
  11492. }, _callee, this);
  11493. }));
  11494. function _writeToStorage(_x) {
  11495. return _writeToStorage2.apply(this, arguments);
  11496. }
  11497. return _writeToStorage;
  11498. }()
  11499. }, {
  11500. key: "_readFromStorage",
  11501. value: function () {
  11502. var _readFromStorage2 = _asyncToGenerator(
  11503. /*#__PURE__*/
  11504. _regenerator.default.mark(function _callee2(prefObj) {
  11505. return _regenerator.default.wrap(function _callee2$(_context2) {
  11506. while (1) {
  11507. switch (_context2.prev = _context2.next) {
  11508. case 0:
  11509. throw new Error('Not implemented: _readFromStorage');
  11510. case 1:
  11511. case "end":
  11512. return _context2.stop();
  11513. }
  11514. }
  11515. }, _callee2, this);
  11516. }));
  11517. function _readFromStorage(_x2) {
  11518. return _readFromStorage2.apply(this, arguments);
  11519. }
  11520. return _readFromStorage;
  11521. }()
  11522. }, {
  11523. key: "reset",
  11524. value: function () {
  11525. var _reset = _asyncToGenerator(
  11526. /*#__PURE__*/
  11527. _regenerator.default.mark(function _callee3() {
  11528. return _regenerator.default.wrap(function _callee3$(_context3) {
  11529. while (1) {
  11530. switch (_context3.prev = _context3.next) {
  11531. case 0:
  11532. _context3.next = 2;
  11533. return this._initializedPromise;
  11534. case 2:
  11535. this.prefs = Object.assign(Object.create(null), this.defaults);
  11536. return _context3.abrupt("return", this._writeToStorage(this.defaults));
  11537. case 4:
  11538. case "end":
  11539. return _context3.stop();
  11540. }
  11541. }
  11542. }, _callee3, this);
  11543. }));
  11544. function reset() {
  11545. return _reset.apply(this, arguments);
  11546. }
  11547. return reset;
  11548. }()
  11549. }, {
  11550. key: "set",
  11551. value: function () {
  11552. var _set = _asyncToGenerator(
  11553. /*#__PURE__*/
  11554. _regenerator.default.mark(function _callee4(name, value) {
  11555. var defaultValue, valueType, defaultType;
  11556. return _regenerator.default.wrap(function _callee4$(_context4) {
  11557. while (1) {
  11558. switch (_context4.prev = _context4.next) {
  11559. case 0:
  11560. _context4.next = 2;
  11561. return this._initializedPromise;
  11562. case 2:
  11563. defaultValue = this.defaults[name];
  11564. if (!(defaultValue === undefined)) {
  11565. _context4.next = 7;
  11566. break;
  11567. }
  11568. throw new Error("Set preference: \"".concat(name, "\" is undefined."));
  11569. case 7:
  11570. if (!(value === undefined)) {
  11571. _context4.next = 9;
  11572. break;
  11573. }
  11574. throw new Error('Set preference: no value is specified.');
  11575. case 9:
  11576. valueType = _typeof(value);
  11577. defaultType = _typeof(defaultValue);
  11578. if (!(valueType !== defaultType)) {
  11579. _context4.next = 19;
  11580. break;
  11581. }
  11582. if (!(valueType === 'number' && defaultType === 'string')) {
  11583. _context4.next = 16;
  11584. break;
  11585. }
  11586. value = value.toString();
  11587. _context4.next = 17;
  11588. break;
  11589. case 16:
  11590. throw new Error("Set preference: \"".concat(value, "\" is a ").concat(valueType, ", ") + "expected a ".concat(defaultType, "."));
  11591. case 17:
  11592. _context4.next = 21;
  11593. break;
  11594. case 19:
  11595. if (!(valueType === 'number' && !Number.isInteger(value))) {
  11596. _context4.next = 21;
  11597. break;
  11598. }
  11599. throw new Error("Set preference: \"".concat(value, "\" must be an integer."));
  11600. case 21:
  11601. this.prefs[name] = value;
  11602. return _context4.abrupt("return", this._writeToStorage(this.prefs));
  11603. case 23:
  11604. case "end":
  11605. return _context4.stop();
  11606. }
  11607. }
  11608. }, _callee4, this);
  11609. }));
  11610. function set(_x3, _x4) {
  11611. return _set.apply(this, arguments);
  11612. }
  11613. return set;
  11614. }()
  11615. }, {
  11616. key: "get",
  11617. value: function () {
  11618. var _get = _asyncToGenerator(
  11619. /*#__PURE__*/
  11620. _regenerator.default.mark(function _callee5(name) {
  11621. var defaultValue, prefValue;
  11622. return _regenerator.default.wrap(function _callee5$(_context5) {
  11623. while (1) {
  11624. switch (_context5.prev = _context5.next) {
  11625. case 0:
  11626. _context5.next = 2;
  11627. return this._initializedPromise;
  11628. case 2:
  11629. defaultValue = this.defaults[name];
  11630. if (!(defaultValue === undefined)) {
  11631. _context5.next = 7;
  11632. break;
  11633. }
  11634. throw new Error("Get preference: \"".concat(name, "\" is undefined."));
  11635. case 7:
  11636. prefValue = this.prefs[name];
  11637. if (!(prefValue !== undefined)) {
  11638. _context5.next = 10;
  11639. break;
  11640. }
  11641. return _context5.abrupt("return", prefValue);
  11642. case 10:
  11643. return _context5.abrupt("return", defaultValue);
  11644. case 11:
  11645. case "end":
  11646. return _context5.stop();
  11647. }
  11648. }
  11649. }, _callee5, this);
  11650. }));
  11651. function get(_x5) {
  11652. return _get.apply(this, arguments);
  11653. }
  11654. return get;
  11655. }()
  11656. }, {
  11657. key: "getAll",
  11658. value: function () {
  11659. var _getAll = _asyncToGenerator(
  11660. /*#__PURE__*/
  11661. _regenerator.default.mark(function _callee6() {
  11662. return _regenerator.default.wrap(function _callee6$(_context6) {
  11663. while (1) {
  11664. switch (_context6.prev = _context6.next) {
  11665. case 0:
  11666. _context6.next = 2;
  11667. return this._initializedPromise;
  11668. case 2:
  11669. return _context6.abrupt("return", Object.assign(Object.create(null), this.defaults, this.prefs));
  11670. case 3:
  11671. case "end":
  11672. return _context6.stop();
  11673. }
  11674. }
  11675. }, _callee6, this);
  11676. }));
  11677. function getAll() {
  11678. return _getAll.apply(this, arguments);
  11679. }
  11680. return getAll;
  11681. }()
  11682. }]);
  11683. return BasePreferences;
  11684. }();
  11685. exports.BasePreferences = BasePreferences;
  11686. /***/ }),
  11687. /* 39 */
  11688. /***/ (function(module, exports, __webpack_require__) {
  11689. "use strict";
  11690. Object.defineProperty(exports, "__esModule", {
  11691. value: true
  11692. });
  11693. exports.DownloadManager = void 0;
  11694. var _pdfjsLib = __webpack_require__(7);
  11695. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11696. 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); } }
  11697. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11698. ;
  11699. var DISABLE_CREATE_OBJECT_URL = _pdfjsLib.apiCompatibilityParams.disableCreateObjectURL || false;
  11700. function _download(blobUrl, filename) {
  11701. var a = document.createElement('a');
  11702. if (!a.click) {
  11703. throw new Error('DownloadManager: "a.click()" is not supported.');
  11704. }
  11705. a.href = blobUrl;
  11706. a.target = '_parent';
  11707. if ('download' in a) {
  11708. a.download = filename;
  11709. }
  11710. (document.body || document.documentElement).appendChild(a);
  11711. a.click();
  11712. a.remove();
  11713. }
  11714. var DownloadManager =
  11715. /*#__PURE__*/
  11716. function () {
  11717. function DownloadManager(_ref) {
  11718. var _ref$disableCreateObj = _ref.disableCreateObjectURL,
  11719. disableCreateObjectURL = _ref$disableCreateObj === void 0 ? DISABLE_CREATE_OBJECT_URL : _ref$disableCreateObj;
  11720. _classCallCheck(this, DownloadManager);
  11721. this.disableCreateObjectURL = disableCreateObjectURL;
  11722. }
  11723. _createClass(DownloadManager, [{
  11724. key: "downloadUrl",
  11725. value: function downloadUrl(url, filename) {
  11726. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, 'http://example.com')) {
  11727. return;
  11728. }
  11729. _download(url + '#pdfjs.action=download', filename);
  11730. }
  11731. }, {
  11732. key: "downloadData",
  11733. value: function downloadData(data, filename, contentType) {
  11734. if (navigator.msSaveBlob) {
  11735. return navigator.msSaveBlob(new Blob([data], {
  11736. type: contentType
  11737. }), filename);
  11738. }
  11739. var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, this.disableCreateObjectURL);
  11740. _download(blobUrl, filename);
  11741. }
  11742. },
  11743. // {
  11744. // key: "download",
  11745. // value: function download(blob, url, filename) {
  11746. // if (navigator.msSaveBlob) {
  11747. // if (!navigator.msSaveBlob(blob, filename)) {
  11748. // this.downloadUrl(url, filename);
  11749. // }
  11750. //
  11751. // return;
  11752. // }
  11753. //
  11754. // if (this.disableCreateObjectURL) {
  11755. // this.downloadUrl(url, filename);
  11756. // return;
  11757. // }
  11758. //
  11759. // var blobUrl = _pdfjsLib.URL.createObjectURL(blob);
  11760. //
  11761. // _download(blobUrl, filename);
  11762. // }
  11763. // }
  11764. ]);
  11765. return DownloadManager;
  11766. }();
  11767. exports.DownloadManager = DownloadManager;
  11768. /***/ }),
  11769. /* 40 */
  11770. /***/ (function(module, exports, __webpack_require__) {
  11771. "use strict";
  11772. Object.defineProperty(exports, "__esModule", {
  11773. value: true
  11774. });
  11775. exports.GenericL10n = void 0;
  11776. var _regenerator = _interopRequireDefault(__webpack_require__(2));
  11777. __webpack_require__(41);
  11778. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11779. 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); } }
  11780. 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); }); }; }
  11781. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11782. 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); } }
  11783. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  11784. var webL10n = document.webL10n;
  11785. var GenericL10n =
  11786. /*#__PURE__*/
  11787. function () {
  11788. function GenericL10n(lang) {
  11789. _classCallCheck(this, GenericL10n);
  11790. this._lang = lang;
  11791. this._ready = new Promise(function (resolve, reject) {
  11792. webL10n.setLanguage(lang, function () {
  11793. resolve(webL10n);
  11794. });
  11795. });
  11796. }
  11797. _createClass(GenericL10n, [{
  11798. key: "getLanguage",
  11799. value: function () {
  11800. var _getLanguage = _asyncToGenerator(
  11801. /*#__PURE__*/
  11802. _regenerator.default.mark(function _callee() {
  11803. var l10n;
  11804. return _regenerator.default.wrap(function _callee$(_context) {
  11805. while (1) {
  11806. switch (_context.prev = _context.next) {
  11807. case 0:
  11808. _context.next = 2;
  11809. return this._ready;
  11810. case 2:
  11811. l10n = _context.sent;
  11812. return _context.abrupt("return", l10n.getLanguage());
  11813. case 4:
  11814. case "end":
  11815. return _context.stop();
  11816. }
  11817. }
  11818. }, _callee, this);
  11819. }));
  11820. function getLanguage() {
  11821. return _getLanguage.apply(this, arguments);
  11822. }
  11823. return getLanguage;
  11824. }()
  11825. }, {
  11826. key: "getDirection",
  11827. value: function () {
  11828. var _getDirection = _asyncToGenerator(
  11829. /*#__PURE__*/
  11830. _regenerator.default.mark(function _callee2() {
  11831. var l10n;
  11832. return _regenerator.default.wrap(function _callee2$(_context2) {
  11833. while (1) {
  11834. switch (_context2.prev = _context2.next) {
  11835. case 0:
  11836. _context2.next = 2;
  11837. return this._ready;
  11838. case 2:
  11839. l10n = _context2.sent;
  11840. return _context2.abrupt("return", l10n.getDirection());
  11841. case 4:
  11842. case "end":
  11843. return _context2.stop();
  11844. }
  11845. }
  11846. }, _callee2, this);
  11847. }));
  11848. function getDirection() {
  11849. return _getDirection.apply(this, arguments);
  11850. }
  11851. return getDirection;
  11852. }()
  11853. }, {
  11854. key: "get",
  11855. value: function () {
  11856. var _get = _asyncToGenerator(
  11857. /*#__PURE__*/
  11858. _regenerator.default.mark(function _callee3(property, args, fallback) {
  11859. var l10n;
  11860. return _regenerator.default.wrap(function _callee3$(_context3) {
  11861. while (1) {
  11862. switch (_context3.prev = _context3.next) {
  11863. case 0:
  11864. _context3.next = 2;
  11865. return this._ready;
  11866. case 2:
  11867. l10n = _context3.sent;
  11868. return _context3.abrupt("return", l10n.get(property, args, fallback));
  11869. case 4:
  11870. case "end":
  11871. return _context3.stop();
  11872. }
  11873. }
  11874. }, _callee3, this);
  11875. }));
  11876. function get(_x, _x2, _x3) {
  11877. return _get.apply(this, arguments);
  11878. }
  11879. return get;
  11880. }()
  11881. }, {
  11882. key: "translate",
  11883. value: function () {
  11884. var _translate = _asyncToGenerator(
  11885. /*#__PURE__*/
  11886. _regenerator.default.mark(function _callee4(element) {
  11887. var l10n;
  11888. return _regenerator.default.wrap(function _callee4$(_context4) {
  11889. while (1) {
  11890. switch (_context4.prev = _context4.next) {
  11891. case 0:
  11892. _context4.next = 2;
  11893. return this._ready;
  11894. case 2:
  11895. l10n = _context4.sent;
  11896. return _context4.abrupt("return", l10n.translate(element));
  11897. case 4:
  11898. case "end":
  11899. return _context4.stop();
  11900. }
  11901. }
  11902. }, _callee4, this);
  11903. }));
  11904. function translate(_x4) {
  11905. return _translate.apply(this, arguments);
  11906. }
  11907. return translate;
  11908. }()
  11909. }]);
  11910. return GenericL10n;
  11911. }();
  11912. exports.GenericL10n = GenericL10n;
  11913. /***/ }),
  11914. /* 41 */
  11915. /***/ (function(module, exports, __webpack_require__) {
  11916. "use strict";
  11917. document.webL10n = function (window, document, undefined) {
  11918. var gL10nData = {};
  11919. var gTextData = '';
  11920. var gTextProp = 'textContent';
  11921. var gLanguage = '';
  11922. var gMacros = {};
  11923. var gReadyState = 'loading';
  11924. var gAsyncResourceLoading = true;
  11925. function getL10nResourceLinks() {
  11926. return document.querySelectorAll('link[type="application/l10n"]');
  11927. }
  11928. function getL10nDictionary() {
  11929. var script = document.querySelector('script[type="application/l10n"]');
  11930. return script ? JSON.parse(script.innerHTML) : null;
  11931. }
  11932. function getTranslatableChildren(element) {
  11933. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  11934. }
  11935. function getL10nAttributes(element) {
  11936. if (!element) return {};
  11937. var l10nId = element.getAttribute('data-l10n-id');
  11938. var l10nArgs = element.getAttribute('data-l10n-args');
  11939. var args = {};
  11940. if (l10nArgs) {
  11941. try {
  11942. args = JSON.parse(l10nArgs);
  11943. } catch (e) {
  11944. console.warn('could not parse arguments for #' + l10nId);
  11945. }
  11946. }
  11947. return {
  11948. id: l10nId,
  11949. args: args
  11950. };
  11951. }
  11952. function fireL10nReadyEvent(lang) {
  11953. var evtObject = document.createEvent('Event');
  11954. evtObject.initEvent('localized', true, false);
  11955. evtObject.language = lang;
  11956. document.dispatchEvent(evtObject);
  11957. }
  11958. function xhrLoadText(url, onSuccess, onFailure) {
  11959. onSuccess = onSuccess || function _onSuccess(data) {};
  11960. onFailure = onFailure || function _onFailure() {};
  11961. var xhr = new XMLHttpRequest();
  11962. xhr.open('GET', url, gAsyncResourceLoading);
  11963. if (xhr.overrideMimeType) {
  11964. xhr.overrideMimeType('text/plain; charset=utf-8');
  11965. }
  11966. xhr.onreadystatechange = function () {
  11967. if (xhr.readyState == 4) {
  11968. if (xhr.status == 200 || xhr.status === 0) {
  11969. onSuccess(xhr.responseText);
  11970. } else {
  11971. onFailure();
  11972. }
  11973. }
  11974. };
  11975. xhr.onerror = onFailure;
  11976. xhr.ontimeout = onFailure;
  11977. try {
  11978. xhr.send(null);
  11979. } catch (e) {
  11980. onFailure();
  11981. }
  11982. }
  11983. function parseResource(href, lang, successCallback, failureCallback) {
  11984. var baseURL = href.replace(/[^\/]*$/, '') || './';
  11985. function evalString(text) {
  11986. if (text.lastIndexOf('\\') < 0) return text;
  11987. 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, "'");
  11988. }
  11989. function parseProperties(text, parsedPropertiesCallback) {
  11990. var dictionary = {};
  11991. var reBlank = /^\s*|\s*$/;
  11992. var reComment = /^\s*#|^\s*$/;
  11993. var reSection = /^\s*\[(.*)\]\s*$/;
  11994. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  11995. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  11996. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  11997. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  11998. var currentLang = '*';
  11999. var genericLang = lang.split('-', 1)[0];
  12000. var skipLang = false;
  12001. var match = '';
  12002. function nextEntry() {
  12003. while (true) {
  12004. if (!entries.length) {
  12005. parsedRawLinesCallback();
  12006. return;
  12007. }
  12008. var line = entries.shift();
  12009. if (reComment.test(line)) continue;
  12010. if (extendedSyntax) {
  12011. match = reSection.exec(line);
  12012. if (match) {
  12013. currentLang = match[1].toLowerCase();
  12014. skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
  12015. continue;
  12016. } else if (skipLang) {
  12017. continue;
  12018. }
  12019. match = reImport.exec(line);
  12020. if (match) {
  12021. loadImport(baseURL + match[1], nextEntry);
  12022. return;
  12023. }
  12024. }
  12025. var tmp = line.match(reSplit);
  12026. if (tmp && tmp.length == 3) {
  12027. dictionary[tmp[1]] = evalString(tmp[2]);
  12028. }
  12029. }
  12030. }
  12031. nextEntry();
  12032. }
  12033. function loadImport(url, callback) {
  12034. xhrLoadText(url, function (content) {
  12035. parseRawLines(content, false, callback);
  12036. }, function () {
  12037. console.warn(url + ' not found.');
  12038. callback();
  12039. });
  12040. }
  12041. parseRawLines(text, true, function () {
  12042. parsedPropertiesCallback(dictionary);
  12043. });
  12044. }
  12045. xhrLoadText(href, function (response) {
  12046. gTextData += response;
  12047. parseProperties(response, function (data) {
  12048. for (var key in data) {
  12049. var id,
  12050. prop,
  12051. index = key.lastIndexOf('.');
  12052. if (index > 0) {
  12053. id = key.substring(0, index);
  12054. prop = key.substring(index + 1);
  12055. } else {
  12056. id = key;
  12057. prop = gTextProp;
  12058. }
  12059. if (!gL10nData[id]) {
  12060. gL10nData[id] = {};
  12061. }
  12062. gL10nData[id][prop] = data[key];
  12063. }
  12064. if (successCallback) {
  12065. successCallback();
  12066. }
  12067. });
  12068. }, failureCallback);
  12069. }
  12070. function loadLocale(lang, callback) {
  12071. if (lang) {
  12072. lang = lang.toLowerCase();
  12073. }
  12074. callback = callback || function _callback() {};
  12075. clear();
  12076. gLanguage = lang;
  12077. var langLinks = getL10nResourceLinks();
  12078. var langCount = langLinks.length;
  12079. if (langCount === 0) {
  12080. var dict = getL10nDictionary();
  12081. if (dict && dict.locales && dict.default_locale) {
  12082. console.log('using the embedded JSON directory, early way out');
  12083. gL10nData = dict.locales[lang];
  12084. if (!gL10nData) {
  12085. var defaultLocale = dict.default_locale.toLowerCase();
  12086. for (var anyCaseLang in dict.locales) {
  12087. anyCaseLang = anyCaseLang.toLowerCase();
  12088. if (anyCaseLang === lang) {
  12089. gL10nData = dict.locales[lang];
  12090. break;
  12091. } else if (anyCaseLang === defaultLocale) {
  12092. gL10nData = dict.locales[defaultLocale];
  12093. }
  12094. }
  12095. }
  12096. callback();
  12097. } else {
  12098. console.log('no resource to load, early way out');
  12099. }
  12100. fireL10nReadyEvent(lang);
  12101. gReadyState = 'complete';
  12102. return;
  12103. }
  12104. var onResourceLoaded = null;
  12105. var gResourceCount = 0;
  12106. onResourceLoaded = function onResourceLoaded() {
  12107. gResourceCount++;
  12108. if (gResourceCount >= langCount) {
  12109. callback();
  12110. fireL10nReadyEvent(lang);
  12111. gReadyState = 'complete';
  12112. }
  12113. };
  12114. function L10nResourceLink(link) {
  12115. var href = link.href;
  12116. this.load = function (lang, callback) {
  12117. parseResource(href, lang, callback, function () {
  12118. console.warn(href + ' not found.');
  12119. console.warn('"' + lang + '" resource not found');
  12120. gLanguage = '';
  12121. callback();
  12122. });
  12123. };
  12124. }
  12125. for (var i = 0; i < langCount; i++) {
  12126. var resource = new L10nResourceLink(langLinks[i]);
  12127. resource.load(lang, onResourceLoaded);
  12128. }
  12129. }
  12130. function clear() {
  12131. gL10nData = {};
  12132. gTextData = '';
  12133. gLanguage = '';
  12134. }
  12135. function getPluralRules(lang) {
  12136. var locales2rules = {
  12137. 'af': 3,
  12138. 'ak': 4,
  12139. 'am': 4,
  12140. 'ar': 1,
  12141. 'asa': 3,
  12142. 'az': 0,
  12143. 'be': 11,
  12144. 'bem': 3,
  12145. 'bez': 3,
  12146. 'bg': 3,
  12147. 'bh': 4,
  12148. 'bm': 0,
  12149. 'bn': 3,
  12150. 'bo': 0,
  12151. 'br': 20,
  12152. 'brx': 3,
  12153. 'bs': 11,
  12154. 'ca': 3,
  12155. 'cgg': 3,
  12156. 'chr': 3,
  12157. 'cs': 12,
  12158. 'cy': 17,
  12159. 'da': 3,
  12160. 'de': 3,
  12161. 'dv': 3,
  12162. 'dz': 0,
  12163. 'ee': 3,
  12164. 'el': 3,
  12165. 'en': 3,
  12166. 'eo': 3,
  12167. 'es': 3,
  12168. 'et': 3,
  12169. 'eu': 3,
  12170. 'fa': 0,
  12171. 'ff': 5,
  12172. 'fi': 3,
  12173. 'fil': 4,
  12174. 'fo': 3,
  12175. 'fr': 5,
  12176. 'fur': 3,
  12177. 'fy': 3,
  12178. 'ga': 8,
  12179. 'gd': 24,
  12180. 'gl': 3,
  12181. 'gsw': 3,
  12182. 'gu': 3,
  12183. 'guw': 4,
  12184. 'gv': 23,
  12185. 'ha': 3,
  12186. 'haw': 3,
  12187. 'he': 2,
  12188. 'hi': 4,
  12189. 'hr': 11,
  12190. 'hu': 0,
  12191. 'id': 0,
  12192. 'ig': 0,
  12193. 'ii': 0,
  12194. 'is': 3,
  12195. 'it': 3,
  12196. 'iu': 7,
  12197. 'ja': 0,
  12198. 'jmc': 3,
  12199. 'jv': 0,
  12200. 'ka': 0,
  12201. 'kab': 5,
  12202. 'kaj': 3,
  12203. 'kcg': 3,
  12204. 'kde': 0,
  12205. 'kea': 0,
  12206. 'kk': 3,
  12207. 'kl': 3,
  12208. 'km': 0,
  12209. 'kn': 0,
  12210. 'ko': 0,
  12211. 'ksb': 3,
  12212. 'ksh': 21,
  12213. 'ku': 3,
  12214. 'kw': 7,
  12215. 'lag': 18,
  12216. 'lb': 3,
  12217. 'lg': 3,
  12218. 'ln': 4,
  12219. 'lo': 0,
  12220. 'lt': 10,
  12221. 'lv': 6,
  12222. 'mas': 3,
  12223. 'mg': 4,
  12224. 'mk': 16,
  12225. 'ml': 3,
  12226. 'mn': 3,
  12227. 'mo': 9,
  12228. 'mr': 3,
  12229. 'ms': 0,
  12230. 'mt': 15,
  12231. 'my': 0,
  12232. 'nah': 3,
  12233. 'naq': 7,
  12234. 'nb': 3,
  12235. 'nd': 3,
  12236. 'ne': 3,
  12237. 'nl': 3,
  12238. 'nn': 3,
  12239. 'no': 3,
  12240. 'nr': 3,
  12241. 'nso': 4,
  12242. 'ny': 3,
  12243. 'nyn': 3,
  12244. 'om': 3,
  12245. 'or': 3,
  12246. 'pa': 3,
  12247. 'pap': 3,
  12248. 'pl': 13,
  12249. 'ps': 3,
  12250. 'pt': 3,
  12251. 'rm': 3,
  12252. 'ro': 9,
  12253. 'rof': 3,
  12254. 'ru': 11,
  12255. 'rwk': 3,
  12256. 'sah': 0,
  12257. 'saq': 3,
  12258. 'se': 7,
  12259. 'seh': 3,
  12260. 'ses': 0,
  12261. 'sg': 0,
  12262. 'sh': 11,
  12263. 'shi': 19,
  12264. 'sk': 12,
  12265. 'sl': 14,
  12266. 'sma': 7,
  12267. 'smi': 7,
  12268. 'smj': 7,
  12269. 'smn': 7,
  12270. 'sms': 7,
  12271. 'sn': 3,
  12272. 'so': 3,
  12273. 'sq': 3,
  12274. 'sr': 11,
  12275. 'ss': 3,
  12276. 'ssy': 3,
  12277. 'st': 3,
  12278. 'sv': 3,
  12279. 'sw': 3,
  12280. 'syr': 3,
  12281. 'ta': 3,
  12282. 'te': 3,
  12283. 'teo': 3,
  12284. 'th': 0,
  12285. 'ti': 4,
  12286. 'tig': 3,
  12287. 'tk': 3,
  12288. 'tl': 4,
  12289. 'tn': 3,
  12290. 'to': 0,
  12291. 'tr': 0,
  12292. 'ts': 3,
  12293. 'tzm': 22,
  12294. 'uk': 11,
  12295. 'ur': 3,
  12296. 've': 3,
  12297. 'vi': 0,
  12298. 'vun': 3,
  12299. 'wa': 4,
  12300. 'wae': 3,
  12301. 'wo': 0,
  12302. 'xh': 3,
  12303. 'xog': 3,
  12304. 'yo': 0,
  12305. 'zh': 0,
  12306. 'zu': 3
  12307. };
  12308. function isIn(n, list) {
  12309. return list.indexOf(n) !== -1;
  12310. }
  12311. function isBetween(n, start, end) {
  12312. return start <= n && n <= end;
  12313. }
  12314. var pluralRules = {
  12315. '0': function _(n) {
  12316. return 'other';
  12317. },
  12318. '1': function _(n) {
  12319. if (isBetween(n % 100, 3, 10)) return 'few';
  12320. if (n === 0) return 'zero';
  12321. if (isBetween(n % 100, 11, 99)) return 'many';
  12322. if (n == 2) return 'two';
  12323. if (n == 1) return 'one';
  12324. return 'other';
  12325. },
  12326. '2': function _(n) {
  12327. if (n !== 0 && n % 10 === 0) return 'many';
  12328. if (n == 2) return 'two';
  12329. if (n == 1) return 'one';
  12330. return 'other';
  12331. },
  12332. '3': function _(n) {
  12333. if (n == 1) return 'one';
  12334. return 'other';
  12335. },
  12336. '4': function _(n) {
  12337. if (isBetween(n, 0, 1)) return 'one';
  12338. return 'other';
  12339. },
  12340. '5': function _(n) {
  12341. if (isBetween(n, 0, 2) && n != 2) return 'one';
  12342. return 'other';
  12343. },
  12344. '6': function _(n) {
  12345. if (n === 0) return 'zero';
  12346. if (n % 10 == 1 && n % 100 != 11) return 'one';
  12347. return 'other';
  12348. },
  12349. '7': function _(n) {
  12350. if (n == 2) return 'two';
  12351. if (n == 1) return 'one';
  12352. return 'other';
  12353. },
  12354. '8': function _(n) {
  12355. if (isBetween(n, 3, 6)) return 'few';
  12356. if (isBetween(n, 7, 10)) return 'many';
  12357. if (n == 2) return 'two';
  12358. if (n == 1) return 'one';
  12359. return 'other';
  12360. },
  12361. '9': function _(n) {
  12362. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  12363. if (n == 1) return 'one';
  12364. return 'other';
  12365. },
  12366. '10': function _(n) {
  12367. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  12368. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  12369. return 'other';
  12370. },
  12371. '11': function _(n) {
  12372. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  12373. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
  12374. if (n % 10 == 1 && n % 100 != 11) return 'one';
  12375. return 'other';
  12376. },
  12377. '12': function _(n) {
  12378. if (isBetween(n, 2, 4)) return 'few';
  12379. if (n == 1) return 'one';
  12380. return 'other';
  12381. },
  12382. '13': function _(n) {
  12383. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  12384. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
  12385. if (n == 1) return 'one';
  12386. return 'other';
  12387. },
  12388. '14': function _(n) {
  12389. if (isBetween(n % 100, 3, 4)) return 'few';
  12390. if (n % 100 == 2) return 'two';
  12391. if (n % 100 == 1) return 'one';
  12392. return 'other';
  12393. },
  12394. '15': function _(n) {
  12395. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  12396. if (isBetween(n % 100, 11, 19)) return 'many';
  12397. if (n == 1) return 'one';
  12398. return 'other';
  12399. },
  12400. '16': function _(n) {
  12401. if (n % 10 == 1 && n != 11) return 'one';
  12402. return 'other';
  12403. },
  12404. '17': function _(n) {
  12405. if (n == 3) return 'few';
  12406. if (n === 0) return 'zero';
  12407. if (n == 6) return 'many';
  12408. if (n == 2) return 'two';
  12409. if (n == 1) return 'one';
  12410. return 'other';
  12411. },
  12412. '18': function _(n) {
  12413. if (n === 0) return 'zero';
  12414. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  12415. return 'other';
  12416. },
  12417. '19': function _(n) {
  12418. if (isBetween(n, 2, 10)) return 'few';
  12419. if (isBetween(n, 0, 1)) return 'one';
  12420. return 'other';
  12421. },
  12422. '20': function _(n) {
  12423. 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';
  12424. if (n % 1000000 === 0 && n !== 0) return 'many';
  12425. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  12426. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  12427. return 'other';
  12428. },
  12429. '21': function _(n) {
  12430. if (n === 0) return 'zero';
  12431. if (n == 1) return 'one';
  12432. return 'other';
  12433. },
  12434. '22': function _(n) {
  12435. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  12436. return 'other';
  12437. },
  12438. '23': function _(n) {
  12439. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  12440. return 'other';
  12441. },
  12442. '24': function _(n) {
  12443. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  12444. if (isIn(n, [2, 12])) return 'two';
  12445. if (isIn(n, [1, 11])) return 'one';
  12446. return 'other';
  12447. }
  12448. };
  12449. var index = locales2rules[lang.replace(/-.*$/, '')];
  12450. if (!(index in pluralRules)) {
  12451. console.warn('plural form unknown for [' + lang + ']');
  12452. return function () {
  12453. return 'other';
  12454. };
  12455. }
  12456. return pluralRules[index];
  12457. }
  12458. gMacros.plural = function (str, param, key, prop) {
  12459. var n = parseFloat(param);
  12460. if (isNaN(n)) return str;
  12461. if (prop != gTextProp) return str;
  12462. if (!gMacros._pluralRules) {
  12463. gMacros._pluralRules = getPluralRules(gLanguage);
  12464. }
  12465. var index = '[' + gMacros._pluralRules(n) + ']';
  12466. if (n === 0 && key + '[zero]' in gL10nData) {
  12467. str = gL10nData[key + '[zero]'][prop];
  12468. } else if (n == 1 && key + '[one]' in gL10nData) {
  12469. str = gL10nData[key + '[one]'][prop];
  12470. } else if (n == 2 && key + '[two]' in gL10nData) {
  12471. str = gL10nData[key + '[two]'][prop];
  12472. } else if (key + index in gL10nData) {
  12473. str = gL10nData[key + index][prop];
  12474. } else if (key + '[other]' in gL10nData) {
  12475. str = gL10nData[key + '[other]'][prop];
  12476. }
  12477. return str;
  12478. };
  12479. function getL10nData(key, args, fallback) {
  12480. var data = gL10nData[key];
  12481. if (!data) {
  12482. console.warn('#' + key + ' is undefined.');
  12483. if (!fallback) {
  12484. return null;
  12485. }
  12486. data = fallback;
  12487. }
  12488. var rv = {};
  12489. for (var prop in data) {
  12490. var str = data[prop];
  12491. str = substIndexes(str, args, key, prop);
  12492. str = substArguments(str, args, key);
  12493. rv[prop] = str;
  12494. }
  12495. return rv;
  12496. }
  12497. function substIndexes(str, args, key, prop) {
  12498. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  12499. var reMatch = reIndex.exec(str);
  12500. if (!reMatch || !reMatch.length) return str;
  12501. var macroName = reMatch[1];
  12502. var paramName = reMatch[2];
  12503. var param;
  12504. if (args && paramName in args) {
  12505. param = args[paramName];
  12506. } else if (paramName in gL10nData) {
  12507. param = gL10nData[paramName];
  12508. }
  12509. if (macroName in gMacros) {
  12510. var macro = gMacros[macroName];
  12511. str = macro(str, param, key, prop);
  12512. }
  12513. return str;
  12514. }
  12515. function substArguments(str, args, key) {
  12516. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  12517. return str.replace(reArgs, function (matched_text, arg) {
  12518. if (args && arg in args) {
  12519. return args[arg];
  12520. }
  12521. if (arg in gL10nData) {
  12522. return gL10nData[arg];
  12523. }
  12524. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  12525. return matched_text;
  12526. });
  12527. }
  12528. function translateElement(element) {
  12529. var l10n = getL10nAttributes(element);
  12530. if (!l10n.id) return;
  12531. var data = getL10nData(l10n.id, l10n.args);
  12532. if (!data) {
  12533. console.warn('#' + l10n.id + ' is undefined.');
  12534. return;
  12535. }
  12536. if (data[gTextProp]) {
  12537. if (getChildElementCount(element) === 0) {
  12538. element[gTextProp] = data[gTextProp];
  12539. } else {
  12540. var children = element.childNodes;
  12541. var found = false;
  12542. for (var i = 0, l = children.length; i < l; i++) {
  12543. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  12544. if (found) {
  12545. children[i].nodeValue = '';
  12546. } else {
  12547. children[i].nodeValue = data[gTextProp];
  12548. found = true;
  12549. }
  12550. }
  12551. }
  12552. if (!found) {
  12553. var textNode = document.createTextNode(data[gTextProp]);
  12554. element.insertBefore(textNode, element.firstChild);
  12555. }
  12556. }
  12557. delete data[gTextProp];
  12558. }
  12559. for (var k in data) {
  12560. element[k] = data[k];
  12561. }
  12562. }
  12563. function getChildElementCount(element) {
  12564. if (element.children) {
  12565. return element.children.length;
  12566. }
  12567. if (typeof element.childElementCount !== 'undefined') {
  12568. return element.childElementCount;
  12569. }
  12570. var count = 0;
  12571. for (var i = 0; i < element.childNodes.length; i++) {
  12572. count += element.nodeType === 1 ? 1 : 0;
  12573. }
  12574. return count;
  12575. }
  12576. function translateFragment(element) {
  12577. element = element || document.documentElement;
  12578. var children = getTranslatableChildren(element);
  12579. var elementCount = children.length;
  12580. for (var i = 0; i < elementCount; i++) {
  12581. translateElement(children[i]);
  12582. }
  12583. translateElement(element);
  12584. }
  12585. return {
  12586. get: function get(key, args, fallbackString) {
  12587. var index = key.lastIndexOf('.');
  12588. var prop = gTextProp;
  12589. if (index > 0) {
  12590. prop = key.substring(index + 1);
  12591. key = key.substring(0, index);
  12592. }
  12593. var fallback;
  12594. if (fallbackString) {
  12595. fallback = {};
  12596. fallback[prop] = fallbackString;
  12597. }
  12598. var data = getL10nData(key, args, fallback);
  12599. if (data && prop in data) {
  12600. return data[prop];
  12601. }
  12602. return '{{' + key + '}}';
  12603. },
  12604. getData: function getData() {
  12605. return gL10nData;
  12606. },
  12607. getText: function getText() {
  12608. return gTextData;
  12609. },
  12610. getLanguage: function getLanguage() {
  12611. return gLanguage;
  12612. },
  12613. setLanguage: function setLanguage(lang, callback) {
  12614. loadLocale(lang, function () {
  12615. if (callback) callback();
  12616. });
  12617. },
  12618. getDirection: function getDirection() {
  12619. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  12620. var shortCode = gLanguage.split('-', 1)[0];
  12621. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  12622. },
  12623. translate: translateFragment,
  12624. getReadyState: function getReadyState() {
  12625. return gReadyState;
  12626. },
  12627. ready: function ready(callback) {
  12628. if (!callback) {
  12629. return;
  12630. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  12631. window.setTimeout(function () {
  12632. callback();
  12633. });
  12634. } else if (document.addEventListener) {
  12635. document.addEventListener('localized', function once() {
  12636. document.removeEventListener('localized', once);
  12637. callback();
  12638. });
  12639. }
  12640. }
  12641. };
  12642. }(window, document);
  12643. /***/ }),
  12644. /* 42 */
  12645. /***/ (function(module, exports, __webpack_require__) {
  12646. "use strict";
  12647. Object.defineProperty(exports, "__esModule", {
  12648. value: true
  12649. });
  12650. exports.PDFPrintService = PDFPrintService;
  12651. var _ui_utils = __webpack_require__(6);
  12652. var _app = __webpack_require__(1);
  12653. var _pdfjsLib = __webpack_require__(7);
  12654. var activeService = null;
  12655. var overlayManager = null;
  12656. function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size) {
  12657. var scratchCanvas = activeService.scratchCanvas;
  12658. var PRINT_RESOLUTION = 150;
  12659. var PRINT_UNITS = PRINT_RESOLUTION / 72.0;
  12660. scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
  12661. scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
  12662. var width = Math.floor(size.width * _ui_utils.CSS_UNITS) + 'px';
  12663. var height = Math.floor(size.height * _ui_utils.CSS_UNITS) + 'px';
  12664. var ctx = scratchCanvas.getContext('2d');
  12665. ctx.save();
  12666. ctx.fillStyle = 'rgb(255, 255, 255)';
  12667. ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height);
  12668. ctx.restore();
  12669. return pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  12670. var renderContext = {
  12671. canvasContext: ctx,
  12672. transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
  12673. viewport: pdfPage.getViewport({
  12674. scale: 1,
  12675. rotation: size.rotation
  12676. }),
  12677. intent: 'print'
  12678. };
  12679. return pdfPage.render(renderContext).promise;
  12680. }).then(function () {
  12681. return {
  12682. width: width,
  12683. height: height
  12684. };
  12685. });
  12686. }
  12687. function PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
  12688. this.pdfDocument = pdfDocument;
  12689. this.pagesOverview = pagesOverview;
  12690. this.printContainer = printContainer;
  12691. this.l10n = l10n || _ui_utils.NullL10n;
  12692. this.disableCreateObjectURL = pdfDocument.loadingParams['disableCreateObjectURL'];
  12693. this.currentPage = -1;
  12694. this.scratchCanvas = document.createElement('canvas');
  12695. }
  12696. PDFPrintService.prototype = {
  12697. layout: function layout() {
  12698. this.throwIfInactive();
  12699. var body = document.querySelector('body');
  12700. body.setAttribute('data-pdfjsprinting', true);
  12701. var hasEqualPageSizes = this.pagesOverview.every(function (size) {
  12702. return size.width === this.pagesOverview[0].width && size.height === this.pagesOverview[0].height;
  12703. }, this);
  12704. if (!hasEqualPageSizes) {
  12705. console.warn('Not all pages have the same size. The printed ' + 'result may be incorrect!');
  12706. }
  12707. this.pageStyleSheet = document.createElement('style');
  12708. var pageSize = this.pagesOverview[0];
  12709. this.pageStyleSheet.textContent = '@supports ((size:A4) and (size:1pt 1pt)) {' + '@page { size: ' + pageSize.width + 'pt ' + pageSize.height + 'pt;}' + '}';
  12710. body.appendChild(this.pageStyleSheet);
  12711. },
  12712. destroy: function destroy() {
  12713. if (activeService !== this) {
  12714. return;
  12715. }
  12716. this.printContainer.textContent = '';
  12717. if (this.pageStyleSheet) {
  12718. this.pageStyleSheet.remove();
  12719. this.pageStyleSheet = null;
  12720. }
  12721. this.scratchCanvas.width = this.scratchCanvas.height = 0;
  12722. this.scratchCanvas = null;
  12723. activeService = null;
  12724. ensureOverlay().then(function () {
  12725. if (overlayManager.active !== 'printServiceOverlay') {
  12726. return;
  12727. }
  12728. overlayManager.close('printServiceOverlay');
  12729. });
  12730. },
  12731. renderPages: function renderPages() {
  12732. var _this = this;
  12733. var pageCount = this.pagesOverview.length;
  12734. var renderNextPage = function renderNextPage(resolve, reject) {
  12735. _this.throwIfInactive();
  12736. if (++_this.currentPage >= pageCount) {
  12737. renderProgress(pageCount, pageCount, _this.l10n);
  12738. resolve();
  12739. return;
  12740. }
  12741. var index = _this.currentPage;
  12742. renderProgress(index, pageCount, _this.l10n);
  12743. renderPage(_this, _this.pdfDocument, index + 1, _this.pagesOverview[index]).then(_this.useRenderedPage.bind(_this)).then(function () {
  12744. renderNextPage(resolve, reject);
  12745. }, reject);
  12746. };
  12747. return new Promise(renderNextPage);
  12748. },
  12749. useRenderedPage: function useRenderedPage(printItem) {
  12750. this.throwIfInactive();
  12751. var img = document.createElement('img');
  12752. img.style.width = printItem.width;
  12753. img.style.height = printItem.height;
  12754. var scratchCanvas = this.scratchCanvas;
  12755. if ('toBlob' in scratchCanvas && !this.disableCreateObjectURL) {
  12756. scratchCanvas.toBlob(function (blob) {
  12757. img.src = _pdfjsLib.URL.createObjectURL(blob);
  12758. });
  12759. } else {
  12760. img.src = scratchCanvas.toDataURL();
  12761. }
  12762. var wrapper = document.createElement('div');
  12763. wrapper.appendChild(img);
  12764. this.printContainer.appendChild(wrapper);
  12765. return new Promise(function (resolve, reject) {
  12766. img.onload = resolve;
  12767. img.onerror = reject;
  12768. });
  12769. },
  12770. performPrint: function performPrint() {
  12771. var _this2 = this;
  12772. this.throwIfInactive();
  12773. return new Promise(function (resolve) {
  12774. setTimeout(function () {
  12775. if (!_this2.active) {
  12776. resolve();
  12777. return;
  12778. }
  12779. print.call(window);
  12780. setTimeout(resolve, 20);
  12781. }, 0);
  12782. });
  12783. },
  12784. get active() {
  12785. return this === activeService;
  12786. },
  12787. throwIfInactive: function throwIfInactive() {
  12788. if (!this.active) {
  12789. throw new Error('This print request was cancelled or completed.');
  12790. }
  12791. }
  12792. };
  12793. var print = window.print;
  12794. window.print = function print() {
  12795. debugger;
  12796. if (activeService) {
  12797. console.warn('Ignored window.print() because of a pending print job.');
  12798. return;
  12799. }
  12800. ensureOverlay().then(function () {
  12801. if (activeService) {
  12802. overlayManager.open('printServiceOverlay');
  12803. }
  12804. });
  12805. try {
  12806. dispatchEvent('beforeprint');
  12807. } finally {
  12808. if (!activeService) {
  12809. console.error('Expected print service to be initialized.');
  12810. ensureOverlay().then(function () {
  12811. if (overlayManager.active === 'printServiceOverlay') {
  12812. overlayManager.close('printServiceOverlay');
  12813. }
  12814. });
  12815. return;
  12816. }
  12817. var activeServiceOnEntry = activeService;
  12818. activeService.renderPages().then(function () {
  12819. return activeServiceOnEntry.performPrint();
  12820. }).catch(function () {}).then(function () {
  12821. if (activeServiceOnEntry.active) {
  12822. abort();
  12823. }
  12824. });
  12825. }
  12826. };
  12827. function dispatchEvent(eventType) {
  12828. var event = document.createEvent('CustomEvent');
  12829. event.initCustomEvent(eventType, false, false, 'custom');
  12830. window.dispatchEvent(event);
  12831. }
  12832. function abort() {
  12833. if (activeService) {
  12834. activeService.destroy();
  12835. dispatchEvent('afterprint');
  12836. }
  12837. }
  12838. function renderProgress(index, total, l10n) {
  12839. var progressContainer = document.getElementById('printServiceOverlay');
  12840. var progress = Math.round(100 * index / total);
  12841. var progressBar = progressContainer.querySelector('progress');
  12842. var progressPerc = progressContainer.querySelector('.relative-progress');
  12843. progressBar.value = progress;
  12844. l10n.get('print_progress_percent', {
  12845. progress: progress
  12846. }, progress + '%').then(function (msg) {
  12847. progressPerc.textContent = msg;
  12848. });
  12849. }
  12850. var hasAttachEvent = !!document.attachEvent;
  12851. window.addEventListener('keydown', function (event) {
  12852. if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
  12853. window.print();
  12854. if (hasAttachEvent) {
  12855. return;
  12856. }
  12857. event.preventDefault();
  12858. if (event.stopImmediatePropagation) {
  12859. event.stopImmediatePropagation();
  12860. } else {
  12861. event.stopPropagation();
  12862. }
  12863. return;
  12864. }
  12865. }, true);
  12866. if (hasAttachEvent) {
  12867. document.attachEvent('onkeydown', function (event) {
  12868. event = event || window.event;
  12869. if (event.keyCode === 80 && event.ctrlKey) {
  12870. event.keyCode = 0;
  12871. return false;
  12872. }
  12873. });
  12874. }
  12875. if ('onbeforeprint' in window) {
  12876. var stopPropagationIfNeeded = function stopPropagationIfNeeded(event) {
  12877. if (event.detail !== 'custom' && event.stopImmediatePropagation) {
  12878. event.stopImmediatePropagation();
  12879. }
  12880. };
  12881. window.addEventListener('beforeprint', stopPropagationIfNeeded);
  12882. window.addEventListener('afterprint', stopPropagationIfNeeded);
  12883. }
  12884. var overlayPromise;
  12885. function ensureOverlay() {
  12886. if (!overlayPromise) {
  12887. overlayManager = _app.PDFViewerApplication.overlayManager;
  12888. if (!overlayManager) {
  12889. throw new Error('The overlay manager has not yet been initialized.');
  12890. }
  12891. overlayPromise = overlayManager.register('printServiceOverlay', document.getElementById('printServiceOverlay'), abort, true);
  12892. document.getElementById('printCancel').onclick = abort;
  12893. }
  12894. return overlayPromise;
  12895. }
  12896. _app.PDFPrintServiceFactory.instance = {
  12897. supportsPrinting: true,
  12898. createPrintService: function createPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
  12899. if (activeService) {
  12900. throw new Error('The print service is created and active.');
  12901. }
  12902. activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n);
  12903. return activeService;
  12904. }
  12905. };
  12906. /***/ })
  12907. /******/ ]);
  12908. //# sourceMappingURL=viewer.js.map