2
0

pdf_viewer.js 173 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2017 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * Javascript code in this page
  21. */
  22. (function webpackUniversalModuleDefinition(root, factory) {
  23. if(typeof exports === 'object' && typeof module === 'object')
  24. module.exports = factory();
  25. else if(typeof define === 'function' && define.amd)
  26. define("pdfjs-dist/web/pdf_viewer", [], factory);
  27. else if(typeof exports === 'object')
  28. exports["pdfjs-dist/web/pdf_viewer"] = factory();
  29. else
  30. root["pdfjs-dist/web/pdf_viewer"] = root.pdfjsViewer = factory();
  31. })(typeof self !== 'undefined' ? self : this, function() {
  32. return /******/ (function(modules) { // webpackBootstrap
  33. /******/ // The module cache
  34. /******/ var installedModules = {};
  35. /******/
  36. /******/ // The require function
  37. /******/ function __w_pdfjs_require__(moduleId) {
  38. /******/
  39. /******/ // Check if module is in cache
  40. /******/ if(installedModules[moduleId]) {
  41. /******/ return installedModules[moduleId].exports;
  42. /******/ }
  43. /******/ // Create a new module (and put it into the cache)
  44. /******/ var module = installedModules[moduleId] = {
  45. /******/ i: moduleId,
  46. /******/ l: false,
  47. /******/ exports: {}
  48. /******/ };
  49. /******/
  50. /******/ // Execute the module function
  51. /******/ modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);
  52. /******/
  53. /******/ // Flag the module as loaded
  54. /******/ module.l = true;
  55. /******/
  56. /******/ // Return the exports of the module
  57. /******/ return module.exports;
  58. /******/ }
  59. /******/
  60. /******/
  61. /******/ // expose the modules object (__webpack_modules__)
  62. /******/ __w_pdfjs_require__.m = modules;
  63. /******/
  64. /******/ // expose the module cache
  65. /******/ __w_pdfjs_require__.c = installedModules;
  66. /******/
  67. /******/ // define getter function for harmony exports
  68. /******/ __w_pdfjs_require__.d = function(exports, name, getter) {
  69. /******/ if(!__w_pdfjs_require__.o(exports, name)) {
  70. /******/ Object.defineProperty(exports, name, {
  71. /******/ configurable: false,
  72. /******/ enumerable: true,
  73. /******/ get: getter
  74. /******/ });
  75. /******/ }
  76. /******/ };
  77. /******/
  78. /******/ // getDefaultExport function for compatibility with non-harmony modules
  79. /******/ __w_pdfjs_require__.n = function(module) {
  80. /******/ var getter = module && module.__esModule ?
  81. /******/ function getDefault() { return module['default']; } :
  82. /******/ function getModuleExports() { return module; };
  83. /******/ __w_pdfjs_require__.d(getter, 'a', getter);
  84. /******/ return getter;
  85. /******/ };
  86. /******/
  87. /******/ // Object.prototype.hasOwnProperty.call
  88. /******/ __w_pdfjs_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  89. /******/
  90. /******/ // __webpack_public_path__
  91. /******/ __w_pdfjs_require__.p = "";
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __w_pdfjs_require__(__w_pdfjs_require__.s = 9);
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ([
  98. /* 0 */
  99. /***/ (function(module, exports, __w_pdfjs_require__) {
  100. "use strict";
  101. Object.defineProperty(exports, "__esModule", {
  102. value: true
  103. });
  104. exports.waitOnEventOrTimeout = exports.WaitOnType = exports.animationStarted = exports.normalizeWheelEventDelta = exports.binarySearchFirstItem = exports.watchScroll = exports.scrollIntoView = exports.getOutputScale = exports.approximateFraction = exports.getPageSizeInches = exports.roundToDivide = exports.getVisibleElements = exports.parseQueryString = exports.noContextMenuHandler = exports.getPDFFileNameFromURL = exports.ProgressBar = exports.EventBus = exports.NullL10n = exports.TextLayerMode = exports.RendererType = exports.PresentationModeState = exports.cloneObj = exports.isFileSchema = exports.isValidRotation = exports.VERTICAL_PADDING = exports.SCROLLBAR_PADDING = exports.MAX_AUTO_SCALE = exports.UNKNOWN_SCALE = exports.MAX_SCALE = exports.MIN_SCALE = exports.DEFAULT_SCALE = exports.DEFAULT_SCALE_VALUE = exports.CSS_UNITS = undefined;
  105. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  106. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  107. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  108. var _pdfjsLib = __w_pdfjs_require__(1);
  109. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  110. var CSS_UNITS = 96.0 / 72.0;
  111. var DEFAULT_SCALE_VALUE = 'auto';
  112. var DEFAULT_SCALE = 1.0;
  113. var MIN_SCALE = 0.10;
  114. var MAX_SCALE = 10.0;
  115. var UNKNOWN_SCALE = 0;
  116. var MAX_AUTO_SCALE = 1.25;
  117. var SCROLLBAR_PADDING = 40;
  118. var VERTICAL_PADDING = 5;
  119. var PresentationModeState = {
  120. UNKNOWN: 0,
  121. NORMAL: 1,
  122. CHANGING: 2,
  123. FULLSCREEN: 3
  124. };
  125. var RendererType = {
  126. CANVAS: 'canvas',
  127. SVG: 'svg'
  128. };
  129. var TextLayerMode = {
  130. DISABLE: 0,
  131. ENABLE: 1,
  132. ENABLE_ENHANCE: 2
  133. };
  134. function formatL10nValue(text, args) {
  135. if (!args) {
  136. return text;
  137. }
  138. return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function (all, name) {
  139. return name in args ? args[name] : '{{' + name + '}}';
  140. });
  141. }
  142. var NullL10n = {
  143. getDirection: function getDirection() {
  144. return Promise.resolve('ltr');
  145. },
  146. get: function get(property, args, fallback) {
  147. return Promise.resolve(formatL10nValue(fallback, args));
  148. },
  149. translate: function translate(element) {
  150. return Promise.resolve();
  151. }
  152. };
  153. function getOutputScale(ctx) {
  154. var devicePixelRatio = window.devicePixelRatio || 1;
  155. var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
  156. var pixelRatio = devicePixelRatio / backingStoreRatio;
  157. return {
  158. sx: pixelRatio,
  159. sy: pixelRatio,
  160. scaled: pixelRatio !== 1
  161. };
  162. }
  163. function scrollIntoView(element, spot) {
  164. var skipOverflowHiddenElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  165. var parent = element.offsetParent;
  166. if (!parent) {
  167. console.error('offsetParent is not set -- cannot scroll');
  168. return;
  169. }
  170. var offsetY = element.offsetTop + element.clientTop;
  171. var offsetX = element.offsetLeft + element.clientLeft;
  172. while (parent.clientHeight === parent.scrollHeight || skipOverflowHiddenElements && getComputedStyle(parent).overflow === 'hidden') {
  173. if (parent.dataset._scaleY) {
  174. offsetY /= parent.dataset._scaleY;
  175. offsetX /= parent.dataset._scaleX;
  176. }
  177. offsetY += parent.offsetTop;
  178. offsetX += parent.offsetLeft;
  179. parent = parent.offsetParent;
  180. if (!parent) {
  181. return;
  182. }
  183. }
  184. if (spot) {
  185. if (spot.top !== undefined) {
  186. offsetY += spot.top;
  187. }
  188. if (spot.left !== undefined) {
  189. offsetX += spot.left;
  190. parent.scrollLeft = offsetX;
  191. }
  192. }
  193. parent.scrollTop = offsetY;
  194. }
  195. function watchScroll(viewAreaElement, callback) {
  196. var debounceScroll = function debounceScroll(evt) {
  197. if (rAF) {
  198. return;
  199. }
  200. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  201. rAF = null;
  202. var currentY = viewAreaElement.scrollTop;
  203. var lastY = state.lastY;
  204. if (currentY !== lastY) {
  205. state.down = currentY > lastY;
  206. }
  207. state.lastY = currentY;
  208. callback(state);
  209. });
  210. };
  211. var state = {
  212. down: true,
  213. lastY: viewAreaElement.scrollTop,
  214. _eventHandler: debounceScroll
  215. };
  216. var rAF = null;
  217. viewAreaElement.addEventListener('scroll', debounceScroll, true);
  218. return state;
  219. }
  220. function parseQueryString(query) {
  221. var parts = query.split('&');
  222. var params = Object.create(null);
  223. for (var i = 0, ii = parts.length; i < ii; ++i) {
  224. var param = parts[i].split('=');
  225. var key = param[0].toLowerCase();
  226. var value = param.length > 1 ? param[1] : null;
  227. params[decodeURIComponent(key)] = decodeURIComponent(value);
  228. }
  229. return params;
  230. }
  231. function binarySearchFirstItem(items, condition) {
  232. var minIndex = 0;
  233. var maxIndex = items.length - 1;
  234. if (items.length === 0 || !condition(items[maxIndex])) {
  235. return items.length;
  236. }
  237. if (condition(items[minIndex])) {
  238. return minIndex;
  239. }
  240. while (minIndex < maxIndex) {
  241. var currentIndex = minIndex + maxIndex >> 1;
  242. var currentItem = items[currentIndex];
  243. if (condition(currentItem)) {
  244. maxIndex = currentIndex;
  245. } else {
  246. minIndex = currentIndex + 1;
  247. }
  248. }
  249. return minIndex;
  250. }
  251. function approximateFraction(x) {
  252. if (Math.floor(x) === x) {
  253. return [x, 1];
  254. }
  255. var xinv = 1 / x;
  256. var limit = 8;
  257. if (xinv > limit) {
  258. return [1, limit];
  259. } else if (Math.floor(xinv) === xinv) {
  260. return [1, xinv];
  261. }
  262. var x_ = x > 1 ? xinv : x;
  263. var a = 0,
  264. b = 1,
  265. c = 1,
  266. d = 1;
  267. while (true) {
  268. var p = a + c,
  269. q = b + d;
  270. if (q > limit) {
  271. break;
  272. }
  273. if (x_ <= p / q) {
  274. c = p;
  275. d = q;
  276. } else {
  277. a = p;
  278. b = q;
  279. }
  280. }
  281. var result = void 0;
  282. if (x_ - a / b < c / d - x_) {
  283. result = x_ === x ? [a, b] : [b, a];
  284. } else {
  285. result = x_ === x ? [c, d] : [d, c];
  286. }
  287. return result;
  288. }
  289. function roundToDivide(x, div) {
  290. var r = x % div;
  291. return r === 0 ? x : Math.round(x - r + div);
  292. }
  293. function getPageSizeInches(_ref) {
  294. var view = _ref.view,
  295. userUnit = _ref.userUnit,
  296. rotate = _ref.rotate;
  297. var _view = _slicedToArray(view, 4),
  298. x1 = _view[0],
  299. y1 = _view[1],
  300. x2 = _view[2],
  301. y2 = _view[3];
  302. var changeOrientation = rotate % 180 !== 0;
  303. var width = (x2 - x1) / 72 * userUnit;
  304. var height = (y2 - y1) / 72 * userUnit;
  305. return {
  306. width: changeOrientation ? height : width,
  307. height: changeOrientation ? width : height
  308. };
  309. }
  310. function getVisibleElements(scrollEl, views) {
  311. var sortByVisibility = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  312. var top = scrollEl.scrollTop,
  313. bottom = top + scrollEl.clientHeight;
  314. var left = scrollEl.scrollLeft,
  315. right = left + scrollEl.clientWidth;
  316. function isElementBottomBelowViewTop(view) {
  317. var element = view.div;
  318. var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  319. return elementBottom > top;
  320. }
  321. var visible = [],
  322. view = void 0,
  323. element = void 0;
  324. var currentHeight = void 0,
  325. viewHeight = void 0,
  326. hiddenHeight = void 0,
  327. percentHeight = void 0;
  328. var currentWidth = void 0,
  329. viewWidth = void 0;
  330. var firstVisibleElementInd = views.length === 0 ? 0 : binarySearchFirstItem(views, isElementBottomBelowViewTop);
  331. for (var i = firstVisibleElementInd, ii = views.length; i < ii; i++) {
  332. view = views[i];
  333. element = view.div;
  334. currentHeight = element.offsetTop + element.clientTop;
  335. viewHeight = element.clientHeight;
  336. if (currentHeight > bottom) {
  337. break;
  338. }
  339. currentWidth = element.offsetLeft + element.clientLeft;
  340. viewWidth = element.clientWidth;
  341. if (currentWidth + viewWidth < left || currentWidth > right) {
  342. continue;
  343. }
  344. hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, currentHeight + viewHeight - bottom);
  345. percentHeight = (viewHeight - hiddenHeight) * 100 / viewHeight | 0;
  346. visible.push({
  347. id: view.id,
  348. x: currentWidth,
  349. y: currentHeight,
  350. view: view,
  351. percent: percentHeight
  352. });
  353. }
  354. var first = visible[0];
  355. var last = visible[visible.length - 1];
  356. if (sortByVisibility) {
  357. visible.sort(function (a, b) {
  358. var pc = a.percent - b.percent;
  359. if (Math.abs(pc) > 0.001) {
  360. return -pc;
  361. }
  362. return a.id - b.id;
  363. });
  364. }
  365. return {
  366. first: first,
  367. last: last,
  368. views: visible
  369. };
  370. }
  371. function noContextMenuHandler(evt) {
  372. evt.preventDefault();
  373. }
  374. function isFileSchema(url) {
  375. var i = 0,
  376. ii = url.length;
  377. while (i < ii && url[i].trim() === '') {
  378. i++;
  379. }
  380. return url.substr(i, 7).toLowerCase() === 'file://';
  381. }
  382. function isDataSchema(url) {
  383. var i = 0,
  384. ii = url.length;
  385. while (i < ii && url[i].trim() === '') {
  386. i++;
  387. }
  388. return url.substr(i, 5).toLowerCase() === 'data:';
  389. }
  390. function getPDFFileNameFromURL(url) {
  391. var defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'document.pdf';
  392. if (isDataSchema(url)) {
  393. console.warn('getPDFFileNameFromURL: ' + 'ignoring "data:" URL for performance reasons.');
  394. return defaultFilename;
  395. }
  396. var reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
  397. var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
  398. var splitURI = reURI.exec(url);
  399. var suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
  400. if (suggestedFilename) {
  401. suggestedFilename = suggestedFilename[0];
  402. if (suggestedFilename.includes('%')) {
  403. try {
  404. suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
  405. } catch (ex) {}
  406. }
  407. }
  408. return suggestedFilename || defaultFilename;
  409. }
  410. function normalizeWheelEventDelta(evt) {
  411. var delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
  412. var angle = Math.atan2(evt.deltaY, evt.deltaX);
  413. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  414. delta = -delta;
  415. }
  416. var MOUSE_DOM_DELTA_PIXEL_MODE = 0;
  417. var MOUSE_DOM_DELTA_LINE_MODE = 1;
  418. var MOUSE_PIXELS_PER_LINE = 30;
  419. var MOUSE_LINES_PER_PAGE = 30;
  420. if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
  421. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  422. } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
  423. delta /= MOUSE_LINES_PER_PAGE;
  424. }
  425. return delta;
  426. }
  427. function isValidRotation(angle) {
  428. return Number.isInteger(angle) && angle % 90 === 0;
  429. }
  430. function cloneObj(obj) {
  431. var result = Object.create(null);
  432. for (var i in obj) {
  433. if (Object.prototype.hasOwnProperty.call(obj, i)) {
  434. result[i] = obj[i];
  435. }
  436. }
  437. return result;
  438. }
  439. var WaitOnType = {
  440. EVENT: 'event',
  441. TIMEOUT: 'timeout'
  442. };
  443. function waitOnEventOrTimeout(_ref2) {
  444. var target = _ref2.target,
  445. name = _ref2.name,
  446. _ref2$delay = _ref2.delay,
  447. delay = _ref2$delay === undefined ? 0 : _ref2$delay;
  448. if ((typeof target === 'undefined' ? 'undefined' : _typeof(target)) !== 'object' || !(name && typeof name === 'string') || !(Number.isInteger(delay) && delay >= 0)) {
  449. return Promise.reject(new Error('waitOnEventOrTimeout - invalid paramaters.'));
  450. }
  451. var capability = (0, _pdfjsLib.createPromiseCapability)();
  452. function handler(type) {
  453. if (target instanceof EventBus) {
  454. target.off(name, eventHandler);
  455. } else {
  456. target.removeEventListener(name, eventHandler);
  457. }
  458. if (timeout) {
  459. clearTimeout(timeout);
  460. }
  461. capability.resolve(type);
  462. }
  463. var eventHandler = handler.bind(null, WaitOnType.EVENT);
  464. if (target instanceof EventBus) {
  465. target.on(name, eventHandler);
  466. } else {
  467. target.addEventListener(name, eventHandler);
  468. }
  469. var timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
  470. var timeout = setTimeout(timeoutHandler, delay);
  471. return capability.promise;
  472. }
  473. var animationStarted = new Promise(function (resolve) {
  474. window.requestAnimationFrame(resolve);
  475. });
  476. var EventBus = function () {
  477. function EventBus() {
  478. _classCallCheck(this, EventBus);
  479. this._listeners = Object.create(null);
  480. }
  481. _createClass(EventBus, [{
  482. key: 'on',
  483. value: function on(eventName, listener) {
  484. var eventListeners = this._listeners[eventName];
  485. if (!eventListeners) {
  486. eventListeners = [];
  487. this._listeners[eventName] = eventListeners;
  488. }
  489. eventListeners.push(listener);
  490. }
  491. }, {
  492. key: 'off',
  493. value: function off(eventName, listener) {
  494. var eventListeners = this._listeners[eventName];
  495. var i = void 0;
  496. if (!eventListeners || (i = eventListeners.indexOf(listener)) < 0) {
  497. return;
  498. }
  499. eventListeners.splice(i, 1);
  500. }
  501. }, {
  502. key: 'dispatch',
  503. value: function dispatch(eventName) {
  504. var eventListeners = this._listeners[eventName];
  505. if (!eventListeners || eventListeners.length === 0) {
  506. return;
  507. }
  508. var args = Array.prototype.slice.call(arguments, 1);
  509. eventListeners.slice(0).forEach(function (listener) {
  510. listener.apply(null, args);
  511. });
  512. }
  513. }]);
  514. return EventBus;
  515. }();
  516. function clamp(v, min, max) {
  517. return Math.min(Math.max(v, min), max);
  518. }
  519. var ProgressBar = function () {
  520. function ProgressBar(id) {
  521. var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  522. height = _ref3.height,
  523. width = _ref3.width,
  524. units = _ref3.units;
  525. _classCallCheck(this, ProgressBar);
  526. this.visible = true;
  527. this.div = document.querySelector(id + ' .progress');
  528. this.bar = this.div.parentNode;
  529. this.height = height || 100;
  530. this.width = width || 100;
  531. this.units = units || '%';
  532. this.div.style.height = this.height + this.units;
  533. this.percent = 0;
  534. }
  535. _createClass(ProgressBar, [{
  536. key: '_updateBar',
  537. value: function _updateBar() {
  538. if (this._indeterminate) {
  539. this.div.classList.add('indeterminate');
  540. this.div.style.width = this.width + this.units;
  541. return;
  542. }
  543. this.div.classList.remove('indeterminate');
  544. var progressSize = this.width * this._percent / 100;
  545. this.div.style.width = progressSize + this.units;
  546. }
  547. }, {
  548. key: 'setWidth',
  549. value: function setWidth(viewer) {
  550. if (!viewer) {
  551. return;
  552. }
  553. var container = viewer.parentNode;
  554. var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  555. if (scrollbarWidth > 0) {
  556. this.bar.setAttribute('style', 'width: calc(100% - ' + scrollbarWidth + 'px);');
  557. }
  558. }
  559. }, {
  560. key: 'hide',
  561. value: function hide() {
  562. if (!this.visible) {
  563. return;
  564. }
  565. this.visible = false;
  566. this.bar.classList.add('hidden');
  567. document.body.classList.remove('loadingInProgress');
  568. }
  569. }, {
  570. key: 'show',
  571. value: function show() {
  572. if (this.visible) {
  573. return;
  574. }
  575. this.visible = true;
  576. document.body.classList.add('loadingInProgress');
  577. this.bar.classList.remove('hidden');
  578. }
  579. }, {
  580. key: 'percent',
  581. get: function get() {
  582. return this._percent;
  583. },
  584. set: function set(val) {
  585. this._indeterminate = isNaN(val);
  586. this._percent = clamp(val, 0, 100);
  587. this._updateBar();
  588. }
  589. }]);
  590. return ProgressBar;
  591. }();
  592. exports.CSS_UNITS = CSS_UNITS;
  593. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  594. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  595. exports.MIN_SCALE = MIN_SCALE;
  596. exports.MAX_SCALE = MAX_SCALE;
  597. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  598. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  599. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  600. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  601. exports.isValidRotation = isValidRotation;
  602. exports.isFileSchema = isFileSchema;
  603. exports.cloneObj = cloneObj;
  604. exports.PresentationModeState = PresentationModeState;
  605. exports.RendererType = RendererType;
  606. exports.TextLayerMode = TextLayerMode;
  607. exports.NullL10n = NullL10n;
  608. exports.EventBus = EventBus;
  609. exports.ProgressBar = ProgressBar;
  610. exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
  611. exports.noContextMenuHandler = noContextMenuHandler;
  612. exports.parseQueryString = parseQueryString;
  613. exports.getVisibleElements = getVisibleElements;
  614. exports.roundToDivide = roundToDivide;
  615. exports.getPageSizeInches = getPageSizeInches;
  616. exports.approximateFraction = approximateFraction;
  617. exports.getOutputScale = getOutputScale;
  618. exports.scrollIntoView = scrollIntoView;
  619. exports.watchScroll = watchScroll;
  620. exports.binarySearchFirstItem = binarySearchFirstItem;
  621. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  622. exports.animationStarted = animationStarted;
  623. exports.WaitOnType = WaitOnType;
  624. exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
  625. /***/ }),
  626. /* 1 */
  627. /***/ (function(module, exports, __w_pdfjs_require__) {
  628. "use strict";
  629. var pdfjsLib = void 0;
  630. if (typeof window !== 'undefined' && window['pdfjs-dist/build/pdf']) {
  631. pdfjsLib = window['pdfjs-dist/build/pdf'];
  632. } else {
  633. pdfjsLib = require('../build/pdf.js');
  634. }
  635. module.exports = pdfjsLib;
  636. /***/ }),
  637. /* 2 */
  638. /***/ (function(module, exports, __w_pdfjs_require__) {
  639. "use strict";
  640. Object.defineProperty(exports, "__esModule", {
  641. value: true
  642. });
  643. exports.getGlobalEventBus = exports.attachDOMEventsToEventBus = undefined;
  644. var _ui_utils = __w_pdfjs_require__(0);
  645. function attachDOMEventsToEventBus(eventBus) {
  646. eventBus.on('documentload', function () {
  647. var event = document.createEvent('CustomEvent');
  648. event.initCustomEvent('documentload', true, true, {});
  649. window.dispatchEvent(event);
  650. });
  651. eventBus.on('pagerendered', function (evt) {
  652. var event = document.createEvent('CustomEvent');
  653. event.initCustomEvent('pagerendered', true, true, {
  654. pageNumber: evt.pageNumber,
  655. cssTransform: evt.cssTransform
  656. });
  657. evt.source.div.dispatchEvent(event);
  658. });
  659. eventBus.on('textlayerrendered', function (evt) {
  660. var event = document.createEvent('CustomEvent');
  661. event.initCustomEvent('textlayerrendered', true, true, { pageNumber: evt.pageNumber });
  662. evt.source.textLayerDiv.dispatchEvent(event);
  663. });
  664. eventBus.on('pagechange', function (evt) {
  665. var event = document.createEvent('UIEvents');
  666. event.initUIEvent('pagechange', true, true, window, 0);
  667. event.pageNumber = evt.pageNumber;
  668. evt.source.container.dispatchEvent(event);
  669. });
  670. eventBus.on('pagesinit', function (evt) {
  671. var event = document.createEvent('CustomEvent');
  672. event.initCustomEvent('pagesinit', true, true, null);
  673. evt.source.container.dispatchEvent(event);
  674. });
  675. eventBus.on('pagesloaded', function (evt) {
  676. var event = document.createEvent('CustomEvent');
  677. event.initCustomEvent('pagesloaded', true, true, { pagesCount: evt.pagesCount });
  678. evt.source.container.dispatchEvent(event);
  679. });
  680. eventBus.on('scalechange', function (evt) {
  681. var event = document.createEvent('UIEvents');
  682. event.initUIEvent('scalechange', true, true, window, 0);
  683. event.scale = evt.scale;
  684. event.presetValue = evt.presetValue;
  685. evt.source.container.dispatchEvent(event);
  686. });
  687. eventBus.on('updateviewarea', function (evt) {
  688. var event = document.createEvent('UIEvents');
  689. event.initUIEvent('updateviewarea', true, true, window, 0);
  690. event.location = evt.location;
  691. evt.source.container.dispatchEvent(event);
  692. });
  693. eventBus.on('find', function (evt) {
  694. if (evt.source === window) {
  695. return;
  696. }
  697. var event = document.createEvent('CustomEvent');
  698. event.initCustomEvent('find' + evt.type, true, true, {
  699. query: evt.query,
  700. phraseSearch: evt.phraseSearch,
  701. caseSensitive: evt.caseSensitive,
  702. highlightAll: evt.highlightAll,
  703. findPrevious: evt.findPrevious
  704. });
  705. window.dispatchEvent(event);
  706. });
  707. eventBus.on('attachmentsloaded', function (evt) {
  708. var event = document.createEvent('CustomEvent');
  709. event.initCustomEvent('attachmentsloaded', true, true, { attachmentsCount: evt.attachmentsCount });
  710. evt.source.container.dispatchEvent(event);
  711. });
  712. eventBus.on('sidebarviewchanged', function (evt) {
  713. var event = document.createEvent('CustomEvent');
  714. event.initCustomEvent('sidebarviewchanged', true, true, { view: evt.view });
  715. evt.source.outerContainer.dispatchEvent(event);
  716. });
  717. eventBus.on('pagemode', function (evt) {
  718. var event = document.createEvent('CustomEvent');
  719. event.initCustomEvent('pagemode', true, true, { mode: evt.mode });
  720. evt.source.pdfViewer.container.dispatchEvent(event);
  721. });
  722. eventBus.on('namedaction', function (evt) {
  723. var event = document.createEvent('CustomEvent');
  724. event.initCustomEvent('namedaction', true, true, { action: evt.action });
  725. evt.source.pdfViewer.container.dispatchEvent(event);
  726. });
  727. eventBus.on('presentationmodechanged', function (evt) {
  728. var event = document.createEvent('CustomEvent');
  729. event.initCustomEvent('presentationmodechanged', true, true, {
  730. active: evt.active,
  731. switchInProgress: evt.switchInProgress
  732. });
  733. window.dispatchEvent(event);
  734. });
  735. eventBus.on('outlineloaded', function (evt) {
  736. var event = document.createEvent('CustomEvent');
  737. event.initCustomEvent('outlineloaded', true, true, { outlineCount: evt.outlineCount });
  738. evt.source.container.dispatchEvent(event);
  739. });
  740. }
  741. var globalEventBus = null;
  742. function getGlobalEventBus() {
  743. if (globalEventBus) {
  744. return globalEventBus;
  745. }
  746. globalEventBus = new _ui_utils.EventBus();
  747. attachDOMEventsToEventBus(globalEventBus);
  748. return globalEventBus;
  749. }
  750. exports.attachDOMEventsToEventBus = attachDOMEventsToEventBus;
  751. exports.getGlobalEventBus = getGlobalEventBus;
  752. /***/ }),
  753. /* 3 */
  754. /***/ (function(module, exports, __w_pdfjs_require__) {
  755. "use strict";
  756. Object.defineProperty(exports, "__esModule", {
  757. value: true
  758. });
  759. exports.SimpleLinkService = exports.PDFLinkService = undefined;
  760. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  761. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  762. var _dom_events = __w_pdfjs_require__(2);
  763. var _ui_utils = __w_pdfjs_require__(0);
  764. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  765. var PDFLinkService = function () {
  766. function PDFLinkService() {
  767. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  768. eventBus = _ref.eventBus,
  769. _ref$externalLinkTarg = _ref.externalLinkTarget,
  770. externalLinkTarget = _ref$externalLinkTarg === undefined ? null : _ref$externalLinkTarg,
  771. _ref$externalLinkRel = _ref.externalLinkRel,
  772. externalLinkRel = _ref$externalLinkRel === undefined ? null : _ref$externalLinkRel;
  773. _classCallCheck(this, PDFLinkService);
  774. this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)();
  775. this.externalLinkTarget = externalLinkTarget;
  776. this.externalLinkRel = externalLinkRel;
  777. this.baseUrl = null;
  778. this.pdfDocument = null;
  779. this.pdfViewer = null;
  780. this.pdfHistory = null;
  781. this._pagesRefCache = null;
  782. }
  783. _createClass(PDFLinkService, [{
  784. key: 'setDocument',
  785. value: function setDocument(pdfDocument, baseUrl) {
  786. this.baseUrl = baseUrl;
  787. this.pdfDocument = pdfDocument;
  788. this._pagesRefCache = Object.create(null);
  789. }
  790. }, {
  791. key: 'setViewer',
  792. value: function setViewer(pdfViewer) {
  793. this.pdfViewer = pdfViewer;
  794. }
  795. }, {
  796. key: 'setHistory',
  797. value: function setHistory(pdfHistory) {
  798. this.pdfHistory = pdfHistory;
  799. }
  800. }, {
  801. key: 'navigateTo',
  802. value: function navigateTo(dest) {
  803. var _this = this;
  804. var goToDestination = function goToDestination(_ref2) {
  805. var namedDest = _ref2.namedDest,
  806. explicitDest = _ref2.explicitDest;
  807. var destRef = explicitDest[0],
  808. pageNumber = void 0;
  809. if (destRef instanceof Object) {
  810. pageNumber = _this._cachedPageNumber(destRef);
  811. if (pageNumber === null) {
  812. _this.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
  813. _this.cachePageRef(pageIndex + 1, destRef);
  814. goToDestination({
  815. namedDest: namedDest,
  816. explicitDest: explicitDest
  817. });
  818. }).catch(function () {
  819. console.error('PDFLinkService.navigateTo: "' + destRef + '" is not ' + ('a valid page reference, for dest="' + dest + '".'));
  820. });
  821. return;
  822. }
  823. } else if (Number.isInteger(destRef)) {
  824. pageNumber = destRef + 1;
  825. } else {
  826. console.error('PDFLinkService.navigateTo: "' + destRef + '" is not ' + ('a valid destination reference, for dest="' + dest + '".'));
  827. return;
  828. }
  829. if (!pageNumber || pageNumber < 1 || pageNumber > _this.pagesCount) {
  830. console.error('PDFLinkService.navigateTo: "' + pageNumber + '" is not ' + ('a valid page number, for dest="' + dest + '".'));
  831. return;
  832. }
  833. if (_this.pdfHistory) {
  834. _this.pdfHistory.pushCurrentPosition();
  835. _this.pdfHistory.push({
  836. namedDest: namedDest,
  837. explicitDest: explicitDest,
  838. pageNumber: pageNumber
  839. });
  840. }
  841. _this.pdfViewer.scrollPageIntoView({
  842. pageNumber: pageNumber,
  843. destArray: explicitDest
  844. });
  845. };
  846. new Promise(function (resolve, reject) {
  847. if (typeof dest === 'string') {
  848. _this.pdfDocument.getDestination(dest).then(function (destArray) {
  849. resolve({
  850. namedDest: dest,
  851. explicitDest: destArray
  852. });
  853. });
  854. return;
  855. }
  856. resolve({
  857. namedDest: '',
  858. explicitDest: dest
  859. });
  860. }).then(function (data) {
  861. if (!(data.explicitDest instanceof Array)) {
  862. console.error('PDFLinkService.navigateTo: "' + data.explicitDest + '" is' + (' not a valid destination array, for dest="' + dest + '".'));
  863. return;
  864. }
  865. goToDestination(data);
  866. });
  867. }
  868. }, {
  869. key: 'getDestinationHash',
  870. value: function getDestinationHash(dest) {
  871. if (typeof dest === 'string') {
  872. return this.getAnchorUrl('#' + escape(dest));
  873. }
  874. if (dest instanceof Array) {
  875. var str = JSON.stringify(dest);
  876. return this.getAnchorUrl('#' + escape(str));
  877. }
  878. return this.getAnchorUrl('');
  879. }
  880. }, {
  881. key: 'getAnchorUrl',
  882. value: function getAnchorUrl(anchor) {
  883. return (this.baseUrl || '') + anchor;
  884. }
  885. }, {
  886. key: 'setHash',
  887. value: function setHash(hash) {
  888. var pageNumber = void 0,
  889. dest = void 0;
  890. if (hash.includes('=')) {
  891. var params = (0, _ui_utils.parseQueryString)(hash);
  892. if ('search' in params) {
  893. this.eventBus.dispatch('findfromurlhash', {
  894. source: this,
  895. query: params['search'].replace(/"/g, ''),
  896. phraseSearch: params['phrase'] === 'true'
  897. });
  898. }
  899. if ('nameddest' in params) {
  900. this.navigateTo(params.nameddest);
  901. return;
  902. }
  903. if ('page' in params) {
  904. pageNumber = params.page | 0 || 1;
  905. }
  906. if ('zoom' in params) {
  907. var zoomArgs = params.zoom.split(',');
  908. var zoomArg = zoomArgs[0];
  909. var zoomArgNumber = parseFloat(zoomArg);
  910. if (!zoomArg.includes('Fit')) {
  911. dest = [null, { name: 'XYZ' }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
  912. } else {
  913. if (zoomArg === 'Fit' || zoomArg === 'FitB') {
  914. dest = [null, { name: zoomArg }];
  915. } else if (zoomArg === 'FitH' || zoomArg === 'FitBH' || zoomArg === 'FitV' || zoomArg === 'FitBV') {
  916. dest = [null, { name: zoomArg }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
  917. } else if (zoomArg === 'FitR') {
  918. if (zoomArgs.length !== 5) {
  919. console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
  920. } else {
  921. dest = [null, { name: zoomArg }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
  922. }
  923. } else {
  924. console.error('PDFLinkService.setHash: "' + zoomArg + '" is not ' + 'a valid zoom value.');
  925. }
  926. }
  927. }
  928. if (dest) {
  929. this.pdfViewer.scrollPageIntoView({
  930. pageNumber: pageNumber || this.page,
  931. destArray: dest,
  932. allowNegativeOffset: true
  933. });
  934. } else if (pageNumber) {
  935. this.page = pageNumber;
  936. }
  937. if ('pagemode' in params) {
  938. this.eventBus.dispatch('pagemode', {
  939. source: this,
  940. mode: params.pagemode
  941. });
  942. }
  943. } else {
  944. dest = unescape(hash);
  945. try {
  946. dest = JSON.parse(dest);
  947. if (!(dest instanceof Array)) {
  948. dest = dest.toString();
  949. }
  950. } catch (ex) {}
  951. if (typeof dest === 'string' || isValidExplicitDestination(dest)) {
  952. this.navigateTo(dest);
  953. return;
  954. }
  955. console.error('PDFLinkService.setHash: "' + unescape(hash) + '" is not ' + 'a valid destination.');
  956. }
  957. }
  958. }, {
  959. key: 'executeNamedAction',
  960. value: function executeNamedAction(action) {
  961. switch (action) {
  962. case 'GoBack':
  963. if (this.pdfHistory) {
  964. this.pdfHistory.back();
  965. }
  966. break;
  967. case 'GoForward':
  968. if (this.pdfHistory) {
  969. this.pdfHistory.forward();
  970. }
  971. break;
  972. case 'NextPage':
  973. if (this.page < this.pagesCount) {
  974. this.page++;
  975. }
  976. break;
  977. case 'PrevPage':
  978. if (this.page > 1) {
  979. this.page--;
  980. }
  981. break;
  982. case 'LastPage':
  983. this.page = this.pagesCount;
  984. break;
  985. case 'FirstPage':
  986. this.page = 1;
  987. break;
  988. default:
  989. break;
  990. }
  991. this.eventBus.dispatch('namedaction', {
  992. source: this,
  993. action: action
  994. });
  995. }
  996. }, {
  997. key: 'onFileAttachmentAnnotation',
  998. value: function onFileAttachmentAnnotation(_ref3) {
  999. var id = _ref3.id,
  1000. filename = _ref3.filename,
  1001. content = _ref3.content;
  1002. this.eventBus.dispatch('fileattachmentannotation', {
  1003. source: this,
  1004. id: id,
  1005. filename: filename,
  1006. content: content
  1007. });
  1008. }
  1009. }, {
  1010. key: 'cachePageRef',
  1011. value: function cachePageRef(pageNum, pageRef) {
  1012. if (!pageRef) {
  1013. return;
  1014. }
  1015. var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
  1016. this._pagesRefCache[refStr] = pageNum;
  1017. }
  1018. }, {
  1019. key: '_cachedPageNumber',
  1020. value: function _cachedPageNumber(pageRef) {
  1021. var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
  1022. return this._pagesRefCache && this._pagesRefCache[refStr] || null;
  1023. }
  1024. }, {
  1025. key: 'pagesCount',
  1026. get: function get() {
  1027. return this.pdfDocument ? this.pdfDocument.numPages : 0;
  1028. }
  1029. }, {
  1030. key: 'page',
  1031. get: function get() {
  1032. return this.pdfViewer.currentPageNumber;
  1033. },
  1034. set: function set(value) {
  1035. this.pdfViewer.currentPageNumber = value;
  1036. }
  1037. }, {
  1038. key: 'rotation',
  1039. get: function get() {
  1040. return this.pdfViewer.pagesRotation;
  1041. },
  1042. set: function set(value) {
  1043. this.pdfViewer.pagesRotation = value;
  1044. }
  1045. }]);
  1046. return PDFLinkService;
  1047. }();
  1048. function isValidExplicitDestination(dest) {
  1049. if (!(dest instanceof Array)) {
  1050. return false;
  1051. }
  1052. var destLength = dest.length,
  1053. allowNull = true;
  1054. if (destLength < 2) {
  1055. return false;
  1056. }
  1057. var page = dest[0];
  1058. if (!((typeof page === 'undefined' ? 'undefined' : _typeof(page)) === 'object' && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
  1059. return false;
  1060. }
  1061. var zoom = dest[1];
  1062. if (!((typeof zoom === 'undefined' ? 'undefined' : _typeof(zoom)) === 'object' && typeof zoom.name === 'string')) {
  1063. return false;
  1064. }
  1065. switch (zoom.name) {
  1066. case 'XYZ':
  1067. if (destLength !== 5) {
  1068. return false;
  1069. }
  1070. break;
  1071. case 'Fit':
  1072. case 'FitB':
  1073. return destLength === 2;
  1074. case 'FitH':
  1075. case 'FitBH':
  1076. case 'FitV':
  1077. case 'FitBV':
  1078. if (destLength !== 3) {
  1079. return false;
  1080. }
  1081. break;
  1082. case 'FitR':
  1083. if (destLength !== 6) {
  1084. return false;
  1085. }
  1086. allowNull = false;
  1087. break;
  1088. default:
  1089. return false;
  1090. }
  1091. for (var i = 2; i < destLength; i++) {
  1092. var param = dest[i];
  1093. if (!(typeof param === 'number' || allowNull && param === null)) {
  1094. return false;
  1095. }
  1096. }
  1097. return true;
  1098. }
  1099. var SimpleLinkService = function () {
  1100. function SimpleLinkService() {
  1101. _classCallCheck(this, SimpleLinkService);
  1102. this.externalLinkTarget = null;
  1103. this.externalLinkRel = null;
  1104. }
  1105. _createClass(SimpleLinkService, [{
  1106. key: 'navigateTo',
  1107. value: function navigateTo(dest) {}
  1108. }, {
  1109. key: 'getDestinationHash',
  1110. value: function getDestinationHash(dest) {
  1111. return '#';
  1112. }
  1113. }, {
  1114. key: 'getAnchorUrl',
  1115. value: function getAnchorUrl(hash) {
  1116. return '#';
  1117. }
  1118. }, {
  1119. key: 'setHash',
  1120. value: function setHash(hash) {}
  1121. }, {
  1122. key: 'executeNamedAction',
  1123. value: function executeNamedAction(action) {}
  1124. }, {
  1125. key: 'onFileAttachmentAnnotation',
  1126. value: function onFileAttachmentAnnotation(_ref4) {
  1127. var id = _ref4.id,
  1128. filename = _ref4.filename,
  1129. content = _ref4.content;
  1130. }
  1131. }, {
  1132. key: 'cachePageRef',
  1133. value: function cachePageRef(pageNum, pageRef) {}
  1134. }, {
  1135. key: 'page',
  1136. get: function get() {
  1137. return 0;
  1138. },
  1139. set: function set(value) {}
  1140. }, {
  1141. key: 'rotation',
  1142. get: function get() {
  1143. return 0;
  1144. },
  1145. set: function set(value) {}
  1146. }]);
  1147. return SimpleLinkService;
  1148. }();
  1149. exports.PDFLinkService = PDFLinkService;
  1150. exports.SimpleLinkService = SimpleLinkService;
  1151. /***/ }),
  1152. /* 4 */
  1153. /***/ (function(module, exports, __w_pdfjs_require__) {
  1154. "use strict";
  1155. Object.defineProperty(exports, "__esModule", {
  1156. value: true
  1157. });
  1158. exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = undefined;
  1159. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1160. var _pdfjsLib = __w_pdfjs_require__(1);
  1161. var _ui_utils = __w_pdfjs_require__(0);
  1162. var _pdf_link_service = __w_pdfjs_require__(3);
  1163. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1164. var AnnotationLayerBuilder = function () {
  1165. function AnnotationLayerBuilder(_ref) {
  1166. var pageDiv = _ref.pageDiv,
  1167. pdfPage = _ref.pdfPage,
  1168. linkService = _ref.linkService,
  1169. downloadManager = _ref.downloadManager,
  1170. _ref$imageResourcesPa = _ref.imageResourcesPath,
  1171. imageResourcesPath = _ref$imageResourcesPa === undefined ? '' : _ref$imageResourcesPa,
  1172. _ref$renderInteractiv = _ref.renderInteractiveForms,
  1173. renderInteractiveForms = _ref$renderInteractiv === undefined ? false : _ref$renderInteractiv,
  1174. _ref$l10n = _ref.l10n,
  1175. l10n = _ref$l10n === undefined ? _ui_utils.NullL10n : _ref$l10n;
  1176. _classCallCheck(this, AnnotationLayerBuilder);
  1177. this.pageDiv = pageDiv;
  1178. this.pdfPage = pdfPage;
  1179. this.linkService = linkService;
  1180. this.downloadManager = downloadManager;
  1181. this.imageResourcesPath = imageResourcesPath;
  1182. this.renderInteractiveForms = renderInteractiveForms;
  1183. this.l10n = l10n;
  1184. this.div = null;
  1185. this._cancelled = false;
  1186. }
  1187. _createClass(AnnotationLayerBuilder, [{
  1188. key: 'render',
  1189. value: function render(viewport) {
  1190. var _this = this;
  1191. var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'display';
  1192. this.pdfPage.getAnnotations({ intent: intent }).then(function (annotations) {
  1193. if (_this._cancelled) {
  1194. return;
  1195. }
  1196. var parameters = {
  1197. viewport: viewport.clone({ dontFlip: true }),
  1198. div: _this.div,
  1199. annotations: annotations,
  1200. page: _this.pdfPage,
  1201. imageResourcesPath: _this.imageResourcesPath,
  1202. renderInteractiveForms: _this.renderInteractiveForms,
  1203. linkService: _this.linkService,
  1204. downloadManager: _this.downloadManager
  1205. };
  1206. if (_this.div) {
  1207. _pdfjsLib.AnnotationLayer.update(parameters);
  1208. } else {
  1209. if (annotations.length === 0) {
  1210. return;
  1211. }
  1212. _this.div = document.createElement('div');
  1213. _this.div.className = 'annotationLayer';
  1214. _this.pageDiv.appendChild(_this.div);
  1215. parameters.div = _this.div;
  1216. _pdfjsLib.AnnotationLayer.render(parameters);
  1217. _this.l10n.translate(_this.div);
  1218. }
  1219. });
  1220. }
  1221. }, {
  1222. key: 'cancel',
  1223. value: function cancel() {
  1224. this._cancelled = true;
  1225. }
  1226. }, {
  1227. key: 'hide',
  1228. value: function hide() {
  1229. if (!this.div) {
  1230. return;
  1231. }
  1232. this.div.setAttribute('hidden', 'true');
  1233. }
  1234. }]);
  1235. return AnnotationLayerBuilder;
  1236. }();
  1237. var DefaultAnnotationLayerFactory = function () {
  1238. function DefaultAnnotationLayerFactory() {
  1239. _classCallCheck(this, DefaultAnnotationLayerFactory);
  1240. }
  1241. _createClass(DefaultAnnotationLayerFactory, [{
  1242. key: 'createAnnotationLayerBuilder',
  1243. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  1244. var imageResourcesPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  1245. var renderInteractiveForms = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  1246. var l10n = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _ui_utils.NullL10n;
  1247. return new AnnotationLayerBuilder({
  1248. pageDiv: pageDiv,
  1249. pdfPage: pdfPage,
  1250. imageResourcesPath: imageResourcesPath,
  1251. renderInteractiveForms: renderInteractiveForms,
  1252. linkService: new _pdf_link_service.SimpleLinkService(),
  1253. l10n: l10n
  1254. });
  1255. }
  1256. }]);
  1257. return DefaultAnnotationLayerFactory;
  1258. }();
  1259. exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
  1260. exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
  1261. /***/ }),
  1262. /* 5 */
  1263. /***/ (function(module, exports, __w_pdfjs_require__) {
  1264. "use strict";
  1265. Object.defineProperty(exports, "__esModule", {
  1266. value: true
  1267. });
  1268. exports.DefaultTextLayerFactory = exports.TextLayerBuilder = undefined;
  1269. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1270. var _dom_events = __w_pdfjs_require__(2);
  1271. var _pdfjsLib = __w_pdfjs_require__(1);
  1272. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1273. var EXPAND_DIVS_TIMEOUT = 300;
  1274. var TextLayerBuilder = function () {
  1275. function TextLayerBuilder(_ref) {
  1276. var textLayerDiv = _ref.textLayerDiv,
  1277. eventBus = _ref.eventBus,
  1278. pageIndex = _ref.pageIndex,
  1279. viewport = _ref.viewport,
  1280. _ref$findController = _ref.findController,
  1281. findController = _ref$findController === undefined ? null : _ref$findController,
  1282. _ref$enhanceTextSelec = _ref.enhanceTextSelection,
  1283. enhanceTextSelection = _ref$enhanceTextSelec === undefined ? false : _ref$enhanceTextSelec;
  1284. _classCallCheck(this, TextLayerBuilder);
  1285. this.textLayerDiv = textLayerDiv;
  1286. this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)();
  1287. this.textContent = null;
  1288. this.textContentItemsStr = [];
  1289. this.textContentStream = null;
  1290. this.renderingDone = false;
  1291. this.pageIdx = pageIndex;
  1292. this.pageNumber = this.pageIdx + 1;
  1293. this.matches = [];
  1294. this.viewport = viewport;
  1295. this.textDivs = [];
  1296. this.findController = findController;
  1297. this.textLayerRenderTask = null;
  1298. this.enhanceTextSelection = enhanceTextSelection;
  1299. this._bindMouse();
  1300. }
  1301. _createClass(TextLayerBuilder, [{
  1302. key: '_finishRendering',
  1303. value: function _finishRendering() {
  1304. this.renderingDone = true;
  1305. if (!this.enhanceTextSelection) {
  1306. var endOfContent = document.createElement('div');
  1307. endOfContent.className = 'endOfContent';
  1308. this.textLayerDiv.appendChild(endOfContent);
  1309. }
  1310. this.eventBus.dispatch('textlayerrendered', {
  1311. source: this,
  1312. pageNumber: this.pageNumber,
  1313. numTextDivs: this.textDivs.length
  1314. });
  1315. }
  1316. }, {
  1317. key: 'render',
  1318. value: function render() {
  1319. var _this = this;
  1320. var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  1321. if (!(this.textContent || this.textContentStream) || this.renderingDone) {
  1322. return;
  1323. }
  1324. this.cancel();
  1325. this.textDivs = [];
  1326. var textLayerFrag = document.createDocumentFragment();
  1327. this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
  1328. textContent: this.textContent,
  1329. textContentStream: this.textContentStream,
  1330. container: textLayerFrag,
  1331. viewport: this.viewport,
  1332. textDivs: this.textDivs,
  1333. textContentItemsStr: this.textContentItemsStr,
  1334. timeout: timeout,
  1335. enhanceTextSelection: this.enhanceTextSelection
  1336. });
  1337. this.textLayerRenderTask.promise.then(function () {
  1338. _this.textLayerDiv.appendChild(textLayerFrag);
  1339. _this._finishRendering();
  1340. _this.updateMatches();
  1341. }, function (reason) {});
  1342. }
  1343. }, {
  1344. key: 'cancel',
  1345. value: function cancel() {
  1346. if (this.textLayerRenderTask) {
  1347. this.textLayerRenderTask.cancel();
  1348. this.textLayerRenderTask = null;
  1349. }
  1350. }
  1351. }, {
  1352. key: 'setTextContentStream',
  1353. value: function setTextContentStream(readableStream) {
  1354. this.cancel();
  1355. this.textContentStream = readableStream;
  1356. }
  1357. }, {
  1358. key: 'setTextContent',
  1359. value: function setTextContent(textContent) {
  1360. this.cancel();
  1361. this.textContent = textContent;
  1362. }
  1363. }, {
  1364. key: 'convertMatches',
  1365. value: function convertMatches(matches, matchesLength) {
  1366. var i = 0;
  1367. var iIndex = 0;
  1368. var textContentItemsStr = this.textContentItemsStr;
  1369. var end = textContentItemsStr.length - 1;
  1370. var queryLen = this.findController === null ? 0 : this.findController.state.query.length;
  1371. var ret = [];
  1372. if (!matches) {
  1373. return ret;
  1374. }
  1375. for (var m = 0, len = matches.length; m < len; m++) {
  1376. var matchIdx = matches[m];
  1377. while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
  1378. iIndex += textContentItemsStr[i].length;
  1379. i++;
  1380. }
  1381. if (i === textContentItemsStr.length) {
  1382. console.error('Could not find a matching mapping');
  1383. }
  1384. var match = {
  1385. begin: {
  1386. divIdx: i,
  1387. offset: matchIdx - iIndex
  1388. }
  1389. };
  1390. if (matchesLength) {
  1391. matchIdx += matchesLength[m];
  1392. } else {
  1393. matchIdx += queryLen;
  1394. }
  1395. while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
  1396. iIndex += textContentItemsStr[i].length;
  1397. i++;
  1398. }
  1399. match.end = {
  1400. divIdx: i,
  1401. offset: matchIdx - iIndex
  1402. };
  1403. ret.push(match);
  1404. }
  1405. return ret;
  1406. }
  1407. }, {
  1408. key: 'renderMatches',
  1409. value: function renderMatches(matches) {
  1410. if (matches.length === 0) {
  1411. return;
  1412. }
  1413. var textContentItemsStr = this.textContentItemsStr;
  1414. var textDivs = this.textDivs;
  1415. var prevEnd = null;
  1416. var pageIdx = this.pageIdx;
  1417. var isSelectedPage = this.findController === null ? false : pageIdx === this.findController.selected.pageIdx;
  1418. var selectedMatchIdx = this.findController === null ? -1 : this.findController.selected.matchIdx;
  1419. var highlightAll = this.findController === null ? false : this.findController.state.highlightAll;
  1420. var infinity = {
  1421. divIdx: -1,
  1422. offset: undefined
  1423. };
  1424. function beginText(begin, className) {
  1425. var divIdx = begin.divIdx;
  1426. textDivs[divIdx].textContent = '';
  1427. appendTextToDiv(divIdx, 0, begin.offset, className);
  1428. }
  1429. function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
  1430. var div = textDivs[divIdx];
  1431. var content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
  1432. var node = document.createTextNode(content);
  1433. if (className) {
  1434. var span = document.createElement('span');
  1435. span.className = className;
  1436. span.appendChild(node);
  1437. div.appendChild(span);
  1438. return;
  1439. }
  1440. div.appendChild(node);
  1441. }
  1442. var i0 = selectedMatchIdx,
  1443. i1 = i0 + 1;
  1444. if (highlightAll) {
  1445. i0 = 0;
  1446. i1 = matches.length;
  1447. } else if (!isSelectedPage) {
  1448. return;
  1449. }
  1450. for (var i = i0; i < i1; i++) {
  1451. var match = matches[i];
  1452. var begin = match.begin;
  1453. var end = match.end;
  1454. var isSelected = isSelectedPage && i === selectedMatchIdx;
  1455. var highlightSuffix = isSelected ? ' selected' : '';
  1456. if (this.findController) {
  1457. this.findController.updateMatchPosition(pageIdx, i, textDivs, begin.divIdx);
  1458. }
  1459. if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
  1460. if (prevEnd !== null) {
  1461. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  1462. }
  1463. beginText(begin);
  1464. } else {
  1465. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
  1466. }
  1467. if (begin.divIdx === end.divIdx) {
  1468. appendTextToDiv(begin.divIdx, begin.offset, end.offset, 'highlight' + highlightSuffix);
  1469. } else {
  1470. appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, 'highlight begin' + highlightSuffix);
  1471. for (var n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
  1472. textDivs[n0].className = 'highlight middle' + highlightSuffix;
  1473. }
  1474. beginText(end, 'highlight end' + highlightSuffix);
  1475. }
  1476. prevEnd = end;
  1477. }
  1478. if (prevEnd) {
  1479. appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
  1480. }
  1481. }
  1482. }, {
  1483. key: 'updateMatches',
  1484. value: function updateMatches() {
  1485. if (!this.renderingDone) {
  1486. return;
  1487. }
  1488. var matches = this.matches;
  1489. var textDivs = this.textDivs;
  1490. var textContentItemsStr = this.textContentItemsStr;
  1491. var clearedUntilDivIdx = -1;
  1492. for (var i = 0, len = matches.length; i < len; i++) {
  1493. var match = matches[i];
  1494. var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
  1495. for (var n = begin, end = match.end.divIdx; n <= end; n++) {
  1496. var div = textDivs[n];
  1497. div.textContent = textContentItemsStr[n];
  1498. div.className = '';
  1499. }
  1500. clearedUntilDivIdx = match.end.divIdx + 1;
  1501. }
  1502. if (this.findController === null || !this.findController.active) {
  1503. return;
  1504. }
  1505. var pageMatches = void 0,
  1506. pageMatchesLength = void 0;
  1507. if (this.findController !== null) {
  1508. pageMatches = this.findController.pageMatches[this.pageIdx] || null;
  1509. pageMatchesLength = this.findController.pageMatchesLength ? this.findController.pageMatchesLength[this.pageIdx] || null : null;
  1510. }
  1511. this.matches = this.convertMatches(pageMatches, pageMatchesLength);
  1512. this.renderMatches(this.matches);
  1513. }
  1514. }, {
  1515. key: '_bindMouse',
  1516. value: function _bindMouse() {
  1517. var _this2 = this;
  1518. var div = this.textLayerDiv;
  1519. var expandDivsTimer = null;
  1520. div.addEventListener('mousedown', function (evt) {
  1521. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  1522. _this2.textLayerRenderTask.expandTextDivs(true);
  1523. if (expandDivsTimer) {
  1524. clearTimeout(expandDivsTimer);
  1525. expandDivsTimer = null;
  1526. }
  1527. return;
  1528. }
  1529. var end = div.querySelector('.endOfContent');
  1530. if (!end) {
  1531. return;
  1532. }
  1533. var adjustTop = evt.target !== div;
  1534. adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue('-moz-user-select') !== 'none';
  1535. if (adjustTop) {
  1536. var divBounds = div.getBoundingClientRect();
  1537. var r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
  1538. end.style.top = (r * 100).toFixed(2) + '%';
  1539. }
  1540. end.classList.add('active');
  1541. });
  1542. div.addEventListener('mouseup', function () {
  1543. if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
  1544. expandDivsTimer = setTimeout(function () {
  1545. if (_this2.textLayerRenderTask) {
  1546. _this2.textLayerRenderTask.expandTextDivs(false);
  1547. }
  1548. expandDivsTimer = null;
  1549. }, EXPAND_DIVS_TIMEOUT);
  1550. return;
  1551. }
  1552. var end = div.querySelector('.endOfContent');
  1553. if (!end) {
  1554. return;
  1555. }
  1556. end.style.top = '';
  1557. end.classList.remove('active');
  1558. });
  1559. }
  1560. }]);
  1561. return TextLayerBuilder;
  1562. }();
  1563. var DefaultTextLayerFactory = function () {
  1564. function DefaultTextLayerFactory() {
  1565. _classCallCheck(this, DefaultTextLayerFactory);
  1566. }
  1567. _createClass(DefaultTextLayerFactory, [{
  1568. key: 'createTextLayerBuilder',
  1569. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  1570. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  1571. return new TextLayerBuilder({
  1572. textLayerDiv: textLayerDiv,
  1573. pageIndex: pageIndex,
  1574. viewport: viewport,
  1575. enhanceTextSelection: enhanceTextSelection
  1576. });
  1577. }
  1578. }]);
  1579. return DefaultTextLayerFactory;
  1580. }();
  1581. exports.TextLayerBuilder = TextLayerBuilder;
  1582. exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
  1583. /***/ }),
  1584. /* 6 */
  1585. /***/ (function(module, exports, __w_pdfjs_require__) {
  1586. "use strict";
  1587. Object.defineProperty(exports, "__esModule", {
  1588. value: true
  1589. });
  1590. exports.PDFPageView = undefined;
  1591. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1592. var _ui_utils = __w_pdfjs_require__(0);
  1593. var _pdfjsLib = __w_pdfjs_require__(1);
  1594. var _dom_events = __w_pdfjs_require__(2);
  1595. var _pdf_rendering_queue = __w_pdfjs_require__(7);
  1596. var _viewer_compatibility = __w_pdfjs_require__(15);
  1597. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1598. var MAX_CANVAS_PIXELS = _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216;
  1599. var PDFPageView = function () {
  1600. function PDFPageView(options) {
  1601. _classCallCheck(this, PDFPageView);
  1602. var container = options.container;
  1603. var defaultViewport = options.defaultViewport;
  1604. this.id = options.id;
  1605. this.renderingId = 'page' + this.id;
  1606. this.pdfPage = null;
  1607. this.pageLabel = null;
  1608. this.rotation = 0;
  1609. this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
  1610. this.viewport = defaultViewport;
  1611. this.pdfPageRotate = defaultViewport.rotation;
  1612. this.hasRestrictedScaling = false;
  1613. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  1614. this.imageResourcesPath = options.imageResourcesPath || '';
  1615. this.renderInteractiveForms = options.renderInteractiveForms || false;
  1616. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  1617. this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
  1618. this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)();
  1619. this.renderingQueue = options.renderingQueue;
  1620. this.textLayerFactory = options.textLayerFactory;
  1621. this.annotationLayerFactory = options.annotationLayerFactory;
  1622. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  1623. this.enableWebGL = options.enableWebGL || false;
  1624. this.l10n = options.l10n || _ui_utils.NullL10n;
  1625. this.paintTask = null;
  1626. this.paintedViewportMap = new WeakMap();
  1627. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  1628. this.resume = null;
  1629. this.error = null;
  1630. this.onBeforeDraw = null;
  1631. this.onAfterDraw = null;
  1632. this.annotationLayer = null;
  1633. this.textLayer = null;
  1634. this.zoomLayer = null;
  1635. var div = document.createElement('div');
  1636. div.className = 'page';
  1637. div.style.width = Math.floor(this.viewport.width) + 'px';
  1638. div.style.height = Math.floor(this.viewport.height) + 'px';
  1639. div.setAttribute('data-page-number', this.id);
  1640. this.div = div;
  1641. container.appendChild(div);
  1642. }
  1643. _createClass(PDFPageView, [{
  1644. key: 'setPdfPage',
  1645. value: function setPdfPage(pdfPage) {
  1646. this.pdfPage = pdfPage;
  1647. this.pdfPageRotate = pdfPage.rotate;
  1648. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  1649. this.viewport = pdfPage.getViewport(this.scale * _ui_utils.CSS_UNITS, totalRotation);
  1650. this.stats = pdfPage.stats;
  1651. this.reset();
  1652. }
  1653. }, {
  1654. key: 'destroy',
  1655. value: function destroy() {
  1656. this.reset();
  1657. if (this.pdfPage) {
  1658. this.pdfPage.cleanup();
  1659. }
  1660. }
  1661. }, {
  1662. key: '_resetZoomLayer',
  1663. value: function _resetZoomLayer() {
  1664. var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  1665. if (!this.zoomLayer) {
  1666. return;
  1667. }
  1668. var zoomLayerCanvas = this.zoomLayer.firstChild;
  1669. this.paintedViewportMap.delete(zoomLayerCanvas);
  1670. zoomLayerCanvas.width = 0;
  1671. zoomLayerCanvas.height = 0;
  1672. if (removeFromDOM) {
  1673. this.zoomLayer.remove();
  1674. }
  1675. this.zoomLayer = null;
  1676. }
  1677. }, {
  1678. key: 'reset',
  1679. value: function reset() {
  1680. var keepZoomLayer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  1681. var keepAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  1682. this.cancelRendering(keepAnnotations);
  1683. var div = this.div;
  1684. div.style.width = Math.floor(this.viewport.width) + 'px';
  1685. div.style.height = Math.floor(this.viewport.height) + 'px';
  1686. var childNodes = div.childNodes;
  1687. var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
  1688. var currentAnnotationNode = keepAnnotations && this.annotationLayer && this.annotationLayer.div || null;
  1689. for (var i = childNodes.length - 1; i >= 0; i--) {
  1690. var node = childNodes[i];
  1691. if (currentZoomLayerNode === node || currentAnnotationNode === node) {
  1692. continue;
  1693. }
  1694. div.removeChild(node);
  1695. }
  1696. div.removeAttribute('data-loaded');
  1697. if (currentAnnotationNode) {
  1698. this.annotationLayer.hide();
  1699. } else if (this.annotationLayer) {
  1700. this.annotationLayer.cancel();
  1701. this.annotationLayer = null;
  1702. }
  1703. if (!currentZoomLayerNode) {
  1704. if (this.canvas) {
  1705. this.paintedViewportMap.delete(this.canvas);
  1706. this.canvas.width = 0;
  1707. this.canvas.height = 0;
  1708. delete this.canvas;
  1709. }
  1710. this._resetZoomLayer();
  1711. }
  1712. if (this.svg) {
  1713. this.paintedViewportMap.delete(this.svg);
  1714. delete this.svg;
  1715. }
  1716. this.loadingIconDiv = document.createElement('div');
  1717. this.loadingIconDiv.className = 'loadingIcon';
  1718. div.appendChild(this.loadingIconDiv);
  1719. }
  1720. }, {
  1721. key: 'update',
  1722. value: function update(scale, rotation) {
  1723. this.scale = scale || this.scale;
  1724. if (typeof rotation !== 'undefined') {
  1725. this.rotation = rotation;
  1726. }
  1727. var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
  1728. this.viewport = this.viewport.clone({
  1729. scale: this.scale * _ui_utils.CSS_UNITS,
  1730. rotation: totalRotation
  1731. });
  1732. if (this.svg) {
  1733. this.cssTransform(this.svg, true);
  1734. this.eventBus.dispatch('pagerendered', {
  1735. source: this,
  1736. pageNumber: this.id,
  1737. cssTransform: true
  1738. });
  1739. return;
  1740. }
  1741. var isScalingRestricted = false;
  1742. if (this.canvas && this.maxCanvasPixels > 0) {
  1743. var outputScale = this.outputScale;
  1744. if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > this.maxCanvasPixels) {
  1745. isScalingRestricted = true;
  1746. }
  1747. }
  1748. if (this.canvas) {
  1749. if (this.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
  1750. this.cssTransform(this.canvas, true);
  1751. this.eventBus.dispatch('pagerendered', {
  1752. source: this,
  1753. pageNumber: this.id,
  1754. cssTransform: true
  1755. });
  1756. return;
  1757. }
  1758. if (!this.zoomLayer && !this.canvas.hasAttribute('hidden')) {
  1759. this.zoomLayer = this.canvas.parentNode;
  1760. this.zoomLayer.style.position = 'absolute';
  1761. }
  1762. }
  1763. if (this.zoomLayer) {
  1764. this.cssTransform(this.zoomLayer.firstChild);
  1765. }
  1766. this.reset(true, true);
  1767. }
  1768. }, {
  1769. key: 'cancelRendering',
  1770. value: function cancelRendering() {
  1771. var keepAnnotations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  1772. if (this.paintTask) {
  1773. this.paintTask.cancel();
  1774. this.paintTask = null;
  1775. }
  1776. this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
  1777. this.resume = null;
  1778. if (this.textLayer) {
  1779. this.textLayer.cancel();
  1780. this.textLayer = null;
  1781. }
  1782. if (!keepAnnotations && this.annotationLayer) {
  1783. this.annotationLayer.cancel();
  1784. this.annotationLayer = null;
  1785. }
  1786. }
  1787. }, {
  1788. key: 'cssTransform',
  1789. value: function cssTransform(target) {
  1790. var redrawAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  1791. var width = this.viewport.width;
  1792. var height = this.viewport.height;
  1793. var div = this.div;
  1794. target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + 'px';
  1795. target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + 'px';
  1796. var relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
  1797. var absRotation = Math.abs(relativeRotation);
  1798. var scaleX = 1,
  1799. scaleY = 1;
  1800. if (absRotation === 90 || absRotation === 270) {
  1801. scaleX = height / width;
  1802. scaleY = width / height;
  1803. }
  1804. var cssTransform = 'rotate(' + relativeRotation + 'deg) ' + 'scale(' + scaleX + ',' + scaleY + ')';
  1805. target.style.transform = cssTransform;
  1806. if (this.textLayer) {
  1807. var textLayerViewport = this.textLayer.viewport;
  1808. var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
  1809. var textAbsRotation = Math.abs(textRelativeRotation);
  1810. var scale = width / textLayerViewport.width;
  1811. if (textAbsRotation === 90 || textAbsRotation === 270) {
  1812. scale = width / textLayerViewport.height;
  1813. }
  1814. var textLayerDiv = this.textLayer.textLayerDiv;
  1815. var transX = void 0,
  1816. transY = void 0;
  1817. switch (textAbsRotation) {
  1818. case 0:
  1819. transX = transY = 0;
  1820. break;
  1821. case 90:
  1822. transX = 0;
  1823. transY = '-' + textLayerDiv.style.height;
  1824. break;
  1825. case 180:
  1826. transX = '-' + textLayerDiv.style.width;
  1827. transY = '-' + textLayerDiv.style.height;
  1828. break;
  1829. case 270:
  1830. transX = '-' + textLayerDiv.style.width;
  1831. transY = 0;
  1832. break;
  1833. default:
  1834. console.error('Bad rotation value.');
  1835. break;
  1836. }
  1837. textLayerDiv.style.transform = 'rotate(' + textAbsRotation + 'deg) ' + 'scale(' + scale + ', ' + scale + ') ' + 'translate(' + transX + ', ' + transY + ')';
  1838. textLayerDiv.style.transformOrigin = '0% 0%';
  1839. }
  1840. if (redrawAnnotations && this.annotationLayer) {
  1841. this.annotationLayer.render(this.viewport, 'display');
  1842. }
  1843. }
  1844. }, {
  1845. key: 'getPagePoint',
  1846. value: function getPagePoint(x, y) {
  1847. return this.viewport.convertToPdfPoint(x, y);
  1848. }
  1849. }, {
  1850. key: 'draw',
  1851. value: function draw() {
  1852. var _this = this;
  1853. if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
  1854. console.error('Must be in new state before drawing');
  1855. this.reset();
  1856. }
  1857. if (!this.pdfPage) {
  1858. this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  1859. return Promise.reject(new Error('Page is not loaded'));
  1860. }
  1861. this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  1862. var pdfPage = this.pdfPage;
  1863. var div = this.div;
  1864. var canvasWrapper = document.createElement('div');
  1865. canvasWrapper.style.width = div.style.width;
  1866. canvasWrapper.style.height = div.style.height;
  1867. canvasWrapper.classList.add('canvasWrapper');
  1868. if (this.annotationLayer && this.annotationLayer.div) {
  1869. div.insertBefore(canvasWrapper, this.annotationLayer.div);
  1870. } else {
  1871. div.appendChild(canvasWrapper);
  1872. }
  1873. var textLayer = null;
  1874. if (this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && this.textLayerFactory) {
  1875. var textLayerDiv = document.createElement('div');
  1876. textLayerDiv.className = 'textLayer';
  1877. textLayerDiv.style.width = canvasWrapper.style.width;
  1878. textLayerDiv.style.height = canvasWrapper.style.height;
  1879. if (this.annotationLayer && this.annotationLayer.div) {
  1880. div.insertBefore(textLayerDiv, this.annotationLayer.div);
  1881. } else {
  1882. div.appendChild(textLayerDiv);
  1883. }
  1884. textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.textLayerMode === _ui_utils.TextLayerMode.ENABLE_ENHANCE);
  1885. }
  1886. this.textLayer = textLayer;
  1887. var renderContinueCallback = null;
  1888. if (this.renderingQueue) {
  1889. renderContinueCallback = function renderContinueCallback(cont) {
  1890. if (!_this.renderingQueue.isHighestPriority(_this)) {
  1891. _this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
  1892. _this.resume = function () {
  1893. _this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
  1894. cont();
  1895. };
  1896. return;
  1897. }
  1898. cont();
  1899. };
  1900. }
  1901. var finishPaintTask = function finishPaintTask(error) {
  1902. if (paintTask === _this.paintTask) {
  1903. _this.paintTask = null;
  1904. }
  1905. if (error instanceof _pdfjsLib.RenderingCancelledException) {
  1906. _this.error = null;
  1907. return Promise.resolve(undefined);
  1908. }
  1909. _this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  1910. if (_this.loadingIconDiv) {
  1911. div.removeChild(_this.loadingIconDiv);
  1912. delete _this.loadingIconDiv;
  1913. }
  1914. _this._resetZoomLayer(true);
  1915. _this.error = error;
  1916. _this.stats = pdfPage.stats;
  1917. if (_this.onAfterDraw) {
  1918. _this.onAfterDraw();
  1919. }
  1920. _this.eventBus.dispatch('pagerendered', {
  1921. source: _this,
  1922. pageNumber: _this.id,
  1923. cssTransform: false
  1924. });
  1925. if (error) {
  1926. return Promise.reject(error);
  1927. }
  1928. return Promise.resolve(undefined);
  1929. };
  1930. var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
  1931. paintTask.onRenderContinue = renderContinueCallback;
  1932. this.paintTask = paintTask;
  1933. var resultPromise = paintTask.promise.then(function () {
  1934. return finishPaintTask(null).then(function () {
  1935. if (textLayer) {
  1936. var readableStream = pdfPage.streamTextContent({ normalizeWhitespace: true });
  1937. textLayer.setTextContentStream(readableStream);
  1938. textLayer.render();
  1939. }
  1940. });
  1941. }, function (reason) {
  1942. return finishPaintTask(reason);
  1943. });
  1944. if (this.annotationLayerFactory) {
  1945. if (!this.annotationLayer) {
  1946. this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this.imageResourcesPath, this.renderInteractiveForms, this.l10n);
  1947. }
  1948. this.annotationLayer.render(this.viewport, 'display');
  1949. }
  1950. div.setAttribute('data-loaded', true);
  1951. if (this.onBeforeDraw) {
  1952. this.onBeforeDraw();
  1953. }
  1954. return resultPromise;
  1955. }
  1956. }, {
  1957. key: 'paintOnCanvas',
  1958. value: function paintOnCanvas(canvasWrapper) {
  1959. var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
  1960. var result = {
  1961. promise: renderCapability.promise,
  1962. onRenderContinue: function onRenderContinue(cont) {
  1963. cont();
  1964. },
  1965. cancel: function cancel() {
  1966. renderTask.cancel();
  1967. }
  1968. };
  1969. var viewport = this.viewport;
  1970. var canvas = document.createElement('canvas');
  1971. canvas.id = this.renderingId;
  1972. canvas.setAttribute('hidden', 'hidden');
  1973. var isCanvasHidden = true;
  1974. var showCanvas = function showCanvas() {
  1975. if (isCanvasHidden) {
  1976. canvas.removeAttribute('hidden');
  1977. isCanvasHidden = false;
  1978. }
  1979. };
  1980. canvasWrapper.appendChild(canvas);
  1981. this.canvas = canvas;
  1982. canvas.mozOpaque = true;
  1983. var ctx = canvas.getContext('2d', { alpha: false });
  1984. var outputScale = (0, _ui_utils.getOutputScale)(ctx);
  1985. this.outputScale = outputScale;
  1986. if (this.useOnlyCssZoom) {
  1987. var actualSizeViewport = viewport.clone({ scale: _ui_utils.CSS_UNITS });
  1988. outputScale.sx *= actualSizeViewport.width / viewport.width;
  1989. outputScale.sy *= actualSizeViewport.height / viewport.height;
  1990. outputScale.scaled = true;
  1991. }
  1992. if (this.maxCanvasPixels > 0) {
  1993. var pixelsInViewport = viewport.width * viewport.height;
  1994. var maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
  1995. if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
  1996. outputScale.sx = maxScale;
  1997. outputScale.sy = maxScale;
  1998. outputScale.scaled = true;
  1999. this.hasRestrictedScaling = true;
  2000. } else {
  2001. this.hasRestrictedScaling = false;
  2002. }
  2003. }
  2004. var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
  2005. var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
  2006. canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
  2007. canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
  2008. canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + 'px';
  2009. canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + 'px';
  2010. this.paintedViewportMap.set(canvas, viewport);
  2011. var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
  2012. var renderContext = {
  2013. canvasContext: ctx,
  2014. transform: transform,
  2015. viewport: this.viewport,
  2016. enableWebGL: this.enableWebGL,
  2017. renderInteractiveForms: this.renderInteractiveForms
  2018. };
  2019. var renderTask = this.pdfPage.render(renderContext);
  2020. renderTask.onContinue = function (cont) {
  2021. showCanvas();
  2022. if (result.onRenderContinue) {
  2023. result.onRenderContinue(cont);
  2024. } else {
  2025. cont();
  2026. }
  2027. };
  2028. renderTask.promise.then(function () {
  2029. showCanvas();
  2030. renderCapability.resolve(undefined);
  2031. }, function (error) {
  2032. showCanvas();
  2033. renderCapability.reject(error);
  2034. });
  2035. return result;
  2036. }
  2037. }, {
  2038. key: 'paintOnSvg',
  2039. value: function paintOnSvg(wrapper) {
  2040. var _this2 = this;
  2041. var cancelled = false;
  2042. var ensureNotCancelled = function ensureNotCancelled() {
  2043. if (cancelled) {
  2044. throw new _pdfjsLib.RenderingCancelledException('Rendering cancelled, page ' + _this2.id, 'svg');
  2045. }
  2046. };
  2047. var pdfPage = this.pdfPage;
  2048. var actualSizeViewport = this.viewport.clone({ scale: _ui_utils.CSS_UNITS });
  2049. var promise = pdfPage.getOperatorList().then(function (opList) {
  2050. ensureNotCancelled();
  2051. var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
  2052. return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {
  2053. ensureNotCancelled();
  2054. _this2.svg = svg;
  2055. _this2.paintedViewportMap.set(svg, actualSizeViewport);
  2056. svg.style.width = wrapper.style.width;
  2057. svg.style.height = wrapper.style.height;
  2058. _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
  2059. wrapper.appendChild(svg);
  2060. });
  2061. });
  2062. return {
  2063. promise: promise,
  2064. onRenderContinue: function onRenderContinue(cont) {
  2065. cont();
  2066. },
  2067. cancel: function cancel() {
  2068. cancelled = true;
  2069. }
  2070. };
  2071. }
  2072. }, {
  2073. key: 'setPageLabel',
  2074. value: function setPageLabel(label) {
  2075. this.pageLabel = typeof label === 'string' ? label : null;
  2076. if (this.pageLabel !== null) {
  2077. this.div.setAttribute('data-page-label', this.pageLabel);
  2078. } else {
  2079. this.div.removeAttribute('data-page-label');
  2080. }
  2081. }
  2082. }, {
  2083. key: 'width',
  2084. get: function get() {
  2085. return this.viewport.width;
  2086. }
  2087. }, {
  2088. key: 'height',
  2089. get: function get() {
  2090. return this.viewport.height;
  2091. }
  2092. }]);
  2093. return PDFPageView;
  2094. }();
  2095. exports.PDFPageView = PDFPageView;
  2096. /***/ }),
  2097. /* 7 */
  2098. /***/ (function(module, exports, __w_pdfjs_require__) {
  2099. "use strict";
  2100. Object.defineProperty(exports, "__esModule", {
  2101. value: true
  2102. });
  2103. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  2104. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2105. var CLEANUP_TIMEOUT = 30000;
  2106. var RenderingStates = {
  2107. INITIAL: 0,
  2108. RUNNING: 1,
  2109. PAUSED: 2,
  2110. FINISHED: 3
  2111. };
  2112. var PDFRenderingQueue = function () {
  2113. function PDFRenderingQueue() {
  2114. _classCallCheck(this, PDFRenderingQueue);
  2115. this.pdfViewer = null;
  2116. this.pdfThumbnailViewer = null;
  2117. this.onIdle = null;
  2118. this.highestPriorityPage = null;
  2119. this.idleTimeout = null;
  2120. this.printing = false;
  2121. this.isThumbnailViewEnabled = false;
  2122. }
  2123. _createClass(PDFRenderingQueue, [{
  2124. key: "setViewer",
  2125. value: function setViewer(pdfViewer) {
  2126. this.pdfViewer = pdfViewer;
  2127. }
  2128. }, {
  2129. key: "setThumbnailViewer",
  2130. value: function setThumbnailViewer(pdfThumbnailViewer) {
  2131. this.pdfThumbnailViewer = pdfThumbnailViewer;
  2132. }
  2133. }, {
  2134. key: "isHighestPriority",
  2135. value: function isHighestPriority(view) {
  2136. return this.highestPriorityPage === view.renderingId;
  2137. }
  2138. }, {
  2139. key: "renderHighestPriority",
  2140. value: function renderHighestPriority(currentlyVisiblePages) {
  2141. if (this.idleTimeout) {
  2142. clearTimeout(this.idleTimeout);
  2143. this.idleTimeout = null;
  2144. }
  2145. if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
  2146. return;
  2147. }
  2148. if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
  2149. if (this.pdfThumbnailViewer.forceRendering()) {
  2150. return;
  2151. }
  2152. }
  2153. if (this.printing) {
  2154. return;
  2155. }
  2156. if (this.onIdle) {
  2157. this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
  2158. }
  2159. }
  2160. }, {
  2161. key: "getHighestPriority",
  2162. value: function getHighestPriority(visible, views, scrolledDown) {
  2163. var visibleViews = visible.views;
  2164. var numVisible = visibleViews.length;
  2165. if (numVisible === 0) {
  2166. return false;
  2167. }
  2168. for (var i = 0; i < numVisible; ++i) {
  2169. var view = visibleViews[i].view;
  2170. if (!this.isViewFinished(view)) {
  2171. return view;
  2172. }
  2173. }
  2174. if (scrolledDown) {
  2175. var nextPageIndex = visible.last.id;
  2176. if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {
  2177. return views[nextPageIndex];
  2178. }
  2179. } else {
  2180. var previousPageIndex = visible.first.id - 2;
  2181. if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) {
  2182. return views[previousPageIndex];
  2183. }
  2184. }
  2185. return null;
  2186. }
  2187. }, {
  2188. key: "isViewFinished",
  2189. value: function isViewFinished(view) {
  2190. return view.renderingState === RenderingStates.FINISHED;
  2191. }
  2192. }, {
  2193. key: "renderView",
  2194. value: function renderView(view) {
  2195. var _this = this;
  2196. switch (view.renderingState) {
  2197. case RenderingStates.FINISHED:
  2198. return false;
  2199. case RenderingStates.PAUSED:
  2200. this.highestPriorityPage = view.renderingId;
  2201. view.resume();
  2202. break;
  2203. case RenderingStates.RUNNING:
  2204. this.highestPriorityPage = view.renderingId;
  2205. break;
  2206. case RenderingStates.INITIAL:
  2207. this.highestPriorityPage = view.renderingId;
  2208. var continueRendering = function continueRendering() {
  2209. _this.renderHighestPriority();
  2210. };
  2211. view.draw().then(continueRendering, continueRendering);
  2212. break;
  2213. }
  2214. return true;
  2215. }
  2216. }]);
  2217. return PDFRenderingQueue;
  2218. }();
  2219. exports.RenderingStates = RenderingStates;
  2220. exports.PDFRenderingQueue = PDFRenderingQueue;
  2221. /***/ }),
  2222. /* 8 */
  2223. /***/ (function(module, exports, __w_pdfjs_require__) {
  2224. "use strict";
  2225. Object.defineProperty(exports, "__esModule", {
  2226. value: true
  2227. });
  2228. exports.BaseViewer = undefined;
  2229. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  2230. var _ui_utils = __w_pdfjs_require__(0);
  2231. var _pdf_rendering_queue = __w_pdfjs_require__(7);
  2232. var _annotation_layer_builder = __w_pdfjs_require__(4);
  2233. var _pdfjsLib = __w_pdfjs_require__(1);
  2234. var _dom_events = __w_pdfjs_require__(2);
  2235. var _pdf_page_view = __w_pdfjs_require__(6);
  2236. var _pdf_link_service = __w_pdfjs_require__(3);
  2237. var _text_layer_builder = __w_pdfjs_require__(5);
  2238. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2239. var DEFAULT_CACHE_SIZE = 10;
  2240. function PDFPageViewBuffer(size) {
  2241. var data = [];
  2242. this.push = function (view) {
  2243. var i = data.indexOf(view);
  2244. if (i >= 0) {
  2245. data.splice(i, 1);
  2246. }
  2247. data.push(view);
  2248. if (data.length > size) {
  2249. data.shift().destroy();
  2250. }
  2251. };
  2252. this.resize = function (newSize) {
  2253. size = newSize;
  2254. while (data.length > size) {
  2255. data.shift().destroy();
  2256. }
  2257. };
  2258. }
  2259. function isSameScale(oldScale, newScale) {
  2260. if (newScale === oldScale) {
  2261. return true;
  2262. }
  2263. if (Math.abs(newScale - oldScale) < 1e-15) {
  2264. return true;
  2265. }
  2266. return false;
  2267. }
  2268. function isPortraitOrientation(size) {
  2269. return size.width <= size.height;
  2270. }
  2271. var BaseViewer = function () {
  2272. function BaseViewer(options) {
  2273. _classCallCheck(this, BaseViewer);
  2274. if (this.constructor === BaseViewer) {
  2275. throw new Error('Cannot initialize BaseViewer.');
  2276. }
  2277. this._name = this.constructor.name;
  2278. this.container = options.container;
  2279. this.viewer = options.viewer || options.container.firstElementChild;
  2280. this.eventBus = options.eventBus || (0, _dom_events.getGlobalEventBus)();
  2281. this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
  2282. this.downloadManager = options.downloadManager || null;
  2283. this.removePageBorders = options.removePageBorders || false;
  2284. this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
  2285. this.enhanceTextSelection = options.enhanceTextSelection || false;
  2286. this.imageResourcesPath = options.imageResourcesPath || '';
  2287. this.renderInteractiveForms = options.renderInteractiveForms || false;
  2288. this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
  2289. this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
  2290. this.enableWebGL = options.enableWebGL || false;
  2291. this.useOnlyCssZoom = options.useOnlyCssZoom || false;
  2292. this.maxCanvasPixels = options.maxCanvasPixels;
  2293. this.l10n = options.l10n || _ui_utils.NullL10n;
  2294. this.defaultRenderingQueue = !options.renderingQueue;
  2295. if (this.defaultRenderingQueue) {
  2296. this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
  2297. this.renderingQueue.setViewer(this);
  2298. } else {
  2299. this.renderingQueue = options.renderingQueue;
  2300. }
  2301. this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
  2302. this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
  2303. this._resetView();
  2304. if (this.removePageBorders) {
  2305. this.viewer.classList.add('removePageBorders');
  2306. }
  2307. }
  2308. _createClass(BaseViewer, [{
  2309. key: 'getPageView',
  2310. value: function getPageView(index) {
  2311. return this._pages[index];
  2312. }
  2313. }, {
  2314. key: '_setCurrentPageNumber',
  2315. value: function _setCurrentPageNumber(val) {
  2316. var resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  2317. if (this._currentPageNumber === val) {
  2318. if (resetCurrentPageView) {
  2319. this._resetCurrentPageView();
  2320. }
  2321. return;
  2322. }
  2323. if (!(0 < val && val <= this.pagesCount)) {
  2324. console.error(this._name + '._setCurrentPageNumber: "' + val + '" is out of bounds.');
  2325. return;
  2326. }
  2327. var arg = {
  2328. source: this,
  2329. pageNumber: val,
  2330. pageLabel: this._pageLabels && this._pageLabels[val - 1]
  2331. };
  2332. this._currentPageNumber = val;
  2333. this.eventBus.dispatch('pagechanging', arg);
  2334. this.eventBus.dispatch('pagechange', arg);
  2335. if (resetCurrentPageView) {
  2336. this._resetCurrentPageView();
  2337. }
  2338. }
  2339. }, {
  2340. key: 'setDocument',
  2341. value: function setDocument(pdfDocument) {
  2342. var _this = this;
  2343. if (this.pdfDocument) {
  2344. this._cancelRendering();
  2345. this._resetView();
  2346. }
  2347. this.pdfDocument = pdfDocument;
  2348. if (!pdfDocument) {
  2349. return;
  2350. }
  2351. var pagesCount = pdfDocument.numPages;
  2352. var pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
  2353. this.pagesPromise = pagesCapability.promise;
  2354. pagesCapability.promise.then(function () {
  2355. _this._pageViewsReady = true;
  2356. _this.eventBus.dispatch('pagesloaded', {
  2357. source: _this,
  2358. pagesCount: pagesCount
  2359. });
  2360. });
  2361. var isOnePageRenderedResolved = false;
  2362. var onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
  2363. this.onePageRendered = onePageRenderedCapability.promise;
  2364. var bindOnAfterAndBeforeDraw = function bindOnAfterAndBeforeDraw(pageView) {
  2365. pageView.onBeforeDraw = function () {
  2366. _this._buffer.push(pageView);
  2367. };
  2368. pageView.onAfterDraw = function () {
  2369. if (!isOnePageRenderedResolved) {
  2370. isOnePageRenderedResolved = true;
  2371. onePageRenderedCapability.resolve();
  2372. }
  2373. };
  2374. };
  2375. var firstPagePromise = pdfDocument.getPage(1);
  2376. this.firstPagePromise = firstPagePromise;
  2377. firstPagePromise.then(function (pdfPage) {
  2378. var scale = _this.currentScale;
  2379. var viewport = pdfPage.getViewport(scale * _ui_utils.CSS_UNITS);
  2380. for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
  2381. var textLayerFactory = null;
  2382. if (_this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE) {
  2383. textLayerFactory = _this;
  2384. }
  2385. var pageView = new _pdf_page_view.PDFPageView({
  2386. container: _this._setDocumentViewerElement,
  2387. eventBus: _this.eventBus,
  2388. id: pageNum,
  2389. scale: scale,
  2390. defaultViewport: viewport.clone(),
  2391. renderingQueue: _this.renderingQueue,
  2392. textLayerFactory: textLayerFactory,
  2393. textLayerMode: _this.textLayerMode,
  2394. annotationLayerFactory: _this,
  2395. imageResourcesPath: _this.imageResourcesPath,
  2396. renderInteractiveForms: _this.renderInteractiveForms,
  2397. renderer: _this.renderer,
  2398. enableWebGL: _this.enableWebGL,
  2399. useOnlyCssZoom: _this.useOnlyCssZoom,
  2400. maxCanvasPixels: _this.maxCanvasPixels,
  2401. l10n: _this.l10n
  2402. });
  2403. bindOnAfterAndBeforeDraw(pageView);
  2404. _this._pages.push(pageView);
  2405. }
  2406. onePageRenderedCapability.promise.then(function () {
  2407. if (pdfDocument.loadingParams['disableAutoFetch']) {
  2408. pagesCapability.resolve();
  2409. return;
  2410. }
  2411. var getPagesLeft = pagesCount;
  2412. var _loop = function _loop(_pageNum) {
  2413. pdfDocument.getPage(_pageNum).then(function (pdfPage) {
  2414. var pageView = _this._pages[_pageNum - 1];
  2415. if (!pageView.pdfPage) {
  2416. pageView.setPdfPage(pdfPage);
  2417. }
  2418. _this.linkService.cachePageRef(_pageNum, pdfPage.ref);
  2419. if (--getPagesLeft === 0) {
  2420. pagesCapability.resolve();
  2421. }
  2422. }, function (reason) {
  2423. console.error('Unable to get page ' + _pageNum + ' to initialize viewer', reason);
  2424. if (--getPagesLeft === 0) {
  2425. pagesCapability.resolve();
  2426. }
  2427. });
  2428. };
  2429. for (var _pageNum = 1; _pageNum <= pagesCount; ++_pageNum) {
  2430. _loop(_pageNum);
  2431. }
  2432. });
  2433. _this.eventBus.dispatch('pagesinit', { source: _this });
  2434. if (_this.defaultRenderingQueue) {
  2435. _this.update();
  2436. }
  2437. if (_this.findController) {
  2438. _this.findController.resolveFirstPage();
  2439. }
  2440. }).catch(function (reason) {
  2441. console.error('Unable to initialize viewer', reason);
  2442. });
  2443. }
  2444. }, {
  2445. key: 'setPageLabels',
  2446. value: function setPageLabels(labels) {
  2447. if (!this.pdfDocument) {
  2448. return;
  2449. }
  2450. if (!labels) {
  2451. this._pageLabels = null;
  2452. } else if (!(labels instanceof Array && this.pdfDocument.numPages === labels.length)) {
  2453. this._pageLabels = null;
  2454. console.error(this._name + '.setPageLabels: Invalid page labels.');
  2455. } else {
  2456. this._pageLabels = labels;
  2457. }
  2458. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  2459. var pageView = this._pages[i];
  2460. var label = this._pageLabels && this._pageLabels[i];
  2461. pageView.setPageLabel(label);
  2462. }
  2463. }
  2464. }, {
  2465. key: '_resetView',
  2466. value: function _resetView() {
  2467. this._pages = [];
  2468. this._currentPageNumber = 1;
  2469. this._currentScale = _ui_utils.UNKNOWN_SCALE;
  2470. this._currentScaleValue = null;
  2471. this._pageLabels = null;
  2472. this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
  2473. this._location = null;
  2474. this._pagesRotation = 0;
  2475. this._pagesRequests = [];
  2476. this._pageViewsReady = false;
  2477. this.viewer.textContent = '';
  2478. }
  2479. }, {
  2480. key: '_scrollUpdate',
  2481. value: function _scrollUpdate() {
  2482. if (this.pagesCount === 0) {
  2483. return;
  2484. }
  2485. this.update();
  2486. }
  2487. }, {
  2488. key: '_scrollIntoView',
  2489. value: function _scrollIntoView(_ref) {
  2490. var pageDiv = _ref.pageDiv,
  2491. _ref$pageSpot = _ref.pageSpot,
  2492. pageSpot = _ref$pageSpot === undefined ? null : _ref$pageSpot,
  2493. _ref$pageNumber = _ref.pageNumber,
  2494. pageNumber = _ref$pageNumber === undefined ? null : _ref$pageNumber;
  2495. throw new Error('Not implemented: _scrollIntoView');
  2496. }
  2497. }, {
  2498. key: '_setScaleDispatchEvent',
  2499. value: function _setScaleDispatchEvent(newScale, newValue) {
  2500. var preset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  2501. var arg = {
  2502. source: this,
  2503. scale: newScale,
  2504. presetValue: preset ? newValue : undefined
  2505. };
  2506. this.eventBus.dispatch('scalechanging', arg);
  2507. this.eventBus.dispatch('scalechange', arg);
  2508. }
  2509. }, {
  2510. key: '_setScaleUpdatePages',
  2511. value: function _setScaleUpdatePages(newScale, newValue) {
  2512. var noScroll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  2513. var preset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  2514. this._currentScaleValue = newValue.toString();
  2515. if (isSameScale(this._currentScale, newScale)) {
  2516. if (preset) {
  2517. this._setScaleDispatchEvent(newScale, newValue, true);
  2518. }
  2519. return;
  2520. }
  2521. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  2522. this._pages[i].update(newScale);
  2523. }
  2524. this._currentScale = newScale;
  2525. if (!noScroll) {
  2526. var page = this._currentPageNumber,
  2527. dest = void 0;
  2528. if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
  2529. page = this._location.pageNumber;
  2530. dest = [null, { name: 'XYZ' }, this._location.left, this._location.top, null];
  2531. }
  2532. this.scrollPageIntoView({
  2533. pageNumber: page,
  2534. destArray: dest,
  2535. allowNegativeOffset: true
  2536. });
  2537. }
  2538. this._setScaleDispatchEvent(newScale, newValue, preset);
  2539. if (this.defaultRenderingQueue) {
  2540. this.update();
  2541. }
  2542. }
  2543. }, {
  2544. key: '_setScale',
  2545. value: function _setScale(value) {
  2546. var noScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  2547. var scale = parseFloat(value);
  2548. if (scale > 0) {
  2549. this._setScaleUpdatePages(scale, value, noScroll, false);
  2550. } else {
  2551. var currentPage = this._pages[this._currentPageNumber - 1];
  2552. if (!currentPage) {
  2553. return;
  2554. }
  2555. var hPadding = this.isInPresentationMode || this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  2556. var vPadding = this.isInPresentationMode || this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  2557. var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale;
  2558. var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
  2559. switch (value) {
  2560. case 'page-actual':
  2561. scale = 1;
  2562. break;
  2563. case 'page-width':
  2564. scale = pageWidthScale;
  2565. break;
  2566. case 'page-height':
  2567. scale = pageHeightScale;
  2568. break;
  2569. case 'page-fit':
  2570. scale = Math.min(pageWidthScale, pageHeightScale);
  2571. break;
  2572. case 'auto':
  2573. var isLandscape = currentPage.width > currentPage.height;
  2574. var horizontalScale = isLandscape ? Math.min(pageHeightScale, pageWidthScale) : pageWidthScale;
  2575. scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
  2576. break;
  2577. default:
  2578. console.error(this._name + '._setScale: "' + value + '" is an unknown zoom value.');
  2579. return;
  2580. }
  2581. this._setScaleUpdatePages(scale, value, noScroll, true);
  2582. }
  2583. }
  2584. }, {
  2585. key: '_resetCurrentPageView',
  2586. value: function _resetCurrentPageView() {
  2587. if (this.isInPresentationMode) {
  2588. this._setScale(this._currentScaleValue, true);
  2589. }
  2590. var pageView = this._pages[this._currentPageNumber - 1];
  2591. this._scrollIntoView({ pageDiv: pageView.div });
  2592. }
  2593. }, {
  2594. key: 'scrollPageIntoView',
  2595. value: function scrollPageIntoView(params) {
  2596. if (!this.pdfDocument) {
  2597. return;
  2598. }
  2599. var pageNumber = params.pageNumber || 0;
  2600. var dest = params.destArray || null;
  2601. var allowNegativeOffset = params.allowNegativeOffset || false;
  2602. if (this.isInPresentationMode || !dest) {
  2603. this._setCurrentPageNumber(pageNumber, true);
  2604. return;
  2605. }
  2606. var pageView = this._pages[pageNumber - 1];
  2607. if (!pageView) {
  2608. console.error(this._name + '.scrollPageIntoView: Invalid "pageNumber" parameter.');
  2609. return;
  2610. }
  2611. var x = 0,
  2612. y = 0;
  2613. var width = 0,
  2614. height = 0,
  2615. widthScale = void 0,
  2616. heightScale = void 0;
  2617. var changeOrientation = pageView.rotation % 180 === 0 ? false : true;
  2618. var pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;
  2619. var pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;
  2620. var scale = 0;
  2621. switch (dest[1].name) {
  2622. case 'XYZ':
  2623. x = dest[2];
  2624. y = dest[3];
  2625. scale = dest[4];
  2626. x = x !== null ? x : 0;
  2627. y = y !== null ? y : pageHeight;
  2628. break;
  2629. case 'Fit':
  2630. case 'FitB':
  2631. scale = 'page-fit';
  2632. break;
  2633. case 'FitH':
  2634. case 'FitBH':
  2635. y = dest[2];
  2636. scale = 'page-width';
  2637. if (y === null && this._location) {
  2638. x = this._location.left;
  2639. y = this._location.top;
  2640. }
  2641. break;
  2642. case 'FitV':
  2643. case 'FitBV':
  2644. x = dest[2];
  2645. width = pageWidth;
  2646. height = pageHeight;
  2647. scale = 'page-height';
  2648. break;
  2649. case 'FitR':
  2650. x = dest[2];
  2651. y = dest[3];
  2652. width = dest[4] - x;
  2653. height = dest[5] - y;
  2654. var hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
  2655. var vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
  2656. widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;
  2657. heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;
  2658. scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
  2659. break;
  2660. default:
  2661. console.error(this._name + '.scrollPageIntoView: "' + dest[1].name + '" ' + 'is not a valid destination type.');
  2662. return;
  2663. }
  2664. if (scale && scale !== this._currentScale) {
  2665. this.currentScaleValue = scale;
  2666. } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
  2667. this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
  2668. }
  2669. if (scale === 'page-fit' && !dest[4]) {
  2670. this._scrollIntoView({
  2671. pageDiv: pageView.div,
  2672. pageNumber: pageNumber
  2673. });
  2674. return;
  2675. }
  2676. var boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
  2677. var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
  2678. var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
  2679. if (!allowNegativeOffset) {
  2680. left = Math.max(left, 0);
  2681. top = Math.max(top, 0);
  2682. }
  2683. this._scrollIntoView({
  2684. pageDiv: pageView.div,
  2685. pageSpot: {
  2686. left: left,
  2687. top: top
  2688. },
  2689. pageNumber: pageNumber
  2690. });
  2691. }
  2692. }, {
  2693. key: '_resizeBuffer',
  2694. value: function _resizeBuffer(numVisiblePages) {
  2695. var suggestedCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
  2696. this._buffer.resize(suggestedCacheSize);
  2697. }
  2698. }, {
  2699. key: '_updateLocation',
  2700. value: function _updateLocation(firstPage) {
  2701. var currentScale = this._currentScale;
  2702. var currentScaleValue = this._currentScaleValue;
  2703. var normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
  2704. var pageNumber = firstPage.id;
  2705. var pdfOpenParams = '#page=' + pageNumber;
  2706. pdfOpenParams += '&zoom=' + normalizedScaleValue;
  2707. var currentPageView = this._pages[pageNumber - 1];
  2708. var container = this.container;
  2709. var topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
  2710. var intLeft = Math.round(topLeft[0]);
  2711. var intTop = Math.round(topLeft[1]);
  2712. pdfOpenParams += ',' + intLeft + ',' + intTop;
  2713. this._location = {
  2714. pageNumber: pageNumber,
  2715. scale: normalizedScaleValue,
  2716. top: intTop,
  2717. left: intLeft,
  2718. rotation: this._pagesRotation,
  2719. pdfOpenParams: pdfOpenParams
  2720. };
  2721. }
  2722. }, {
  2723. key: 'update',
  2724. value: function update() {
  2725. throw new Error('Not implemented: update');
  2726. }
  2727. }, {
  2728. key: 'containsElement',
  2729. value: function containsElement(element) {
  2730. return this.container.contains(element);
  2731. }
  2732. }, {
  2733. key: 'focus',
  2734. value: function focus() {
  2735. this.container.focus();
  2736. }
  2737. }, {
  2738. key: '_getVisiblePages',
  2739. value: function _getVisiblePages() {
  2740. throw new Error('Not implemented: _getVisiblePages');
  2741. }
  2742. }, {
  2743. key: 'cleanup',
  2744. value: function cleanup() {
  2745. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  2746. if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
  2747. this._pages[i].reset();
  2748. }
  2749. }
  2750. }
  2751. }, {
  2752. key: '_cancelRendering',
  2753. value: function _cancelRendering() {
  2754. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  2755. if (this._pages[i]) {
  2756. this._pages[i].cancelRendering();
  2757. }
  2758. }
  2759. }
  2760. }, {
  2761. key: '_ensurePdfPageLoaded',
  2762. value: function _ensurePdfPageLoaded(pageView) {
  2763. var _this2 = this;
  2764. if (pageView.pdfPage) {
  2765. return Promise.resolve(pageView.pdfPage);
  2766. }
  2767. var pageNumber = pageView.id;
  2768. if (this._pagesRequests[pageNumber]) {
  2769. return this._pagesRequests[pageNumber];
  2770. }
  2771. var promise = this.pdfDocument.getPage(pageNumber).then(function (pdfPage) {
  2772. if (!pageView.pdfPage) {
  2773. pageView.setPdfPage(pdfPage);
  2774. }
  2775. _this2._pagesRequests[pageNumber] = null;
  2776. return pdfPage;
  2777. }).catch(function (reason) {
  2778. console.error('Unable to get page for page view', reason);
  2779. _this2._pagesRequests[pageNumber] = null;
  2780. });
  2781. this._pagesRequests[pageNumber] = promise;
  2782. return promise;
  2783. }
  2784. }, {
  2785. key: 'forceRendering',
  2786. value: function forceRendering(currentlyVisiblePages) {
  2787. var _this3 = this;
  2788. var visiblePages = currentlyVisiblePages || this._getVisiblePages();
  2789. var pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, this.scroll.down);
  2790. if (pageView) {
  2791. this._ensurePdfPageLoaded(pageView).then(function () {
  2792. _this3.renderingQueue.renderView(pageView);
  2793. });
  2794. return true;
  2795. }
  2796. return false;
  2797. }
  2798. }, {
  2799. key: 'getPageTextContent',
  2800. value: function getPageTextContent(pageIndex) {
  2801. return this.pdfDocument.getPage(pageIndex + 1).then(function (page) {
  2802. return page.getTextContent({ normalizeWhitespace: true });
  2803. });
  2804. }
  2805. }, {
  2806. key: 'createTextLayerBuilder',
  2807. value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
  2808. var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  2809. return new _text_layer_builder.TextLayerBuilder({
  2810. textLayerDiv: textLayerDiv,
  2811. eventBus: this.eventBus,
  2812. pageIndex: pageIndex,
  2813. viewport: viewport,
  2814. findController: this.isInPresentationMode ? null : this.findController,
  2815. enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection
  2816. });
  2817. }
  2818. }, {
  2819. key: 'createAnnotationLayerBuilder',
  2820. value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
  2821. var imageResourcesPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  2822. var renderInteractiveForms = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  2823. var l10n = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _ui_utils.NullL10n;
  2824. return new _annotation_layer_builder.AnnotationLayerBuilder({
  2825. pageDiv: pageDiv,
  2826. pdfPage: pdfPage,
  2827. imageResourcesPath: imageResourcesPath,
  2828. renderInteractiveForms: renderInteractiveForms,
  2829. linkService: this.linkService,
  2830. downloadManager: this.downloadManager,
  2831. l10n: l10n
  2832. });
  2833. }
  2834. }, {
  2835. key: 'setFindController',
  2836. value: function setFindController(findController) {
  2837. this.findController = findController;
  2838. }
  2839. }, {
  2840. key: 'getPagesOverview',
  2841. value: function getPagesOverview() {
  2842. var pagesOverview = this._pages.map(function (pageView) {
  2843. var viewport = pageView.pdfPage.getViewport(1);
  2844. return {
  2845. width: viewport.width,
  2846. height: viewport.height,
  2847. rotation: viewport.rotation
  2848. };
  2849. });
  2850. if (!this.enablePrintAutoRotate) {
  2851. return pagesOverview;
  2852. }
  2853. var isFirstPagePortrait = isPortraitOrientation(pagesOverview[0]);
  2854. return pagesOverview.map(function (size) {
  2855. if (isFirstPagePortrait === isPortraitOrientation(size)) {
  2856. return size;
  2857. }
  2858. return {
  2859. width: size.height,
  2860. height: size.width,
  2861. rotation: (size.rotation + 90) % 360
  2862. };
  2863. });
  2864. }
  2865. }, {
  2866. key: 'pagesCount',
  2867. get: function get() {
  2868. return this._pages.length;
  2869. }
  2870. }, {
  2871. key: 'pageViewsReady',
  2872. get: function get() {
  2873. return this._pageViewsReady;
  2874. }
  2875. }, {
  2876. key: 'currentPageNumber',
  2877. get: function get() {
  2878. return this._currentPageNumber;
  2879. },
  2880. set: function set(val) {
  2881. if (!Number.isInteger(val)) {
  2882. throw new Error('Invalid page number.');
  2883. }
  2884. if (!this.pdfDocument) {
  2885. return;
  2886. }
  2887. this._setCurrentPageNumber(val, true);
  2888. }
  2889. }, {
  2890. key: 'currentPageLabel',
  2891. get: function get() {
  2892. return this._pageLabels && this._pageLabels[this._currentPageNumber - 1];
  2893. },
  2894. set: function set(val) {
  2895. var pageNumber = val | 0;
  2896. if (this._pageLabels) {
  2897. var i = this._pageLabels.indexOf(val);
  2898. if (i >= 0) {
  2899. pageNumber = i + 1;
  2900. }
  2901. }
  2902. this.currentPageNumber = pageNumber;
  2903. }
  2904. }, {
  2905. key: 'currentScale',
  2906. get: function get() {
  2907. return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
  2908. },
  2909. set: function set(val) {
  2910. if (isNaN(val)) {
  2911. throw new Error('Invalid numeric scale');
  2912. }
  2913. if (!this.pdfDocument) {
  2914. return;
  2915. }
  2916. this._setScale(val, false);
  2917. }
  2918. }, {
  2919. key: 'currentScaleValue',
  2920. get: function get() {
  2921. return this._currentScaleValue;
  2922. },
  2923. set: function set(val) {
  2924. if (!this.pdfDocument) {
  2925. return;
  2926. }
  2927. this._setScale(val, false);
  2928. }
  2929. }, {
  2930. key: 'pagesRotation',
  2931. get: function get() {
  2932. return this._pagesRotation;
  2933. },
  2934. set: function set(rotation) {
  2935. if (!(0, _ui_utils.isValidRotation)(rotation)) {
  2936. throw new Error('Invalid pages rotation angle.');
  2937. }
  2938. if (!this.pdfDocument) {
  2939. return;
  2940. }
  2941. if (this._pagesRotation === rotation) {
  2942. return;
  2943. }
  2944. this._pagesRotation = rotation;
  2945. var pageNumber = this._currentPageNumber;
  2946. for (var i = 0, ii = this._pages.length; i < ii; i++) {
  2947. var pageView = this._pages[i];
  2948. pageView.update(pageView.scale, rotation);
  2949. }
  2950. if (this._currentScaleValue) {
  2951. this._setScale(this._currentScaleValue, true);
  2952. }
  2953. this.eventBus.dispatch('rotationchanging', {
  2954. source: this,
  2955. pagesRotation: rotation,
  2956. pageNumber: pageNumber
  2957. });
  2958. if (this.defaultRenderingQueue) {
  2959. this.update();
  2960. }
  2961. }
  2962. }, {
  2963. key: '_setDocumentViewerElement',
  2964. get: function get() {
  2965. throw new Error('Not implemented: _setDocumentViewerElement');
  2966. }
  2967. }, {
  2968. key: 'isInPresentationMode',
  2969. get: function get() {
  2970. return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
  2971. }
  2972. }, {
  2973. key: 'isChangingPresentationMode',
  2974. get: function get() {
  2975. return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
  2976. }
  2977. }, {
  2978. key: 'isHorizontalScrollbarEnabled',
  2979. get: function get() {
  2980. return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
  2981. }
  2982. }, {
  2983. key: 'hasEqualPageSizes',
  2984. get: function get() {
  2985. var firstPageView = this._pages[0];
  2986. for (var i = 1, ii = this._pages.length; i < ii; ++i) {
  2987. var pageView = this._pages[i];
  2988. if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
  2989. return false;
  2990. }
  2991. }
  2992. return true;
  2993. }
  2994. }]);
  2995. return BaseViewer;
  2996. }();
  2997. exports.BaseViewer = BaseViewer;
  2998. /***/ }),
  2999. /* 9 */
  3000. /***/ (function(module, exports, __w_pdfjs_require__) {
  3001. "use strict";
  3002. Object.defineProperty(exports, "__esModule", {
  3003. value: true
  3004. });
  3005. exports.NullL10n = exports.GenericL10n = exports.ProgressBar = exports.DownloadManager = exports.EventBus = exports.PDFFindController = exports.PDFHistory = exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = exports.DefaultTextLayerFactory = exports.TextLayerBuilder = exports.SimpleLinkService = exports.PDFLinkService = exports.PDFPageView = exports.PDFSinglePageViewer = exports.PDFViewer = undefined;
  3006. var _annotation_layer_builder = __w_pdfjs_require__(4);
  3007. var _text_layer_builder = __w_pdfjs_require__(5);
  3008. var _ui_utils = __w_pdfjs_require__(0);
  3009. var _pdf_link_service = __w_pdfjs_require__(3);
  3010. var _download_manager = __w_pdfjs_require__(10);
  3011. var _genericl10n = __w_pdfjs_require__(11);
  3012. var _pdf_find_controller = __w_pdfjs_require__(13);
  3013. var _pdf_history = __w_pdfjs_require__(14);
  3014. var _pdf_page_view = __w_pdfjs_require__(6);
  3015. var _pdf_single_page_viewer = __w_pdfjs_require__(16);
  3016. var _pdf_viewer = __w_pdfjs_require__(17);
  3017. var pdfjsVersion = '2.0.457';
  3018. var pdfjsBuild = '5c1a16ba';
  3019. exports.PDFViewer = _pdf_viewer.PDFViewer;
  3020. exports.PDFSinglePageViewer = _pdf_single_page_viewer.PDFSinglePageViewer;
  3021. exports.PDFPageView = _pdf_page_view.PDFPageView;
  3022. exports.PDFLinkService = _pdf_link_service.PDFLinkService;
  3023. exports.SimpleLinkService = _pdf_link_service.SimpleLinkService;
  3024. exports.TextLayerBuilder = _text_layer_builder.TextLayerBuilder;
  3025. exports.DefaultTextLayerFactory = _text_layer_builder.DefaultTextLayerFactory;
  3026. exports.AnnotationLayerBuilder = _annotation_layer_builder.AnnotationLayerBuilder;
  3027. exports.DefaultAnnotationLayerFactory = _annotation_layer_builder.DefaultAnnotationLayerFactory;
  3028. exports.PDFHistory = _pdf_history.PDFHistory;
  3029. exports.PDFFindController = _pdf_find_controller.PDFFindController;
  3030. exports.EventBus = _ui_utils.EventBus;
  3031. exports.DownloadManager = _download_manager.DownloadManager;
  3032. exports.ProgressBar = _ui_utils.ProgressBar;
  3033. exports.GenericL10n = _genericl10n.GenericL10n;
  3034. exports.NullL10n = _ui_utils.NullL10n;
  3035. /***/ }),
  3036. /* 10 */
  3037. /***/ (function(module, exports, __w_pdfjs_require__) {
  3038. "use strict";
  3039. Object.defineProperty(exports, "__esModule", {
  3040. value: true
  3041. });
  3042. exports.DownloadManager = undefined;
  3043. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  3044. var _pdfjsLib = __w_pdfjs_require__(1);
  3045. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3046. ;
  3047. var DISABLE_CREATE_OBJECT_URL = _pdfjsLib.apiCompatibilityParams.disableCreateObjectURL || false;
  3048. function _download(blobUrl, filename) {
  3049. var a = document.createElement('a');
  3050. if (!a.click) {
  3051. throw new Error('DownloadManager: "a.click()" is not supported.');
  3052. }
  3053. a.href = blobUrl;
  3054. a.target = '_parent';
  3055. if ('download' in a) {
  3056. a.download = filename;
  3057. }
  3058. (document.body || document.documentElement).appendChild(a);
  3059. a.click();
  3060. a.remove();
  3061. }
  3062. var DownloadManager = function () {
  3063. function DownloadManager(_ref) {
  3064. var _ref$disableCreateObj = _ref.disableCreateObjectURL,
  3065. disableCreateObjectURL = _ref$disableCreateObj === undefined ? DISABLE_CREATE_OBJECT_URL : _ref$disableCreateObj;
  3066. _classCallCheck(this, DownloadManager);
  3067. this.disableCreateObjectURL = disableCreateObjectURL;
  3068. }
  3069. _createClass(DownloadManager, [{
  3070. key: 'downloadUrl',
  3071. value: function downloadUrl(url, filename) {
  3072. if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, 'http://example.com')) {
  3073. return;
  3074. }
  3075. _download(url + '#pdfjs.action=download', filename);
  3076. }
  3077. }, {
  3078. key: 'downloadData',
  3079. value: function downloadData(data, filename, contentType) {
  3080. if (navigator.msSaveBlob) {
  3081. return navigator.msSaveBlob(new Blob([data], { type: contentType }), filename);
  3082. }
  3083. var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, this.disableCreateObjectURL);
  3084. _download(blobUrl, filename);
  3085. }
  3086. }, {
  3087. key: 'download',
  3088. value: function download(blob, url, filename) {
  3089. if (navigator.msSaveBlob) {
  3090. if (!navigator.msSaveBlob(blob, filename)) {
  3091. this.downloadUrl(url, filename);
  3092. }
  3093. return;
  3094. }
  3095. if (this.disableCreateObjectURL) {
  3096. this.downloadUrl(url, filename);
  3097. return;
  3098. }
  3099. var blobUrl = URL.createObjectURL(blob);
  3100. _download(blobUrl, filename);
  3101. }
  3102. }]);
  3103. return DownloadManager;
  3104. }();
  3105. exports.DownloadManager = DownloadManager;
  3106. /***/ }),
  3107. /* 11 */
  3108. /***/ (function(module, exports, __w_pdfjs_require__) {
  3109. "use strict";
  3110. Object.defineProperty(exports, "__esModule", {
  3111. value: true
  3112. });
  3113. exports.GenericL10n = undefined;
  3114. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  3115. __w_pdfjs_require__(12);
  3116. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3117. var webL10n = document.webL10n;
  3118. var GenericL10n = function () {
  3119. function GenericL10n(lang) {
  3120. _classCallCheck(this, GenericL10n);
  3121. this._lang = lang;
  3122. this._ready = new Promise(function (resolve, reject) {
  3123. webL10n.setLanguage(lang, function () {
  3124. resolve(webL10n);
  3125. });
  3126. });
  3127. }
  3128. _createClass(GenericL10n, [{
  3129. key: 'getDirection',
  3130. value: function getDirection() {
  3131. return this._ready.then(function (l10n) {
  3132. return l10n.getDirection();
  3133. });
  3134. }
  3135. }, {
  3136. key: 'get',
  3137. value: function get(property, args, fallback) {
  3138. return this._ready.then(function (l10n) {
  3139. return l10n.get(property, args, fallback);
  3140. });
  3141. }
  3142. }, {
  3143. key: 'translate',
  3144. value: function translate(element) {
  3145. return this._ready.then(function (l10n) {
  3146. return l10n.translate(element);
  3147. });
  3148. }
  3149. }]);
  3150. return GenericL10n;
  3151. }();
  3152. exports.GenericL10n = GenericL10n;
  3153. /***/ }),
  3154. /* 12 */
  3155. /***/ (function(module, exports, __w_pdfjs_require__) {
  3156. "use strict";
  3157. document.webL10n = function (window, document, undefined) {
  3158. var gL10nData = {};
  3159. var gTextData = '';
  3160. var gTextProp = 'textContent';
  3161. var gLanguage = '';
  3162. var gMacros = {};
  3163. var gReadyState = 'loading';
  3164. var gAsyncResourceLoading = true;
  3165. function getL10nResourceLinks() {
  3166. return document.querySelectorAll('link[type="application/l10n"]');
  3167. }
  3168. function getL10nDictionary() {
  3169. var script = document.querySelector('script[type="application/l10n"]');
  3170. return script ? JSON.parse(script.innerHTML) : null;
  3171. }
  3172. function getTranslatableChildren(element) {
  3173. return element ? element.querySelectorAll('*[data-l10n-id]') : [];
  3174. }
  3175. function getL10nAttributes(element) {
  3176. if (!element) return {};
  3177. var l10nId = element.getAttribute('data-l10n-id');
  3178. var l10nArgs = element.getAttribute('data-l10n-args');
  3179. var args = {};
  3180. if (l10nArgs) {
  3181. try {
  3182. args = JSON.parse(l10nArgs);
  3183. } catch (e) {
  3184. console.warn('could not parse arguments for #' + l10nId);
  3185. }
  3186. }
  3187. return {
  3188. id: l10nId,
  3189. args: args
  3190. };
  3191. }
  3192. function fireL10nReadyEvent(lang) {
  3193. var evtObject = document.createEvent('Event');
  3194. evtObject.initEvent('localized', true, false);
  3195. evtObject.language = lang;
  3196. document.dispatchEvent(evtObject);
  3197. }
  3198. function xhrLoadText(url, onSuccess, onFailure) {
  3199. onSuccess = onSuccess || function _onSuccess(data) {};
  3200. onFailure = onFailure || function _onFailure() {};
  3201. var xhr = new XMLHttpRequest();
  3202. xhr.open('GET', url, gAsyncResourceLoading);
  3203. if (xhr.overrideMimeType) {
  3204. xhr.overrideMimeType('text/plain; charset=utf-8');
  3205. }
  3206. xhr.onreadystatechange = function () {
  3207. if (xhr.readyState == 4) {
  3208. if (xhr.status == 200 || xhr.status === 0) {
  3209. onSuccess(xhr.responseText);
  3210. } else {
  3211. onFailure();
  3212. }
  3213. }
  3214. };
  3215. xhr.onerror = onFailure;
  3216. xhr.ontimeout = onFailure;
  3217. try {
  3218. xhr.send(null);
  3219. } catch (e) {
  3220. onFailure();
  3221. }
  3222. }
  3223. function parseResource(href, lang, successCallback, failureCallback) {
  3224. var baseURL = href.replace(/[^\/]*$/, '') || './';
  3225. function evalString(text) {
  3226. if (text.lastIndexOf('\\') < 0) return text;
  3227. return text.replace(/\\\\/g, '\\').replace(/\\n/g, '\n').replace(/\\r/g, '\r').replace(/\\t/g, '\t').replace(/\\b/g, '\b').replace(/\\f/g, '\f').replace(/\\{/g, '{').replace(/\\}/g, '}').replace(/\\"/g, '"').replace(/\\'/g, "'");
  3228. }
  3229. function parseProperties(text, parsedPropertiesCallback) {
  3230. var dictionary = {};
  3231. var reBlank = /^\s*|\s*$/;
  3232. var reComment = /^\s*#|^\s*$/;
  3233. var reSection = /^\s*\[(.*)\]\s*$/;
  3234. var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
  3235. var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
  3236. function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
  3237. var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
  3238. var currentLang = '*';
  3239. var genericLang = lang.split('-', 1)[0];
  3240. var skipLang = false;
  3241. var match = '';
  3242. function nextEntry() {
  3243. while (true) {
  3244. if (!entries.length) {
  3245. parsedRawLinesCallback();
  3246. return;
  3247. }
  3248. var line = entries.shift();
  3249. if (reComment.test(line)) continue;
  3250. if (extendedSyntax) {
  3251. match = reSection.exec(line);
  3252. if (match) {
  3253. currentLang = match[1].toLowerCase();
  3254. skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
  3255. continue;
  3256. } else if (skipLang) {
  3257. continue;
  3258. }
  3259. match = reImport.exec(line);
  3260. if (match) {
  3261. loadImport(baseURL + match[1], nextEntry);
  3262. return;
  3263. }
  3264. }
  3265. var tmp = line.match(reSplit);
  3266. if (tmp && tmp.length == 3) {
  3267. dictionary[tmp[1]] = evalString(tmp[2]);
  3268. }
  3269. }
  3270. }
  3271. nextEntry();
  3272. }
  3273. function loadImport(url, callback) {
  3274. xhrLoadText(url, function (content) {
  3275. parseRawLines(content, false, callback);
  3276. }, function () {
  3277. console.warn(url + ' not found.');
  3278. callback();
  3279. });
  3280. }
  3281. parseRawLines(text, true, function () {
  3282. parsedPropertiesCallback(dictionary);
  3283. });
  3284. }
  3285. xhrLoadText(href, function (response) {
  3286. gTextData += response;
  3287. parseProperties(response, function (data) {
  3288. for (var key in data) {
  3289. var id,
  3290. prop,
  3291. index = key.lastIndexOf('.');
  3292. if (index > 0) {
  3293. id = key.substring(0, index);
  3294. prop = key.substr(index + 1);
  3295. } else {
  3296. id = key;
  3297. prop = gTextProp;
  3298. }
  3299. if (!gL10nData[id]) {
  3300. gL10nData[id] = {};
  3301. }
  3302. gL10nData[id][prop] = data[key];
  3303. }
  3304. if (successCallback) {
  3305. successCallback();
  3306. }
  3307. });
  3308. }, failureCallback);
  3309. }
  3310. function loadLocale(lang, callback) {
  3311. if (lang) {
  3312. lang = lang.toLowerCase();
  3313. }
  3314. callback = callback || function _callback() {};
  3315. clear();
  3316. gLanguage = lang;
  3317. var langLinks = getL10nResourceLinks();
  3318. var langCount = langLinks.length;
  3319. if (langCount === 0) {
  3320. var dict = getL10nDictionary();
  3321. if (dict && dict.locales && dict.default_locale) {
  3322. console.log('using the embedded JSON directory, early way out');
  3323. gL10nData = dict.locales[lang];
  3324. if (!gL10nData) {
  3325. var defaultLocale = dict.default_locale.toLowerCase();
  3326. for (var anyCaseLang in dict.locales) {
  3327. anyCaseLang = anyCaseLang.toLowerCase();
  3328. if (anyCaseLang === lang) {
  3329. gL10nData = dict.locales[lang];
  3330. break;
  3331. } else if (anyCaseLang === defaultLocale) {
  3332. gL10nData = dict.locales[defaultLocale];
  3333. }
  3334. }
  3335. }
  3336. callback();
  3337. } else {
  3338. console.log('no resource to load, early way out');
  3339. }
  3340. fireL10nReadyEvent(lang);
  3341. gReadyState = 'complete';
  3342. return;
  3343. }
  3344. var onResourceLoaded = null;
  3345. var gResourceCount = 0;
  3346. onResourceLoaded = function onResourceLoaded() {
  3347. gResourceCount++;
  3348. if (gResourceCount >= langCount) {
  3349. callback();
  3350. fireL10nReadyEvent(lang);
  3351. gReadyState = 'complete';
  3352. }
  3353. };
  3354. function L10nResourceLink(link) {
  3355. var href = link.href;
  3356. this.load = function (lang, callback) {
  3357. parseResource(href, lang, callback, function () {
  3358. console.warn(href + ' not found.');
  3359. console.warn('"' + lang + '" resource not found');
  3360. gLanguage = '';
  3361. callback();
  3362. });
  3363. };
  3364. }
  3365. for (var i = 0; i < langCount; i++) {
  3366. var resource = new L10nResourceLink(langLinks[i]);
  3367. resource.load(lang, onResourceLoaded);
  3368. }
  3369. }
  3370. function clear() {
  3371. gL10nData = {};
  3372. gTextData = '';
  3373. gLanguage = '';
  3374. }
  3375. function getPluralRules(lang) {
  3376. var locales2rules = {
  3377. 'af': 3,
  3378. 'ak': 4,
  3379. 'am': 4,
  3380. 'ar': 1,
  3381. 'asa': 3,
  3382. 'az': 0,
  3383. 'be': 11,
  3384. 'bem': 3,
  3385. 'bez': 3,
  3386. 'bg': 3,
  3387. 'bh': 4,
  3388. 'bm': 0,
  3389. 'bn': 3,
  3390. 'bo': 0,
  3391. 'br': 20,
  3392. 'brx': 3,
  3393. 'bs': 11,
  3394. 'ca': 3,
  3395. 'cgg': 3,
  3396. 'chr': 3,
  3397. 'cs': 12,
  3398. 'cy': 17,
  3399. 'da': 3,
  3400. 'de': 3,
  3401. 'dv': 3,
  3402. 'dz': 0,
  3403. 'ee': 3,
  3404. 'el': 3,
  3405. 'en': 3,
  3406. 'eo': 3,
  3407. 'es': 3,
  3408. 'et': 3,
  3409. 'eu': 3,
  3410. 'fa': 0,
  3411. 'ff': 5,
  3412. 'fi': 3,
  3413. 'fil': 4,
  3414. 'fo': 3,
  3415. 'fr': 5,
  3416. 'fur': 3,
  3417. 'fy': 3,
  3418. 'ga': 8,
  3419. 'gd': 24,
  3420. 'gl': 3,
  3421. 'gsw': 3,
  3422. 'gu': 3,
  3423. 'guw': 4,
  3424. 'gv': 23,
  3425. 'ha': 3,
  3426. 'haw': 3,
  3427. 'he': 2,
  3428. 'hi': 4,
  3429. 'hr': 11,
  3430. 'hu': 0,
  3431. 'id': 0,
  3432. 'ig': 0,
  3433. 'ii': 0,
  3434. 'is': 3,
  3435. 'it': 3,
  3436. 'iu': 7,
  3437. 'ja': 0,
  3438. 'jmc': 3,
  3439. 'jv': 0,
  3440. 'ka': 0,
  3441. 'kab': 5,
  3442. 'kaj': 3,
  3443. 'kcg': 3,
  3444. 'kde': 0,
  3445. 'kea': 0,
  3446. 'kk': 3,
  3447. 'kl': 3,
  3448. 'km': 0,
  3449. 'kn': 0,
  3450. 'ko': 0,
  3451. 'ksb': 3,
  3452. 'ksh': 21,
  3453. 'ku': 3,
  3454. 'kw': 7,
  3455. 'lag': 18,
  3456. 'lb': 3,
  3457. 'lg': 3,
  3458. 'ln': 4,
  3459. 'lo': 0,
  3460. 'lt': 10,
  3461. 'lv': 6,
  3462. 'mas': 3,
  3463. 'mg': 4,
  3464. 'mk': 16,
  3465. 'ml': 3,
  3466. 'mn': 3,
  3467. 'mo': 9,
  3468. 'mr': 3,
  3469. 'ms': 0,
  3470. 'mt': 15,
  3471. 'my': 0,
  3472. 'nah': 3,
  3473. 'naq': 7,
  3474. 'nb': 3,
  3475. 'nd': 3,
  3476. 'ne': 3,
  3477. 'nl': 3,
  3478. 'nn': 3,
  3479. 'no': 3,
  3480. 'nr': 3,
  3481. 'nso': 4,
  3482. 'ny': 3,
  3483. 'nyn': 3,
  3484. 'om': 3,
  3485. 'or': 3,
  3486. 'pa': 3,
  3487. 'pap': 3,
  3488. 'pl': 13,
  3489. 'ps': 3,
  3490. 'pt': 3,
  3491. 'rm': 3,
  3492. 'ro': 9,
  3493. 'rof': 3,
  3494. 'ru': 11,
  3495. 'rwk': 3,
  3496. 'sah': 0,
  3497. 'saq': 3,
  3498. 'se': 7,
  3499. 'seh': 3,
  3500. 'ses': 0,
  3501. 'sg': 0,
  3502. 'sh': 11,
  3503. 'shi': 19,
  3504. 'sk': 12,
  3505. 'sl': 14,
  3506. 'sma': 7,
  3507. 'smi': 7,
  3508. 'smj': 7,
  3509. 'smn': 7,
  3510. 'sms': 7,
  3511. 'sn': 3,
  3512. 'so': 3,
  3513. 'sq': 3,
  3514. 'sr': 11,
  3515. 'ss': 3,
  3516. 'ssy': 3,
  3517. 'st': 3,
  3518. 'sv': 3,
  3519. 'sw': 3,
  3520. 'syr': 3,
  3521. 'ta': 3,
  3522. 'te': 3,
  3523. 'teo': 3,
  3524. 'th': 0,
  3525. 'ti': 4,
  3526. 'tig': 3,
  3527. 'tk': 3,
  3528. 'tl': 4,
  3529. 'tn': 3,
  3530. 'to': 0,
  3531. 'tr': 0,
  3532. 'ts': 3,
  3533. 'tzm': 22,
  3534. 'uk': 11,
  3535. 'ur': 3,
  3536. 've': 3,
  3537. 'vi': 0,
  3538. 'vun': 3,
  3539. 'wa': 4,
  3540. 'wae': 3,
  3541. 'wo': 0,
  3542. 'xh': 3,
  3543. 'xog': 3,
  3544. 'yo': 0,
  3545. 'zh': 0,
  3546. 'zu': 3
  3547. };
  3548. function isIn(n, list) {
  3549. return list.indexOf(n) !== -1;
  3550. }
  3551. function isBetween(n, start, end) {
  3552. return start <= n && n <= end;
  3553. }
  3554. var pluralRules = {
  3555. '0': function _(n) {
  3556. return 'other';
  3557. },
  3558. '1': function _(n) {
  3559. if (isBetween(n % 100, 3, 10)) return 'few';
  3560. if (n === 0) return 'zero';
  3561. if (isBetween(n % 100, 11, 99)) return 'many';
  3562. if (n == 2) return 'two';
  3563. if (n == 1) return 'one';
  3564. return 'other';
  3565. },
  3566. '2': function _(n) {
  3567. if (n !== 0 && n % 10 === 0) return 'many';
  3568. if (n == 2) return 'two';
  3569. if (n == 1) return 'one';
  3570. return 'other';
  3571. },
  3572. '3': function _(n) {
  3573. if (n == 1) return 'one';
  3574. return 'other';
  3575. },
  3576. '4': function _(n) {
  3577. if (isBetween(n, 0, 1)) return 'one';
  3578. return 'other';
  3579. },
  3580. '5': function _(n) {
  3581. if (isBetween(n, 0, 2) && n != 2) return 'one';
  3582. return 'other';
  3583. },
  3584. '6': function _(n) {
  3585. if (n === 0) return 'zero';
  3586. if (n % 10 == 1 && n % 100 != 11) return 'one';
  3587. return 'other';
  3588. },
  3589. '7': function _(n) {
  3590. if (n == 2) return 'two';
  3591. if (n == 1) return 'one';
  3592. return 'other';
  3593. },
  3594. '8': function _(n) {
  3595. if (isBetween(n, 3, 6)) return 'few';
  3596. if (isBetween(n, 7, 10)) return 'many';
  3597. if (n == 2) return 'two';
  3598. if (n == 1) return 'one';
  3599. return 'other';
  3600. },
  3601. '9': function _(n) {
  3602. if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
  3603. if (n == 1) return 'one';
  3604. return 'other';
  3605. },
  3606. '10': function _(n) {
  3607. if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
  3608. if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
  3609. return 'other';
  3610. },
  3611. '11': function _(n) {
  3612. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  3613. if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
  3614. if (n % 10 == 1 && n % 100 != 11) return 'one';
  3615. return 'other';
  3616. },
  3617. '12': function _(n) {
  3618. if (isBetween(n, 2, 4)) return 'few';
  3619. if (n == 1) return 'one';
  3620. return 'other';
  3621. },
  3622. '13': function _(n) {
  3623. if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
  3624. if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
  3625. if (n == 1) return 'one';
  3626. return 'other';
  3627. },
  3628. '14': function _(n) {
  3629. if (isBetween(n % 100, 3, 4)) return 'few';
  3630. if (n % 100 == 2) return 'two';
  3631. if (n % 100 == 1) return 'one';
  3632. return 'other';
  3633. },
  3634. '15': function _(n) {
  3635. if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
  3636. if (isBetween(n % 100, 11, 19)) return 'many';
  3637. if (n == 1) return 'one';
  3638. return 'other';
  3639. },
  3640. '16': function _(n) {
  3641. if (n % 10 == 1 && n != 11) return 'one';
  3642. return 'other';
  3643. },
  3644. '17': function _(n) {
  3645. if (n == 3) return 'few';
  3646. if (n === 0) return 'zero';
  3647. if (n == 6) return 'many';
  3648. if (n == 2) return 'two';
  3649. if (n == 1) return 'one';
  3650. return 'other';
  3651. },
  3652. '18': function _(n) {
  3653. if (n === 0) return 'zero';
  3654. if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
  3655. return 'other';
  3656. },
  3657. '19': function _(n) {
  3658. if (isBetween(n, 2, 10)) return 'few';
  3659. if (isBetween(n, 0, 1)) return 'one';
  3660. return 'other';
  3661. },
  3662. '20': function _(n) {
  3663. if ((isBetween(n % 10, 3, 4) || n % 10 == 9) && !(isBetween(n % 100, 10, 19) || isBetween(n % 100, 70, 79) || isBetween(n % 100, 90, 99))) return 'few';
  3664. if (n % 1000000 === 0 && n !== 0) return 'many';
  3665. if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
  3666. if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
  3667. return 'other';
  3668. },
  3669. '21': function _(n) {
  3670. if (n === 0) return 'zero';
  3671. if (n == 1) return 'one';
  3672. return 'other';
  3673. },
  3674. '22': function _(n) {
  3675. if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
  3676. return 'other';
  3677. },
  3678. '23': function _(n) {
  3679. if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
  3680. return 'other';
  3681. },
  3682. '24': function _(n) {
  3683. if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
  3684. if (isIn(n, [2, 12])) return 'two';
  3685. if (isIn(n, [1, 11])) return 'one';
  3686. return 'other';
  3687. }
  3688. };
  3689. var index = locales2rules[lang.replace(/-.*$/, '')];
  3690. if (!(index in pluralRules)) {
  3691. console.warn('plural form unknown for [' + lang + ']');
  3692. return function () {
  3693. return 'other';
  3694. };
  3695. }
  3696. return pluralRules[index];
  3697. }
  3698. gMacros.plural = function (str, param, key, prop) {
  3699. var n = parseFloat(param);
  3700. if (isNaN(n)) return str;
  3701. if (prop != gTextProp) return str;
  3702. if (!gMacros._pluralRules) {
  3703. gMacros._pluralRules = getPluralRules(gLanguage);
  3704. }
  3705. var index = '[' + gMacros._pluralRules(n) + ']';
  3706. if (n === 0 && key + '[zero]' in gL10nData) {
  3707. str = gL10nData[key + '[zero]'][prop];
  3708. } else if (n == 1 && key + '[one]' in gL10nData) {
  3709. str = gL10nData[key + '[one]'][prop];
  3710. } else if (n == 2 && key + '[two]' in gL10nData) {
  3711. str = gL10nData[key + '[two]'][prop];
  3712. } else if (key + index in gL10nData) {
  3713. str = gL10nData[key + index][prop];
  3714. } else if (key + '[other]' in gL10nData) {
  3715. str = gL10nData[key + '[other]'][prop];
  3716. }
  3717. return str;
  3718. };
  3719. function getL10nData(key, args, fallback) {
  3720. var data = gL10nData[key];
  3721. if (!data) {
  3722. console.warn('#' + key + ' is undefined.');
  3723. if (!fallback) {
  3724. return null;
  3725. }
  3726. data = fallback;
  3727. }
  3728. var rv = {};
  3729. for (var prop in data) {
  3730. var str = data[prop];
  3731. str = substIndexes(str, args, key, prop);
  3732. str = substArguments(str, args, key);
  3733. rv[prop] = str;
  3734. }
  3735. return rv;
  3736. }
  3737. function substIndexes(str, args, key, prop) {
  3738. var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
  3739. var reMatch = reIndex.exec(str);
  3740. if (!reMatch || !reMatch.length) return str;
  3741. var macroName = reMatch[1];
  3742. var paramName = reMatch[2];
  3743. var param;
  3744. if (args && paramName in args) {
  3745. param = args[paramName];
  3746. } else if (paramName in gL10nData) {
  3747. param = gL10nData[paramName];
  3748. }
  3749. if (macroName in gMacros) {
  3750. var macro = gMacros[macroName];
  3751. str = macro(str, param, key, prop);
  3752. }
  3753. return str;
  3754. }
  3755. function substArguments(str, args, key) {
  3756. var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
  3757. return str.replace(reArgs, function (matched_text, arg) {
  3758. if (args && arg in args) {
  3759. return args[arg];
  3760. }
  3761. if (arg in gL10nData) {
  3762. return gL10nData[arg];
  3763. }
  3764. console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
  3765. return matched_text;
  3766. });
  3767. }
  3768. function translateElement(element) {
  3769. var l10n = getL10nAttributes(element);
  3770. if (!l10n.id) return;
  3771. var data = getL10nData(l10n.id, l10n.args);
  3772. if (!data) {
  3773. console.warn('#' + l10n.id + ' is undefined.');
  3774. return;
  3775. }
  3776. if (data[gTextProp]) {
  3777. if (getChildElementCount(element) === 0) {
  3778. element[gTextProp] = data[gTextProp];
  3779. } else {
  3780. var children = element.childNodes;
  3781. var found = false;
  3782. for (var i = 0, l = children.length; i < l; i++) {
  3783. if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
  3784. if (found) {
  3785. children[i].nodeValue = '';
  3786. } else {
  3787. children[i].nodeValue = data[gTextProp];
  3788. found = true;
  3789. }
  3790. }
  3791. }
  3792. if (!found) {
  3793. var textNode = document.createTextNode(data[gTextProp]);
  3794. element.insertBefore(textNode, element.firstChild);
  3795. }
  3796. }
  3797. delete data[gTextProp];
  3798. }
  3799. for (var k in data) {
  3800. element[k] = data[k];
  3801. }
  3802. }
  3803. function getChildElementCount(element) {
  3804. if (element.children) {
  3805. return element.children.length;
  3806. }
  3807. if (typeof element.childElementCount !== 'undefined') {
  3808. return element.childElementCount;
  3809. }
  3810. var count = 0;
  3811. for (var i = 0; i < element.childNodes.length; i++) {
  3812. count += element.nodeType === 1 ? 1 : 0;
  3813. }
  3814. return count;
  3815. }
  3816. function translateFragment(element) {
  3817. element = element || document.documentElement;
  3818. var children = getTranslatableChildren(element);
  3819. var elementCount = children.length;
  3820. for (var i = 0; i < elementCount; i++) {
  3821. translateElement(children[i]);
  3822. }
  3823. translateElement(element);
  3824. }
  3825. return {
  3826. get: function get(key, args, fallbackString) {
  3827. var index = key.lastIndexOf('.');
  3828. var prop = gTextProp;
  3829. if (index > 0) {
  3830. prop = key.substr(index + 1);
  3831. key = key.substring(0, index);
  3832. }
  3833. var fallback;
  3834. if (fallbackString) {
  3835. fallback = {};
  3836. fallback[prop] = fallbackString;
  3837. }
  3838. var data = getL10nData(key, args, fallback);
  3839. if (data && prop in data) {
  3840. return data[prop];
  3841. }
  3842. return '{{' + key + '}}';
  3843. },
  3844. getData: function getData() {
  3845. return gL10nData;
  3846. },
  3847. getText: function getText() {
  3848. return gTextData;
  3849. },
  3850. getLanguage: function getLanguage() {
  3851. return gLanguage;
  3852. },
  3853. setLanguage: function setLanguage(lang, callback) {
  3854. loadLocale(lang, function () {
  3855. if (callback) callback();
  3856. });
  3857. },
  3858. getDirection: function getDirection() {
  3859. var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
  3860. var shortCode = gLanguage.split('-', 1)[0];
  3861. return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
  3862. },
  3863. translate: translateFragment,
  3864. getReadyState: function getReadyState() {
  3865. return gReadyState;
  3866. },
  3867. ready: function ready(callback) {
  3868. if (!callback) {
  3869. return;
  3870. } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
  3871. window.setTimeout(function () {
  3872. callback();
  3873. });
  3874. } else if (document.addEventListener) {
  3875. document.addEventListener('localized', function once() {
  3876. document.removeEventListener('localized', once);
  3877. callback();
  3878. });
  3879. }
  3880. }
  3881. };
  3882. }(window, document);
  3883. /***/ }),
  3884. /* 13 */
  3885. /***/ (function(module, exports, __w_pdfjs_require__) {
  3886. "use strict";
  3887. Object.defineProperty(exports, "__esModule", {
  3888. value: true
  3889. });
  3890. exports.PDFFindController = exports.FindState = undefined;
  3891. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  3892. var _pdfjsLib = __w_pdfjs_require__(1);
  3893. var _ui_utils = __w_pdfjs_require__(0);
  3894. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3895. var FindState = {
  3896. FOUND: 0,
  3897. NOT_FOUND: 1,
  3898. WRAPPED: 2,
  3899. PENDING: 3
  3900. };
  3901. var FIND_SCROLL_OFFSET_TOP = -50;
  3902. var FIND_SCROLL_OFFSET_LEFT = -400;
  3903. var FIND_TIMEOUT = 250;
  3904. var CHARACTERS_TO_NORMALIZE = {
  3905. '\u2018': '\'',
  3906. '\u2019': '\'',
  3907. '\u201A': '\'',
  3908. '\u201B': '\'',
  3909. '\u201C': '"',
  3910. '\u201D': '"',
  3911. '\u201E': '"',
  3912. '\u201F': '"',
  3913. '\xBC': '1/4',
  3914. '\xBD': '1/2',
  3915. '\xBE': '3/4'
  3916. };
  3917. var PDFFindController = function () {
  3918. function PDFFindController(_ref) {
  3919. var pdfViewer = _ref.pdfViewer;
  3920. _classCallCheck(this, PDFFindController);
  3921. this.pdfViewer = pdfViewer;
  3922. this.onUpdateResultsCount = null;
  3923. this.onUpdateState = null;
  3924. this.reset();
  3925. var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join('');
  3926. this.normalizationRegex = new RegExp('[' + replace + ']', 'g');
  3927. }
  3928. _createClass(PDFFindController, [{
  3929. key: 'reset',
  3930. value: function reset() {
  3931. var _this = this;
  3932. this.startedTextExtraction = false;
  3933. this.extractTextPromises = [];
  3934. this.pendingFindMatches = Object.create(null);
  3935. this.active = false;
  3936. this.pageContents = [];
  3937. this.pageMatches = [];
  3938. this.pageMatchesLength = null;
  3939. this.matchCount = 0;
  3940. this.selected = {
  3941. pageIdx: -1,
  3942. matchIdx: -1
  3943. };
  3944. this.offset = {
  3945. pageIdx: null,
  3946. matchIdx: null
  3947. };
  3948. this.pagesToSearch = null;
  3949. this.resumePageIdx = null;
  3950. this.state = null;
  3951. this.dirtyMatch = false;
  3952. this.findTimeout = null;
  3953. this._firstPagePromise = new Promise(function (resolve) {
  3954. _this.resolveFirstPage = resolve;
  3955. });
  3956. }
  3957. }, {
  3958. key: 'executeCommand',
  3959. value: function executeCommand(cmd, state) {
  3960. var _this2 = this;
  3961. if (this.state === null || cmd !== 'findagain') {
  3962. this.dirtyMatch = true;
  3963. }
  3964. this.state = state;
  3965. this._updateUIState(FindState.PENDING);
  3966. this._firstPagePromise.then(function () {
  3967. _this2._extractText();
  3968. clearTimeout(_this2.findTimeout);
  3969. if (cmd === 'find') {
  3970. _this2.findTimeout = setTimeout(_this2._nextMatch.bind(_this2), FIND_TIMEOUT);
  3971. } else {
  3972. _this2._nextMatch();
  3973. }
  3974. });
  3975. }
  3976. }, {
  3977. key: 'updateMatchPosition',
  3978. value: function updateMatchPosition(pageIndex, matchIndex, elements, beginIdx) {
  3979. if (this.selected.matchIdx === matchIndex && this.selected.pageIdx === pageIndex) {
  3980. var spot = {
  3981. top: FIND_SCROLL_OFFSET_TOP,
  3982. left: FIND_SCROLL_OFFSET_LEFT
  3983. };
  3984. (0, _ui_utils.scrollIntoView)(elements[beginIdx], spot, true);
  3985. }
  3986. }
  3987. }, {
  3988. key: '_normalize',
  3989. value: function _normalize(text) {
  3990. return text.replace(this.normalizationRegex, function (ch) {
  3991. return CHARACTERS_TO_NORMALIZE[ch];
  3992. });
  3993. }
  3994. }, {
  3995. key: '_prepareMatches',
  3996. value: function _prepareMatches(matchesWithLength, matches, matchesLength) {
  3997. function isSubTerm(matchesWithLength, currentIndex) {
  3998. var currentElem = matchesWithLength[currentIndex];
  3999. var nextElem = matchesWithLength[currentIndex + 1];
  4000. if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {
  4001. currentElem.skipped = true;
  4002. return true;
  4003. }
  4004. for (var i = currentIndex - 1; i >= 0; i--) {
  4005. var prevElem = matchesWithLength[i];
  4006. if (prevElem.skipped) {
  4007. continue;
  4008. }
  4009. if (prevElem.match + prevElem.matchLength < currentElem.match) {
  4010. break;
  4011. }
  4012. if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {
  4013. currentElem.skipped = true;
  4014. return true;
  4015. }
  4016. }
  4017. return false;
  4018. }
  4019. matchesWithLength.sort(function (a, b) {
  4020. return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match;
  4021. });
  4022. for (var i = 0, len = matchesWithLength.length; i < len; i++) {
  4023. if (isSubTerm(matchesWithLength, i)) {
  4024. continue;
  4025. }
  4026. matches.push(matchesWithLength[i].match);
  4027. matchesLength.push(matchesWithLength[i].matchLength);
  4028. }
  4029. }
  4030. }, {
  4031. key: '_calculatePhraseMatch',
  4032. value: function _calculatePhraseMatch(query, pageIndex, pageContent) {
  4033. var matches = [];
  4034. var queryLen = query.length;
  4035. var matchIdx = -queryLen;
  4036. while (true) {
  4037. matchIdx = pageContent.indexOf(query, matchIdx + queryLen);
  4038. if (matchIdx === -1) {
  4039. break;
  4040. }
  4041. matches.push(matchIdx);
  4042. }
  4043. this.pageMatches[pageIndex] = matches;
  4044. }
  4045. }, {
  4046. key: '_calculateWordMatch',
  4047. value: function _calculateWordMatch(query, pageIndex, pageContent) {
  4048. var matchesWithLength = [];
  4049. var queryArray = query.match(/\S+/g);
  4050. for (var i = 0, len = queryArray.length; i < len; i++) {
  4051. var subquery = queryArray[i];
  4052. var subqueryLen = subquery.length;
  4053. var matchIdx = -subqueryLen;
  4054. while (true) {
  4055. matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen);
  4056. if (matchIdx === -1) {
  4057. break;
  4058. }
  4059. matchesWithLength.push({
  4060. match: matchIdx,
  4061. matchLength: subqueryLen,
  4062. skipped: false
  4063. });
  4064. }
  4065. }
  4066. if (!this.pageMatchesLength) {
  4067. this.pageMatchesLength = [];
  4068. }
  4069. this.pageMatchesLength[pageIndex] = [];
  4070. this.pageMatches[pageIndex] = [];
  4071. this._prepareMatches(matchesWithLength, this.pageMatches[pageIndex], this.pageMatchesLength[pageIndex]);
  4072. }
  4073. }, {
  4074. key: '_calculateMatch',
  4075. value: function _calculateMatch(pageIndex) {
  4076. var pageContent = this._normalize(this.pageContents[pageIndex]);
  4077. var query = this._normalize(this.state.query);
  4078. var caseSensitive = this.state.caseSensitive;
  4079. var phraseSearch = this.state.phraseSearch;
  4080. var queryLen = query.length;
  4081. if (queryLen === 0) {
  4082. return;
  4083. }
  4084. if (!caseSensitive) {
  4085. pageContent = pageContent.toLowerCase();
  4086. query = query.toLowerCase();
  4087. }
  4088. if (phraseSearch) {
  4089. this._calculatePhraseMatch(query, pageIndex, pageContent);
  4090. } else {
  4091. this._calculateWordMatch(query, pageIndex, pageContent);
  4092. }
  4093. this._updatePage(pageIndex);
  4094. if (this.resumePageIdx === pageIndex) {
  4095. this.resumePageIdx = null;
  4096. this._nextPageMatch();
  4097. }
  4098. if (this.pageMatches[pageIndex].length > 0) {
  4099. this.matchCount += this.pageMatches[pageIndex].length;
  4100. this._updateUIResultsCount();
  4101. }
  4102. }
  4103. }, {
  4104. key: '_extractText',
  4105. value: function _extractText() {
  4106. var _this3 = this;
  4107. if (this.startedTextExtraction) {
  4108. return;
  4109. }
  4110. this.startedTextExtraction = true;
  4111. this.pageContents.length = 0;
  4112. var promise = Promise.resolve();
  4113. var _loop = function _loop(i, ii) {
  4114. var extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
  4115. _this3.extractTextPromises[i] = extractTextCapability.promise;
  4116. promise = promise.then(function () {
  4117. return _this3.pdfViewer.getPageTextContent(i).then(function (textContent) {
  4118. var textItems = textContent.items;
  4119. var strBuf = [];
  4120. for (var j = 0, jj = textItems.length; j < jj; j++) {
  4121. strBuf.push(textItems[j].str);
  4122. }
  4123. _this3.pageContents[i] = strBuf.join('');
  4124. extractTextCapability.resolve(i);
  4125. }, function (reason) {
  4126. console.error('Unable to get page ' + (i + 1) + ' text content', reason);
  4127. _this3.pageContents[i] = '';
  4128. extractTextCapability.resolve(i);
  4129. });
  4130. });
  4131. };
  4132. for (var i = 0, ii = this.pdfViewer.pagesCount; i < ii; i++) {
  4133. _loop(i, ii);
  4134. }
  4135. }
  4136. }, {
  4137. key: '_updatePage',
  4138. value: function _updatePage(index) {
  4139. if (this.selected.pageIdx === index) {
  4140. this.pdfViewer.currentPageNumber = index + 1;
  4141. }
  4142. var page = this.pdfViewer.getPageView(index);
  4143. if (page.textLayer) {
  4144. page.textLayer.updateMatches();
  4145. }
  4146. }
  4147. }, {
  4148. key: '_nextMatch',
  4149. value: function _nextMatch() {
  4150. var _this4 = this;
  4151. var previous = this.state.findPrevious;
  4152. var currentPageIndex = this.pdfViewer.currentPageNumber - 1;
  4153. var numPages = this.pdfViewer.pagesCount;
  4154. this.active = true;
  4155. if (this.dirtyMatch) {
  4156. this.dirtyMatch = false;
  4157. this.selected.pageIdx = this.selected.matchIdx = -1;
  4158. this.offset.pageIdx = currentPageIndex;
  4159. this.offset.matchIdx = null;
  4160. this.hadMatch = false;
  4161. this.resumePageIdx = null;
  4162. this.pageMatches = [];
  4163. this.matchCount = 0;
  4164. this.pageMatchesLength = null;
  4165. for (var i = 0; i < numPages; i++) {
  4166. this._updatePage(i);
  4167. if (!(i in this.pendingFindMatches)) {
  4168. this.pendingFindMatches[i] = true;
  4169. this.extractTextPromises[i].then(function (pageIdx) {
  4170. delete _this4.pendingFindMatches[pageIdx];
  4171. _this4._calculateMatch(pageIdx);
  4172. });
  4173. }
  4174. }
  4175. }
  4176. if (this.state.query === '') {
  4177. this._updateUIState(FindState.FOUND);
  4178. return;
  4179. }
  4180. if (this.resumePageIdx) {
  4181. return;
  4182. }
  4183. var offset = this.offset;
  4184. this.pagesToSearch = numPages;
  4185. if (offset.matchIdx !== null) {
  4186. var numPageMatches = this.pageMatches[offset.pageIdx].length;
  4187. if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
  4188. this.hadMatch = true;
  4189. offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
  4190. this._updateMatch(true);
  4191. return;
  4192. }
  4193. this._advanceOffsetPage(previous);
  4194. }
  4195. this._nextPageMatch();
  4196. }
  4197. }, {
  4198. key: '_matchesReady',
  4199. value: function _matchesReady(matches) {
  4200. var offset = this.offset;
  4201. var numMatches = matches.length;
  4202. var previous = this.state.findPrevious;
  4203. if (numMatches) {
  4204. this.hadMatch = true;
  4205. offset.matchIdx = previous ? numMatches - 1 : 0;
  4206. this._updateMatch(true);
  4207. return true;
  4208. }
  4209. this._advanceOffsetPage(previous);
  4210. if (offset.wrapped) {
  4211. offset.matchIdx = null;
  4212. if (this.pagesToSearch < 0) {
  4213. this._updateMatch(false);
  4214. return true;
  4215. }
  4216. }
  4217. return false;
  4218. }
  4219. }, {
  4220. key: '_nextPageMatch',
  4221. value: function _nextPageMatch() {
  4222. if (this.resumePageIdx !== null) {
  4223. console.error('There can only be one pending page.');
  4224. }
  4225. var matches = null;
  4226. do {
  4227. var pageIdx = this.offset.pageIdx;
  4228. matches = this.pageMatches[pageIdx];
  4229. if (!matches) {
  4230. this.resumePageIdx = pageIdx;
  4231. break;
  4232. }
  4233. } while (!this._matchesReady(matches));
  4234. }
  4235. }, {
  4236. key: '_advanceOffsetPage',
  4237. value: function _advanceOffsetPage(previous) {
  4238. var offset = this.offset;
  4239. var numPages = this.extractTextPromises.length;
  4240. offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
  4241. offset.matchIdx = null;
  4242. this.pagesToSearch--;
  4243. if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
  4244. offset.pageIdx = previous ? numPages - 1 : 0;
  4245. offset.wrapped = true;
  4246. }
  4247. }
  4248. }, {
  4249. key: '_updateMatch',
  4250. value: function _updateMatch() {
  4251. var found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4252. var state = FindState.NOT_FOUND;
  4253. var wrapped = this.offset.wrapped;
  4254. this.offset.wrapped = false;
  4255. if (found) {
  4256. var previousPage = this.selected.pageIdx;
  4257. this.selected.pageIdx = this.offset.pageIdx;
  4258. this.selected.matchIdx = this.offset.matchIdx;
  4259. state = wrapped ? FindState.WRAPPED : FindState.FOUND;
  4260. if (previousPage !== -1 && previousPage !== this.selected.pageIdx) {
  4261. this._updatePage(previousPage);
  4262. }
  4263. }
  4264. this._updateUIState(state, this.state.findPrevious);
  4265. if (this.selected.pageIdx !== -1) {
  4266. this._updatePage(this.selected.pageIdx);
  4267. }
  4268. }
  4269. }, {
  4270. key: '_updateUIResultsCount',
  4271. value: function _updateUIResultsCount() {
  4272. if (this.onUpdateResultsCount) {
  4273. this.onUpdateResultsCount(this.matchCount);
  4274. }
  4275. }
  4276. }, {
  4277. key: '_updateUIState',
  4278. value: function _updateUIState(state, previous) {
  4279. if (this.onUpdateState) {
  4280. this.onUpdateState(state, previous, this.matchCount);
  4281. }
  4282. }
  4283. }]);
  4284. return PDFFindController;
  4285. }();
  4286. exports.FindState = FindState;
  4287. exports.PDFFindController = PDFFindController;
  4288. /***/ }),
  4289. /* 14 */
  4290. /***/ (function(module, exports, __w_pdfjs_require__) {
  4291. "use strict";
  4292. Object.defineProperty(exports, "__esModule", {
  4293. value: true
  4294. });
  4295. exports.isDestArraysEqual = exports.isDestHashesEqual = exports.PDFHistory = undefined;
  4296. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  4297. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  4298. var _ui_utils = __w_pdfjs_require__(0);
  4299. var _dom_events = __w_pdfjs_require__(2);
  4300. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4301. var HASH_CHANGE_TIMEOUT = 1000;
  4302. var POSITION_UPDATED_THRESHOLD = 50;
  4303. var UPDATE_VIEWAREA_TIMEOUT = 1000;
  4304. function getCurrentHash() {
  4305. return document.location.hash;
  4306. }
  4307. function parseCurrentHash(linkService) {
  4308. var hash = unescape(getCurrentHash()).substring(1);
  4309. var params = (0, _ui_utils.parseQueryString)(hash);
  4310. var page = params.page | 0;
  4311. if (!(Number.isInteger(page) && page > 0 && page <= linkService.pagesCount)) {
  4312. page = null;
  4313. }
  4314. return {
  4315. hash: hash,
  4316. page: page,
  4317. rotation: linkService.rotation
  4318. };
  4319. }
  4320. var PDFHistory = function () {
  4321. function PDFHistory(_ref) {
  4322. var _this = this;
  4323. var linkService = _ref.linkService,
  4324. eventBus = _ref.eventBus;
  4325. _classCallCheck(this, PDFHistory);
  4326. this.linkService = linkService;
  4327. this.eventBus = eventBus || (0, _dom_events.getGlobalEventBus)();
  4328. this.initialized = false;
  4329. this.initialBookmark = null;
  4330. this.initialRotation = null;
  4331. this._boundEvents = Object.create(null);
  4332. this._isViewerInPresentationMode = false;
  4333. this._isPagesLoaded = false;
  4334. this.eventBus.on('presentationmodechanged', function (evt) {
  4335. _this._isViewerInPresentationMode = evt.active || evt.switchInProgress;
  4336. });
  4337. this.eventBus.on('pagesloaded', function (evt) {
  4338. _this._isPagesLoaded = !!evt.pagesCount;
  4339. });
  4340. }
  4341. _createClass(PDFHistory, [{
  4342. key: 'initialize',
  4343. value: function initialize(fingerprint) {
  4344. var resetHistory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4345. if (!fingerprint || typeof fingerprint !== 'string') {
  4346. console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
  4347. return;
  4348. }
  4349. var reInitialized = this.initialized && this.fingerprint !== fingerprint;
  4350. this.fingerprint = fingerprint;
  4351. if (!this.initialized) {
  4352. this._bindEvents();
  4353. }
  4354. var state = window.history.state;
  4355. this.initialized = true;
  4356. this.initialBookmark = null;
  4357. this.initialRotation = null;
  4358. this._popStateInProgress = false;
  4359. this._blockHashChange = 0;
  4360. this._currentHash = getCurrentHash();
  4361. this._numPositionUpdates = 0;
  4362. this._uid = this._maxUid = 0;
  4363. this._destination = null;
  4364. this._position = null;
  4365. if (!this._isValidState(state) || resetHistory) {
  4366. var _parseCurrentHash = parseCurrentHash(this.linkService),
  4367. hash = _parseCurrentHash.hash,
  4368. page = _parseCurrentHash.page,
  4369. rotation = _parseCurrentHash.rotation;
  4370. if (!hash || reInitialized || resetHistory) {
  4371. this._pushOrReplaceState(null, true);
  4372. return;
  4373. }
  4374. this._pushOrReplaceState({
  4375. hash: hash,
  4376. page: page,
  4377. rotation: rotation
  4378. }, true);
  4379. return;
  4380. }
  4381. var destination = state.destination;
  4382. this._updateInternalState(destination, state.uid, true);
  4383. if (this._uid > this._maxUid) {
  4384. this._maxUid = this._uid;
  4385. }
  4386. if (destination.rotation !== undefined) {
  4387. this.initialRotation = destination.rotation;
  4388. }
  4389. if (destination.dest) {
  4390. this.initialBookmark = JSON.stringify(destination.dest);
  4391. this._destination.page = null;
  4392. } else if (destination.hash) {
  4393. this.initialBookmark = destination.hash;
  4394. } else if (destination.page) {
  4395. this.initialBookmark = 'page=' + destination.page;
  4396. }
  4397. }
  4398. }, {
  4399. key: 'push',
  4400. value: function push(_ref2) {
  4401. var _this2 = this;
  4402. var namedDest = _ref2.namedDest,
  4403. explicitDest = _ref2.explicitDest,
  4404. pageNumber = _ref2.pageNumber;
  4405. if (!this.initialized) {
  4406. return;
  4407. }
  4408. if (namedDest && typeof namedDest !== 'string' || !(explicitDest instanceof Array) || !(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {
  4409. console.error('PDFHistory.push: Invalid parameters.');
  4410. return;
  4411. }
  4412. var hash = namedDest || JSON.stringify(explicitDest);
  4413. if (!hash) {
  4414. return;
  4415. }
  4416. var forceReplace = false;
  4417. if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
  4418. if (this._destination.page) {
  4419. return;
  4420. }
  4421. forceReplace = true;
  4422. }
  4423. if (this._popStateInProgress && !forceReplace) {
  4424. return;
  4425. }
  4426. this._pushOrReplaceState({
  4427. dest: explicitDest,
  4428. hash: hash,
  4429. page: pageNumber,
  4430. rotation: this.linkService.rotation
  4431. }, forceReplace);
  4432. if (!this._popStateInProgress) {
  4433. this._popStateInProgress = true;
  4434. Promise.resolve().then(function () {
  4435. _this2._popStateInProgress = false;
  4436. });
  4437. }
  4438. }
  4439. }, {
  4440. key: 'pushCurrentPosition',
  4441. value: function pushCurrentPosition() {
  4442. if (!this.initialized || this._popStateInProgress) {
  4443. return;
  4444. }
  4445. this._tryPushCurrentPosition();
  4446. }
  4447. }, {
  4448. key: 'back',
  4449. value: function back() {
  4450. if (!this.initialized || this._popStateInProgress) {
  4451. return;
  4452. }
  4453. var state = window.history.state;
  4454. if (this._isValidState(state) && state.uid > 0) {
  4455. window.history.back();
  4456. }
  4457. }
  4458. }, {
  4459. key: 'forward',
  4460. value: function forward() {
  4461. if (!this.initialized || this._popStateInProgress) {
  4462. return;
  4463. }
  4464. var state = window.history.state;
  4465. if (this._isValidState(state) && state.uid < this._maxUid) {
  4466. window.history.forward();
  4467. }
  4468. }
  4469. }, {
  4470. key: '_pushOrReplaceState',
  4471. value: function _pushOrReplaceState(destination) {
  4472. var forceReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  4473. var shouldReplace = forceReplace || !this._destination;
  4474. var newState = {
  4475. fingerprint: this.fingerprint,
  4476. uid: shouldReplace ? this._uid : this._uid + 1,
  4477. destination: destination
  4478. };
  4479. this._updateInternalState(destination, newState.uid);
  4480. if (shouldReplace) {
  4481. window.history.replaceState(newState, '');
  4482. } else {
  4483. this._maxUid = this._uid;
  4484. window.history.pushState(newState, '');
  4485. }
  4486. }
  4487. }, {
  4488. key: '_tryPushCurrentPosition',
  4489. value: function _tryPushCurrentPosition() {
  4490. var temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  4491. if (!this._position) {
  4492. return;
  4493. }
  4494. var position = this._position;
  4495. if (temporary) {
  4496. position = (0, _ui_utils.cloneObj)(this._position);
  4497. position.temporary = true;
  4498. }
  4499. if (!this._destination) {
  4500. this._pushOrReplaceState(position);
  4501. return;
  4502. }
  4503. if (this._destination.temporary) {
  4504. this._pushOrReplaceState(position, true);
  4505. return;
  4506. }
  4507. if (this._destination.hash === position.hash) {
  4508. return;
  4509. }
  4510. if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
  4511. return;
  4512. }
  4513. var forceReplace = false;
  4514. if (this._destination.page === position.first || this._destination.page === position.page) {
  4515. if (this._destination.dest || !this._destination.first) {
  4516. return;
  4517. }
  4518. forceReplace = true;
  4519. }
  4520. this._pushOrReplaceState(position, forceReplace);
  4521. }
  4522. }, {
  4523. key: '_isValidState',
  4524. value: function _isValidState(state) {
  4525. if (!state) {
  4526. return false;
  4527. }
  4528. if (state.fingerprint !== this.fingerprint) {
  4529. return false;
  4530. }
  4531. if (!Number.isInteger(state.uid) || state.uid < 0) {
  4532. return false;
  4533. }
  4534. if (state.destination === null || _typeof(state.destination) !== 'object') {
  4535. return false;
  4536. }
  4537. return true;
  4538. }
  4539. }, {
  4540. key: '_updateInternalState',
  4541. value: function _updateInternalState(destination, uid) {
  4542. var removeTemporary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  4543. if (this._updateViewareaTimeout) {
  4544. clearTimeout(this._updateViewareaTimeout);
  4545. this._updateViewareaTimeout = null;
  4546. }
  4547. if (removeTemporary && destination && destination.temporary) {
  4548. delete destination.temporary;
  4549. }
  4550. this._destination = destination;
  4551. this._uid = uid;
  4552. this._numPositionUpdates = 0;
  4553. }
  4554. }, {
  4555. key: '_updateViewarea',
  4556. value: function _updateViewarea(_ref3) {
  4557. var _this3 = this;
  4558. var location = _ref3.location;
  4559. if (this._updateViewareaTimeout) {
  4560. clearTimeout(this._updateViewareaTimeout);
  4561. this._updateViewareaTimeout = null;
  4562. }
  4563. this._position = {
  4564. hash: this._isViewerInPresentationMode ? 'page=' + location.pageNumber : location.pdfOpenParams.substring(1),
  4565. page: this.linkService.page,
  4566. first: location.pageNumber,
  4567. rotation: location.rotation
  4568. };
  4569. if (this._popStateInProgress) {
  4570. return;
  4571. }
  4572. if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
  4573. this._numPositionUpdates++;
  4574. }
  4575. if (UPDATE_VIEWAREA_TIMEOUT > 0) {
  4576. this._updateViewareaTimeout = setTimeout(function () {
  4577. if (!_this3._popStateInProgress) {
  4578. _this3._tryPushCurrentPosition(true);
  4579. }
  4580. _this3._updateViewareaTimeout = null;
  4581. }, UPDATE_VIEWAREA_TIMEOUT);
  4582. }
  4583. }
  4584. }, {
  4585. key: '_popState',
  4586. value: function _popState(_ref4) {
  4587. var _this4 = this;
  4588. var state = _ref4.state;
  4589. var newHash = getCurrentHash(),
  4590. hashChanged = this._currentHash !== newHash;
  4591. this._currentHash = newHash;
  4592. if (!state || false) {
  4593. this._uid++;
  4594. var _parseCurrentHash2 = parseCurrentHash(this.linkService),
  4595. hash = _parseCurrentHash2.hash,
  4596. page = _parseCurrentHash2.page,
  4597. rotation = _parseCurrentHash2.rotation;
  4598. this._pushOrReplaceState({
  4599. hash: hash,
  4600. page: page,
  4601. rotation: rotation
  4602. }, true);
  4603. return;
  4604. }
  4605. if (!this._isValidState(state)) {
  4606. return;
  4607. }
  4608. this._popStateInProgress = true;
  4609. if (hashChanged) {
  4610. this._blockHashChange++;
  4611. (0, _ui_utils.waitOnEventOrTimeout)({
  4612. target: window,
  4613. name: 'hashchange',
  4614. delay: HASH_CHANGE_TIMEOUT
  4615. }).then(function () {
  4616. _this4._blockHashChange--;
  4617. });
  4618. }
  4619. var destination = state.destination;
  4620. this._updateInternalState(destination, state.uid, true);
  4621. if (this._uid > this._maxUid) {
  4622. this._maxUid = this._uid;
  4623. }
  4624. if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
  4625. this.linkService.rotation = destination.rotation;
  4626. }
  4627. if (destination.dest) {
  4628. this.linkService.navigateTo(destination.dest);
  4629. } else if (destination.hash) {
  4630. this.linkService.setHash(destination.hash);
  4631. } else if (destination.page) {
  4632. this.linkService.page = destination.page;
  4633. }
  4634. Promise.resolve().then(function () {
  4635. _this4._popStateInProgress = false;
  4636. });
  4637. }
  4638. }, {
  4639. key: '_bindEvents',
  4640. value: function _bindEvents() {
  4641. var _this5 = this;
  4642. var _boundEvents = this._boundEvents,
  4643. eventBus = this.eventBus;
  4644. _boundEvents.updateViewarea = this._updateViewarea.bind(this);
  4645. _boundEvents.popState = this._popState.bind(this);
  4646. _boundEvents.pageHide = function (evt) {
  4647. if (!_this5._destination || _this5._destination.temporary) {
  4648. _this5._tryPushCurrentPosition();
  4649. }
  4650. };
  4651. eventBus.on('updateviewarea', _boundEvents.updateViewarea);
  4652. window.addEventListener('popstate', _boundEvents.popState);
  4653. window.addEventListener('pagehide', _boundEvents.pageHide);
  4654. }
  4655. }, {
  4656. key: 'popStateInProgress',
  4657. get: function get() {
  4658. return this.initialized && (this._popStateInProgress || this._blockHashChange > 0);
  4659. }
  4660. }]);
  4661. return PDFHistory;
  4662. }();
  4663. function isDestHashesEqual(destHash, pushHash) {
  4664. if (typeof destHash !== 'string' || typeof pushHash !== 'string') {
  4665. return false;
  4666. }
  4667. if (destHash === pushHash) {
  4668. return true;
  4669. }
  4670. var _parseQueryString = (0, _ui_utils.parseQueryString)(destHash),
  4671. nameddest = _parseQueryString.nameddest;
  4672. if (nameddest === pushHash) {
  4673. return true;
  4674. }
  4675. return false;
  4676. }
  4677. function isDestArraysEqual(firstDest, secondDest) {
  4678. function isEntryEqual(first, second) {
  4679. if ((typeof first === 'undefined' ? 'undefined' : _typeof(first)) !== (typeof second === 'undefined' ? 'undefined' : _typeof(second))) {
  4680. return false;
  4681. }
  4682. if (first instanceof Array || second instanceof Array) {
  4683. return false;
  4684. }
  4685. if (first !== null && (typeof first === 'undefined' ? 'undefined' : _typeof(first)) === 'object' && second !== null) {
  4686. if (Object.keys(first).length !== Object.keys(second).length) {
  4687. return false;
  4688. }
  4689. for (var key in first) {
  4690. if (!isEntryEqual(first[key], second[key])) {
  4691. return false;
  4692. }
  4693. }
  4694. return true;
  4695. }
  4696. return first === second || Number.isNaN(first) && Number.isNaN(second);
  4697. }
  4698. if (!(firstDest instanceof Array && secondDest instanceof Array)) {
  4699. return false;
  4700. }
  4701. if (firstDest.length !== secondDest.length) {
  4702. return false;
  4703. }
  4704. for (var i = 0, ii = firstDest.length; i < ii; i++) {
  4705. if (!isEntryEqual(firstDest[i], secondDest[i])) {
  4706. return false;
  4707. }
  4708. }
  4709. return true;
  4710. }
  4711. exports.PDFHistory = PDFHistory;
  4712. exports.isDestHashesEqual = isDestHashesEqual;
  4713. exports.isDestArraysEqual = isDestArraysEqual;
  4714. /***/ }),
  4715. /* 15 */
  4716. /***/ (function(module, exports, __w_pdfjs_require__) {
  4717. "use strict";
  4718. Object.defineProperty(exports, "__esModule", {
  4719. value: true
  4720. });
  4721. var compatibilityParams = Object.create(null);
  4722. {
  4723. var userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
  4724. var isAndroid = /Android/.test(userAgent);
  4725. var isIE = /Trident/.test(userAgent);
  4726. var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent);
  4727. (function checkFullscreenSupport() {
  4728. if (isIE && window.parent !== window) {
  4729. compatibilityParams.disableFullscreen = true;
  4730. }
  4731. })();
  4732. (function checkCanvasSizeLimitation() {
  4733. if (isIOS || isAndroid) {
  4734. compatibilityParams.maxCanvasPixels = 5242880;
  4735. }
  4736. })();
  4737. }
  4738. var viewerCompatibilityParams = Object.freeze(compatibilityParams);
  4739. exports.viewerCompatibilityParams = viewerCompatibilityParams;
  4740. /***/ }),
  4741. /* 16 */
  4742. /***/ (function(module, exports, __w_pdfjs_require__) {
  4743. "use strict";
  4744. Object.defineProperty(exports, "__esModule", {
  4745. value: true
  4746. });
  4747. exports.PDFSinglePageViewer = undefined;
  4748. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  4749. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  4750. var _base_viewer = __w_pdfjs_require__(8);
  4751. var _ui_utils = __w_pdfjs_require__(0);
  4752. var _pdfjsLib = __w_pdfjs_require__(1);
  4753. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4754. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4755. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4756. var PDFSinglePageViewer = function (_BaseViewer) {
  4757. _inherits(PDFSinglePageViewer, _BaseViewer);
  4758. function PDFSinglePageViewer(options) {
  4759. _classCallCheck(this, PDFSinglePageViewer);
  4760. var _this = _possibleConstructorReturn(this, (PDFSinglePageViewer.__proto__ || Object.getPrototypeOf(PDFSinglePageViewer)).call(this, options));
  4761. _this.eventBus.on('pagesinit', function (evt) {
  4762. _this._ensurePageViewVisible();
  4763. });
  4764. return _this;
  4765. }
  4766. _createClass(PDFSinglePageViewer, [{
  4767. key: '_resetView',
  4768. value: function _resetView() {
  4769. _get(PDFSinglePageViewer.prototype.__proto__ || Object.getPrototypeOf(PDFSinglePageViewer.prototype), '_resetView', this).call(this);
  4770. this._previousPageNumber = 1;
  4771. this._shadowViewer = document.createDocumentFragment();
  4772. }
  4773. }, {
  4774. key: '_ensurePageViewVisible',
  4775. value: function _ensurePageViewVisible() {
  4776. var pageView = this._pages[this._currentPageNumber - 1];
  4777. var previousPageView = this._pages[this._previousPageNumber - 1];
  4778. var viewerNodes = this.viewer.childNodes;
  4779. switch (viewerNodes.length) {
  4780. case 0:
  4781. this.viewer.appendChild(pageView.div);
  4782. break;
  4783. case 1:
  4784. if (viewerNodes[0] !== previousPageView.div) {
  4785. throw new Error('_ensurePageViewVisible: Unexpected previously visible page.');
  4786. }
  4787. if (pageView === previousPageView) {
  4788. break;
  4789. }
  4790. this._shadowViewer.appendChild(previousPageView.div);
  4791. this.viewer.appendChild(pageView.div);
  4792. this.container.scrollTop = 0;
  4793. break;
  4794. default:
  4795. throw new Error('_ensurePageViewVisible: Only one page should be visible at a time.');
  4796. }
  4797. this._previousPageNumber = this._currentPageNumber;
  4798. }
  4799. }, {
  4800. key: '_scrollUpdate',
  4801. value: function _scrollUpdate() {
  4802. if (this._updateScrollDown) {
  4803. this._updateScrollDown();
  4804. }
  4805. _get(PDFSinglePageViewer.prototype.__proto__ || Object.getPrototypeOf(PDFSinglePageViewer.prototype), '_scrollUpdate', this).call(this);
  4806. }
  4807. }, {
  4808. key: '_scrollIntoView',
  4809. value: function _scrollIntoView(_ref) {
  4810. var _this2 = this;
  4811. var pageDiv = _ref.pageDiv,
  4812. _ref$pageSpot = _ref.pageSpot,
  4813. pageSpot = _ref$pageSpot === undefined ? null : _ref$pageSpot,
  4814. _ref$pageNumber = _ref.pageNumber,
  4815. pageNumber = _ref$pageNumber === undefined ? null : _ref$pageNumber;
  4816. if (pageNumber) {
  4817. this._setCurrentPageNumber(pageNumber);
  4818. }
  4819. var scrolledDown = this._currentPageNumber >= this._previousPageNumber;
  4820. var previousLocation = this._location;
  4821. this._ensurePageViewVisible();
  4822. (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
  4823. this._updateScrollDown = function () {
  4824. _this2.scroll.down = scrolledDown;
  4825. delete _this2._updateScrollDown;
  4826. };
  4827. setTimeout(function () {
  4828. if (_this2._location === previousLocation) {
  4829. if (_this2._updateScrollDown) {
  4830. _this2._updateScrollDown();
  4831. }
  4832. _this2.update();
  4833. }
  4834. }, 0);
  4835. }
  4836. }, {
  4837. key: '_getVisiblePages',
  4838. value: function _getVisiblePages() {
  4839. if (!this.pagesCount) {
  4840. return { views: [] };
  4841. }
  4842. var pageView = this._pages[this._currentPageNumber - 1];
  4843. var element = pageView.div;
  4844. var view = {
  4845. id: pageView.id,
  4846. x: element.offsetLeft + element.clientLeft,
  4847. y: element.offsetTop + element.clientTop,
  4848. view: pageView
  4849. };
  4850. return {
  4851. first: view,
  4852. last: view,
  4853. views: [view]
  4854. };
  4855. }
  4856. }, {
  4857. key: 'update',
  4858. value: function update() {
  4859. var visible = this._getVisiblePages();
  4860. var visiblePages = visible.views,
  4861. numVisiblePages = visiblePages.length;
  4862. if (numVisiblePages === 0) {
  4863. return;
  4864. }
  4865. this._resizeBuffer(numVisiblePages);
  4866. this.renderingQueue.renderHighestPriority(visible);
  4867. this._updateLocation(visible.first);
  4868. this.eventBus.dispatch('updateviewarea', {
  4869. source: this,
  4870. location: this._location
  4871. });
  4872. }
  4873. }, {
  4874. key: '_setDocumentViewerElement',
  4875. get: function get() {
  4876. return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this._shadowViewer);
  4877. }
  4878. }]);
  4879. return PDFSinglePageViewer;
  4880. }(_base_viewer.BaseViewer);
  4881. exports.PDFSinglePageViewer = PDFSinglePageViewer;
  4882. /***/ }),
  4883. /* 17 */
  4884. /***/ (function(module, exports, __w_pdfjs_require__) {
  4885. "use strict";
  4886. Object.defineProperty(exports, "__esModule", {
  4887. value: true
  4888. });
  4889. exports.PDFViewer = undefined;
  4890. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  4891. var _ui_utils = __w_pdfjs_require__(0);
  4892. var _base_viewer = __w_pdfjs_require__(8);
  4893. var _pdfjsLib = __w_pdfjs_require__(1);
  4894. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4895. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4896. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4897. var PDFViewer = function (_BaseViewer) {
  4898. _inherits(PDFViewer, _BaseViewer);
  4899. function PDFViewer() {
  4900. _classCallCheck(this, PDFViewer);
  4901. return _possibleConstructorReturn(this, (PDFViewer.__proto__ || Object.getPrototypeOf(PDFViewer)).apply(this, arguments));
  4902. }
  4903. _createClass(PDFViewer, [{
  4904. key: '_scrollIntoView',
  4905. value: function _scrollIntoView(_ref) {
  4906. var pageDiv = _ref.pageDiv,
  4907. _ref$pageSpot = _ref.pageSpot,
  4908. pageSpot = _ref$pageSpot === undefined ? null : _ref$pageSpot;
  4909. (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
  4910. }
  4911. }, {
  4912. key: '_getVisiblePages',
  4913. value: function _getVisiblePages() {
  4914. if (!this.isInPresentationMode) {
  4915. return (0, _ui_utils.getVisibleElements)(this.container, this._pages, true);
  4916. }
  4917. var currentPage = this._pages[this._currentPageNumber - 1];
  4918. var visible = [{
  4919. id: currentPage.id,
  4920. view: currentPage
  4921. }];
  4922. return {
  4923. first: currentPage,
  4924. last: currentPage,
  4925. views: visible
  4926. };
  4927. }
  4928. }, {
  4929. key: 'update',
  4930. value: function update() {
  4931. var visible = this._getVisiblePages();
  4932. var visiblePages = visible.views,
  4933. numVisiblePages = visiblePages.length;
  4934. if (numVisiblePages === 0) {
  4935. return;
  4936. }
  4937. this._resizeBuffer(numVisiblePages);
  4938. this.renderingQueue.renderHighestPriority(visible);
  4939. var currentId = this._currentPageNumber;
  4940. var stillFullyVisible = false;
  4941. for (var i = 0; i < numVisiblePages; ++i) {
  4942. var page = visiblePages[i];
  4943. if (page.percent < 100) {
  4944. break;
  4945. }
  4946. if (page.id === currentId) {
  4947. stillFullyVisible = true;
  4948. break;
  4949. }
  4950. }
  4951. if (!stillFullyVisible) {
  4952. currentId = visiblePages[0].id;
  4953. }
  4954. if (!this.isInPresentationMode) {
  4955. this._setCurrentPageNumber(currentId);
  4956. }
  4957. this._updateLocation(visible.first);
  4958. this.eventBus.dispatch('updateviewarea', {
  4959. source: this,
  4960. location: this._location
  4961. });
  4962. }
  4963. }, {
  4964. key: '_setDocumentViewerElement',
  4965. get: function get() {
  4966. return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this.viewer);
  4967. }
  4968. }]);
  4969. return PDFViewer;
  4970. }(_base_viewer.BaseViewer);
  4971. exports.PDFViewer = PDFViewer;
  4972. /***/ })
  4973. /******/ ]);
  4974. });
  4975. //# sourceMappingURL=pdf_viewer.js.map