viewer.js 808 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2022 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * Javascript code in this page
  21. */
  22. /******/
  23. (() => { // webpackBootstrap
  24. /******/
  25. "use strict";
  26. /******/
  27. var __webpack_modules__ = ([
  28. /* 0 */
  29. ,
  30. /* 1 */
  31. /***/
  32. ((__unused_webpack_module, exports) => {
  33. Object.defineProperty(exports, "__esModule", ({
  34. value: true
  35. }));
  36. exports.compatibilityParams = exports.OptionKind = exports.AppOptions = void 0;
  37. function _typeof(obj) {
  38. "@babel/helpers - typeof";
  39. return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ?
  40. function(obj) {
  41. return typeof obj;
  42. } : function(obj) {
  43. return obj && "function" == typeof Symbol && obj.constructor === Symbol &&
  44. obj !== Symbol.prototype ? "symbol" : typeof obj;
  45. }, _typeof(obj);
  46. }
  47. function _classCallCheck(instance, Constructor) {
  48. if (!(instance instanceof Constructor)) {
  49. throw new TypeError("Cannot call a class as a function");
  50. }
  51. }
  52. function _defineProperties(target, props) {
  53. for (var i = 0; i < props.length; i++) {
  54. var descriptor = props[i];
  55. descriptor.enumerable = descriptor.enumerable || false;
  56. descriptor.configurable = true;
  57. if ("value" in descriptor) descriptor.writable = true;
  58. Object.defineProperty(target, descriptor.key, descriptor);
  59. }
  60. }
  61. function _createClass(Constructor, protoProps, staticProps) {
  62. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  63. if (staticProps) _defineProperties(Constructor, staticProps);
  64. Object.defineProperty(Constructor, "prototype", {
  65. writable: false
  66. });
  67. return Constructor;
  68. }
  69. var compatibilityParams = Object.create(null);
  70. exports.compatibilityParams = compatibilityParams; {
  71. var userAgent = navigator.userAgent || "";
  72. var platform = navigator.platform || "";
  73. var maxTouchPoints = navigator.maxTouchPoints || 1;
  74. var isAndroid = /Android/.test(userAgent);
  75. var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" &&
  76. maxTouchPoints > 1;
  77. (function checkCanvasSizeLimitation() {
  78. if (isIOS || isAndroid) {
  79. compatibilityParams.maxCanvasPixels = 5242880;
  80. }
  81. })();
  82. }
  83. var OptionKind = {
  84. VIEWER: 0x02,
  85. API: 0x04,
  86. WORKER: 0x08,
  87. PREFERENCE: 0x80
  88. };
  89. exports.OptionKind = OptionKind;
  90. var defaultOptions = {
  91. annotationMode: {
  92. value: 2,
  93. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  94. },
  95. cursorToolOnLoad: {
  96. value: 0,
  97. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  98. },
  99. defaultUrl: {
  100. value: "compressed.tracemonkey-pldi-09.pdf",
  101. kind: OptionKind.VIEWER
  102. },
  103. defaultZoomValue: {
  104. value: "",
  105. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  106. },
  107. disableHistory: {
  108. value: false,
  109. kind: OptionKind.VIEWER
  110. },
  111. disablePageLabels: {
  112. value: false,
  113. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  114. },
  115. enablePermissions: {
  116. value: false,
  117. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  118. },
  119. enablePrintAutoRotate: {
  120. value: true,
  121. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  122. },
  123. enableScripting: {
  124. value: true,
  125. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  126. },
  127. externalLinkRel: {
  128. value: "noopener noreferrer nofollow",
  129. kind: OptionKind.VIEWER
  130. },
  131. externalLinkTarget: {
  132. value: 0,
  133. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  134. },
  135. historyUpdateUrl: {
  136. value: false,
  137. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  138. },
  139. ignoreDestinationZoom: {
  140. value: false,
  141. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  142. },
  143. imageResourcesPath: {
  144. value: "./images/",
  145. kind: OptionKind.VIEWER
  146. },
  147. maxCanvasPixels: {
  148. value: 16777216,
  149. compatibility: compatibilityParams.maxCanvasPixels,
  150. kind: OptionKind.VIEWER
  151. },
  152. pdfBugEnabled: {
  153. value: false,
  154. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  155. },
  156. printResolution: {
  157. value: 150,
  158. kind: OptionKind.VIEWER
  159. },
  160. renderer: {
  161. value: "canvas",
  162. kind: OptionKind.VIEWER
  163. },
  164. sidebarViewOnLoad: {
  165. value: -1,
  166. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  167. },
  168. scrollModeOnLoad: {
  169. value: -1,
  170. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  171. },
  172. spreadModeOnLoad: {
  173. value: -1,
  174. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  175. },
  176. textLayerMode: {
  177. value: 1,
  178. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  179. },
  180. useOnlyCssZoom: {
  181. value: false,
  182. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  183. },
  184. viewerCssTheme: {
  185. value: 0,
  186. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  187. },
  188. viewOnLoad: {
  189. value: 0,
  190. kind: OptionKind.VIEWER + OptionKind.PREFERENCE
  191. },
  192. cMapPacked: {
  193. value: true,
  194. kind: OptionKind.API
  195. },
  196. cMapUrl: {
  197. value: "../web/cmaps/",
  198. kind: OptionKind.API
  199. },
  200. disableAutoFetch: {
  201. value: false,
  202. kind: OptionKind.API + OptionKind.PREFERENCE
  203. },
  204. disableFontFace: {
  205. value: false,
  206. kind: OptionKind.API + OptionKind.PREFERENCE
  207. },
  208. disableRange: {
  209. value: false,
  210. kind: OptionKind.API + OptionKind.PREFERENCE
  211. },
  212. disableStream: {
  213. value: false,
  214. kind: OptionKind.API + OptionKind.PREFERENCE
  215. },
  216. docBaseUrl: {
  217. value: "",
  218. kind: OptionKind.API
  219. },
  220. enableXfa: {
  221. value: true,
  222. kind: OptionKind.API + OptionKind.PREFERENCE
  223. },
  224. fontExtraProperties: {
  225. value: false,
  226. kind: OptionKind.API
  227. },
  228. isEvalSupported: {
  229. value: true,
  230. kind: OptionKind.API
  231. },
  232. maxImageSize: {
  233. value: -1,
  234. kind: OptionKind.API
  235. },
  236. pdfBug: {
  237. value: false,
  238. kind: OptionKind.API
  239. },
  240. standardFontDataUrl: {
  241. value: "../web/standard_fonts/",
  242. kind: OptionKind.API
  243. },
  244. verbosity: {
  245. value: 1,
  246. kind: OptionKind.API
  247. },
  248. workerPort: {
  249. value: null,
  250. kind: OptionKind.WORKER
  251. },
  252. workerSrc: {
  253. value: "../build/pdf.worker.js",
  254. kind: OptionKind.WORKER
  255. }
  256. }; {
  257. defaultOptions.disablePreferences = {
  258. value: false,
  259. kind: OptionKind.VIEWER
  260. };
  261. defaultOptions.locale = {
  262. value: navigator.language || "en-US",
  263. kind: OptionKind.VIEWER
  264. };
  265. defaultOptions.sandboxBundleSrc = {
  266. value: "../build/pdf.sandbox.js",
  267. kind: OptionKind.VIEWER
  268. };
  269. defaultOptions.renderer.kind += OptionKind.PREFERENCE;
  270. }
  271. var userOptions = Object.create(null);
  272. var AppOptions = /*#__PURE__*/ function() {
  273. function AppOptions() {
  274. _classCallCheck(this, AppOptions);
  275. throw new Error("Cannot initialize AppOptions.");
  276. }
  277. _createClass(AppOptions, null, [{
  278. key: "get",
  279. value: function get(name) {
  280. var userOption = userOptions[name];
  281. if (userOption !== undefined) {
  282. return userOption;
  283. }
  284. var defaultOption = defaultOptions[name];
  285. if (defaultOption !== undefined) {
  286. var _defaultOption$compat;
  287. return (_defaultOption$compat = defaultOption
  288. .compatibility) !== null &&
  289. _defaultOption$compat !== void 0 ?
  290. _defaultOption$compat : defaultOption.value;
  291. }
  292. return undefined;
  293. }
  294. }, {
  295. key: "getAll",
  296. value: function getAll() {
  297. var kind = arguments.length > 0 && arguments[0] !==
  298. undefined ? arguments[0] : null;
  299. var options = Object.create(null);
  300. for (var name in defaultOptions) {
  301. var _defaultOption$compat2;
  302. var defaultOption = defaultOptions[name];
  303. if (kind) {
  304. if ((kind & defaultOption.kind) === 0) {
  305. continue;
  306. }
  307. if (kind === OptionKind.PREFERENCE) {
  308. var value = defaultOption.value,
  309. valueType = _typeof(value);
  310. if (valueType === "boolean" || valueType ===
  311. "string" || valueType === "number" && Number
  312. .isInteger(value)) {
  313. options[name] = value;
  314. continue;
  315. }
  316. throw new Error("Invalid type for preference: "
  317. .concat(name));
  318. }
  319. }
  320. var userOption = userOptions[name];
  321. options[name] = userOption !== undefined ? userOption :
  322. (_defaultOption$compat2 = defaultOption
  323. .compatibility) !== null &&
  324. _defaultOption$compat2 !== void 0 ?
  325. _defaultOption$compat2 : defaultOption.value;
  326. }
  327. return options;
  328. }
  329. }, {
  330. key: "set",
  331. value: function set(name, value) {
  332. userOptions[name] = value;
  333. }
  334. }, {
  335. key: "setAll",
  336. value: function setAll(options) {
  337. for (var name in options) {
  338. userOptions[name] = options[name];
  339. }
  340. }
  341. }, {
  342. key: "remove",
  343. value: function remove(name) {
  344. delete userOptions[name];
  345. }
  346. }, {
  347. key: "_hasUserOptions",
  348. value: function _hasUserOptions() {
  349. return Object.keys(userOptions).length > 0;
  350. }
  351. }]);
  352. return AppOptions;
  353. }();
  354. exports.AppOptions = AppOptions;
  355. /***/
  356. }),
  357. /* 2 */
  358. /***/
  359. ((__unused_webpack_module, exports, __webpack_require__) => {
  360. Object.defineProperty(exports, "__esModule", ({
  361. value: true
  362. }));
  363. exports.PDFViewerApplication = exports.PDFPrintServiceFactory = exports
  364. .DefaultExternalServices = void 0;
  365. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  366. var _ui_utils = __webpack_require__(5);
  367. var _app_options = __webpack_require__(1);
  368. var _event_utils = __webpack_require__(6);
  369. var _pdfjsLib = __webpack_require__(7);
  370. var _pdf_cursor_tools = __webpack_require__(8);
  371. var _pdf_link_service = __webpack_require__(10);
  372. var _overlay_manager = __webpack_require__(11);
  373. var _password_prompt = __webpack_require__(12);
  374. var _pdf_attachment_viewer = __webpack_require__(13);
  375. var _pdf_document_properties = __webpack_require__(15);
  376. var _pdf_find_bar = __webpack_require__(16);
  377. var _pdf_find_controller = __webpack_require__(17);
  378. var _pdf_history = __webpack_require__(19);
  379. var _pdf_layer_viewer = __webpack_require__(20);
  380. var _pdf_outline_viewer = __webpack_require__(21);
  381. var _pdf_presentation_mode = __webpack_require__(22);
  382. var _pdf_rendering_queue = __webpack_require__(23);
  383. var _pdf_scripting_manager = __webpack_require__(24);
  384. var _pdf_sidebar = __webpack_require__(25);
  385. var _pdf_sidebar_resizer = __webpack_require__(26);
  386. var _pdf_thumbnail_viewer = __webpack_require__(27);
  387. var _pdf_viewer = __webpack_require__(29);
  388. var _secondary_toolbar = __webpack_require__(38);
  389. var _toolbar = __webpack_require__(39);
  390. var _view_history = __webpack_require__(40);
  391. function _interopRequireDefault(obj) {
  392. return obj && obj.__esModule ? obj : {
  393. "default": obj
  394. };
  395. }
  396. function ownKeys(object, enumerableOnly) {
  397. var keys = Object.keys(object);
  398. if (Object.getOwnPropertySymbols) {
  399. var symbols = Object.getOwnPropertySymbols(object);
  400. enumerableOnly && (symbols = symbols.filter(function(sym) {
  401. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  402. })), keys.push.apply(keys, symbols);
  403. }
  404. return keys;
  405. }
  406. function _objectSpread(target) {
  407. for (var i = 1; i < arguments.length; i++) {
  408. var source = null != arguments[i] ? arguments[i] : {};
  409. i % 2 ? ownKeys(Object(source), !0).forEach(function(key) {
  410. _defineProperty(target, key, source[key]);
  411. }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object
  412. .getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(
  413. function(key) {
  414. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(
  415. source, key));
  416. });
  417. }
  418. return target;
  419. }
  420. function _defineProperty(obj, key, value) {
  421. if (key in obj) {
  422. Object.defineProperty(obj, key, {
  423. value: value,
  424. enumerable: true,
  425. configurable: true,
  426. writable: true
  427. });
  428. } else {
  429. obj[key] = value;
  430. }
  431. return obj;
  432. }
  433. function _slicedToArray(arr, i) {
  434. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) ||
  435. _unsupportedIterableToArray(arr, i) || _nonIterableRest();
  436. }
  437. function _nonIterableRest() {
  438. throw new TypeError(
  439. "Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
  440. );
  441. }
  442. function _iterableToArrayLimit(arr, i) {
  443. var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] ||
  444. arr["@@iterator"];
  445. if (_i == null) return;
  446. var _arr = [];
  447. var _n = true;
  448. var _d = false;
  449. var _s, _e;
  450. try {
  451. for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
  452. _arr.push(_s.value);
  453. if (i && _arr.length === i) break;
  454. }
  455. } catch (err) {
  456. _d = true;
  457. _e = err;
  458. } finally {
  459. try {
  460. if (!_n && _i["return"] != null) _i["return"]();
  461. } finally {
  462. if (_d) throw _e;
  463. }
  464. }
  465. return _arr;
  466. }
  467. function _arrayWithHoles(arr) {
  468. if (Array.isArray(arr)) return arr;
  469. }
  470. function _createForOfIteratorHelper(o, allowArrayLike) {
  471. var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
  472. if (!it) {
  473. if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike &&
  474. o && typeof o.length === "number") {
  475. if (it) o = it;
  476. var i = 0;
  477. var F = function F() {};
  478. return {
  479. s: F,
  480. n: function n() {
  481. if (i >= o.length) return {
  482. done: true
  483. };
  484. return {
  485. done: false,
  486. value: o[i++]
  487. };
  488. },
  489. e: function e(_e2) {
  490. throw _e2;
  491. },
  492. f: F
  493. };
  494. }
  495. throw new TypeError(
  496. "Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
  497. );
  498. }
  499. var normalCompletion = true,
  500. didErr = false,
  501. err;
  502. return {
  503. s: function s() {
  504. it = it.call(o);
  505. },
  506. n: function n() {
  507. var step = it.next();
  508. normalCompletion = step.done;
  509. return step;
  510. },
  511. e: function e(_e3) {
  512. didErr = true;
  513. err = _e3;
  514. },
  515. f: function f() {
  516. try {
  517. if (!normalCompletion && it["return"] != null) it["return"]();
  518. } finally {
  519. if (didErr) throw err;
  520. }
  521. }
  522. };
  523. }
  524. function _unsupportedIterableToArray(o, minLen) {
  525. if (!o) return;
  526. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  527. var n = Object.prototype.toString.call(o).slice(8, -1);
  528. if (n === "Object" && o.constructor) n = o.constructor.name;
  529. if (n === "Map" || n === "Set") return Array.from(o);
  530. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
  531. return _arrayLikeToArray(o, minLen);
  532. }
  533. function _arrayLikeToArray(arr, len) {
  534. if (len == null || len > arr.length) len = arr.length;
  535. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  536. arr2[i] = arr[i];
  537. }
  538. return arr2;
  539. }
  540. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  541. try {
  542. var info = gen[key](arg);
  543. var value = info.value;
  544. } catch (error) {
  545. reject(error);
  546. return;
  547. }
  548. if (info.done) {
  549. resolve(value);
  550. } else {
  551. Promise.resolve(value).then(_next, _throw);
  552. }
  553. }
  554. function _asyncToGenerator(fn) {
  555. return function() {
  556. var self = this,
  557. args = arguments;
  558. return new Promise(function(resolve, reject) {
  559. var gen = fn.apply(self, args);
  560. function _next(value) {
  561. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next",
  562. value);
  563. }
  564. function _throw(err) {
  565. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw",
  566. err);
  567. }
  568. _next(undefined);
  569. });
  570. };
  571. }
  572. function _classCallCheck(instance, Constructor) {
  573. if (!(instance instanceof Constructor)) {
  574. throw new TypeError("Cannot call a class as a function");
  575. }
  576. }
  577. function _defineProperties(target, props) {
  578. for (var i = 0; i < props.length; i++) {
  579. var descriptor = props[i];
  580. descriptor.enumerable = descriptor.enumerable || false;
  581. descriptor.configurable = true;
  582. if ("value" in descriptor) descriptor.writable = true;
  583. Object.defineProperty(target, descriptor.key, descriptor);
  584. }
  585. }
  586. function _createClass(Constructor, protoProps, staticProps) {
  587. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  588. if (staticProps) _defineProperties(Constructor, staticProps);
  589. Object.defineProperty(Constructor, "prototype", {
  590. writable: false
  591. });
  592. return Constructor;
  593. }
  594. var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
  595. var FORCE_PAGES_LOADED_TIMEOUT = 10000;
  596. var WHEEL_ZOOM_DISABLED_TIMEOUT = 1000;
  597. var ViewOnLoad = {
  598. UNKNOWN: -1,
  599. PREVIOUS: 0,
  600. INITIAL: 1
  601. };
  602. var ViewerCssTheme = {
  603. AUTOMATIC: 0,
  604. LIGHT: 1,
  605. DARK: 2
  606. };
  607. var KNOWN_VERSIONS = ["1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9",
  608. "2.0", "2.1", "2.2", "2.3"
  609. ];
  610. var KNOWN_GENERATORS = ["acrobat distiller", "acrobat pdfwriter", "adobe livecycle",
  611. "adobe pdf library", "adobe photoshop", "ghostscript", "tcpdf", "cairo", "dvipdfm",
  612. "dvips", "pdftex", "pdfkit", "itext", "prince", "quarkxpress", "mac os x",
  613. "microsoft", "openoffice", "oracle", "luradocument", "pdf-xchange", "antenna house",
  614. "aspose.cells", "fpdf"
  615. ];
  616. var DefaultExternalServices = /*#__PURE__*/ function() {
  617. function DefaultExternalServices() {
  618. _classCallCheck(this, DefaultExternalServices);
  619. throw new Error("Cannot initialize DefaultExternalServices.");
  620. }
  621. _createClass(DefaultExternalServices, null, [{
  622. key: "updateFindControlState",
  623. value: function updateFindControlState(data) {}
  624. }, {
  625. key: "updateFindMatchesCount",
  626. value: function updateFindMatchesCount(data) {}
  627. }, {
  628. key: "initPassiveLoading",
  629. value: function initPassiveLoading(callbacks) {}
  630. }, {
  631. key: "fallback",
  632. value: function() {
  633. var _fallback = _asyncToGenerator( /*#__PURE__*/
  634. _regenerator["default"].mark(function _callee(
  635. data) {
  636. return _regenerator["default"].wrap(
  637. function _callee$(_context) {
  638. while (1) {
  639. switch (_context.prev =
  640. _context.next) {
  641. case 0:
  642. case "end":
  643. return _context
  644. .stop();
  645. }
  646. }
  647. }, _callee);
  648. }));
  649. function fallback(_x) {
  650. return _fallback.apply(this, arguments);
  651. }
  652. return fallback;
  653. }()
  654. }, {
  655. key: "reportTelemetry",
  656. value: function reportTelemetry(data) {}
  657. }, {
  658. key: "createDownloadManager",
  659. value: function createDownloadManager(options) {
  660. throw new Error("Not implemented: createDownloadManager");
  661. }
  662. }, {
  663. key: "createPreferences",
  664. value: function createPreferences() {
  665. throw new Error("Not implemented: createPreferences");
  666. }
  667. }, {
  668. key: "createL10n",
  669. value: function createL10n(options) {
  670. throw new Error("Not implemented: createL10n");
  671. }
  672. }, {
  673. key: "createScripting",
  674. value: function createScripting(options) {
  675. throw new Error("Not implemented: createScripting");
  676. }
  677. }, {
  678. key: "supportsIntegratedFind",
  679. get: function get() {
  680. return (0, _pdfjsLib.shadow)(this, "supportsIntegratedFind",
  681. false);
  682. }
  683. }, {
  684. key: "supportsDocumentFonts",
  685. get: function get() {
  686. return (0, _pdfjsLib.shadow)(this, "supportsDocumentFonts",
  687. true);
  688. }
  689. }, {
  690. key: "supportedMouseWheelZoomModifierKeys",
  691. get: function get() {
  692. return (0, _pdfjsLib.shadow)(this,
  693. "supportedMouseWheelZoomModifierKeys", {
  694. ctrlKey: true,
  695. metaKey: true
  696. });
  697. }
  698. }, {
  699. key: "isInAutomation",
  700. get: function get() {
  701. return (0, _pdfjsLib.shadow)(this, "isInAutomation", false);
  702. }
  703. }]);
  704. return DefaultExternalServices;
  705. }();
  706. exports.DefaultExternalServices = DefaultExternalServices;
  707. var PDFViewerApplication = {
  708. initialBookmark: document.location.hash.substring(1),
  709. _initializedCapability: (0, _pdfjsLib.createPromiseCapability)(),
  710. _fellback: false,
  711. appConfig: null,
  712. pdfDocument: null,
  713. pdfLoadingTask: null,
  714. printService: null,
  715. pdfViewer: null,
  716. pdfThumbnailViewer: null,
  717. pdfRenderingQueue: null,
  718. pdfPresentationMode: null,
  719. pdfDocumentProperties: null,
  720. pdfLinkService: null,
  721. pdfHistory: null,
  722. pdfSidebar: null,
  723. pdfSidebarResizer: null,
  724. pdfOutlineViewer: null,
  725. pdfAttachmentViewer: null,
  726. pdfLayerViewer: null,
  727. pdfCursorTools: null,
  728. pdfScriptingManager: null,
  729. store: null,
  730. downloadManager: null,
  731. overlayManager: null,
  732. preferences: null,
  733. toolbar: null,
  734. secondaryToolbar: null,
  735. eventBus: null,
  736. l10n: null,
  737. isInitialViewSet: false,
  738. downloadComplete: false,
  739. isViewerEmbedded: window.parent !== window,
  740. url: "",
  741. baseUrl: "",
  742. _downloadUrl: "",
  743. externalServices: DefaultExternalServices,
  744. _boundEvents: Object.create(null),
  745. documentInfo: null,
  746. metadata: null,
  747. _contentDispositionFilename: null,
  748. _contentLength: null,
  749. _saveInProgress: false,
  750. _docStats: null,
  751. _wheelUnusedTicks: 0,
  752. _idleCallbacks: new Set(),
  753. initialize: function initialize(appConfig) {
  754. var _this = this;
  755. return _asyncToGenerator( /*#__PURE__*/ _regenerator["default"].mark(
  756. function _callee2() {
  757. var appContainer;
  758. return _regenerator["default"].wrap(function _callee2$(
  759. _context2) {
  760. while (1) {
  761. switch (_context2.prev = _context2.next) {
  762. case 0:
  763. _this.preferences = _this
  764. .externalServices
  765. .createPreferences();
  766. _this.appConfig = appConfig;
  767. _context2.next = 4;
  768. return _this._readPreferences();
  769. case 4:
  770. _context2.next = 6;
  771. return _this._parseHashParameters();
  772. case 6:
  773. _this._forceCssTheme();
  774. _context2.next = 9;
  775. return _this._initializeL10n();
  776. case 9:
  777. if (_this.isViewerEmbedded &&
  778. _app_options.AppOptions.get(
  779. "externalLinkTarget") ===
  780. _pdf_link_service.LinkTarget
  781. .NONE) {
  782. _app_options.AppOptions.set(
  783. "externalLinkTarget",
  784. _pdf_link_service
  785. .LinkTarget.TOP);
  786. }
  787. _context2.next = 12;
  788. return _this
  789. ._initializeViewerComponents();
  790. case 12:
  791. _this.bindEvents();
  792. _this.bindWindowEvents();
  793. appContainer = appConfig
  794. .appContainer || document
  795. .documentElement;
  796. _this.l10n.translate(appContainer)
  797. .then(function() {
  798. _this.eventBus.dispatch(
  799. "localized", {
  800. source: _this
  801. });
  802. });
  803. _this._initializedCapability
  804. .resolve();
  805. case 17:
  806. case "end":
  807. return _context2.stop();
  808. }
  809. }
  810. }, _callee2);
  811. }))();
  812. },
  813. _readPreferences: function _readPreferences() {
  814. var _this2 = this;
  815. return _asyncToGenerator( /*#__PURE__*/ _regenerator["default"].mark(
  816. function _callee3() {
  817. return _regenerator["default"].wrap(function _callee3$(
  818. _context3) {
  819. while (1) {
  820. switch (_context3.prev = _context3.next) {
  821. case 0:
  822. if (!_app_options.AppOptions.get(
  823. "disablePreferences")) {
  824. _context3.next = 2;
  825. break;
  826. }
  827. return _context3.abrupt("return");
  828. case 2:
  829. if (_app_options.AppOptions
  830. ._hasUserOptions()) {
  831. console.warn(
  832. "_readPreferences: The Preferences may override manually set AppOptions; " +
  833. 'please use the "disablePreferences"-option in order to prevent that.'
  834. );
  835. }
  836. _context3.prev = 3;
  837. _context3.t0 = _app_options
  838. .AppOptions;
  839. _context3.next = 7;
  840. return _this2.preferences.getAll();
  841. case 7:
  842. _context3.t1 = _context3.sent;
  843. _context3.t0.setAll.call(_context3
  844. .t0, _context3.t1);
  845. _context3.next = 14;
  846. break;
  847. case 11:
  848. _context3.prev = 11;
  849. _context3.t2 = _context3["catch"](
  850. 3);
  851. console.error("_readPreferences: \""
  852. .concat(_context3.t2 ===
  853. null || _context3.t2 ===
  854. void 0 ? void 0 :
  855. _context3.t2.message,
  856. "\"."));
  857. case 14:
  858. case "end":
  859. return _context3.stop();
  860. }
  861. }
  862. }, _callee3, null, [
  863. [3, 11]
  864. ]);
  865. }))();
  866. },
  867. _parseHashParameters: function _parseHashParameters() {
  868. var _this3 = this;
  869. return _asyncToGenerator( /*#__PURE__*/ _regenerator["default"].mark(
  870. function _callee4() {
  871. var hash, params, waitOn, viewer, enabled;
  872. return _regenerator["default"].wrap(function _callee4$(
  873. _context4) {
  874. while (1) {
  875. switch (_context4.prev = _context4.next) {
  876. case 0:
  877. if (_app_options.AppOptions.get(
  878. "pdfBugEnabled")) {
  879. _context4.next = 2;
  880. break;
  881. }
  882. return _context4.abrupt("return");
  883. case 2:
  884. hash = document.location.hash
  885. .substring(1);
  886. if (hash) {
  887. _context4.next = 5;
  888. break;
  889. }
  890. return _context4.abrupt("return");
  891. case 5:
  892. params = (0, _ui_utils
  893. .parseQueryString)(hash),
  894. waitOn = [];
  895. if (params.get("disableworker") ===
  896. "true") {
  897. waitOn.push(loadFakeWorker());
  898. }
  899. if (params.has("disablerange")) {
  900. _app_options.AppOptions.set(
  901. "disableRange", params
  902. .get("disablerange") ===
  903. "true");
  904. }
  905. if (params.has("disablestream")) {
  906. _app_options.AppOptions.set(
  907. "disableStream", params
  908. .get(
  909. "disablestream") ===
  910. "true");
  911. }
  912. if (params.has(
  913. "disableautofetch")) {
  914. _app_options.AppOptions.set(
  915. "disableAutoFetch",
  916. params.get(
  917. "disableautofetch"
  918. ) === "true");
  919. }
  920. if (params.has("disablefontface")) {
  921. _app_options.AppOptions.set(
  922. "disableFontFace",
  923. params.get(
  924. "disablefontface"
  925. ) === "true");
  926. }
  927. if (params.has("disablehistory")) {
  928. _app_options.AppOptions.set(
  929. "disableHistory", params
  930. .get(
  931. "disablehistory") ===
  932. "true");
  933. }
  934. if (params.has("verbosity")) {
  935. _app_options.AppOptions.set(
  936. "verbosity", params.get(
  937. "verbosity") | 0);
  938. }
  939. if (!params.has("textlayer")) {
  940. _context4.next = 22;
  941. break;
  942. }
  943. _context4.t0 = params.get(
  944. "textlayer");
  945. _context4.next = _context4.t0 ===
  946. "off" ? 17 : _context4.t0 ===
  947. "visible" ? 19 : _context4
  948. .t0 === "shadow" ? 19 :
  949. _context4.t0 === "hover" ? 19 :
  950. 22;
  951. break;
  952. case 17:
  953. _app_options.AppOptions.set(
  954. "textLayerMode", _ui_utils
  955. .TextLayerMode.DISABLE);
  956. return _context4.abrupt("break",
  957. 22);
  958. case 19:
  959. viewer = _this3.appConfig
  960. .viewerContainer;
  961. viewer.classList.add("textLayer-"
  962. .concat(params.get(
  963. "textlayer")));
  964. return _context4.abrupt("break",
  965. 22);
  966. case 22:
  967. if (params.has("pdfbug")) {
  968. _app_options.AppOptions.set(
  969. "pdfBug", true);
  970. _app_options.AppOptions.set(
  971. "fontExtraProperties",
  972. true);
  973. enabled = params.get("pdfbug")
  974. .split(",");
  975. waitOn.push(initPDFBug(
  976. enabled));
  977. }
  978. if (params.has("locale")) {
  979. _app_options.AppOptions.set(
  980. "locale", params.get(
  981. "locale"));
  982. }
  983. if (!(waitOn.length === 0)) {
  984. _context4.next = 26;
  985. break;
  986. }
  987. return _context4.abrupt("return");
  988. case 26:
  989. _context4.prev = 26;
  990. _context4.next = 29;
  991. return Promise.all(waitOn);
  992. case 29:
  993. _context4.next = 34;
  994. break;
  995. case 31:
  996. _context4.prev = 31;
  997. _context4.t1 = _context4["catch"](
  998. 26);
  999. console.error(
  1000. "_parseHashParameters: \""
  1001. .concat(_context4.t1
  1002. .message, "\"."));
  1003. case 34:
  1004. case "end":
  1005. return _context4.stop();
  1006. }
  1007. }
  1008. }, _callee4, null, [
  1009. [26, 31]
  1010. ]);
  1011. }))();
  1012. },
  1013. _initializeL10n: function _initializeL10n() {
  1014. var _this4 = this;
  1015. return _asyncToGenerator( /*#__PURE__*/ _regenerator["default"].mark(
  1016. function _callee5() {
  1017. var dir;
  1018. return _regenerator["default"].wrap(function _callee5$(
  1019. _context5) {
  1020. while (1) {
  1021. switch (_context5.prev = _context5.next) {
  1022. case 0:
  1023. _this4.l10n = _this4
  1024. .externalServices.createL10n({
  1025. locale: _app_options
  1026. .AppOptions.get(
  1027. "locale")
  1028. });
  1029. _context5.next = 3;
  1030. return _this4.l10n.getDirection();
  1031. case 3:
  1032. dir = _context5.sent;
  1033. document.getElementsByTagName(
  1034. "html")[0].dir = dir;
  1035. case 5:
  1036. case "end":
  1037. return _context5.stop();
  1038. }
  1039. }
  1040. }, _callee5);
  1041. }))();
  1042. },
  1043. _forceCssTheme: function _forceCssTheme() {
  1044. var cssTheme = _app_options.AppOptions.get("viewerCssTheme");
  1045. if (cssTheme === ViewerCssTheme.AUTOMATIC || !Object.values(ViewerCssTheme)
  1046. .includes(cssTheme)) {
  1047. return;
  1048. }
  1049. try {
  1050. var styleSheet = document.styleSheets[0];
  1051. var cssRules = (styleSheet === null || styleSheet === void 0 ? void 0 :
  1052. styleSheet.cssRules) || [];
  1053. for (var i = 0, ii = cssRules.length; i < ii; i++) {
  1054. var _rule$media;
  1055. var rule = cssRules[i];
  1056. if (rule instanceof CSSMediaRule && ((_rule$media = rule.media) ===
  1057. null || _rule$media === void 0 ? void 0 : _rule$media[0]
  1058. ) === "(prefers-color-scheme: dark)") {
  1059. if (cssTheme === ViewerCssTheme.LIGHT) {
  1060. styleSheet.deleteRule(i);
  1061. return;
  1062. }
  1063. var darkRules =
  1064. /^@media \(prefers-color-scheme: dark\) {\n\s*([\w\s-.,:;/\\{}()]+)\n}$/
  1065. .exec(rule.cssText);
  1066. if (darkRules !== null && darkRules !== void 0 && darkRules[
  1067. 1]) {
  1068. styleSheet.deleteRule(i);
  1069. styleSheet.insertRule(darkRules[1], i);
  1070. }
  1071. return;
  1072. }
  1073. }
  1074. } catch (reason) {
  1075. console.error("_forceCssTheme: \"".concat(reason === null || reason ===
  1076. void 0 ? void 0 : reason.message, "\"."));
  1077. }
  1078. },
  1079. _initializeViewerComponents: function _initializeViewerComponents() {
  1080. var _this5 = this;
  1081. return _asyncToGenerator( /*#__PURE__*/ _regenerator["default"].mark(
  1082. function _callee6() {
  1083. var appConfig, externalServices, eventBus,
  1084. pdfRenderingQueue, pdfLinkService, downloadManager,
  1085. findController, pdfScriptingManager, container, viewer;
  1086. return _regenerator["default"].wrap(function _callee6$(
  1087. _context6) {
  1088. while (1) {
  1089. switch (_context6.prev = _context6.next) {
  1090. case 0:
  1091. appConfig = _this5.appConfig,
  1092. externalServices = _this5
  1093. .externalServices;
  1094. eventBus = externalServices
  1095. .isInAutomation ?
  1096. new _event_utils
  1097. .AutomationEventBus() :
  1098. new _event_utils.EventBus();
  1099. _this5.eventBus = eventBus;
  1100. _this5.overlayManager =
  1101. new _overlay_manager
  1102. .OverlayManager();
  1103. pdfRenderingQueue =
  1104. new _pdf_rendering_queue
  1105. .PDFRenderingQueue();
  1106. pdfRenderingQueue.onIdle = _this5
  1107. ._cleanup.bind(_this5);
  1108. _this5.pdfRenderingQueue =
  1109. pdfRenderingQueue;
  1110. pdfLinkService =
  1111. new _pdf_link_service
  1112. .PDFLinkService({
  1113. eventBus: eventBus,
  1114. externalLinkTarget: _app_options
  1115. .AppOptions.get(
  1116. "externalLinkTarget"
  1117. ),
  1118. externalLinkRel: _app_options
  1119. .AppOptions.get(
  1120. "externalLinkRel"
  1121. ),
  1122. ignoreDestinationZoom: _app_options
  1123. .AppOptions.get(
  1124. "ignoreDestinationZoom"
  1125. )
  1126. });
  1127. _this5.pdfLinkService =
  1128. pdfLinkService;
  1129. downloadManager = externalServices
  1130. .createDownloadManager();
  1131. _this5.downloadManager =
  1132. downloadManager;
  1133. findController =
  1134. new _pdf_find_controller
  1135. .PDFFindController({
  1136. linkService: pdfLinkService,
  1137. eventBus: eventBus
  1138. });
  1139. _this5.findController =
  1140. findController;
  1141. pdfScriptingManager =
  1142. new _pdf_scripting_manager
  1143. .PDFScriptingManager({
  1144. eventBus: eventBus,
  1145. sandboxBundleSrc: _app_options
  1146. .AppOptions.get(
  1147. "sandboxBundleSrc"
  1148. ),
  1149. scriptingFactory: externalServices,
  1150. docPropertiesLookup: _this5
  1151. ._scriptingDocProperties
  1152. .bind(_this5)
  1153. });
  1154. _this5.pdfScriptingManager =
  1155. pdfScriptingManager;
  1156. container = appConfig.mainContainer;
  1157. viewer = appConfig.viewerContainer;
  1158. _this5.pdfViewer = new _pdf_viewer
  1159. .PDFViewer({
  1160. container: container,
  1161. viewer: viewer,
  1162. eventBus: eventBus,
  1163. renderingQueue: pdfRenderingQueue,
  1164. linkService: pdfLinkService,
  1165. downloadManager: downloadManager,
  1166. findController: findController,
  1167. scriptingManager: _app_options
  1168. .AppOptions.get(
  1169. "enableScripting"
  1170. ) &&
  1171. pdfScriptingManager,
  1172. renderer: _app_options
  1173. .AppOptions.get(
  1174. "renderer"),
  1175. l10n: _this5.l10n,
  1176. textLayerMode: _app_options
  1177. .AppOptions.get(
  1178. "textLayerMode"
  1179. ),
  1180. annotationMode: _app_options
  1181. .AppOptions.get(
  1182. "annotationMode"
  1183. ),
  1184. imageResourcesPath: _app_options
  1185. .AppOptions.get(
  1186. "imageResourcesPath"
  1187. ),
  1188. enablePrintAutoRotate: _app_options
  1189. .AppOptions.get(
  1190. "enablePrintAutoRotate"
  1191. ),
  1192. useOnlyCssZoom: _app_options
  1193. .AppOptions.get(
  1194. "useOnlyCssZoom"
  1195. ),
  1196. maxCanvasPixels: _app_options
  1197. .AppOptions.get(
  1198. "maxCanvasPixels"
  1199. ),
  1200. enablePermissions: _app_options
  1201. .AppOptions.get(
  1202. "enablePermissions"
  1203. )
  1204. });
  1205. pdfRenderingQueue.setViewer(_this5
  1206. .pdfViewer);
  1207. pdfLinkService.setViewer(_this5
  1208. .pdfViewer);
  1209. pdfScriptingManager.setViewer(_this5
  1210. .pdfViewer);
  1211. _this5.pdfThumbnailViewer =
  1212. new _pdf_thumbnail_viewer
  1213. .PDFThumbnailViewer({
  1214. container: appConfig
  1215. .sidebar
  1216. .thumbnailView,
  1217. eventBus: eventBus,
  1218. renderingQueue: pdfRenderingQueue,
  1219. linkService: pdfLinkService,
  1220. l10n: _this5.l10n
  1221. });
  1222. pdfRenderingQueue
  1223. .setThumbnailViewer(_this5
  1224. .pdfThumbnailViewer);
  1225. if (!_this5.isViewerEmbedded && !
  1226. _app_options.AppOptions.get(
  1227. "disableHistory")) {
  1228. _this5.pdfHistory =
  1229. new _pdf_history
  1230. .PDFHistory({
  1231. linkService: pdfLinkService,
  1232. eventBus: eventBus
  1233. });
  1234. pdfLinkService.setHistory(_this5
  1235. .pdfHistory);
  1236. }
  1237. if (!_this5
  1238. .supportsIntegratedFind) {
  1239. _this5.findBar =
  1240. new _pdf_find_bar
  1241. .PDFFindBar(appConfig
  1242. .findBar, eventBus,
  1243. _this5.l10n);
  1244. }
  1245. _this5.pdfDocumentProperties =
  1246. new _pdf_document_properties
  1247. .PDFDocumentProperties(appConfig
  1248. .documentProperties, _this5
  1249. .overlayManager, eventBus,
  1250. _this5.l10n);
  1251. _this5.pdfCursorTools =
  1252. new _pdf_cursor_tools
  1253. .PDFCursorTools({
  1254. container: container,
  1255. eventBus: eventBus,
  1256. cursorToolOnLoad: _app_options
  1257. .AppOptions.get(
  1258. "cursorToolOnLoad"
  1259. )
  1260. });
  1261. _this5.toolbar = new _toolbar
  1262. .Toolbar(appConfig.toolbar,
  1263. eventBus, _this5.l10n);
  1264. _this5.secondaryToolbar =
  1265. new _secondary_toolbar
  1266. .SecondaryToolbar(appConfig
  1267. .secondaryToolbar,
  1268. container, eventBus);
  1269. if (_this5.supportsFullscreen) {
  1270. _this5.pdfPresentationMode =
  1271. new _pdf_presentation_mode
  1272. .PDFPresentationMode({
  1273. container: container,
  1274. pdfViewer: _this5
  1275. .pdfViewer,
  1276. eventBus: eventBus
  1277. });
  1278. }
  1279. _this5.passwordPrompt =
  1280. new _password_prompt
  1281. .PasswordPrompt(appConfig
  1282. .passwordOverlay, _this5
  1283. .overlayManager, _this5
  1284. .l10n, _this5
  1285. .isViewerEmbedded);
  1286. _this5.pdfOutlineViewer =
  1287. new _pdf_outline_viewer
  1288. .PDFOutlineViewer({
  1289. container: appConfig
  1290. .sidebar
  1291. .outlineView,
  1292. eventBus: eventBus,
  1293. linkService: pdfLinkService
  1294. });
  1295. _this5.pdfAttachmentViewer =
  1296. new _pdf_attachment_viewer
  1297. .PDFAttachmentViewer({
  1298. container: appConfig
  1299. .sidebar
  1300. .attachmentsView,
  1301. eventBus: eventBus,
  1302. downloadManager: downloadManager
  1303. });
  1304. _this5.pdfLayerViewer =
  1305. new _pdf_layer_viewer
  1306. .PDFLayerViewer({
  1307. container: appConfig
  1308. .sidebar.layersView,
  1309. eventBus: eventBus,
  1310. l10n: _this5.l10n
  1311. });
  1312. _this5.pdfSidebar = new _pdf_sidebar
  1313. .PDFSidebar({
  1314. elements: appConfig
  1315. .sidebar,
  1316. pdfViewer: _this5
  1317. .pdfViewer,
  1318. pdfThumbnailViewer: _this5
  1319. .pdfThumbnailViewer,
  1320. eventBus: eventBus,
  1321. l10n: _this5.l10n
  1322. });
  1323. _this5.pdfSidebar.onToggled = _this5
  1324. .forceRendering.bind(_this5);
  1325. _this5.pdfSidebarResizer =
  1326. new _pdf_sidebar_resizer
  1327. .PDFSidebarResizer(appConfig
  1328. .sidebarResizer, eventBus,
  1329. _this5.l10n);
  1330. case 37:
  1331. case "end":
  1332. return _context6.stop();
  1333. }
  1334. }
  1335. }, _callee6);
  1336. }))();
  1337. },
  1338. run: function run(config) {
  1339. this.initialize(config).then(webViewerInitialized);
  1340. },
  1341. get initialized() {
  1342. return this._initializedCapability.settled;
  1343. },
  1344. get initializedPromise() {
  1345. return this._initializedCapability.promise;
  1346. },
  1347. zoomIn: function zoomIn(steps) {
  1348. if (this.pdfViewer.isInPresentationMode) {
  1349. return;
  1350. }
  1351. this.pdfViewer.increaseScale(steps);
  1352. },
  1353. zoomOut: function zoomOut(steps) {
  1354. if (this.pdfViewer.isInPresentationMode) {
  1355. return;
  1356. }
  1357. this.pdfViewer.decreaseScale(steps);
  1358. },
  1359. zoomReset: function zoomReset() {
  1360. if (this.pdfViewer.isInPresentationMode) {
  1361. return;
  1362. }
  1363. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  1364. },
  1365. get pagesCount() {
  1366. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  1367. },
  1368. get page() {
  1369. return this.pdfViewer.currentPageNumber;
  1370. },
  1371. set page(val) {
  1372. this.pdfViewer.currentPageNumber = val;
  1373. },
  1374. get supportsPrinting() {
  1375. return PDFPrintServiceFactory.instance.supportsPrinting;
  1376. },
  1377. get supportsFullscreen() {
  1378. return (0, _pdfjsLib.shadow)(this, "supportsFullscreen", document
  1379. .fullscreenEnabled);
  1380. },
  1381. get supportsIntegratedFind() {
  1382. return this.externalServices.supportsIntegratedFind;
  1383. },
  1384. get supportsDocumentFonts() {
  1385. return this.externalServices.supportsDocumentFonts;
  1386. },
  1387. get loadingBar() {
  1388. var bar = new _ui_utils.ProgressBar("#loadingBar");
  1389. return (0, _pdfjsLib.shadow)(this, "loadingBar", bar);
  1390. },
  1391. get supportedMouseWheelZoomModifierKeys() {
  1392. return this.externalServices.supportedMouseWheelZoomModifierKeys;
  1393. },
  1394. initPassiveLoading: function initPassiveLoading() {
  1395. throw new Error("Not implemented: initPassiveLoading");
  1396. },
  1397. setTitleUsingUrl: function setTitleUsingUrl() {
  1398. var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[
  1399. 0] : "";
  1400. var downloadUrl = arguments.length > 1 && arguments[1] !== undefined ?
  1401. arguments[1] : null;
  1402. this.url = url;
  1403. this.baseUrl = url.split("#")[0];
  1404. if (downloadUrl) {
  1405. this._downloadUrl = downloadUrl === url ? this.baseUrl : downloadUrl
  1406. .split("#")[0];
  1407. }
  1408. var title = (0, _pdfjsLib.getPdfFilenameFromUrl)(url, "");
  1409. if (!title) {
  1410. try {
  1411. title = decodeURIComponent((0, _pdfjsLib.getFilenameFromUrl)(
  1412. url)) || url;
  1413. } catch (ex) {
  1414. title = url;
  1415. }
  1416. }
  1417. this.setTitle(title);
  1418. },
  1419. setTitle: function setTitle(title) {
  1420. if (this.isViewerEmbedded) {
  1421. return;
  1422. }
  1423. document.title = title;
  1424. },
  1425. get _docFilename() {
  1426. return this._contentDispositionFilename || (0, _pdfjsLib
  1427. .getPdfFilenameFromUrl)(this.url);
  1428. },
  1429. _hideViewBookmark: function _hideViewBookmark() {
  1430. var _this$appConfig = this.appConfig,
  1431. toolbar = _this$appConfig.toolbar,
  1432. secondaryToolbar = _this$appConfig.secondaryToolbar;
  1433. toolbar.viewBookmark.hidden = true;
  1434. secondaryToolbar.viewBookmarkButton.hidden = true;
  1435. },
  1436. _cancelIdleCallbacks: function _cancelIdleCallbacks() {
  1437. if (!this._idleCallbacks.size) {
  1438. return;
  1439. }
  1440. var _iterator = _createForOfIteratorHelper(this._idleCallbacks),
  1441. _step;
  1442. try {
  1443. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  1444. var callback = _step.value;
  1445. window.cancelIdleCallback(callback);
  1446. }
  1447. } catch (err) {
  1448. _iterator.e(err);
  1449. } finally {
  1450. _iterator.f();
  1451. }
  1452. this._idleCallbacks.clear();
  1453. },
  1454. close: function close() {
  1455. var _this6 = this;
  1456. return _asyncToGenerator( /*#__PURE__*/ _regenerator["default"].mark(
  1457. function _callee7() {
  1458. var _this6$pdfDocument, _this6$pdfHistory, _this6$findBar;
  1459. var container, promises;
  1460. return _regenerator["default"].wrap(function _callee7$(
  1461. _context7) {
  1462. while (1) {
  1463. switch (_context7.prev = _context7.next) {
  1464. case 0:
  1465. _this6._unblockDocumentLoadEvent();
  1466. _this6._hideViewBookmark();
  1467. container = _this6.appConfig
  1468. .errorWrapper.container;
  1469. container.hidden = true;
  1470. if (_this6.pdfLoadingTask) {
  1471. _context7.next = 6;
  1472. break;
  1473. }
  1474. return _context7.abrupt("return");
  1475. case 6:
  1476. if (!(((_this6$pdfDocument = _this6
  1477. .pdfDocument) ===
  1478. null ||
  1479. _this6$pdfDocument ===
  1480. void 0 ? void 0 :
  1481. _this6$pdfDocument
  1482. .annotationStorage.size
  1483. ) > 0 && _this6
  1484. ._annotationStorageModified
  1485. )) {
  1486. _context7.next = 14;
  1487. break;
  1488. }
  1489. _context7.prev = 7;
  1490. _context7.next = 10;
  1491. return _this6.save({
  1492. sourceEventType: "save"
  1493. });
  1494. case 10:
  1495. _context7.next = 14;
  1496. break;
  1497. case 12:
  1498. _context7.prev = 12;
  1499. _context7.t0 = _context7["catch"](
  1500. 7);
  1501. case 14:
  1502. promises = [];
  1503. promises.push(_this6.pdfLoadingTask
  1504. .destroy());
  1505. _this6.pdfLoadingTask = null;
  1506. if (_this6.pdfDocument) {
  1507. _this6.pdfDocument = null;
  1508. _this6.pdfThumbnailViewer
  1509. .setDocument(null);
  1510. _this6.pdfViewer.setDocument(
  1511. null);
  1512. _this6.pdfLinkService
  1513. .setDocument(null);
  1514. _this6.pdfDocumentProperties
  1515. .setDocument(null);
  1516. }
  1517. _this6.pdfLinkService
  1518. .externalLinkEnabled = true;
  1519. _this6._fellback = false;
  1520. _this6.store = null;
  1521. _this6.isInitialViewSet = false;
  1522. _this6.downloadComplete = false;
  1523. _this6.url = "";
  1524. _this6.baseUrl = "";
  1525. _this6._downloadUrl = "";
  1526. _this6.documentInfo = null;
  1527. _this6.metadata = null;
  1528. _this6._contentDispositionFilename =
  1529. null;
  1530. _this6._contentLength = null;
  1531. _this6._saveInProgress = false;
  1532. _this6._docStats = null;
  1533. _this6._cancelIdleCallbacks();
  1534. promises.push(_this6
  1535. .pdfScriptingManager
  1536. .destroyPromise);
  1537. _this6.pdfSidebar.reset();
  1538. _this6.pdfOutlineViewer.reset();
  1539. _this6.pdfAttachmentViewer.reset();
  1540. _this6.pdfLayerViewer.reset();
  1541. (_this6$pdfHistory = _this6
  1542. .pdfHistory) === null ||
  1543. _this6$pdfHistory === void 0 ?
  1544. void 0 : _this6$pdfHistory
  1545. .reset();
  1546. (_this6$findBar = _this6
  1547. .findBar) === null ||
  1548. _this6$findBar === void 0 ?
  1549. void 0 : _this6$findBar.reset();
  1550. _this6.toolbar.reset();
  1551. _this6.secondaryToolbar.reset();
  1552. if (typeof PDFBug !== "undefined") {
  1553. PDFBug.cleanup();
  1554. }
  1555. _context7.next = 45;
  1556. return Promise.all(promises);
  1557. case 45:
  1558. case "end":
  1559. return _context7.stop();
  1560. }
  1561. }
  1562. }, _callee7, null, [
  1563. [7, 12]
  1564. ]);
  1565. }))();
  1566. },
  1567. open: function open(file, args) {
  1568. var _this7 = this;
  1569. return _asyncToGenerator( /*#__PURE__*/ _regenerator["default"].mark(
  1570. function _callee8() {
  1571. var workerParameters, key, parameters, apiParameters, _key,
  1572. value, _key2, loadingTask;
  1573. return _regenerator["default"].wrap(function _callee8$(
  1574. _context8) {
  1575. while (1) {
  1576. switch (_context8.prev = _context8.next) {
  1577. case 0:
  1578. if (!_this7.pdfLoadingTask) {
  1579. _context8.next = 3;
  1580. break;
  1581. }
  1582. _context8.next = 3;
  1583. return _this7.close();
  1584. case 3:
  1585. workerParameters = _app_options
  1586. .AppOptions.getAll(_app_options
  1587. .OptionKind.WORKER);
  1588. for (key in workerParameters) {
  1589. _pdfjsLib.GlobalWorkerOptions[
  1590. key] = workerParameters[
  1591. key];
  1592. }
  1593. parameters = Object.create(null);
  1594. if (typeof file === "string") {
  1595. _this7.setTitleUsingUrl(file,
  1596. file);
  1597. parameters.url = file;
  1598. } else if (file && "byteLength" in
  1599. file) {
  1600. parameters.data = file;
  1601. } else if (file.url && file
  1602. .originalUrl) {
  1603. _this7.setTitleUsingUrl(file
  1604. .originalUrl, file.url);
  1605. parameters.url = file.url;
  1606. }
  1607. apiParameters = _app_options
  1608. .AppOptions.getAll(_app_options
  1609. .OptionKind.API);
  1610. for (_key in apiParameters) {
  1611. value = apiParameters[_key];
  1612. if (_key === "docBaseUrl" && !
  1613. value) {}
  1614. parameters[_key] = value;
  1615. }
  1616. if (args) {
  1617. for (_key2 in args) {
  1618. parameters[_key2] = args[
  1619. _key2];
  1620. }
  1621. }
  1622. loadingTask = (0, _pdfjsLib
  1623. .getDocument)(parameters);
  1624. _this7.pdfLoadingTask = loadingTask;
  1625. loadingTask.onPassword = function(
  1626. updateCallback, reason) {
  1627. _this7.pdfLinkService
  1628. .externalLinkEnabled =
  1629. false;
  1630. _this7.passwordPrompt
  1631. .setUpdateCallback(
  1632. updateCallback,
  1633. reason);
  1634. _this7.passwordPrompt
  1635. .open();
  1636. };
  1637. loadingTask.onProgress = function(
  1638. _ref) {
  1639. var loaded = _ref.loaded,
  1640. total = _ref.total;
  1641. _this7.progress(loaded /
  1642. total);
  1643. };
  1644. loadingTask.onUnsupportedFeature =
  1645. _this7.fallback.bind(_this7);
  1646. return _context8.abrupt("return",
  1647. loadingTask.promise.then(
  1648. function(pdfDocument) {
  1649. _this7.load(
  1650. pdfDocument);
  1651. },
  1652. function(reason) {
  1653. if (loadingTask !==
  1654. _this7
  1655. .pdfLoadingTask
  1656. ) {
  1657. return undefined;
  1658. }
  1659. var key =
  1660. "loading_error";
  1661. if (reason instanceof _pdfjsLib
  1662. .InvalidPDFException
  1663. ) {
  1664. key =
  1665. "invalid_file_error";
  1666. } else if (
  1667. reason instanceof _pdfjsLib
  1668. .MissingPDFException
  1669. ) {
  1670. key =
  1671. "missing_file_error";
  1672. } else if (
  1673. reason instanceof _pdfjsLib
  1674. .UnexpectedResponseException
  1675. ) {
  1676. key =
  1677. "unexpected_response_error";
  1678. }
  1679. return _this7.l10n
  1680. .get(key).then(
  1681. function(
  1682. msg) {
  1683. _this7
  1684. ._documentError(
  1685. msg, {
  1686. message: reason ===
  1687. null ||
  1688. reason ===
  1689. void 0 ?
  1690. void 0 :
  1691. reason
  1692. .message
  1693. }
  1694. );
  1695. throw reason;
  1696. });
  1697. }));
  1698. case 16:
  1699. case "end":
  1700. return _context8.stop();
  1701. }
  1702. }
  1703. }, _callee8);
  1704. }))();
  1705. },
  1706. _ensureDownloadComplete: function _ensureDownloadComplete() {
  1707. if (this.pdfDocument && this.downloadComplete) {
  1708. return;
  1709. }
  1710. throw new Error("PDF document not downloaded.");
  1711. },
  1712. download: function download() {
  1713. var _arguments = arguments,
  1714. _this8 = this;
  1715. return _asyncToGenerator( /*#__PURE__*/ _regenerator["default"].mark(
  1716. function _callee9() {
  1717. var _ref2, _ref2$sourceEventType, sourceEventType, url,
  1718. filename, data, blob;
  1719. return _regenerator["default"].wrap(function _callee9$(
  1720. _context9) {
  1721. while (1) {
  1722. switch (_context9.prev = _context9.next) {
  1723. case 0:
  1724. _ref2 = _arguments.length > 0 &&
  1725. _arguments[0] !== undefined ?
  1726. _arguments[0] : {},
  1727. _ref2$sourceEventType = _ref2
  1728. .sourceEventType,
  1729. sourceEventType =
  1730. _ref2$sourceEventType ===
  1731. void 0 ? "download" :
  1732. _ref2$sourceEventType;
  1733. url = _this8._downloadUrl,
  1734. filename = _this8._docFilename;
  1735. _context9.prev = 2;
  1736. _this8._ensureDownloadComplete();
  1737. _context9.next = 6;
  1738. return _this8.pdfDocument.getData();
  1739. case 6:
  1740. data = _context9.sent;
  1741. blob = new Blob([data], {
  1742. type: "application/pdf"
  1743. });
  1744. _context9.next = 10;
  1745. return _this8.downloadManager
  1746. .download(blob, url, filename,
  1747. sourceEventType);
  1748. case 10:
  1749. _context9.next = 16;
  1750. break;
  1751. case 12:
  1752. _context9.prev = 12;
  1753. _context9.t0 = _context9["catch"](
  1754. 2);
  1755. _context9.next = 16;
  1756. return _this8.downloadManager
  1757. .downloadUrl(url, filename);
  1758. case 16:
  1759. case "end":
  1760. return _context9.stop();
  1761. }
  1762. }
  1763. }, _callee9, null, [
  1764. [2, 12]
  1765. ]);
  1766. }))();
  1767. },
  1768. save: function save() {
  1769. var _arguments2 = arguments,
  1770. _this9 = this;
  1771. return _asyncToGenerator( /*#__PURE__*/ _regenerator["default"].mark(
  1772. function _callee10() {
  1773. var _ref3, _ref3$sourceEventType, sourceEventType, url,
  1774. filename, data, blob;
  1775. return _regenerator["default"].wrap(function _callee10$(
  1776. _context10) {
  1777. while (1) {
  1778. switch (_context10.prev = _context10.next) {
  1779. case 0:
  1780. _ref3 = _arguments2.length > 0 &&
  1781. _arguments2[0] !== undefined ?
  1782. _arguments2[0] : {},
  1783. _ref3$sourceEventType = _ref3
  1784. .sourceEventType,
  1785. sourceEventType =
  1786. _ref3$sourceEventType ===
  1787. void 0 ? "download" :
  1788. _ref3$sourceEventType;
  1789. if (!_this9._saveInProgress) {
  1790. _context10.next = 3;
  1791. break;
  1792. }
  1793. return _context10.abrupt("return");
  1794. case 3:
  1795. _this9._saveInProgress = true;
  1796. _context10.next = 6;
  1797. return _this9.pdfScriptingManager
  1798. .dispatchWillSave();
  1799. case 6:
  1800. url = _this9._downloadUrl,
  1801. filename = _this9._docFilename;
  1802. _context10.prev = 7;
  1803. _this9._ensureDownloadComplete();
  1804. _context10.next = 11;
  1805. return _this9.pdfDocument
  1806. .saveDocument();
  1807. case 11:
  1808. data = _context10.sent;
  1809. blob = new Blob([data], {
  1810. type: "application/pdf"
  1811. });
  1812. _context10.next = 15;
  1813. return _this9.downloadManager
  1814. .download(blob, url, filename,
  1815. sourceEventType);
  1816. case 15:
  1817. _context10.next = 22;
  1818. break;
  1819. case 17:
  1820. _context10.prev = 17;
  1821. _context10.t0 = _context10["catch"](
  1822. 7);
  1823. console.error(
  1824. "Error when saving the document: "
  1825. .concat(_context10.t0
  1826. .message));
  1827. _context10.next = 22;
  1828. return _this9.download({
  1829. sourceEventType: sourceEventType
  1830. });
  1831. case 22:
  1832. _context10.prev = 22;
  1833. _context10.next = 25;
  1834. return _this9.pdfScriptingManager
  1835. .dispatchDidSave();
  1836. case 25:
  1837. _this9._saveInProgress = false;
  1838. return _context10.finish(22);
  1839. case 27:
  1840. case "end":
  1841. return _context10.stop();
  1842. }
  1843. }
  1844. }, _callee10, null, [
  1845. [7, 17, 22, 27]
  1846. ]);
  1847. }))();
  1848. },
  1849. downloadOrSave: function downloadOrSave(options) {
  1850. var _this$pdfDocument;
  1851. if (((_this$pdfDocument = this.pdfDocument) === null ||
  1852. _this$pdfDocument === void 0 ? void 0 : _this$pdfDocument
  1853. .annotationStorage.size) > 0) {
  1854. this.save(options);
  1855. } else {
  1856. this.download(options);
  1857. }
  1858. },
  1859. fallback: function fallback(featureId) {
  1860. var _this10 = this;
  1861. this.externalServices.reportTelemetry({
  1862. type: "unsupportedFeature",
  1863. featureId: featureId
  1864. });
  1865. if (this._fellback) {
  1866. return;
  1867. }
  1868. this._fellback = true;
  1869. this.externalServices.fallback({
  1870. featureId: featureId,
  1871. url: this.baseUrl
  1872. }).then(function(download) {
  1873. if (!download) {
  1874. return;
  1875. }
  1876. _this10.download({
  1877. sourceEventType: "download"
  1878. });
  1879. });
  1880. },
  1881. _documentError: function _documentError(message) {
  1882. var _moreInfo$message;
  1883. var moreInfo = arguments.length > 1 && arguments[1] !== undefined ?
  1884. arguments[1] : null;
  1885. this._unblockDocumentLoadEvent();
  1886. this._otherError(message, moreInfo);
  1887. this.eventBus.dispatch("documenterror", {
  1888. source: this,
  1889. message: message,
  1890. reason: (_moreInfo$message = moreInfo === null || moreInfo ===
  1891. void 0 ? void 0 : moreInfo.message) !== null &&
  1892. _moreInfo$message !== void 0 ? _moreInfo$message : null
  1893. });
  1894. },
  1895. _otherError: function _otherError(message) {
  1896. var moreInfo = arguments.length > 1 && arguments[1] !== undefined ?
  1897. arguments[1] : null;
  1898. var moreInfoText = [this.l10n.get("error_version_info", {
  1899. version: _pdfjsLib.version || "?",
  1900. build: _pdfjsLib.build || "?"
  1901. })];
  1902. if (moreInfo) {
  1903. moreInfoText.push(this.l10n.get("error_message", {
  1904. message: moreInfo.message
  1905. }));
  1906. if (moreInfo.stack) {
  1907. moreInfoText.push(this.l10n.get("error_stack", {
  1908. stack: moreInfo.stack
  1909. }));
  1910. } else {
  1911. if (moreInfo.filename) {
  1912. moreInfoText.push(this.l10n.get("error_file", {
  1913. file: moreInfo.filename
  1914. }));
  1915. }
  1916. if (moreInfo.lineNumber) {
  1917. moreInfoText.push(this.l10n.get("error_line", {
  1918. line: moreInfo.lineNumber
  1919. }));
  1920. }
  1921. }
  1922. }
  1923. var errorWrapperConfig = this.appConfig.errorWrapper;
  1924. var errorWrapper = errorWrapperConfig.container;
  1925. errorWrapper.hidden = false;
  1926. var errorMessage = errorWrapperConfig.errorMessage;
  1927. errorMessage.textContent = message;
  1928. var closeButton = errorWrapperConfig.closeButton;
  1929. closeButton.onclick = function() {
  1930. errorWrapper.hidden = true;
  1931. };
  1932. var errorMoreInfo = errorWrapperConfig.errorMoreInfo;
  1933. var moreInfoButton = errorWrapperConfig.moreInfoButton;
  1934. var lessInfoButton = errorWrapperConfig.lessInfoButton;
  1935. moreInfoButton.onclick = function() {
  1936. errorMoreInfo.hidden = false;
  1937. moreInfoButton.hidden = true;
  1938. lessInfoButton.hidden = false;
  1939. errorMoreInfo.style.height = errorMoreInfo.scrollHeight + "px";
  1940. };
  1941. lessInfoButton.onclick = function() {
  1942. errorMoreInfo.hidden = true;
  1943. moreInfoButton.hidden = false;
  1944. lessInfoButton.hidden = true;
  1945. };
  1946. moreInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1947. lessInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1948. closeButton.oncontextmenu = _ui_utils.noContextMenuHandler;
  1949. moreInfoButton.hidden = false;
  1950. lessInfoButton.hidden = true;
  1951. Promise.all(moreInfoText).then(function(parts) {
  1952. errorMoreInfo.value = parts.join("\n");
  1953. });
  1954. },
  1955. progress: function progress(level) {
  1956. var _this11 = this;
  1957. if (this.downloadComplete) {
  1958. return;
  1959. }
  1960. var percent = Math.round(level * 100);
  1961. if (percent > this.loadingBar.percent || isNaN(percent)) {
  1962. this.loadingBar.percent = percent;
  1963. var disableAutoFetch = this.pdfDocument ? this.pdfDocument.loadingParams
  1964. .disableAutoFetch : _app_options.AppOptions.get("disableAutoFetch");
  1965. if (disableAutoFetch && percent) {
  1966. if (this.disableAutoFetchLoadingBarTimeout) {
  1967. clearTimeout(this.disableAutoFetchLoadingBarTimeout);
  1968. this.disableAutoFetchLoadingBarTimeout = null;
  1969. }
  1970. this.loadingBar.show();
  1971. this.disableAutoFetchLoadingBarTimeout = setTimeout(function() {
  1972. _this11.loadingBar.hide();
  1973. _this11.disableAutoFetchLoadingBarTimeout = null;
  1974. }, DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT);
  1975. }
  1976. }
  1977. },
  1978. load: function load(pdfDocument) {
  1979. var _this12 = this;
  1980. this.pdfDocument = pdfDocument;
  1981. pdfDocument.getDownloadInfo().then(function(_ref4) {
  1982. var length = _ref4.length;
  1983. _this12._contentLength = length;
  1984. _this12.downloadComplete = true;
  1985. _this12.loadingBar.hide();
  1986. firstPagePromise.then(function() {
  1987. _this12.eventBus.dispatch("documentloaded", {
  1988. source: _this12
  1989. });
  1990. });
  1991. });
  1992. var pageLayoutPromise = pdfDocument.getPageLayout()["catch"](function() {});
  1993. var pageModePromise = pdfDocument.getPageMode()["catch"](function() {});
  1994. var openActionPromise = pdfDocument.getOpenAction()["catch"](function() {});
  1995. this.toolbar.setPagesCount(pdfDocument.numPages, false);
  1996. this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
  1997. var baseDocumentUrl;
  1998. baseDocumentUrl = null;
  1999. this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
  2000. this.pdfDocumentProperties.setDocument(pdfDocument, this.url);
  2001. var pdfViewer = this.pdfViewer;
  2002. pdfViewer.setDocument(pdfDocument);
  2003. var firstPagePromise = pdfViewer.firstPagePromise,
  2004. onePageRendered = pdfViewer.onePageRendered,
  2005. pagesPromise = pdfViewer.pagesPromise;
  2006. var pdfThumbnailViewer = this.pdfThumbnailViewer;
  2007. pdfThumbnailViewer.setDocument(pdfDocument);
  2008. var storedPromise = (this.store = new _view_history.ViewHistory(pdfDocument
  2009. .fingerprints[0])).getMultiple({
  2010. page: null,
  2011. zoom: _ui_utils.DEFAULT_SCALE_VALUE,
  2012. scrollLeft: "0",
  2013. scrollTop: "0",
  2014. rotation: null,
  2015. sidebarView: _ui_utils.SidebarView.UNKNOWN,
  2016. scrollMode: _ui_utils.ScrollMode.UNKNOWN,
  2017. spreadMode: _ui_utils.SpreadMode.UNKNOWN
  2018. })["catch"](function() {
  2019. return Object.create(null);
  2020. });
  2021. firstPagePromise.then(function(pdfPage) {
  2022. _this12.loadingBar.setWidth(_this12.appConfig.viewerContainer);
  2023. _this12._initializeAnnotationStorageCallbacks(pdfDocument);
  2024. Promise.all([_ui_utils.animationStarted, storedPromise,
  2025. pageLayoutPromise, pageModePromise,
  2026. openActionPromise
  2027. ]).then( /*#__PURE__*/ function() {
  2028. var _ref6 = _asyncToGenerator( /*#__PURE__*/
  2029. _regenerator["default"].mark(
  2030. function _callee11(_ref5) {
  2031. var _ref7, timeStamp, stored,
  2032. pageLayout, pageMode,
  2033. openAction, viewOnLoad,
  2034. initialBookmark, zoom, hash,
  2035. rotation, sidebarView,
  2036. scrollMode, spreadMode, modes;
  2037. return _regenerator["default"].wrap(
  2038. function _callee11$(
  2039. _context11) {
  2040. while (1) {
  2041. switch (_context11
  2042. .prev =
  2043. _context11.next
  2044. ) {
  2045. case 0:
  2046. _ref7 =
  2047. _slicedToArray(
  2048. _ref5,
  2049. 5),
  2050. timeStamp =
  2051. _ref7[
  2052. 0],
  2053. stored =
  2054. _ref7[
  2055. 1],
  2056. pageLayout =
  2057. _ref7[
  2058. 2],
  2059. pageMode =
  2060. _ref7[
  2061. 3],
  2062. openAction =
  2063. _ref7[
  2064. 4];
  2065. viewOnLoad =
  2066. _app_options
  2067. .AppOptions
  2068. .get(
  2069. "viewOnLoad"
  2070. );
  2071. _this12
  2072. ._initializePdfHistory({
  2073. fingerprint: pdfDocument
  2074. .fingerprints[
  2075. 0
  2076. ],
  2077. viewOnLoad: viewOnLoad,
  2078. initialDest: openAction ===
  2079. null ||
  2080. openAction ===
  2081. void 0 ?
  2082. void 0 :
  2083. openAction
  2084. .dest
  2085. });
  2086. initialBookmark
  2087. =
  2088. _this12
  2089. .initialBookmark;
  2090. zoom =
  2091. _app_options
  2092. .AppOptions
  2093. .get(
  2094. "defaultZoomValue"
  2095. );
  2096. hash =
  2097. zoom ?
  2098. "zoom="
  2099. .concat(
  2100. zoom
  2101. ) :
  2102. null;
  2103. rotation =
  2104. null;
  2105. sidebarView
  2106. =
  2107. _app_options
  2108. .AppOptions
  2109. .get(
  2110. "sidebarViewOnLoad"
  2111. );
  2112. scrollMode =
  2113. _app_options
  2114. .AppOptions
  2115. .get(
  2116. "scrollModeOnLoad"
  2117. );
  2118. spreadMode =
  2119. _app_options
  2120. .AppOptions
  2121. .get(
  2122. "spreadModeOnLoad"
  2123. );
  2124. if (stored
  2125. .page &&
  2126. viewOnLoad !==
  2127. ViewOnLoad
  2128. .INITIAL
  2129. ) {
  2130. hash =
  2131. "page="
  2132. .concat(
  2133. stored
  2134. .page,
  2135. "&zoom="
  2136. )
  2137. .concat(
  2138. zoom ||
  2139. stored
  2140. .zoom,
  2141. ","
  2142. ) +
  2143. ""
  2144. .concat(
  2145. stored
  2146. .scrollLeft,
  2147. ","
  2148. )
  2149. .concat(
  2150. stored
  2151. .scrollTop
  2152. );
  2153. rotation
  2154. =
  2155. parseInt(
  2156. stored
  2157. .rotation,
  2158. 10
  2159. );
  2160. if (sidebarView ===
  2161. _ui_utils
  2162. .SidebarView
  2163. .UNKNOWN
  2164. ) {
  2165. sidebarView
  2166. =
  2167. stored
  2168. .sidebarView |
  2169. 0;
  2170. }
  2171. if (scrollMode ===
  2172. _ui_utils
  2173. .ScrollMode
  2174. .UNKNOWN
  2175. ) {
  2176. scrollMode
  2177. =
  2178. stored
  2179. .scrollMode |
  2180. 0;
  2181. }
  2182. if (spreadMode ===
  2183. _ui_utils
  2184. .SpreadMode
  2185. .UNKNOWN
  2186. ) {
  2187. spreadMode
  2188. =
  2189. stored
  2190. .spreadMode |
  2191. 0;
  2192. }
  2193. }
  2194. if (pageMode &&
  2195. sidebarView ===
  2196. _ui_utils
  2197. .SidebarView
  2198. .UNKNOWN
  2199. ) {
  2200. sidebarView
  2201. = (0,
  2202. _ui_utils
  2203. .apiPageModeToSidebarView
  2204. )
  2205. (
  2206. pageMode);
  2207. }
  2208. if (pageLayout &&
  2209. scrollMode ===
  2210. _ui_utils
  2211. .ScrollMode
  2212. .UNKNOWN &&
  2213. spreadMode ===
  2214. _ui_utils
  2215. .SpreadMode
  2216. .UNKNOWN
  2217. ) {
  2218. modes =
  2219. (0, _ui_utils
  2220. .apiPageLayoutToViewerModes
  2221. )
  2222. (
  2223. pageLayout);
  2224. spreadMode
  2225. =
  2226. modes
  2227. .spreadMode;
  2228. }
  2229. _this12
  2230. .setInitialView(
  2231. hash, {
  2232. rotation: rotation,
  2233. sidebarView: sidebarView,
  2234. scrollMode: scrollMode,
  2235. spreadMode: spreadMode
  2236. });
  2237. _this12
  2238. .eventBus
  2239. .dispatch(
  2240. "documentinit", {
  2241. source: _this12
  2242. });
  2243. if (!_this12
  2244. .isViewerEmbedded
  2245. ) {
  2246. pdfViewer
  2247. .focus();
  2248. }
  2249. _context11
  2250. .next =
  2251. 18;
  2252. return Promise
  2253. .race([pagesPromise,
  2254. new Promise(
  2255. function(
  2256. resolve
  2257. ) {
  2258. setTimeout
  2259. (resolve,
  2260. FORCE_PAGES_LOADED_TIMEOUT
  2261. );
  2262. }
  2263. )
  2264. ]);
  2265. case 18:
  2266. if (!(!initialBookmark &&
  2267. !
  2268. hash
  2269. )) {
  2270. _context11
  2271. .next =
  2272. 20;
  2273. break;
  2274. }
  2275. return _context11
  2276. .abrupt(
  2277. "return"
  2278. );
  2279. case 20:
  2280. if (!
  2281. pdfViewer
  2282. .hasEqualPageSizes
  2283. ) {
  2284. _context11
  2285. .next =
  2286. 22;
  2287. break;
  2288. }
  2289. return _context11
  2290. .abrupt(
  2291. "return"
  2292. );
  2293. case 22:
  2294. _this12
  2295. .initialBookmark =
  2296. initialBookmark;
  2297. pdfViewer
  2298. .currentScaleValue =
  2299. pdfViewer
  2300. .currentScaleValue;
  2301. _this12
  2302. .setInitialView(
  2303. hash
  2304. );
  2305. case 25:
  2306. case "end":
  2307. return _context11
  2308. .stop();
  2309. }
  2310. }
  2311. }, _callee11);
  2312. }));
  2313. return function(_x2) {
  2314. return _ref6.apply(this, arguments);
  2315. };
  2316. }())["catch"](function() {
  2317. _this12.setInitialView();
  2318. }).then(function() {
  2319. pdfViewer.update();
  2320. });
  2321. });
  2322. pagesPromise.then(function() {
  2323. _this12._unblockDocumentLoadEvent();
  2324. _this12._initializeAutoPrint(pdfDocument, openActionPromise);
  2325. }, function(reason) {
  2326. _this12.l10n.get("loading_error").then(function(msg) {
  2327. _this12._documentError(msg, {
  2328. message: reason === null || reason ===
  2329. void 0 ? void 0 : reason.message
  2330. });
  2331. });
  2332. });
  2333. onePageRendered.then(function(data) {
  2334. _this12.externalServices.reportTelemetry({
  2335. type: "pageInfo",
  2336. timestamp: data.timestamp
  2337. });
  2338. pdfDocument.getOutline().then(function(outline) {
  2339. if (pdfDocument !== _this12.pdfDocument) {
  2340. return;
  2341. }
  2342. _this12.pdfOutlineViewer.render({
  2343. outline: outline,
  2344. pdfDocument: pdfDocument
  2345. });
  2346. });
  2347. pdfDocument.getAttachments().then(function(attachments) {
  2348. if (pdfDocument !== _this12.pdfDocument) {
  2349. return;
  2350. }
  2351. _this12.pdfAttachmentViewer.render({
  2352. attachments: attachments
  2353. });
  2354. });
  2355. pdfViewer.optionalContentConfigPromise.then(function(
  2356. optionalContentConfig) {
  2357. if (pdfDocument !== _this12.pdfDocument) {
  2358. return;
  2359. }
  2360. _this12.pdfLayerViewer.render({
  2361. optionalContentConfig: optionalContentConfig,
  2362. pdfDocument: pdfDocument
  2363. });
  2364. });
  2365. if ("requestIdleCallback" in window) {
  2366. var callback = window.requestIdleCallback(function() {
  2367. _this12._collectTelemetry(pdfDocument);
  2368. _this12._idleCallbacks["delete"](callback);
  2369. }, {
  2370. timeout: 1000
  2371. });
  2372. _this12._idleCallbacks.add(callback);
  2373. }
  2374. });
  2375. this._initializePageLabels(pdfDocument);
  2376. this._initializeMetadata(pdfDocument);
  2377. },
  2378. _scriptingDocProperties: function _scriptingDocProperties(pdfDocument) {
  2379. var _this13 = this;
  2380. return _asyncToGenerator( /*#__PURE__*/ _regenerator["default"].mark(
  2381. function _callee12() {
  2382. var _this13$metadata, _this13$metadata2;
  2383. return _regenerator["default"].wrap(function _callee12$(
  2384. _context12) {
  2385. while (1) {
  2386. switch (_context12.prev = _context12.next) {
  2387. case 0:
  2388. if (_this13.documentInfo) {
  2389. _context12.next = 5;
  2390. break;
  2391. }
  2392. _context12.next = 3;
  2393. return new Promise(function(
  2394. resolve) {
  2395. _this13.eventBus._on(
  2396. "metadataloaded",
  2397. resolve, {
  2398. once: true
  2399. });
  2400. });
  2401. case 3:
  2402. if (!(pdfDocument !== _this13
  2403. .pdfDocument)) {
  2404. _context12.next = 5;
  2405. break;
  2406. }
  2407. return _context12.abrupt("return",
  2408. null);
  2409. case 5:
  2410. if (_this13._contentLength) {
  2411. _context12.next = 10;
  2412. break;
  2413. }
  2414. _context12.next = 8;
  2415. return new Promise(function(
  2416. resolve) {
  2417. _this13.eventBus._on(
  2418. "documentloaded",
  2419. resolve, {
  2420. once: true
  2421. });
  2422. });
  2423. case 8:
  2424. if (!(pdfDocument !== _this13
  2425. .pdfDocument)) {
  2426. _context12.next = 10;
  2427. break;
  2428. }
  2429. return _context12.abrupt("return",
  2430. null);
  2431. case 10:
  2432. return _context12.abrupt("return",
  2433. _objectSpread(
  2434. _objectSpread({},
  2435. _this13.documentInfo
  2436. ), {}, {
  2437. baseURL: _this13
  2438. .baseUrl,
  2439. filesize: _this13
  2440. ._contentLength,
  2441. filename: _this13
  2442. ._docFilename,
  2443. metadata: (
  2444. _this13$metadata =
  2445. _this13
  2446. .metadata
  2447. ) ===
  2448. null ||
  2449. _this13$metadata ===
  2450. void 0 ?
  2451. void 0 :
  2452. _this13$metadata
  2453. .getRaw(),
  2454. authors: (
  2455. _this13$metadata2 =
  2456. _this13
  2457. .metadata
  2458. ) ===
  2459. null ||
  2460. _this13$metadata2 ===
  2461. void 0 ?
  2462. void 0 :
  2463. _this13$metadata2
  2464. .get(
  2465. "dc:creator"
  2466. ),
  2467. numPages: _this13
  2468. .pagesCount,
  2469. URL: _this13.url
  2470. }));
  2471. case 11:
  2472. case "end":
  2473. return _context12.stop();
  2474. }
  2475. }
  2476. }, _callee12);
  2477. }))();
  2478. },
  2479. _collectTelemetry: function _collectTelemetry(pdfDocument) {
  2480. var _this14 = this;
  2481. return _asyncToGenerator( /*#__PURE__*/ _regenerator["default"].mark(
  2482. function _callee13() {
  2483. var markInfo, tagged;
  2484. return _regenerator["default"].wrap(function _callee13$(
  2485. _context13) {
  2486. while (1) {
  2487. switch (_context13.prev = _context13.next) {
  2488. case 0:
  2489. _context13.next = 2;
  2490. return _this14.pdfDocument
  2491. .getMarkInfo();
  2492. case 2:
  2493. markInfo = _context13.sent;
  2494. if (!(pdfDocument !== _this14
  2495. .pdfDocument)) {
  2496. _context13.next = 5;
  2497. break;
  2498. }
  2499. return _context13.abrupt("return");
  2500. case 5:
  2501. tagged = (markInfo === null ||
  2502. markInfo === void 0 ?
  2503. void 0 : markInfo.Marked) ||
  2504. false;
  2505. _this14.externalServices
  2506. .reportTelemetry({
  2507. type: "tagged",
  2508. tagged: tagged
  2509. });
  2510. case 7:
  2511. case "end":
  2512. return _context13.stop();
  2513. }
  2514. }
  2515. }, _callee13);
  2516. }))();
  2517. },
  2518. _initializeAutoPrint: function _initializeAutoPrint(pdfDocument,
  2519. openActionPromise) {
  2520. var _this15 = this;
  2521. return _asyncToGenerator( /*#__PURE__*/ _regenerator["default"].mark(
  2522. function _callee14() {
  2523. var _yield$Promise$all, _yield$Promise$all2, openAction,
  2524. javaScript, triggerAutoPrint, _iterator2, _step2, js;
  2525. return _regenerator["default"].wrap(function _callee14$(
  2526. _context14) {
  2527. while (1) {
  2528. switch (_context14.prev = _context14.next) {
  2529. case 0:
  2530. _context14.next = 2;
  2531. return Promise.all([
  2532. openActionPromise, !
  2533. _this15.pdfViewer
  2534. .enableScripting ?
  2535. pdfDocument
  2536. .getJavaScript() : null
  2537. ]);
  2538. case 2:
  2539. _yield$Promise$all = _context14
  2540. .sent;
  2541. _yield$Promise$all2 =
  2542. _slicedToArray(
  2543. _yield$Promise$all, 2);
  2544. openAction = _yield$Promise$all2[0];
  2545. javaScript = _yield$Promise$all2[1];
  2546. if (!(pdfDocument !== _this15
  2547. .pdfDocument)) {
  2548. _context14.next = 8;
  2549. break;
  2550. }
  2551. return _context14.abrupt("return");
  2552. case 8:
  2553. triggerAutoPrint = false;
  2554. if ((openAction === null ||
  2555. openAction === void 0 ?
  2556. void 0 : openAction.action
  2557. ) === "Print") {
  2558. triggerAutoPrint = true;
  2559. }
  2560. if (!javaScript) {
  2561. _context14.next = 31;
  2562. break;
  2563. }
  2564. javaScript.some(function(js) {
  2565. if (!js) {
  2566. return false;
  2567. }
  2568. console.warn(
  2569. "Warning: JavaScript support is not enabled"
  2570. );
  2571. _this15.fallback(
  2572. _pdfjsLib
  2573. .UNSUPPORTED_FEATURES
  2574. .javaScript);
  2575. return true;
  2576. });
  2577. if (triggerAutoPrint) {
  2578. _context14.next = 31;
  2579. break;
  2580. }
  2581. _iterator2 =
  2582. _createForOfIteratorHelper(
  2583. javaScript);
  2584. _context14.prev = 14;
  2585. _iterator2.s();
  2586. case 16:
  2587. if ((_step2 = _iterator2.n())
  2588. .done) {
  2589. _context14.next = 23;
  2590. break;
  2591. }
  2592. js = _step2.value;
  2593. if (!(js && _ui_utils
  2594. .AutoPrintRegExp.test(js)
  2595. )) {
  2596. _context14.next = 21;
  2597. break;
  2598. }
  2599. triggerAutoPrint = true;
  2600. return _context14.abrupt("break",
  2601. 23);
  2602. case 21:
  2603. _context14.next = 16;
  2604. break;
  2605. case 23:
  2606. _context14.next = 28;
  2607. break;
  2608. case 25:
  2609. _context14.prev = 25;
  2610. _context14.t0 = _context14["catch"](
  2611. 14);
  2612. _iterator2.e(_context14.t0);
  2613. case 28:
  2614. _context14.prev = 28;
  2615. _iterator2.f();
  2616. return _context14.finish(28);
  2617. case 31:
  2618. if (triggerAutoPrint) {
  2619. _this15.triggerPrinting();
  2620. }
  2621. case 32:
  2622. case "end":
  2623. return _context14.stop();
  2624. }
  2625. }
  2626. }, _callee14, null, [
  2627. [14, 25, 28, 31]
  2628. ]);
  2629. }))();
  2630. },
  2631. _initializeMetadata: function _initializeMetadata(pdfDocument) {
  2632. var _this16 = this;
  2633. return _asyncToGenerator( /*#__PURE__*/ _regenerator["default"].mark(
  2634. function _callee15() {
  2635. var _this16$_contentDispo, _this16$_contentLengt;
  2636. var _yield$pdfDocument$ge, info, metadata,
  2637. contentDispositionFilename, contentLength, pdfTitle,
  2638. metadataTitle, versionId, generatorId, producer,
  2639. formType;
  2640. return _regenerator["default"].wrap(function _callee15$(
  2641. _context15) {
  2642. while (1) {
  2643. switch (_context15.prev = _context15.next) {
  2644. case 0:
  2645. _context15.next = 2;
  2646. return pdfDocument.getMetadata();
  2647. case 2:
  2648. _yield$pdfDocument$ge = _context15
  2649. .sent;
  2650. info = _yield$pdfDocument$ge.info;
  2651. metadata = _yield$pdfDocument$ge
  2652. .metadata;
  2653. contentDispositionFilename =
  2654. _yield$pdfDocument$ge
  2655. .contentDispositionFilename;
  2656. contentLength =
  2657. _yield$pdfDocument$ge
  2658. .contentLength;
  2659. if (!(pdfDocument !== _this16
  2660. .pdfDocument)) {
  2661. _context15.next = 9;
  2662. break;
  2663. }
  2664. return _context15.abrupt("return");
  2665. case 9:
  2666. _this16.documentInfo = info;
  2667. _this16.metadata = metadata;
  2668. (_this16$_contentDispo = _this16
  2669. ._contentDispositionFilename
  2670. ) !== null &&
  2671. _this16$_contentDispo !==
  2672. void 0 ? _this16$_contentDispo :
  2673. _this16
  2674. ._contentDispositionFilename =
  2675. contentDispositionFilename;
  2676. (_this16$_contentLengt = _this16
  2677. ._contentLength) !== null &&
  2678. _this16$_contentLengt !==
  2679. void 0 ? _this16$_contentLengt :
  2680. _this16._contentLength =
  2681. contentLength;
  2682. console.log("PDF ".concat(
  2683. pdfDocument
  2684. .fingerprints[0], " [")
  2685. .concat(info
  2686. .PDFFormatVersion, " "
  2687. ) + "".concat((info
  2688. .Producer || "-")
  2689. .trim(), " / ").concat((
  2690. info.Creator || "-")
  2691. .trim(), "] ") +
  2692. "(PDF.js: ".concat(_pdfjsLib
  2693. .version || "-", ")"));
  2694. pdfTitle = info === null || info ===
  2695. void 0 ? void 0 : info.Title;
  2696. metadataTitle = metadata === null ||
  2697. metadata === void 0 ? void 0 :
  2698. metadata.get("dc:title");
  2699. if (metadataTitle) {
  2700. if (metadataTitle !==
  2701. "Untitled" && !
  2702. /[\uFFF0-\uFFFF]/g.test(
  2703. metadataTitle)) {
  2704. pdfTitle = metadataTitle;
  2705. }
  2706. }
  2707. if (pdfTitle) {
  2708. _this16.setTitle("".concat(
  2709. pdfTitle, " - ")
  2710. .concat(
  2711. contentDispositionFilename ||
  2712. document.title));
  2713. } else if (
  2714. contentDispositionFilename) {
  2715. _this16.setTitle(
  2716. contentDispositionFilename
  2717. );
  2718. }
  2719. if (info.IsXFAPresent && !info
  2720. .IsAcroFormPresent && !
  2721. pdfDocument.isPureXfa) {
  2722. if (pdfDocument.loadingParams
  2723. .enableXfa) {
  2724. console.warn(
  2725. "Warning: XFA Foreground documents are not supported"
  2726. );
  2727. } else {
  2728. console.warn(
  2729. "Warning: XFA support is not enabled"
  2730. );
  2731. }
  2732. _this16.fallback(_pdfjsLib
  2733. .UNSUPPORTED_FEATURES
  2734. .forms);
  2735. } else if ((info
  2736. .IsAcroFormPresent || info
  2737. .IsXFAPresent) && !_this16
  2738. .pdfViewer.renderForms) {
  2739. console.warn(
  2740. "Warning: Interactive form support is not enabled"
  2741. );
  2742. _this16.fallback(_pdfjsLib
  2743. .UNSUPPORTED_FEATURES
  2744. .forms);
  2745. }
  2746. if (info.IsSignaturesPresent) {
  2747. console.warn(
  2748. "Warning: Digital signatures validation is not supported"
  2749. );
  2750. _this16.fallback(_pdfjsLib
  2751. .UNSUPPORTED_FEATURES
  2752. .signatures);
  2753. }
  2754. versionId = "other";
  2755. if (KNOWN_VERSIONS.includes(info
  2756. .PDFFormatVersion)) {
  2757. versionId = "v".concat(info
  2758. .PDFFormatVersion
  2759. .replace(".", "_"));
  2760. }
  2761. generatorId = "other";
  2762. if (info.Producer) {
  2763. producer = info.Producer
  2764. .toLowerCase();
  2765. KNOWN_GENERATORS.some(function(
  2766. generator) {
  2767. if (!producer
  2768. .includes(
  2769. generator)
  2770. ) {
  2771. return false;
  2772. }
  2773. generatorId =
  2774. generator
  2775. .replace(
  2776. /[ .-]/g,
  2777. "_");
  2778. return true;
  2779. });
  2780. }
  2781. formType = null;
  2782. if (info.IsXFAPresent) {
  2783. formType = "xfa";
  2784. } else if (info.IsAcroFormPresent) {
  2785. formType = "acroform";
  2786. }
  2787. _this16.externalServices
  2788. .reportTelemetry({
  2789. type: "documentInfo",
  2790. version: versionId,
  2791. generator: generatorId,
  2792. formType: formType
  2793. });
  2794. _this16.eventBus.dispatch(
  2795. "metadataloaded", {
  2796. source: _this16
  2797. });
  2798. case 28:
  2799. case "end":
  2800. return _context15.stop();
  2801. }
  2802. }
  2803. }, _callee15);
  2804. }))();
  2805. },
  2806. _initializePageLabels: function _initializePageLabels(pdfDocument) {
  2807. var _this17 = this;
  2808. return _asyncToGenerator( /*#__PURE__*/ _regenerator["default"].mark(
  2809. function _callee16() {
  2810. var labels, numLabels, standardLabels, emptyLabels, i,
  2811. label, pdfViewer, pdfThumbnailViewer, toolbar;
  2812. return _regenerator["default"].wrap(function _callee16$(
  2813. _context16) {
  2814. while (1) {
  2815. switch (_context16.prev = _context16.next) {
  2816. case 0:
  2817. _context16.next = 2;
  2818. return pdfDocument.getPageLabels();
  2819. case 2:
  2820. labels = _context16.sent;
  2821. if (!(pdfDocument !== _this17
  2822. .pdfDocument)) {
  2823. _context16.next = 5;
  2824. break;
  2825. }
  2826. return _context16.abrupt("return");
  2827. case 5:
  2828. if (!(!labels || _app_options
  2829. .AppOptions.get(
  2830. "disablePageLabels"))) {
  2831. _context16.next = 7;
  2832. break;
  2833. }
  2834. return _context16.abrupt("return");
  2835. case 7:
  2836. numLabels = labels.length;
  2837. standardLabels = 0, emptyLabels = 0;
  2838. i = 0;
  2839. case 10:
  2840. if (!(i < numLabels)) {
  2841. _context16.next = 24;
  2842. break;
  2843. }
  2844. label = labels[i];
  2845. if (!(label === (i + 1)
  2846. .toString())) {
  2847. _context16.next = 16;
  2848. break;
  2849. }
  2850. standardLabels++;
  2851. _context16.next = 21;
  2852. break;
  2853. case 16:
  2854. if (!(label === "")) {
  2855. _context16.next = 20;
  2856. break;
  2857. }
  2858. emptyLabels++;
  2859. _context16.next = 21;
  2860. break;
  2861. case 20:
  2862. return _context16.abrupt("break",
  2863. 24);
  2864. case 21:
  2865. i++;
  2866. _context16.next = 10;
  2867. break;
  2868. case 24:
  2869. if (!(standardLabels >= numLabels ||
  2870. emptyLabels >= numLabels)) {
  2871. _context16.next = 26;
  2872. break;
  2873. }
  2874. return _context16.abrupt("return");
  2875. case 26:
  2876. pdfViewer = _this17.pdfViewer,
  2877. pdfThumbnailViewer = _this17
  2878. .pdfThumbnailViewer, toolbar =
  2879. _this17.toolbar;
  2880. pdfViewer.setPageLabels(labels);
  2881. pdfThumbnailViewer.setPageLabels(
  2882. labels);
  2883. toolbar.setPagesCount(numLabels,
  2884. true);
  2885. toolbar.setPageNumber(pdfViewer
  2886. .currentPageNumber,
  2887. pdfViewer.currentPageLabel);
  2888. case 31:
  2889. case "end":
  2890. return _context16.stop();
  2891. }
  2892. }
  2893. }, _callee16);
  2894. }))();
  2895. },
  2896. _initializePdfHistory: function _initializePdfHistory(_ref8) {
  2897. var fingerprint = _ref8.fingerprint,
  2898. viewOnLoad = _ref8.viewOnLoad,
  2899. _ref8$initialDest = _ref8.initialDest,
  2900. initialDest = _ref8$initialDest === void 0 ? null : _ref8$initialDest;
  2901. if (!this.pdfHistory) {
  2902. return;
  2903. }
  2904. this.pdfHistory.initialize({
  2905. fingerprint: fingerprint,
  2906. resetHistory: viewOnLoad === ViewOnLoad.INITIAL,
  2907. updateUrl: _app_options.AppOptions.get("historyUpdateUrl")
  2908. });
  2909. if (this.pdfHistory.initialBookmark) {
  2910. this.initialBookmark = this.pdfHistory.initialBookmark;
  2911. this.initialRotation = this.pdfHistory.initialRotation;
  2912. }
  2913. if (initialDest && !this.initialBookmark && viewOnLoad === ViewOnLoad
  2914. .UNKNOWN) {
  2915. this.initialBookmark = JSON.stringify(initialDest);
  2916. this.pdfHistory.push({
  2917. explicitDest: initialDest,
  2918. pageNumber: null
  2919. });
  2920. }
  2921. },
  2922. _initializeAnnotationStorageCallbacks: function _initializeAnnotationStorageCallbacks(
  2923. pdfDocument) {
  2924. var _this18 = this;
  2925. if (pdfDocument !== this.pdfDocument) {
  2926. return;
  2927. }
  2928. var annotationStorage = pdfDocument.annotationStorage;
  2929. annotationStorage.onSetModified = function() {
  2930. window.addEventListener("beforeunload", beforeUnload);
  2931. _this18._annotationStorageModified = true;
  2932. };
  2933. annotationStorage.onResetModified = function() {
  2934. window.removeEventListener("beforeunload", beforeUnload);
  2935. delete _this18._annotationStorageModified;
  2936. };
  2937. },
  2938. setInitialView: function setInitialView(storedHash) {
  2939. var _this19 = this;
  2940. var _ref9 = arguments.length > 1 && arguments[1] !== undefined ? arguments[
  2941. 1] : {},
  2942. rotation = _ref9.rotation,
  2943. sidebarView = _ref9.sidebarView,
  2944. scrollMode = _ref9.scrollMode,
  2945. spreadMode = _ref9.spreadMode;
  2946. var setRotation = function setRotation(angle) {
  2947. if ((0, _ui_utils.isValidRotation)(angle)) {
  2948. _this19.pdfViewer.pagesRotation = angle;
  2949. }
  2950. };
  2951. var setViewerModes = function setViewerModes(scroll, spread) {
  2952. if ((0, _ui_utils.isValidScrollMode)(scroll)) {
  2953. _this19.pdfViewer.scrollMode = scroll;
  2954. }
  2955. if ((0, _ui_utils.isValidSpreadMode)(spread)) {
  2956. _this19.pdfViewer.spreadMode = spread;
  2957. }
  2958. };
  2959. this.isInitialViewSet = true;
  2960. this.pdfSidebar.setInitialView(sidebarView);
  2961. setViewerModes(scrollMode, spreadMode);
  2962. if (this.initialBookmark) {
  2963. setRotation(this.initialRotation);
  2964. delete this.initialRotation;
  2965. this.pdfLinkService.setHash(this.initialBookmark);
  2966. this.initialBookmark = null;
  2967. } else if (storedHash) {
  2968. setRotation(rotation);
  2969. this.pdfLinkService.setHash(storedHash);
  2970. }
  2971. this.toolbar.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer
  2972. .currentPageLabel);
  2973. this.secondaryToolbar.setPageNumber(this.pdfViewer.currentPageNumber);
  2974. if (!this.pdfViewer.currentScaleValue) {
  2975. this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  2976. }
  2977. },
  2978. _cleanup: function _cleanup() {
  2979. if (!this.pdfDocument) {
  2980. return;
  2981. }
  2982. this.pdfViewer.cleanup();
  2983. this.pdfThumbnailViewer.cleanup();
  2984. this.pdfDocument.cleanup(this.pdfViewer.renderer === _ui_utils.RendererType
  2985. .SVG);
  2986. },
  2987. forceRendering: function forceRendering() {
  2988. this.pdfRenderingQueue.printing = !!this.printService;
  2989. this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar
  2990. .isThumbnailViewVisible;
  2991. this.pdfRenderingQueue.renderHighestPriority();
  2992. },
  2993. beforePrint: function beforePrint() {
  2994. var _this20 = this;
  2995. this.pdfScriptingManager.dispatchWillPrint();
  2996. if (this.printService) {
  2997. return;
  2998. }
  2999. if (!this.supportsPrinting) {
  3000. this.l10n.get("printing_not_supported").then(function(msg) {
  3001. _this20._otherError(msg);
  3002. });
  3003. return;
  3004. }
  3005. if (!this.pdfViewer.pageViewsReady) {
  3006. this.l10n.get("printing_not_ready").then(function(msg) {
  3007. window.alert(msg);
  3008. });
  3009. return;
  3010. }
  3011. var pagesOverview = this.pdfViewer.getPagesOverview();
  3012. var printContainer = this.appConfig.printContainer;
  3013. var printResolution = _app_options.AppOptions.get("printResolution");
  3014. var optionalContentConfigPromise = this.pdfViewer
  3015. .optionalContentConfigPromise;
  3016. var printService = PDFPrintServiceFactory.instance.createPrintService(this
  3017. .pdfDocument, pagesOverview, printContainer, printResolution,
  3018. optionalContentConfigPromise, this.l10n);
  3019. this.printService = printService;
  3020. this.forceRendering();
  3021. printService.layout();
  3022. this.externalServices.reportTelemetry({
  3023. type: "print"
  3024. });
  3025. },
  3026. afterPrint: function afterPrint() {
  3027. this.pdfScriptingManager.dispatchDidPrint();
  3028. if (this.printService) {
  3029. var _this$pdfDocument2;
  3030. this.printService.destroy();
  3031. this.printService = null;
  3032. (_this$pdfDocument2 = this.pdfDocument) === null ||
  3033. _this$pdfDocument2 === void 0 ? void 0 : _this$pdfDocument2
  3034. .annotationStorage.resetModified();
  3035. }
  3036. this.forceRendering();
  3037. },
  3038. rotatePages: function rotatePages(delta) {
  3039. this.pdfViewer.pagesRotation += delta;
  3040. },
  3041. requestPresentationMode: function requestPresentationMode() {
  3042. var _this$pdfPresentation;
  3043. (_this$pdfPresentation = this.pdfPresentationMode) === null ||
  3044. _this$pdfPresentation === void 0 ? void 0 : _this$pdfPresentation
  3045. .request();
  3046. },
  3047. triggerPrinting: function triggerPrinting() {
  3048. if (!this.supportsPrinting) {
  3049. return;
  3050. }
  3051. window.print();
  3052. },
  3053. bindEvents: function bindEvents() {
  3054. var eventBus = this.eventBus,
  3055. _boundEvents = this._boundEvents;
  3056. _boundEvents.beforePrint = this.beforePrint.bind(this);
  3057. _boundEvents.afterPrint = this.afterPrint.bind(this);
  3058. eventBus._on("resize", webViewerResize);
  3059. eventBus._on("hashchange", webViewerHashchange);
  3060. eventBus._on("beforeprint", _boundEvents.beforePrint);
  3061. eventBus._on("afterprint", _boundEvents.afterPrint);
  3062. eventBus._on("pagerendered", webViewerPageRendered);
  3063. eventBus._on("updateviewarea", webViewerUpdateViewarea);
  3064. eventBus._on("pagechanging", webViewerPageChanging);
  3065. eventBus._on("scalechanging", webViewerScaleChanging);
  3066. eventBus._on("rotationchanging", webViewerRotationChanging);
  3067. eventBus._on("sidebarviewchanged", webViewerSidebarViewChanged);
  3068. eventBus._on("pagemode", webViewerPageMode);
  3069. eventBus._on("namedaction", webViewerNamedAction);
  3070. eventBus._on("presentationmodechanged", webViewerPresentationModeChanged);
  3071. eventBus._on("presentationmode", webViewerPresentationMode);
  3072. eventBus._on("print", webViewerPrint);
  3073. eventBus._on("download", webViewerDownload);
  3074. eventBus._on("save", webViewerSave);
  3075. eventBus._on("firstpage", webViewerFirstPage);
  3076. eventBus._on("lastpage", webViewerLastPage);
  3077. eventBus._on("nextpage", webViewerNextPage);
  3078. eventBus._on("previouspage", webViewerPreviousPage);
  3079. eventBus._on("zoomin", webViewerZoomIn);
  3080. eventBus._on("zoomout", webViewerZoomOut);
  3081. eventBus._on("zoomreset", webViewerZoomReset);
  3082. eventBus._on("pagenumberchanged", webViewerPageNumberChanged);
  3083. eventBus._on("scalechanged", webViewerScaleChanged);
  3084. eventBus._on("rotatecw", webViewerRotateCw);
  3085. eventBus._on("rotateccw", webViewerRotateCcw);
  3086. eventBus._on("optionalcontentconfig", webViewerOptionalContentConfig);
  3087. eventBus._on("switchscrollmode", webViewerSwitchScrollMode);
  3088. eventBus._on("scrollmodechanged", webViewerScrollModeChanged);
  3089. eventBus._on("switchspreadmode", webViewerSwitchSpreadMode);
  3090. eventBus._on("spreadmodechanged", webViewerSpreadModeChanged);
  3091. eventBus._on("documentproperties", webViewerDocumentProperties);
  3092. eventBus._on("findfromurlhash", webViewerFindFromUrlHash);
  3093. eventBus._on("updatefindmatchescount", webViewerUpdateFindMatchesCount);
  3094. eventBus._on("updatefindcontrolstate", webViewerUpdateFindControlState);
  3095. if (_app_options.AppOptions.get("pdfBug")) {
  3096. _boundEvents.reportPageStatsPDFBug = reportPageStatsPDFBug;
  3097. eventBus._on("pagerendered", _boundEvents.reportPageStatsPDFBug);
  3098. eventBus._on("pagechanging", _boundEvents.reportPageStatsPDFBug);
  3099. }
  3100. eventBus._on("fileinputchange", webViewerFileInputChange);
  3101. eventBus._on("openfile", webViewerOpenFile);
  3102. },
  3103. bindWindowEvents: function bindWindowEvents() {
  3104. var eventBus = this.eventBus,
  3105. _boundEvents = this._boundEvents;
  3106. _boundEvents.windowResize = function() {
  3107. eventBus.dispatch("resize", {
  3108. source: window
  3109. });
  3110. };
  3111. _boundEvents.windowHashChange = function() {
  3112. eventBus.dispatch("hashchange", {
  3113. source: window,
  3114. hash: document.location.hash.substring(1)
  3115. });
  3116. };
  3117. _boundEvents.windowBeforePrint = function() {
  3118. eventBus.dispatch("beforeprint", {
  3119. source: window
  3120. });
  3121. };
  3122. _boundEvents.windowAfterPrint = function() {
  3123. eventBus.dispatch("afterprint", {
  3124. source: window
  3125. });
  3126. };
  3127. _boundEvents.windowUpdateFromSandbox = function(event) {
  3128. eventBus.dispatch("updatefromsandbox", {
  3129. source: window,
  3130. detail: event.detail
  3131. });
  3132. };
  3133. window.addEventListener("visibilitychange", webViewerVisibilityChange);
  3134. window.addEventListener("wheel", webViewerWheel, {
  3135. passive: false
  3136. });
  3137. window.addEventListener("touchstart", webViewerTouchStart, {
  3138. passive: false
  3139. });
  3140. window.addEventListener("click", webViewerClick);
  3141. window.addEventListener("keydown", webViewerKeyDown);
  3142. window.addEventListener("resize", _boundEvents.windowResize);
  3143. window.addEventListener("hashchange", _boundEvents.windowHashChange);
  3144. window.addEventListener("beforeprint", _boundEvents.windowBeforePrint);
  3145. window.addEventListener("afterprint", _boundEvents.windowAfterPrint);
  3146. window.addEventListener("updatefromsandbox", _boundEvents
  3147. .windowUpdateFromSandbox);
  3148. },
  3149. unbindEvents: function unbindEvents() {
  3150. var eventBus = this.eventBus,
  3151. _boundEvents = this._boundEvents;
  3152. eventBus._off("resize", webViewerResize);
  3153. eventBus._off("hashchange", webViewerHashchange);
  3154. eventBus._off("beforeprint", _boundEvents.beforePrint);
  3155. eventBus._off("afterprint", _boundEvents.afterPrint);
  3156. eventBus._off("pagerendered", webViewerPageRendered);
  3157. eventBus._off("updateviewarea", webViewerUpdateViewarea);
  3158. eventBus._off("pagechanging", webViewerPageChanging);
  3159. eventBus._off("scalechanging", webViewerScaleChanging);
  3160. eventBus._off("rotationchanging", webViewerRotationChanging);
  3161. eventBus._off("sidebarviewchanged", webViewerSidebarViewChanged);
  3162. eventBus._off("pagemode", webViewerPageMode);
  3163. eventBus._off("namedaction", webViewerNamedAction);
  3164. eventBus._off("presentationmodechanged", webViewerPresentationModeChanged);
  3165. eventBus._off("presentationmode", webViewerPresentationMode);
  3166. eventBus._off("print", webViewerPrint);
  3167. eventBus._off("download", webViewerDownload);
  3168. eventBus._off("save", webViewerSave);
  3169. eventBus._off("firstpage", webViewerFirstPage);
  3170. eventBus._off("lastpage", webViewerLastPage);
  3171. eventBus._off("nextpage", webViewerNextPage);
  3172. eventBus._off("previouspage", webViewerPreviousPage);
  3173. eventBus._off("zoomin", webViewerZoomIn);
  3174. eventBus._off("zoomout", webViewerZoomOut);
  3175. eventBus._off("zoomreset", webViewerZoomReset);
  3176. eventBus._off("pagenumberchanged", webViewerPageNumberChanged);
  3177. eventBus._off("scalechanged", webViewerScaleChanged);
  3178. eventBus._off("rotatecw", webViewerRotateCw);
  3179. eventBus._off("rotateccw", webViewerRotateCcw);
  3180. eventBus._off("optionalcontentconfig", webViewerOptionalContentConfig);
  3181. eventBus._off("switchscrollmode", webViewerSwitchScrollMode);
  3182. eventBus._off("scrollmodechanged", webViewerScrollModeChanged);
  3183. eventBus._off("switchspreadmode", webViewerSwitchSpreadMode);
  3184. eventBus._off("spreadmodechanged", webViewerSpreadModeChanged);
  3185. eventBus._off("documentproperties", webViewerDocumentProperties);
  3186. eventBus._off("findfromurlhash", webViewerFindFromUrlHash);
  3187. eventBus._off("updatefindmatchescount", webViewerUpdateFindMatchesCount);
  3188. eventBus._off("updatefindcontrolstate", webViewerUpdateFindControlState);
  3189. if (_boundEvents.reportPageStatsPDFBug) {
  3190. eventBus._off("pagerendered", _boundEvents.reportPageStatsPDFBug);
  3191. eventBus._off("pagechanging", _boundEvents.reportPageStatsPDFBug);
  3192. _boundEvents.reportPageStatsPDFBug = null;
  3193. }
  3194. eventBus._off("fileinputchange", webViewerFileInputChange);
  3195. eventBus._off("openfile", webViewerOpenFile);
  3196. _boundEvents.beforePrint = null;
  3197. _boundEvents.afterPrint = null;
  3198. },
  3199. unbindWindowEvents: function unbindWindowEvents() {
  3200. var _boundEvents = this._boundEvents;
  3201. window.removeEventListener("visibilitychange", webViewerVisibilityChange);
  3202. window.removeEventListener("wheel", webViewerWheel, {
  3203. passive: false
  3204. });
  3205. window.removeEventListener("touchstart", webViewerTouchStart, {
  3206. passive: false
  3207. });
  3208. window.removeEventListener("click", webViewerClick);
  3209. window.removeEventListener("keydown", webViewerKeyDown);
  3210. window.removeEventListener("resize", _boundEvents.windowResize);
  3211. window.removeEventListener("hashchange", _boundEvents.windowHashChange);
  3212. window.removeEventListener("beforeprint", _boundEvents.windowBeforePrint);
  3213. window.removeEventListener("afterprint", _boundEvents.windowAfterPrint);
  3214. window.removeEventListener("updatefromsandbox", _boundEvents
  3215. .windowUpdateFromSandbox);
  3216. _boundEvents.windowResize = null;
  3217. _boundEvents.windowHashChange = null;
  3218. _boundEvents.windowBeforePrint = null;
  3219. _boundEvents.windowAfterPrint = null;
  3220. _boundEvents.windowUpdateFromSandbox = null;
  3221. },
  3222. accumulateWheelTicks: function accumulateWheelTicks(ticks) {
  3223. if (this._wheelUnusedTicks > 0 && ticks < 0 || this._wheelUnusedTicks < 0 &&
  3224. ticks > 0) {
  3225. this._wheelUnusedTicks = 0;
  3226. }
  3227. this._wheelUnusedTicks += ticks;
  3228. var wholeTicks = Math.sign(this._wheelUnusedTicks) * Math.floor(Math.abs(
  3229. this._wheelUnusedTicks));
  3230. this._wheelUnusedTicks -= wholeTicks;
  3231. return wholeTicks;
  3232. },
  3233. _unblockDocumentLoadEvent: function _unblockDocumentLoadEvent() {
  3234. if (document.blockUnblockOnload) {
  3235. document.blockUnblockOnload(false);
  3236. }
  3237. this._unblockDocumentLoadEvent = function() {};
  3238. },
  3239. _reportDocumentStatsTelemetry: function _reportDocumentStatsTelemetry() {
  3240. var stats = this.pdfDocument.stats;
  3241. if (stats !== this._docStats) {
  3242. this._docStats = stats;
  3243. this.externalServices.reportTelemetry({
  3244. type: "documentStats",
  3245. stats: stats
  3246. });
  3247. }
  3248. },
  3249. get scriptingReady() {
  3250. return this.pdfScriptingManager.ready;
  3251. }
  3252. };
  3253. exports.PDFViewerApplication = PDFViewerApplication;
  3254. var validateFileURL; {
  3255. var HOSTED_VIEWER_ORIGINS = ["null", "http://mozilla.github.io",
  3256. "https://mozilla.github.io"
  3257. ];
  3258. validateFileURL = function validateFileURL(file) {
  3259. if (file === undefined) {
  3260. return;
  3261. }
  3262. try {
  3263. var viewerOrigin = new URL(window.location.href).origin || "null";
  3264. if (HOSTED_VIEWER_ORIGINS.includes(viewerOrigin)) {
  3265. return;
  3266. }
  3267. var fileOrigin = new URL(file, window.location.href).origin;
  3268. if (fileOrigin !== viewerOrigin) {
  3269. throw new Error("file origin does not match viewer's");
  3270. }
  3271. } catch (ex) {
  3272. PDFViewerApplication.l10n.get("loading_error").then(function(msg) {
  3273. PDFViewerApplication._documentError(msg, {
  3274. message: ex === null || ex === void 0 ? void 0 : ex
  3275. .message
  3276. });
  3277. });
  3278. throw ex;
  3279. }
  3280. };
  3281. }
  3282. function loadFakeWorker() {
  3283. return _loadFakeWorker.apply(this, arguments);
  3284. }
  3285. function _loadFakeWorker() {
  3286. _loadFakeWorker = _asyncToGenerator( /*#__PURE__*/ _regenerator["default"].mark(
  3287. function _callee17() {
  3288. return _regenerator["default"].wrap(function _callee17$(_context17) {
  3289. while (1) {
  3290. switch (_context17.prev = _context17.next) {
  3291. case 0:
  3292. if (!_pdfjsLib.GlobalWorkerOptions.workerSrc) {
  3293. _pdfjsLib.GlobalWorkerOptions.workerSrc =
  3294. _app_options.AppOptions.get(
  3295. "workerSrc");
  3296. }
  3297. _context17.next = 3;
  3298. return (0, _pdfjsLib.loadScript)(_pdfjsLib
  3299. .PDFWorker.workerSrc);
  3300. case 3:
  3301. case "end":
  3302. return _context17.stop();
  3303. }
  3304. }
  3305. }, _callee17);
  3306. }));
  3307. return _loadFakeWorker.apply(this, arguments);
  3308. }
  3309. function initPDFBug(_x3) {
  3310. return _initPDFBug.apply(this, arguments);
  3311. }
  3312. function _initPDFBug() {
  3313. _initPDFBug = _asyncToGenerator( /*#__PURE__*/ _regenerator["default"].mark(
  3314. function _callee18(enabledTabs) {
  3315. var _PDFViewerApplication7, debuggerScriptPath, mainContainer;
  3316. return _regenerator["default"].wrap(function _callee18$(_context18) {
  3317. while (1) {
  3318. switch (_context18.prev = _context18.next) {
  3319. case 0:
  3320. _PDFViewerApplication7 = PDFViewerApplication
  3321. .appConfig, debuggerScriptPath =
  3322. _PDFViewerApplication7.debuggerScriptPath,
  3323. mainContainer = _PDFViewerApplication7
  3324. .mainContainer;
  3325. _context18.next = 3;
  3326. return (0, _pdfjsLib.loadScript)(
  3327. debuggerScriptPath);
  3328. case 3:
  3329. PDFBug.init({
  3330. OPS: _pdfjsLib.OPS
  3331. }, mainContainer, enabledTabs);
  3332. case 4:
  3333. case "end":
  3334. return _context18.stop();
  3335. }
  3336. }
  3337. }, _callee18);
  3338. }));
  3339. return _initPDFBug.apply(this, arguments);
  3340. }
  3341. function reportPageStatsPDFBug(_ref10) {
  3342. var _pageView$pdfPage;
  3343. var pageNumber = _ref10.pageNumber;
  3344. if (typeof Stats === "undefined" || !Stats.enabled) {
  3345. return;
  3346. }
  3347. var pageView = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
  3348. var pageStats = pageView === null || pageView === void 0 ? void 0 : (_pageView$pdfPage =
  3349. pageView.pdfPage) === null || _pageView$pdfPage === void 0 ? void 0 :
  3350. _pageView$pdfPage.stats;
  3351. if (!pageStats) {
  3352. return;
  3353. }
  3354. Stats.add(pageNumber, pageStats);
  3355. }
  3356. function webViewerInitialized() {
  3357. var _params$get;
  3358. var appConfig = PDFViewerApplication.appConfig;
  3359. var file;
  3360. var queryString = document.location.search.substring(1);
  3361. var params = (0, _ui_utils.parseQueryString)(queryString);
  3362. file = (_params$get = params.get("file")) !== null && _params$get !== void 0 ?
  3363. _params$get : _app_options.AppOptions.get("defaultUrl");
  3364. validateFileURL(file);
  3365. var fileInput = document.createElement("input");
  3366. fileInput.id = appConfig.openFileInputName;
  3367. fileInput.className = "fileInput";
  3368. fileInput.setAttribute("type", "file");
  3369. fileInput.oncontextmenu = _ui_utils.noContextMenuHandler;
  3370. document.body.appendChild(fileInput);
  3371. if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
  3372. appConfig.toolbar.openFile.hidden = true;
  3373. appConfig.secondaryToolbar.openFileButton.hidden = true;
  3374. } else {
  3375. fileInput.value = null;
  3376. }
  3377. fileInput.addEventListener("change", function(evt) {
  3378. var files = evt.target.files;
  3379. if (!files || files.length === 0) {
  3380. return;
  3381. }
  3382. PDFViewerApplication.eventBus.dispatch("fileinputchange", {
  3383. source: this,
  3384. fileInput: evt.target
  3385. });
  3386. });
  3387. appConfig.mainContainer.addEventListener("dragover", function(evt) {
  3388. evt.preventDefault();
  3389. evt.dataTransfer.dropEffect = "move";
  3390. });
  3391. appConfig.mainContainer.addEventListener("drop", function(evt) {
  3392. evt.preventDefault();
  3393. var files = evt.dataTransfer.files;
  3394. if (!files || files.length === 0) {
  3395. return;
  3396. }
  3397. PDFViewerApplication.eventBus.dispatch("fileinputchange", {
  3398. source: this,
  3399. fileInput: evt.dataTransfer
  3400. });
  3401. });
  3402. if (!PDFViewerApplication.supportsDocumentFonts) {
  3403. _app_options.AppOptions.set("disableFontFace", true);
  3404. PDFViewerApplication.l10n.get("web_fonts_disabled").then(function(msg) {
  3405. console.warn(msg);
  3406. });
  3407. }
  3408. if (!PDFViewerApplication.supportsPrinting) {
  3409. appConfig.toolbar.print.classList.add("hidden");
  3410. appConfig.secondaryToolbar.printButton.classList.add("hidden");
  3411. }
  3412. if (!PDFViewerApplication.supportsFullscreen) {
  3413. appConfig.toolbar.presentationModeButton.classList.add("hidden");
  3414. appConfig.secondaryToolbar.presentationModeButton.classList.add("hidden");
  3415. }
  3416. if (PDFViewerApplication.supportsIntegratedFind) {
  3417. appConfig.toolbar.viewFind.classList.add("hidden");
  3418. }
  3419. appConfig.mainContainer.addEventListener("transitionend", function(evt) {
  3420. if (evt.target === this) {
  3421. PDFViewerApplication.eventBus.dispatch("resize", {
  3422. source: this
  3423. });
  3424. }
  3425. }, true);
  3426. try {
  3427. webViewerOpenFileViaURL(file);
  3428. } catch (reason) {
  3429. PDFViewerApplication.l10n.get("loading_error").then(function(msg) {
  3430. PDFViewerApplication._documentError(msg, reason);
  3431. });
  3432. }
  3433. }
  3434. function webViewerOpenFileViaURL(file) {
  3435. if (file) {
  3436. PDFViewerApplication.open(file);
  3437. } else {
  3438. PDFViewerApplication._hideViewBookmark();
  3439. }
  3440. }
  3441. function webViewerPageRendered(_ref11) {
  3442. var pageNumber = _ref11.pageNumber,
  3443. error = _ref11.error;
  3444. if (pageNumber === PDFViewerApplication.page) {
  3445. PDFViewerApplication.toolbar.updateLoadingIndicatorState(false);
  3446. }
  3447. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  3448. var pageView = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
  3449. var thumbnailView = PDFViewerApplication.pdfThumbnailViewer.getThumbnail(
  3450. pageNumber - 1);
  3451. if (pageView && thumbnailView) {
  3452. thumbnailView.setImage(pageView);
  3453. }
  3454. }
  3455. if (error) {
  3456. PDFViewerApplication.l10n.get("rendering_error").then(function(msg) {
  3457. PDFViewerApplication._otherError(msg, error);
  3458. });
  3459. }
  3460. PDFViewerApplication._reportDocumentStatsTelemetry();
  3461. }
  3462. function webViewerPageMode(_ref12) {
  3463. var mode = _ref12.mode;
  3464. var view;
  3465. switch (mode) {
  3466. case "thumbs":
  3467. view = _ui_utils.SidebarView.THUMBS;
  3468. break;
  3469. case "bookmarks":
  3470. case "outline":
  3471. view = _ui_utils.SidebarView.OUTLINE;
  3472. break;
  3473. case "attachments":
  3474. view = _ui_utils.SidebarView.ATTACHMENTS;
  3475. break;
  3476. case "layers":
  3477. view = _ui_utils.SidebarView.LAYERS;
  3478. break;
  3479. case "none":
  3480. view = _ui_utils.SidebarView.NONE;
  3481. break;
  3482. default:
  3483. console.error('Invalid "pagemode" hash parameter: ' + mode);
  3484. return;
  3485. }
  3486. PDFViewerApplication.pdfSidebar.switchView(view, true);
  3487. }
  3488. function webViewerNamedAction(evt) {
  3489. switch (evt.action) {
  3490. case "GoToPage":
  3491. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  3492. break;
  3493. case "Find":
  3494. if (!PDFViewerApplication.supportsIntegratedFind) {
  3495. PDFViewerApplication.findBar.toggle();
  3496. }
  3497. break;
  3498. case "Print":
  3499. PDFViewerApplication.triggerPrinting();
  3500. break;
  3501. case "SaveAs":
  3502. webViewerSave();
  3503. break;
  3504. }
  3505. }
  3506. function webViewerPresentationModeChanged(evt) {
  3507. PDFViewerApplication.pdfViewer.presentationModeState = evt.state;
  3508. }
  3509. function webViewerSidebarViewChanged(evt) {
  3510. PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = PDFViewerApplication
  3511. .pdfSidebar.isThumbnailViewVisible;
  3512. if (PDFViewerApplication.isInitialViewSet) {
  3513. var _PDFViewerApplication;
  3514. (_PDFViewerApplication = PDFViewerApplication.store) === null ||
  3515. _PDFViewerApplication === void 0 ? void 0 : _PDFViewerApplication.set(
  3516. "sidebarView", evt.view)["catch"](function() {});
  3517. }
  3518. }
  3519. function webViewerUpdateViewarea(evt) {
  3520. var location = evt.location;
  3521. if (PDFViewerApplication.isInitialViewSet) {
  3522. var _PDFViewerApplication2;
  3523. (_PDFViewerApplication2 = PDFViewerApplication.store) === null ||
  3524. _PDFViewerApplication2 === void 0 ? void 0 : _PDFViewerApplication2
  3525. .setMultiple({
  3526. page: location.pageNumber,
  3527. zoom: location.scale,
  3528. scrollLeft: location.left,
  3529. scrollTop: location.top,
  3530. rotation: location.rotation
  3531. })["catch"](function() {});
  3532. }
  3533. var href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
  3534. PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href;
  3535. PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
  3536. var currentPage = PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page -
  3537. 1);
  3538. var loading = (currentPage === null || currentPage === void 0 ? void 0 : currentPage
  3539. .renderingState) !== _ui_utils.RenderingStates.FINISHED;
  3540. PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading);
  3541. }
  3542. function webViewerScrollModeChanged(evt) {
  3543. if (PDFViewerApplication.isInitialViewSet) {
  3544. var _PDFViewerApplication3;
  3545. (_PDFViewerApplication3 = PDFViewerApplication.store) === null ||
  3546. _PDFViewerApplication3 === void 0 ? void 0 : _PDFViewerApplication3.set(
  3547. "scrollMode", evt.mode)["catch"](function() {});
  3548. }
  3549. }
  3550. function webViewerSpreadModeChanged(evt) {
  3551. if (PDFViewerApplication.isInitialViewSet) {
  3552. var _PDFViewerApplication4;
  3553. (_PDFViewerApplication4 = PDFViewerApplication.store) === null ||
  3554. _PDFViewerApplication4 === void 0 ? void 0 : _PDFViewerApplication4.set(
  3555. "spreadMode", evt.mode)["catch"](function() {});
  3556. }
  3557. }
  3558. function webViewerResize() {
  3559. var pdfDocument = PDFViewerApplication.pdfDocument,
  3560. pdfViewer = PDFViewerApplication.pdfViewer;
  3561. if (!pdfDocument) {
  3562. return;
  3563. }
  3564. var currentScaleValue = pdfViewer.currentScaleValue;
  3565. if (currentScaleValue === "auto" || currentScaleValue === "page-fit" ||
  3566. currentScaleValue === "page-width") {
  3567. pdfViewer.currentScaleValue = currentScaleValue;
  3568. }
  3569. pdfViewer.update();
  3570. }
  3571. function webViewerHashchange(evt) {
  3572. var _PDFViewerApplication5;
  3573. var hash = evt.hash;
  3574. if (!hash) {
  3575. return;
  3576. }
  3577. if (!PDFViewerApplication.isInitialViewSet) {
  3578. PDFViewerApplication.initialBookmark = hash;
  3579. } else if (!((_PDFViewerApplication5 = PDFViewerApplication.pdfHistory) !== null &&
  3580. _PDFViewerApplication5 !== void 0 && _PDFViewerApplication5.popStateInProgress
  3581. )) {
  3582. PDFViewerApplication.pdfLinkService.setHash(hash);
  3583. }
  3584. }
  3585. var webViewerFileInputChange, webViewerOpenFile; {
  3586. webViewerFileInputChange = function webViewerFileInputChange(evt) {
  3587. var _PDFViewerApplication6;
  3588. if ((_PDFViewerApplication6 = PDFViewerApplication.pdfViewer) !== null &&
  3589. _PDFViewerApplication6 !== void 0 && _PDFViewerApplication6
  3590. .isInPresentationMode) {
  3591. return;
  3592. }
  3593. var file = evt.fileInput.files[0];
  3594. var url = URL.createObjectURL(file);
  3595. if (file.name) {
  3596. url = {
  3597. url: url,
  3598. originalUrl: file.name
  3599. };
  3600. }
  3601. PDFViewerApplication.open(url);
  3602. };
  3603. webViewerOpenFile = function webViewerOpenFile(evt) {
  3604. var openFileInputName = PDFViewerApplication.appConfig.openFileInputName;
  3605. document.getElementById(openFileInputName).click();
  3606. };
  3607. }
  3608. function webViewerPresentationMode() {
  3609. PDFViewerApplication.requestPresentationMode();
  3610. }
  3611. function webViewerPrint() {
  3612. PDFViewerApplication.triggerPrinting();
  3613. }
  3614. function webViewerDownload() {
  3615. PDFViewerApplication.downloadOrSave({
  3616. sourceEventType: "download"
  3617. });
  3618. }
  3619. function webViewerSave() {
  3620. PDFViewerApplication.downloadOrSave({
  3621. sourceEventType: "save"
  3622. });
  3623. }
  3624. function webViewerFirstPage() {
  3625. if (PDFViewerApplication.pdfDocument) {
  3626. PDFViewerApplication.page = 1;
  3627. }
  3628. }
  3629. function webViewerLastPage() {
  3630. if (PDFViewerApplication.pdfDocument) {
  3631. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  3632. }
  3633. }
  3634. function webViewerNextPage() {
  3635. PDFViewerApplication.pdfViewer.nextPage();
  3636. }
  3637. function webViewerPreviousPage() {
  3638. PDFViewerApplication.pdfViewer.previousPage();
  3639. }
  3640. function webViewerZoomIn() {
  3641. PDFViewerApplication.zoomIn();
  3642. }
  3643. function webViewerZoomOut() {
  3644. PDFViewerApplication.zoomOut();
  3645. }
  3646. function webViewerZoomReset() {
  3647. PDFViewerApplication.zoomReset();
  3648. }
  3649. function webViewerPageNumberChanged(evt) {
  3650. var pdfViewer = PDFViewerApplication.pdfViewer;
  3651. if (evt.value !== "") {
  3652. PDFViewerApplication.pdfLinkService.goToPage(evt.value);
  3653. }
  3654. if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer
  3655. .currentPageLabel) {
  3656. PDFViewerApplication.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer
  3657. .currentPageLabel);
  3658. }
  3659. }
  3660. function webViewerScaleChanged(evt) {
  3661. PDFViewerApplication.pdfViewer.currentScaleValue = evt.value;
  3662. }
  3663. function webViewerRotateCw() {
  3664. PDFViewerApplication.rotatePages(90);
  3665. }
  3666. function webViewerRotateCcw() {
  3667. PDFViewerApplication.rotatePages(-90);
  3668. }
  3669. function webViewerOptionalContentConfig(evt) {
  3670. PDFViewerApplication.pdfViewer.optionalContentConfigPromise = evt.promise;
  3671. }
  3672. function webViewerSwitchScrollMode(evt) {
  3673. PDFViewerApplication.pdfViewer.scrollMode = evt.mode;
  3674. }
  3675. function webViewerSwitchSpreadMode(evt) {
  3676. PDFViewerApplication.pdfViewer.spreadMode = evt.mode;
  3677. }
  3678. function webViewerDocumentProperties() {
  3679. PDFViewerApplication.pdfDocumentProperties.open();
  3680. }
  3681. function webViewerFindFromUrlHash(evt) {
  3682. PDFViewerApplication.eventBus.dispatch("find", {
  3683. source: evt.source,
  3684. type: "",
  3685. query: evt.query,
  3686. phraseSearch: evt.phraseSearch,
  3687. caseSensitive: false,
  3688. entireWord: false,
  3689. highlightAll: true,
  3690. findPrevious: false,
  3691. matchDiacritics: true
  3692. });
  3693. }
  3694. function webViewerUpdateFindMatchesCount(_ref13) {
  3695. var matchesCount = _ref13.matchesCount;
  3696. if (PDFViewerApplication.supportsIntegratedFind) {
  3697. PDFViewerApplication.externalServices.updateFindMatchesCount(matchesCount);
  3698. } else {
  3699. PDFViewerApplication.findBar.updateResultsCount(matchesCount);
  3700. }
  3701. }
  3702. function webViewerUpdateFindControlState(_ref14) {
  3703. var state = _ref14.state,
  3704. previous = _ref14.previous,
  3705. matchesCount = _ref14.matchesCount,
  3706. rawQuery = _ref14.rawQuery;
  3707. if (PDFViewerApplication.supportsIntegratedFind) {
  3708. PDFViewerApplication.externalServices.updateFindControlState({
  3709. result: state,
  3710. findPrevious: previous,
  3711. matchesCount: matchesCount,
  3712. rawQuery: rawQuery
  3713. });
  3714. } else {
  3715. PDFViewerApplication.findBar.updateUIState(state, previous, matchesCount);
  3716. }
  3717. }
  3718. function webViewerScaleChanging(evt) {
  3719. PDFViewerApplication.toolbar.setPageScale(evt.presetValue, evt.scale);
  3720. PDFViewerApplication.pdfViewer.update();
  3721. }
  3722. function webViewerRotationChanging(evt) {
  3723. PDFViewerApplication.pdfThumbnailViewer.pagesRotation = evt.pagesRotation;
  3724. PDFViewerApplication.forceRendering();
  3725. PDFViewerApplication.pdfViewer.currentPageNumber = evt.pageNumber;
  3726. }
  3727. function webViewerPageChanging(_ref15) {
  3728. var pageNumber = _ref15.pageNumber,
  3729. pageLabel = _ref15.pageLabel;
  3730. PDFViewerApplication.toolbar.setPageNumber(pageNumber, pageLabel);
  3731. PDFViewerApplication.secondaryToolbar.setPageNumber(pageNumber);
  3732. if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
  3733. PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(pageNumber);
  3734. }
  3735. }
  3736. function webViewerVisibilityChange(evt) {
  3737. if (document.visibilityState === "visible") {
  3738. setZoomDisabledTimeout();
  3739. }
  3740. }
  3741. var zoomDisabledTimeout = null;
  3742. function setZoomDisabledTimeout() {
  3743. if (zoomDisabledTimeout) {
  3744. clearTimeout(zoomDisabledTimeout);
  3745. }
  3746. zoomDisabledTimeout = setTimeout(function() {
  3747. zoomDisabledTimeout = null;
  3748. }, WHEEL_ZOOM_DISABLED_TIMEOUT);
  3749. }
  3750. function webViewerWheel(evt) {
  3751. var pdfViewer = PDFViewerApplication.pdfViewer,
  3752. supportedMouseWheelZoomModifierKeys = PDFViewerApplication
  3753. .supportedMouseWheelZoomModifierKeys;
  3754. if (pdfViewer.isInPresentationMode) {
  3755. return;
  3756. }
  3757. if (evt.ctrlKey && supportedMouseWheelZoomModifierKeys.ctrlKey || evt.metaKey &&
  3758. supportedMouseWheelZoomModifierKeys.metaKey) {
  3759. evt.preventDefault();
  3760. if (zoomDisabledTimeout || document.visibilityState === "hidden") {
  3761. return;
  3762. }
  3763. var deltaMode = evt.deltaMode;
  3764. var delta = (0, _ui_utils.normalizeWheelEventDirection)(evt);
  3765. var previousScale = pdfViewer.currentScale;
  3766. var ticks = 0;
  3767. if (deltaMode === WheelEvent.DOM_DELTA_LINE || deltaMode === WheelEvent
  3768. .DOM_DELTA_PAGE) {
  3769. if (Math.abs(delta) >= 1) {
  3770. ticks = Math.sign(delta);
  3771. } else {
  3772. ticks = PDFViewerApplication.accumulateWheelTicks(delta);
  3773. }
  3774. } else {
  3775. var PIXELS_PER_LINE_SCALE = 30;
  3776. ticks = PDFViewerApplication.accumulateWheelTicks(delta /
  3777. PIXELS_PER_LINE_SCALE);
  3778. }
  3779. if (ticks < 0) {
  3780. PDFViewerApplication.zoomOut(-ticks);
  3781. } else if (ticks > 0) {
  3782. PDFViewerApplication.zoomIn(ticks);
  3783. }
  3784. var currentScale = pdfViewer.currentScale;
  3785. if (previousScale !== currentScale) {
  3786. var scaleCorrectionFactor = currentScale / previousScale - 1;
  3787. var rect = pdfViewer.container.getBoundingClientRect();
  3788. var dx = evt.clientX - rect.left;
  3789. var dy = evt.clientY - rect.top;
  3790. pdfViewer.container.scrollLeft += dx * scaleCorrectionFactor;
  3791. pdfViewer.container.scrollTop += dy * scaleCorrectionFactor;
  3792. }
  3793. } else {
  3794. setZoomDisabledTimeout();
  3795. }
  3796. }
  3797. function webViewerTouchStart(evt) {
  3798. if (evt.touches.length > 1) {
  3799. evt.preventDefault();
  3800. }
  3801. }
  3802. function webViewerClick(evt) {
  3803. if (!PDFViewerApplication.secondaryToolbar.isOpen) {
  3804. return;
  3805. }
  3806. var appConfig = PDFViewerApplication.appConfig;
  3807. if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar
  3808. .container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar
  3809. .toggleButton) {
  3810. PDFViewerApplication.secondaryToolbar.close();
  3811. }
  3812. }
  3813. function webViewerKeyDown(evt) {
  3814. if (PDFViewerApplication.overlayManager.active) {
  3815. return;
  3816. }
  3817. var eventBus = PDFViewerApplication.eventBus,
  3818. pdfViewer = PDFViewerApplication.pdfViewer;
  3819. var isViewerInPresentationMode = pdfViewer.isInPresentationMode;
  3820. var handled = false,
  3821. ensureViewerFocused = false;
  3822. var cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt
  3823. .metaKey ? 8 : 0);
  3824. if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
  3825. switch (evt.keyCode) {
  3826. case 70:
  3827. if (!PDFViewerApplication.supportsIntegratedFind && !evt.shiftKey) {
  3828. PDFViewerApplication.findBar.open();
  3829. handled = true;
  3830. }
  3831. break;
  3832. case 71:
  3833. if (!PDFViewerApplication.supportsIntegratedFind) {
  3834. var state = PDFViewerApplication.findController.state;
  3835. if (state) {
  3836. var eventState = Object.assign(Object.create(null), state, {
  3837. source: window,
  3838. type: "again",
  3839. findPrevious: cmd === 5 || cmd === 12
  3840. });
  3841. eventBus.dispatch("find", eventState);
  3842. }
  3843. handled = true;
  3844. }
  3845. break;
  3846. case 61:
  3847. case 107:
  3848. case 187:
  3849. case 171:
  3850. if (!isViewerInPresentationMode) {
  3851. PDFViewerApplication.zoomIn();
  3852. }
  3853. handled = true;
  3854. break;
  3855. case 173:
  3856. case 109:
  3857. case 189:
  3858. if (!isViewerInPresentationMode) {
  3859. PDFViewerApplication.zoomOut();
  3860. }
  3861. handled = true;
  3862. break;
  3863. case 48:
  3864. case 96:
  3865. if (!isViewerInPresentationMode) {
  3866. setTimeout(function() {
  3867. PDFViewerApplication.zoomReset();
  3868. });
  3869. handled = false;
  3870. }
  3871. break;
  3872. case 38:
  3873. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  3874. PDFViewerApplication.page = 1;
  3875. handled = true;
  3876. ensureViewerFocused = true;
  3877. }
  3878. break;
  3879. case 40:
  3880. if (isViewerInPresentationMode || PDFViewerApplication.page <
  3881. PDFViewerApplication.pagesCount) {
  3882. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  3883. handled = true;
  3884. ensureViewerFocused = true;
  3885. }
  3886. break;
  3887. }
  3888. }
  3889. if (cmd === 1 || cmd === 8) {
  3890. switch (evt.keyCode) {
  3891. case 83:
  3892. eventBus.dispatch("download", {
  3893. source: window
  3894. });
  3895. handled = true;
  3896. break;
  3897. case 79: {
  3898. eventBus.dispatch("openfile", {
  3899. source: window
  3900. });
  3901. handled = true;
  3902. }
  3903. break;
  3904. }
  3905. }
  3906. if (cmd === 3 || cmd === 10) {
  3907. switch (evt.keyCode) {
  3908. case 80:
  3909. PDFViewerApplication.requestPresentationMode();
  3910. handled = true;
  3911. break;
  3912. case 71:
  3913. PDFViewerApplication.appConfig.toolbar.pageNumber.select();
  3914. handled = true;
  3915. break;
  3916. }
  3917. }
  3918. if (handled) {
  3919. if (ensureViewerFocused && !isViewerInPresentationMode) {
  3920. pdfViewer.focus();
  3921. }
  3922. evt.preventDefault();
  3923. return;
  3924. }
  3925. var curElement = (0, _ui_utils.getActiveOrFocusedElement)();
  3926. var curElementTagName = curElement === null || curElement === void 0 ? void 0 :
  3927. curElement.tagName.toUpperCase();
  3928. if (curElementTagName === "INPUT" || curElementTagName === "TEXTAREA" ||
  3929. curElementTagName === "SELECT" || curElement !== null && curElement !== void 0 &&
  3930. curElement.isContentEditable) {
  3931. if (evt.keyCode !== 27) {
  3932. return;
  3933. }
  3934. }
  3935. if (cmd === 0) {
  3936. var turnPage = 0,
  3937. turnOnlyIfPageFit = false;
  3938. switch (evt.keyCode) {
  3939. case 38:
  3940. case 33:
  3941. if (pdfViewer.isVerticalScrollbarEnabled) {
  3942. turnOnlyIfPageFit = true;
  3943. }
  3944. turnPage = -1;
  3945. break;
  3946. case 8:
  3947. if (!isViewerInPresentationMode) {
  3948. turnOnlyIfPageFit = true;
  3949. }
  3950. turnPage = -1;
  3951. break;
  3952. case 37:
  3953. if (pdfViewer.isHorizontalScrollbarEnabled) {
  3954. turnOnlyIfPageFit = true;
  3955. }
  3956. case 75:
  3957. case 80:
  3958. turnPage = -1;
  3959. break;
  3960. case 27:
  3961. if (PDFViewerApplication.secondaryToolbar.isOpen) {
  3962. PDFViewerApplication.secondaryToolbar.close();
  3963. handled = true;
  3964. }
  3965. if (!PDFViewerApplication.supportsIntegratedFind && PDFViewerApplication
  3966. .findBar.opened) {
  3967. PDFViewerApplication.findBar.close();
  3968. handled = true;
  3969. }
  3970. break;
  3971. case 40:
  3972. case 34:
  3973. if (pdfViewer.isVerticalScrollbarEnabled) {
  3974. turnOnlyIfPageFit = true;
  3975. }
  3976. turnPage = 1;
  3977. break;
  3978. case 13:
  3979. case 32:
  3980. if (!isViewerInPresentationMode) {
  3981. turnOnlyIfPageFit = true;
  3982. }
  3983. turnPage = 1;
  3984. break;
  3985. case 39:
  3986. if (pdfViewer.isHorizontalScrollbarEnabled) {
  3987. turnOnlyIfPageFit = true;
  3988. }
  3989. case 74:
  3990. case 78:
  3991. turnPage = 1;
  3992. break;
  3993. case 36:
  3994. if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
  3995. PDFViewerApplication.page = 1;
  3996. handled = true;
  3997. ensureViewerFocused = true;
  3998. }
  3999. break;
  4000. case 35:
  4001. if (isViewerInPresentationMode || PDFViewerApplication.page <
  4002. PDFViewerApplication.pagesCount) {
  4003. PDFViewerApplication.page = PDFViewerApplication.pagesCount;
  4004. handled = true;
  4005. ensureViewerFocused = true;
  4006. }
  4007. break;
  4008. case 83:
  4009. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools
  4010. .CursorTool.SELECT);
  4011. break;
  4012. case 72:
  4013. PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools
  4014. .CursorTool.HAND);
  4015. break;
  4016. case 82:
  4017. PDFViewerApplication.rotatePages(90);
  4018. break;
  4019. case 115:
  4020. PDFViewerApplication.pdfSidebar.toggle();
  4021. break;
  4022. }
  4023. if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue ===
  4024. "page-fit")) {
  4025. if (turnPage > 0) {
  4026. pdfViewer.nextPage();
  4027. } else {
  4028. pdfViewer.previousPage();
  4029. }
  4030. handled = true;
  4031. }
  4032. }
  4033. if (cmd === 4) {
  4034. switch (evt.keyCode) {
  4035. case 13:
  4036. case 32:
  4037. if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !==
  4038. "page-fit") {
  4039. break;
  4040. }
  4041. pdfViewer.previousPage();
  4042. handled = true;
  4043. break;
  4044. case 82:
  4045. PDFViewerApplication.rotatePages(-90);
  4046. break;
  4047. }
  4048. }
  4049. if (!handled && !isViewerInPresentationMode) {
  4050. if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 &&
  4051. curElementTagName !== "BUTTON") {
  4052. ensureViewerFocused = true;
  4053. }
  4054. }
  4055. if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
  4056. pdfViewer.focus();
  4057. }
  4058. if (handled) {
  4059. evt.preventDefault();
  4060. }
  4061. }
  4062. function beforeUnload(evt) {
  4063. evt.preventDefault();
  4064. evt.returnValue = "";
  4065. return false;
  4066. }
  4067. var PDFPrintServiceFactory = {
  4068. instance: {
  4069. supportsPrinting: false,
  4070. createPrintService: function createPrintService() {
  4071. throw new Error("Not implemented: createPrintService");
  4072. }
  4073. }
  4074. };
  4075. exports.PDFPrintServiceFactory = PDFPrintServiceFactory;
  4076. /***/
  4077. }),
  4078. /* 3 */
  4079. /***/
  4080. ((module, __unused_webpack_exports, __webpack_require__) => {
  4081. module.exports = __webpack_require__(4);
  4082. /***/
  4083. }),
  4084. /* 4 */
  4085. /***/
  4086. ((module, __unused_webpack_exports, __webpack_require__) => {
  4087. /* module decorator */
  4088. module = __webpack_require__.nmd(module);
  4089. function _typeof(obj) {
  4090. "@babel/helpers - typeof";
  4091. return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ?
  4092. function(obj) {
  4093. return typeof obj;
  4094. } : function(obj) {
  4095. return obj && "function" == typeof Symbol && obj.constructor === Symbol &&
  4096. obj !== Symbol.prototype ? "symbol" : typeof obj;
  4097. }, _typeof(obj);
  4098. }
  4099. var runtime = function(exports) {
  4100. "use strict";
  4101. var Op = Object.prototype;
  4102. var hasOwn = Op.hasOwnProperty;
  4103. var undefined;
  4104. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  4105. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  4106. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  4107. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  4108. function define(obj, key, value) {
  4109. Object.defineProperty(obj, key, {
  4110. value: value,
  4111. enumerable: true,
  4112. configurable: true,
  4113. writable: true
  4114. });
  4115. return obj[key];
  4116. }
  4117. try {
  4118. define({}, "");
  4119. } catch (err) {
  4120. define = function define(obj, key, value) {
  4121. return obj[key] = value;
  4122. };
  4123. }
  4124. function wrap(innerFn, outerFn, self, tryLocsList) {
  4125. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ?
  4126. outerFn : Generator;
  4127. var generator = Object.create(protoGenerator.prototype);
  4128. var context = new Context(tryLocsList || []);
  4129. generator._invoke = makeInvokeMethod(innerFn, self, context);
  4130. return generator;
  4131. }
  4132. exports.wrap = wrap;
  4133. function tryCatch(fn, obj, arg) {
  4134. try {
  4135. return {
  4136. type: "normal",
  4137. arg: fn.call(obj, arg)
  4138. };
  4139. } catch (err) {
  4140. return {
  4141. type: "throw",
  4142. arg: err
  4143. };
  4144. }
  4145. }
  4146. var GenStateSuspendedStart = "suspendedStart";
  4147. var GenStateSuspendedYield = "suspendedYield";
  4148. var GenStateExecuting = "executing";
  4149. var GenStateCompleted = "completed";
  4150. var ContinueSentinel = {};
  4151. function Generator() {}
  4152. function GeneratorFunction() {}
  4153. function GeneratorFunctionPrototype() {}
  4154. var IteratorPrototype = {};
  4155. define(IteratorPrototype, iteratorSymbol, function() {
  4156. return this;
  4157. });
  4158. var getProto = Object.getPrototypeOf;
  4159. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  4160. if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(
  4161. NativeIteratorPrototype, iteratorSymbol)) {
  4162. IteratorPrototype = NativeIteratorPrototype;
  4163. }
  4164. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(
  4165. IteratorPrototype);
  4166. GeneratorFunction.prototype = GeneratorFunctionPrototype;
  4167. define(Gp, "constructor", GeneratorFunctionPrototype);
  4168. define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
  4169. GeneratorFunction.displayName = define(GeneratorFunctionPrototype,
  4170. toStringTagSymbol, "GeneratorFunction");
  4171. function defineIteratorMethods(prototype) {
  4172. ["next", "throw", "return"].forEach(function(method) {
  4173. define(prototype, method, function(arg) {
  4174. return this._invoke(method, arg);
  4175. });
  4176. });
  4177. }
  4178. exports.isGeneratorFunction = function(genFun) {
  4179. var ctor = typeof genFun === "function" && genFun.constructor;
  4180. return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor
  4181. .name) === "GeneratorFunction" : false;
  4182. };
  4183. exports.mark = function(genFun) {
  4184. if (Object.setPrototypeOf) {
  4185. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  4186. } else {
  4187. genFun.__proto__ = GeneratorFunctionPrototype;
  4188. define(genFun, toStringTagSymbol, "GeneratorFunction");
  4189. }
  4190. genFun.prototype = Object.create(Gp);
  4191. return genFun;
  4192. };
  4193. exports.awrap = function(arg) {
  4194. return {
  4195. __await: arg
  4196. };
  4197. };
  4198. function AsyncIterator(generator, PromiseImpl) {
  4199. function invoke(method, arg, resolve, reject) {
  4200. var record = tryCatch(generator[method], generator, arg);
  4201. if (record.type === "throw") {
  4202. reject(record.arg);
  4203. } else {
  4204. var result = record.arg;
  4205. var value = result.value;
  4206. if (value && _typeof(value) === "object" && hasOwn.call(value,
  4207. "__await")) {
  4208. return PromiseImpl.resolve(value.__await).then(function(value) {
  4209. invoke("next", value, resolve, reject);
  4210. }, function(err) {
  4211. invoke("throw", err, resolve, reject);
  4212. });
  4213. }
  4214. return PromiseImpl.resolve(value).then(function(unwrapped) {
  4215. result.value = unwrapped;
  4216. resolve(result);
  4217. }, function(error) {
  4218. return invoke("throw", error, resolve, reject);
  4219. });
  4220. }
  4221. }
  4222. var previousPromise;
  4223. function enqueue(method, arg) {
  4224. function callInvokeWithMethodAndArg() {
  4225. return new PromiseImpl(function(resolve, reject) {
  4226. invoke(method, arg, resolve, reject);
  4227. });
  4228. }
  4229. return previousPromise = previousPromise ? previousPromise.then(
  4230. callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) :
  4231. callInvokeWithMethodAndArg();
  4232. }
  4233. this._invoke = enqueue;
  4234. }
  4235. defineIteratorMethods(AsyncIterator.prototype);
  4236. define(AsyncIterator.prototype, asyncIteratorSymbol, function() {
  4237. return this;
  4238. });
  4239. exports.AsyncIterator = AsyncIterator;
  4240. exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  4241. if (PromiseImpl === void 0) PromiseImpl = Promise;
  4242. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList),
  4243. PromiseImpl);
  4244. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(
  4245. function(result) {
  4246. return result.done ? result.value : iter.next();
  4247. });
  4248. };
  4249. function makeInvokeMethod(innerFn, self, context) {
  4250. var state = GenStateSuspendedStart;
  4251. return function invoke(method, arg) {
  4252. if (state === GenStateExecuting) {
  4253. throw new Error("Generator is already running");
  4254. }
  4255. if (state === GenStateCompleted) {
  4256. if (method === "throw") {
  4257. throw arg;
  4258. }
  4259. return doneResult();
  4260. }
  4261. context.method = method;
  4262. context.arg = arg;
  4263. while (true) {
  4264. var delegate = context.delegate;
  4265. if (delegate) {
  4266. var delegateResult = maybeInvokeDelegate(delegate, context);
  4267. if (delegateResult) {
  4268. if (delegateResult === ContinueSentinel) continue;
  4269. return delegateResult;
  4270. }
  4271. }
  4272. if (context.method === "next") {
  4273. context.sent = context._sent = context.arg;
  4274. } else if (context.method === "throw") {
  4275. if (state === GenStateSuspendedStart) {
  4276. state = GenStateCompleted;
  4277. throw context.arg;
  4278. }
  4279. context.dispatchException(context.arg);
  4280. } else if (context.method === "return") {
  4281. context.abrupt("return", context.arg);
  4282. }
  4283. state = GenStateExecuting;
  4284. var record = tryCatch(innerFn, self, context);
  4285. if (record.type === "normal") {
  4286. state = context.done ? GenStateCompleted :
  4287. GenStateSuspendedYield;
  4288. if (record.arg === ContinueSentinel) {
  4289. continue;
  4290. }
  4291. return {
  4292. value: record.arg,
  4293. done: context.done
  4294. };
  4295. } else if (record.type === "throw") {
  4296. state = GenStateCompleted;
  4297. context.method = "throw";
  4298. context.arg = record.arg;
  4299. }
  4300. }
  4301. };
  4302. }
  4303. function maybeInvokeDelegate(delegate, context) {
  4304. var method = delegate.iterator[context.method];
  4305. if (method === undefined) {
  4306. context.delegate = null;
  4307. if (context.method === "throw") {
  4308. if (delegate.iterator["return"]) {
  4309. context.method = "return";
  4310. context.arg = undefined;
  4311. maybeInvokeDelegate(delegate, context);
  4312. if (context.method === "throw") {
  4313. return ContinueSentinel;
  4314. }
  4315. }
  4316. context.method = "throw";
  4317. context.arg = new TypeError(
  4318. "The iterator does not provide a 'throw' method");
  4319. }
  4320. return ContinueSentinel;
  4321. }
  4322. var record = tryCatch(method, delegate.iterator, context.arg);
  4323. if (record.type === "throw") {
  4324. context.method = "throw";
  4325. context.arg = record.arg;
  4326. context.delegate = null;
  4327. return ContinueSentinel;
  4328. }
  4329. var info = record.arg;
  4330. if (!info) {
  4331. context.method = "throw";
  4332. context.arg = new TypeError("iterator result is not an object");
  4333. context.delegate = null;
  4334. return ContinueSentinel;
  4335. }
  4336. if (info.done) {
  4337. context[delegate.resultName] = info.value;
  4338. context.next = delegate.nextLoc;
  4339. if (context.method !== "return") {
  4340. context.method = "next";
  4341. context.arg = undefined;
  4342. }
  4343. } else {
  4344. return info;
  4345. }
  4346. context.delegate = null;
  4347. return ContinueSentinel;
  4348. }
  4349. defineIteratorMethods(Gp);
  4350. define(Gp, toStringTagSymbol, "Generator");
  4351. define(Gp, iteratorSymbol, function() {
  4352. return this;
  4353. });
  4354. define(Gp, "toString", function() {
  4355. return "[object Generator]";
  4356. });
  4357. function pushTryEntry(locs) {
  4358. var entry = {
  4359. tryLoc: locs[0]
  4360. };
  4361. if (1 in locs) {
  4362. entry.catchLoc = locs[1];
  4363. }
  4364. if (2 in locs) {
  4365. entry.finallyLoc = locs[2];
  4366. entry.afterLoc = locs[3];
  4367. }
  4368. this.tryEntries.push(entry);
  4369. }
  4370. function resetTryEntry(entry) {
  4371. var record = entry.completion || {};
  4372. record.type = "normal";
  4373. delete record.arg;
  4374. entry.completion = record;
  4375. }
  4376. function Context(tryLocsList) {
  4377. this.tryEntries = [{
  4378. tryLoc: "root"
  4379. }];
  4380. tryLocsList.forEach(pushTryEntry, this);
  4381. this.reset(true);
  4382. }
  4383. exports.keys = function(object) {
  4384. var keys = [];
  4385. for (var key in object) {
  4386. keys.push(key);
  4387. }
  4388. keys.reverse();
  4389. return function next() {
  4390. while (keys.length) {
  4391. var key = keys.pop();
  4392. if (key in object) {
  4393. next.value = key;
  4394. next.done = false;
  4395. return next;
  4396. }
  4397. }
  4398. next.done = true;
  4399. return next;
  4400. };
  4401. };
  4402. function values(iterable) {
  4403. if (iterable) {
  4404. var iteratorMethod = iterable[iteratorSymbol];
  4405. if (iteratorMethod) {
  4406. return iteratorMethod.call(iterable);
  4407. }
  4408. if (typeof iterable.next === "function") {
  4409. return iterable;
  4410. }
  4411. if (!isNaN(iterable.length)) {
  4412. var i = -1,
  4413. next = function next() {
  4414. while (++i < iterable.length) {
  4415. if (hasOwn.call(iterable, i)) {
  4416. next.value = iterable[i];
  4417. next.done = false;
  4418. return next;
  4419. }
  4420. }
  4421. next.value = undefined;
  4422. next.done = true;
  4423. return next;
  4424. };
  4425. return next.next = next;
  4426. }
  4427. }
  4428. return {
  4429. next: doneResult
  4430. };
  4431. }
  4432. exports.values = values;
  4433. function doneResult() {
  4434. return {
  4435. value: undefined,
  4436. done: true
  4437. };
  4438. }
  4439. Context.prototype = {
  4440. constructor: Context,
  4441. reset: function reset(skipTempReset) {
  4442. this.prev = 0;
  4443. this.next = 0;
  4444. this.sent = this._sent = undefined;
  4445. this.done = false;
  4446. this.delegate = null;
  4447. this.method = "next";
  4448. this.arg = undefined;
  4449. this.tryEntries.forEach(resetTryEntry);
  4450. if (!skipTempReset) {
  4451. for (var name in this) {
  4452. if (name.charAt(0) === "t" && hasOwn.call(this, name) && !
  4453. isNaN(+name.slice(1))) {
  4454. this[name] = undefined;
  4455. }
  4456. }
  4457. }
  4458. },
  4459. stop: function stop() {
  4460. this.done = true;
  4461. var rootEntry = this.tryEntries[0];
  4462. var rootRecord = rootEntry.completion;
  4463. if (rootRecord.type === "throw") {
  4464. throw rootRecord.arg;
  4465. }
  4466. return this.rval;
  4467. },
  4468. dispatchException: function dispatchException(exception) {
  4469. if (this.done) {
  4470. throw exception;
  4471. }
  4472. var context = this;
  4473. function handle(loc, caught) {
  4474. record.type = "throw";
  4475. record.arg = exception;
  4476. context.next = loc;
  4477. if (caught) {
  4478. context.method = "next";
  4479. context.arg = undefined;
  4480. }
  4481. return !!caught;
  4482. }
  4483. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  4484. var entry = this.tryEntries[i];
  4485. var record = entry.completion;
  4486. if (entry.tryLoc === "root") {
  4487. return handle("end");
  4488. }
  4489. if (entry.tryLoc <= this.prev) {
  4490. var hasCatch = hasOwn.call(entry, "catchLoc");
  4491. var hasFinally = hasOwn.call(entry, "finallyLoc");
  4492. if (hasCatch && hasFinally) {
  4493. if (this.prev < entry.catchLoc) {
  4494. return handle(entry.catchLoc, true);
  4495. } else if (this.prev < entry.finallyLoc) {
  4496. return handle(entry.finallyLoc);
  4497. }
  4498. } else if (hasCatch) {
  4499. if (this.prev < entry.catchLoc) {
  4500. return handle(entry.catchLoc, true);
  4501. }
  4502. } else if (hasFinally) {
  4503. if (this.prev < entry.finallyLoc) {
  4504. return handle(entry.finallyLoc);
  4505. }
  4506. } else {
  4507. throw new Error(
  4508. "try statement without catch or finally");
  4509. }
  4510. }
  4511. }
  4512. },
  4513. abrupt: function abrupt(type, arg) {
  4514. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  4515. var entry = this.tryEntries[i];
  4516. if (entry.tryLoc <= this.prev && hasOwn.call(entry,
  4517. "finallyLoc") && this.prev < entry.finallyLoc) {
  4518. var finallyEntry = entry;
  4519. break;
  4520. }
  4521. }
  4522. if (finallyEntry && (type === "break" || type === "continue") &&
  4523. finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
  4524. finallyEntry = null;
  4525. }
  4526. var record = finallyEntry ? finallyEntry.completion : {};
  4527. record.type = type;
  4528. record.arg = arg;
  4529. if (finallyEntry) {
  4530. this.method = "next";
  4531. this.next = finallyEntry.finallyLoc;
  4532. return ContinueSentinel;
  4533. }
  4534. return this.complete(record);
  4535. },
  4536. complete: function complete(record, afterLoc) {
  4537. if (record.type === "throw") {
  4538. throw record.arg;
  4539. }
  4540. if (record.type === "break" || record.type === "continue") {
  4541. this.next = record.arg;
  4542. } else if (record.type === "return") {
  4543. this.rval = this.arg = record.arg;
  4544. this.method = "return";
  4545. this.next = "end";
  4546. } else if (record.type === "normal" && afterLoc) {
  4547. this.next = afterLoc;
  4548. }
  4549. return ContinueSentinel;
  4550. },
  4551. finish: function finish(finallyLoc) {
  4552. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  4553. var entry = this.tryEntries[i];
  4554. if (entry.finallyLoc === finallyLoc) {
  4555. this.complete(entry.completion, entry.afterLoc);
  4556. resetTryEntry(entry);
  4557. return ContinueSentinel;
  4558. }
  4559. }
  4560. },
  4561. "catch": function _catch(tryLoc) {
  4562. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  4563. var entry = this.tryEntries[i];
  4564. if (entry.tryLoc === tryLoc) {
  4565. var record = entry.completion;
  4566. if (record.type === "throw") {
  4567. var thrown = record.arg;
  4568. resetTryEntry(entry);
  4569. }
  4570. return thrown;
  4571. }
  4572. }
  4573. throw new Error("illegal catch attempt");
  4574. },
  4575. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  4576. this.delegate = {
  4577. iterator: values(iterable),
  4578. resultName: resultName,
  4579. nextLoc: nextLoc
  4580. };
  4581. if (this.method === "next") {
  4582. this.arg = undefined;
  4583. }
  4584. return ContinueSentinel;
  4585. }
  4586. };
  4587. return exports;
  4588. }((false ? 0 : _typeof(module)) === "object" ? module.exports : {});
  4589. try {
  4590. regeneratorRuntime = runtime;
  4591. } catch (accidentalStrictMode) {
  4592. if ((typeof globalThis === "undefined" ? "undefined" : _typeof(globalThis)) ===
  4593. "object") {
  4594. globalThis.regeneratorRuntime = runtime;
  4595. } else {
  4596. Function("r", "regeneratorRuntime = r")(runtime);
  4597. }
  4598. }
  4599. /***/
  4600. }),
  4601. /* 5 */
  4602. /***/
  4603. ((__unused_webpack_module, exports) => {
  4604. Object.defineProperty(exports, "__esModule", ({
  4605. value: true
  4606. }));
  4607. exports.animationStarted = exports.VERTICAL_PADDING = exports.UNKNOWN_SCALE = exports
  4608. .TextLayerMode = exports.SpreadMode = exports.SidebarView = exports.ScrollMode = exports
  4609. .SCROLLBAR_PADDING = exports.RenderingStates = exports.RendererType = exports
  4610. .ProgressBar = exports.PresentationModeState = exports.OutputScale = exports.MIN_SCALE =
  4611. exports.MAX_SCALE = exports.MAX_AUTO_SCALE = exports.DEFAULT_SCALE_VALUE = exports
  4612. .DEFAULT_SCALE_DELTA = exports.DEFAULT_SCALE = exports.AutoPrintRegExp = void 0;
  4613. exports.apiPageLayoutToViewerModes = apiPageLayoutToViewerModes;
  4614. exports.apiPageModeToSidebarView = apiPageModeToSidebarView;
  4615. exports.approximateFraction = approximateFraction;
  4616. exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
  4617. exports.binarySearchFirstItem = binarySearchFirstItem;
  4618. exports.getActiveOrFocusedElement = getActiveOrFocusedElement;
  4619. exports.getPageSizeInches = getPageSizeInches;
  4620. exports.getVisibleElements = getVisibleElements;
  4621. exports.isPortraitOrientation = isPortraitOrientation;
  4622. exports.isValidRotation = isValidRotation;
  4623. exports.isValidScrollMode = isValidScrollMode;
  4624. exports.isValidSpreadMode = isValidSpreadMode;
  4625. exports.noContextMenuHandler = noContextMenuHandler;
  4626. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  4627. exports.normalizeWheelEventDirection = normalizeWheelEventDirection;
  4628. exports.parseQueryString = parseQueryString;
  4629. exports.removeNullCharacters = removeNullCharacters;
  4630. exports.roundToDivide = roundToDivide;
  4631. exports.scrollIntoView = scrollIntoView;
  4632. exports.watchScroll = watchScroll;
  4633. function _slicedToArray(arr, i) {
  4634. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) ||
  4635. _unsupportedIterableToArray(arr, i) || _nonIterableRest();
  4636. }
  4637. function _nonIterableRest() {
  4638. throw new TypeError(
  4639. "Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
  4640. );
  4641. }
  4642. function _iterableToArrayLimit(arr, i) {
  4643. var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] ||
  4644. arr["@@iterator"];
  4645. if (_i == null) return;
  4646. var _arr = [];
  4647. var _n = true;
  4648. var _d = false;
  4649. var _s, _e;
  4650. try {
  4651. for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
  4652. _arr.push(_s.value);
  4653. if (i && _arr.length === i) break;
  4654. }
  4655. } catch (err) {
  4656. _d = true;
  4657. _e = err;
  4658. } finally {
  4659. try {
  4660. if (!_n && _i["return"] != null) _i["return"]();
  4661. } finally {
  4662. if (_d) throw _e;
  4663. }
  4664. }
  4665. return _arr;
  4666. }
  4667. function _arrayWithHoles(arr) {
  4668. if (Array.isArray(arr)) return arr;
  4669. }
  4670. function _createForOfIteratorHelper(o, allowArrayLike) {
  4671. var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
  4672. if (!it) {
  4673. if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike &&
  4674. o && typeof o.length === "number") {
  4675. if (it) o = it;
  4676. var i = 0;
  4677. var F = function F() {};
  4678. return {
  4679. s: F,
  4680. n: function n() {
  4681. if (i >= o.length) return {
  4682. done: true
  4683. };
  4684. return {
  4685. done: false,
  4686. value: o[i++]
  4687. };
  4688. },
  4689. e: function e(_e2) {
  4690. throw _e2;
  4691. },
  4692. f: F
  4693. };
  4694. }
  4695. throw new TypeError(
  4696. "Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
  4697. );
  4698. }
  4699. var normalCompletion = true,
  4700. didErr = false,
  4701. err;
  4702. return {
  4703. s: function s() {
  4704. it = it.call(o);
  4705. },
  4706. n: function n() {
  4707. var step = it.next();
  4708. normalCompletion = step.done;
  4709. return step;
  4710. },
  4711. e: function e(_e3) {
  4712. didErr = true;
  4713. err = _e3;
  4714. },
  4715. f: function f() {
  4716. try {
  4717. if (!normalCompletion && it["return"] != null) it["return"]();
  4718. } finally {
  4719. if (didErr) throw err;
  4720. }
  4721. }
  4722. };
  4723. }
  4724. function _unsupportedIterableToArray(o, minLen) {
  4725. if (!o) return;
  4726. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  4727. var n = Object.prototype.toString.call(o).slice(8, -1);
  4728. if (n === "Object" && o.constructor) n = o.constructor.name;
  4729. if (n === "Map" || n === "Set") return Array.from(o);
  4730. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
  4731. return _arrayLikeToArray(o, minLen);
  4732. }
  4733. function _arrayLikeToArray(arr, len) {
  4734. if (len == null || len > arr.length) len = arr.length;
  4735. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  4736. arr2[i] = arr[i];
  4737. }
  4738. return arr2;
  4739. }
  4740. function _classCallCheck(instance, Constructor) {
  4741. if (!(instance instanceof Constructor)) {
  4742. throw new TypeError("Cannot call a class as a function");
  4743. }
  4744. }
  4745. function _defineProperties(target, props) {
  4746. for (var i = 0; i < props.length; i++) {
  4747. var descriptor = props[i];
  4748. descriptor.enumerable = descriptor.enumerable || false;
  4749. descriptor.configurable = true;
  4750. if ("value" in descriptor) descriptor.writable = true;
  4751. Object.defineProperty(target, descriptor.key, descriptor);
  4752. }
  4753. }
  4754. function _createClass(Constructor, protoProps, staticProps) {
  4755. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  4756. if (staticProps) _defineProperties(Constructor, staticProps);
  4757. Object.defineProperty(Constructor, "prototype", {
  4758. writable: false
  4759. });
  4760. return Constructor;
  4761. }
  4762. var DEFAULT_SCALE_VALUE = "auto";
  4763. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  4764. var DEFAULT_SCALE = 1.0;
  4765. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  4766. var DEFAULT_SCALE_DELTA = 1.1;
  4767. exports.DEFAULT_SCALE_DELTA = DEFAULT_SCALE_DELTA;
  4768. var MIN_SCALE = 0.1;
  4769. exports.MIN_SCALE = MIN_SCALE;
  4770. var MAX_SCALE = 10.0;
  4771. exports.MAX_SCALE = MAX_SCALE;
  4772. var UNKNOWN_SCALE = 0;
  4773. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  4774. var MAX_AUTO_SCALE = 1.25;
  4775. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  4776. var SCROLLBAR_PADDING = 40;
  4777. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  4778. var VERTICAL_PADDING = 5;
  4779. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  4780. var LOADINGBAR_END_OFFSET_VAR = "--loadingBar-end-offset";
  4781. var RenderingStates = {
  4782. INITIAL: 0,
  4783. RUNNING: 1,
  4784. PAUSED: 2,
  4785. FINISHED: 3
  4786. };
  4787. exports.RenderingStates = RenderingStates;
  4788. var PresentationModeState = {
  4789. UNKNOWN: 0,
  4790. NORMAL: 1,
  4791. CHANGING: 2,
  4792. FULLSCREEN: 3
  4793. };
  4794. exports.PresentationModeState = PresentationModeState;
  4795. var SidebarView = {
  4796. UNKNOWN: -1,
  4797. NONE: 0,
  4798. THUMBS: 1,
  4799. OUTLINE: 2,
  4800. ATTACHMENTS: 3,
  4801. LAYERS: 4
  4802. };
  4803. exports.SidebarView = SidebarView;
  4804. var RendererType = {
  4805. CANVAS: "canvas",
  4806. SVG: "svg"
  4807. };
  4808. exports.RendererType = RendererType;
  4809. var TextLayerMode = {
  4810. DISABLE: 0,
  4811. ENABLE: 1,
  4812. ENABLE_ENHANCE: 2
  4813. };
  4814. exports.TextLayerMode = TextLayerMode;
  4815. var ScrollMode = {
  4816. UNKNOWN: -1,
  4817. VERTICAL: 0,
  4818. HORIZONTAL: 1,
  4819. WRAPPED: 2,
  4820. PAGE: 3
  4821. };
  4822. exports.ScrollMode = ScrollMode;
  4823. var SpreadMode = {
  4824. UNKNOWN: -1,
  4825. NONE: 0,
  4826. ODD: 1,
  4827. EVEN: 2
  4828. };
  4829. exports.SpreadMode = SpreadMode;
  4830. var AutoPrintRegExp = /\bprint\s*\(/;
  4831. exports.AutoPrintRegExp = AutoPrintRegExp;
  4832. var OutputScale = /*#__PURE__*/ function() {
  4833. function OutputScale() {
  4834. _classCallCheck(this, OutputScale);
  4835. var pixelRatio = window.devicePixelRatio || 1;
  4836. this.sx = pixelRatio;
  4837. this.sy = pixelRatio;
  4838. }
  4839. _createClass(OutputScale, [{
  4840. key: "scaled",
  4841. get: function get() {
  4842. return this.sx !== 1 || this.sy !== 1;
  4843. }
  4844. }]);
  4845. return OutputScale;
  4846. }();
  4847. exports.OutputScale = OutputScale;
  4848. function scrollIntoView(element, spot) {
  4849. var scrollMatches = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] :
  4850. false;
  4851. var parent = element.offsetParent;
  4852. if (!parent) {
  4853. console.error("offsetParent is not set -- cannot scroll");
  4854. return;
  4855. }
  4856. var offsetY = element.offsetTop + element.clientTop;
  4857. var offsetX = element.offsetLeft + element.clientLeft;
  4858. while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent
  4859. .scrollWidth || scrollMatches && (parent.classList.contains("markedContent") ||
  4860. getComputedStyle(parent).overflow === "hidden")) {
  4861. offsetY += parent.offsetTop;
  4862. offsetX += parent.offsetLeft;
  4863. parent = parent.offsetParent;
  4864. if (!parent) {
  4865. return;
  4866. }
  4867. }
  4868. if (spot) {
  4869. if (spot.top !== undefined) {
  4870. offsetY += spot.top;
  4871. }
  4872. if (spot.left !== undefined) {
  4873. offsetX += spot.left;
  4874. parent.scrollLeft = offsetX;
  4875. }
  4876. }
  4877. parent.scrollTop = offsetY;
  4878. }
  4879. function watchScroll(viewAreaElement, callback) {
  4880. var debounceScroll = function debounceScroll(evt) {
  4881. if (rAF) {
  4882. return;
  4883. }
  4884. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  4885. rAF = null;
  4886. var currentX = viewAreaElement.scrollLeft;
  4887. var lastX = state.lastX;
  4888. if (currentX !== lastX) {
  4889. state.right = currentX > lastX;
  4890. }
  4891. state.lastX = currentX;
  4892. var currentY = viewAreaElement.scrollTop;
  4893. var lastY = state.lastY;
  4894. if (currentY !== lastY) {
  4895. state.down = currentY > lastY;
  4896. }
  4897. state.lastY = currentY;
  4898. callback(state);
  4899. });
  4900. };
  4901. var state = {
  4902. right: true,
  4903. down: true,
  4904. lastX: viewAreaElement.scrollLeft,
  4905. lastY: viewAreaElement.scrollTop,
  4906. _eventHandler: debounceScroll
  4907. };
  4908. var rAF = null;
  4909. viewAreaElement.addEventListener("scroll", debounceScroll, true);
  4910. return state;
  4911. }
  4912. function parseQueryString(query) {
  4913. var params = new Map();
  4914. var _iterator = _createForOfIteratorHelper(new URLSearchParams(query)),
  4915. _step;
  4916. try {
  4917. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  4918. var _step$value = _slicedToArray(_step.value, 2),
  4919. key = _step$value[0],
  4920. value = _step$value[1];
  4921. params.set(key.toLowerCase(), value);
  4922. }
  4923. } catch (err) {
  4924. _iterator.e(err);
  4925. } finally {
  4926. _iterator.f();
  4927. }
  4928. return params;
  4929. }
  4930. var NullCharactersRegExp = /\x00/g;
  4931. var InvisibleCharactersRegExp = /[\x01-\x1F]/g;
  4932. function removeNullCharacters(str) {
  4933. var replaceInvisible = arguments.length > 1 && arguments[1] !== undefined ? arguments[
  4934. 1] : false;
  4935. if (typeof str !== "string") {
  4936. console.error("The argument must be a string.");
  4937. return str;
  4938. }
  4939. if (replaceInvisible) {
  4940. str = str.replace(InvisibleCharactersRegExp, " ");
  4941. }
  4942. return str.replace(NullCharactersRegExp, "");
  4943. }
  4944. function binarySearchFirstItem(items, condition) {
  4945. var start = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  4946. var minIndex = start;
  4947. var maxIndex = items.length - 1;
  4948. if (maxIndex < 0 || !condition(items[maxIndex])) {
  4949. return items.length;
  4950. }
  4951. if (condition(items[minIndex])) {
  4952. return minIndex;
  4953. }
  4954. while (minIndex < maxIndex) {
  4955. var currentIndex = minIndex + maxIndex >> 1;
  4956. var currentItem = items[currentIndex];
  4957. if (condition(currentItem)) {
  4958. maxIndex = currentIndex;
  4959. } else {
  4960. minIndex = currentIndex + 1;
  4961. }
  4962. }
  4963. return minIndex;
  4964. }
  4965. function approximateFraction(x) {
  4966. if (Math.floor(x) === x) {
  4967. return [x, 1];
  4968. }
  4969. var xinv = 1 / x;
  4970. var limit = 8;
  4971. if (xinv > limit) {
  4972. return [1, limit];
  4973. } else if (Math.floor(xinv) === xinv) {
  4974. return [1, xinv];
  4975. }
  4976. var x_ = x > 1 ? xinv : x;
  4977. var a = 0,
  4978. b = 1,
  4979. c = 1,
  4980. d = 1;
  4981. while (true) {
  4982. var p = a + c,
  4983. q = b + d;
  4984. if (q > limit) {
  4985. break;
  4986. }
  4987. if (x_ <= p / q) {
  4988. c = p;
  4989. d = q;
  4990. } else {
  4991. a = p;
  4992. b = q;
  4993. }
  4994. }
  4995. var result;
  4996. if (x_ - a / b < c / d - x_) {
  4997. result = x_ === x ? [a, b] : [b, a];
  4998. } else {
  4999. result = x_ === x ? [c, d] : [d, c];
  5000. }
  5001. return result;
  5002. }
  5003. function roundToDivide(x, div) {
  5004. var r = x % div;
  5005. return r === 0 ? x : Math.round(x - r + div);
  5006. }
  5007. function getPageSizeInches(_ref) {
  5008. var view = _ref.view,
  5009. userUnit = _ref.userUnit,
  5010. rotate = _ref.rotate;
  5011. var _view = _slicedToArray(view, 4),
  5012. x1 = _view[0],
  5013. y1 = _view[1],
  5014. x2 = _view[2],
  5015. y2 = _view[3];
  5016. var changeOrientation = rotate % 180 !== 0;
  5017. var width = (x2 - x1) / 72 * userUnit;
  5018. var height = (y2 - y1) / 72 * userUnit;
  5019. return {
  5020. width: changeOrientation ? height : width,
  5021. height: changeOrientation ? width : height
  5022. };
  5023. }
  5024. function backtrackBeforeAllVisibleElements(index, views, top) {
  5025. if (index < 2) {
  5026. return index;
  5027. }
  5028. var elt = views[index].div;
  5029. var pageTop = elt.offsetTop + elt.clientTop;
  5030. if (pageTop >= top) {
  5031. elt = views[index - 1].div;
  5032. pageTop = elt.offsetTop + elt.clientTop;
  5033. }
  5034. for (var i = index - 2; i >= 0; --i) {
  5035. elt = views[i].div;
  5036. if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
  5037. break;
  5038. }
  5039. index = i;
  5040. }
  5041. return index;
  5042. }
  5043. function getVisibleElements(_ref2) {
  5044. var scrollEl = _ref2.scrollEl,
  5045. views = _ref2.views,
  5046. _ref2$sortByVisibilit = _ref2.sortByVisibility,
  5047. sortByVisibility = _ref2$sortByVisibilit === void 0 ? false : _ref2$sortByVisibilit,
  5048. _ref2$horizontal = _ref2.horizontal,
  5049. horizontal = _ref2$horizontal === void 0 ? false : _ref2$horizontal,
  5050. _ref2$rtl = _ref2.rtl,
  5051. rtl = _ref2$rtl === void 0 ? false : _ref2$rtl;
  5052. var top = scrollEl.scrollTop,
  5053. bottom = top + scrollEl.clientHeight;
  5054. var left = scrollEl.scrollLeft,
  5055. right = left + scrollEl.clientWidth;
  5056. function isElementBottomAfterViewTop(view) {
  5057. var element = view.div;
  5058. var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  5059. return elementBottom > top;
  5060. }
  5061. function isElementNextAfterViewHorizontally(view) {
  5062. var element = view.div;
  5063. var elementLeft = element.offsetLeft + element.clientLeft;
  5064. var elementRight = elementLeft + element.clientWidth;
  5065. return rtl ? elementLeft < right : elementRight > left;
  5066. }
  5067. var visible = [],
  5068. ids = new Set(),
  5069. numViews = views.length;
  5070. var firstVisibleElementInd = binarySearchFirstItem(views, horizontal ?
  5071. isElementNextAfterViewHorizontally : isElementBottomAfterViewTop);
  5072. if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
  5073. firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd,
  5074. views, top);
  5075. }
  5076. var lastEdge = horizontal ? right : -1;
  5077. for (var i = firstVisibleElementInd; i < numViews; i++) {
  5078. var view = views[i],
  5079. element = view.div;
  5080. var currentWidth = element.offsetLeft + element.clientLeft;
  5081. var currentHeight = element.offsetTop + element.clientTop;
  5082. var viewWidth = element.clientWidth,
  5083. viewHeight = element.clientHeight;
  5084. var viewRight = currentWidth + viewWidth;
  5085. var viewBottom = currentHeight + viewHeight;
  5086. if (lastEdge === -1) {
  5087. if (viewBottom >= bottom) {
  5088. lastEdge = viewBottom;
  5089. }
  5090. } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
  5091. break;
  5092. }
  5093. if (viewBottom <= top || currentHeight >= bottom || viewRight <= left ||
  5094. currentWidth >= right) {
  5095. continue;
  5096. }
  5097. var hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom -
  5098. bottom);
  5099. var hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
  5100. var fractionHeight = (viewHeight - hiddenHeight) / viewHeight,
  5101. fractionWidth = (viewWidth - hiddenWidth) / viewWidth;
  5102. var percent = fractionHeight * fractionWidth * 100 | 0;
  5103. visible.push({
  5104. id: view.id,
  5105. x: currentWidth,
  5106. y: currentHeight,
  5107. view: view,
  5108. percent: percent,
  5109. widthPercent: fractionWidth * 100 | 0
  5110. });
  5111. ids.add(view.id);
  5112. }
  5113. var first = visible[0],
  5114. last = visible[visible.length - 1];
  5115. if (sortByVisibility) {
  5116. visible.sort(function(a, b) {
  5117. var pc = a.percent - b.percent;
  5118. if (Math.abs(pc) > 0.001) {
  5119. return -pc;
  5120. }
  5121. return a.id - b.id;
  5122. });
  5123. }
  5124. return {
  5125. first: first,
  5126. last: last,
  5127. views: visible,
  5128. ids: ids
  5129. };
  5130. }
  5131. function noContextMenuHandler(evt) {
  5132. evt.preventDefault();
  5133. }
  5134. function normalizeWheelEventDirection(evt) {
  5135. var delta = Math.hypot(evt.deltaX, evt.deltaY);
  5136. var angle = Math.atan2(evt.deltaY, evt.deltaX);
  5137. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  5138. delta = -delta;
  5139. }
  5140. return delta;
  5141. }
  5142. function normalizeWheelEventDelta(evt) {
  5143. var delta = normalizeWheelEventDirection(evt);
  5144. var MOUSE_DOM_DELTA_PIXEL_MODE = 0;
  5145. var MOUSE_DOM_DELTA_LINE_MODE = 1;
  5146. var MOUSE_PIXELS_PER_LINE = 30;
  5147. var MOUSE_LINES_PER_PAGE = 30;
  5148. if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
  5149. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  5150. } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
  5151. delta /= MOUSE_LINES_PER_PAGE;
  5152. }
  5153. return delta;
  5154. }
  5155. function isValidRotation(angle) {
  5156. return Number.isInteger(angle) && angle % 90 === 0;
  5157. }
  5158. function isValidScrollMode(mode) {
  5159. return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !==
  5160. ScrollMode.UNKNOWN;
  5161. }
  5162. function isValidSpreadMode(mode) {
  5163. return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !==
  5164. SpreadMode.UNKNOWN;
  5165. }
  5166. function isPortraitOrientation(size) {
  5167. return size.width <= size.height;
  5168. }
  5169. var animationStarted = new Promise(function(resolve) {
  5170. window.requestAnimationFrame(resolve);
  5171. });
  5172. exports.animationStarted = animationStarted;
  5173. function clamp(v, min, max) {
  5174. return Math.min(Math.max(v, min), max);
  5175. }
  5176. var ProgressBar = /*#__PURE__*/ function() {
  5177. function ProgressBar(id) {
  5178. var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] :
  5179. {},
  5180. height = _ref3.height,
  5181. width = _ref3.width,
  5182. units = _ref3.units;
  5183. _classCallCheck(this, ProgressBar);
  5184. this.visible = true;
  5185. this.div = document.querySelector(id + " .progress");
  5186. this.bar = this.div.parentNode;
  5187. this.height = height || 100;
  5188. this.width = width || 100;
  5189. this.units = units || "%";
  5190. this.div.style.height = this.height + this.units;
  5191. this.percent = 0;
  5192. }
  5193. _createClass(ProgressBar, [{
  5194. key: "_updateBar",
  5195. value: function _updateBar() {
  5196. if (this._indeterminate) {
  5197. this.div.classList.add("indeterminate");
  5198. this.div.style.width = this.width + this.units;
  5199. return;
  5200. }
  5201. this.div.classList.remove("indeterminate");
  5202. var progressSize = this.width * this._percent / 100;
  5203. this.div.style.width = progressSize + this.units;
  5204. }
  5205. }, {
  5206. key: "percent",
  5207. get: function get() {
  5208. return this._percent;
  5209. },
  5210. set: function set(val) {
  5211. this._indeterminate = isNaN(val);
  5212. this._percent = clamp(val, 0, 100);
  5213. this._updateBar();
  5214. }
  5215. }, {
  5216. key: "setWidth",
  5217. value: function setWidth(viewer) {
  5218. if (!viewer) {
  5219. return;
  5220. }
  5221. var container = viewer.parentNode;
  5222. var scrollbarWidth = container.offsetWidth - viewer
  5223. .offsetWidth;
  5224. if (scrollbarWidth > 0) {
  5225. var doc = document.documentElement;
  5226. doc.style.setProperty(LOADINGBAR_END_OFFSET_VAR, ""
  5227. .concat(scrollbarWidth, "px"));
  5228. }
  5229. }
  5230. }, {
  5231. key: "hide",
  5232. value: function hide() {
  5233. if (!this.visible) {
  5234. return;
  5235. }
  5236. this.visible = false;
  5237. this.bar.classList.add("hidden");
  5238. }
  5239. }, {
  5240. key: "show",
  5241. value: function show() {
  5242. if (this.visible) {
  5243. return;
  5244. }
  5245. this.visible = true;
  5246. this.bar.classList.remove("hidden");
  5247. }
  5248. }]);
  5249. return ProgressBar;
  5250. }();
  5251. exports.ProgressBar = ProgressBar;
  5252. function getActiveOrFocusedElement() {
  5253. var curRoot = document;
  5254. var curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
  5255. while ((_curActiveOrFocused = curActiveOrFocused) !== null && _curActiveOrFocused !==
  5256. void 0 && _curActiveOrFocused.shadowRoot) {
  5257. var _curActiveOrFocused;
  5258. curRoot = curActiveOrFocused.shadowRoot;
  5259. curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
  5260. }
  5261. return curActiveOrFocused;
  5262. }
  5263. function apiPageLayoutToViewerModes(layout) {
  5264. var scrollMode = ScrollMode.VERTICAL,
  5265. spreadMode = SpreadMode.NONE;
  5266. switch (layout) {
  5267. case "SinglePage":
  5268. scrollMode = ScrollMode.PAGE;
  5269. break;
  5270. case "OneColumn":
  5271. break;
  5272. case "TwoPageLeft":
  5273. scrollMode = ScrollMode.PAGE;
  5274. case "TwoColumnLeft":
  5275. spreadMode = SpreadMode.ODD;
  5276. break;
  5277. case "TwoPageRight":
  5278. scrollMode = ScrollMode.PAGE;
  5279. case "TwoColumnRight":
  5280. spreadMode = SpreadMode.EVEN;
  5281. break;
  5282. }
  5283. return {
  5284. scrollMode: scrollMode,
  5285. spreadMode: spreadMode
  5286. };
  5287. }
  5288. function apiPageModeToSidebarView(mode) {
  5289. switch (mode) {
  5290. case "UseNone":
  5291. return SidebarView.NONE;
  5292. case "UseThumbs":
  5293. return SidebarView.THUMBS;
  5294. case "UseOutlines":
  5295. return SidebarView.OUTLINE;
  5296. case "UseAttachments":
  5297. return SidebarView.ATTACHMENTS;
  5298. case "UseOC":
  5299. return SidebarView.LAYERS;
  5300. }
  5301. return SidebarView.NONE;
  5302. }
  5303. /***/
  5304. }),
  5305. /* 6 */
  5306. /***/
  5307. ((__unused_webpack_module, exports) => {
  5308. Object.defineProperty(exports, "__esModule", ({
  5309. value: true
  5310. }));
  5311. exports.WaitOnType = exports.EventBus = exports.AutomationEventBus = void 0;
  5312. exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
  5313. function _inherits(subClass, superClass) {
  5314. if (typeof superClass !== "function" && superClass !== null) {
  5315. throw new TypeError("Super expression must either be null or a function");
  5316. }
  5317. subClass.prototype = Object.create(superClass && superClass.prototype, {
  5318. constructor: {
  5319. value: subClass,
  5320. writable: true,
  5321. configurable: true
  5322. }
  5323. });
  5324. Object.defineProperty(subClass, "prototype", {
  5325. writable: false
  5326. });
  5327. if (superClass) _setPrototypeOf(subClass, superClass);
  5328. }
  5329. function _setPrototypeOf(o, p) {
  5330. _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  5331. o.__proto__ = p;
  5332. return o;
  5333. };
  5334. return _setPrototypeOf(o, p);
  5335. }
  5336. function _createSuper(Derived) {
  5337. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  5338. return function _createSuperInternal() {
  5339. var Super = _getPrototypeOf(Derived),
  5340. result;
  5341. if (hasNativeReflectConstruct) {
  5342. var NewTarget = _getPrototypeOf(this).constructor;
  5343. result = Reflect.construct(Super, arguments, NewTarget);
  5344. } else {
  5345. result = Super.apply(this, arguments);
  5346. }
  5347. return _possibleConstructorReturn(this, result);
  5348. };
  5349. }
  5350. function _possibleConstructorReturn(self, call) {
  5351. if (call && (_typeof(call) === "object" || typeof call === "function")) {
  5352. return call;
  5353. } else if (call !== void 0) {
  5354. throw new TypeError("Derived constructors may only return object or undefined");
  5355. }
  5356. return _assertThisInitialized(self);
  5357. }
  5358. function _assertThisInitialized(self) {
  5359. if (self === void 0) {
  5360. throw new ReferenceError(
  5361. "this hasn't been initialised - super() hasn't been called");
  5362. }
  5363. return self;
  5364. }
  5365. function _isNativeReflectConstruct() {
  5366. if (typeof Reflect === "undefined" || !Reflect.construct) return false;
  5367. if (Reflect.construct.sham) return false;
  5368. if (typeof Proxy === "function") return true;
  5369. try {
  5370. Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
  5371. return true;
  5372. } catch (e) {
  5373. return false;
  5374. }
  5375. }
  5376. function _getPrototypeOf(o) {
  5377. _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf :
  5378. function _getPrototypeOf(o) {
  5379. return o.__proto__ || Object.getPrototypeOf(o);
  5380. };
  5381. return _getPrototypeOf(o);
  5382. }
  5383. function _createForOfIteratorHelper(o, allowArrayLike) {
  5384. var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
  5385. if (!it) {
  5386. if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike &&
  5387. o && typeof o.length === "number") {
  5388. if (it) o = it;
  5389. var i = 0;
  5390. var F = function F() {};
  5391. return {
  5392. s: F,
  5393. n: function n() {
  5394. if (i >= o.length) return {
  5395. done: true
  5396. };
  5397. return {
  5398. done: false,
  5399. value: o[i++]
  5400. };
  5401. },
  5402. e: function e(_e) {
  5403. throw _e;
  5404. },
  5405. f: F
  5406. };
  5407. }
  5408. throw new TypeError(
  5409. "Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
  5410. );
  5411. }
  5412. var normalCompletion = true,
  5413. didErr = false,
  5414. err;
  5415. return {
  5416. s: function s() {
  5417. it = it.call(o);
  5418. },
  5419. n: function n() {
  5420. var step = it.next();
  5421. normalCompletion = step.done;
  5422. return step;
  5423. },
  5424. e: function e(_e2) {
  5425. didErr = true;
  5426. err = _e2;
  5427. },
  5428. f: function f() {
  5429. try {
  5430. if (!normalCompletion && it["return"] != null) it["return"]();
  5431. } finally {
  5432. if (didErr) throw err;
  5433. }
  5434. }
  5435. };
  5436. }
  5437. function _unsupportedIterableToArray(o, minLen) {
  5438. if (!o) return;
  5439. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  5440. var n = Object.prototype.toString.call(o).slice(8, -1);
  5441. if (n === "Object" && o.constructor) n = o.constructor.name;
  5442. if (n === "Map" || n === "Set") return Array.from(o);
  5443. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
  5444. return _arrayLikeToArray(o, minLen);
  5445. }
  5446. function _arrayLikeToArray(arr, len) {
  5447. if (len == null || len > arr.length) len = arr.length;
  5448. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  5449. arr2[i] = arr[i];
  5450. }
  5451. return arr2;
  5452. }
  5453. function _classCallCheck(instance, Constructor) {
  5454. if (!(instance instanceof Constructor)) {
  5455. throw new TypeError("Cannot call a class as a function");
  5456. }
  5457. }
  5458. function _defineProperties(target, props) {
  5459. for (var i = 0; i < props.length; i++) {
  5460. var descriptor = props[i];
  5461. descriptor.enumerable = descriptor.enumerable || false;
  5462. descriptor.configurable = true;
  5463. if ("value" in descriptor) descriptor.writable = true;
  5464. Object.defineProperty(target, descriptor.key, descriptor);
  5465. }
  5466. }
  5467. function _createClass(Constructor, protoProps, staticProps) {
  5468. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  5469. if (staticProps) _defineProperties(Constructor, staticProps);
  5470. Object.defineProperty(Constructor, "prototype", {
  5471. writable: false
  5472. });
  5473. return Constructor;
  5474. }
  5475. function _typeof(obj) {
  5476. "@babel/helpers - typeof";
  5477. return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ?
  5478. function(obj) {
  5479. return typeof obj;
  5480. } : function(obj) {
  5481. return obj && "function" == typeof Symbol && obj.constructor === Symbol &&
  5482. obj !== Symbol.prototype ? "symbol" : typeof obj;
  5483. }, _typeof(obj);
  5484. }
  5485. var WaitOnType = {
  5486. EVENT: "event",
  5487. TIMEOUT: "timeout"
  5488. };
  5489. exports.WaitOnType = WaitOnType;
  5490. function waitOnEventOrTimeout(_ref) {
  5491. var target = _ref.target,
  5492. name = _ref.name,
  5493. _ref$delay = _ref.delay,
  5494. delay = _ref$delay === void 0 ? 0 : _ref$delay;
  5495. return new Promise(function(resolve, reject) {
  5496. if (_typeof(target) !== "object" || !(name && typeof name === "string") || !
  5497. (Number.isInteger(delay) && delay >= 0)) {
  5498. throw new Error("waitOnEventOrTimeout - invalid parameters.");
  5499. }
  5500. function handler(type) {
  5501. if (target instanceof EventBus) {
  5502. target._off(name, eventHandler);
  5503. } else {
  5504. target.removeEventListener(name, eventHandler);
  5505. }
  5506. if (timeout) {
  5507. clearTimeout(timeout);
  5508. }
  5509. resolve(type);
  5510. }
  5511. var eventHandler = handler.bind(null, WaitOnType.EVENT);
  5512. if (target instanceof EventBus) {
  5513. target._on(name, eventHandler);
  5514. } else {
  5515. target.addEventListener(name, eventHandler);
  5516. }
  5517. var timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
  5518. var timeout = setTimeout(timeoutHandler, delay);
  5519. });
  5520. }
  5521. var EventBus = /*#__PURE__*/ function() {
  5522. function EventBus() {
  5523. _classCallCheck(this, EventBus);
  5524. this._listeners = Object.create(null);
  5525. }
  5526. _createClass(EventBus, [{
  5527. key: "on",
  5528. value: function on(eventName, listener) {
  5529. var options = arguments.length > 2 && arguments[2] !==
  5530. undefined ? arguments[2] : null;
  5531. this._on(eventName, listener, {
  5532. external: true,
  5533. once: options === null || options === void 0 ?
  5534. void 0 : options.once
  5535. });
  5536. }
  5537. }, {
  5538. key: "off",
  5539. value: function off(eventName, listener) {
  5540. var options = arguments.length > 2 && arguments[2] !==
  5541. undefined ? arguments[2] : null;
  5542. this._off(eventName, listener, {
  5543. external: true,
  5544. once: options === null || options === void 0 ?
  5545. void 0 : options.once
  5546. });
  5547. }
  5548. }, {
  5549. key: "dispatch",
  5550. value: function dispatch(eventName, data) {
  5551. var eventListeners = this._listeners[eventName];
  5552. if (!eventListeners || eventListeners.length === 0) {
  5553. return;
  5554. }
  5555. var externalListeners;
  5556. var _iterator = _createForOfIteratorHelper(eventListeners
  5557. .slice(0)),
  5558. _step;
  5559. try {
  5560. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  5561. var _step$value = _step.value,
  5562. _listener = _step$value.listener,
  5563. external = _step$value.external,
  5564. once = _step$value.once;
  5565. if (once) {
  5566. this._off(eventName, _listener);
  5567. }
  5568. if (external) {
  5569. (externalListeners || (externalListeners = []))
  5570. .push(_listener);
  5571. continue;
  5572. }
  5573. _listener(data);
  5574. }
  5575. } catch (err) {
  5576. _iterator.e(err);
  5577. } finally {
  5578. _iterator.f();
  5579. }
  5580. if (externalListeners) {
  5581. var _iterator2 = _createForOfIteratorHelper(
  5582. externalListeners),
  5583. _step2;
  5584. try {
  5585. for (_iterator2.s(); !(_step2 = _iterator2.n())
  5586. .done;) {
  5587. var listener = _step2.value;
  5588. listener(data);
  5589. }
  5590. } catch (err) {
  5591. _iterator2.e(err);
  5592. } finally {
  5593. _iterator2.f();
  5594. }
  5595. externalListeners = null;
  5596. }
  5597. }
  5598. }, {
  5599. key: "_on",
  5600. value: function _on(eventName, listener) {
  5601. var _this$_listeners;
  5602. var options = arguments.length > 2 && arguments[2] !==
  5603. undefined ? arguments[2] : null;
  5604. var eventListeners = (_this$_listeners = this._listeners)[
  5605. eventName] || (_this$_listeners[eventName] = []);
  5606. eventListeners.push({
  5607. listener: listener,
  5608. external: (options === null || options ===
  5609. void 0 ? void 0 : options.external) ===
  5610. true,
  5611. once: (options === null || options === void 0 ?
  5612. void 0 : options.once) === true
  5613. });
  5614. }
  5615. }, {
  5616. key: "_off",
  5617. value: function _off(eventName, listener) {
  5618. var options = arguments.length > 2 && arguments[2] !==
  5619. undefined ? arguments[2] : null;
  5620. var eventListeners = this._listeners[eventName];
  5621. if (!eventListeners) {
  5622. return;
  5623. }
  5624. for (var i = 0, ii = eventListeners.length; i < ii; i++) {
  5625. if (eventListeners[i].listener === listener) {
  5626. eventListeners.splice(i, 1);
  5627. return;
  5628. }
  5629. }
  5630. }
  5631. }]);
  5632. return EventBus;
  5633. }();
  5634. exports.EventBus = EventBus;
  5635. var AutomationEventBus = /*#__PURE__*/ function(_EventBus) {
  5636. _inherits(AutomationEventBus, _EventBus);
  5637. var _super = _createSuper(AutomationEventBus);
  5638. function AutomationEventBus() {
  5639. _classCallCheck(this, AutomationEventBus);
  5640. return _super.apply(this, arguments);
  5641. }
  5642. _createClass(AutomationEventBus, [{
  5643. key: "dispatch",
  5644. value: function dispatch(eventName, data) {
  5645. throw new Error(
  5646. "Not implemented: AutomationEventBus.dispatch");
  5647. }
  5648. }]);
  5649. return AutomationEventBus;
  5650. }(EventBus);
  5651. exports.AutomationEventBus = AutomationEventBus;
  5652. /***/
  5653. }),
  5654. /* 7 */
  5655. /***/
  5656. ((module) => {
  5657. var pdfjsLib;
  5658. if (typeof window !== "undefined" && window["pdfjs-dist/build/pdf"]) {
  5659. pdfjsLib = window["pdfjs-dist/build/pdf"];
  5660. } else {
  5661. pdfjsLib = require("../build/pdf.js");
  5662. }
  5663. module.exports = pdfjsLib;
  5664. /***/
  5665. }),
  5666. /* 8 */
  5667. /***/
  5668. ((__unused_webpack_module, exports, __webpack_require__) => {
  5669. Object.defineProperty(exports, "__esModule", ({
  5670. value: true
  5671. }));
  5672. exports.PDFCursorTools = exports.CursorTool = void 0;
  5673. var _grab_to_pan = __webpack_require__(9);
  5674. var _ui_utils = __webpack_require__(5);
  5675. function _classCallCheck(instance, Constructor) {
  5676. if (!(instance instanceof Constructor)) {
  5677. throw new TypeError("Cannot call a class as a function");
  5678. }
  5679. }
  5680. function _defineProperties(target, props) {
  5681. for (var i = 0; i < props.length; i++) {
  5682. var descriptor = props[i];
  5683. descriptor.enumerable = descriptor.enumerable || false;
  5684. descriptor.configurable = true;
  5685. if ("value" in descriptor) descriptor.writable = true;
  5686. Object.defineProperty(target, descriptor.key, descriptor);
  5687. }
  5688. }
  5689. function _createClass(Constructor, protoProps, staticProps) {
  5690. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  5691. if (staticProps) _defineProperties(Constructor, staticProps);
  5692. Object.defineProperty(Constructor, "prototype", {
  5693. writable: false
  5694. });
  5695. return Constructor;
  5696. }
  5697. var CursorTool = {
  5698. SELECT: 0,
  5699. HAND: 1,
  5700. ZOOM: 2
  5701. };
  5702. exports.CursorTool = CursorTool;
  5703. var PDFCursorTools = /*#__PURE__*/ function() {
  5704. function PDFCursorTools(_ref) {
  5705. var _this = this;
  5706. var container = _ref.container,
  5707. eventBus = _ref.eventBus,
  5708. _ref$cursorToolOnLoad = _ref.cursorToolOnLoad,
  5709. cursorToolOnLoad = _ref$cursorToolOnLoad === void 0 ? CursorTool.SELECT :
  5710. _ref$cursorToolOnLoad;
  5711. _classCallCheck(this, PDFCursorTools);
  5712. this.container = container;
  5713. this.eventBus = eventBus;
  5714. this.active = CursorTool.SELECT;
  5715. this.activeBeforePresentationMode = null;
  5716. this.handTool = new _grab_to_pan.GrabToPan({
  5717. element: this.container
  5718. });
  5719. this._addEventListeners();
  5720. Promise.resolve().then(function() {
  5721. _this.switchTool(cursorToolOnLoad);
  5722. });
  5723. }
  5724. _createClass(PDFCursorTools, [{
  5725. key: "activeTool",
  5726. get: function get() {
  5727. return this.active;
  5728. }
  5729. }, {
  5730. key: "switchTool",
  5731. value: function switchTool(tool) {
  5732. var _this2 = this;
  5733. if (this.activeBeforePresentationMode !== null) {
  5734. return;
  5735. }
  5736. if (tool === this.active) {
  5737. return;
  5738. }
  5739. var disableActiveTool = function disableActiveTool() {
  5740. switch (_this2.active) {
  5741. case CursorTool.SELECT:
  5742. break;
  5743. case CursorTool.HAND:
  5744. _this2.handTool.deactivate();
  5745. break;
  5746. case CursorTool.ZOOM:
  5747. }
  5748. };
  5749. switch (tool) {
  5750. case CursorTool.SELECT:
  5751. disableActiveTool();
  5752. break;
  5753. case CursorTool.HAND:
  5754. disableActiveTool();
  5755. this.handTool.activate();
  5756. break;
  5757. case CursorTool.ZOOM:
  5758. default:
  5759. console.error("switchTool: \"".concat(tool,
  5760. "\" is an unsupported value."));
  5761. return;
  5762. }
  5763. this.active = tool;
  5764. this._dispatchEvent();
  5765. }
  5766. }, {
  5767. key: "_dispatchEvent",
  5768. value: function _dispatchEvent() {
  5769. this.eventBus.dispatch("cursortoolchanged", {
  5770. source: this,
  5771. tool: this.active
  5772. });
  5773. }
  5774. }, {
  5775. key: "_addEventListeners",
  5776. value: function _addEventListeners() {
  5777. var _this3 = this;
  5778. this.eventBus._on("switchcursortool", function(evt) {
  5779. _this3.switchTool(evt.tool);
  5780. });
  5781. this.eventBus._on("presentationmodechanged", function(evt) {
  5782. switch (evt.state) {
  5783. case _ui_utils.PresentationModeState
  5784. .FULLSCREEN: {
  5785. var previouslyActive = _this3.active;
  5786. _this3.switchTool(CursorTool.SELECT);
  5787. _this3.activeBeforePresentationMode =
  5788. previouslyActive;
  5789. break;
  5790. }
  5791. case _ui_utils.PresentationModeState
  5792. .NORMAL: {
  5793. var _previouslyActive = _this3
  5794. .activeBeforePresentationMode;
  5795. _this3.activeBeforePresentationMode =
  5796. null;
  5797. _this3.switchTool(_previouslyActive);
  5798. break;
  5799. }
  5800. }
  5801. });
  5802. }
  5803. }]);
  5804. return PDFCursorTools;
  5805. }();
  5806. exports.PDFCursorTools = PDFCursorTools;
  5807. /***/
  5808. }),
  5809. /* 9 */
  5810. /***/
  5811. ((__unused_webpack_module, exports) => {
  5812. Object.defineProperty(exports, "__esModule", ({
  5813. value: true
  5814. }));
  5815. exports.GrabToPan = void 0;
  5816. function _classCallCheck(instance, Constructor) {
  5817. if (!(instance instanceof Constructor)) {
  5818. throw new TypeError("Cannot call a class as a function");
  5819. }
  5820. }
  5821. function _defineProperties(target, props) {
  5822. for (var i = 0; i < props.length; i++) {
  5823. var descriptor = props[i];
  5824. descriptor.enumerable = descriptor.enumerable || false;
  5825. descriptor.configurable = true;
  5826. if ("value" in descriptor) descriptor.writable = true;
  5827. Object.defineProperty(target, descriptor.key, descriptor);
  5828. }
  5829. }
  5830. function _createClass(Constructor, protoProps, staticProps) {
  5831. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  5832. if (staticProps) _defineProperties(Constructor, staticProps);
  5833. Object.defineProperty(Constructor, "prototype", {
  5834. writable: false
  5835. });
  5836. return Constructor;
  5837. }
  5838. function _classPrivateMethodInitSpec(obj, privateSet) {
  5839. _checkPrivateRedeclaration(obj, privateSet);
  5840. privateSet.add(obj);
  5841. }
  5842. function _checkPrivateRedeclaration(obj, privateCollection) {
  5843. if (privateCollection.has(obj)) {
  5844. throw new TypeError(
  5845. "Cannot initialize the same private elements twice on an object");
  5846. }
  5847. }
  5848. function _classPrivateMethodGet(receiver, privateSet, fn) {
  5849. if (!privateSet.has(receiver)) {
  5850. throw new TypeError("attempted to get private field on non-instance");
  5851. }
  5852. return fn;
  5853. }
  5854. var CSS_CLASS_GRAB = "grab-to-pan-grab";
  5855. var _onMouseDown = /*#__PURE__*/ new WeakSet();
  5856. var _onMouseMove = /*#__PURE__*/ new WeakSet();
  5857. var _endPan = /*#__PURE__*/ new WeakSet();
  5858. var GrabToPan = /*#__PURE__*/ function() {
  5859. function GrabToPan(options) {
  5860. _classCallCheck(this, GrabToPan);
  5861. _classPrivateMethodInitSpec(this, _endPan);
  5862. _classPrivateMethodInitSpec(this, _onMouseMove);
  5863. _classPrivateMethodInitSpec(this, _onMouseDown);
  5864. this.element = options.element;
  5865. this.document = options.element.ownerDocument;
  5866. if (typeof options.ignoreTarget === "function") {
  5867. this.ignoreTarget = options.ignoreTarget;
  5868. }
  5869. this.onActiveChanged = options.onActiveChanged;
  5870. this.activate = this.activate.bind(this);
  5871. this.deactivate = this.deactivate.bind(this);
  5872. this.toggle = this.toggle.bind(this);
  5873. this._onMouseDown = _classPrivateMethodGet(this, _onMouseDown, _onMouseDown2)
  5874. .bind(this);
  5875. this._onMouseMove = _classPrivateMethodGet(this, _onMouseMove, _onMouseMove2)
  5876. .bind(this);
  5877. this._endPan = _classPrivateMethodGet(this, _endPan, _endPan2).bind(this);
  5878. var overlay = this.overlay = document.createElement("div");
  5879. overlay.className = "grab-to-pan-grabbing";
  5880. }
  5881. _createClass(GrabToPan, [{
  5882. key: "activate",
  5883. value: function activate() {
  5884. if (!this.active) {
  5885. var _this$onActiveChanged;
  5886. this.active = true;
  5887. this.element.addEventListener("mousedown", this
  5888. ._onMouseDown, true);
  5889. this.element.classList.add(CSS_CLASS_GRAB);
  5890. (_this$onActiveChanged = this.onActiveChanged) === null
  5891. || _this$onActiveChanged === void 0 ? void 0 :
  5892. _this$onActiveChanged.call(this, true);
  5893. }
  5894. }
  5895. }, {
  5896. key: "deactivate",
  5897. value: function deactivate() {
  5898. if (this.active) {
  5899. var _this$onActiveChanged2;
  5900. this.active = false;
  5901. this.element.removeEventListener("mousedown", this
  5902. ._onMouseDown, true);
  5903. this._endPan();
  5904. this.element.classList.remove(CSS_CLASS_GRAB);
  5905. (_this$onActiveChanged2 = this.onActiveChanged) === null
  5906. || _this$onActiveChanged2 === void 0 ? void 0 :
  5907. _this$onActiveChanged2.call(this, false);
  5908. }
  5909. }
  5910. }, {
  5911. key: "toggle",
  5912. value: function toggle() {
  5913. if (this.active) {
  5914. this.deactivate();
  5915. } else {
  5916. this.activate();
  5917. }
  5918. }
  5919. }, {
  5920. key: "ignoreTarget",
  5921. value: function ignoreTarget(node) {
  5922. return node.matches(
  5923. "a[href], a[href] *, input, textarea, button, button *, select, option"
  5924. );
  5925. }
  5926. }]);
  5927. return GrabToPan;
  5928. }();
  5929. exports.GrabToPan = GrabToPan;
  5930. function _onMouseDown2(event) {
  5931. if (event.button !== 0 || this.ignoreTarget(event.target)) {
  5932. return;
  5933. }
  5934. if (event.originalTarget) {
  5935. try {
  5936. event.originalTarget.tagName;
  5937. } catch (e) {
  5938. return;
  5939. }
  5940. }
  5941. this.scrollLeftStart = this.element.scrollLeft;
  5942. this.scrollTopStart = this.element.scrollTop;
  5943. this.clientXStart = event.clientX;
  5944. this.clientYStart = event.clientY;
  5945. this.document.addEventListener("mousemove", this._onMouseMove, true);
  5946. this.document.addEventListener("mouseup", this._endPan, true);
  5947. this.element.addEventListener("scroll", this._endPan, true);
  5948. event.preventDefault();
  5949. event.stopPropagation();
  5950. var focusedElement = document.activeElement;
  5951. if (focusedElement && !focusedElement.contains(event.target)) {
  5952. focusedElement.blur();
  5953. }
  5954. }
  5955. function _onMouseMove2(event) {
  5956. this.element.removeEventListener("scroll", this._endPan, true);
  5957. if (!(event.buttons & 1)) {
  5958. this._endPan();
  5959. return;
  5960. }
  5961. var xDiff = event.clientX - this.clientXStart;
  5962. var yDiff = event.clientY - this.clientYStart;
  5963. var scrollTop = this.scrollTopStart - yDiff;
  5964. var scrollLeft = this.scrollLeftStart - xDiff;
  5965. if (this.element.scrollTo) {
  5966. this.element.scrollTo({
  5967. top: scrollTop,
  5968. left: scrollLeft,
  5969. behavior: "instant"
  5970. });
  5971. } else {
  5972. this.element.scrollTop = scrollTop;
  5973. this.element.scrollLeft = scrollLeft;
  5974. }
  5975. if (!this.overlay.parentNode) {
  5976. document.body.appendChild(this.overlay);
  5977. }
  5978. }
  5979. function _endPan2() {
  5980. this.element.removeEventListener("scroll", this._endPan, true);
  5981. this.document.removeEventListener("mousemove", this._onMouseMove, true);
  5982. this.document.removeEventListener("mouseup", this._endPan, true);
  5983. this.overlay.remove();
  5984. }
  5985. /***/
  5986. }),
  5987. /* 10 */
  5988. /***/
  5989. ((__unused_webpack_module, exports, __webpack_require__) => {
  5990. Object.defineProperty(exports, "__esModule", ({
  5991. value: true
  5992. }));
  5993. exports.SimpleLinkService = exports.PDFLinkService = exports.LinkTarget = void 0;
  5994. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  5995. var _ui_utils = __webpack_require__(5);
  5996. function _interopRequireDefault(obj) {
  5997. return obj && obj.__esModule ? obj : {
  5998. "default": obj
  5999. };
  6000. }
  6001. function _typeof(obj) {
  6002. "@babel/helpers - typeof";
  6003. return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ?
  6004. function(obj) {
  6005. return typeof obj;
  6006. } : function(obj) {
  6007. return obj && "function" == typeof Symbol && obj.constructor === Symbol &&
  6008. obj !== Symbol.prototype ? "symbol" : typeof obj;
  6009. }, _typeof(obj);
  6010. }
  6011. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  6012. try {
  6013. var info = gen[key](arg);
  6014. var value = info.value;
  6015. } catch (error) {
  6016. reject(error);
  6017. return;
  6018. }
  6019. if (info.done) {
  6020. resolve(value);
  6021. } else {
  6022. Promise.resolve(value).then(_next, _throw);
  6023. }
  6024. }
  6025. function _asyncToGenerator(fn) {
  6026. return function() {
  6027. var self = this,
  6028. args = arguments;
  6029. return new Promise(function(resolve, reject) {
  6030. var gen = fn.apply(self, args);
  6031. function _next(value) {
  6032. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next",
  6033. value);
  6034. }
  6035. function _throw(err) {
  6036. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw",
  6037. err);
  6038. }
  6039. _next(undefined);
  6040. });
  6041. };
  6042. }
  6043. function _classCallCheck(instance, Constructor) {
  6044. if (!(instance instanceof Constructor)) {
  6045. throw new TypeError("Cannot call a class as a function");
  6046. }
  6047. }
  6048. function _defineProperties(target, props) {
  6049. for (var i = 0; i < props.length; i++) {
  6050. var descriptor = props[i];
  6051. descriptor.enumerable = descriptor.enumerable || false;
  6052. descriptor.configurable = true;
  6053. if ("value" in descriptor) descriptor.writable = true;
  6054. Object.defineProperty(target, descriptor.key, descriptor);
  6055. }
  6056. }
  6057. function _createClass(Constructor, protoProps, staticProps) {
  6058. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  6059. if (staticProps) _defineProperties(Constructor, staticProps);
  6060. Object.defineProperty(Constructor, "prototype", {
  6061. writable: false
  6062. });
  6063. return Constructor;
  6064. }
  6065. function _classPrivateMethodInitSpec(obj, privateSet) {
  6066. _checkPrivateRedeclaration(obj, privateSet);
  6067. privateSet.add(obj);
  6068. }
  6069. function _classPrivateFieldInitSpec(obj, privateMap, value) {
  6070. _checkPrivateRedeclaration(obj, privateMap);
  6071. privateMap.set(obj, value);
  6072. }
  6073. function _checkPrivateRedeclaration(obj, privateCollection) {
  6074. if (privateCollection.has(obj)) {
  6075. throw new TypeError(
  6076. "Cannot initialize the same private elements twice on an object");
  6077. }
  6078. }
  6079. function _classStaticPrivateMethodGet(receiver, classConstructor, method) {
  6080. _classCheckPrivateStaticAccess(receiver, classConstructor);
  6081. return method;
  6082. }
  6083. function _classCheckPrivateStaticAccess(receiver, classConstructor) {
  6084. if (receiver !== classConstructor) {
  6085. throw new TypeError("Private static access of wrong provenance");
  6086. }
  6087. }
  6088. function _classPrivateMethodGet(receiver, privateSet, fn) {
  6089. if (!privateSet.has(receiver)) {
  6090. throw new TypeError("attempted to get private field on non-instance");
  6091. }
  6092. return fn;
  6093. }
  6094. function _classPrivateFieldGet(receiver, privateMap) {
  6095. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get");
  6096. return _classApplyDescriptorGet(receiver, descriptor);
  6097. }
  6098. function _classExtractFieldDescriptor(receiver, privateMap, action) {
  6099. if (!privateMap.has(receiver)) {
  6100. throw new TypeError("attempted to " + action + " private field on non-instance");
  6101. }
  6102. return privateMap.get(receiver);
  6103. }
  6104. function _classApplyDescriptorGet(receiver, descriptor) {
  6105. if (descriptor.get) {
  6106. return descriptor.get.call(receiver);
  6107. }
  6108. return descriptor.value;
  6109. }
  6110. var DEFAULT_LINK_REL = "noopener noreferrer nofollow";
  6111. var LinkTarget = {
  6112. NONE: 0,
  6113. SELF: 1,
  6114. BLANK: 2,
  6115. PARENT: 3,
  6116. TOP: 4
  6117. };
  6118. exports.LinkTarget = LinkTarget;
  6119. function _addLinkAttributes(link) {
  6120. var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  6121. url = _ref.url,
  6122. target = _ref.target,
  6123. rel = _ref.rel,
  6124. _ref$enabled = _ref.enabled,
  6125. enabled = _ref$enabled === void 0 ? true : _ref$enabled;
  6126. if (!url || typeof url !== "string") {
  6127. throw new Error('A valid "url" parameter must provided.');
  6128. }
  6129. var urlNullRemoved = (0, _ui_utils.removeNullCharacters)(url);
  6130. if (enabled) {
  6131. link.href = link.title = urlNullRemoved;
  6132. } else {
  6133. link.href = "";
  6134. link.title = "Disabled: ".concat(urlNullRemoved);
  6135. link.onclick = function() {
  6136. return false;
  6137. };
  6138. }
  6139. var targetStr = "";
  6140. switch (target) {
  6141. case LinkTarget.NONE:
  6142. break;
  6143. case LinkTarget.SELF:
  6144. targetStr = "_self";
  6145. break;
  6146. case LinkTarget.BLANK:
  6147. targetStr = "_blank";
  6148. break;
  6149. case LinkTarget.PARENT:
  6150. targetStr = "_parent";
  6151. break;
  6152. case LinkTarget.TOP:
  6153. targetStr = "_top";
  6154. break;
  6155. }
  6156. link.target = targetStr;
  6157. link.rel = typeof rel === "string" ? rel : DEFAULT_LINK_REL;
  6158. }
  6159. var _pagesRefCache = /*#__PURE__*/ new WeakMap();
  6160. var _goToDestinationHelper = /*#__PURE__*/ new WeakSet();
  6161. var PDFLinkService = /*#__PURE__*/ function() {
  6162. function PDFLinkService() {
  6163. var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
  6164. {},
  6165. eventBus = _ref2.eventBus,
  6166. _ref2$externalLinkTar = _ref2.externalLinkTarget,
  6167. externalLinkTarget = _ref2$externalLinkTar === void 0 ? null :
  6168. _ref2$externalLinkTar,
  6169. _ref2$externalLinkRel = _ref2.externalLinkRel,
  6170. externalLinkRel = _ref2$externalLinkRel === void 0 ? null :
  6171. _ref2$externalLinkRel,
  6172. _ref2$ignoreDestinati = _ref2.ignoreDestinationZoom,
  6173. ignoreDestinationZoom = _ref2$ignoreDestinati === void 0 ? false :
  6174. _ref2$ignoreDestinati;
  6175. _classCallCheck(this, PDFLinkService);
  6176. _classPrivateMethodInitSpec(this, _goToDestinationHelper);
  6177. _classPrivateFieldInitSpec(this, _pagesRefCache, {
  6178. writable: true,
  6179. value: new Map()
  6180. });
  6181. this.eventBus = eventBus;
  6182. this.externalLinkTarget = externalLinkTarget;
  6183. this.externalLinkRel = externalLinkRel;
  6184. this.externalLinkEnabled = true;
  6185. this._ignoreDestinationZoom = ignoreDestinationZoom;
  6186. this.baseUrl = null;
  6187. this.pdfDocument = null;
  6188. this.pdfViewer = null;
  6189. this.pdfHistory = null;
  6190. }
  6191. _createClass(PDFLinkService, [{
  6192. key: "setDocument",
  6193. value: function setDocument(pdfDocument) {
  6194. var baseUrl = arguments.length > 1 && arguments[1] !==
  6195. undefined ? arguments[1] : null;
  6196. this.baseUrl = baseUrl;
  6197. this.pdfDocument = pdfDocument;
  6198. _classPrivateFieldGet(this, _pagesRefCache).clear();
  6199. }
  6200. }, {
  6201. key: "setViewer",
  6202. value: function setViewer(pdfViewer) {
  6203. this.pdfViewer = pdfViewer;
  6204. }
  6205. }, {
  6206. key: "setHistory",
  6207. value: function setHistory(pdfHistory) {
  6208. this.pdfHistory = pdfHistory;
  6209. }
  6210. }, {
  6211. key: "pagesCount",
  6212. get: function get() {
  6213. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  6214. }
  6215. }, {
  6216. key: "page",
  6217. get: function get() {
  6218. return this.pdfViewer.currentPageNumber;
  6219. },
  6220. set: function set(value) {
  6221. this.pdfViewer.currentPageNumber = value;
  6222. }
  6223. }, {
  6224. key: "rotation",
  6225. get: function get() {
  6226. return this.pdfViewer.pagesRotation;
  6227. },
  6228. set: function set(value) {
  6229. this.pdfViewer.pagesRotation = value;
  6230. }
  6231. }, {
  6232. key: "goToDestination",
  6233. value: function() {
  6234. var _goToDestination = _asyncToGenerator( /*#__PURE__*/
  6235. _regenerator["default"].mark(function _callee(
  6236. dest) {
  6237. var namedDest, explicitDest;
  6238. return _regenerator["default"].wrap(
  6239. function _callee$(_context) {
  6240. while (1) {
  6241. switch (_context.prev =
  6242. _context.next) {
  6243. case 0:
  6244. if (this
  6245. .pdfDocument) {
  6246. _context.next =
  6247. 2;
  6248. break;
  6249. }
  6250. return _context
  6251. .abrupt(
  6252. "return");
  6253. case 2:
  6254. if (!(typeof dest ===
  6255. "string")) {
  6256. _context.next =
  6257. 9;
  6258. break;
  6259. }
  6260. namedDest = dest;
  6261. _context.next = 6;
  6262. return this
  6263. .pdfDocument
  6264. .getDestination(
  6265. dest);
  6266. case 6:
  6267. explicitDest =
  6268. _context.sent;
  6269. _context.next = 13;
  6270. break;
  6271. case 9:
  6272. namedDest = null;
  6273. _context.next = 12;
  6274. return dest;
  6275. case 12:
  6276. explicitDest =
  6277. _context.sent;
  6278. case 13:
  6279. if (Array.isArray(
  6280. explicitDest
  6281. )) {
  6282. _context.next =
  6283. 16;
  6284. break;
  6285. }
  6286. console.error(
  6287. "PDFLinkService.goToDestination: \""
  6288. .concat(
  6289. explicitDest,
  6290. "\" is not "
  6291. ) +
  6292. "a valid destination array, for dest=\""
  6293. .concat(
  6294. dest,
  6295. "\"."));
  6296. return _context
  6297. .abrupt(
  6298. "return");
  6299. case 16:
  6300. _classPrivateMethodGet
  6301. (this,
  6302. _goToDestinationHelper,
  6303. _goToDestinationHelper2
  6304. ).call(this,
  6305. dest,
  6306. namedDest,
  6307. explicitDest
  6308. );
  6309. case 17:
  6310. case "end":
  6311. return _context
  6312. .stop();
  6313. }
  6314. }
  6315. }, _callee, this);
  6316. }));
  6317. function goToDestination(_x) {
  6318. return _goToDestination.apply(this, arguments);
  6319. }
  6320. return goToDestination;
  6321. }()
  6322. }, {
  6323. key: "goToPage",
  6324. value: function goToPage(val) {
  6325. if (!this.pdfDocument) {
  6326. return;
  6327. }
  6328. var pageNumber = typeof val === "string" && this.pdfViewer
  6329. .pageLabelToPageNumber(val) || val | 0;
  6330. if (!(Number.isInteger(pageNumber) && pageNumber > 0 &&
  6331. pageNumber <= this.pagesCount)) {
  6332. console.error("PDFLinkService.goToPage: \"".concat(val,
  6333. "\" is not a valid page."));
  6334. return;
  6335. }
  6336. if (this.pdfHistory) {
  6337. this.pdfHistory.pushCurrentPosition();
  6338. this.pdfHistory.pushPage(pageNumber);
  6339. }
  6340. this.pdfViewer.scrollPageIntoView({
  6341. pageNumber: pageNumber
  6342. });
  6343. }
  6344. }, {
  6345. key: "addLinkAttributes",
  6346. value: function addLinkAttributes(link, url) {
  6347. var newWindow = arguments.length > 2 && arguments[2] !==
  6348. undefined ? arguments[2] : false;
  6349. _addLinkAttributes(link, {
  6350. url: url,
  6351. target: newWindow ? LinkTarget.BLANK : this
  6352. .externalLinkTarget,
  6353. rel: this.externalLinkRel,
  6354. enabled: this.externalLinkEnabled
  6355. });
  6356. }
  6357. }, {
  6358. key: "getDestinationHash",
  6359. value: function getDestinationHash(dest) {
  6360. if (typeof dest === "string") {
  6361. if (dest.length > 0) {
  6362. return this.getAnchorUrl("#" + escape(dest));
  6363. }
  6364. } else if (Array.isArray(dest)) {
  6365. var str = JSON.stringify(dest);
  6366. if (str.length > 0) {
  6367. return this.getAnchorUrl("#" + escape(str));
  6368. }
  6369. }
  6370. return this.getAnchorUrl("");
  6371. }
  6372. }, {
  6373. key: "getAnchorUrl",
  6374. value: function getAnchorUrl(anchor) {
  6375. return (this.baseUrl || "") + anchor;
  6376. }
  6377. }, {
  6378. key: "setHash",
  6379. value: function setHash(hash) {
  6380. if (!this.pdfDocument) {
  6381. return;
  6382. }
  6383. var pageNumber, dest;
  6384. if (hash.includes("=")) {
  6385. var params = (0, _ui_utils.parseQueryString)(hash);
  6386. if (params.has("search")) {
  6387. this.eventBus.dispatch("findfromurlhash", {
  6388. source: this,
  6389. query: params.get("search").replace(
  6390. /"/g, ""),
  6391. phraseSearch: params.get("phrase") ===
  6392. "true"
  6393. });
  6394. }
  6395. if (params.has("page")) {
  6396. pageNumber = params.get("page") | 0 || 1;
  6397. }
  6398. if (params.has("zoom")) {
  6399. var zoomArgs = params.get("zoom").split(",");
  6400. var zoomArg = zoomArgs[0];
  6401. var zoomArgNumber = parseFloat(zoomArg);
  6402. if (!zoomArg.includes("Fit")) {
  6403. dest = [null, {
  6404. name: "XYZ"
  6405. }, zoomArgs.length > 1 ? zoomArgs[1] |
  6406. 0 : null, zoomArgs.length > 2 ?
  6407. zoomArgs[2] | 0 : null, zoomArgNumber ?
  6408. zoomArgNumber / 100 : zoomArg
  6409. ];
  6410. } else {
  6411. if (zoomArg === "Fit" || zoomArg === "FitB") {
  6412. dest = [null, {
  6413. name: zoomArg
  6414. }];
  6415. } else if (zoomArg === "FitH" || zoomArg ===
  6416. "FitBH" || zoomArg === "FitV" || zoomArg ===
  6417. "FitBV") {
  6418. dest = [null, {
  6419. name: zoomArg
  6420. }, zoomArgs.length > 1 ? zoomArgs[
  6421. 1] | 0 : null
  6422. ];
  6423. } else if (zoomArg === "FitR") {
  6424. if (zoomArgs.length !== 5) {
  6425. console.error(
  6426. 'PDFLinkService.setHash: Not enough parameters for "FitR".'
  6427. );
  6428. } else {
  6429. dest = [null, {
  6430. name: zoomArg
  6431. }, zoomArgs[1] | 0, zoomArgs[
  6432. 2] | 0, zoomArgs[3] | 0,
  6433. zoomArgs[4] | 0
  6434. ];
  6435. }
  6436. } else {
  6437. console.error("PDFLinkService.setHash: \""
  6438. .concat(zoomArg,
  6439. "\" is not a valid zoom value.")
  6440. );
  6441. }
  6442. }
  6443. }
  6444. if (dest) {
  6445. this.pdfViewer.scrollPageIntoView({
  6446. pageNumber: pageNumber || this.page,
  6447. destArray: dest,
  6448. allowNegativeOffset: true
  6449. });
  6450. } else if (pageNumber) {
  6451. this.page = pageNumber;
  6452. }
  6453. if (params.has("pagemode")) {
  6454. this.eventBus.dispatch("pagemode", {
  6455. source: this,
  6456. mode: params.get("pagemode")
  6457. });
  6458. }
  6459. if (params.has("nameddest")) {
  6460. this.goToDestination(params.get("nameddest"));
  6461. }
  6462. } else {
  6463. dest = unescape(hash);
  6464. try {
  6465. dest = JSON.parse(dest);
  6466. if (!Array.isArray(dest)) {
  6467. dest = dest.toString();
  6468. }
  6469. } catch (ex) {}
  6470. if (typeof dest === "string" ||
  6471. _classStaticPrivateMethodGet(PDFLinkService,
  6472. PDFLinkService, _isValidExplicitDestination)
  6473. .call(PDFLinkService, dest)) {
  6474. this.goToDestination(dest);
  6475. return;
  6476. }
  6477. console.error("PDFLinkService.setHash: \"".concat(
  6478. unescape(hash),
  6479. "\" is not a valid destination."));
  6480. }
  6481. }
  6482. }, {
  6483. key: "executeNamedAction",
  6484. value: function executeNamedAction(action) {
  6485. var _this$pdfHistory, _this$pdfHistory2;
  6486. switch (action) {
  6487. case "GoBack":
  6488. (_this$pdfHistory = this.pdfHistory) === null ||
  6489. _this$pdfHistory === void 0 ? void 0 :
  6490. _this$pdfHistory.back();
  6491. break;
  6492. case "GoForward":
  6493. (_this$pdfHistory2 = this.pdfHistory) === null ||
  6494. _this$pdfHistory2 === void 0 ? void 0 :
  6495. _this$pdfHistory2.forward();
  6496. break;
  6497. case "NextPage":
  6498. this.pdfViewer.nextPage();
  6499. break;
  6500. case "PrevPage":
  6501. this.pdfViewer.previousPage();
  6502. break;
  6503. case "LastPage":
  6504. this.page = this.pagesCount;
  6505. break;
  6506. case "FirstPage":
  6507. this.page = 1;
  6508. break;
  6509. default:
  6510. break;
  6511. }
  6512. this.eventBus.dispatch("namedaction", {
  6513. source: this,
  6514. action: action
  6515. });
  6516. }
  6517. }, {
  6518. key: "cachePageRef",
  6519. value: function cachePageRef(pageNum, pageRef) {
  6520. if (!pageRef) {
  6521. return;
  6522. }
  6523. var refStr = pageRef.gen === 0 ? "".concat(pageRef.num,
  6524. "R") : "".concat(pageRef.num, "R").concat(pageRef.gen);
  6525. _classPrivateFieldGet(this, _pagesRefCache).set(refStr,
  6526. pageNum);
  6527. }
  6528. }, {
  6529. key: "_cachedPageNumber",
  6530. value: function _cachedPageNumber(pageRef) {
  6531. if (!pageRef) {
  6532. return null;
  6533. }
  6534. var refStr = pageRef.gen === 0 ? "".concat(pageRef.num,
  6535. "R") : "".concat(pageRef.num, "R").concat(pageRef.gen);
  6536. return _classPrivateFieldGet(this, _pagesRefCache).get(
  6537. refStr) || null;
  6538. }
  6539. }, {
  6540. key: "isPageVisible",
  6541. value: function isPageVisible(pageNumber) {
  6542. return this.pdfViewer.isPageVisible(pageNumber);
  6543. }
  6544. }, {
  6545. key: "isPageCached",
  6546. value: function isPageCached(pageNumber) {
  6547. return this.pdfViewer.isPageCached(pageNumber);
  6548. }
  6549. }]);
  6550. return PDFLinkService;
  6551. }();
  6552. exports.PDFLinkService = PDFLinkService;
  6553. function _goToDestinationHelper2(rawDest) {
  6554. var _this = this;
  6555. var namedDest = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] :
  6556. null;
  6557. var explicitDest = arguments.length > 2 ? arguments[2] : undefined;
  6558. var destRef = explicitDest[0];
  6559. var pageNumber;
  6560. if (_typeof(destRef) === "object" && destRef !== null) {
  6561. pageNumber = this._cachedPageNumber(destRef);
  6562. if (!pageNumber) {
  6563. this.pdfDocument.getPageIndex(destRef).then(function(pageIndex) {
  6564. _this.cachePageRef(pageIndex + 1, destRef);
  6565. _classPrivateMethodGet(_this, _goToDestinationHelper,
  6566. _goToDestinationHelper2).call(_this, rawDest, namedDest,
  6567. explicitDest);
  6568. })["catch"](function() {
  6569. console.error("PDFLinkService.#goToDestinationHelper: \"".concat(
  6570. destRef, "\" is not ") +
  6571. "a valid page reference, for dest=\"".concat(rawDest, "\".")
  6572. );
  6573. });
  6574. return;
  6575. }
  6576. } else if (Number.isInteger(destRef)) {
  6577. pageNumber = destRef + 1;
  6578. } else {
  6579. console.error("PDFLinkService.#goToDestinationHelper: \"".concat(destRef,
  6580. "\" is not ") + "a valid destination reference, for dest=\"".concat(
  6581. rawDest, "\"."));
  6582. return;
  6583. }
  6584. if (!pageNumber || pageNumber < 1 || pageNumber > this.pagesCount) {
  6585. console.error("PDFLinkService.#goToDestinationHelper: \"".concat(pageNumber,
  6586. "\" is not ") + "a valid page number, for dest=\"".concat(rawDest,
  6587. "\"."));
  6588. return;
  6589. }
  6590. if (this.pdfHistory) {
  6591. this.pdfHistory.pushCurrentPosition();
  6592. this.pdfHistory.push({
  6593. namedDest: namedDest,
  6594. explicitDest: explicitDest,
  6595. pageNumber: pageNumber
  6596. });
  6597. }
  6598. this.pdfViewer.scrollPageIntoView({
  6599. pageNumber: pageNumber,
  6600. destArray: explicitDest,
  6601. ignoreDestinationZoom: this._ignoreDestinationZoom
  6602. });
  6603. }
  6604. function _isValidExplicitDestination(dest) {
  6605. if (!Array.isArray(dest)) {
  6606. return false;
  6607. }
  6608. var destLength = dest.length;
  6609. if (destLength < 2) {
  6610. return false;
  6611. }
  6612. var page = dest[0];
  6613. if (!(_typeof(page) === "object" && Number.isInteger(page.num) && Number.isInteger(page
  6614. .gen)) && !(Number.isInteger(page) && page >= 0)) {
  6615. return false;
  6616. }
  6617. var zoom = dest[1];
  6618. if (!(_typeof(zoom) === "object" && typeof zoom.name === "string")) {
  6619. return false;
  6620. }
  6621. var allowNull = true;
  6622. switch (zoom.name) {
  6623. case "XYZ":
  6624. if (destLength !== 5) {
  6625. return false;
  6626. }
  6627. break;
  6628. case "Fit":
  6629. case "FitB":
  6630. return destLength === 2;
  6631. case "FitH":
  6632. case "FitBH":
  6633. case "FitV":
  6634. case "FitBV":
  6635. if (destLength !== 3) {
  6636. return false;
  6637. }
  6638. break;
  6639. case "FitR":
  6640. if (destLength !== 6) {
  6641. return false;
  6642. }
  6643. allowNull = false;
  6644. break;
  6645. default:
  6646. return false;
  6647. }
  6648. for (var i = 2; i < destLength; i++) {
  6649. var param = dest[i];
  6650. if (!(typeof param === "number" || allowNull && param === null)) {
  6651. return false;
  6652. }
  6653. }
  6654. return true;
  6655. }
  6656. var SimpleLinkService = /*#__PURE__*/ function() {
  6657. function SimpleLinkService() {
  6658. _classCallCheck(this, SimpleLinkService);
  6659. this.externalLinkEnabled = true;
  6660. }
  6661. _createClass(SimpleLinkService, [{
  6662. key: "pagesCount",
  6663. get: function get() {
  6664. return 0;
  6665. }
  6666. }, {
  6667. key: "page",
  6668. get: function get() {
  6669. return 0;
  6670. },
  6671. set: function set(value) {}
  6672. }, {
  6673. key: "rotation",
  6674. get: function get() {
  6675. return 0;
  6676. },
  6677. set: function set(value) {}
  6678. }, {
  6679. key: "goToDestination",
  6680. value: function() {
  6681. var _goToDestination2 = _asyncToGenerator( /*#__PURE__*/
  6682. _regenerator["default"].mark(function _callee2(
  6683. dest) {
  6684. return _regenerator["default"].wrap(
  6685. function _callee2$(_context2) {
  6686. while (1) {
  6687. switch (_context2.prev =
  6688. _context2.next) {
  6689. case 0:
  6690. case "end":
  6691. return _context2
  6692. .stop();
  6693. }
  6694. }
  6695. }, _callee2);
  6696. }));
  6697. function goToDestination(_x2) {
  6698. return _goToDestination2.apply(this, arguments);
  6699. }
  6700. return goToDestination;
  6701. }()
  6702. }, {
  6703. key: "goToPage",
  6704. value: function goToPage(val) {}
  6705. }, {
  6706. key: "addLinkAttributes",
  6707. value: function addLinkAttributes(link, url) {
  6708. var newWindow = arguments.length > 2 && arguments[2] !==
  6709. undefined ? arguments[2] : false;
  6710. _addLinkAttributes(link, {
  6711. url: url,
  6712. enabled: this.externalLinkEnabled
  6713. });
  6714. }
  6715. }, {
  6716. key: "getDestinationHash",
  6717. value: function getDestinationHash(dest) {
  6718. return "#";
  6719. }
  6720. }, {
  6721. key: "getAnchorUrl",
  6722. value: function getAnchorUrl(hash) {
  6723. return "#";
  6724. }
  6725. }, {
  6726. key: "setHash",
  6727. value: function setHash(hash) {}
  6728. }, {
  6729. key: "executeNamedAction",
  6730. value: function executeNamedAction(action) {}
  6731. }, {
  6732. key: "cachePageRef",
  6733. value: function cachePageRef(pageNum, pageRef) {}
  6734. }, {
  6735. key: "isPageVisible",
  6736. value: function isPageVisible(pageNumber) {
  6737. return true;
  6738. }
  6739. }, {
  6740. key: "isPageCached",
  6741. value: function isPageCached(pageNumber) {
  6742. return true;
  6743. }
  6744. }]);
  6745. return SimpleLinkService;
  6746. }();
  6747. exports.SimpleLinkService = SimpleLinkService;
  6748. /***/
  6749. }),
  6750. /* 11 */
  6751. /***/
  6752. ((__unused_webpack_module, exports, __webpack_require__) => {
  6753. Object.defineProperty(exports, "__esModule", ({
  6754. value: true
  6755. }));
  6756. exports.OverlayManager = void 0;
  6757. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  6758. function _interopRequireDefault(obj) {
  6759. return obj && obj.__esModule ? obj : {
  6760. "default": obj
  6761. };
  6762. }
  6763. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  6764. try {
  6765. var info = gen[key](arg);
  6766. var value = info.value;
  6767. } catch (error) {
  6768. reject(error);
  6769. return;
  6770. }
  6771. if (info.done) {
  6772. resolve(value);
  6773. } else {
  6774. Promise.resolve(value).then(_next, _throw);
  6775. }
  6776. }
  6777. function _asyncToGenerator(fn) {
  6778. return function() {
  6779. var self = this,
  6780. args = arguments;
  6781. return new Promise(function(resolve, reject) {
  6782. var gen = fn.apply(self, args);
  6783. function _next(value) {
  6784. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next",
  6785. value);
  6786. }
  6787. function _throw(err) {
  6788. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw",
  6789. err);
  6790. }
  6791. _next(undefined);
  6792. });
  6793. };
  6794. }
  6795. function _classCallCheck(instance, Constructor) {
  6796. if (!(instance instanceof Constructor)) {
  6797. throw new TypeError("Cannot call a class as a function");
  6798. }
  6799. }
  6800. function _defineProperties(target, props) {
  6801. for (var i = 0; i < props.length; i++) {
  6802. var descriptor = props[i];
  6803. descriptor.enumerable = descriptor.enumerable || false;
  6804. descriptor.configurable = true;
  6805. if ("value" in descriptor) descriptor.writable = true;
  6806. Object.defineProperty(target, descriptor.key, descriptor);
  6807. }
  6808. }
  6809. function _createClass(Constructor, protoProps, staticProps) {
  6810. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  6811. if (staticProps) _defineProperties(Constructor, staticProps);
  6812. Object.defineProperty(Constructor, "prototype", {
  6813. writable: false
  6814. });
  6815. return Constructor;
  6816. }
  6817. var OverlayManager = /*#__PURE__*/ function() {
  6818. function OverlayManager() {
  6819. _classCallCheck(this, OverlayManager);
  6820. this._overlays = {};
  6821. this._active = null;
  6822. this._keyDownBound = this._keyDown.bind(this);
  6823. }
  6824. _createClass(OverlayManager, [{
  6825. key: "active",
  6826. get: function get() {
  6827. return this._active;
  6828. }
  6829. }, {
  6830. key: "register",
  6831. value: function() {
  6832. var _register = _asyncToGenerator( /*#__PURE__*/
  6833. _regenerator["default"].mark(function _callee(name,
  6834. element) {
  6835. var callerCloseMethod,
  6836. canForceClose,
  6837. container,
  6838. _args = arguments;
  6839. return _regenerator["default"].wrap(
  6840. function _callee$(_context) {
  6841. while (1) {
  6842. switch (_context.prev =
  6843. _context.next) {
  6844. case 0:
  6845. callerCloseMethod =
  6846. _args.length >
  6847. 2 && _args[
  6848. 2] !==
  6849. undefined ?
  6850. _args[2] : null;
  6851. canForceClose =
  6852. _args.length >
  6853. 3 && _args[
  6854. 3] !==
  6855. undefined ?
  6856. _args[3] :
  6857. false;
  6858. if (!(!name || !
  6859. element || !
  6860. (container =
  6861. element
  6862. .parentNode
  6863. ))) {
  6864. _context.next =
  6865. 6;
  6866. break;
  6867. }
  6868. throw new Error(
  6869. "Not enough parameters."
  6870. );
  6871. case 6:
  6872. if (!this._overlays[
  6873. name]) {
  6874. _context.next =
  6875. 8;
  6876. break;
  6877. }
  6878. throw new Error(
  6879. "The overlay is already registered."
  6880. );
  6881. case 8:
  6882. this._overlays[
  6883. name] = {
  6884. element: element,
  6885. container: container,
  6886. callerCloseMethod: callerCloseMethod,
  6887. canForceClose: canForceClose
  6888. };
  6889. case 9:
  6890. case "end":
  6891. return _context
  6892. .stop();
  6893. }
  6894. }
  6895. }, _callee, this);
  6896. }));
  6897. function register(_x, _x2) {
  6898. return _register.apply(this, arguments);
  6899. }
  6900. return register;
  6901. }()
  6902. }, {
  6903. key: "unregister",
  6904. value: function() {
  6905. var _unregister = _asyncToGenerator( /*#__PURE__*/
  6906. _regenerator["default"].mark(function _callee2(
  6907. name) {
  6908. return _regenerator["default"].wrap(
  6909. function _callee2$(_context2) {
  6910. while (1) {
  6911. switch (_context2.prev =
  6912. _context2.next) {
  6913. case 0:
  6914. if (this._overlays[
  6915. name]) {
  6916. _context2.next =
  6917. 4;
  6918. break;
  6919. }
  6920. throw new Error(
  6921. "The overlay does not exist."
  6922. );
  6923. case 4:
  6924. if (!(this
  6925. ._active ===
  6926. name)) {
  6927. _context2.next =
  6928. 6;
  6929. break;
  6930. }
  6931. throw new Error(
  6932. "The overlay cannot be removed while it is active."
  6933. );
  6934. case 6:
  6935. delete this
  6936. ._overlays[
  6937. name];
  6938. case 7:
  6939. case "end":
  6940. return _context2
  6941. .stop();
  6942. }
  6943. }
  6944. }, _callee2, this);
  6945. }));
  6946. function unregister(_x3) {
  6947. return _unregister.apply(this, arguments);
  6948. }
  6949. return unregister;
  6950. }()
  6951. }, {
  6952. key: "open",
  6953. value: function() {
  6954. var _open = _asyncToGenerator( /*#__PURE__*/ _regenerator[
  6955. "default"].mark(function _callee3(name) {
  6956. return _regenerator["default"].wrap(
  6957. function _callee3$(_context3) {
  6958. while (1) {
  6959. switch (_context3.prev =
  6960. _context3.next) {
  6961. case 0:
  6962. if (this._overlays[
  6963. name]) {
  6964. _context3.next =
  6965. 4;
  6966. break;
  6967. }
  6968. throw new Error(
  6969. "The overlay does not exist."
  6970. );
  6971. case 4:
  6972. if (!this._active) {
  6973. _context3.next =
  6974. 14;
  6975. break;
  6976. }
  6977. if (!this._overlays[
  6978. name]
  6979. .canForceClose
  6980. ) {
  6981. _context3.next =
  6982. 9;
  6983. break;
  6984. }
  6985. this
  6986. ._closeThroughCaller();
  6987. _context3.next = 14;
  6988. break;
  6989. case 9:
  6990. if (!(this
  6991. ._active ===
  6992. name)) {
  6993. _context3.next =
  6994. 13;
  6995. break;
  6996. }
  6997. throw new Error(
  6998. "The overlay is already active."
  6999. );
  7000. case 13:
  7001. throw new Error(
  7002. "Another overlay is currently active."
  7003. );
  7004. case 14:
  7005. this._active = name;
  7006. this._overlays[this
  7007. ._active]
  7008. .element
  7009. .classList
  7010. .remove(
  7011. "hidden");
  7012. this._overlays[this
  7013. ._active]
  7014. .container
  7015. .classList
  7016. .remove(
  7017. "hidden");
  7018. window
  7019. .addEventListener(
  7020. "keydown",
  7021. this
  7022. ._keyDownBound
  7023. );
  7024. case 18:
  7025. case "end":
  7026. return _context3
  7027. .stop();
  7028. }
  7029. }
  7030. }, _callee3, this);
  7031. }));
  7032. function open(_x4) {
  7033. return _open.apply(this, arguments);
  7034. }
  7035. return open;
  7036. }()
  7037. }, {
  7038. key: "close",
  7039. value: function() {
  7040. var _close = _asyncToGenerator( /*#__PURE__*/ _regenerator[
  7041. "default"].mark(function _callee4(name) {
  7042. return _regenerator["default"].wrap(
  7043. function _callee4$(_context4) {
  7044. while (1) {
  7045. switch (_context4.prev =
  7046. _context4.next) {
  7047. case 0:
  7048. if (this._overlays[
  7049. name]) {
  7050. _context4.next =
  7051. 4;
  7052. break;
  7053. }
  7054. throw new Error(
  7055. "The overlay does not exist."
  7056. );
  7057. case 4:
  7058. if (this._active) {
  7059. _context4.next =
  7060. 8;
  7061. break;
  7062. }
  7063. throw new Error(
  7064. "The overlay is currently not active."
  7065. );
  7066. case 8:
  7067. if (!(this
  7068. ._active !==
  7069. name)) {
  7070. _context4.next =
  7071. 10;
  7072. break;
  7073. }
  7074. throw new Error(
  7075. "Another overlay is currently active."
  7076. );
  7077. case 10:
  7078. this._overlays[this
  7079. ._active]
  7080. .container
  7081. .classList.add(
  7082. "hidden");
  7083. this._overlays[this
  7084. ._active]
  7085. .element
  7086. .classList.add(
  7087. "hidden");
  7088. this._active = null;
  7089. window
  7090. .removeEventListener(
  7091. "keydown",
  7092. this
  7093. ._keyDownBound
  7094. );
  7095. case 14:
  7096. case "end":
  7097. return _context4
  7098. .stop();
  7099. }
  7100. }
  7101. }, _callee4, this);
  7102. }));
  7103. function close(_x5) {
  7104. return _close.apply(this, arguments);
  7105. }
  7106. return close;
  7107. }()
  7108. }, {
  7109. key: "_keyDown",
  7110. value: function _keyDown(evt) {
  7111. if (this._active && evt.keyCode === 27) {
  7112. this._closeThroughCaller();
  7113. evt.preventDefault();
  7114. }
  7115. }
  7116. }, {
  7117. key: "_closeThroughCaller",
  7118. value: function _closeThroughCaller() {
  7119. if (this._overlays[this._active].callerCloseMethod) {
  7120. this._overlays[this._active].callerCloseMethod();
  7121. }
  7122. if (this._active) {
  7123. this.close(this._active);
  7124. }
  7125. }
  7126. }]);
  7127. return OverlayManager;
  7128. }();
  7129. exports.OverlayManager = OverlayManager;
  7130. /***/
  7131. }),
  7132. /* 12 */
  7133. /***/
  7134. ((__unused_webpack_module, exports, __webpack_require__) => {
  7135. Object.defineProperty(exports, "__esModule", ({
  7136. value: true
  7137. }));
  7138. exports.PasswordPrompt = void 0;
  7139. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  7140. var _pdfjsLib = __webpack_require__(7);
  7141. function _interopRequireDefault(obj) {
  7142. return obj && obj.__esModule ? obj : {
  7143. "default": obj
  7144. };
  7145. }
  7146. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  7147. try {
  7148. var info = gen[key](arg);
  7149. var value = info.value;
  7150. } catch (error) {
  7151. reject(error);
  7152. return;
  7153. }
  7154. if (info.done) {
  7155. resolve(value);
  7156. } else {
  7157. Promise.resolve(value).then(_next, _throw);
  7158. }
  7159. }
  7160. function _asyncToGenerator(fn) {
  7161. return function() {
  7162. var self = this,
  7163. args = arguments;
  7164. return new Promise(function(resolve, reject) {
  7165. var gen = fn.apply(self, args);
  7166. function _next(value) {
  7167. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next",
  7168. value);
  7169. }
  7170. function _throw(err) {
  7171. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw",
  7172. err);
  7173. }
  7174. _next(undefined);
  7175. });
  7176. };
  7177. }
  7178. function _classCallCheck(instance, Constructor) {
  7179. if (!(instance instanceof Constructor)) {
  7180. throw new TypeError("Cannot call a class as a function");
  7181. }
  7182. }
  7183. function _defineProperties(target, props) {
  7184. for (var i = 0; i < props.length; i++) {
  7185. var descriptor = props[i];
  7186. descriptor.enumerable = descriptor.enumerable || false;
  7187. descriptor.configurable = true;
  7188. if ("value" in descriptor) descriptor.writable = true;
  7189. Object.defineProperty(target, descriptor.key, descriptor);
  7190. }
  7191. }
  7192. function _createClass(Constructor, protoProps, staticProps) {
  7193. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  7194. if (staticProps) _defineProperties(Constructor, staticProps);
  7195. Object.defineProperty(Constructor, "prototype", {
  7196. writable: false
  7197. });
  7198. return Constructor;
  7199. }
  7200. function _classPrivateMethodInitSpec(obj, privateSet) {
  7201. _checkPrivateRedeclaration(obj, privateSet);
  7202. privateSet.add(obj);
  7203. }
  7204. function _checkPrivateRedeclaration(obj, privateCollection) {
  7205. if (privateCollection.has(obj)) {
  7206. throw new TypeError(
  7207. "Cannot initialize the same private elements twice on an object");
  7208. }
  7209. }
  7210. function _classPrivateMethodGet(receiver, privateSet, fn) {
  7211. if (!privateSet.has(receiver)) {
  7212. throw new TypeError("attempted to get private field on non-instance");
  7213. }
  7214. return fn;
  7215. }
  7216. var _verify = /*#__PURE__*/ new WeakSet();
  7217. var _cancel = /*#__PURE__*/ new WeakSet();
  7218. var PasswordPrompt = /*#__PURE__*/ function() {
  7219. function PasswordPrompt(options, overlayManager, l10n) {
  7220. var _this = this;
  7221. var isViewerEmbedded = arguments.length > 3 && arguments[3] !== undefined ?
  7222. arguments[3] : false;
  7223. _classCallCheck(this, PasswordPrompt);
  7224. _classPrivateMethodInitSpec(this, _cancel);
  7225. _classPrivateMethodInitSpec(this, _verify);
  7226. this.overlayName = options.overlayName;
  7227. this.container = options.container;
  7228. this.label = options.label;
  7229. this.input = options.input;
  7230. this.submitButton = options.submitButton;
  7231. this.cancelButton = options.cancelButton;
  7232. this.overlayManager = overlayManager;
  7233. this.l10n = l10n;
  7234. this._isViewerEmbedded = isViewerEmbedded;
  7235. this.updateCallback = null;
  7236. this.reason = null;
  7237. this.submitButton.addEventListener("click", _classPrivateMethodGet(this,
  7238. _verify, _verify2).bind(this));
  7239. this.cancelButton.addEventListener("click", _classPrivateMethodGet(this,
  7240. _cancel, _cancel2).bind(this));
  7241. this.input.addEventListener("keydown", function(e) {
  7242. if (e.keyCode === 13) {
  7243. _classPrivateMethodGet(_this, _verify, _verify2).call(_this);
  7244. }
  7245. });
  7246. this.overlayManager.register(this.overlayName, this.container,
  7247. _classPrivateMethodGet(this, _cancel, _cancel2).bind(this), true);
  7248. }
  7249. _createClass(PasswordPrompt, [{
  7250. key: "open",
  7251. value: function() {
  7252. var _open = _asyncToGenerator( /*#__PURE__*/ _regenerator[
  7253. "default"].mark(function _callee() {
  7254. var passwordIncorrect;
  7255. return _regenerator["default"].wrap(
  7256. function _callee$(_context) {
  7257. while (1) {
  7258. switch (_context.prev =
  7259. _context.next) {
  7260. case 0:
  7261. _context.next = 2;
  7262. return this
  7263. .overlayManager
  7264. .open(this
  7265. .overlayName
  7266. );
  7267. case 2:
  7268. passwordIncorrect =
  7269. this.reason ===
  7270. _pdfjsLib
  7271. .PasswordResponses
  7272. .INCORRECT_PASSWORD;
  7273. if (!this
  7274. ._isViewerEmbedded ||
  7275. passwordIncorrect
  7276. ) {
  7277. this.input
  7278. .focus();
  7279. }
  7280. _context.next = 6;
  7281. return this.l10n
  7282. .get("password_"
  7283. .concat(
  7284. passwordIncorrect ?
  7285. "invalid" :
  7286. "label")
  7287. );
  7288. case 6:
  7289. this.label
  7290. .textContent =
  7291. _context.sent;
  7292. case 7:
  7293. case "end":
  7294. return _context
  7295. .stop();
  7296. }
  7297. }
  7298. }, _callee, this);
  7299. }));
  7300. function open() {
  7301. return _open.apply(this, arguments);
  7302. }
  7303. return open;
  7304. }()
  7305. }, {
  7306. key: "close",
  7307. value: function() {
  7308. var _close = _asyncToGenerator( /*#__PURE__*/ _regenerator[
  7309. "default"].mark(function _callee2() {
  7310. return _regenerator["default"].wrap(
  7311. function _callee2$(_context2) {
  7312. while (1) {
  7313. switch (_context2.prev =
  7314. _context2.next) {
  7315. case 0:
  7316. _context2.next = 2;
  7317. return this
  7318. .overlayManager
  7319. .close(this
  7320. .overlayName
  7321. );
  7322. case 2:
  7323. this.input.value =
  7324. "";
  7325. case 3:
  7326. case "end":
  7327. return _context2
  7328. .stop();
  7329. }
  7330. }
  7331. }, _callee2, this);
  7332. }));
  7333. function close() {
  7334. return _close.apply(this, arguments);
  7335. }
  7336. return close;
  7337. }()
  7338. }, {
  7339. key: "setUpdateCallback",
  7340. value: function setUpdateCallback(updateCallback, reason) {
  7341. this.updateCallback = updateCallback;
  7342. this.reason = reason;
  7343. }
  7344. }]);
  7345. return PasswordPrompt;
  7346. }();
  7347. exports.PasswordPrompt = PasswordPrompt;
  7348. function _verify2() {
  7349. var password = this.input.value;
  7350. if ((password === null || password === void 0 ? void 0 : password.length) > 0) {
  7351. this.close();
  7352. this.updateCallback(password);
  7353. }
  7354. }
  7355. function _cancel2() {
  7356. this.close();
  7357. this.updateCallback(new Error("PasswordPrompt cancelled."));
  7358. }
  7359. /***/
  7360. }),
  7361. /* 13 */
  7362. /***/
  7363. ((__unused_webpack_module, exports, __webpack_require__) => {
  7364. function _typeof(obj) {
  7365. "@babel/helpers - typeof";
  7366. return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ?
  7367. function(obj) {
  7368. return typeof obj;
  7369. } : function(obj) {
  7370. return obj && "function" == typeof Symbol && obj.constructor === Symbol &&
  7371. obj !== Symbol.prototype ? "symbol" : typeof obj;
  7372. }, _typeof(obj);
  7373. }
  7374. Object.defineProperty(exports, "__esModule", ({
  7375. value: true
  7376. }));
  7377. exports.PDFAttachmentViewer = void 0;
  7378. var _pdfjsLib = __webpack_require__(7);
  7379. var _base_tree_viewer = __webpack_require__(14);
  7380. function _createForOfIteratorHelper(o, allowArrayLike) {
  7381. var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
  7382. if (!it) {
  7383. if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike &&
  7384. o && typeof o.length === "number") {
  7385. if (it) o = it;
  7386. var i = 0;
  7387. var F = function F() {};
  7388. return {
  7389. s: F,
  7390. n: function n() {
  7391. if (i >= o.length) return {
  7392. done: true
  7393. };
  7394. return {
  7395. done: false,
  7396. value: o[i++]
  7397. };
  7398. },
  7399. e: function e(_e) {
  7400. throw _e;
  7401. },
  7402. f: F
  7403. };
  7404. }
  7405. throw new TypeError(
  7406. "Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
  7407. );
  7408. }
  7409. var normalCompletion = true,
  7410. didErr = false,
  7411. err;
  7412. return {
  7413. s: function s() {
  7414. it = it.call(o);
  7415. },
  7416. n: function n() {
  7417. var step = it.next();
  7418. normalCompletion = step.done;
  7419. return step;
  7420. },
  7421. e: function e(_e2) {
  7422. didErr = true;
  7423. err = _e2;
  7424. },
  7425. f: function f() {
  7426. try {
  7427. if (!normalCompletion && it["return"] != null) it["return"]();
  7428. } finally {
  7429. if (didErr) throw err;
  7430. }
  7431. }
  7432. };
  7433. }
  7434. function _unsupportedIterableToArray(o, minLen) {
  7435. if (!o) return;
  7436. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  7437. var n = Object.prototype.toString.call(o).slice(8, -1);
  7438. if (n === "Object" && o.constructor) n = o.constructor.name;
  7439. if (n === "Map" || n === "Set") return Array.from(o);
  7440. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
  7441. return _arrayLikeToArray(o, minLen);
  7442. }
  7443. function _arrayLikeToArray(arr, len) {
  7444. if (len == null || len > arr.length) len = arr.length;
  7445. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  7446. arr2[i] = arr[i];
  7447. }
  7448. return arr2;
  7449. }
  7450. function _classCallCheck(instance, Constructor) {
  7451. if (!(instance instanceof Constructor)) {
  7452. throw new TypeError("Cannot call a class as a function");
  7453. }
  7454. }
  7455. function _defineProperties(target, props) {
  7456. for (var i = 0; i < props.length; i++) {
  7457. var descriptor = props[i];
  7458. descriptor.enumerable = descriptor.enumerable || false;
  7459. descriptor.configurable = true;
  7460. if ("value" in descriptor) descriptor.writable = true;
  7461. Object.defineProperty(target, descriptor.key, descriptor);
  7462. }
  7463. }
  7464. function _createClass(Constructor, protoProps, staticProps) {
  7465. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  7466. if (staticProps) _defineProperties(Constructor, staticProps);
  7467. Object.defineProperty(Constructor, "prototype", {
  7468. writable: false
  7469. });
  7470. return Constructor;
  7471. }
  7472. function _get() {
  7473. if (typeof Reflect !== "undefined" && Reflect.get) {
  7474. _get = Reflect.get;
  7475. } else {
  7476. _get = function _get(target, property, receiver) {
  7477. var base = _superPropBase(target, property);
  7478. if (!base) return;
  7479. var desc = Object.getOwnPropertyDescriptor(base, property);
  7480. if (desc.get) {
  7481. return desc.get.call(arguments.length < 3 ? target : receiver);
  7482. }
  7483. return desc.value;
  7484. };
  7485. }
  7486. return _get.apply(this, arguments);
  7487. }
  7488. function _superPropBase(object, property) {
  7489. while (!Object.prototype.hasOwnProperty.call(object, property)) {
  7490. object = _getPrototypeOf(object);
  7491. if (object === null) break;
  7492. }
  7493. return object;
  7494. }
  7495. function _inherits(subClass, superClass) {
  7496. if (typeof superClass !== "function" && superClass !== null) {
  7497. throw new TypeError("Super expression must either be null or a function");
  7498. }
  7499. subClass.prototype = Object.create(superClass && superClass.prototype, {
  7500. constructor: {
  7501. value: subClass,
  7502. writable: true,
  7503. configurable: true
  7504. }
  7505. });
  7506. Object.defineProperty(subClass, "prototype", {
  7507. writable: false
  7508. });
  7509. if (superClass) _setPrototypeOf(subClass, superClass);
  7510. }
  7511. function _setPrototypeOf(o, p) {
  7512. _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  7513. o.__proto__ = p;
  7514. return o;
  7515. };
  7516. return _setPrototypeOf(o, p);
  7517. }
  7518. function _createSuper(Derived) {
  7519. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  7520. return function _createSuperInternal() {
  7521. var Super = _getPrototypeOf(Derived),
  7522. result;
  7523. if (hasNativeReflectConstruct) {
  7524. var NewTarget = _getPrototypeOf(this).constructor;
  7525. result = Reflect.construct(Super, arguments, NewTarget);
  7526. } else {
  7527. result = Super.apply(this, arguments);
  7528. }
  7529. return _possibleConstructorReturn(this, result);
  7530. };
  7531. }
  7532. function _possibleConstructorReturn(self, call) {
  7533. if (call && (_typeof(call) === "object" || typeof call === "function")) {
  7534. return call;
  7535. } else if (call !== void 0) {
  7536. throw new TypeError("Derived constructors may only return object or undefined");
  7537. }
  7538. return _assertThisInitialized(self);
  7539. }
  7540. function _assertThisInitialized(self) {
  7541. if (self === void 0) {
  7542. throw new ReferenceError(
  7543. "this hasn't been initialised - super() hasn't been called");
  7544. }
  7545. return self;
  7546. }
  7547. function _isNativeReflectConstruct() {
  7548. if (typeof Reflect === "undefined" || !Reflect.construct) return false;
  7549. if (Reflect.construct.sham) return false;
  7550. if (typeof Proxy === "function") return true;
  7551. try {
  7552. Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
  7553. return true;
  7554. } catch (e) {
  7555. return false;
  7556. }
  7557. }
  7558. function _getPrototypeOf(o) {
  7559. _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf :
  7560. function _getPrototypeOf(o) {
  7561. return o.__proto__ || Object.getPrototypeOf(o);
  7562. };
  7563. return _getPrototypeOf(o);
  7564. }
  7565. var PDFAttachmentViewer = /*#__PURE__*/ function(_BaseTreeViewer) {
  7566. _inherits(PDFAttachmentViewer, _BaseTreeViewer);
  7567. var _super = _createSuper(PDFAttachmentViewer);
  7568. function PDFAttachmentViewer(options) {
  7569. var _this;
  7570. _classCallCheck(this, PDFAttachmentViewer);
  7571. _this = _super.call(this, options);
  7572. _this.downloadManager = options.downloadManager;
  7573. _this.eventBus._on("fileattachmentannotation", _this._appendAttachment.bind(
  7574. _assertThisInitialized(_this)));
  7575. return _this;
  7576. }
  7577. _createClass(PDFAttachmentViewer, [{
  7578. key: "reset",
  7579. value: function reset() {
  7580. var keepRenderedCapability = arguments.length > 0 &&
  7581. arguments[0] !== undefined ? arguments[0] : false;
  7582. _get(_getPrototypeOf(PDFAttachmentViewer.prototype),
  7583. "reset", this).call(this);
  7584. this._attachments = null;
  7585. if (!keepRenderedCapability) {
  7586. this._renderedCapability = (0, _pdfjsLib
  7587. .createPromiseCapability)();
  7588. }
  7589. if (this._pendingDispatchEvent) {
  7590. clearTimeout(this._pendingDispatchEvent);
  7591. }
  7592. this._pendingDispatchEvent = null;
  7593. }
  7594. }, {
  7595. key: "_dispatchEvent",
  7596. value: function _dispatchEvent(attachmentsCount) {
  7597. var _this2 = this;
  7598. this._renderedCapability.resolve();
  7599. if (this._pendingDispatchEvent) {
  7600. clearTimeout(this._pendingDispatchEvent);
  7601. this._pendingDispatchEvent = null;
  7602. }
  7603. if (attachmentsCount === 0) {
  7604. this._pendingDispatchEvent = setTimeout(function() {
  7605. _this2.eventBus.dispatch(
  7606. "attachmentsloaded", {
  7607. source: _this2,
  7608. attachmentsCount: 0
  7609. });
  7610. _this2._pendingDispatchEvent = null;
  7611. });
  7612. return;
  7613. }
  7614. this.eventBus.dispatch("attachmentsloaded", {
  7615. source: this,
  7616. attachmentsCount: attachmentsCount
  7617. });
  7618. }
  7619. }, {
  7620. key: "_bindLink",
  7621. value: function _bindLink(element, _ref) {
  7622. var _this3 = this;
  7623. var content = _ref.content,
  7624. filename = _ref.filename;
  7625. element.onclick = function() {
  7626. _this3.downloadManager.openOrDownloadData(element,
  7627. content, filename);
  7628. return false;
  7629. };
  7630. }
  7631. }, {
  7632. key: "render",
  7633. value: function render(_ref2) {
  7634. var attachments = _ref2.attachments,
  7635. _ref2$keepRenderedCap = _ref2.keepRenderedCapability,
  7636. keepRenderedCapability = _ref2$keepRenderedCap ===
  7637. void 0 ? false : _ref2$keepRenderedCap;
  7638. if (this._attachments) {
  7639. this.reset(keepRenderedCapability);
  7640. }
  7641. this._attachments = attachments || null;
  7642. if (!attachments) {
  7643. this._dispatchEvent(0);
  7644. return;
  7645. }
  7646. var names = Object.keys(attachments).sort(function(a, b) {
  7647. return a.toLowerCase().localeCompare(b
  7648. .toLowerCase());
  7649. });
  7650. var fragment = document.createDocumentFragment();
  7651. var attachmentsCount = 0;
  7652. var _iterator = _createForOfIteratorHelper(names),
  7653. _step;
  7654. try {
  7655. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  7656. var name = _step.value;
  7657. var item = attachments[name];
  7658. var content = item.content,
  7659. filename = (0, _pdfjsLib.getFilenameFromUrl)(
  7660. item.filename);
  7661. var div = document.createElement("div");
  7662. div.className = "treeItem";
  7663. var element = document.createElement("a");
  7664. this._bindLink(element, {
  7665. content: content,
  7666. filename: filename
  7667. });
  7668. element.textContent = this._normalizeTextContent(
  7669. filename);
  7670. div.appendChild(element);
  7671. fragment.appendChild(div);
  7672. attachmentsCount++;
  7673. }
  7674. } catch (err) {
  7675. _iterator.e(err);
  7676. } finally {
  7677. _iterator.f();
  7678. }
  7679. this._finishRendering(fragment, attachmentsCount);
  7680. }
  7681. }, {
  7682. key: "_appendAttachment",
  7683. value: function _appendAttachment(_ref3) {
  7684. var _this4 = this;
  7685. var id = _ref3.id,
  7686. filename = _ref3.filename,
  7687. content = _ref3.content;
  7688. var renderedPromise = this._renderedCapability.promise;
  7689. renderedPromise.then(function() {
  7690. if (renderedPromise !== _this4
  7691. ._renderedCapability.promise) {
  7692. return;
  7693. }
  7694. var attachments = _this4._attachments;
  7695. if (!attachments) {
  7696. attachments = Object.create(null);
  7697. } else {
  7698. for (var name in attachments) {
  7699. if (id === name) {
  7700. return;
  7701. }
  7702. }
  7703. }
  7704. attachments[id] = {
  7705. filename: filename,
  7706. content: content
  7707. };
  7708. _this4.render({
  7709. attachments: attachments,
  7710. keepRenderedCapability: true
  7711. });
  7712. });
  7713. }
  7714. }]);
  7715. return PDFAttachmentViewer;
  7716. }(_base_tree_viewer.BaseTreeViewer);
  7717. exports.PDFAttachmentViewer = PDFAttachmentViewer;
  7718. /***/
  7719. }),
  7720. /* 14 */
  7721. /***/
  7722. ((__unused_webpack_module, exports, __webpack_require__) => {
  7723. Object.defineProperty(exports, "__esModule", ({
  7724. value: true
  7725. }));
  7726. exports.BaseTreeViewer = void 0;
  7727. var _ui_utils = __webpack_require__(5);
  7728. function _createForOfIteratorHelper(o, allowArrayLike) {
  7729. var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
  7730. if (!it) {
  7731. if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike &&
  7732. o && typeof o.length === "number") {
  7733. if (it) o = it;
  7734. var i = 0;
  7735. var F = function F() {};
  7736. return {
  7737. s: F,
  7738. n: function n() {
  7739. if (i >= o.length) return {
  7740. done: true
  7741. };
  7742. return {
  7743. done: false,
  7744. value: o[i++]
  7745. };
  7746. },
  7747. e: function e(_e) {
  7748. throw _e;
  7749. },
  7750. f: F
  7751. };
  7752. }
  7753. throw new TypeError(
  7754. "Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
  7755. );
  7756. }
  7757. var normalCompletion = true,
  7758. didErr = false,
  7759. err;
  7760. return {
  7761. s: function s() {
  7762. it = it.call(o);
  7763. },
  7764. n: function n() {
  7765. var step = it.next();
  7766. normalCompletion = step.done;
  7767. return step;
  7768. },
  7769. e: function e(_e2) {
  7770. didErr = true;
  7771. err = _e2;
  7772. },
  7773. f: function f() {
  7774. try {
  7775. if (!normalCompletion && it["return"] != null) it["return"]();
  7776. } finally {
  7777. if (didErr) throw err;
  7778. }
  7779. }
  7780. };
  7781. }
  7782. function _unsupportedIterableToArray(o, minLen) {
  7783. if (!o) return;
  7784. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  7785. var n = Object.prototype.toString.call(o).slice(8, -1);
  7786. if (n === "Object" && o.constructor) n = o.constructor.name;
  7787. if (n === "Map" || n === "Set") return Array.from(o);
  7788. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
  7789. return _arrayLikeToArray(o, minLen);
  7790. }
  7791. function _arrayLikeToArray(arr, len) {
  7792. if (len == null || len > arr.length) len = arr.length;
  7793. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  7794. arr2[i] = arr[i];
  7795. }
  7796. return arr2;
  7797. }
  7798. function _classCallCheck(instance, Constructor) {
  7799. if (!(instance instanceof Constructor)) {
  7800. throw new TypeError("Cannot call a class as a function");
  7801. }
  7802. }
  7803. function _defineProperties(target, props) {
  7804. for (var i = 0; i < props.length; i++) {
  7805. var descriptor = props[i];
  7806. descriptor.enumerable = descriptor.enumerable || false;
  7807. descriptor.configurable = true;
  7808. if ("value" in descriptor) descriptor.writable = true;
  7809. Object.defineProperty(target, descriptor.key, descriptor);
  7810. }
  7811. }
  7812. function _createClass(Constructor, protoProps, staticProps) {
  7813. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  7814. if (staticProps) _defineProperties(Constructor, staticProps);
  7815. Object.defineProperty(Constructor, "prototype", {
  7816. writable: false
  7817. });
  7818. return Constructor;
  7819. }
  7820. var TREEITEM_OFFSET_TOP = -100;
  7821. var TREEITEM_SELECTED_CLASS = "selected";
  7822. var BaseTreeViewer = /*#__PURE__*/ function() {
  7823. function BaseTreeViewer(options) {
  7824. _classCallCheck(this, BaseTreeViewer);
  7825. if (this.constructor === BaseTreeViewer) {
  7826. throw new Error("Cannot initialize BaseTreeViewer.");
  7827. }
  7828. this.container = options.container;
  7829. this.eventBus = options.eventBus;
  7830. this.reset();
  7831. }
  7832. _createClass(BaseTreeViewer, [{
  7833. key: "reset",
  7834. value: function reset() {
  7835. this._pdfDocument = null;
  7836. this._lastToggleIsShow = true;
  7837. this._currentTreeItem = null;
  7838. this.container.textContent = "";
  7839. this.container.classList.remove("treeWithDeepNesting");
  7840. }
  7841. }, {
  7842. key: "_dispatchEvent",
  7843. value: function _dispatchEvent(count) {
  7844. throw new Error("Not implemented: _dispatchEvent");
  7845. }
  7846. }, {
  7847. key: "_bindLink",
  7848. value: function _bindLink(element, params) {
  7849. throw new Error("Not implemented: _bindLink");
  7850. }
  7851. }, {
  7852. key: "_normalizeTextContent",
  7853. value: function _normalizeTextContent(str) {
  7854. return (0, _ui_utils.removeNullCharacters)(str, true) ||
  7855. "\u2013";
  7856. }
  7857. }, {
  7858. key: "_addToggleButton",
  7859. value: function _addToggleButton(div) {
  7860. var _this = this;
  7861. var hidden = arguments.length > 1 && arguments[1] !==
  7862. undefined ? arguments[1] : false;
  7863. var toggler = document.createElement("div");
  7864. toggler.className = "treeItemToggler";
  7865. if (hidden) {
  7866. toggler.classList.add("treeItemsHidden");
  7867. }
  7868. toggler.onclick = function(evt) {
  7869. evt.stopPropagation();
  7870. toggler.classList.toggle("treeItemsHidden");
  7871. if (evt.shiftKey) {
  7872. var shouldShowAll = !toggler.classList.contains(
  7873. "treeItemsHidden");
  7874. _this._toggleTreeItem(div, shouldShowAll);
  7875. }
  7876. };
  7877. div.insertBefore(toggler, div.firstChild);
  7878. }
  7879. }, {
  7880. key: "_toggleTreeItem",
  7881. value: function _toggleTreeItem(root) {
  7882. var show = arguments.length > 1 && arguments[1] !==
  7883. undefined ? arguments[1] : false;
  7884. this._lastToggleIsShow = show;
  7885. var _iterator = _createForOfIteratorHelper(root
  7886. .querySelectorAll(".treeItemToggler")),
  7887. _step;
  7888. try {
  7889. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  7890. var toggler = _step.value;
  7891. toggler.classList.toggle("treeItemsHidden", !show);
  7892. }
  7893. } catch (err) {
  7894. _iterator.e(err);
  7895. } finally {
  7896. _iterator.f();
  7897. }
  7898. }
  7899. }, {
  7900. key: "_toggleAllTreeItems",
  7901. value: function _toggleAllTreeItems() {
  7902. this._toggleTreeItem(this.container, !this
  7903. ._lastToggleIsShow);
  7904. }
  7905. }, {
  7906. key: "_finishRendering",
  7907. value: function _finishRendering(fragment, count) {
  7908. var hasAnyNesting = arguments.length > 2 && arguments[2] !==
  7909. undefined ? arguments[2] : false;
  7910. if (hasAnyNesting) {
  7911. this.container.classList.add("treeWithDeepNesting");
  7912. this._lastToggleIsShow = !fragment.querySelector(
  7913. ".treeItemsHidden");
  7914. }
  7915. this.container.appendChild(fragment);
  7916. this._dispatchEvent(count);
  7917. }
  7918. }, {
  7919. key: "render",
  7920. value: function render(params) {
  7921. throw new Error("Not implemented: render");
  7922. }
  7923. }, {
  7924. key: "_updateCurrentTreeItem",
  7925. value: function _updateCurrentTreeItem() {
  7926. var treeItem = arguments.length > 0 && arguments[0] !==
  7927. undefined ? arguments[0] : null;
  7928. if (this._currentTreeItem) {
  7929. this._currentTreeItem.classList.remove(
  7930. TREEITEM_SELECTED_CLASS);
  7931. this._currentTreeItem = null;
  7932. }
  7933. if (treeItem) {
  7934. treeItem.classList.add(TREEITEM_SELECTED_CLASS);
  7935. this._currentTreeItem = treeItem;
  7936. }
  7937. }
  7938. }, {
  7939. key: "_scrollToCurrentTreeItem",
  7940. value: function _scrollToCurrentTreeItem(treeItem) {
  7941. if (!treeItem) {
  7942. return;
  7943. }
  7944. var currentNode = treeItem.parentNode;
  7945. while (currentNode && currentNode !== this.container) {
  7946. if (currentNode.classList.contains("treeItem")) {
  7947. var toggler = currentNode.firstElementChild;
  7948. toggler === null || toggler === void 0 ? void 0 :
  7949. toggler.classList.remove("treeItemsHidden");
  7950. }
  7951. currentNode = currentNode.parentNode;
  7952. }
  7953. this._updateCurrentTreeItem(treeItem);
  7954. this.container.scrollTo(treeItem.offsetLeft, treeItem
  7955. .offsetTop + TREEITEM_OFFSET_TOP);
  7956. }
  7957. }]);
  7958. return BaseTreeViewer;
  7959. }();
  7960. exports.BaseTreeViewer = BaseTreeViewer;
  7961. /***/
  7962. }),
  7963. /* 15 */
  7964. /***/
  7965. ((__unused_webpack_module, exports, __webpack_require__) => {
  7966. Object.defineProperty(exports, "__esModule", ({
  7967. value: true
  7968. }));
  7969. exports.PDFDocumentProperties = void 0;
  7970. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  7971. var _pdfjsLib = __webpack_require__(7);
  7972. var _ui_utils = __webpack_require__(5);
  7973. function _interopRequireDefault(obj) {
  7974. return obj && obj.__esModule ? obj : {
  7975. "default": obj
  7976. };
  7977. }
  7978. function _slicedToArray(arr, i) {
  7979. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) ||
  7980. _unsupportedIterableToArray(arr, i) || _nonIterableRest();
  7981. }
  7982. function _nonIterableRest() {
  7983. throw new TypeError(
  7984. "Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
  7985. );
  7986. }
  7987. function _unsupportedIterableToArray(o, minLen) {
  7988. if (!o) return;
  7989. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  7990. var n = Object.prototype.toString.call(o).slice(8, -1);
  7991. if (n === "Object" && o.constructor) n = o.constructor.name;
  7992. if (n === "Map" || n === "Set") return Array.from(o);
  7993. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
  7994. return _arrayLikeToArray(o, minLen);
  7995. }
  7996. function _arrayLikeToArray(arr, len) {
  7997. if (len == null || len > arr.length) len = arr.length;
  7998. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  7999. arr2[i] = arr[i];
  8000. }
  8001. return arr2;
  8002. }
  8003. function _iterableToArrayLimit(arr, i) {
  8004. var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] ||
  8005. arr["@@iterator"];
  8006. if (_i == null) return;
  8007. var _arr = [];
  8008. var _n = true;
  8009. var _d = false;
  8010. var _s, _e;
  8011. try {
  8012. for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
  8013. _arr.push(_s.value);
  8014. if (i && _arr.length === i) break;
  8015. }
  8016. } catch (err) {
  8017. _d = true;
  8018. _e = err;
  8019. } finally {
  8020. try {
  8021. if (!_n && _i["return"] != null) _i["return"]();
  8022. } finally {
  8023. if (_d) throw _e;
  8024. }
  8025. }
  8026. return _arr;
  8027. }
  8028. function _arrayWithHoles(arr) {
  8029. if (Array.isArray(arr)) return arr;
  8030. }
  8031. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  8032. try {
  8033. var info = gen[key](arg);
  8034. var value = info.value;
  8035. } catch (error) {
  8036. reject(error);
  8037. return;
  8038. }
  8039. if (info.done) {
  8040. resolve(value);
  8041. } else {
  8042. Promise.resolve(value).then(_next, _throw);
  8043. }
  8044. }
  8045. function _asyncToGenerator(fn) {
  8046. return function() {
  8047. var self = this,
  8048. args = arguments;
  8049. return new Promise(function(resolve, reject) {
  8050. var gen = fn.apply(self, args);
  8051. function _next(value) {
  8052. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next",
  8053. value);
  8054. }
  8055. function _throw(err) {
  8056. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw",
  8057. err);
  8058. }
  8059. _next(undefined);
  8060. });
  8061. };
  8062. }
  8063. function _classCallCheck(instance, Constructor) {
  8064. if (!(instance instanceof Constructor)) {
  8065. throw new TypeError("Cannot call a class as a function");
  8066. }
  8067. }
  8068. function _defineProperties(target, props) {
  8069. for (var i = 0; i < props.length; i++) {
  8070. var descriptor = props[i];
  8071. descriptor.enumerable = descriptor.enumerable || false;
  8072. descriptor.configurable = true;
  8073. if ("value" in descriptor) descriptor.writable = true;
  8074. Object.defineProperty(target, descriptor.key, descriptor);
  8075. }
  8076. }
  8077. function _createClass(Constructor, protoProps, staticProps) {
  8078. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  8079. if (staticProps) _defineProperties(Constructor, staticProps);
  8080. Object.defineProperty(Constructor, "prototype", {
  8081. writable: false
  8082. });
  8083. return Constructor;
  8084. }
  8085. var DEFAULT_FIELD_CONTENT = "-";
  8086. var NON_METRIC_LOCALES = ["en-us", "en-lr", "my"];
  8087. var US_PAGE_NAMES = {
  8088. "8.5x11": "Letter",
  8089. "8.5x14": "Legal"
  8090. };
  8091. var METRIC_PAGE_NAMES = {
  8092. "297x420": "A3",
  8093. "210x297": "A4"
  8094. };
  8095. function getPageName(size, isPortrait, pageNames) {
  8096. var width = isPortrait ? size.width : size.height;
  8097. var height = isPortrait ? size.height : size.width;
  8098. return pageNames["".concat(width, "x").concat(height)];
  8099. }
  8100. var PDFDocumentProperties = /*#__PURE__*/ function() {
  8101. function PDFDocumentProperties(_ref, overlayManager, eventBus, l10n) {
  8102. var _this = this;
  8103. var overlayName = _ref.overlayName,
  8104. fields = _ref.fields,
  8105. container = _ref.container,
  8106. closeButton = _ref.closeButton;
  8107. _classCallCheck(this, PDFDocumentProperties);
  8108. this.overlayName = overlayName;
  8109. this.fields = fields;
  8110. this.container = container;
  8111. this.overlayManager = overlayManager;
  8112. this.l10n = l10n;
  8113. this._reset();
  8114. closeButton.addEventListener("click", this.close.bind(this));
  8115. this.overlayManager.register(this.overlayName, this.container, this.close.bind(
  8116. this));
  8117. eventBus._on("pagechanging", function(evt) {
  8118. _this._currentPageNumber = evt.pageNumber;
  8119. });
  8120. eventBus._on("rotationchanging", function(evt) {
  8121. _this._pagesRotation = evt.pagesRotation;
  8122. });
  8123. this._isNonMetricLocale = true;
  8124. l10n.getLanguage().then(function(locale) {
  8125. _this._isNonMetricLocale = NON_METRIC_LOCALES.includes(locale);
  8126. });
  8127. }
  8128. _createClass(PDFDocumentProperties, [{
  8129. key: "open",
  8130. value: function() {
  8131. var _open = _asyncToGenerator( /*#__PURE__*/ _regenerator[
  8132. "default"].mark(function _callee() {
  8133. var _this2 = this;
  8134. var freezeFieldData, currentPageNumber,
  8135. pagesRotation, _yield$this$pdfDocume,
  8136. info, contentDispositionFilename,
  8137. contentLength, _yield$Promise$all,
  8138. _yield$Promise$all2, fileName, fileSize,
  8139. creationDate, modificationDate,
  8140. pageSize, isLinearized,
  8141. _yield$this$pdfDocume2, length, data;
  8142. return _regenerator["default"].wrap(
  8143. function _callee$(_context) {
  8144. while (1) {
  8145. switch (_context.prev =
  8146. _context.next) {
  8147. case 0:
  8148. freezeFieldData =
  8149. function freezeFieldData(
  8150. data) {
  8151. Object
  8152. .defineProperty(
  8153. _this2,
  8154. "fieldData", {
  8155. value: Object
  8156. .freeze(
  8157. data
  8158. ),
  8159. writable: false,
  8160. enumerable: true,
  8161. configurable: true
  8162. });
  8163. };
  8164. _context.next = 3;
  8165. return Promise.all([
  8166. this
  8167. .overlayManager
  8168. .open(
  8169. this
  8170. .overlayName
  8171. ),
  8172. this
  8173. ._dataAvailableCapability
  8174. .promise
  8175. ]);
  8176. case 3:
  8177. currentPageNumber =
  8178. this
  8179. ._currentPageNumber;
  8180. pagesRotation = this
  8181. ._pagesRotation;
  8182. if (!(this
  8183. .fieldData &&
  8184. currentPageNumber ===
  8185. this
  8186. .fieldData
  8187. ._currentPageNumber &&
  8188. pagesRotation ===
  8189. this
  8190. .fieldData
  8191. ._pagesRotation
  8192. )) {
  8193. _context.next =
  8194. 8;
  8195. break;
  8196. }
  8197. this._updateUI();
  8198. return _context
  8199. .abrupt(
  8200. "return");
  8201. case 8:
  8202. _context.next = 10;
  8203. return this
  8204. .pdfDocument
  8205. .getMetadata();
  8206. case 10:
  8207. _yield$this$pdfDocume
  8208. = _context.sent;
  8209. info =
  8210. _yield$this$pdfDocume
  8211. .info;
  8212. contentDispositionFilename
  8213. =
  8214. _yield$this$pdfDocume
  8215. .contentDispositionFilename;
  8216. contentLength =
  8217. _yield$this$pdfDocume
  8218. .contentLength;
  8219. _context.next = 16;
  8220. return Promise.all([
  8221. contentDispositionFilename ||
  8222. (0, _pdfjsLib
  8223. .getPdfFilenameFromUrl
  8224. )(
  8225. this
  8226. .url
  8227. ),
  8228. this
  8229. ._parseFileSize(
  8230. contentLength
  8231. ),
  8232. this
  8233. ._parseDate(
  8234. info
  8235. .CreationDate
  8236. ),
  8237. this
  8238. ._parseDate(
  8239. info
  8240. .ModDate
  8241. ),
  8242. this
  8243. .pdfDocument
  8244. .getPage(
  8245. currentPageNumber
  8246. )
  8247. .then(
  8248. function(
  8249. pdfPage
  8250. ) {
  8251. return _this2
  8252. ._parsePageSize(
  8253. (0, _ui_utils
  8254. .getPageSizeInches
  8255. )
  8256. (
  8257. pdfPage),
  8258. pagesRotation
  8259. );
  8260. }),
  8261. this
  8262. ._parseLinearization(
  8263. info
  8264. .IsLinearized
  8265. )
  8266. ]);
  8267. case 16:
  8268. _yield$Promise$all =
  8269. _context.sent;
  8270. _yield$Promise$all2
  8271. =
  8272. _slicedToArray(
  8273. _yield$Promise$all,
  8274. 6);
  8275. fileName =
  8276. _yield$Promise$all2[
  8277. 0];
  8278. fileSize =
  8279. _yield$Promise$all2[
  8280. 1];
  8281. creationDate =
  8282. _yield$Promise$all2[
  8283. 2];
  8284. modificationDate =
  8285. _yield$Promise$all2[
  8286. 3];
  8287. pageSize =
  8288. _yield$Promise$all2[
  8289. 4];
  8290. isLinearized =
  8291. _yield$Promise$all2[
  8292. 5];
  8293. freezeFieldData({
  8294. fileName: fileName,
  8295. fileSize: fileSize,
  8296. title: info
  8297. .Title,
  8298. author: info
  8299. .Author,
  8300. subject: info
  8301. .Subject,
  8302. keywords: info
  8303. .Keywords,
  8304. creationDate: creationDate,
  8305. modificationDate: modificationDate,
  8306. creator: info
  8307. .Creator,
  8308. producer: info
  8309. .Producer,
  8310. version: info
  8311. .PDFFormatVersion,
  8312. pageCount: this
  8313. .pdfDocument
  8314. .numPages,
  8315. pageSize: pageSize,
  8316. linearized: isLinearized,
  8317. _currentPageNumber: currentPageNumber,
  8318. _pagesRotation: pagesRotation
  8319. });
  8320. this._updateUI();
  8321. _context.next = 28;
  8322. return this
  8323. .pdfDocument
  8324. .getDownloadInfo();
  8325. case 28:
  8326. _yield$this$pdfDocume2
  8327. = _context.sent;
  8328. length =
  8329. _yield$this$pdfDocume2
  8330. .length;
  8331. if (!(contentLength ===
  8332. length)) {
  8333. _context.next =
  8334. 32;
  8335. break;
  8336. }
  8337. return _context
  8338. .abrupt(
  8339. "return");
  8340. case 32:
  8341. data = Object
  8342. .assign(Object
  8343. .create(
  8344. null),
  8345. this
  8346. .fieldData);
  8347. _context.next = 35;
  8348. return this
  8349. ._parseFileSize(
  8350. length);
  8351. case 35:
  8352. data.fileSize =
  8353. _context.sent;
  8354. freezeFieldData(
  8355. data);
  8356. this._updateUI();
  8357. case 38:
  8358. case "end":
  8359. return _context
  8360. .stop();
  8361. }
  8362. }
  8363. }, _callee, this);
  8364. }));
  8365. function open() {
  8366. return _open.apply(this, arguments);
  8367. }
  8368. return open;
  8369. }()
  8370. }, {
  8371. key: "close",
  8372. value: function close() {
  8373. this.overlayManager.close(this.overlayName);
  8374. }
  8375. }, {
  8376. key: "setDocument",
  8377. value: function setDocument(pdfDocument) {
  8378. var url = arguments.length > 1 && arguments[1] !==
  8379. undefined ? arguments[1] : null;
  8380. if (this.pdfDocument) {
  8381. this._reset();
  8382. this._updateUI(true);
  8383. }
  8384. if (!pdfDocument) {
  8385. return;
  8386. }
  8387. this.pdfDocument = pdfDocument;
  8388. this.url = url;
  8389. this._dataAvailableCapability.resolve();
  8390. }
  8391. }, {
  8392. key: "_reset",
  8393. value: function _reset() {
  8394. this.pdfDocument = null;
  8395. this.url = null;
  8396. delete this.fieldData;
  8397. this._dataAvailableCapability = (0, _pdfjsLib
  8398. .createPromiseCapability)();
  8399. this._currentPageNumber = 1;
  8400. this._pagesRotation = 0;
  8401. }
  8402. }, {
  8403. key: "_updateUI",
  8404. value: function _updateUI() {
  8405. var reset = arguments.length > 0 && arguments[0] !==
  8406. undefined ? arguments[0] : false;
  8407. if (reset || !this.fieldData) {
  8408. for (var id in this.fields) {
  8409. this.fields[id].textContent = DEFAULT_FIELD_CONTENT;
  8410. }
  8411. return;
  8412. }
  8413. if (this.overlayManager.active !== this.overlayName) {
  8414. return;
  8415. }
  8416. for (var _id in this.fields) {
  8417. var content = this.fieldData[_id];
  8418. this.fields[_id].textContent = content || content ===
  8419. 0 ? content : DEFAULT_FIELD_CONTENT;
  8420. }
  8421. }
  8422. }, {
  8423. key: "_parseFileSize",
  8424. value: function() {
  8425. var _parseFileSize2 = _asyncToGenerator( /*#__PURE__*/
  8426. _regenerator["default"].mark(function _callee2() {
  8427. var fileSize,
  8428. kb,
  8429. mb,
  8430. _args2 = arguments;
  8431. return _regenerator["default"].wrap(
  8432. function _callee2$(_context2) {
  8433. while (1) {
  8434. switch (_context2.prev =
  8435. _context2.next) {
  8436. case 0:
  8437. fileSize = _args2
  8438. .length > 0 &&
  8439. _args2[0] !==
  8440. undefined ?
  8441. _args2[0] : 0;
  8442. kb = fileSize /
  8443. 1024, mb = kb /
  8444. 1024;
  8445. if (kb) {
  8446. _context2.next =
  8447. 4;
  8448. break;
  8449. }
  8450. return _context2
  8451. .abrupt(
  8452. "return",
  8453. undefined);
  8454. case 4:
  8455. return _context2
  8456. .abrupt(
  8457. "return",
  8458. this.l10n
  8459. .get(
  8460. "document_properties_"
  8461. .concat(
  8462. mb >=
  8463. 1 ?
  8464. "mb" :
  8465. "kb"
  8466. ), {
  8467. size_mb: mb >=
  8468. 1 &&
  8469. (+mb.toPrecision(
  8470. 3
  8471. ))
  8472. .toLocaleString(),
  8473. size_kb: mb <
  8474. 1 &&
  8475. (+kb.toPrecision(
  8476. 3
  8477. ))
  8478. .toLocaleString(),
  8479. size_b: fileSize
  8480. .toLocaleString()
  8481. }));
  8482. case 5:
  8483. case "end":
  8484. return _context2
  8485. .stop();
  8486. }
  8487. }
  8488. }, _callee2, this);
  8489. }));
  8490. function _parseFileSize() {
  8491. return _parseFileSize2.apply(this, arguments);
  8492. }
  8493. return _parseFileSize;
  8494. }()
  8495. }, {
  8496. key: "_parsePageSize",
  8497. value: function() {
  8498. var _parsePageSize2 = _asyncToGenerator( /*#__PURE__*/
  8499. _regenerator["default"].mark(function _callee3(
  8500. pageSizeInches, pagesRotation) {
  8501. var isPortrait, sizeInches, sizeMillimeters,
  8502. rawName, exactMillimeters,
  8503. intMillimeters, _yield$Promise$all3,
  8504. _yield$Promise$all4,
  8505. _yield$Promise$all4$, width, height,
  8506. unit, name, orientation;
  8507. return _regenerator["default"].wrap(
  8508. function _callee3$(_context3) {
  8509. while (1) {
  8510. switch (_context3.prev =
  8511. _context3.next) {
  8512. case 0:
  8513. if (
  8514. pageSizeInches) {
  8515. _context3.next =
  8516. 2;
  8517. break;
  8518. }
  8519. return _context3
  8520. .abrupt(
  8521. "return",
  8522. undefined);
  8523. case 2:
  8524. if (pagesRotation %
  8525. 180 !== 0) {
  8526. pageSizeInches
  8527. = {
  8528. width: pageSizeInches
  8529. .height,
  8530. height: pageSizeInches
  8531. .width
  8532. };
  8533. }
  8534. isPortrait = (0,
  8535. _ui_utils
  8536. .isPortraitOrientation
  8537. )(
  8538. pageSizeInches
  8539. );
  8540. sizeInches = {
  8541. width: Math
  8542. .round(
  8543. pageSizeInches
  8544. .width *
  8545. 100
  8546. ) /
  8547. 100,
  8548. height: Math
  8549. .round(
  8550. pageSizeInches
  8551. .height *
  8552. 100
  8553. ) /
  8554. 100
  8555. };
  8556. sizeMillimeters = {
  8557. width: Math
  8558. .round(
  8559. pageSizeInches
  8560. .width *
  8561. 25.4 *
  8562. 10
  8563. ) /
  8564. 10,
  8565. height: Math
  8566. .round(
  8567. pageSizeInches
  8568. .height *
  8569. 25.4 *
  8570. 10
  8571. ) /
  8572. 10
  8573. };
  8574. rawName =
  8575. getPageName(
  8576. sizeInches,
  8577. isPortrait,
  8578. US_PAGE_NAMES
  8579. ) ||
  8580. getPageName(
  8581. sizeMillimeters,
  8582. isPortrait,
  8583. METRIC_PAGE_NAMES
  8584. );
  8585. if (!rawName && !(
  8586. Number
  8587. .isInteger(
  8588. sizeMillimeters
  8589. .width
  8590. ) &&
  8591. Number
  8592. .isInteger(
  8593. sizeMillimeters
  8594. .height)
  8595. )) {
  8596. exactMillimeters
  8597. = {
  8598. width: pageSizeInches
  8599. .width *
  8600. 25.4,
  8601. height: pageSizeInches
  8602. .height *
  8603. 25.4
  8604. };
  8605. intMillimeters
  8606. = {
  8607. width: Math
  8608. .round(
  8609. sizeMillimeters
  8610. .width
  8611. ),
  8612. height: Math
  8613. .round(
  8614. sizeMillimeters
  8615. .height
  8616. )
  8617. };
  8618. if (Math.abs(
  8619. exactMillimeters
  8620. .width -
  8621. intMillimeters
  8622. .width
  8623. ) <
  8624. 0.1 && Math
  8625. .abs(
  8626. exactMillimeters
  8627. .height -
  8628. intMillimeters
  8629. .height
  8630. ) < 0.1
  8631. ) {
  8632. rawName =
  8633. getPageName(
  8634. intMillimeters,
  8635. isPortrait,
  8636. METRIC_PAGE_NAMES
  8637. );
  8638. if (
  8639. rawName) {
  8640. sizeInches
  8641. = {
  8642. width: Math
  8643. .round(
  8644. intMillimeters
  8645. .width /
  8646. 25.4 *
  8647. 100
  8648. ) /
  8649. 100,
  8650. height: Math
  8651. .round(
  8652. intMillimeters
  8653. .height /
  8654. 25.4 *
  8655. 100
  8656. ) /
  8657. 100
  8658. };
  8659. sizeMillimeters
  8660. =
  8661. intMillimeters;
  8662. }
  8663. }
  8664. }
  8665. _context3.next = 10;
  8666. return Promise.all([
  8667. this
  8668. ._isNonMetricLocale ?
  8669. sizeInches :
  8670. sizeMillimeters,
  8671. this
  8672. .l10n
  8673. .get(
  8674. "document_properties_page_size_unit_"
  8675. .concat(
  8676. this
  8677. ._isNonMetricLocale ?
  8678. "inches" :
  8679. "millimeters"
  8680. )
  8681. ),
  8682. rawName &&
  8683. this
  8684. .l10n
  8685. .get(
  8686. "document_properties_page_size_name_"
  8687. .concat(
  8688. rawName
  8689. .toLowerCase()
  8690. )
  8691. ),
  8692. this
  8693. .l10n
  8694. .get(
  8695. "document_properties_page_size_orientation_"
  8696. .concat(
  8697. isPortrait ?
  8698. "portrait" :
  8699. "landscape"
  8700. )
  8701. )
  8702. ]);
  8703. case 10:
  8704. _yield$Promise$all3
  8705. = _context3
  8706. .sent;
  8707. _yield$Promise$all4
  8708. =
  8709. _slicedToArray(
  8710. _yield$Promise$all3,
  8711. 4);
  8712. _yield$Promise$all4$
  8713. =
  8714. _yield$Promise$all4[
  8715. 0];
  8716. width =
  8717. _yield$Promise$all4$
  8718. .width;
  8719. height =
  8720. _yield$Promise$all4$
  8721. .height;
  8722. unit =
  8723. _yield$Promise$all4[
  8724. 1];
  8725. name =
  8726. _yield$Promise$all4[
  8727. 2];
  8728. orientation =
  8729. _yield$Promise$all4[
  8730. 3];
  8731. return _context3
  8732. .abrupt(
  8733. "return",
  8734. this.l10n
  8735. .get(
  8736. "document_properties_page_size_dimension_"
  8737. .concat(
  8738. name ?
  8739. "name_" :
  8740. "",
  8741. "string"
  8742. ), {
  8743. width: width
  8744. .toLocaleString(),
  8745. height: height
  8746. .toLocaleString(),
  8747. unit: unit,
  8748. name: name,
  8749. orientation: orientation
  8750. }));
  8751. case 19:
  8752. case "end":
  8753. return _context3
  8754. .stop();
  8755. }
  8756. }
  8757. }, _callee3, this);
  8758. }));
  8759. function _parsePageSize(_x, _x2) {
  8760. return _parsePageSize2.apply(this, arguments);
  8761. }
  8762. return _parsePageSize;
  8763. }()
  8764. }, {
  8765. key: "_parseDate",
  8766. value: function() {
  8767. var _parseDate2 = _asyncToGenerator( /*#__PURE__*/
  8768. _regenerator["default"].mark(function _callee4(
  8769. inputDate) {
  8770. var dateObject;
  8771. return _regenerator["default"].wrap(
  8772. function _callee4$(_context4) {
  8773. while (1) {
  8774. switch (_context4.prev =
  8775. _context4.next) {
  8776. case 0:
  8777. dateObject =
  8778. _pdfjsLib
  8779. .PDFDateString
  8780. .toDateObject(
  8781. inputDate);
  8782. if (dateObject) {
  8783. _context4.next =
  8784. 3;
  8785. break;
  8786. }
  8787. return _context4
  8788. .abrupt(
  8789. "return",
  8790. undefined);
  8791. case 3:
  8792. return _context4
  8793. .abrupt(
  8794. "return",
  8795. this.l10n
  8796. .get(
  8797. "document_properties_date_string", {
  8798. date: dateObject
  8799. .toLocaleDateString(),
  8800. time: dateObject
  8801. .toLocaleTimeString()
  8802. }));
  8803. case 4:
  8804. case "end":
  8805. return _context4
  8806. .stop();
  8807. }
  8808. }
  8809. }, _callee4, this);
  8810. }));
  8811. function _parseDate(_x3) {
  8812. return _parseDate2.apply(this, arguments);
  8813. }
  8814. return _parseDate;
  8815. }()
  8816. }, {
  8817. key: "_parseLinearization",
  8818. value: function _parseLinearization(isLinearized) {
  8819. return this.l10n.get("document_properties_linearized_"
  8820. .concat(isLinearized ? "yes" : "no"));
  8821. }
  8822. }]);
  8823. return PDFDocumentProperties;
  8824. }();
  8825. exports.PDFDocumentProperties = PDFDocumentProperties;
  8826. /***/
  8827. }),
  8828. /* 16 */
  8829. /***/
  8830. ((__unused_webpack_module, exports, __webpack_require__) => {
  8831. Object.defineProperty(exports, "__esModule", ({
  8832. value: true
  8833. }));
  8834. exports.PDFFindBar = void 0;
  8835. var _pdf_find_controller = __webpack_require__(17);
  8836. function _classCallCheck(instance, Constructor) {
  8837. if (!(instance instanceof Constructor)) {
  8838. throw new TypeError("Cannot call a class as a function");
  8839. }
  8840. }
  8841. function _defineProperties(target, props) {
  8842. for (var i = 0; i < props.length; i++) {
  8843. var descriptor = props[i];
  8844. descriptor.enumerable = descriptor.enumerable || false;
  8845. descriptor.configurable = true;
  8846. if ("value" in descriptor) descriptor.writable = true;
  8847. Object.defineProperty(target, descriptor.key, descriptor);
  8848. }
  8849. }
  8850. function _createClass(Constructor, protoProps, staticProps) {
  8851. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  8852. if (staticProps) _defineProperties(Constructor, staticProps);
  8853. Object.defineProperty(Constructor, "prototype", {
  8854. writable: false
  8855. });
  8856. return Constructor;
  8857. }
  8858. var MATCHES_COUNT_LIMIT = 1000;
  8859. var PDFFindBar = /*#__PURE__*/ function() {
  8860. function PDFFindBar(options, eventBus, l10n) {
  8861. var _this = this;
  8862. _classCallCheck(this, PDFFindBar);
  8863. this.opened = false;
  8864. this.bar = options.bar;
  8865. this.toggleButton = options.toggleButton;
  8866. this.findField = options.findField;
  8867. this.highlightAll = options.highlightAllCheckbox;
  8868. this.caseSensitive = options.caseSensitiveCheckbox;
  8869. this.matchDiacritics = options.matchDiacriticsCheckbox;
  8870. this.entireWord = options.entireWordCheckbox;
  8871. this.findMsg = options.findMsg;
  8872. this.findResultsCount = options.findResultsCount;
  8873. this.findPreviousButton = options.findPreviousButton;
  8874. this.findNextButton = options.findNextButton;
  8875. this.eventBus = eventBus;
  8876. this.l10n = l10n;
  8877. this.toggleButton.addEventListener("click", function() {
  8878. _this.toggle();
  8879. });
  8880. this.findField.addEventListener("input", function() {
  8881. _this.dispatchEvent("");
  8882. });
  8883. this.bar.addEventListener("keydown", function(e) {
  8884. switch (e.keyCode) {
  8885. case 13:
  8886. if (e.target === _this.findField) {
  8887. _this.dispatchEvent("again", e.shiftKey);
  8888. }
  8889. break;
  8890. case 27:
  8891. _this.close();
  8892. break;
  8893. }
  8894. });
  8895. this.findPreviousButton.addEventListener("click", function() {
  8896. _this.dispatchEvent("again", true);
  8897. });
  8898. this.findNextButton.addEventListener("click", function() {
  8899. _this.dispatchEvent("again", false);
  8900. });
  8901. this.highlightAll.addEventListener("click", function() {
  8902. _this.dispatchEvent("highlightallchange");
  8903. });
  8904. this.caseSensitive.addEventListener("click", function() {
  8905. _this.dispatchEvent("casesensitivitychange");
  8906. });
  8907. this.entireWord.addEventListener("click", function() {
  8908. _this.dispatchEvent("entirewordchange");
  8909. });
  8910. this.matchDiacritics.addEventListener("click", function() {
  8911. _this.dispatchEvent("diacriticmatchingchange");
  8912. });
  8913. this.eventBus._on("resize", this._adjustWidth.bind(this));
  8914. }
  8915. _createClass(PDFFindBar, [{
  8916. key: "reset",
  8917. value: function reset() {
  8918. this.updateUIState();
  8919. }
  8920. }, {
  8921. key: "dispatchEvent",
  8922. value: function dispatchEvent(type) {
  8923. var findPrev = arguments.length > 1 && arguments[1] !==
  8924. undefined ? arguments[1] : false;
  8925. this.eventBus.dispatch("find", {
  8926. source: this,
  8927. type: type,
  8928. query: this.findField.value,
  8929. phraseSearch: true,
  8930. caseSensitive: this.caseSensitive.checked,
  8931. entireWord: this.entireWord.checked,
  8932. highlightAll: this.highlightAll.checked,
  8933. findPrevious: findPrev,
  8934. matchDiacritics: this.matchDiacritics.checked
  8935. });
  8936. }
  8937. }, {
  8938. key: "updateUIState",
  8939. value: function updateUIState(state, previous, matchesCount) {
  8940. var _this2 = this;
  8941. var findMsg = Promise.resolve("");
  8942. var status = "";
  8943. switch (state) {
  8944. case _pdf_find_controller.FindState.FOUND:
  8945. break;
  8946. case _pdf_find_controller.FindState.PENDING:
  8947. status = "pending";
  8948. break;
  8949. case _pdf_find_controller.FindState.NOT_FOUND:
  8950. findMsg = this.l10n.get("find_not_found");
  8951. status = "notFound";
  8952. break;
  8953. case _pdf_find_controller.FindState.WRAPPED:
  8954. findMsg = this.l10n.get("find_reached_".concat(
  8955. previous ? "top" : "bottom"));
  8956. break;
  8957. }
  8958. this.findField.setAttribute("data-status", status);
  8959. findMsg.then(function(msg) {
  8960. _this2.findMsg.textContent = msg;
  8961. _this2._adjustWidth();
  8962. });
  8963. this.updateResultsCount(matchesCount);
  8964. }
  8965. }, {
  8966. key: "updateResultsCount",
  8967. value: function updateResultsCount() {
  8968. var _this3 = this;
  8969. var _ref = arguments.length > 0 && arguments[0] !==
  8970. undefined ? arguments[0] : {},
  8971. _ref$current = _ref.current,
  8972. current = _ref$current === void 0 ? 0 : _ref$current,
  8973. _ref$total = _ref.total,
  8974. total = _ref$total === void 0 ? 0 : _ref$total;
  8975. var limit = MATCHES_COUNT_LIMIT;
  8976. var matchCountMsg = Promise.resolve("");
  8977. if (total > 0) {
  8978. if (total > limit) {
  8979. var key = "find_match_count_limit";
  8980. matchCountMsg = this.l10n.get(key, {
  8981. limit: limit
  8982. });
  8983. } else {
  8984. var _key = "find_match_count";
  8985. matchCountMsg = this.l10n.get(_key, {
  8986. current: current,
  8987. total: total
  8988. });
  8989. }
  8990. }
  8991. matchCountMsg.then(function(msg) {
  8992. _this3.findResultsCount.textContent = msg;
  8993. _this3._adjustWidth();
  8994. });
  8995. }
  8996. }, {
  8997. key: "open",
  8998. value: function open() {
  8999. if (!this.opened) {
  9000. this.opened = true;
  9001. this.toggleButton.classList.add("toggled");
  9002. this.toggleButton.setAttribute("aria-expanded", "true");
  9003. this.bar.classList.remove("hidden");
  9004. }
  9005. this.findField.select();
  9006. this.findField.focus();
  9007. this._adjustWidth();
  9008. }
  9009. }, {
  9010. key: "close",
  9011. value: function close() {
  9012. if (!this.opened) {
  9013. return;
  9014. }
  9015. this.opened = false;
  9016. this.toggleButton.classList.remove("toggled");
  9017. this.toggleButton.setAttribute("aria-expanded", "false");
  9018. this.bar.classList.add("hidden");
  9019. this.eventBus.dispatch("findbarclose", {
  9020. source: this
  9021. });
  9022. }
  9023. }, {
  9024. key: "toggle",
  9025. value: function toggle() {
  9026. if (this.opened) {
  9027. this.close();
  9028. } else {
  9029. this.open();
  9030. }
  9031. }
  9032. }, {
  9033. key: "_adjustWidth",
  9034. value: function _adjustWidth() {
  9035. if (!this.opened) {
  9036. return;
  9037. }
  9038. this.bar.classList.remove("wrapContainers");
  9039. var findbarHeight = this.bar.clientHeight;
  9040. var inputContainerHeight = this.bar.firstElementChild
  9041. .clientHeight;
  9042. if (findbarHeight > inputContainerHeight) {
  9043. this.bar.classList.add("wrapContainers");
  9044. }
  9045. }
  9046. }]);
  9047. return PDFFindBar;
  9048. }();
  9049. exports.PDFFindBar = PDFFindBar;
  9050. /***/
  9051. }),
  9052. /* 17 */
  9053. /***/
  9054. ((__unused_webpack_module, exports, __webpack_require__) => {
  9055. Object.defineProperty(exports, "__esModule", ({
  9056. value: true
  9057. }));
  9058. exports.PDFFindController = exports.FindState = void 0;
  9059. var _ui_utils = __webpack_require__(5);
  9060. var _pdfjsLib = __webpack_require__(7);
  9061. var _pdf_find_utils = __webpack_require__(18);
  9062. function _slicedToArray(arr, i) {
  9063. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) ||
  9064. _unsupportedIterableToArray(arr, i) || _nonIterableRest();
  9065. }
  9066. function _nonIterableRest() {
  9067. throw new TypeError(
  9068. "Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
  9069. );
  9070. }
  9071. function _iterableToArrayLimit(arr, i) {
  9072. var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] ||
  9073. arr["@@iterator"];
  9074. if (_i == null) return;
  9075. var _arr = [];
  9076. var _n = true;
  9077. var _d = false;
  9078. var _s, _e;
  9079. try {
  9080. for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
  9081. _arr.push(_s.value);
  9082. if (i && _arr.length === i) break;
  9083. }
  9084. } catch (err) {
  9085. _d = true;
  9086. _e = err;
  9087. } finally {
  9088. try {
  9089. if (!_n && _i["return"] != null) _i["return"]();
  9090. } finally {
  9091. if (_d) throw _e;
  9092. }
  9093. }
  9094. return _arr;
  9095. }
  9096. function _arrayWithHoles(arr) {
  9097. if (Array.isArray(arr)) return arr;
  9098. }
  9099. function _classCallCheck(instance, Constructor) {
  9100. if (!(instance instanceof Constructor)) {
  9101. throw new TypeError("Cannot call a class as a function");
  9102. }
  9103. }
  9104. function _defineProperties(target, props) {
  9105. for (var i = 0; i < props.length; i++) {
  9106. var descriptor = props[i];
  9107. descriptor.enumerable = descriptor.enumerable || false;
  9108. descriptor.configurable = true;
  9109. if ("value" in descriptor) descriptor.writable = true;
  9110. Object.defineProperty(target, descriptor.key, descriptor);
  9111. }
  9112. }
  9113. function _createClass(Constructor, protoProps, staticProps) {
  9114. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  9115. if (staticProps) _defineProperties(Constructor, staticProps);
  9116. Object.defineProperty(Constructor, "prototype", {
  9117. writable: false
  9118. });
  9119. return Constructor;
  9120. }
  9121. function _toConsumableArray(arr) {
  9122. return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(
  9123. arr) || _nonIterableSpread();
  9124. }
  9125. function _nonIterableSpread() {
  9126. throw new TypeError(
  9127. "Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
  9128. );
  9129. }
  9130. function _unsupportedIterableToArray(o, minLen) {
  9131. if (!o) return;
  9132. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  9133. var n = Object.prototype.toString.call(o).slice(8, -1);
  9134. if (n === "Object" && o.constructor) n = o.constructor.name;
  9135. if (n === "Map" || n === "Set") return Array.from(o);
  9136. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
  9137. return _arrayLikeToArray(o, minLen);
  9138. }
  9139. function _iterableToArray(iter) {
  9140. if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter[
  9141. "@@iterator"] != null) return Array.from(iter);
  9142. }
  9143. function _arrayWithoutHoles(arr) {
  9144. if (Array.isArray(arr)) return _arrayLikeToArray(arr);
  9145. }
  9146. function _arrayLikeToArray(arr, len) {
  9147. if (len == null || len > arr.length) len = arr.length;
  9148. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  9149. arr2[i] = arr[i];
  9150. }
  9151. return arr2;
  9152. }
  9153. var FindState = {
  9154. FOUND: 0,
  9155. NOT_FOUND: 1,
  9156. WRAPPED: 2,
  9157. PENDING: 3
  9158. };
  9159. exports.FindState = FindState;
  9160. var FIND_TIMEOUT = 250;
  9161. var MATCH_SCROLL_OFFSET_TOP = -50;
  9162. var MATCH_SCROLL_OFFSET_LEFT = -400;
  9163. var CHARACTERS_TO_NORMALIZE = {
  9164. "\u2010": "-",
  9165. "\u2018": "'",
  9166. "\u2019": "'",
  9167. "\u201A": "'",
  9168. "\u201B": "'",
  9169. "\u201C": '"',
  9170. "\u201D": '"',
  9171. "\u201E": '"',
  9172. "\u201F": '"',
  9173. "\xBC": "1/4",
  9174. "\xBD": "1/2",
  9175. "\xBE": "3/4"
  9176. };
  9177. var DIACRITICS_EXCEPTION = new Set([0x3099, 0x309a, 0x094d, 0x09cd, 0x0a4d, 0x0acd, 0x0b4d,
  9178. 0x0bcd, 0x0c4d, 0x0ccd, 0x0d3b, 0x0d3c, 0x0d4d, 0x0dca, 0x0e3a, 0x0eba, 0x0f84,
  9179. 0x1039, 0x103a, 0x1714, 0x1734, 0x17d2, 0x1a60, 0x1b44, 0x1baa, 0x1bab, 0x1bf2,
  9180. 0x1bf3, 0x2d7f, 0xa806, 0xa82c, 0xa8c4, 0xa953, 0xa9c0, 0xaaf6, 0xabed, 0x0c56,
  9181. 0x0f71, 0x0f72, 0x0f7a, 0x0f7b, 0x0f7c, 0x0f7d, 0x0f80, 0x0f74
  9182. ]);
  9183. var DIACRITICS_EXCEPTION_STR = _toConsumableArray(DIACRITICS_EXCEPTION.values()).map(
  9184. function(x) {
  9185. return String.fromCharCode(x);
  9186. }).join("");
  9187. var DIACRITICS_REG_EXP =
  9188. /(?:[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0898-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ACE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD803[\uDD24-\uDD27\uDEAB\uDEAC\uDF46-\uDF50\uDF82-\uDF85]|\uD804[\uDC00-\uDC02\uDC38-\uDC46\uDC70\uDC73\uDC74\uDC7F-\uDC82\uDCB0-\uDCBA\uDCC2\uDD00-\uDD02\uDD27-\uDD34\uDD45\uDD46\uDD73\uDD80-\uDD82\uDDB3-\uDDC0\uDDC9-\uDDCC\uDDCE\uDDCF\uDE2C-\uDE37\uDE3E\uDEDF-\uDEEA\uDF00-\uDF03\uDF3B\uDF3C\uDF3E-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF62\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC35-\uDC46\uDC5E\uDCB0-\uDCC3\uDDAF-\uDDB5\uDDB8-\uDDC0\uDDDC\uDDDD\uDE30-\uDE40\uDEAB-\uDEB7\uDF1D-\uDF2B]|\uD806[\uDC2C-\uDC3A\uDD30-\uDD35\uDD37\uDD38\uDD3B-\uDD3E\uDD40\uDD42\uDD43\uDDD1-\uDDD7\uDDDA-\uDDE0\uDDE4\uDE01-\uDE0A\uDE33-\uDE39\uDE3B-\uDE3E\uDE47\uDE51-\uDE5B\uDE8A-\uDE99]|\uD807[\uDC2F-\uDC36\uDC38-\uDC3F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD31-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD45\uDD47\uDD8A-\uDD8E\uDD90\uDD91\uDD93-\uDD97\uDEF3-\uDEF6]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF4F\uDF51-\uDF87\uDF8F-\uDF92\uDFE4\uDFF0\uDFF1]|\uD82F[\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDD30-\uDD36\uDEAE\uDEEC-\uDEEF]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD4A]|\uDB40[\uDD00-\uDDEF])+/g;
  9189. var SPECIAL_CHARS_REG_EXP =
  9190. /([\$\(-\+\.\?\[-\^\{-\}])|((?:[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDEAD\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]))|([\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+)|((?:[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0898-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ACE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD803[\uDD24-\uDD27\uDEAB\uDEAC\uDF46-\uDF50\uDF82-\uDF85]|\uD804[\uDC00-\uDC02\uDC38-\uDC46\uDC70\uDC73\uDC74\uDC7F-\uDC82\uDCB0-\uDCBA\uDCC2\uDD00-\uDD02\uDD27-\uDD34\uDD45\uDD46\uDD73\uDD80-\uDD82\uDDB3-\uDDC0\uDDC9-\uDDCC\uDDCE\uDDCF\uDE2C-\uDE37\uDE3E\uDEDF-\uDEEA\uDF00-\uDF03\uDF3B\uDF3C\uDF3E-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF62\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC35-\uDC46\uDC5E\uDCB0-\uDCC3\uDDAF-\uDDB5\uDDB8-\uDDC0\uDDDC\uDDDD\uDE30-\uDE40\uDEAB-\uDEB7\uDF1D-\uDF2B]|\uD806[\uDC2C-\uDC3A\uDD30-\uDD35\uDD37\uDD38\uDD3B-\uDD3E\uDD40\uDD42\uDD43\uDDD1-\uDDD7\uDDDA-\uDDE0\uDDE4\uDE01-\uDE0A\uDE33-\uDE39\uDE3B-\uDE3E\uDE47\uDE51-\uDE5B\uDE8A-\uDE99]|\uD807[\uDC2F-\uDC36\uDC38-\uDC3F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD31-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD45\uDD47\uDD8A-\uDD8E\uDD90\uDD91\uDD93-\uDD97\uDEF3-\uDEF6]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF4F\uDF51-\uDF87\uDF8F-\uDF92\uDFE4\uDFF0\uDFF1]|\uD82F[\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDD30-\uDD36\uDEAE\uDEEC-\uDEEF]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD4A]|\uDB40[\uDD00-\uDDEF]))|((?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF38\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A]))/g;
  9191. var NOT_DIACRITIC_FROM_END_REG_EXP =
  9192. /((?:(?![\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0898-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ACE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD803[\uDD24-\uDD27\uDEAB\uDEAC\uDF46-\uDF50\uDF82-\uDF85]|\uD804[\uDC00-\uDC02\uDC38-\uDC46\uDC70\uDC73\uDC74\uDC7F-\uDC82\uDCB0-\uDCBA\uDCC2\uDD00-\uDD02\uDD27-\uDD34\uDD45\uDD46\uDD73\uDD80-\uDD82\uDDB3-\uDDC0\uDDC9-\uDDCC\uDDCE\uDDCF\uDE2C-\uDE37\uDE3E\uDEDF-\uDEEA\uDF00-\uDF03\uDF3B\uDF3C\uDF3E-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF62\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC35-\uDC46\uDC5E\uDCB0-\uDCC3\uDDAF-\uDDB5\uDDB8-\uDDC0\uDDDC\uDDDD\uDE30-\uDE40\uDEAB-\uDEB7\uDF1D-\uDF2B]|\uD806[\uDC2C-\uDC3A\uDD30-\uDD35\uDD37\uDD38\uDD3B-\uDD3E\uDD40\uDD42\uDD43\uDDD1-\uDDD7\uDDDA-\uDDE0\uDDE4\uDE01-\uDE0A\uDE33-\uDE39\uDE3B-\uDE3E\uDE47\uDE51-\uDE5B\uDE8A-\uDE99]|\uD807[\uDC2F-\uDC36\uDC38-\uDC3F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD31-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD45\uDD47\uDD8A-\uDD8E\uDD90\uDD91\uDD93-\uDD97\uDEF3-\uDEF6]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF4F\uDF51-\uDF87\uDF8F-\uDF92\uDFE4\uDFF0\uDFF1]|\uD82F[\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDD30-\uDD36\uDEAE\uDEEC-\uDEEF]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD4A]|\uDB40[\uDD00-\uDDEF])[\s\S]))(?:[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0898-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ACE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD803[\uDD24-\uDD27\uDEAB\uDEAC\uDF46-\uDF50\uDF82-\uDF85]|\uD804[\uDC00-\uDC02\uDC38-\uDC46\uDC70\uDC73\uDC74\uDC7F-\uDC82\uDCB0-\uDCBA\uDCC2\uDD00-\uDD02\uDD27-\uDD34\uDD45\uDD46\uDD73\uDD80-\uDD82\uDDB3-\uDDC0\uDDC9-\uDDCC\uDDCE\uDDCF\uDE2C-\uDE37\uDE3E\uDEDF-\uDEEA\uDF00-\uDF03\uDF3B\uDF3C\uDF3E-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF62\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC35-\uDC46\uDC5E\uDCB0-\uDCC3\uDDAF-\uDDB5\uDDB8-\uDDC0\uDDDC\uDDDD\uDE30-\uDE40\uDEAB-\uDEB7\uDF1D-\uDF2B]|\uD806[\uDC2C-\uDC3A\uDD30-\uDD35\uDD37\uDD38\uDD3B-\uDD3E\uDD40\uDD42\uDD43\uDDD1-\uDDD7\uDDDA-\uDDE0\uDDE4\uDE01-\uDE0A\uDE33-\uDE39\uDE3B-\uDE3E\uDE47\uDE51-\uDE5B\uDE8A-\uDE99]|\uD807[\uDC2F-\uDC36\uDC38-\uDC3F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD31-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD45\uDD47\uDD8A-\uDD8E\uDD90\uDD91\uDD93-\uDD97\uDEF3-\uDEF6]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF4F\uDF51-\uDF87\uDF8F-\uDF92\uDFE4\uDFF0\uDFF1]|\uD82F[\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDD30-\uDD36\uDEAE\uDEEC-\uDEEF]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD4A]|\uDB40[\uDD00-\uDDEF])*$/;
  9193. var NOT_DIACRITIC_FROM_START_REG_EXP =
  9194. /^(?:[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0898-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ACE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD803[\uDD24-\uDD27\uDEAB\uDEAC\uDF46-\uDF50\uDF82-\uDF85]|\uD804[\uDC00-\uDC02\uDC38-\uDC46\uDC70\uDC73\uDC74\uDC7F-\uDC82\uDCB0-\uDCBA\uDCC2\uDD00-\uDD02\uDD27-\uDD34\uDD45\uDD46\uDD73\uDD80-\uDD82\uDDB3-\uDDC0\uDDC9-\uDDCC\uDDCE\uDDCF\uDE2C-\uDE37\uDE3E\uDEDF-\uDEEA\uDF00-\uDF03\uDF3B\uDF3C\uDF3E-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF62\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC35-\uDC46\uDC5E\uDCB0-\uDCC3\uDDAF-\uDDB5\uDDB8-\uDDC0\uDDDC\uDDDD\uDE30-\uDE40\uDEAB-\uDEB7\uDF1D-\uDF2B]|\uD806[\uDC2C-\uDC3A\uDD30-\uDD35\uDD37\uDD38\uDD3B-\uDD3E\uDD40\uDD42\uDD43\uDDD1-\uDDD7\uDDDA-\uDDE0\uDDE4\uDE01-\uDE0A\uDE33-\uDE39\uDE3B-\uDE3E\uDE47\uDE51-\uDE5B\uDE8A-\uDE99]|\uD807[\uDC2F-\uDC36\uDC38-\uDC3F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD31-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD45\uDD47\uDD8A-\uDD8E\uDD90\uDD91\uDD93-\uDD97\uDEF3-\uDEF6]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF4F\uDF51-\uDF87\uDF8F-\uDF92\uDFE4\uDFF0\uDFF1]|\uD82F[\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDD30-\uDD36\uDEAE\uDEEC-\uDEEF]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD4A]|\uDB40[\uDD00-\uDDEF])*((?:(?![\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0898-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ACE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD803[\uDD24-\uDD27\uDEAB\uDEAC\uDF46-\uDF50\uDF82-\uDF85]|\uD804[\uDC00-\uDC02\uDC38-\uDC46\uDC70\uDC73\uDC74\uDC7F-\uDC82\uDCB0-\uDCBA\uDCC2\uDD00-\uDD02\uDD27-\uDD34\uDD45\uDD46\uDD73\uDD80-\uDD82\uDDB3-\uDDC0\uDDC9-\uDDCC\uDDCE\uDDCF\uDE2C-\uDE37\uDE3E\uDEDF-\uDEEA\uDF00-\uDF03\uDF3B\uDF3C\uDF3E-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF62\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC35-\uDC46\uDC5E\uDCB0-\uDCC3\uDDAF-\uDDB5\uDDB8-\uDDC0\uDDDC\uDDDD\uDE30-\uDE40\uDEAB-\uDEB7\uDF1D-\uDF2B]|\uD806[\uDC2C-\uDC3A\uDD30-\uDD35\uDD37\uDD38\uDD3B-\uDD3E\uDD40\uDD42\uDD43\uDDD1-\uDDD7\uDDDA-\uDDE0\uDDE4\uDE01-\uDE0A\uDE33-\uDE39\uDE3B-\uDE3E\uDE47\uDE51-\uDE5B\uDE8A-\uDE99]|\uD807[\uDC2F-\uDC36\uDC38-\uDC3F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD31-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD45\uDD47\uDD8A-\uDD8E\uDD90\uDD91\uDD93-\uDD97\uDEF3-\uDEF6]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF4F\uDF51-\uDF87\uDF8F-\uDF92\uDFE4\uDFF0\uDFF1]|\uD82F[\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDD30-\uDD36\uDEAE\uDEEC-\uDEEF]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD4A]|\uDB40[\uDD00-\uDDEF])[\s\S]))/;
  9195. var normalizationRegex = null;
  9196. function normalize(text) {
  9197. if (!normalizationRegex) {
  9198. var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join("");
  9199. normalizationRegex = new RegExp("([".concat(replace,
  9200. "])|(\\p{M}+(?:-\\n)?)|(\\S-\\n)|(\\n)"), "gum");
  9201. }
  9202. var rawDiacriticsPositions = [];
  9203. var m;
  9204. while ((m = DIACRITICS_REG_EXP.exec(text)) !== null) {
  9205. rawDiacriticsPositions.push([m[0].length, m.index]);
  9206. }
  9207. var normalized = text.normalize("NFD");
  9208. var positions = [
  9209. [0, 0]
  9210. ];
  9211. var k = 0;
  9212. var shift = 0;
  9213. var shiftOrigin = 0;
  9214. var eol = 0;
  9215. var hasDiacritics = false;
  9216. normalized = normalized.replace(normalizationRegex, function(match, p1, p2, p3, p4, i) {
  9217. i -= shiftOrigin;
  9218. if (p1) {
  9219. var replacement = CHARACTERS_TO_NORMALIZE[match];
  9220. var jj = replacement.length;
  9221. for (var j = 1; j < jj; j++) {
  9222. positions.push([i - shift + j, shift - j]);
  9223. }
  9224. shift -= jj - 1;
  9225. return replacement;
  9226. }
  9227. if (p2) {
  9228. var _rawDiacriticsPositio;
  9229. var hasTrailingDashEOL = p2.endsWith("\n");
  9230. var len = hasTrailingDashEOL ? p2.length - 2 : p2.length;
  9231. hasDiacritics = true;
  9232. var _jj = len;
  9233. if (i + eol === ((_rawDiacriticsPositio = rawDiacriticsPositions[k]) ===
  9234. null || _rawDiacriticsPositio === void 0 ? void 0 :
  9235. _rawDiacriticsPositio[1])) {
  9236. _jj -= rawDiacriticsPositions[k][0];
  9237. ++k;
  9238. }
  9239. for (var _j = 1; _j < _jj + 1; _j++) {
  9240. positions.push([i - 1 - shift + _j, shift - _j]);
  9241. }
  9242. shift -= _jj;
  9243. shiftOrigin += _jj;
  9244. if (hasTrailingDashEOL) {
  9245. i += len - 1;
  9246. positions.push([i - shift + 1, 1 + shift]);
  9247. shift += 1;
  9248. shiftOrigin += 1;
  9249. eol += 1;
  9250. return p2.slice(0, len);
  9251. }
  9252. return p2;
  9253. }
  9254. if (p3) {
  9255. positions.push([i - shift + 1, 1 + shift]);
  9256. shift += 1;
  9257. shiftOrigin += 1;
  9258. eol += 1;
  9259. return p3.charAt(0);
  9260. }
  9261. positions.push([i - shift + 1, shift - 1]);
  9262. shift -= 1;
  9263. shiftOrigin += 1;
  9264. eol += 1;
  9265. return " ";
  9266. });
  9267. positions.push([normalized.length, shift]);
  9268. return [normalized, positions, hasDiacritics];
  9269. }
  9270. function getOriginalIndex(diffs, pos, len) {
  9271. if (!diffs) {
  9272. return [pos, len];
  9273. }
  9274. var start = pos;
  9275. var end = pos + len;
  9276. var i = (0, _ui_utils.binarySearchFirstItem)(diffs, function(x) {
  9277. return x[0] >= start;
  9278. });
  9279. if (diffs[i][0] > start) {
  9280. --i;
  9281. }
  9282. var j = (0, _ui_utils.binarySearchFirstItem)(diffs, function(x) {
  9283. return x[0] >= end;
  9284. }, i);
  9285. if (diffs[j][0] > end) {
  9286. --j;
  9287. }
  9288. return [start + diffs[i][1], len + diffs[j][1] - diffs[i][1]];
  9289. }
  9290. var PDFFindController = /*#__PURE__*/ function() {
  9291. function PDFFindController(_ref) {
  9292. var _this = this;
  9293. var linkService = _ref.linkService,
  9294. eventBus = _ref.eventBus;
  9295. _classCallCheck(this, PDFFindController);
  9296. this._linkService = linkService;
  9297. this._eventBus = eventBus;
  9298. this._reset();
  9299. eventBus._on("find", this._onFind.bind(this));
  9300. eventBus._on("findbarclose", this._onFindBarClose.bind(this));
  9301. this.executeCommand = function(cmd, state) {
  9302. console.error(
  9303. "Deprecated method `PDFFindController.executeCommand` called, " +
  9304. 'please dispatch a "find"-event using the EventBus instead.');
  9305. var eventState = Object.assign(Object.create(null), state, {
  9306. type: cmd.substring("find".length)
  9307. });
  9308. _this._onFind(eventState);
  9309. };
  9310. }
  9311. _createClass(PDFFindController, [{
  9312. key: "highlightMatches",
  9313. get: function get() {
  9314. return this._highlightMatches;
  9315. }
  9316. }, {
  9317. key: "pageMatches",
  9318. get: function get() {
  9319. return this._pageMatches;
  9320. }
  9321. }, {
  9322. key: "pageMatchesLength",
  9323. get: function get() {
  9324. return this._pageMatchesLength;
  9325. }
  9326. }, {
  9327. key: "selected",
  9328. get: function get() {
  9329. return this._selected;
  9330. }
  9331. }, {
  9332. key: "state",
  9333. get: function get() {
  9334. return this._state;
  9335. }
  9336. }, {
  9337. key: "setDocument",
  9338. value: function setDocument(pdfDocument) {
  9339. if (this._pdfDocument) {
  9340. this._reset();
  9341. }
  9342. if (!pdfDocument) {
  9343. return;
  9344. }
  9345. this._pdfDocument = pdfDocument;
  9346. this._firstPageCapability.resolve();
  9347. }
  9348. }, {
  9349. key: "_onFind",
  9350. value: function _onFind(state) {
  9351. var _this2 = this;
  9352. if (!state) {
  9353. return;
  9354. }
  9355. var pdfDocument = this._pdfDocument;
  9356. var type = state.type;
  9357. if (this._state === null || this._shouldDirtyMatch(state)) {
  9358. this._dirtyMatch = true;
  9359. }
  9360. this._state = state;
  9361. if (type !== "highlightallchange") {
  9362. this._updateUIState(FindState.PENDING);
  9363. }
  9364. this._firstPageCapability.promise.then(function() {
  9365. if (!_this2._pdfDocument || pdfDocument &&
  9366. _this2._pdfDocument !== pdfDocument) {
  9367. return;
  9368. }
  9369. _this2._extractText();
  9370. var findbarClosed = !_this2._highlightMatches;
  9371. var pendingTimeout = !!_this2._findTimeout;
  9372. if (_this2._findTimeout) {
  9373. clearTimeout(_this2._findTimeout);
  9374. _this2._findTimeout = null;
  9375. }
  9376. if (!type) {
  9377. _this2._findTimeout = setTimeout(
  9378. function() {
  9379. _this2._nextMatch();
  9380. _this2._findTimeout = null;
  9381. }, FIND_TIMEOUT);
  9382. } else if (_this2._dirtyMatch) {
  9383. _this2._nextMatch();
  9384. } else if (type === "again") {
  9385. _this2._nextMatch();
  9386. if (findbarClosed && _this2._state
  9387. .highlightAll) {
  9388. _this2._updateAllPages();
  9389. }
  9390. } else if (type === "highlightallchange") {
  9391. if (pendingTimeout) {
  9392. _this2._nextMatch();
  9393. } else {
  9394. _this2._highlightMatches = true;
  9395. }
  9396. _this2._updateAllPages();
  9397. } else {
  9398. _this2._nextMatch();
  9399. }
  9400. });
  9401. }
  9402. }, {
  9403. key: "scrollMatchIntoView",
  9404. value: function scrollMatchIntoView(_ref2) {
  9405. var _ref2$element = _ref2.element,
  9406. element = _ref2$element === void 0 ? null :
  9407. _ref2$element,
  9408. _ref2$selectedLeft = _ref2.selectedLeft,
  9409. selectedLeft = _ref2$selectedLeft === void 0 ? 0 :
  9410. _ref2$selectedLeft,
  9411. _ref2$pageIndex = _ref2.pageIndex,
  9412. pageIndex = _ref2$pageIndex === void 0 ? -1 :
  9413. _ref2$pageIndex,
  9414. _ref2$matchIndex = _ref2.matchIndex,
  9415. matchIndex = _ref2$matchIndex === void 0 ? -1 :
  9416. _ref2$matchIndex;
  9417. if (!this._scrollMatches || !element) {
  9418. return;
  9419. } else if (matchIndex === -1 || matchIndex !== this
  9420. ._selected.matchIdx) {
  9421. return;
  9422. } else if (pageIndex === -1 || pageIndex !== this._selected
  9423. .pageIdx) {
  9424. return;
  9425. }
  9426. this._scrollMatches = false;
  9427. var spot = {
  9428. top: MATCH_SCROLL_OFFSET_TOP,
  9429. left: selectedLeft + MATCH_SCROLL_OFFSET_LEFT
  9430. };
  9431. (0, _ui_utils.scrollIntoView)(element, spot, true);
  9432. }
  9433. }, {
  9434. key: "_reset",
  9435. value: function _reset() {
  9436. this._highlightMatches = false;
  9437. this._scrollMatches = false;
  9438. this._pdfDocument = null;
  9439. this._pageMatches = [];
  9440. this._pageMatchesLength = [];
  9441. this._state = null;
  9442. this._selected = {
  9443. pageIdx: -1,
  9444. matchIdx: -1
  9445. };
  9446. this._offset = {
  9447. pageIdx: null,
  9448. matchIdx: null,
  9449. wrapped: false
  9450. };
  9451. this._extractTextPromises = [];
  9452. this._pageContents = [];
  9453. this._pageDiffs = [];
  9454. this._hasDiacritics = [];
  9455. this._matchesCountTotal = 0;
  9456. this._pagesToSearch = null;
  9457. this._pendingFindMatches = new Set();
  9458. this._resumePageIdx = null;
  9459. this._dirtyMatch = false;
  9460. clearTimeout(this._findTimeout);
  9461. this._findTimeout = null;
  9462. this._firstPageCapability = (0, _pdfjsLib
  9463. .createPromiseCapability)();
  9464. }
  9465. }, {
  9466. key: "_query",
  9467. get: function get() {
  9468. if (this._state.query !== this._rawQuery) {
  9469. this._rawQuery = this._state.query;
  9470. var _normalize = normalize(this._state.query);
  9471. var _normalize2 = _slicedToArray(_normalize, 1);
  9472. this._normalizedQuery = _normalize2[0];
  9473. }
  9474. return this._normalizedQuery;
  9475. }
  9476. }, {
  9477. key: "_shouldDirtyMatch",
  9478. value: function _shouldDirtyMatch(state) {
  9479. if (state.query !== this._state.query) {
  9480. return true;
  9481. }
  9482. switch (state.type) {
  9483. case "again":
  9484. var pageNumber = this._selected.pageIdx + 1;
  9485. var linkService = this._linkService;
  9486. if (pageNumber >= 1 && pageNumber <= linkService
  9487. .pagesCount && pageNumber !== linkService
  9488. .page && !linkService.isPageVisible(pageNumber)
  9489. ) {
  9490. return true;
  9491. }
  9492. return false;
  9493. case "highlightallchange":
  9494. return false;
  9495. }
  9496. return true;
  9497. }
  9498. }, {
  9499. key: "_isEntireWord",
  9500. value: function _isEntireWord(content, startIdx, length) {
  9501. var match = content.slice(0, startIdx).match(
  9502. NOT_DIACRITIC_FROM_END_REG_EXP);
  9503. if (match) {
  9504. var first = content.charCodeAt(startIdx);
  9505. var limit = match[1].charCodeAt(0);
  9506. if ((0, _pdf_find_utils.getCharacterType)(first) === (0,
  9507. _pdf_find_utils.getCharacterType)(limit)) {
  9508. return false;
  9509. }
  9510. }
  9511. match = content.slice(startIdx + length).match(
  9512. NOT_DIACRITIC_FROM_START_REG_EXP);
  9513. if (match) {
  9514. var last = content.charCodeAt(startIdx + length - 1);
  9515. var _limit = match[1].charCodeAt(0);
  9516. if ((0, _pdf_find_utils.getCharacterType)(last) === (0,
  9517. _pdf_find_utils.getCharacterType)(_limit)) {
  9518. return false;
  9519. }
  9520. }
  9521. return true;
  9522. }
  9523. }, {
  9524. key: "_calculateRegExpMatch",
  9525. value: function _calculateRegExpMatch(query, entireWord, pageIndex,
  9526. pageContent) {
  9527. var matches = [],
  9528. matchesLength = [];
  9529. var diffs = this._pageDiffs[pageIndex];
  9530. var match;
  9531. while ((match = query.exec(pageContent)) !== null) {
  9532. if (entireWord && !this._isEntireWord(pageContent, match
  9533. .index, match[0].length)) {
  9534. continue;
  9535. }
  9536. var _getOriginalIndex = getOriginalIndex(diffs, match
  9537. .index, match[0].length),
  9538. _getOriginalIndex2 = _slicedToArray(
  9539. _getOriginalIndex, 2),
  9540. matchPos = _getOriginalIndex2[0],
  9541. matchLen = _getOriginalIndex2[1];
  9542. if (matchLen) {
  9543. matches.push(matchPos);
  9544. matchesLength.push(matchLen);
  9545. }
  9546. }
  9547. this._pageMatches[pageIndex] = matches;
  9548. this._pageMatchesLength[pageIndex] = matchesLength;
  9549. }
  9550. }, {
  9551. key: "_convertToRegExpString",
  9552. value: function _convertToRegExpString(query, hasDiacritics) {
  9553. var matchDiacritics = this._state.matchDiacritics;
  9554. var isUnicode = false;
  9555. query = query.replace(SPECIAL_CHARS_REG_EXP, function(match,
  9556. p1, p2, p3, p4, p5) {
  9557. if (p1) {
  9558. return "[ ]*\\".concat(p1, "[ ]*");
  9559. }
  9560. if (p2) {
  9561. return "[ ]*".concat(p2, "[ ]*");
  9562. }
  9563. if (p3) {
  9564. return "[ ]+";
  9565. }
  9566. if (matchDiacritics) {
  9567. return p4 || p5;
  9568. }
  9569. if (p4) {
  9570. return DIACRITICS_EXCEPTION.has(p4
  9571. .charCodeAt(0)) ? p4 : "";
  9572. }
  9573. if (hasDiacritics) {
  9574. isUnicode = true;
  9575. return "".concat(p5, "\\p{M}*");
  9576. }
  9577. return p5;
  9578. });
  9579. var trailingSpaces = "[ ]*";
  9580. if (query.endsWith(trailingSpaces)) {
  9581. query = query.slice(0, query.length - trailingSpaces
  9582. .length);
  9583. }
  9584. if (matchDiacritics) {
  9585. if (hasDiacritics) {
  9586. isUnicode = true;
  9587. query = "".concat(query, "(?=[").concat(
  9588. DIACRITICS_EXCEPTION_STR, "]|[^\\p{M}]|$)");
  9589. }
  9590. }
  9591. return [isUnicode, query];
  9592. }
  9593. }, {
  9594. key: "_calculateMatch",
  9595. value: function _calculateMatch(pageIndex) {
  9596. var _this3 = this;
  9597. var query = this._query;
  9598. if (query.length === 0) {
  9599. return;
  9600. }
  9601. var _this$_state = this._state,
  9602. caseSensitive = _this$_state.caseSensitive,
  9603. entireWord = _this$_state.entireWord,
  9604. phraseSearch = _this$_state.phraseSearch;
  9605. var pageContent = this._pageContents[pageIndex];
  9606. var hasDiacritics = this._hasDiacritics[pageIndex];
  9607. var isUnicode = false;
  9608. if (phraseSearch) {
  9609. var _this$_convertToRegEx = this._convertToRegExpString(
  9610. query, hasDiacritics);
  9611. var _this$_convertToRegEx2 = _slicedToArray(
  9612. _this$_convertToRegEx, 2);
  9613. isUnicode = _this$_convertToRegEx2[0];
  9614. query = _this$_convertToRegEx2[1];
  9615. } else {
  9616. var match = query.match(/\S+/g);
  9617. if (match) {
  9618. query = match.sort().reverse().map(function(q) {
  9619. var _this3$_convertToRegE = _this3
  9620. ._convertToRegExpString(q,
  9621. hasDiacritics),
  9622. _this3$_convertToRegE2 =
  9623. _slicedToArray(
  9624. _this3$_convertToRegE, 2),
  9625. isUnicodePart =
  9626. _this3$_convertToRegE2[0],
  9627. queryPart = _this3$_convertToRegE2[
  9628. 1];
  9629. isUnicode || (isUnicode =
  9630. isUnicodePart);
  9631. return "(".concat(queryPart, ")");
  9632. }).join("|");
  9633. }
  9634. }
  9635. var flags = "g".concat(isUnicode ? "u" : "").concat(
  9636. caseSensitive ? "" : "i");
  9637. query = new RegExp(query, flags);
  9638. this._calculateRegExpMatch(query, entireWord, pageIndex,
  9639. pageContent);
  9640. if (this._state.highlightAll) {
  9641. this._updatePage(pageIndex);
  9642. }
  9643. if (this._resumePageIdx === pageIndex) {
  9644. this._resumePageIdx = null;
  9645. this._nextPageMatch();
  9646. }
  9647. var pageMatchesCount = this._pageMatches[pageIndex].length;
  9648. if (pageMatchesCount > 0) {
  9649. this._matchesCountTotal += pageMatchesCount;
  9650. this._updateUIResultsCount();
  9651. }
  9652. }
  9653. }, {
  9654. key: "_extractText",
  9655. value: function _extractText() {
  9656. var _this4 = this;
  9657. if (this._extractTextPromises.length > 0) {
  9658. return;
  9659. }
  9660. var promise = Promise.resolve();
  9661. var _loop = function _loop(i, ii) {
  9662. var extractTextCapability = (0, _pdfjsLib
  9663. .createPromiseCapability)();
  9664. _this4._extractTextPromises[i] =
  9665. extractTextCapability.promise;
  9666. promise = promise.then(function() {
  9667. return _this4._pdfDocument.getPage(i +
  9668. 1).then(function(pdfPage) {
  9669. return pdfPage
  9670. .getTextContent();
  9671. }).then(function(textContent) {
  9672. var textItems = textContent
  9673. .items;
  9674. var strBuf = [];
  9675. for (var j = 0, jj =
  9676. textItems
  9677. .length; j < jj; j++
  9678. ) {
  9679. strBuf.push(textItems[j]
  9680. .str);
  9681. if (textItems[j]
  9682. .hasEOL) {
  9683. strBuf.push("\n");
  9684. }
  9685. }
  9686. var _normalize3 = normalize(
  9687. strBuf.join(""));
  9688. var _normalize4 =
  9689. _slicedToArray(
  9690. _normalize3, 3);
  9691. _this4._pageContents[i] =
  9692. _normalize4[0];
  9693. _this4._pageDiffs[i] =
  9694. _normalize4[1];
  9695. _this4._hasDiacritics[i] =
  9696. _normalize4[2];
  9697. extractTextCapability
  9698. .resolve(i);
  9699. }, function(reason) {
  9700. console.error(
  9701. "Unable to get text content for page "
  9702. .concat(i + 1),
  9703. reason);
  9704. _this4._pageContents[i] =
  9705. "";
  9706. _this4._pageDiffs[i] = null;
  9707. _this4._hasDiacritics[i] =
  9708. false;
  9709. extractTextCapability
  9710. .resolve(i);
  9711. });
  9712. });
  9713. };
  9714. for (var i = 0, ii = this._linkService.pagesCount; i <
  9715. ii; i++) {
  9716. _loop(i, ii);
  9717. }
  9718. }
  9719. }, {
  9720. key: "_updatePage",
  9721. value: function _updatePage(index) {
  9722. if (this._scrollMatches && this._selected.pageIdx ===
  9723. index) {
  9724. this._linkService.page = index + 1;
  9725. }
  9726. this._eventBus.dispatch("updatetextlayermatches", {
  9727. source: this,
  9728. pageIndex: index
  9729. });
  9730. }
  9731. }, {
  9732. key: "_updateAllPages",
  9733. value: function _updateAllPages() {
  9734. this._eventBus.dispatch("updatetextlayermatches", {
  9735. source: this,
  9736. pageIndex: -1
  9737. });
  9738. }
  9739. }, {
  9740. key: "_nextMatch",
  9741. value: function _nextMatch() {
  9742. var _this5 = this;
  9743. var previous = this._state.findPrevious;
  9744. var currentPageIndex = this._linkService.page - 1;
  9745. var numPages = this._linkService.pagesCount;
  9746. this._highlightMatches = true;
  9747. if (this._dirtyMatch) {
  9748. this._dirtyMatch = false;
  9749. this._selected.pageIdx = this._selected.matchIdx = -1;
  9750. this._offset.pageIdx = currentPageIndex;
  9751. this._offset.matchIdx = null;
  9752. this._offset.wrapped = false;
  9753. this._resumePageIdx = null;
  9754. this._pageMatches.length = 0;
  9755. this._pageMatchesLength.length = 0;
  9756. this._matchesCountTotal = 0;
  9757. this._updateAllPages();
  9758. for (var i = 0; i < numPages; i++) {
  9759. if (this._pendingFindMatches.has(i)) {
  9760. continue;
  9761. }
  9762. this._pendingFindMatches.add(i);
  9763. this._extractTextPromises[i].then(function(
  9764. pageIdx) {
  9765. _this5._pendingFindMatches["delete"](
  9766. pageIdx);
  9767. _this5._calculateMatch(pageIdx);
  9768. });
  9769. }
  9770. }
  9771. if (this._query === "") {
  9772. this._updateUIState(FindState.FOUND);
  9773. return;
  9774. }
  9775. if (this._resumePageIdx) {
  9776. return;
  9777. }
  9778. var offset = this._offset;
  9779. this._pagesToSearch = numPages;
  9780. if (offset.matchIdx !== null) {
  9781. var numPageMatches = this._pageMatches[offset.pageIdx]
  9782. .length;
  9783. if (!previous && offset.matchIdx + 1 < numPageMatches ||
  9784. previous && offset.matchIdx > 0) {
  9785. offset.matchIdx = previous ? offset.matchIdx - 1 :
  9786. offset.matchIdx + 1;
  9787. this._updateMatch(true);
  9788. return;
  9789. }
  9790. this._advanceOffsetPage(previous);
  9791. }
  9792. this._nextPageMatch();
  9793. }
  9794. }, {
  9795. key: "_matchesReady",
  9796. value: function _matchesReady(matches) {
  9797. var offset = this._offset;
  9798. var numMatches = matches.length;
  9799. var previous = this._state.findPrevious;
  9800. if (numMatches) {
  9801. offset.matchIdx = previous ? numMatches - 1 : 0;
  9802. this._updateMatch(true);
  9803. return true;
  9804. }
  9805. this._advanceOffsetPage(previous);
  9806. if (offset.wrapped) {
  9807. offset.matchIdx = null;
  9808. if (this._pagesToSearch < 0) {
  9809. this._updateMatch(false);
  9810. return true;
  9811. }
  9812. }
  9813. return false;
  9814. }
  9815. }, {
  9816. key: "_nextPageMatch",
  9817. value: function _nextPageMatch() {
  9818. if (this._resumePageIdx !== null) {
  9819. console.error("There can only be one pending page.");
  9820. }
  9821. var matches = null;
  9822. do {
  9823. var pageIdx = this._offset.pageIdx;
  9824. matches = this._pageMatches[pageIdx];
  9825. if (!matches) {
  9826. this._resumePageIdx = pageIdx;
  9827. break;
  9828. }
  9829. } while (!this._matchesReady(matches));
  9830. }
  9831. }, {
  9832. key: "_advanceOffsetPage",
  9833. value: function _advanceOffsetPage(previous) {
  9834. var offset = this._offset;
  9835. var numPages = this._linkService.pagesCount;
  9836. offset.pageIdx = previous ? offset.pageIdx - 1 : offset
  9837. .pageIdx + 1;
  9838. offset.matchIdx = null;
  9839. this._pagesToSearch--;
  9840. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  9841. offset.pageIdx = previous ? numPages - 1 : 0;
  9842. offset.wrapped = true;
  9843. }
  9844. }
  9845. }, {
  9846. key: "_updateMatch",
  9847. value: function _updateMatch() {
  9848. var found = arguments.length > 0 && arguments[0] !==
  9849. undefined ? arguments[0] : false;
  9850. var state = FindState.NOT_FOUND;
  9851. var wrapped = this._offset.wrapped;
  9852. this._offset.wrapped = false;
  9853. if (found) {
  9854. var previousPage = this._selected.pageIdx;
  9855. this._selected.pageIdx = this._offset.pageIdx;
  9856. this._selected.matchIdx = this._offset.matchIdx;
  9857. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  9858. if (previousPage !== -1 && previousPage !== this
  9859. ._selected.pageIdx) {
  9860. this._updatePage(previousPage);
  9861. }
  9862. }
  9863. this._updateUIState(state, this._state.findPrevious);
  9864. if (this._selected.pageIdx !== -1) {
  9865. this._scrollMatches = true;
  9866. this._updatePage(this._selected.pageIdx);
  9867. }
  9868. }
  9869. }, {
  9870. key: "_onFindBarClose",
  9871. value: function _onFindBarClose(evt) {
  9872. var _this6 = this;
  9873. var pdfDocument = this._pdfDocument;
  9874. this._firstPageCapability.promise.then(function() {
  9875. if (!_this6._pdfDocument || pdfDocument &&
  9876. _this6._pdfDocument !== pdfDocument) {
  9877. return;
  9878. }
  9879. if (_this6._findTimeout) {
  9880. clearTimeout(_this6._findTimeout);
  9881. _this6._findTimeout = null;
  9882. }
  9883. if (_this6._resumePageIdx) {
  9884. _this6._resumePageIdx = null;
  9885. _this6._dirtyMatch = true;
  9886. }
  9887. _this6._updateUIState(FindState.FOUND);
  9888. _this6._highlightMatches = false;
  9889. _this6._updateAllPages();
  9890. });
  9891. }
  9892. }, {
  9893. key: "_requestMatchesCount",
  9894. value: function _requestMatchesCount() {
  9895. var _this$_selected = this._selected,
  9896. pageIdx = _this$_selected.pageIdx,
  9897. matchIdx = _this$_selected.matchIdx;
  9898. var current = 0,
  9899. total = this._matchesCountTotal;
  9900. if (matchIdx !== -1) {
  9901. for (var i = 0; i < pageIdx; i++) {
  9902. var _this$_pageMatches$i;
  9903. current += ((_this$_pageMatches$i = this
  9904. ._pageMatches[i]) === null ||
  9905. _this$_pageMatches$i === void 0 ? void 0 :
  9906. _this$_pageMatches$i.length) || 0;
  9907. }
  9908. current += matchIdx + 1;
  9909. }
  9910. if (current < 1 || current > total) {
  9911. current = total = 0;
  9912. }
  9913. return {
  9914. current: current,
  9915. total: total
  9916. };
  9917. }
  9918. }, {
  9919. key: "_updateUIResultsCount",
  9920. value: function _updateUIResultsCount() {
  9921. this._eventBus.dispatch("updatefindmatchescount", {
  9922. source: this,
  9923. matchesCount: this._requestMatchesCount()
  9924. });
  9925. }
  9926. }, {
  9927. key: "_updateUIState",
  9928. value: function _updateUIState(state) {
  9929. var _this$_state$query, _this$_state2;
  9930. var previous = arguments.length > 1 && arguments[1] !==
  9931. undefined ? arguments[1] : false;
  9932. this._eventBus.dispatch("updatefindcontrolstate", {
  9933. source: this,
  9934. state: state,
  9935. previous: previous,
  9936. matchesCount: this._requestMatchesCount(),
  9937. rawQuery: (_this$_state$query = (_this$_state2 =
  9938. this._state) === null ||
  9939. _this$_state2 === void 0 ? void 0 :
  9940. _this$_state2.query) !== null &&
  9941. _this$_state$query !== void 0 ?
  9942. _this$_state$query : null
  9943. });
  9944. }
  9945. }]);
  9946. return PDFFindController;
  9947. }();
  9948. exports.PDFFindController = PDFFindController;
  9949. /***/
  9950. }),
  9951. /* 18 */
  9952. /***/
  9953. ((__unused_webpack_module, exports) => {
  9954. Object.defineProperty(exports, "__esModule", ({
  9955. value: true
  9956. }));
  9957. exports.CharacterType = void 0;
  9958. exports.getCharacterType = getCharacterType;
  9959. var CharacterType = {
  9960. SPACE: 0,
  9961. ALPHA_LETTER: 1,
  9962. PUNCT: 2,
  9963. HAN_LETTER: 3,
  9964. KATAKANA_LETTER: 4,
  9965. HIRAGANA_LETTER: 5,
  9966. HALFWIDTH_KATAKANA_LETTER: 6,
  9967. THAI_LETTER: 7
  9968. };
  9969. exports.CharacterType = CharacterType;
  9970. function isAlphabeticalScript(charCode) {
  9971. return charCode < 0x2e80;
  9972. }
  9973. function isAscii(charCode) {
  9974. return (charCode & 0xff80) === 0;
  9975. }
  9976. function isAsciiAlpha(charCode) {
  9977. return charCode >= 0x61 && charCode <= 0x7a || charCode >= 0x41 && charCode <= 0x5a;
  9978. }
  9979. function isAsciiDigit(charCode) {
  9980. return charCode >= 0x30 && charCode <= 0x39;
  9981. }
  9982. function isAsciiSpace(charCode) {
  9983. return charCode === 0x20 || charCode === 0x09 || charCode === 0x0d || charCode === 0x0a;
  9984. }
  9985. function isHan(charCode) {
  9986. return charCode >= 0x3400 && charCode <= 0x9fff || charCode >= 0xf900 && charCode <=
  9987. 0xfaff;
  9988. }
  9989. function isKatakana(charCode) {
  9990. return charCode >= 0x30a0 && charCode <= 0x30ff;
  9991. }
  9992. function isHiragana(charCode) {
  9993. return charCode >= 0x3040 && charCode <= 0x309f;
  9994. }
  9995. function isHalfwidthKatakana(charCode) {
  9996. return charCode >= 0xff60 && charCode <= 0xff9f;
  9997. }
  9998. function isThai(charCode) {
  9999. return (charCode & 0xff80) === 0x0e00;
  10000. }
  10001. function getCharacterType(charCode) {
  10002. if (isAlphabeticalScript(charCode)) {
  10003. if (isAscii(charCode)) {
  10004. if (isAsciiSpace(charCode)) {
  10005. return CharacterType.SPACE;
  10006. } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode ===
  10007. 0x5f) {
  10008. return CharacterType.ALPHA_LETTER;
  10009. }
  10010. return CharacterType.PUNCT;
  10011. } else if (isThai(charCode)) {
  10012. return CharacterType.THAI_LETTER;
  10013. } else if (charCode === 0xa0) {
  10014. return CharacterType.SPACE;
  10015. }
  10016. return CharacterType.ALPHA_LETTER;
  10017. }
  10018. if (isHan(charCode)) {
  10019. return CharacterType.HAN_LETTER;
  10020. } else if (isKatakana(charCode)) {
  10021. return CharacterType.KATAKANA_LETTER;
  10022. } else if (isHiragana(charCode)) {
  10023. return CharacterType.HIRAGANA_LETTER;
  10024. } else if (isHalfwidthKatakana(charCode)) {
  10025. return CharacterType.HALFWIDTH_KATAKANA_LETTER;
  10026. }
  10027. return CharacterType.ALPHA_LETTER;
  10028. }
  10029. /***/
  10030. }),
  10031. /* 19 */
  10032. /***/
  10033. ((__unused_webpack_module, exports, __webpack_require__) => {
  10034. Object.defineProperty(exports, "__esModule", ({
  10035. value: true
  10036. }));
  10037. exports.PDFHistory = void 0;
  10038. exports.isDestArraysEqual = isDestArraysEqual;
  10039. exports.isDestHashesEqual = isDestHashesEqual;
  10040. var _ui_utils = __webpack_require__(5);
  10041. var _event_utils = __webpack_require__(6);
  10042. function _typeof(obj) {
  10043. "@babel/helpers - typeof";
  10044. return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ?
  10045. function(obj) {
  10046. return typeof obj;
  10047. } : function(obj) {
  10048. return obj && "function" == typeof Symbol && obj.constructor === Symbol &&
  10049. obj !== Symbol.prototype ? "symbol" : typeof obj;
  10050. }, _typeof(obj);
  10051. }
  10052. function _slicedToArray(arr, i) {
  10053. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) ||
  10054. _unsupportedIterableToArray(arr, i) || _nonIterableRest();
  10055. }
  10056. function _nonIterableRest() {
  10057. throw new TypeError(
  10058. "Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
  10059. );
  10060. }
  10061. function _unsupportedIterableToArray(o, minLen) {
  10062. if (!o) return;
  10063. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  10064. var n = Object.prototype.toString.call(o).slice(8, -1);
  10065. if (n === "Object" && o.constructor) n = o.constructor.name;
  10066. if (n === "Map" || n === "Set") return Array.from(o);
  10067. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
  10068. return _arrayLikeToArray(o, minLen);
  10069. }
  10070. function _arrayLikeToArray(arr, len) {
  10071. if (len == null || len > arr.length) len = arr.length;
  10072. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  10073. arr2[i] = arr[i];
  10074. }
  10075. return arr2;
  10076. }
  10077. function _iterableToArrayLimit(arr, i) {
  10078. var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] ||
  10079. arr["@@iterator"];
  10080. if (_i == null) return;
  10081. var _arr = [];
  10082. var _n = true;
  10083. var _d = false;
  10084. var _s, _e;
  10085. try {
  10086. for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
  10087. _arr.push(_s.value);
  10088. if (i && _arr.length === i) break;
  10089. }
  10090. } catch (err) {
  10091. _d = true;
  10092. _e = err;
  10093. } finally {
  10094. try {
  10095. if (!_n && _i["return"] != null) _i["return"]();
  10096. } finally {
  10097. if (_d) throw _e;
  10098. }
  10099. }
  10100. return _arr;
  10101. }
  10102. function _arrayWithHoles(arr) {
  10103. if (Array.isArray(arr)) return arr;
  10104. }
  10105. function _classCallCheck(instance, Constructor) {
  10106. if (!(instance instanceof Constructor)) {
  10107. throw new TypeError("Cannot call a class as a function");
  10108. }
  10109. }
  10110. function _defineProperties(target, props) {
  10111. for (var i = 0; i < props.length; i++) {
  10112. var descriptor = props[i];
  10113. descriptor.enumerable = descriptor.enumerable || false;
  10114. descriptor.configurable = true;
  10115. if ("value" in descriptor) descriptor.writable = true;
  10116. Object.defineProperty(target, descriptor.key, descriptor);
  10117. }
  10118. }
  10119. function _createClass(Constructor, protoProps, staticProps) {
  10120. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  10121. if (staticProps) _defineProperties(Constructor, staticProps);
  10122. Object.defineProperty(Constructor, "prototype", {
  10123. writable: false
  10124. });
  10125. return Constructor;
  10126. }
  10127. var HASH_CHANGE_TIMEOUT = 1000;
  10128. var POSITION_UPDATED_THRESHOLD = 50;
  10129. var UPDATE_VIEWAREA_TIMEOUT = 1000;
  10130. function getCurrentHash() {
  10131. return document.location.hash;
  10132. }
  10133. var PDFHistory = /*#__PURE__*/ function() {
  10134. function PDFHistory(_ref) {
  10135. var _this = this;
  10136. var linkService = _ref.linkService,
  10137. eventBus = _ref.eventBus;
  10138. _classCallCheck(this, PDFHistory);
  10139. this.linkService = linkService;
  10140. this.eventBus = eventBus;
  10141. this._initialized = false;
  10142. this._fingerprint = "";
  10143. this.reset();
  10144. this._boundEvents = null;
  10145. this._isViewerInPresentationMode = false;
  10146. this.eventBus._on("presentationmodechanged", function(evt) {
  10147. _this._isViewerInPresentationMode = evt.state !== _ui_utils
  10148. .PresentationModeState.NORMAL;
  10149. });
  10150. this.eventBus._on("pagesinit", function() {
  10151. _this._isPagesLoaded = false;
  10152. _this.eventBus._on("pagesloaded", function(evt) {
  10153. _this._isPagesLoaded = !!evt.pagesCount;
  10154. }, {
  10155. once: true
  10156. });
  10157. });
  10158. }
  10159. _createClass(PDFHistory, [{
  10160. key: "initialize",
  10161. value: function initialize(_ref2) {
  10162. var fingerprint = _ref2.fingerprint,
  10163. _ref2$resetHistory = _ref2.resetHistory,
  10164. resetHistory = _ref2$resetHistory === void 0 ? false :
  10165. _ref2$resetHistory,
  10166. _ref2$updateUrl = _ref2.updateUrl,
  10167. updateUrl = _ref2$updateUrl === void 0 ? false :
  10168. _ref2$updateUrl;
  10169. if (!fingerprint || typeof fingerprint !== "string") {
  10170. console.error(
  10171. 'PDFHistory.initialize: The "fingerprint" must be a non-empty string.'
  10172. );
  10173. return;
  10174. }
  10175. if (this._initialized) {
  10176. this.reset();
  10177. }
  10178. var reInitialized = this._fingerprint !== "" && this
  10179. ._fingerprint !== fingerprint;
  10180. this._fingerprint = fingerprint;
  10181. this._updateUrl = updateUrl === true;
  10182. this._initialized = true;
  10183. this._bindEvents();
  10184. var state = window.history.state;
  10185. this._popStateInProgress = false;
  10186. this._blockHashChange = 0;
  10187. this._currentHash = getCurrentHash();
  10188. this._numPositionUpdates = 0;
  10189. this._uid = this._maxUid = 0;
  10190. this._destination = null;
  10191. this._position = null;
  10192. if (!this._isValidState(state, true) || resetHistory) {
  10193. var _this$_parseCurrentHa = this._parseCurrentHash(
  10194. true),
  10195. hash = _this$_parseCurrentHa.hash,
  10196. page = _this$_parseCurrentHa.page,
  10197. rotation = _this$_parseCurrentHa.rotation;
  10198. if (!hash || reInitialized || resetHistory) {
  10199. this._pushOrReplaceState(null, true);
  10200. return;
  10201. }
  10202. this._pushOrReplaceState({
  10203. hash: hash,
  10204. page: page,
  10205. rotation: rotation
  10206. }, true);
  10207. return;
  10208. }
  10209. var destination = state.destination;
  10210. this._updateInternalState(destination, state.uid, true);
  10211. if (destination.rotation !== undefined) {
  10212. this._initialRotation = destination.rotation;
  10213. }
  10214. if (destination.dest) {
  10215. this._initialBookmark = JSON.stringify(destination
  10216. .dest);
  10217. this._destination.page = null;
  10218. } else if (destination.hash) {
  10219. this._initialBookmark = destination.hash;
  10220. } else if (destination.page) {
  10221. this._initialBookmark = "page=".concat(destination
  10222. .page);
  10223. }
  10224. }
  10225. }, {
  10226. key: "reset",
  10227. value: function reset() {
  10228. if (this._initialized) {
  10229. this._pageHide();
  10230. this._initialized = false;
  10231. this._unbindEvents();
  10232. }
  10233. if (this._updateViewareaTimeout) {
  10234. clearTimeout(this._updateViewareaTimeout);
  10235. this._updateViewareaTimeout = null;
  10236. }
  10237. this._initialBookmark = null;
  10238. this._initialRotation = null;
  10239. }
  10240. }, {
  10241. key: "push",
  10242. value: function push(_ref3) {
  10243. var _this2 = this;
  10244. var _ref3$namedDest = _ref3.namedDest,
  10245. namedDest = _ref3$namedDest === void 0 ? null :
  10246. _ref3$namedDest,
  10247. explicitDest = _ref3.explicitDest,
  10248. pageNumber = _ref3.pageNumber;
  10249. if (!this._initialized) {
  10250. return;
  10251. }
  10252. if (namedDest && typeof namedDest !== "string") {
  10253. console.error("PDFHistory.push: " + "\"".concat(
  10254. namedDest,
  10255. "\" is not a valid namedDest parameter."));
  10256. return;
  10257. } else if (!Array.isArray(explicitDest)) {
  10258. console.error("PDFHistory.push: " + "\"".concat(
  10259. explicitDest,
  10260. "\" is not a valid explicitDest parameter."
  10261. ));
  10262. return;
  10263. } else if (!this._isValidPage(pageNumber)) {
  10264. if (pageNumber !== null || this._destination) {
  10265. console.error("PDFHistory.push: " + "\"".concat(
  10266. pageNumber,
  10267. "\" is not a valid pageNumber parameter."
  10268. ));
  10269. return;
  10270. }
  10271. }
  10272. var hash = namedDest || JSON.stringify(explicitDest);
  10273. if (!hash) {
  10274. return;
  10275. }
  10276. var forceReplace = false;
  10277. if (this._destination && (isDestHashesEqual(this
  10278. ._destination.hash, hash) || isDestArraysEqual(
  10279. this._destination.dest, explicitDest))) {
  10280. if (this._destination.page) {
  10281. return;
  10282. }
  10283. forceReplace = true;
  10284. }
  10285. if (this._popStateInProgress && !forceReplace) {
  10286. return;
  10287. }
  10288. this._pushOrReplaceState({
  10289. dest: explicitDest,
  10290. hash: hash,
  10291. page: pageNumber,
  10292. rotation: this.linkService.rotation
  10293. }, forceReplace);
  10294. if (!this._popStateInProgress) {
  10295. this._popStateInProgress = true;
  10296. Promise.resolve().then(function() {
  10297. _this2._popStateInProgress = false;
  10298. });
  10299. }
  10300. }
  10301. }, {
  10302. key: "pushPage",
  10303. value: function pushPage(pageNumber) {
  10304. var _this$_destination,
  10305. _this3 = this;
  10306. if (!this._initialized) {
  10307. return;
  10308. }
  10309. if (!this._isValidPage(pageNumber)) {
  10310. console.error("PDFHistory.pushPage: \"".concat(
  10311. pageNumber, "\" is not a valid page number."
  10312. ));
  10313. return;
  10314. }
  10315. if (((_this$_destination = this._destination) === null ||
  10316. _this$_destination === void 0 ? void 0 :
  10317. _this$_destination.page) === pageNumber) {
  10318. return;
  10319. }
  10320. if (this._popStateInProgress) {
  10321. return;
  10322. }
  10323. this._pushOrReplaceState({
  10324. dest: null,
  10325. hash: "page=".concat(pageNumber),
  10326. page: pageNumber,
  10327. rotation: this.linkService.rotation
  10328. });
  10329. if (!this._popStateInProgress) {
  10330. this._popStateInProgress = true;
  10331. Promise.resolve().then(function() {
  10332. _this3._popStateInProgress = false;
  10333. });
  10334. }
  10335. }
  10336. }, {
  10337. key: "pushCurrentPosition",
  10338. value: function pushCurrentPosition() {
  10339. if (!this._initialized || this._popStateInProgress) {
  10340. return;
  10341. }
  10342. this._tryPushCurrentPosition();
  10343. }
  10344. }, {
  10345. key: "back",
  10346. value: function back() {
  10347. if (!this._initialized || this._popStateInProgress) {
  10348. return;
  10349. }
  10350. var state = window.history.state;
  10351. if (this._isValidState(state) && state.uid > 0) {
  10352. window.history.back();
  10353. }
  10354. }
  10355. }, {
  10356. key: "forward",
  10357. value: function forward() {
  10358. if (!this._initialized || this._popStateInProgress) {
  10359. return;
  10360. }
  10361. var state = window.history.state;
  10362. if (this._isValidState(state) && state.uid < this._maxUid) {
  10363. window.history.forward();
  10364. }
  10365. }
  10366. }, {
  10367. key: "popStateInProgress",
  10368. get: function get() {
  10369. return this._initialized && (this._popStateInProgress ||
  10370. this._blockHashChange > 0);
  10371. }
  10372. }, {
  10373. key: "initialBookmark",
  10374. get: function get() {
  10375. return this._initialized ? this._initialBookmark : null;
  10376. }
  10377. }, {
  10378. key: "initialRotation",
  10379. get: function get() {
  10380. return this._initialized ? this._initialRotation : null;
  10381. }
  10382. }, {
  10383. key: "_pushOrReplaceState",
  10384. value: function _pushOrReplaceState(destination) {
  10385. var forceReplace = arguments.length > 1 && arguments[1] !==
  10386. undefined ? arguments[1] : false;
  10387. var shouldReplace = forceReplace || !this._destination;
  10388. var newState = {
  10389. fingerprint: this._fingerprint,
  10390. uid: shouldReplace ? this._uid : this._uid + 1,
  10391. destination: destination
  10392. };
  10393. this._updateInternalState(destination, newState.uid);
  10394. var newUrl;
  10395. if (this._updateUrl && destination !== null &&
  10396. destination !== void 0 && destination.hash) {
  10397. var baseUrl = document.location.href.split("#")[0];
  10398. if (!baseUrl.startsWith("file://")) {
  10399. newUrl = "".concat(baseUrl, "#").concat(destination
  10400. .hash);
  10401. }
  10402. }
  10403. if (shouldReplace) {
  10404. window.history.replaceState(newState, "", newUrl);
  10405. } else {
  10406. window.history.pushState(newState, "", newUrl);
  10407. }
  10408. }
  10409. }, {
  10410. key: "_tryPushCurrentPosition",
  10411. value: function _tryPushCurrentPosition() {
  10412. var temporary = arguments.length > 0 && arguments[0] !==
  10413. undefined ? arguments[0] : false;
  10414. if (!this._position) {
  10415. return;
  10416. }
  10417. var position = this._position;
  10418. if (temporary) {
  10419. position = Object.assign(Object.create(null), this
  10420. ._position);
  10421. position.temporary = true;
  10422. }
  10423. if (!this._destination) {
  10424. this._pushOrReplaceState(position);
  10425. return;
  10426. }
  10427. if (this._destination.temporary) {
  10428. this._pushOrReplaceState(position, true);
  10429. return;
  10430. }
  10431. if (this._destination.hash === position.hash) {
  10432. return;
  10433. }
  10434. if (!this._destination.page && (
  10435. POSITION_UPDATED_THRESHOLD <= 0 || this
  10436. ._numPositionUpdates <= POSITION_UPDATED_THRESHOLD
  10437. )) {
  10438. return;
  10439. }
  10440. var forceReplace = false;
  10441. if (this._destination.page >= position.first && this
  10442. ._destination.page <= position.page) {
  10443. if (this._destination.dest !== undefined || !this
  10444. ._destination.first) {
  10445. return;
  10446. }
  10447. forceReplace = true;
  10448. }
  10449. this._pushOrReplaceState(position, forceReplace);
  10450. }
  10451. }, {
  10452. key: "_isValidPage",
  10453. value: function _isValidPage(val) {
  10454. return Number.isInteger(val) && val > 0 && val <= this
  10455. .linkService.pagesCount;
  10456. }
  10457. }, {
  10458. key: "_isValidState",
  10459. value: function _isValidState(state) {
  10460. var checkReload = arguments.length > 1 && arguments[1] !==
  10461. undefined ? arguments[1] : false;
  10462. if (!state) {
  10463. return false;
  10464. }
  10465. if (state.fingerprint !== this._fingerprint) {
  10466. if (checkReload) {
  10467. if (typeof state.fingerprint !== "string" || state
  10468. .fingerprint.length !== this._fingerprint.length
  10469. ) {
  10470. return false;
  10471. }
  10472. var _performance$getEntri = performance
  10473. .getEntriesByType("navigation"),
  10474. _performance$getEntri2 = _slicedToArray(
  10475. _performance$getEntri, 1),
  10476. perfEntry = _performance$getEntri2[0];
  10477. if ((perfEntry === null || perfEntry === void 0 ?
  10478. void 0 : perfEntry.type) !== "reload") {
  10479. return false;
  10480. }
  10481. } else {
  10482. return false;
  10483. }
  10484. }
  10485. if (!Number.isInteger(state.uid) || state.uid < 0) {
  10486. return false;
  10487. }
  10488. if (state.destination === null || _typeof(state
  10489. .destination) !== "object") {
  10490. return false;
  10491. }
  10492. return true;
  10493. }
  10494. }, {
  10495. key: "_updateInternalState",
  10496. value: function _updateInternalState(destination, uid) {
  10497. var removeTemporary = arguments.length > 2 && arguments[
  10498. 2] !== undefined ? arguments[2] : false;
  10499. if (this._updateViewareaTimeout) {
  10500. clearTimeout(this._updateViewareaTimeout);
  10501. this._updateViewareaTimeout = null;
  10502. }
  10503. if (removeTemporary && destination !== null &&
  10504. destination !== void 0 && destination.temporary) {
  10505. delete destination.temporary;
  10506. }
  10507. this._destination = destination;
  10508. this._uid = uid;
  10509. this._maxUid = Math.max(this._maxUid, uid);
  10510. this._numPositionUpdates = 0;
  10511. }
  10512. }, {
  10513. key: "_parseCurrentHash",
  10514. value: function _parseCurrentHash() {
  10515. var checkNameddest = arguments.length > 0 && arguments[
  10516. 0] !== undefined ? arguments[0] : false;
  10517. var hash = unescape(getCurrentHash()).substring(1);
  10518. var params = (0, _ui_utils.parseQueryString)(hash);
  10519. var nameddest = params.get("nameddest") || "";
  10520. var page = params.get("page") | 0;
  10521. if (!this._isValidPage(page) || checkNameddest && nameddest
  10522. .length > 0) {
  10523. page = null;
  10524. }
  10525. return {
  10526. hash: hash,
  10527. page: page,
  10528. rotation: this.linkService.rotation
  10529. };
  10530. }
  10531. }, {
  10532. key: "_updateViewarea",
  10533. value: function _updateViewarea(_ref4) {
  10534. var _this4 = this;
  10535. var location = _ref4.location;
  10536. if (this._updateViewareaTimeout) {
  10537. clearTimeout(this._updateViewareaTimeout);
  10538. this._updateViewareaTimeout = null;
  10539. }
  10540. this._position = {
  10541. hash: this._isViewerInPresentationMode ? "page="
  10542. .concat(location.pageNumber) : location
  10543. .pdfOpenParams.substring(1),
  10544. page: this.linkService.page,
  10545. first: location.pageNumber,
  10546. rotation: location.rotation
  10547. };
  10548. if (this._popStateInProgress) {
  10549. return;
  10550. }
  10551. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded &&
  10552. this._destination && !this._destination.page) {
  10553. this._numPositionUpdates++;
  10554. }
  10555. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  10556. this._updateViewareaTimeout = setTimeout(function() {
  10557. if (!_this4._popStateInProgress) {
  10558. _this4._tryPushCurrentPosition(true);
  10559. }
  10560. _this4._updateViewareaTimeout = null;
  10561. }, UPDATE_VIEWAREA_TIMEOUT);
  10562. }
  10563. }
  10564. }, {
  10565. key: "_popState",
  10566. value: function _popState(_ref5) {
  10567. var _this5 = this;
  10568. var state = _ref5.state;
  10569. var newHash = getCurrentHash(),
  10570. hashChanged = this._currentHash !== newHash;
  10571. this._currentHash = newHash;
  10572. if (!state) {
  10573. this._uid++;
  10574. var _this$_parseCurrentHa2 = this._parseCurrentHash(),
  10575. hash = _this$_parseCurrentHa2.hash,
  10576. page = _this$_parseCurrentHa2.page,
  10577. rotation = _this$_parseCurrentHa2.rotation;
  10578. this._pushOrReplaceState({
  10579. hash: hash,
  10580. page: page,
  10581. rotation: rotation
  10582. }, true);
  10583. return;
  10584. }
  10585. if (!this._isValidState(state)) {
  10586. return;
  10587. }
  10588. this._popStateInProgress = true;
  10589. if (hashChanged) {
  10590. this._blockHashChange++;
  10591. (0, _event_utils.waitOnEventOrTimeout)({
  10592. target: window,
  10593. name: "hashchange",
  10594. delay: HASH_CHANGE_TIMEOUT
  10595. }).then(function() {
  10596. _this5._blockHashChange--;
  10597. });
  10598. }
  10599. var destination = state.destination;
  10600. this._updateInternalState(destination, state.uid, true);
  10601. if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
  10602. this.linkService.rotation = destination.rotation;
  10603. }
  10604. if (destination.dest) {
  10605. this.linkService.goToDestination(destination.dest);
  10606. } else if (destination.hash) {
  10607. this.linkService.setHash(destination.hash);
  10608. } else if (destination.page) {
  10609. this.linkService.page = destination.page;
  10610. }
  10611. Promise.resolve().then(function() {
  10612. _this5._popStateInProgress = false;
  10613. });
  10614. }
  10615. }, {
  10616. key: "_pageHide",
  10617. value: function _pageHide() {
  10618. if (!this._destination || this._destination.temporary) {
  10619. this._tryPushCurrentPosition();
  10620. }
  10621. }
  10622. }, {
  10623. key: "_bindEvents",
  10624. value: function _bindEvents() {
  10625. if (this._boundEvents) {
  10626. return;
  10627. }
  10628. this._boundEvents = {
  10629. updateViewarea: this._updateViewarea.bind(this),
  10630. popState: this._popState.bind(this),
  10631. pageHide: this._pageHide.bind(this)
  10632. };
  10633. this.eventBus._on("updateviewarea", this._boundEvents
  10634. .updateViewarea);
  10635. window.addEventListener("popstate", this._boundEvents
  10636. .popState);
  10637. window.addEventListener("pagehide", this._boundEvents
  10638. .pageHide);
  10639. }
  10640. }, {
  10641. key: "_unbindEvents",
  10642. value: function _unbindEvents() {
  10643. if (!this._boundEvents) {
  10644. return;
  10645. }
  10646. this.eventBus._off("updateviewarea", this._boundEvents
  10647. .updateViewarea);
  10648. window.removeEventListener("popstate", this._boundEvents
  10649. .popState);
  10650. window.removeEventListener("pagehide", this._boundEvents
  10651. .pageHide);
  10652. this._boundEvents = null;
  10653. }
  10654. }]);
  10655. return PDFHistory;
  10656. }();
  10657. exports.PDFHistory = PDFHistory;
  10658. function isDestHashesEqual(destHash, pushHash) {
  10659. if (typeof destHash !== "string" || typeof pushHash !== "string") {
  10660. return false;
  10661. }
  10662. if (destHash === pushHash) {
  10663. return true;
  10664. }
  10665. var nameddest = (0, _ui_utils.parseQueryString)(destHash).get("nameddest");
  10666. if (nameddest === pushHash) {
  10667. return true;
  10668. }
  10669. return false;
  10670. }
  10671. function isDestArraysEqual(firstDest, secondDest) {
  10672. function isEntryEqual(first, second) {
  10673. if (_typeof(first) !== _typeof(second)) {
  10674. return false;
  10675. }
  10676. if (Array.isArray(first) || Array.isArray(second)) {
  10677. return false;
  10678. }
  10679. if (first !== null && _typeof(first) === "object" && second !== null) {
  10680. if (Object.keys(first).length !== Object.keys(second).length) {
  10681. return false;
  10682. }
  10683. for (var key in first) {
  10684. if (!isEntryEqual(first[key], second[key])) {
  10685. return false;
  10686. }
  10687. }
  10688. return true;
  10689. }
  10690. return first === second || Number.isNaN(first) && Number.isNaN(second);
  10691. }
  10692. if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
  10693. return false;
  10694. }
  10695. if (firstDest.length !== secondDest.length) {
  10696. return false;
  10697. }
  10698. for (var i = 0, ii = firstDest.length; i < ii; i++) {
  10699. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  10700. return false;
  10701. }
  10702. }
  10703. return true;
  10704. }
  10705. /***/
  10706. }),
  10707. /* 20 */
  10708. /***/
  10709. ((__unused_webpack_module, exports, __webpack_require__) => {
  10710. Object.defineProperty(exports, "__esModule", ({
  10711. value: true
  10712. }));
  10713. exports.PDFLayerViewer = void 0;
  10714. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  10715. var _base_tree_viewer = __webpack_require__(14);
  10716. function _interopRequireDefault(obj) {
  10717. return obj && obj.__esModule ? obj : {
  10718. "default": obj
  10719. };
  10720. }
  10721. function _typeof(obj) {
  10722. "@babel/helpers - typeof";
  10723. return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ?
  10724. function(obj) {
  10725. return typeof obj;
  10726. } : function(obj) {
  10727. return obj && "function" == typeof Symbol && obj.constructor === Symbol &&
  10728. obj !== Symbol.prototype ? "symbol" : typeof obj;
  10729. }, _typeof(obj);
  10730. }
  10731. function _createForOfIteratorHelper(o, allowArrayLike) {
  10732. var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
  10733. if (!it) {
  10734. if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike &&
  10735. o && typeof o.length === "number") {
  10736. if (it) o = it;
  10737. var i = 0;
  10738. var F = function F() {};
  10739. return {
  10740. s: F,
  10741. n: function n() {
  10742. if (i >= o.length) return {
  10743. done: true
  10744. };
  10745. return {
  10746. done: false,
  10747. value: o[i++]
  10748. };
  10749. },
  10750. e: function e(_e) {
  10751. throw _e;
  10752. },
  10753. f: F
  10754. };
  10755. }
  10756. throw new TypeError(
  10757. "Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
  10758. );
  10759. }
  10760. var normalCompletion = true,
  10761. didErr = false,
  10762. err;
  10763. return {
  10764. s: function s() {
  10765. it = it.call(o);
  10766. },
  10767. n: function n() {
  10768. var step = it.next();
  10769. normalCompletion = step.done;
  10770. return step;
  10771. },
  10772. e: function e(_e2) {
  10773. didErr = true;
  10774. err = _e2;
  10775. },
  10776. f: function f() {
  10777. try {
  10778. if (!normalCompletion && it["return"] != null) it["return"]();
  10779. } finally {
  10780. if (didErr) throw err;
  10781. }
  10782. }
  10783. };
  10784. }
  10785. function _unsupportedIterableToArray(o, minLen) {
  10786. if (!o) return;
  10787. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  10788. var n = Object.prototype.toString.call(o).slice(8, -1);
  10789. if (n === "Object" && o.constructor) n = o.constructor.name;
  10790. if (n === "Map" || n === "Set") return Array.from(o);
  10791. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
  10792. return _arrayLikeToArray(o, minLen);
  10793. }
  10794. function _arrayLikeToArray(arr, len) {
  10795. if (len == null || len > arr.length) len = arr.length;
  10796. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  10797. arr2[i] = arr[i];
  10798. }
  10799. return arr2;
  10800. }
  10801. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  10802. try {
  10803. var info = gen[key](arg);
  10804. var value = info.value;
  10805. } catch (error) {
  10806. reject(error);
  10807. return;
  10808. }
  10809. if (info.done) {
  10810. resolve(value);
  10811. } else {
  10812. Promise.resolve(value).then(_next, _throw);
  10813. }
  10814. }
  10815. function _asyncToGenerator(fn) {
  10816. return function() {
  10817. var self = this,
  10818. args = arguments;
  10819. return new Promise(function(resolve, reject) {
  10820. var gen = fn.apply(self, args);
  10821. function _next(value) {
  10822. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next",
  10823. value);
  10824. }
  10825. function _throw(err) {
  10826. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw",
  10827. err);
  10828. }
  10829. _next(undefined);
  10830. });
  10831. };
  10832. }
  10833. function _classCallCheck(instance, Constructor) {
  10834. if (!(instance instanceof Constructor)) {
  10835. throw new TypeError("Cannot call a class as a function");
  10836. }
  10837. }
  10838. function _defineProperties(target, props) {
  10839. for (var i = 0; i < props.length; i++) {
  10840. var descriptor = props[i];
  10841. descriptor.enumerable = descriptor.enumerable || false;
  10842. descriptor.configurable = true;
  10843. if ("value" in descriptor) descriptor.writable = true;
  10844. Object.defineProperty(target, descriptor.key, descriptor);
  10845. }
  10846. }
  10847. function _createClass(Constructor, protoProps, staticProps) {
  10848. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  10849. if (staticProps) _defineProperties(Constructor, staticProps);
  10850. Object.defineProperty(Constructor, "prototype", {
  10851. writable: false
  10852. });
  10853. return Constructor;
  10854. }
  10855. function _get() {
  10856. if (typeof Reflect !== "undefined" && Reflect.get) {
  10857. _get = Reflect.get;
  10858. } else {
  10859. _get = function _get(target, property, receiver) {
  10860. var base = _superPropBase(target, property);
  10861. if (!base) return;
  10862. var desc = Object.getOwnPropertyDescriptor(base, property);
  10863. if (desc.get) {
  10864. return desc.get.call(arguments.length < 3 ? target : receiver);
  10865. }
  10866. return desc.value;
  10867. };
  10868. }
  10869. return _get.apply(this, arguments);
  10870. }
  10871. function _superPropBase(object, property) {
  10872. while (!Object.prototype.hasOwnProperty.call(object, property)) {
  10873. object = _getPrototypeOf(object);
  10874. if (object === null) break;
  10875. }
  10876. return object;
  10877. }
  10878. function _inherits(subClass, superClass) {
  10879. if (typeof superClass !== "function" && superClass !== null) {
  10880. throw new TypeError("Super expression must either be null or a function");
  10881. }
  10882. subClass.prototype = Object.create(superClass && superClass.prototype, {
  10883. constructor: {
  10884. value: subClass,
  10885. writable: true,
  10886. configurable: true
  10887. }
  10888. });
  10889. Object.defineProperty(subClass, "prototype", {
  10890. writable: false
  10891. });
  10892. if (superClass) _setPrototypeOf(subClass, superClass);
  10893. }
  10894. function _setPrototypeOf(o, p) {
  10895. _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  10896. o.__proto__ = p;
  10897. return o;
  10898. };
  10899. return _setPrototypeOf(o, p);
  10900. }
  10901. function _createSuper(Derived) {
  10902. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  10903. return function _createSuperInternal() {
  10904. var Super = _getPrototypeOf(Derived),
  10905. result;
  10906. if (hasNativeReflectConstruct) {
  10907. var NewTarget = _getPrototypeOf(this).constructor;
  10908. result = Reflect.construct(Super, arguments, NewTarget);
  10909. } else {
  10910. result = Super.apply(this, arguments);
  10911. }
  10912. return _possibleConstructorReturn(this, result);
  10913. };
  10914. }
  10915. function _possibleConstructorReturn(self, call) {
  10916. if (call && (_typeof(call) === "object" || typeof call === "function")) {
  10917. return call;
  10918. } else if (call !== void 0) {
  10919. throw new TypeError("Derived constructors may only return object or undefined");
  10920. }
  10921. return _assertThisInitialized(self);
  10922. }
  10923. function _assertThisInitialized(self) {
  10924. if (self === void 0) {
  10925. throw new ReferenceError(
  10926. "this hasn't been initialised - super() hasn't been called");
  10927. }
  10928. return self;
  10929. }
  10930. function _isNativeReflectConstruct() {
  10931. if (typeof Reflect === "undefined" || !Reflect.construct) return false;
  10932. if (Reflect.construct.sham) return false;
  10933. if (typeof Proxy === "function") return true;
  10934. try {
  10935. Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
  10936. return true;
  10937. } catch (e) {
  10938. return false;
  10939. }
  10940. }
  10941. function _getPrototypeOf(o) {
  10942. _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf :
  10943. function _getPrototypeOf(o) {
  10944. return o.__proto__ || Object.getPrototypeOf(o);
  10945. };
  10946. return _getPrototypeOf(o);
  10947. }
  10948. var PDFLayerViewer = /*#__PURE__*/ function(_BaseTreeViewer) {
  10949. _inherits(PDFLayerViewer, _BaseTreeViewer);
  10950. var _super = _createSuper(PDFLayerViewer);
  10951. function PDFLayerViewer(options) {
  10952. var _this;
  10953. _classCallCheck(this, PDFLayerViewer);
  10954. _this = _super.call(this, options);
  10955. _this.l10n = options.l10n;
  10956. _this.eventBus._on("resetlayers", _this._resetLayers.bind(
  10957. _assertThisInitialized(_this)));
  10958. _this.eventBus._on("togglelayerstree", _this._toggleAllTreeItems.bind(
  10959. _assertThisInitialized(_this)));
  10960. return _this;
  10961. }
  10962. _createClass(PDFLayerViewer, [{
  10963. key: "reset",
  10964. value: function reset() {
  10965. _get(_getPrototypeOf(PDFLayerViewer.prototype), "reset",
  10966. this).call(this);
  10967. this._optionalContentConfig = null;
  10968. }
  10969. }, {
  10970. key: "_dispatchEvent",
  10971. value: function _dispatchEvent(layersCount) {
  10972. this.eventBus.dispatch("layersloaded", {
  10973. source: this,
  10974. layersCount: layersCount
  10975. });
  10976. }
  10977. }, {
  10978. key: "_bindLink",
  10979. value: function _bindLink(element, _ref) {
  10980. var _this2 = this;
  10981. var groupId = _ref.groupId,
  10982. input = _ref.input;
  10983. var setVisibility = function setVisibility() {
  10984. _this2._optionalContentConfig.setVisibility(groupId,
  10985. input.checked);
  10986. _this2.eventBus.dispatch("optionalcontentconfig", {
  10987. source: _this2,
  10988. promise: Promise.resolve(_this2
  10989. ._optionalContentConfig)
  10990. });
  10991. };
  10992. element.onclick = function(evt) {
  10993. if (evt.target === input) {
  10994. setVisibility();
  10995. return true;
  10996. } else if (evt.target !== element) {
  10997. return true;
  10998. }
  10999. input.checked = !input.checked;
  11000. setVisibility();
  11001. return false;
  11002. };
  11003. }
  11004. }, {
  11005. key: "_setNestedName",
  11006. value: function() {
  11007. var _setNestedName2 = _asyncToGenerator( /*#__PURE__*/
  11008. _regenerator["default"].mark(function _callee(
  11009. element, _ref2) {
  11010. var _ref2$name, name;
  11011. return _regenerator["default"].wrap(
  11012. function _callee$(_context) {
  11013. while (1) {
  11014. switch (_context.prev =
  11015. _context.next) {
  11016. case 0:
  11017. _ref2$name = _ref2
  11018. .name, name =
  11019. _ref2$name ===
  11020. void 0 ? null :
  11021. _ref2$name;
  11022. if (!(typeof name ===
  11023. "string")) {
  11024. _context.next =
  11025. 4;
  11026. break;
  11027. }
  11028. element
  11029. .textContent =
  11030. this
  11031. ._normalizeTextContent(
  11032. name);
  11033. return _context
  11034. .abrupt(
  11035. "return");
  11036. case 4:
  11037. _context.next = 6;
  11038. return this.l10n
  11039. .get(
  11040. "additional_layers"
  11041. );
  11042. case 6:
  11043. element
  11044. .textContent =
  11045. _context.sent;
  11046. element.style
  11047. .fontStyle =
  11048. "italic";
  11049. case 8:
  11050. case "end":
  11051. return _context
  11052. .stop();
  11053. }
  11054. }
  11055. }, _callee, this);
  11056. }));
  11057. function _setNestedName(_x, _x2) {
  11058. return _setNestedName2.apply(this, arguments);
  11059. }
  11060. return _setNestedName;
  11061. }()
  11062. }, {
  11063. key: "_addToggleButton",
  11064. value: function _addToggleButton(div, _ref3) {
  11065. var _ref3$name = _ref3.name,
  11066. name = _ref3$name === void 0 ? null : _ref3$name;
  11067. _get(_getPrototypeOf(PDFLayerViewer.prototype),
  11068. "_addToggleButton", this).call(this, div, name ===
  11069. null);
  11070. }
  11071. }, {
  11072. key: "_toggleAllTreeItems",
  11073. value: function _toggleAllTreeItems() {
  11074. if (!this._optionalContentConfig) {
  11075. return;
  11076. }
  11077. _get(_getPrototypeOf(PDFLayerViewer.prototype),
  11078. "_toggleAllTreeItems", this).call(this);
  11079. }
  11080. }, {
  11081. key: "render",
  11082. value: function render(_ref4) {
  11083. var optionalContentConfig = _ref4.optionalContentConfig,
  11084. pdfDocument = _ref4.pdfDocument;
  11085. if (this._optionalContentConfig) {
  11086. this.reset();
  11087. }
  11088. this._optionalContentConfig = optionalContentConfig || null;
  11089. this._pdfDocument = pdfDocument || null;
  11090. var groups = optionalContentConfig === null ||
  11091. optionalContentConfig === void 0 ? void 0 :
  11092. optionalContentConfig.getOrder();
  11093. if (!groups) {
  11094. this._dispatchEvent(0);
  11095. return;
  11096. }
  11097. var fragment = document.createDocumentFragment(),
  11098. queue = [{
  11099. parent: fragment,
  11100. groups: groups
  11101. }];
  11102. var layersCount = 0,
  11103. hasAnyNesting = false;
  11104. while (queue.length > 0) {
  11105. var levelData = queue.shift();
  11106. var _iterator = _createForOfIteratorHelper(levelData
  11107. .groups),
  11108. _step;
  11109. try {
  11110. for (_iterator.s(); !(_step = _iterator.n())
  11111. .done;) {
  11112. var groupId = _step.value;
  11113. var div = document.createElement("div");
  11114. div.className = "treeItem";
  11115. var element = document.createElement("a");
  11116. div.appendChild(element);
  11117. if (_typeof(groupId) === "object") {
  11118. hasAnyNesting = true;
  11119. this._addToggleButton(div, groupId);
  11120. this._setNestedName(element, groupId);
  11121. var itemsDiv = document.createElement(
  11122. "div");
  11123. itemsDiv.className = "treeItems";
  11124. div.appendChild(itemsDiv);
  11125. queue.push({
  11126. parent: itemsDiv,
  11127. groups: groupId.order
  11128. });
  11129. } else {
  11130. var group = optionalContentConfig.getGroup(
  11131. groupId);
  11132. var input = document.createElement("input");
  11133. this._bindLink(element, {
  11134. groupId: groupId,
  11135. input: input
  11136. });
  11137. input.type = "checkbox";
  11138. input.id = groupId;
  11139. input.checked = group.visible;
  11140. var label = document.createElement("label");
  11141. label.setAttribute("for", groupId);
  11142. label.textContent = this
  11143. ._normalizeTextContent(group.name);
  11144. element.appendChild(input);
  11145. element.appendChild(label);
  11146. layersCount++;
  11147. }
  11148. levelData.parent.appendChild(div);
  11149. }
  11150. } catch (err) {
  11151. _iterator.e(err);
  11152. } finally {
  11153. _iterator.f();
  11154. }
  11155. }
  11156. this._finishRendering(fragment, layersCount, hasAnyNesting);
  11157. }
  11158. }, {
  11159. key: "_resetLayers",
  11160. value: function() {
  11161. var _resetLayers2 = _asyncToGenerator( /*#__PURE__*/
  11162. _regenerator["default"].mark(function _callee2() {
  11163. var optionalContentConfig;
  11164. return _regenerator["default"].wrap(
  11165. function _callee2$(_context2) {
  11166. while (1) {
  11167. switch (_context2.prev =
  11168. _context2.next) {
  11169. case 0:
  11170. if (this
  11171. ._optionalContentConfig
  11172. ) {
  11173. _context2.next =
  11174. 2;
  11175. break;
  11176. }
  11177. return _context2
  11178. .abrupt(
  11179. "return");
  11180. case 2:
  11181. _context2.next = 4;
  11182. return this
  11183. ._pdfDocument
  11184. .getOptionalContentConfig();
  11185. case 4:
  11186. optionalContentConfig
  11187. = _context2
  11188. .sent;
  11189. this.eventBus
  11190. .dispatch(
  11191. "optionalcontentconfig", {
  11192. source: this,
  11193. promise: Promise
  11194. .resolve(
  11195. optionalContentConfig
  11196. )
  11197. });
  11198. this.render({
  11199. optionalContentConfig: optionalContentConfig,
  11200. pdfDocument: this
  11201. ._pdfDocument
  11202. });
  11203. case 7:
  11204. case "end":
  11205. return _context2
  11206. .stop();
  11207. }
  11208. }
  11209. }, _callee2, this);
  11210. }));
  11211. function _resetLayers() {
  11212. return _resetLayers2.apply(this, arguments);
  11213. }
  11214. return _resetLayers;
  11215. }()
  11216. }]);
  11217. return PDFLayerViewer;
  11218. }(_base_tree_viewer.BaseTreeViewer);
  11219. exports.PDFLayerViewer = PDFLayerViewer;
  11220. /***/
  11221. }),
  11222. /* 21 */
  11223. /***/
  11224. ((__unused_webpack_module, exports, __webpack_require__) => {
  11225. Object.defineProperty(exports, "__esModule", ({
  11226. value: true
  11227. }));
  11228. exports.PDFOutlineViewer = void 0;
  11229. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  11230. var _base_tree_viewer = __webpack_require__(14);
  11231. var _pdfjsLib = __webpack_require__(7);
  11232. var _ui_utils = __webpack_require__(5);
  11233. function _interopRequireDefault(obj) {
  11234. return obj && obj.__esModule ? obj : {
  11235. "default": obj
  11236. };
  11237. }
  11238. function _typeof(obj) {
  11239. "@babel/helpers - typeof";
  11240. return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ?
  11241. function(obj) {
  11242. return typeof obj;
  11243. } : function(obj) {
  11244. return obj && "function" == typeof Symbol && obj.constructor === Symbol &&
  11245. obj !== Symbol.prototype ? "symbol" : typeof obj;
  11246. }, _typeof(obj);
  11247. }
  11248. function _slicedToArray(arr, i) {
  11249. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) ||
  11250. _unsupportedIterableToArray(arr, i) || _nonIterableRest();
  11251. }
  11252. function _nonIterableRest() {
  11253. throw new TypeError(
  11254. "Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
  11255. );
  11256. }
  11257. function _iterableToArrayLimit(arr, i) {
  11258. var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] ||
  11259. arr["@@iterator"];
  11260. if (_i == null) return;
  11261. var _arr = [];
  11262. var _n = true;
  11263. var _d = false;
  11264. var _s, _e;
  11265. try {
  11266. for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
  11267. _arr.push(_s.value);
  11268. if (i && _arr.length === i) break;
  11269. }
  11270. } catch (err) {
  11271. _d = true;
  11272. _e = err;
  11273. } finally {
  11274. try {
  11275. if (!_n && _i["return"] != null) _i["return"]();
  11276. } finally {
  11277. if (_d) throw _e;
  11278. }
  11279. }
  11280. return _arr;
  11281. }
  11282. function _arrayWithHoles(arr) {
  11283. if (Array.isArray(arr)) return arr;
  11284. }
  11285. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  11286. try {
  11287. var info = gen[key](arg);
  11288. var value = info.value;
  11289. } catch (error) {
  11290. reject(error);
  11291. return;
  11292. }
  11293. if (info.done) {
  11294. resolve(value);
  11295. } else {
  11296. Promise.resolve(value).then(_next, _throw);
  11297. }
  11298. }
  11299. function _asyncToGenerator(fn) {
  11300. return function() {
  11301. var self = this,
  11302. args = arguments;
  11303. return new Promise(function(resolve, reject) {
  11304. var gen = fn.apply(self, args);
  11305. function _next(value) {
  11306. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next",
  11307. value);
  11308. }
  11309. function _throw(err) {
  11310. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw",
  11311. err);
  11312. }
  11313. _next(undefined);
  11314. });
  11315. };
  11316. }
  11317. function _createForOfIteratorHelper(o, allowArrayLike) {
  11318. var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
  11319. if (!it) {
  11320. if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike &&
  11321. o && typeof o.length === "number") {
  11322. if (it) o = it;
  11323. var i = 0;
  11324. var F = function F() {};
  11325. return {
  11326. s: F,
  11327. n: function n() {
  11328. if (i >= o.length) return {
  11329. done: true
  11330. };
  11331. return {
  11332. done: false,
  11333. value: o[i++]
  11334. };
  11335. },
  11336. e: function e(_e2) {
  11337. throw _e2;
  11338. },
  11339. f: F
  11340. };
  11341. }
  11342. throw new TypeError(
  11343. "Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
  11344. );
  11345. }
  11346. var normalCompletion = true,
  11347. didErr = false,
  11348. err;
  11349. return {
  11350. s: function s() {
  11351. it = it.call(o);
  11352. },
  11353. n: function n() {
  11354. var step = it.next();
  11355. normalCompletion = step.done;
  11356. return step;
  11357. },
  11358. e: function e(_e3) {
  11359. didErr = true;
  11360. err = _e3;
  11361. },
  11362. f: function f() {
  11363. try {
  11364. if (!normalCompletion && it["return"] != null) it["return"]();
  11365. } finally {
  11366. if (didErr) throw err;
  11367. }
  11368. }
  11369. };
  11370. }
  11371. function _toConsumableArray(arr) {
  11372. return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(
  11373. arr) || _nonIterableSpread();
  11374. }
  11375. function _nonIterableSpread() {
  11376. throw new TypeError(
  11377. "Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
  11378. );
  11379. }
  11380. function _unsupportedIterableToArray(o, minLen) {
  11381. if (!o) return;
  11382. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  11383. var n = Object.prototype.toString.call(o).slice(8, -1);
  11384. if (n === "Object" && o.constructor) n = o.constructor.name;
  11385. if (n === "Map" || n === "Set") return Array.from(o);
  11386. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
  11387. return _arrayLikeToArray(o, minLen);
  11388. }
  11389. function _iterableToArray(iter) {
  11390. if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter[
  11391. "@@iterator"] != null) return Array.from(iter);
  11392. }
  11393. function _arrayWithoutHoles(arr) {
  11394. if (Array.isArray(arr)) return _arrayLikeToArray(arr);
  11395. }
  11396. function _arrayLikeToArray(arr, len) {
  11397. if (len == null || len > arr.length) len = arr.length;
  11398. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  11399. arr2[i] = arr[i];
  11400. }
  11401. return arr2;
  11402. }
  11403. function _classCallCheck(instance, Constructor) {
  11404. if (!(instance instanceof Constructor)) {
  11405. throw new TypeError("Cannot call a class as a function");
  11406. }
  11407. }
  11408. function _defineProperties(target, props) {
  11409. for (var i = 0; i < props.length; i++) {
  11410. var descriptor = props[i];
  11411. descriptor.enumerable = descriptor.enumerable || false;
  11412. descriptor.configurable = true;
  11413. if ("value" in descriptor) descriptor.writable = true;
  11414. Object.defineProperty(target, descriptor.key, descriptor);
  11415. }
  11416. }
  11417. function _createClass(Constructor, protoProps, staticProps) {
  11418. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  11419. if (staticProps) _defineProperties(Constructor, staticProps);
  11420. Object.defineProperty(Constructor, "prototype", {
  11421. writable: false
  11422. });
  11423. return Constructor;
  11424. }
  11425. function _get() {
  11426. if (typeof Reflect !== "undefined" && Reflect.get) {
  11427. _get = Reflect.get;
  11428. } else {
  11429. _get = function _get(target, property, receiver) {
  11430. var base = _superPropBase(target, property);
  11431. if (!base) return;
  11432. var desc = Object.getOwnPropertyDescriptor(base, property);
  11433. if (desc.get) {
  11434. return desc.get.call(arguments.length < 3 ? target : receiver);
  11435. }
  11436. return desc.value;
  11437. };
  11438. }
  11439. return _get.apply(this, arguments);
  11440. }
  11441. function _superPropBase(object, property) {
  11442. while (!Object.prototype.hasOwnProperty.call(object, property)) {
  11443. object = _getPrototypeOf(object);
  11444. if (object === null) break;
  11445. }
  11446. return object;
  11447. }
  11448. function _inherits(subClass, superClass) {
  11449. if (typeof superClass !== "function" && superClass !== null) {
  11450. throw new TypeError("Super expression must either be null or a function");
  11451. }
  11452. subClass.prototype = Object.create(superClass && superClass.prototype, {
  11453. constructor: {
  11454. value: subClass,
  11455. writable: true,
  11456. configurable: true
  11457. }
  11458. });
  11459. Object.defineProperty(subClass, "prototype", {
  11460. writable: false
  11461. });
  11462. if (superClass) _setPrototypeOf(subClass, superClass);
  11463. }
  11464. function _setPrototypeOf(o, p) {
  11465. _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  11466. o.__proto__ = p;
  11467. return o;
  11468. };
  11469. return _setPrototypeOf(o, p);
  11470. }
  11471. function _createSuper(Derived) {
  11472. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  11473. return function _createSuperInternal() {
  11474. var Super = _getPrototypeOf(Derived),
  11475. result;
  11476. if (hasNativeReflectConstruct) {
  11477. var NewTarget = _getPrototypeOf(this).constructor;
  11478. result = Reflect.construct(Super, arguments, NewTarget);
  11479. } else {
  11480. result = Super.apply(this, arguments);
  11481. }
  11482. return _possibleConstructorReturn(this, result);
  11483. };
  11484. }
  11485. function _possibleConstructorReturn(self, call) {
  11486. if (call && (_typeof(call) === "object" || typeof call === "function")) {
  11487. return call;
  11488. } else if (call !== void 0) {
  11489. throw new TypeError("Derived constructors may only return object or undefined");
  11490. }
  11491. return _assertThisInitialized(self);
  11492. }
  11493. function _assertThisInitialized(self) {
  11494. if (self === void 0) {
  11495. throw new ReferenceError(
  11496. "this hasn't been initialised - super() hasn't been called");
  11497. }
  11498. return self;
  11499. }
  11500. function _isNativeReflectConstruct() {
  11501. if (typeof Reflect === "undefined" || !Reflect.construct) return false;
  11502. if (Reflect.construct.sham) return false;
  11503. if (typeof Proxy === "function") return true;
  11504. try {
  11505. Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
  11506. return true;
  11507. } catch (e) {
  11508. return false;
  11509. }
  11510. }
  11511. function _getPrototypeOf(o) {
  11512. _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf :
  11513. function _getPrototypeOf(o) {
  11514. return o.__proto__ || Object.getPrototypeOf(o);
  11515. };
  11516. return _getPrototypeOf(o);
  11517. }
  11518. var PDFOutlineViewer = /*#__PURE__*/ function(_BaseTreeViewer) {
  11519. _inherits(PDFOutlineViewer, _BaseTreeViewer);
  11520. var _super = _createSuper(PDFOutlineViewer);
  11521. function PDFOutlineViewer(options) {
  11522. var _this;
  11523. _classCallCheck(this, PDFOutlineViewer);
  11524. _this = _super.call(this, options);
  11525. _this.linkService = options.linkService;
  11526. _this.eventBus._on("toggleoutlinetree", _this._toggleAllTreeItems.bind(
  11527. _assertThisInitialized(_this)));
  11528. _this.eventBus._on("currentoutlineitem", _this._currentOutlineItem.bind(
  11529. _assertThisInitialized(_this)));
  11530. _this.eventBus._on("pagechanging", function(evt) {
  11531. _this._currentPageNumber = evt.pageNumber;
  11532. });
  11533. _this.eventBus._on("pagesloaded", function(evt) {
  11534. _this._isPagesLoaded = !!evt.pagesCount;
  11535. if (_this._currentOutlineItemCapability && !_this
  11536. ._currentOutlineItemCapability.settled) {
  11537. _this._currentOutlineItemCapability.resolve(_this
  11538. ._isPagesLoaded);
  11539. }
  11540. });
  11541. _this.eventBus._on("sidebarviewchanged", function(evt) {
  11542. _this._sidebarView = evt.view;
  11543. });
  11544. return _this;
  11545. }
  11546. _createClass(PDFOutlineViewer, [{
  11547. key: "reset",
  11548. value: function reset() {
  11549. _get(_getPrototypeOf(PDFOutlineViewer.prototype), "reset",
  11550. this).call(this);
  11551. this._outline = null;
  11552. this._pageNumberToDestHashCapability = null;
  11553. this._currentPageNumber = 1;
  11554. this._isPagesLoaded = null;
  11555. if (this._currentOutlineItemCapability && !this
  11556. ._currentOutlineItemCapability.settled) {
  11557. this._currentOutlineItemCapability.resolve(false);
  11558. }
  11559. this._currentOutlineItemCapability = null;
  11560. }
  11561. }, {
  11562. key: "_dispatchEvent",
  11563. value: function _dispatchEvent(outlineCount) {
  11564. var _this$_pdfDocument;
  11565. this._currentOutlineItemCapability = (0, _pdfjsLib
  11566. .createPromiseCapability)();
  11567. if (outlineCount === 0 || (_this$_pdfDocument = this
  11568. ._pdfDocument) !== null && _this$_pdfDocument !==
  11569. void 0 && _this$_pdfDocument.loadingParams
  11570. .disableAutoFetch) {
  11571. this._currentOutlineItemCapability.resolve(false);
  11572. } else if (this._isPagesLoaded !== null) {
  11573. this._currentOutlineItemCapability.resolve(this
  11574. ._isPagesLoaded);
  11575. }
  11576. this.eventBus.dispatch("outlineloaded", {
  11577. source: this,
  11578. outlineCount: outlineCount,
  11579. currentOutlineItemPromise: this
  11580. ._currentOutlineItemCapability.promise
  11581. });
  11582. }
  11583. }, {
  11584. key: "_bindLink",
  11585. value: function _bindLink(element, _ref) {
  11586. var _this2 = this;
  11587. var url = _ref.url,
  11588. newWindow = _ref.newWindow,
  11589. dest = _ref.dest;
  11590. var linkService = this.linkService;
  11591. if (url) {
  11592. linkService.addLinkAttributes(element, url, newWindow);
  11593. return;
  11594. }
  11595. element.href = linkService.getDestinationHash(dest);
  11596. element.onclick = function(evt) {
  11597. _this2._updateCurrentTreeItem(evt.target
  11598. .parentNode);
  11599. if (dest) {
  11600. linkService.goToDestination(dest);
  11601. }
  11602. return false;
  11603. };
  11604. }
  11605. }, {
  11606. key: "_setStyles",
  11607. value: function _setStyles(element, _ref2) {
  11608. var bold = _ref2.bold,
  11609. italic = _ref2.italic;
  11610. if (bold) {
  11611. element.style.fontWeight = "bold";
  11612. }
  11613. if (italic) {
  11614. element.style.fontStyle = "italic";
  11615. }
  11616. }
  11617. }, {
  11618. key: "_addToggleButton",
  11619. value: function _addToggleButton(div, _ref3) {
  11620. var count = _ref3.count,
  11621. items = _ref3.items;
  11622. var hidden = false;
  11623. if (count < 0) {
  11624. var totalCount = items.length;
  11625. if (totalCount > 0) {
  11626. var queue = _toConsumableArray(items);
  11627. while (queue.length > 0) {
  11628. var _queue$shift = queue.shift(),
  11629. nestedCount = _queue$shift.count,
  11630. nestedItems = _queue$shift.items;
  11631. if (nestedCount > 0 && nestedItems.length > 0) {
  11632. totalCount += nestedItems.length;
  11633. queue.push.apply(queue, _toConsumableArray(
  11634. nestedItems));
  11635. }
  11636. }
  11637. }
  11638. if (Math.abs(count) === totalCount) {
  11639. hidden = true;
  11640. }
  11641. }
  11642. _get(_getPrototypeOf(PDFOutlineViewer.prototype),
  11643. "_addToggleButton", this).call(this, div, hidden);
  11644. }
  11645. }, {
  11646. key: "_toggleAllTreeItems",
  11647. value: function _toggleAllTreeItems() {
  11648. if (!this._outline) {
  11649. return;
  11650. }
  11651. _get(_getPrototypeOf(PDFOutlineViewer.prototype),
  11652. "_toggleAllTreeItems", this).call(this);
  11653. }
  11654. }, {
  11655. key: "render",
  11656. value: function render(_ref4) {
  11657. var outline = _ref4.outline,
  11658. pdfDocument = _ref4.pdfDocument;
  11659. if (this._outline) {
  11660. this.reset();
  11661. }
  11662. this._outline = outline || null;
  11663. this._pdfDocument = pdfDocument || null;
  11664. if (!outline) {
  11665. this._dispatchEvent(0);
  11666. return;
  11667. }
  11668. var fragment = document.createDocumentFragment();
  11669. var queue = [{
  11670. parent: fragment,
  11671. items: outline
  11672. }];
  11673. var outlineCount = 0,
  11674. hasAnyNesting = false;
  11675. while (queue.length > 0) {
  11676. var levelData = queue.shift();
  11677. var _iterator = _createForOfIteratorHelper(levelData
  11678. .items),
  11679. _step;
  11680. try {
  11681. for (_iterator.s(); !(_step = _iterator.n())
  11682. .done;) {
  11683. var item = _step.value;
  11684. var div = document.createElement("div");
  11685. div.className = "treeItem";
  11686. var element = document.createElement("a");
  11687. this._bindLink(element, item);
  11688. this._setStyles(element, item);
  11689. element.textContent = this
  11690. ._normalizeTextContent(item.title);
  11691. div.appendChild(element);
  11692. if (item.items.length > 0) {
  11693. hasAnyNesting = true;
  11694. this._addToggleButton(div, item);
  11695. var itemsDiv = document.createElement(
  11696. "div");
  11697. itemsDiv.className = "treeItems";
  11698. div.appendChild(itemsDiv);
  11699. queue.push({
  11700. parent: itemsDiv,
  11701. items: item.items
  11702. });
  11703. }
  11704. levelData.parent.appendChild(div);
  11705. outlineCount++;
  11706. }
  11707. } catch (err) {
  11708. _iterator.e(err);
  11709. } finally {
  11710. _iterator.f();
  11711. }
  11712. }
  11713. this._finishRendering(fragment, outlineCount,
  11714. hasAnyNesting);
  11715. }
  11716. }, {
  11717. key: "_currentOutlineItem",
  11718. value: function() {
  11719. var _currentOutlineItem2 = _asyncToGenerator( /*#__PURE__*/
  11720. _regenerator["default"].mark(function _callee() {
  11721. var pageNumberToDestHash, i, destHash,
  11722. linkElement;
  11723. return _regenerator["default"].wrap(
  11724. function _callee$(_context) {
  11725. while (1) {
  11726. switch (_context.prev =
  11727. _context.next) {
  11728. case 0:
  11729. if (this
  11730. ._isPagesLoaded
  11731. ) {
  11732. _context.next =
  11733. 2;
  11734. break;
  11735. }
  11736. throw new Error(
  11737. "_currentOutlineItem: All pages have not been loaded."
  11738. );
  11739. case 2:
  11740. if (!(!this
  11741. ._outline ||
  11742. !this
  11743. ._pdfDocument
  11744. )) {
  11745. _context.next =
  11746. 4;
  11747. break;
  11748. }
  11749. return _context
  11750. .abrupt(
  11751. "return");
  11752. case 4:
  11753. _context.next = 6;
  11754. return this
  11755. ._getPageNumberToDestHash(
  11756. this
  11757. ._pdfDocument
  11758. );
  11759. case 6:
  11760. pageNumberToDestHash
  11761. = _context.sent;
  11762. if (
  11763. pageNumberToDestHash) {
  11764. _context.next =
  11765. 9;
  11766. break;
  11767. }
  11768. return _context
  11769. .abrupt(
  11770. "return");
  11771. case 9:
  11772. this._updateCurrentTreeItem(
  11773. null);
  11774. if (!(this
  11775. ._sidebarView !==
  11776. _ui_utils
  11777. .SidebarView
  11778. .OUTLINE)) {
  11779. _context.next =
  11780. 12;
  11781. break;
  11782. }
  11783. return _context
  11784. .abrupt(
  11785. "return");
  11786. case 12:
  11787. i = this
  11788. ._currentPageNumber;
  11789. case 13:
  11790. if (!(i > 0)) {
  11791. _context.next =
  11792. 25;
  11793. break;
  11794. }
  11795. destHash =
  11796. pageNumberToDestHash
  11797. .get(i);
  11798. if (destHash) {
  11799. _context.next =
  11800. 17;
  11801. break;
  11802. }
  11803. return _context
  11804. .abrupt(
  11805. "continue",
  11806. 22);
  11807. case 17:
  11808. linkElement = this
  11809. .container
  11810. .querySelector(
  11811. "a[href=\""
  11812. .concat(
  11813. destHash,
  11814. "\"]"));
  11815. if (linkElement) {
  11816. _context.next =
  11817. 20;
  11818. break;
  11819. }
  11820. return _context
  11821. .abrupt(
  11822. "continue",
  11823. 22);
  11824. case 20:
  11825. this._scrollToCurrentTreeItem(
  11826. linkElement
  11827. .parentNode);
  11828. return _context
  11829. .abrupt("break",
  11830. 25);
  11831. case 22:
  11832. i--;
  11833. _context.next = 13;
  11834. break;
  11835. case 25:
  11836. case "end":
  11837. return _context
  11838. .stop();
  11839. }
  11840. }
  11841. }, _callee, this);
  11842. }));
  11843. function _currentOutlineItem() {
  11844. return _currentOutlineItem2.apply(this, arguments);
  11845. }
  11846. return _currentOutlineItem;
  11847. }()
  11848. }, {
  11849. key: "_getPageNumberToDestHash",
  11850. value: function() {
  11851. var _getPageNumberToDestHash2 =
  11852. _asyncToGenerator( /*#__PURE__*/ _regenerator["default"]
  11853. .mark(function _callee2(pdfDocument) {
  11854. var pageNumberToDestHash, pageNumberNesting,
  11855. queue, levelData, currentNesting,
  11856. _iterator2, _step2, _step2$value, dest,
  11857. items, explicitDest, pageNumber,
  11858. _explicitDest, _explicitDest2, destRef,
  11859. destHash;
  11860. return _regenerator["default"].wrap(
  11861. function _callee2$(_context2) {
  11862. while (1) {
  11863. switch (_context2.prev =
  11864. _context2.next) {
  11865. case 0:
  11866. if (!this
  11867. ._pageNumberToDestHashCapability
  11868. ) {
  11869. _context2.next =
  11870. 2;
  11871. break;
  11872. }
  11873. return _context2
  11874. .abrupt(
  11875. "return",
  11876. this
  11877. ._pageNumberToDestHashCapability
  11878. .promise);
  11879. case 2:
  11880. this._pageNumberToDestHashCapability =
  11881. (0, _pdfjsLib
  11882. .createPromiseCapability
  11883. )();
  11884. pageNumberToDestHash
  11885. = new Map(),
  11886. pageNumberNesting =
  11887. new Map();
  11888. queue = [{
  11889. nesting: 0,
  11890. items: this
  11891. ._outline
  11892. }];
  11893. case 5:
  11894. if (!(queue.length >
  11895. 0)) {
  11896. _context2.next =
  11897. 56;
  11898. break;
  11899. }
  11900. levelData = queue
  11901. .shift(),
  11902. currentNesting =
  11903. levelData
  11904. .nesting;
  11905. _iterator2 =
  11906. _createForOfIteratorHelper(
  11907. levelData
  11908. .items);
  11909. _context2.prev = 8;
  11910. _iterator2.s();
  11911. case 10:
  11912. if ((_step2 =
  11913. _iterator2
  11914. .n())
  11915. .done) {
  11916. _context2.next =
  11917. 46;
  11918. break;
  11919. }
  11920. _step2$value =
  11921. _step2.value,
  11922. dest =
  11923. _step2$value
  11924. .dest, items =
  11925. _step2$value
  11926. .items;
  11927. explicitDest =
  11928. void 0,
  11929. pageNumber =
  11930. void 0;
  11931. if (!(typeof dest ===
  11932. "string")) {
  11933. _context2.next =
  11934. 21;
  11935. break;
  11936. }
  11937. _context2.next = 16;
  11938. return pdfDocument
  11939. .getDestination(
  11940. dest);
  11941. case 16:
  11942. explicitDest =
  11943. _context2.sent;
  11944. if (!(pdfDocument !==
  11945. this
  11946. ._pdfDocument
  11947. )) {
  11948. _context2.next =
  11949. 19;
  11950. break;
  11951. }
  11952. return _context2
  11953. .abrupt(
  11954. "return",
  11955. null);
  11956. case 19:
  11957. _context2.next = 22;
  11958. break;
  11959. case 21:
  11960. explicitDest = dest;
  11961. case 22:
  11962. if (!Array.isArray(
  11963. explicitDest
  11964. )) {
  11965. _context2.next =
  11966. 43;
  11967. break;
  11968. }
  11969. _explicitDest =
  11970. explicitDest,
  11971. _explicitDest2 =
  11972. _slicedToArray(
  11973. _explicitDest,
  11974. 1),
  11975. destRef =
  11976. _explicitDest2[
  11977. 0];
  11978. if (!(_typeof(
  11979. destRef
  11980. ) ===
  11981. "object" &&
  11982. destRef !==
  11983. null)) {
  11984. _context2.next =
  11985. 41;
  11986. break;
  11987. }
  11988. pageNumber = this
  11989. .linkService
  11990. ._cachedPageNumber(
  11991. destRef);
  11992. if (pageNumber) {
  11993. _context2.next =
  11994. 39;
  11995. break;
  11996. }
  11997. _context2.prev = 27;
  11998. _context2.next = 30;
  11999. return pdfDocument
  12000. .getPageIndex(
  12001. destRef);
  12002. case 30:
  12003. _context2.t0 =
  12004. _context2.sent;
  12005. pageNumber =
  12006. _context2.t0 +
  12007. 1;
  12008. if (!(pdfDocument !==
  12009. this
  12010. ._pdfDocument
  12011. )) {
  12012. _context2.next =
  12013. 34;
  12014. break;
  12015. }
  12016. return _context2
  12017. .abrupt(
  12018. "return",
  12019. null);
  12020. case 34:
  12021. this.linkService
  12022. .cachePageRef(
  12023. pageNumber,
  12024. destRef);
  12025. _context2.next = 39;
  12026. break;
  12027. case 37:
  12028. _context2.prev = 37;
  12029. _context2.t1 =
  12030. _context2[
  12031. "catch"](
  12032. 27);
  12033. case 39:
  12034. _context2.next = 42;
  12035. break;
  12036. case 41:
  12037. if (Number
  12038. .isInteger(
  12039. destRef)) {
  12040. pageNumber =
  12041. destRef + 1;
  12042. }
  12043. case 42:
  12044. if (Number
  12045. .isInteger(
  12046. pageNumber
  12047. ) && (!
  12048. pageNumberToDestHash
  12049. .has(
  12050. pageNumber
  12051. ) ||
  12052. currentNesting >
  12053. pageNumberNesting
  12054. .get(
  12055. pageNumber
  12056. ))
  12057. ) {
  12058. destHash =
  12059. this
  12060. .linkService
  12061. .getDestinationHash(
  12062. dest
  12063. );
  12064. pageNumberToDestHash
  12065. .set(
  12066. pageNumber,
  12067. destHash
  12068. );
  12069. pageNumberNesting
  12070. .set(
  12071. pageNumber,
  12072. currentNesting
  12073. );
  12074. }
  12075. case 43:
  12076. if (items
  12077. .length >
  12078. 0) {
  12079. queue
  12080. .push({
  12081. nesting: currentNesting +
  12082. 1,
  12083. items: items
  12084. });
  12085. }
  12086. case 44:
  12087. _context2
  12088. .next =
  12089. 10;
  12090. break;
  12091. case 46:
  12092. _context2
  12093. .next =
  12094. 51;
  12095. break;
  12096. case 48:
  12097. _context2
  12098. .prev =
  12099. 48;
  12100. _context2
  12101. .t2 =
  12102. _context2[
  12103. "catch"
  12104. ]
  12105. (8);
  12106. _iterator2
  12107. .e(_context2
  12108. .t2
  12109. );
  12110. case 51:
  12111. _context2
  12112. .prev =
  12113. 51;
  12114. _iterator2
  12115. .f();
  12116. return _context2
  12117. .finish(
  12118. 51
  12119. );
  12120. case 54:
  12121. _context2
  12122. .next =
  12123. 5;
  12124. break;
  12125. case 56:
  12126. this._pageNumberToDestHashCapability
  12127. .resolve(
  12128. pageNumberToDestHash
  12129. .size >
  12130. 0 ?
  12131. pageNumberToDestHash :
  12132. null
  12133. );
  12134. return _context2
  12135. .abrupt(
  12136. "return",
  12137. this
  12138. ._pageNumberToDestHashCapability
  12139. .promise
  12140. );
  12141. case 58:
  12142. case "end":
  12143. return _context2
  12144. .stop();
  12145. }
  12146. }
  12147. }, _callee2, this, [
  12148. [8, 48, 51, 54],
  12149. [27, 37]
  12150. ]);
  12151. }));
  12152. function _getPageNumberToDestHash(_x) {
  12153. return _getPageNumberToDestHash2.apply(this, arguments);
  12154. }
  12155. return _getPageNumberToDestHash;
  12156. }()
  12157. }]);
  12158. return PDFOutlineViewer;
  12159. }(_base_tree_viewer.BaseTreeViewer);
  12160. exports.PDFOutlineViewer = PDFOutlineViewer;
  12161. /***/
  12162. }),
  12163. /* 22 */
  12164. /***/
  12165. ((__unused_webpack_module, exports, __webpack_require__) => {
  12166. Object.defineProperty(exports, "__esModule", ({
  12167. value: true
  12168. }));
  12169. exports.PDFPresentationMode = void 0;
  12170. var _ui_utils = __webpack_require__(5);
  12171. function _classCallCheck(instance, Constructor) {
  12172. if (!(instance instanceof Constructor)) {
  12173. throw new TypeError("Cannot call a class as a function");
  12174. }
  12175. }
  12176. function _defineProperties(target, props) {
  12177. for (var i = 0; i < props.length; i++) {
  12178. var descriptor = props[i];
  12179. descriptor.enumerable = descriptor.enumerable || false;
  12180. descriptor.configurable = true;
  12181. if ("value" in descriptor) descriptor.writable = true;
  12182. Object.defineProperty(target, descriptor.key, descriptor);
  12183. }
  12184. }
  12185. function _createClass(Constructor, protoProps, staticProps) {
  12186. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  12187. if (staticProps) _defineProperties(Constructor, staticProps);
  12188. Object.defineProperty(Constructor, "prototype", {
  12189. writable: false
  12190. });
  12191. return Constructor;
  12192. }
  12193. function _classPrivateMethodInitSpec(obj, privateSet) {
  12194. _checkPrivateRedeclaration(obj, privateSet);
  12195. privateSet.add(obj);
  12196. }
  12197. function _checkPrivateRedeclaration(obj, privateCollection) {
  12198. if (privateCollection.has(obj)) {
  12199. throw new TypeError(
  12200. "Cannot initialize the same private elements twice on an object");
  12201. }
  12202. }
  12203. function _classPrivateMethodGet(receiver, privateSet, fn) {
  12204. if (!privateSet.has(receiver)) {
  12205. throw new TypeError("attempted to get private field on non-instance");
  12206. }
  12207. return fn;
  12208. }
  12209. var DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1500;
  12210. var DELAY_BEFORE_HIDING_CONTROLS = 3000;
  12211. var ACTIVE_SELECTOR = "pdfPresentationMode";
  12212. var CONTROLS_SELECTOR = "pdfPresentationModeControls";
  12213. var MOUSE_SCROLL_COOLDOWN_TIME = 50;
  12214. var PAGE_SWITCH_THRESHOLD = 0.1;
  12215. var SWIPE_MIN_DISTANCE_THRESHOLD = 50;
  12216. var SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
  12217. var _mouseWheel = /*#__PURE__*/ new WeakSet();
  12218. var _notifyStateChange = /*#__PURE__*/ new WeakSet();
  12219. var _setSwitchInProgress = /*#__PURE__*/ new WeakSet();
  12220. var _resetSwitchInProgress = /*#__PURE__*/ new WeakSet();
  12221. var _enter = /*#__PURE__*/ new WeakSet();
  12222. var _exit = /*#__PURE__*/ new WeakSet();
  12223. var _mouseDown = /*#__PURE__*/ new WeakSet();
  12224. var _contextMenu = /*#__PURE__*/ new WeakSet();
  12225. var _showControls = /*#__PURE__*/ new WeakSet();
  12226. var _hideControls = /*#__PURE__*/ new WeakSet();
  12227. var _resetMouseScrollState = /*#__PURE__*/ new WeakSet();
  12228. var _touchSwipe = /*#__PURE__*/ new WeakSet();
  12229. var _addWindowListeners = /*#__PURE__*/ new WeakSet();
  12230. var _removeWindowListeners = /*#__PURE__*/ new WeakSet();
  12231. var _fullscreenChange = /*#__PURE__*/ new WeakSet();
  12232. var _addFullscreenChangeListeners = /*#__PURE__*/ new WeakSet();
  12233. var _removeFullscreenChangeListeners = /*#__PURE__*/ new WeakSet();
  12234. var PDFPresentationMode = /*#__PURE__*/ function() {
  12235. function PDFPresentationMode(_ref) {
  12236. var container = _ref.container,
  12237. pdfViewer = _ref.pdfViewer,
  12238. eventBus = _ref.eventBus;
  12239. _classCallCheck(this, PDFPresentationMode);
  12240. _classPrivateMethodInitSpec(this, _removeFullscreenChangeListeners);
  12241. _classPrivateMethodInitSpec(this, _addFullscreenChangeListeners);
  12242. _classPrivateMethodInitSpec(this, _fullscreenChange);
  12243. _classPrivateMethodInitSpec(this, _removeWindowListeners);
  12244. _classPrivateMethodInitSpec(this, _addWindowListeners);
  12245. _classPrivateMethodInitSpec(this, _touchSwipe);
  12246. _classPrivateMethodInitSpec(this, _resetMouseScrollState);
  12247. _classPrivateMethodInitSpec(this, _hideControls);
  12248. _classPrivateMethodInitSpec(this, _showControls);
  12249. _classPrivateMethodInitSpec(this, _contextMenu);
  12250. _classPrivateMethodInitSpec(this, _mouseDown);
  12251. _classPrivateMethodInitSpec(this, _exit);
  12252. _classPrivateMethodInitSpec(this, _enter);
  12253. _classPrivateMethodInitSpec(this, _resetSwitchInProgress);
  12254. _classPrivateMethodInitSpec(this, _setSwitchInProgress);
  12255. _classPrivateMethodInitSpec(this, _notifyStateChange);
  12256. _classPrivateMethodInitSpec(this, _mouseWheel);
  12257. this.container = container;
  12258. this.pdfViewer = pdfViewer;
  12259. this.eventBus = eventBus;
  12260. this.active = false;
  12261. this.args = null;
  12262. this.contextMenuOpen = false;
  12263. this.mouseScrollTimeStamp = 0;
  12264. this.mouseScrollDelta = 0;
  12265. this.touchSwipeState = null;
  12266. }
  12267. _createClass(PDFPresentationMode, [{
  12268. key: "request",
  12269. value: function request() {
  12270. if (this.switchInProgress || this.active || !this.pdfViewer
  12271. .pagesCount || !this.container.requestFullscreen) {
  12272. return false;
  12273. }
  12274. _classPrivateMethodGet(this, _addFullscreenChangeListeners,
  12275. _addFullscreenChangeListeners2).call(this);
  12276. _classPrivateMethodGet(this, _setSwitchInProgress,
  12277. _setSwitchInProgress2).call(this);
  12278. _classPrivateMethodGet(this, _notifyStateChange,
  12279. _notifyStateChange2).call(this);
  12280. this.container.requestFullscreen();
  12281. this.args = {
  12282. pageNumber: this.pdfViewer.currentPageNumber,
  12283. scaleValue: this.pdfViewer.currentScaleValue,
  12284. scrollMode: this.pdfViewer.scrollMode,
  12285. spreadMode: this.pdfViewer.spreadMode
  12286. };
  12287. return true;
  12288. }
  12289. }]);
  12290. return PDFPresentationMode;
  12291. }();
  12292. exports.PDFPresentationMode = PDFPresentationMode;
  12293. function _mouseWheel2(evt) {
  12294. if (!this.active) {
  12295. return;
  12296. }
  12297. evt.preventDefault();
  12298. var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
  12299. var currentTime = Date.now();
  12300. var storedTime = this.mouseScrollTimeStamp;
  12301. if (currentTime > storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {
  12302. return;
  12303. }
  12304. if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) {
  12305. _classPrivateMethodGet(this, _resetMouseScrollState, _resetMouseScrollState2).call(
  12306. this);
  12307. }
  12308. this.mouseScrollDelta += delta;
  12309. if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
  12310. var totalDelta = this.mouseScrollDelta;
  12311. _classPrivateMethodGet(this, _resetMouseScrollState, _resetMouseScrollState2).call(
  12312. this);
  12313. var success = totalDelta > 0 ? this.pdfViewer.previousPage() : this.pdfViewer
  12314. .nextPage();
  12315. if (success) {
  12316. this.mouseScrollTimeStamp = currentTime;
  12317. }
  12318. }
  12319. }
  12320. function _notifyStateChange2() {
  12321. var state = _ui_utils.PresentationModeState.NORMAL;
  12322. if (this.switchInProgress) {
  12323. state = _ui_utils.PresentationModeState.CHANGING;
  12324. } else if (this.active) {
  12325. state = _ui_utils.PresentationModeState.FULLSCREEN;
  12326. }
  12327. this.eventBus.dispatch("presentationmodechanged", {
  12328. source: this,
  12329. state: state
  12330. });
  12331. }
  12332. function _setSwitchInProgress2() {
  12333. var _this = this;
  12334. if (this.switchInProgress) {
  12335. clearTimeout(this.switchInProgress);
  12336. }
  12337. this.switchInProgress = setTimeout(function() {
  12338. _classPrivateMethodGet(_this, _removeFullscreenChangeListeners,
  12339. _removeFullscreenChangeListeners2).call(_this);
  12340. delete _this.switchInProgress;
  12341. _classPrivateMethodGet(_this, _notifyStateChange, _notifyStateChange2).call(
  12342. _this);
  12343. }, DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS);
  12344. }
  12345. function _resetSwitchInProgress2() {
  12346. if (this.switchInProgress) {
  12347. clearTimeout(this.switchInProgress);
  12348. delete this.switchInProgress;
  12349. }
  12350. }
  12351. function _enter2() {
  12352. var _this2 = this;
  12353. this.active = true;
  12354. _classPrivateMethodGet(this, _resetSwitchInProgress, _resetSwitchInProgress2).call(
  12355. this);
  12356. _classPrivateMethodGet(this, _notifyStateChange, _notifyStateChange2).call(this);
  12357. this.container.classList.add(ACTIVE_SELECTOR);
  12358. setTimeout(function() {
  12359. _this2.pdfViewer.scrollMode = _ui_utils.ScrollMode.PAGE;
  12360. _this2.pdfViewer.spreadMode = _ui_utils.SpreadMode.NONE;
  12361. _this2.pdfViewer.currentPageNumber = _this2.args.pageNumber;
  12362. _this2.pdfViewer.currentScaleValue = "page-fit";
  12363. }, 0);
  12364. _classPrivateMethodGet(this, _addWindowListeners, _addWindowListeners2).call(this);
  12365. _classPrivateMethodGet(this, _showControls, _showControls2).call(this);
  12366. this.contextMenuOpen = false;
  12367. window.getSelection().removeAllRanges();
  12368. }
  12369. function _exit2() {
  12370. var _this3 = this;
  12371. var pageNumber = this.pdfViewer.currentPageNumber;
  12372. this.container.classList.remove(ACTIVE_SELECTOR);
  12373. setTimeout(function() {
  12374. _this3.active = false;
  12375. _classPrivateMethodGet(_this3, _removeFullscreenChangeListeners,
  12376. _removeFullscreenChangeListeners2).call(_this3);
  12377. _classPrivateMethodGet(_this3, _notifyStateChange, _notifyStateChange2)
  12378. .call(_this3);
  12379. _this3.pdfViewer.scrollMode = _this3.args.scrollMode;
  12380. _this3.pdfViewer.spreadMode = _this3.args.spreadMode;
  12381. _this3.pdfViewer.currentScaleValue = _this3.args.scaleValue;
  12382. _this3.pdfViewer.currentPageNumber = pageNumber;
  12383. _this3.args = null;
  12384. }, 0);
  12385. _classPrivateMethodGet(this, _removeWindowListeners, _removeWindowListeners2).call(
  12386. this);
  12387. _classPrivateMethodGet(this, _hideControls, _hideControls2).call(this);
  12388. _classPrivateMethodGet(this, _resetMouseScrollState, _resetMouseScrollState2).call(
  12389. this);
  12390. this.contextMenuOpen = false;
  12391. }
  12392. function _mouseDown2(evt) {
  12393. if (this.contextMenuOpen) {
  12394. this.contextMenuOpen = false;
  12395. evt.preventDefault();
  12396. return;
  12397. }
  12398. if (evt.button === 0) {
  12399. var isInternalLink = evt.target.href && evt.target.classList.contains(
  12400. "internalLink");
  12401. if (!isInternalLink) {
  12402. evt.preventDefault();
  12403. if (evt.shiftKey) {
  12404. this.pdfViewer.previousPage();
  12405. } else {
  12406. this.pdfViewer.nextPage();
  12407. }
  12408. }
  12409. }
  12410. }
  12411. function _contextMenu2() {
  12412. this.contextMenuOpen = true;
  12413. }
  12414. function _showControls2() {
  12415. var _this4 = this;
  12416. if (this.controlsTimeout) {
  12417. clearTimeout(this.controlsTimeout);
  12418. } else {
  12419. this.container.classList.add(CONTROLS_SELECTOR);
  12420. }
  12421. this.controlsTimeout = setTimeout(function() {
  12422. _this4.container.classList.remove(CONTROLS_SELECTOR);
  12423. delete _this4.controlsTimeout;
  12424. }, DELAY_BEFORE_HIDING_CONTROLS);
  12425. }
  12426. function _hideControls2() {
  12427. if (!this.controlsTimeout) {
  12428. return;
  12429. }
  12430. clearTimeout(this.controlsTimeout);
  12431. this.container.classList.remove(CONTROLS_SELECTOR);
  12432. delete this.controlsTimeout;
  12433. }
  12434. function _resetMouseScrollState2() {
  12435. this.mouseScrollTimeStamp = 0;
  12436. this.mouseScrollDelta = 0;
  12437. }
  12438. function _touchSwipe2(evt) {
  12439. if (!this.active) {
  12440. return;
  12441. }
  12442. if (evt.touches.length > 1) {
  12443. this.touchSwipeState = null;
  12444. return;
  12445. }
  12446. switch (evt.type) {
  12447. case "touchstart":
  12448. this.touchSwipeState = {
  12449. startX: evt.touches[0].pageX,
  12450. startY: evt.touches[0].pageY,
  12451. endX: evt.touches[0].pageX,
  12452. endY: evt.touches[0].pageY
  12453. };
  12454. break;
  12455. case "touchmove":
  12456. if (this.touchSwipeState === null) {
  12457. return;
  12458. }
  12459. this.touchSwipeState.endX = evt.touches[0].pageX;
  12460. this.touchSwipeState.endY = evt.touches[0].pageY;
  12461. evt.preventDefault();
  12462. break;
  12463. case "touchend":
  12464. if (this.touchSwipeState === null) {
  12465. return;
  12466. }
  12467. var delta = 0;
  12468. var dx = this.touchSwipeState.endX - this.touchSwipeState.startX;
  12469. var dy = this.touchSwipeState.endY - this.touchSwipeState.startY;
  12470. var absAngle = Math.abs(Math.atan2(dy, dx));
  12471. if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <=
  12472. SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI - SWIPE_ANGLE_THRESHOLD)) {
  12473. delta = dx;
  12474. } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math.abs(absAngle -
  12475. Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) {
  12476. delta = dy;
  12477. }
  12478. if (delta > 0) {
  12479. this.pdfViewer.previousPage();
  12480. } else if (delta < 0) {
  12481. this.pdfViewer.nextPage();
  12482. }
  12483. break;
  12484. }
  12485. }
  12486. function _addWindowListeners2() {
  12487. this.showControlsBind = _classPrivateMethodGet(this, _showControls, _showControls2)
  12488. .bind(this);
  12489. this.mouseDownBind = _classPrivateMethodGet(this, _mouseDown, _mouseDown2).bind(this);
  12490. this.mouseWheelBind = _classPrivateMethodGet(this, _mouseWheel, _mouseWheel2).bind(
  12491. this);
  12492. this.resetMouseScrollStateBind = _classPrivateMethodGet(this, _resetMouseScrollState,
  12493. _resetMouseScrollState2).bind(this);
  12494. this.contextMenuBind = _classPrivateMethodGet(this, _contextMenu, _contextMenu2).bind(
  12495. this);
  12496. this.touchSwipeBind = _classPrivateMethodGet(this, _touchSwipe, _touchSwipe2).bind(
  12497. this);
  12498. window.addEventListener("mousemove", this.showControlsBind);
  12499. window.addEventListener("mousedown", this.mouseDownBind);
  12500. window.addEventListener("wheel", this.mouseWheelBind, {
  12501. passive: false
  12502. });
  12503. window.addEventListener("keydown", this.resetMouseScrollStateBind);
  12504. window.addEventListener("contextmenu", this.contextMenuBind);
  12505. window.addEventListener("touchstart", this.touchSwipeBind);
  12506. window.addEventListener("touchmove", this.touchSwipeBind);
  12507. window.addEventListener("touchend", this.touchSwipeBind);
  12508. }
  12509. function _removeWindowListeners2() {
  12510. window.removeEventListener("mousemove", this.showControlsBind);
  12511. window.removeEventListener("mousedown", this.mouseDownBind);
  12512. window.removeEventListener("wheel", this.mouseWheelBind, {
  12513. passive: false
  12514. });
  12515. window.removeEventListener("keydown", this.resetMouseScrollStateBind);
  12516. window.removeEventListener("contextmenu", this.contextMenuBind);
  12517. window.removeEventListener("touchstart", this.touchSwipeBind);
  12518. window.removeEventListener("touchmove", this.touchSwipeBind);
  12519. window.removeEventListener("touchend", this.touchSwipeBind);
  12520. delete this.showControlsBind;
  12521. delete this.mouseDownBind;
  12522. delete this.mouseWheelBind;
  12523. delete this.resetMouseScrollStateBind;
  12524. delete this.contextMenuBind;
  12525. delete this.touchSwipeBind;
  12526. }
  12527. function _fullscreenChange2() {
  12528. if (document.fullscreenElement) {
  12529. _classPrivateMethodGet(this, _enter, _enter2).call(this);
  12530. } else {
  12531. _classPrivateMethodGet(this, _exit, _exit2).call(this);
  12532. }
  12533. }
  12534. function _addFullscreenChangeListeners2() {
  12535. this.fullscreenChangeBind = _classPrivateMethodGet(this, _fullscreenChange,
  12536. _fullscreenChange2).bind(this);
  12537. window.addEventListener("fullscreenchange", this.fullscreenChangeBind);
  12538. }
  12539. function _removeFullscreenChangeListeners2() {
  12540. window.removeEventListener("fullscreenchange", this.fullscreenChangeBind);
  12541. delete this.fullscreenChangeBind;
  12542. }
  12543. /***/
  12544. }),
  12545. /* 23 */
  12546. /***/
  12547. ((__unused_webpack_module, exports, __webpack_require__) => {
  12548. Object.defineProperty(exports, "__esModule", ({
  12549. value: true
  12550. }));
  12551. exports.PDFRenderingQueue = void 0;
  12552. var _pdfjsLib = __webpack_require__(7);
  12553. var _ui_utils = __webpack_require__(5);
  12554. function _classCallCheck(instance, Constructor) {
  12555. if (!(instance instanceof Constructor)) {
  12556. throw new TypeError("Cannot call a class as a function");
  12557. }
  12558. }
  12559. function _defineProperties(target, props) {
  12560. for (var i = 0; i < props.length; i++) {
  12561. var descriptor = props[i];
  12562. descriptor.enumerable = descriptor.enumerable || false;
  12563. descriptor.configurable = true;
  12564. if ("value" in descriptor) descriptor.writable = true;
  12565. Object.defineProperty(target, descriptor.key, descriptor);
  12566. }
  12567. }
  12568. function _createClass(Constructor, protoProps, staticProps) {
  12569. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  12570. if (staticProps) _defineProperties(Constructor, staticProps);
  12571. Object.defineProperty(Constructor, "prototype", {
  12572. writable: false
  12573. });
  12574. return Constructor;
  12575. }
  12576. var CLEANUP_TIMEOUT = 30000;
  12577. var PDFRenderingQueue = /*#__PURE__*/ function() {
  12578. function PDFRenderingQueue() {
  12579. _classCallCheck(this, PDFRenderingQueue);
  12580. this.pdfViewer = null;
  12581. this.pdfThumbnailViewer = null;
  12582. this.onIdle = null;
  12583. this.highestPriorityPage = null;
  12584. this.idleTimeout = null;
  12585. this.printing = false;
  12586. this.isThumbnailViewEnabled = false;
  12587. }
  12588. _createClass(PDFRenderingQueue, [{
  12589. key: "setViewer",
  12590. value: function setViewer(pdfViewer) {
  12591. this.pdfViewer = pdfViewer;
  12592. }
  12593. }, {
  12594. key: "setThumbnailViewer",
  12595. value: function setThumbnailViewer(pdfThumbnailViewer) {
  12596. this.pdfThumbnailViewer = pdfThumbnailViewer;
  12597. }
  12598. }, {
  12599. key: "isHighestPriority",
  12600. value: function isHighestPriority(view) {
  12601. return this.highestPriorityPage === view.renderingId;
  12602. }
  12603. }, {
  12604. key: "hasViewer",
  12605. value: function hasViewer() {
  12606. return !!this.pdfViewer;
  12607. }
  12608. }, {
  12609. key: "renderHighestPriority",
  12610. value: function renderHighestPriority(currentlyVisiblePages) {
  12611. var _this$pdfThumbnailVie;
  12612. if (this.idleTimeout) {
  12613. clearTimeout(this.idleTimeout);
  12614. this.idleTimeout = null;
  12615. }
  12616. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  12617. return;
  12618. }
  12619. if (this.isThumbnailViewEnabled && (_this$pdfThumbnailVie =
  12620. this.pdfThumbnailViewer) !== null &&
  12621. _this$pdfThumbnailVie !== void 0 &&
  12622. _this$pdfThumbnailVie.forceRendering()) {
  12623. return;
  12624. }
  12625. if (this.printing) {
  12626. return;
  12627. }
  12628. if (this.onIdle) {
  12629. this.idleTimeout = setTimeout(this.onIdle.bind(this),
  12630. CLEANUP_TIMEOUT);
  12631. }
  12632. }
  12633. }, {
  12634. key: "getHighestPriority",
  12635. value: function getHighestPriority(visible, views, scrolledDown) {
  12636. var preRenderExtra = arguments.length > 3 && arguments[
  12637. 3] !== undefined ? arguments[3] : false;
  12638. var visibleViews = visible.views,
  12639. numVisible = visibleViews.length;
  12640. if (numVisible === 0) {
  12641. return null;
  12642. }
  12643. for (var i = 0; i < numVisible; i++) {
  12644. var view = visibleViews[i].view;
  12645. if (!this.isViewFinished(view)) {
  12646. return view;
  12647. }
  12648. }
  12649. var firstId = visible.first.id,
  12650. lastId = visible.last.id;
  12651. if (lastId - firstId + 1 > numVisible) {
  12652. var visibleIds = visible.ids;
  12653. for (var _i = 1, ii = lastId - firstId; _i < ii; _i++) {
  12654. var holeId = scrolledDown ? firstId + _i : lastId -
  12655. _i;
  12656. if (visibleIds.has(holeId)) {
  12657. continue;
  12658. }
  12659. var holeView = views[holeId - 1];
  12660. if (!this.isViewFinished(holeView)) {
  12661. return holeView;
  12662. }
  12663. }
  12664. }
  12665. var preRenderIndex = scrolledDown ? lastId : firstId - 2;
  12666. var preRenderView = views[preRenderIndex];
  12667. if (preRenderView && !this.isViewFinished(preRenderView)) {
  12668. return preRenderView;
  12669. }
  12670. if (preRenderExtra) {
  12671. preRenderIndex += scrolledDown ? 1 : -1;
  12672. preRenderView = views[preRenderIndex];
  12673. if (preRenderView && !this.isViewFinished(
  12674. preRenderView)) {
  12675. return preRenderView;
  12676. }
  12677. }
  12678. return null;
  12679. }
  12680. }, {
  12681. key: "isViewFinished",
  12682. value: function isViewFinished(view) {
  12683. return view.renderingState === _ui_utils.RenderingStates
  12684. .FINISHED;
  12685. }
  12686. }, {
  12687. key: "renderView",
  12688. value: function renderView(view) {
  12689. var _this = this;
  12690. switch (view.renderingState) {
  12691. case _ui_utils.RenderingStates.FINISHED:
  12692. return false;
  12693. case _ui_utils.RenderingStates.PAUSED:
  12694. this.highestPriorityPage = view.renderingId;
  12695. view.resume();
  12696. break;
  12697. case _ui_utils.RenderingStates.RUNNING:
  12698. this.highestPriorityPage = view.renderingId;
  12699. break;
  12700. case _ui_utils.RenderingStates.INITIAL:
  12701. this.highestPriorityPage = view.renderingId;
  12702. view.draw()["finally"](function() {
  12703. _this.renderHighestPriority();
  12704. })["catch"](function(reason) {
  12705. if (reason instanceof _pdfjsLib
  12706. .RenderingCancelledException) {
  12707. return;
  12708. }
  12709. console.error("renderView: \"".concat(
  12710. reason, "\""));
  12711. });
  12712. break;
  12713. }
  12714. return true;
  12715. }
  12716. }]);
  12717. return PDFRenderingQueue;
  12718. }();
  12719. exports.PDFRenderingQueue = PDFRenderingQueue;
  12720. /***/
  12721. }),
  12722. /* 24 */
  12723. /***/
  12724. ((__unused_webpack_module, exports, __webpack_require__) => {
  12725. Object.defineProperty(exports, "__esModule", ({
  12726. value: true
  12727. }));
  12728. exports.PDFScriptingManager = void 0;
  12729. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  12730. var _ui_utils = __webpack_require__(5);
  12731. var _pdfjsLib = __webpack_require__(7);
  12732. function _interopRequireDefault(obj) {
  12733. return obj && obj.__esModule ? obj : {
  12734. "default": obj
  12735. };
  12736. }
  12737. function _toConsumableArray(arr) {
  12738. return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(
  12739. arr) || _nonIterableSpread();
  12740. }
  12741. function _nonIterableSpread() {
  12742. throw new TypeError(
  12743. "Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
  12744. );
  12745. }
  12746. function _iterableToArray(iter) {
  12747. if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter[
  12748. "@@iterator"] != null) return Array.from(iter);
  12749. }
  12750. function _arrayWithoutHoles(arr) {
  12751. if (Array.isArray(arr)) return _arrayLikeToArray(arr);
  12752. }
  12753. function ownKeys(object, enumerableOnly) {
  12754. var keys = Object.keys(object);
  12755. if (Object.getOwnPropertySymbols) {
  12756. var symbols = Object.getOwnPropertySymbols(object);
  12757. enumerableOnly && (symbols = symbols.filter(function(sym) {
  12758. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  12759. })), keys.push.apply(keys, symbols);
  12760. }
  12761. return keys;
  12762. }
  12763. function _objectSpread(target) {
  12764. for (var i = 1; i < arguments.length; i++) {
  12765. var source = null != arguments[i] ? arguments[i] : {};
  12766. i % 2 ? ownKeys(Object(source), !0).forEach(function(key) {
  12767. _defineProperty(target, key, source[key]);
  12768. }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object
  12769. .getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(
  12770. function(key) {
  12771. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(
  12772. source, key));
  12773. });
  12774. }
  12775. return target;
  12776. }
  12777. function _defineProperty(obj, key, value) {
  12778. if (key in obj) {
  12779. Object.defineProperty(obj, key, {
  12780. value: value,
  12781. enumerable: true,
  12782. configurable: true,
  12783. writable: true
  12784. });
  12785. } else {
  12786. obj[key] = value;
  12787. }
  12788. return obj;
  12789. }
  12790. function _createForOfIteratorHelper(o, allowArrayLike) {
  12791. var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
  12792. if (!it) {
  12793. if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike &&
  12794. o && typeof o.length === "number") {
  12795. if (it) o = it;
  12796. var i = 0;
  12797. var F = function F() {};
  12798. return {
  12799. s: F,
  12800. n: function n() {
  12801. if (i >= o.length) return {
  12802. done: true
  12803. };
  12804. return {
  12805. done: false,
  12806. value: o[i++]
  12807. };
  12808. },
  12809. e: function e(_e2) {
  12810. throw _e2;
  12811. },
  12812. f: F
  12813. };
  12814. }
  12815. throw new TypeError(
  12816. "Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
  12817. );
  12818. }
  12819. var normalCompletion = true,
  12820. didErr = false,
  12821. err;
  12822. return {
  12823. s: function s() {
  12824. it = it.call(o);
  12825. },
  12826. n: function n() {
  12827. var step = it.next();
  12828. normalCompletion = step.done;
  12829. return step;
  12830. },
  12831. e: function e(_e3) {
  12832. didErr = true;
  12833. err = _e3;
  12834. },
  12835. f: function f() {
  12836. try {
  12837. if (!normalCompletion && it["return"] != null) it["return"]();
  12838. } finally {
  12839. if (didErr) throw err;
  12840. }
  12841. }
  12842. };
  12843. }
  12844. function _slicedToArray(arr, i) {
  12845. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) ||
  12846. _unsupportedIterableToArray(arr, i) || _nonIterableRest();
  12847. }
  12848. function _nonIterableRest() {
  12849. throw new TypeError(
  12850. "Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
  12851. );
  12852. }
  12853. function _unsupportedIterableToArray(o, minLen) {
  12854. if (!o) return;
  12855. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  12856. var n = Object.prototype.toString.call(o).slice(8, -1);
  12857. if (n === "Object" && o.constructor) n = o.constructor.name;
  12858. if (n === "Map" || n === "Set") return Array.from(o);
  12859. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
  12860. return _arrayLikeToArray(o, minLen);
  12861. }
  12862. function _arrayLikeToArray(arr, len) {
  12863. if (len == null || len > arr.length) len = arr.length;
  12864. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  12865. arr2[i] = arr[i];
  12866. }
  12867. return arr2;
  12868. }
  12869. function _iterableToArrayLimit(arr, i) {
  12870. var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] ||
  12871. arr["@@iterator"];
  12872. if (_i == null) return;
  12873. var _arr = [];
  12874. var _n = true;
  12875. var _d = false;
  12876. var _s, _e;
  12877. try {
  12878. for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
  12879. _arr.push(_s.value);
  12880. if (i && _arr.length === i) break;
  12881. }
  12882. } catch (err) {
  12883. _d = true;
  12884. _e = err;
  12885. } finally {
  12886. try {
  12887. if (!_n && _i["return"] != null) _i["return"]();
  12888. } finally {
  12889. if (_d) throw _e;
  12890. }
  12891. }
  12892. return _arr;
  12893. }
  12894. function _arrayWithHoles(arr) {
  12895. if (Array.isArray(arr)) return arr;
  12896. }
  12897. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  12898. try {
  12899. var info = gen[key](arg);
  12900. var value = info.value;
  12901. } catch (error) {
  12902. reject(error);
  12903. return;
  12904. }
  12905. if (info.done) {
  12906. resolve(value);
  12907. } else {
  12908. Promise.resolve(value).then(_next, _throw);
  12909. }
  12910. }
  12911. function _asyncToGenerator(fn) {
  12912. return function() {
  12913. var self = this,
  12914. args = arguments;
  12915. return new Promise(function(resolve, reject) {
  12916. var gen = fn.apply(self, args);
  12917. function _next(value) {
  12918. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next",
  12919. value);
  12920. }
  12921. function _throw(err) {
  12922. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw",
  12923. err);
  12924. }
  12925. _next(undefined);
  12926. });
  12927. };
  12928. }
  12929. function _classCallCheck(instance, Constructor) {
  12930. if (!(instance instanceof Constructor)) {
  12931. throw new TypeError("Cannot call a class as a function");
  12932. }
  12933. }
  12934. function _defineProperties(target, props) {
  12935. for (var i = 0; i < props.length; i++) {
  12936. var descriptor = props[i];
  12937. descriptor.enumerable = descriptor.enumerable || false;
  12938. descriptor.configurable = true;
  12939. if ("value" in descriptor) descriptor.writable = true;
  12940. Object.defineProperty(target, descriptor.key, descriptor);
  12941. }
  12942. }
  12943. function _createClass(Constructor, protoProps, staticProps) {
  12944. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  12945. if (staticProps) _defineProperties(Constructor, staticProps);
  12946. Object.defineProperty(Constructor, "prototype", {
  12947. writable: false
  12948. });
  12949. return Constructor;
  12950. }
  12951. var PDFScriptingManager = /*#__PURE__*/ function() {
  12952. function PDFScriptingManager(_ref) {
  12953. var eventBus = _ref.eventBus,
  12954. _ref$sandboxBundleSrc = _ref.sandboxBundleSrc,
  12955. sandboxBundleSrc = _ref$sandboxBundleSrc === void 0 ? null :
  12956. _ref$sandboxBundleSrc,
  12957. _ref$scriptingFactory = _ref.scriptingFactory,
  12958. scriptingFactory = _ref$scriptingFactory === void 0 ? null :
  12959. _ref$scriptingFactory,
  12960. _ref$docPropertiesLoo = _ref.docPropertiesLookup,
  12961. docPropertiesLookup = _ref$docPropertiesLoo === void 0 ? null :
  12962. _ref$docPropertiesLoo;
  12963. _classCallCheck(this, PDFScriptingManager);
  12964. this._pdfDocument = null;
  12965. this._pdfViewer = null;
  12966. this._closeCapability = null;
  12967. this._destroyCapability = null;
  12968. this._scripting = null;
  12969. this._mouseState = Object.create(null);
  12970. this._ready = false;
  12971. this._eventBus = eventBus;
  12972. this._sandboxBundleSrc = sandboxBundleSrc;
  12973. this._scriptingFactory = scriptingFactory;
  12974. this._docPropertiesLookup = docPropertiesLookup;
  12975. }
  12976. _createClass(PDFScriptingManager, [{
  12977. key: "setViewer",
  12978. value: function setViewer(pdfViewer) {
  12979. this._pdfViewer = pdfViewer;
  12980. }
  12981. }, {
  12982. key: "setDocument",
  12983. value: function() {
  12984. var _setDocument = _asyncToGenerator( /*#__PURE__*/
  12985. _regenerator["default"].mark(function _callee2(
  12986. pdfDocument) {
  12987. var _this = this,
  12988. _this$_scripting3;
  12989. var _yield$Promise$all, _yield$Promise$all2,
  12990. objects, calculationOrder, docActions,
  12991. _iterator, _step, _step$value, name,
  12992. listener, _iterator2, _step2,
  12993. _step2$value, _name, _listener,
  12994. docProperties;
  12995. return _regenerator["default"].wrap(
  12996. function _callee2$(_context2) {
  12997. while (1) {
  12998. switch (_context2.prev =
  12999. _context2.next) {
  13000. case 0:
  13001. if (!this
  13002. ._pdfDocument) {
  13003. _context2.next =
  13004. 3;
  13005. break;
  13006. }
  13007. _context2.next = 3;
  13008. return this
  13009. ._destroyScripting();
  13010. case 3:
  13011. this._pdfDocument =
  13012. pdfDocument;
  13013. if (pdfDocument) {
  13014. _context2.next =
  13015. 6;
  13016. break;
  13017. }
  13018. return _context2
  13019. .abrupt(
  13020. "return");
  13021. case 6:
  13022. _context2.next = 8;
  13023. return Promise.all([
  13024. pdfDocument
  13025. .getFieldObjects(),
  13026. pdfDocument
  13027. .getCalculationOrderIds(),
  13028. pdfDocument
  13029. .getJSActions()
  13030. ]);
  13031. case 8:
  13032. _yield$Promise$all =
  13033. _context2.sent;
  13034. _yield$Promise$all2
  13035. =
  13036. _slicedToArray(
  13037. _yield$Promise$all,
  13038. 3);
  13039. objects =
  13040. _yield$Promise$all2[
  13041. 0];
  13042. calculationOrder =
  13043. _yield$Promise$all2[
  13044. 1];
  13045. docActions =
  13046. _yield$Promise$all2[
  13047. 2];
  13048. if (!(!objects && !
  13049. docActions
  13050. )) {
  13051. _context2.next =
  13052. 17;
  13053. break;
  13054. }
  13055. _context2.next = 16;
  13056. return this
  13057. ._destroyScripting();
  13058. case 16:
  13059. return _context2
  13060. .abrupt(
  13061. "return");
  13062. case 17:
  13063. if (!(pdfDocument !==
  13064. this
  13065. ._pdfDocument
  13066. )) {
  13067. _context2.next =
  13068. 19;
  13069. break;
  13070. }
  13071. return _context2
  13072. .abrupt(
  13073. "return");
  13074. case 19:
  13075. _context2.prev = 19;
  13076. this._scripting =
  13077. this
  13078. ._createScripting();
  13079. _context2.next = 29;
  13080. break;
  13081. case 23:
  13082. _context2.prev = 23;
  13083. _context2.t0 =
  13084. _context2[
  13085. "catch"](
  13086. 19);
  13087. console.error(
  13088. "PDFScriptingManager.setDocument: \""
  13089. .concat(
  13090. _context2
  13091. .t0 ===
  13092. null ||
  13093. _context2
  13094. .t0 ===
  13095. void 0 ?
  13096. void 0 :
  13097. _context2
  13098. .t0
  13099. .message,
  13100. "\"."));
  13101. _context2.next = 28;
  13102. return this
  13103. ._destroyScripting();
  13104. case 28:
  13105. return _context2
  13106. .abrupt(
  13107. "return");
  13108. case 29:
  13109. this._internalEvents
  13110. .set(
  13111. "updatefromsandbox",
  13112. function(
  13113. event) {
  13114. if ((event ===
  13115. null ||
  13116. event ===
  13117. void 0 ?
  13118. void 0 :
  13119. event
  13120. .source
  13121. ) !==
  13122. window
  13123. ) {
  13124. return;
  13125. }
  13126. _this
  13127. ._updateFromSandbox(
  13128. event
  13129. .detail
  13130. );
  13131. });
  13132. this._internalEvents
  13133. .set(
  13134. "dispatcheventinsandbox",
  13135. function(
  13136. event) {
  13137. var
  13138. _this$_scripting;
  13139. (_this$_scripting =
  13140. _this
  13141. ._scripting
  13142. ) ===
  13143. null ||
  13144. _this$_scripting ===
  13145. void 0 ?
  13146. void 0 :
  13147. _this$_scripting
  13148. .dispatchEventInSandbox(
  13149. event
  13150. .detail
  13151. );
  13152. });
  13153. this._internalEvents
  13154. .set(
  13155. "pagechanging",
  13156. function(
  13157. _ref2) {
  13158. var pageNumber =
  13159. _ref2
  13160. .pageNumber,
  13161. previous =
  13162. _ref2
  13163. .previous;
  13164. if (pageNumber ===
  13165. previous
  13166. ) {
  13167. return;
  13168. }
  13169. _this
  13170. ._dispatchPageClose(
  13171. previous
  13172. );
  13173. _this
  13174. ._dispatchPageOpen(
  13175. pageNumber
  13176. );
  13177. });
  13178. this._internalEvents
  13179. .set(
  13180. "pagerendered",
  13181. function(
  13182. _ref3) {
  13183. var pageNumber =
  13184. _ref3
  13185. .pageNumber;
  13186. if (!
  13187. _this
  13188. ._pageOpenPending
  13189. .has(
  13190. pageNumber
  13191. )
  13192. ) {
  13193. return;
  13194. }
  13195. if (pageNumber !==
  13196. _this
  13197. ._pdfViewer
  13198. .currentPageNumber
  13199. ) {
  13200. return;
  13201. }
  13202. _this
  13203. ._dispatchPageOpen(
  13204. pageNumber
  13205. );
  13206. });
  13207. this._internalEvents
  13208. .set(
  13209. "pagesdestroy", /*#__PURE__*/
  13210. function() {
  13211. var _ref4 =
  13212. _asyncToGenerator( /*#__PURE__*/
  13213. _regenerator[
  13214. "default"
  13215. ]
  13216. .mark(
  13217. function _callee(
  13218. event
  13219. ) {
  13220. var _this$_scripting2,
  13221. _this$_closeCapabilit;
  13222. return _regenerator[
  13223. "default"
  13224. ]
  13225. .wrap(
  13226. function _callee$(
  13227. _context
  13228. ) {
  13229. while (
  13230. 1
  13231. ) {
  13232. switch (
  13233. _context
  13234. .prev =
  13235. _context
  13236. .next
  13237. ) {
  13238. case 0:
  13239. _context
  13240. .next =
  13241. 2;
  13242. return _this
  13243. ._dispatchPageClose(
  13244. _this
  13245. ._pdfViewer
  13246. .currentPageNumber
  13247. );
  13248. case 2:
  13249. _context
  13250. .next =
  13251. 4;
  13252. return (_this$_scripting2 =
  13253. _this
  13254. ._scripting
  13255. ) ===
  13256. null ||
  13257. _this$_scripting2 ===
  13258. void 0 ?
  13259. void 0 :
  13260. _this$_scripting2
  13261. .dispatchEventInSandbox({
  13262. id: "doc",
  13263. name: "WillClose"
  13264. });
  13265. case 4:
  13266. (_this$_closeCapabilit =
  13267. _this
  13268. ._closeCapability
  13269. ) ===
  13270. null ||
  13271. _this$_closeCapabilit ===
  13272. void 0 ?
  13273. void 0 :
  13274. _this$_closeCapabilit
  13275. .resolve();
  13276. case 5:
  13277. case "end":
  13278. return _context
  13279. .stop();
  13280. }
  13281. }
  13282. },
  13283. _callee
  13284. );
  13285. }
  13286. )
  13287. );
  13288. return function(
  13289. _x2
  13290. ) {
  13291. return _ref4
  13292. .apply(
  13293. this,
  13294. arguments
  13295. );
  13296. };
  13297. }());
  13298. this._domEvents.set(
  13299. "mousedown",
  13300. function(
  13301. event) {
  13302. _this
  13303. ._mouseState
  13304. .isDown =
  13305. true;
  13306. });
  13307. this._domEvents.set(
  13308. "mouseup",
  13309. function(
  13310. event) {
  13311. _this
  13312. ._mouseState
  13313. .isDown =
  13314. false;
  13315. });
  13316. _iterator =
  13317. _createForOfIteratorHelper(
  13318. this
  13319. ._internalEvents
  13320. );
  13321. try {
  13322. for (_iterator
  13323. .s(); !(
  13324. _step =
  13325. _iterator
  13326. .n())
  13327. .done;) {
  13328. _step$value
  13329. =
  13330. _slicedToArray(
  13331. _step
  13332. .value,
  13333. 2),
  13334. name =
  13335. _step$value[
  13336. 0],
  13337. listener =
  13338. _step$value[
  13339. 1];
  13340. this._eventBus
  13341. ._on(
  13342. name,
  13343. listener
  13344. );
  13345. }
  13346. } catch (err) {
  13347. _iterator.e(
  13348. err);
  13349. } finally {
  13350. _iterator.f();
  13351. }
  13352. _iterator2 =
  13353. _createForOfIteratorHelper(
  13354. this
  13355. ._domEvents
  13356. );
  13357. try {
  13358. for (_iterator2
  13359. .s(); !(
  13360. _step2 =
  13361. _iterator2
  13362. .n())
  13363. .done;) {
  13364. _step2$value
  13365. =
  13366. _slicedToArray(
  13367. _step2
  13368. .value,
  13369. 2),
  13370. _name =
  13371. _step2$value[
  13372. 0],
  13373. _listener =
  13374. _step2$value[
  13375. 1];
  13376. window
  13377. .addEventListener(
  13378. _name,
  13379. _listener
  13380. );
  13381. }
  13382. } catch (err) {
  13383. _iterator2.e(
  13384. err);
  13385. } finally {
  13386. _iterator2.f();
  13387. }
  13388. _context2.prev = 40;
  13389. _context2.next = 43;
  13390. return this
  13391. ._getDocProperties();
  13392. case 43:
  13393. docProperties =
  13394. _context2.sent;
  13395. if (!(pdfDocument !==
  13396. this
  13397. ._pdfDocument
  13398. )) {
  13399. _context2.next =
  13400. 46;
  13401. break;
  13402. }
  13403. return _context2
  13404. .abrupt(
  13405. "return");
  13406. case 46:
  13407. _context2.next = 48;
  13408. return this
  13409. ._scripting
  13410. .createSandbox({
  13411. objects: objects,
  13412. calculationOrder: calculationOrder,
  13413. appInfo: {
  13414. platform: navigator
  13415. .platform,
  13416. language: navigator
  13417. .language
  13418. },
  13419. docInfo: _objectSpread(
  13420. _objectSpread({},
  13421. docProperties
  13422. ), {}, {
  13423. actions: docActions
  13424. }
  13425. )
  13426. });
  13427. case 48:
  13428. this._eventBus
  13429. .dispatch(
  13430. "sandboxcreated", {
  13431. source: this
  13432. });
  13433. _context2.next = 57;
  13434. break;
  13435. case 51:
  13436. _context2.prev = 51;
  13437. _context2.t1 =
  13438. _context2[
  13439. "catch"](
  13440. 40);
  13441. console.error(
  13442. "PDFScriptingManager.setDocument: \""
  13443. .concat(
  13444. _context2
  13445. .t1 ===
  13446. null ||
  13447. _context2
  13448. .t1 ===
  13449. void 0 ?
  13450. void 0 :
  13451. _context2
  13452. .t1
  13453. .message,
  13454. "\"."));
  13455. _context2.next = 56;
  13456. return this
  13457. ._destroyScripting();
  13458. case 56:
  13459. return _context2
  13460. .abrupt(
  13461. "return");
  13462. case 57:
  13463. _context2.next = 59;
  13464. return (_this$_scripting3 =
  13465. this
  13466. ._scripting
  13467. ) ===
  13468. null ||
  13469. _this$_scripting3 ===
  13470. void 0 ?
  13471. void 0 :
  13472. _this$_scripting3
  13473. .dispatchEventInSandbox({
  13474. id: "doc",
  13475. name: "Open"
  13476. });
  13477. case 59:
  13478. _context2.next = 61;
  13479. return this
  13480. ._dispatchPageOpen(
  13481. this
  13482. ._pdfViewer
  13483. .currentPageNumber,
  13484. true);
  13485. case 61:
  13486. Promise.resolve()
  13487. .then(
  13488. function() {
  13489. if (pdfDocument ===
  13490. _this
  13491. ._pdfDocument
  13492. ) {
  13493. _this
  13494. ._ready =
  13495. true;
  13496. }
  13497. });
  13498. case 62:
  13499. case "end":
  13500. return _context2
  13501. .stop();
  13502. }
  13503. }
  13504. }, _callee2, this, [
  13505. [19, 23],
  13506. [40, 51]
  13507. ]);
  13508. }));
  13509. function setDocument(_x) {
  13510. return _setDocument.apply(this, arguments);
  13511. }
  13512. return setDocument;
  13513. }()
  13514. }, {
  13515. key: "dispatchWillSave",
  13516. value: function() {
  13517. var _dispatchWillSave = _asyncToGenerator( /*#__PURE__*/
  13518. _regenerator["default"].mark(function _callee3(
  13519. detail) {
  13520. var _this$_scripting4;
  13521. return _regenerator["default"].wrap(
  13522. function _callee3$(_context3) {
  13523. while (1) {
  13524. switch (_context3.prev =
  13525. _context3.next) {
  13526. case 0:
  13527. return _context3
  13528. .abrupt(
  13529. "return", (
  13530. _this$_scripting4 =
  13531. this
  13532. ._scripting
  13533. ) ===
  13534. null ||
  13535. _this$_scripting4 ===
  13536. void 0 ?
  13537. void 0 :
  13538. _this$_scripting4
  13539. .dispatchEventInSandbox({
  13540. id: "doc",
  13541. name: "WillSave"
  13542. }));
  13543. case 1:
  13544. case "end":
  13545. return _context3
  13546. .stop();
  13547. }
  13548. }
  13549. }, _callee3, this);
  13550. }));
  13551. function dispatchWillSave(_x3) {
  13552. return _dispatchWillSave.apply(this, arguments);
  13553. }
  13554. return dispatchWillSave;
  13555. }()
  13556. }, {
  13557. key: "dispatchDidSave",
  13558. value: function() {
  13559. var _dispatchDidSave = _asyncToGenerator( /*#__PURE__*/
  13560. _regenerator["default"].mark(function _callee4(
  13561. detail) {
  13562. var _this$_scripting5;
  13563. return _regenerator["default"].wrap(
  13564. function _callee4$(_context4) {
  13565. while (1) {
  13566. switch (_context4.prev =
  13567. _context4.next) {
  13568. case 0:
  13569. return _context4
  13570. .abrupt(
  13571. "return", (
  13572. _this$_scripting5 =
  13573. this
  13574. ._scripting
  13575. ) ===
  13576. null ||
  13577. _this$_scripting5 ===
  13578. void 0 ?
  13579. void 0 :
  13580. _this$_scripting5
  13581. .dispatchEventInSandbox({
  13582. id: "doc",
  13583. name: "DidSave"
  13584. }));
  13585. case 1:
  13586. case "end":
  13587. return _context4
  13588. .stop();
  13589. }
  13590. }
  13591. }, _callee4, this);
  13592. }));
  13593. function dispatchDidSave(_x4) {
  13594. return _dispatchDidSave.apply(this, arguments);
  13595. }
  13596. return dispatchDidSave;
  13597. }()
  13598. }, {
  13599. key: "dispatchWillPrint",
  13600. value: function() {
  13601. var _dispatchWillPrint = _asyncToGenerator( /*#__PURE__*/
  13602. _regenerator["default"].mark(function _callee5(
  13603. detail) {
  13604. var _this$_scripting6;
  13605. return _regenerator["default"].wrap(
  13606. function _callee5$(_context5) {
  13607. while (1) {
  13608. switch (_context5.prev =
  13609. _context5.next) {
  13610. case 0:
  13611. return _context5
  13612. .abrupt(
  13613. "return", (
  13614. _this$_scripting6 =
  13615. this
  13616. ._scripting
  13617. ) ===
  13618. null ||
  13619. _this$_scripting6 ===
  13620. void 0 ?
  13621. void 0 :
  13622. _this$_scripting6
  13623. .dispatchEventInSandbox({
  13624. id: "doc",
  13625. name: "WillPrint"
  13626. }));
  13627. case 1:
  13628. case "end":
  13629. return _context5
  13630. .stop();
  13631. }
  13632. }
  13633. }, _callee5, this);
  13634. }));
  13635. function dispatchWillPrint(_x5) {
  13636. return _dispatchWillPrint.apply(this, arguments);
  13637. }
  13638. return dispatchWillPrint;
  13639. }()
  13640. }, {
  13641. key: "dispatchDidPrint",
  13642. value: function() {
  13643. var _dispatchDidPrint = _asyncToGenerator( /*#__PURE__*/
  13644. _regenerator["default"].mark(function _callee6(
  13645. detail) {
  13646. var _this$_scripting7;
  13647. return _regenerator["default"].wrap(
  13648. function _callee6$(_context6) {
  13649. while (1) {
  13650. switch (_context6.prev =
  13651. _context6.next) {
  13652. case 0:
  13653. return _context6
  13654. .abrupt(
  13655. "return", (
  13656. _this$_scripting7 =
  13657. this
  13658. ._scripting
  13659. ) ===
  13660. null ||
  13661. _this$_scripting7 ===
  13662. void 0 ?
  13663. void 0 :
  13664. _this$_scripting7
  13665. .dispatchEventInSandbox({
  13666. id: "doc",
  13667. name: "DidPrint"
  13668. }));
  13669. case 1:
  13670. case "end":
  13671. return _context6
  13672. .stop();
  13673. }
  13674. }
  13675. }, _callee6, this);
  13676. }));
  13677. function dispatchDidPrint(_x6) {
  13678. return _dispatchDidPrint.apply(this, arguments);
  13679. }
  13680. return dispatchDidPrint;
  13681. }()
  13682. }, {
  13683. key: "mouseState",
  13684. get: function get() {
  13685. return this._mouseState;
  13686. }
  13687. }, {
  13688. key: "destroyPromise",
  13689. get: function get() {
  13690. var _this$_destroyCapabil;
  13691. return ((_this$_destroyCapabil = this
  13692. ._destroyCapability) === null ||
  13693. _this$_destroyCapabil === void 0 ? void 0 :
  13694. _this$_destroyCapabil.promise) || null;
  13695. }
  13696. }, {
  13697. key: "ready",
  13698. get: function get() {
  13699. return this._ready;
  13700. }
  13701. }, {
  13702. key: "_internalEvents",
  13703. get: function get() {
  13704. return (0, _pdfjsLib.shadow)(this, "_internalEvents",
  13705. new Map());
  13706. }
  13707. }, {
  13708. key: "_domEvents",
  13709. get: function get() {
  13710. return (0, _pdfjsLib.shadow)(this, "_domEvents", new Map());
  13711. }
  13712. }, {
  13713. key: "_pageOpenPending",
  13714. get: function get() {
  13715. return (0, _pdfjsLib.shadow)(this, "_pageOpenPending",
  13716. new Set());
  13717. }
  13718. }, {
  13719. key: "_visitedPages",
  13720. get: function get() {
  13721. return (0, _pdfjsLib.shadow)(this, "_visitedPages",
  13722. new Map());
  13723. }
  13724. }, {
  13725. key: "_updateFromSandbox",
  13726. value: function() {
  13727. var _updateFromSandbox2 = _asyncToGenerator( /*#__PURE__*/
  13728. _regenerator["default"].mark(function _callee7(
  13729. detail) {
  13730. var isInPresentationMode, id, siblings,
  13731. command, value, modes, ids, _iterator3,
  13732. _step3, elementId, element,
  13733. _this$_pdfDocument;
  13734. return _regenerator["default"].wrap(
  13735. function _callee7$(_context7) {
  13736. while (1) {
  13737. switch (_context7.prev =
  13738. _context7.next) {
  13739. case 0:
  13740. isInPresentationMode
  13741. = this
  13742. ._pdfViewer
  13743. .isInPresentationMode ||
  13744. this._pdfViewer
  13745. .isChangingPresentationMode;
  13746. id = detail.id,
  13747. siblings =
  13748. detail.siblings,
  13749. command = detail
  13750. .command,
  13751. value = detail
  13752. .value;
  13753. if (id) {
  13754. _context7.next =
  13755. 46;
  13756. break;
  13757. }
  13758. _context7.t0 =
  13759. command;
  13760. _context7.next =
  13761. _context7.t0 ===
  13762. "clear" ? 6 :
  13763. _context7.t0 ===
  13764. "error" ? 8 :
  13765. _context7.t0 ===
  13766. "layout" ? 10 :
  13767. _context7.t0 ===
  13768. "page-num" ?
  13769. 15 : _context7
  13770. .t0 ===
  13771. "print" ? 17 :
  13772. _context7.t0 ===
  13773. "println" ? 21 :
  13774. _context7.t0 ===
  13775. "zoom" ? 23 :
  13776. _context7.t0 ===
  13777. "SaveAs" ? 27 :
  13778. _context7.t0 ===
  13779. "FirstPage" ?
  13780. 29 : _context7
  13781. .t0 ===
  13782. "LastPage" ?
  13783. 31 : _context7
  13784. .t0 ===
  13785. "NextPage" ?
  13786. 33 : _context7
  13787. .t0 ===
  13788. "PrevPage" ?
  13789. 35 : _context7
  13790. .t0 ===
  13791. "ZoomViewIn" ?
  13792. 37 : _context7
  13793. .t0 ===
  13794. "ZoomViewOut" ?
  13795. 41 : 45;
  13796. break;
  13797. case 6:
  13798. console.clear();
  13799. return _context7
  13800. .abrupt("break",
  13801. 45);
  13802. case 8:
  13803. console.error(
  13804. value);
  13805. return _context7
  13806. .abrupt("break",
  13807. 45);
  13808. case 10:
  13809. if (!
  13810. isInPresentationMode
  13811. ) {
  13812. _context7.next =
  13813. 12;
  13814. break;
  13815. }
  13816. return _context7
  13817. .abrupt(
  13818. "return");
  13819. case 12:
  13820. modes = (0,
  13821. _ui_utils
  13822. .apiPageLayoutToViewerModes
  13823. )(value);
  13824. this._pdfViewer
  13825. .spreadMode =
  13826. modes
  13827. .spreadMode;
  13828. return _context7
  13829. .abrupt("break",
  13830. 45);
  13831. case 15:
  13832. this._pdfViewer
  13833. .currentPageNumber =
  13834. value + 1;
  13835. return _context7
  13836. .abrupt("break",
  13837. 45);
  13838. case 17:
  13839. _context7.next = 19;
  13840. return this
  13841. ._pdfViewer
  13842. .pagesPromise;
  13843. case 19:
  13844. this._eventBus
  13845. .dispatch(
  13846. "print", {
  13847. source: this
  13848. });
  13849. return _context7
  13850. .abrupt("break",
  13851. 45);
  13852. case 21:
  13853. console.log(value);
  13854. return _context7
  13855. .abrupt("break",
  13856. 45);
  13857. case 23:
  13858. if (!
  13859. isInPresentationMode
  13860. ) {
  13861. _context7.next =
  13862. 25;
  13863. break;
  13864. }
  13865. return _context7
  13866. .abrupt(
  13867. "return");
  13868. case 25:
  13869. this._pdfViewer
  13870. .currentScaleValue =
  13871. value;
  13872. return _context7
  13873. .abrupt("break",
  13874. 45);
  13875. case 27:
  13876. this._eventBus
  13877. .dispatch(
  13878. "save", {
  13879. source: this
  13880. });
  13881. return _context7
  13882. .abrupt("break",
  13883. 45);
  13884. case 29:
  13885. this._pdfViewer
  13886. .currentPageNumber =
  13887. 1;
  13888. return _context7
  13889. .abrupt("break",
  13890. 45);
  13891. case 31:
  13892. this._pdfViewer
  13893. .currentPageNumber =
  13894. this._pdfViewer
  13895. .pagesCount;
  13896. return _context7
  13897. .abrupt("break",
  13898. 45);
  13899. case 33:
  13900. this._pdfViewer
  13901. .nextPage();
  13902. return _context7
  13903. .abrupt("break",
  13904. 45);
  13905. case 35:
  13906. this._pdfViewer
  13907. .previousPage();
  13908. return _context7
  13909. .abrupt("break",
  13910. 45);
  13911. case 37:
  13912. if (!
  13913. isInPresentationMode
  13914. ) {
  13915. _context7.next =
  13916. 39;
  13917. break;
  13918. }
  13919. return _context7
  13920. .abrupt(
  13921. "return");
  13922. case 39:
  13923. this._pdfViewer
  13924. .increaseScale();
  13925. return _context7
  13926. .abrupt("break",
  13927. 45);
  13928. case 41:
  13929. if (!
  13930. isInPresentationMode
  13931. ) {
  13932. _context7.next =
  13933. 43;
  13934. break;
  13935. }
  13936. return _context7
  13937. .abrupt(
  13938. "return");
  13939. case 43:
  13940. this._pdfViewer
  13941. .decreaseScale();
  13942. return _context7
  13943. .abrupt("break",
  13944. 45);
  13945. case 45:
  13946. return _context7
  13947. .abrupt(
  13948. "return");
  13949. case 46:
  13950. if (!
  13951. isInPresentationMode
  13952. ) {
  13953. _context7.next =
  13954. 49;
  13955. break;
  13956. }
  13957. if (!detail.focus) {
  13958. _context7.next =
  13959. 49;
  13960. break;
  13961. }
  13962. return _context7
  13963. .abrupt(
  13964. "return");
  13965. case 49:
  13966. delete detail.id;
  13967. delete detail
  13968. .siblings;
  13969. ids = siblings ? [
  13970. id].concat(
  13971. _toConsumableArray(
  13972. siblings
  13973. )) : [
  13974. id];
  13975. _iterator3 =
  13976. _createForOfIteratorHelper(
  13977. ids);
  13978. try {
  13979. for (_iterator3
  13980. .s(); !(
  13981. _step3 =
  13982. _iterator3
  13983. .n())
  13984. .done;) {
  13985. elementId =
  13986. _step3
  13987. .value;
  13988. element =
  13989. document
  13990. .getElementById(
  13991. elementId
  13992. );
  13993. if (
  13994. element) {
  13995. element
  13996. .dispatchEvent(
  13997. new CustomEvent(
  13998. "updatefromsandbox", {
  13999. detail: detail
  14000. }
  14001. )
  14002. );
  14003. } else {
  14004. (_this$_pdfDocument =
  14005. this
  14006. ._pdfDocument
  14007. ) ===
  14008. null ||
  14009. _this$_pdfDocument ===
  14010. void 0 ?
  14011. void 0 :
  14012. _this$_pdfDocument
  14013. .annotationStorage
  14014. .setValue(
  14015. elementId,
  14016. detail
  14017. );
  14018. }
  14019. }
  14020. } catch (err) {
  14021. _iterator3.e(
  14022. err);
  14023. } finally {
  14024. _iterator3.f();
  14025. }
  14026. case 54:
  14027. case "end":
  14028. return _context7
  14029. .stop();
  14030. }
  14031. }
  14032. }, _callee7, this);
  14033. }));
  14034. function _updateFromSandbox(_x7) {
  14035. return _updateFromSandbox2.apply(this, arguments);
  14036. }
  14037. return _updateFromSandbox;
  14038. }()
  14039. }, {
  14040. key: "_dispatchPageOpen",
  14041. value: function() {
  14042. var _dispatchPageOpen2 = _asyncToGenerator( /*#__PURE__*/
  14043. _regenerator["default"].mark(function _callee9(
  14044. pageNumber) {
  14045. var _this2 = this;
  14046. var initialize,
  14047. pdfDocument,
  14048. visitedPages,
  14049. pageView,
  14050. actionsPromise,
  14051. _args9 = arguments;
  14052. return _regenerator["default"].wrap(
  14053. function _callee9$(_context9) {
  14054. while (1) {
  14055. switch (_context9.prev =
  14056. _context9.next) {
  14057. case 0:
  14058. initialize = _args9
  14059. .length > 1 &&
  14060. _args9[1] !==
  14061. undefined ?
  14062. _args9[1] :
  14063. false;
  14064. pdfDocument = this
  14065. ._pdfDocument,
  14066. visitedPages =
  14067. this
  14068. ._visitedPages;
  14069. if (initialize) {
  14070. this._closeCapability =
  14071. (0, _pdfjsLib
  14072. .createPromiseCapability
  14073. )();
  14074. }
  14075. if (this
  14076. ._closeCapability
  14077. ) {
  14078. _context9.next =
  14079. 5;
  14080. break;
  14081. }
  14082. return _context9
  14083. .abrupt(
  14084. "return");
  14085. case 5:
  14086. pageView = this
  14087. ._pdfViewer
  14088. .getPageView(
  14089. pageNumber -
  14090. 1);
  14091. if (!((pageView ===
  14092. null ||
  14093. pageView ===
  14094. void 0 ?
  14095. void 0 :
  14096. pageView
  14097. .renderingState
  14098. ) !==
  14099. _ui_utils
  14100. .RenderingStates
  14101. .FINISHED
  14102. )) {
  14103. _context9.next =
  14104. 9;
  14105. break;
  14106. }
  14107. this._pageOpenPending
  14108. .add(
  14109. pageNumber);
  14110. return _context9
  14111. .abrupt(
  14112. "return");
  14113. case 9:
  14114. this._pageOpenPending[
  14115. "delete"](
  14116. pageNumber);
  14117. actionsPromise =
  14118. _asyncToGenerator( /*#__PURE__*/
  14119. _regenerator[
  14120. "default"
  14121. ].mark(
  14122. function _callee8() {
  14123. var _pageView$pdfPage,
  14124. _this2$_scripting;
  14125. var
  14126. actions;
  14127. return _regenerator[
  14128. "default"
  14129. ]
  14130. .wrap(
  14131. function _callee8$(
  14132. _context8
  14133. ) {
  14134. while (
  14135. 1
  14136. ) {
  14137. switch (
  14138. _context8
  14139. .prev =
  14140. _context8
  14141. .next
  14142. ) {
  14143. case 0:
  14144. _context8
  14145. .next =
  14146. 2;
  14147. return !
  14148. visitedPages
  14149. .has(
  14150. pageNumber
  14151. ) ?
  14152. (_pageView$pdfPage =
  14153. pageView
  14154. .pdfPage
  14155. ) ===
  14156. null ||
  14157. _pageView$pdfPage ===
  14158. void 0 ?
  14159. void 0 :
  14160. _pageView$pdfPage
  14161. .getJSActions() :
  14162. null;
  14163. case 2:
  14164. actions
  14165. =
  14166. _context8
  14167. .sent;
  14168. if (!
  14169. (pdfDocument !==
  14170. _this2
  14171. ._pdfDocument
  14172. )
  14173. ) {
  14174. _context8
  14175. .next =
  14176. 5;
  14177. break;
  14178. }
  14179. return _context8
  14180. .abrupt(
  14181. "return"
  14182. );
  14183. case 5:
  14184. _context8
  14185. .next =
  14186. 7;
  14187. return (_this2$_scripting =
  14188. _this2
  14189. ._scripting
  14190. ) ===
  14191. null ||
  14192. _this2$_scripting ===
  14193. void 0 ?
  14194. void 0 :
  14195. _this2$_scripting
  14196. .dispatchEventInSandbox({
  14197. id: "page",
  14198. name: "PageOpen",
  14199. pageNumber: pageNumber,
  14200. actions: actions
  14201. });
  14202. case 7:
  14203. case "end":
  14204. return _context8
  14205. .stop();
  14206. }
  14207. }
  14208. },
  14209. _callee8
  14210. );
  14211. }))();
  14212. visitedPages.set(
  14213. pageNumber,
  14214. actionsPromise
  14215. );
  14216. case 12:
  14217. case "end":
  14218. return _context9
  14219. .stop();
  14220. }
  14221. }
  14222. }, _callee9, this);
  14223. }));
  14224. function _dispatchPageOpen(_x8) {
  14225. return _dispatchPageOpen2.apply(this, arguments);
  14226. }
  14227. return _dispatchPageOpen;
  14228. }()
  14229. }, {
  14230. key: "_dispatchPageClose",
  14231. value: function() {
  14232. var _dispatchPageClose2 = _asyncToGenerator( /*#__PURE__*/
  14233. _regenerator["default"].mark(function _callee10(
  14234. pageNumber) {
  14235. var _this$_scripting8;
  14236. var pdfDocument, visitedPages,
  14237. actionsPromise;
  14238. return _regenerator["default"].wrap(
  14239. function _callee10$(_context10) {
  14240. while (1) {
  14241. switch (_context10.prev =
  14242. _context10.next) {
  14243. case 0:
  14244. pdfDocument = this
  14245. ._pdfDocument,
  14246. visitedPages =
  14247. this
  14248. ._visitedPages;
  14249. if (this
  14250. ._closeCapability
  14251. ) {
  14252. _context10
  14253. .next = 3;
  14254. break;
  14255. }
  14256. return _context10
  14257. .abrupt(
  14258. "return");
  14259. case 3:
  14260. if (!this
  14261. ._pageOpenPending
  14262. .has(pageNumber)
  14263. ) {
  14264. _context10
  14265. .next = 5;
  14266. break;
  14267. }
  14268. return _context10
  14269. .abrupt(
  14270. "return");
  14271. case 5:
  14272. actionsPromise =
  14273. visitedPages
  14274. .get(
  14275. pageNumber);
  14276. if (
  14277. actionsPromise) {
  14278. _context10
  14279. .next = 8;
  14280. break;
  14281. }
  14282. return _context10
  14283. .abrupt(
  14284. "return");
  14285. case 8:
  14286. visitedPages.set(
  14287. pageNumber,
  14288. null);
  14289. _context10.next =
  14290. 11;
  14291. return actionsPromise;
  14292. case 11:
  14293. if (!(pdfDocument !==
  14294. this
  14295. ._pdfDocument
  14296. )) {
  14297. _context10
  14298. .next = 13;
  14299. break;
  14300. }
  14301. return _context10
  14302. .abrupt(
  14303. "return");
  14304. case 13:
  14305. _context10.next =
  14306. 15;
  14307. return (_this$_scripting8 =
  14308. this
  14309. ._scripting
  14310. ) ===
  14311. null ||
  14312. _this$_scripting8 ===
  14313. void 0 ?
  14314. void 0 :
  14315. _this$_scripting8
  14316. .dispatchEventInSandbox({
  14317. id: "page",
  14318. name: "PageClose",
  14319. pageNumber: pageNumber
  14320. });
  14321. case 15:
  14322. case "end":
  14323. return _context10
  14324. .stop();
  14325. }
  14326. }
  14327. }, _callee10, this);
  14328. }));
  14329. function _dispatchPageClose(_x9) {
  14330. return _dispatchPageClose2.apply(this, arguments);
  14331. }
  14332. return _dispatchPageClose;
  14333. }()
  14334. }, {
  14335. key: "_getDocProperties",
  14336. value: function() {
  14337. var _getDocProperties2 = _asyncToGenerator( /*#__PURE__*/
  14338. _regenerator["default"].mark(function _callee11() {
  14339. return _regenerator["default"].wrap(
  14340. function _callee11$(_context11) {
  14341. while (1) {
  14342. switch (_context11.prev =
  14343. _context11.next) {
  14344. case 0:
  14345. if (!this
  14346. ._docPropertiesLookup
  14347. ) {
  14348. _context11
  14349. .next = 2;
  14350. break;
  14351. }
  14352. return _context11
  14353. .abrupt(
  14354. "return",
  14355. this
  14356. ._docPropertiesLookup(
  14357. this
  14358. ._pdfDocument
  14359. ));
  14360. case 2:
  14361. throw new Error(
  14362. "_getDocProperties: Unable to lookup properties."
  14363. );
  14364. case 3:
  14365. case "end":
  14366. return _context11
  14367. .stop();
  14368. }
  14369. }
  14370. }, _callee11, this);
  14371. }));
  14372. function _getDocProperties() {
  14373. return _getDocProperties2.apply(this, arguments);
  14374. }
  14375. return _getDocProperties;
  14376. }()
  14377. }, {
  14378. key: "_createScripting",
  14379. value: function _createScripting() {
  14380. this._destroyCapability = (0, _pdfjsLib
  14381. .createPromiseCapability)();
  14382. if (this._scripting) {
  14383. throw new Error(
  14384. "_createScripting: Scripting already exists.");
  14385. }
  14386. if (this._scriptingFactory) {
  14387. return this._scriptingFactory.createScripting({
  14388. sandboxBundleSrc: this._sandboxBundleSrc
  14389. });
  14390. }
  14391. throw new Error(
  14392. "_createScripting: Cannot create scripting.");
  14393. }
  14394. }, {
  14395. key: "_destroyScripting",
  14396. value: function() {
  14397. var _destroyScripting2 = _asyncToGenerator( /*#__PURE__*/
  14398. _regenerator["default"].mark(function _callee12() {
  14399. var _this$_destroyCapabil3;
  14400. var _this$_destroyCapabil2, _iterator4,
  14401. _step4, _step4$value, name, listener,
  14402. _iterator5, _step5, _step5$value,
  14403. _name2, _listener2;
  14404. return _regenerator["default"].wrap(
  14405. function _callee12$(_context12) {
  14406. while (1) {
  14407. switch (_context12.prev =
  14408. _context12.next) {
  14409. case 0:
  14410. if (this
  14411. ._scripting) {
  14412. _context12
  14413. .next = 4;
  14414. break;
  14415. }
  14416. this._pdfDocument =
  14417. null;
  14418. (_this$_destroyCapabil2 =
  14419. this
  14420. ._destroyCapability
  14421. ) === null ||
  14422. _this$_destroyCapabil2 ===
  14423. void 0 ?
  14424. void 0 :
  14425. _this$_destroyCapabil2
  14426. .resolve();
  14427. return _context12
  14428. .abrupt(
  14429. "return");
  14430. case 4:
  14431. if (!this
  14432. ._closeCapability
  14433. ) {
  14434. _context12
  14435. .next = 8;
  14436. break;
  14437. }
  14438. _context12.next = 7;
  14439. return Promise.race(
  14440. [this
  14441. ._closeCapability
  14442. .promise,
  14443. new Promise(
  14444. function(
  14445. resolve
  14446. ) {
  14447. setTimeout
  14448. (resolve,
  14449. 1000
  14450. );
  14451. })
  14452. ])["catch"](
  14453. function(
  14454. reason
  14455. ) {});
  14456. case 7:
  14457. this._closeCapability =
  14458. null;
  14459. case 8:
  14460. this._pdfDocument =
  14461. null;
  14462. _context12.prev = 9;
  14463. _context12.next =
  14464. 12;
  14465. return this
  14466. ._scripting
  14467. .destroySandbox();
  14468. case 12:
  14469. _context12.next =
  14470. 16;
  14471. break;
  14472. case 14:
  14473. _context12.prev =
  14474. 14;
  14475. _context12.t0 =
  14476. _context12[
  14477. "catch"](9);
  14478. case 16:
  14479. _iterator4 =
  14480. _createForOfIteratorHelper(
  14481. this
  14482. ._internalEvents
  14483. );
  14484. try {
  14485. for (_iterator4
  14486. .s(); !(
  14487. _step4 =
  14488. _iterator4
  14489. .n())
  14490. .done;) {
  14491. _step4$value
  14492. =
  14493. _slicedToArray(
  14494. _step4
  14495. .value,
  14496. 2),
  14497. name =
  14498. _step4$value[
  14499. 0],
  14500. listener =
  14501. _step4$value[
  14502. 1];
  14503. this._eventBus
  14504. ._off(
  14505. name,
  14506. listener
  14507. );
  14508. }
  14509. } catch (err) {
  14510. _iterator4.e(
  14511. err);
  14512. } finally {
  14513. _iterator4.f();
  14514. }
  14515. this._internalEvents
  14516. .clear();
  14517. _iterator5 =
  14518. _createForOfIteratorHelper(
  14519. this
  14520. ._domEvents
  14521. );
  14522. try {
  14523. for (_iterator5
  14524. .s(); !(
  14525. _step5 =
  14526. _iterator5
  14527. .n())
  14528. .done;) {
  14529. _step5$value
  14530. =
  14531. _slicedToArray(
  14532. _step5
  14533. .value,
  14534. 2),
  14535. _name2 =
  14536. _step5$value[
  14537. 0],
  14538. _listener2 =
  14539. _step5$value[
  14540. 1];
  14541. window
  14542. .removeEventListener(
  14543. _name2,
  14544. _listener2
  14545. );
  14546. }
  14547. } catch (err) {
  14548. _iterator5.e(
  14549. err);
  14550. } finally {
  14551. _iterator5.f();
  14552. }
  14553. this._domEvents
  14554. .clear();
  14555. this._pageOpenPending
  14556. .clear();
  14557. this._visitedPages
  14558. .clear();
  14559. this._scripting =
  14560. null;
  14561. delete this
  14562. ._mouseState
  14563. .isDown;
  14564. this._ready = false;
  14565. (_this$_destroyCapabil3 =
  14566. this
  14567. ._destroyCapability
  14568. ) === null ||
  14569. _this$_destroyCapabil3 ===
  14570. void 0 ?
  14571. void 0 :
  14572. _this$_destroyCapabil3
  14573. .resolve();
  14574. case 28:
  14575. case "end":
  14576. return _context12
  14577. .stop();
  14578. }
  14579. }
  14580. }, _callee12, this, [
  14581. [9, 14]
  14582. ]);
  14583. }));
  14584. function _destroyScripting() {
  14585. return _destroyScripting2.apply(this, arguments);
  14586. }
  14587. return _destroyScripting;
  14588. }()
  14589. }]);
  14590. return PDFScriptingManager;
  14591. }();
  14592. exports.PDFScriptingManager = PDFScriptingManager;
  14593. /***/
  14594. }),
  14595. /* 25 */
  14596. /***/
  14597. ((__unused_webpack_module, exports, __webpack_require__) => {
  14598. Object.defineProperty(exports, "__esModule", ({
  14599. value: true
  14600. }));
  14601. exports.PDFSidebar = void 0;
  14602. var _ui_utils = __webpack_require__(5);
  14603. function _classCallCheck(instance, Constructor) {
  14604. if (!(instance instanceof Constructor)) {
  14605. throw new TypeError("Cannot call a class as a function");
  14606. }
  14607. }
  14608. function _defineProperties(target, props) {
  14609. for (var i = 0; i < props.length; i++) {
  14610. var descriptor = props[i];
  14611. descriptor.enumerable = descriptor.enumerable || false;
  14612. descriptor.configurable = true;
  14613. if ("value" in descriptor) descriptor.writable = true;
  14614. Object.defineProperty(target, descriptor.key, descriptor);
  14615. }
  14616. }
  14617. function _createClass(Constructor, protoProps, staticProps) {
  14618. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  14619. if (staticProps) _defineProperties(Constructor, staticProps);
  14620. Object.defineProperty(Constructor, "prototype", {
  14621. writable: false
  14622. });
  14623. return Constructor;
  14624. }
  14625. var UI_NOTIFICATION_CLASS = "pdfSidebarNotification";
  14626. var PDFSidebar = /*#__PURE__*/ function() {
  14627. function PDFSidebar(_ref) {
  14628. var elements = _ref.elements,
  14629. pdfViewer = _ref.pdfViewer,
  14630. pdfThumbnailViewer = _ref.pdfThumbnailViewer,
  14631. eventBus = _ref.eventBus,
  14632. l10n = _ref.l10n;
  14633. _classCallCheck(this, PDFSidebar);
  14634. this.isOpen = false;
  14635. this.active = _ui_utils.SidebarView.THUMBS;
  14636. this.isInitialViewSet = false;
  14637. this.onToggled = null;
  14638. this.pdfViewer = pdfViewer;
  14639. this.pdfThumbnailViewer = pdfThumbnailViewer;
  14640. this.outerContainer = elements.outerContainer;
  14641. this.viewerContainer = elements.viewerContainer;
  14642. this.toggleButton = elements.toggleButton;
  14643. this.thumbnailButton = elements.thumbnailButton;
  14644. this.outlineButton = elements.outlineButton;
  14645. this.attachmentsButton = elements.attachmentsButton;
  14646. this.layersButton = elements.layersButton;
  14647. this.thumbnailView = elements.thumbnailView;
  14648. this.outlineView = elements.outlineView;
  14649. this.attachmentsView = elements.attachmentsView;
  14650. this.layersView = elements.layersView;
  14651. this._outlineOptionsContainer = elements.outlineOptionsContainer;
  14652. this._currentOutlineItemButton = elements.currentOutlineItemButton;
  14653. this.eventBus = eventBus;
  14654. this.l10n = l10n;
  14655. this._addEventListeners();
  14656. }
  14657. _createClass(PDFSidebar, [{
  14658. key: "reset",
  14659. value: function reset() {
  14660. this.isInitialViewSet = false;
  14661. this._hideUINotification(true);
  14662. this.switchView(_ui_utils.SidebarView.THUMBS);
  14663. this.outlineButton.disabled = false;
  14664. this.attachmentsButton.disabled = false;
  14665. this.layersButton.disabled = false;
  14666. this._currentOutlineItemButton.disabled = true;
  14667. }
  14668. }, {
  14669. key: "visibleView",
  14670. get: function get() {
  14671. return this.isOpen ? this.active : _ui_utils.SidebarView
  14672. .NONE;
  14673. }
  14674. }, {
  14675. key: "isThumbnailViewVisible",
  14676. get: function get() {
  14677. return this.isOpen && this.active === _ui_utils.SidebarView
  14678. .THUMBS;
  14679. }
  14680. }, {
  14681. key: "isOutlineViewVisible",
  14682. get: function get() {
  14683. return this.isOpen && this.active === _ui_utils.SidebarView
  14684. .OUTLINE;
  14685. }
  14686. }, {
  14687. key: "isAttachmentsViewVisible",
  14688. get: function get() {
  14689. return this.isOpen && this.active === _ui_utils.SidebarView
  14690. .ATTACHMENTS;
  14691. }
  14692. }, {
  14693. key: "isLayersViewVisible",
  14694. get: function get() {
  14695. return this.isOpen && this.active === _ui_utils.SidebarView
  14696. .LAYERS;
  14697. }
  14698. }, {
  14699. key: "setInitialView",
  14700. value: function setInitialView() {
  14701. var view = arguments.length > 0 && arguments[0] !==
  14702. undefined ? arguments[0] : _ui_utils.SidebarView.NONE;
  14703. if (this.isInitialViewSet) {
  14704. return;
  14705. }
  14706. this.isInitialViewSet = true;
  14707. if (view === _ui_utils.SidebarView.NONE || view ===
  14708. _ui_utils.SidebarView.UNKNOWN) {
  14709. this._dispatchEvent();
  14710. return;
  14711. }
  14712. if (!this._switchView(view, true)) {
  14713. this._dispatchEvent();
  14714. }
  14715. }
  14716. }, {
  14717. key: "switchView",
  14718. value: function switchView(view) {
  14719. var forceOpen = arguments.length > 1 && arguments[1] !==
  14720. undefined ? arguments[1] : false;
  14721. this._switchView(view, forceOpen);
  14722. }
  14723. }, {
  14724. key: "_switchView",
  14725. value: function _switchView(view) {
  14726. var forceOpen = arguments.length > 1 && arguments[1] !==
  14727. undefined ? arguments[1] : false;
  14728. var isViewChanged = view !== this.active;
  14729. var shouldForceRendering = false;
  14730. switch (view) {
  14731. case _ui_utils.SidebarView.NONE:
  14732. if (this.isOpen) {
  14733. this.close();
  14734. return true;
  14735. }
  14736. return false;
  14737. case _ui_utils.SidebarView.THUMBS:
  14738. if (this.isOpen && isViewChanged) {
  14739. shouldForceRendering = true;
  14740. }
  14741. break;
  14742. case _ui_utils.SidebarView.OUTLINE:
  14743. if (this.outlineButton.disabled) {
  14744. return false;
  14745. }
  14746. break;
  14747. case _ui_utils.SidebarView.ATTACHMENTS:
  14748. if (this.attachmentsButton.disabled) {
  14749. return false;
  14750. }
  14751. break;
  14752. case _ui_utils.SidebarView.LAYERS:
  14753. if (this.layersButton.disabled) {
  14754. return false;
  14755. }
  14756. break;
  14757. default:
  14758. console.error("PDFSidebar._switchView: \"".concat(
  14759. view, "\" is not a valid view."));
  14760. return false;
  14761. }
  14762. this.active = view;
  14763. this.thumbnailButton.classList.toggle("toggled", view ===
  14764. _ui_utils.SidebarView.THUMBS);
  14765. this.outlineButton.classList.toggle("toggled", view ===
  14766. _ui_utils.SidebarView.OUTLINE);
  14767. this.attachmentsButton.classList.toggle("toggled", view ===
  14768. _ui_utils.SidebarView.ATTACHMENTS);
  14769. this.layersButton.classList.toggle("toggled", view ===
  14770. _ui_utils.SidebarView.LAYERS);
  14771. this.thumbnailView.classList.toggle("hidden", view !==
  14772. _ui_utils.SidebarView.THUMBS);
  14773. this.outlineView.classList.toggle("hidden", view !==
  14774. _ui_utils.SidebarView.OUTLINE);
  14775. this.attachmentsView.classList.toggle("hidden", view !==
  14776. _ui_utils.SidebarView.ATTACHMENTS);
  14777. this.layersView.classList.toggle("hidden", view !==
  14778. _ui_utils.SidebarView.LAYERS);
  14779. this._outlineOptionsContainer.classList.toggle("hidden",
  14780. view !== _ui_utils.SidebarView.OUTLINE);
  14781. if (forceOpen && !this.isOpen) {
  14782. this.open();
  14783. return true;
  14784. }
  14785. if (shouldForceRendering) {
  14786. this._updateThumbnailViewer();
  14787. this._forceRendering();
  14788. }
  14789. if (isViewChanged) {
  14790. this._dispatchEvent();
  14791. }
  14792. return isViewChanged;
  14793. }
  14794. }, {
  14795. key: "open",
  14796. value: function open() {
  14797. if (this.isOpen) {
  14798. return;
  14799. }
  14800. this.isOpen = true;
  14801. this.toggleButton.classList.add("toggled");
  14802. this.toggleButton.setAttribute("aria-expanded", "true");
  14803. this.outerContainer.classList.add("sidebarMoving",
  14804. "sidebarOpen");
  14805. if (this.active === _ui_utils.SidebarView.THUMBS) {
  14806. this._updateThumbnailViewer();
  14807. }
  14808. this._forceRendering();
  14809. this._dispatchEvent();
  14810. this._hideUINotification();
  14811. }
  14812. }, {
  14813. key: "close",
  14814. value: function close() {
  14815. if (!this.isOpen) {
  14816. return;
  14817. }
  14818. this.isOpen = false;
  14819. this.toggleButton.classList.remove("toggled");
  14820. this.toggleButton.setAttribute("aria-expanded", "false");
  14821. this.outerContainer.classList.add("sidebarMoving");
  14822. this.outerContainer.classList.remove("sidebarOpen");
  14823. this._forceRendering();
  14824. this._dispatchEvent();
  14825. }
  14826. }, {
  14827. key: "toggle",
  14828. value: function toggle() {
  14829. if (this.isOpen) {
  14830. this.close();
  14831. } else {
  14832. this.open();
  14833. }
  14834. }
  14835. }, {
  14836. key: "_dispatchEvent",
  14837. value: function _dispatchEvent() {
  14838. this.eventBus.dispatch("sidebarviewchanged", {
  14839. source: this,
  14840. view: this.visibleView
  14841. });
  14842. }
  14843. }, {
  14844. key: "_forceRendering",
  14845. value: function _forceRendering() {
  14846. if (this.onToggled) {
  14847. this.onToggled();
  14848. } else {
  14849. this.pdfViewer.forceRendering();
  14850. this.pdfThumbnailViewer.forceRendering();
  14851. }
  14852. }
  14853. }, {
  14854. key: "_updateThumbnailViewer",
  14855. value: function _updateThumbnailViewer() {
  14856. var pdfViewer = this.pdfViewer,
  14857. pdfThumbnailViewer = this.pdfThumbnailViewer;
  14858. var pagesCount = pdfViewer.pagesCount;
  14859. for (var pageIndex = 0; pageIndex <
  14860. pagesCount; pageIndex++) {
  14861. var pageView = pdfViewer.getPageView(pageIndex);
  14862. if ((pageView === null || pageView === void 0 ? void 0 :
  14863. pageView.renderingState) === _ui_utils
  14864. .RenderingStates.FINISHED) {
  14865. var thumbnailView = pdfThumbnailViewer.getThumbnail(
  14866. pageIndex);
  14867. thumbnailView.setImage(pageView);
  14868. }
  14869. }
  14870. pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer
  14871. .currentPageNumber);
  14872. }
  14873. }, {
  14874. key: "_showUINotification",
  14875. value: function _showUINotification() {
  14876. var _this = this;
  14877. this.l10n.get("toggle_sidebar_notification2.title").then(
  14878. function(msg) {
  14879. _this.toggleButton.title = msg;
  14880. });
  14881. if (!this.isOpen) {
  14882. this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
  14883. }
  14884. }
  14885. }, {
  14886. key: "_hideUINotification",
  14887. value: function _hideUINotification() {
  14888. var _this2 = this;
  14889. var reset = arguments.length > 0 && arguments[0] !==
  14890. undefined ? arguments[0] : false;
  14891. if (this.isOpen || reset) {
  14892. this.toggleButton.classList.remove(
  14893. UI_NOTIFICATION_CLASS);
  14894. }
  14895. if (reset) {
  14896. this.l10n.get("toggle_sidebar.title").then(function(
  14897. msg) {
  14898. _this2.toggleButton.title = msg;
  14899. });
  14900. }
  14901. }
  14902. }, {
  14903. key: "_addEventListeners",
  14904. value: function _addEventListeners() {
  14905. var _this3 = this;
  14906. this.viewerContainer.addEventListener("transitionend",
  14907. function(evt) {
  14908. if (evt.target === _this3.viewerContainer) {
  14909. _this3.outerContainer.classList.remove(
  14910. "sidebarMoving");
  14911. }
  14912. });
  14913. this.toggleButton.addEventListener("click", function() {
  14914. _this3.toggle();
  14915. });
  14916. this.thumbnailButton.addEventListener("click", function() {
  14917. _this3.switchView(_ui_utils.SidebarView.THUMBS);
  14918. });
  14919. this.outlineButton.addEventListener("click", function() {
  14920. _this3.switchView(_ui_utils.SidebarView
  14921. .OUTLINE);
  14922. });
  14923. this.outlineButton.addEventListener("dblclick", function() {
  14924. _this3.eventBus.dispatch("toggleoutlinetree", {
  14925. source: _this3
  14926. });
  14927. });
  14928. this.attachmentsButton.addEventListener("click",
  14929. function() {
  14930. _this3.switchView(_ui_utils.SidebarView
  14931. .ATTACHMENTS);
  14932. });
  14933. this.layersButton.addEventListener("click", function() {
  14934. _this3.switchView(_ui_utils.SidebarView.LAYERS);
  14935. });
  14936. this.layersButton.addEventListener("dblclick", function() {
  14937. _this3.eventBus.dispatch("resetlayers", {
  14938. source: _this3
  14939. });
  14940. });
  14941. this._currentOutlineItemButton.addEventListener("click",
  14942. function() {
  14943. _this3.eventBus.dispatch("currentoutlineitem", {
  14944. source: _this3
  14945. });
  14946. });
  14947. var onTreeLoaded = function onTreeLoaded(count, button,
  14948. view) {
  14949. button.disabled = !count;
  14950. if (count) {
  14951. _this3._showUINotification();
  14952. } else if (_this3.active === view) {
  14953. _this3.switchView(_ui_utils.SidebarView.THUMBS);
  14954. }
  14955. };
  14956. this.eventBus._on("outlineloaded", function(evt) {
  14957. onTreeLoaded(evt.outlineCount, _this3
  14958. .outlineButton, _ui_utils.SidebarView
  14959. .OUTLINE);
  14960. evt.currentOutlineItemPromise.then(function(
  14961. enabled) {
  14962. if (!_this3.isInitialViewSet) {
  14963. return;
  14964. }
  14965. _this3._currentOutlineItemButton
  14966. .disabled = !enabled;
  14967. });
  14968. });
  14969. this.eventBus._on("attachmentsloaded", function(evt) {
  14970. onTreeLoaded(evt.attachmentsCount, _this3
  14971. .attachmentsButton, _ui_utils
  14972. .SidebarView.ATTACHMENTS);
  14973. });
  14974. this.eventBus._on("layersloaded", function(evt) {
  14975. onTreeLoaded(evt.layersCount, _this3
  14976. .layersButton, _ui_utils.SidebarView
  14977. .LAYERS);
  14978. });
  14979. this.eventBus._on("presentationmodechanged", function(evt) {
  14980. if (evt.state === _ui_utils
  14981. .PresentationModeState.NORMAL && _this3
  14982. .isThumbnailViewVisible) {
  14983. _this3._updateThumbnailViewer();
  14984. }
  14985. });
  14986. }
  14987. }]);
  14988. return PDFSidebar;
  14989. }();
  14990. exports.PDFSidebar = PDFSidebar;
  14991. /***/
  14992. }),
  14993. /* 26 */
  14994. /***/
  14995. ((__unused_webpack_module, exports) => {
  14996. Object.defineProperty(exports, "__esModule", ({
  14997. value: true
  14998. }));
  14999. exports.PDFSidebarResizer = void 0;
  15000. function _classCallCheck(instance, Constructor) {
  15001. if (!(instance instanceof Constructor)) {
  15002. throw new TypeError("Cannot call a class as a function");
  15003. }
  15004. }
  15005. function _defineProperties(target, props) {
  15006. for (var i = 0; i < props.length; i++) {
  15007. var descriptor = props[i];
  15008. descriptor.enumerable = descriptor.enumerable || false;
  15009. descriptor.configurable = true;
  15010. if ("value" in descriptor) descriptor.writable = true;
  15011. Object.defineProperty(target, descriptor.key, descriptor);
  15012. }
  15013. }
  15014. function _createClass(Constructor, protoProps, staticProps) {
  15015. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  15016. if (staticProps) _defineProperties(Constructor, staticProps);
  15017. Object.defineProperty(Constructor, "prototype", {
  15018. writable: false
  15019. });
  15020. return Constructor;
  15021. }
  15022. var SIDEBAR_WIDTH_VAR = "--sidebar-width";
  15023. var SIDEBAR_MIN_WIDTH = 200;
  15024. var SIDEBAR_RESIZING_CLASS = "sidebarResizing";
  15025. var PDFSidebarResizer = /*#__PURE__*/ function() {
  15026. function PDFSidebarResizer(options, eventBus, l10n) {
  15027. var _this = this;
  15028. _classCallCheck(this, PDFSidebarResizer);
  15029. this.isRTL = false;
  15030. this.sidebarOpen = false;
  15031. this.doc = document.documentElement;
  15032. this._width = null;
  15033. this._outerContainerWidth = null;
  15034. this._boundEvents = Object.create(null);
  15035. this.outerContainer = options.outerContainer;
  15036. this.resizer = options.resizer;
  15037. this.eventBus = eventBus;
  15038. l10n.getDirection().then(function(dir) {
  15039. _this.isRTL = dir === "rtl";
  15040. });
  15041. this._addEventListeners();
  15042. }
  15043. _createClass(PDFSidebarResizer, [{
  15044. key: "outerContainerWidth",
  15045. get: function get() {
  15046. return this._outerContainerWidth || (this
  15047. ._outerContainerWidth = this.outerContainer
  15048. .clientWidth);
  15049. }
  15050. }, {
  15051. key: "_updateWidth",
  15052. value: function _updateWidth() {
  15053. var width = arguments.length > 0 && arguments[0] !==
  15054. undefined ? arguments[0] : 0;
  15055. var maxWidth = Math.floor(this.outerContainerWidth / 2);
  15056. if (width > maxWidth) {
  15057. width = maxWidth;
  15058. }
  15059. if (width < SIDEBAR_MIN_WIDTH) {
  15060. width = SIDEBAR_MIN_WIDTH;
  15061. }
  15062. if (width === this._width) {
  15063. return false;
  15064. }
  15065. this._width = width;
  15066. this.doc.style.setProperty(SIDEBAR_WIDTH_VAR, "".concat(
  15067. width, "px"));
  15068. return true;
  15069. }
  15070. }, {
  15071. key: "_mouseMove",
  15072. value: function _mouseMove(evt) {
  15073. var width = evt.clientX;
  15074. if (this.isRTL) {
  15075. width = this.outerContainerWidth - width;
  15076. }
  15077. this._updateWidth(width);
  15078. }
  15079. }, {
  15080. key: "_mouseUp",
  15081. value: function _mouseUp(evt) {
  15082. this.outerContainer.classList.remove(
  15083. SIDEBAR_RESIZING_CLASS);
  15084. this.eventBus.dispatch("resize", {
  15085. source: this
  15086. });
  15087. var _boundEvents = this._boundEvents;
  15088. window.removeEventListener("mousemove", _boundEvents
  15089. .mouseMove);
  15090. window.removeEventListener("mouseup", _boundEvents.mouseUp);
  15091. }
  15092. }, {
  15093. key: "_addEventListeners",
  15094. value: function _addEventListeners() {
  15095. var _this2 = this;
  15096. var _boundEvents = this._boundEvents;
  15097. _boundEvents.mouseMove = this._mouseMove.bind(this);
  15098. _boundEvents.mouseUp = this._mouseUp.bind(this);
  15099. this.resizer.addEventListener("mousedown", function(evt) {
  15100. if (evt.button !== 0) {
  15101. return;
  15102. }
  15103. _this2.outerContainer.classList.add(
  15104. SIDEBAR_RESIZING_CLASS);
  15105. window.addEventListener("mousemove",
  15106. _boundEvents.mouseMove);
  15107. window.addEventListener("mouseup", _boundEvents
  15108. .mouseUp);
  15109. });
  15110. this.eventBus._on("sidebarviewchanged", function(evt) {
  15111. _this2.sidebarOpen = !!(evt !== null && evt !==
  15112. void 0 && evt.view);
  15113. });
  15114. this.eventBus._on("resize", function(evt) {
  15115. if ((evt === null || evt === void 0 ? void 0 :
  15116. evt.source) !== window) {
  15117. return;
  15118. }
  15119. _this2._outerContainerWidth = null;
  15120. if (!_this2._width) {
  15121. return;
  15122. }
  15123. if (!_this2.sidebarOpen) {
  15124. _this2._updateWidth(_this2._width);
  15125. return;
  15126. }
  15127. _this2.outerContainer.classList.add(
  15128. SIDEBAR_RESIZING_CLASS);
  15129. var updated = _this2._updateWidth(_this2
  15130. ._width);
  15131. Promise.resolve().then(function() {
  15132. _this2.outerContainer.classList
  15133. .remove(SIDEBAR_RESIZING_CLASS);
  15134. if (updated) {
  15135. _this2.eventBus.dispatch(
  15136. "resize", {
  15137. source: _this2
  15138. });
  15139. }
  15140. });
  15141. });
  15142. }
  15143. }]);
  15144. return PDFSidebarResizer;
  15145. }();
  15146. exports.PDFSidebarResizer = PDFSidebarResizer;
  15147. /***/
  15148. }),
  15149. /* 27 */
  15150. /***/
  15151. ((__unused_webpack_module, exports, __webpack_require__) => {
  15152. Object.defineProperty(exports, "__esModule", ({
  15153. value: true
  15154. }));
  15155. exports.PDFThumbnailViewer = void 0;
  15156. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  15157. var _ui_utils = __webpack_require__(5);
  15158. var _pdf_thumbnail_view = __webpack_require__(28);
  15159. function _interopRequireDefault(obj) {
  15160. return obj && obj.__esModule ? obj : {
  15161. "default": obj
  15162. };
  15163. }
  15164. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  15165. try {
  15166. var info = gen[key](arg);
  15167. var value = info.value;
  15168. } catch (error) {
  15169. reject(error);
  15170. return;
  15171. }
  15172. if (info.done) {
  15173. resolve(value);
  15174. } else {
  15175. Promise.resolve(value).then(_next, _throw);
  15176. }
  15177. }
  15178. function _asyncToGenerator(fn) {
  15179. return function() {
  15180. var self = this,
  15181. args = arguments;
  15182. return new Promise(function(resolve, reject) {
  15183. var gen = fn.apply(self, args);
  15184. function _next(value) {
  15185. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next",
  15186. value);
  15187. }
  15188. function _throw(err) {
  15189. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw",
  15190. err);
  15191. }
  15192. _next(undefined);
  15193. });
  15194. };
  15195. }
  15196. function _createForOfIteratorHelper(o, allowArrayLike) {
  15197. var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
  15198. if (!it) {
  15199. if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike &&
  15200. o && typeof o.length === "number") {
  15201. if (it) o = it;
  15202. var i = 0;
  15203. var F = function F() {};
  15204. return {
  15205. s: F,
  15206. n: function n() {
  15207. if (i >= o.length) return {
  15208. done: true
  15209. };
  15210. return {
  15211. done: false,
  15212. value: o[i++]
  15213. };
  15214. },
  15215. e: function e(_e) {
  15216. throw _e;
  15217. },
  15218. f: F
  15219. };
  15220. }
  15221. throw new TypeError(
  15222. "Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
  15223. );
  15224. }
  15225. var normalCompletion = true,
  15226. didErr = false,
  15227. err;
  15228. return {
  15229. s: function s() {
  15230. it = it.call(o);
  15231. },
  15232. n: function n() {
  15233. var step = it.next();
  15234. normalCompletion = step.done;
  15235. return step;
  15236. },
  15237. e: function e(_e2) {
  15238. didErr = true;
  15239. err = _e2;
  15240. },
  15241. f: function f() {
  15242. try {
  15243. if (!normalCompletion && it["return"] != null) it["return"]();
  15244. } finally {
  15245. if (didErr) throw err;
  15246. }
  15247. }
  15248. };
  15249. }
  15250. function _unsupportedIterableToArray(o, minLen) {
  15251. if (!o) return;
  15252. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  15253. var n = Object.prototype.toString.call(o).slice(8, -1);
  15254. if (n === "Object" && o.constructor) n = o.constructor.name;
  15255. if (n === "Map" || n === "Set") return Array.from(o);
  15256. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
  15257. return _arrayLikeToArray(o, minLen);
  15258. }
  15259. function _arrayLikeToArray(arr, len) {
  15260. if (len == null || len > arr.length) len = arr.length;
  15261. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  15262. arr2[i] = arr[i];
  15263. }
  15264. return arr2;
  15265. }
  15266. function _classCallCheck(instance, Constructor) {
  15267. if (!(instance instanceof Constructor)) {
  15268. throw new TypeError("Cannot call a class as a function");
  15269. }
  15270. }
  15271. function _defineProperties(target, props) {
  15272. for (var i = 0; i < props.length; i++) {
  15273. var descriptor = props[i];
  15274. descriptor.enumerable = descriptor.enumerable || false;
  15275. descriptor.configurable = true;
  15276. if ("value" in descriptor) descriptor.writable = true;
  15277. Object.defineProperty(target, descriptor.key, descriptor);
  15278. }
  15279. }
  15280. function _createClass(Constructor, protoProps, staticProps) {
  15281. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  15282. if (staticProps) _defineProperties(Constructor, staticProps);
  15283. Object.defineProperty(Constructor, "prototype", {
  15284. writable: false
  15285. });
  15286. return Constructor;
  15287. }
  15288. function _classPrivateMethodInitSpec(obj, privateSet) {
  15289. _checkPrivateRedeclaration(obj, privateSet);
  15290. privateSet.add(obj);
  15291. }
  15292. function _checkPrivateRedeclaration(obj, privateCollection) {
  15293. if (privateCollection.has(obj)) {
  15294. throw new TypeError(
  15295. "Cannot initialize the same private elements twice on an object");
  15296. }
  15297. }
  15298. function _classPrivateMethodGet(receiver, privateSet, fn) {
  15299. if (!privateSet.has(receiver)) {
  15300. throw new TypeError("attempted to get private field on non-instance");
  15301. }
  15302. return fn;
  15303. }
  15304. var THUMBNAIL_SCROLL_MARGIN = -19;
  15305. var THUMBNAIL_SELECTED_CLASS = "selected";
  15306. var _ensurePdfPageLoaded = /*#__PURE__*/ new WeakSet();
  15307. var _getScrollAhead = /*#__PURE__*/ new WeakSet();
  15308. var PDFThumbnailViewer = /*#__PURE__*/ function() {
  15309. function PDFThumbnailViewer(_ref) {
  15310. var _this = this;
  15311. var container = _ref.container,
  15312. eventBus = _ref.eventBus,
  15313. linkService = _ref.linkService,
  15314. renderingQueue = _ref.renderingQueue,
  15315. l10n = _ref.l10n;
  15316. _classCallCheck(this, PDFThumbnailViewer);
  15317. _classPrivateMethodInitSpec(this, _getScrollAhead);
  15318. _classPrivateMethodInitSpec(this, _ensurePdfPageLoaded);
  15319. this.container = container;
  15320. this.linkService = linkService;
  15321. this.renderingQueue = renderingQueue;
  15322. this.l10n = l10n;
  15323. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdated
  15324. .bind(this));
  15325. this._resetView();
  15326. eventBus._on("optionalcontentconfigchanged", function() {
  15327. _this._setImageDisabled = true;
  15328. });
  15329. }
  15330. _createClass(PDFThumbnailViewer, [{
  15331. key: "_scrollUpdated",
  15332. value: function _scrollUpdated() {
  15333. this.renderingQueue.renderHighestPriority();
  15334. }
  15335. }, {
  15336. key: "getThumbnail",
  15337. value: function getThumbnail(index) {
  15338. return this._thumbnails[index];
  15339. }
  15340. }, {
  15341. key: "_getVisibleThumbs",
  15342. value: function _getVisibleThumbs() {
  15343. return (0, _ui_utils.getVisibleElements)({
  15344. scrollEl: this.container,
  15345. views: this._thumbnails
  15346. });
  15347. }
  15348. }, {
  15349. key: "scrollThumbnailIntoView",
  15350. value: function scrollThumbnailIntoView(pageNumber) {
  15351. if (!this.pdfDocument) {
  15352. return;
  15353. }
  15354. var thumbnailView = this._thumbnails[pageNumber - 1];
  15355. if (!thumbnailView) {
  15356. console.error(
  15357. 'scrollThumbnailIntoView: Invalid "pageNumber" parameter.'
  15358. );
  15359. return;
  15360. }
  15361. if (pageNumber !== this._currentPageNumber) {
  15362. var prevThumbnailView = this._thumbnails[this
  15363. ._currentPageNumber - 1];
  15364. prevThumbnailView.div.classList.remove(
  15365. THUMBNAIL_SELECTED_CLASS);
  15366. thumbnailView.div.classList.add(
  15367. THUMBNAIL_SELECTED_CLASS);
  15368. }
  15369. var _this$_getVisibleThum = this._getVisibleThumbs(),
  15370. first = _this$_getVisibleThum.first,
  15371. last = _this$_getVisibleThum.last,
  15372. views = _this$_getVisibleThum.views;
  15373. if (views.length > 0) {
  15374. var shouldScroll = false;
  15375. if (pageNumber <= first.id || pageNumber >= last.id) {
  15376. shouldScroll = true;
  15377. } else {
  15378. var _iterator = _createForOfIteratorHelper(views),
  15379. _step;
  15380. try {
  15381. for (_iterator.s(); !(_step = _iterator.n())
  15382. .done;) {
  15383. var _step$value = _step.value,
  15384. id = _step$value.id,
  15385. percent = _step$value.percent;
  15386. if (id !== pageNumber) {
  15387. continue;
  15388. }
  15389. shouldScroll = percent < 100;
  15390. break;
  15391. }
  15392. } catch (err) {
  15393. _iterator.e(err);
  15394. } finally {
  15395. _iterator.f();
  15396. }
  15397. }
  15398. if (shouldScroll) {
  15399. (0, _ui_utils.scrollIntoView)(thumbnailView.div, {
  15400. top: THUMBNAIL_SCROLL_MARGIN
  15401. });
  15402. }
  15403. }
  15404. this._currentPageNumber = pageNumber;
  15405. }
  15406. }, {
  15407. key: "pagesRotation",
  15408. get: function get() {
  15409. return this._pagesRotation;
  15410. },
  15411. set: function set(rotation) {
  15412. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  15413. throw new Error("Invalid thumbnails rotation angle.");
  15414. }
  15415. if (!this.pdfDocument) {
  15416. return;
  15417. }
  15418. if (this._pagesRotation === rotation) {
  15419. return;
  15420. }
  15421. this._pagesRotation = rotation;
  15422. var updateArgs = {
  15423. rotation: rotation
  15424. };
  15425. var _iterator2 = _createForOfIteratorHelper(this
  15426. ._thumbnails),
  15427. _step2;
  15428. try {
  15429. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  15430. var thumbnail = _step2.value;
  15431. thumbnail.update(updateArgs);
  15432. }
  15433. } catch (err) {
  15434. _iterator2.e(err);
  15435. } finally {
  15436. _iterator2.f();
  15437. }
  15438. }
  15439. }, {
  15440. key: "cleanup",
  15441. value: function cleanup() {
  15442. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  15443. if (this._thumbnails[i] && this._thumbnails[i]
  15444. .renderingState !== _ui_utils.RenderingStates
  15445. .FINISHED) {
  15446. this._thumbnails[i].reset();
  15447. }
  15448. }
  15449. _pdf_thumbnail_view.TempImageFactory.destroyCanvas();
  15450. }
  15451. }, {
  15452. key: "_resetView",
  15453. value: function _resetView() {
  15454. this._thumbnails = [];
  15455. this._currentPageNumber = 1;
  15456. this._pageLabels = null;
  15457. this._pagesRotation = 0;
  15458. this._optionalContentConfigPromise = null;
  15459. this._setImageDisabled = false;
  15460. this.container.textContent = "";
  15461. }
  15462. }, {
  15463. key: "setDocument",
  15464. value: function setDocument(pdfDocument) {
  15465. var _this2 = this;
  15466. if (this.pdfDocument) {
  15467. this._cancelRendering();
  15468. this._resetView();
  15469. }
  15470. this.pdfDocument = pdfDocument;
  15471. if (!pdfDocument) {
  15472. return;
  15473. }
  15474. var firstPagePromise = pdfDocument.getPage(1);
  15475. var optionalContentConfigPromise = pdfDocument
  15476. .getOptionalContentConfig();
  15477. firstPagePromise.then(function(firstPdfPage) {
  15478. _this2._optionalContentConfigPromise =
  15479. optionalContentConfigPromise;
  15480. var pagesCount = pdfDocument.numPages;
  15481. var viewport = firstPdfPage.getViewport({
  15482. scale: 1
  15483. });
  15484. var checkSetImageDisabled =
  15485. function checkSetImageDisabled() {
  15486. return _this2._setImageDisabled;
  15487. };
  15488. for (var pageNum = 1; pageNum <= pagesCount; ++
  15489. pageNum) {
  15490. var thumbnail = new _pdf_thumbnail_view
  15491. .PDFThumbnailView({
  15492. container: _this2.container,
  15493. id: pageNum,
  15494. defaultViewport: viewport
  15495. .clone(),
  15496. optionalContentConfigPromise: optionalContentConfigPromise,
  15497. linkService: _this2.linkService,
  15498. renderingQueue: _this2
  15499. .renderingQueue,
  15500. checkSetImageDisabled: checkSetImageDisabled,
  15501. l10n: _this2.l10n
  15502. });
  15503. _this2._thumbnails.push(thumbnail);
  15504. }
  15505. var firstThumbnailView = _this2._thumbnails[0];
  15506. if (firstThumbnailView) {
  15507. firstThumbnailView.setPdfPage(firstPdfPage);
  15508. }
  15509. var thumbnailView = _this2._thumbnails[_this2
  15510. ._currentPageNumber - 1];
  15511. thumbnailView.div.classList.add(
  15512. THUMBNAIL_SELECTED_CLASS);
  15513. })["catch"](function(reason) {
  15514. console.error(
  15515. "Unable to initialize thumbnail viewer",
  15516. reason);
  15517. });
  15518. }
  15519. }, {
  15520. key: "_cancelRendering",
  15521. value: function _cancelRendering() {
  15522. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  15523. if (this._thumbnails[i]) {
  15524. this._thumbnails[i].cancelRendering();
  15525. }
  15526. }
  15527. }
  15528. }, {
  15529. key: "setPageLabels",
  15530. value: function setPageLabels(labels) {
  15531. if (!this.pdfDocument) {
  15532. return;
  15533. }
  15534. if (!labels) {
  15535. this._pageLabels = null;
  15536. } else if (!(Array.isArray(labels) && this.pdfDocument
  15537. .numPages === labels.length)) {
  15538. this._pageLabels = null;
  15539. console.error(
  15540. "PDFThumbnailViewer_setPageLabels: Invalid page labels."
  15541. );
  15542. } else {
  15543. this._pageLabels = labels;
  15544. }
  15545. for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
  15546. var _this$_pageLabels$i, _this$_pageLabels;
  15547. this._thumbnails[i].setPageLabel((_this$_pageLabels$i =
  15548. (_this$_pageLabels = this._pageLabels) ===
  15549. null || _this$_pageLabels === void 0 ?
  15550. void 0 : _this$_pageLabels[i]) !== null &&
  15551. _this$_pageLabels$i !== void 0 ?
  15552. _this$_pageLabels$i : null);
  15553. }
  15554. }
  15555. }, {
  15556. key: "forceRendering",
  15557. value: function forceRendering() {
  15558. var _this3 = this;
  15559. var visibleThumbs = this._getVisibleThumbs();
  15560. var scrollAhead = _classPrivateMethodGet(this,
  15561. _getScrollAhead, _getScrollAhead2).call(this,
  15562. visibleThumbs);
  15563. var thumbView = this.renderingQueue.getHighestPriority(
  15564. visibleThumbs, this._thumbnails, scrollAhead);
  15565. if (thumbView) {
  15566. _classPrivateMethodGet(this, _ensurePdfPageLoaded,
  15567. _ensurePdfPageLoaded2).call(this, thumbView)
  15568. .then(function() {
  15569. _this3.renderingQueue.renderView(thumbView);
  15570. });
  15571. return true;
  15572. }
  15573. return false;
  15574. }
  15575. }]);
  15576. return PDFThumbnailViewer;
  15577. }();
  15578. exports.PDFThumbnailViewer = PDFThumbnailViewer;
  15579. function _ensurePdfPageLoaded2(_x) {
  15580. return _ensurePdfPageLoaded3.apply(this, arguments);
  15581. }
  15582. function _ensurePdfPageLoaded3() {
  15583. _ensurePdfPageLoaded3 = _asyncToGenerator( /*#__PURE__*/ _regenerator["default"].mark(
  15584. function _callee(thumbView) {
  15585. var pdfPage;
  15586. return _regenerator["default"].wrap(function _callee$(_context) {
  15587. while (1) {
  15588. switch (_context.prev = _context.next) {
  15589. case 0:
  15590. if (!thumbView.pdfPage) {
  15591. _context.next = 2;
  15592. break;
  15593. }
  15594. return _context.abrupt("return", thumbView
  15595. .pdfPage);
  15596. case 2:
  15597. _context.prev = 2;
  15598. _context.next = 5;
  15599. return this.pdfDocument.getPage(thumbView.id);
  15600. case 5:
  15601. pdfPage = _context.sent;
  15602. if (!thumbView.pdfPage) {
  15603. thumbView.setPdfPage(pdfPage);
  15604. }
  15605. return _context.abrupt("return", pdfPage);
  15606. case 10:
  15607. _context.prev = 10;
  15608. _context.t0 = _context["catch"](2);
  15609. console.error(
  15610. "Unable to get page for thumb view",
  15611. _context.t0);
  15612. return _context.abrupt("return", null);
  15613. case 14:
  15614. case "end":
  15615. return _context.stop();
  15616. }
  15617. }
  15618. }, _callee, this, [
  15619. [2, 10]
  15620. ]);
  15621. }));
  15622. return _ensurePdfPageLoaded3.apply(this, arguments);
  15623. }
  15624. function _getScrollAhead2(visible) {
  15625. var _visible$first, _visible$last;
  15626. if (((_visible$first = visible.first) === null || _visible$first === void 0 ? void 0 :
  15627. _visible$first.id) === 1) {
  15628. return true;
  15629. } else if (((_visible$last = visible.last) === null || _visible$last === void 0 ?
  15630. void 0 : _visible$last.id) === this._thumbnails.length) {
  15631. return false;
  15632. }
  15633. return this.scroll.down;
  15634. }
  15635. /***/
  15636. }),
  15637. /* 28 */
  15638. /***/
  15639. ((__unused_webpack_module, exports, __webpack_require__) => {
  15640. Object.defineProperty(exports, "__esModule", ({
  15641. value: true
  15642. }));
  15643. exports.TempImageFactory = exports.PDFThumbnailView = void 0;
  15644. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  15645. var _ui_utils = __webpack_require__(5);
  15646. var _pdfjsLib = __webpack_require__(7);
  15647. function _interopRequireDefault(obj) {
  15648. return obj && obj.__esModule ? obj : {
  15649. "default": obj
  15650. };
  15651. }
  15652. function _slicedToArray(arr, i) {
  15653. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) ||
  15654. _unsupportedIterableToArray(arr, i) || _nonIterableRest();
  15655. }
  15656. function _nonIterableRest() {
  15657. throw new TypeError(
  15658. "Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
  15659. );
  15660. }
  15661. function _unsupportedIterableToArray(o, minLen) {
  15662. if (!o) return;
  15663. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  15664. var n = Object.prototype.toString.call(o).slice(8, -1);
  15665. if (n === "Object" && o.constructor) n = o.constructor.name;
  15666. if (n === "Map" || n === "Set") return Array.from(o);
  15667. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
  15668. return _arrayLikeToArray(o, minLen);
  15669. }
  15670. function _arrayLikeToArray(arr, len) {
  15671. if (len == null || len > arr.length) len = arr.length;
  15672. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  15673. arr2[i] = arr[i];
  15674. }
  15675. return arr2;
  15676. }
  15677. function _iterableToArrayLimit(arr, i) {
  15678. var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] ||
  15679. arr["@@iterator"];
  15680. if (_i == null) return;
  15681. var _arr = [];
  15682. var _n = true;
  15683. var _d = false;
  15684. var _s, _e;
  15685. try {
  15686. for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
  15687. _arr.push(_s.value);
  15688. if (i && _arr.length === i) break;
  15689. }
  15690. } catch (err) {
  15691. _d = true;
  15692. _e = err;
  15693. } finally {
  15694. try {
  15695. if (!_n && _i["return"] != null) _i["return"]();
  15696. } finally {
  15697. if (_d) throw _e;
  15698. }
  15699. }
  15700. return _arr;
  15701. }
  15702. function _arrayWithHoles(arr) {
  15703. if (Array.isArray(arr)) return arr;
  15704. }
  15705. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  15706. try {
  15707. var info = gen[key](arg);
  15708. var value = info.value;
  15709. } catch (error) {
  15710. reject(error);
  15711. return;
  15712. }
  15713. if (info.done) {
  15714. resolve(value);
  15715. } else {
  15716. Promise.resolve(value).then(_next, _throw);
  15717. }
  15718. }
  15719. function _asyncToGenerator(fn) {
  15720. return function() {
  15721. var self = this,
  15722. args = arguments;
  15723. return new Promise(function(resolve, reject) {
  15724. var gen = fn.apply(self, args);
  15725. function _next(value) {
  15726. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next",
  15727. value);
  15728. }
  15729. function _throw(err) {
  15730. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw",
  15731. err);
  15732. }
  15733. _next(undefined);
  15734. });
  15735. };
  15736. }
  15737. function _classCallCheck(instance, Constructor) {
  15738. if (!(instance instanceof Constructor)) {
  15739. throw new TypeError("Cannot call a class as a function");
  15740. }
  15741. }
  15742. function _defineProperties(target, props) {
  15743. for (var i = 0; i < props.length; i++) {
  15744. var descriptor = props[i];
  15745. descriptor.enumerable = descriptor.enumerable || false;
  15746. descriptor.configurable = true;
  15747. if ("value" in descriptor) descriptor.writable = true;
  15748. Object.defineProperty(target, descriptor.key, descriptor);
  15749. }
  15750. }
  15751. function _createClass(Constructor, protoProps, staticProps) {
  15752. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  15753. if (staticProps) _defineProperties(Constructor, staticProps);
  15754. Object.defineProperty(Constructor, "prototype", {
  15755. writable: false
  15756. });
  15757. return Constructor;
  15758. }
  15759. function _classStaticPrivateFieldSpecSet(receiver, classConstructor, descriptor, value) {
  15760. _classCheckPrivateStaticAccess(receiver, classConstructor);
  15761. _classCheckPrivateStaticFieldDescriptor(descriptor, "set");
  15762. _classApplyDescriptorSet(receiver, descriptor, value);
  15763. return value;
  15764. }
  15765. function _classApplyDescriptorSet(receiver, descriptor, value) {
  15766. if (descriptor.set) {
  15767. descriptor.set.call(receiver, value);
  15768. } else {
  15769. if (!descriptor.writable) {
  15770. throw new TypeError("attempted to set read only private field");
  15771. }
  15772. descriptor.value = value;
  15773. }
  15774. }
  15775. function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) {
  15776. _classCheckPrivateStaticAccess(receiver, classConstructor);
  15777. _classCheckPrivateStaticFieldDescriptor(descriptor, "get");
  15778. return _classApplyDescriptorGet(receiver, descriptor);
  15779. }
  15780. function _classCheckPrivateStaticFieldDescriptor(descriptor, action) {
  15781. if (descriptor === undefined) {
  15782. throw new TypeError("attempted to " + action +
  15783. " private static field before its declaration");
  15784. }
  15785. }
  15786. function _classCheckPrivateStaticAccess(receiver, classConstructor) {
  15787. if (receiver !== classConstructor) {
  15788. throw new TypeError("Private static access of wrong provenance");
  15789. }
  15790. }
  15791. function _classApplyDescriptorGet(receiver, descriptor) {
  15792. if (descriptor.get) {
  15793. return descriptor.get.call(receiver);
  15794. }
  15795. return descriptor.value;
  15796. }
  15797. var DRAW_UPSCALE_FACTOR = 2;
  15798. var MAX_NUM_SCALING_STEPS = 3;
  15799. var THUMBNAIL_CANVAS_BORDER_WIDTH = 1;
  15800. var THUMBNAIL_WIDTH = 98;
  15801. var TempImageFactory = /*#__PURE__*/ function() {
  15802. function TempImageFactory() {
  15803. _classCallCheck(this, TempImageFactory);
  15804. }
  15805. _createClass(TempImageFactory, null, [{
  15806. key: "getCanvas",
  15807. value: function getCanvas(width, height) {
  15808. var tempCanvas = _classStaticPrivateFieldSpecGet(this,
  15809. TempImageFactory, _tempCanvas) ||
  15810. _classStaticPrivateFieldSpecSet(this, TempImageFactory,
  15811. _tempCanvas, document.createElement("canvas"));
  15812. tempCanvas.width = width;
  15813. tempCanvas.height = height;
  15814. tempCanvas.mozOpaque = true;
  15815. var ctx = tempCanvas.getContext("2d", {
  15816. alpha: false
  15817. });
  15818. ctx.save();
  15819. ctx.fillStyle = "rgb(255, 255, 255)";
  15820. ctx.fillRect(0, 0, width, height);
  15821. ctx.restore();
  15822. return [tempCanvas, tempCanvas.getContext("2d")];
  15823. }
  15824. }, {
  15825. key: "destroyCanvas",
  15826. value: function destroyCanvas() {
  15827. var tempCanvas = _classStaticPrivateFieldSpecGet(this,
  15828. TempImageFactory, _tempCanvas);
  15829. if (tempCanvas) {
  15830. tempCanvas.width = 0;
  15831. tempCanvas.height = 0;
  15832. }
  15833. _classStaticPrivateFieldSpecSet(this, TempImageFactory,
  15834. _tempCanvas, null);
  15835. }
  15836. }]);
  15837. return TempImageFactory;
  15838. }();
  15839. exports.TempImageFactory = TempImageFactory;
  15840. var _tempCanvas = {
  15841. writable: true,
  15842. value: null
  15843. };
  15844. var PDFThumbnailView = /*#__PURE__*/ function() {
  15845. function PDFThumbnailView(_ref) {
  15846. var container = _ref.container,
  15847. id = _ref.id,
  15848. defaultViewport = _ref.defaultViewport,
  15849. optionalContentConfigPromise = _ref.optionalContentConfigPromise,
  15850. linkService = _ref.linkService,
  15851. renderingQueue = _ref.renderingQueue,
  15852. checkSetImageDisabled = _ref.checkSetImageDisabled,
  15853. l10n = _ref.l10n;
  15854. _classCallCheck(this, PDFThumbnailView);
  15855. this.id = id;
  15856. this.renderingId = "thumbnail" + id;
  15857. this.pageLabel = null;
  15858. this.pdfPage = null;
  15859. this.rotation = 0;
  15860. this.viewport = defaultViewport;
  15861. this.pdfPageRotate = defaultViewport.rotation;
  15862. this._optionalContentConfigPromise = optionalContentConfigPromise || null;
  15863. this.linkService = linkService;
  15864. this.renderingQueue = renderingQueue;
  15865. this.renderTask = null;
  15866. this.renderingState = _ui_utils.RenderingStates.INITIAL;
  15867. this.resume = null;
  15868. this._checkSetImageDisabled = checkSetImageDisabled || function() {
  15869. return false;
  15870. };
  15871. var pageWidth = this.viewport.width,
  15872. pageHeight = this.viewport.height,
  15873. pageRatio = pageWidth / pageHeight;
  15874. this.canvasWidth = THUMBNAIL_WIDTH;
  15875. this.canvasHeight = this.canvasWidth / pageRatio | 0;
  15876. this.scale = this.canvasWidth / pageWidth;
  15877. this.l10n = l10n;
  15878. var anchor = document.createElement("a");
  15879. anchor.href = linkService.getAnchorUrl("#page=" + id);
  15880. this._thumbPageTitle.then(function(msg) {
  15881. anchor.title = msg;
  15882. });
  15883. anchor.onclick = function() {
  15884. linkService.goToPage(id);
  15885. return false;
  15886. };
  15887. this.anchor = anchor;
  15888. var div = document.createElement("div");
  15889. div.className = "thumbnail";
  15890. div.setAttribute("data-page-number", this.id);
  15891. this.div = div;
  15892. var ring = document.createElement("div");
  15893. ring.className = "thumbnailSelectionRing";
  15894. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  15895. ring.style.width = this.canvasWidth + borderAdjustment + "px";
  15896. ring.style.height = this.canvasHeight + borderAdjustment + "px";
  15897. this.ring = ring;
  15898. div.appendChild(ring);
  15899. anchor.appendChild(div);
  15900. container.appendChild(anchor);
  15901. }
  15902. _createClass(PDFThumbnailView, [{
  15903. key: "setPdfPage",
  15904. value: function setPdfPage(pdfPage) {
  15905. this.pdfPage = pdfPage;
  15906. this.pdfPageRotate = pdfPage.rotate;
  15907. var totalRotation = (this.rotation + this.pdfPageRotate) %
  15908. 360;
  15909. this.viewport = pdfPage.getViewport({
  15910. scale: 1,
  15911. rotation: totalRotation
  15912. });
  15913. this.reset();
  15914. }
  15915. }, {
  15916. key: "reset",
  15917. value: function reset() {
  15918. this.cancelRendering();
  15919. this.renderingState = _ui_utils.RenderingStates.INITIAL;
  15920. var pageWidth = this.viewport.width,
  15921. pageHeight = this.viewport.height,
  15922. pageRatio = pageWidth / pageHeight;
  15923. this.canvasHeight = this.canvasWidth / pageRatio | 0;
  15924. this.scale = this.canvasWidth / pageWidth;
  15925. this.div.removeAttribute("data-loaded");
  15926. var ring = this.ring;
  15927. ring.textContent = "";
  15928. var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
  15929. ring.style.width = this.canvasWidth + borderAdjustment +
  15930. "px";
  15931. ring.style.height = this.canvasHeight + borderAdjustment +
  15932. "px";
  15933. if (this.canvas) {
  15934. this.canvas.width = 0;
  15935. this.canvas.height = 0;
  15936. delete this.canvas;
  15937. }
  15938. if (this.image) {
  15939. this.image.removeAttribute("src");
  15940. delete this.image;
  15941. }
  15942. }
  15943. }, {
  15944. key: "update",
  15945. value: function update(_ref2) {
  15946. var _ref2$rotation = _ref2.rotation,
  15947. rotation = _ref2$rotation === void 0 ? null :
  15948. _ref2$rotation;
  15949. if (typeof rotation === "number") {
  15950. this.rotation = rotation;
  15951. }
  15952. var totalRotation = (this.rotation + this.pdfPageRotate) %
  15953. 360;
  15954. this.viewport = this.viewport.clone({
  15955. scale: 1,
  15956. rotation: totalRotation
  15957. });
  15958. this.reset();
  15959. }
  15960. }, {
  15961. key: "cancelRendering",
  15962. value: function cancelRendering() {
  15963. if (this.renderTask) {
  15964. this.renderTask.cancel();
  15965. this.renderTask = null;
  15966. }
  15967. this.resume = null;
  15968. }
  15969. }, {
  15970. key: "_getPageDrawContext",
  15971. value: function _getPageDrawContext() {
  15972. var upscaleFactor = arguments.length > 0 && arguments[0] !==
  15973. undefined ? arguments[0] : 1;
  15974. var canvas = document.createElement("canvas");
  15975. canvas.mozOpaque = true;
  15976. var ctx = canvas.getContext("2d", {
  15977. alpha: false
  15978. });
  15979. var outputScale = new _ui_utils.OutputScale();
  15980. canvas.width = upscaleFactor * this.canvasWidth *
  15981. outputScale.sx | 0;
  15982. canvas.height = upscaleFactor * this.canvasHeight *
  15983. outputScale.sy | 0;
  15984. var transform = outputScale.scaled ? [outputScale.sx, 0, 0,
  15985. outputScale.sy, 0, 0
  15986. ] : null;
  15987. return {
  15988. ctx: ctx,
  15989. canvas: canvas,
  15990. transform: transform
  15991. };
  15992. }
  15993. }, {
  15994. key: "_convertCanvasToImage",
  15995. value: function _convertCanvasToImage(canvas) {
  15996. if (this.renderingState !== _ui_utils.RenderingStates
  15997. .FINISHED) {
  15998. throw new Error(
  15999. "_convertCanvasToImage: Rendering has not finished."
  16000. );
  16001. }
  16002. var reducedCanvas = this._reduceImage(canvas);
  16003. var image = document.createElement("img");
  16004. image.className = "thumbnailImage";
  16005. this._thumbPageCanvas.then(function(msg) {
  16006. image.setAttribute("aria-label", msg);
  16007. });
  16008. image.style.width = this.canvasWidth + "px";
  16009. image.style.height = this.canvasHeight + "px";
  16010. image.src = reducedCanvas.toDataURL();
  16011. this.image = image;
  16012. this.div.setAttribute("data-loaded", true);
  16013. this.ring.appendChild(image);
  16014. reducedCanvas.width = 0;
  16015. reducedCanvas.height = 0;
  16016. }
  16017. }, {
  16018. key: "draw",
  16019. value: function draw() {
  16020. var _this = this;
  16021. if (this.renderingState !== _ui_utils.RenderingStates
  16022. .INITIAL) {
  16023. console.error("Must be in new state before drawing");
  16024. return Promise.resolve();
  16025. }
  16026. var pdfPage = this.pdfPage;
  16027. if (!pdfPage) {
  16028. this.renderingState = _ui_utils.RenderingStates
  16029. .FINISHED;
  16030. return Promise.reject(new Error(
  16031. "pdfPage is not loaded"));
  16032. }
  16033. this.renderingState = _ui_utils.RenderingStates.RUNNING;
  16034. var finishRenderTask = /*#__PURE__*/ function() {
  16035. var _ref3 = _asyncToGenerator( /*#__PURE__*/
  16036. _regenerator["default"].mark(
  16037. function _callee() {
  16038. var error,
  16039. _args = arguments;
  16040. return _regenerator["default"].wrap(
  16041. function _callee$(
  16042. _context) {
  16043. while (1) {
  16044. switch (_context
  16045. .prev = _context
  16046. .next) {
  16047. case 0:
  16048. error =
  16049. _args
  16050. .length >
  16051. 0 &&
  16052. _args[
  16053. 0] !==
  16054. undefined ?
  16055. _args[
  16056. 0] :
  16057. null;
  16058. if (renderTask ===
  16059. _this
  16060. .renderTask
  16061. ) {
  16062. _this
  16063. .renderTask =
  16064. null;
  16065. }
  16066. if (!(error instanceof _pdfjsLib
  16067. .RenderingCancelledException
  16068. )) {
  16069. _context
  16070. .next =
  16071. 4;
  16072. break;
  16073. }
  16074. return _context
  16075. .abrupt(
  16076. "return"
  16077. );
  16078. case 4:
  16079. _this
  16080. .renderingState =
  16081. _ui_utils
  16082. .RenderingStates
  16083. .FINISHED;
  16084. _this
  16085. ._convertCanvasToImage(
  16086. canvas
  16087. );
  16088. if (!
  16089. error) {
  16090. _context
  16091. .next =
  16092. 8;
  16093. break;
  16094. }
  16095. throw error;
  16096. case 8:
  16097. case "end":
  16098. return _context
  16099. .stop();
  16100. }
  16101. }
  16102. }, _callee);
  16103. }));
  16104. return function finishRenderTask() {
  16105. return _ref3.apply(this, arguments);
  16106. };
  16107. }();
  16108. var _this$_getPageDrawCon = this._getPageDrawContext(
  16109. DRAW_UPSCALE_FACTOR),
  16110. ctx = _this$_getPageDrawCon.ctx,
  16111. canvas = _this$_getPageDrawCon.canvas,
  16112. transform = _this$_getPageDrawCon.transform;
  16113. var drawViewport = this.viewport.clone({
  16114. scale: DRAW_UPSCALE_FACTOR * this.scale
  16115. });
  16116. var renderContinueCallback =
  16117. function renderContinueCallback(cont) {
  16118. if (!_this.renderingQueue.isHighestPriority(
  16119. _this)) {
  16120. _this.renderingState = _ui_utils.RenderingStates
  16121. .PAUSED;
  16122. _this.resume = function() {
  16123. _this.renderingState = _ui_utils
  16124. .RenderingStates.RUNNING;
  16125. cont();
  16126. };
  16127. return;
  16128. }
  16129. cont();
  16130. };
  16131. var renderContext = {
  16132. canvasContext: ctx,
  16133. transform: transform,
  16134. viewport: drawViewport,
  16135. optionalContentConfigPromise: this
  16136. ._optionalContentConfigPromise
  16137. };
  16138. var renderTask = this.renderTask = pdfPage.render(
  16139. renderContext);
  16140. renderTask.onContinue = renderContinueCallback;
  16141. var resultPromise = renderTask.promise.then(function() {
  16142. return finishRenderTask(null);
  16143. }, function(error) {
  16144. return finishRenderTask(error);
  16145. });
  16146. resultPromise["finally"](function() {
  16147. canvas.width = 0;
  16148. canvas.height = 0;
  16149. var pageCached = _this.linkService.isPageCached(
  16150. _this.id);
  16151. if (!pageCached) {
  16152. var _this$pdfPage;
  16153. (_this$pdfPage = _this.pdfPage) === null ||
  16154. _this$pdfPage === void 0 ? void 0 :
  16155. _this$pdfPage.cleanup();
  16156. }
  16157. });
  16158. return resultPromise;
  16159. }
  16160. }, {
  16161. key: "setImage",
  16162. value: function setImage(pageView) {
  16163. if (this._checkSetImageDisabled()) {
  16164. return;
  16165. }
  16166. if (this.renderingState !== _ui_utils.RenderingStates
  16167. .INITIAL) {
  16168. return;
  16169. }
  16170. var canvas = pageView.canvas,
  16171. pdfPage = pageView.pdfPage;
  16172. if (!canvas) {
  16173. return;
  16174. }
  16175. if (!this.pdfPage) {
  16176. this.setPdfPage(pdfPage);
  16177. }
  16178. this.renderingState = _ui_utils.RenderingStates.FINISHED;
  16179. this._convertCanvasToImage(canvas);
  16180. }
  16181. }, {
  16182. key: "_reduceImage",
  16183. value: function _reduceImage(img) {
  16184. var _this$_getPageDrawCon2 = this._getPageDrawContext(),
  16185. ctx = _this$_getPageDrawCon2.ctx,
  16186. canvas = _this$_getPageDrawCon2.canvas;
  16187. if (img.width <= 2 * canvas.width) {
  16188. ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0,
  16189. canvas.width, canvas.height);
  16190. return canvas;
  16191. }
  16192. var reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
  16193. var reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
  16194. var _TempImageFactory$get = TempImageFactory.getCanvas(
  16195. reducedWidth, reducedHeight),
  16196. _TempImageFactory$get2 = _slicedToArray(
  16197. _TempImageFactory$get, 2),
  16198. reducedImage = _TempImageFactory$get2[0],
  16199. reducedImageCtx = _TempImageFactory$get2[1];
  16200. while (reducedWidth > img.width || reducedHeight > img
  16201. .height) {
  16202. reducedWidth >>= 1;
  16203. reducedHeight >>= 1;
  16204. }
  16205. reducedImageCtx.drawImage(img, 0, 0, img.width, img.height,
  16206. 0, 0, reducedWidth, reducedHeight);
  16207. while (reducedWidth > 2 * canvas.width) {
  16208. reducedImageCtx.drawImage(reducedImage, 0, 0,
  16209. reducedWidth, reducedHeight, 0, 0,
  16210. reducedWidth >> 1, reducedHeight >> 1);
  16211. reducedWidth >>= 1;
  16212. reducedHeight >>= 1;
  16213. }
  16214. ctx.drawImage(reducedImage, 0, 0, reducedWidth,
  16215. reducedHeight, 0, 0, canvas.width, canvas.height);
  16216. return canvas;
  16217. }
  16218. }, {
  16219. key: "_thumbPageTitle",
  16220. get: function get() {
  16221. var _this$pageLabel;
  16222. return this.l10n.get("thumb_page_title", {
  16223. page: (_this$pageLabel = this.pageLabel) !==
  16224. null && _this$pageLabel !== void 0 ?
  16225. _this$pageLabel : this.id
  16226. });
  16227. }
  16228. }, {
  16229. key: "_thumbPageCanvas",
  16230. get: function get() {
  16231. var _this$pageLabel2;
  16232. return this.l10n.get("thumb_page_canvas", {
  16233. page: (_this$pageLabel2 = this.pageLabel) !==
  16234. null && _this$pageLabel2 !== void 0 ?
  16235. _this$pageLabel2 : this.id
  16236. });
  16237. }
  16238. }, {
  16239. key: "setPageLabel",
  16240. value: function setPageLabel(label) {
  16241. var _this2 = this;
  16242. this.pageLabel = typeof label === "string" ? label : null;
  16243. this._thumbPageTitle.then(function(msg) {
  16244. _this2.anchor.title = msg;
  16245. });
  16246. if (this.renderingState !== _ui_utils.RenderingStates
  16247. .FINISHED) {
  16248. return;
  16249. }
  16250. this._thumbPageCanvas.then(function(msg) {
  16251. var _this2$image;
  16252. (_this2$image = _this2.image) === null ||
  16253. _this2$image === void 0 ? void 0 :
  16254. _this2$image.setAttribute("aria-label",
  16255. msg);
  16256. });
  16257. }
  16258. }]);
  16259. return PDFThumbnailView;
  16260. }();
  16261. exports.PDFThumbnailView = PDFThumbnailView;
  16262. /***/
  16263. }),
  16264. /* 29 */
  16265. /***/
  16266. ((__unused_webpack_module, exports, __webpack_require__) => {
  16267. function _typeof(obj) {
  16268. "@babel/helpers - typeof";
  16269. return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ?
  16270. function(obj) {
  16271. return typeof obj;
  16272. } : function(obj) {
  16273. return obj && "function" == typeof Symbol && obj.constructor === Symbol &&
  16274. obj !== Symbol.prototype ? "symbol" : typeof obj;
  16275. }, _typeof(obj);
  16276. }
  16277. Object.defineProperty(exports, "__esModule", ({
  16278. value: true
  16279. }));
  16280. exports.PDFViewer = exports.PDFSinglePageViewer = void 0;
  16281. var _ui_utils = __webpack_require__(5);
  16282. var _base_viewer = __webpack_require__(30);
  16283. function _get() {
  16284. if (typeof Reflect !== "undefined" && Reflect.get) {
  16285. _get = Reflect.get;
  16286. } else {
  16287. _get = function _get(target, property, receiver) {
  16288. var base = _superPropBase(target, property);
  16289. if (!base) return;
  16290. var desc = Object.getOwnPropertyDescriptor(base, property);
  16291. if (desc.get) {
  16292. return desc.get.call(arguments.length < 3 ? target : receiver);
  16293. }
  16294. return desc.value;
  16295. };
  16296. }
  16297. return _get.apply(this, arguments);
  16298. }
  16299. function _superPropBase(object, property) {
  16300. while (!Object.prototype.hasOwnProperty.call(object, property)) {
  16301. object = _getPrototypeOf(object);
  16302. if (object === null) break;
  16303. }
  16304. return object;
  16305. }
  16306. function _defineProperties(target, props) {
  16307. for (var i = 0; i < props.length; i++) {
  16308. var descriptor = props[i];
  16309. descriptor.enumerable = descriptor.enumerable || false;
  16310. descriptor.configurable = true;
  16311. if ("value" in descriptor) descriptor.writable = true;
  16312. Object.defineProperty(target, descriptor.key, descriptor);
  16313. }
  16314. }
  16315. function _createClass(Constructor, protoProps, staticProps) {
  16316. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  16317. if (staticProps) _defineProperties(Constructor, staticProps);
  16318. Object.defineProperty(Constructor, "prototype", {
  16319. writable: false
  16320. });
  16321. return Constructor;
  16322. }
  16323. function _classCallCheck(instance, Constructor) {
  16324. if (!(instance instanceof Constructor)) {
  16325. throw new TypeError("Cannot call a class as a function");
  16326. }
  16327. }
  16328. function _inherits(subClass, superClass) {
  16329. if (typeof superClass !== "function" && superClass !== null) {
  16330. throw new TypeError("Super expression must either be null or a function");
  16331. }
  16332. subClass.prototype = Object.create(superClass && superClass.prototype, {
  16333. constructor: {
  16334. value: subClass,
  16335. writable: true,
  16336. configurable: true
  16337. }
  16338. });
  16339. Object.defineProperty(subClass, "prototype", {
  16340. writable: false
  16341. });
  16342. if (superClass) _setPrototypeOf(subClass, superClass);
  16343. }
  16344. function _setPrototypeOf(o, p) {
  16345. _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  16346. o.__proto__ = p;
  16347. return o;
  16348. };
  16349. return _setPrototypeOf(o, p);
  16350. }
  16351. function _createSuper(Derived) {
  16352. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  16353. return function _createSuperInternal() {
  16354. var Super = _getPrototypeOf(Derived),
  16355. result;
  16356. if (hasNativeReflectConstruct) {
  16357. var NewTarget = _getPrototypeOf(this).constructor;
  16358. result = Reflect.construct(Super, arguments, NewTarget);
  16359. } else {
  16360. result = Super.apply(this, arguments);
  16361. }
  16362. return _possibleConstructorReturn(this, result);
  16363. };
  16364. }
  16365. function _possibleConstructorReturn(self, call) {
  16366. if (call && (_typeof(call) === "object" || typeof call === "function")) {
  16367. return call;
  16368. } else if (call !== void 0) {
  16369. throw new TypeError("Derived constructors may only return object or undefined");
  16370. }
  16371. return _assertThisInitialized(self);
  16372. }
  16373. function _assertThisInitialized(self) {
  16374. if (self === void 0) {
  16375. throw new ReferenceError(
  16376. "this hasn't been initialised - super() hasn't been called");
  16377. }
  16378. return self;
  16379. }
  16380. function _isNativeReflectConstruct() {
  16381. if (typeof Reflect === "undefined" || !Reflect.construct) return false;
  16382. if (Reflect.construct.sham) return false;
  16383. if (typeof Proxy === "function") return true;
  16384. try {
  16385. Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
  16386. return true;
  16387. } catch (e) {
  16388. return false;
  16389. }
  16390. }
  16391. function _getPrototypeOf(o) {
  16392. _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf :
  16393. function _getPrototypeOf(o) {
  16394. return o.__proto__ || Object.getPrototypeOf(o);
  16395. };
  16396. return _getPrototypeOf(o);
  16397. }
  16398. var PDFViewer = /*#__PURE__*/ function(_BaseViewer) {
  16399. _inherits(PDFViewer, _BaseViewer);
  16400. var _super = _createSuper(PDFViewer);
  16401. function PDFViewer() {
  16402. _classCallCheck(this, PDFViewer);
  16403. return _super.apply(this, arguments);
  16404. }
  16405. return _createClass(PDFViewer);
  16406. }(_base_viewer.BaseViewer);
  16407. exports.PDFViewer = PDFViewer;
  16408. var PDFSinglePageViewer = /*#__PURE__*/ function(_BaseViewer2) {
  16409. _inherits(PDFSinglePageViewer, _BaseViewer2);
  16410. var _super2 = _createSuper(PDFSinglePageViewer);
  16411. function PDFSinglePageViewer() {
  16412. _classCallCheck(this, PDFSinglePageViewer);
  16413. return _super2.apply(this, arguments);
  16414. }
  16415. _createClass(PDFSinglePageViewer, [{
  16416. key: "_resetView",
  16417. value: function _resetView() {
  16418. _get(_getPrototypeOf(PDFSinglePageViewer.prototype),
  16419. "_resetView", this).call(this);
  16420. this._scrollMode = _ui_utils.ScrollMode.PAGE;
  16421. this._spreadMode = _ui_utils.SpreadMode.NONE;
  16422. }
  16423. }, {
  16424. key: "scrollMode",
  16425. set: function set(mode) {}
  16426. }, {
  16427. key: "_updateScrollMode",
  16428. value: function _updateScrollMode() {}
  16429. }, {
  16430. key: "spreadMode",
  16431. set: function set(mode) {}
  16432. }, {
  16433. key: "_updateSpreadMode",
  16434. value: function _updateSpreadMode() {}
  16435. }]);
  16436. return PDFSinglePageViewer;
  16437. }(_base_viewer.BaseViewer);
  16438. exports.PDFSinglePageViewer = PDFSinglePageViewer;
  16439. /***/
  16440. }),
  16441. /* 30 */
  16442. /***/
  16443. ((__unused_webpack_module, exports, __webpack_require__) => {
  16444. Object.defineProperty(exports, "__esModule", ({
  16445. value: true
  16446. }));
  16447. exports.PagesCountLimit = exports.PDFPageViewBuffer = exports.BaseViewer = void 0;
  16448. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  16449. var _pdfjsLib = __webpack_require__(7);
  16450. var _ui_utils = __webpack_require__(5);
  16451. var _annotation_layer_builder = __webpack_require__(31);
  16452. var _l10n_utils = __webpack_require__(32);
  16453. var _pdf_page_view = __webpack_require__(33);
  16454. var _pdf_rendering_queue = __webpack_require__(23);
  16455. var _pdf_link_service = __webpack_require__(10);
  16456. var _struct_tree_layer_builder = __webpack_require__(34);
  16457. var _text_highlighter = __webpack_require__(35);
  16458. var _text_layer_builder = __webpack_require__(36);
  16459. var _xfa_layer_builder = __webpack_require__(37);
  16460. var _Symbol$iterator;
  16461. function _interopRequireDefault(obj) {
  16462. return obj && obj.__esModule ? obj : {
  16463. "default": obj
  16464. };
  16465. }
  16466. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  16467. try {
  16468. var info = gen[key](arg);
  16469. var value = info.value;
  16470. } catch (error) {
  16471. reject(error);
  16472. return;
  16473. }
  16474. if (info.done) {
  16475. resolve(value);
  16476. } else {
  16477. Promise.resolve(value).then(_next, _throw);
  16478. }
  16479. }
  16480. function _asyncToGenerator(fn) {
  16481. return function() {
  16482. var self = this,
  16483. args = arguments;
  16484. return new Promise(function(resolve, reject) {
  16485. var gen = fn.apply(self, args);
  16486. function _next(value) {
  16487. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next",
  16488. value);
  16489. }
  16490. function _throw(err) {
  16491. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw",
  16492. err);
  16493. }
  16494. _next(undefined);
  16495. });
  16496. };
  16497. }
  16498. function _slicedToArray(arr, i) {
  16499. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) ||
  16500. _unsupportedIterableToArray(arr, i) || _nonIterableRest();
  16501. }
  16502. function _nonIterableRest() {
  16503. throw new TypeError(
  16504. "Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
  16505. );
  16506. }
  16507. function _iterableToArrayLimit(arr, i) {
  16508. var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] ||
  16509. arr["@@iterator"];
  16510. if (_i == null) return;
  16511. var _arr = [];
  16512. var _n = true;
  16513. var _d = false;
  16514. var _s, _e;
  16515. try {
  16516. for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
  16517. _arr.push(_s.value);
  16518. if (i && _arr.length === i) break;
  16519. }
  16520. } catch (err) {
  16521. _d = true;
  16522. _e = err;
  16523. } finally {
  16524. try {
  16525. if (!_n && _i["return"] != null) _i["return"]();
  16526. } finally {
  16527. if (_d) throw _e;
  16528. }
  16529. }
  16530. return _arr;
  16531. }
  16532. function _arrayWithHoles(arr) {
  16533. if (Array.isArray(arr)) return arr;
  16534. }
  16535. function _createForOfIteratorHelper(o, allowArrayLike) {
  16536. var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
  16537. if (!it) {
  16538. if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike &&
  16539. o && typeof o.length === "number") {
  16540. if (it) o = it;
  16541. var i = 0;
  16542. var F = function F() {};
  16543. return {
  16544. s: F,
  16545. n: function n() {
  16546. if (i >= o.length) return {
  16547. done: true
  16548. };
  16549. return {
  16550. done: false,
  16551. value: o[i++]
  16552. };
  16553. },
  16554. e: function e(_e2) {
  16555. throw _e2;
  16556. },
  16557. f: F
  16558. };
  16559. }
  16560. throw new TypeError(
  16561. "Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
  16562. );
  16563. }
  16564. var normalCompletion = true,
  16565. didErr = false,
  16566. err;
  16567. return {
  16568. s: function s() {
  16569. it = it.call(o);
  16570. },
  16571. n: function n() {
  16572. var step = it.next();
  16573. normalCompletion = step.done;
  16574. return step;
  16575. },
  16576. e: function e(_e3) {
  16577. didErr = true;
  16578. err = _e3;
  16579. },
  16580. f: function f() {
  16581. try {
  16582. if (!normalCompletion && it["return"] != null) it["return"]();
  16583. } finally {
  16584. if (didErr) throw err;
  16585. }
  16586. }
  16587. };
  16588. }
  16589. function _unsupportedIterableToArray(o, minLen) {
  16590. if (!o) return;
  16591. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  16592. var n = Object.prototype.toString.call(o).slice(8, -1);
  16593. if (n === "Object" && o.constructor) n = o.constructor.name;
  16594. if (n === "Map" || n === "Set") return Array.from(o);
  16595. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
  16596. return _arrayLikeToArray(o, minLen);
  16597. }
  16598. function _arrayLikeToArray(arr, len) {
  16599. if (len == null || len > arr.length) len = arr.length;
  16600. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  16601. arr2[i] = arr[i];
  16602. }
  16603. return arr2;
  16604. }
  16605. function _classCallCheck(instance, Constructor) {
  16606. if (!(instance instanceof Constructor)) {
  16607. throw new TypeError("Cannot call a class as a function");
  16608. }
  16609. }
  16610. function _defineProperties(target, props) {
  16611. for (var i = 0; i < props.length; i++) {
  16612. var descriptor = props[i];
  16613. descriptor.enumerable = descriptor.enumerable || false;
  16614. descriptor.configurable = true;
  16615. if ("value" in descriptor) descriptor.writable = true;
  16616. Object.defineProperty(target, descriptor.key, descriptor);
  16617. }
  16618. }
  16619. function _createClass(Constructor, protoProps, staticProps) {
  16620. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  16621. if (staticProps) _defineProperties(Constructor, staticProps);
  16622. Object.defineProperty(Constructor, "prototype", {
  16623. writable: false
  16624. });
  16625. return Constructor;
  16626. }
  16627. function _classPrivateMethodInitSpec(obj, privateSet) {
  16628. _checkPrivateRedeclaration(obj, privateSet);
  16629. privateSet.add(obj);
  16630. }
  16631. function _classPrivateFieldInitSpec(obj, privateMap, value) {
  16632. _checkPrivateRedeclaration(obj, privateMap);
  16633. privateMap.set(obj, value);
  16634. }
  16635. function _checkPrivateRedeclaration(obj, privateCollection) {
  16636. if (privateCollection.has(obj)) {
  16637. throw new TypeError(
  16638. "Cannot initialize the same private elements twice on an object");
  16639. }
  16640. }
  16641. function _classPrivateMethodGet(receiver, privateSet, fn) {
  16642. if (!privateSet.has(receiver)) {
  16643. throw new TypeError("attempted to get private field on non-instance");
  16644. }
  16645. return fn;
  16646. }
  16647. function _classPrivateFieldGet(receiver, privateMap) {
  16648. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get");
  16649. return _classApplyDescriptorGet(receiver, descriptor);
  16650. }
  16651. function _classApplyDescriptorGet(receiver, descriptor) {
  16652. if (descriptor.get) {
  16653. return descriptor.get.call(receiver);
  16654. }
  16655. return descriptor.value;
  16656. }
  16657. function _classPrivateFieldSet(receiver, privateMap, value) {
  16658. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set");
  16659. _classApplyDescriptorSet(receiver, descriptor, value);
  16660. return value;
  16661. }
  16662. function _classExtractFieldDescriptor(receiver, privateMap, action) {
  16663. if (!privateMap.has(receiver)) {
  16664. throw new TypeError("attempted to " + action + " private field on non-instance");
  16665. }
  16666. return privateMap.get(receiver);
  16667. }
  16668. function _classApplyDescriptorSet(receiver, descriptor, value) {
  16669. if (descriptor.set) {
  16670. descriptor.set.call(receiver, value);
  16671. } else {
  16672. if (!descriptor.writable) {
  16673. throw new TypeError("attempted to set read only private field");
  16674. }
  16675. descriptor.value = value;
  16676. }
  16677. }
  16678. var DEFAULT_CACHE_SIZE = 10;
  16679. var ENABLE_PERMISSIONS_CLASS = "enablePermissions";
  16680. var PagesCountLimit = {
  16681. FORCE_SCROLL_MODE_PAGE: 15000,
  16682. FORCE_LAZY_PAGE_INIT: 7500,
  16683. PAUSE_EAGER_PAGE_INIT: 250
  16684. };
  16685. exports.PagesCountLimit = PagesCountLimit;
  16686. var _buf = /*#__PURE__*/ new WeakMap();
  16687. var _size = /*#__PURE__*/ new WeakMap();
  16688. var _destroyFirstView = /*#__PURE__*/ new WeakSet();
  16689. _Symbol$iterator = Symbol.iterator;
  16690. var PDFPageViewBuffer = /*#__PURE__*/ function() {
  16691. function PDFPageViewBuffer(size) {
  16692. _classCallCheck(this, PDFPageViewBuffer);
  16693. _classPrivateMethodInitSpec(this, _destroyFirstView);
  16694. _classPrivateFieldInitSpec(this, _buf, {
  16695. writable: true,
  16696. value: new Set()
  16697. });
  16698. _classPrivateFieldInitSpec(this, _size, {
  16699. writable: true,
  16700. value: 0
  16701. });
  16702. _classPrivateFieldSet(this, _size, size);
  16703. }
  16704. _createClass(PDFPageViewBuffer, [{
  16705. key: "push",
  16706. value: function push(view) {
  16707. var buf = _classPrivateFieldGet(this, _buf);
  16708. if (buf.has(view)) {
  16709. buf["delete"](view);
  16710. }
  16711. buf.add(view);
  16712. if (buf.size > _classPrivateFieldGet(this, _size)) {
  16713. _classPrivateMethodGet(this, _destroyFirstView,
  16714. _destroyFirstView2).call(this);
  16715. }
  16716. }
  16717. }, {
  16718. key: "resize",
  16719. value: function resize(newSize) {
  16720. var idsToKeep = arguments.length > 1 && arguments[1] !==
  16721. undefined ? arguments[1] : null;
  16722. _classPrivateFieldSet(this, _size, newSize);
  16723. var buf = _classPrivateFieldGet(this, _buf);
  16724. if (idsToKeep) {
  16725. var ii = buf.size;
  16726. var i = 1;
  16727. var _iterator = _createForOfIteratorHelper(buf),
  16728. _step;
  16729. try {
  16730. for (_iterator.s(); !(_step = _iterator.n())
  16731. .done;) {
  16732. var view = _step.value;
  16733. if (idsToKeep.has(view.id)) {
  16734. buf["delete"](view);
  16735. buf.add(view);
  16736. }
  16737. if (++i > ii) {
  16738. break;
  16739. }
  16740. }
  16741. } catch (err) {
  16742. _iterator.e(err);
  16743. } finally {
  16744. _iterator.f();
  16745. }
  16746. }
  16747. while (buf.size > _classPrivateFieldGet(this, _size)) {
  16748. _classPrivateMethodGet(this, _destroyFirstView,
  16749. _destroyFirstView2).call(this);
  16750. }
  16751. }
  16752. }, {
  16753. key: "has",
  16754. value: function has(view) {
  16755. return _classPrivateFieldGet(this, _buf).has(view);
  16756. }
  16757. }, {
  16758. key: _Symbol$iterator,
  16759. value: function value() {
  16760. return _classPrivateFieldGet(this, _buf).keys();
  16761. }
  16762. }]);
  16763. return PDFPageViewBuffer;
  16764. }();
  16765. exports.PDFPageViewBuffer = PDFPageViewBuffer;
  16766. function _destroyFirstView2() {
  16767. var firstView = _classPrivateFieldGet(this, _buf).keys().next().value;
  16768. firstView === null || firstView === void 0 ? void 0 : firstView.destroy();
  16769. _classPrivateFieldGet(this, _buf)["delete"](firstView);
  16770. }
  16771. var _buffer = /*#__PURE__*/ new WeakMap();
  16772. var _annotationMode = /*#__PURE__*/ new WeakMap();
  16773. var _previousAnnotationMode = /*#__PURE__*/ new WeakMap();
  16774. var _enablePermissions = /*#__PURE__*/ new WeakMap();
  16775. var _previousContainerHeight = /*#__PURE__*/ new WeakMap();
  16776. var _scrollModePageState = /*#__PURE__*/ new WeakMap();
  16777. var _onVisibilityChange = /*#__PURE__*/ new WeakMap();
  16778. var _initializePermissions = /*#__PURE__*/ new WeakSet();
  16779. var _onePageRenderedOrForceFetch = /*#__PURE__*/ new WeakSet();
  16780. var _ensurePageViewVisible = /*#__PURE__*/ new WeakSet();
  16781. var _isSameScale = /*#__PURE__*/ new WeakSet();
  16782. var _ensurePdfPageLoaded = /*#__PURE__*/ new WeakSet();
  16783. var _getScrollAhead = /*#__PURE__*/ new WeakSet();
  16784. var _toggleLoadingIconSpinner = /*#__PURE__*/ new WeakSet();
  16785. var BaseViewer = /*#__PURE__*/ function() {
  16786. function BaseViewer(options) {
  16787. var _this$container,
  16788. _this$viewer,
  16789. _options$textLayerMod,
  16790. _options$annotationMo,
  16791. _this = this;
  16792. _classCallCheck(this, BaseViewer);
  16793. _classPrivateMethodInitSpec(this, _toggleLoadingIconSpinner);
  16794. _classPrivateMethodInitSpec(this, _getScrollAhead);
  16795. _classPrivateMethodInitSpec(this, _ensurePdfPageLoaded);
  16796. _classPrivateMethodInitSpec(this, _isSameScale);
  16797. _classPrivateMethodInitSpec(this, _ensurePageViewVisible);
  16798. _classPrivateMethodInitSpec(this, _onePageRenderedOrForceFetch);
  16799. _classPrivateMethodInitSpec(this, _initializePermissions);
  16800. _classPrivateFieldInitSpec(this, _buffer, {
  16801. writable: true,
  16802. value: null
  16803. });
  16804. _classPrivateFieldInitSpec(this, _annotationMode, {
  16805. writable: true,
  16806. value: _pdfjsLib.AnnotationMode.ENABLE_FORMS
  16807. });
  16808. _classPrivateFieldInitSpec(this, _previousAnnotationMode, {
  16809. writable: true,
  16810. value: null
  16811. });
  16812. _classPrivateFieldInitSpec(this, _enablePermissions, {
  16813. writable: true,
  16814. value: false
  16815. });
  16816. _classPrivateFieldInitSpec(this, _previousContainerHeight, {
  16817. writable: true,
  16818. value: 0
  16819. });
  16820. _classPrivateFieldInitSpec(this, _scrollModePageState, {
  16821. writable: true,
  16822. value: null
  16823. });
  16824. _classPrivateFieldInitSpec(this, _onVisibilityChange, {
  16825. writable: true,
  16826. value: null
  16827. });
  16828. if (this.constructor === BaseViewer) {
  16829. throw new Error("Cannot initialize BaseViewer.");
  16830. }
  16831. var viewerVersion = '2.13.216';
  16832. if (_pdfjsLib.version !== viewerVersion) {
  16833. throw new Error("The API version \"".concat(_pdfjsLib.version,
  16834. "\" does not match the Viewer version \"").concat(viewerVersion,
  16835. "\"."));
  16836. }
  16837. this.container = options.container;
  16838. this.viewer = options.viewer || options.container.firstElementChild;
  16839. if (!(((_this$container = this.container) === null || _this$container ===
  16840. void 0 ? void 0 : _this$container.tagName.toUpperCase()) ===
  16841. "DIV" && ((_this$viewer = this.viewer) === null || _this$viewer ===
  16842. void 0 ? void 0 : _this$viewer.tagName.toUpperCase()) === "DIV")) {
  16843. throw new Error("Invalid `container` and/or `viewer` option.");
  16844. }
  16845. if (this.container.offsetParent && getComputedStyle(this.container).position !==
  16846. "absolute") {
  16847. throw new Error("The `container` must be absolutely positioned.");
  16848. }
  16849. this.eventBus = options.eventBus;
  16850. this.linkService = options.linkService || new _pdf_link_service
  16851. .SimpleLinkService();
  16852. this.downloadManager = options.downloadManager || null;
  16853. this.findController = options.findController || null;
  16854. this._scriptingManager = options.scriptingManager || null;
  16855. this.removePageBorders = options.removePageBorders || false;
  16856. this.textLayerMode = (_options$textLayerMod = options.textLayerMode) !== null &&
  16857. _options$textLayerMod !== void 0 ? _options$textLayerMod : _ui_utils
  16858. .TextLayerMode.ENABLE;
  16859. _classPrivateFieldSet(this, _annotationMode, (_options$annotationMo = options
  16860. .annotationMode) !== null && _options$annotationMo !== void 0 ?
  16861. _options$annotationMo : _pdfjsLib.AnnotationMode.ENABLE_FORMS);
  16862. this.imageResourcesPath = options.imageResourcesPath || "";
  16863. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  16864. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  16865. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  16866. this.maxCanvasPixels = options.maxCanvasPixels;
  16867. this.l10n = options.l10n || _l10n_utils.NullL10n;
  16868. _classPrivateFieldSet(this, _enablePermissions, options.enablePermissions ||
  16869. false);
  16870. this.defaultRenderingQueue = !options.renderingQueue;
  16871. if (this.defaultRenderingQueue) {
  16872. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  16873. this.renderingQueue.setViewer(this);
  16874. } else {
  16875. this.renderingQueue = options.renderingQueue;
  16876. }
  16877. this._doc = document.documentElement;
  16878. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate
  16879. .bind(this));
  16880. this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
  16881. this._onBeforeDraw = this._onAfterDraw = null;
  16882. this._resetView();
  16883. if (this.removePageBorders) {
  16884. this.viewer.classList.add("removePageBorders");
  16885. }
  16886. Promise.resolve().then(function() {
  16887. _this.eventBus.dispatch("baseviewerinit", {
  16888. source: _this
  16889. });
  16890. });
  16891. }
  16892. _createClass(BaseViewer, [{
  16893. key: "pagesCount",
  16894. get: function get() {
  16895. return this._pages.length;
  16896. }
  16897. }, {
  16898. key: "getPageView",
  16899. value: function getPageView(index) {
  16900. return this._pages[index];
  16901. }
  16902. }, {
  16903. key: "pageViewsReady",
  16904. get: function get() {
  16905. if (!this._pagesCapability.settled) {
  16906. return false;
  16907. }
  16908. return this._pages.every(function(pageView) {
  16909. return pageView === null || pageView ===
  16910. void 0 ? void 0 : pageView.pdfPage;
  16911. });
  16912. }
  16913. }, {
  16914. key: "renderForms",
  16915. get: function get() {
  16916. return _classPrivateFieldGet(this, _annotationMode) ===
  16917. _pdfjsLib.AnnotationMode.ENABLE_FORMS;
  16918. }
  16919. }, {
  16920. key: "enableScripting",
  16921. get: function get() {
  16922. return !!this._scriptingManager;
  16923. }
  16924. }, {
  16925. key: "currentPageNumber",
  16926. get: function get() {
  16927. return this._currentPageNumber;
  16928. },
  16929. set: function set(val) {
  16930. if (!Number.isInteger(val)) {
  16931. throw new Error("Invalid page number.");
  16932. }
  16933. if (!this.pdfDocument) {
  16934. return;
  16935. }
  16936. if (!this._setCurrentPageNumber(val, true)) {
  16937. console.error("currentPageNumber: \"".concat(val,
  16938. "\" is not a valid page."));
  16939. }
  16940. }
  16941. }, {
  16942. key: "_setCurrentPageNumber",
  16943. value: function _setCurrentPageNumber(val) {
  16944. var _this$_pageLabels, _this$_pageLabels2;
  16945. var resetCurrentPageView = arguments.length > 1 &&
  16946. arguments[1] !== undefined ? arguments[1] : false;
  16947. if (this._currentPageNumber === val) {
  16948. if (resetCurrentPageView) {
  16949. this._resetCurrentPageView();
  16950. }
  16951. return true;
  16952. }
  16953. if (!(0 < val && val <= this.pagesCount)) {
  16954. return false;
  16955. }
  16956. var previous = this._currentPageNumber;
  16957. this._currentPageNumber = val;
  16958. this.eventBus.dispatch("pagechanging", {
  16959. source: this,
  16960. pageNumber: val,
  16961. pageLabel: (_this$_pageLabels = (
  16962. _this$_pageLabels2 = this
  16963. ._pageLabels) === null ||
  16964. _this$_pageLabels2 === void 0 ? void 0 :
  16965. _this$_pageLabels2[val - 1]) !== null &&
  16966. _this$_pageLabels !== void 0 ?
  16967. _this$_pageLabels : null,
  16968. previous: previous
  16969. });
  16970. if (resetCurrentPageView) {
  16971. this._resetCurrentPageView();
  16972. }
  16973. return true;
  16974. }
  16975. }, {
  16976. key: "currentPageLabel",
  16977. get: function get() {
  16978. var _this$_pageLabels3, _this$_pageLabels4;
  16979. return (_this$_pageLabels3 = (_this$_pageLabels4 = this
  16980. ._pageLabels) === null || _this$_pageLabels4 ===
  16981. void 0 ? void 0 : _this$_pageLabels4[this
  16982. ._currentPageNumber - 1]) !== null &&
  16983. _this$_pageLabels3 !== void 0 ? _this$_pageLabels3 :
  16984. null;
  16985. },
  16986. set: function set(val) {
  16987. if (!this.pdfDocument) {
  16988. return;
  16989. }
  16990. var page = val | 0;
  16991. if (this._pageLabels) {
  16992. var i = this._pageLabels.indexOf(val);
  16993. if (i >= 0) {
  16994. page = i + 1;
  16995. }
  16996. }
  16997. if (!this._setCurrentPageNumber(page, true)) {
  16998. console.error("currentPageLabel: \"".concat(val,
  16999. "\" is not a valid page."));
  17000. }
  17001. }
  17002. }, {
  17003. key: "currentScale",
  17004. get: function get() {
  17005. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this
  17006. ._currentScale : _ui_utils.DEFAULT_SCALE;
  17007. },
  17008. set: function set(val) {
  17009. if (isNaN(val)) {
  17010. throw new Error("Invalid numeric scale.");
  17011. }
  17012. if (!this.pdfDocument) {
  17013. return;
  17014. }
  17015. this._setScale(val, false);
  17016. }
  17017. }, {
  17018. key: "currentScaleValue",
  17019. get: function get() {
  17020. return this._currentScaleValue;
  17021. },
  17022. set: function set(val) {
  17023. if (!this.pdfDocument) {
  17024. return;
  17025. }
  17026. this._setScale(val, false);
  17027. }
  17028. }, {
  17029. key: "pagesRotation",
  17030. get: function get() {
  17031. return this._pagesRotation;
  17032. },
  17033. set: function set(rotation) {
  17034. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  17035. throw new Error("Invalid pages rotation angle.");
  17036. }
  17037. if (!this.pdfDocument) {
  17038. return;
  17039. }
  17040. rotation %= 360;
  17041. if (rotation < 0) {
  17042. rotation += 360;
  17043. }
  17044. if (this._pagesRotation === rotation) {
  17045. return;
  17046. }
  17047. this._pagesRotation = rotation;
  17048. var pageNumber = this._currentPageNumber;
  17049. var updateArgs = {
  17050. rotation: rotation
  17051. };
  17052. var _iterator2 = _createForOfIteratorHelper(this._pages),
  17053. _step2;
  17054. try {
  17055. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  17056. var pageView = _step2.value;
  17057. pageView.update(updateArgs);
  17058. }
  17059. } catch (err) {
  17060. _iterator2.e(err);
  17061. } finally {
  17062. _iterator2.f();
  17063. }
  17064. if (this._currentScaleValue) {
  17065. this._setScale(this._currentScaleValue, true);
  17066. }
  17067. this.eventBus.dispatch("rotationchanging", {
  17068. source: this,
  17069. pagesRotation: rotation,
  17070. pageNumber: pageNumber
  17071. });
  17072. if (this.defaultRenderingQueue) {
  17073. this.update();
  17074. }
  17075. }
  17076. }, {
  17077. key: "firstPagePromise",
  17078. get: function get() {
  17079. return this.pdfDocument ? this._firstPageCapability
  17080. .promise : null;
  17081. }
  17082. }, {
  17083. key: "onePageRendered",
  17084. get: function get() {
  17085. return this.pdfDocument ? this._onePageRenderedCapability
  17086. .promise : null;
  17087. }
  17088. }, {
  17089. key: "pagesPromise",
  17090. get: function get() {
  17091. return this.pdfDocument ? this._pagesCapability.promise :
  17092. null;
  17093. }
  17094. }, {
  17095. key: "setDocument",
  17096. value: function setDocument(pdfDocument) {
  17097. var _this2 = this;
  17098. if (this.pdfDocument) {
  17099. this.eventBus.dispatch("pagesdestroy", {
  17100. source: this
  17101. });
  17102. this._cancelRendering();
  17103. this._resetView();
  17104. if (this.findController) {
  17105. this.findController.setDocument(null);
  17106. }
  17107. if (this._scriptingManager) {
  17108. this._scriptingManager.setDocument(null);
  17109. }
  17110. }
  17111. this.pdfDocument = pdfDocument;
  17112. if (!pdfDocument) {
  17113. return;
  17114. }
  17115. var isPureXfa = pdfDocument.isPureXfa;
  17116. var pagesCount = pdfDocument.numPages;
  17117. var firstPagePromise = pdfDocument.getPage(1);
  17118. var optionalContentConfigPromise = pdfDocument
  17119. .getOptionalContentConfig();
  17120. var permissionsPromise = _classPrivateFieldGet(this,
  17121. _enablePermissions) ? pdfDocument.getPermissions() :
  17122. Promise.resolve();
  17123. if (pagesCount > PagesCountLimit.FORCE_SCROLL_MODE_PAGE) {
  17124. console.warn(
  17125. "Forcing PAGE-scrolling for performance reasons, given the length of the document."
  17126. );
  17127. var mode = this._scrollMode = _ui_utils.ScrollMode.PAGE;
  17128. this.eventBus.dispatch("scrollmodechanged", {
  17129. source: this,
  17130. mode: mode
  17131. });
  17132. }
  17133. this._pagesCapability.promise.then(function() {
  17134. _this2.eventBus.dispatch("pagesloaded", {
  17135. source: _this2,
  17136. pagesCount: pagesCount
  17137. });
  17138. }, function() {});
  17139. this._onBeforeDraw = function(evt) {
  17140. var pageView = _this2._pages[evt.pageNumber - 1];
  17141. if (!pageView) {
  17142. return;
  17143. }
  17144. _classPrivateFieldGet(_this2, _buffer).push(
  17145. pageView);
  17146. };
  17147. this.eventBus._on("pagerender", this._onBeforeDraw);
  17148. this._onAfterDraw = function(evt) {
  17149. if (evt.cssTransform || _this2
  17150. ._onePageRenderedCapability.settled) {
  17151. return;
  17152. }
  17153. _this2._onePageRenderedCapability.resolve({
  17154. timestamp: evt.timestamp
  17155. });
  17156. _this2.eventBus._off("pagerendered", _this2
  17157. ._onAfterDraw);
  17158. _this2._onAfterDraw = null;
  17159. if (_classPrivateFieldGet(_this2,
  17160. _onVisibilityChange)) {
  17161. document.removeEventListener("visibilitychange",
  17162. _classPrivateFieldGet(_this2,
  17163. _onVisibilityChange));
  17164. _classPrivateFieldSet(_this2,
  17165. _onVisibilityChange, null);
  17166. }
  17167. };
  17168. this.eventBus._on("pagerendered", this._onAfterDraw);
  17169. Promise.all([firstPagePromise, permissionsPromise]).then(
  17170. function(_ref) {
  17171. var _ref2 = _slicedToArray(_ref, 2),
  17172. firstPdfPage = _ref2[0],
  17173. permissions = _ref2[1];
  17174. if (pdfDocument !== _this2.pdfDocument) {
  17175. return;
  17176. }
  17177. _this2._firstPageCapability.resolve(
  17178. firstPdfPage);
  17179. _this2._optionalContentConfigPromise =
  17180. optionalContentConfigPromise;
  17181. _classPrivateMethodGet(_this2,
  17182. _initializePermissions,
  17183. _initializePermissions2).call(_this2,
  17184. permissions);
  17185. var viewerElement = _this2._scrollMode ===
  17186. _ui_utils.ScrollMode.PAGE ? null : _this2
  17187. .viewer;
  17188. var scale = _this2.currentScale;
  17189. var viewport = firstPdfPage.getViewport({
  17190. scale: scale * _pdfjsLib
  17191. .PixelsPerInch.PDF_TO_CSS_UNITS
  17192. });
  17193. var textLayerFactory = _this2.textLayerMode !==
  17194. _ui_utils.TextLayerMode.DISABLE && !
  17195. isPureXfa ? _this2 : null;
  17196. var annotationLayerFactory =
  17197. _classPrivateFieldGet(_this2,
  17198. _annotationMode) !== _pdfjsLib
  17199. .AnnotationMode.DISABLE ? _this2 : null;
  17200. var xfaLayerFactory = isPureXfa ? _this2 : null;
  17201. for (var pageNum = 1; pageNum <= pagesCount; ++
  17202. pageNum) {
  17203. var pageView = new _pdf_page_view
  17204. .PDFPageView({
  17205. container: viewerElement,
  17206. eventBus: _this2.eventBus,
  17207. id: pageNum,
  17208. scale: scale,
  17209. defaultViewport: viewport
  17210. .clone(),
  17211. optionalContentConfigPromise: optionalContentConfigPromise,
  17212. renderingQueue: _this2
  17213. .renderingQueue,
  17214. textLayerFactory: textLayerFactory,
  17215. textLayerMode: _this2
  17216. .textLayerMode,
  17217. annotationLayerFactory: annotationLayerFactory,
  17218. annotationMode: _classPrivateFieldGet(
  17219. _this2, _annotationMode
  17220. ),
  17221. xfaLayerFactory: xfaLayerFactory,
  17222. textHighlighterFactory: _this2,
  17223. structTreeLayerFactory: _this2,
  17224. imageResourcesPath: _this2
  17225. .imageResourcesPath,
  17226. renderer: _this2.renderer,
  17227. useOnlyCssZoom: _this2
  17228. .useOnlyCssZoom,
  17229. maxCanvasPixels: _this2
  17230. .maxCanvasPixels,
  17231. l10n: _this2.l10n
  17232. });
  17233. _this2._pages.push(pageView);
  17234. }
  17235. var firstPageView = _this2._pages[0];
  17236. if (firstPageView) {
  17237. firstPageView.setPdfPage(firstPdfPage);
  17238. _this2.linkService.cachePageRef(1,
  17239. firstPdfPage.ref);
  17240. }
  17241. if (_this2._scrollMode === _ui_utils.ScrollMode
  17242. .PAGE) {
  17243. _classPrivateMethodGet(_this2,
  17244. _ensurePageViewVisible,
  17245. _ensurePageViewVisible2).call(
  17246. _this2);
  17247. } else if (_this2._spreadMode !== _ui_utils
  17248. .SpreadMode.NONE) {
  17249. _this2._updateSpreadMode();
  17250. }
  17251. _classPrivateMethodGet(_this2,
  17252. _onePageRenderedOrForceFetch,
  17253. _onePageRenderedOrForceFetch2).call(
  17254. _this2).then( /*#__PURE__*/
  17255. _asyncToGenerator( /*#__PURE__*/
  17256. _regenerator["default"].mark(
  17257. function _callee() {
  17258. var getPagesLeft, _loop,
  17259. _pageNum;
  17260. return _regenerator[
  17261. "default"].wrap(
  17262. function _callee$(
  17263. _context2) {
  17264. while (1) {
  17265. switch (
  17266. _context2
  17267. .prev =
  17268. _context2
  17269. .next) {
  17270. case 0:
  17271. if (_this2
  17272. .findController
  17273. ) {
  17274. _this2
  17275. .findController
  17276. .setDocument(
  17277. pdfDocument
  17278. );
  17279. }
  17280. if (_this2
  17281. ._scriptingManager
  17282. ) {
  17283. _this2
  17284. ._scriptingManager
  17285. .setDocument(
  17286. pdfDocument
  17287. );
  17288. }
  17289. if (!
  17290. (pdfDocument
  17291. .loadingParams
  17292. .disableAutoFetch ||
  17293. pagesCount >
  17294. PagesCountLimit
  17295. .FORCE_LAZY_PAGE_INIT
  17296. )
  17297. ) {
  17298. _context2
  17299. .next =
  17300. 5;
  17301. break;
  17302. }
  17303. _this2
  17304. ._pagesCapability
  17305. .resolve();
  17306. return _context2
  17307. .abrupt(
  17308. "return"
  17309. );
  17310. case 5:
  17311. getPagesLeft
  17312. =
  17313. pagesCount -
  17314. 1;
  17315. if (!
  17316. (getPagesLeft <=
  17317. 0
  17318. )
  17319. ) {
  17320. _context2
  17321. .next =
  17322. 9;
  17323. break;
  17324. }
  17325. _this2
  17326. ._pagesCapability
  17327. .resolve();
  17328. return _context2
  17329. .abrupt(
  17330. "return"
  17331. );
  17332. case 9:
  17333. _loop
  17334. = /*#__PURE__*/
  17335. _regenerator[
  17336. "default"
  17337. ]
  17338. .mark(
  17339. function _loop(
  17340. _pageNum
  17341. ) {
  17342. var
  17343. promise;
  17344. return _regenerator[
  17345. "default"
  17346. ]
  17347. .wrap(
  17348. function _loop$(
  17349. _context
  17350. ) {
  17351. while (
  17352. 1
  17353. ) {
  17354. switch (
  17355. _context
  17356. .prev =
  17357. _context
  17358. .next
  17359. ) {
  17360. case 0:
  17361. promise
  17362. =
  17363. pdfDocument
  17364. .getPage(
  17365. _pageNum
  17366. )
  17367. .then(
  17368. function(
  17369. pdfPage
  17370. ) {
  17371. var pageView =
  17372. _this2
  17373. ._pages[
  17374. _pageNum -
  17375. 1
  17376. ];
  17377. if (!
  17378. pageView
  17379. .pdfPage
  17380. ) {
  17381. pageView
  17382. .setPdfPage(
  17383. pdfPage
  17384. );
  17385. }
  17386. _this2
  17387. .linkService
  17388. .cachePageRef(
  17389. _pageNum,
  17390. pdfPage
  17391. .ref
  17392. );
  17393. if (--
  17394. getPagesLeft ===
  17395. 0
  17396. ) {
  17397. _this2
  17398. ._pagesCapability
  17399. .resolve();
  17400. }
  17401. },
  17402. function(
  17403. reason
  17404. ) {
  17405. console
  17406. .error(
  17407. "Unable to get page "
  17408. .concat(
  17409. _pageNum,
  17410. " to initialize viewer"
  17411. ),
  17412. reason
  17413. );
  17414. if (--
  17415. getPagesLeft ===
  17416. 0
  17417. ) {
  17418. _this2
  17419. ._pagesCapability
  17420. .resolve();
  17421. }
  17422. }
  17423. );
  17424. if (!
  17425. (_pageNum %
  17426. PagesCountLimit
  17427. .PAUSE_EAGER_PAGE_INIT ===
  17428. 0
  17429. )
  17430. ) {
  17431. _context
  17432. .next =
  17433. 4;
  17434. break;
  17435. }
  17436. _context
  17437. .next =
  17438. 4;
  17439. return promise;
  17440. case 4:
  17441. case "end":
  17442. return _context
  17443. .stop();
  17444. }
  17445. }
  17446. },
  17447. _loop
  17448. );
  17449. }
  17450. );
  17451. _pageNum
  17452. =
  17453. 2;
  17454. case 11:
  17455. if (!
  17456. (_pageNum <=
  17457. pagesCount
  17458. )
  17459. ) {
  17460. _context2
  17461. .next =
  17462. 16;
  17463. break;
  17464. }
  17465. return _context2
  17466. .delegateYield(
  17467. _loop(
  17468. _pageNum
  17469. ),
  17470. "t0",
  17471. 13
  17472. );
  17473. case 13:
  17474. ++
  17475. _pageNum
  17476. ;
  17477. _context2
  17478. .next =
  17479. 11;
  17480. break;
  17481. case 16:
  17482. case "end":
  17483. return _context2
  17484. .stop();
  17485. }
  17486. }
  17487. }, _callee);
  17488. })));
  17489. _this2.eventBus.dispatch("pagesinit", {
  17490. source: _this2
  17491. });
  17492. pdfDocument.getMetadata().then(function(_ref4) {
  17493. var info = _ref4.info;
  17494. if (pdfDocument !== _this2
  17495. .pdfDocument) {
  17496. return;
  17497. }
  17498. if (info.Language) {
  17499. _this2.viewer.lang = info
  17500. .Language;
  17501. }
  17502. });
  17503. if (_this2.defaultRenderingQueue) {
  17504. _this2.update();
  17505. }
  17506. })["catch"](function(reason) {
  17507. console.error("Unable to initialize viewer",
  17508. reason);
  17509. _this2._pagesCapability.reject(reason);
  17510. });
  17511. }
  17512. }, {
  17513. key: "setPageLabels",
  17514. value: function setPageLabels(labels) {
  17515. if (!this.pdfDocument) {
  17516. return;
  17517. }
  17518. if (!labels) {
  17519. this._pageLabels = null;
  17520. } else if (!(Array.isArray(labels) && this.pdfDocument
  17521. .numPages === labels.length)) {
  17522. this._pageLabels = null;
  17523. console.error("setPageLabels: Invalid page labels.");
  17524. } else {
  17525. this._pageLabels = labels;
  17526. }
  17527. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  17528. var _this$_pageLabels$i, _this$_pageLabels5;
  17529. this._pages[i].setPageLabel((_this$_pageLabels$i = (
  17530. _this$_pageLabels5 = this._pageLabels
  17531. ) === null || _this$_pageLabels5 ===
  17532. void 0 ? void 0 : _this$_pageLabels5[i]) !==
  17533. null && _this$_pageLabels$i !== void 0 ?
  17534. _this$_pageLabels$i : null);
  17535. }
  17536. }
  17537. }, {
  17538. key: "_resetView",
  17539. value: function _resetView() {
  17540. this._pages = [];
  17541. this._currentPageNumber = 1;
  17542. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  17543. this._currentScaleValue = null;
  17544. this._pageLabels = null;
  17545. _classPrivateFieldSet(this, _buffer, new PDFPageViewBuffer(
  17546. DEFAULT_CACHE_SIZE));
  17547. this._location = null;
  17548. this._pagesRotation = 0;
  17549. this._optionalContentConfigPromise = null;
  17550. this._firstPageCapability = (0, _pdfjsLib
  17551. .createPromiseCapability)();
  17552. this._onePageRenderedCapability = (0, _pdfjsLib
  17553. .createPromiseCapability)();
  17554. this._pagesCapability = (0, _pdfjsLib
  17555. .createPromiseCapability)();
  17556. this._scrollMode = _ui_utils.ScrollMode.VERTICAL;
  17557. this._previousScrollMode = _ui_utils.ScrollMode.UNKNOWN;
  17558. this._spreadMode = _ui_utils.SpreadMode.NONE;
  17559. _classPrivateFieldSet(this, _scrollModePageState, {
  17560. previousPageNumber: 1,
  17561. scrollDown: true,
  17562. pages: []
  17563. });
  17564. if (this._onBeforeDraw) {
  17565. this.eventBus._off("pagerender", this._onBeforeDraw);
  17566. this._onBeforeDraw = null;
  17567. }
  17568. if (this._onAfterDraw) {
  17569. this.eventBus._off("pagerendered", this._onAfterDraw);
  17570. this._onAfterDraw = null;
  17571. }
  17572. if (_classPrivateFieldGet(this, _onVisibilityChange)) {
  17573. document.removeEventListener("visibilitychange",
  17574. _classPrivateFieldGet(this, _onVisibilityChange)
  17575. );
  17576. _classPrivateFieldSet(this, _onVisibilityChange, null);
  17577. }
  17578. this.viewer.textContent = "";
  17579. this._updateScrollMode();
  17580. this.viewer.removeAttribute("lang");
  17581. this.viewer.classList.remove(ENABLE_PERMISSIONS_CLASS);
  17582. if (_classPrivateFieldGet(this, _previousAnnotationMode) !==
  17583. null) {
  17584. _classPrivateFieldSet(this, _annotationMode,
  17585. _classPrivateFieldGet(this,
  17586. _previousAnnotationMode));
  17587. _classPrivateFieldSet(this, _previousAnnotationMode,
  17588. null);
  17589. }
  17590. }
  17591. }, {
  17592. key: "_scrollUpdate",
  17593. value: function _scrollUpdate() {
  17594. if (this.pagesCount === 0) {
  17595. return;
  17596. }
  17597. this.update();
  17598. }
  17599. }, {
  17600. key: "_scrollIntoView",
  17601. value: function _scrollIntoView(_ref5) {
  17602. var pageDiv = _ref5.pageDiv,
  17603. _ref5$pageSpot = _ref5.pageSpot,
  17604. pageSpot = _ref5$pageSpot === void 0 ? null :
  17605. _ref5$pageSpot,
  17606. _ref5$pageNumber = _ref5.pageNumber,
  17607. pageNumber = _ref5$pageNumber === void 0 ? null :
  17608. _ref5$pageNumber;
  17609. if (this._scrollMode === _ui_utils.ScrollMode.PAGE) {
  17610. if (pageNumber) {
  17611. this._setCurrentPageNumber(pageNumber);
  17612. }
  17613. _classPrivateMethodGet(this, _ensurePageViewVisible,
  17614. _ensurePageViewVisible2).call(this);
  17615. this.update();
  17616. }
  17617. if (!pageSpot && !this.isInPresentationMode) {
  17618. var left = pageDiv.offsetLeft + pageDiv.clientLeft;
  17619. var right = left + pageDiv.clientWidth;
  17620. var _this$container2 = this.container,
  17621. scrollLeft = _this$container2.scrollLeft,
  17622. clientWidth = _this$container2.clientWidth;
  17623. if (this._scrollMode === _ui_utils.ScrollMode
  17624. .HORIZONTAL || left < scrollLeft || right >
  17625. scrollLeft + clientWidth) {
  17626. pageSpot = {
  17627. left: 0,
  17628. top: 0
  17629. };
  17630. }
  17631. }
  17632. (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
  17633. }
  17634. }, {
  17635. key: "_setScaleUpdatePages",
  17636. value: function _setScaleUpdatePages(newScale, newValue) {
  17637. var noScroll = arguments.length > 2 && arguments[2] !==
  17638. undefined ? arguments[2] : false;
  17639. var preset = arguments.length > 3 && arguments[3] !==
  17640. undefined ? arguments[3] : false;
  17641. this._currentScaleValue = newValue.toString();
  17642. if (_classPrivateMethodGet(this, _isSameScale,
  17643. _isSameScale2).call(this, newScale)) {
  17644. if (preset) {
  17645. this.eventBus.dispatch("scalechanging", {
  17646. source: this,
  17647. scale: newScale,
  17648. presetValue: newValue
  17649. });
  17650. }
  17651. return;
  17652. }
  17653. this._doc.style.setProperty("--zoom-factor", newScale);
  17654. this._doc.style.setProperty("--viewport-scale-factor",
  17655. newScale * _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS);
  17656. var updateArgs = {
  17657. scale: newScale
  17658. };
  17659. var _iterator3 = _createForOfIteratorHelper(this._pages),
  17660. _step3;
  17661. try {
  17662. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  17663. var pageView = _step3.value;
  17664. pageView.update(updateArgs);
  17665. }
  17666. } catch (err) {
  17667. _iterator3.e(err);
  17668. } finally {
  17669. _iterator3.f();
  17670. }
  17671. this._currentScale = newScale;
  17672. if (!noScroll) {
  17673. var page = this._currentPageNumber,
  17674. dest;
  17675. if (this._location && !(this.isInPresentationMode ||
  17676. this.isChangingPresentationMode)) {
  17677. page = this._location.pageNumber;
  17678. dest = [null, {
  17679. name: "XYZ"
  17680. }, this._location.left, this._location.top,
  17681. null
  17682. ];
  17683. }
  17684. this.scrollPageIntoView({
  17685. pageNumber: page,
  17686. destArray: dest,
  17687. allowNegativeOffset: true
  17688. });
  17689. }
  17690. this.eventBus.dispatch("scalechanging", {
  17691. source: this,
  17692. scale: newScale,
  17693. presetValue: preset ? newValue : undefined
  17694. });
  17695. if (this.defaultRenderingQueue) {
  17696. this.update();
  17697. }
  17698. _classPrivateFieldSet(this, _previousContainerHeight, this
  17699. .container.clientHeight);
  17700. }
  17701. }, {
  17702. key: "_pageWidthScaleFactor",
  17703. get: function get() {
  17704. if (this._spreadMode !== _ui_utils.SpreadMode.NONE && this
  17705. ._scrollMode !== _ui_utils.ScrollMode.HORIZONTAL) {
  17706. return 2;
  17707. }
  17708. return 1;
  17709. }
  17710. }, {
  17711. key: "_setScale",
  17712. value: function _setScale(value) {
  17713. var noScroll = arguments.length > 1 && arguments[1] !==
  17714. undefined ? arguments[1] : false;
  17715. var scale = parseFloat(value);
  17716. if (scale > 0) {
  17717. this._setScaleUpdatePages(scale, value, noScroll,
  17718. false);
  17719. } else {
  17720. var currentPage = this._pages[this._currentPageNumber -
  17721. 1];
  17722. if (!currentPage) {
  17723. return;
  17724. }
  17725. var hPadding = _ui_utils.SCROLLBAR_PADDING,
  17726. vPadding = _ui_utils.VERTICAL_PADDING;
  17727. if (this.isInPresentationMode) {
  17728. hPadding = vPadding = 4;
  17729. } else if (this.removePageBorders) {
  17730. hPadding = vPadding = 0;
  17731. }
  17732. if (this._scrollMode === _ui_utils.ScrollMode
  17733. .HORIZONTAL) {
  17734. var _ref6 = [vPadding, hPadding];
  17735. hPadding = _ref6[0];
  17736. vPadding = _ref6[1];
  17737. }
  17738. var pageWidthScale = (this.container.clientWidth -
  17739. hPadding) / currentPage.width * currentPage
  17740. .scale / this._pageWidthScaleFactor;
  17741. var pageHeightScale = (this.container.clientHeight -
  17742. vPadding) / currentPage.height * currentPage
  17743. .scale;
  17744. switch (value) {
  17745. case "page-actual":
  17746. scale = 1;
  17747. break;
  17748. case "page-width":
  17749. scale = pageWidthScale;
  17750. break;
  17751. case "page-height":
  17752. scale = pageHeightScale;
  17753. break;
  17754. case "page-fit":
  17755. scale = Math.min(pageWidthScale,
  17756. pageHeightScale);
  17757. break;
  17758. case "auto":
  17759. var horizontalScale = (0, _ui_utils
  17760. .isPortraitOrientation)(currentPage) ?
  17761. pageWidthScale : Math.min(pageHeightScale,
  17762. pageWidthScale);
  17763. scale = Math.min(_ui_utils.MAX_AUTO_SCALE,
  17764. horizontalScale);
  17765. break;
  17766. default:
  17767. console.error("_setScale: \"".concat(value,
  17768. "\" is an unknown zoom value."));
  17769. return;
  17770. }
  17771. this._setScaleUpdatePages(scale, value, noScroll, true);
  17772. }
  17773. }
  17774. }, {
  17775. key: "_resetCurrentPageView",
  17776. value: function _resetCurrentPageView() {
  17777. if (this.isInPresentationMode) {
  17778. this._setScale(this._currentScaleValue, true);
  17779. }
  17780. var pageView = this._pages[this._currentPageNumber - 1];
  17781. this._scrollIntoView({
  17782. pageDiv: pageView.div
  17783. });
  17784. }
  17785. }, {
  17786. key: "pageLabelToPageNumber",
  17787. value: function pageLabelToPageNumber(label) {
  17788. if (!this._pageLabels) {
  17789. return null;
  17790. }
  17791. var i = this._pageLabels.indexOf(label);
  17792. if (i < 0) {
  17793. return null;
  17794. }
  17795. return i + 1;
  17796. }
  17797. }, {
  17798. key: "scrollPageIntoView",
  17799. value: function scrollPageIntoView(_ref7) {
  17800. var pageNumber = _ref7.pageNumber,
  17801. _ref7$destArray = _ref7.destArray,
  17802. destArray = _ref7$destArray === void 0 ? null :
  17803. _ref7$destArray,
  17804. _ref7$allowNegativeOf = _ref7.allowNegativeOffset,
  17805. allowNegativeOffset = _ref7$allowNegativeOf === void 0 ?
  17806. false : _ref7$allowNegativeOf,
  17807. _ref7$ignoreDestinati = _ref7.ignoreDestinationZoom,
  17808. ignoreDestinationZoom = _ref7$ignoreDestinati ===
  17809. void 0 ? false : _ref7$ignoreDestinati;
  17810. if (!this.pdfDocument) {
  17811. return;
  17812. }
  17813. var pageView = Number.isInteger(pageNumber) && this._pages[
  17814. pageNumber - 1];
  17815. if (!pageView) {
  17816. console.error("scrollPageIntoView: \"".concat(
  17817. pageNumber,
  17818. "\" is not a valid pageNumber parameter."));
  17819. return;
  17820. }
  17821. if (this.isInPresentationMode || !destArray) {
  17822. this._setCurrentPageNumber(pageNumber, true);
  17823. return;
  17824. }
  17825. var x = 0,
  17826. y = 0;
  17827. var width = 0,
  17828. height = 0,
  17829. widthScale,
  17830. heightScale;
  17831. var changeOrientation = pageView.rotation % 180 !== 0;
  17832. var pageWidth = (changeOrientation ? pageView.height :
  17833. pageView.width) / pageView.scale / _pdfjsLib
  17834. .PixelsPerInch.PDF_TO_CSS_UNITS;
  17835. var pageHeight = (changeOrientation ? pageView.width :
  17836. pageView.height) / pageView.scale / _pdfjsLib
  17837. .PixelsPerInch.PDF_TO_CSS_UNITS;
  17838. var scale = 0;
  17839. switch (destArray[1].name) {
  17840. case "XYZ":
  17841. x = destArray[2];
  17842. y = destArray[3];
  17843. scale = destArray[4];
  17844. x = x !== null ? x : 0;
  17845. y = y !== null ? y : pageHeight;
  17846. break;
  17847. case "Fit":
  17848. case "FitB":
  17849. scale = "page-fit";
  17850. break;
  17851. case "FitH":
  17852. case "FitBH":
  17853. y = destArray[2];
  17854. scale = "page-width";
  17855. if (y === null && this._location) {
  17856. x = this._location.left;
  17857. y = this._location.top;
  17858. } else if (typeof y !== "number" || y < 0) {
  17859. y = pageHeight;
  17860. }
  17861. break;
  17862. case "FitV":
  17863. case "FitBV":
  17864. x = destArray[2];
  17865. width = pageWidth;
  17866. height = pageHeight;
  17867. scale = "page-height";
  17868. break;
  17869. case "FitR":
  17870. x = destArray[2];
  17871. y = destArray[3];
  17872. width = destArray[4] - x;
  17873. height = destArray[5] - y;
  17874. var hPadding = this.removePageBorders ? 0 :
  17875. _ui_utils.SCROLLBAR_PADDING;
  17876. var vPadding = this.removePageBorders ? 0 :
  17877. _ui_utils.VERTICAL_PADDING;
  17878. widthScale = (this.container.clientWidth -
  17879. hPadding) / width / _pdfjsLib.PixelsPerInch
  17880. .PDF_TO_CSS_UNITS;
  17881. heightScale = (this.container.clientHeight -
  17882. vPadding) / height / _pdfjsLib.PixelsPerInch
  17883. .PDF_TO_CSS_UNITS;
  17884. scale = Math.min(Math.abs(widthScale), Math.abs(
  17885. heightScale));
  17886. break;
  17887. default:
  17888. console.error("scrollPageIntoView: \"".concat(
  17889. destArray[1].name,
  17890. "\" is not a valid destination type."));
  17891. return;
  17892. }
  17893. if (!ignoreDestinationZoom) {
  17894. if (scale && scale !== this._currentScale) {
  17895. this.currentScaleValue = scale;
  17896. } else if (this._currentScale === _ui_utils
  17897. .UNKNOWN_SCALE) {
  17898. this.currentScaleValue = _ui_utils
  17899. .DEFAULT_SCALE_VALUE;
  17900. }
  17901. }
  17902. if (scale === "page-fit" && !destArray[4]) {
  17903. this._scrollIntoView({
  17904. pageDiv: pageView.div,
  17905. pageNumber: pageNumber
  17906. });
  17907. return;
  17908. }
  17909. var boundingRect = [pageView.viewport
  17910. .convertToViewportPoint(x, y), pageView.viewport
  17911. .convertToViewportPoint(x + width, y + height)
  17912. ];
  17913. var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  17914. var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  17915. if (!allowNegativeOffset) {
  17916. left = Math.max(left, 0);
  17917. top = Math.max(top, 0);
  17918. }
  17919. this._scrollIntoView({
  17920. pageDiv: pageView.div,
  17921. pageSpot: {
  17922. left: left,
  17923. top: top
  17924. },
  17925. pageNumber: pageNumber
  17926. });
  17927. }
  17928. }, {
  17929. key: "_updateLocation",
  17930. value: function _updateLocation(firstPage) {
  17931. var currentScale = this._currentScale;
  17932. var currentScaleValue = this._currentScaleValue;
  17933. var normalizedScaleValue = parseFloat(currentScaleValue) ===
  17934. currentScale ? Math.round(currentScale * 10000) / 100 :
  17935. currentScaleValue;
  17936. var pageNumber = firstPage.id;
  17937. var pdfOpenParams = "#page=" + pageNumber;
  17938. pdfOpenParams += "&zoom=" + normalizedScaleValue;
  17939. var currentPageView = this._pages[pageNumber - 1];
  17940. var container = this.container;
  17941. var topLeft = currentPageView.getPagePoint(container
  17942. .scrollLeft - firstPage.x, container.scrollTop -
  17943. firstPage.y);
  17944. var intLeft = Math.round(topLeft[0]);
  17945. var intTop = Math.round(topLeft[1]);
  17946. pdfOpenParams += "," + intLeft + "," + intTop;
  17947. this._location = {
  17948. pageNumber: pageNumber,
  17949. scale: normalizedScaleValue,
  17950. top: intTop,
  17951. left: intLeft,
  17952. rotation: this._pagesRotation,
  17953. pdfOpenParams: pdfOpenParams
  17954. };
  17955. }
  17956. }, {
  17957. key: "update",
  17958. value: function update() {
  17959. var visible = this._getVisiblePages();
  17960. var visiblePages = visible.views,
  17961. numVisiblePages = visiblePages.length;
  17962. if (numVisiblePages === 0) {
  17963. return;
  17964. }
  17965. var newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 *
  17966. numVisiblePages + 1);
  17967. _classPrivateFieldGet(this, _buffer).resize(newCacheSize,
  17968. visible.ids);
  17969. this.renderingQueue.renderHighestPriority(visible);
  17970. if (!this.isInPresentationMode) {
  17971. var isSimpleLayout = this._spreadMode === _ui_utils
  17972. .SpreadMode.NONE && (this._scrollMode === _ui_utils
  17973. .ScrollMode.PAGE || this._scrollMode ===
  17974. _ui_utils.ScrollMode.VERTICAL);
  17975. var currentId = this._currentPageNumber;
  17976. var stillFullyVisible = false;
  17977. var _iterator4 = _createForOfIteratorHelper(
  17978. visiblePages),
  17979. _step4;
  17980. try {
  17981. for (_iterator4.s(); !(_step4 = _iterator4.n())
  17982. .done;) {
  17983. var page = _step4.value;
  17984. if (page.percent < 100) {
  17985. break;
  17986. }
  17987. if (page.id === currentId && isSimpleLayout) {
  17988. stillFullyVisible = true;
  17989. break;
  17990. }
  17991. }
  17992. } catch (err) {
  17993. _iterator4.e(err);
  17994. } finally {
  17995. _iterator4.f();
  17996. }
  17997. if (!stillFullyVisible) {
  17998. currentId = visiblePages[0].id;
  17999. }
  18000. this._setCurrentPageNumber(currentId);
  18001. }
  18002. this._updateLocation(visible.first);
  18003. this.eventBus.dispatch("updateviewarea", {
  18004. source: this,
  18005. location: this._location
  18006. });
  18007. }
  18008. }, {
  18009. key: "containsElement",
  18010. value: function containsElement(element) {
  18011. return this.container.contains(element);
  18012. }
  18013. }, {
  18014. key: "focus",
  18015. value: function focus() {
  18016. this.container.focus();
  18017. }
  18018. }, {
  18019. key: "_isContainerRtl",
  18020. get: function get() {
  18021. return getComputedStyle(this.container).direction === "rtl";
  18022. }
  18023. }, {
  18024. key: "isInPresentationMode",
  18025. get: function get() {
  18026. return this.presentationModeState === _ui_utils
  18027. .PresentationModeState.FULLSCREEN;
  18028. }
  18029. }, {
  18030. key: "isChangingPresentationMode",
  18031. get: function get() {
  18032. return this.presentationModeState === _ui_utils
  18033. .PresentationModeState.CHANGING;
  18034. }
  18035. }, {
  18036. key: "isHorizontalScrollbarEnabled",
  18037. get: function get() {
  18038. return this.isInPresentationMode ? false : this.container
  18039. .scrollWidth > this.container.clientWidth;
  18040. }
  18041. }, {
  18042. key: "isVerticalScrollbarEnabled",
  18043. get: function get() {
  18044. return this.isInPresentationMode ? false : this.container
  18045. .scrollHeight > this.container.clientHeight;
  18046. }
  18047. }, {
  18048. key: "_getCurrentVisiblePage",
  18049. value: function _getCurrentVisiblePage() {
  18050. if (!this.pagesCount) {
  18051. return {
  18052. views: []
  18053. };
  18054. }
  18055. var pageView = this._pages[this._currentPageNumber - 1];
  18056. var element = pageView.div;
  18057. var view = {
  18058. id: pageView.id,
  18059. x: element.offsetLeft + element.clientLeft,
  18060. y: element.offsetTop + element.clientTop,
  18061. view: pageView
  18062. };
  18063. var ids = new Set([pageView.id]);
  18064. return {
  18065. first: view,
  18066. last: view,
  18067. views: [view],
  18068. ids: ids
  18069. };
  18070. }
  18071. }, {
  18072. key: "_getVisiblePages",
  18073. value: function _getVisiblePages() {
  18074. if (this.isInPresentationMode) {
  18075. return this._getCurrentVisiblePage();
  18076. }
  18077. var views = this._scrollMode === _ui_utils.ScrollMode.PAGE ?
  18078. _classPrivateFieldGet(this, _scrollModePageState)
  18079. .pages : this._pages,
  18080. horizontal = this._scrollMode === _ui_utils.ScrollMode
  18081. .HORIZONTAL,
  18082. rtl = horizontal && this._isContainerRtl;
  18083. return (0, _ui_utils.getVisibleElements)({
  18084. scrollEl: this.container,
  18085. views: views,
  18086. sortByVisibility: true,
  18087. horizontal: horizontal,
  18088. rtl: rtl
  18089. });
  18090. }
  18091. }, {
  18092. key: "isPageVisible",
  18093. value: function isPageVisible(pageNumber) {
  18094. if (!this.pdfDocument) {
  18095. return false;
  18096. }
  18097. if (!(Number.isInteger(pageNumber) && pageNumber > 0 &&
  18098. pageNumber <= this.pagesCount)) {
  18099. console.error("isPageVisible: \"".concat(pageNumber,
  18100. "\" is not a valid page."));
  18101. return false;
  18102. }
  18103. return this._getVisiblePages().ids.has(pageNumber);
  18104. }
  18105. }, {
  18106. key: "isPageCached",
  18107. value: function isPageCached(pageNumber) {
  18108. if (!this.pdfDocument) {
  18109. return false;
  18110. }
  18111. if (!(Number.isInteger(pageNumber) && pageNumber > 0 &&
  18112. pageNumber <= this.pagesCount)) {
  18113. console.error("isPageCached: \"".concat(pageNumber,
  18114. "\" is not a valid page."));
  18115. return false;
  18116. }
  18117. var pageView = this._pages[pageNumber - 1];
  18118. return _classPrivateFieldGet(this, _buffer).has(pageView);
  18119. }
  18120. }, {
  18121. key: "cleanup",
  18122. value: function cleanup() {
  18123. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  18124. if (this._pages[i] && this._pages[i].renderingState !==
  18125. _ui_utils.RenderingStates.FINISHED) {
  18126. this._pages[i].reset();
  18127. }
  18128. }
  18129. }
  18130. }, {
  18131. key: "_cancelRendering",
  18132. value: function _cancelRendering() {
  18133. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  18134. if (this._pages[i]) {
  18135. this._pages[i].cancelRendering();
  18136. }
  18137. }
  18138. }
  18139. }, {
  18140. key: "forceRendering",
  18141. value: function forceRendering(currentlyVisiblePages) {
  18142. var _this3 = this;
  18143. var visiblePages = currentlyVisiblePages || this
  18144. ._getVisiblePages();
  18145. var scrollAhead = _classPrivateMethodGet(this,
  18146. _getScrollAhead, _getScrollAhead2).call(this,
  18147. visiblePages);
  18148. var preRenderExtra = this._spreadMode !== _ui_utils
  18149. .SpreadMode.NONE && this._scrollMode !== _ui_utils
  18150. .ScrollMode.HORIZONTAL;
  18151. var pageView = this.renderingQueue.getHighestPriority(
  18152. visiblePages, this._pages, scrollAhead,
  18153. preRenderExtra);
  18154. _classPrivateMethodGet(this, _toggleLoadingIconSpinner,
  18155. _toggleLoadingIconSpinner2).call(this, visiblePages
  18156. .ids);
  18157. if (pageView) {
  18158. _classPrivateMethodGet(this, _ensurePdfPageLoaded,
  18159. _ensurePdfPageLoaded2).call(this, pageView)
  18160. .then(function() {
  18161. _this3.renderingQueue.renderView(pageView);
  18162. });
  18163. return true;
  18164. }
  18165. return false;
  18166. }
  18167. }, {
  18168. key: "createTextLayerBuilder",
  18169. value: function createTextLayerBuilder(textLayerDiv, pageIndex,
  18170. viewport) {
  18171. var enhanceTextSelection = arguments.length > 3 &&
  18172. arguments[3] !== undefined ? arguments[3] : false;
  18173. var eventBus = arguments.length > 4 ? arguments[4] :
  18174. undefined;
  18175. var highlighter = arguments.length > 5 ? arguments[5] :
  18176. undefined;
  18177. return new _text_layer_builder.TextLayerBuilder({
  18178. textLayerDiv: textLayerDiv,
  18179. eventBus: eventBus,
  18180. pageIndex: pageIndex,
  18181. viewport: viewport,
  18182. enhanceTextSelection: this
  18183. .isInPresentationMode ? false :
  18184. enhanceTextSelection,
  18185. highlighter: highlighter
  18186. });
  18187. }
  18188. }, {
  18189. key: "createTextHighlighter",
  18190. value: function createTextHighlighter(pageIndex, eventBus) {
  18191. return new _text_highlighter.TextHighlighter({
  18192. eventBus: eventBus,
  18193. pageIndex: pageIndex,
  18194. findController: this.isInPresentationMode ?
  18195. null : this.findController
  18196. });
  18197. }
  18198. }, {
  18199. key: "createAnnotationLayerBuilder",
  18200. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  18201. var _this$pdfDocument, _this$pdfDocument2,
  18202. _this$pdfDocument3, _this$_scriptingManag;
  18203. var annotationStorage = arguments.length > 2 && arguments[
  18204. 2] !== undefined ? arguments[2] : null;
  18205. var imageResourcesPath = arguments.length > 3 && arguments[
  18206. 3] !== undefined ? arguments[3] : "";
  18207. var renderForms = arguments.length > 4 && arguments[4] !==
  18208. undefined ? arguments[4] : true;
  18209. var l10n = arguments.length > 5 && arguments[5] !==
  18210. undefined ? arguments[5] : _l10n_utils.NullL10n;
  18211. var enableScripting = arguments.length > 6 && arguments[
  18212. 6] !== undefined ? arguments[6] : null;
  18213. var hasJSActionsPromise = arguments.length > 7 && arguments[
  18214. 7] !== undefined ? arguments[7] : null;
  18215. var mouseState = arguments.length > 8 && arguments[8] !==
  18216. undefined ? arguments[8] : null;
  18217. var fieldObjectsPromise = arguments.length > 9 && arguments[
  18218. 9] !== undefined ? arguments[9] : null;
  18219. var annotationCanvasMap = arguments.length > 10 &&
  18220. arguments[10] !== undefined ? arguments[10] : null;
  18221. return new _annotation_layer_builder
  18222. .AnnotationLayerBuilder({
  18223. pageDiv: pageDiv,
  18224. pdfPage: pdfPage,
  18225. annotationStorage: annotationStorage || ((
  18226. _this$pdfDocument = this.pdfDocument
  18227. ) === null || _this$pdfDocument ===
  18228. void 0 ? void 0 : _this$pdfDocument
  18229. .annotationStorage),
  18230. imageResourcesPath: imageResourcesPath,
  18231. renderForms: renderForms,
  18232. linkService: this.linkService,
  18233. downloadManager: this.downloadManager,
  18234. l10n: l10n,
  18235. enableScripting: enableScripting !== null &&
  18236. enableScripting !== void 0 ?
  18237. enableScripting : this.enableScripting,
  18238. hasJSActionsPromise: hasJSActionsPromise || ((
  18239. _this$pdfDocument2 = this
  18240. .pdfDocument) === null ||
  18241. _this$pdfDocument2 === void 0 ? void 0 :
  18242. _this$pdfDocument2.hasJSActions()),
  18243. fieldObjectsPromise: fieldObjectsPromise || ((
  18244. _this$pdfDocument3 = this
  18245. .pdfDocument) === null ||
  18246. _this$pdfDocument3 === void 0 ? void 0 :
  18247. _this$pdfDocument3.getFieldObjects()),
  18248. mouseState: mouseState || ((
  18249. _this$_scriptingManag = this
  18250. ._scriptingManager) === null ||
  18251. _this$_scriptingManag === void 0 ?
  18252. void 0 : _this$_scriptingManag
  18253. .mouseState),
  18254. annotationCanvasMap: annotationCanvasMap
  18255. });
  18256. }
  18257. }, {
  18258. key: "createXfaLayerBuilder",
  18259. value: function createXfaLayerBuilder(pageDiv, pdfPage) {
  18260. var _this$pdfDocument4;
  18261. var annotationStorage = arguments.length > 2 && arguments[
  18262. 2] !== undefined ? arguments[2] : null;
  18263. return new _xfa_layer_builder.XfaLayerBuilder({
  18264. pageDiv: pageDiv,
  18265. pdfPage: pdfPage,
  18266. annotationStorage: annotationStorage || ((
  18267. _this$pdfDocument4 = this
  18268. .pdfDocument) === null ||
  18269. _this$pdfDocument4 === void 0 ? void 0 :
  18270. _this$pdfDocument4.annotationStorage),
  18271. linkService: this.linkService
  18272. });
  18273. }
  18274. }, {
  18275. key: "createStructTreeLayerBuilder",
  18276. value: function createStructTreeLayerBuilder(pdfPage) {
  18277. return new _struct_tree_layer_builder
  18278. .StructTreeLayerBuilder({
  18279. pdfPage: pdfPage
  18280. });
  18281. }
  18282. }, {
  18283. key: "hasEqualPageSizes",
  18284. get: function get() {
  18285. var firstPageView = this._pages[0];
  18286. for (var i = 1, ii = this._pages.length; i < ii; ++i) {
  18287. var pageView = this._pages[i];
  18288. if (pageView.width !== firstPageView.width || pageView
  18289. .height !== firstPageView.height) {
  18290. return false;
  18291. }
  18292. }
  18293. return true;
  18294. }
  18295. }, {
  18296. key: "getPagesOverview",
  18297. value: function getPagesOverview() {
  18298. var _this4 = this;
  18299. return this._pages.map(function(pageView) {
  18300. var viewport = pageView.pdfPage.getViewport({
  18301. scale: 1
  18302. });
  18303. if (!_this4.enablePrintAutoRotate || (0,
  18304. _ui_utils.isPortraitOrientation)(
  18305. viewport)) {
  18306. return {
  18307. width: viewport.width,
  18308. height: viewport.height,
  18309. rotation: viewport.rotation
  18310. };
  18311. }
  18312. return {
  18313. width: viewport.height,
  18314. height: viewport.width,
  18315. rotation: (viewport.rotation - 90) % 360
  18316. };
  18317. });
  18318. }
  18319. }, {
  18320. key: "optionalContentConfigPromise",
  18321. get: function get() {
  18322. if (!this.pdfDocument) {
  18323. return Promise.resolve(null);
  18324. }
  18325. if (!this._optionalContentConfigPromise) {
  18326. return this.pdfDocument.getOptionalContentConfig();
  18327. }
  18328. return this._optionalContentConfigPromise;
  18329. },
  18330. set: function set(promise) {
  18331. if (!(promise instanceof Promise)) {
  18332. throw new Error("Invalid optionalContentConfigPromise: "
  18333. .concat(promise));
  18334. }
  18335. if (!this.pdfDocument) {
  18336. return;
  18337. }
  18338. if (!this._optionalContentConfigPromise) {
  18339. return;
  18340. }
  18341. this._optionalContentConfigPromise = promise;
  18342. var updateArgs = {
  18343. optionalContentConfigPromise: promise
  18344. };
  18345. var _iterator5 = _createForOfIteratorHelper(this._pages),
  18346. _step5;
  18347. try {
  18348. for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
  18349. var pageView = _step5.value;
  18350. pageView.update(updateArgs);
  18351. }
  18352. } catch (err) {
  18353. _iterator5.e(err);
  18354. } finally {
  18355. _iterator5.f();
  18356. }
  18357. this.update();
  18358. this.eventBus.dispatch("optionalcontentconfigchanged", {
  18359. source: this,
  18360. promise: promise
  18361. });
  18362. }
  18363. }, {
  18364. key: "scrollMode",
  18365. get: function get() {
  18366. return this._scrollMode;
  18367. },
  18368. set: function set(mode) {
  18369. if (this._scrollMode === mode) {
  18370. return;
  18371. }
  18372. if (!(0, _ui_utils.isValidScrollMode)(mode)) {
  18373. throw new Error("Invalid scroll mode: ".concat(mode));
  18374. }
  18375. if (this.pagesCount > PagesCountLimit
  18376. .FORCE_SCROLL_MODE_PAGE) {
  18377. return;
  18378. }
  18379. this._previousScrollMode = this._scrollMode;
  18380. this._scrollMode = mode;
  18381. this.eventBus.dispatch("scrollmodechanged", {
  18382. source: this,
  18383. mode: mode
  18384. });
  18385. this._updateScrollMode(this._currentPageNumber);
  18386. }
  18387. }, {
  18388. key: "_updateScrollMode",
  18389. value: function _updateScrollMode() {
  18390. var pageNumber = arguments.length > 0 && arguments[0] !==
  18391. undefined ? arguments[0] : null;
  18392. var scrollMode = this._scrollMode,
  18393. viewer = this.viewer;
  18394. viewer.classList.toggle("scrollHorizontal", scrollMode ===
  18395. _ui_utils.ScrollMode.HORIZONTAL);
  18396. viewer.classList.toggle("scrollWrapped", scrollMode ===
  18397. _ui_utils.ScrollMode.WRAPPED);
  18398. if (!this.pdfDocument || !pageNumber) {
  18399. return;
  18400. }
  18401. if (scrollMode === _ui_utils.ScrollMode.PAGE) {
  18402. _classPrivateMethodGet(this, _ensurePageViewVisible,
  18403. _ensurePageViewVisible2).call(this);
  18404. } else if (this._previousScrollMode === _ui_utils.ScrollMode
  18405. .PAGE) {
  18406. this._updateSpreadMode();
  18407. }
  18408. if (this._currentScaleValue && isNaN(this
  18409. ._currentScaleValue)) {
  18410. this._setScale(this._currentScaleValue, true);
  18411. }
  18412. this._setCurrentPageNumber(pageNumber, true);
  18413. this.update();
  18414. }
  18415. }, {
  18416. key: "spreadMode",
  18417. get: function get() {
  18418. return this._spreadMode;
  18419. },
  18420. set: function set(mode) {
  18421. if (this._spreadMode === mode) {
  18422. return;
  18423. }
  18424. if (!(0, _ui_utils.isValidSpreadMode)(mode)) {
  18425. throw new Error("Invalid spread mode: ".concat(mode));
  18426. }
  18427. this._spreadMode = mode;
  18428. this.eventBus.dispatch("spreadmodechanged", {
  18429. source: this,
  18430. mode: mode
  18431. });
  18432. this._updateSpreadMode(this._currentPageNumber);
  18433. }
  18434. }, {
  18435. key: "_updateSpreadMode",
  18436. value: function _updateSpreadMode() {
  18437. var pageNumber = arguments.length > 0 && arguments[0] !==
  18438. undefined ? arguments[0] : null;
  18439. if (!this.pdfDocument) {
  18440. return;
  18441. }
  18442. var viewer = this.viewer,
  18443. pages = this._pages;
  18444. if (this._scrollMode === _ui_utils.ScrollMode.PAGE) {
  18445. _classPrivateMethodGet(this, _ensurePageViewVisible,
  18446. _ensurePageViewVisible2).call(this);
  18447. } else {
  18448. viewer.textContent = "";
  18449. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  18450. for (var i = 0, ii = pages.length; i < ii; ++i) {
  18451. viewer.appendChild(pages[i].div);
  18452. }
  18453. } else {
  18454. var parity = this._spreadMode - 1;
  18455. var spread = null;
  18456. for (var _i2 = 0, _ii = pages.length; _i2 < _ii; ++
  18457. _i2) {
  18458. if (spread === null) {
  18459. spread = document.createElement("div");
  18460. spread.className = "spread";
  18461. viewer.appendChild(spread);
  18462. } else if (_i2 % 2 === parity) {
  18463. spread = spread.cloneNode(false);
  18464. viewer.appendChild(spread);
  18465. }
  18466. spread.appendChild(pages[_i2].div);
  18467. }
  18468. }
  18469. }
  18470. if (!pageNumber) {
  18471. return;
  18472. }
  18473. if (this._currentScaleValue && isNaN(this
  18474. ._currentScaleValue)) {
  18475. this._setScale(this._currentScaleValue, true);
  18476. }
  18477. this._setCurrentPageNumber(pageNumber, true);
  18478. this.update();
  18479. }
  18480. }, {
  18481. key: "_getPageAdvance",
  18482. value: function _getPageAdvance(currentPageNumber) {
  18483. var previous = arguments.length > 1 && arguments[1] !==
  18484. undefined ? arguments[1] : false;
  18485. switch (this._scrollMode) {
  18486. case _ui_utils.ScrollMode.WRAPPED: {
  18487. var _this$_getVisiblePage = this._getVisiblePages(),
  18488. views = _this$_getVisiblePage.views,
  18489. pageLayout = new Map();
  18490. var _iterator6 = _createForOfIteratorHelper(views),
  18491. _step6;
  18492. try {
  18493. for (_iterator6.s(); !(_step6 = _iterator6.n())
  18494. .done;) {
  18495. var _step6$value = _step6.value,
  18496. id = _step6$value.id,
  18497. y = _step6$value.y,
  18498. percent = _step6$value.percent,
  18499. widthPercent = _step6$value
  18500. .widthPercent;
  18501. if (percent === 0 || widthPercent < 100) {
  18502. continue;
  18503. }
  18504. var yArray = pageLayout.get(y);
  18505. if (!yArray) {
  18506. pageLayout.set(y, yArray || (
  18507. yArray = []));
  18508. }
  18509. yArray.push(id);
  18510. }
  18511. } catch (err) {
  18512. _iterator6.e(err);
  18513. } finally {
  18514. _iterator6.f();
  18515. }
  18516. var _iterator7 = _createForOfIteratorHelper(
  18517. pageLayout.values()),
  18518. _step7;
  18519. try {
  18520. for (_iterator7.s(); !(_step7 = _iterator7.n())
  18521. .done;) {
  18522. var _yArray = _step7.value;
  18523. var currentIndex = _yArray.indexOf(
  18524. currentPageNumber);
  18525. if (currentIndex === -1) {
  18526. continue;
  18527. }
  18528. var numPages = _yArray.length;
  18529. if (numPages === 1) {
  18530. break;
  18531. }
  18532. if (previous) {
  18533. for (var i = currentIndex - 1, ii =
  18534. 0; i >= ii; i--) {
  18535. var currentId = _yArray[i],
  18536. expectedId = _yArray[i + 1] - 1;
  18537. if (currentId < expectedId) {
  18538. return currentPageNumber -
  18539. expectedId;
  18540. }
  18541. }
  18542. } else {
  18543. for (var _i3 = currentIndex + 1, _ii2 =
  18544. numPages; _i3 < _ii2; _i3++) {
  18545. var _currentId = _yArray[_i3],
  18546. _expectedId = _yArray[_i3 - 1] +
  18547. 1;
  18548. if (_currentId > _expectedId) {
  18549. return _expectedId -
  18550. currentPageNumber;
  18551. }
  18552. }
  18553. }
  18554. if (previous) {
  18555. var firstId = _yArray[0];
  18556. if (firstId < currentPageNumber) {
  18557. return currentPageNumber - firstId +
  18558. 1;
  18559. }
  18560. } else {
  18561. var lastId = _yArray[numPages - 1];
  18562. if (lastId > currentPageNumber) {
  18563. return lastId - currentPageNumber +
  18564. 1;
  18565. }
  18566. }
  18567. break;
  18568. }
  18569. } catch (err) {
  18570. _iterator7.e(err);
  18571. } finally {
  18572. _iterator7.f();
  18573. }
  18574. break;
  18575. }
  18576. case _ui_utils.ScrollMode.HORIZONTAL: {
  18577. break;
  18578. }
  18579. case _ui_utils.ScrollMode.PAGE:
  18580. case _ui_utils.ScrollMode.VERTICAL: {
  18581. if (this._spreadMode === _ui_utils.SpreadMode
  18582. .NONE) {
  18583. break;
  18584. }
  18585. var parity = this._spreadMode - 1;
  18586. if (previous && currentPageNumber % 2 !== parity) {
  18587. break;
  18588. } else if (!previous && currentPageNumber % 2 ===
  18589. parity) {
  18590. break;
  18591. }
  18592. var _this$_getVisiblePage2 = this
  18593. ._getVisiblePages(),
  18594. _views = _this$_getVisiblePage2.views,
  18595. _expectedId2 = previous ? currentPageNumber -
  18596. 1 : currentPageNumber + 1;
  18597. var _iterator8 = _createForOfIteratorHelper(_views),
  18598. _step8;
  18599. try {
  18600. for (_iterator8.s(); !(_step8 = _iterator8.n())
  18601. .done;) {
  18602. var _step8$value = _step8.value,
  18603. _id = _step8$value.id,
  18604. _percent = _step8$value.percent,
  18605. _widthPercent = _step8$value
  18606. .widthPercent;
  18607. if (_id !== _expectedId2) {
  18608. continue;
  18609. }
  18610. if (_percent > 0 && _widthPercent === 100) {
  18611. return 2;
  18612. }
  18613. break;
  18614. }
  18615. } catch (err) {
  18616. _iterator8.e(err);
  18617. } finally {
  18618. _iterator8.f();
  18619. }
  18620. break;
  18621. }
  18622. }
  18623. return 1;
  18624. }
  18625. }, {
  18626. key: "nextPage",
  18627. value: function nextPage() {
  18628. var currentPageNumber = this._currentPageNumber,
  18629. pagesCount = this.pagesCount;
  18630. if (currentPageNumber >= pagesCount) {
  18631. return false;
  18632. }
  18633. var advance = this._getPageAdvance(currentPageNumber,
  18634. false) || 1;
  18635. this.currentPageNumber = Math.min(currentPageNumber +
  18636. advance, pagesCount);
  18637. return true;
  18638. }
  18639. }, {
  18640. key: "previousPage",
  18641. value: function previousPage() {
  18642. var currentPageNumber = this._currentPageNumber;
  18643. if (currentPageNumber <= 1) {
  18644. return false;
  18645. }
  18646. var advance = this._getPageAdvance(currentPageNumber,
  18647. true) || 1;
  18648. this.currentPageNumber = Math.max(currentPageNumber -
  18649. advance, 1);
  18650. return true;
  18651. }
  18652. }, {
  18653. key: "increaseScale",
  18654. value: function increaseScale() {
  18655. var steps = arguments.length > 0 && arguments[0] !==
  18656. undefined ? arguments[0] : 1;
  18657. var newScale = this._currentScale;
  18658. do {
  18659. newScale = (newScale * _ui_utils.DEFAULT_SCALE_DELTA)
  18660. .toFixed(2);
  18661. newScale = Math.ceil(newScale * 10) / 10;
  18662. newScale = Math.min(_ui_utils.MAX_SCALE, newScale);
  18663. } while (--steps > 0 && newScale < _ui_utils.MAX_SCALE);
  18664. this.currentScaleValue = newScale;
  18665. }
  18666. }, {
  18667. key: "decreaseScale",
  18668. value: function decreaseScale() {
  18669. var steps = arguments.length > 0 && arguments[0] !==
  18670. undefined ? arguments[0] : 1;
  18671. var newScale = this._currentScale;
  18672. do {
  18673. newScale = (newScale / _ui_utils.DEFAULT_SCALE_DELTA)
  18674. .toFixed(2);
  18675. newScale = Math.floor(newScale * 10) / 10;
  18676. newScale = Math.max(_ui_utils.MIN_SCALE, newScale);
  18677. } while (--steps > 0 && newScale > _ui_utils.MIN_SCALE);
  18678. this.currentScaleValue = newScale;
  18679. }
  18680. }]);
  18681. return BaseViewer;
  18682. }();
  18683. exports.BaseViewer = BaseViewer;
  18684. function _initializePermissions2(permissions) {
  18685. if (!permissions) {
  18686. return;
  18687. }
  18688. if (!permissions.includes(_pdfjsLib.PermissionFlag.COPY)) {
  18689. this.viewer.classList.add(ENABLE_PERMISSIONS_CLASS);
  18690. }
  18691. if (!permissions.includes(_pdfjsLib.PermissionFlag.MODIFY_ANNOTATIONS) && !permissions
  18692. .includes(_pdfjsLib.PermissionFlag.FILL_INTERACTIVE_FORMS)) {
  18693. if (_classPrivateFieldGet(this, _annotationMode) === _pdfjsLib.AnnotationMode
  18694. .ENABLE_FORMS) {
  18695. _classPrivateFieldSet(this, _previousAnnotationMode, _classPrivateFieldGet(this,
  18696. _annotationMode));
  18697. _classPrivateFieldSet(this, _annotationMode, _pdfjsLib.AnnotationMode.ENABLE);
  18698. }
  18699. }
  18700. }
  18701. function _onePageRenderedOrForceFetch2() {
  18702. var _this5 = this;
  18703. if (document.visibilityState === "hidden" || !this.container.offsetParent || this
  18704. ._getVisiblePages().views.length === 0) {
  18705. return Promise.resolve();
  18706. }
  18707. var visibilityChangePromise = new Promise(function(resolve) {
  18708. _classPrivateFieldSet(_this5, _onVisibilityChange, function() {
  18709. if (document.visibilityState !== "hidden") {
  18710. return;
  18711. }
  18712. resolve();
  18713. document.removeEventListener("visibilitychange",
  18714. _classPrivateFieldGet(_this5, _onVisibilityChange));
  18715. _classPrivateFieldSet(_this5, _onVisibilityChange, null);
  18716. });
  18717. document.addEventListener("visibilitychange", _classPrivateFieldGet(_this5,
  18718. _onVisibilityChange));
  18719. });
  18720. return Promise.race([this._onePageRenderedCapability.promise, visibilityChangePromise]);
  18721. }
  18722. function _ensurePageViewVisible2() {
  18723. if (this._scrollMode !== _ui_utils.ScrollMode.PAGE) {
  18724. throw new Error("#ensurePageViewVisible: Invalid scrollMode value.");
  18725. }
  18726. var pageNumber = this._currentPageNumber,
  18727. state = _classPrivateFieldGet(this, _scrollModePageState),
  18728. viewer = this.viewer;
  18729. viewer.textContent = "";
  18730. state.pages.length = 0;
  18731. if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
  18732. var pageView = this._pages[pageNumber - 1];
  18733. if (this.isInPresentationMode) {
  18734. var spread = document.createElement("div");
  18735. spread.className = "spread";
  18736. var dummyPage = document.createElement("div");
  18737. dummyPage.className = "dummyPage";
  18738. dummyPage.style.height = "".concat(this.container.clientHeight, "px");
  18739. spread.appendChild(dummyPage);
  18740. spread.appendChild(pageView.div);
  18741. viewer.appendChild(spread);
  18742. } else {
  18743. viewer.appendChild(pageView.div);
  18744. }
  18745. state.pages.push(pageView);
  18746. } else {
  18747. var pageIndexSet = new Set(),
  18748. parity = this._spreadMode - 1;
  18749. if (pageNumber % 2 !== parity) {
  18750. pageIndexSet.add(pageNumber - 1);
  18751. pageIndexSet.add(pageNumber);
  18752. } else {
  18753. pageIndexSet.add(pageNumber - 2);
  18754. pageIndexSet.add(pageNumber - 1);
  18755. }
  18756. var _spread = null;
  18757. var _iterator9 = _createForOfIteratorHelper(pageIndexSet),
  18758. _step9;
  18759. try {
  18760. for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
  18761. var i = _step9.value;
  18762. var _pageView = this._pages[i];
  18763. if (!_pageView) {
  18764. continue;
  18765. }
  18766. if (_spread === null) {
  18767. _spread = document.createElement("div");
  18768. _spread.className = "spread";
  18769. viewer.appendChild(_spread);
  18770. } else if (i % 2 === parity) {
  18771. _spread = _spread.cloneNode(false);
  18772. viewer.appendChild(_spread);
  18773. }
  18774. _spread.appendChild(_pageView.div);
  18775. state.pages.push(_pageView);
  18776. }
  18777. } catch (err) {
  18778. _iterator9.e(err);
  18779. } finally {
  18780. _iterator9.f();
  18781. }
  18782. }
  18783. state.scrollDown = pageNumber >= state.previousPageNumber;
  18784. state.previousPageNumber = pageNumber;
  18785. }
  18786. function _isSameScale2(newScale) {
  18787. if (this.isInPresentationMode && this.container.clientHeight !== _classPrivateFieldGet(
  18788. this, _previousContainerHeight)) {
  18789. return false;
  18790. }
  18791. return newScale === this._currentScale || Math.abs(newScale - this._currentScale) <
  18792. 1e-15;
  18793. }
  18794. function _ensurePdfPageLoaded2(_x) {
  18795. return _ensurePdfPageLoaded3.apply(this, arguments);
  18796. }
  18797. function _ensurePdfPageLoaded3() {
  18798. _ensurePdfPageLoaded3 = _asyncToGenerator( /*#__PURE__*/ _regenerator["default"].mark(
  18799. function _callee2(pageView) {
  18800. var _this$linkService$_ca, _this$linkService, pdfPage;
  18801. return _regenerator["default"].wrap(function _callee2$(_context3) {
  18802. while (1) {
  18803. switch (_context3.prev = _context3.next) {
  18804. case 0:
  18805. if (!pageView.pdfPage) {
  18806. _context3.next = 2;
  18807. break;
  18808. }
  18809. return _context3.abrupt("return", pageView
  18810. .pdfPage);
  18811. case 2:
  18812. _context3.prev = 2;
  18813. _context3.next = 5;
  18814. return this.pdfDocument.getPage(pageView.id);
  18815. case 5:
  18816. pdfPage = _context3.sent;
  18817. if (!pageView.pdfPage) {
  18818. pageView.setPdfPage(pdfPage);
  18819. }
  18820. if (!((_this$linkService$_ca = (
  18821. _this$linkService = this
  18822. .linkService)._cachedPageNumber) !==
  18823. null && _this$linkService$_ca !==
  18824. void 0 && _this$linkService$_ca.call(
  18825. _this$linkService, pdfPage.ref))) {
  18826. this.linkService.cachePageRef(pageView.id,
  18827. pdfPage.ref);
  18828. }
  18829. return _context3.abrupt("return", pdfPage);
  18830. case 11:
  18831. _context3.prev = 11;
  18832. _context3.t0 = _context3["catch"](2);
  18833. console.error(
  18834. "Unable to get page for page view",
  18835. _context3.t0);
  18836. return _context3.abrupt("return", null);
  18837. case 15:
  18838. case "end":
  18839. return _context3.stop();
  18840. }
  18841. }
  18842. }, _callee2, this, [
  18843. [2, 11]
  18844. ]);
  18845. }));
  18846. return _ensurePdfPageLoaded3.apply(this, arguments);
  18847. }
  18848. function _getScrollAhead2(visible) {
  18849. var _visible$first, _visible$last;
  18850. if (((_visible$first = visible.first) === null || _visible$first === void 0 ? void 0 :
  18851. _visible$first.id) === 1) {
  18852. return true;
  18853. } else if (((_visible$last = visible.last) === null || _visible$last === void 0 ?
  18854. void 0 : _visible$last.id) === this.pagesCount) {
  18855. return false;
  18856. }
  18857. switch (this._scrollMode) {
  18858. case _ui_utils.ScrollMode.PAGE:
  18859. return _classPrivateFieldGet(this, _scrollModePageState).scrollDown;
  18860. case _ui_utils.ScrollMode.HORIZONTAL:
  18861. return this.scroll.right;
  18862. }
  18863. return this.scroll.down;
  18864. }
  18865. function _toggleLoadingIconSpinner2(visibleIds) {
  18866. var _iterator10 = _createForOfIteratorHelper(visibleIds),
  18867. _step10;
  18868. try {
  18869. for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
  18870. var id = _step10.value;
  18871. var pageView = this._pages[id - 1];
  18872. pageView === null || pageView === void 0 ? void 0 : pageView
  18873. .toggleLoadingIconSpinner(true);
  18874. }
  18875. } catch (err) {
  18876. _iterator10.e(err);
  18877. } finally {
  18878. _iterator10.f();
  18879. }
  18880. var _iterator11 = _createForOfIteratorHelper(_classPrivateFieldGet(this, _buffer)),
  18881. _step11;
  18882. try {
  18883. for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
  18884. var _pageView2 = _step11.value;
  18885. if (visibleIds.has(_pageView2.id)) {
  18886. continue;
  18887. }
  18888. _pageView2.toggleLoadingIconSpinner(false);
  18889. }
  18890. } catch (err) {
  18891. _iterator11.e(err);
  18892. } finally {
  18893. _iterator11.f();
  18894. }
  18895. }
  18896. /***/
  18897. }),
  18898. /* 31 */
  18899. /***/
  18900. ((__unused_webpack_module, exports, __webpack_require__) => {
  18901. Object.defineProperty(exports, "__esModule", ({
  18902. value: true
  18903. }));
  18904. exports.AnnotationLayerBuilder = void 0;
  18905. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  18906. var _pdfjsLib = __webpack_require__(7);
  18907. var _l10n_utils = __webpack_require__(32);
  18908. function _interopRequireDefault(obj) {
  18909. return obj && obj.__esModule ? obj : {
  18910. "default": obj
  18911. };
  18912. }
  18913. function _slicedToArray(arr, i) {
  18914. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) ||
  18915. _unsupportedIterableToArray(arr, i) || _nonIterableRest();
  18916. }
  18917. function _nonIterableRest() {
  18918. throw new TypeError(
  18919. "Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
  18920. );
  18921. }
  18922. function _unsupportedIterableToArray(o, minLen) {
  18923. if (!o) return;
  18924. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  18925. var n = Object.prototype.toString.call(o).slice(8, -1);
  18926. if (n === "Object" && o.constructor) n = o.constructor.name;
  18927. if (n === "Map" || n === "Set") return Array.from(o);
  18928. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
  18929. return _arrayLikeToArray(o, minLen);
  18930. }
  18931. function _arrayLikeToArray(arr, len) {
  18932. if (len == null || len > arr.length) len = arr.length;
  18933. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  18934. arr2[i] = arr[i];
  18935. }
  18936. return arr2;
  18937. }
  18938. function _iterableToArrayLimit(arr, i) {
  18939. var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] ||
  18940. arr["@@iterator"];
  18941. if (_i == null) return;
  18942. var _arr = [];
  18943. var _n = true;
  18944. var _d = false;
  18945. var _s, _e;
  18946. try {
  18947. for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
  18948. _arr.push(_s.value);
  18949. if (i && _arr.length === i) break;
  18950. }
  18951. } catch (err) {
  18952. _d = true;
  18953. _e = err;
  18954. } finally {
  18955. try {
  18956. if (!_n && _i["return"] != null) _i["return"]();
  18957. } finally {
  18958. if (_d) throw _e;
  18959. }
  18960. }
  18961. return _arr;
  18962. }
  18963. function _arrayWithHoles(arr) {
  18964. if (Array.isArray(arr)) return arr;
  18965. }
  18966. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  18967. try {
  18968. var info = gen[key](arg);
  18969. var value = info.value;
  18970. } catch (error) {
  18971. reject(error);
  18972. return;
  18973. }
  18974. if (info.done) {
  18975. resolve(value);
  18976. } else {
  18977. Promise.resolve(value).then(_next, _throw);
  18978. }
  18979. }
  18980. function _asyncToGenerator(fn) {
  18981. return function() {
  18982. var self = this,
  18983. args = arguments;
  18984. return new Promise(function(resolve, reject) {
  18985. var gen = fn.apply(self, args);
  18986. function _next(value) {
  18987. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next",
  18988. value);
  18989. }
  18990. function _throw(err) {
  18991. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw",
  18992. err);
  18993. }
  18994. _next(undefined);
  18995. });
  18996. };
  18997. }
  18998. function _classCallCheck(instance, Constructor) {
  18999. if (!(instance instanceof Constructor)) {
  19000. throw new TypeError("Cannot call a class as a function");
  19001. }
  19002. }
  19003. function _defineProperties(target, props) {
  19004. for (var i = 0; i < props.length; i++) {
  19005. var descriptor = props[i];
  19006. descriptor.enumerable = descriptor.enumerable || false;
  19007. descriptor.configurable = true;
  19008. if ("value" in descriptor) descriptor.writable = true;
  19009. Object.defineProperty(target, descriptor.key, descriptor);
  19010. }
  19011. }
  19012. function _createClass(Constructor, protoProps, staticProps) {
  19013. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  19014. if (staticProps) _defineProperties(Constructor, staticProps);
  19015. Object.defineProperty(Constructor, "prototype", {
  19016. writable: false
  19017. });
  19018. return Constructor;
  19019. }
  19020. var AnnotationLayerBuilder = /*#__PURE__*/ function() {
  19021. function AnnotationLayerBuilder(_ref) {
  19022. var pageDiv = _ref.pageDiv,
  19023. pdfPage = _ref.pdfPage,
  19024. linkService = _ref.linkService,
  19025. downloadManager = _ref.downloadManager,
  19026. _ref$annotationStorag = _ref.annotationStorage,
  19027. annotationStorage = _ref$annotationStorag === void 0 ? null :
  19028. _ref$annotationStorag,
  19029. _ref$imageResourcesPa = _ref.imageResourcesPath,
  19030. imageResourcesPath = _ref$imageResourcesPa === void 0 ? "" :
  19031. _ref$imageResourcesPa,
  19032. _ref$renderForms = _ref.renderForms,
  19033. renderForms = _ref$renderForms === void 0 ? true : _ref$renderForms,
  19034. _ref$l10n = _ref.l10n,
  19035. l10n = _ref$l10n === void 0 ? _l10n_utils.NullL10n : _ref$l10n,
  19036. _ref$enableScripting = _ref.enableScripting,
  19037. enableScripting = _ref$enableScripting === void 0 ? false :
  19038. _ref$enableScripting,
  19039. _ref$hasJSActionsProm = _ref.hasJSActionsPromise,
  19040. hasJSActionsPromise = _ref$hasJSActionsProm === void 0 ? null :
  19041. _ref$hasJSActionsProm,
  19042. _ref$fieldObjectsProm = _ref.fieldObjectsPromise,
  19043. fieldObjectsPromise = _ref$fieldObjectsProm === void 0 ? null :
  19044. _ref$fieldObjectsProm,
  19045. _ref$mouseState = _ref.mouseState,
  19046. mouseState = _ref$mouseState === void 0 ? null : _ref$mouseState,
  19047. _ref$annotationCanvas = _ref.annotationCanvasMap,
  19048. annotationCanvasMap = _ref$annotationCanvas === void 0 ? null :
  19049. _ref$annotationCanvas;
  19050. _classCallCheck(this, AnnotationLayerBuilder);
  19051. this.pageDiv = pageDiv;
  19052. this.pdfPage = pdfPage;
  19053. this.linkService = linkService;
  19054. this.downloadManager = downloadManager;
  19055. this.imageResourcesPath = imageResourcesPath;
  19056. this.renderForms = renderForms;
  19057. this.l10n = l10n;
  19058. this.annotationStorage = annotationStorage;
  19059. this.enableScripting = enableScripting;
  19060. this._hasJSActionsPromise = hasJSActionsPromise;
  19061. this._fieldObjectsPromise = fieldObjectsPromise;
  19062. this._mouseState = mouseState;
  19063. this._annotationCanvasMap = annotationCanvasMap;
  19064. this.div = null;
  19065. this._cancelled = false;
  19066. }
  19067. _createClass(AnnotationLayerBuilder, [{
  19068. key: "render",
  19069. value: function() {
  19070. var _render = _asyncToGenerator( /*#__PURE__*/ _regenerator[
  19071. "default"].mark(function _callee(viewport) {
  19072. var intent,
  19073. _yield$Promise$all,
  19074. _yield$Promise$all2,
  19075. annotations,
  19076. _yield$Promise$all2$,
  19077. hasJSActions,
  19078. _yield$Promise$all2$2,
  19079. fieldObjects,
  19080. parameters,
  19081. _args = arguments;
  19082. return _regenerator["default"].wrap(
  19083. function _callee$(_context) {
  19084. while (1) {
  19085. switch (_context.prev =
  19086. _context.next) {
  19087. case 0:
  19088. intent = _args
  19089. .length > 1 &&
  19090. _args[1] !==
  19091. undefined ?
  19092. _args[1] :
  19093. "display";
  19094. _context.next = 3;
  19095. return Promise.all([
  19096. this
  19097. .pdfPage
  19098. .getAnnotations({
  19099. intent: intent
  19100. }), this
  19101. ._hasJSActionsPromise,
  19102. this
  19103. ._fieldObjectsPromise
  19104. ]);
  19105. case 3:
  19106. _yield$Promise$all =
  19107. _context.sent;
  19108. _yield$Promise$all2
  19109. =
  19110. _slicedToArray(
  19111. _yield$Promise$all,
  19112. 3);
  19113. annotations =
  19114. _yield$Promise$all2[
  19115. 0];
  19116. _yield$Promise$all2$
  19117. =
  19118. _yield$Promise$all2[
  19119. 1];
  19120. hasJSActions =
  19121. _yield$Promise$all2$ ===
  19122. void 0 ? false :
  19123. _yield$Promise$all2$;
  19124. _yield$Promise$all2$2
  19125. =
  19126. _yield$Promise$all2[
  19127. 2];
  19128. fieldObjects =
  19129. _yield$Promise$all2$2 ===
  19130. void 0 ? null :
  19131. _yield$Promise$all2$2;
  19132. if (!(this
  19133. ._cancelled ||
  19134. annotations
  19135. .length ===
  19136. 0)) {
  19137. _context.next =
  19138. 12;
  19139. break;
  19140. }
  19141. return _context
  19142. .abrupt(
  19143. "return");
  19144. case 12:
  19145. parameters = {
  19146. viewport: viewport
  19147. .clone({
  19148. dontFlip: true
  19149. }),
  19150. div: this
  19151. .div,
  19152. annotations: annotations,
  19153. page: this
  19154. .pdfPage,
  19155. imageResourcesPath: this
  19156. .imageResourcesPath,
  19157. renderForms: this
  19158. .renderForms,
  19159. linkService: this
  19160. .linkService,
  19161. downloadManager: this
  19162. .downloadManager,
  19163. annotationStorage: this
  19164. .annotationStorage,
  19165. enableScripting: this
  19166. .enableScripting,
  19167. hasJSActions: hasJSActions,
  19168. fieldObjects: fieldObjects,
  19169. mouseState: this
  19170. ._mouseState,
  19171. annotationCanvasMap: this
  19172. ._annotationCanvasMap
  19173. };
  19174. if (this.div) {
  19175. _pdfjsLib
  19176. .AnnotationLayer
  19177. .update(
  19178. parameters
  19179. );
  19180. } else {
  19181. this.div =
  19182. document
  19183. .createElement(
  19184. "div");
  19185. this.div
  19186. .className =
  19187. "annotationLayer";
  19188. this.pageDiv
  19189. .appendChild(
  19190. this.div
  19191. );
  19192. parameters.div =
  19193. this.div;
  19194. _pdfjsLib
  19195. .AnnotationLayer
  19196. .render(
  19197. parameters
  19198. );
  19199. this.l10n
  19200. .translate(
  19201. this.div
  19202. );
  19203. }
  19204. case 14:
  19205. case "end":
  19206. return _context
  19207. .stop();
  19208. }
  19209. }
  19210. }, _callee, this);
  19211. }));
  19212. function render(_x) {
  19213. return _render.apply(this, arguments);
  19214. }
  19215. return render;
  19216. }()
  19217. }, {
  19218. key: "cancel",
  19219. value: function cancel() {
  19220. this._cancelled = true;
  19221. }
  19222. }, {
  19223. key: "hide",
  19224. value: function hide() {
  19225. if (!this.div) {
  19226. return;
  19227. }
  19228. this.div.hidden = true;
  19229. }
  19230. }]);
  19231. return AnnotationLayerBuilder;
  19232. }();
  19233. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  19234. /***/
  19235. }),
  19236. /* 32 */
  19237. /***/
  19238. ((__unused_webpack_module, exports, __webpack_require__) => {
  19239. Object.defineProperty(exports, "__esModule", ({
  19240. value: true
  19241. }));
  19242. exports.NullL10n = void 0;
  19243. exports.fixupLangCode = fixupLangCode;
  19244. exports.getL10nFallback = getL10nFallback;
  19245. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  19246. function _interopRequireDefault(obj) {
  19247. return obj && obj.__esModule ? obj : {
  19248. "default": obj
  19249. };
  19250. }
  19251. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  19252. try {
  19253. var info = gen[key](arg);
  19254. var value = info.value;
  19255. } catch (error) {
  19256. reject(error);
  19257. return;
  19258. }
  19259. if (info.done) {
  19260. resolve(value);
  19261. } else {
  19262. Promise.resolve(value).then(_next, _throw);
  19263. }
  19264. }
  19265. function _asyncToGenerator(fn) {
  19266. return function() {
  19267. var self = this,
  19268. args = arguments;
  19269. return new Promise(function(resolve, reject) {
  19270. var gen = fn.apply(self, args);
  19271. function _next(value) {
  19272. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next",
  19273. value);
  19274. }
  19275. function _throw(err) {
  19276. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw",
  19277. err);
  19278. }
  19279. _next(undefined);
  19280. });
  19281. };
  19282. }
  19283. var DEFAULT_L10N_STRINGS = {
  19284. of_pages: "of {{pagesCount}}",
  19285. page_of_pages: "({{pageNumber}} of {{pagesCount}})",
  19286. document_properties_kb: "{{size_kb}} KB ({{size_b}} bytes)",
  19287. document_properties_mb: "{{size_mb}} MB ({{size_b}} bytes)",
  19288. document_properties_date_string: "{{date}}, {{time}}",
  19289. document_properties_page_size_unit_inches: "in",
  19290. document_properties_page_size_unit_millimeters: "mm",
  19291. document_properties_page_size_orientation_portrait: "portrait",
  19292. document_properties_page_size_orientation_landscape: "landscape",
  19293. document_properties_page_size_name_a3: "A3",
  19294. document_properties_page_size_name_a4: "A4",
  19295. document_properties_page_size_name_letter: "Letter",
  19296. document_properties_page_size_name_legal: "Legal",
  19297. document_properties_page_size_dimension_string: "{{width}} × {{height}} {{unit}} ({{orientation}})",
  19298. document_properties_page_size_dimension_name_string: "{{width}} × {{height}} {{unit}} ({{name}}, {{orientation}})",
  19299. document_properties_linearized_yes: "Yes",
  19300. document_properties_linearized_no: "No",
  19301. print_progress_percent: "{{progress}}%",
  19302. "toggle_sidebar.title": "Toggle Sidebar",
  19303. "toggle_sidebar_notification2.title": "Toggle Sidebar (document contains outline/attachments/layers)",
  19304. additional_layers: "Additional Layers",
  19305. page_landmark: "Page {{page}}",
  19306. thumb_page_title: "Page {{page}}",
  19307. thumb_page_canvas: "Thumbnail of Page {{page}}",
  19308. find_reached_top: "Reached top of document, continued from bottom",
  19309. find_reached_bottom: "Reached end of document, continued from top",
  19310. "find_match_count[one]": "{{current}} of {{total}} match",
  19311. "find_match_count[other]": "{{current}} of {{total}} matches",
  19312. "find_match_count_limit[one]": "More than {{limit}} match",
  19313. "find_match_count_limit[other]": "More than {{limit}} matches",
  19314. find_not_found: "Phrase not found",
  19315. error_version_info: "PDF.js v{{version}} (build: {{build}})",
  19316. error_message: "Message: {{message}}",
  19317. error_stack: "Stack: {{stack}}",
  19318. error_file: "File: {{file}}",
  19319. error_line: "Line: {{line}}",
  19320. rendering_error: "An error occurred while rendering the page.",
  19321. page_scale_width: "Page Width",
  19322. page_scale_fit: "Page Fit",
  19323. page_scale_auto: "Automatic Zoom",
  19324. page_scale_actual: "Actual Size",
  19325. page_scale_percent: "{{scale}}%",
  19326. loading: "Loading…",
  19327. loading_error: "An error occurred while loading the PDF.",
  19328. invalid_file_error: "Invalid or corrupted PDF file.",
  19329. missing_file_error: "Missing PDF file.",
  19330. unexpected_response_error: "Unexpected server response.",
  19331. printing_not_supported: "Warning: Printing is not fully supported by this browser.",
  19332. printing_not_ready: "Warning: The PDF is not fully loaded for printing.",
  19333. web_fonts_disabled: "Web fonts are disabled: unable to use embedded PDF fonts."
  19334. };
  19335. function getL10nFallback(key, args) {
  19336. switch (key) {
  19337. case "find_match_count":
  19338. key = "find_match_count[".concat(args.total === 1 ? "one" : "other", "]");
  19339. break;
  19340. case "find_match_count_limit":
  19341. key = "find_match_count_limit[".concat(args.limit === 1 ? "one" : "other", "]");
  19342. break;
  19343. }
  19344. return DEFAULT_L10N_STRINGS[key] || "";
  19345. }
  19346. var PARTIAL_LANG_CODES = {
  19347. en: "en-US",
  19348. es: "es-ES",
  19349. fy: "fy-NL",
  19350. ga: "ga-IE",
  19351. gu: "gu-IN",
  19352. hi: "hi-IN",
  19353. hy: "hy-AM",
  19354. nb: "nb-NO",
  19355. ne: "ne-NP",
  19356. nn: "nn-NO",
  19357. pa: "pa-IN",
  19358. pt: "pt-PT",
  19359. sv: "sv-SE",
  19360. zh: "zh-CN"
  19361. };
  19362. function fixupLangCode(langCode) {
  19363. return PARTIAL_LANG_CODES[langCode === null || langCode === void 0 ? void 0 : langCode
  19364. .toLowerCase()] || langCode;
  19365. }
  19366. function formatL10nValue(text, args) {
  19367. if (!args) {
  19368. return text;
  19369. }
  19370. return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function(all, name) {
  19371. return name in args ? args[name] : "{{" + name + "}}";
  19372. });
  19373. }
  19374. var NullL10n = {
  19375. getLanguage: function getLanguage() {
  19376. return _asyncToGenerator( /*#__PURE__*/ _regenerator["default"].mark(
  19377. function _callee() {
  19378. return _regenerator["default"].wrap(function _callee$(
  19379. _context) {
  19380. while (1) {
  19381. switch (_context.prev = _context.next) {
  19382. case 0:
  19383. return _context.abrupt("return",
  19384. "en-us");
  19385. case 1:
  19386. case "end":
  19387. return _context.stop();
  19388. }
  19389. }
  19390. }, _callee);
  19391. }))();
  19392. },
  19393. getDirection: function getDirection() {
  19394. return _asyncToGenerator( /*#__PURE__*/ _regenerator["default"].mark(
  19395. function _callee2() {
  19396. return _regenerator["default"].wrap(function _callee2$(
  19397. _context2) {
  19398. while (1) {
  19399. switch (_context2.prev = _context2.next) {
  19400. case 0:
  19401. return _context2.abrupt("return",
  19402. "ltr");
  19403. case 1:
  19404. case "end":
  19405. return _context2.stop();
  19406. }
  19407. }
  19408. }, _callee2);
  19409. }))();
  19410. },
  19411. get: function get(key) {
  19412. var _arguments = arguments;
  19413. return _asyncToGenerator( /*#__PURE__*/ _regenerator["default"].mark(
  19414. function _callee3() {
  19415. var args, fallback;
  19416. return _regenerator["default"].wrap(function _callee3$(
  19417. _context3) {
  19418. while (1) {
  19419. switch (_context3.prev = _context3.next) {
  19420. case 0:
  19421. args = _arguments.length > 1 &&
  19422. _arguments[1] !== undefined ?
  19423. _arguments[1] : null;
  19424. fallback = _arguments.length > 2 &&
  19425. _arguments[2] !== undefined ?
  19426. _arguments[2] : getL10nFallback(
  19427. key, args);
  19428. return _context3.abrupt("return",
  19429. formatL10nValue(fallback,
  19430. args));
  19431. case 3:
  19432. case "end":
  19433. return _context3.stop();
  19434. }
  19435. }
  19436. }, _callee3);
  19437. }))();
  19438. },
  19439. translate: function translate(element) {
  19440. return _asyncToGenerator( /*#__PURE__*/ _regenerator["default"].mark(
  19441. function _callee4() {
  19442. return _regenerator["default"].wrap(function _callee4$(
  19443. _context4) {
  19444. while (1) {
  19445. switch (_context4.prev = _context4.next) {
  19446. case 0:
  19447. case "end":
  19448. return _context4.stop();
  19449. }
  19450. }
  19451. }, _callee4);
  19452. }))();
  19453. }
  19454. };
  19455. exports.NullL10n = NullL10n;
  19456. /***/
  19457. }),
  19458. /* 33 */
  19459. /***/
  19460. ((__unused_webpack_module, exports, __webpack_require__) => {
  19461. Object.defineProperty(exports, "__esModule", ({
  19462. value: true
  19463. }));
  19464. exports.PDFPageView = void 0;
  19465. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  19466. var _pdfjsLib = __webpack_require__(7);
  19467. var _ui_utils = __webpack_require__(5);
  19468. var _app_options = __webpack_require__(1);
  19469. var _l10n_utils = __webpack_require__(32);
  19470. function _interopRequireDefault(obj) {
  19471. return obj && obj.__esModule ? obj : {
  19472. "default": obj
  19473. };
  19474. }
  19475. function _typeof(obj) {
  19476. "@babel/helpers - typeof";
  19477. return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ?
  19478. function(obj) {
  19479. return typeof obj;
  19480. } : function(obj) {
  19481. return obj && "function" == typeof Symbol && obj.constructor === Symbol &&
  19482. obj !== Symbol.prototype ? "symbol" : typeof obj;
  19483. }, _typeof(obj);
  19484. }
  19485. function _createForOfIteratorHelper(o, allowArrayLike) {
  19486. var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
  19487. if (!it) {
  19488. if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike &&
  19489. o && typeof o.length === "number") {
  19490. if (it) o = it;
  19491. var i = 0;
  19492. var F = function F() {};
  19493. return {
  19494. s: F,
  19495. n: function n() {
  19496. if (i >= o.length) return {
  19497. done: true
  19498. };
  19499. return {
  19500. done: false,
  19501. value: o[i++]
  19502. };
  19503. },
  19504. e: function e(_e) {
  19505. throw _e;
  19506. },
  19507. f: F
  19508. };
  19509. }
  19510. throw new TypeError(
  19511. "Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
  19512. );
  19513. }
  19514. var normalCompletion = true,
  19515. didErr = false,
  19516. err;
  19517. return {
  19518. s: function s() {
  19519. it = it.call(o);
  19520. },
  19521. n: function n() {
  19522. var step = it.next();
  19523. normalCompletion = step.done;
  19524. return step;
  19525. },
  19526. e: function e(_e2) {
  19527. didErr = true;
  19528. err = _e2;
  19529. },
  19530. f: function f() {
  19531. try {
  19532. if (!normalCompletion && it["return"] != null) it["return"]();
  19533. } finally {
  19534. if (didErr) throw err;
  19535. }
  19536. }
  19537. };
  19538. }
  19539. function _unsupportedIterableToArray(o, minLen) {
  19540. if (!o) return;
  19541. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  19542. var n = Object.prototype.toString.call(o).slice(8, -1);
  19543. if (n === "Object" && o.constructor) n = o.constructor.name;
  19544. if (n === "Map" || n === "Set") return Array.from(o);
  19545. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
  19546. return _arrayLikeToArray(o, minLen);
  19547. }
  19548. function _arrayLikeToArray(arr, len) {
  19549. if (len == null || len > arr.length) len = arr.length;
  19550. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  19551. arr2[i] = arr[i];
  19552. }
  19553. return arr2;
  19554. }
  19555. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  19556. try {
  19557. var info = gen[key](arg);
  19558. var value = info.value;
  19559. } catch (error) {
  19560. reject(error);
  19561. return;
  19562. }
  19563. if (info.done) {
  19564. resolve(value);
  19565. } else {
  19566. Promise.resolve(value).then(_next, _throw);
  19567. }
  19568. }
  19569. function _asyncToGenerator(fn) {
  19570. return function() {
  19571. var self = this,
  19572. args = arguments;
  19573. return new Promise(function(resolve, reject) {
  19574. var gen = fn.apply(self, args);
  19575. function _next(value) {
  19576. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next",
  19577. value);
  19578. }
  19579. function _throw(err) {
  19580. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw",
  19581. err);
  19582. }
  19583. _next(undefined);
  19584. });
  19585. };
  19586. }
  19587. function _classCallCheck(instance, Constructor) {
  19588. if (!(instance instanceof Constructor)) {
  19589. throw new TypeError("Cannot call a class as a function");
  19590. }
  19591. }
  19592. function _defineProperties(target, props) {
  19593. for (var i = 0; i < props.length; i++) {
  19594. var descriptor = props[i];
  19595. descriptor.enumerable = descriptor.enumerable || false;
  19596. descriptor.configurable = true;
  19597. if ("value" in descriptor) descriptor.writable = true;
  19598. Object.defineProperty(target, descriptor.key, descriptor);
  19599. }
  19600. }
  19601. function _createClass(Constructor, protoProps, staticProps) {
  19602. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  19603. if (staticProps) _defineProperties(Constructor, staticProps);
  19604. Object.defineProperty(Constructor, "prototype", {
  19605. writable: false
  19606. });
  19607. return Constructor;
  19608. }
  19609. function _classPrivateFieldInitSpec(obj, privateMap, value) {
  19610. _checkPrivateRedeclaration(obj, privateMap);
  19611. privateMap.set(obj, value);
  19612. }
  19613. function _checkPrivateRedeclaration(obj, privateCollection) {
  19614. if (privateCollection.has(obj)) {
  19615. throw new TypeError(
  19616. "Cannot initialize the same private elements twice on an object");
  19617. }
  19618. }
  19619. function _classPrivateFieldGet(receiver, privateMap) {
  19620. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get");
  19621. return _classApplyDescriptorGet(receiver, descriptor);
  19622. }
  19623. function _classApplyDescriptorGet(receiver, descriptor) {
  19624. if (descriptor.get) {
  19625. return descriptor.get.call(receiver);
  19626. }
  19627. return descriptor.value;
  19628. }
  19629. function _classPrivateFieldSet(receiver, privateMap, value) {
  19630. var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set");
  19631. _classApplyDescriptorSet(receiver, descriptor, value);
  19632. return value;
  19633. }
  19634. function _classExtractFieldDescriptor(receiver, privateMap, action) {
  19635. if (!privateMap.has(receiver)) {
  19636. throw new TypeError("attempted to " + action + " private field on non-instance");
  19637. }
  19638. return privateMap.get(receiver);
  19639. }
  19640. function _classApplyDescriptorSet(receiver, descriptor, value) {
  19641. if (descriptor.set) {
  19642. descriptor.set.call(receiver, value);
  19643. } else {
  19644. if (!descriptor.writable) {
  19645. throw new TypeError("attempted to set read only private field");
  19646. }
  19647. descriptor.value = value;
  19648. }
  19649. }
  19650. var MAX_CANVAS_PIXELS = _app_options.compatibilityParams.maxCanvasPixels || 16777216;
  19651. var _annotationMode = /*#__PURE__*/ new WeakMap();
  19652. var PDFPageView = /*#__PURE__*/ function() {
  19653. function PDFPageView(options) {
  19654. var _options$textLayerMod, _options$annotationMo, _options$textHighligh,
  19655. _this$renderingQueue;
  19656. _classCallCheck(this, PDFPageView);
  19657. _classPrivateFieldInitSpec(this, _annotationMode, {
  19658. writable: true,
  19659. value: _pdfjsLib.AnnotationMode.ENABLE_FORMS
  19660. });
  19661. var container = options.container;
  19662. var defaultViewport = options.defaultViewport;
  19663. this.id = options.id;
  19664. this.renderingId = "page" + this.id;
  19665. this.pdfPage = null;
  19666. this.pageLabel = null;
  19667. this.rotation = 0;
  19668. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  19669. this.viewport = defaultViewport;
  19670. this.pdfPageRotate = defaultViewport.rotation;
  19671. this._optionalContentConfigPromise = options.optionalContentConfigPromise ||
  19672. null;
  19673. this.hasRestrictedScaling = false;
  19674. this.textLayerMode = (_options$textLayerMod = options.textLayerMode) !== null &&
  19675. _options$textLayerMod !== void 0 ? _options$textLayerMod : _ui_utils
  19676. .TextLayerMode.ENABLE;
  19677. _classPrivateFieldSet(this, _annotationMode, (_options$annotationMo = options
  19678. .annotationMode) !== null && _options$annotationMo !== void 0 ?
  19679. _options$annotationMo : _pdfjsLib.AnnotationMode.ENABLE_FORMS);
  19680. this.imageResourcesPath = options.imageResourcesPath || "";
  19681. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  19682. this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
  19683. this.eventBus = options.eventBus;
  19684. this.renderingQueue = options.renderingQueue;
  19685. this.textLayerFactory = options.textLayerFactory;
  19686. this.annotationLayerFactory = options.annotationLayerFactory;
  19687. this.xfaLayerFactory = options.xfaLayerFactory;
  19688. this.textHighlighter = (_options$textHighligh = options
  19689. .textHighlighterFactory) === null || _options$textHighligh === void 0 ?
  19690. void 0 : _options$textHighligh.createTextHighlighter(this.id - 1, this
  19691. .eventBus);
  19692. this.structTreeLayerFactory = options.structTreeLayerFactory;
  19693. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  19694. this.l10n = options.l10n || _l10n_utils.NullL10n;
  19695. this.paintTask = null;
  19696. this.paintedViewportMap = new WeakMap();
  19697. this.renderingState = _ui_utils.RenderingStates.INITIAL;
  19698. this.resume = null;
  19699. this._renderError = null;
  19700. this._isStandalone = !((_this$renderingQueue = this.renderingQueue) !== null &&
  19701. _this$renderingQueue !== void 0 && _this$renderingQueue.hasViewer());
  19702. this._annotationCanvasMap = null;
  19703. this.annotationLayer = null;
  19704. this.textLayer = null;
  19705. this.zoomLayer = null;
  19706. this.xfaLayer = null;
  19707. this.structTreeLayer = null;
  19708. var div = document.createElement("div");
  19709. div.className = "page";
  19710. div.style.width = Math.floor(this.viewport.width) + "px";
  19711. div.style.height = Math.floor(this.viewport.height) + "px";
  19712. div.setAttribute("data-page-number", this.id);
  19713. div.setAttribute("role", "region");
  19714. this.l10n.get("page_landmark", {
  19715. page: this.id
  19716. }).then(function(msg) {
  19717. div.setAttribute("aria-label", msg);
  19718. });
  19719. this.div = div;
  19720. container === null || container === void 0 ? void 0 : container.appendChild(
  19721. div);
  19722. }
  19723. _createClass(PDFPageView, [{
  19724. key: "setPdfPage",
  19725. value: function setPdfPage(pdfPage) {
  19726. this.pdfPage = pdfPage;
  19727. this.pdfPageRotate = pdfPage.rotate;
  19728. var totalRotation = (this.rotation + this.pdfPageRotate) %
  19729. 360;
  19730. this.viewport = pdfPage.getViewport({
  19731. scale: this.scale * _pdfjsLib.PixelsPerInch
  19732. .PDF_TO_CSS_UNITS,
  19733. rotation: totalRotation
  19734. });
  19735. this.reset();
  19736. }
  19737. }, {
  19738. key: "destroy",
  19739. value: function destroy() {
  19740. this.reset();
  19741. if (this.pdfPage) {
  19742. this.pdfPage.cleanup();
  19743. }
  19744. }
  19745. }, {
  19746. key: "_renderAnnotationLayer",
  19747. value: function() {
  19748. var _renderAnnotationLayer2 =
  19749. _asyncToGenerator( /*#__PURE__*/ _regenerator["default"]
  19750. .mark(function _callee() {
  19751. var error;
  19752. return _regenerator["default"].wrap(
  19753. function _callee$(_context) {
  19754. while (1) {
  19755. switch (_context.prev =
  19756. _context.next) {
  19757. case 0:
  19758. error = null;
  19759. _context.prev = 1;
  19760. _context.next = 4;
  19761. return this
  19762. .annotationLayer
  19763. .render(this
  19764. .viewport,
  19765. "display");
  19766. case 4:
  19767. _context.next = 9;
  19768. break;
  19769. case 6:
  19770. _context.prev = 6;
  19771. _context.t0 =
  19772. _context[
  19773. "catch"](1);
  19774. error = _context.t0;
  19775. case 9:
  19776. _context.prev = 9;
  19777. this.eventBus
  19778. .dispatch(
  19779. "annotationlayerrendered", {
  19780. source: this,
  19781. pageNumber: this
  19782. .id,
  19783. error: error
  19784. });
  19785. return _context
  19786. .finish(9);
  19787. case 12:
  19788. case "end":
  19789. return _context
  19790. .stop();
  19791. }
  19792. }
  19793. }, _callee, this, [
  19794. [1, 6, 9, 12]
  19795. ]);
  19796. }));
  19797. function _renderAnnotationLayer() {
  19798. return _renderAnnotationLayer2.apply(this, arguments);
  19799. }
  19800. return _renderAnnotationLayer;
  19801. }()
  19802. }, {
  19803. key: "_renderXfaLayer",
  19804. value: function() {
  19805. var _renderXfaLayer2 = _asyncToGenerator( /*#__PURE__*/
  19806. _regenerator["default"].mark(function _callee2() {
  19807. var error, result;
  19808. return _regenerator["default"].wrap(
  19809. function _callee2$(_context2) {
  19810. while (1) {
  19811. switch (_context2.prev =
  19812. _context2.next) {
  19813. case 0:
  19814. error = null;
  19815. _context2.prev = 1;
  19816. _context2.next = 4;
  19817. return this.xfaLayer
  19818. .render(this
  19819. .viewport,
  19820. "display");
  19821. case 4:
  19822. result = _context2
  19823. .sent;
  19824. if (this
  19825. .textHighlighter
  19826. ) {
  19827. this._buildXfaTextContentItems(
  19828. result
  19829. .textDivs
  19830. );
  19831. }
  19832. _context2.next = 11;
  19833. break;
  19834. case 8:
  19835. _context2.prev = 8;
  19836. _context2.t0 =
  19837. _context2[
  19838. "catch"](1);
  19839. error = _context2
  19840. .t0;
  19841. case 11:
  19842. _context2.prev = 11;
  19843. this.eventBus
  19844. .dispatch(
  19845. "xfalayerrendered", {
  19846. source: this,
  19847. pageNumber: this
  19848. .id,
  19849. error: error
  19850. });
  19851. return _context2
  19852. .finish(11);
  19853. case 14:
  19854. case "end":
  19855. return _context2
  19856. .stop();
  19857. }
  19858. }
  19859. }, _callee2, this, [
  19860. [1, 8, 11, 14]
  19861. ]);
  19862. }));
  19863. function _renderXfaLayer() {
  19864. return _renderXfaLayer2.apply(this, arguments);
  19865. }
  19866. return _renderXfaLayer;
  19867. }()
  19868. }, {
  19869. key: "_buildXfaTextContentItems",
  19870. value: function() {
  19871. var _buildXfaTextContentItems2 =
  19872. _asyncToGenerator( /*#__PURE__*/ _regenerator["default"]
  19873. .mark(function _callee3(textDivs) {
  19874. var text, items, _iterator, _step, item;
  19875. return _regenerator["default"].wrap(
  19876. function _callee3$(_context3) {
  19877. while (1) {
  19878. switch (_context3.prev =
  19879. _context3.next) {
  19880. case 0:
  19881. _context3.next = 2;
  19882. return this.pdfPage
  19883. .getTextContent();
  19884. case 2:
  19885. text = _context3
  19886. .sent;
  19887. items = [];
  19888. _iterator =
  19889. _createForOfIteratorHelper(
  19890. text.items);
  19891. try {
  19892. for (_iterator
  19893. .s(); !(
  19894. _step =
  19895. _iterator
  19896. .n())
  19897. .done;) {
  19898. item = _step
  19899. .value;
  19900. items.push(
  19901. item
  19902. .str
  19903. );
  19904. }
  19905. } catch (err) {
  19906. _iterator.e(
  19907. err);
  19908. } finally {
  19909. _iterator.f();
  19910. }
  19911. this.textHighlighter
  19912. .setTextMapping(
  19913. textDivs,
  19914. items);
  19915. this.textHighlighter
  19916. .enable();
  19917. case 8:
  19918. case "end":
  19919. return _context3
  19920. .stop();
  19921. }
  19922. }
  19923. }, _callee3, this);
  19924. }));
  19925. function _buildXfaTextContentItems(_x) {
  19926. return _buildXfaTextContentItems2.apply(this,
  19927. arguments);
  19928. }
  19929. return _buildXfaTextContentItems;
  19930. }()
  19931. }, {
  19932. key: "_resetZoomLayer",
  19933. value: function _resetZoomLayer() {
  19934. var removeFromDOM = arguments.length > 0 && arguments[0] !==
  19935. undefined ? arguments[0] : false;
  19936. if (!this.zoomLayer) {
  19937. return;
  19938. }
  19939. var zoomLayerCanvas = this.zoomLayer.firstChild;
  19940. this.paintedViewportMap["delete"](zoomLayerCanvas);
  19941. zoomLayerCanvas.width = 0;
  19942. zoomLayerCanvas.height = 0;
  19943. if (removeFromDOM) {
  19944. this.zoomLayer.remove();
  19945. }
  19946. this.zoomLayer = null;
  19947. }
  19948. }, {
  19949. key: "reset",
  19950. value: function reset() {
  19951. var _this$annotationLayer,
  19952. _this$xfaLayer,
  19953. _this = this;
  19954. var _ref = arguments.length > 0 && arguments[0] !==
  19955. undefined ? arguments[0] : {},
  19956. _ref$keepZoomLayer = _ref.keepZoomLayer,
  19957. keepZoomLayer = _ref$keepZoomLayer === void 0 ? false :
  19958. _ref$keepZoomLayer,
  19959. _ref$keepAnnotationLa = _ref.keepAnnotationLayer,
  19960. keepAnnotationLayer = _ref$keepAnnotationLa === void 0 ?
  19961. false : _ref$keepAnnotationLa,
  19962. _ref$keepXfaLayer = _ref.keepXfaLayer,
  19963. keepXfaLayer = _ref$keepXfaLayer === void 0 ? false :
  19964. _ref$keepXfaLayer;
  19965. this.cancelRendering({
  19966. keepAnnotationLayer: keepAnnotationLayer,
  19967. keepXfaLayer: keepXfaLayer
  19968. });
  19969. this.renderingState = _ui_utils.RenderingStates.INITIAL;
  19970. var div = this.div;
  19971. div.style.width = Math.floor(this.viewport.width) + "px";
  19972. div.style.height = Math.floor(this.viewport.height) + "px";
  19973. var childNodes = div.childNodes,
  19974. zoomLayerNode = keepZoomLayer && this.zoomLayer || null,
  19975. annotationLayerNode = keepAnnotationLayer && ((
  19976. _this$annotationLayer = this.annotationLayer
  19977. ) === null || _this$annotationLayer === void 0 ?
  19978. void 0 : _this$annotationLayer.div) || null,
  19979. xfaLayerNode = keepXfaLayer && ((_this$xfaLayer = this
  19980. .xfaLayer) === null || _this$xfaLayer ===
  19981. void 0 ? void 0 : _this$xfaLayer.div) || null;
  19982. for (var i = childNodes.length - 1; i >= 0; i--) {
  19983. var node = childNodes[i];
  19984. switch (node) {
  19985. case zoomLayerNode:
  19986. case annotationLayerNode:
  19987. case xfaLayerNode:
  19988. continue;
  19989. }
  19990. node.remove();
  19991. }
  19992. div.removeAttribute("data-loaded");
  19993. if (annotationLayerNode) {
  19994. this.annotationLayer.hide();
  19995. }
  19996. if (xfaLayerNode) {
  19997. this.xfaLayer.hide();
  19998. }
  19999. if (!zoomLayerNode) {
  20000. if (this.canvas) {
  20001. this.paintedViewportMap["delete"](this.canvas);
  20002. this.canvas.width = 0;
  20003. this.canvas.height = 0;
  20004. delete this.canvas;
  20005. }
  20006. this._resetZoomLayer();
  20007. }
  20008. if (this.svg) {
  20009. this.paintedViewportMap["delete"](this.svg);
  20010. delete this.svg;
  20011. }
  20012. this.loadingIconDiv = document.createElement("div");
  20013. this.loadingIconDiv.className = "loadingIcon notVisible";
  20014. if (this._isStandalone) {
  20015. this.toggleLoadingIconSpinner(true);
  20016. }
  20017. this.loadingIconDiv.setAttribute("role", "img");
  20018. this.l10n.get("loading").then(function(msg) {
  20019. var _this$loadingIconDiv;
  20020. (_this$loadingIconDiv = _this
  20021. .loadingIconDiv) === null ||
  20022. _this$loadingIconDiv === void 0 ? void 0 :
  20023. _this$loadingIconDiv.setAttribute(
  20024. "aria-label", msg);
  20025. });
  20026. div.appendChild(this.loadingIconDiv);
  20027. }
  20028. }, {
  20029. key: "update",
  20030. value: function update(_ref2) {
  20031. var _ref2$scale = _ref2.scale,
  20032. scale = _ref2$scale === void 0 ? 0 : _ref2$scale,
  20033. _ref2$rotation = _ref2.rotation,
  20034. rotation = _ref2$rotation === void 0 ? null :
  20035. _ref2$rotation,
  20036. _ref2$optionalContent = _ref2
  20037. .optionalContentConfigPromise,
  20038. optionalContentConfigPromise = _ref2$optionalContent ===
  20039. void 0 ? null : _ref2$optionalContent;
  20040. if (_typeof(arguments[0]) !== "object") {
  20041. console.error(
  20042. "PDFPageView.update called with separate parameters, please use an object instead."
  20043. );
  20044. this.update({
  20045. scale: arguments[0],
  20046. rotation: arguments[1],
  20047. optionalContentConfigPromise: arguments[2]
  20048. });
  20049. return;
  20050. }
  20051. this.scale = scale || this.scale;
  20052. if (typeof rotation === "number") {
  20053. this.rotation = rotation;
  20054. }
  20055. if (optionalContentConfigPromise instanceof Promise) {
  20056. this._optionalContentConfigPromise =
  20057. optionalContentConfigPromise;
  20058. }
  20059. var totalRotation = (this.rotation + this.pdfPageRotate) %
  20060. 360;
  20061. var viewportScale = this.scale * _pdfjsLib.PixelsPerInch
  20062. .PDF_TO_CSS_UNITS;
  20063. this.viewport = this.viewport.clone({
  20064. scale: viewportScale,
  20065. rotation: totalRotation
  20066. });
  20067. if (this._isStandalone) {
  20068. var style = document.documentElement.style;
  20069. style.setProperty("--zoom-factor", this.scale);
  20070. style.setProperty("--viewport-scale-factor",
  20071. viewportScale);
  20072. }
  20073. if (this.svg) {
  20074. this.cssTransform({
  20075. target: this.svg,
  20076. redrawAnnotationLayer: true,
  20077. redrawXfaLayer: true
  20078. });
  20079. this.eventBus.dispatch("pagerendered", {
  20080. source: this,
  20081. pageNumber: this.id,
  20082. cssTransform: true,
  20083. timestamp: performance.now(),
  20084. error: this._renderError
  20085. });
  20086. return;
  20087. }
  20088. var isScalingRestricted = false;
  20089. if (this.canvas && this.maxCanvasPixels > 0) {
  20090. var outputScale = this.outputScale;
  20091. if ((Math.floor(this.viewport.width) * outputScale.sx |
  20092. 0) * (Math.floor(this.viewport.height) *
  20093. outputScale.sy | 0) > this.maxCanvasPixels) {
  20094. isScalingRestricted = true;
  20095. }
  20096. }
  20097. if (this.canvas) {
  20098. if (this.useOnlyCssZoom || this.hasRestrictedScaling &&
  20099. isScalingRestricted) {
  20100. this.cssTransform({
  20101. target: this.canvas,
  20102. redrawAnnotationLayer: true,
  20103. redrawXfaLayer: true
  20104. });
  20105. this.eventBus.dispatch("pagerendered", {
  20106. source: this,
  20107. pageNumber: this.id,
  20108. cssTransform: true,
  20109. timestamp: performance.now(),
  20110. error: this._renderError
  20111. });
  20112. return;
  20113. }
  20114. if (!this.zoomLayer && !this.canvas.hidden) {
  20115. this.zoomLayer = this.canvas.parentNode;
  20116. this.zoomLayer.style.position = "absolute";
  20117. }
  20118. }
  20119. if (this.zoomLayer) {
  20120. this.cssTransform({
  20121. target: this.zoomLayer.firstChild
  20122. });
  20123. }
  20124. this.reset({
  20125. keepZoomLayer: true,
  20126. keepAnnotationLayer: true,
  20127. keepXfaLayer: true
  20128. });
  20129. }
  20130. }, {
  20131. key: "cancelRendering",
  20132. value: function cancelRendering() {
  20133. var _ref3 = arguments.length > 0 && arguments[0] !==
  20134. undefined ? arguments[0] : {},
  20135. _ref3$keepAnnotationL = _ref3.keepAnnotationLayer,
  20136. keepAnnotationLayer = _ref3$keepAnnotationL === void 0 ?
  20137. false : _ref3$keepAnnotationL,
  20138. _ref3$keepXfaLayer = _ref3.keepXfaLayer,
  20139. keepXfaLayer = _ref3$keepXfaLayer === void 0 ? false :
  20140. _ref3$keepXfaLayer;
  20141. if (this.paintTask) {
  20142. this.paintTask.cancel();
  20143. this.paintTask = null;
  20144. }
  20145. this.resume = null;
  20146. if (this.textLayer) {
  20147. this.textLayer.cancel();
  20148. this.textLayer = null;
  20149. }
  20150. if (this.annotationLayer && (!keepAnnotationLayer || !this
  20151. .annotationLayer.div)) {
  20152. this.annotationLayer.cancel();
  20153. this.annotationLayer = null;
  20154. this._annotationCanvasMap = null;
  20155. }
  20156. if (this.xfaLayer && (!keepXfaLayer || !this.xfaLayer
  20157. .div)) {
  20158. var _this$textHighlighter;
  20159. this.xfaLayer.cancel();
  20160. this.xfaLayer = null;
  20161. (_this$textHighlighter = this.textHighlighter) === null
  20162. || _this$textHighlighter === void 0 ? void 0 :
  20163. _this$textHighlighter.disable();
  20164. }
  20165. if (this._onTextLayerRendered) {
  20166. this.eventBus._off("textlayerrendered", this
  20167. ._onTextLayerRendered);
  20168. this._onTextLayerRendered = null;
  20169. }
  20170. }
  20171. }, {
  20172. key: "cssTransform",
  20173. value: function cssTransform(_ref4) {
  20174. var target = _ref4.target,
  20175. _ref4$redrawAnnotatio = _ref4.redrawAnnotationLayer,
  20176. redrawAnnotationLayer = _ref4$redrawAnnotatio ===
  20177. void 0 ? false : _ref4$redrawAnnotatio,
  20178. _ref4$redrawXfaLayer = _ref4.redrawXfaLayer,
  20179. redrawXfaLayer = _ref4$redrawXfaLayer === void 0 ?
  20180. false : _ref4$redrawXfaLayer;
  20181. var width = this.viewport.width;
  20182. var height = this.viewport.height;
  20183. var div = this.div;
  20184. target.style.width = target.parentNode.style.width = div
  20185. .style.width = Math.floor(width) + "px";
  20186. target.style.height = target.parentNode.style.height = div
  20187. .style.height = Math.floor(height) + "px";
  20188. var relativeRotation = this.viewport.rotation - this
  20189. .paintedViewportMap.get(target).rotation;
  20190. var absRotation = Math.abs(relativeRotation);
  20191. var scaleX = 1,
  20192. scaleY = 1;
  20193. if (absRotation === 90 || absRotation === 270) {
  20194. scaleX = height / width;
  20195. scaleY = width / height;
  20196. }
  20197. target.style.transform = "rotate(".concat(relativeRotation,
  20198. "deg) scale(").concat(scaleX, ", ").concat(scaleY,
  20199. ")");
  20200. if (this.textLayer) {
  20201. var textLayerViewport = this.textLayer.viewport;
  20202. var textRelativeRotation = this.viewport.rotation -
  20203. textLayerViewport.rotation;
  20204. var textAbsRotation = Math.abs(textRelativeRotation);
  20205. var scale = width / textLayerViewport.width;
  20206. if (textAbsRotation === 90 || textAbsRotation === 270) {
  20207. scale = width / textLayerViewport.height;
  20208. }
  20209. var textLayerDiv = this.textLayer.textLayerDiv;
  20210. var transX, transY;
  20211. switch (textAbsRotation) {
  20212. case 0:
  20213. transX = transY = 0;
  20214. break;
  20215. case 90:
  20216. transX = 0;
  20217. transY = "-" + textLayerDiv.style.height;
  20218. break;
  20219. case 180:
  20220. transX = "-" + textLayerDiv.style.width;
  20221. transY = "-" + textLayerDiv.style.height;
  20222. break;
  20223. case 270:
  20224. transX = "-" + textLayerDiv.style.width;
  20225. transY = 0;
  20226. break;
  20227. default:
  20228. console.error("Bad rotation value.");
  20229. break;
  20230. }
  20231. textLayerDiv.style.transform = "rotate(".concat(
  20232. textAbsRotation, "deg) ") + "scale(".concat(
  20233. scale, ") ") + "translate(".concat(transX, ", ")
  20234. .concat(transY, ")");
  20235. textLayerDiv.style.transformOrigin = "0% 0%";
  20236. }
  20237. if (redrawAnnotationLayer && this.annotationLayer) {
  20238. this._renderAnnotationLayer();
  20239. }
  20240. if (redrawXfaLayer && this.xfaLayer) {
  20241. this._renderXfaLayer();
  20242. }
  20243. }
  20244. }, {
  20245. key: "width",
  20246. get: function get() {
  20247. return this.viewport.width;
  20248. }
  20249. }, {
  20250. key: "height",
  20251. get: function get() {
  20252. return this.viewport.height;
  20253. }
  20254. }, {
  20255. key: "getPagePoint",
  20256. value: function getPagePoint(x, y) {
  20257. return this.viewport.convertToPdfPoint(x, y);
  20258. }
  20259. }, {
  20260. key: "toggleLoadingIconSpinner",
  20261. value: function toggleLoadingIconSpinner() {
  20262. var _this$loadingIconDiv2;
  20263. var viewVisible = arguments.length > 0 && arguments[0] !==
  20264. undefined ? arguments[0] : false;
  20265. (_this$loadingIconDiv2 = this.loadingIconDiv) === null ||
  20266. _this$loadingIconDiv2 === void 0 ? void 0 :
  20267. _this$loadingIconDiv2.classList.toggle("notVisible", !
  20268. viewVisible);
  20269. }
  20270. }, {
  20271. key: "draw",
  20272. value: function draw() {
  20273. var _this$annotationLayer2,
  20274. _this$xfaLayer2,
  20275. _this2 = this;
  20276. if (this.renderingState !== _ui_utils.RenderingStates
  20277. .INITIAL) {
  20278. console.error("Must be in new state before drawing");
  20279. this.reset();
  20280. }
  20281. var div = this.div,
  20282. pdfPage = this.pdfPage;
  20283. if (!pdfPage) {
  20284. this.renderingState = _ui_utils.RenderingStates
  20285. .FINISHED;
  20286. if (this.loadingIconDiv) {
  20287. this.loadingIconDiv.remove();
  20288. delete this.loadingIconDiv;
  20289. }
  20290. return Promise.reject(new Error(
  20291. "pdfPage is not loaded"));
  20292. }
  20293. this.renderingState = _ui_utils.RenderingStates.RUNNING;
  20294. var canvasWrapper = document.createElement("div");
  20295. canvasWrapper.style.width = div.style.width;
  20296. canvasWrapper.style.height = div.style.height;
  20297. canvasWrapper.classList.add("canvasWrapper");
  20298. if ((_this$annotationLayer2 = this.annotationLayer) !==
  20299. null && _this$annotationLayer2 !== void 0 &&
  20300. _this$annotationLayer2.div) {
  20301. div.insertBefore(canvasWrapper, this.annotationLayer
  20302. .div);
  20303. } else {
  20304. div.appendChild(canvasWrapper);
  20305. }
  20306. var textLayer = null;
  20307. if (this.textLayerMode !== _ui_utils.TextLayerMode
  20308. .DISABLE && this.textLayerFactory) {
  20309. var _this$annotationLayer3;
  20310. var textLayerDiv = document.createElement("div");
  20311. textLayerDiv.className = "textLayer";
  20312. textLayerDiv.style.width = canvasWrapper.style.width;
  20313. textLayerDiv.style.height = canvasWrapper.style.height;
  20314. if ((_this$annotationLayer3 = this.annotationLayer) !==
  20315. null && _this$annotationLayer3 !== void 0 &&
  20316. _this$annotationLayer3.div) {
  20317. div.insertBefore(textLayerDiv, this.annotationLayer
  20318. .div);
  20319. } else {
  20320. div.appendChild(textLayerDiv);
  20321. }
  20322. textLayer = this.textLayerFactory
  20323. .createTextLayerBuilder(textLayerDiv, this.id - 1,
  20324. this.viewport, this.textLayerMode === _ui_utils
  20325. .TextLayerMode.ENABLE_ENHANCE, this.eventBus,
  20326. this.textHighlighter);
  20327. }
  20328. this.textLayer = textLayer;
  20329. if (_classPrivateFieldGet(this, _annotationMode) !==
  20330. _pdfjsLib.AnnotationMode.DISABLE && this
  20331. .annotationLayerFactory) {
  20332. this._annotationCanvasMap || (this
  20333. ._annotationCanvasMap = new Map());
  20334. this.annotationLayer || (this.annotationLayer = this
  20335. .annotationLayerFactory
  20336. .createAnnotationLayerBuilder(div, pdfPage,
  20337. null, this.imageResourcesPath,
  20338. _classPrivateFieldGet(this,
  20339. _annotationMode) === _pdfjsLib
  20340. .AnnotationMode.ENABLE_FORMS, this.l10n,
  20341. null, null, null, null, this
  20342. ._annotationCanvasMap));
  20343. }
  20344. if ((_this$xfaLayer2 = this.xfaLayer) !== null &&
  20345. _this$xfaLayer2 !== void 0 && _this$xfaLayer2.div) {
  20346. div.appendChild(this.xfaLayer.div);
  20347. }
  20348. var renderContinueCallback = null;
  20349. if (this.renderingQueue) {
  20350. renderContinueCallback =
  20351. function renderContinueCallback(cont) {
  20352. if (!_this2.renderingQueue.isHighestPriority(
  20353. _this2)) {
  20354. _this2.renderingState = _ui_utils
  20355. .RenderingStates.PAUSED;
  20356. _this2.resume = function() {
  20357. _this2.renderingState = _ui_utils
  20358. .RenderingStates.RUNNING;
  20359. cont();
  20360. };
  20361. return;
  20362. }
  20363. cont();
  20364. };
  20365. }
  20366. var finishPaintTask = /*#__PURE__*/ function() {
  20367. var _ref5 = _asyncToGenerator( /*#__PURE__*/
  20368. _regenerator["default"].mark(
  20369. function _callee4() {
  20370. var error,
  20371. _args4 = arguments;
  20372. return _regenerator["default"].wrap(
  20373. function _callee4$(
  20374. _context4) {
  20375. while (1) {
  20376. switch (_context4
  20377. .prev =
  20378. _context4.next
  20379. ) {
  20380. case 0:
  20381. error =
  20382. _args4
  20383. .length >
  20384. 0 &&
  20385. _args4[
  20386. 0] !==
  20387. undefined ?
  20388. _args4[
  20389. 0] :
  20390. null;
  20391. if (paintTask ===
  20392. _this2
  20393. .paintTask
  20394. ) {
  20395. _this2
  20396. .paintTask =
  20397. null;
  20398. }
  20399. if (!(error instanceof _pdfjsLib
  20400. .RenderingCancelledException
  20401. )) {
  20402. _context4
  20403. .next =
  20404. 5;
  20405. break;
  20406. }
  20407. _this2
  20408. ._renderError =
  20409. null;
  20410. return _context4
  20411. .abrupt(
  20412. "return"
  20413. );
  20414. case 5:
  20415. _this2
  20416. ._renderError =
  20417. error;
  20418. _this2
  20419. .renderingState =
  20420. _ui_utils
  20421. .RenderingStates
  20422. .FINISHED;
  20423. if (_this2
  20424. .loadingIconDiv
  20425. ) {
  20426. _this2
  20427. .loadingIconDiv
  20428. .remove();
  20429. delete _this2
  20430. .loadingIconDiv;
  20431. }
  20432. _this2
  20433. ._resetZoomLayer(
  20434. true
  20435. );
  20436. _this2
  20437. .eventBus
  20438. .dispatch(
  20439. "pagerendered", {
  20440. source: _this2,
  20441. pageNumber: _this2
  20442. .id,
  20443. cssTransform: false,
  20444. timestamp: performance
  20445. .now(),
  20446. error: _this2
  20447. ._renderError
  20448. });
  20449. if (!
  20450. error) {
  20451. _context4
  20452. .next =
  20453. 12;
  20454. break;
  20455. }
  20456. throw error;
  20457. case 12:
  20458. case "end":
  20459. return _context4
  20460. .stop();
  20461. }
  20462. }
  20463. }, _callee4);
  20464. }));
  20465. return function finishPaintTask() {
  20466. return _ref5.apply(this, arguments);
  20467. };
  20468. }();
  20469. var paintTask = this.renderer === _ui_utils.RendererType
  20470. .SVG ? this.paintOnSvg(canvasWrapper) : this
  20471. .paintOnCanvas(canvasWrapper);
  20472. paintTask.onRenderContinue = renderContinueCallback;
  20473. this.paintTask = paintTask;
  20474. var resultPromise = paintTask.promise.then(function() {
  20475. return finishPaintTask(null).then(function() {
  20476. if (textLayer) {
  20477. var readableStream = pdfPage
  20478. .streamTextContent({
  20479. includeMarkedContent: true
  20480. });
  20481. textLayer.setTextContentStream(
  20482. readableStream);
  20483. textLayer.render();
  20484. }
  20485. if (_this2.annotationLayer) {
  20486. _this2._renderAnnotationLayer();
  20487. }
  20488. });
  20489. }, function(reason) {
  20490. return finishPaintTask(reason);
  20491. });
  20492. if (this.xfaLayerFactory) {
  20493. if (!this.xfaLayer) {
  20494. this.xfaLayer = this.xfaLayerFactory
  20495. .createXfaLayerBuilder(div, pdfPage, null);
  20496. }
  20497. this._renderXfaLayer();
  20498. }
  20499. if (this.structTreeLayerFactory && this.textLayer && this
  20500. .canvas) {
  20501. this._onTextLayerRendered = function(event) {
  20502. if (event.pageNumber !== _this2.id) {
  20503. return;
  20504. }
  20505. _this2.eventBus._off("textlayerrendered", _this2
  20506. ._onTextLayerRendered);
  20507. _this2._onTextLayerRendered = null;
  20508. if (!_this2.canvas) {
  20509. return;
  20510. }
  20511. _this2.pdfPage.getStructTree().then(function(
  20512. tree) {
  20513. if (!tree) {
  20514. return;
  20515. }
  20516. if (!_this2.canvas) {
  20517. return;
  20518. }
  20519. var treeDom = _this2.structTreeLayer
  20520. .render(tree);
  20521. treeDom.classList.add("structTree");
  20522. _this2.canvas.appendChild(treeDom);
  20523. });
  20524. };
  20525. this.eventBus._on("textlayerrendered", this
  20526. ._onTextLayerRendered);
  20527. this.structTreeLayer = this.structTreeLayerFactory
  20528. .createStructTreeLayerBuilder(pdfPage);
  20529. }
  20530. div.setAttribute("data-loaded", true);
  20531. this.eventBus.dispatch("pagerender", {
  20532. source: this,
  20533. pageNumber: this.id
  20534. });
  20535. return resultPromise;
  20536. }
  20537. }, {
  20538. key: "paintOnCanvas",
  20539. value: function paintOnCanvas(canvasWrapper) {
  20540. var renderCapability = (0, _pdfjsLib
  20541. .createPromiseCapability)();
  20542. var result = {
  20543. promise: renderCapability.promise,
  20544. onRenderContinue: function onRenderContinue(cont) {
  20545. cont();
  20546. },
  20547. cancel: function cancel() {
  20548. renderTask.cancel();
  20549. }
  20550. };
  20551. var viewport = this.viewport;
  20552. var canvas = document.createElement("canvas");
  20553. canvas.hidden = true;
  20554. var isCanvasHidden = true;
  20555. var showCanvas = function showCanvas() {
  20556. if (isCanvasHidden) {
  20557. canvas.hidden = false;
  20558. isCanvasHidden = false;
  20559. }
  20560. };
  20561. canvasWrapper.appendChild(canvas);
  20562. this.canvas = canvas;
  20563. canvas.mozOpaque = true;
  20564. var ctx = canvas.getContext("2d", {
  20565. alpha: false
  20566. });
  20567. var outputScale = this.outputScale = new _ui_utils
  20568. .OutputScale();
  20569. if (this.useOnlyCssZoom) {
  20570. var actualSizeViewport = viewport.clone({
  20571. scale: _pdfjsLib.PixelsPerInch
  20572. .PDF_TO_CSS_UNITS
  20573. });
  20574. outputScale.sx *= actualSizeViewport.width / viewport
  20575. .width;
  20576. outputScale.sy *= actualSizeViewport.height / viewport
  20577. .height;
  20578. }
  20579. if (this.maxCanvasPixels > 0) {
  20580. var pixelsInViewport = viewport.width * viewport.height;
  20581. var maxScale = Math.sqrt(this.maxCanvasPixels /
  20582. pixelsInViewport);
  20583. if (outputScale.sx > maxScale || outputScale.sy >
  20584. maxScale) {
  20585. outputScale.sx = maxScale;
  20586. outputScale.sy = maxScale;
  20587. this.hasRestrictedScaling = true;
  20588. } else {
  20589. this.hasRestrictedScaling = false;
  20590. }
  20591. }
  20592. var sfx = (0, _ui_utils.approximateFraction)(outputScale
  20593. .sx);
  20594. var sfy = (0, _ui_utils.approximateFraction)(outputScale
  20595. .sy);
  20596. canvas.width = (0, _ui_utils.roundToDivide)(viewport.width *
  20597. outputScale.sx, sfx[0]);
  20598. canvas.height = (0, _ui_utils.roundToDivide)(viewport
  20599. .height * outputScale.sy, sfy[0]);
  20600. canvas.style.width = (0, _ui_utils.roundToDivide)(viewport
  20601. .width, sfx[1]) + "px";
  20602. canvas.style.height = (0, _ui_utils.roundToDivide)(viewport
  20603. .height, sfy[1]) + "px";
  20604. this.paintedViewportMap.set(canvas, viewport);
  20605. var transform = outputScale.scaled ? [outputScale.sx, 0, 0,
  20606. outputScale.sy, 0, 0
  20607. ] : null;
  20608. var renderContext = {
  20609. canvasContext: ctx,
  20610. transform: transform,
  20611. viewport: this.viewport,
  20612. annotationMode: _classPrivateFieldGet(this,
  20613. _annotationMode),
  20614. optionalContentConfigPromise: this
  20615. ._optionalContentConfigPromise,
  20616. annotationCanvasMap: this._annotationCanvasMap
  20617. };
  20618. var renderTask = this.pdfPage.render(renderContext);
  20619. renderTask.onContinue = function(cont) {
  20620. showCanvas();
  20621. if (result.onRenderContinue) {
  20622. result.onRenderContinue(cont);
  20623. } else {
  20624. cont();
  20625. }
  20626. };
  20627. renderTask.promise.then(function() {
  20628. showCanvas();
  20629. renderCapability.resolve();
  20630. }, function(error) {
  20631. showCanvas();
  20632. renderCapability.reject(error);
  20633. });
  20634. return result;
  20635. }
  20636. }, {
  20637. key: "paintOnSvg",
  20638. value: function paintOnSvg(wrapper) {
  20639. var _this3 = this;
  20640. var cancelled = false;
  20641. var ensureNotCancelled = function ensureNotCancelled() {
  20642. if (cancelled) {
  20643. throw new _pdfjsLib.RenderingCancelledException(
  20644. "Rendering cancelled, page ".concat(
  20645. _this3.id), "svg");
  20646. }
  20647. };
  20648. var pdfPage = this.pdfPage;
  20649. var actualSizeViewport = this.viewport.clone({
  20650. scale: _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS
  20651. });
  20652. var promise = pdfPage.getOperatorList({
  20653. annotationMode: _classPrivateFieldGet(this,
  20654. _annotationMode)
  20655. }).then(function(opList) {
  20656. ensureNotCancelled();
  20657. var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage
  20658. .commonObjs, pdfPage.objs);
  20659. return svgGfx.getSVG(opList, actualSizeViewport)
  20660. .then(function(svg) {
  20661. ensureNotCancelled();
  20662. _this3.svg = svg;
  20663. _this3.paintedViewportMap.set(svg,
  20664. actualSizeViewport);
  20665. svg.style.width = wrapper.style
  20666. .width;
  20667. svg.style.height = wrapper.style
  20668. .height;
  20669. _this3.renderingState = _ui_utils
  20670. .RenderingStates.FINISHED;
  20671. wrapper.appendChild(svg);
  20672. });
  20673. });
  20674. return {
  20675. promise: promise,
  20676. onRenderContinue: function onRenderContinue(cont) {
  20677. cont();
  20678. },
  20679. cancel: function cancel() {
  20680. cancelled = true;
  20681. }
  20682. };
  20683. }
  20684. }, {
  20685. key: "setPageLabel",
  20686. value: function setPageLabel(label) {
  20687. this.pageLabel = typeof label === "string" ? label : null;
  20688. if (this.pageLabel !== null) {
  20689. this.div.setAttribute("data-page-label", this
  20690. .pageLabel);
  20691. } else {
  20692. this.div.removeAttribute("data-page-label");
  20693. }
  20694. }
  20695. }]);
  20696. return PDFPageView;
  20697. }();
  20698. exports.PDFPageView = PDFPageView;
  20699. /***/
  20700. }),
  20701. /* 34 */
  20702. /***/
  20703. ((__unused_webpack_module, exports) => {
  20704. Object.defineProperty(exports, "__esModule", ({
  20705. value: true
  20706. }));
  20707. exports.StructTreeLayerBuilder = void 0;
  20708. function _createForOfIteratorHelper(o, allowArrayLike) {
  20709. var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
  20710. if (!it) {
  20711. if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike &&
  20712. o && typeof o.length === "number") {
  20713. if (it) o = it;
  20714. var i = 0;
  20715. var F = function F() {};
  20716. return {
  20717. s: F,
  20718. n: function n() {
  20719. if (i >= o.length) return {
  20720. done: true
  20721. };
  20722. return {
  20723. done: false,
  20724. value: o[i++]
  20725. };
  20726. },
  20727. e: function e(_e) {
  20728. throw _e;
  20729. },
  20730. f: F
  20731. };
  20732. }
  20733. throw new TypeError(
  20734. "Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
  20735. );
  20736. }
  20737. var normalCompletion = true,
  20738. didErr = false,
  20739. err;
  20740. return {
  20741. s: function s() {
  20742. it = it.call(o);
  20743. },
  20744. n: function n() {
  20745. var step = it.next();
  20746. normalCompletion = step.done;
  20747. return step;
  20748. },
  20749. e: function e(_e2) {
  20750. didErr = true;
  20751. err = _e2;
  20752. },
  20753. f: function f() {
  20754. try {
  20755. if (!normalCompletion && it["return"] != null) it["return"]();
  20756. } finally {
  20757. if (didErr) throw err;
  20758. }
  20759. }
  20760. };
  20761. }
  20762. function _unsupportedIterableToArray(o, minLen) {
  20763. if (!o) return;
  20764. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  20765. var n = Object.prototype.toString.call(o).slice(8, -1);
  20766. if (n === "Object" && o.constructor) n = o.constructor.name;
  20767. if (n === "Map" || n === "Set") return Array.from(o);
  20768. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
  20769. return _arrayLikeToArray(o, minLen);
  20770. }
  20771. function _arrayLikeToArray(arr, len) {
  20772. if (len == null || len > arr.length) len = arr.length;
  20773. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  20774. arr2[i] = arr[i];
  20775. }
  20776. return arr2;
  20777. }
  20778. function _classCallCheck(instance, Constructor) {
  20779. if (!(instance instanceof Constructor)) {
  20780. throw new TypeError("Cannot call a class as a function");
  20781. }
  20782. }
  20783. function _defineProperties(target, props) {
  20784. for (var i = 0; i < props.length; i++) {
  20785. var descriptor = props[i];
  20786. descriptor.enumerable = descriptor.enumerable || false;
  20787. descriptor.configurable = true;
  20788. if ("value" in descriptor) descriptor.writable = true;
  20789. Object.defineProperty(target, descriptor.key, descriptor);
  20790. }
  20791. }
  20792. function _createClass(Constructor, protoProps, staticProps) {
  20793. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  20794. if (staticProps) _defineProperties(Constructor, staticProps);
  20795. Object.defineProperty(Constructor, "prototype", {
  20796. writable: false
  20797. });
  20798. return Constructor;
  20799. }
  20800. var PDF_ROLE_TO_HTML_ROLE = {
  20801. Document: null,
  20802. DocumentFragment: null,
  20803. Part: "group",
  20804. Sect: "group",
  20805. Div: "group",
  20806. Aside: "note",
  20807. NonStruct: "none",
  20808. P: null,
  20809. H: "heading",
  20810. Title: null,
  20811. FENote: "note",
  20812. Sub: "group",
  20813. Lbl: null,
  20814. Span: null,
  20815. Em: null,
  20816. Strong: null,
  20817. Link: "link",
  20818. Annot: "note",
  20819. Form: "form",
  20820. Ruby: null,
  20821. RB: null,
  20822. RT: null,
  20823. RP: null,
  20824. Warichu: null,
  20825. WT: null,
  20826. WP: null,
  20827. L: "list",
  20828. LI: "listitem",
  20829. LBody: null,
  20830. Table: "table",
  20831. TR: "row",
  20832. TH: "columnheader",
  20833. TD: "cell",
  20834. THead: "columnheader",
  20835. TBody: null,
  20836. TFoot: null,
  20837. Caption: null,
  20838. Figure: "figure",
  20839. Formula: null,
  20840. Artifact: null
  20841. };
  20842. var HEADING_PATTERN = /^H(\d+)$/;
  20843. var StructTreeLayerBuilder = /*#__PURE__*/ function() {
  20844. function StructTreeLayerBuilder(_ref) {
  20845. var pdfPage = _ref.pdfPage;
  20846. _classCallCheck(this, StructTreeLayerBuilder);
  20847. this.pdfPage = pdfPage;
  20848. }
  20849. _createClass(StructTreeLayerBuilder, [{
  20850. key: "render",
  20851. value: function render(structTree) {
  20852. return this._walk(structTree);
  20853. }
  20854. }, {
  20855. key: "_setAttributes",
  20856. value: function _setAttributes(structElement, htmlElement) {
  20857. if (structElement.alt !== undefined) {
  20858. htmlElement.setAttribute("aria-label", structElement
  20859. .alt);
  20860. }
  20861. if (structElement.id !== undefined) {
  20862. htmlElement.setAttribute("aria-owns", structElement.id);
  20863. }
  20864. if (structElement.lang !== undefined) {
  20865. htmlElement.setAttribute("lang", structElement.lang);
  20866. }
  20867. }
  20868. }, {
  20869. key: "_walk",
  20870. value: function _walk(node) {
  20871. if (!node) {
  20872. return null;
  20873. }
  20874. var element = document.createElement("span");
  20875. if ("role" in node) {
  20876. var role = node.role;
  20877. var match = role.match(HEADING_PATTERN);
  20878. if (match) {
  20879. element.setAttribute("role", "heading");
  20880. element.setAttribute("aria-level", match[1]);
  20881. } else if (PDF_ROLE_TO_HTML_ROLE[role]) {
  20882. element.setAttribute("role", PDF_ROLE_TO_HTML_ROLE[
  20883. role]);
  20884. }
  20885. }
  20886. this._setAttributes(node, element);
  20887. if (node.children) {
  20888. if (node.children.length === 1 && "id" in node.children[
  20889. 0]) {
  20890. this._setAttributes(node.children[0], element);
  20891. } else {
  20892. var _iterator = _createForOfIteratorHelper(node
  20893. .children),
  20894. _step;
  20895. try {
  20896. for (_iterator.s(); !(_step = _iterator.n())
  20897. .done;) {
  20898. var kid = _step.value;
  20899. element.appendChild(this._walk(kid));
  20900. }
  20901. } catch (err) {
  20902. _iterator.e(err);
  20903. } finally {
  20904. _iterator.f();
  20905. }
  20906. }
  20907. }
  20908. return element;
  20909. }
  20910. }]);
  20911. return StructTreeLayerBuilder;
  20912. }();
  20913. exports.StructTreeLayerBuilder = StructTreeLayerBuilder;
  20914. /***/
  20915. }),
  20916. /* 35 */
  20917. /***/
  20918. ((__unused_webpack_module, exports) => {
  20919. Object.defineProperty(exports, "__esModule", ({
  20920. value: true
  20921. }));
  20922. exports.TextHighlighter = void 0;
  20923. function _classCallCheck(instance, Constructor) {
  20924. if (!(instance instanceof Constructor)) {
  20925. throw new TypeError("Cannot call a class as a function");
  20926. }
  20927. }
  20928. function _defineProperties(target, props) {
  20929. for (var i = 0; i < props.length; i++) {
  20930. var descriptor = props[i];
  20931. descriptor.enumerable = descriptor.enumerable || false;
  20932. descriptor.configurable = true;
  20933. if ("value" in descriptor) descriptor.writable = true;
  20934. Object.defineProperty(target, descriptor.key, descriptor);
  20935. }
  20936. }
  20937. function _createClass(Constructor, protoProps, staticProps) {
  20938. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  20939. if (staticProps) _defineProperties(Constructor, staticProps);
  20940. Object.defineProperty(Constructor, "prototype", {
  20941. writable: false
  20942. });
  20943. return Constructor;
  20944. }
  20945. var TextHighlighter = /*#__PURE__*/ function() {
  20946. function TextHighlighter(_ref) {
  20947. var findController = _ref.findController,
  20948. eventBus = _ref.eventBus,
  20949. pageIndex = _ref.pageIndex;
  20950. _classCallCheck(this, TextHighlighter);
  20951. this.findController = findController;
  20952. this.matches = [];
  20953. this.eventBus = eventBus;
  20954. this.pageIdx = pageIndex;
  20955. this._onUpdateTextLayerMatches = null;
  20956. this.textDivs = null;
  20957. this.textContentItemsStr = null;
  20958. this.enabled = false;
  20959. }
  20960. _createClass(TextHighlighter, [{
  20961. key: "setTextMapping",
  20962. value: function setTextMapping(divs, texts) {
  20963. this.textDivs = divs;
  20964. this.textContentItemsStr = texts;
  20965. }
  20966. }, {
  20967. key: "enable",
  20968. value: function enable() {
  20969. var _this = this;
  20970. if (!this.textDivs || !this.textContentItemsStr) {
  20971. throw new Error(
  20972. "Text divs and strings have not been set.");
  20973. }
  20974. if (this.enabled) {
  20975. throw new Error("TextHighlighter is already enabled.");
  20976. }
  20977. this.enabled = true;
  20978. if (!this._onUpdateTextLayerMatches) {
  20979. this._onUpdateTextLayerMatches = function(evt) {
  20980. if (evt.pageIndex === _this.pageIdx || evt
  20981. .pageIndex === -1) {
  20982. _this._updateMatches();
  20983. }
  20984. };
  20985. this.eventBus._on("updatetextlayermatches", this
  20986. ._onUpdateTextLayerMatches);
  20987. }
  20988. this._updateMatches();
  20989. }
  20990. }, {
  20991. key: "disable",
  20992. value: function disable() {
  20993. if (!this.enabled) {
  20994. return;
  20995. }
  20996. this.enabled = false;
  20997. if (this._onUpdateTextLayerMatches) {
  20998. this.eventBus._off("updatetextlayermatches", this
  20999. ._onUpdateTextLayerMatches);
  21000. this._onUpdateTextLayerMatches = null;
  21001. }
  21002. }
  21003. }, {
  21004. key: "_convertMatches",
  21005. value: function _convertMatches(matches, matchesLength) {
  21006. if (!matches) {
  21007. return [];
  21008. }
  21009. var textContentItemsStr = this.textContentItemsStr;
  21010. var i = 0,
  21011. iIndex = 0;
  21012. var end = textContentItemsStr.length - 1;
  21013. var result = [];
  21014. for (var m = 0, mm = matches.length; m < mm; m++) {
  21015. var matchIdx = matches[m];
  21016. while (i !== end && matchIdx >= iIndex +
  21017. textContentItemsStr[i].length) {
  21018. iIndex += textContentItemsStr[i].length;
  21019. i++;
  21020. }
  21021. if (i === textContentItemsStr.length) {
  21022. console.error("Could not find a matching mapping");
  21023. }
  21024. var match = {
  21025. begin: {
  21026. divIdx: i,
  21027. offset: matchIdx - iIndex
  21028. }
  21029. };
  21030. matchIdx += matchesLength[m];
  21031. while (i !== end && matchIdx > iIndex +
  21032. textContentItemsStr[i].length) {
  21033. iIndex += textContentItemsStr[i].length;
  21034. i++;
  21035. }
  21036. match.end = {
  21037. divIdx: i,
  21038. offset: matchIdx - iIndex
  21039. };
  21040. result.push(match);
  21041. }
  21042. return result;
  21043. }
  21044. }, {
  21045. key: "_renderMatches",
  21046. value: function _renderMatches(matches) {
  21047. if (matches.length === 0) {
  21048. return;
  21049. }
  21050. var findController = this.findController,
  21051. pageIdx = this.pageIdx;
  21052. var textContentItemsStr = this.textContentItemsStr,
  21053. textDivs = this.textDivs;
  21054. var isSelectedPage = pageIdx === findController.selected
  21055. .pageIdx;
  21056. var selectedMatchIdx = findController.selected.matchIdx;
  21057. var highlightAll = findController.state.highlightAll;
  21058. var prevEnd = null;
  21059. var infinity = {
  21060. divIdx: -1,
  21061. offset: undefined
  21062. };
  21063. function beginText(begin, className) {
  21064. var divIdx = begin.divIdx;
  21065. textDivs[divIdx].textContent = "";
  21066. return appendTextToDiv(divIdx, 0, begin.offset,
  21067. className);
  21068. }
  21069. function appendTextToDiv(divIdx, fromOffset, toOffset,
  21070. className) {
  21071. var div = textDivs[divIdx];
  21072. if (div.nodeType === Node.TEXT_NODE) {
  21073. var span = document.createElement("span");
  21074. div.parentNode.insertBefore(span, div);
  21075. span.appendChild(div);
  21076. textDivs[divIdx] = span;
  21077. div = span;
  21078. }
  21079. var content = textContentItemsStr[divIdx].substring(
  21080. fromOffset, toOffset);
  21081. var node = document.createTextNode(content);
  21082. if (className) {
  21083. var _span = document.createElement("span");
  21084. _span.className = "".concat(className, " appended");
  21085. _span.appendChild(node);
  21086. div.appendChild(_span);
  21087. return className.includes("selected") ? _span
  21088. .offsetLeft : 0;
  21089. }
  21090. div.appendChild(node);
  21091. return 0;
  21092. }
  21093. var i0 = selectedMatchIdx,
  21094. i1 = i0 + 1;
  21095. if (highlightAll) {
  21096. i0 = 0;
  21097. i1 = matches.length;
  21098. } else if (!isSelectedPage) {
  21099. return;
  21100. }
  21101. for (var i = i0; i < i1; i++) {
  21102. var match = matches[i];
  21103. var begin = match.begin;
  21104. var end = match.end;
  21105. var isSelected = isSelectedPage && i ===
  21106. selectedMatchIdx;
  21107. var highlightSuffix = isSelected ? " selected" : "";
  21108. var selectedLeft = 0;
  21109. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  21110. if (prevEnd !== null) {
  21111. appendTextToDiv(prevEnd.divIdx, prevEnd.offset,
  21112. infinity.offset);
  21113. }
  21114. beginText(begin);
  21115. } else {
  21116. appendTextToDiv(prevEnd.divIdx, prevEnd.offset,
  21117. begin.offset);
  21118. }
  21119. if (begin.divIdx === end.divIdx) {
  21120. selectedLeft = appendTextToDiv(begin.divIdx, begin
  21121. .offset, end.offset, "highlight" +
  21122. highlightSuffix);
  21123. } else {
  21124. selectedLeft = appendTextToDiv(begin.divIdx, begin
  21125. .offset, infinity.offset,
  21126. "highlight begin" + highlightSuffix);
  21127. for (var n0 = begin.divIdx + 1, n1 = end
  21128. .divIdx; n0 < n1; n0++) {
  21129. textDivs[n0].className = "highlight middle" +
  21130. highlightSuffix;
  21131. }
  21132. beginText(end, "highlight end" + highlightSuffix);
  21133. }
  21134. prevEnd = end;
  21135. if (isSelected) {
  21136. findController.scrollMatchIntoView({
  21137. element: textDivs[begin.divIdx],
  21138. selectedLeft: selectedLeft,
  21139. pageIndex: pageIdx,
  21140. matchIndex: selectedMatchIdx
  21141. });
  21142. }
  21143. }
  21144. if (prevEnd) {
  21145. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity
  21146. .offset);
  21147. }
  21148. }
  21149. }, {
  21150. key: "_updateMatches",
  21151. value: function _updateMatches() {
  21152. if (!this.enabled) {
  21153. return;
  21154. }
  21155. var findController = this.findController,
  21156. matches = this.matches,
  21157. pageIdx = this.pageIdx;
  21158. var textContentItemsStr = this.textContentItemsStr,
  21159. textDivs = this.textDivs;
  21160. var clearedUntilDivIdx = -1;
  21161. for (var i = 0, ii = matches.length; i < ii; i++) {
  21162. var match = matches[i];
  21163. var begin = Math.max(clearedUntilDivIdx, match.begin
  21164. .divIdx);
  21165. for (var n = begin, end = match.end.divIdx; n <=
  21166. end; n++) {
  21167. var div = textDivs[n];
  21168. div.textContent = textContentItemsStr[n];
  21169. div.className = "";
  21170. }
  21171. clearedUntilDivIdx = match.end.divIdx + 1;
  21172. }
  21173. if (!(findController !== null && findController !==
  21174. void 0 && findController.highlightMatches)) {
  21175. return;
  21176. }
  21177. var pageMatches = findController.pageMatches[pageIdx] ||
  21178. null;
  21179. var pageMatchesLength = findController.pageMatchesLength[
  21180. pageIdx] || null;
  21181. this.matches = this._convertMatches(pageMatches,
  21182. pageMatchesLength);
  21183. this._renderMatches(this.matches);
  21184. }
  21185. }]);
  21186. return TextHighlighter;
  21187. }();
  21188. exports.TextHighlighter = TextHighlighter;
  21189. /***/
  21190. }),
  21191. /* 36 */
  21192. /***/
  21193. ((__unused_webpack_module, exports, __webpack_require__) => {
  21194. Object.defineProperty(exports, "__esModule", ({
  21195. value: true
  21196. }));
  21197. exports.TextLayerBuilder = void 0;
  21198. var _pdfjsLib = __webpack_require__(7);
  21199. function _classCallCheck(instance, Constructor) {
  21200. if (!(instance instanceof Constructor)) {
  21201. throw new TypeError("Cannot call a class as a function");
  21202. }
  21203. }
  21204. function _defineProperties(target, props) {
  21205. for (var i = 0; i < props.length; i++) {
  21206. var descriptor = props[i];
  21207. descriptor.enumerable = descriptor.enumerable || false;
  21208. descriptor.configurable = true;
  21209. if ("value" in descriptor) descriptor.writable = true;
  21210. Object.defineProperty(target, descriptor.key, descriptor);
  21211. }
  21212. }
  21213. function _createClass(Constructor, protoProps, staticProps) {
  21214. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  21215. if (staticProps) _defineProperties(Constructor, staticProps);
  21216. Object.defineProperty(Constructor, "prototype", {
  21217. writable: false
  21218. });
  21219. return Constructor;
  21220. }
  21221. var EXPAND_DIVS_TIMEOUT = 300;
  21222. var TextLayerBuilder = /*#__PURE__*/ function() {
  21223. function TextLayerBuilder(_ref) {
  21224. var textLayerDiv = _ref.textLayerDiv,
  21225. eventBus = _ref.eventBus,
  21226. pageIndex = _ref.pageIndex,
  21227. viewport = _ref.viewport,
  21228. _ref$highlighter = _ref.highlighter,
  21229. highlighter = _ref$highlighter === void 0 ? null : _ref$highlighter,
  21230. _ref$enhanceTextSelec = _ref.enhanceTextSelection,
  21231. enhanceTextSelection = _ref$enhanceTextSelec === void 0 ? false :
  21232. _ref$enhanceTextSelec;
  21233. _classCallCheck(this, TextLayerBuilder);
  21234. this.textLayerDiv = textLayerDiv;
  21235. this.eventBus = eventBus;
  21236. this.textContent = null;
  21237. this.textContentItemsStr = [];
  21238. this.textContentStream = null;
  21239. this.renderingDone = false;
  21240. this.pageNumber = pageIndex + 1;
  21241. this.viewport = viewport;
  21242. this.textDivs = [];
  21243. this.textLayerRenderTask = null;
  21244. this.highlighter = highlighter;
  21245. this.enhanceTextSelection = enhanceTextSelection;
  21246. this._bindMouse();
  21247. }
  21248. _createClass(TextLayerBuilder, [{
  21249. key: "_finishRendering",
  21250. value: function _finishRendering() {
  21251. this.renderingDone = true;
  21252. if (!this.enhanceTextSelection) {
  21253. var endOfContent = document.createElement("div");
  21254. endOfContent.className = "endOfContent";
  21255. this.textLayerDiv.appendChild(endOfContent);
  21256. }
  21257. this.eventBus.dispatch("textlayerrendered", {
  21258. source: this,
  21259. pageNumber: this.pageNumber,
  21260. numTextDivs: this.textDivs.length
  21261. });
  21262. }
  21263. }, {
  21264. key: "render",
  21265. value: function render() {
  21266. var _this$highlighter,
  21267. _this = this;
  21268. var timeout = arguments.length > 0 && arguments[0] !==
  21269. undefined ? arguments[0] : 0;
  21270. if (!(this.textContent || this.textContentStream) || this
  21271. .renderingDone) {
  21272. return;
  21273. }
  21274. this.cancel();
  21275. this.textDivs.length = 0;
  21276. (_this$highlighter = this.highlighter) === null ||
  21277. _this$highlighter === void 0 ? void 0 :
  21278. _this$highlighter.setTextMapping(this.textDivs, this
  21279. .textContentItemsStr);
  21280. var textLayerFrag = document.createDocumentFragment();
  21281. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  21282. textContent: this.textContent,
  21283. textContentStream: this.textContentStream,
  21284. container: textLayerFrag,
  21285. viewport: this.viewport,
  21286. textDivs: this.textDivs,
  21287. textContentItemsStr: this.textContentItemsStr,
  21288. timeout: timeout,
  21289. enhanceTextSelection: this.enhanceTextSelection
  21290. });
  21291. this.textLayerRenderTask.promise.then(function() {
  21292. var _this$highlighter2;
  21293. _this.textLayerDiv.appendChild(textLayerFrag);
  21294. _this._finishRendering();
  21295. (_this$highlighter2 = _this.highlighter) ===
  21296. null || _this$highlighter2 === void 0 ? void 0 :
  21297. _this$highlighter2.enable();
  21298. }, function(reason) {});
  21299. }
  21300. }, {
  21301. key: "cancel",
  21302. value: function cancel() {
  21303. var _this$highlighter3;
  21304. if (this.textLayerRenderTask) {
  21305. this.textLayerRenderTask.cancel();
  21306. this.textLayerRenderTask = null;
  21307. }
  21308. (_this$highlighter3 = this.highlighter) === null ||
  21309. _this$highlighter3 === void 0 ? void 0 :
  21310. _this$highlighter3.disable();
  21311. }
  21312. }, {
  21313. key: "setTextContentStream",
  21314. value: function setTextContentStream(readableStream) {
  21315. this.cancel();
  21316. this.textContentStream = readableStream;
  21317. }
  21318. }, {
  21319. key: "setTextContent",
  21320. value: function setTextContent(textContent) {
  21321. this.cancel();
  21322. this.textContent = textContent;
  21323. }
  21324. }, {
  21325. key: "_bindMouse",
  21326. value: function _bindMouse() {
  21327. var _this2 = this;
  21328. var div = this.textLayerDiv;
  21329. var expandDivsTimer = null;
  21330. div.addEventListener("mousedown", function(evt) {
  21331. if (_this2.enhanceTextSelection && _this2
  21332. .textLayerRenderTask) {
  21333. _this2.textLayerRenderTask.expandTextDivs(
  21334. true);
  21335. if (expandDivsTimer) {
  21336. clearTimeout(expandDivsTimer);
  21337. expandDivsTimer = null;
  21338. }
  21339. return;
  21340. }
  21341. var end = div.querySelector(".endOfContent");
  21342. if (!end) {
  21343. return;
  21344. }
  21345. var adjustTop = evt.target !== div;
  21346. adjustTop = adjustTop && window
  21347. .getComputedStyle(end).getPropertyValue(
  21348. "-moz-user-select") !== "none";
  21349. if (adjustTop) {
  21350. var divBounds = div.getBoundingClientRect();
  21351. var r = Math.max(0, (evt.pageY - divBounds
  21352. .top) / divBounds.height);
  21353. end.style.top = (r * 100).toFixed(2) + "%";
  21354. }
  21355. end.classList.add("active");
  21356. });
  21357. div.addEventListener("mouseup", function() {
  21358. if (_this2.enhanceTextSelection && _this2
  21359. .textLayerRenderTask) {
  21360. expandDivsTimer = setTimeout(function() {
  21361. if (_this2
  21362. .textLayerRenderTask) {
  21363. _this2.textLayerRenderTask
  21364. .expandTextDivs(false);
  21365. }
  21366. expandDivsTimer = null;
  21367. }, EXPAND_DIVS_TIMEOUT);
  21368. return;
  21369. }
  21370. var end = div.querySelector(".endOfContent");
  21371. if (!end) {
  21372. return;
  21373. }
  21374. end.style.top = "";
  21375. end.classList.remove("active");
  21376. });
  21377. }
  21378. }]);
  21379. return TextLayerBuilder;
  21380. }();
  21381. exports.TextLayerBuilder = TextLayerBuilder;
  21382. /***/
  21383. }),
  21384. /* 37 */
  21385. /***/
  21386. ((__unused_webpack_module, exports, __webpack_require__) => {
  21387. Object.defineProperty(exports, "__esModule", ({
  21388. value: true
  21389. }));
  21390. exports.XfaLayerBuilder = void 0;
  21391. var _pdfjsLib = __webpack_require__(7);
  21392. function _classCallCheck(instance, Constructor) {
  21393. if (!(instance instanceof Constructor)) {
  21394. throw new TypeError("Cannot call a class as a function");
  21395. }
  21396. }
  21397. function _defineProperties(target, props) {
  21398. for (var i = 0; i < props.length; i++) {
  21399. var descriptor = props[i];
  21400. descriptor.enumerable = descriptor.enumerable || false;
  21401. descriptor.configurable = true;
  21402. if ("value" in descriptor) descriptor.writable = true;
  21403. Object.defineProperty(target, descriptor.key, descriptor);
  21404. }
  21405. }
  21406. function _createClass(Constructor, protoProps, staticProps) {
  21407. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  21408. if (staticProps) _defineProperties(Constructor, staticProps);
  21409. Object.defineProperty(Constructor, "prototype", {
  21410. writable: false
  21411. });
  21412. return Constructor;
  21413. }
  21414. var XfaLayerBuilder = /*#__PURE__*/ function() {
  21415. function XfaLayerBuilder(_ref) {
  21416. var pageDiv = _ref.pageDiv,
  21417. pdfPage = _ref.pdfPage,
  21418. _ref$annotationStorag = _ref.annotationStorage,
  21419. annotationStorage = _ref$annotationStorag === void 0 ? null :
  21420. _ref$annotationStorag,
  21421. linkService = _ref.linkService,
  21422. _ref$xfaHtml = _ref.xfaHtml,
  21423. xfaHtml = _ref$xfaHtml === void 0 ? null : _ref$xfaHtml;
  21424. _classCallCheck(this, XfaLayerBuilder);
  21425. this.pageDiv = pageDiv;
  21426. this.pdfPage = pdfPage;
  21427. this.annotationStorage = annotationStorage;
  21428. this.linkService = linkService;
  21429. this.xfaHtml = xfaHtml;
  21430. this.div = null;
  21431. this._cancelled = false;
  21432. }
  21433. _createClass(XfaLayerBuilder, [{
  21434. key: "render",
  21435. value: function render(viewport) {
  21436. var _this = this;
  21437. var intent = arguments.length > 1 && arguments[1] !==
  21438. undefined ? arguments[1] : "display";
  21439. if (intent === "print") {
  21440. var parameters = {
  21441. viewport: viewport.clone({
  21442. dontFlip: true
  21443. }),
  21444. div: this.div,
  21445. xfaHtml: this.xfaHtml,
  21446. annotationStorage: this.annotationStorage,
  21447. linkService: this.linkService,
  21448. intent: intent
  21449. };
  21450. var div = document.createElement("div");
  21451. this.pageDiv.appendChild(div);
  21452. parameters.div = div;
  21453. var result = _pdfjsLib.XfaLayer.render(parameters);
  21454. return Promise.resolve(result);
  21455. }
  21456. return this.pdfPage.getXfa().then(function(xfaHtml) {
  21457. if (_this._cancelled || !xfaHtml) {
  21458. return {
  21459. textDivs: []
  21460. };
  21461. }
  21462. var parameters = {
  21463. viewport: viewport.clone({
  21464. dontFlip: true
  21465. }),
  21466. div: _this.div,
  21467. xfaHtml: xfaHtml,
  21468. annotationStorage: _this
  21469. .annotationStorage,
  21470. linkService: _this.linkService,
  21471. intent: intent
  21472. };
  21473. if (_this.div) {
  21474. return _pdfjsLib.XfaLayer.update(
  21475. parameters);
  21476. }
  21477. _this.div = document.createElement("div");
  21478. _this.pageDiv.appendChild(_this.div);
  21479. parameters.div = _this.div;
  21480. return _pdfjsLib.XfaLayer.render(parameters);
  21481. })["catch"](function(error) {
  21482. console.error(error);
  21483. });
  21484. }
  21485. }, {
  21486. key: "cancel",
  21487. value: function cancel() {
  21488. this._cancelled = true;
  21489. }
  21490. }, {
  21491. key: "hide",
  21492. value: function hide() {
  21493. if (!this.div) {
  21494. return;
  21495. }
  21496. this.div.hidden = true;
  21497. }
  21498. }]);
  21499. return XfaLayerBuilder;
  21500. }();
  21501. exports.XfaLayerBuilder = XfaLayerBuilder;
  21502. /***/
  21503. }),
  21504. /* 38 */
  21505. /***/
  21506. ((__unused_webpack_module, exports, __webpack_require__) => {
  21507. Object.defineProperty(exports, "__esModule", ({
  21508. value: true
  21509. }));
  21510. exports.SecondaryToolbar = void 0;
  21511. var _ui_utils = __webpack_require__(5);
  21512. var _pdf_cursor_tools = __webpack_require__(8);
  21513. var _base_viewer = __webpack_require__(30);
  21514. function _createForOfIteratorHelper(o, allowArrayLike) {
  21515. var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
  21516. if (!it) {
  21517. if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike &&
  21518. o && typeof o.length === "number") {
  21519. if (it) o = it;
  21520. var i = 0;
  21521. var F = function F() {};
  21522. return {
  21523. s: F,
  21524. n: function n() {
  21525. if (i >= o.length) return {
  21526. done: true
  21527. };
  21528. return {
  21529. done: false,
  21530. value: o[i++]
  21531. };
  21532. },
  21533. e: function e(_e) {
  21534. throw _e;
  21535. },
  21536. f: F
  21537. };
  21538. }
  21539. throw new TypeError(
  21540. "Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
  21541. );
  21542. }
  21543. var normalCompletion = true,
  21544. didErr = false,
  21545. err;
  21546. return {
  21547. s: function s() {
  21548. it = it.call(o);
  21549. },
  21550. n: function n() {
  21551. var step = it.next();
  21552. normalCompletion = step.done;
  21553. return step;
  21554. },
  21555. e: function e(_e2) {
  21556. didErr = true;
  21557. err = _e2;
  21558. },
  21559. f: function f() {
  21560. try {
  21561. if (!normalCompletion && it["return"] != null) it["return"]();
  21562. } finally {
  21563. if (didErr) throw err;
  21564. }
  21565. }
  21566. };
  21567. }
  21568. function _unsupportedIterableToArray(o, minLen) {
  21569. if (!o) return;
  21570. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  21571. var n = Object.prototype.toString.call(o).slice(8, -1);
  21572. if (n === "Object" && o.constructor) n = o.constructor.name;
  21573. if (n === "Map" || n === "Set") return Array.from(o);
  21574. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
  21575. return _arrayLikeToArray(o, minLen);
  21576. }
  21577. function _arrayLikeToArray(arr, len) {
  21578. if (len == null || len > arr.length) len = arr.length;
  21579. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  21580. arr2[i] = arr[i];
  21581. }
  21582. return arr2;
  21583. }
  21584. function _classCallCheck(instance, Constructor) {
  21585. if (!(instance instanceof Constructor)) {
  21586. throw new TypeError("Cannot call a class as a function");
  21587. }
  21588. }
  21589. function _defineProperties(target, props) {
  21590. for (var i = 0; i < props.length; i++) {
  21591. var descriptor = props[i];
  21592. descriptor.enumerable = descriptor.enumerable || false;
  21593. descriptor.configurable = true;
  21594. if ("value" in descriptor) descriptor.writable = true;
  21595. Object.defineProperty(target, descriptor.key, descriptor);
  21596. }
  21597. }
  21598. function _createClass(Constructor, protoProps, staticProps) {
  21599. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  21600. if (staticProps) _defineProperties(Constructor, staticProps);
  21601. Object.defineProperty(Constructor, "prototype", {
  21602. writable: false
  21603. });
  21604. return Constructor;
  21605. }
  21606. var SecondaryToolbar = /*#__PURE__*/ function() {
  21607. function SecondaryToolbar(options, mainContainer, eventBus) {
  21608. _classCallCheck(this, SecondaryToolbar);
  21609. this.toolbar = options.toolbar;
  21610. this.toggleButton = options.toggleButton;
  21611. this.toolbarButtonContainer = options.toolbarButtonContainer;
  21612. this.buttons = [{
  21613. element: options.presentationModeButton,
  21614. eventName: "presentationmode",
  21615. close: true
  21616. }, {
  21617. element: options.openFileButton,
  21618. eventName: "openfile",
  21619. close: true
  21620. }, {
  21621. element: options.printButton,
  21622. eventName: "print",
  21623. close: true
  21624. }, {
  21625. element: options.downloadButton,
  21626. eventName: "download",
  21627. close: true
  21628. }, {
  21629. element: options.viewBookmarkButton,
  21630. eventName: null,
  21631. close: true
  21632. }, {
  21633. element: options.firstPageButton,
  21634. eventName: "firstpage",
  21635. close: true
  21636. }, {
  21637. element: options.lastPageButton,
  21638. eventName: "lastpage",
  21639. close: true
  21640. }, {
  21641. element: options.pageRotateCwButton,
  21642. eventName: "rotatecw",
  21643. close: false
  21644. }, {
  21645. element: options.pageRotateCcwButton,
  21646. eventName: "rotateccw",
  21647. close: false
  21648. }, {
  21649. element: options.cursorSelectToolButton,
  21650. eventName: "switchcursortool",
  21651. eventDetails: {
  21652. tool: _pdf_cursor_tools.CursorTool.SELECT
  21653. },
  21654. close: true
  21655. }, {
  21656. element: options.cursorHandToolButton,
  21657. eventName: "switchcursortool",
  21658. eventDetails: {
  21659. tool: _pdf_cursor_tools.CursorTool.HAND
  21660. },
  21661. close: true
  21662. }, {
  21663. element: options.scrollPageButton,
  21664. eventName: "switchscrollmode",
  21665. eventDetails: {
  21666. mode: _ui_utils.ScrollMode.PAGE
  21667. },
  21668. close: true
  21669. }, {
  21670. element: options.scrollVerticalButton,
  21671. eventName: "switchscrollmode",
  21672. eventDetails: {
  21673. mode: _ui_utils.ScrollMode.VERTICAL
  21674. },
  21675. close: true
  21676. }, {
  21677. element: options.scrollHorizontalButton,
  21678. eventName: "switchscrollmode",
  21679. eventDetails: {
  21680. mode: _ui_utils.ScrollMode.HORIZONTAL
  21681. },
  21682. close: true
  21683. }, {
  21684. element: options.scrollWrappedButton,
  21685. eventName: "switchscrollmode",
  21686. eventDetails: {
  21687. mode: _ui_utils.ScrollMode.WRAPPED
  21688. },
  21689. close: true
  21690. }, {
  21691. element: options.spreadNoneButton,
  21692. eventName: "switchspreadmode",
  21693. eventDetails: {
  21694. mode: _ui_utils.SpreadMode.NONE
  21695. },
  21696. close: true
  21697. }, {
  21698. element: options.spreadOddButton,
  21699. eventName: "switchspreadmode",
  21700. eventDetails: {
  21701. mode: _ui_utils.SpreadMode.ODD
  21702. },
  21703. close: true
  21704. }, {
  21705. element: options.spreadEvenButton,
  21706. eventName: "switchspreadmode",
  21707. eventDetails: {
  21708. mode: _ui_utils.SpreadMode.EVEN
  21709. },
  21710. close: true
  21711. }, {
  21712. element: options.documentPropertiesButton,
  21713. eventName: "documentproperties",
  21714. close: true
  21715. }];
  21716. this.items = {
  21717. firstPage: options.firstPageButton,
  21718. lastPage: options.lastPageButton,
  21719. pageRotateCw: options.pageRotateCwButton,
  21720. pageRotateCcw: options.pageRotateCcwButton
  21721. };
  21722. this.mainContainer = mainContainer;
  21723. this.eventBus = eventBus;
  21724. this.opened = false;
  21725. this.containerHeight = null;
  21726. this.previousContainerHeight = null;
  21727. this.reset();
  21728. this._bindClickListeners();
  21729. this._bindCursorToolsListener(options);
  21730. this._bindScrollModeListener(options);
  21731. this._bindSpreadModeListener(options);
  21732. this.eventBus._on("resize", this._setMaxHeight.bind(this));
  21733. }
  21734. _createClass(SecondaryToolbar, [{
  21735. key: "isOpen",
  21736. get: function get() {
  21737. return this.opened;
  21738. }
  21739. }, {
  21740. key: "setPageNumber",
  21741. value: function setPageNumber(pageNumber) {
  21742. this.pageNumber = pageNumber;
  21743. this._updateUIState();
  21744. }
  21745. }, {
  21746. key: "setPagesCount",
  21747. value: function setPagesCount(pagesCount) {
  21748. this.pagesCount = pagesCount;
  21749. this._updateUIState();
  21750. }
  21751. }, {
  21752. key: "reset",
  21753. value: function reset() {
  21754. this.pageNumber = 0;
  21755. this.pagesCount = 0;
  21756. this._updateUIState();
  21757. this.eventBus.dispatch("secondarytoolbarreset", {
  21758. source: this
  21759. });
  21760. }
  21761. }, {
  21762. key: "_updateUIState",
  21763. value: function _updateUIState() {
  21764. this.items.firstPage.disabled = this.pageNumber <= 1;
  21765. this.items.lastPage.disabled = this.pageNumber >= this
  21766. .pagesCount;
  21767. this.items.pageRotateCw.disabled = this.pagesCount === 0;
  21768. this.items.pageRotateCcw.disabled = this.pagesCount === 0;
  21769. }
  21770. }, {
  21771. key: "_bindClickListeners",
  21772. value: function _bindClickListeners() {
  21773. var _this = this;
  21774. this.toggleButton.addEventListener("click", this.toggle
  21775. .bind(this));
  21776. var _iterator = _createForOfIteratorHelper(this.buttons),
  21777. _step;
  21778. try {
  21779. var _loop = function _loop() {
  21780. var _step$value = _step.value,
  21781. element = _step$value.element,
  21782. eventName = _step$value.eventName,
  21783. close = _step$value.close,
  21784. eventDetails = _step$value.eventDetails;
  21785. element.addEventListener("click", function(
  21786. evt) {
  21787. if (eventName !== null) {
  21788. var details = {
  21789. source: _this
  21790. };
  21791. for (var property in
  21792. eventDetails) {
  21793. details[property] =
  21794. eventDetails[property];
  21795. }
  21796. _this.eventBus.dispatch(
  21797. eventName, details);
  21798. }
  21799. if (close) {
  21800. _this.close();
  21801. }
  21802. });
  21803. };
  21804. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  21805. _loop();
  21806. }
  21807. } catch (err) {
  21808. _iterator.e(err);
  21809. } finally {
  21810. _iterator.f();
  21811. }
  21812. }
  21813. }, {
  21814. key: "_bindCursorToolsListener",
  21815. value: function _bindCursorToolsListener(buttons) {
  21816. this.eventBus._on("cursortoolchanged", function(_ref) {
  21817. var tool = _ref.tool;
  21818. buttons.cursorSelectToolButton.classList.toggle(
  21819. "toggled", tool === _pdf_cursor_tools
  21820. .CursorTool.SELECT);
  21821. buttons.cursorHandToolButton.classList.toggle(
  21822. "toggled", tool === _pdf_cursor_tools
  21823. .CursorTool.HAND);
  21824. });
  21825. }
  21826. }, {
  21827. key: "_bindScrollModeListener",
  21828. value: function _bindScrollModeListener(buttons) {
  21829. var _this2 = this;
  21830. var scrollModeChanged = function scrollModeChanged(_ref2) {
  21831. var mode = _ref2.mode;
  21832. buttons.scrollPageButton.classList.toggle("toggled",
  21833. mode === _ui_utils.ScrollMode.PAGE);
  21834. buttons.scrollVerticalButton.classList.toggle(
  21835. "toggled", mode === _ui_utils.ScrollMode
  21836. .VERTICAL);
  21837. buttons.scrollHorizontalButton.classList.toggle(
  21838. "toggled", mode === _ui_utils.ScrollMode
  21839. .HORIZONTAL);
  21840. buttons.scrollWrappedButton.classList.toggle(
  21841. "toggled", mode === _ui_utils.ScrollMode
  21842. .WRAPPED);
  21843. var forceScrollModePage = _this2.pagesCount >
  21844. _base_viewer.PagesCountLimit
  21845. .FORCE_SCROLL_MODE_PAGE;
  21846. buttons.scrollPageButton.disabled =
  21847. forceScrollModePage;
  21848. buttons.scrollVerticalButton.disabled =
  21849. forceScrollModePage;
  21850. buttons.scrollHorizontalButton.disabled =
  21851. forceScrollModePage;
  21852. buttons.scrollWrappedButton.disabled =
  21853. forceScrollModePage;
  21854. var isScrollModeHorizontal = mode === _ui_utils
  21855. .ScrollMode.HORIZONTAL;
  21856. buttons.spreadNoneButton.disabled =
  21857. isScrollModeHorizontal;
  21858. buttons.spreadOddButton.disabled =
  21859. isScrollModeHorizontal;
  21860. buttons.spreadEvenButton.disabled =
  21861. isScrollModeHorizontal;
  21862. };
  21863. this.eventBus._on("scrollmodechanged", scrollModeChanged);
  21864. this.eventBus._on("secondarytoolbarreset", function(evt) {
  21865. if (evt.source === _this2) {
  21866. scrollModeChanged({
  21867. mode: _ui_utils.ScrollMode
  21868. .VERTICAL
  21869. });
  21870. }
  21871. });
  21872. }
  21873. }, {
  21874. key: "_bindSpreadModeListener",
  21875. value: function _bindSpreadModeListener(buttons) {
  21876. var _this3 = this;
  21877. function spreadModeChanged(_ref3) {
  21878. var mode = _ref3.mode;
  21879. buttons.spreadNoneButton.classList.toggle("toggled",
  21880. mode === _ui_utils.SpreadMode.NONE);
  21881. buttons.spreadOddButton.classList.toggle("toggled",
  21882. mode === _ui_utils.SpreadMode.ODD);
  21883. buttons.spreadEvenButton.classList.toggle("toggled",
  21884. mode === _ui_utils.SpreadMode.EVEN);
  21885. }
  21886. this.eventBus._on("spreadmodechanged", spreadModeChanged);
  21887. this.eventBus._on("secondarytoolbarreset", function(evt) {
  21888. if (evt.source === _this3) {
  21889. spreadModeChanged({
  21890. mode: _ui_utils.SpreadMode.NONE
  21891. });
  21892. }
  21893. });
  21894. }
  21895. }, {
  21896. key: "open",
  21897. value: function open() {
  21898. if (this.opened) {
  21899. return;
  21900. }
  21901. this.opened = true;
  21902. this._setMaxHeight();
  21903. this.toggleButton.classList.add("toggled");
  21904. this.toggleButton.setAttribute("aria-expanded", "true");
  21905. this.toolbar.classList.remove("hidden");
  21906. }
  21907. }, {
  21908. key: "close",
  21909. value: function close() {
  21910. if (!this.opened) {
  21911. return;
  21912. }
  21913. this.opened = false;
  21914. this.toolbar.classList.add("hidden");
  21915. this.toggleButton.classList.remove("toggled");
  21916. this.toggleButton.setAttribute("aria-expanded", "false");
  21917. }
  21918. }, {
  21919. key: "toggle",
  21920. value: function toggle() {
  21921. if (this.opened) {
  21922. this.close();
  21923. } else {
  21924. this.open();
  21925. }
  21926. }
  21927. }, {
  21928. key: "_setMaxHeight",
  21929. value: function _setMaxHeight() {
  21930. if (!this.opened) {
  21931. return;
  21932. }
  21933. this.containerHeight = this.mainContainer.clientHeight;
  21934. if (this.containerHeight === this.previousContainerHeight) {
  21935. return;
  21936. }
  21937. this.toolbarButtonContainer.style.maxHeight = "".concat(this
  21938. .containerHeight - _ui_utils.SCROLLBAR_PADDING, "px"
  21939. );
  21940. this.previousContainerHeight = this.containerHeight;
  21941. }
  21942. }]);
  21943. return SecondaryToolbar;
  21944. }();
  21945. exports.SecondaryToolbar = SecondaryToolbar;
  21946. /***/
  21947. }),
  21948. /* 39 */
  21949. /***/
  21950. ((__unused_webpack_module, exports, __webpack_require__) => {
  21951. Object.defineProperty(exports, "__esModule", ({
  21952. value: true
  21953. }));
  21954. exports.Toolbar = void 0;
  21955. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  21956. var _ui_utils = __webpack_require__(5);
  21957. function _interopRequireDefault(obj) {
  21958. return obj && obj.__esModule ? obj : {
  21959. "default": obj
  21960. };
  21961. }
  21962. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  21963. try {
  21964. var info = gen[key](arg);
  21965. var value = info.value;
  21966. } catch (error) {
  21967. reject(error);
  21968. return;
  21969. }
  21970. if (info.done) {
  21971. resolve(value);
  21972. } else {
  21973. Promise.resolve(value).then(_next, _throw);
  21974. }
  21975. }
  21976. function _asyncToGenerator(fn) {
  21977. return function() {
  21978. var self = this,
  21979. args = arguments;
  21980. return new Promise(function(resolve, reject) {
  21981. var gen = fn.apply(self, args);
  21982. function _next(value) {
  21983. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next",
  21984. value);
  21985. }
  21986. function _throw(err) {
  21987. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw",
  21988. err);
  21989. }
  21990. _next(undefined);
  21991. });
  21992. };
  21993. }
  21994. function _createForOfIteratorHelper(o, allowArrayLike) {
  21995. var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
  21996. if (!it) {
  21997. if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike &&
  21998. o && typeof o.length === "number") {
  21999. if (it) o = it;
  22000. var i = 0;
  22001. var F = function F() {};
  22002. return {
  22003. s: F,
  22004. n: function n() {
  22005. if (i >= o.length) return {
  22006. done: true
  22007. };
  22008. return {
  22009. done: false,
  22010. value: o[i++]
  22011. };
  22012. },
  22013. e: function e(_e) {
  22014. throw _e;
  22015. },
  22016. f: F
  22017. };
  22018. }
  22019. throw new TypeError(
  22020. "Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
  22021. );
  22022. }
  22023. var normalCompletion = true,
  22024. didErr = false,
  22025. err;
  22026. return {
  22027. s: function s() {
  22028. it = it.call(o);
  22029. },
  22030. n: function n() {
  22031. var step = it.next();
  22032. normalCompletion = step.done;
  22033. return step;
  22034. },
  22035. e: function e(_e2) {
  22036. didErr = true;
  22037. err = _e2;
  22038. },
  22039. f: function f() {
  22040. try {
  22041. if (!normalCompletion && it["return"] != null) it["return"]();
  22042. } finally {
  22043. if (didErr) throw err;
  22044. }
  22045. }
  22046. };
  22047. }
  22048. function _unsupportedIterableToArray(o, minLen) {
  22049. if (!o) return;
  22050. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  22051. var n = Object.prototype.toString.call(o).slice(8, -1);
  22052. if (n === "Object" && o.constructor) n = o.constructor.name;
  22053. if (n === "Map" || n === "Set") return Array.from(o);
  22054. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
  22055. return _arrayLikeToArray(o, minLen);
  22056. }
  22057. function _arrayLikeToArray(arr, len) {
  22058. if (len == null || len > arr.length) len = arr.length;
  22059. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  22060. arr2[i] = arr[i];
  22061. }
  22062. return arr2;
  22063. }
  22064. function _classCallCheck(instance, Constructor) {
  22065. if (!(instance instanceof Constructor)) {
  22066. throw new TypeError("Cannot call a class as a function");
  22067. }
  22068. }
  22069. function _defineProperties(target, props) {
  22070. for (var i = 0; i < props.length; i++) {
  22071. var descriptor = props[i];
  22072. descriptor.enumerable = descriptor.enumerable || false;
  22073. descriptor.configurable = true;
  22074. if ("value" in descriptor) descriptor.writable = true;
  22075. Object.defineProperty(target, descriptor.key, descriptor);
  22076. }
  22077. }
  22078. function _createClass(Constructor, protoProps, staticProps) {
  22079. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  22080. if (staticProps) _defineProperties(Constructor, staticProps);
  22081. Object.defineProperty(Constructor, "prototype", {
  22082. writable: false
  22083. });
  22084. return Constructor;
  22085. }
  22086. var PAGE_NUMBER_LOADING_INDICATOR = "visiblePageIsLoading";
  22087. var Toolbar = /*#__PURE__*/ function() {
  22088. function Toolbar(options, eventBus, l10n) {
  22089. _classCallCheck(this, Toolbar);
  22090. this.toolbar = options.container;
  22091. this.eventBus = eventBus;
  22092. this.l10n = l10n;
  22093. this.buttons = [{
  22094. element: options.previous,
  22095. eventName: "previouspage"
  22096. }, {
  22097. element: options.next,
  22098. eventName: "nextpage"
  22099. }, {
  22100. element: options.zoomIn,
  22101. eventName: "zoomin"
  22102. }, {
  22103. element: options.zoomOut,
  22104. eventName: "zoomout"
  22105. }, {
  22106. element: options.openFile,
  22107. eventName: "openfile"
  22108. }, {
  22109. element: options.print,
  22110. eventName: "print"
  22111. }, {
  22112. element: options.presentationModeButton,
  22113. eventName: "presentationmode"
  22114. }, {
  22115. element: options.download,
  22116. eventName: "download"
  22117. }, {
  22118. element: options.viewBookmark,
  22119. eventName: null
  22120. }];
  22121. this.items = {
  22122. numPages: options.numPages,
  22123. pageNumber: options.pageNumber,
  22124. scaleSelect: options.scaleSelect,
  22125. customScaleOption: options.customScaleOption,
  22126. previous: options.previous,
  22127. next: options.next,
  22128. zoomIn: options.zoomIn,
  22129. zoomOut: options.zoomOut
  22130. };
  22131. this._wasLocalized = false;
  22132. this.reset();
  22133. this._bindListeners();
  22134. }
  22135. _createClass(Toolbar, [{
  22136. key: "setPageNumber",
  22137. value: function setPageNumber(pageNumber, pageLabel) {
  22138. this.pageNumber = pageNumber;
  22139. this.pageLabel = pageLabel;
  22140. this._updateUIState(false);
  22141. }
  22142. }, {
  22143. key: "setPagesCount",
  22144. value: function setPagesCount(pagesCount, hasPageLabels) {
  22145. this.pagesCount = pagesCount;
  22146. this.hasPageLabels = hasPageLabels;
  22147. this._updateUIState(true);
  22148. }
  22149. }, {
  22150. key: "setPageScale",
  22151. value: function setPageScale(pageScaleValue, pageScale) {
  22152. this.pageScaleValue = (pageScaleValue || pageScale)
  22153. .toString();
  22154. this.pageScale = pageScale;
  22155. this._updateUIState(false);
  22156. }
  22157. }, {
  22158. key: "reset",
  22159. value: function reset() {
  22160. this.pageNumber = 0;
  22161. this.pageLabel = null;
  22162. this.hasPageLabels = false;
  22163. this.pagesCount = 0;
  22164. this.pageScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  22165. this.pageScale = _ui_utils.DEFAULT_SCALE;
  22166. this._updateUIState(true);
  22167. this.updateLoadingIndicatorState();
  22168. }
  22169. }, {
  22170. key: "_bindListeners",
  22171. value: function _bindListeners() {
  22172. var _this = this;
  22173. var _this$items = this.items,
  22174. pageNumber = _this$items.pageNumber,
  22175. scaleSelect = _this$items.scaleSelect;
  22176. var self = this;
  22177. var _iterator = _createForOfIteratorHelper(this.buttons),
  22178. _step;
  22179. try {
  22180. var _loop = function _loop() {
  22181. var _step$value = _step.value,
  22182. element = _step$value.element,
  22183. eventName = _step$value.eventName;
  22184. element.addEventListener("click", function(
  22185. evt) {
  22186. if (eventName !== null) {
  22187. _this.eventBus.dispatch(
  22188. eventName, {
  22189. source: _this
  22190. });
  22191. }
  22192. });
  22193. };
  22194. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  22195. _loop();
  22196. }
  22197. } catch (err) {
  22198. _iterator.e(err);
  22199. } finally {
  22200. _iterator.f();
  22201. }
  22202. pageNumber.addEventListener("click", function() {
  22203. this.select();
  22204. });
  22205. pageNumber.addEventListener("change", function() {
  22206. self.eventBus.dispatch("pagenumberchanged", {
  22207. source: self,
  22208. value: this.value
  22209. });
  22210. });
  22211. scaleSelect.addEventListener("change", function() {
  22212. if (this.value === "custom") {
  22213. return;
  22214. }
  22215. self.eventBus.dispatch("scalechanged", {
  22216. source: self,
  22217. value: this.value
  22218. });
  22219. });
  22220. scaleSelect.addEventListener("click", function(evt) {
  22221. var target = evt.target;
  22222. if (this.value === self.pageScaleValue && target
  22223. .tagName.toUpperCase() === "OPTION") {
  22224. this.blur();
  22225. }
  22226. });
  22227. scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler;
  22228. this.eventBus._on("localized", function() {
  22229. _this._wasLocalized = true;
  22230. _this._adjustScaleWidth();
  22231. _this._updateUIState(true);
  22232. });
  22233. }
  22234. }, {
  22235. key: "_updateUIState",
  22236. value: function _updateUIState() {
  22237. var resetNumPages = arguments.length > 0 && arguments[0] !==
  22238. undefined ? arguments[0] : false;
  22239. if (!this._wasLocalized) {
  22240. return;
  22241. }
  22242. var pageNumber = this.pageNumber,
  22243. pagesCount = this.pagesCount,
  22244. pageScaleValue = this.pageScaleValue,
  22245. pageScale = this.pageScale,
  22246. items = this.items;
  22247. if (resetNumPages) {
  22248. if (this.hasPageLabels) {
  22249. items.pageNumber.type = "text";
  22250. } else {
  22251. items.pageNumber.type = "number";
  22252. this.l10n.get("of_pages", {
  22253. pagesCount: pagesCount
  22254. }).then(function(msg) {
  22255. items.numPages.textContent = msg;
  22256. });
  22257. }
  22258. items.pageNumber.max = pagesCount;
  22259. }
  22260. if (this.hasPageLabels) {
  22261. items.pageNumber.value = this.pageLabel;
  22262. this.l10n.get("page_of_pages", {
  22263. pageNumber: pageNumber,
  22264. pagesCount: pagesCount
  22265. }).then(function(msg) {
  22266. items.numPages.textContent = msg;
  22267. });
  22268. } else {
  22269. items.pageNumber.value = pageNumber;
  22270. }
  22271. items.previous.disabled = pageNumber <= 1;
  22272. items.next.disabled = pageNumber >= pagesCount;
  22273. items.zoomOut.disabled = pageScale <= _ui_utils.MIN_SCALE;
  22274. items.zoomIn.disabled = pageScale >= _ui_utils.MAX_SCALE;
  22275. this.l10n.get("page_scale_percent", {
  22276. scale: Math.round(pageScale * 10000) / 100
  22277. }).then(function(msg) {
  22278. var predefinedValueFound = false;
  22279. var _iterator2 = _createForOfIteratorHelper(
  22280. items.scaleSelect.options),
  22281. _step2;
  22282. try {
  22283. for (_iterator2.s(); !(_step2 = _iterator2
  22284. .n()).done;) {
  22285. var option = _step2.value;
  22286. if (option.value !== pageScaleValue) {
  22287. option.selected = false;
  22288. continue;
  22289. }
  22290. option.selected = true;
  22291. predefinedValueFound = true;
  22292. }
  22293. } catch (err) {
  22294. _iterator2.e(err);
  22295. } finally {
  22296. _iterator2.f();
  22297. }
  22298. if (!predefinedValueFound) {
  22299. items.customScaleOption.textContent = msg;
  22300. items.customScaleOption.selected = true;
  22301. }
  22302. });
  22303. }
  22304. }, {
  22305. key: "updateLoadingIndicatorState",
  22306. value: function updateLoadingIndicatorState() {
  22307. var loading = arguments.length > 0 && arguments[0] !==
  22308. undefined ? arguments[0] : false;
  22309. var pageNumberInput = this.items.pageNumber;
  22310. pageNumberInput.classList.toggle(
  22311. PAGE_NUMBER_LOADING_INDICATOR, loading);
  22312. }
  22313. }, {
  22314. key: "_adjustScaleWidth",
  22315. value: function() {
  22316. var _adjustScaleWidth2 = _asyncToGenerator( /*#__PURE__*/
  22317. _regenerator["default"].mark(function _callee() {
  22318. var items, l10n, predefinedValuesPromise,
  22319. style, scaleSelectContainerWidth,
  22320. scaleSelectOverflow, canvas, ctx,
  22321. maxWidth, _iterator3, _step3,
  22322. predefinedValue, _ctx$measureText,
  22323. width, doc;
  22324. return _regenerator["default"].wrap(
  22325. function _callee$(_context) {
  22326. while (1) {
  22327. switch (_context.prev =
  22328. _context.next) {
  22329. case 0:
  22330. items = this.items,
  22331. l10n = this
  22332. .l10n;
  22333. predefinedValuesPromise
  22334. = Promise.all([
  22335. l10n
  22336. .get(
  22337. "page_scale_auto"
  22338. ),
  22339. l10n
  22340. .get(
  22341. "page_scale_actual"
  22342. ),
  22343. l10n
  22344. .get(
  22345. "page_scale_fit"
  22346. ),
  22347. l10n
  22348. .get(
  22349. "page_scale_width"
  22350. )
  22351. ]);
  22352. style =
  22353. getComputedStyle(
  22354. items
  22355. .scaleSelect
  22356. ),
  22357. scaleSelectContainerWidth =
  22358. parseInt(style
  22359. .getPropertyValue(
  22360. "--scale-select-container-width"
  22361. ), 10),
  22362. scaleSelectOverflow =
  22363. parseInt(style
  22364. .getPropertyValue(
  22365. "--scale-select-overflow"
  22366. ), 10);
  22367. canvas = document
  22368. .createElement(
  22369. "canvas");
  22370. canvas.mozOpaque =
  22371. true;
  22372. ctx = canvas
  22373. .getContext(
  22374. "2d", {
  22375. alpha: false
  22376. });
  22377. _context.next = 8;
  22378. return _ui_utils
  22379. .animationStarted;
  22380. case 8:
  22381. ctx.font = ""
  22382. .concat(style
  22383. .fontSize,
  22384. " ").concat(
  22385. style
  22386. .fontFamily
  22387. );
  22388. maxWidth = 0;
  22389. _context.t0 =
  22390. _createForOfIteratorHelper;
  22391. _context.next = 13;
  22392. return predefinedValuesPromise;
  22393. case 13:
  22394. _context.t1 =
  22395. _context.sent;
  22396. _iterator3 = (0,
  22397. _context.t0)
  22398. (_context.t1);
  22399. try {
  22400. for (_iterator3
  22401. .s(); !(
  22402. _step3 =
  22403. _iterator3
  22404. .n())
  22405. .done;) {
  22406. predefinedValue
  22407. = _step3
  22408. .value;
  22409. _ctx$measureText
  22410. = ctx
  22411. .measureText(
  22412. predefinedValue
  22413. ),
  22414. width =
  22415. _ctx$measureText
  22416. .width;
  22417. if (width >
  22418. maxWidth
  22419. ) {
  22420. maxWidth
  22421. =
  22422. width;
  22423. }
  22424. }
  22425. } catch (err) {
  22426. _iterator3.e(
  22427. err);
  22428. } finally {
  22429. _iterator3.f();
  22430. }
  22431. maxWidth += 2 *
  22432. scaleSelectOverflow;
  22433. if (maxWidth >
  22434. scaleSelectContainerWidth
  22435. ) {
  22436. doc = document
  22437. .documentElement;
  22438. doc.style
  22439. .setProperty(
  22440. "--scale-select-container-width",
  22441. ""
  22442. .concat(
  22443. maxWidth,
  22444. "px"
  22445. ));
  22446. }
  22447. canvas.width = 0;
  22448. canvas.height = 0;
  22449. canvas = ctx = null;
  22450. case 21:
  22451. case "end":
  22452. return _context
  22453. .stop();
  22454. }
  22455. }
  22456. }, _callee, this);
  22457. }));
  22458. function _adjustScaleWidth() {
  22459. return _adjustScaleWidth2.apply(this, arguments);
  22460. }
  22461. return _adjustScaleWidth;
  22462. }()
  22463. }]);
  22464. return Toolbar;
  22465. }();
  22466. exports.Toolbar = Toolbar;
  22467. /***/
  22468. }),
  22469. /* 40 */
  22470. /***/
  22471. ((__unused_webpack_module, exports, __webpack_require__) => {
  22472. Object.defineProperty(exports, "__esModule", ({
  22473. value: true
  22474. }));
  22475. exports.ViewHistory = void 0;
  22476. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  22477. function _interopRequireDefault(obj) {
  22478. return obj && obj.__esModule ? obj : {
  22479. "default": obj
  22480. };
  22481. }
  22482. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  22483. try {
  22484. var info = gen[key](arg);
  22485. var value = info.value;
  22486. } catch (error) {
  22487. reject(error);
  22488. return;
  22489. }
  22490. if (info.done) {
  22491. resolve(value);
  22492. } else {
  22493. Promise.resolve(value).then(_next, _throw);
  22494. }
  22495. }
  22496. function _asyncToGenerator(fn) {
  22497. return function() {
  22498. var self = this,
  22499. args = arguments;
  22500. return new Promise(function(resolve, reject) {
  22501. var gen = fn.apply(self, args);
  22502. function _next(value) {
  22503. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next",
  22504. value);
  22505. }
  22506. function _throw(err) {
  22507. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw",
  22508. err);
  22509. }
  22510. _next(undefined);
  22511. });
  22512. };
  22513. }
  22514. function _classCallCheck(instance, Constructor) {
  22515. if (!(instance instanceof Constructor)) {
  22516. throw new TypeError("Cannot call a class as a function");
  22517. }
  22518. }
  22519. function _defineProperties(target, props) {
  22520. for (var i = 0; i < props.length; i++) {
  22521. var descriptor = props[i];
  22522. descriptor.enumerable = descriptor.enumerable || false;
  22523. descriptor.configurable = true;
  22524. if ("value" in descriptor) descriptor.writable = true;
  22525. Object.defineProperty(target, descriptor.key, descriptor);
  22526. }
  22527. }
  22528. function _createClass(Constructor, protoProps, staticProps) {
  22529. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  22530. if (staticProps) _defineProperties(Constructor, staticProps);
  22531. Object.defineProperty(Constructor, "prototype", {
  22532. writable: false
  22533. });
  22534. return Constructor;
  22535. }
  22536. var DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
  22537. var ViewHistory = /*#__PURE__*/ function() {
  22538. function ViewHistory(fingerprint) {
  22539. var _this = this;
  22540. var cacheSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[
  22541. 1] : DEFAULT_VIEW_HISTORY_CACHE_SIZE;
  22542. _classCallCheck(this, ViewHistory);
  22543. this.fingerprint = fingerprint;
  22544. this.cacheSize = cacheSize;
  22545. this._initializedPromise = this._readFromStorage().then(function(databaseStr) {
  22546. var database = JSON.parse(databaseStr || "{}");
  22547. var index = -1;
  22548. if (!Array.isArray(database.files)) {
  22549. database.files = [];
  22550. } else {
  22551. while (database.files.length >= _this.cacheSize) {
  22552. database.files.shift();
  22553. }
  22554. for (var i = 0, ii = database.files.length; i < ii; i++) {
  22555. var branch = database.files[i];
  22556. if (branch.fingerprint === _this.fingerprint) {
  22557. index = i;
  22558. break;
  22559. }
  22560. }
  22561. }
  22562. if (index === -1) {
  22563. index = database.files.push({
  22564. fingerprint: _this.fingerprint
  22565. }) - 1;
  22566. }
  22567. _this.file = database.files[index];
  22568. _this.database = database;
  22569. });
  22570. }
  22571. _createClass(ViewHistory, [{
  22572. key: "_writeToStorage",
  22573. value: function() {
  22574. var _writeToStorage2 = _asyncToGenerator( /*#__PURE__*/
  22575. _regenerator["default"].mark(function _callee() {
  22576. var databaseStr;
  22577. return _regenerator["default"].wrap(
  22578. function _callee$(_context) {
  22579. while (1) {
  22580. switch (_context.prev =
  22581. _context.next) {
  22582. case 0:
  22583. databaseStr = JSON
  22584. .stringify(this
  22585. .database);
  22586. localStorage
  22587. .setItem(
  22588. "pdfjs.history",
  22589. databaseStr
  22590. );
  22591. case 2:
  22592. case "end":
  22593. return _context
  22594. .stop();
  22595. }
  22596. }
  22597. }, _callee, this);
  22598. }));
  22599. function _writeToStorage() {
  22600. return _writeToStorage2.apply(this, arguments);
  22601. }
  22602. return _writeToStorage;
  22603. }()
  22604. }, {
  22605. key: "_readFromStorage",
  22606. value: function() {
  22607. var _readFromStorage2 = _asyncToGenerator( /*#__PURE__*/
  22608. _regenerator["default"].mark(function _callee2() {
  22609. return _regenerator["default"].wrap(
  22610. function _callee2$(_context2) {
  22611. while (1) {
  22612. switch (_context2.prev =
  22613. _context2.next) {
  22614. case 0:
  22615. return _context2
  22616. .abrupt(
  22617. "return",
  22618. localStorage
  22619. .getItem(
  22620. "pdfjs.history"
  22621. ));
  22622. case 1:
  22623. case "end":
  22624. return _context2
  22625. .stop();
  22626. }
  22627. }
  22628. }, _callee2);
  22629. }));
  22630. function _readFromStorage() {
  22631. return _readFromStorage2.apply(this, arguments);
  22632. }
  22633. return _readFromStorage;
  22634. }()
  22635. }, {
  22636. key: "set",
  22637. value: function() {
  22638. var _set = _asyncToGenerator( /*#__PURE__*/ _regenerator[
  22639. "default"].mark(function _callee3(name, val) {
  22640. return _regenerator["default"].wrap(
  22641. function _callee3$(_context3) {
  22642. while (1) {
  22643. switch (_context3.prev =
  22644. _context3.next) {
  22645. case 0:
  22646. _context3.next = 2;
  22647. return this
  22648. ._initializedPromise;
  22649. case 2:
  22650. this.file[name] =
  22651. val;
  22652. return _context3
  22653. .abrupt(
  22654. "return",
  22655. this
  22656. ._writeToStorage()
  22657. );
  22658. case 4:
  22659. case "end":
  22660. return _context3
  22661. .stop();
  22662. }
  22663. }
  22664. }, _callee3, this);
  22665. }));
  22666. function set(_x, _x2) {
  22667. return _set.apply(this, arguments);
  22668. }
  22669. return set;
  22670. }()
  22671. }, {
  22672. key: "setMultiple",
  22673. value: function() {
  22674. var _setMultiple = _asyncToGenerator( /*#__PURE__*/
  22675. _regenerator["default"].mark(function _callee4(
  22676. properties) {
  22677. var name;
  22678. return _regenerator["default"].wrap(
  22679. function _callee4$(_context4) {
  22680. while (1) {
  22681. switch (_context4.prev =
  22682. _context4.next) {
  22683. case 0:
  22684. _context4.next = 2;
  22685. return this
  22686. ._initializedPromise;
  22687. case 2:
  22688. for (name in
  22689. properties) {
  22690. this.file[
  22691. name] =
  22692. properties[
  22693. name];
  22694. }
  22695. return _context4
  22696. .abrupt(
  22697. "return",
  22698. this
  22699. ._writeToStorage()
  22700. );
  22701. case 4:
  22702. case "end":
  22703. return _context4
  22704. .stop();
  22705. }
  22706. }
  22707. }, _callee4, this);
  22708. }));
  22709. function setMultiple(_x3) {
  22710. return _setMultiple.apply(this, arguments);
  22711. }
  22712. return setMultiple;
  22713. }()
  22714. }, {
  22715. key: "get",
  22716. value: function() {
  22717. var _get = _asyncToGenerator( /*#__PURE__*/ _regenerator[
  22718. "default"].mark(function _callee5(name,
  22719. defaultValue) {
  22720. var val;
  22721. return _regenerator["default"].wrap(
  22722. function _callee5$(_context5) {
  22723. while (1) {
  22724. switch (_context5.prev =
  22725. _context5.next) {
  22726. case 0:
  22727. _context5.next = 2;
  22728. return this
  22729. ._initializedPromise;
  22730. case 2:
  22731. val = this.file[
  22732. name];
  22733. return _context5
  22734. .abrupt(
  22735. "return",
  22736. val !==
  22737. undefined ?
  22738. val :
  22739. defaultValue
  22740. );
  22741. case 4:
  22742. case "end":
  22743. return _context5
  22744. .stop();
  22745. }
  22746. }
  22747. }, _callee5, this);
  22748. }));
  22749. function get(_x4, _x5) {
  22750. return _get.apply(this, arguments);
  22751. }
  22752. return get;
  22753. }()
  22754. }, {
  22755. key: "getMultiple",
  22756. value: function() {
  22757. var _getMultiple = _asyncToGenerator( /*#__PURE__*/
  22758. _regenerator["default"].mark(function _callee6(
  22759. properties) {
  22760. var values, name, val;
  22761. return _regenerator["default"].wrap(
  22762. function _callee6$(_context6) {
  22763. while (1) {
  22764. switch (_context6.prev =
  22765. _context6.next) {
  22766. case 0:
  22767. _context6.next = 2;
  22768. return this
  22769. ._initializedPromise;
  22770. case 2:
  22771. values = Object
  22772. .create(null);
  22773. for (name in
  22774. properties) {
  22775. val = this.file[
  22776. name];
  22777. values[name] =
  22778. val !==
  22779. undefined ?
  22780. val :
  22781. properties[
  22782. name];
  22783. }
  22784. return _context6
  22785. .abrupt(
  22786. "return",
  22787. values);
  22788. case 5:
  22789. case "end":
  22790. return _context6
  22791. .stop();
  22792. }
  22793. }
  22794. }, _callee6, this);
  22795. }));
  22796. function getMultiple(_x6) {
  22797. return _getMultiple.apply(this, arguments);
  22798. }
  22799. return getMultiple;
  22800. }()
  22801. }]);
  22802. return ViewHistory;
  22803. }();
  22804. exports.ViewHistory = ViewHistory;
  22805. /***/
  22806. }),
  22807. /* 41 */
  22808. /***/
  22809. ((__unused_webpack_module, exports, __webpack_require__) => {
  22810. function _typeof(obj) {
  22811. "@babel/helpers - typeof";
  22812. return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ?
  22813. function(obj) {
  22814. return typeof obj;
  22815. } : function(obj) {
  22816. return obj && "function" == typeof Symbol && obj.constructor === Symbol &&
  22817. obj !== Symbol.prototype ? "symbol" : typeof obj;
  22818. }, _typeof(obj);
  22819. }
  22820. Object.defineProperty(exports, "__esModule", ({
  22821. value: true
  22822. }));
  22823. exports.GenericCom = void 0;
  22824. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  22825. var _app = __webpack_require__(2);
  22826. var _preferences = __webpack_require__(42);
  22827. var _download_manager = __webpack_require__(43);
  22828. var _genericl10n = __webpack_require__(44);
  22829. var _generic_scripting = __webpack_require__(46);
  22830. function _interopRequireDefault(obj) {
  22831. return obj && obj.__esModule ? obj : {
  22832. "default": obj
  22833. };
  22834. }
  22835. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  22836. try {
  22837. var info = gen[key](arg);
  22838. var value = info.value;
  22839. } catch (error) {
  22840. reject(error);
  22841. return;
  22842. }
  22843. if (info.done) {
  22844. resolve(value);
  22845. } else {
  22846. Promise.resolve(value).then(_next, _throw);
  22847. }
  22848. }
  22849. function _asyncToGenerator(fn) {
  22850. return function() {
  22851. var self = this,
  22852. args = arguments;
  22853. return new Promise(function(resolve, reject) {
  22854. var gen = fn.apply(self, args);
  22855. function _next(value) {
  22856. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next",
  22857. value);
  22858. }
  22859. function _throw(err) {
  22860. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw",
  22861. err);
  22862. }
  22863. _next(undefined);
  22864. });
  22865. };
  22866. }
  22867. function _classCallCheck(instance, Constructor) {
  22868. if (!(instance instanceof Constructor)) {
  22869. throw new TypeError("Cannot call a class as a function");
  22870. }
  22871. }
  22872. function _defineProperties(target, props) {
  22873. for (var i = 0; i < props.length; i++) {
  22874. var descriptor = props[i];
  22875. descriptor.enumerable = descriptor.enumerable || false;
  22876. descriptor.configurable = true;
  22877. if ("value" in descriptor) descriptor.writable = true;
  22878. Object.defineProperty(target, descriptor.key, descriptor);
  22879. }
  22880. }
  22881. function _createClass(Constructor, protoProps, staticProps) {
  22882. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  22883. if (staticProps) _defineProperties(Constructor, staticProps);
  22884. Object.defineProperty(Constructor, "prototype", {
  22885. writable: false
  22886. });
  22887. return Constructor;
  22888. }
  22889. function _inherits(subClass, superClass) {
  22890. if (typeof superClass !== "function" && superClass !== null) {
  22891. throw new TypeError("Super expression must either be null or a function");
  22892. }
  22893. subClass.prototype = Object.create(superClass && superClass.prototype, {
  22894. constructor: {
  22895. value: subClass,
  22896. writable: true,
  22897. configurable: true
  22898. }
  22899. });
  22900. Object.defineProperty(subClass, "prototype", {
  22901. writable: false
  22902. });
  22903. if (superClass) _setPrototypeOf(subClass, superClass);
  22904. }
  22905. function _setPrototypeOf(o, p) {
  22906. _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  22907. o.__proto__ = p;
  22908. return o;
  22909. };
  22910. return _setPrototypeOf(o, p);
  22911. }
  22912. function _createSuper(Derived) {
  22913. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  22914. return function _createSuperInternal() {
  22915. var Super = _getPrototypeOf(Derived),
  22916. result;
  22917. if (hasNativeReflectConstruct) {
  22918. var NewTarget = _getPrototypeOf(this).constructor;
  22919. result = Reflect.construct(Super, arguments, NewTarget);
  22920. } else {
  22921. result = Super.apply(this, arguments);
  22922. }
  22923. return _possibleConstructorReturn(this, result);
  22924. };
  22925. }
  22926. function _possibleConstructorReturn(self, call) {
  22927. if (call && (_typeof(call) === "object" || typeof call === "function")) {
  22928. return call;
  22929. } else if (call !== void 0) {
  22930. throw new TypeError("Derived constructors may only return object or undefined");
  22931. }
  22932. return _assertThisInitialized(self);
  22933. }
  22934. function _assertThisInitialized(self) {
  22935. if (self === void 0) {
  22936. throw new ReferenceError(
  22937. "this hasn't been initialised - super() hasn't been called");
  22938. }
  22939. return self;
  22940. }
  22941. function _isNativeReflectConstruct() {
  22942. if (typeof Reflect === "undefined" || !Reflect.construct) return false;
  22943. if (Reflect.construct.sham) return false;
  22944. if (typeof Proxy === "function") return true;
  22945. try {
  22946. Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
  22947. return true;
  22948. } catch (e) {
  22949. return false;
  22950. }
  22951. }
  22952. function _getPrototypeOf(o) {
  22953. _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf :
  22954. function _getPrototypeOf(o) {
  22955. return o.__proto__ || Object.getPrototypeOf(o);
  22956. };
  22957. return _getPrototypeOf(o);
  22958. }
  22959. ;
  22960. var GenericCom = {};
  22961. exports.GenericCom = GenericCom;
  22962. var GenericPreferences = /*#__PURE__*/ function(_BasePreferences) {
  22963. _inherits(GenericPreferences, _BasePreferences);
  22964. var _super = _createSuper(GenericPreferences);
  22965. function GenericPreferences() {
  22966. _classCallCheck(this, GenericPreferences);
  22967. return _super.apply(this, arguments);
  22968. }
  22969. _createClass(GenericPreferences, [{
  22970. key: "_writeToStorage",
  22971. value: function() {
  22972. var _writeToStorage2 = _asyncToGenerator( /*#__PURE__*/
  22973. _regenerator["default"].mark(function _callee(
  22974. prefObj) {
  22975. return _regenerator["default"].wrap(
  22976. function _callee$(_context) {
  22977. while (1) {
  22978. switch (_context.prev =
  22979. _context.next) {
  22980. case 0:
  22981. localStorage
  22982. .setItem(
  22983. "pdfjs.preferences",
  22984. JSON
  22985. .stringify(
  22986. prefObj)
  22987. );
  22988. case 1:
  22989. case "end":
  22990. return _context
  22991. .stop();
  22992. }
  22993. }
  22994. }, _callee);
  22995. }));
  22996. function _writeToStorage(_x) {
  22997. return _writeToStorage2.apply(this, arguments);
  22998. }
  22999. return _writeToStorage;
  23000. }()
  23001. }, {
  23002. key: "_readFromStorage",
  23003. value: function() {
  23004. var _readFromStorage2 = _asyncToGenerator( /*#__PURE__*/
  23005. _regenerator["default"].mark(function _callee2(
  23006. prefObj) {
  23007. return _regenerator["default"].wrap(
  23008. function _callee2$(_context2) {
  23009. while (1) {
  23010. switch (_context2.prev =
  23011. _context2.next) {
  23012. case 0:
  23013. return _context2
  23014. .abrupt(
  23015. "return",
  23016. JSON.parse(
  23017. localStorage
  23018. .getItem(
  23019. "pdfjs.preferences"
  23020. )));
  23021. case 1:
  23022. case "end":
  23023. return _context2
  23024. .stop();
  23025. }
  23026. }
  23027. }, _callee2);
  23028. }));
  23029. function _readFromStorage(_x2) {
  23030. return _readFromStorage2.apply(this, arguments);
  23031. }
  23032. return _readFromStorage;
  23033. }()
  23034. }]);
  23035. return GenericPreferences;
  23036. }(_preferences.BasePreferences);
  23037. var GenericExternalServices = /*#__PURE__*/ function(_DefaultExternalServi) {
  23038. _inherits(GenericExternalServices, _DefaultExternalServi);
  23039. var _super2 = _createSuper(GenericExternalServices);
  23040. function GenericExternalServices() {
  23041. _classCallCheck(this, GenericExternalServices);
  23042. return _super2.apply(this, arguments);
  23043. }
  23044. _createClass(GenericExternalServices, null, [{
  23045. key: "createDownloadManager",
  23046. value: function createDownloadManager(options) {
  23047. return new _download_manager.DownloadManager();
  23048. }
  23049. }, {
  23050. key: "createPreferences",
  23051. value: function createPreferences() {
  23052. return new GenericPreferences();
  23053. }
  23054. }, {
  23055. key: "createL10n",
  23056. value: function createL10n(_ref) {
  23057. var _ref$locale = _ref.locale,
  23058. locale = _ref$locale === void 0 ? "en-US" : _ref$locale;
  23059. return new _genericl10n.GenericL10n(locale);
  23060. }
  23061. }, {
  23062. key: "createScripting",
  23063. value: function createScripting(_ref2) {
  23064. var sandboxBundleSrc = _ref2.sandboxBundleSrc;
  23065. return new _generic_scripting.GenericScripting(
  23066. sandboxBundleSrc);
  23067. }
  23068. }]);
  23069. return GenericExternalServices;
  23070. }(_app.DefaultExternalServices);
  23071. _app.PDFViewerApplication.externalServices = GenericExternalServices;
  23072. /***/
  23073. }),
  23074. /* 42 */
  23075. /***/
  23076. ((__unused_webpack_module, exports, __webpack_require__) => {
  23077. Object.defineProperty(exports, "__esModule", ({
  23078. value: true
  23079. }));
  23080. exports.BasePreferences = void 0;
  23081. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  23082. var _app_options = __webpack_require__(1);
  23083. function _interopRequireDefault(obj) {
  23084. return obj && obj.__esModule ? obj : {
  23085. "default": obj
  23086. };
  23087. }
  23088. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  23089. try {
  23090. var info = gen[key](arg);
  23091. var value = info.value;
  23092. } catch (error) {
  23093. reject(error);
  23094. return;
  23095. }
  23096. if (info.done) {
  23097. resolve(value);
  23098. } else {
  23099. Promise.resolve(value).then(_next, _throw);
  23100. }
  23101. }
  23102. function _asyncToGenerator(fn) {
  23103. return function() {
  23104. var self = this,
  23105. args = arguments;
  23106. return new Promise(function(resolve, reject) {
  23107. var gen = fn.apply(self, args);
  23108. function _next(value) {
  23109. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next",
  23110. value);
  23111. }
  23112. function _throw(err) {
  23113. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw",
  23114. err);
  23115. }
  23116. _next(undefined);
  23117. });
  23118. };
  23119. }
  23120. function _typeof(obj) {
  23121. "@babel/helpers - typeof";
  23122. return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ?
  23123. function(obj) {
  23124. return typeof obj;
  23125. } : function(obj) {
  23126. return obj && "function" == typeof Symbol && obj.constructor === Symbol &&
  23127. obj !== Symbol.prototype ? "symbol" : typeof obj;
  23128. }, _typeof(obj);
  23129. }
  23130. function _classCallCheck(instance, Constructor) {
  23131. if (!(instance instanceof Constructor)) {
  23132. throw new TypeError("Cannot call a class as a function");
  23133. }
  23134. }
  23135. function _defineProperties(target, props) {
  23136. for (var i = 0; i < props.length; i++) {
  23137. var descriptor = props[i];
  23138. descriptor.enumerable = descriptor.enumerable || false;
  23139. descriptor.configurable = true;
  23140. if ("value" in descriptor) descriptor.writable = true;
  23141. Object.defineProperty(target, descriptor.key, descriptor);
  23142. }
  23143. }
  23144. function _createClass(Constructor, protoProps, staticProps) {
  23145. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  23146. if (staticProps) _defineProperties(Constructor, staticProps);
  23147. Object.defineProperty(Constructor, "prototype", {
  23148. writable: false
  23149. });
  23150. return Constructor;
  23151. }
  23152. var BasePreferences = /*#__PURE__*/ function() {
  23153. function BasePreferences() {
  23154. var _this = this;
  23155. _classCallCheck(this, BasePreferences);
  23156. if (this.constructor === BasePreferences) {
  23157. throw new Error("Cannot initialize BasePreferences.");
  23158. }
  23159. Object.defineProperty(this, "defaults", {
  23160. value: Object.freeze({
  23161. "annotationMode": 2,
  23162. "cursorToolOnLoad": 0,
  23163. "defaultZoomValue": "",
  23164. "disablePageLabels": false,
  23165. "enablePermissions": false,
  23166. "enablePrintAutoRotate": true,
  23167. "enableScripting": true,
  23168. "externalLinkTarget": 0,
  23169. "historyUpdateUrl": false,
  23170. "ignoreDestinationZoom": false,
  23171. "pdfBugEnabled": false,
  23172. "renderer": "canvas",
  23173. "sidebarViewOnLoad": -1,
  23174. "scrollModeOnLoad": -1,
  23175. "spreadModeOnLoad": -1,
  23176. "textLayerMode": 1,
  23177. "useOnlyCssZoom": false,
  23178. "viewerCssTheme": 0,
  23179. "viewOnLoad": 0,
  23180. "disableAutoFetch": false,
  23181. "disableFontFace": false,
  23182. "disableRange": false,
  23183. "disableStream": false,
  23184. "enableXfa": true
  23185. }),
  23186. writable: false,
  23187. enumerable: true,
  23188. configurable: false
  23189. });
  23190. this.prefs = Object.create(null);
  23191. this._initializedPromise = this._readFromStorage(this.defaults).then(function(
  23192. prefs) {
  23193. for (var name in _this.defaults) {
  23194. var prefValue = prefs === null || prefs === void 0 ? void 0 :
  23195. prefs[name];
  23196. if (_typeof(prefValue) === _typeof(_this.defaults[name])) {
  23197. _this.prefs[name] = prefValue;
  23198. }
  23199. }
  23200. });
  23201. }
  23202. _createClass(BasePreferences, [{
  23203. key: "_writeToStorage",
  23204. value: function() {
  23205. var _writeToStorage2 = _asyncToGenerator( /*#__PURE__*/
  23206. _regenerator["default"].mark(function _callee(
  23207. prefObj) {
  23208. return _regenerator["default"].wrap(
  23209. function _callee$(_context) {
  23210. while (1) {
  23211. switch (_context.prev =
  23212. _context.next) {
  23213. case 0:
  23214. throw new Error(
  23215. "Not implemented: _writeToStorage"
  23216. );
  23217. case 1:
  23218. case "end":
  23219. return _context
  23220. .stop();
  23221. }
  23222. }
  23223. }, _callee);
  23224. }));
  23225. function _writeToStorage(_x) {
  23226. return _writeToStorage2.apply(this, arguments);
  23227. }
  23228. return _writeToStorage;
  23229. }()
  23230. }, {
  23231. key: "_readFromStorage",
  23232. value: function() {
  23233. var _readFromStorage2 = _asyncToGenerator( /*#__PURE__*/
  23234. _regenerator["default"].mark(function _callee2(
  23235. prefObj) {
  23236. return _regenerator["default"].wrap(
  23237. function _callee2$(_context2) {
  23238. while (1) {
  23239. switch (_context2.prev =
  23240. _context2.next) {
  23241. case 0:
  23242. throw new Error(
  23243. "Not implemented: _readFromStorage"
  23244. );
  23245. case 1:
  23246. case "end":
  23247. return _context2
  23248. .stop();
  23249. }
  23250. }
  23251. }, _callee2);
  23252. }));
  23253. function _readFromStorage(_x2) {
  23254. return _readFromStorage2.apply(this, arguments);
  23255. }
  23256. return _readFromStorage;
  23257. }()
  23258. }, {
  23259. key: "reset",
  23260. value: function() {
  23261. var _reset = _asyncToGenerator( /*#__PURE__*/ _regenerator[
  23262. "default"].mark(function _callee3() {
  23263. return _regenerator["default"].wrap(
  23264. function _callee3$(_context3) {
  23265. while (1) {
  23266. switch (_context3.prev =
  23267. _context3.next) {
  23268. case 0:
  23269. _context3.next = 2;
  23270. return this
  23271. ._initializedPromise;
  23272. case 2:
  23273. this.prefs = Object
  23274. .create(null);
  23275. return _context3
  23276. .abrupt(
  23277. "return",
  23278. this
  23279. ._writeToStorage(
  23280. this
  23281. .defaults
  23282. ));
  23283. case 4:
  23284. case "end":
  23285. return _context3
  23286. .stop();
  23287. }
  23288. }
  23289. }, _callee3, this);
  23290. }));
  23291. function reset() {
  23292. return _reset.apply(this, arguments);
  23293. }
  23294. return reset;
  23295. }()
  23296. }, {
  23297. key: "set",
  23298. value: function() {
  23299. var _set = _asyncToGenerator( /*#__PURE__*/ _regenerator[
  23300. "default"].mark(function _callee4(name, value) {
  23301. var defaultValue, valueType, defaultType;
  23302. return _regenerator["default"].wrap(
  23303. function _callee4$(_context4) {
  23304. while (1) {
  23305. switch (_context4.prev =
  23306. _context4.next) {
  23307. case 0:
  23308. _context4.next = 2;
  23309. return this
  23310. ._initializedPromise;
  23311. case 2:
  23312. defaultValue = this
  23313. .defaults[name];
  23314. if (!(defaultValue ===
  23315. undefined
  23316. )) {
  23317. _context4.next =
  23318. 7;
  23319. break;
  23320. }
  23321. throw new Error(
  23322. "Set preference: \""
  23323. .concat(
  23324. name,
  23325. "\" is undefined."
  23326. ));
  23327. case 7:
  23328. if (!(value ===
  23329. undefined
  23330. )) {
  23331. _context4.next =
  23332. 9;
  23333. break;
  23334. }
  23335. throw new Error(
  23336. "Set preference: no value is specified."
  23337. );
  23338. case 9:
  23339. valueType = _typeof(
  23340. value);
  23341. defaultType =
  23342. _typeof(
  23343. defaultValue
  23344. );
  23345. if (!(valueType !==
  23346. defaultType
  23347. )) {
  23348. _context4.next =
  23349. 19;
  23350. break;
  23351. }
  23352. if (!(valueType ===
  23353. "number" &&
  23354. defaultType ===
  23355. "string")) {
  23356. _context4.next =
  23357. 16;
  23358. break;
  23359. }
  23360. value = value
  23361. .toString();
  23362. _context4.next = 17;
  23363. break;
  23364. case 16:
  23365. throw new Error(
  23366. "Set preference: \""
  23367. .concat(
  23368. value,
  23369. "\" is a "
  23370. )
  23371. .concat(
  23372. valueType,
  23373. ", expected a "
  23374. )
  23375. .concat(
  23376. defaultType,
  23377. "."));
  23378. case 17:
  23379. _context4.next = 21;
  23380. break;
  23381. case 19:
  23382. if (!(valueType ===
  23383. "number" &&
  23384. !Number
  23385. .isInteger(
  23386. value)
  23387. )) {
  23388. _context4.next =
  23389. 21;
  23390. break;
  23391. }
  23392. throw new Error(
  23393. "Set preference: \""
  23394. .concat(
  23395. value,
  23396. "\" must be an integer."
  23397. ));
  23398. case 21:
  23399. this.prefs[name] =
  23400. value;
  23401. return _context4
  23402. .abrupt(
  23403. "return",
  23404. this
  23405. ._writeToStorage(
  23406. this
  23407. .prefs)
  23408. );
  23409. case 23:
  23410. case "end":
  23411. return _context4
  23412. .stop();
  23413. }
  23414. }
  23415. }, _callee4, this);
  23416. }));
  23417. function set(_x3, _x4) {
  23418. return _set.apply(this, arguments);
  23419. }
  23420. return set;
  23421. }()
  23422. }, {
  23423. key: "get",
  23424. value: function() {
  23425. var _get = _asyncToGenerator( /*#__PURE__*/ _regenerator[
  23426. "default"].mark(function _callee5(name) {
  23427. var defaultValue, prefValue;
  23428. return _regenerator["default"].wrap(
  23429. function _callee5$(_context5) {
  23430. while (1) {
  23431. switch (_context5.prev =
  23432. _context5.next) {
  23433. case 0:
  23434. _context5.next = 2;
  23435. return this
  23436. ._initializedPromise;
  23437. case 2:
  23438. defaultValue = this
  23439. .defaults[name],
  23440. prefValue = this
  23441. .prefs[name];
  23442. if (!(defaultValue ===
  23443. undefined
  23444. )) {
  23445. _context5.next =
  23446. 5;
  23447. break;
  23448. }
  23449. throw new Error(
  23450. "Get preference: \""
  23451. .concat(
  23452. name,
  23453. "\" is undefined."
  23454. ));
  23455. case 5:
  23456. return _context5
  23457. .abrupt(
  23458. "return",
  23459. prefValue !==
  23460. undefined ?
  23461. prefValue :
  23462. defaultValue
  23463. );
  23464. case 6:
  23465. case "end":
  23466. return _context5
  23467. .stop();
  23468. }
  23469. }
  23470. }, _callee5, this);
  23471. }));
  23472. function get(_x5) {
  23473. return _get.apply(this, arguments);
  23474. }
  23475. return get;
  23476. }()
  23477. }, {
  23478. key: "getAll",
  23479. value: function() {
  23480. var _getAll = _asyncToGenerator( /*#__PURE__*/ _regenerator[
  23481. "default"].mark(function _callee6() {
  23482. var obj, name, prefValue;
  23483. return _regenerator["default"].wrap(
  23484. function _callee6$(_context6) {
  23485. while (1) {
  23486. switch (_context6.prev =
  23487. _context6.next) {
  23488. case 0:
  23489. _context6.next = 2;
  23490. return this
  23491. ._initializedPromise;
  23492. case 2:
  23493. obj = Object.create(
  23494. null);
  23495. for (name in this
  23496. .defaults) {
  23497. prefValue = this
  23498. .prefs[
  23499. name];
  23500. obj[name] =
  23501. prefValue !==
  23502. undefined ?
  23503. prefValue :
  23504. this
  23505. .defaults[
  23506. name];
  23507. }
  23508. return _context6
  23509. .abrupt(
  23510. "return",
  23511. obj);
  23512. case 5:
  23513. case "end":
  23514. return _context6
  23515. .stop();
  23516. }
  23517. }
  23518. }, _callee6, this);
  23519. }));
  23520. function getAll() {
  23521. return _getAll.apply(this, arguments);
  23522. }
  23523. return getAll;
  23524. }()
  23525. }]);
  23526. return BasePreferences;
  23527. }();
  23528. exports.BasePreferences = BasePreferences;
  23529. /***/
  23530. }),
  23531. /* 43 */
  23532. /***/
  23533. ((__unused_webpack_module, exports, __webpack_require__) => {
  23534. Object.defineProperty(exports, "__esModule", ({
  23535. value: true
  23536. }));
  23537. exports.DownloadManager = void 0;
  23538. var _pdfjsLib = __webpack_require__(7);
  23539. function _classCallCheck(instance, Constructor) {
  23540. if (!(instance instanceof Constructor)) {
  23541. throw new TypeError("Cannot call a class as a function");
  23542. }
  23543. }
  23544. function _defineProperties(target, props) {
  23545. for (var i = 0; i < props.length; i++) {
  23546. var descriptor = props[i];
  23547. descriptor.enumerable = descriptor.enumerable || false;
  23548. descriptor.configurable = true;
  23549. if ("value" in descriptor) descriptor.writable = true;
  23550. Object.defineProperty(target, descriptor.key, descriptor);
  23551. }
  23552. }
  23553. function _createClass(Constructor, protoProps, staticProps) {
  23554. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  23555. if (staticProps) _defineProperties(Constructor, staticProps);
  23556. Object.defineProperty(Constructor, "prototype", {
  23557. writable: false
  23558. });
  23559. return Constructor;
  23560. }
  23561. ;
  23562. function _download(blobUrl, filename) {
  23563. var a = document.createElement("a");
  23564. if (!a.click) {
  23565. throw new Error('DownloadManager: "a.click()" is not supported.');
  23566. }
  23567. a.href = blobUrl;
  23568. a.target = "_parent";
  23569. if ("download" in a) {
  23570. a.download = filename;
  23571. }
  23572. (document.body || document.documentElement).appendChild(a);
  23573. a.click();
  23574. a.remove();
  23575. }
  23576. var DownloadManager = /*#__PURE__*/ function() {
  23577. function DownloadManager() {
  23578. _classCallCheck(this, DownloadManager);
  23579. this._openBlobUrls = new WeakMap();
  23580. }
  23581. _createClass(DownloadManager, [{
  23582. key: "downloadUrl",
  23583. value: function downloadUrl(url, filename) {
  23584. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url,
  23585. "http://example.com")) {
  23586. console.error("downloadUrl - not a valid URL: ".concat(
  23587. url));
  23588. return;
  23589. }
  23590. _download(url + "#pdfjs.action=download", filename);
  23591. }
  23592. }, {
  23593. key: "downloadData",
  23594. value: function downloadData(data, filename, contentType) {
  23595. var blobUrl = URL.createObjectURL(new Blob([data], {
  23596. type: contentType
  23597. }));
  23598. _download(blobUrl, filename);
  23599. }
  23600. }, {
  23601. key: "openOrDownloadData",
  23602. value: function openOrDownloadData(element, data, filename) {
  23603. var isPdfData = (0, _pdfjsLib.isPdfFile)(filename);
  23604. var contentType = isPdfData ? "application/pdf" : "";
  23605. if (isPdfData) {
  23606. var blobUrl = this._openBlobUrls.get(element);
  23607. if (!blobUrl) {
  23608. blobUrl = URL.createObjectURL(new Blob([data], {
  23609. type: contentType
  23610. }));
  23611. this._openBlobUrls.set(element, blobUrl);
  23612. }
  23613. var viewerUrl;
  23614. viewerUrl = "?file=" + encodeURIComponent(blobUrl +
  23615. "#" + filename);
  23616. try {
  23617. window.open(viewerUrl);
  23618. return true;
  23619. } catch (ex) {
  23620. console.error("openOrDownloadData: ".concat(ex));
  23621. URL.revokeObjectURL(blobUrl);
  23622. this._openBlobUrls["delete"](element);
  23623. }
  23624. }
  23625. this.downloadData(data, filename, contentType);
  23626. return false;
  23627. }
  23628. }, {
  23629. key: "download",
  23630. value: function download(blob, url, filename) {
  23631. var sourceEventType = arguments.length > 3 && arguments[
  23632. 3] !== undefined ? arguments[3] : "download";
  23633. var blobUrl = URL.createObjectURL(blob);
  23634. _download(blobUrl, filename);
  23635. }
  23636. }]);
  23637. return DownloadManager;
  23638. }();
  23639. exports.DownloadManager = DownloadManager;
  23640. /***/
  23641. }),
  23642. /* 44 */
  23643. /***/
  23644. ((__unused_webpack_module, exports, __webpack_require__) => {
  23645. Object.defineProperty(exports, "__esModule", ({
  23646. value: true
  23647. }));
  23648. exports.GenericL10n = void 0;
  23649. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  23650. __webpack_require__(45);
  23651. var _l10n_utils = __webpack_require__(32);
  23652. function _interopRequireDefault(obj) {
  23653. return obj && obj.__esModule ? obj : {
  23654. "default": obj
  23655. };
  23656. }
  23657. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  23658. try {
  23659. var info = gen[key](arg);
  23660. var value = info.value;
  23661. } catch (error) {
  23662. reject(error);
  23663. return;
  23664. }
  23665. if (info.done) {
  23666. resolve(value);
  23667. } else {
  23668. Promise.resolve(value).then(_next, _throw);
  23669. }
  23670. }
  23671. function _asyncToGenerator(fn) {
  23672. return function() {
  23673. var self = this,
  23674. args = arguments;
  23675. return new Promise(function(resolve, reject) {
  23676. var gen = fn.apply(self, args);
  23677. function _next(value) {
  23678. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next",
  23679. value);
  23680. }
  23681. function _throw(err) {
  23682. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw",
  23683. err);
  23684. }
  23685. _next(undefined);
  23686. });
  23687. };
  23688. }
  23689. function _classCallCheck(instance, Constructor) {
  23690. if (!(instance instanceof Constructor)) {
  23691. throw new TypeError("Cannot call a class as a function");
  23692. }
  23693. }
  23694. function _defineProperties(target, props) {
  23695. for (var i = 0; i < props.length; i++) {
  23696. var descriptor = props[i];
  23697. descriptor.enumerable = descriptor.enumerable || false;
  23698. descriptor.configurable = true;
  23699. if ("value" in descriptor) descriptor.writable = true;
  23700. Object.defineProperty(target, descriptor.key, descriptor);
  23701. }
  23702. }
  23703. function _createClass(Constructor, protoProps, staticProps) {
  23704. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  23705. if (staticProps) _defineProperties(Constructor, staticProps);
  23706. Object.defineProperty(Constructor, "prototype", {
  23707. writable: false
  23708. });
  23709. return Constructor;
  23710. }
  23711. var webL10n = document.webL10n;
  23712. var GenericL10n = /*#__PURE__*/ function() {
  23713. function GenericL10n(lang) {
  23714. _classCallCheck(this, GenericL10n);
  23715. this._lang = lang;
  23716. this._ready = new Promise(function(resolve, reject) {
  23717. webL10n.setLanguage((0, _l10n_utils.fixupLangCode)(lang),
  23718. function() {
  23719. resolve(webL10n);
  23720. });
  23721. });
  23722. }
  23723. _createClass(GenericL10n, [{
  23724. key: "getLanguage",
  23725. value: function() {
  23726. var _getLanguage = _asyncToGenerator( /*#__PURE__*/
  23727. _regenerator["default"].mark(function _callee() {
  23728. var l10n;
  23729. return _regenerator["default"].wrap(
  23730. function _callee$(_context) {
  23731. while (1) {
  23732. switch (_context.prev =
  23733. _context.next) {
  23734. case 0:
  23735. _context.next = 2;
  23736. return this._ready;
  23737. case 2:
  23738. l10n = _context
  23739. .sent;
  23740. return _context
  23741. .abrupt(
  23742. "return",
  23743. l10n
  23744. .getLanguage()
  23745. );
  23746. case 4:
  23747. case "end":
  23748. return _context
  23749. .stop();
  23750. }
  23751. }
  23752. }, _callee, this);
  23753. }));
  23754. function getLanguage() {
  23755. return _getLanguage.apply(this, arguments);
  23756. }
  23757. return getLanguage;
  23758. }()
  23759. }, {
  23760. key: "getDirection",
  23761. value: function() {
  23762. var _getDirection = _asyncToGenerator( /*#__PURE__*/
  23763. _regenerator["default"].mark(function _callee2() {
  23764. var l10n;
  23765. return _regenerator["default"].wrap(
  23766. function _callee2$(_context2) {
  23767. while (1) {
  23768. switch (_context2.prev =
  23769. _context2.next) {
  23770. case 0:
  23771. _context2.next = 2;
  23772. return this._ready;
  23773. case 2:
  23774. l10n = _context2
  23775. .sent;
  23776. return _context2
  23777. .abrupt(
  23778. "return",
  23779. l10n
  23780. .getDirection()
  23781. );
  23782. case 4:
  23783. case "end":
  23784. return _context2
  23785. .stop();
  23786. }
  23787. }
  23788. }, _callee2, this);
  23789. }));
  23790. function getDirection() {
  23791. return _getDirection.apply(this, arguments);
  23792. }
  23793. return getDirection;
  23794. }()
  23795. }, {
  23796. key: "get",
  23797. value: function() {
  23798. var _get = _asyncToGenerator( /*#__PURE__*/ _regenerator[
  23799. "default"].mark(function _callee3(key) {
  23800. var args,
  23801. fallback,
  23802. l10n,
  23803. _args3 = arguments;
  23804. return _regenerator["default"].wrap(
  23805. function _callee3$(_context3) {
  23806. while (1) {
  23807. switch (_context3.prev =
  23808. _context3.next) {
  23809. case 0:
  23810. args = _args3
  23811. .length > 1 &&
  23812. _args3[1] !==
  23813. undefined ?
  23814. _args3[1] :
  23815. null;
  23816. fallback = _args3
  23817. .length > 2 &&
  23818. _args3[2] !==
  23819. undefined ?
  23820. _args3[2] : (0,
  23821. _l10n_utils
  23822. .getL10nFallback
  23823. )(key,
  23824. args);
  23825. _context3.next = 4;
  23826. return this._ready;
  23827. case 4:
  23828. l10n = _context3
  23829. .sent;
  23830. return _context3
  23831. .abrupt(
  23832. "return",
  23833. l10n.get(
  23834. key,
  23835. args,
  23836. fallback
  23837. ));
  23838. case 6:
  23839. case "end":
  23840. return _context3
  23841. .stop();
  23842. }
  23843. }
  23844. }, _callee3, this);
  23845. }));
  23846. function get(_x) {
  23847. return _get.apply(this, arguments);
  23848. }
  23849. return get;
  23850. }()
  23851. }, {
  23852. key: "translate",
  23853. value: function() {
  23854. var _translate = _asyncToGenerator( /*#__PURE__*/
  23855. _regenerator["default"].mark(function _callee4(
  23856. element) {
  23857. var l10n;
  23858. return _regenerator["default"].wrap(
  23859. function _callee4$(_context4) {
  23860. while (1) {
  23861. switch (_context4.prev =
  23862. _context4.next) {
  23863. case 0:
  23864. _context4.next = 2;
  23865. return this._ready;
  23866. case 2:
  23867. l10n = _context4
  23868. .sent;
  23869. return _context4
  23870. .abrupt(
  23871. "return",
  23872. l10n
  23873. .translate(
  23874. element)
  23875. );
  23876. case 4:
  23877. case "end":
  23878. return _context4
  23879. .stop();
  23880. }
  23881. }
  23882. }, _callee4, this);
  23883. }));
  23884. function translate(_x2) {
  23885. return _translate.apply(this, arguments);
  23886. }
  23887. return translate;
  23888. }()
  23889. }]);
  23890. return GenericL10n;
  23891. }();
  23892. exports.GenericL10n = GenericL10n;
  23893. /***/
  23894. }),
  23895. /* 45 */
  23896. /***/
  23897. (() => {
  23898. document.webL10n = function(window, document, undefined) {
  23899. var gL10nData = {};
  23900. var gTextData = '';
  23901. var gTextProp = 'textContent';
  23902. var gLanguage = '';
  23903. var gMacros = {};
  23904. var gReadyState = 'loading';
  23905. var gAsyncResourceLoading = true;
  23906. function getL10nResourceLinks() {
  23907. return document.querySelectorAll('link[type="application/l10n"]');
  23908. }
  23909. function getL10nDictionary() {
  23910. var script = document.querySelector('script[type="application/l10n"]');
  23911. return script ? JSON.parse(script.innerHTML) : null;
  23912. }
  23913. function getTranslatableChildren(element) {
  23914. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  23915. }
  23916. function getL10nAttributes(element) {
  23917. if (!element) return {};
  23918. var l10nId = element.getAttribute('data-l10n-id');
  23919. var l10nArgs = element.getAttribute('data-l10n-args');
  23920. var args = {};
  23921. if (l10nArgs) {
  23922. try {
  23923. args = JSON.parse(l10nArgs);
  23924. } catch (e) {
  23925. console.warn('could not parse arguments for #' + l10nId);
  23926. }
  23927. }
  23928. return {
  23929. id: l10nId,
  23930. args: args
  23931. };
  23932. }
  23933. function xhrLoadText(url, onSuccess, onFailure) {
  23934. onSuccess = onSuccess || function _onSuccess(data) {};
  23935. onFailure = onFailure || function _onFailure() {};
  23936. var xhr = new XMLHttpRequest();
  23937. xhr.open('GET', url, gAsyncResourceLoading);
  23938. if (xhr.overrideMimeType) {
  23939. xhr.overrideMimeType('text/plain; charset=utf-8');
  23940. }
  23941. xhr.onreadystatechange = function() {
  23942. if (xhr.readyState == 4) {
  23943. if (xhr.status == 200 || xhr.status === 0) {
  23944. onSuccess(xhr.responseText);
  23945. } else {
  23946. onFailure();
  23947. }
  23948. }
  23949. };
  23950. xhr.onerror = onFailure;
  23951. xhr.ontimeout = onFailure;
  23952. try {
  23953. xhr.send(null);
  23954. } catch (e) {
  23955. onFailure();
  23956. }
  23957. }
  23958. function parseResource(href, lang, successCallback, failureCallback) {
  23959. var baseURL = href.replace(/[^\/]*$/, '') || './';
  23960. function evalString(text) {
  23961. if (text.lastIndexOf('\\') < 0) return text;
  23962. return text.replace(/\\\\/g, '\\').replace(/\\n/g, '\n').replace(/\\r/g,
  23963. '\r').replace(/\\t/g, '\t').replace(/\\b/g, '\b').replace(/\\f/g,
  23964. '\f').replace(/\\{/g, '{').replace(/\\}/g, '}').replace(/\\"/g, '"')
  23965. .replace(/\\'/g, "'");
  23966. }
  23967. function parseProperties(text, parsedPropertiesCallback) {
  23968. var dictionary = {};
  23969. var reBlank = /^\s*|\s*$/;
  23970. var reComment = /^\s*#|^\s*$/;
  23971. var reSection = /^\s*\[(.*)\]\s*$/;
  23972. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  23973. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  23974. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  23975. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  23976. var currentLang = '*';
  23977. var genericLang = lang.split('-', 1)[0];
  23978. var skipLang = false;
  23979. var match = '';
  23980. function nextEntry() {
  23981. while (true) {
  23982. if (!entries.length) {
  23983. parsedRawLinesCallback();
  23984. return;
  23985. }
  23986. var line = entries.shift();
  23987. if (reComment.test(line)) continue;
  23988. if (extendedSyntax) {
  23989. match = reSection.exec(line);
  23990. if (match) {
  23991. currentLang = match[1].toLowerCase();
  23992. skipLang = currentLang !== '*' && currentLang !==
  23993. lang && currentLang !== genericLang;
  23994. continue;
  23995. } else if (skipLang) {
  23996. continue;
  23997. }
  23998. match = reImport.exec(line);
  23999. if (match) {
  24000. loadImport(baseURL + match[1], nextEntry);
  24001. return;
  24002. }
  24003. }
  24004. var tmp = line.match(reSplit);
  24005. if (tmp && tmp.length == 3) {
  24006. dictionary[tmp[1]] = evalString(tmp[2]);
  24007. }
  24008. }
  24009. }
  24010. nextEntry();
  24011. }
  24012. function loadImport(url, callback) {
  24013. xhrLoadText(url, function(content) {
  24014. parseRawLines(content, false, callback);
  24015. }, function() {
  24016. console.warn(url + ' not found.');
  24017. callback();
  24018. });
  24019. }
  24020. parseRawLines(text, true, function() {
  24021. parsedPropertiesCallback(dictionary);
  24022. });
  24023. }
  24024. xhrLoadText(href, function(response) {
  24025. gTextData += response;
  24026. parseProperties(response, function(data) {
  24027. for (var key in data) {
  24028. var id,
  24029. prop,
  24030. index = key.lastIndexOf('.');
  24031. if (index > 0) {
  24032. id = key.substring(0, index);
  24033. prop = key.substring(index + 1);
  24034. } else {
  24035. id = key;
  24036. prop = gTextProp;
  24037. }
  24038. if (!gL10nData[id]) {
  24039. gL10nData[id] = {};
  24040. }
  24041. gL10nData[id][prop] = data[key];
  24042. }
  24043. if (successCallback) {
  24044. successCallback();
  24045. }
  24046. });
  24047. }, failureCallback);
  24048. }
  24049. function loadLocale(lang, callback) {
  24050. if (lang) {
  24051. lang = lang.toLowerCase();
  24052. }
  24053. callback = callback || function _callback() {};
  24054. clear();
  24055. gLanguage = lang;
  24056. var langLinks = getL10nResourceLinks();
  24057. var langCount = langLinks.length;
  24058. if (langCount === 0) {
  24059. var dict = getL10nDictionary();
  24060. if (dict && dict.locales && dict.default_locale) {
  24061. console.log('using the embedded JSON directory, early way out');
  24062. gL10nData = dict.locales[lang];
  24063. if (!gL10nData) {
  24064. var defaultLocale = dict.default_locale.toLowerCase();
  24065. for (var anyCaseLang in dict.locales) {
  24066. anyCaseLang = anyCaseLang.toLowerCase();
  24067. if (anyCaseLang === lang) {
  24068. gL10nData = dict.locales[lang];
  24069. break;
  24070. } else if (anyCaseLang === defaultLocale) {
  24071. gL10nData = dict.locales[defaultLocale];
  24072. }
  24073. }
  24074. }
  24075. callback();
  24076. } else {
  24077. console.log('no resource to load, early way out');
  24078. }
  24079. gReadyState = 'complete';
  24080. return;
  24081. }
  24082. var onResourceLoaded = null;
  24083. var gResourceCount = 0;
  24084. onResourceLoaded = function onResourceLoaded() {
  24085. gResourceCount++;
  24086. if (gResourceCount >= langCount) {
  24087. callback();
  24088. gReadyState = 'complete';
  24089. }
  24090. };
  24091. function L10nResourceLink(link) {
  24092. var href = link.href;
  24093. this.load = function(lang, callback) {
  24094. parseResource(href, lang, callback, function() {
  24095. console.warn(href + ' not found.');
  24096. console.warn('"' + lang + '" resource not found');
  24097. gLanguage = '';
  24098. callback();
  24099. });
  24100. };
  24101. }
  24102. for (var i = 0; i < langCount; i++) {
  24103. var resource = new L10nResourceLink(langLinks[i]);
  24104. resource.load(lang, onResourceLoaded);
  24105. }
  24106. }
  24107. function clear() {
  24108. gL10nData = {};
  24109. gTextData = '';
  24110. gLanguage = '';
  24111. }
  24112. function getPluralRules(lang) {
  24113. var locales2rules = {
  24114. 'af': 3,
  24115. 'ak': 4,
  24116. 'am': 4,
  24117. 'ar': 1,
  24118. 'asa': 3,
  24119. 'az': 0,
  24120. 'be': 11,
  24121. 'bem': 3,
  24122. 'bez': 3,
  24123. 'bg': 3,
  24124. 'bh': 4,
  24125. 'bm': 0,
  24126. 'bn': 3,
  24127. 'bo': 0,
  24128. 'br': 20,
  24129. 'brx': 3,
  24130. 'bs': 11,
  24131. 'ca': 3,
  24132. 'cgg': 3,
  24133. 'chr': 3,
  24134. 'cs': 12,
  24135. 'cy': 17,
  24136. 'da': 3,
  24137. 'de': 3,
  24138. 'dv': 3,
  24139. 'dz': 0,
  24140. 'ee': 3,
  24141. 'el': 3,
  24142. 'en': 3,
  24143. 'eo': 3,
  24144. 'es': 3,
  24145. 'et': 3,
  24146. 'eu': 3,
  24147. 'fa': 0,
  24148. 'ff': 5,
  24149. 'fi': 3,
  24150. 'fil': 4,
  24151. 'fo': 3,
  24152. 'fr': 5,
  24153. 'fur': 3,
  24154. 'fy': 3,
  24155. 'ga': 8,
  24156. 'gd': 24,
  24157. 'gl': 3,
  24158. 'gsw': 3,
  24159. 'gu': 3,
  24160. 'guw': 4,
  24161. 'gv': 23,
  24162. 'ha': 3,
  24163. 'haw': 3,
  24164. 'he': 2,
  24165. 'hi': 4,
  24166. 'hr': 11,
  24167. 'hu': 0,
  24168. 'id': 0,
  24169. 'ig': 0,
  24170. 'ii': 0,
  24171. 'is': 3,
  24172. 'it': 3,
  24173. 'iu': 7,
  24174. 'ja': 0,
  24175. 'jmc': 3,
  24176. 'jv': 0,
  24177. 'ka': 0,
  24178. 'kab': 5,
  24179. 'kaj': 3,
  24180. 'kcg': 3,
  24181. 'kde': 0,
  24182. 'kea': 0,
  24183. 'kk': 3,
  24184. 'kl': 3,
  24185. 'km': 0,
  24186. 'kn': 0,
  24187. 'ko': 0,
  24188. 'ksb': 3,
  24189. 'ksh': 21,
  24190. 'ku': 3,
  24191. 'kw': 7,
  24192. 'lag': 18,
  24193. 'lb': 3,
  24194. 'lg': 3,
  24195. 'ln': 4,
  24196. 'lo': 0,
  24197. 'lt': 10,
  24198. 'lv': 6,
  24199. 'mas': 3,
  24200. 'mg': 4,
  24201. 'mk': 16,
  24202. 'ml': 3,
  24203. 'mn': 3,
  24204. 'mo': 9,
  24205. 'mr': 3,
  24206. 'ms': 0,
  24207. 'mt': 15,
  24208. 'my': 0,
  24209. 'nah': 3,
  24210. 'naq': 7,
  24211. 'nb': 3,
  24212. 'nd': 3,
  24213. 'ne': 3,
  24214. 'nl': 3,
  24215. 'nn': 3,
  24216. 'no': 3,
  24217. 'nr': 3,
  24218. 'nso': 4,
  24219. 'ny': 3,
  24220. 'nyn': 3,
  24221. 'om': 3,
  24222. 'or': 3,
  24223. 'pa': 3,
  24224. 'pap': 3,
  24225. 'pl': 13,
  24226. 'ps': 3,
  24227. 'pt': 3,
  24228. 'rm': 3,
  24229. 'ro': 9,
  24230. 'rof': 3,
  24231. 'ru': 11,
  24232. 'rwk': 3,
  24233. 'sah': 0,
  24234. 'saq': 3,
  24235. 'se': 7,
  24236. 'seh': 3,
  24237. 'ses': 0,
  24238. 'sg': 0,
  24239. 'sh': 11,
  24240. 'shi': 19,
  24241. 'sk': 12,
  24242. 'sl': 14,
  24243. 'sma': 7,
  24244. 'smi': 7,
  24245. 'smj': 7,
  24246. 'smn': 7,
  24247. 'sms': 7,
  24248. 'sn': 3,
  24249. 'so': 3,
  24250. 'sq': 3,
  24251. 'sr': 11,
  24252. 'ss': 3,
  24253. 'ssy': 3,
  24254. 'st': 3,
  24255. 'sv': 3,
  24256. 'sw': 3,
  24257. 'syr': 3,
  24258. 'ta': 3,
  24259. 'te': 3,
  24260. 'teo': 3,
  24261. 'th': 0,
  24262. 'ti': 4,
  24263. 'tig': 3,
  24264. 'tk': 3,
  24265. 'tl': 4,
  24266. 'tn': 3,
  24267. 'to': 0,
  24268. 'tr': 0,
  24269. 'ts': 3,
  24270. 'tzm': 22,
  24271. 'uk': 11,
  24272. 'ur': 3,
  24273. 've': 3,
  24274. 'vi': 0,
  24275. 'vun': 3,
  24276. 'wa': 4,
  24277. 'wae': 3,
  24278. 'wo': 0,
  24279. 'xh': 3,
  24280. 'xog': 3,
  24281. 'yo': 0,
  24282. 'zh': 0,
  24283. 'zu': 3
  24284. };
  24285. function isIn(n, list) {
  24286. return list.indexOf(n) !== -1;
  24287. }
  24288. function isBetween(n, start, end) {
  24289. return start <= n && n <= end;
  24290. }
  24291. var pluralRules = {
  24292. '0': function _(n) {
  24293. return 'other';
  24294. },
  24295. '1': function _(n) {
  24296. if (isBetween(n % 100, 3, 10)) return 'few';
  24297. if (n === 0) return 'zero';
  24298. if (isBetween(n % 100, 11, 99)) return 'many';
  24299. if (n == 2) return 'two';
  24300. if (n == 1) return 'one';
  24301. return 'other';
  24302. },
  24303. '2': function _(n) {
  24304. if (n !== 0 && n % 10 === 0) return 'many';
  24305. if (n == 2) return 'two';
  24306. if (n == 1) return 'one';
  24307. return 'other';
  24308. },
  24309. '3': function _(n) {
  24310. if (n == 1) return 'one';
  24311. return 'other';
  24312. },
  24313. '4': function _(n) {
  24314. if (isBetween(n, 0, 1)) return 'one';
  24315. return 'other';
  24316. },
  24317. '5': function _(n) {
  24318. if (isBetween(n, 0, 2) && n != 2) return 'one';
  24319. return 'other';
  24320. },
  24321. '6': function _(n) {
  24322. if (n === 0) return 'zero';
  24323. if (n % 10 == 1 && n % 100 != 11) return 'one';
  24324. return 'other';
  24325. },
  24326. '7': function _(n) {
  24327. if (n == 2) return 'two';
  24328. if (n == 1) return 'one';
  24329. return 'other';
  24330. },
  24331. '8': function _(n) {
  24332. if (isBetween(n, 3, 6)) return 'few';
  24333. if (isBetween(n, 7, 10)) return 'many';
  24334. if (n == 2) return 'two';
  24335. if (n == 1) return 'one';
  24336. return 'other';
  24337. },
  24338. '9': function _(n) {
  24339. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19))
  24340. return 'few';
  24341. if (n == 1) return 'one';
  24342. return 'other';
  24343. },
  24344. '10': function _(n) {
  24345. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19))
  24346. return 'few';
  24347. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  24348. return 'other';
  24349. },
  24350. '11': function _(n) {
  24351. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14))
  24352. return 'few';
  24353. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n %
  24354. 100, 11, 14)) return 'many';
  24355. if (n % 10 == 1 && n % 100 != 11) return 'one';
  24356. return 'other';
  24357. },
  24358. '12': function _(n) {
  24359. if (isBetween(n, 2, 4)) return 'few';
  24360. if (n == 1) return 'one';
  24361. return 'other';
  24362. },
  24363. '13': function _(n) {
  24364. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14))
  24365. return 'few';
  24366. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5,
  24367. 9) || isBetween(n % 100, 12, 14)) return 'many';
  24368. if (n == 1) return 'one';
  24369. return 'other';
  24370. },
  24371. '14': function _(n) {
  24372. if (isBetween(n % 100, 3, 4)) return 'few';
  24373. if (n % 100 == 2) return 'two';
  24374. if (n % 100 == 1) return 'one';
  24375. return 'other';
  24376. },
  24377. '15': function _(n) {
  24378. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  24379. if (isBetween(n % 100, 11, 19)) return 'many';
  24380. if (n == 1) return 'one';
  24381. return 'other';
  24382. },
  24383. '16': function _(n) {
  24384. if (n % 10 == 1 && n != 11) return 'one';
  24385. return 'other';
  24386. },
  24387. '17': function _(n) {
  24388. if (n == 3) return 'few';
  24389. if (n === 0) return 'zero';
  24390. if (n == 6) return 'many';
  24391. if (n == 2) return 'two';
  24392. if (n == 1) return 'one';
  24393. return 'other';
  24394. },
  24395. '18': function _(n) {
  24396. if (n === 0) return 'zero';
  24397. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  24398. return 'other';
  24399. },
  24400. '19': function _(n) {
  24401. if (isBetween(n, 2, 10)) return 'few';
  24402. if (isBetween(n, 0, 1)) return 'one';
  24403. return 'other';
  24404. },
  24405. '20': function _(n) {
  24406. if ((isBetween(n % 10, 3, 4) || n % 10 == 9) && !(isBetween(n %
  24407. 100, 10, 19) || isBetween(n % 100, 70, 79) ||
  24408. isBetween(n % 100, 90, 99))) return 'few';
  24409. if (n % 1000000 === 0 && n !== 0) return 'many';
  24410. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  24411. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  24412. return 'other';
  24413. },
  24414. '21': function _(n) {
  24415. if (n === 0) return 'zero';
  24416. if (n == 1) return 'one';
  24417. return 'other';
  24418. },
  24419. '22': function _(n) {
  24420. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  24421. return 'other';
  24422. },
  24423. '23': function _(n) {
  24424. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  24425. return 'other';
  24426. },
  24427. '24': function _(n) {
  24428. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  24429. if (isIn(n, [2, 12])) return 'two';
  24430. if (isIn(n, [1, 11])) return 'one';
  24431. return 'other';
  24432. }
  24433. };
  24434. var index = locales2rules[lang.replace(/-.*$/, '')];
  24435. if (!(index in pluralRules)) {
  24436. console.warn('plural form unknown for [' + lang + ']');
  24437. return function() {
  24438. return 'other';
  24439. };
  24440. }
  24441. return pluralRules[index];
  24442. }
  24443. gMacros.plural = function(str, param, key, prop) {
  24444. var n = parseFloat(param);
  24445. if (isNaN(n)) return str;
  24446. if (prop != gTextProp) return str;
  24447. if (!gMacros._pluralRules) {
  24448. gMacros._pluralRules = getPluralRules(gLanguage);
  24449. }
  24450. var index = '[' + gMacros._pluralRules(n) + ']';
  24451. if (n === 0 && key + '[zero]' in gL10nData) {
  24452. str = gL10nData[key + '[zero]'][prop];
  24453. } else if (n == 1 && key + '[one]' in gL10nData) {
  24454. str = gL10nData[key + '[one]'][prop];
  24455. } else if (n == 2 && key + '[two]' in gL10nData) {
  24456. str = gL10nData[key + '[two]'][prop];
  24457. } else if (key + index in gL10nData) {
  24458. str = gL10nData[key + index][prop];
  24459. } else if (key + '[other]' in gL10nData) {
  24460. str = gL10nData[key + '[other]'][prop];
  24461. }
  24462. return str;
  24463. };
  24464. function getL10nData(key, args, fallback) {
  24465. var data = gL10nData[key];
  24466. if (!data) {
  24467. console.warn('#' + key + ' is undefined.');
  24468. if (!fallback) {
  24469. return null;
  24470. }
  24471. data = fallback;
  24472. }
  24473. var rv = {};
  24474. for (var prop in data) {
  24475. var str = data[prop];
  24476. str = substIndexes(str, args, key, prop);
  24477. str = substArguments(str, args, key);
  24478. rv[prop] = str;
  24479. }
  24480. return rv;
  24481. }
  24482. function substIndexes(str, args, key, prop) {
  24483. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  24484. var reMatch = reIndex.exec(str);
  24485. if (!reMatch || !reMatch.length) return str;
  24486. var macroName = reMatch[1];
  24487. var paramName = reMatch[2];
  24488. var param;
  24489. if (args && paramName in args) {
  24490. param = args[paramName];
  24491. } else if (paramName in gL10nData) {
  24492. param = gL10nData[paramName];
  24493. }
  24494. if (macroName in gMacros) {
  24495. var macro = gMacros[macroName];
  24496. str = macro(str, param, key, prop);
  24497. }
  24498. return str;
  24499. }
  24500. function substArguments(str, args, key) {
  24501. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  24502. return str.replace(reArgs, function(matched_text, arg) {
  24503. if (args && arg in args) {
  24504. return args[arg];
  24505. }
  24506. if (arg in gL10nData) {
  24507. return gL10nData[arg];
  24508. }
  24509. console.log('argument {{' + arg + '}} for #' + key +
  24510. ' is undefined.');
  24511. return matched_text;
  24512. });
  24513. }
  24514. function translateElement(element) {
  24515. var l10n = getL10nAttributes(element);
  24516. if (!l10n.id) return;
  24517. var data = getL10nData(l10n.id, l10n.args);
  24518. if (!data) {
  24519. console.warn('#' + l10n.id + ' is undefined.');
  24520. return;
  24521. }
  24522. if (data[gTextProp]) {
  24523. if (getChildElementCount(element) === 0) {
  24524. element[gTextProp] = data[gTextProp];
  24525. } else {
  24526. var children = element.childNodes;
  24527. var found = false;
  24528. for (var i = 0, l = children.length; i < l; i++) {
  24529. if (children[i].nodeType === 3 && /\S/.test(children[i]
  24530. .nodeValue)) {
  24531. if (found) {
  24532. children[i].nodeValue = '';
  24533. } else {
  24534. children[i].nodeValue = data[gTextProp];
  24535. found = true;
  24536. }
  24537. }
  24538. }
  24539. if (!found) {
  24540. var textNode = document.createTextNode(data[gTextProp]);
  24541. element.insertBefore(textNode, element.firstChild);
  24542. }
  24543. }
  24544. delete data[gTextProp];
  24545. }
  24546. for (var k in data) {
  24547. element[k] = data[k];
  24548. }
  24549. }
  24550. function getChildElementCount(element) {
  24551. if (element.children) {
  24552. return element.children.length;
  24553. }
  24554. if (typeof element.childElementCount !== 'undefined') {
  24555. return element.childElementCount;
  24556. }
  24557. var count = 0;
  24558. for (var i = 0; i < element.childNodes.length; i++) {
  24559. count += element.nodeType === 1 ? 1 : 0;
  24560. }
  24561. return count;
  24562. }
  24563. function translateFragment(element) {
  24564. element = element || document.documentElement;
  24565. var children = getTranslatableChildren(element);
  24566. var elementCount = children.length;
  24567. for (var i = 0; i < elementCount; i++) {
  24568. translateElement(children[i]);
  24569. }
  24570. translateElement(element);
  24571. }
  24572. return {
  24573. get: function get(key, args, fallbackString) {
  24574. var index = key.lastIndexOf('.');
  24575. var prop = gTextProp;
  24576. if (index > 0) {
  24577. prop = key.substring(index + 1);
  24578. key = key.substring(0, index);
  24579. }
  24580. var fallback;
  24581. if (fallbackString) {
  24582. fallback = {};
  24583. fallback[prop] = fallbackString;
  24584. }
  24585. var data = getL10nData(key, args, fallback);
  24586. if (data && prop in data) {
  24587. return data[prop];
  24588. }
  24589. return '{{' + key + '}}';
  24590. },
  24591. getData: function getData() {
  24592. return gL10nData;
  24593. },
  24594. getText: function getText() {
  24595. return gTextData;
  24596. },
  24597. getLanguage: function getLanguage() {
  24598. return gLanguage;
  24599. },
  24600. setLanguage: function setLanguage(lang, callback) {
  24601. loadLocale(lang, function() {
  24602. if (callback) callback();
  24603. });
  24604. },
  24605. getDirection: function getDirection() {
  24606. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  24607. var shortCode = gLanguage.split('-', 1)[0];
  24608. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  24609. },
  24610. translate: translateFragment,
  24611. getReadyState: function getReadyState() {
  24612. return gReadyState;
  24613. },
  24614. ready: function ready(callback) {
  24615. if (!callback) {
  24616. return;
  24617. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  24618. window.setTimeout(function() {
  24619. callback();
  24620. });
  24621. } else if (document.addEventListener) {
  24622. document.addEventListener('localized', function once() {
  24623. document.removeEventListener('localized', once);
  24624. callback();
  24625. });
  24626. }
  24627. }
  24628. };
  24629. }(window, document);
  24630. /***/
  24631. }),
  24632. /* 46 */
  24633. /***/
  24634. ((__unused_webpack_module, exports, __webpack_require__) => {
  24635. Object.defineProperty(exports, "__esModule", ({
  24636. value: true
  24637. }));
  24638. exports.GenericScripting = void 0;
  24639. exports.docPropertiesLookup = docPropertiesLookup;
  24640. var _regenerator = _interopRequireDefault(__webpack_require__(3));
  24641. var _pdfjsLib = __webpack_require__(7);
  24642. function _interopRequireDefault(obj) {
  24643. return obj && obj.__esModule ? obj : {
  24644. "default": obj
  24645. };
  24646. }
  24647. function ownKeys(object, enumerableOnly) {
  24648. var keys = Object.keys(object);
  24649. if (Object.getOwnPropertySymbols) {
  24650. var symbols = Object.getOwnPropertySymbols(object);
  24651. enumerableOnly && (symbols = symbols.filter(function(sym) {
  24652. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  24653. })), keys.push.apply(keys, symbols);
  24654. }
  24655. return keys;
  24656. }
  24657. function _objectSpread(target) {
  24658. for (var i = 1; i < arguments.length; i++) {
  24659. var source = null != arguments[i] ? arguments[i] : {};
  24660. i % 2 ? ownKeys(Object(source), !0).forEach(function(key) {
  24661. _defineProperty(target, key, source[key]);
  24662. }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object
  24663. .getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(
  24664. function(key) {
  24665. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(
  24666. source, key));
  24667. });
  24668. }
  24669. return target;
  24670. }
  24671. function _defineProperty(obj, key, value) {
  24672. if (key in obj) {
  24673. Object.defineProperty(obj, key, {
  24674. value: value,
  24675. enumerable: true,
  24676. configurable: true,
  24677. writable: true
  24678. });
  24679. } else {
  24680. obj[key] = value;
  24681. }
  24682. return obj;
  24683. }
  24684. function _classCallCheck(instance, Constructor) {
  24685. if (!(instance instanceof Constructor)) {
  24686. throw new TypeError("Cannot call a class as a function");
  24687. }
  24688. }
  24689. function _defineProperties(target, props) {
  24690. for (var i = 0; i < props.length; i++) {
  24691. var descriptor = props[i];
  24692. descriptor.enumerable = descriptor.enumerable || false;
  24693. descriptor.configurable = true;
  24694. if ("value" in descriptor) descriptor.writable = true;
  24695. Object.defineProperty(target, descriptor.key, descriptor);
  24696. }
  24697. }
  24698. function _createClass(Constructor, protoProps, staticProps) {
  24699. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  24700. if (staticProps) _defineProperties(Constructor, staticProps);
  24701. Object.defineProperty(Constructor, "prototype", {
  24702. writable: false
  24703. });
  24704. return Constructor;
  24705. }
  24706. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  24707. try {
  24708. var info = gen[key](arg);
  24709. var value = info.value;
  24710. } catch (error) {
  24711. reject(error);
  24712. return;
  24713. }
  24714. if (info.done) {
  24715. resolve(value);
  24716. } else {
  24717. Promise.resolve(value).then(_next, _throw);
  24718. }
  24719. }
  24720. function _asyncToGenerator(fn) {
  24721. return function() {
  24722. var self = this,
  24723. args = arguments;
  24724. return new Promise(function(resolve, reject) {
  24725. var gen = fn.apply(self, args);
  24726. function _next(value) {
  24727. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next",
  24728. value);
  24729. }
  24730. function _throw(err) {
  24731. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw",
  24732. err);
  24733. }
  24734. _next(undefined);
  24735. });
  24736. };
  24737. }
  24738. function docPropertiesLookup(_x) {
  24739. return _docPropertiesLookup.apply(this, arguments);
  24740. }
  24741. function _docPropertiesLookup() {
  24742. _docPropertiesLookup = _asyncToGenerator( /*#__PURE__*/ _regenerator["default"].mark(
  24743. function _callee4(pdfDocument) {
  24744. var url, baseUrl, _yield$pdfDocument$ge, info, metadata,
  24745. contentDispositionFilename, contentLength, _yield$pdfDocument$ge2,
  24746. length;
  24747. return _regenerator["default"].wrap(function _callee4$(_context4) {
  24748. while (1) {
  24749. switch (_context4.prev = _context4.next) {
  24750. case 0:
  24751. url = "", baseUrl = url.split("#")[0];
  24752. _context4.next = 3;
  24753. return pdfDocument.getMetadata();
  24754. case 3:
  24755. _yield$pdfDocument$ge = _context4.sent;
  24756. info = _yield$pdfDocument$ge.info;
  24757. metadata = _yield$pdfDocument$ge.metadata;
  24758. contentDispositionFilename =
  24759. _yield$pdfDocument$ge
  24760. .contentDispositionFilename;
  24761. contentLength = _yield$pdfDocument$ge
  24762. .contentLength;
  24763. if (contentLength) {
  24764. _context4.next = 14;
  24765. break;
  24766. }
  24767. _context4.next = 11;
  24768. return pdfDocument.getDownloadInfo();
  24769. case 11:
  24770. _yield$pdfDocument$ge2 = _context4.sent;
  24771. length = _yield$pdfDocument$ge2.length;
  24772. contentLength = length;
  24773. case 14:
  24774. return _context4.abrupt("return", _objectSpread(
  24775. _objectSpread({}, info), {}, {
  24776. baseURL: baseUrl,
  24777. filesize: contentLength,
  24778. filename: contentDispositionFilename ||
  24779. (0, _pdfjsLib
  24780. .getPdfFilenameFromUrl)(
  24781. url),
  24782. metadata: metadata === null ||
  24783. metadata === void 0 ?
  24784. void 0 : metadata.getRaw(),
  24785. authors: metadata === null ||
  24786. metadata === void 0 ?
  24787. void 0 : metadata.get(
  24788. "dc:creator"),
  24789. numPages: pdfDocument.numPages,
  24790. URL: url
  24791. }));
  24792. case 15:
  24793. case "end":
  24794. return _context4.stop();
  24795. }
  24796. }
  24797. }, _callee4);
  24798. }));
  24799. return _docPropertiesLookup.apply(this, arguments);
  24800. }
  24801. var GenericScripting = /*#__PURE__*/ function() {
  24802. function GenericScripting(sandboxBundleSrc) {
  24803. _classCallCheck(this, GenericScripting);
  24804. this._ready = (0, _pdfjsLib.loadScript)(sandboxBundleSrc, true).then(
  24805. function() {
  24806. return window.pdfjsSandbox.QuickJSSandbox();
  24807. });
  24808. }
  24809. _createClass(GenericScripting, [{
  24810. key: "createSandbox",
  24811. value: function() {
  24812. var _createSandbox = _asyncToGenerator( /*#__PURE__*/
  24813. _regenerator["default"].mark(function _callee(
  24814. data) {
  24815. var sandbox;
  24816. return _regenerator["default"].wrap(
  24817. function _callee$(_context) {
  24818. while (1) {
  24819. switch (_context.prev =
  24820. _context.next) {
  24821. case 0:
  24822. _context.next = 2;
  24823. return this._ready;
  24824. case 2:
  24825. sandbox = _context
  24826. .sent;
  24827. sandbox.create(
  24828. data);
  24829. case 4:
  24830. case "end":
  24831. return _context
  24832. .stop();
  24833. }
  24834. }
  24835. }, _callee, this);
  24836. }));
  24837. function createSandbox(_x2) {
  24838. return _createSandbox.apply(this, arguments);
  24839. }
  24840. return createSandbox;
  24841. }()
  24842. }, {
  24843. key: "dispatchEventInSandbox",
  24844. value: function() {
  24845. var _dispatchEventInSandbox =
  24846. _asyncToGenerator( /*#__PURE__*/ _regenerator["default"]
  24847. .mark(function _callee2(event) {
  24848. var sandbox;
  24849. return _regenerator["default"].wrap(
  24850. function _callee2$(_context2) {
  24851. while (1) {
  24852. switch (_context2.prev =
  24853. _context2.next) {
  24854. case 0:
  24855. _context2.next = 2;
  24856. return this._ready;
  24857. case 2:
  24858. sandbox = _context2
  24859. .sent;
  24860. setTimeout(
  24861. function() {
  24862. return sandbox
  24863. .dispatchEvent(
  24864. event
  24865. );
  24866. }, 0);
  24867. case 4:
  24868. case "end":
  24869. return _context2
  24870. .stop();
  24871. }
  24872. }
  24873. }, _callee2, this);
  24874. }));
  24875. function dispatchEventInSandbox(_x3) {
  24876. return _dispatchEventInSandbox.apply(this, arguments);
  24877. }
  24878. return dispatchEventInSandbox;
  24879. }()
  24880. }, {
  24881. key: "destroySandbox",
  24882. value: function() {
  24883. var _destroySandbox = _asyncToGenerator( /*#__PURE__*/
  24884. _regenerator["default"].mark(function _callee3() {
  24885. var sandbox;
  24886. return _regenerator["default"].wrap(
  24887. function _callee3$(_context3) {
  24888. while (1) {
  24889. switch (_context3.prev =
  24890. _context3.next) {
  24891. case 0:
  24892. _context3.next = 2;
  24893. return this._ready;
  24894. case 2:
  24895. sandbox = _context3
  24896. .sent;
  24897. sandbox
  24898. .nukeSandbox();
  24899. case 4:
  24900. case "end":
  24901. return _context3
  24902. .stop();
  24903. }
  24904. }
  24905. }, _callee3, this);
  24906. }));
  24907. function destroySandbox() {
  24908. return _destroySandbox.apply(this, arguments);
  24909. }
  24910. return destroySandbox;
  24911. }()
  24912. }]);
  24913. return GenericScripting;
  24914. }();
  24915. exports.GenericScripting = GenericScripting;
  24916. /***/
  24917. }),
  24918. /* 47 */
  24919. /***/
  24920. ((__unused_webpack_module, exports, __webpack_require__) => {
  24921. Object.defineProperty(exports, "__esModule", ({
  24922. value: true
  24923. }));
  24924. exports.PDFPrintService = PDFPrintService;
  24925. var _pdfjsLib = __webpack_require__(7);
  24926. var _app = __webpack_require__(2);
  24927. var _print_utils = __webpack_require__(48);
  24928. var activeService = null;
  24929. var overlayManager = null;
  24930. function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size, printResolution,
  24931. optionalContentConfigPromise) {
  24932. var scratchCanvas = activeService.scratchCanvas;
  24933. var PRINT_UNITS = printResolution / _pdfjsLib.PixelsPerInch.PDF;
  24934. scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
  24935. scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
  24936. var ctx = scratchCanvas.getContext("2d");
  24937. ctx.save();
  24938. ctx.fillStyle = "rgb(255, 255, 255)";
  24939. ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height);
  24940. ctx.restore();
  24941. return pdfDocument.getPage(pageNumber).then(function(pdfPage) {
  24942. var renderContext = {
  24943. canvasContext: ctx,
  24944. transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
  24945. viewport: pdfPage.getViewport({
  24946. scale: 1,
  24947. rotation: size.rotation
  24948. }),
  24949. intent: "print",
  24950. annotationMode: _pdfjsLib.AnnotationMode.ENABLE_STORAGE,
  24951. optionalContentConfigPromise: optionalContentConfigPromise
  24952. };
  24953. return pdfPage.render(renderContext).promise;
  24954. });
  24955. }
  24956. function PDFPrintService(pdfDocument, pagesOverview, printContainer, printResolution) {
  24957. var optionalContentConfigPromise = arguments.length > 4 && arguments[4] !== undefined ?
  24958. arguments[4] : null;
  24959. var l10n = arguments.length > 5 ? arguments[5] : undefined;
  24960. this.pdfDocument = pdfDocument;
  24961. this.pagesOverview = pagesOverview;
  24962. this.printContainer = printContainer;
  24963. this._printResolution = printResolution || 150;
  24964. this._optionalContentConfigPromise = optionalContentConfigPromise || pdfDocument
  24965. .getOptionalContentConfig();
  24966. this.l10n = l10n;
  24967. this.currentPage = -1;
  24968. this.scratchCanvas = document.createElement("canvas");
  24969. }
  24970. PDFPrintService.prototype = {
  24971. layout: function layout() {
  24972. this.throwIfInactive();
  24973. var body = document.querySelector("body");
  24974. body.setAttribute("data-pdfjsprinting", true);
  24975. var hasEqualPageSizes = this.pagesOverview.every(function(size) {
  24976. return size.width === this.pagesOverview[0].width && size
  24977. .height === this.pagesOverview[0].height;
  24978. }, this);
  24979. if (!hasEqualPageSizes) {
  24980. console.warn("Not all pages have the same size. The printed " +
  24981. "result may be incorrect!");
  24982. }
  24983. this.pageStyleSheet = document.createElement("style");
  24984. var pageSize = this.pagesOverview[0];
  24985. this.pageStyleSheet.textContent = "@page { size: " + pageSize.width +
  24986. "pt " + pageSize.height + "pt;}";
  24987. body.appendChild(this.pageStyleSheet);
  24988. },
  24989. destroy: function destroy() {
  24990. if (activeService !== this) {
  24991. return;
  24992. }
  24993. this.printContainer.textContent = "";
  24994. var body = document.querySelector("body");
  24995. body.removeAttribute("data-pdfjsprinting");
  24996. if (this.pageStyleSheet) {
  24997. this.pageStyleSheet.remove();
  24998. this.pageStyleSheet = null;
  24999. }
  25000. this.scratchCanvas.width = this.scratchCanvas.height = 0;
  25001. this.scratchCanvas = null;
  25002. activeService = null;
  25003. ensureOverlay().then(function() {
  25004. if (overlayManager.active !== "printServiceOverlay") {
  25005. return;
  25006. }
  25007. overlayManager.close("printServiceOverlay");
  25008. });
  25009. },
  25010. renderPages: function renderPages() {
  25011. var _this = this;
  25012. if (this.pdfDocument.isPureXfa) {
  25013. (0, _print_utils.getXfaHtmlForPrinting)(this.printContainer, this
  25014. .pdfDocument);
  25015. return Promise.resolve();
  25016. }
  25017. var pageCount = this.pagesOverview.length;
  25018. var renderNextPage = function renderNextPage(resolve, reject) {
  25019. _this.throwIfInactive();
  25020. if (++_this.currentPage >= pageCount) {
  25021. renderProgress(pageCount, pageCount, _this.l10n);
  25022. resolve();
  25023. return;
  25024. }
  25025. var index = _this.currentPage;
  25026. renderProgress(index, pageCount, _this.l10n);
  25027. renderPage(_this, _this.pdfDocument, index + 1, _this.pagesOverview[
  25028. index], _this._printResolution, _this
  25029. ._optionalContentConfigPromise).then(_this.useRenderedPage
  25030. .bind(_this)).then(function() {
  25031. renderNextPage(resolve, reject);
  25032. }, reject);
  25033. };
  25034. return new Promise(renderNextPage);
  25035. },
  25036. useRenderedPage: function useRenderedPage() {
  25037. this.throwIfInactive();
  25038. var img = document.createElement("img");
  25039. var scratchCanvas = this.scratchCanvas;
  25040. if ("toBlob" in scratchCanvas) {
  25041. scratchCanvas.toBlob(function(blob) {
  25042. img.src = URL.createObjectURL(blob);
  25043. });
  25044. } else {
  25045. img.src = scratchCanvas.toDataURL();
  25046. }
  25047. var wrapper = document.createElement("div");
  25048. wrapper.className = "printedPage";
  25049. wrapper.appendChild(img);
  25050. this.printContainer.appendChild(wrapper);
  25051. return new Promise(function(resolve, reject) {
  25052. img.onload = resolve;
  25053. img.onerror = reject;
  25054. });
  25055. },
  25056. performPrint: function performPrint() {
  25057. var _this2 = this;
  25058. this.throwIfInactive();
  25059. return new Promise(function(resolve) {
  25060. setTimeout(function() {
  25061. if (!_this2.active) {
  25062. resolve();
  25063. return;
  25064. }
  25065. print.call(window);
  25066. setTimeout(resolve, 20);
  25067. }, 0);
  25068. });
  25069. },
  25070. get active() {
  25071. return this === activeService;
  25072. },
  25073. throwIfInactive: function throwIfInactive() {
  25074. if (!this.active) {
  25075. throw new Error("This print request was cancelled or completed.");
  25076. }
  25077. }
  25078. };
  25079. var print = window.print;
  25080. window.print = function() {
  25081. if (activeService) {
  25082. console.warn("Ignored window.print() because of a pending print job.");
  25083. return;
  25084. }
  25085. ensureOverlay().then(function() {
  25086. if (activeService) {
  25087. overlayManager.open("printServiceOverlay");
  25088. }
  25089. });
  25090. try {
  25091. dispatchEvent("beforeprint");
  25092. } finally {
  25093. if (!activeService) {
  25094. console.error("Expected print service to be initialized.");
  25095. ensureOverlay().then(function() {
  25096. if (overlayManager.active === "printServiceOverlay") {
  25097. overlayManager.close("printServiceOverlay");
  25098. }
  25099. });
  25100. return;
  25101. }
  25102. var activeServiceOnEntry = activeService;
  25103. activeService.renderPages().then(function() {
  25104. return activeServiceOnEntry.performPrint();
  25105. })["catch"](function() {}).then(function() {
  25106. if (activeServiceOnEntry.active) {
  25107. abort();
  25108. }
  25109. });
  25110. }
  25111. };
  25112. function dispatchEvent(eventType) {
  25113. var event = document.createEvent("CustomEvent");
  25114. event.initCustomEvent(eventType, false, false, "custom");
  25115. window.dispatchEvent(event);
  25116. }
  25117. function abort() {
  25118. if (activeService) {
  25119. activeService.destroy();
  25120. dispatchEvent("afterprint");
  25121. }
  25122. }
  25123. function renderProgress(index, total, l10n) {
  25124. var progressContainer = document.getElementById("printServiceOverlay");
  25125. var progress = Math.round(100 * index / total);
  25126. var progressBar = progressContainer.querySelector("progress");
  25127. var progressPerc = progressContainer.querySelector(".relative-progress");
  25128. progressBar.value = progress;
  25129. l10n.get("print_progress_percent", {
  25130. progress: progress
  25131. }).then(function(msg) {
  25132. progressPerc.textContent = msg;
  25133. });
  25134. }
  25135. window.addEventListener("keydown", function(event) {
  25136. if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey &&
  25137. (!event.shiftKey || window.chrome || window.opera)) {
  25138. window.print();
  25139. event.preventDefault();
  25140. if (event.stopImmediatePropagation) {
  25141. event.stopImmediatePropagation();
  25142. } else {
  25143. event.stopPropagation();
  25144. }
  25145. }
  25146. }, true);
  25147. if ("onbeforeprint" in window) {
  25148. var stopPropagationIfNeeded = function stopPropagationIfNeeded(event) {
  25149. if (event.detail !== "custom" && event.stopImmediatePropagation) {
  25150. event.stopImmediatePropagation();
  25151. }
  25152. };
  25153. window.addEventListener("beforeprint", stopPropagationIfNeeded);
  25154. window.addEventListener("afterprint", stopPropagationIfNeeded);
  25155. }
  25156. var overlayPromise;
  25157. function ensureOverlay() {
  25158. if (!overlayPromise) {
  25159. overlayManager = _app.PDFViewerApplication.overlayManager;
  25160. if (!overlayManager) {
  25161. throw new Error("The overlay manager has not yet been initialized.");
  25162. }
  25163. overlayPromise = overlayManager.register("printServiceOverlay", document
  25164. .getElementById("printServiceOverlay"), abort, true);
  25165. document.getElementById("printCancel").onclick = abort;
  25166. }
  25167. return overlayPromise;
  25168. }
  25169. _app.PDFPrintServiceFactory.instance = {
  25170. supportsPrinting: true,
  25171. createPrintService: function createPrintService(pdfDocument, pagesOverview,
  25172. printContainer, printResolution, optionalContentConfigPromise, l10n) {
  25173. if (activeService) {
  25174. throw new Error("The print service is created and active.");
  25175. }
  25176. activeService = new PDFPrintService(pdfDocument, pagesOverview,
  25177. printContainer, printResolution, optionalContentConfigPromise, l10n);
  25178. return activeService;
  25179. }
  25180. };
  25181. /***/
  25182. }),
  25183. /* 48 */
  25184. /***/
  25185. ((__unused_webpack_module, exports, __webpack_require__) => {
  25186. Object.defineProperty(exports, "__esModule", ({
  25187. value: true
  25188. }));
  25189. exports.getXfaHtmlForPrinting = getXfaHtmlForPrinting;
  25190. var _pdfjsLib = __webpack_require__(7);
  25191. var _pdf_link_service = __webpack_require__(10);
  25192. var _xfa_layer_builder = __webpack_require__(37);
  25193. function _createForOfIteratorHelper(o, allowArrayLike) {
  25194. var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
  25195. if (!it) {
  25196. if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike &&
  25197. o && typeof o.length === "number") {
  25198. if (it) o = it;
  25199. var i = 0;
  25200. var F = function F() {};
  25201. return {
  25202. s: F,
  25203. n: function n() {
  25204. if (i >= o.length) return {
  25205. done: true
  25206. };
  25207. return {
  25208. done: false,
  25209. value: o[i++]
  25210. };
  25211. },
  25212. e: function e(_e) {
  25213. throw _e;
  25214. },
  25215. f: F
  25216. };
  25217. }
  25218. throw new TypeError(
  25219. "Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
  25220. );
  25221. }
  25222. var normalCompletion = true,
  25223. didErr = false,
  25224. err;
  25225. return {
  25226. s: function s() {
  25227. it = it.call(o);
  25228. },
  25229. n: function n() {
  25230. var step = it.next();
  25231. normalCompletion = step.done;
  25232. return step;
  25233. },
  25234. e: function e(_e2) {
  25235. didErr = true;
  25236. err = _e2;
  25237. },
  25238. f: function f() {
  25239. try {
  25240. if (!normalCompletion && it["return"] != null) it["return"]();
  25241. } finally {
  25242. if (didErr) throw err;
  25243. }
  25244. }
  25245. };
  25246. }
  25247. function _unsupportedIterableToArray(o, minLen) {
  25248. if (!o) return;
  25249. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  25250. var n = Object.prototype.toString.call(o).slice(8, -1);
  25251. if (n === "Object" && o.constructor) n = o.constructor.name;
  25252. if (n === "Map" || n === "Set") return Array.from(o);
  25253. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
  25254. return _arrayLikeToArray(o, minLen);
  25255. }
  25256. function _arrayLikeToArray(arr, len) {
  25257. if (len == null || len > arr.length) len = arr.length;
  25258. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  25259. arr2[i] = arr[i];
  25260. }
  25261. return arr2;
  25262. }
  25263. function getXfaHtmlForPrinting(printContainer, pdfDocument) {
  25264. var xfaHtml = pdfDocument.allXfaHtml;
  25265. var linkService = new _pdf_link_service.SimpleLinkService();
  25266. var scale = Math.round(_pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS * 100) / 100;
  25267. var _iterator = _createForOfIteratorHelper(xfaHtml.children),
  25268. _step;
  25269. try {
  25270. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  25271. var xfaPage = _step.value;
  25272. var page = document.createElement("div");
  25273. page.className = "xfaPrintedPage";
  25274. printContainer.appendChild(page);
  25275. var builder = new _xfa_layer_builder.XfaLayerBuilder({
  25276. pageDiv: page,
  25277. pdfPage: null,
  25278. annotationStorage: pdfDocument.annotationStorage,
  25279. linkService: linkService,
  25280. xfaHtml: xfaPage
  25281. });
  25282. var viewport = (0, _pdfjsLib.getXfaPageViewport)(xfaPage, {
  25283. scale: scale
  25284. });
  25285. builder.render(viewport, "print");
  25286. }
  25287. } catch (err) {
  25288. _iterator.e(err);
  25289. } finally {
  25290. _iterator.f();
  25291. }
  25292. }
  25293. /***/
  25294. })
  25295. /******/
  25296. ]);
  25297. /************************************************************************/
  25298. /******/ // The module cache
  25299. /******/
  25300. var __webpack_module_cache__ = {};
  25301. /******/
  25302. /******/ // The require function
  25303. /******/
  25304. function __webpack_require__(moduleId) {
  25305. /******/ // Check if module is in cache
  25306. /******/
  25307. var cachedModule = __webpack_module_cache__[moduleId];
  25308. /******/
  25309. if (cachedModule !== undefined) {
  25310. /******/
  25311. return cachedModule.exports;
  25312. /******/
  25313. }
  25314. /******/ // Create a new module (and put it into the cache)
  25315. /******/
  25316. var module = __webpack_module_cache__[moduleId] = {
  25317. /******/
  25318. id: moduleId,
  25319. /******/
  25320. loaded: false,
  25321. /******/
  25322. exports: {}
  25323. /******/
  25324. };
  25325. /******/
  25326. /******/ // Execute the module function
  25327. /******/
  25328. __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  25329. /******/
  25330. /******/ // Flag the module as loaded
  25331. /******/
  25332. module.loaded = true;
  25333. /******/
  25334. /******/ // Return the exports of the module
  25335. /******/
  25336. return module.exports;
  25337. /******/
  25338. }
  25339. /******/
  25340. /************************************************************************/
  25341. /******/
  25342. /* webpack/runtime/node module decorator */
  25343. /******/
  25344. (() => {
  25345. /******/
  25346. __webpack_require__.nmd = (module) => {
  25347. /******/
  25348. module.paths = [];
  25349. /******/
  25350. if (!module.children) module.children = [];
  25351. /******/
  25352. return module;
  25353. /******/
  25354. };
  25355. /******/
  25356. })();
  25357. /******/
  25358. /************************************************************************/
  25359. var __webpack_exports__ = {};
  25360. // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
  25361. (() => {
  25362. var exports = __webpack_exports__;
  25363. Object.defineProperty(exports, "__esModule", ({
  25364. value: true
  25365. }));
  25366. Object.defineProperty(exports, "PDFViewerApplication", ({
  25367. enumerable: true,
  25368. get: function get() {
  25369. return _app.PDFViewerApplication;
  25370. }
  25371. }));
  25372. Object.defineProperty(exports, "PDFViewerApplicationOptions", ({
  25373. enumerable: true,
  25374. get: function get() {
  25375. return _app_options.AppOptions;
  25376. }
  25377. }));
  25378. var _app_options = __webpack_require__(1);
  25379. var _app = __webpack_require__(2);
  25380. var pdfjsVersion = '2.13.216';
  25381. var pdfjsBuild = '399a0ec60';
  25382. window.PDFViewerApplication = _app.PDFViewerApplication;
  25383. window.PDFViewerApplicationOptions = _app_options.AppOptions;;; {
  25384. __webpack_require__(41);
  25385. }; {
  25386. __webpack_require__(47);
  25387. }
  25388. function getViewerConfiguration() {
  25389. var errorWrapper = null;
  25390. errorWrapper = {
  25391. container: document.getElementById("errorWrapper"),
  25392. errorMessage: document.getElementById("errorMessage"),
  25393. closeButton: document.getElementById("errorClose"),
  25394. errorMoreInfo: document.getElementById("errorMoreInfo"),
  25395. moreInfoButton: document.getElementById("errorShowMore"),
  25396. lessInfoButton: document.getElementById("errorShowLess")
  25397. };
  25398. return {
  25399. appContainer: document.body,
  25400. mainContainer: document.getElementById("viewerContainer"),
  25401. viewerContainer: document.getElementById("viewer"),
  25402. toolbar: {
  25403. container: document.getElementById("toolbarViewer"),
  25404. numPages: document.getElementById("numPages"),
  25405. pageNumber: document.getElementById("pageNumber"),
  25406. scaleSelect: document.getElementById("scaleSelect"),
  25407. customScaleOption: document.getElementById("customScaleOption"),
  25408. previous: document.getElementById("previous"),
  25409. next: document.getElementById("next"),
  25410. zoomIn: document.getElementById("zoomIn"),
  25411. zoomOut: document.getElementById("zoomOut"),
  25412. viewFind: document.getElementById("viewFind"),
  25413. openFile: document.getElementById("openFile"),
  25414. print: document.getElementById("print"),
  25415. presentationModeButton: document.getElementById("presentationMode"),
  25416. download: document.getElementById("download"),
  25417. viewBookmark: document.getElementById("viewBookmark")
  25418. },
  25419. secondaryToolbar: {
  25420. toolbar: document.getElementById("secondaryToolbar"),
  25421. toggleButton: document.getElementById("secondaryToolbarToggle"),
  25422. toolbarButtonContainer: document.getElementById("secondaryToolbarButtonContainer"),
  25423. presentationModeButton: document.getElementById("secondaryPresentationMode"),
  25424. openFileButton: document.getElementById("secondaryOpenFile"),
  25425. printButton: document.getElementById("secondaryPrint"),
  25426. downloadButton: document.getElementById("secondaryDownload"),
  25427. viewBookmarkButton: document.getElementById("secondaryViewBookmark"),
  25428. firstPageButton: document.getElementById("firstPage"),
  25429. lastPageButton: document.getElementById("lastPage"),
  25430. pageRotateCwButton: document.getElementById("pageRotateCw"),
  25431. pageRotateCcwButton: document.getElementById("pageRotateCcw"),
  25432. cursorSelectToolButton: document.getElementById("cursorSelectTool"),
  25433. cursorHandToolButton: document.getElementById("cursorHandTool"),
  25434. scrollPageButton: document.getElementById("scrollPage"),
  25435. scrollVerticalButton: document.getElementById("scrollVertical"),
  25436. scrollHorizontalButton: document.getElementById("scrollHorizontal"),
  25437. scrollWrappedButton: document.getElementById("scrollWrapped"),
  25438. spreadNoneButton: document.getElementById("spreadNone"),
  25439. spreadOddButton: document.getElementById("spreadOdd"),
  25440. spreadEvenButton: document.getElementById("spreadEven"),
  25441. documentPropertiesButton: document.getElementById("documentProperties")
  25442. },
  25443. sidebar: {
  25444. outerContainer: document.getElementById("outerContainer"),
  25445. viewerContainer: document.getElementById("viewerContainer"),
  25446. toggleButton: document.getElementById("sidebarToggle"),
  25447. thumbnailButton: document.getElementById("viewThumbnail"),
  25448. outlineButton: document.getElementById("viewOutline"),
  25449. attachmentsButton: document.getElementById("viewAttachments"),
  25450. layersButton: document.getElementById("viewLayers"),
  25451. thumbnailView: document.getElementById("thumbnailView"),
  25452. outlineView: document.getElementById("outlineView"),
  25453. attachmentsView: document.getElementById("attachmentsView"),
  25454. layersView: document.getElementById("layersView"),
  25455. outlineOptionsContainer: document.getElementById("outlineOptionsContainer"),
  25456. currentOutlineItemButton: document.getElementById("currentOutlineItem")
  25457. },
  25458. sidebarResizer: {
  25459. outerContainer: document.getElementById("outerContainer"),
  25460. resizer: document.getElementById("sidebarResizer")
  25461. },
  25462. findBar: {
  25463. bar: document.getElementById("findbar"),
  25464. toggleButton: document.getElementById("viewFind"),
  25465. findField: document.getElementById("findInput"),
  25466. highlightAllCheckbox: document.getElementById("findHighlightAll"),
  25467. caseSensitiveCheckbox: document.getElementById("findMatchCase"),
  25468. matchDiacriticsCheckbox: document.getElementById("findMatchDiacritics"),
  25469. entireWordCheckbox: document.getElementById("findEntireWord"),
  25470. findMsg: document.getElementById("findMsg"),
  25471. findResultsCount: document.getElementById("findResultsCount"),
  25472. findPreviousButton: document.getElementById("findPrevious"),
  25473. findNextButton: document.getElementById("findNext")
  25474. },
  25475. passwordOverlay: {
  25476. overlayName: "passwordOverlay",
  25477. container: document.getElementById("passwordOverlay"),
  25478. label: document.getElementById("passwordText"),
  25479. input: document.getElementById("password"),
  25480. submitButton: document.getElementById("passwordSubmit"),
  25481. cancelButton: document.getElementById("passwordCancel")
  25482. },
  25483. documentProperties: {
  25484. overlayName: "documentPropertiesOverlay",
  25485. container: document.getElementById("documentPropertiesOverlay"),
  25486. closeButton: document.getElementById("documentPropertiesClose"),
  25487. fields: {
  25488. fileName: document.getElementById("fileNameField"),
  25489. fileSize: document.getElementById("fileSizeField"),
  25490. title: document.getElementById("titleField"),
  25491. author: document.getElementById("authorField"),
  25492. subject: document.getElementById("subjectField"),
  25493. keywords: document.getElementById("keywordsField"),
  25494. creationDate: document.getElementById("creationDateField"),
  25495. modificationDate: document.getElementById("modificationDateField"),
  25496. creator: document.getElementById("creatorField"),
  25497. producer: document.getElementById("producerField"),
  25498. version: document.getElementById("versionField"),
  25499. pageCount: document.getElementById("pageCountField"),
  25500. pageSize: document.getElementById("pageSizeField"),
  25501. linearized: document.getElementById("linearizedField")
  25502. }
  25503. },
  25504. errorWrapper: errorWrapper,
  25505. printContainer: document.getElementById("printContainer"),
  25506. openFileInputName: "fileInput",
  25507. debuggerScriptPath: "./debugger.js"
  25508. };
  25509. }
  25510. function webViewerLoad() {
  25511. var config = getViewerConfiguration();
  25512. var event = document.createEvent("CustomEvent");
  25513. event.initCustomEvent("webviewerloaded", true, true, {
  25514. source: window
  25515. });
  25516. try {
  25517. parent.document.dispatchEvent(event);
  25518. } catch (ex) {
  25519. console.error("webviewerloaded: ".concat(ex));
  25520. document.dispatchEvent(event);
  25521. }
  25522. _app.PDFViewerApplication.run(config);
  25523. }
  25524. if (document.blockUnblockOnload) {
  25525. document.blockUnblockOnload(true);
  25526. }
  25527. if (document.readyState === "interactive" || document.readyState === "complete") {
  25528. webViewerLoad();
  25529. } else {
  25530. document.addEventListener("DOMContentLoaded", webViewerLoad, true);
  25531. }
  25532. })();
  25533. /******/
  25534. })();
  25535. //# sourceMappingURL=viewer.js.map