pdf.js 625 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234
  1. /* Copyright 2017 Mozilla Foundation
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. (function webpackUniversalModuleDefinition(root, factory) {
  16. if(typeof exports === 'object' && typeof module === 'object')
  17. module.exports = factory();
  18. else if(typeof define === 'function' && define.amd)
  19. define("pdfjs-dist/build/pdf", [], factory);
  20. else if(typeof exports === 'object')
  21. exports["pdfjs-dist/build/pdf"] = factory();
  22. else
  23. root["pdfjs-dist/build/pdf"] = root.pdfjsDistBuildPdf = factory();
  24. })(this, function() {
  25. return /******/ (function(modules) { // webpackBootstrap
  26. /******/ // The module cache
  27. /******/ var installedModules = {};
  28. /******/
  29. /******/ // The require function
  30. /******/ function __w_pdfjs_require__(moduleId) {
  31. /******/
  32. /******/ // Check if module is in cache
  33. /******/ if(installedModules[moduleId]) {
  34. /******/ return installedModules[moduleId].exports;
  35. /******/ }
  36. /******/ // Create a new module (and put it into the cache)
  37. /******/ var module = installedModules[moduleId] = {
  38. /******/ i: moduleId,
  39. /******/ l: false,
  40. /******/ exports: {}
  41. /******/ };
  42. /******/
  43. /******/ // Execute the module function
  44. /******/ modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);
  45. /******/
  46. /******/ // Flag the module as loaded
  47. /******/ module.l = true;
  48. /******/
  49. /******/ // Return the exports of the module
  50. /******/ return module.exports;
  51. /******/ }
  52. /******/
  53. /******/
  54. /******/ // expose the modules object (__webpack_modules__)
  55. /******/ __w_pdfjs_require__.m = modules;
  56. /******/
  57. /******/ // expose the module cache
  58. /******/ __w_pdfjs_require__.c = installedModules;
  59. /******/
  60. /******/ // define getter function for harmony exports
  61. /******/ __w_pdfjs_require__.d = function(exports, name, getter) {
  62. /******/ if(!__w_pdfjs_require__.o(exports, name)) {
  63. /******/ Object.defineProperty(exports, name, {
  64. /******/ configurable: false,
  65. /******/ enumerable: true,
  66. /******/ get: getter
  67. /******/ });
  68. /******/ }
  69. /******/ };
  70. /******/
  71. /******/ // getDefaultExport function for compatibility with non-harmony modules
  72. /******/ __w_pdfjs_require__.n = function(module) {
  73. /******/ var getter = module && module.__esModule ?
  74. /******/ function getDefault() { return module['default']; } :
  75. /******/ function getModuleExports() { return module; };
  76. /******/ __w_pdfjs_require__.d(getter, 'a', getter);
  77. /******/ return getter;
  78. /******/ };
  79. /******/
  80. /******/ // Object.prototype.hasOwnProperty.call
  81. /******/ __w_pdfjs_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  82. /******/
  83. /******/ // __webpack_public_path__
  84. /******/ __w_pdfjs_require__.p = "";
  85. /******/
  86. /******/ // Load entry module and return exports
  87. /******/ return __w_pdfjs_require__(__w_pdfjs_require__.s = 75);
  88. /******/ })
  89. /************************************************************************/
  90. /******/ ([
  91. /* 0 */
  92. /***/ (function(module, exports, __w_pdfjs_require__) {
  93. "use strict";
  94. Object.defineProperty(exports, "__esModule", {
  95. value: true
  96. });
  97. exports.unreachable = exports.warn = exports.utf8StringToString = exports.stringToUTF8String = exports.stringToPDFString = exports.stringToBytes = exports.string32 = exports.shadow = exports.setVerbosityLevel = exports.ReadableStream = exports.removeNullCharacters = exports.readUint32 = exports.readUint16 = exports.readInt8 = exports.log2 = exports.loadJpegStream = exports.isEvalSupported = exports.isLittleEndian = exports.createValidAbsoluteUrl = exports.isSameOrigin = exports.isNodeJS = exports.isSpace = exports.isString = exports.isNum = exports.isEmptyObj = exports.isBool = exports.isArrayBuffer = exports.info = exports.getVerbosityLevel = exports.getLookupTableFactory = exports.deprecated = exports.createObjectURL = exports.createPromiseCapability = exports.createBlob = exports.bytesToString = exports.assert = exports.arraysToBytes = exports.arrayByteLength = exports.FormatError = exports.XRefParseException = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.StatTimer = exports.PasswordResponses = exports.PasswordException = exports.PageViewport = exports.NotImplementedException = exports.NativeImageDecoding = exports.MissingPDFException = exports.MissingDataException = exports.MessageHandler = exports.InvalidPDFException = exports.AbortException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VERBOSITY_LEVELS = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = undefined;
  98. 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; };
  99. __w_pdfjs_require__(76);
  100. var _streams_polyfill = __w_pdfjs_require__(115);
  101. var FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
  102. var NativeImageDecoding = {
  103. NONE: 'none',
  104. DECODE: 'decode',
  105. DISPLAY: 'display'
  106. };
  107. var TextRenderingMode = {
  108. FILL: 0,
  109. STROKE: 1,
  110. FILL_STROKE: 2,
  111. INVISIBLE: 3,
  112. FILL_ADD_TO_PATH: 4,
  113. STROKE_ADD_TO_PATH: 5,
  114. FILL_STROKE_ADD_TO_PATH: 6,
  115. ADD_TO_PATH: 7,
  116. FILL_STROKE_MASK: 3,
  117. ADD_TO_PATH_FLAG: 4
  118. };
  119. var ImageKind = {
  120. GRAYSCALE_1BPP: 1,
  121. RGB_24BPP: 2,
  122. RGBA_32BPP: 3
  123. };
  124. var AnnotationType = {
  125. TEXT: 1,
  126. LINK: 2,
  127. FREETEXT: 3,
  128. LINE: 4,
  129. SQUARE: 5,
  130. CIRCLE: 6,
  131. POLYGON: 7,
  132. POLYLINE: 8,
  133. HIGHLIGHT: 9,
  134. UNDERLINE: 10,
  135. SQUIGGLY: 11,
  136. STRIKEOUT: 12,
  137. STAMP: 13,
  138. CARET: 14,
  139. INK: 15,
  140. POPUP: 16,
  141. FILEATTACHMENT: 17,
  142. SOUND: 18,
  143. MOVIE: 19,
  144. WIDGET: 20,
  145. SCREEN: 21,
  146. PRINTERMARK: 22,
  147. TRAPNET: 23,
  148. WATERMARK: 24,
  149. THREED: 25,
  150. REDACT: 26
  151. };
  152. var AnnotationFlag = {
  153. INVISIBLE: 0x01,
  154. HIDDEN: 0x02,
  155. PRINT: 0x04,
  156. NOZOOM: 0x08,
  157. NOROTATE: 0x10,
  158. NOVIEW: 0x20,
  159. READONLY: 0x40,
  160. LOCKED: 0x80,
  161. TOGGLENOVIEW: 0x100,
  162. LOCKEDCONTENTS: 0x200
  163. };
  164. var AnnotationFieldFlag = {
  165. READONLY: 0x0000001,
  166. REQUIRED: 0x0000002,
  167. NOEXPORT: 0x0000004,
  168. MULTILINE: 0x0001000,
  169. PASSWORD: 0x0002000,
  170. NOTOGGLETOOFF: 0x0004000,
  171. RADIO: 0x0008000,
  172. PUSHBUTTON: 0x0010000,
  173. COMBO: 0x0020000,
  174. EDIT: 0x0040000,
  175. SORT: 0x0080000,
  176. FILESELECT: 0x0100000,
  177. MULTISELECT: 0x0200000,
  178. DONOTSPELLCHECK: 0x0400000,
  179. DONOTSCROLL: 0x0800000,
  180. COMB: 0x1000000,
  181. RICHTEXT: 0x2000000,
  182. RADIOSINUNISON: 0x2000000,
  183. COMMITONSELCHANGE: 0x4000000
  184. };
  185. var AnnotationBorderStyleType = {
  186. SOLID: 1,
  187. DASHED: 2,
  188. BEVELED: 3,
  189. INSET: 4,
  190. UNDERLINE: 5
  191. };
  192. var StreamType = {
  193. UNKNOWN: 0,
  194. FLATE: 1,
  195. LZW: 2,
  196. DCT: 3,
  197. JPX: 4,
  198. JBIG: 5,
  199. A85: 6,
  200. AHX: 7,
  201. CCF: 8,
  202. RL: 9
  203. };
  204. var FontType = {
  205. UNKNOWN: 0,
  206. TYPE1: 1,
  207. TYPE1C: 2,
  208. CIDFONTTYPE0: 3,
  209. CIDFONTTYPE0C: 4,
  210. TRUETYPE: 5,
  211. CIDFONTTYPE2: 6,
  212. TYPE3: 7,
  213. OPENTYPE: 8,
  214. TYPE0: 9,
  215. MMTYPE1: 10
  216. };
  217. var VERBOSITY_LEVELS = {
  218. errors: 0,
  219. warnings: 1,
  220. infos: 5
  221. };
  222. var CMapCompressionType = {
  223. NONE: 0,
  224. BINARY: 1,
  225. STREAM: 2
  226. };
  227. var OPS = {
  228. dependency: 1,
  229. setLineWidth: 2,
  230. setLineCap: 3,
  231. setLineJoin: 4,
  232. setMiterLimit: 5,
  233. setDash: 6,
  234. setRenderingIntent: 7,
  235. setFlatness: 8,
  236. setGState: 9,
  237. save: 10,
  238. restore: 11,
  239. transform: 12,
  240. moveTo: 13,
  241. lineTo: 14,
  242. curveTo: 15,
  243. curveTo2: 16,
  244. curveTo3: 17,
  245. closePath: 18,
  246. rectangle: 19,
  247. stroke: 20,
  248. closeStroke: 21,
  249. fill: 22,
  250. eoFill: 23,
  251. fillStroke: 24,
  252. eoFillStroke: 25,
  253. closeFillStroke: 26,
  254. closeEOFillStroke: 27,
  255. endPath: 28,
  256. clip: 29,
  257. eoClip: 30,
  258. beginText: 31,
  259. endText: 32,
  260. setCharSpacing: 33,
  261. setWordSpacing: 34,
  262. setHScale: 35,
  263. setLeading: 36,
  264. setFont: 37,
  265. setTextRenderingMode: 38,
  266. setTextRise: 39,
  267. moveText: 40,
  268. setLeadingMoveText: 41,
  269. setTextMatrix: 42,
  270. nextLine: 43,
  271. showText: 44,
  272. showSpacedText: 45,
  273. nextLineShowText: 46,
  274. nextLineSetSpacingShowText: 47,
  275. setCharWidth: 48,
  276. setCharWidthAndBounds: 49,
  277. setStrokeColorSpace: 50,
  278. setFillColorSpace: 51,
  279. setStrokeColor: 52,
  280. setStrokeColorN: 53,
  281. setFillColor: 54,
  282. setFillColorN: 55,
  283. setStrokeGray: 56,
  284. setFillGray: 57,
  285. setStrokeRGBColor: 58,
  286. setFillRGBColor: 59,
  287. setStrokeCMYKColor: 60,
  288. setFillCMYKColor: 61,
  289. shadingFill: 62,
  290. beginInlineImage: 63,
  291. beginImageData: 64,
  292. endInlineImage: 65,
  293. paintXObject: 66,
  294. markPoint: 67,
  295. markPointProps: 68,
  296. beginMarkedContent: 69,
  297. beginMarkedContentProps: 70,
  298. endMarkedContent: 71,
  299. beginCompat: 72,
  300. endCompat: 73,
  301. paintFormXObjectBegin: 74,
  302. paintFormXObjectEnd: 75,
  303. beginGroup: 76,
  304. endGroup: 77,
  305. beginAnnotations: 78,
  306. endAnnotations: 79,
  307. beginAnnotation: 80,
  308. endAnnotation: 81,
  309. paintJpegXObject: 82,
  310. paintImageMaskXObject: 83,
  311. paintImageMaskXObjectGroup: 84,
  312. paintImageXObject: 85,
  313. paintInlineImageXObject: 86,
  314. paintInlineImageXObjectGroup: 87,
  315. paintImageXObjectRepeat: 88,
  316. paintImageMaskXObjectRepeat: 89,
  317. paintSolidColorImageMask: 90,
  318. constructPath: 91
  319. };
  320. var verbosity = VERBOSITY_LEVELS.warnings;
  321. function setVerbosityLevel(level) {
  322. verbosity = level;
  323. }
  324. function getVerbosityLevel() {
  325. return verbosity;
  326. }
  327. function info(msg) {
  328. if (verbosity >= VERBOSITY_LEVELS.infos) {
  329. console.log('Info: ' + msg);
  330. }
  331. }
  332. function warn(msg) {
  333. if (verbosity >= VERBOSITY_LEVELS.warnings) {
  334. console.log('Warning: ' + msg);
  335. }
  336. }
  337. function deprecated(details) {
  338. console.log('Deprecated API usage: ' + details);
  339. }
  340. function unreachable(msg) {
  341. throw new Error(msg);
  342. }
  343. function assert(cond, msg) {
  344. if (!cond) {
  345. unreachable(msg);
  346. }
  347. }
  348. var UNSUPPORTED_FEATURES = {
  349. unknown: 'unknown',
  350. forms: 'forms',
  351. javaScript: 'javaScript',
  352. smask: 'smask',
  353. shadingPattern: 'shadingPattern',
  354. font: 'font'
  355. };
  356. function isSameOrigin(baseUrl, otherUrl) {
  357. try {
  358. var base = new URL(baseUrl);
  359. if (!base.origin || base.origin === 'null') {
  360. return false;
  361. }
  362. } catch (e) {
  363. return false;
  364. }
  365. var other = new URL(otherUrl, base);
  366. return base.origin === other.origin;
  367. }
  368. function isValidProtocol(url) {
  369. if (!url) {
  370. return false;
  371. }
  372. switch (url.protocol) {
  373. case 'http:':
  374. case 'https:':
  375. case 'ftp:':
  376. case 'mailto:':
  377. case 'tel:':
  378. return true;
  379. default:
  380. return false;
  381. }
  382. }
  383. function createValidAbsoluteUrl(url, baseUrl) {
  384. if (!url) {
  385. return null;
  386. }
  387. try {
  388. var absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
  389. if (isValidProtocol(absoluteUrl)) {
  390. return absoluteUrl;
  391. }
  392. } catch (ex) {}
  393. return null;
  394. }
  395. function shadow(obj, prop, value) {
  396. Object.defineProperty(obj, prop, {
  397. value: value,
  398. enumerable: true,
  399. configurable: true,
  400. writable: false
  401. });
  402. return value;
  403. }
  404. function getLookupTableFactory(initializer) {
  405. var lookup;
  406. return function () {
  407. if (initializer) {
  408. lookup = Object.create(null);
  409. initializer(lookup);
  410. initializer = null;
  411. }
  412. return lookup;
  413. };
  414. }
  415. var PasswordResponses = {
  416. NEED_PASSWORD: 1,
  417. INCORRECT_PASSWORD: 2
  418. };
  419. var PasswordException = function PasswordExceptionClosure() {
  420. function PasswordException(msg, code) {
  421. this.name = 'PasswordException';
  422. this.message = msg;
  423. this.code = code;
  424. }
  425. PasswordException.prototype = new Error();
  426. PasswordException.constructor = PasswordException;
  427. return PasswordException;
  428. }();
  429. var UnknownErrorException = function UnknownErrorExceptionClosure() {
  430. function UnknownErrorException(msg, details) {
  431. this.name = 'UnknownErrorException';
  432. this.message = msg;
  433. this.details = details;
  434. }
  435. UnknownErrorException.prototype = new Error();
  436. UnknownErrorException.constructor = UnknownErrorException;
  437. return UnknownErrorException;
  438. }();
  439. var InvalidPDFException = function InvalidPDFExceptionClosure() {
  440. function InvalidPDFException(msg) {
  441. this.name = 'InvalidPDFException';
  442. this.message = msg;
  443. }
  444. InvalidPDFException.prototype = new Error();
  445. InvalidPDFException.constructor = InvalidPDFException;
  446. return InvalidPDFException;
  447. }();
  448. var MissingPDFException = function MissingPDFExceptionClosure() {
  449. function MissingPDFException(msg) {
  450. this.name = 'MissingPDFException';
  451. this.message = msg;
  452. }
  453. MissingPDFException.prototype = new Error();
  454. MissingPDFException.constructor = MissingPDFException;
  455. return MissingPDFException;
  456. }();
  457. var UnexpectedResponseException = function UnexpectedResponseExceptionClosure() {
  458. function UnexpectedResponseException(msg, status) {
  459. this.name = 'UnexpectedResponseException';
  460. this.message = msg;
  461. this.status = status;
  462. }
  463. UnexpectedResponseException.prototype = new Error();
  464. UnexpectedResponseException.constructor = UnexpectedResponseException;
  465. return UnexpectedResponseException;
  466. }();
  467. var NotImplementedException = function NotImplementedExceptionClosure() {
  468. function NotImplementedException(msg) {
  469. this.message = msg;
  470. }
  471. NotImplementedException.prototype = new Error();
  472. NotImplementedException.prototype.name = 'NotImplementedException';
  473. NotImplementedException.constructor = NotImplementedException;
  474. return NotImplementedException;
  475. }();
  476. var MissingDataException = function MissingDataExceptionClosure() {
  477. function MissingDataException(begin, end) {
  478. this.begin = begin;
  479. this.end = end;
  480. this.message = 'Missing data [' + begin + ', ' + end + ')';
  481. }
  482. MissingDataException.prototype = new Error();
  483. MissingDataException.prototype.name = 'MissingDataException';
  484. MissingDataException.constructor = MissingDataException;
  485. return MissingDataException;
  486. }();
  487. var XRefParseException = function XRefParseExceptionClosure() {
  488. function XRefParseException(msg) {
  489. this.message = msg;
  490. }
  491. XRefParseException.prototype = new Error();
  492. XRefParseException.prototype.name = 'XRefParseException';
  493. XRefParseException.constructor = XRefParseException;
  494. return XRefParseException;
  495. }();
  496. var FormatError = function FormatErrorClosure() {
  497. function FormatError(msg) {
  498. this.message = msg;
  499. }
  500. FormatError.prototype = new Error();
  501. FormatError.prototype.name = 'FormatError';
  502. FormatError.constructor = FormatError;
  503. return FormatError;
  504. }();
  505. var AbortException = function AbortExceptionClosure() {
  506. function AbortException(msg) {
  507. this.name = 'AbortException';
  508. this.message = msg;
  509. }
  510. AbortException.prototype = new Error();
  511. AbortException.constructor = AbortException;
  512. return AbortException;
  513. }();
  514. var NullCharactersRegExp = /\x00/g;
  515. function removeNullCharacters(str) {
  516. if (typeof str !== 'string') {
  517. warn('The argument for removeNullCharacters must be a string.');
  518. return str;
  519. }
  520. return str.replace(NullCharactersRegExp, '');
  521. }
  522. function bytesToString(bytes) {
  523. assert(bytes !== null && (typeof bytes === 'undefined' ? 'undefined' : _typeof(bytes)) === 'object' && bytes.length !== undefined, 'Invalid argument for bytesToString');
  524. var length = bytes.length;
  525. var MAX_ARGUMENT_COUNT = 8192;
  526. if (length < MAX_ARGUMENT_COUNT) {
  527. return String.fromCharCode.apply(null, bytes);
  528. }
  529. var strBuf = [];
  530. for (var i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
  531. var chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
  532. var chunk = bytes.subarray(i, chunkEnd);
  533. strBuf.push(String.fromCharCode.apply(null, chunk));
  534. }
  535. return strBuf.join('');
  536. }
  537. function stringToBytes(str) {
  538. assert(typeof str === 'string', 'Invalid argument for stringToBytes');
  539. var length = str.length;
  540. var bytes = new Uint8Array(length);
  541. for (var i = 0; i < length; ++i) {
  542. bytes[i] = str.charCodeAt(i) & 0xFF;
  543. }
  544. return bytes;
  545. }
  546. function arrayByteLength(arr) {
  547. if (arr.length !== undefined) {
  548. return arr.length;
  549. }
  550. assert(arr.byteLength !== undefined);
  551. return arr.byteLength;
  552. }
  553. function arraysToBytes(arr) {
  554. if (arr.length === 1 && arr[0] instanceof Uint8Array) {
  555. return arr[0];
  556. }
  557. var resultLength = 0;
  558. var i,
  559. ii = arr.length;
  560. var item, itemLength;
  561. for (i = 0; i < ii; i++) {
  562. item = arr[i];
  563. itemLength = arrayByteLength(item);
  564. resultLength += itemLength;
  565. }
  566. var pos = 0;
  567. var data = new Uint8Array(resultLength);
  568. for (i = 0; i < ii; i++) {
  569. item = arr[i];
  570. if (!(item instanceof Uint8Array)) {
  571. if (typeof item === 'string') {
  572. item = stringToBytes(item);
  573. } else {
  574. item = new Uint8Array(item);
  575. }
  576. }
  577. itemLength = item.byteLength;
  578. data.set(item, pos);
  579. pos += itemLength;
  580. }
  581. return data;
  582. }
  583. function string32(value) {
  584. return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
  585. }
  586. function log2(x) {
  587. var n = 1,
  588. i = 0;
  589. while (x > n) {
  590. n <<= 1;
  591. i++;
  592. }
  593. return i;
  594. }
  595. function readInt8(data, start) {
  596. return data[start] << 24 >> 24;
  597. }
  598. function readUint16(data, offset) {
  599. return data[offset] << 8 | data[offset + 1];
  600. }
  601. function readUint32(data, offset) {
  602. return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
  603. }
  604. function isLittleEndian() {
  605. var buffer8 = new Uint8Array(4);
  606. buffer8[0] = 1;
  607. var view32 = new Uint32Array(buffer8.buffer, 0, 1);
  608. return view32[0] === 1;
  609. }
  610. function isEvalSupported() {
  611. try {
  612. new Function('');
  613. return true;
  614. } catch (e) {
  615. return false;
  616. }
  617. }
  618. var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
  619. var Util = function UtilClosure() {
  620. function Util() {}
  621. var rgbBuf = ['rgb(', 0, ',', 0, ',', 0, ')'];
  622. Util.makeCssRgb = function Util_makeCssRgb(r, g, b) {
  623. rgbBuf[1] = r;
  624. rgbBuf[3] = g;
  625. rgbBuf[5] = b;
  626. return rgbBuf.join('');
  627. };
  628. Util.transform = function Util_transform(m1, m2) {
  629. return [m1[0] * m2[0] + m1[2] * m2[1], m1[1] * m2[0] + m1[3] * m2[1], m1[0] * m2[2] + m1[2] * m2[3], m1[1] * m2[2] + m1[3] * m2[3], m1[0] * m2[4] + m1[2] * m2[5] + m1[4], m1[1] * m2[4] + m1[3] * m2[5] + m1[5]];
  630. };
  631. Util.applyTransform = function Util_applyTransform(p, m) {
  632. var xt = p[0] * m[0] + p[1] * m[2] + m[4];
  633. var yt = p[0] * m[1] + p[1] * m[3] + m[5];
  634. return [xt, yt];
  635. };
  636. Util.applyInverseTransform = function Util_applyInverseTransform(p, m) {
  637. var d = m[0] * m[3] - m[1] * m[2];
  638. var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
  639. var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
  640. return [xt, yt];
  641. };
  642. Util.getAxialAlignedBoundingBox = function Util_getAxialAlignedBoundingBox(r, m) {
  643. var p1 = Util.applyTransform(r, m);
  644. var p2 = Util.applyTransform(r.slice(2, 4), m);
  645. var p3 = Util.applyTransform([r[0], r[3]], m);
  646. var p4 = Util.applyTransform([r[2], r[1]], m);
  647. return [Math.min(p1[0], p2[0], p3[0], p4[0]), Math.min(p1[1], p2[1], p3[1], p4[1]), Math.max(p1[0], p2[0], p3[0], p4[0]), Math.max(p1[1], p2[1], p3[1], p4[1])];
  648. };
  649. Util.inverseTransform = function Util_inverseTransform(m) {
  650. var d = m[0] * m[3] - m[1] * m[2];
  651. return [m[3] / d, -m[1] / d, -m[2] / d, m[0] / d, (m[2] * m[5] - m[4] * m[3]) / d, (m[4] * m[1] - m[5] * m[0]) / d];
  652. };
  653. Util.apply3dTransform = function Util_apply3dTransform(m, v) {
  654. return [m[0] * v[0] + m[1] * v[1] + m[2] * v[2], m[3] * v[0] + m[4] * v[1] + m[5] * v[2], m[6] * v[0] + m[7] * v[1] + m[8] * v[2]];
  655. };
  656. Util.singularValueDecompose2dScale = function Util_singularValueDecompose2dScale(m) {
  657. var transpose = [m[0], m[2], m[1], m[3]];
  658. var a = m[0] * transpose[0] + m[1] * transpose[2];
  659. var b = m[0] * transpose[1] + m[1] * transpose[3];
  660. var c = m[2] * transpose[0] + m[3] * transpose[2];
  661. var d = m[2] * transpose[1] + m[3] * transpose[3];
  662. var first = (a + d) / 2;
  663. var second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;
  664. var sx = first + second || 1;
  665. var sy = first - second || 1;
  666. return [Math.sqrt(sx), Math.sqrt(sy)];
  667. };
  668. Util.normalizeRect = function Util_normalizeRect(rect) {
  669. var r = rect.slice(0);
  670. if (rect[0] > rect[2]) {
  671. r[0] = rect[2];
  672. r[2] = rect[0];
  673. }
  674. if (rect[1] > rect[3]) {
  675. r[1] = rect[3];
  676. r[3] = rect[1];
  677. }
  678. return r;
  679. };
  680. Util.intersect = function Util_intersect(rect1, rect2) {
  681. function compare(a, b) {
  682. return a - b;
  683. }
  684. var orderedX = [rect1[0], rect1[2], rect2[0], rect2[2]].sort(compare),
  685. orderedY = [rect1[1], rect1[3], rect2[1], rect2[3]].sort(compare),
  686. result = [];
  687. rect1 = Util.normalizeRect(rect1);
  688. rect2 = Util.normalizeRect(rect2);
  689. if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) {
  690. result[0] = orderedX[1];
  691. result[2] = orderedX[2];
  692. } else {
  693. return false;
  694. }
  695. if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) {
  696. result[1] = orderedY[1];
  697. result[3] = orderedY[2];
  698. } else {
  699. return false;
  700. }
  701. return result;
  702. };
  703. var ROMAN_NUMBER_MAP = ['', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM', '', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC', '', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX'];
  704. Util.toRoman = function Util_toRoman(number, lowerCase) {
  705. assert(Number.isInteger(number) && number > 0, 'The number should be a positive integer.');
  706. var pos,
  707. romanBuf = [];
  708. while (number >= 1000) {
  709. number -= 1000;
  710. romanBuf.push('M');
  711. }
  712. pos = number / 100 | 0;
  713. number %= 100;
  714. romanBuf.push(ROMAN_NUMBER_MAP[pos]);
  715. pos = number / 10 | 0;
  716. number %= 10;
  717. romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]);
  718. romanBuf.push(ROMAN_NUMBER_MAP[20 + number]);
  719. var romanStr = romanBuf.join('');
  720. return lowerCase ? romanStr.toLowerCase() : romanStr;
  721. };
  722. Util.appendToArray = function Util_appendToArray(arr1, arr2) {
  723. Array.prototype.push.apply(arr1, arr2);
  724. };
  725. Util.prependToArray = function Util_prependToArray(arr1, arr2) {
  726. Array.prototype.unshift.apply(arr1, arr2);
  727. };
  728. Util.extendObj = function extendObj(obj1, obj2) {
  729. for (var key in obj2) {
  730. obj1[key] = obj2[key];
  731. }
  732. };
  733. Util.getInheritableProperty = function Util_getInheritableProperty(dict, name, getArray) {
  734. while (dict && !dict.has(name)) {
  735. dict = dict.get('Parent');
  736. }
  737. if (!dict) {
  738. return null;
  739. }
  740. return getArray ? dict.getArray(name) : dict.get(name);
  741. };
  742. Util.inherit = function Util_inherit(sub, base, prototype) {
  743. sub.prototype = Object.create(base.prototype);
  744. sub.prototype.constructor = sub;
  745. for (var prop in prototype) {
  746. sub.prototype[prop] = prototype[prop];
  747. }
  748. };
  749. Util.loadScript = function Util_loadScript(src, callback) {
  750. var script = document.createElement('script');
  751. var loaded = false;
  752. script.setAttribute('src', src);
  753. if (callback) {
  754. script.onload = function () {
  755. if (!loaded) {
  756. callback();
  757. }
  758. loaded = true;
  759. };
  760. }
  761. document.getElementsByTagName('head')[0].appendChild(script);
  762. };
  763. return Util;
  764. }();
  765. var PageViewport = function PageViewportClosure() {
  766. function PageViewport(viewBox, scale, rotation, offsetX, offsetY, dontFlip) {
  767. this.viewBox = viewBox;
  768. this.scale = scale;
  769. this.rotation = rotation;
  770. this.offsetX = offsetX;
  771. this.offsetY = offsetY;
  772. var centerX = (viewBox[2] + viewBox[0]) / 2;
  773. var centerY = (viewBox[3] + viewBox[1]) / 2;
  774. var rotateA, rotateB, rotateC, rotateD;
  775. rotation = rotation % 360;
  776. rotation = rotation < 0 ? rotation + 360 : rotation;
  777. switch (rotation) {
  778. case 180:
  779. rotateA = -1;
  780. rotateB = 0;
  781. rotateC = 0;
  782. rotateD = 1;
  783. break;
  784. case 90:
  785. rotateA = 0;
  786. rotateB = 1;
  787. rotateC = 1;
  788. rotateD = 0;
  789. break;
  790. case 270:
  791. rotateA = 0;
  792. rotateB = -1;
  793. rotateC = -1;
  794. rotateD = 0;
  795. break;
  796. default:
  797. rotateA = 1;
  798. rotateB = 0;
  799. rotateC = 0;
  800. rotateD = -1;
  801. break;
  802. }
  803. if (dontFlip) {
  804. rotateC = -rotateC;
  805. rotateD = -rotateD;
  806. }
  807. var offsetCanvasX, offsetCanvasY;
  808. var width, height;
  809. if (rotateA === 0) {
  810. offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
  811. offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
  812. width = Math.abs(viewBox[3] - viewBox[1]) * scale;
  813. height = Math.abs(viewBox[2] - viewBox[0]) * scale;
  814. } else {
  815. offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
  816. offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
  817. width = Math.abs(viewBox[2] - viewBox[0]) * scale;
  818. height = Math.abs(viewBox[3] - viewBox[1]) * scale;
  819. }
  820. this.transform = [rotateA * scale, rotateB * scale, rotateC * scale, rotateD * scale, offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY, offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY];
  821. this.width = width;
  822. this.height = height;
  823. this.fontScale = scale;
  824. }
  825. PageViewport.prototype = {
  826. clone: function PageViewPort_clone(args) {
  827. args = args || {};
  828. var scale = 'scale' in args ? args.scale : this.scale;
  829. var rotation = 'rotation' in args ? args.rotation : this.rotation;
  830. return new PageViewport(this.viewBox.slice(), scale, rotation, this.offsetX, this.offsetY, args.dontFlip);
  831. },
  832. convertToViewportPoint: function PageViewport_convertToViewportPoint(x, y) {
  833. return Util.applyTransform([x, y], this.transform);
  834. },
  835. convertToViewportRectangle: function PageViewport_convertToViewportRectangle(rect) {
  836. var tl = Util.applyTransform([rect[0], rect[1]], this.transform);
  837. var br = Util.applyTransform([rect[2], rect[3]], this.transform);
  838. return [tl[0], tl[1], br[0], br[1]];
  839. },
  840. convertToPdfPoint: function PageViewport_convertToPdfPoint(x, y) {
  841. return Util.applyInverseTransform([x, y], this.transform);
  842. }
  843. };
  844. return PageViewport;
  845. }();
  846. var PDFStringTranslateTable = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2D8, 0x2C7, 0x2C6, 0x2D9, 0x2DD, 0x2DB, 0x2DA, 0x2DC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2022, 0x2020, 0x2021, 0x2026, 0x2014, 0x2013, 0x192, 0x2044, 0x2039, 0x203A, 0x2212, 0x2030, 0x201E, 0x201C, 0x201D, 0x2018, 0x2019, 0x201A, 0x2122, 0xFB01, 0xFB02, 0x141, 0x152, 0x160, 0x178, 0x17D, 0x131, 0x142, 0x153, 0x161, 0x17E, 0, 0x20AC];
  847. function stringToPDFString(str) {
  848. var i,
  849. n = str.length,
  850. strBuf = [];
  851. if (str[0] === '\xFE' && str[1] === '\xFF') {
  852. for (i = 2; i < n; i += 2) {
  853. strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1)));
  854. }
  855. } else {
  856. for (i = 0; i < n; ++i) {
  857. var code = PDFStringTranslateTable[str.charCodeAt(i)];
  858. strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
  859. }
  860. }
  861. return strBuf.join('');
  862. }
  863. function stringToUTF8String(str) {
  864. return decodeURIComponent(escape(str));
  865. }
  866. function utf8StringToString(str) {
  867. return unescape(encodeURIComponent(str));
  868. }
  869. function isEmptyObj(obj) {
  870. for (var key in obj) {
  871. return false;
  872. }
  873. return true;
  874. }
  875. function isBool(v) {
  876. return typeof v === 'boolean';
  877. }
  878. function isNum(v) {
  879. return typeof v === 'number';
  880. }
  881. function isString(v) {
  882. return typeof v === 'string';
  883. }
  884. function isArrayBuffer(v) {
  885. return (typeof v === 'undefined' ? 'undefined' : _typeof(v)) === 'object' && v !== null && v.byteLength !== undefined;
  886. }
  887. function isSpace(ch) {
  888. return ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A;
  889. }
  890. function isNodeJS() {
  891. return (typeof process === 'undefined' ? 'undefined' : _typeof(process)) === 'object' && process + '' === '[object process]';
  892. }
  893. function createPromiseCapability() {
  894. var capability = {};
  895. capability.promise = new Promise(function (resolve, reject) {
  896. capability.resolve = resolve;
  897. capability.reject = reject;
  898. });
  899. return capability;
  900. }
  901. var StatTimer = function StatTimerClosure() {
  902. function rpad(str, pad, length) {
  903. while (str.length < length) {
  904. str += pad;
  905. }
  906. return str;
  907. }
  908. function StatTimer() {
  909. this.started = Object.create(null);
  910. this.times = [];
  911. this.enabled = true;
  912. }
  913. StatTimer.prototype = {
  914. time: function StatTimer_time(name) {
  915. if (!this.enabled) {
  916. return;
  917. }
  918. if (name in this.started) {
  919. warn('Timer is already running for ' + name);
  920. }
  921. this.started[name] = Date.now();
  922. },
  923. timeEnd: function StatTimer_timeEnd(name) {
  924. if (!this.enabled) {
  925. return;
  926. }
  927. if (!(name in this.started)) {
  928. warn('Timer has not been started for ' + name);
  929. }
  930. this.times.push({
  931. 'name': name,
  932. 'start': this.started[name],
  933. 'end': Date.now()
  934. });
  935. delete this.started[name];
  936. },
  937. toString: function StatTimer_toString() {
  938. var i, ii;
  939. var times = this.times;
  940. var out = '';
  941. var longest = 0;
  942. for (i = 0, ii = times.length; i < ii; ++i) {
  943. var name = times[i]['name'];
  944. if (name.length > longest) {
  945. longest = name.length;
  946. }
  947. }
  948. for (i = 0, ii = times.length; i < ii; ++i) {
  949. var span = times[i];
  950. var duration = span.end - span.start;
  951. out += rpad(span['name'], ' ', longest) + ' ' + duration + 'ms\n';
  952. }
  953. return out;
  954. }
  955. };
  956. return StatTimer;
  957. }();
  958. var createBlob = function createBlob(data, contentType) {
  959. if (typeof Blob !== 'undefined') {
  960. return new Blob([data], { type: contentType });
  961. }
  962. throw new Error('The "Blob" constructor is not supported.');
  963. };
  964. var createObjectURL = function createObjectURLClosure() {
  965. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  966. return function createObjectURL(data, contentType) {
  967. var forceDataSchema = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  968. if (!forceDataSchema && URL.createObjectURL) {
  969. var blob = createBlob(data, contentType);
  970. return URL.createObjectURL(blob);
  971. }
  972. var buffer = 'data:' + contentType + ';base64,';
  973. for (var i = 0, ii = data.length; i < ii; i += 3) {
  974. var b1 = data[i] & 0xFF;
  975. var b2 = data[i + 1] & 0xFF;
  976. var b3 = data[i + 2] & 0xFF;
  977. var d1 = b1 >> 2,
  978. d2 = (b1 & 3) << 4 | b2 >> 4;
  979. var d3 = i + 1 < ii ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
  980. var d4 = i + 2 < ii ? b3 & 0x3F : 64;
  981. buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
  982. }
  983. return buffer;
  984. };
  985. }();
  986. function resolveCall(fn, args) {
  987. var thisArg = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  988. if (!fn) {
  989. return Promise.resolve(undefined);
  990. }
  991. return new Promise(function (resolve, reject) {
  992. resolve(fn.apply(thisArg, args));
  993. });
  994. }
  995. function wrapReason(reason) {
  996. if ((typeof reason === 'undefined' ? 'undefined' : _typeof(reason)) !== 'object') {
  997. return reason;
  998. }
  999. switch (reason.name) {
  1000. case 'AbortException':
  1001. return new AbortException(reason.message);
  1002. case 'MissingPDFException':
  1003. return new MissingPDFException(reason.message);
  1004. case 'UnexpectedResponseException':
  1005. return new UnexpectedResponseException(reason.message, reason.status);
  1006. default:
  1007. return new UnknownErrorException(reason.message, reason.details);
  1008. }
  1009. }
  1010. function makeReasonSerializable(reason) {
  1011. if (!(reason instanceof Error) || reason instanceof AbortException || reason instanceof MissingPDFException || reason instanceof UnexpectedResponseException || reason instanceof UnknownErrorException) {
  1012. return reason;
  1013. }
  1014. return new UnknownErrorException(reason.message, reason.toString());
  1015. }
  1016. function resolveOrReject(capability, success, reason) {
  1017. if (success) {
  1018. capability.resolve();
  1019. } else {
  1020. capability.reject(reason);
  1021. }
  1022. }
  1023. function finalize(promise) {
  1024. return Promise.resolve(promise).catch(function () {});
  1025. }
  1026. function MessageHandler(sourceName, targetName, comObj) {
  1027. var _this = this;
  1028. this.sourceName = sourceName;
  1029. this.targetName = targetName;
  1030. this.comObj = comObj;
  1031. this.callbackId = 1;
  1032. this.streamId = 1;
  1033. this.postMessageTransfers = true;
  1034. this.streamSinks = Object.create(null);
  1035. this.streamControllers = Object.create(null);
  1036. var callbacksCapabilities = this.callbacksCapabilities = Object.create(null);
  1037. var ah = this.actionHandler = Object.create(null);
  1038. this._onComObjOnMessage = function (event) {
  1039. var data = event.data;
  1040. if (data.targetName !== _this.sourceName) {
  1041. return;
  1042. }
  1043. if (data.stream) {
  1044. _this._processStreamMessage(data);
  1045. } else if (data.isReply) {
  1046. var callbackId = data.callbackId;
  1047. if (data.callbackId in callbacksCapabilities) {
  1048. var callback = callbacksCapabilities[callbackId];
  1049. delete callbacksCapabilities[callbackId];
  1050. if ('error' in data) {
  1051. callback.reject(wrapReason(data.error));
  1052. } else {
  1053. callback.resolve(data.data);
  1054. }
  1055. } else {
  1056. throw new Error('Cannot resolve callback ' + callbackId);
  1057. }
  1058. } else if (data.action in ah) {
  1059. var action = ah[data.action];
  1060. if (data.callbackId) {
  1061. var _sourceName = _this.sourceName;
  1062. var _targetName = data.sourceName;
  1063. Promise.resolve().then(function () {
  1064. return action[0].call(action[1], data.data);
  1065. }).then(function (result) {
  1066. comObj.postMessage({
  1067. sourceName: _sourceName,
  1068. targetName: _targetName,
  1069. isReply: true,
  1070. callbackId: data.callbackId,
  1071. data: result
  1072. });
  1073. }, function (reason) {
  1074. comObj.postMessage({
  1075. sourceName: _sourceName,
  1076. targetName: _targetName,
  1077. isReply: true,
  1078. callbackId: data.callbackId,
  1079. error: makeReasonSerializable(reason)
  1080. });
  1081. });
  1082. } else if (data.streamId) {
  1083. _this._createStreamSink(data);
  1084. } else {
  1085. action[0].call(action[1], data.data);
  1086. }
  1087. } else {
  1088. throw new Error('Unknown action from worker: ' + data.action);
  1089. }
  1090. };
  1091. comObj.addEventListener('message', this._onComObjOnMessage);
  1092. }
  1093. MessageHandler.prototype = {
  1094. on: function on(actionName, handler, scope) {
  1095. var ah = this.actionHandler;
  1096. if (ah[actionName]) {
  1097. throw new Error('There is already an actionName called "' + actionName + '"');
  1098. }
  1099. ah[actionName] = [handler, scope];
  1100. },
  1101. send: function send(actionName, data, transfers) {
  1102. var message = {
  1103. sourceName: this.sourceName,
  1104. targetName: this.targetName,
  1105. action: actionName,
  1106. data: data
  1107. };
  1108. this.postMessage(message, transfers);
  1109. },
  1110. sendWithPromise: function sendWithPromise(actionName, data, transfers) {
  1111. var callbackId = this.callbackId++;
  1112. var message = {
  1113. sourceName: this.sourceName,
  1114. targetName: this.targetName,
  1115. action: actionName,
  1116. data: data,
  1117. callbackId: callbackId
  1118. };
  1119. var capability = createPromiseCapability();
  1120. this.callbacksCapabilities[callbackId] = capability;
  1121. try {
  1122. this.postMessage(message, transfers);
  1123. } catch (e) {
  1124. capability.reject(e);
  1125. }
  1126. return capability.promise;
  1127. },
  1128. sendWithStream: function sendWithStream(actionName, data, queueingStrategy, transfers) {
  1129. var _this2 = this;
  1130. var streamId = this.streamId++;
  1131. var sourceName = this.sourceName;
  1132. var targetName = this.targetName;
  1133. return new _streams_polyfill.ReadableStream({
  1134. start: function start(controller) {
  1135. var startCapability = createPromiseCapability();
  1136. _this2.streamControllers[streamId] = {
  1137. controller: controller,
  1138. startCall: startCapability,
  1139. isClosed: false
  1140. };
  1141. _this2.postMessage({
  1142. sourceName: sourceName,
  1143. targetName: targetName,
  1144. action: actionName,
  1145. streamId: streamId,
  1146. data: data,
  1147. desiredSize: controller.desiredSize
  1148. });
  1149. return startCapability.promise;
  1150. },
  1151. pull: function pull(controller) {
  1152. var pullCapability = createPromiseCapability();
  1153. _this2.streamControllers[streamId].pullCall = pullCapability;
  1154. _this2.postMessage({
  1155. sourceName: sourceName,
  1156. targetName: targetName,
  1157. stream: 'pull',
  1158. streamId: streamId,
  1159. desiredSize: controller.desiredSize
  1160. });
  1161. return pullCapability.promise;
  1162. },
  1163. cancel: function cancel(reason) {
  1164. var cancelCapability = createPromiseCapability();
  1165. _this2.streamControllers[streamId].cancelCall = cancelCapability;
  1166. _this2.streamControllers[streamId].isClosed = true;
  1167. _this2.postMessage({
  1168. sourceName: sourceName,
  1169. targetName: targetName,
  1170. stream: 'cancel',
  1171. reason: reason,
  1172. streamId: streamId
  1173. });
  1174. return cancelCapability.promise;
  1175. }
  1176. }, queueingStrategy);
  1177. },
  1178. _createStreamSink: function _createStreamSink(data) {
  1179. var _this3 = this;
  1180. var self = this;
  1181. var action = this.actionHandler[data.action];
  1182. var streamId = data.streamId;
  1183. var desiredSize = data.desiredSize;
  1184. var sourceName = this.sourceName;
  1185. var targetName = data.sourceName;
  1186. var capability = createPromiseCapability();
  1187. var sendStreamRequest = function sendStreamRequest(_ref) {
  1188. var stream = _ref.stream,
  1189. chunk = _ref.chunk,
  1190. transfers = _ref.transfers,
  1191. success = _ref.success,
  1192. reason = _ref.reason;
  1193. _this3.postMessage({
  1194. sourceName: sourceName,
  1195. targetName: targetName,
  1196. stream: stream,
  1197. streamId: streamId,
  1198. chunk: chunk,
  1199. success: success,
  1200. reason: reason
  1201. }, transfers);
  1202. };
  1203. var streamSink = {
  1204. enqueue: function enqueue(chunk) {
  1205. var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  1206. var transfers = arguments[2];
  1207. if (this.isCancelled) {
  1208. return;
  1209. }
  1210. var lastDesiredSize = this.desiredSize;
  1211. this.desiredSize -= size;
  1212. if (lastDesiredSize > 0 && this.desiredSize <= 0) {
  1213. this.sinkCapability = createPromiseCapability();
  1214. this.ready = this.sinkCapability.promise;
  1215. }
  1216. sendStreamRequest({
  1217. stream: 'enqueue',
  1218. chunk: chunk,
  1219. transfers: transfers
  1220. });
  1221. },
  1222. close: function close() {
  1223. if (this.isCancelled) {
  1224. return;
  1225. }
  1226. this.isCancelled = true;
  1227. sendStreamRequest({ stream: 'close' });
  1228. delete self.streamSinks[streamId];
  1229. },
  1230. error: function error(reason) {
  1231. if (this.isCancelled) {
  1232. return;
  1233. }
  1234. this.isCancelled = true;
  1235. sendStreamRequest({
  1236. stream: 'error',
  1237. reason: reason
  1238. });
  1239. },
  1240. sinkCapability: capability,
  1241. onPull: null,
  1242. onCancel: null,
  1243. isCancelled: false,
  1244. desiredSize: desiredSize,
  1245. ready: null
  1246. };
  1247. streamSink.sinkCapability.resolve();
  1248. streamSink.ready = streamSink.sinkCapability.promise;
  1249. this.streamSinks[streamId] = streamSink;
  1250. resolveCall(action[0], [data.data, streamSink], action[1]).then(function () {
  1251. sendStreamRequest({
  1252. stream: 'start_complete',
  1253. success: true
  1254. });
  1255. }, function (reason) {
  1256. sendStreamRequest({
  1257. stream: 'start_complete',
  1258. success: false,
  1259. reason: reason
  1260. });
  1261. });
  1262. },
  1263. _processStreamMessage: function _processStreamMessage(data) {
  1264. var _this4 = this;
  1265. var sourceName = this.sourceName;
  1266. var targetName = data.sourceName;
  1267. var streamId = data.streamId;
  1268. var sendStreamResponse = function sendStreamResponse(_ref2) {
  1269. var stream = _ref2.stream,
  1270. success = _ref2.success,
  1271. reason = _ref2.reason;
  1272. _this4.comObj.postMessage({
  1273. sourceName: sourceName,
  1274. targetName: targetName,
  1275. stream: stream,
  1276. success: success,
  1277. streamId: streamId,
  1278. reason: reason
  1279. });
  1280. };
  1281. var deleteStreamController = function deleteStreamController() {
  1282. Promise.all([_this4.streamControllers[data.streamId].startCall, _this4.streamControllers[data.streamId].pullCall, _this4.streamControllers[data.streamId].cancelCall].map(function (capability) {
  1283. return capability && finalize(capability.promise);
  1284. })).then(function () {
  1285. delete _this4.streamControllers[data.streamId];
  1286. });
  1287. };
  1288. switch (data.stream) {
  1289. case 'start_complete':
  1290. resolveOrReject(this.streamControllers[data.streamId].startCall, data.success, wrapReason(data.reason));
  1291. break;
  1292. case 'pull_complete':
  1293. resolveOrReject(this.streamControllers[data.streamId].pullCall, data.success, wrapReason(data.reason));
  1294. break;
  1295. case 'pull':
  1296. if (!this.streamSinks[data.streamId]) {
  1297. sendStreamResponse({
  1298. stream: 'pull_complete',
  1299. success: true
  1300. });
  1301. break;
  1302. }
  1303. if (this.streamSinks[data.streamId].desiredSize <= 0 && data.desiredSize > 0) {
  1304. this.streamSinks[data.streamId].sinkCapability.resolve();
  1305. }
  1306. this.streamSinks[data.streamId].desiredSize = data.desiredSize;
  1307. resolveCall(this.streamSinks[data.streamId].onPull).then(function () {
  1308. sendStreamResponse({
  1309. stream: 'pull_complete',
  1310. success: true
  1311. });
  1312. }, function (reason) {
  1313. sendStreamResponse({
  1314. stream: 'pull_complete',
  1315. success: false,
  1316. reason: reason
  1317. });
  1318. });
  1319. break;
  1320. case 'enqueue':
  1321. assert(this.streamControllers[data.streamId], 'enqueue should have stream controller');
  1322. if (!this.streamControllers[data.streamId].isClosed) {
  1323. this.streamControllers[data.streamId].controller.enqueue(data.chunk);
  1324. }
  1325. break;
  1326. case 'close':
  1327. assert(this.streamControllers[data.streamId], 'close should have stream controller');
  1328. if (this.streamControllers[data.streamId].isClosed) {
  1329. break;
  1330. }
  1331. this.streamControllers[data.streamId].isClosed = true;
  1332. this.streamControllers[data.streamId].controller.close();
  1333. deleteStreamController();
  1334. break;
  1335. case 'error':
  1336. assert(this.streamControllers[data.streamId], 'error should have stream controller');
  1337. this.streamControllers[data.streamId].controller.error(wrapReason(data.reason));
  1338. deleteStreamController();
  1339. break;
  1340. case 'cancel_complete':
  1341. resolveOrReject(this.streamControllers[data.streamId].cancelCall, data.success, wrapReason(data.reason));
  1342. deleteStreamController();
  1343. break;
  1344. case 'cancel':
  1345. if (!this.streamSinks[data.streamId]) {
  1346. break;
  1347. }
  1348. resolveCall(this.streamSinks[data.streamId].onCancel, [wrapReason(data.reason)]).then(function () {
  1349. sendStreamResponse({
  1350. stream: 'cancel_complete',
  1351. success: true
  1352. });
  1353. }, function (reason) {
  1354. sendStreamResponse({
  1355. stream: 'cancel_complete',
  1356. success: false,
  1357. reason: reason
  1358. });
  1359. });
  1360. this.streamSinks[data.streamId].sinkCapability.reject(wrapReason(data.reason));
  1361. this.streamSinks[data.streamId].isCancelled = true;
  1362. delete this.streamSinks[data.streamId];
  1363. break;
  1364. default:
  1365. throw new Error('Unexpected stream case');
  1366. }
  1367. },
  1368. postMessage: function postMessage(message, transfers) {
  1369. if (transfers && this.postMessageTransfers) {
  1370. this.comObj.postMessage(message, transfers);
  1371. } else {
  1372. this.comObj.postMessage(message);
  1373. }
  1374. },
  1375. destroy: function destroy() {
  1376. this.comObj.removeEventListener('message', this._onComObjOnMessage);
  1377. }
  1378. };
  1379. function loadJpegStream(id, imageUrl, objs) {
  1380. var img = new Image();
  1381. img.onload = function loadJpegStream_onloadClosure() {
  1382. objs.resolve(id, img);
  1383. };
  1384. img.onerror = function loadJpegStream_onerrorClosure() {
  1385. objs.resolve(id, null);
  1386. warn('Error during JPEG image loading');
  1387. };
  1388. img.src = imageUrl;
  1389. }
  1390. exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
  1391. exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
  1392. exports.OPS = OPS;
  1393. exports.VERBOSITY_LEVELS = VERBOSITY_LEVELS;
  1394. exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
  1395. exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
  1396. exports.AnnotationFieldFlag = AnnotationFieldFlag;
  1397. exports.AnnotationFlag = AnnotationFlag;
  1398. exports.AnnotationType = AnnotationType;
  1399. exports.FontType = FontType;
  1400. exports.ImageKind = ImageKind;
  1401. exports.CMapCompressionType = CMapCompressionType;
  1402. exports.AbortException = AbortException;
  1403. exports.InvalidPDFException = InvalidPDFException;
  1404. exports.MessageHandler = MessageHandler;
  1405. exports.MissingDataException = MissingDataException;
  1406. exports.MissingPDFException = MissingPDFException;
  1407. exports.NativeImageDecoding = NativeImageDecoding;
  1408. exports.NotImplementedException = NotImplementedException;
  1409. exports.PageViewport = PageViewport;
  1410. exports.PasswordException = PasswordException;
  1411. exports.PasswordResponses = PasswordResponses;
  1412. exports.StatTimer = StatTimer;
  1413. exports.StreamType = StreamType;
  1414. exports.TextRenderingMode = TextRenderingMode;
  1415. exports.UnexpectedResponseException = UnexpectedResponseException;
  1416. exports.UnknownErrorException = UnknownErrorException;
  1417. exports.Util = Util;
  1418. exports.XRefParseException = XRefParseException;
  1419. exports.FormatError = FormatError;
  1420. exports.arrayByteLength = arrayByteLength;
  1421. exports.arraysToBytes = arraysToBytes;
  1422. exports.assert = assert;
  1423. exports.bytesToString = bytesToString;
  1424. exports.createBlob = createBlob;
  1425. exports.createPromiseCapability = createPromiseCapability;
  1426. exports.createObjectURL = createObjectURL;
  1427. exports.deprecated = deprecated;
  1428. exports.getLookupTableFactory = getLookupTableFactory;
  1429. exports.getVerbosityLevel = getVerbosityLevel;
  1430. exports.info = info;
  1431. exports.isArrayBuffer = isArrayBuffer;
  1432. exports.isBool = isBool;
  1433. exports.isEmptyObj = isEmptyObj;
  1434. exports.isNum = isNum;
  1435. exports.isString = isString;
  1436. exports.isSpace = isSpace;
  1437. exports.isNodeJS = isNodeJS;
  1438. exports.isSameOrigin = isSameOrigin;
  1439. exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
  1440. exports.isLittleEndian = isLittleEndian;
  1441. exports.isEvalSupported = isEvalSupported;
  1442. exports.loadJpegStream = loadJpegStream;
  1443. exports.log2 = log2;
  1444. exports.readInt8 = readInt8;
  1445. exports.readUint16 = readUint16;
  1446. exports.readUint32 = readUint32;
  1447. exports.removeNullCharacters = removeNullCharacters;
  1448. exports.ReadableStream = _streams_polyfill.ReadableStream;
  1449. exports.setVerbosityLevel = setVerbosityLevel;
  1450. exports.shadow = shadow;
  1451. exports.string32 = string32;
  1452. exports.stringToBytes = stringToBytes;
  1453. exports.stringToPDFString = stringToPDFString;
  1454. exports.stringToUTF8String = stringToUTF8String;
  1455. exports.utf8StringToString = utf8StringToString;
  1456. exports.warn = warn;
  1457. exports.unreachable = unreachable;
  1458. /***/ }),
  1459. /* 1 */
  1460. /***/ (function(module, exports, __w_pdfjs_require__) {
  1461. "use strict";
  1462. var global = module.exports = typeof window != 'undefined' && window.Math == Math ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')();
  1463. if (typeof __g == 'number') __g = global;
  1464. /***/ }),
  1465. /* 2 */
  1466. /***/ (function(module, exports, __w_pdfjs_require__) {
  1467. "use strict";
  1468. 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; };
  1469. module.exports = function (it) {
  1470. return (typeof it === 'undefined' ? 'undefined' : _typeof(it)) === 'object' ? it !== null : typeof it === 'function';
  1471. };
  1472. /***/ }),
  1473. /* 3 */
  1474. /***/ (function(module, exports, __w_pdfjs_require__) {
  1475. "use strict";
  1476. var store = __w_pdfjs_require__(51)('wks');
  1477. var uid = __w_pdfjs_require__(16);
  1478. var _Symbol = __w_pdfjs_require__(1).Symbol;
  1479. var USE_SYMBOL = typeof _Symbol == 'function';
  1480. var $exports = module.exports = function (name) {
  1481. return store[name] || (store[name] = USE_SYMBOL && _Symbol[name] || (USE_SYMBOL ? _Symbol : uid)('Symbol.' + name));
  1482. };
  1483. $exports.store = store;
  1484. /***/ }),
  1485. /* 4 */
  1486. /***/ (function(module, exports, __w_pdfjs_require__) {
  1487. "use strict";
  1488. var global = __w_pdfjs_require__(1);
  1489. var core = __w_pdfjs_require__(5);
  1490. var hide = __w_pdfjs_require__(6);
  1491. var redefine = __w_pdfjs_require__(15);
  1492. var ctx = __w_pdfjs_require__(11);
  1493. var PROTOTYPE = 'prototype';
  1494. var $export = function $export(type, name, source) {
  1495. var IS_FORCED = type & $export.F;
  1496. var IS_GLOBAL = type & $export.G;
  1497. var IS_STATIC = type & $export.S;
  1498. var IS_PROTO = type & $export.P;
  1499. var IS_BIND = type & $export.B;
  1500. var target = IS_GLOBAL ? global : IS_STATIC ? global[name] || (global[name] = {}) : (global[name] || {})[PROTOTYPE];
  1501. var exports = IS_GLOBAL ? core : core[name] || (core[name] = {});
  1502. var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {});
  1503. var key, own, out, exp;
  1504. if (IS_GLOBAL) source = name;
  1505. for (key in source) {
  1506. own = !IS_FORCED && target && target[key] !== undefined;
  1507. out = (own ? target : source)[key];
  1508. exp = IS_BIND && own ? ctx(out, global) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
  1509. if (target) redefine(target, key, out, type & $export.U);
  1510. if (exports[key] != out) hide(exports, key, exp);
  1511. if (IS_PROTO && expProto[key] != out) expProto[key] = out;
  1512. }
  1513. };
  1514. global.core = core;
  1515. $export.F = 1;
  1516. $export.G = 2;
  1517. $export.S = 4;
  1518. $export.P = 8;
  1519. $export.B = 16;
  1520. $export.W = 32;
  1521. $export.U = 64;
  1522. $export.R = 128;
  1523. module.exports = $export;
  1524. /***/ }),
  1525. /* 5 */
  1526. /***/ (function(module, exports, __w_pdfjs_require__) {
  1527. "use strict";
  1528. var core = module.exports = { version: '2.5.1' };
  1529. if (typeof __e == 'number') __e = core;
  1530. /***/ }),
  1531. /* 6 */
  1532. /***/ (function(module, exports, __w_pdfjs_require__) {
  1533. "use strict";
  1534. var dP = __w_pdfjs_require__(14);
  1535. var createDesc = __w_pdfjs_require__(27);
  1536. module.exports = __w_pdfjs_require__(9) ? function (object, key, value) {
  1537. return dP.f(object, key, createDesc(1, value));
  1538. } : function (object, key, value) {
  1539. object[key] = value;
  1540. return object;
  1541. };
  1542. /***/ }),
  1543. /* 7 */
  1544. /***/ (function(module, exports, __w_pdfjs_require__) {
  1545. "use strict";
  1546. var isObject = __w_pdfjs_require__(2);
  1547. module.exports = function (it) {
  1548. if (!isObject(it)) throw TypeError(it + ' is not an object!');
  1549. return it;
  1550. };
  1551. /***/ }),
  1552. /* 8 */
  1553. /***/ (function(module, exports, __w_pdfjs_require__) {
  1554. "use strict";
  1555. var hasOwnProperty = {}.hasOwnProperty;
  1556. module.exports = function (it, key) {
  1557. return hasOwnProperty.call(it, key);
  1558. };
  1559. /***/ }),
  1560. /* 9 */
  1561. /***/ (function(module, exports, __w_pdfjs_require__) {
  1562. "use strict";
  1563. module.exports = !__w_pdfjs_require__(10)(function () {
  1564. return Object.defineProperty({}, 'a', {
  1565. get: function get() {
  1566. return 7;
  1567. }
  1568. }).a != 7;
  1569. });
  1570. /***/ }),
  1571. /* 10 */
  1572. /***/ (function(module, exports, __w_pdfjs_require__) {
  1573. "use strict";
  1574. module.exports = function (exec) {
  1575. try {
  1576. return !!exec();
  1577. } catch (e) {
  1578. return true;
  1579. }
  1580. };
  1581. /***/ }),
  1582. /* 11 */
  1583. /***/ (function(module, exports, __w_pdfjs_require__) {
  1584. "use strict";
  1585. var aFunction = __w_pdfjs_require__(21);
  1586. module.exports = function (fn, that, length) {
  1587. aFunction(fn);
  1588. if (that === undefined) return fn;
  1589. switch (length) {
  1590. case 1:
  1591. return function (a) {
  1592. return fn.call(that, a);
  1593. };
  1594. case 2:
  1595. return function (a, b) {
  1596. return fn.call(that, a, b);
  1597. };
  1598. case 3:
  1599. return function (a, b, c) {
  1600. return fn.call(that, a, b, c);
  1601. };
  1602. }
  1603. return function () {
  1604. return fn.apply(that, arguments);
  1605. };
  1606. };
  1607. /***/ }),
  1608. /* 12 */
  1609. /***/ (function(module, exports, __w_pdfjs_require__) {
  1610. "use strict";
  1611. var toInteger = __w_pdfjs_require__(17);
  1612. var min = Math.min;
  1613. module.exports = function (it) {
  1614. return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0;
  1615. };
  1616. /***/ }),
  1617. /* 13 */
  1618. /***/ (function(module, exports, __w_pdfjs_require__) {
  1619. "use strict";
  1620. Object.defineProperty(exports, "__esModule", {
  1621. value: true
  1622. });
  1623. exports.SimpleXMLParser = exports.DOMSVGFactory = exports.DOMCMapReaderFactory = exports.DOMCanvasFactory = exports.DEFAULT_LINK_REL = exports.getDefaultSetting = exports.LinkTarget = exports.getFilenameFromUrl = exports.isValidUrl = exports.isExternalLinkTargetSet = exports.addLinkAttributes = exports.RenderingCancelledException = exports.CustomStyle = undefined;
  1624. 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; }; }();
  1625. var _util = __w_pdfjs_require__(0);
  1626. var _global_scope = __w_pdfjs_require__(20);
  1627. var _global_scope2 = _interopRequireDefault(_global_scope);
  1628. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1629. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1630. var DEFAULT_LINK_REL = 'noopener noreferrer nofollow';
  1631. var SVG_NS = 'http://www.w3.org/2000/svg';
  1632. var DOMCanvasFactory = function () {
  1633. function DOMCanvasFactory() {
  1634. _classCallCheck(this, DOMCanvasFactory);
  1635. }
  1636. _createClass(DOMCanvasFactory, [{
  1637. key: 'create',
  1638. value: function create(width, height) {
  1639. if (width <= 0 || height <= 0) {
  1640. throw new Error('invalid canvas size');
  1641. }
  1642. var canvas = document.createElement('canvas');
  1643. var context = canvas.getContext('2d');
  1644. canvas.width = width;
  1645. canvas.height = height;
  1646. return {
  1647. canvas: canvas,
  1648. context: context
  1649. };
  1650. }
  1651. }, {
  1652. key: 'reset',
  1653. value: function reset(canvasAndContext, width, height) {
  1654. if (!canvasAndContext.canvas) {
  1655. throw new Error('canvas is not specified');
  1656. }
  1657. if (width <= 0 || height <= 0) {
  1658. throw new Error('invalid canvas size');
  1659. }
  1660. canvasAndContext.canvas.width = width;
  1661. canvasAndContext.canvas.height = height;
  1662. }
  1663. }, {
  1664. key: 'destroy',
  1665. value: function destroy(canvasAndContext) {
  1666. if (!canvasAndContext.canvas) {
  1667. throw new Error('canvas is not specified');
  1668. }
  1669. canvasAndContext.canvas.width = 0;
  1670. canvasAndContext.canvas.height = 0;
  1671. canvasAndContext.canvas = null;
  1672. canvasAndContext.context = null;
  1673. }
  1674. }]);
  1675. return DOMCanvasFactory;
  1676. }();
  1677. var DOMCMapReaderFactory = function () {
  1678. function DOMCMapReaderFactory(_ref) {
  1679. var _ref$baseUrl = _ref.baseUrl,
  1680. baseUrl = _ref$baseUrl === undefined ? null : _ref$baseUrl,
  1681. _ref$isCompressed = _ref.isCompressed,
  1682. isCompressed = _ref$isCompressed === undefined ? false : _ref$isCompressed;
  1683. _classCallCheck(this, DOMCMapReaderFactory);
  1684. this.baseUrl = baseUrl;
  1685. this.isCompressed = isCompressed;
  1686. }
  1687. _createClass(DOMCMapReaderFactory, [{
  1688. key: 'fetch',
  1689. value: function fetch(_ref2) {
  1690. var _this = this;
  1691. var name = _ref2.name;
  1692. if (!this.baseUrl) {
  1693. return Promise.reject(new Error('CMap baseUrl must be specified, ' + 'see "PDFJS.cMapUrl" (and also "PDFJS.cMapPacked").'));
  1694. }
  1695. if (!name) {
  1696. return Promise.reject(new Error('CMap name must be specified.'));
  1697. }
  1698. return new Promise(function (resolve, reject) {
  1699. var url = _this.baseUrl + name + (_this.isCompressed ? '.bcmap' : '');
  1700. var request = new XMLHttpRequest();
  1701. request.open('GET', url, true);
  1702. if (_this.isCompressed) {
  1703. request.responseType = 'arraybuffer';
  1704. }
  1705. request.onreadystatechange = function () {
  1706. if (request.readyState !== XMLHttpRequest.DONE) {
  1707. return;
  1708. }
  1709. if (request.status === 200 || request.status === 0) {
  1710. var data = void 0;
  1711. if (_this.isCompressed && request.response) {
  1712. data = new Uint8Array(request.response);
  1713. } else if (!_this.isCompressed && request.responseText) {
  1714. data = (0, _util.stringToBytes)(request.responseText);
  1715. }
  1716. if (data) {
  1717. resolve({
  1718. cMapData: data,
  1719. compressionType: _this.isCompressed ? _util.CMapCompressionType.BINARY : _util.CMapCompressionType.NONE
  1720. });
  1721. return;
  1722. }
  1723. }
  1724. reject(new Error('Unable to load ' + (_this.isCompressed ? 'binary ' : '') + 'CMap at: ' + url));
  1725. };
  1726. request.send(null);
  1727. });
  1728. }
  1729. }]);
  1730. return DOMCMapReaderFactory;
  1731. }();
  1732. var DOMSVGFactory = function () {
  1733. function DOMSVGFactory() {
  1734. _classCallCheck(this, DOMSVGFactory);
  1735. }
  1736. _createClass(DOMSVGFactory, [{
  1737. key: 'create',
  1738. value: function create(width, height) {
  1739. (0, _util.assert)(width > 0 && height > 0, 'Invalid SVG dimensions');
  1740. var svg = document.createElementNS(SVG_NS, 'svg:svg');
  1741. svg.setAttribute('version', '1.1');
  1742. svg.setAttribute('width', width + 'px');
  1743. svg.setAttribute('height', height + 'px');
  1744. svg.setAttribute('preserveAspectRatio', 'none');
  1745. svg.setAttribute('viewBox', '0 0 ' + width + ' ' + height);
  1746. return svg;
  1747. }
  1748. }, {
  1749. key: 'createElement',
  1750. value: function createElement(type) {
  1751. (0, _util.assert)(typeof type === 'string', 'Invalid SVG element type');
  1752. return document.createElementNS(SVG_NS, type);
  1753. }
  1754. }]);
  1755. return DOMSVGFactory;
  1756. }();
  1757. var SimpleDOMNode = function () {
  1758. function SimpleDOMNode(nodeName, nodeValue) {
  1759. _classCallCheck(this, SimpleDOMNode);
  1760. this.nodeName = nodeName;
  1761. this.nodeValue = nodeValue;
  1762. Object.defineProperty(this, 'parentNode', {
  1763. value: null,
  1764. writable: true
  1765. });
  1766. }
  1767. _createClass(SimpleDOMNode, [{
  1768. key: 'hasChildNodes',
  1769. value: function hasChildNodes() {
  1770. return this.childNodes && this.childNodes.length > 0;
  1771. }
  1772. }, {
  1773. key: 'firstChild',
  1774. get: function get() {
  1775. return this.childNodes[0];
  1776. }
  1777. }, {
  1778. key: 'nextSibling',
  1779. get: function get() {
  1780. var index = this.parentNode.childNodes.indexOf(this);
  1781. return this.parentNode.childNodes[index + 1];
  1782. }
  1783. }, {
  1784. key: 'textContent',
  1785. get: function get() {
  1786. if (!this.childNodes) {
  1787. return this.nodeValue || '';
  1788. }
  1789. return this.childNodes.map(function (child) {
  1790. return child.textContent;
  1791. }).join('');
  1792. }
  1793. }]);
  1794. return SimpleDOMNode;
  1795. }();
  1796. var SimpleXMLParser = function () {
  1797. function SimpleXMLParser() {
  1798. _classCallCheck(this, SimpleXMLParser);
  1799. }
  1800. _createClass(SimpleXMLParser, [{
  1801. key: 'parseFromString',
  1802. value: function parseFromString(data) {
  1803. var _this2 = this;
  1804. var nodes = [];
  1805. data = data.replace(/<\?[\s\S]*?\?>|<!--[\s\S]*?-->/g, '').trim();
  1806. data = data.replace(/<!DOCTYPE[^>\[]+(\[[^\]]+)?[^>]+>/g, '').trim();
  1807. data = data.replace(/>([^<][\s\S]*?)</g, function (all, text) {
  1808. var length = nodes.length;
  1809. var node = new SimpleDOMNode('#text', _this2._decodeXML(text));
  1810. nodes.push(node);
  1811. if (node.textContent.trim().length === 0) {
  1812. return '><';
  1813. }
  1814. return '>' + length + ',<';
  1815. });
  1816. data = data.replace(/<!\[CDATA\[([\s\S]*?)\]\]>/g, function (all, text) {
  1817. var length = nodes.length;
  1818. var node = new SimpleDOMNode('#text', text);
  1819. nodes.push(node);
  1820. return length + ',';
  1821. });
  1822. var regex = /<([\w\:]+)((?:[\s\w:=]|'[^']*'|"[^"]*")*)(?:\/>|>([\d,]*)<\/[^>]+>)/g;
  1823. var lastLength = void 0;
  1824. do {
  1825. lastLength = nodes.length;
  1826. data = data.replace(regex, function (all, name, attrs, data) {
  1827. var length = nodes.length;
  1828. var node = new SimpleDOMNode(name);
  1829. var children = [];
  1830. if (data) {
  1831. data = data.split(',');
  1832. data.pop();
  1833. data.forEach(function (child) {
  1834. var childNode = nodes[+child];
  1835. childNode.parentNode = node;
  1836. children.push(childNode);
  1837. });
  1838. }
  1839. node.childNodes = children;
  1840. nodes.push(node);
  1841. return length + ',';
  1842. });
  1843. } while (lastLength < nodes.length);
  1844. return { documentElement: nodes.pop() };
  1845. }
  1846. }, {
  1847. key: '_decodeXML',
  1848. value: function _decodeXML(text) {
  1849. if (text.indexOf('&') < 0) {
  1850. return text;
  1851. }
  1852. return text.replace(/&(#(x[0-9a-f]+|\d+)|\w+);/gi, function (all, entityName, number) {
  1853. if (number) {
  1854. if (number[0] === 'x') {
  1855. number = parseInt(number.substring(1), 16);
  1856. } else {
  1857. number = +number;
  1858. }
  1859. return String.fromCharCode(number);
  1860. }
  1861. switch (entityName) {
  1862. case 'amp':
  1863. return '&';
  1864. case 'lt':
  1865. return '<';
  1866. case 'gt':
  1867. return '>';
  1868. case 'quot':
  1869. return '\"';
  1870. case 'apos':
  1871. return '\'';
  1872. }
  1873. return '&' + entityName + ';';
  1874. });
  1875. }
  1876. }]);
  1877. return SimpleXMLParser;
  1878. }();
  1879. var CustomStyle = function CustomStyleClosure() {
  1880. var prefixes = ['ms', 'Moz', 'Webkit', 'O'];
  1881. var _cache = Object.create(null);
  1882. function CustomStyle() {}
  1883. CustomStyle.getProp = function get(propName, element) {
  1884. if (arguments.length === 1 && typeof _cache[propName] === 'string') {
  1885. return _cache[propName];
  1886. }
  1887. element = element || document.documentElement;
  1888. var style = element.style,
  1889. prefixed,
  1890. uPropName;
  1891. if (typeof style[propName] === 'string') {
  1892. return _cache[propName] = propName;
  1893. }
  1894. uPropName = propName.charAt(0).toUpperCase() + propName.slice(1);
  1895. for (var i = 0, l = prefixes.length; i < l; i++) {
  1896. prefixed = prefixes[i] + uPropName;
  1897. if (typeof style[prefixed] === 'string') {
  1898. return _cache[propName] = prefixed;
  1899. }
  1900. }
  1901. return _cache[propName] = 'undefined';
  1902. };
  1903. CustomStyle.setProp = function set(propName, element, str) {
  1904. var prop = this.getProp(propName);
  1905. if (prop !== 'undefined') {
  1906. element.style[prop] = str;
  1907. }
  1908. };
  1909. return CustomStyle;
  1910. }();
  1911. var RenderingCancelledException = function RenderingCancelledException() {
  1912. function RenderingCancelledException(msg, type) {
  1913. this.message = msg;
  1914. this.type = type;
  1915. }
  1916. RenderingCancelledException.prototype = new Error();
  1917. RenderingCancelledException.prototype.name = 'RenderingCancelledException';
  1918. RenderingCancelledException.constructor = RenderingCancelledException;
  1919. return RenderingCancelledException;
  1920. }();
  1921. var LinkTarget = {
  1922. NONE: 0,
  1923. SELF: 1,
  1924. BLANK: 2,
  1925. PARENT: 3,
  1926. TOP: 4
  1927. };
  1928. var LinkTargetStringMap = ['', '_self', '_blank', '_parent', '_top'];
  1929. function addLinkAttributes(link, params) {
  1930. var url = params && params.url;
  1931. link.href = link.title = url ? (0, _util.removeNullCharacters)(url) : '';
  1932. if (url) {
  1933. var target = params.target;
  1934. if (typeof target === 'undefined') {
  1935. target = getDefaultSetting('externalLinkTarget');
  1936. }
  1937. link.target = LinkTargetStringMap[target];
  1938. var rel = params.rel;
  1939. if (typeof rel === 'undefined') {
  1940. rel = getDefaultSetting('externalLinkRel');
  1941. }
  1942. link.rel = rel;
  1943. }
  1944. }
  1945. function getFilenameFromUrl(url) {
  1946. var anchor = url.indexOf('#');
  1947. var query = url.indexOf('?');
  1948. var end = Math.min(anchor > 0 ? anchor : url.length, query > 0 ? query : url.length);
  1949. return url.substring(url.lastIndexOf('/', end) + 1, end);
  1950. }
  1951. function getDefaultSetting(id) {
  1952. var globalSettings = _global_scope2.default.PDFJS;
  1953. switch (id) {
  1954. case 'pdfBug':
  1955. return globalSettings ? globalSettings.pdfBug : false;
  1956. case 'disableAutoFetch':
  1957. return globalSettings ? globalSettings.disableAutoFetch : false;
  1958. case 'disableStream':
  1959. return globalSettings ? globalSettings.disableStream : false;
  1960. case 'disableRange':
  1961. return globalSettings ? globalSettings.disableRange : false;
  1962. case 'disableFontFace':
  1963. return globalSettings ? globalSettings.disableFontFace : false;
  1964. case 'disableCreateObjectURL':
  1965. return globalSettings ? globalSettings.disableCreateObjectURL : false;
  1966. case 'disableWebGL':
  1967. return globalSettings ? globalSettings.disableWebGL : true;
  1968. case 'cMapUrl':
  1969. return globalSettings ? globalSettings.cMapUrl : null;
  1970. case 'cMapPacked':
  1971. return globalSettings ? globalSettings.cMapPacked : false;
  1972. case 'postMessageTransfers':
  1973. return globalSettings ? globalSettings.postMessageTransfers : true;
  1974. case 'workerPort':
  1975. return globalSettings ? globalSettings.workerPort : null;
  1976. case 'workerSrc':
  1977. return globalSettings ? globalSettings.workerSrc : null;
  1978. case 'disableWorker':
  1979. return globalSettings ? globalSettings.disableWorker : false;
  1980. case 'maxImageSize':
  1981. return globalSettings ? globalSettings.maxImageSize : -1;
  1982. case 'imageResourcesPath':
  1983. return globalSettings ? globalSettings.imageResourcesPath : '';
  1984. case 'isEvalSupported':
  1985. return globalSettings ? globalSettings.isEvalSupported : true;
  1986. case 'externalLinkTarget':
  1987. if (!globalSettings) {
  1988. return LinkTarget.NONE;
  1989. }
  1990. switch (globalSettings.externalLinkTarget) {
  1991. case LinkTarget.NONE:
  1992. case LinkTarget.SELF:
  1993. case LinkTarget.BLANK:
  1994. case LinkTarget.PARENT:
  1995. case LinkTarget.TOP:
  1996. return globalSettings.externalLinkTarget;
  1997. }
  1998. (0, _util.warn)('PDFJS.externalLinkTarget is invalid: ' + globalSettings.externalLinkTarget);
  1999. globalSettings.externalLinkTarget = LinkTarget.NONE;
  2000. return LinkTarget.NONE;
  2001. case 'externalLinkRel':
  2002. return globalSettings ? globalSettings.externalLinkRel : DEFAULT_LINK_REL;
  2003. case 'enableStats':
  2004. return !!(globalSettings && globalSettings.enableStats);
  2005. case 'pdfjsNext':
  2006. return !!(globalSettings && globalSettings.pdfjsNext);
  2007. default:
  2008. throw new Error('Unknown default setting: ' + id);
  2009. }
  2010. }
  2011. function isExternalLinkTargetSet() {
  2012. var externalLinkTarget = getDefaultSetting('externalLinkTarget');
  2013. switch (externalLinkTarget) {
  2014. case LinkTarget.NONE:
  2015. return false;
  2016. case LinkTarget.SELF:
  2017. case LinkTarget.BLANK:
  2018. case LinkTarget.PARENT:
  2019. case LinkTarget.TOP:
  2020. return true;
  2021. }
  2022. }
  2023. function isValidUrl(url, allowRelative) {
  2024. (0, _util.deprecated)('isValidUrl(), please use createValidAbsoluteUrl() instead.');
  2025. var baseUrl = allowRelative ? 'http://example.com' : null;
  2026. return (0, _util.createValidAbsoluteUrl)(url, baseUrl) !== null;
  2027. }
  2028. exports.CustomStyle = CustomStyle;
  2029. exports.RenderingCancelledException = RenderingCancelledException;
  2030. exports.addLinkAttributes = addLinkAttributes;
  2031. exports.isExternalLinkTargetSet = isExternalLinkTargetSet;
  2032. exports.isValidUrl = isValidUrl;
  2033. exports.getFilenameFromUrl = getFilenameFromUrl;
  2034. exports.LinkTarget = LinkTarget;
  2035. exports.getDefaultSetting = getDefaultSetting;
  2036. exports.DEFAULT_LINK_REL = DEFAULT_LINK_REL;
  2037. exports.DOMCanvasFactory = DOMCanvasFactory;
  2038. exports.DOMCMapReaderFactory = DOMCMapReaderFactory;
  2039. exports.DOMSVGFactory = DOMSVGFactory;
  2040. exports.SimpleXMLParser = SimpleXMLParser;
  2041. /***/ }),
  2042. /* 14 */
  2043. /***/ (function(module, exports, __w_pdfjs_require__) {
  2044. "use strict";
  2045. var anObject = __w_pdfjs_require__(7);
  2046. var IE8_DOM_DEFINE = __w_pdfjs_require__(45);
  2047. var toPrimitive = __w_pdfjs_require__(33);
  2048. var dP = Object.defineProperty;
  2049. exports.f = __w_pdfjs_require__(9) ? Object.defineProperty : function defineProperty(O, P, Attributes) {
  2050. anObject(O);
  2051. P = toPrimitive(P, true);
  2052. anObject(Attributes);
  2053. if (IE8_DOM_DEFINE) try {
  2054. return dP(O, P, Attributes);
  2055. } catch (e) {}
  2056. if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
  2057. if ('value' in Attributes) O[P] = Attributes.value;
  2058. return O;
  2059. };
  2060. /***/ }),
  2061. /* 15 */
  2062. /***/ (function(module, exports, __w_pdfjs_require__) {
  2063. "use strict";
  2064. var global = __w_pdfjs_require__(1);
  2065. var hide = __w_pdfjs_require__(6);
  2066. var has = __w_pdfjs_require__(8);
  2067. var SRC = __w_pdfjs_require__(16)('src');
  2068. var TO_STRING = 'toString';
  2069. var $toString = Function[TO_STRING];
  2070. var TPL = ('' + $toString).split(TO_STRING);
  2071. __w_pdfjs_require__(5).inspectSource = function (it) {
  2072. return $toString.call(it);
  2073. };
  2074. (module.exports = function (O, key, val, safe) {
  2075. var isFunction = typeof val == 'function';
  2076. if (isFunction) has(val, 'name') || hide(val, 'name', key);
  2077. if (O[key] === val) return;
  2078. if (isFunction) has(val, SRC) || hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key)));
  2079. if (O === global) {
  2080. O[key] = val;
  2081. } else if (!safe) {
  2082. delete O[key];
  2083. hide(O, key, val);
  2084. } else if (O[key]) {
  2085. O[key] = val;
  2086. } else {
  2087. hide(O, key, val);
  2088. }
  2089. })(Function.prototype, TO_STRING, function toString() {
  2090. return typeof this == 'function' && this[SRC] || $toString.call(this);
  2091. });
  2092. /***/ }),
  2093. /* 16 */
  2094. /***/ (function(module, exports, __w_pdfjs_require__) {
  2095. "use strict";
  2096. var id = 0;
  2097. var px = Math.random();
  2098. module.exports = function (key) {
  2099. return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
  2100. };
  2101. /***/ }),
  2102. /* 17 */
  2103. /***/ (function(module, exports, __w_pdfjs_require__) {
  2104. "use strict";
  2105. var ceil = Math.ceil;
  2106. var floor = Math.floor;
  2107. module.exports = function (it) {
  2108. return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
  2109. };
  2110. /***/ }),
  2111. /* 18 */
  2112. /***/ (function(module, exports, __w_pdfjs_require__) {
  2113. "use strict";
  2114. var defined = __w_pdfjs_require__(35);
  2115. module.exports = function (it) {
  2116. return Object(defined(it));
  2117. };
  2118. /***/ }),
  2119. /* 19 */
  2120. /***/ (function(module, exports, __w_pdfjs_require__) {
  2121. "use strict";
  2122. module.exports = {};
  2123. /***/ }),
  2124. /* 20 */
  2125. /***/ (function(module, exports, __w_pdfjs_require__) {
  2126. "use strict";
  2127. module.exports = typeof window !== 'undefined' && window.Math === Math ? window : typeof global !== 'undefined' && global.Math === Math ? global : typeof self !== 'undefined' && self.Math === Math ? self : {};
  2128. /***/ }),
  2129. /* 21 */
  2130. /***/ (function(module, exports, __w_pdfjs_require__) {
  2131. "use strict";
  2132. module.exports = function (it) {
  2133. if (typeof it != 'function') throw TypeError(it + ' is not a function!');
  2134. return it;
  2135. };
  2136. /***/ }),
  2137. /* 22 */
  2138. /***/ (function(module, exports, __w_pdfjs_require__) {
  2139. "use strict";
  2140. var redefine = __w_pdfjs_require__(15);
  2141. module.exports = function (target, src, safe) {
  2142. for (var key in src) {
  2143. redefine(target, key, src[key], safe);
  2144. }return target;
  2145. };
  2146. /***/ }),
  2147. /* 23 */
  2148. /***/ (function(module, exports, __w_pdfjs_require__) {
  2149. "use strict";
  2150. module.exports = function (it, Constructor, name, forbiddenField) {
  2151. if (!(it instanceof Constructor) || forbiddenField !== undefined && forbiddenField in it) {
  2152. throw TypeError(name + ': incorrect invocation!');
  2153. }
  2154. return it;
  2155. };
  2156. /***/ }),
  2157. /* 24 */
  2158. /***/ (function(module, exports, __w_pdfjs_require__) {
  2159. "use strict";
  2160. var toString = {}.toString;
  2161. module.exports = function (it) {
  2162. return toString.call(it).slice(8, -1);
  2163. };
  2164. /***/ }),
  2165. /* 25 */
  2166. /***/ (function(module, exports, __w_pdfjs_require__) {
  2167. "use strict";
  2168. var def = __w_pdfjs_require__(14).f;
  2169. var has = __w_pdfjs_require__(8);
  2170. var TAG = __w_pdfjs_require__(3)('toStringTag');
  2171. module.exports = function (it, tag, stat) {
  2172. if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, {
  2173. configurable: true,
  2174. value: tag
  2175. });
  2176. };
  2177. /***/ }),
  2178. /* 26 */
  2179. /***/ (function(module, exports, __w_pdfjs_require__) {
  2180. "use strict";
  2181. module.exports = false;
  2182. /***/ }),
  2183. /* 27 */
  2184. /***/ (function(module, exports, __w_pdfjs_require__) {
  2185. "use strict";
  2186. module.exports = function (bitmap, value) {
  2187. return {
  2188. enumerable: !(bitmap & 1),
  2189. configurable: !(bitmap & 2),
  2190. writable: !(bitmap & 4),
  2191. value: value
  2192. };
  2193. };
  2194. /***/ }),
  2195. /* 28 */
  2196. /***/ (function(module, exports, __w_pdfjs_require__) {
  2197. "use strict";
  2198. var IObject = __w_pdfjs_require__(34);
  2199. var defined = __w_pdfjs_require__(35);
  2200. module.exports = function (it) {
  2201. return IObject(defined(it));
  2202. };
  2203. /***/ }),
  2204. /* 29 */
  2205. /***/ (function(module, exports, __w_pdfjs_require__) {
  2206. "use strict";
  2207. var toInteger = __w_pdfjs_require__(17);
  2208. var max = Math.max;
  2209. var min = Math.min;
  2210. module.exports = function (index, length) {
  2211. index = toInteger(index);
  2212. return index < 0 ? max(index + length, 0) : min(index, length);
  2213. };
  2214. /***/ }),
  2215. /* 30 */
  2216. /***/ (function(module, exports, __w_pdfjs_require__) {
  2217. "use strict";
  2218. var cof = __w_pdfjs_require__(24);
  2219. var TAG = __w_pdfjs_require__(3)('toStringTag');
  2220. var ARG = cof(function () {
  2221. return arguments;
  2222. }()) == 'Arguments';
  2223. var tryGet = function tryGet(it, key) {
  2224. try {
  2225. return it[key];
  2226. } catch (e) {}
  2227. };
  2228. module.exports = function (it) {
  2229. var O, T, B;
  2230. return it === undefined ? 'Undefined' : it === null ? 'Null' : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T : ARG ? cof(O) : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
  2231. };
  2232. /***/ }),
  2233. /* 31 */
  2234. /***/ (function(module, exports, __w_pdfjs_require__) {
  2235. "use strict";
  2236. var ctx = __w_pdfjs_require__(11);
  2237. var call = __w_pdfjs_require__(98);
  2238. var isArrayIter = __w_pdfjs_require__(53);
  2239. var anObject = __w_pdfjs_require__(7);
  2240. var toLength = __w_pdfjs_require__(12);
  2241. var getIterFn = __w_pdfjs_require__(57);
  2242. var BREAK = {};
  2243. var RETURN = {};
  2244. var _exports = module.exports = function (iterable, entries, fn, that, ITERATOR) {
  2245. var iterFn = ITERATOR ? function () {
  2246. return iterable;
  2247. } : getIterFn(iterable);
  2248. var f = ctx(fn, that, entries ? 2 : 1);
  2249. var index = 0;
  2250. var length, step, iterator, result;
  2251. if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!');
  2252. if (isArrayIter(iterFn)) for (length = toLength(iterable.length); length > index; index++) {
  2253. result = entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
  2254. if (result === BREAK || result === RETURN) return result;
  2255. } else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) {
  2256. result = call(iterator, f, step.value, entries);
  2257. if (result === BREAK || result === RETURN) return result;
  2258. }
  2259. };
  2260. _exports.BREAK = BREAK;
  2261. _exports.RETURN = RETURN;
  2262. /***/ }),
  2263. /* 32 */
  2264. /***/ (function(module, exports, __w_pdfjs_require__) {
  2265. "use strict";
  2266. var isObject = __w_pdfjs_require__(2);
  2267. var document = __w_pdfjs_require__(1).document;
  2268. var is = isObject(document) && isObject(document.createElement);
  2269. module.exports = function (it) {
  2270. return is ? document.createElement(it) : {};
  2271. };
  2272. /***/ }),
  2273. /* 33 */
  2274. /***/ (function(module, exports, __w_pdfjs_require__) {
  2275. "use strict";
  2276. var isObject = __w_pdfjs_require__(2);
  2277. module.exports = function (it, S) {
  2278. if (!isObject(it)) return it;
  2279. var fn, val;
  2280. if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  2281. if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;
  2282. if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  2283. throw TypeError("Can't convert object to primitive value");
  2284. };
  2285. /***/ }),
  2286. /* 34 */
  2287. /***/ (function(module, exports, __w_pdfjs_require__) {
  2288. "use strict";
  2289. var cof = __w_pdfjs_require__(24);
  2290. module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
  2291. return cof(it) == 'String' ? it.split('') : Object(it);
  2292. };
  2293. /***/ }),
  2294. /* 35 */
  2295. /***/ (function(module, exports, __w_pdfjs_require__) {
  2296. "use strict";
  2297. module.exports = function (it) {
  2298. if (it == undefined) throw TypeError("Can't call method on " + it);
  2299. return it;
  2300. };
  2301. /***/ }),
  2302. /* 36 */
  2303. /***/ (function(module, exports, __w_pdfjs_require__) {
  2304. "use strict";
  2305. var shared = __w_pdfjs_require__(51)('keys');
  2306. var uid = __w_pdfjs_require__(16);
  2307. module.exports = function (key) {
  2308. return shared[key] || (shared[key] = uid(key));
  2309. };
  2310. /***/ }),
  2311. /* 37 */
  2312. /***/ (function(module, exports, __w_pdfjs_require__) {
  2313. "use strict";
  2314. module.exports = 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'.split(',');
  2315. /***/ }),
  2316. /* 38 */
  2317. /***/ (function(module, exports, __w_pdfjs_require__) {
  2318. "use strict";
  2319. var $keys = __w_pdfjs_require__(49);
  2320. var enumBugKeys = __w_pdfjs_require__(37);
  2321. module.exports = Object.keys || function keys(O) {
  2322. return $keys(O, enumBugKeys);
  2323. };
  2324. /***/ }),
  2325. /* 39 */
  2326. /***/ (function(module, exports, __w_pdfjs_require__) {
  2327. "use strict";
  2328. var ctx = __w_pdfjs_require__(11);
  2329. var IObject = __w_pdfjs_require__(34);
  2330. var toObject = __w_pdfjs_require__(18);
  2331. var toLength = __w_pdfjs_require__(12);
  2332. var asc = __w_pdfjs_require__(82);
  2333. module.exports = function (TYPE, $create) {
  2334. var IS_MAP = TYPE == 1;
  2335. var IS_FILTER = TYPE == 2;
  2336. var IS_SOME = TYPE == 3;
  2337. var IS_EVERY = TYPE == 4;
  2338. var IS_FIND_INDEX = TYPE == 6;
  2339. var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
  2340. var create = $create || asc;
  2341. return function ($this, callbackfn, that) {
  2342. var O = toObject($this);
  2343. var self = IObject(O);
  2344. var f = ctx(callbackfn, that, 3);
  2345. var length = toLength(self.length);
  2346. var index = 0;
  2347. var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
  2348. var val, res;
  2349. for (; length > index; index++) {
  2350. if (NO_HOLES || index in self) {
  2351. val = self[index];
  2352. res = f(val, index, O);
  2353. if (TYPE) {
  2354. if (IS_MAP) result[index] = res;else if (res) switch (TYPE) {
  2355. case 3:
  2356. return true;
  2357. case 5:
  2358. return val;
  2359. case 6:
  2360. return index;
  2361. case 2:
  2362. result.push(val);
  2363. } else if (IS_EVERY) return false;
  2364. }
  2365. }
  2366. }return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;
  2367. };
  2368. };
  2369. /***/ }),
  2370. /* 40 */
  2371. /***/ (function(module, exports, __w_pdfjs_require__) {
  2372. "use strict";
  2373. var anObject = __w_pdfjs_require__(7);
  2374. var aFunction = __w_pdfjs_require__(21);
  2375. var SPECIES = __w_pdfjs_require__(3)('species');
  2376. module.exports = function (O, D) {
  2377. var C = anObject(O).constructor;
  2378. var S;
  2379. return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S);
  2380. };
  2381. /***/ }),
  2382. /* 41 */
  2383. /***/ (function(module, exports, __w_pdfjs_require__) {
  2384. "use strict";
  2385. var ITERATOR = __w_pdfjs_require__(3)('iterator');
  2386. var SAFE_CLOSING = false;
  2387. try {
  2388. var riter = [7][ITERATOR]();
  2389. riter['return'] = function () {
  2390. SAFE_CLOSING = true;
  2391. };
  2392. Array.from(riter, function () {
  2393. throw 2;
  2394. });
  2395. } catch (e) {}
  2396. module.exports = function (exec, skipClosing) {
  2397. if (!skipClosing && !SAFE_CLOSING) return false;
  2398. var safe = false;
  2399. try {
  2400. var arr = [7];
  2401. var iter = arr[ITERATOR]();
  2402. iter.next = function () {
  2403. return { done: safe = true };
  2404. };
  2405. arr[ITERATOR] = function () {
  2406. return iter;
  2407. };
  2408. exec(arr);
  2409. } catch (e) {}
  2410. return safe;
  2411. };
  2412. /***/ }),
  2413. /* 42 */
  2414. /***/ (function(module, exports, __w_pdfjs_require__) {
  2415. "use strict";
  2416. var aFunction = __w_pdfjs_require__(21);
  2417. function PromiseCapability(C) {
  2418. var resolve, reject;
  2419. this.promise = new C(function ($$resolve, $$reject) {
  2420. if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');
  2421. resolve = $$resolve;
  2422. reject = $$reject;
  2423. });
  2424. this.resolve = aFunction(resolve);
  2425. this.reject = aFunction(reject);
  2426. }
  2427. module.exports.f = function (C) {
  2428. return new PromiseCapability(C);
  2429. };
  2430. /***/ }),
  2431. /* 43 */
  2432. /***/ (function(module, exports, __w_pdfjs_require__) {
  2433. "use strict";
  2434. 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; };
  2435. var META = __w_pdfjs_require__(16)('meta');
  2436. var isObject = __w_pdfjs_require__(2);
  2437. var has = __w_pdfjs_require__(8);
  2438. var setDesc = __w_pdfjs_require__(14).f;
  2439. var id = 0;
  2440. var isExtensible = Object.isExtensible || function () {
  2441. return true;
  2442. };
  2443. var FREEZE = !__w_pdfjs_require__(10)(function () {
  2444. return isExtensible(Object.preventExtensions({}));
  2445. });
  2446. var setMeta = function setMeta(it) {
  2447. setDesc(it, META, {
  2448. value: {
  2449. i: 'O' + ++id,
  2450. w: {}
  2451. }
  2452. });
  2453. };
  2454. var fastKey = function fastKey(it, create) {
  2455. if (!isObject(it)) return (typeof it === 'undefined' ? 'undefined' : _typeof(it)) == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
  2456. if (!has(it, META)) {
  2457. if (!isExtensible(it)) return 'F';
  2458. if (!create) return 'E';
  2459. setMeta(it);
  2460. }
  2461. return it[META].i;
  2462. };
  2463. var getWeak = function getWeak(it, create) {
  2464. if (!has(it, META)) {
  2465. if (!isExtensible(it)) return true;
  2466. if (!create) return false;
  2467. setMeta(it);
  2468. }
  2469. return it[META].w;
  2470. };
  2471. var onFreeze = function onFreeze(it) {
  2472. if (FREEZE && meta.NEED && isExtensible(it) && !has(it, META)) setMeta(it);
  2473. return it;
  2474. };
  2475. var meta = module.exports = {
  2476. KEY: META,
  2477. NEED: false,
  2478. fastKey: fastKey,
  2479. getWeak: getWeak,
  2480. onFreeze: onFreeze
  2481. };
  2482. /***/ }),
  2483. /* 44 */
  2484. /***/ (function(module, exports, __w_pdfjs_require__) {
  2485. "use strict";
  2486. Object.defineProperty(exports, "__esModule", {
  2487. value: true
  2488. });
  2489. exports.validateResponseStatus = exports.validateRangeRequestCapabilities = exports.createResponseStatusError = undefined;
  2490. var _util = __w_pdfjs_require__(0);
  2491. function validateRangeRequestCapabilities(_ref) {
  2492. var getResponseHeader = _ref.getResponseHeader,
  2493. isHttp = _ref.isHttp,
  2494. rangeChunkSize = _ref.rangeChunkSize,
  2495. disableRange = _ref.disableRange;
  2496. (0, _util.assert)(rangeChunkSize > 0);
  2497. var returnValues = {
  2498. allowRangeRequests: false,
  2499. suggestedLength: undefined
  2500. };
  2501. if (disableRange || !isHttp) {
  2502. return returnValues;
  2503. }
  2504. if (getResponseHeader('Accept-Ranges') !== 'bytes') {
  2505. return returnValues;
  2506. }
  2507. var contentEncoding = getResponseHeader('Content-Encoding') || 'identity';
  2508. if (contentEncoding !== 'identity') {
  2509. return returnValues;
  2510. }
  2511. var length = parseInt(getResponseHeader('Content-Length'), 10);
  2512. if (!Number.isInteger(length)) {
  2513. return returnValues;
  2514. }
  2515. returnValues.suggestedLength = length;
  2516. if (length <= 2 * rangeChunkSize) {
  2517. return returnValues;
  2518. }
  2519. returnValues.allowRangeRequests = true;
  2520. return returnValues;
  2521. }
  2522. function createResponseStatusError(status, url) {
  2523. if (status === 404 || status === 0 && /^file:/.test(url)) {
  2524. return new _util.MissingPDFException('Missing PDF "' + url + '".');
  2525. }
  2526. return new _util.UnexpectedResponseException('Unexpected server response (' + status + ') while retrieving PDF "' + url + '".', status);
  2527. }
  2528. function validateResponseStatus(status) {
  2529. return status === 200 || status === 206;
  2530. }
  2531. exports.createResponseStatusError = createResponseStatusError;
  2532. exports.validateRangeRequestCapabilities = validateRangeRequestCapabilities;
  2533. exports.validateResponseStatus = validateResponseStatus;
  2534. /***/ }),
  2535. /* 45 */
  2536. /***/ (function(module, exports, __w_pdfjs_require__) {
  2537. "use strict";
  2538. module.exports = !__w_pdfjs_require__(9) && !__w_pdfjs_require__(10)(function () {
  2539. return Object.defineProperty(__w_pdfjs_require__(32)('div'), 'a', {
  2540. get: function get() {
  2541. return 7;
  2542. }
  2543. }).a != 7;
  2544. });
  2545. /***/ }),
  2546. /* 46 */
  2547. /***/ (function(module, exports, __w_pdfjs_require__) {
  2548. "use strict";
  2549. var global = __w_pdfjs_require__(1);
  2550. var hide = __w_pdfjs_require__(6);
  2551. var uid = __w_pdfjs_require__(16);
  2552. var TYPED = uid('typed_array');
  2553. var VIEW = uid('view');
  2554. var ABV = !!(global.ArrayBuffer && global.DataView);
  2555. var CONSTR = ABV;
  2556. var i = 0;
  2557. var l = 9;
  2558. var Typed;
  2559. var TypedArrayConstructors = 'Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array'.split(',');
  2560. while (i < l) {
  2561. if (Typed = global[TypedArrayConstructors[i++]]) {
  2562. hide(Typed.prototype, TYPED, true);
  2563. hide(Typed.prototype, VIEW, true);
  2564. } else CONSTR = false;
  2565. }
  2566. module.exports = {
  2567. ABV: ABV,
  2568. CONSTR: CONSTR,
  2569. TYPED: TYPED,
  2570. VIEW: VIEW
  2571. };
  2572. /***/ }),
  2573. /* 47 */
  2574. /***/ (function(module, exports, __w_pdfjs_require__) {
  2575. "use strict";
  2576. var toInteger = __w_pdfjs_require__(17);
  2577. var toLength = __w_pdfjs_require__(12);
  2578. module.exports = function (it) {
  2579. if (it === undefined) return 0;
  2580. var number = toInteger(it);
  2581. var length = toLength(number);
  2582. if (number !== length) throw RangeError('Wrong length!');
  2583. return length;
  2584. };
  2585. /***/ }),
  2586. /* 48 */
  2587. /***/ (function(module, exports, __w_pdfjs_require__) {
  2588. "use strict";
  2589. var $keys = __w_pdfjs_require__(49);
  2590. var hiddenKeys = __w_pdfjs_require__(37).concat('length', 'prototype');
  2591. exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  2592. return $keys(O, hiddenKeys);
  2593. };
  2594. /***/ }),
  2595. /* 49 */
  2596. /***/ (function(module, exports, __w_pdfjs_require__) {
  2597. "use strict";
  2598. var has = __w_pdfjs_require__(8);
  2599. var toIObject = __w_pdfjs_require__(28);
  2600. var arrayIndexOf = __w_pdfjs_require__(50)(false);
  2601. var IE_PROTO = __w_pdfjs_require__(36)('IE_PROTO');
  2602. module.exports = function (object, names) {
  2603. var O = toIObject(object);
  2604. var i = 0;
  2605. var result = [];
  2606. var key;
  2607. for (key in O) {
  2608. if (key != IE_PROTO) has(O, key) && result.push(key);
  2609. }while (names.length > i) {
  2610. if (has(O, key = names[i++])) {
  2611. ~arrayIndexOf(result, key) || result.push(key);
  2612. }
  2613. }return result;
  2614. };
  2615. /***/ }),
  2616. /* 50 */
  2617. /***/ (function(module, exports, __w_pdfjs_require__) {
  2618. "use strict";
  2619. var toIObject = __w_pdfjs_require__(28);
  2620. var toLength = __w_pdfjs_require__(12);
  2621. var toAbsoluteIndex = __w_pdfjs_require__(29);
  2622. module.exports = function (IS_INCLUDES) {
  2623. return function ($this, el, fromIndex) {
  2624. var O = toIObject($this);
  2625. var length = toLength(O.length);
  2626. var index = toAbsoluteIndex(fromIndex, length);
  2627. var value;
  2628. if (IS_INCLUDES && el != el) while (length > index) {
  2629. value = O[index++];
  2630. if (value != value) return true;
  2631. } else for (; length > index; index++) {
  2632. if (IS_INCLUDES || index in O) {
  2633. if (O[index] === el) return IS_INCLUDES || index || 0;
  2634. }
  2635. }return !IS_INCLUDES && -1;
  2636. };
  2637. };
  2638. /***/ }),
  2639. /* 51 */
  2640. /***/ (function(module, exports, __w_pdfjs_require__) {
  2641. "use strict";
  2642. var global = __w_pdfjs_require__(1);
  2643. var SHARED = '__core-js_shared__';
  2644. var store = global[SHARED] || (global[SHARED] = {});
  2645. module.exports = function (key) {
  2646. return store[key] || (store[key] = {});
  2647. };
  2648. /***/ }),
  2649. /* 52 */
  2650. /***/ (function(module, exports, __w_pdfjs_require__) {
  2651. "use strict";
  2652. var toObject = __w_pdfjs_require__(18);
  2653. var toAbsoluteIndex = __w_pdfjs_require__(29);
  2654. var toLength = __w_pdfjs_require__(12);
  2655. module.exports = function fill(value) {
  2656. var O = toObject(this);
  2657. var length = toLength(O.length);
  2658. var aLen = arguments.length;
  2659. var index = toAbsoluteIndex(aLen > 1 ? arguments[1] : undefined, length);
  2660. var end = aLen > 2 ? arguments[2] : undefined;
  2661. var endPos = end === undefined ? length : toAbsoluteIndex(end, length);
  2662. while (endPos > index) {
  2663. O[index++] = value;
  2664. }return O;
  2665. };
  2666. /***/ }),
  2667. /* 53 */
  2668. /***/ (function(module, exports, __w_pdfjs_require__) {
  2669. "use strict";
  2670. var Iterators = __w_pdfjs_require__(19);
  2671. var ITERATOR = __w_pdfjs_require__(3)('iterator');
  2672. var ArrayProto = Array.prototype;
  2673. module.exports = function (it) {
  2674. return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it);
  2675. };
  2676. /***/ }),
  2677. /* 54 */
  2678. /***/ (function(module, exports, __w_pdfjs_require__) {
  2679. "use strict";
  2680. var anObject = __w_pdfjs_require__(7);
  2681. var dPs = __w_pdfjs_require__(81);
  2682. var enumBugKeys = __w_pdfjs_require__(37);
  2683. var IE_PROTO = __w_pdfjs_require__(36)('IE_PROTO');
  2684. var Empty = function Empty() {};
  2685. var PROTOTYPE = 'prototype';
  2686. var _createDict = function createDict() {
  2687. var iframe = __w_pdfjs_require__(32)('iframe');
  2688. var i = enumBugKeys.length;
  2689. var lt = '<';
  2690. var gt = '>';
  2691. var iframeDocument;
  2692. iframe.style.display = 'none';
  2693. __w_pdfjs_require__(55).appendChild(iframe);
  2694. iframe.src = 'javascript:';
  2695. iframeDocument = iframe.contentWindow.document;
  2696. iframeDocument.open();
  2697. iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
  2698. iframeDocument.close();
  2699. _createDict = iframeDocument.F;
  2700. while (i--) {
  2701. delete _createDict[PROTOTYPE][enumBugKeys[i]];
  2702. }return _createDict();
  2703. };
  2704. module.exports = Object.create || function create(O, Properties) {
  2705. var result;
  2706. if (O !== null) {
  2707. Empty[PROTOTYPE] = anObject(O);
  2708. result = new Empty();
  2709. Empty[PROTOTYPE] = null;
  2710. result[IE_PROTO] = O;
  2711. } else result = _createDict();
  2712. return Properties === undefined ? result : dPs(result, Properties);
  2713. };
  2714. /***/ }),
  2715. /* 55 */
  2716. /***/ (function(module, exports, __w_pdfjs_require__) {
  2717. "use strict";
  2718. var document = __w_pdfjs_require__(1).document;
  2719. module.exports = document && document.documentElement;
  2720. /***/ }),
  2721. /* 56 */
  2722. /***/ (function(module, exports, __w_pdfjs_require__) {
  2723. "use strict";
  2724. var has = __w_pdfjs_require__(8);
  2725. var toObject = __w_pdfjs_require__(18);
  2726. var IE_PROTO = __w_pdfjs_require__(36)('IE_PROTO');
  2727. var ObjectProto = Object.prototype;
  2728. module.exports = Object.getPrototypeOf || function (O) {
  2729. O = toObject(O);
  2730. if (has(O, IE_PROTO)) return O[IE_PROTO];
  2731. if (typeof O.constructor == 'function' && O instanceof O.constructor) {
  2732. return O.constructor.prototype;
  2733. }
  2734. return O instanceof Object ? ObjectProto : null;
  2735. };
  2736. /***/ }),
  2737. /* 57 */
  2738. /***/ (function(module, exports, __w_pdfjs_require__) {
  2739. "use strict";
  2740. var classof = __w_pdfjs_require__(30);
  2741. var ITERATOR = __w_pdfjs_require__(3)('iterator');
  2742. var Iterators = __w_pdfjs_require__(19);
  2743. module.exports = __w_pdfjs_require__(5).getIteratorMethod = function (it) {
  2744. if (it != undefined) return it[ITERATOR] || it['@@iterator'] || Iterators[classof(it)];
  2745. };
  2746. /***/ }),
  2747. /* 58 */
  2748. /***/ (function(module, exports, __w_pdfjs_require__) {
  2749. "use strict";
  2750. var addToUnscopables = __w_pdfjs_require__(85);
  2751. var step = __w_pdfjs_require__(86);
  2752. var Iterators = __w_pdfjs_require__(19);
  2753. var toIObject = __w_pdfjs_require__(28);
  2754. module.exports = __w_pdfjs_require__(59)(Array, 'Array', function (iterated, kind) {
  2755. this._t = toIObject(iterated);
  2756. this._i = 0;
  2757. this._k = kind;
  2758. }, function () {
  2759. var O = this._t;
  2760. var kind = this._k;
  2761. var index = this._i++;
  2762. if (!O || index >= O.length) {
  2763. this._t = undefined;
  2764. return step(1);
  2765. }
  2766. if (kind == 'keys') return step(0, index);
  2767. if (kind == 'values') return step(0, O[index]);
  2768. return step(0, [index, O[index]]);
  2769. }, 'values');
  2770. Iterators.Arguments = Iterators.Array;
  2771. addToUnscopables('keys');
  2772. addToUnscopables('values');
  2773. addToUnscopables('entries');
  2774. /***/ }),
  2775. /* 59 */
  2776. /***/ (function(module, exports, __w_pdfjs_require__) {
  2777. "use strict";
  2778. var LIBRARY = __w_pdfjs_require__(26);
  2779. var $export = __w_pdfjs_require__(4);
  2780. var redefine = __w_pdfjs_require__(15);
  2781. var hide = __w_pdfjs_require__(6);
  2782. var has = __w_pdfjs_require__(8);
  2783. var Iterators = __w_pdfjs_require__(19);
  2784. var $iterCreate = __w_pdfjs_require__(87);
  2785. var setToStringTag = __w_pdfjs_require__(25);
  2786. var getPrototypeOf = __w_pdfjs_require__(56);
  2787. var ITERATOR = __w_pdfjs_require__(3)('iterator');
  2788. var BUGGY = !([].keys && 'next' in [].keys());
  2789. var FF_ITERATOR = '@@iterator';
  2790. var KEYS = 'keys';
  2791. var VALUES = 'values';
  2792. var returnThis = function returnThis() {
  2793. return this;
  2794. };
  2795. module.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
  2796. $iterCreate(Constructor, NAME, next);
  2797. var getMethod = function getMethod(kind) {
  2798. if (!BUGGY && kind in proto) return proto[kind];
  2799. switch (kind) {
  2800. case KEYS:
  2801. return function keys() {
  2802. return new Constructor(this, kind);
  2803. };
  2804. case VALUES:
  2805. return function values() {
  2806. return new Constructor(this, kind);
  2807. };
  2808. }
  2809. return function entries() {
  2810. return new Constructor(this, kind);
  2811. };
  2812. };
  2813. var TAG = NAME + ' Iterator';
  2814. var DEF_VALUES = DEFAULT == VALUES;
  2815. var VALUES_BUG = false;
  2816. var proto = Base.prototype;
  2817. var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
  2818. var $default = $native || getMethod(DEFAULT);
  2819. var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
  2820. var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
  2821. var methods, key, IteratorPrototype;
  2822. if ($anyNative) {
  2823. IteratorPrototype = getPrototypeOf($anyNative.call(new Base()));
  2824. if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
  2825. setToStringTag(IteratorPrototype, TAG, true);
  2826. if (!LIBRARY && !has(IteratorPrototype, ITERATOR)) hide(IteratorPrototype, ITERATOR, returnThis);
  2827. }
  2828. }
  2829. if (DEF_VALUES && $native && $native.name !== VALUES) {
  2830. VALUES_BUG = true;
  2831. $default = function values() {
  2832. return $native.call(this);
  2833. };
  2834. }
  2835. if ((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {
  2836. hide(proto, ITERATOR, $default);
  2837. }
  2838. Iterators[NAME] = $default;
  2839. Iterators[TAG] = returnThis;
  2840. if (DEFAULT) {
  2841. methods = {
  2842. values: DEF_VALUES ? $default : getMethod(VALUES),
  2843. keys: IS_SET ? $default : getMethod(KEYS),
  2844. entries: $entries
  2845. };
  2846. if (FORCED) for (key in methods) {
  2847. if (!(key in proto)) redefine(proto, key, methods[key]);
  2848. } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);
  2849. }
  2850. return methods;
  2851. };
  2852. /***/ }),
  2853. /* 60 */
  2854. /***/ (function(module, exports, __w_pdfjs_require__) {
  2855. "use strict";
  2856. var global = __w_pdfjs_require__(1);
  2857. var dP = __w_pdfjs_require__(14);
  2858. var DESCRIPTORS = __w_pdfjs_require__(9);
  2859. var SPECIES = __w_pdfjs_require__(3)('species');
  2860. module.exports = function (KEY) {
  2861. var C = global[KEY];
  2862. if (DESCRIPTORS && C && !C[SPECIES]) dP.f(C, SPECIES, {
  2863. configurable: true,
  2864. get: function get() {
  2865. return this;
  2866. }
  2867. });
  2868. };
  2869. /***/ }),
  2870. /* 61 */
  2871. /***/ (function(module, exports, __w_pdfjs_require__) {
  2872. "use strict";
  2873. var pIE = __w_pdfjs_require__(62);
  2874. var createDesc = __w_pdfjs_require__(27);
  2875. var toIObject = __w_pdfjs_require__(28);
  2876. var toPrimitive = __w_pdfjs_require__(33);
  2877. var has = __w_pdfjs_require__(8);
  2878. var IE8_DOM_DEFINE = __w_pdfjs_require__(45);
  2879. var gOPD = Object.getOwnPropertyDescriptor;
  2880. exports.f = __w_pdfjs_require__(9) ? gOPD : function getOwnPropertyDescriptor(O, P) {
  2881. O = toIObject(O);
  2882. P = toPrimitive(P, true);
  2883. if (IE8_DOM_DEFINE) try {
  2884. return gOPD(O, P);
  2885. } catch (e) {}
  2886. if (has(O, P)) return createDesc(!pIE.f.call(O, P), O[P]);
  2887. };
  2888. /***/ }),
  2889. /* 62 */
  2890. /***/ (function(module, exports, __w_pdfjs_require__) {
  2891. "use strict";
  2892. exports.f = {}.propertyIsEnumerable;
  2893. /***/ }),
  2894. /* 63 */
  2895. /***/ (function(module, exports, __w_pdfjs_require__) {
  2896. "use strict";
  2897. var classof = __w_pdfjs_require__(30);
  2898. var test = {};
  2899. test[__w_pdfjs_require__(3)('toStringTag')] = 'z';
  2900. if (test + '' != '[object z]') {
  2901. __w_pdfjs_require__(15)(Object.prototype, 'toString', function toString() {
  2902. return '[object ' + classof(this) + ']';
  2903. }, true);
  2904. }
  2905. /***/ }),
  2906. /* 64 */
  2907. /***/ (function(module, exports, __w_pdfjs_require__) {
  2908. "use strict";
  2909. var $iterators = __w_pdfjs_require__(58);
  2910. var getKeys = __w_pdfjs_require__(38);
  2911. var redefine = __w_pdfjs_require__(15);
  2912. var global = __w_pdfjs_require__(1);
  2913. var hide = __w_pdfjs_require__(6);
  2914. var Iterators = __w_pdfjs_require__(19);
  2915. var wks = __w_pdfjs_require__(3);
  2916. var ITERATOR = wks('iterator');
  2917. var TO_STRING_TAG = wks('toStringTag');
  2918. var ArrayValues = Iterators.Array;
  2919. var DOMIterables = {
  2920. CSSRuleList: true,
  2921. CSSStyleDeclaration: false,
  2922. CSSValueList: false,
  2923. ClientRectList: false,
  2924. DOMRectList: false,
  2925. DOMStringList: false,
  2926. DOMTokenList: true,
  2927. DataTransferItemList: false,
  2928. FileList: false,
  2929. HTMLAllCollection: false,
  2930. HTMLCollection: false,
  2931. HTMLFormElement: false,
  2932. HTMLSelectElement: false,
  2933. MediaList: true,
  2934. MimeTypeArray: false,
  2935. NamedNodeMap: false,
  2936. NodeList: true,
  2937. PaintRequestList: false,
  2938. Plugin: false,
  2939. PluginArray: false,
  2940. SVGLengthList: false,
  2941. SVGNumberList: false,
  2942. SVGPathSegList: false,
  2943. SVGPointList: false,
  2944. SVGStringList: false,
  2945. SVGTransformList: false,
  2946. SourceBufferList: false,
  2947. StyleSheetList: true,
  2948. TextTrackCueList: false,
  2949. TextTrackList: false,
  2950. TouchList: false
  2951. };
  2952. for (var collections = getKeys(DOMIterables), i = 0; i < collections.length; i++) {
  2953. var NAME = collections[i];
  2954. var explicit = DOMIterables[NAME];
  2955. var Collection = global[NAME];
  2956. var proto = Collection && Collection.prototype;
  2957. var key;
  2958. if (proto) {
  2959. if (!proto[ITERATOR]) hide(proto, ITERATOR, ArrayValues);
  2960. if (!proto[TO_STRING_TAG]) hide(proto, TO_STRING_TAG, NAME);
  2961. Iterators[NAME] = ArrayValues;
  2962. if (explicit) for (key in $iterators) {
  2963. if (!proto[key]) redefine(proto, key, $iterators[key], true);
  2964. }
  2965. }
  2966. }
  2967. /***/ }),
  2968. /* 65 */
  2969. /***/ (function(module, exports, __w_pdfjs_require__) {
  2970. "use strict";
  2971. var ctx = __w_pdfjs_require__(11);
  2972. var invoke = __w_pdfjs_require__(99);
  2973. var html = __w_pdfjs_require__(55);
  2974. var cel = __w_pdfjs_require__(32);
  2975. var global = __w_pdfjs_require__(1);
  2976. var process = global.process;
  2977. var setTask = global.setImmediate;
  2978. var clearTask = global.clearImmediate;
  2979. var MessageChannel = global.MessageChannel;
  2980. var Dispatch = global.Dispatch;
  2981. var counter = 0;
  2982. var queue = {};
  2983. var ONREADYSTATECHANGE = 'onreadystatechange';
  2984. var defer, channel, port;
  2985. var run = function run() {
  2986. var id = +this;
  2987. if (queue.hasOwnProperty(id)) {
  2988. var fn = queue[id];
  2989. delete queue[id];
  2990. fn();
  2991. }
  2992. };
  2993. var listener = function listener(event) {
  2994. run.call(event.data);
  2995. };
  2996. if (!setTask || !clearTask) {
  2997. setTask = function setImmediate(fn) {
  2998. var args = [];
  2999. var i = 1;
  3000. while (arguments.length > i) {
  3001. args.push(arguments[i++]);
  3002. }queue[++counter] = function () {
  3003. invoke(typeof fn == 'function' ? fn : Function(fn), args);
  3004. };
  3005. defer(counter);
  3006. return counter;
  3007. };
  3008. clearTask = function clearImmediate(id) {
  3009. delete queue[id];
  3010. };
  3011. if (__w_pdfjs_require__(24)(process) == 'process') {
  3012. defer = function defer(id) {
  3013. process.nextTick(ctx(run, id, 1));
  3014. };
  3015. } else if (Dispatch && Dispatch.now) {
  3016. defer = function defer(id) {
  3017. Dispatch.now(ctx(run, id, 1));
  3018. };
  3019. } else if (MessageChannel) {
  3020. channel = new MessageChannel();
  3021. port = channel.port2;
  3022. channel.port1.onmessage = listener;
  3023. defer = ctx(port.postMessage, port, 1);
  3024. } else if (global.addEventListener && typeof postMessage == 'function' && !global.importScripts) {
  3025. defer = function defer(id) {
  3026. global.postMessage(id + '', '*');
  3027. };
  3028. global.addEventListener('message', listener, false);
  3029. } else if (ONREADYSTATECHANGE in cel('script')) {
  3030. defer = function defer(id) {
  3031. html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function () {
  3032. html.removeChild(this);
  3033. run.call(id);
  3034. };
  3035. };
  3036. } else {
  3037. defer = function defer(id) {
  3038. setTimeout(ctx(run, id, 1), 0);
  3039. };
  3040. }
  3041. }
  3042. module.exports = {
  3043. set: setTask,
  3044. clear: clearTask
  3045. };
  3046. /***/ }),
  3047. /* 66 */
  3048. /***/ (function(module, exports, __w_pdfjs_require__) {
  3049. "use strict";
  3050. module.exports = function (exec) {
  3051. try {
  3052. return {
  3053. e: false,
  3054. v: exec()
  3055. };
  3056. } catch (e) {
  3057. return {
  3058. e: true,
  3059. v: e
  3060. };
  3061. }
  3062. };
  3063. /***/ }),
  3064. /* 67 */
  3065. /***/ (function(module, exports, __w_pdfjs_require__) {
  3066. "use strict";
  3067. var anObject = __w_pdfjs_require__(7);
  3068. var isObject = __w_pdfjs_require__(2);
  3069. var newPromiseCapability = __w_pdfjs_require__(42);
  3070. module.exports = function (C, x) {
  3071. anObject(C);
  3072. if (isObject(x) && x.constructor === C) return x;
  3073. var promiseCapability = newPromiseCapability.f(C);
  3074. var resolve = promiseCapability.resolve;
  3075. resolve(x);
  3076. return promiseCapability.promise;
  3077. };
  3078. /***/ }),
  3079. /* 68 */
  3080. /***/ (function(module, exports, __w_pdfjs_require__) {
  3081. "use strict";
  3082. var isObject = __w_pdfjs_require__(2);
  3083. module.exports = function (it, TYPE) {
  3084. if (!isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!');
  3085. return it;
  3086. };
  3087. /***/ }),
  3088. /* 69 */
  3089. /***/ (function(module, exports, __w_pdfjs_require__) {
  3090. "use strict";
  3091. Object.defineProperty(exports, "__esModule", {
  3092. value: true
  3093. });
  3094. exports.build = exports.version = exports._UnsupportedManager = exports.setPDFNetworkStreamClass = exports.PDFPageProxy = exports.PDFDocumentProxy = exports.PDFWorker = exports.PDFDataRangeTransport = exports.LoopbackPort = exports.getDocument = undefined;
  3095. 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; }; }();
  3096. 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; };
  3097. var _util = __w_pdfjs_require__(0);
  3098. var _dom_utils = __w_pdfjs_require__(13);
  3099. var _font_loader = __w_pdfjs_require__(118);
  3100. var _canvas = __w_pdfjs_require__(119);
  3101. var _global_scope = __w_pdfjs_require__(20);
  3102. var _global_scope2 = _interopRequireDefault(_global_scope);
  3103. var _metadata = __w_pdfjs_require__(71);
  3104. var _transport_stream = __w_pdfjs_require__(121);
  3105. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3106. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3107. var DEFAULT_RANGE_CHUNK_SIZE = 65536;
  3108. var isWorkerDisabled = false;
  3109. var workerSrc;
  3110. var isPostMessageTransfersDisabled = false;
  3111. var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
  3112. var fakeWorkerFilesLoader = null;
  3113. var useRequireEnsure = false;
  3114. {
  3115. if (typeof window === 'undefined') {
  3116. isWorkerDisabled = true;
  3117. if (typeof require.ensure === 'undefined') {
  3118. require.ensure = require('node-ensure');
  3119. }
  3120. useRequireEnsure = true;
  3121. } else if (typeof require !== 'undefined' && typeof require.ensure === 'function') {
  3122. useRequireEnsure = true;
  3123. }
  3124. if (typeof requirejs !== 'undefined' && requirejs.toUrl) {
  3125. workerSrc = requirejs.toUrl('pdfjs-dist/build/pdf.worker.js');
  3126. }
  3127. var dynamicLoaderSupported = typeof requirejs !== 'undefined' && requirejs.load;
  3128. fakeWorkerFilesLoader = useRequireEnsure ? function (callback) {
  3129. require.ensure([], function () {
  3130. var worker;
  3131. worker = require('./pdf.worker.js');
  3132. callback(worker.WorkerMessageHandler);
  3133. });
  3134. } : dynamicLoaderSupported ? function (callback) {
  3135. requirejs(['pdfjs-dist/build/pdf.worker'], function (worker) {
  3136. callback(worker.WorkerMessageHandler);
  3137. });
  3138. } : null;
  3139. }
  3140. var PDFNetworkStream;
  3141. function setPDFNetworkStreamClass(cls) {
  3142. PDFNetworkStream = cls;
  3143. }
  3144. function getDocument(src, pdfDataRangeTransport, passwordCallback, progressCallback) {
  3145. var task = new PDFDocumentLoadingTask();
  3146. if (arguments.length > 1) {
  3147. (0, _util.deprecated)('getDocument is called with pdfDataRangeTransport, ' + 'passwordCallback or progressCallback argument');
  3148. }
  3149. if (pdfDataRangeTransport) {
  3150. if (!(pdfDataRangeTransport instanceof PDFDataRangeTransport)) {
  3151. pdfDataRangeTransport = Object.create(pdfDataRangeTransport);
  3152. pdfDataRangeTransport.length = src.length;
  3153. pdfDataRangeTransport.initialData = src.initialData;
  3154. if (!pdfDataRangeTransport.abort) {
  3155. pdfDataRangeTransport.abort = function () {};
  3156. }
  3157. }
  3158. src = Object.create(src);
  3159. src.range = pdfDataRangeTransport;
  3160. }
  3161. task.onPassword = passwordCallback || null;
  3162. task.onProgress = progressCallback || null;
  3163. var source;
  3164. if (typeof src === 'string') {
  3165. source = { url: src };
  3166. } else if ((0, _util.isArrayBuffer)(src)) {
  3167. source = { data: src };
  3168. } else if (src instanceof PDFDataRangeTransport) {
  3169. source = { range: src };
  3170. } else {
  3171. if ((typeof src === 'undefined' ? 'undefined' : _typeof(src)) !== 'object') {
  3172. throw new Error('Invalid parameter in getDocument, ' + 'need either Uint8Array, string or a parameter object');
  3173. }
  3174. if (!src.url && !src.data && !src.range) {
  3175. throw new Error('Invalid parameter object: need either .data, .range or .url');
  3176. }
  3177. source = src;
  3178. }
  3179. var params = {};
  3180. var rangeTransport = null;
  3181. var worker = null;
  3182. var CMapReaderFactory = _dom_utils.DOMCMapReaderFactory;
  3183. for (var key in source) {
  3184. if (key === 'url' && typeof window !== 'undefined') {
  3185. params[key] = new URL(source[key], window.location).href;
  3186. continue;
  3187. } else if (key === 'range') {
  3188. rangeTransport = source[key];
  3189. continue;
  3190. } else if (key === 'worker') {
  3191. worker = source[key];
  3192. continue;
  3193. } else if (key === 'data' && !(source[key] instanceof Uint8Array)) {
  3194. var pdfBytes = source[key];
  3195. if (typeof pdfBytes === 'string') {
  3196. params[key] = (0, _util.stringToBytes)(pdfBytes);
  3197. } else if ((typeof pdfBytes === 'undefined' ? 'undefined' : _typeof(pdfBytes)) === 'object' && pdfBytes !== null && !isNaN(pdfBytes.length)) {
  3198. params[key] = new Uint8Array(pdfBytes);
  3199. } else if ((0, _util.isArrayBuffer)(pdfBytes)) {
  3200. params[key] = new Uint8Array(pdfBytes);
  3201. } else {
  3202. throw new Error('Invalid PDF binary data: either typed array, ' + 'string or array-like object is expected in the ' + 'data property.');
  3203. }
  3204. continue;
  3205. } else if (key === 'CMapReaderFactory') {
  3206. CMapReaderFactory = source[key];
  3207. continue;
  3208. }
  3209. params[key] = source[key];
  3210. }
  3211. params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
  3212. params.ignoreErrors = params.stopAtErrors !== true;
  3213. if (params.disableNativeImageDecoder !== undefined) {
  3214. (0, _util.deprecated)('parameter disableNativeImageDecoder, ' + 'use nativeImageDecoderSupport instead');
  3215. }
  3216. params.nativeImageDecoderSupport = params.nativeImageDecoderSupport || (params.disableNativeImageDecoder === true ? _util.NativeImageDecoding.NONE : _util.NativeImageDecoding.DECODE);
  3217. if (params.nativeImageDecoderSupport !== _util.NativeImageDecoding.DECODE && params.nativeImageDecoderSupport !== _util.NativeImageDecoding.NONE && params.nativeImageDecoderSupport !== _util.NativeImageDecoding.DISPLAY) {
  3218. (0, _util.warn)('Invalid parameter nativeImageDecoderSupport: ' + 'need a state of enum {NativeImageDecoding}');
  3219. params.nativeImageDecoderSupport = _util.NativeImageDecoding.DECODE;
  3220. }
  3221. if (!worker) {
  3222. var workerPort = (0, _dom_utils.getDefaultSetting)('workerPort');
  3223. worker = workerPort ? PDFWorker.fromPort(workerPort) : new PDFWorker();
  3224. task._worker = worker;
  3225. }
  3226. var docId = task.docId;
  3227. worker.promise.then(function () {
  3228. if (task.destroyed) {
  3229. throw new Error('Loading aborted');
  3230. }
  3231. return _fetchDocument(worker, params, rangeTransport, docId).then(function (workerId) {
  3232. if (task.destroyed) {
  3233. throw new Error('Loading aborted');
  3234. }
  3235. var networkStream = void 0;
  3236. if (rangeTransport) {
  3237. networkStream = new _transport_stream.PDFDataTransportStream(params, rangeTransport);
  3238. } else if (!params.data) {
  3239. networkStream = new PDFNetworkStream({
  3240. source: params,
  3241. disableRange: (0, _dom_utils.getDefaultSetting)('disableRange')
  3242. });
  3243. }
  3244. var messageHandler = new _util.MessageHandler(docId, workerId, worker.port);
  3245. messageHandler.postMessageTransfers = worker.postMessageTransfers;
  3246. var transport = new WorkerTransport(messageHandler, task, networkStream, CMapReaderFactory);
  3247. task._transport = transport;
  3248. messageHandler.send('Ready', null);
  3249. });
  3250. }).catch(task._capability.reject);
  3251. return task;
  3252. }
  3253. function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
  3254. if (worker.destroyed) {
  3255. return Promise.reject(new Error('Worker was destroyed'));
  3256. }
  3257. var apiVersion = '1.10.88';
  3258. source.disableAutoFetch = (0, _dom_utils.getDefaultSetting)('disableAutoFetch');
  3259. source.disableStream = (0, _dom_utils.getDefaultSetting)('disableStream');
  3260. source.chunkedViewerLoading = !!pdfDataRangeTransport;
  3261. if (pdfDataRangeTransport) {
  3262. source.length = pdfDataRangeTransport.length;
  3263. source.initialData = pdfDataRangeTransport.initialData;
  3264. }
  3265. return worker.messageHandler.sendWithPromise('GetDocRequest', {
  3266. docId: docId,
  3267. apiVersion: apiVersion,
  3268. source: {
  3269. data: source.data,
  3270. url: source.url,
  3271. password: source.password,
  3272. disableAutoFetch: source.disableAutoFetch,
  3273. rangeChunkSize: source.rangeChunkSize,
  3274. length: source.length
  3275. },
  3276. maxImageSize: (0, _dom_utils.getDefaultSetting)('maxImageSize'),
  3277. disableFontFace: (0, _dom_utils.getDefaultSetting)('disableFontFace'),
  3278. disableCreateObjectURL: (0, _dom_utils.getDefaultSetting)('disableCreateObjectURL'),
  3279. postMessageTransfers: (0, _dom_utils.getDefaultSetting)('postMessageTransfers') && !isPostMessageTransfersDisabled,
  3280. docBaseUrl: source.docBaseUrl,
  3281. nativeImageDecoderSupport: source.nativeImageDecoderSupport,
  3282. ignoreErrors: source.ignoreErrors,
  3283. isEvalSupported: (0, _dom_utils.getDefaultSetting)('isEvalSupported')
  3284. }).then(function (workerId) {
  3285. if (worker.destroyed) {
  3286. throw new Error('Worker was destroyed');
  3287. }
  3288. return workerId;
  3289. });
  3290. }
  3291. var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() {
  3292. var nextDocumentId = 0;
  3293. function PDFDocumentLoadingTask() {
  3294. this._capability = (0, _util.createPromiseCapability)();
  3295. this._transport = null;
  3296. this._worker = null;
  3297. this.docId = 'd' + nextDocumentId++;
  3298. this.destroyed = false;
  3299. this.onPassword = null;
  3300. this.onProgress = null;
  3301. this.onUnsupportedFeature = null;
  3302. }
  3303. PDFDocumentLoadingTask.prototype = {
  3304. get promise() {
  3305. return this._capability.promise;
  3306. },
  3307. destroy: function destroy() {
  3308. var _this = this;
  3309. this.destroyed = true;
  3310. var transportDestroyed = !this._transport ? Promise.resolve() : this._transport.destroy();
  3311. return transportDestroyed.then(function () {
  3312. _this._transport = null;
  3313. if (_this._worker) {
  3314. _this._worker.destroy();
  3315. _this._worker = null;
  3316. }
  3317. });
  3318. },
  3319. then: function PDFDocumentLoadingTask_then(onFulfilled, onRejected) {
  3320. return this.promise.then.apply(this.promise, arguments);
  3321. }
  3322. };
  3323. return PDFDocumentLoadingTask;
  3324. }();
  3325. var PDFDataRangeTransport = function pdfDataRangeTransportClosure() {
  3326. function PDFDataRangeTransport(length, initialData) {
  3327. this.length = length;
  3328. this.initialData = initialData;
  3329. this._rangeListeners = [];
  3330. this._progressListeners = [];
  3331. this._progressiveReadListeners = [];
  3332. this._readyCapability = (0, _util.createPromiseCapability)();
  3333. }
  3334. PDFDataRangeTransport.prototype = {
  3335. addRangeListener: function PDFDataRangeTransport_addRangeListener(listener) {
  3336. this._rangeListeners.push(listener);
  3337. },
  3338. addProgressListener: function PDFDataRangeTransport_addProgressListener(listener) {
  3339. this._progressListeners.push(listener);
  3340. },
  3341. addProgressiveReadListener: function PDFDataRangeTransport_addProgressiveReadListener(listener) {
  3342. this._progressiveReadListeners.push(listener);
  3343. },
  3344. onDataRange: function PDFDataRangeTransport_onDataRange(begin, chunk) {
  3345. var listeners = this._rangeListeners;
  3346. for (var i = 0, n = listeners.length; i < n; ++i) {
  3347. listeners[i](begin, chunk);
  3348. }
  3349. },
  3350. onDataProgress: function PDFDataRangeTransport_onDataProgress(loaded) {
  3351. var _this2 = this;
  3352. this._readyCapability.promise.then(function () {
  3353. var listeners = _this2._progressListeners;
  3354. for (var i = 0, n = listeners.length; i < n; ++i) {
  3355. listeners[i](loaded);
  3356. }
  3357. });
  3358. },
  3359. onDataProgressiveRead: function PDFDataRangeTransport_onDataProgress(chunk) {
  3360. var _this3 = this;
  3361. this._readyCapability.promise.then(function () {
  3362. var listeners = _this3._progressiveReadListeners;
  3363. for (var i = 0, n = listeners.length; i < n; ++i) {
  3364. listeners[i](chunk);
  3365. }
  3366. });
  3367. },
  3368. transportReady: function PDFDataRangeTransport_transportReady() {
  3369. this._readyCapability.resolve();
  3370. },
  3371. requestDataRange: function PDFDataRangeTransport_requestDataRange(begin, end) {
  3372. throw new Error('Abstract method PDFDataRangeTransport.requestDataRange');
  3373. },
  3374. abort: function PDFDataRangeTransport_abort() {}
  3375. };
  3376. return PDFDataRangeTransport;
  3377. }();
  3378. var PDFDocumentProxy = function PDFDocumentProxyClosure() {
  3379. function PDFDocumentProxy(pdfInfo, transport, loadingTask) {
  3380. this.pdfInfo = pdfInfo;
  3381. this.transport = transport;
  3382. this.loadingTask = loadingTask;
  3383. }
  3384. PDFDocumentProxy.prototype = {
  3385. get numPages() {
  3386. return this.pdfInfo.numPages;
  3387. },
  3388. get fingerprint() {
  3389. return this.pdfInfo.fingerprint;
  3390. },
  3391. getPage: function PDFDocumentProxy_getPage(pageNumber) {
  3392. return this.transport.getPage(pageNumber);
  3393. },
  3394. getPageIndex: function PDFDocumentProxy_getPageIndex(ref) {
  3395. return this.transport.getPageIndex(ref);
  3396. },
  3397. getDestinations: function PDFDocumentProxy_getDestinations() {
  3398. return this.transport.getDestinations();
  3399. },
  3400. getDestination: function PDFDocumentProxy_getDestination(id) {
  3401. return this.transport.getDestination(id);
  3402. },
  3403. getPageLabels: function PDFDocumentProxy_getPageLabels() {
  3404. return this.transport.getPageLabels();
  3405. },
  3406. getPageMode: function getPageMode() {
  3407. return this.transport.getPageMode();
  3408. },
  3409. getAttachments: function PDFDocumentProxy_getAttachments() {
  3410. return this.transport.getAttachments();
  3411. },
  3412. getJavaScript: function PDFDocumentProxy_getJavaScript() {
  3413. return this.transport.getJavaScript();
  3414. },
  3415. getOutline: function PDFDocumentProxy_getOutline() {
  3416. return this.transport.getOutline();
  3417. },
  3418. getMetadata: function PDFDocumentProxy_getMetadata() {
  3419. return this.transport.getMetadata();
  3420. },
  3421. getData: function PDFDocumentProxy_getData() {
  3422. return this.transport.getData();
  3423. },
  3424. getDownloadInfo: function PDFDocumentProxy_getDownloadInfo() {
  3425. return this.transport.downloadInfoCapability.promise;
  3426. },
  3427. getStats: function PDFDocumentProxy_getStats() {
  3428. return this.transport.getStats();
  3429. },
  3430. cleanup: function PDFDocumentProxy_cleanup() {
  3431. this.transport.startCleanup();
  3432. },
  3433. destroy: function PDFDocumentProxy_destroy() {
  3434. return this.loadingTask.destroy();
  3435. }
  3436. };
  3437. return PDFDocumentProxy;
  3438. }();
  3439. var PDFPageProxy = function PDFPageProxyClosure() {
  3440. function PDFPageProxy(pageIndex, pageInfo, transport) {
  3441. this.pageIndex = pageIndex;
  3442. this.pageInfo = pageInfo;
  3443. this.transport = transport;
  3444. this.stats = new _util.StatTimer();
  3445. this.stats.enabled = (0, _dom_utils.getDefaultSetting)('enableStats');
  3446. this.commonObjs = transport.commonObjs;
  3447. this.objs = new PDFObjects();
  3448. this.cleanupAfterRender = false;
  3449. this.pendingCleanup = false;
  3450. this.intentStates = Object.create(null);
  3451. this.destroyed = false;
  3452. }
  3453. PDFPageProxy.prototype = {
  3454. get pageNumber() {
  3455. return this.pageIndex + 1;
  3456. },
  3457. get rotate() {
  3458. return this.pageInfo.rotate;
  3459. },
  3460. get ref() {
  3461. return this.pageInfo.ref;
  3462. },
  3463. get userUnit() {
  3464. return this.pageInfo.userUnit;
  3465. },
  3466. get view() {
  3467. return this.pageInfo.view;
  3468. },
  3469. getViewport: function PDFPageProxy_getViewport(scale, rotate) {
  3470. if (arguments.length < 2) {
  3471. rotate = this.rotate;
  3472. }
  3473. return new _util.PageViewport(this.view, scale, rotate, 0, 0);
  3474. },
  3475. getAnnotations: function PDFPageProxy_getAnnotations(params) {
  3476. var intent = params && params.intent || null;
  3477. if (!this.annotationsPromise || this.annotationsIntent !== intent) {
  3478. this.annotationsPromise = this.transport.getAnnotations(this.pageIndex, intent);
  3479. this.annotationsIntent = intent;
  3480. }
  3481. return this.annotationsPromise;
  3482. },
  3483. render: function PDFPageProxy_render(params) {
  3484. var _this4 = this;
  3485. var stats = this.stats;
  3486. stats.time('Overall');
  3487. this.pendingCleanup = false;
  3488. var renderingIntent = params.intent === 'print' ? 'print' : 'display';
  3489. var canvasFactory = params.canvasFactory || new _dom_utils.DOMCanvasFactory();
  3490. if (!this.intentStates[renderingIntent]) {
  3491. this.intentStates[renderingIntent] = Object.create(null);
  3492. }
  3493. var intentState = this.intentStates[renderingIntent];
  3494. if (!intentState.displayReadyCapability) {
  3495. intentState.receivingOperatorList = true;
  3496. intentState.displayReadyCapability = (0, _util.createPromiseCapability)();
  3497. intentState.operatorList = {
  3498. fnArray: [],
  3499. argsArray: [],
  3500. lastChunk: false
  3501. };
  3502. this.stats.time('Page Request');
  3503. this.transport.messageHandler.send('RenderPageRequest', {
  3504. pageIndex: this.pageNumber - 1,
  3505. intent: renderingIntent,
  3506. renderInteractiveForms: params.renderInteractiveForms === true
  3507. });
  3508. }
  3509. var complete = function complete(error) {
  3510. var i = intentState.renderTasks.indexOf(internalRenderTask);
  3511. if (i >= 0) {
  3512. intentState.renderTasks.splice(i, 1);
  3513. }
  3514. if (_this4.cleanupAfterRender) {
  3515. _this4.pendingCleanup = true;
  3516. }
  3517. _this4._tryCleanup();
  3518. if (error) {
  3519. internalRenderTask.capability.reject(error);
  3520. } else {
  3521. internalRenderTask.capability.resolve();
  3522. }
  3523. stats.timeEnd('Rendering');
  3524. stats.timeEnd('Overall');
  3525. };
  3526. var internalRenderTask = new InternalRenderTask(complete, params, this.objs, this.commonObjs, intentState.operatorList, this.pageNumber, canvasFactory);
  3527. internalRenderTask.useRequestAnimationFrame = renderingIntent !== 'print';
  3528. if (!intentState.renderTasks) {
  3529. intentState.renderTasks = [];
  3530. }
  3531. intentState.renderTasks.push(internalRenderTask);
  3532. var renderTask = internalRenderTask.task;
  3533. if (params.continueCallback) {
  3534. (0, _util.deprecated)('render is used with continueCallback parameter');
  3535. renderTask.onContinue = params.continueCallback;
  3536. }
  3537. intentState.displayReadyCapability.promise.then(function (transparency) {
  3538. if (_this4.pendingCleanup) {
  3539. complete();
  3540. return;
  3541. }
  3542. stats.time('Rendering');
  3543. internalRenderTask.initializeGraphics(transparency);
  3544. internalRenderTask.operatorListChanged();
  3545. }).catch(complete);
  3546. return renderTask;
  3547. },
  3548. getOperatorList: function PDFPageProxy_getOperatorList() {
  3549. function operatorListChanged() {
  3550. if (intentState.operatorList.lastChunk) {
  3551. intentState.opListReadCapability.resolve(intentState.operatorList);
  3552. var i = intentState.renderTasks.indexOf(opListTask);
  3553. if (i >= 0) {
  3554. intentState.renderTasks.splice(i, 1);
  3555. }
  3556. }
  3557. }
  3558. var renderingIntent = 'oplist';
  3559. if (!this.intentStates[renderingIntent]) {
  3560. this.intentStates[renderingIntent] = Object.create(null);
  3561. }
  3562. var intentState = this.intentStates[renderingIntent];
  3563. var opListTask;
  3564. if (!intentState.opListReadCapability) {
  3565. opListTask = {};
  3566. opListTask.operatorListChanged = operatorListChanged;
  3567. intentState.receivingOperatorList = true;
  3568. intentState.opListReadCapability = (0, _util.createPromiseCapability)();
  3569. intentState.renderTasks = [];
  3570. intentState.renderTasks.push(opListTask);
  3571. intentState.operatorList = {
  3572. fnArray: [],
  3573. argsArray: [],
  3574. lastChunk: false
  3575. };
  3576. this.transport.messageHandler.send('RenderPageRequest', {
  3577. pageIndex: this.pageIndex,
  3578. intent: renderingIntent
  3579. });
  3580. }
  3581. return intentState.opListReadCapability.promise;
  3582. },
  3583. streamTextContent: function streamTextContent() {
  3584. var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  3585. var TEXT_CONTENT_CHUNK_SIZE = 100;
  3586. return this.transport.messageHandler.sendWithStream('GetTextContent', {
  3587. pageIndex: this.pageNumber - 1,
  3588. normalizeWhitespace: params.normalizeWhitespace === true,
  3589. combineTextItems: params.disableCombineTextItems !== true
  3590. }, {
  3591. highWaterMark: TEXT_CONTENT_CHUNK_SIZE,
  3592. size: function size(textContent) {
  3593. return textContent.items.length;
  3594. }
  3595. });
  3596. },
  3597. getTextContent: function PDFPageProxy_getTextContent(params) {
  3598. params = params || {};
  3599. var readableStream = this.streamTextContent(params);
  3600. return new Promise(function (resolve, reject) {
  3601. function pump() {
  3602. reader.read().then(function (_ref) {
  3603. var value = _ref.value,
  3604. done = _ref.done;
  3605. if (done) {
  3606. resolve(textContent);
  3607. return;
  3608. }
  3609. _util.Util.extendObj(textContent.styles, value.styles);
  3610. _util.Util.appendToArray(textContent.items, value.items);
  3611. pump();
  3612. }, reject);
  3613. }
  3614. var reader = readableStream.getReader();
  3615. var textContent = {
  3616. items: [],
  3617. styles: Object.create(null)
  3618. };
  3619. pump();
  3620. });
  3621. },
  3622. _destroy: function PDFPageProxy_destroy() {
  3623. this.destroyed = true;
  3624. this.transport.pageCache[this.pageIndex] = null;
  3625. var waitOn = [];
  3626. Object.keys(this.intentStates).forEach(function (intent) {
  3627. if (intent === 'oplist') {
  3628. return;
  3629. }
  3630. var intentState = this.intentStates[intent];
  3631. intentState.renderTasks.forEach(function (renderTask) {
  3632. var renderCompleted = renderTask.capability.promise.catch(function () {});
  3633. waitOn.push(renderCompleted);
  3634. renderTask.cancel();
  3635. });
  3636. }, this);
  3637. this.objs.clear();
  3638. this.annotationsPromise = null;
  3639. this.pendingCleanup = false;
  3640. return Promise.all(waitOn);
  3641. },
  3642. destroy: function destroy() {
  3643. (0, _util.deprecated)('page destroy method, use cleanup() instead');
  3644. this.cleanup();
  3645. },
  3646. cleanup: function PDFPageProxy_cleanup() {
  3647. this.pendingCleanup = true;
  3648. this._tryCleanup();
  3649. },
  3650. _tryCleanup: function PDFPageProxy_tryCleanup() {
  3651. if (!this.pendingCleanup || Object.keys(this.intentStates).some(function (intent) {
  3652. var intentState = this.intentStates[intent];
  3653. return intentState.renderTasks.length !== 0 || intentState.receivingOperatorList;
  3654. }, this)) {
  3655. return;
  3656. }
  3657. Object.keys(this.intentStates).forEach(function (intent) {
  3658. delete this.intentStates[intent];
  3659. }, this);
  3660. this.objs.clear();
  3661. this.annotationsPromise = null;
  3662. this.pendingCleanup = false;
  3663. },
  3664. _startRenderPage: function PDFPageProxy_startRenderPage(transparency, intent) {
  3665. var intentState = this.intentStates[intent];
  3666. if (intentState.displayReadyCapability) {
  3667. intentState.displayReadyCapability.resolve(transparency);
  3668. }
  3669. },
  3670. _renderPageChunk: function PDFPageProxy_renderPageChunk(operatorListChunk, intent) {
  3671. var intentState = this.intentStates[intent];
  3672. var i, ii;
  3673. for (i = 0, ii = operatorListChunk.length; i < ii; i++) {
  3674. intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
  3675. intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]);
  3676. }
  3677. intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
  3678. for (i = 0; i < intentState.renderTasks.length; i++) {
  3679. intentState.renderTasks[i].operatorListChanged();
  3680. }
  3681. if (operatorListChunk.lastChunk) {
  3682. intentState.receivingOperatorList = false;
  3683. this._tryCleanup();
  3684. }
  3685. }
  3686. };
  3687. return PDFPageProxy;
  3688. }();
  3689. var LoopbackPort = function () {
  3690. function LoopbackPort(defer) {
  3691. _classCallCheck(this, LoopbackPort);
  3692. this._listeners = [];
  3693. this._defer = defer;
  3694. this._deferred = Promise.resolve(undefined);
  3695. }
  3696. _createClass(LoopbackPort, [{
  3697. key: 'postMessage',
  3698. value: function postMessage(obj, transfers) {
  3699. var _this5 = this;
  3700. function cloneValue(value) {
  3701. if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) !== 'object' || value === null) {
  3702. return value;
  3703. }
  3704. if (cloned.has(value)) {
  3705. return cloned.get(value);
  3706. }
  3707. var result;
  3708. var buffer;
  3709. if ((buffer = value.buffer) && (0, _util.isArrayBuffer)(buffer)) {
  3710. var transferable = transfers && transfers.indexOf(buffer) >= 0;
  3711. if (value === buffer) {
  3712. result = value;
  3713. } else if (transferable) {
  3714. result = new value.constructor(buffer, value.byteOffset, value.byteLength);
  3715. } else {
  3716. result = new value.constructor(value);
  3717. }
  3718. cloned.set(value, result);
  3719. return result;
  3720. }
  3721. result = Array.isArray(value) ? [] : {};
  3722. cloned.set(value, result);
  3723. for (var i in value) {
  3724. var desc,
  3725. p = value;
  3726. while (!(desc = Object.getOwnPropertyDescriptor(p, i))) {
  3727. p = Object.getPrototypeOf(p);
  3728. }
  3729. if (typeof desc.value === 'undefined' || typeof desc.value === 'function') {
  3730. continue;
  3731. }
  3732. result[i] = cloneValue(desc.value);
  3733. }
  3734. return result;
  3735. }
  3736. if (!this._defer) {
  3737. this._listeners.forEach(function (listener) {
  3738. listener.call(this, { data: obj });
  3739. }, this);
  3740. return;
  3741. }
  3742. var cloned = new WeakMap();
  3743. var e = { data: cloneValue(obj) };
  3744. this._deferred.then(function () {
  3745. _this5._listeners.forEach(function (listener) {
  3746. listener.call(this, e);
  3747. }, _this5);
  3748. });
  3749. }
  3750. }, {
  3751. key: 'addEventListener',
  3752. value: function addEventListener(name, listener) {
  3753. this._listeners.push(listener);
  3754. }
  3755. }, {
  3756. key: 'removeEventListener',
  3757. value: function removeEventListener(name, listener) {
  3758. var i = this._listeners.indexOf(listener);
  3759. this._listeners.splice(i, 1);
  3760. }
  3761. }, {
  3762. key: 'terminate',
  3763. value: function terminate() {
  3764. this._listeners = [];
  3765. }
  3766. }]);
  3767. return LoopbackPort;
  3768. }();
  3769. var PDFWorker = function PDFWorkerClosure() {
  3770. var nextFakeWorkerId = 0;
  3771. function getWorkerSrc() {
  3772. if (typeof workerSrc !== 'undefined') {
  3773. return workerSrc;
  3774. }
  3775. if ((0, _dom_utils.getDefaultSetting)('workerSrc')) {
  3776. return (0, _dom_utils.getDefaultSetting)('workerSrc');
  3777. }
  3778. if (pdfjsFilePath) {
  3779. return pdfjsFilePath.replace(/(\.(?:min\.)?js)(\?.*)?$/i, '.worker$1$2');
  3780. }
  3781. throw new Error('No PDFJS.workerSrc specified');
  3782. }
  3783. var fakeWorkerFilesLoadedCapability = void 0;
  3784. function setupFakeWorkerGlobal() {
  3785. var WorkerMessageHandler;
  3786. if (fakeWorkerFilesLoadedCapability) {
  3787. return fakeWorkerFilesLoadedCapability.promise;
  3788. }
  3789. fakeWorkerFilesLoadedCapability = (0, _util.createPromiseCapability)();
  3790. var loader = fakeWorkerFilesLoader || function (callback) {
  3791. _util.Util.loadScript(getWorkerSrc(), function () {
  3792. callback(window.pdfjsDistBuildPdfWorker.WorkerMessageHandler);
  3793. });
  3794. };
  3795. loader(fakeWorkerFilesLoadedCapability.resolve);
  3796. return fakeWorkerFilesLoadedCapability.promise;
  3797. }
  3798. function createCDNWrapper(url) {
  3799. var wrapper = 'importScripts(\'' + url + '\');';
  3800. return URL.createObjectURL(new Blob([wrapper]));
  3801. }
  3802. var pdfWorkerPorts = new WeakMap();
  3803. function PDFWorker(name, port) {
  3804. if (port && pdfWorkerPorts.has(port)) {
  3805. throw new Error('Cannot use more than one PDFWorker per port');
  3806. }
  3807. this.name = name;
  3808. this.destroyed = false;
  3809. this.postMessageTransfers = true;
  3810. this._readyCapability = (0, _util.createPromiseCapability)();
  3811. this._port = null;
  3812. this._webWorker = null;
  3813. this._messageHandler = null;
  3814. if (port) {
  3815. pdfWorkerPorts.set(port, this);
  3816. this._initializeFromPort(port);
  3817. return;
  3818. }
  3819. this._initialize();
  3820. }
  3821. PDFWorker.prototype = {
  3822. get promise() {
  3823. return this._readyCapability.promise;
  3824. },
  3825. get port() {
  3826. return this._port;
  3827. },
  3828. get messageHandler() {
  3829. return this._messageHandler;
  3830. },
  3831. _initializeFromPort: function PDFWorker_initializeFromPort(port) {
  3832. this._port = port;
  3833. this._messageHandler = new _util.MessageHandler('main', 'worker', port);
  3834. this._messageHandler.on('ready', function () {});
  3835. this._readyCapability.resolve();
  3836. },
  3837. _initialize: function PDFWorker_initialize() {
  3838. var _this6 = this;
  3839. if (!isWorkerDisabled && !(0, _dom_utils.getDefaultSetting)('disableWorker') && typeof Worker !== 'undefined') {
  3840. var workerSrc = getWorkerSrc();
  3841. try {
  3842. if (!(0, _util.isSameOrigin)(window.location.href, workerSrc)) {
  3843. workerSrc = createCDNWrapper(new URL(workerSrc, window.location).href);
  3844. }
  3845. var worker = new Worker(workerSrc);
  3846. var messageHandler = new _util.MessageHandler('main', 'worker', worker);
  3847. var terminateEarly = function terminateEarly() {
  3848. worker.removeEventListener('error', onWorkerError);
  3849. messageHandler.destroy();
  3850. worker.terminate();
  3851. if (_this6.destroyed) {
  3852. _this6._readyCapability.reject(new Error('Worker was destroyed'));
  3853. } else {
  3854. _this6._setupFakeWorker();
  3855. }
  3856. };
  3857. var onWorkerError = function onWorkerError() {
  3858. if (!_this6._webWorker) {
  3859. terminateEarly();
  3860. }
  3861. };
  3862. worker.addEventListener('error', onWorkerError);
  3863. messageHandler.on('test', function (data) {
  3864. worker.removeEventListener('error', onWorkerError);
  3865. if (_this6.destroyed) {
  3866. terminateEarly();
  3867. return;
  3868. }
  3869. var supportTypedArray = data && data.supportTypedArray;
  3870. if (supportTypedArray) {
  3871. _this6._messageHandler = messageHandler;
  3872. _this6._port = worker;
  3873. _this6._webWorker = worker;
  3874. if (!data.supportTransfers) {
  3875. _this6.postMessageTransfers = false;
  3876. isPostMessageTransfersDisabled = true;
  3877. }
  3878. _this6._readyCapability.resolve();
  3879. messageHandler.send('configure', { verbosity: (0, _util.getVerbosityLevel)() });
  3880. } else {
  3881. _this6._setupFakeWorker();
  3882. messageHandler.destroy();
  3883. worker.terminate();
  3884. }
  3885. });
  3886. messageHandler.on('console_log', function (data) {
  3887. console.log.apply(console, data);
  3888. });
  3889. messageHandler.on('console_error', function (data) {
  3890. console.error.apply(console, data);
  3891. });
  3892. messageHandler.on('ready', function (data) {
  3893. worker.removeEventListener('error', onWorkerError);
  3894. if (_this6.destroyed) {
  3895. terminateEarly();
  3896. return;
  3897. }
  3898. try {
  3899. sendTest();
  3900. } catch (e) {
  3901. _this6._setupFakeWorker();
  3902. }
  3903. });
  3904. var sendTest = function sendTest() {
  3905. var postMessageTransfers = (0, _dom_utils.getDefaultSetting)('postMessageTransfers') && !isPostMessageTransfersDisabled;
  3906. var testObj = new Uint8Array([postMessageTransfers ? 255 : 0]);
  3907. try {
  3908. messageHandler.send('test', testObj, [testObj.buffer]);
  3909. } catch (ex) {
  3910. (0, _util.info)('Cannot use postMessage transfers');
  3911. testObj[0] = 0;
  3912. messageHandler.send('test', testObj);
  3913. }
  3914. };
  3915. sendTest();
  3916. return;
  3917. } catch (e) {
  3918. (0, _util.info)('The worker has been disabled.');
  3919. }
  3920. }
  3921. this._setupFakeWorker();
  3922. },
  3923. _setupFakeWorker: function PDFWorker_setupFakeWorker() {
  3924. var _this7 = this;
  3925. if (!isWorkerDisabled && !(0, _dom_utils.getDefaultSetting)('disableWorker')) {
  3926. (0, _util.warn)('Setting up fake worker.');
  3927. isWorkerDisabled = true;
  3928. }
  3929. setupFakeWorkerGlobal().then(function (WorkerMessageHandler) {
  3930. if (_this7.destroyed) {
  3931. _this7._readyCapability.reject(new Error('Worker was destroyed'));
  3932. return;
  3933. }
  3934. var isTypedArraysPresent = Uint8Array !== Float32Array;
  3935. var port = new LoopbackPort(isTypedArraysPresent);
  3936. _this7._port = port;
  3937. var id = 'fake' + nextFakeWorkerId++;
  3938. var workerHandler = new _util.MessageHandler(id + '_worker', id, port);
  3939. WorkerMessageHandler.setup(workerHandler, port);
  3940. var messageHandler = new _util.MessageHandler(id, id + '_worker', port);
  3941. _this7._messageHandler = messageHandler;
  3942. _this7._readyCapability.resolve();
  3943. });
  3944. },
  3945. destroy: function PDFWorker_destroy() {
  3946. this.destroyed = true;
  3947. if (this._webWorker) {
  3948. this._webWorker.terminate();
  3949. this._webWorker = null;
  3950. }
  3951. pdfWorkerPorts.delete(this._port);
  3952. this._port = null;
  3953. if (this._messageHandler) {
  3954. this._messageHandler.destroy();
  3955. this._messageHandler = null;
  3956. }
  3957. }
  3958. };
  3959. PDFWorker.fromPort = function (port) {
  3960. if (pdfWorkerPorts.has(port)) {
  3961. return pdfWorkerPorts.get(port);
  3962. }
  3963. return new PDFWorker(null, port);
  3964. };
  3965. return PDFWorker;
  3966. }();
  3967. var WorkerTransport = function WorkerTransportClosure() {
  3968. function WorkerTransport(messageHandler, loadingTask, networkStream, CMapReaderFactory) {
  3969. this.messageHandler = messageHandler;
  3970. this.loadingTask = loadingTask;
  3971. this.commonObjs = new PDFObjects();
  3972. this.fontLoader = new _font_loader.FontLoader(loadingTask.docId);
  3973. this.CMapReaderFactory = new CMapReaderFactory({
  3974. baseUrl: (0, _dom_utils.getDefaultSetting)('cMapUrl'),
  3975. isCompressed: (0, _dom_utils.getDefaultSetting)('cMapPacked')
  3976. });
  3977. this.destroyed = false;
  3978. this.destroyCapability = null;
  3979. this._passwordCapability = null;
  3980. this._networkStream = networkStream;
  3981. this._fullReader = null;
  3982. this._lastProgress = null;
  3983. this.pageCache = [];
  3984. this.pagePromises = [];
  3985. this.downloadInfoCapability = (0, _util.createPromiseCapability)();
  3986. this.setupMessageHandler();
  3987. }
  3988. WorkerTransport.prototype = {
  3989. destroy: function WorkerTransport_destroy() {
  3990. var _this8 = this;
  3991. if (this.destroyCapability) {
  3992. return this.destroyCapability.promise;
  3993. }
  3994. this.destroyed = true;
  3995. this.destroyCapability = (0, _util.createPromiseCapability)();
  3996. if (this._passwordCapability) {
  3997. this._passwordCapability.reject(new Error('Worker was destroyed during onPassword callback'));
  3998. }
  3999. var waitOn = [];
  4000. this.pageCache.forEach(function (page) {
  4001. if (page) {
  4002. waitOn.push(page._destroy());
  4003. }
  4004. });
  4005. this.pageCache = [];
  4006. this.pagePromises = [];
  4007. var terminated = this.messageHandler.sendWithPromise('Terminate', null);
  4008. waitOn.push(terminated);
  4009. Promise.all(waitOn).then(function () {
  4010. _this8.fontLoader.clear();
  4011. if (_this8._networkStream) {
  4012. _this8._networkStream.cancelAllRequests();
  4013. }
  4014. if (_this8.messageHandler) {
  4015. _this8.messageHandler.destroy();
  4016. _this8.messageHandler = null;
  4017. }
  4018. _this8.destroyCapability.resolve();
  4019. }, this.destroyCapability.reject);
  4020. return this.destroyCapability.promise;
  4021. },
  4022. setupMessageHandler: function WorkerTransport_setupMessageHandler() {
  4023. var messageHandler = this.messageHandler;
  4024. var loadingTask = this.loadingTask;
  4025. messageHandler.on('GetReader', function (data, sink) {
  4026. var _this9 = this;
  4027. (0, _util.assert)(this._networkStream);
  4028. this._fullReader = this._networkStream.getFullReader();
  4029. this._fullReader.onProgress = function (evt) {
  4030. _this9._lastProgress = {
  4031. loaded: evt.loaded,
  4032. total: evt.total
  4033. };
  4034. };
  4035. sink.onPull = function () {
  4036. _this9._fullReader.read().then(function (_ref2) {
  4037. var value = _ref2.value,
  4038. done = _ref2.done;
  4039. if (done) {
  4040. sink.close();
  4041. return;
  4042. }
  4043. (0, _util.assert)((0, _util.isArrayBuffer)(value));
  4044. sink.enqueue(new Uint8Array(value), 1, [value]);
  4045. }).catch(function (reason) {
  4046. sink.error(reason);
  4047. });
  4048. };
  4049. sink.onCancel = function (reason) {
  4050. _this9._fullReader.cancel(reason);
  4051. };
  4052. }, this);
  4053. messageHandler.on('ReaderHeadersReady', function (data) {
  4054. var _this10 = this;
  4055. var headersCapability = (0, _util.createPromiseCapability)();
  4056. var fullReader = this._fullReader;
  4057. fullReader.headersReady.then(function () {
  4058. if (!fullReader.isStreamingSupported || !fullReader.isRangeSupported) {
  4059. if (_this10._lastProgress) {
  4060. var _loadingTask = _this10.loadingTask;
  4061. if (_loadingTask.onProgress) {
  4062. _loadingTask.onProgress(_this10._lastProgress);
  4063. }
  4064. }
  4065. fullReader.onProgress = function (evt) {
  4066. var loadingTask = _this10.loadingTask;
  4067. if (loadingTask.onProgress) {
  4068. loadingTask.onProgress({
  4069. loaded: evt.loaded,
  4070. total: evt.total
  4071. });
  4072. }
  4073. };
  4074. }
  4075. headersCapability.resolve({
  4076. isStreamingSupported: fullReader.isStreamingSupported,
  4077. isRangeSupported: fullReader.isRangeSupported,
  4078. contentLength: fullReader.contentLength
  4079. });
  4080. }, headersCapability.reject);
  4081. return headersCapability.promise;
  4082. }, this);
  4083. messageHandler.on('GetRangeReader', function (data, sink) {
  4084. (0, _util.assert)(this._networkStream);
  4085. var _rangeReader = this._networkStream.getRangeReader(data.begin, data.end);
  4086. sink.onPull = function () {
  4087. _rangeReader.read().then(function (_ref3) {
  4088. var value = _ref3.value,
  4089. done = _ref3.done;
  4090. if (done) {
  4091. sink.close();
  4092. return;
  4093. }
  4094. (0, _util.assert)((0, _util.isArrayBuffer)(value));
  4095. sink.enqueue(new Uint8Array(value), 1, [value]);
  4096. }).catch(function (reason) {
  4097. sink.error(reason);
  4098. });
  4099. };
  4100. sink.onCancel = function (reason) {
  4101. _rangeReader.cancel(reason);
  4102. };
  4103. }, this);
  4104. messageHandler.on('GetDoc', function transportDoc(data) {
  4105. var pdfInfo = data.pdfInfo;
  4106. this.numPages = data.pdfInfo.numPages;
  4107. var loadingTask = this.loadingTask;
  4108. var pdfDocument = new PDFDocumentProxy(pdfInfo, this, loadingTask);
  4109. this.pdfDocument = pdfDocument;
  4110. loadingTask._capability.resolve(pdfDocument);
  4111. }, this);
  4112. messageHandler.on('PasswordRequest', function transportPasswordRequest(exception) {
  4113. var _this11 = this;
  4114. this._passwordCapability = (0, _util.createPromiseCapability)();
  4115. if (loadingTask.onPassword) {
  4116. var updatePassword = function updatePassword(password) {
  4117. _this11._passwordCapability.resolve({ password: password });
  4118. };
  4119. loadingTask.onPassword(updatePassword, exception.code);
  4120. } else {
  4121. this._passwordCapability.reject(new _util.PasswordException(exception.message, exception.code));
  4122. }
  4123. return this._passwordCapability.promise;
  4124. }, this);
  4125. messageHandler.on('PasswordException', function transportPasswordException(exception) {
  4126. loadingTask._capability.reject(new _util.PasswordException(exception.message, exception.code));
  4127. }, this);
  4128. messageHandler.on('InvalidPDF', function transportInvalidPDF(exception) {
  4129. this.loadingTask._capability.reject(new _util.InvalidPDFException(exception.message));
  4130. }, this);
  4131. messageHandler.on('MissingPDF', function transportMissingPDF(exception) {
  4132. this.loadingTask._capability.reject(new _util.MissingPDFException(exception.message));
  4133. }, this);
  4134. messageHandler.on('UnexpectedResponse', function transportUnexpectedResponse(exception) {
  4135. this.loadingTask._capability.reject(new _util.UnexpectedResponseException(exception.message, exception.status));
  4136. }, this);
  4137. messageHandler.on('UnknownError', function transportUnknownError(exception) {
  4138. this.loadingTask._capability.reject(new _util.UnknownErrorException(exception.message, exception.details));
  4139. }, this);
  4140. messageHandler.on('DataLoaded', function transportPage(data) {
  4141. this.downloadInfoCapability.resolve(data);
  4142. }, this);
  4143. messageHandler.on('PDFManagerReady', function transportPage(data) {}, this);
  4144. messageHandler.on('StartRenderPage', function transportRender(data) {
  4145. if (this.destroyed) {
  4146. return;
  4147. }
  4148. var page = this.pageCache[data.pageIndex];
  4149. page.stats.timeEnd('Page Request');
  4150. page._startRenderPage(data.transparency, data.intent);
  4151. }, this);
  4152. messageHandler.on('RenderPageChunk', function transportRender(data) {
  4153. if (this.destroyed) {
  4154. return;
  4155. }
  4156. var page = this.pageCache[data.pageIndex];
  4157. page._renderPageChunk(data.operatorList, data.intent);
  4158. }, this);
  4159. messageHandler.on('commonobj', function transportObj(data) {
  4160. var _this12 = this;
  4161. if (this.destroyed) {
  4162. return;
  4163. }
  4164. var id = data[0];
  4165. var type = data[1];
  4166. if (this.commonObjs.hasData(id)) {
  4167. return;
  4168. }
  4169. switch (type) {
  4170. case 'Font':
  4171. var exportedData = data[2];
  4172. if ('error' in exportedData) {
  4173. var exportedError = exportedData.error;
  4174. (0, _util.warn)('Error during font loading: ' + exportedError);
  4175. this.commonObjs.resolve(id, exportedError);
  4176. break;
  4177. }
  4178. var fontRegistry = null;
  4179. if ((0, _dom_utils.getDefaultSetting)('pdfBug') && _global_scope2.default.FontInspector && _global_scope2.default['FontInspector'].enabled) {
  4180. fontRegistry = {
  4181. registerFont: function registerFont(font, url) {
  4182. _global_scope2.default['FontInspector'].fontAdded(font, url);
  4183. }
  4184. };
  4185. }
  4186. var font = new _font_loader.FontFaceObject(exportedData, {
  4187. isEvalSupported: (0, _dom_utils.getDefaultSetting)('isEvalSupported'),
  4188. disableFontFace: (0, _dom_utils.getDefaultSetting)('disableFontFace'),
  4189. fontRegistry: fontRegistry
  4190. });
  4191. var fontReady = function fontReady(fontObjs) {
  4192. _this12.commonObjs.resolve(id, font);
  4193. };
  4194. this.fontLoader.bind([font], fontReady);
  4195. break;
  4196. case 'FontPath':
  4197. this.commonObjs.resolve(id, data[2]);
  4198. break;
  4199. default:
  4200. throw new Error('Got unknown common object type ' + type);
  4201. }
  4202. }, this);
  4203. messageHandler.on('obj', function transportObj(data) {
  4204. if (this.destroyed) {
  4205. return;
  4206. }
  4207. var id = data[0];
  4208. var pageIndex = data[1];
  4209. var type = data[2];
  4210. var pageProxy = this.pageCache[pageIndex];
  4211. var imageData;
  4212. if (pageProxy.objs.hasData(id)) {
  4213. return;
  4214. }
  4215. switch (type) {
  4216. case 'JpegStream':
  4217. imageData = data[3];
  4218. (0, _util.loadJpegStream)(id, imageData, pageProxy.objs);
  4219. break;
  4220. case 'Image':
  4221. imageData = data[3];
  4222. pageProxy.objs.resolve(id, imageData);
  4223. var MAX_IMAGE_SIZE_TO_STORE = 8000000;
  4224. if (imageData && 'data' in imageData && imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) {
  4225. pageProxy.cleanupAfterRender = true;
  4226. }
  4227. break;
  4228. default:
  4229. throw new Error('Got unknown object type ' + type);
  4230. }
  4231. }, this);
  4232. messageHandler.on('DocProgress', function transportDocProgress(data) {
  4233. if (this.destroyed) {
  4234. return;
  4235. }
  4236. var loadingTask = this.loadingTask;
  4237. if (loadingTask.onProgress) {
  4238. loadingTask.onProgress({
  4239. loaded: data.loaded,
  4240. total: data.total
  4241. });
  4242. }
  4243. }, this);
  4244. messageHandler.on('PageError', function transportError(data) {
  4245. if (this.destroyed) {
  4246. return;
  4247. }
  4248. var page = this.pageCache[data.pageNum - 1];
  4249. var intentState = page.intentStates[data.intent];
  4250. if (intentState.displayReadyCapability) {
  4251. intentState.displayReadyCapability.reject(data.error);
  4252. } else {
  4253. throw new Error(data.error);
  4254. }
  4255. if (intentState.operatorList) {
  4256. intentState.operatorList.lastChunk = true;
  4257. for (var i = 0; i < intentState.renderTasks.length; i++) {
  4258. intentState.renderTasks[i].operatorListChanged();
  4259. }
  4260. }
  4261. }, this);
  4262. messageHandler.on('UnsupportedFeature', function transportUnsupportedFeature(data) {
  4263. if (this.destroyed) {
  4264. return;
  4265. }
  4266. var featureId = data.featureId;
  4267. var loadingTask = this.loadingTask;
  4268. if (loadingTask.onUnsupportedFeature) {
  4269. loadingTask.onUnsupportedFeature(featureId);
  4270. }
  4271. _UnsupportedManager.notify(featureId);
  4272. }, this);
  4273. messageHandler.on('JpegDecode', function (data) {
  4274. if (this.destroyed) {
  4275. return Promise.reject(new Error('Worker was destroyed'));
  4276. }
  4277. if (typeof document === 'undefined') {
  4278. return Promise.reject(new Error('"document" is not defined.'));
  4279. }
  4280. var imageUrl = data[0];
  4281. var components = data[1];
  4282. if (components !== 3 && components !== 1) {
  4283. return Promise.reject(new Error('Only 3 components or 1 component can be returned'));
  4284. }
  4285. return new Promise(function (resolve, reject) {
  4286. var img = new Image();
  4287. img.onload = function () {
  4288. var width = img.width;
  4289. var height = img.height;
  4290. var size = width * height;
  4291. var rgbaLength = size * 4;
  4292. var buf = new Uint8Array(size * components);
  4293. var tmpCanvas = document.createElement('canvas');
  4294. tmpCanvas.width = width;
  4295. tmpCanvas.height = height;
  4296. var tmpCtx = tmpCanvas.getContext('2d');
  4297. tmpCtx.drawImage(img, 0, 0);
  4298. var data = tmpCtx.getImageData(0, 0, width, height).data;
  4299. var i, j;
  4300. if (components === 3) {
  4301. for (i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
  4302. buf[j] = data[i];
  4303. buf[j + 1] = data[i + 1];
  4304. buf[j + 2] = data[i + 2];
  4305. }
  4306. } else if (components === 1) {
  4307. for (i = 0, j = 0; i < rgbaLength; i += 4, j++) {
  4308. buf[j] = data[i];
  4309. }
  4310. }
  4311. resolve({
  4312. data: buf,
  4313. width: width,
  4314. height: height
  4315. });
  4316. };
  4317. img.onerror = function () {
  4318. reject(new Error('JpegDecode failed to load image'));
  4319. };
  4320. img.src = imageUrl;
  4321. });
  4322. }, this);
  4323. messageHandler.on('FetchBuiltInCMap', function (data) {
  4324. if (this.destroyed) {
  4325. return Promise.reject(new Error('Worker was destroyed'));
  4326. }
  4327. return this.CMapReaderFactory.fetch({ name: data.name });
  4328. }, this);
  4329. },
  4330. getData: function WorkerTransport_getData() {
  4331. return this.messageHandler.sendWithPromise('GetData', null);
  4332. },
  4333. getPage: function WorkerTransport_getPage(pageNumber, capability) {
  4334. var _this13 = this;
  4335. if (!Number.isInteger(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) {
  4336. return Promise.reject(new Error('Invalid page request'));
  4337. }
  4338. var pageIndex = pageNumber - 1;
  4339. if (pageIndex in this.pagePromises) {
  4340. return this.pagePromises[pageIndex];
  4341. }
  4342. var promise = this.messageHandler.sendWithPromise('GetPage', { pageIndex: pageIndex }).then(function (pageInfo) {
  4343. if (_this13.destroyed) {
  4344. throw new Error('Transport destroyed');
  4345. }
  4346. var page = new PDFPageProxy(pageIndex, pageInfo, _this13);
  4347. _this13.pageCache[pageIndex] = page;
  4348. return page;
  4349. });
  4350. this.pagePromises[pageIndex] = promise;
  4351. return promise;
  4352. },
  4353. getPageIndex: function WorkerTransport_getPageIndexByRef(ref) {
  4354. return this.messageHandler.sendWithPromise('GetPageIndex', { ref: ref }).catch(function (reason) {
  4355. return Promise.reject(new Error(reason));
  4356. });
  4357. },
  4358. getAnnotations: function WorkerTransport_getAnnotations(pageIndex, intent) {
  4359. return this.messageHandler.sendWithPromise('GetAnnotations', {
  4360. pageIndex: pageIndex,
  4361. intent: intent
  4362. });
  4363. },
  4364. getDestinations: function WorkerTransport_getDestinations() {
  4365. return this.messageHandler.sendWithPromise('GetDestinations', null);
  4366. },
  4367. getDestination: function WorkerTransport_getDestination(id) {
  4368. return this.messageHandler.sendWithPromise('GetDestination', { id: id });
  4369. },
  4370. getPageLabels: function WorkerTransport_getPageLabels() {
  4371. return this.messageHandler.sendWithPromise('GetPageLabels', null);
  4372. },
  4373. getPageMode: function getPageMode() {
  4374. return this.messageHandler.sendWithPromise('GetPageMode', null);
  4375. },
  4376. getAttachments: function WorkerTransport_getAttachments() {
  4377. return this.messageHandler.sendWithPromise('GetAttachments', null);
  4378. },
  4379. getJavaScript: function WorkerTransport_getJavaScript() {
  4380. return this.messageHandler.sendWithPromise('GetJavaScript', null);
  4381. },
  4382. getOutline: function WorkerTransport_getOutline() {
  4383. return this.messageHandler.sendWithPromise('GetOutline', null);
  4384. },
  4385. getMetadata: function WorkerTransport_getMetadata() {
  4386. return this.messageHandler.sendWithPromise('GetMetadata', null).then(function transportMetadata(results) {
  4387. return {
  4388. info: results[0],
  4389. metadata: results[1] ? new _metadata.Metadata(results[1]) : null
  4390. };
  4391. });
  4392. },
  4393. getStats: function WorkerTransport_getStats() {
  4394. return this.messageHandler.sendWithPromise('GetStats', null);
  4395. },
  4396. startCleanup: function WorkerTransport_startCleanup() {
  4397. var _this14 = this;
  4398. this.messageHandler.sendWithPromise('Cleanup', null).then(function () {
  4399. for (var i = 0, ii = _this14.pageCache.length; i < ii; i++) {
  4400. var page = _this14.pageCache[i];
  4401. if (page) {
  4402. page.cleanup();
  4403. }
  4404. }
  4405. _this14.commonObjs.clear();
  4406. _this14.fontLoader.clear();
  4407. });
  4408. }
  4409. };
  4410. return WorkerTransport;
  4411. }();
  4412. var PDFObjects = function PDFObjectsClosure() {
  4413. function PDFObjects() {
  4414. this.objs = Object.create(null);
  4415. }
  4416. PDFObjects.prototype = {
  4417. ensureObj: function PDFObjects_ensureObj(objId) {
  4418. if (this.objs[objId]) {
  4419. return this.objs[objId];
  4420. }
  4421. var obj = {
  4422. capability: (0, _util.createPromiseCapability)(),
  4423. data: null,
  4424. resolved: false
  4425. };
  4426. this.objs[objId] = obj;
  4427. return obj;
  4428. },
  4429. get: function PDFObjects_get(objId, callback) {
  4430. if (callback) {
  4431. this.ensureObj(objId).capability.promise.then(callback);
  4432. return null;
  4433. }
  4434. var obj = this.objs[objId];
  4435. if (!obj || !obj.resolved) {
  4436. throw new Error('Requesting object that isn\'t resolved yet ' + objId);
  4437. }
  4438. return obj.data;
  4439. },
  4440. resolve: function PDFObjects_resolve(objId, data) {
  4441. var obj = this.ensureObj(objId);
  4442. obj.resolved = true;
  4443. obj.data = data;
  4444. obj.capability.resolve(data);
  4445. },
  4446. isResolved: function PDFObjects_isResolved(objId) {
  4447. var objs = this.objs;
  4448. if (!objs[objId]) {
  4449. return false;
  4450. }
  4451. return objs[objId].resolved;
  4452. },
  4453. hasData: function PDFObjects_hasData(objId) {
  4454. return this.isResolved(objId);
  4455. },
  4456. getData: function PDFObjects_getData(objId) {
  4457. var objs = this.objs;
  4458. if (!objs[objId] || !objs[objId].resolved) {
  4459. return null;
  4460. }
  4461. return objs[objId].data;
  4462. },
  4463. clear: function PDFObjects_clear() {
  4464. this.objs = Object.create(null);
  4465. }
  4466. };
  4467. return PDFObjects;
  4468. }();
  4469. var RenderTask = function RenderTaskClosure() {
  4470. function RenderTask(internalRenderTask) {
  4471. this._internalRenderTask = internalRenderTask;
  4472. this.onContinue = null;
  4473. }
  4474. RenderTask.prototype = {
  4475. get promise() {
  4476. return this._internalRenderTask.capability.promise;
  4477. },
  4478. cancel: function RenderTask_cancel() {
  4479. this._internalRenderTask.cancel();
  4480. },
  4481. then: function RenderTask_then(onFulfilled, onRejected) {
  4482. return this.promise.then.apply(this.promise, arguments);
  4483. }
  4484. };
  4485. return RenderTask;
  4486. }();
  4487. var InternalRenderTask = function InternalRenderTaskClosure() {
  4488. var canvasInRendering = new WeakMap();
  4489. function InternalRenderTask(callback, params, objs, commonObjs, operatorList, pageNumber, canvasFactory) {
  4490. this.callback = callback;
  4491. this.params = params;
  4492. this.objs = objs;
  4493. this.commonObjs = commonObjs;
  4494. this.operatorListIdx = null;
  4495. this.operatorList = operatorList;
  4496. this.pageNumber = pageNumber;
  4497. this.canvasFactory = canvasFactory;
  4498. this.running = false;
  4499. this.graphicsReadyCallback = null;
  4500. this.graphicsReady = false;
  4501. this.useRequestAnimationFrame = false;
  4502. this.cancelled = false;
  4503. this.capability = (0, _util.createPromiseCapability)();
  4504. this.task = new RenderTask(this);
  4505. this._continueBound = this._continue.bind(this);
  4506. this._scheduleNextBound = this._scheduleNext.bind(this);
  4507. this._nextBound = this._next.bind(this);
  4508. this._canvas = params.canvasContext.canvas;
  4509. }
  4510. InternalRenderTask.prototype = {
  4511. initializeGraphics: function InternalRenderTask_initializeGraphics(transparency) {
  4512. if (this._canvas) {
  4513. if (canvasInRendering.has(this._canvas)) {
  4514. throw new Error('Cannot use the same canvas during multiple render() operations. ' + 'Use different canvas or ensure previous operations were ' + 'cancelled or completed.');
  4515. }
  4516. canvasInRendering.set(this._canvas, this);
  4517. }
  4518. if (this.cancelled) {
  4519. return;
  4520. }
  4521. if ((0, _dom_utils.getDefaultSetting)('pdfBug') && _global_scope2.default.StepperManager && _global_scope2.default.StepperManager.enabled) {
  4522. this.stepper = _global_scope2.default.StepperManager.create(this.pageNumber - 1);
  4523. this.stepper.init(this.operatorList);
  4524. this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
  4525. }
  4526. var params = this.params;
  4527. this.gfx = new _canvas.CanvasGraphics(params.canvasContext, this.commonObjs, this.objs, this.canvasFactory, params.imageLayer);
  4528. this.gfx.beginDrawing({
  4529. transform: params.transform,
  4530. viewport: params.viewport,
  4531. transparency: transparency,
  4532. background: params.background
  4533. });
  4534. this.operatorListIdx = 0;
  4535. this.graphicsReady = true;
  4536. if (this.graphicsReadyCallback) {
  4537. this.graphicsReadyCallback();
  4538. }
  4539. },
  4540. cancel: function InternalRenderTask_cancel() {
  4541. this.running = false;
  4542. this.cancelled = true;
  4543. if (this._canvas) {
  4544. canvasInRendering.delete(this._canvas);
  4545. }
  4546. if ((0, _dom_utils.getDefaultSetting)('pdfjsNext')) {
  4547. this.callback(new _dom_utils.RenderingCancelledException('Rendering cancelled, page ' + this.pageNumber, 'canvas'));
  4548. } else {
  4549. this.callback('cancelled');
  4550. }
  4551. },
  4552. operatorListChanged: function InternalRenderTask_operatorListChanged() {
  4553. if (!this.graphicsReady) {
  4554. if (!this.graphicsReadyCallback) {
  4555. this.graphicsReadyCallback = this._continueBound;
  4556. }
  4557. return;
  4558. }
  4559. if (this.stepper) {
  4560. this.stepper.updateOperatorList(this.operatorList);
  4561. }
  4562. if (this.running) {
  4563. return;
  4564. }
  4565. this._continue();
  4566. },
  4567. _continue: function InternalRenderTask__continue() {
  4568. this.running = true;
  4569. if (this.cancelled) {
  4570. return;
  4571. }
  4572. if (this.task.onContinue) {
  4573. this.task.onContinue(this._scheduleNextBound);
  4574. } else {
  4575. this._scheduleNext();
  4576. }
  4577. },
  4578. _scheduleNext: function InternalRenderTask__scheduleNext() {
  4579. if (this.useRequestAnimationFrame && typeof window !== 'undefined') {
  4580. window.requestAnimationFrame(this._nextBound);
  4581. } else {
  4582. Promise.resolve(undefined).then(this._nextBound);
  4583. }
  4584. },
  4585. _next: function InternalRenderTask__next() {
  4586. if (this.cancelled) {
  4587. return;
  4588. }
  4589. this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper);
  4590. if (this.operatorListIdx === this.operatorList.argsArray.length) {
  4591. this.running = false;
  4592. if (this.operatorList.lastChunk) {
  4593. this.gfx.endDrawing();
  4594. if (this._canvas) {
  4595. canvasInRendering.delete(this._canvas);
  4596. }
  4597. this.callback();
  4598. }
  4599. }
  4600. }
  4601. };
  4602. return InternalRenderTask;
  4603. }();
  4604. var _UnsupportedManager = function UnsupportedManagerClosure() {
  4605. var listeners = [];
  4606. return {
  4607. listen: function listen(cb) {
  4608. (0, _util.deprecated)('Global UnsupportedManager.listen is used: ' + ' use PDFDocumentLoadingTask.onUnsupportedFeature instead');
  4609. listeners.push(cb);
  4610. },
  4611. notify: function notify(featureId) {
  4612. for (var i = 0, ii = listeners.length; i < ii; i++) {
  4613. listeners[i](featureId);
  4614. }
  4615. }
  4616. };
  4617. }();
  4618. var version, build;
  4619. {
  4620. exports.version = version = '1.10.88';
  4621. exports.build = build = 'c62a1938';
  4622. }
  4623. exports.getDocument = getDocument;
  4624. exports.LoopbackPort = LoopbackPort;
  4625. exports.PDFDataRangeTransport = PDFDataRangeTransport;
  4626. exports.PDFWorker = PDFWorker;
  4627. exports.PDFDocumentProxy = PDFDocumentProxy;
  4628. exports.PDFPageProxy = PDFPageProxy;
  4629. exports.setPDFNetworkStreamClass = setPDFNetworkStreamClass;
  4630. exports._UnsupportedManager = _UnsupportedManager;
  4631. exports.version = version;
  4632. exports.build = build;
  4633. /***/ }),
  4634. /* 70 */
  4635. /***/ (function(module, exports, __w_pdfjs_require__) {
  4636. "use strict";
  4637. Object.defineProperty(exports, "__esModule", {
  4638. value: true
  4639. });
  4640. exports.WebGLUtils = undefined;
  4641. var _dom_utils = __w_pdfjs_require__(13);
  4642. var _util = __w_pdfjs_require__(0);
  4643. var WebGLUtils = function WebGLUtilsClosure() {
  4644. function loadShader(gl, code, shaderType) {
  4645. var shader = gl.createShader(shaderType);
  4646. gl.shaderSource(shader, code);
  4647. gl.compileShader(shader);
  4648. var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
  4649. if (!compiled) {
  4650. var errorMsg = gl.getShaderInfoLog(shader);
  4651. throw new Error('Error during shader compilation: ' + errorMsg);
  4652. }
  4653. return shader;
  4654. }
  4655. function createVertexShader(gl, code) {
  4656. return loadShader(gl, code, gl.VERTEX_SHADER);
  4657. }
  4658. function createFragmentShader(gl, code) {
  4659. return loadShader(gl, code, gl.FRAGMENT_SHADER);
  4660. }
  4661. function createProgram(gl, shaders) {
  4662. var program = gl.createProgram();
  4663. for (var i = 0, ii = shaders.length; i < ii; ++i) {
  4664. gl.attachShader(program, shaders[i]);
  4665. }
  4666. gl.linkProgram(program);
  4667. var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
  4668. if (!linked) {
  4669. var errorMsg = gl.getProgramInfoLog(program);
  4670. throw new Error('Error during program linking: ' + errorMsg);
  4671. }
  4672. return program;
  4673. }
  4674. function createTexture(gl, image, textureId) {
  4675. gl.activeTexture(textureId);
  4676. var texture = gl.createTexture();
  4677. gl.bindTexture(gl.TEXTURE_2D, texture);
  4678. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  4679. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  4680. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  4681. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  4682. gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
  4683. return texture;
  4684. }
  4685. var currentGL, currentCanvas;
  4686. function generateGL() {
  4687. if (currentGL) {
  4688. return;
  4689. }
  4690. currentCanvas = document.createElement('canvas');
  4691. currentGL = currentCanvas.getContext('webgl', { premultipliedalpha: false });
  4692. }
  4693. var smaskVertexShaderCode = '\
  4694. attribute vec2 a_position; \
  4695. attribute vec2 a_texCoord; \
  4696. \
  4697. uniform vec2 u_resolution; \
  4698. \
  4699. varying vec2 v_texCoord; \
  4700. \
  4701. void main() { \
  4702. vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; \
  4703. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  4704. \
  4705. v_texCoord = a_texCoord; \
  4706. } ';
  4707. var smaskFragmentShaderCode = '\
  4708. precision mediump float; \
  4709. \
  4710. uniform vec4 u_backdrop; \
  4711. uniform int u_subtype; \
  4712. uniform sampler2D u_image; \
  4713. uniform sampler2D u_mask; \
  4714. \
  4715. varying vec2 v_texCoord; \
  4716. \
  4717. void main() { \
  4718. vec4 imageColor = texture2D(u_image, v_texCoord); \
  4719. vec4 maskColor = texture2D(u_mask, v_texCoord); \
  4720. if (u_backdrop.a > 0.0) { \
  4721. maskColor.rgb = maskColor.rgb * maskColor.a + \
  4722. u_backdrop.rgb * (1.0 - maskColor.a); \
  4723. } \
  4724. float lum; \
  4725. if (u_subtype == 0) { \
  4726. lum = maskColor.a; \
  4727. } else { \
  4728. lum = maskColor.r * 0.3 + maskColor.g * 0.59 + \
  4729. maskColor.b * 0.11; \
  4730. } \
  4731. imageColor.a *= lum; \
  4732. imageColor.rgb *= imageColor.a; \
  4733. gl_FragColor = imageColor; \
  4734. } ';
  4735. var smaskCache = null;
  4736. function initSmaskGL() {
  4737. var canvas, gl;
  4738. generateGL();
  4739. canvas = currentCanvas;
  4740. currentCanvas = null;
  4741. gl = currentGL;
  4742. currentGL = null;
  4743. var vertexShader = createVertexShader(gl, smaskVertexShaderCode);
  4744. var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode);
  4745. var program = createProgram(gl, [vertexShader, fragmentShader]);
  4746. gl.useProgram(program);
  4747. var cache = {};
  4748. cache.gl = gl;
  4749. cache.canvas = canvas;
  4750. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  4751. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  4752. cache.backdropLocation = gl.getUniformLocation(program, 'u_backdrop');
  4753. cache.subtypeLocation = gl.getUniformLocation(program, 'u_subtype');
  4754. var texCoordLocation = gl.getAttribLocation(program, 'a_texCoord');
  4755. var texLayerLocation = gl.getUniformLocation(program, 'u_image');
  4756. var texMaskLocation = gl.getUniformLocation(program, 'u_mask');
  4757. var texCoordBuffer = gl.createBuffer();
  4758. gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);
  4759. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0]), gl.STATIC_DRAW);
  4760. gl.enableVertexAttribArray(texCoordLocation);
  4761. gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0);
  4762. gl.uniform1i(texLayerLocation, 0);
  4763. gl.uniform1i(texMaskLocation, 1);
  4764. smaskCache = cache;
  4765. }
  4766. function composeSMask(layer, mask, properties) {
  4767. var width = layer.width,
  4768. height = layer.height;
  4769. if (!smaskCache) {
  4770. initSmaskGL();
  4771. }
  4772. var cache = smaskCache,
  4773. canvas = cache.canvas,
  4774. gl = cache.gl;
  4775. canvas.width = width;
  4776. canvas.height = height;
  4777. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  4778. gl.uniform2f(cache.resolutionLocation, width, height);
  4779. if (properties.backdrop) {
  4780. gl.uniform4f(cache.resolutionLocation, properties.backdrop[0], properties.backdrop[1], properties.backdrop[2], 1);
  4781. } else {
  4782. gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0);
  4783. }
  4784. gl.uniform1i(cache.subtypeLocation, properties.subtype === 'Luminosity' ? 1 : 0);
  4785. var texture = createTexture(gl, layer, gl.TEXTURE0);
  4786. var maskTexture = createTexture(gl, mask, gl.TEXTURE1);
  4787. var buffer = gl.createBuffer();
  4788. gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
  4789. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([0, 0, width, 0, 0, height, 0, height, width, 0, width, height]), gl.STATIC_DRAW);
  4790. gl.enableVertexAttribArray(cache.positionLocation);
  4791. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  4792. gl.clearColor(0, 0, 0, 0);
  4793. gl.enable(gl.BLEND);
  4794. gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
  4795. gl.clear(gl.COLOR_BUFFER_BIT);
  4796. gl.drawArrays(gl.TRIANGLES, 0, 6);
  4797. gl.flush();
  4798. gl.deleteTexture(texture);
  4799. gl.deleteTexture(maskTexture);
  4800. gl.deleteBuffer(buffer);
  4801. return canvas;
  4802. }
  4803. var figuresVertexShaderCode = '\
  4804. attribute vec2 a_position; \
  4805. attribute vec3 a_color; \
  4806. \
  4807. uniform vec2 u_resolution; \
  4808. uniform vec2 u_scale; \
  4809. uniform vec2 u_offset; \
  4810. \
  4811. varying vec4 v_color; \
  4812. \
  4813. void main() { \
  4814. vec2 position = (a_position + u_offset) * u_scale; \
  4815. vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; \
  4816. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  4817. \
  4818. v_color = vec4(a_color / 255.0, 1.0); \
  4819. } ';
  4820. var figuresFragmentShaderCode = '\
  4821. precision mediump float; \
  4822. \
  4823. varying vec4 v_color; \
  4824. \
  4825. void main() { \
  4826. gl_FragColor = v_color; \
  4827. } ';
  4828. var figuresCache = null;
  4829. function initFiguresGL() {
  4830. var canvas, gl;
  4831. generateGL();
  4832. canvas = currentCanvas;
  4833. currentCanvas = null;
  4834. gl = currentGL;
  4835. currentGL = null;
  4836. var vertexShader = createVertexShader(gl, figuresVertexShaderCode);
  4837. var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode);
  4838. var program = createProgram(gl, [vertexShader, fragmentShader]);
  4839. gl.useProgram(program);
  4840. var cache = {};
  4841. cache.gl = gl;
  4842. cache.canvas = canvas;
  4843. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  4844. cache.scaleLocation = gl.getUniformLocation(program, 'u_scale');
  4845. cache.offsetLocation = gl.getUniformLocation(program, 'u_offset');
  4846. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  4847. cache.colorLocation = gl.getAttribLocation(program, 'a_color');
  4848. figuresCache = cache;
  4849. }
  4850. function drawFigures(width, height, backgroundColor, figures, context) {
  4851. if (!figuresCache) {
  4852. initFiguresGL();
  4853. }
  4854. var cache = figuresCache,
  4855. canvas = cache.canvas,
  4856. gl = cache.gl;
  4857. canvas.width = width;
  4858. canvas.height = height;
  4859. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  4860. gl.uniform2f(cache.resolutionLocation, width, height);
  4861. var count = 0;
  4862. var i, ii, rows;
  4863. for (i = 0, ii = figures.length; i < ii; i++) {
  4864. switch (figures[i].type) {
  4865. case 'lattice':
  4866. rows = figures[i].coords.length / figures[i].verticesPerRow | 0;
  4867. count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6;
  4868. break;
  4869. case 'triangles':
  4870. count += figures[i].coords.length;
  4871. break;
  4872. }
  4873. }
  4874. var coords = new Float32Array(count * 2);
  4875. var colors = new Uint8Array(count * 3);
  4876. var coordsMap = context.coords,
  4877. colorsMap = context.colors;
  4878. var pIndex = 0,
  4879. cIndex = 0;
  4880. for (i = 0, ii = figures.length; i < ii; i++) {
  4881. var figure = figures[i],
  4882. ps = figure.coords,
  4883. cs = figure.colors;
  4884. switch (figure.type) {
  4885. case 'lattice':
  4886. var cols = figure.verticesPerRow;
  4887. rows = ps.length / cols | 0;
  4888. for (var row = 1; row < rows; row++) {
  4889. var offset = row * cols + 1;
  4890. for (var col = 1; col < cols; col++, offset++) {
  4891. coords[pIndex] = coordsMap[ps[offset - cols - 1]];
  4892. coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1];
  4893. coords[pIndex + 2] = coordsMap[ps[offset - cols]];
  4894. coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1];
  4895. coords[pIndex + 4] = coordsMap[ps[offset - 1]];
  4896. coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1];
  4897. colors[cIndex] = colorsMap[cs[offset - cols - 1]];
  4898. colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1];
  4899. colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2];
  4900. colors[cIndex + 3] = colorsMap[cs[offset - cols]];
  4901. colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1];
  4902. colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2];
  4903. colors[cIndex + 6] = colorsMap[cs[offset - 1]];
  4904. colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1];
  4905. colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2];
  4906. coords[pIndex + 6] = coords[pIndex + 2];
  4907. coords[pIndex + 7] = coords[pIndex + 3];
  4908. coords[pIndex + 8] = coords[pIndex + 4];
  4909. coords[pIndex + 9] = coords[pIndex + 5];
  4910. coords[pIndex + 10] = coordsMap[ps[offset]];
  4911. coords[pIndex + 11] = coordsMap[ps[offset] + 1];
  4912. colors[cIndex + 9] = colors[cIndex + 3];
  4913. colors[cIndex + 10] = colors[cIndex + 4];
  4914. colors[cIndex + 11] = colors[cIndex + 5];
  4915. colors[cIndex + 12] = colors[cIndex + 6];
  4916. colors[cIndex + 13] = colors[cIndex + 7];
  4917. colors[cIndex + 14] = colors[cIndex + 8];
  4918. colors[cIndex + 15] = colorsMap[cs[offset]];
  4919. colors[cIndex + 16] = colorsMap[cs[offset] + 1];
  4920. colors[cIndex + 17] = colorsMap[cs[offset] + 2];
  4921. pIndex += 12;
  4922. cIndex += 18;
  4923. }
  4924. }
  4925. break;
  4926. case 'triangles':
  4927. for (var j = 0, jj = ps.length; j < jj; j++) {
  4928. coords[pIndex] = coordsMap[ps[j]];
  4929. coords[pIndex + 1] = coordsMap[ps[j] + 1];
  4930. colors[cIndex] = colorsMap[cs[j]];
  4931. colors[cIndex + 1] = colorsMap[cs[j] + 1];
  4932. colors[cIndex + 2] = colorsMap[cs[j] + 2];
  4933. pIndex += 2;
  4934. cIndex += 3;
  4935. }
  4936. break;
  4937. }
  4938. }
  4939. if (backgroundColor) {
  4940. gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255, backgroundColor[2] / 255, 1.0);
  4941. } else {
  4942. gl.clearColor(0, 0, 0, 0);
  4943. }
  4944. gl.clear(gl.COLOR_BUFFER_BIT);
  4945. var coordsBuffer = gl.createBuffer();
  4946. gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer);
  4947. gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW);
  4948. gl.enableVertexAttribArray(cache.positionLocation);
  4949. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  4950. var colorsBuffer = gl.createBuffer();
  4951. gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer);
  4952. gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW);
  4953. gl.enableVertexAttribArray(cache.colorLocation);
  4954. gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false, 0, 0);
  4955. gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY);
  4956. gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY);
  4957. gl.drawArrays(gl.TRIANGLES, 0, count);
  4958. gl.flush();
  4959. gl.deleteBuffer(coordsBuffer);
  4960. gl.deleteBuffer(colorsBuffer);
  4961. return canvas;
  4962. }
  4963. function cleanup() {
  4964. if (smaskCache && smaskCache.canvas) {
  4965. smaskCache.canvas.width = 0;
  4966. smaskCache.canvas.height = 0;
  4967. }
  4968. if (figuresCache && figuresCache.canvas) {
  4969. figuresCache.canvas.width = 0;
  4970. figuresCache.canvas.height = 0;
  4971. }
  4972. smaskCache = null;
  4973. figuresCache = null;
  4974. }
  4975. return {
  4976. get isEnabled() {
  4977. if ((0, _dom_utils.getDefaultSetting)('disableWebGL')) {
  4978. return false;
  4979. }
  4980. var enabled = false;
  4981. try {
  4982. generateGL();
  4983. enabled = !!currentGL;
  4984. } catch (e) {}
  4985. return (0, _util.shadow)(this, 'isEnabled', enabled);
  4986. },
  4987. composeSMask: composeSMask,
  4988. drawFigures: drawFigures,
  4989. clear: cleanup
  4990. };
  4991. }();
  4992. exports.WebGLUtils = WebGLUtils;
  4993. /***/ }),
  4994. /* 71 */
  4995. /***/ (function(module, exports, __w_pdfjs_require__) {
  4996. "use strict";
  4997. Object.defineProperty(exports, "__esModule", {
  4998. value: true
  4999. });
  5000. exports.Metadata = undefined;
  5001. 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; }; }();
  5002. var _util = __w_pdfjs_require__(0);
  5003. var _dom_utils = __w_pdfjs_require__(13);
  5004. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5005. var Metadata = function () {
  5006. function Metadata(data) {
  5007. _classCallCheck(this, Metadata);
  5008. (0, _util.assert)(typeof data === 'string', 'Metadata: input is not a string');
  5009. data = this._repair(data);
  5010. var parser = new _dom_utils.SimpleXMLParser();
  5011. data = parser.parseFromString(data);
  5012. this._metadata = Object.create(null);
  5013. this._parse(data);
  5014. }
  5015. _createClass(Metadata, [{
  5016. key: '_repair',
  5017. value: function _repair(data) {
  5018. return data.replace(/>\\376\\377([^<]+)/g, function (all, codes) {
  5019. var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) {
  5020. return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
  5021. });
  5022. var chars = '';
  5023. for (var i = 0, ii = bytes.length; i < ii; i += 2) {
  5024. var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
  5025. if (code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38) {
  5026. chars += String.fromCharCode(code);
  5027. } else {
  5028. chars += '&#x' + (0x10000 + code).toString(16).substring(1) + ';';
  5029. }
  5030. }
  5031. return '>' + chars;
  5032. });
  5033. }
  5034. }, {
  5035. key: '_parse',
  5036. value: function _parse(domDocument) {
  5037. var rdf = domDocument.documentElement;
  5038. if (rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  5039. rdf = rdf.firstChild;
  5040. while (rdf && rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  5041. rdf = rdf.nextSibling;
  5042. }
  5043. }
  5044. var nodeName = rdf ? rdf.nodeName.toLowerCase() : null;
  5045. if (!rdf || nodeName !== 'rdf:rdf' || !rdf.hasChildNodes()) {
  5046. return;
  5047. }
  5048. var children = rdf.childNodes;
  5049. for (var i = 0, ii = children.length; i < ii; i++) {
  5050. var desc = children[i];
  5051. if (desc.nodeName.toLowerCase() !== 'rdf:description') {
  5052. continue;
  5053. }
  5054. for (var j = 0, jj = desc.childNodes.length; j < jj; j++) {
  5055. if (desc.childNodes[j].nodeName.toLowerCase() !== '#text') {
  5056. var entry = desc.childNodes[j];
  5057. var name = entry.nodeName.toLowerCase();
  5058. this._metadata[name] = entry.textContent.trim();
  5059. }
  5060. }
  5061. }
  5062. }
  5063. }, {
  5064. key: 'get',
  5065. value: function get(name) {
  5066. return this._metadata[name] || null;
  5067. }
  5068. }, {
  5069. key: 'getAll',
  5070. value: function getAll() {
  5071. return this._metadata;
  5072. }
  5073. }, {
  5074. key: 'has',
  5075. value: function has(name) {
  5076. return typeof this._metadata[name] !== 'undefined';
  5077. }
  5078. }, {
  5079. key: 'metadata',
  5080. get: function get() {
  5081. (0, _util.deprecated)('`metadata` getter; use `getAll()` instead.');
  5082. return this.getAll();
  5083. }
  5084. }]);
  5085. return Metadata;
  5086. }();
  5087. exports.Metadata = Metadata;
  5088. /***/ }),
  5089. /* 72 */
  5090. /***/ (function(module, exports, __w_pdfjs_require__) {
  5091. "use strict";
  5092. Object.defineProperty(exports, "__esModule", {
  5093. value: true
  5094. });
  5095. exports.AnnotationLayer = undefined;
  5096. 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; }; }();
  5097. var _dom_utils = __w_pdfjs_require__(13);
  5098. var _util = __w_pdfjs_require__(0);
  5099. 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; }
  5100. 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; }
  5101. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5102. var AnnotationElementFactory = function () {
  5103. function AnnotationElementFactory() {
  5104. _classCallCheck(this, AnnotationElementFactory);
  5105. }
  5106. _createClass(AnnotationElementFactory, null, [{
  5107. key: 'create',
  5108. value: function create(parameters) {
  5109. var subtype = parameters.data.annotationType;
  5110. switch (subtype) {
  5111. case _util.AnnotationType.LINK:
  5112. return new LinkAnnotationElement(parameters);
  5113. case _util.AnnotationType.TEXT:
  5114. return new TextAnnotationElement(parameters);
  5115. case _util.AnnotationType.WIDGET:
  5116. var fieldType = parameters.data.fieldType;
  5117. switch (fieldType) {
  5118. case 'Tx':
  5119. return new TextWidgetAnnotationElement(parameters);
  5120. case 'Btn':
  5121. if (parameters.data.radioButton) {
  5122. return new RadioButtonWidgetAnnotationElement(parameters);
  5123. } else if (parameters.data.checkBox) {
  5124. return new CheckboxWidgetAnnotationElement(parameters);
  5125. }
  5126. (0, _util.warn)('Unimplemented button widget annotation: pushbutton');
  5127. break;
  5128. case 'Ch':
  5129. return new ChoiceWidgetAnnotationElement(parameters);
  5130. }
  5131. return new WidgetAnnotationElement(parameters);
  5132. case _util.AnnotationType.POPUP:
  5133. return new PopupAnnotationElement(parameters);
  5134. case _util.AnnotationType.LINE:
  5135. return new LineAnnotationElement(parameters);
  5136. case _util.AnnotationType.SQUARE:
  5137. return new SquareAnnotationElement(parameters);
  5138. case _util.AnnotationType.CIRCLE:
  5139. return new CircleAnnotationElement(parameters);
  5140. case _util.AnnotationType.POLYLINE:
  5141. return new PolylineAnnotationElement(parameters);
  5142. case _util.AnnotationType.POLYGON:
  5143. return new PolygonAnnotationElement(parameters);
  5144. case _util.AnnotationType.HIGHLIGHT:
  5145. return new HighlightAnnotationElement(parameters);
  5146. case _util.AnnotationType.UNDERLINE:
  5147. return new UnderlineAnnotationElement(parameters);
  5148. case _util.AnnotationType.SQUIGGLY:
  5149. return new SquigglyAnnotationElement(parameters);
  5150. case _util.AnnotationType.STRIKEOUT:
  5151. return new StrikeOutAnnotationElement(parameters);
  5152. case _util.AnnotationType.STAMP:
  5153. return new StampAnnotationElement(parameters);
  5154. case _util.AnnotationType.FILEATTACHMENT:
  5155. return new FileAttachmentAnnotationElement(parameters);
  5156. default:
  5157. return new AnnotationElement(parameters);
  5158. }
  5159. }
  5160. }]);
  5161. return AnnotationElementFactory;
  5162. }();
  5163. var AnnotationElement = function () {
  5164. function AnnotationElement(parameters) {
  5165. var isRenderable = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  5166. var ignoreBorder = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  5167. _classCallCheck(this, AnnotationElement);
  5168. this.isRenderable = isRenderable;
  5169. this.data = parameters.data;
  5170. this.layer = parameters.layer;
  5171. this.page = parameters.page;
  5172. this.viewport = parameters.viewport;
  5173. this.linkService = parameters.linkService;
  5174. this.downloadManager = parameters.downloadManager;
  5175. this.imageResourcesPath = parameters.imageResourcesPath;
  5176. this.renderInteractiveForms = parameters.renderInteractiveForms;
  5177. this.svgFactory = parameters.svgFactory;
  5178. if (isRenderable) {
  5179. this.container = this._createContainer(ignoreBorder);
  5180. }
  5181. }
  5182. _createClass(AnnotationElement, [{
  5183. key: '_createContainer',
  5184. value: function _createContainer() {
  5185. var ignoreBorder = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5186. var data = this.data,
  5187. page = this.page,
  5188. viewport = this.viewport;
  5189. var container = document.createElement('section');
  5190. var width = data.rect[2] - data.rect[0];
  5191. var height = data.rect[3] - data.rect[1];
  5192. container.setAttribute('data-annotation-id', data.id);
  5193. var rect = _util.Util.normalizeRect([data.rect[0], page.view[3] - data.rect[1] + page.view[1], data.rect[2], page.view[3] - data.rect[3] + page.view[1]]);
  5194. _dom_utils.CustomStyle.setProp('transform', container, 'matrix(' + viewport.transform.join(',') + ')');
  5195. _dom_utils.CustomStyle.setProp('transformOrigin', container, -rect[0] + 'px ' + -rect[1] + 'px');
  5196. if (!ignoreBorder && data.borderStyle.width > 0) {
  5197. container.style.borderWidth = data.borderStyle.width + 'px';
  5198. if (data.borderStyle.style !== _util.AnnotationBorderStyleType.UNDERLINE) {
  5199. width = width - 2 * data.borderStyle.width;
  5200. height = height - 2 * data.borderStyle.width;
  5201. }
  5202. var horizontalRadius = data.borderStyle.horizontalCornerRadius;
  5203. var verticalRadius = data.borderStyle.verticalCornerRadius;
  5204. if (horizontalRadius > 0 || verticalRadius > 0) {
  5205. var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';
  5206. _dom_utils.CustomStyle.setProp('borderRadius', container, radius);
  5207. }
  5208. switch (data.borderStyle.style) {
  5209. case _util.AnnotationBorderStyleType.SOLID:
  5210. container.style.borderStyle = 'solid';
  5211. break;
  5212. case _util.AnnotationBorderStyleType.DASHED:
  5213. container.style.borderStyle = 'dashed';
  5214. break;
  5215. case _util.AnnotationBorderStyleType.BEVELED:
  5216. (0, _util.warn)('Unimplemented border style: beveled');
  5217. break;
  5218. case _util.AnnotationBorderStyleType.INSET:
  5219. (0, _util.warn)('Unimplemented border style: inset');
  5220. break;
  5221. case _util.AnnotationBorderStyleType.UNDERLINE:
  5222. container.style.borderBottomStyle = 'solid';
  5223. break;
  5224. default:
  5225. break;
  5226. }
  5227. if (data.color) {
  5228. container.style.borderColor = _util.Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
  5229. } else {
  5230. container.style.borderWidth = 0;
  5231. }
  5232. }
  5233. container.style.left = rect[0] + 'px';
  5234. container.style.top = rect[1] + 'px';
  5235. container.style.width = width + 'px';
  5236. container.style.height = height + 'px';
  5237. return container;
  5238. }
  5239. }, {
  5240. key: '_createPopup',
  5241. value: function _createPopup(container, trigger, data) {
  5242. if (!trigger) {
  5243. trigger = document.createElement('div');
  5244. trigger.style.height = container.style.height;
  5245. trigger.style.width = container.style.width;
  5246. container.appendChild(trigger);
  5247. }
  5248. var popupElement = new PopupElement({
  5249. container: container,
  5250. trigger: trigger,
  5251. color: data.color,
  5252. title: data.title,
  5253. contents: data.contents,
  5254. hideWrapper: true
  5255. });
  5256. var popup = popupElement.render();
  5257. popup.style.left = container.style.width;
  5258. container.appendChild(popup);
  5259. }
  5260. }, {
  5261. key: 'render',
  5262. value: function render() {
  5263. throw new Error('Abstract method `AnnotationElement.render` called');
  5264. }
  5265. }]);
  5266. return AnnotationElement;
  5267. }();
  5268. var LinkAnnotationElement = function (_AnnotationElement) {
  5269. _inherits(LinkAnnotationElement, _AnnotationElement);
  5270. function LinkAnnotationElement(parameters) {
  5271. _classCallCheck(this, LinkAnnotationElement);
  5272. var isRenderable = !!(parameters.data.url || parameters.data.dest || parameters.data.action);
  5273. return _possibleConstructorReturn(this, (LinkAnnotationElement.__proto__ || Object.getPrototypeOf(LinkAnnotationElement)).call(this, parameters, isRenderable));
  5274. }
  5275. _createClass(LinkAnnotationElement, [{
  5276. key: 'render',
  5277. value: function render() {
  5278. this.container.className = 'linkAnnotation';
  5279. var link = document.createElement('a');
  5280. (0, _dom_utils.addLinkAttributes)(link, {
  5281. url: this.data.url,
  5282. target: this.data.newWindow ? _dom_utils.LinkTarget.BLANK : undefined
  5283. });
  5284. if (!this.data.url) {
  5285. if (this.data.action) {
  5286. this._bindNamedAction(link, this.data.action);
  5287. } else {
  5288. this._bindLink(link, this.data.dest);
  5289. }
  5290. }
  5291. this.container.appendChild(link);
  5292. return this.container;
  5293. }
  5294. }, {
  5295. key: '_bindLink',
  5296. value: function _bindLink(link, destination) {
  5297. var _this2 = this;
  5298. link.href = this.linkService.getDestinationHash(destination);
  5299. link.onclick = function () {
  5300. if (destination) {
  5301. _this2.linkService.navigateTo(destination);
  5302. }
  5303. return false;
  5304. };
  5305. if (destination) {
  5306. link.className = 'internalLink';
  5307. }
  5308. }
  5309. }, {
  5310. key: '_bindNamedAction',
  5311. value: function _bindNamedAction(link, action) {
  5312. var _this3 = this;
  5313. link.href = this.linkService.getAnchorUrl('');
  5314. link.onclick = function () {
  5315. _this3.linkService.executeNamedAction(action);
  5316. return false;
  5317. };
  5318. link.className = 'internalLink';
  5319. }
  5320. }]);
  5321. return LinkAnnotationElement;
  5322. }(AnnotationElement);
  5323. var TextAnnotationElement = function (_AnnotationElement2) {
  5324. _inherits(TextAnnotationElement, _AnnotationElement2);
  5325. function TextAnnotationElement(parameters) {
  5326. _classCallCheck(this, TextAnnotationElement);
  5327. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  5328. return _possibleConstructorReturn(this, (TextAnnotationElement.__proto__ || Object.getPrototypeOf(TextAnnotationElement)).call(this, parameters, isRenderable));
  5329. }
  5330. _createClass(TextAnnotationElement, [{
  5331. key: 'render',
  5332. value: function render() {
  5333. this.container.className = 'textAnnotation';
  5334. var image = document.createElement('img');
  5335. image.style.height = this.container.style.height;
  5336. image.style.width = this.container.style.width;
  5337. image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg';
  5338. image.alt = '[{{type}} Annotation]';
  5339. image.dataset.l10nId = 'text_annotation_type';
  5340. image.dataset.l10nArgs = JSON.stringify({ type: this.data.name });
  5341. if (!this.data.hasPopup) {
  5342. this._createPopup(this.container, image, this.data);
  5343. }
  5344. this.container.appendChild(image);
  5345. return this.container;
  5346. }
  5347. }]);
  5348. return TextAnnotationElement;
  5349. }(AnnotationElement);
  5350. var WidgetAnnotationElement = function (_AnnotationElement3) {
  5351. _inherits(WidgetAnnotationElement, _AnnotationElement3);
  5352. function WidgetAnnotationElement() {
  5353. _classCallCheck(this, WidgetAnnotationElement);
  5354. return _possibleConstructorReturn(this, (WidgetAnnotationElement.__proto__ || Object.getPrototypeOf(WidgetAnnotationElement)).apply(this, arguments));
  5355. }
  5356. _createClass(WidgetAnnotationElement, [{
  5357. key: 'render',
  5358. value: function render() {
  5359. return this.container;
  5360. }
  5361. }]);
  5362. return WidgetAnnotationElement;
  5363. }(AnnotationElement);
  5364. var TextWidgetAnnotationElement = function (_WidgetAnnotationElem) {
  5365. _inherits(TextWidgetAnnotationElement, _WidgetAnnotationElem);
  5366. function TextWidgetAnnotationElement(parameters) {
  5367. _classCallCheck(this, TextWidgetAnnotationElement);
  5368. var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
  5369. return _possibleConstructorReturn(this, (TextWidgetAnnotationElement.__proto__ || Object.getPrototypeOf(TextWidgetAnnotationElement)).call(this, parameters, isRenderable));
  5370. }
  5371. _createClass(TextWidgetAnnotationElement, [{
  5372. key: 'render',
  5373. value: function render() {
  5374. var TEXT_ALIGNMENT = ['left', 'center', 'right'];
  5375. this.container.className = 'textWidgetAnnotation';
  5376. var element = null;
  5377. if (this.renderInteractiveForms) {
  5378. if (this.data.multiLine) {
  5379. element = document.createElement('textarea');
  5380. element.textContent = this.data.fieldValue;
  5381. } else {
  5382. element = document.createElement('input');
  5383. element.type = 'text';
  5384. element.setAttribute('value', this.data.fieldValue);
  5385. }
  5386. element.disabled = this.data.readOnly;
  5387. if (this.data.maxLen !== null) {
  5388. element.maxLength = this.data.maxLen;
  5389. }
  5390. if (this.data.comb) {
  5391. var fieldWidth = this.data.rect[2] - this.data.rect[0];
  5392. var combWidth = fieldWidth / this.data.maxLen;
  5393. element.classList.add('comb');
  5394. element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)';
  5395. }
  5396. } else {
  5397. element = document.createElement('div');
  5398. element.textContent = this.data.fieldValue;
  5399. element.style.verticalAlign = 'middle';
  5400. element.style.display = 'table-cell';
  5401. var font = null;
  5402. if (this.data.fontRefName) {
  5403. font = this.page.commonObjs.getData(this.data.fontRefName);
  5404. }
  5405. this._setTextStyle(element, font);
  5406. }
  5407. if (this.data.textAlignment !== null) {
  5408. element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
  5409. }
  5410. this.container.appendChild(element);
  5411. return this.container;
  5412. }
  5413. }, {
  5414. key: '_setTextStyle',
  5415. value: function _setTextStyle(element, font) {
  5416. var style = element.style;
  5417. style.fontSize = this.data.fontSize + 'px';
  5418. style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr';
  5419. if (!font) {
  5420. return;
  5421. }
  5422. style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal';
  5423. style.fontStyle = font.italic ? 'italic' : 'normal';
  5424. var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : '';
  5425. var fallbackName = font.fallbackName || 'Helvetica, sans-serif';
  5426. style.fontFamily = fontFamily + fallbackName;
  5427. }
  5428. }]);
  5429. return TextWidgetAnnotationElement;
  5430. }(WidgetAnnotationElement);
  5431. var CheckboxWidgetAnnotationElement = function (_WidgetAnnotationElem2) {
  5432. _inherits(CheckboxWidgetAnnotationElement, _WidgetAnnotationElem2);
  5433. function CheckboxWidgetAnnotationElement(parameters) {
  5434. _classCallCheck(this, CheckboxWidgetAnnotationElement);
  5435. return _possibleConstructorReturn(this, (CheckboxWidgetAnnotationElement.__proto__ || Object.getPrototypeOf(CheckboxWidgetAnnotationElement)).call(this, parameters, parameters.renderInteractiveForms));
  5436. }
  5437. _createClass(CheckboxWidgetAnnotationElement, [{
  5438. key: 'render',
  5439. value: function render() {
  5440. this.container.className = 'buttonWidgetAnnotation checkBox';
  5441. var element = document.createElement('input');
  5442. element.disabled = this.data.readOnly;
  5443. element.type = 'checkbox';
  5444. if (this.data.fieldValue && this.data.fieldValue !== 'Off') {
  5445. element.setAttribute('checked', true);
  5446. }
  5447. this.container.appendChild(element);
  5448. return this.container;
  5449. }
  5450. }]);
  5451. return CheckboxWidgetAnnotationElement;
  5452. }(WidgetAnnotationElement);
  5453. var RadioButtonWidgetAnnotationElement = function (_WidgetAnnotationElem3) {
  5454. _inherits(RadioButtonWidgetAnnotationElement, _WidgetAnnotationElem3);
  5455. function RadioButtonWidgetAnnotationElement(parameters) {
  5456. _classCallCheck(this, RadioButtonWidgetAnnotationElement);
  5457. return _possibleConstructorReturn(this, (RadioButtonWidgetAnnotationElement.__proto__ || Object.getPrototypeOf(RadioButtonWidgetAnnotationElement)).call(this, parameters, parameters.renderInteractiveForms));
  5458. }
  5459. _createClass(RadioButtonWidgetAnnotationElement, [{
  5460. key: 'render',
  5461. value: function render() {
  5462. this.container.className = 'buttonWidgetAnnotation radioButton';
  5463. var element = document.createElement('input');
  5464. element.disabled = this.data.readOnly;
  5465. element.type = 'radio';
  5466. element.name = this.data.fieldName;
  5467. if (this.data.fieldValue === this.data.buttonValue) {
  5468. element.setAttribute('checked', true);
  5469. }
  5470. this.container.appendChild(element);
  5471. return this.container;
  5472. }
  5473. }]);
  5474. return RadioButtonWidgetAnnotationElement;
  5475. }(WidgetAnnotationElement);
  5476. var ChoiceWidgetAnnotationElement = function (_WidgetAnnotationElem4) {
  5477. _inherits(ChoiceWidgetAnnotationElement, _WidgetAnnotationElem4);
  5478. function ChoiceWidgetAnnotationElement(parameters) {
  5479. _classCallCheck(this, ChoiceWidgetAnnotationElement);
  5480. return _possibleConstructorReturn(this, (ChoiceWidgetAnnotationElement.__proto__ || Object.getPrototypeOf(ChoiceWidgetAnnotationElement)).call(this, parameters, parameters.renderInteractiveForms));
  5481. }
  5482. _createClass(ChoiceWidgetAnnotationElement, [{
  5483. key: 'render',
  5484. value: function render() {
  5485. this.container.className = 'choiceWidgetAnnotation';
  5486. var selectElement = document.createElement('select');
  5487. selectElement.disabled = this.data.readOnly;
  5488. if (!this.data.combo) {
  5489. selectElement.size = this.data.options.length;
  5490. if (this.data.multiSelect) {
  5491. selectElement.multiple = true;
  5492. }
  5493. }
  5494. for (var i = 0, ii = this.data.options.length; i < ii; i++) {
  5495. var option = this.data.options[i];
  5496. var optionElement = document.createElement('option');
  5497. optionElement.textContent = option.displayValue;
  5498. optionElement.value = option.exportValue;
  5499. if (this.data.fieldValue.indexOf(option.displayValue) >= 0) {
  5500. optionElement.setAttribute('selected', true);
  5501. }
  5502. selectElement.appendChild(optionElement);
  5503. }
  5504. this.container.appendChild(selectElement);
  5505. return this.container;
  5506. }
  5507. }]);
  5508. return ChoiceWidgetAnnotationElement;
  5509. }(WidgetAnnotationElement);
  5510. var PopupAnnotationElement = function (_AnnotationElement4) {
  5511. _inherits(PopupAnnotationElement, _AnnotationElement4);
  5512. function PopupAnnotationElement(parameters) {
  5513. _classCallCheck(this, PopupAnnotationElement);
  5514. var isRenderable = !!(parameters.data.title || parameters.data.contents);
  5515. return _possibleConstructorReturn(this, (PopupAnnotationElement.__proto__ || Object.getPrototypeOf(PopupAnnotationElement)).call(this, parameters, isRenderable));
  5516. }
  5517. _createClass(PopupAnnotationElement, [{
  5518. key: 'render',
  5519. value: function render() {
  5520. var IGNORE_TYPES = ['Line', 'Square', 'Circle', 'PolyLine', 'Polygon'];
  5521. this.container.className = 'popupAnnotation';
  5522. if (IGNORE_TYPES.indexOf(this.data.parentType) >= 0) {
  5523. return this.container;
  5524. }
  5525. var selector = '[data-annotation-id="' + this.data.parentId + '"]';
  5526. var parentElement = this.layer.querySelector(selector);
  5527. if (!parentElement) {
  5528. return this.container;
  5529. }
  5530. var popup = new PopupElement({
  5531. container: this.container,
  5532. trigger: parentElement,
  5533. color: this.data.color,
  5534. title: this.data.title,
  5535. contents: this.data.contents
  5536. });
  5537. var parentLeft = parseFloat(parentElement.style.left);
  5538. var parentWidth = parseFloat(parentElement.style.width);
  5539. _dom_utils.CustomStyle.setProp('transformOrigin', this.container, -(parentLeft + parentWidth) + 'px -' + parentElement.style.top);
  5540. this.container.style.left = parentLeft + parentWidth + 'px';
  5541. this.container.appendChild(popup.render());
  5542. return this.container;
  5543. }
  5544. }]);
  5545. return PopupAnnotationElement;
  5546. }(AnnotationElement);
  5547. var PopupElement = function () {
  5548. function PopupElement(parameters) {
  5549. _classCallCheck(this, PopupElement);
  5550. this.container = parameters.container;
  5551. this.trigger = parameters.trigger;
  5552. this.color = parameters.color;
  5553. this.title = parameters.title;
  5554. this.contents = parameters.contents;
  5555. this.hideWrapper = parameters.hideWrapper || false;
  5556. this.pinned = false;
  5557. }
  5558. _createClass(PopupElement, [{
  5559. key: 'render',
  5560. value: function render() {
  5561. var BACKGROUND_ENLIGHT = 0.7;
  5562. var wrapper = document.createElement('div');
  5563. wrapper.className = 'popupWrapper';
  5564. this.hideElement = this.hideWrapper ? wrapper : this.container;
  5565. this.hideElement.setAttribute('hidden', true);
  5566. var popup = document.createElement('div');
  5567. popup.className = 'popup';
  5568. var color = this.color;
  5569. if (color) {
  5570. var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
  5571. var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
  5572. var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
  5573. popup.style.backgroundColor = _util.Util.makeCssRgb(r | 0, g | 0, b | 0);
  5574. }
  5575. var contents = this._formatContents(this.contents);
  5576. var title = document.createElement('h1');
  5577. title.textContent = this.title;
  5578. this.trigger.addEventListener('click', this._toggle.bind(this));
  5579. this.trigger.addEventListener('mouseover', this._show.bind(this, false));
  5580. this.trigger.addEventListener('mouseout', this._hide.bind(this, false));
  5581. popup.addEventListener('click', this._hide.bind(this, true));
  5582. popup.appendChild(title);
  5583. popup.appendChild(contents);
  5584. wrapper.appendChild(popup);
  5585. return wrapper;
  5586. }
  5587. }, {
  5588. key: '_formatContents',
  5589. value: function _formatContents(contents) {
  5590. var p = document.createElement('p');
  5591. var lines = contents.split(/(?:\r\n?|\n)/);
  5592. for (var i = 0, ii = lines.length; i < ii; ++i) {
  5593. var line = lines[i];
  5594. p.appendChild(document.createTextNode(line));
  5595. if (i < ii - 1) {
  5596. p.appendChild(document.createElement('br'));
  5597. }
  5598. }
  5599. return p;
  5600. }
  5601. }, {
  5602. key: '_toggle',
  5603. value: function _toggle() {
  5604. if (this.pinned) {
  5605. this._hide(true);
  5606. } else {
  5607. this._show(true);
  5608. }
  5609. }
  5610. }, {
  5611. key: '_show',
  5612. value: function _show() {
  5613. var pin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5614. if (pin) {
  5615. this.pinned = true;
  5616. }
  5617. if (this.hideElement.hasAttribute('hidden')) {
  5618. this.hideElement.removeAttribute('hidden');
  5619. this.container.style.zIndex += 1;
  5620. }
  5621. }
  5622. }, {
  5623. key: '_hide',
  5624. value: function _hide() {
  5625. var unpin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  5626. if (unpin) {
  5627. this.pinned = false;
  5628. }
  5629. if (!this.hideElement.hasAttribute('hidden') && !this.pinned) {
  5630. this.hideElement.setAttribute('hidden', true);
  5631. this.container.style.zIndex -= 1;
  5632. }
  5633. }
  5634. }]);
  5635. return PopupElement;
  5636. }();
  5637. var LineAnnotationElement = function (_AnnotationElement5) {
  5638. _inherits(LineAnnotationElement, _AnnotationElement5);
  5639. function LineAnnotationElement(parameters) {
  5640. _classCallCheck(this, LineAnnotationElement);
  5641. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  5642. return _possibleConstructorReturn(this, (LineAnnotationElement.__proto__ || Object.getPrototypeOf(LineAnnotationElement)).call(this, parameters, isRenderable, true));
  5643. }
  5644. _createClass(LineAnnotationElement, [{
  5645. key: 'render',
  5646. value: function render() {
  5647. this.container.className = 'lineAnnotation';
  5648. var data = this.data;
  5649. var width = data.rect[2] - data.rect[0];
  5650. var height = data.rect[3] - data.rect[1];
  5651. var svg = this.svgFactory.create(width, height);
  5652. var line = this.svgFactory.createElement('svg:line');
  5653. line.setAttribute('x1', data.rect[2] - data.lineCoordinates[0]);
  5654. line.setAttribute('y1', data.rect[3] - data.lineCoordinates[1]);
  5655. line.setAttribute('x2', data.rect[2] - data.lineCoordinates[2]);
  5656. line.setAttribute('y2', data.rect[3] - data.lineCoordinates[3]);
  5657. line.setAttribute('stroke-width', data.borderStyle.width);
  5658. line.setAttribute('stroke', 'transparent');
  5659. svg.appendChild(line);
  5660. this.container.append(svg);
  5661. this._createPopup(this.container, line, data);
  5662. return this.container;
  5663. }
  5664. }]);
  5665. return LineAnnotationElement;
  5666. }(AnnotationElement);
  5667. var SquareAnnotationElement = function (_AnnotationElement6) {
  5668. _inherits(SquareAnnotationElement, _AnnotationElement6);
  5669. function SquareAnnotationElement(parameters) {
  5670. _classCallCheck(this, SquareAnnotationElement);
  5671. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  5672. return _possibleConstructorReturn(this, (SquareAnnotationElement.__proto__ || Object.getPrototypeOf(SquareAnnotationElement)).call(this, parameters, isRenderable, true));
  5673. }
  5674. _createClass(SquareAnnotationElement, [{
  5675. key: 'render',
  5676. value: function render() {
  5677. this.container.className = 'squareAnnotation';
  5678. var data = this.data;
  5679. var width = data.rect[2] - data.rect[0];
  5680. var height = data.rect[3] - data.rect[1];
  5681. var svg = this.svgFactory.create(width, height);
  5682. var borderWidth = data.borderStyle.width;
  5683. var square = this.svgFactory.createElement('svg:rect');
  5684. square.setAttribute('x', borderWidth / 2);
  5685. square.setAttribute('y', borderWidth / 2);
  5686. square.setAttribute('width', width - borderWidth);
  5687. square.setAttribute('height', height - borderWidth);
  5688. square.setAttribute('stroke-width', borderWidth);
  5689. square.setAttribute('stroke', 'transparent');
  5690. square.setAttribute('fill', 'none');
  5691. svg.appendChild(square);
  5692. this.container.append(svg);
  5693. this._createPopup(this.container, square, data);
  5694. return this.container;
  5695. }
  5696. }]);
  5697. return SquareAnnotationElement;
  5698. }(AnnotationElement);
  5699. var CircleAnnotationElement = function (_AnnotationElement7) {
  5700. _inherits(CircleAnnotationElement, _AnnotationElement7);
  5701. function CircleAnnotationElement(parameters) {
  5702. _classCallCheck(this, CircleAnnotationElement);
  5703. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  5704. return _possibleConstructorReturn(this, (CircleAnnotationElement.__proto__ || Object.getPrototypeOf(CircleAnnotationElement)).call(this, parameters, isRenderable, true));
  5705. }
  5706. _createClass(CircleAnnotationElement, [{
  5707. key: 'render',
  5708. value: function render() {
  5709. this.container.className = 'circleAnnotation';
  5710. var data = this.data;
  5711. var width = data.rect[2] - data.rect[0];
  5712. var height = data.rect[3] - data.rect[1];
  5713. var svg = this.svgFactory.create(width, height);
  5714. var borderWidth = data.borderStyle.width;
  5715. var circle = this.svgFactory.createElement('svg:ellipse');
  5716. circle.setAttribute('cx', width / 2);
  5717. circle.setAttribute('cy', height / 2);
  5718. circle.setAttribute('rx', width / 2 - borderWidth / 2);
  5719. circle.setAttribute('ry', height / 2 - borderWidth / 2);
  5720. circle.setAttribute('stroke-width', borderWidth);
  5721. circle.setAttribute('stroke', 'transparent');
  5722. circle.setAttribute('fill', 'none');
  5723. svg.appendChild(circle);
  5724. this.container.append(svg);
  5725. this._createPopup(this.container, circle, data);
  5726. return this.container;
  5727. }
  5728. }]);
  5729. return CircleAnnotationElement;
  5730. }(AnnotationElement);
  5731. var PolylineAnnotationElement = function (_AnnotationElement8) {
  5732. _inherits(PolylineAnnotationElement, _AnnotationElement8);
  5733. function PolylineAnnotationElement(parameters) {
  5734. _classCallCheck(this, PolylineAnnotationElement);
  5735. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  5736. var _this14 = _possibleConstructorReturn(this, (PolylineAnnotationElement.__proto__ || Object.getPrototypeOf(PolylineAnnotationElement)).call(this, parameters, isRenderable, true));
  5737. _this14.containerClassName = 'polylineAnnotation';
  5738. _this14.svgElementName = 'svg:polyline';
  5739. return _this14;
  5740. }
  5741. _createClass(PolylineAnnotationElement, [{
  5742. key: 'render',
  5743. value: function render() {
  5744. this.container.className = this.containerClassName;
  5745. var data = this.data;
  5746. var width = data.rect[2] - data.rect[0];
  5747. var height = data.rect[3] - data.rect[1];
  5748. var svg = this.svgFactory.create(width, height);
  5749. var vertices = data.vertices;
  5750. var points = [];
  5751. for (var i = 0, ii = vertices.length; i < ii; i++) {
  5752. var x = vertices[i].x - data.rect[0];
  5753. var y = data.rect[3] - vertices[i].y;
  5754. points.push(x + ',' + y);
  5755. }
  5756. points = points.join(' ');
  5757. var borderWidth = data.borderStyle.width;
  5758. var polyline = this.svgFactory.createElement(this.svgElementName);
  5759. polyline.setAttribute('points', points);
  5760. polyline.setAttribute('stroke-width', borderWidth);
  5761. polyline.setAttribute('stroke', 'transparent');
  5762. polyline.setAttribute('fill', 'none');
  5763. svg.appendChild(polyline);
  5764. this.container.append(svg);
  5765. this._createPopup(this.container, polyline, data);
  5766. return this.container;
  5767. }
  5768. }]);
  5769. return PolylineAnnotationElement;
  5770. }(AnnotationElement);
  5771. var PolygonAnnotationElement = function (_PolylineAnnotationEl) {
  5772. _inherits(PolygonAnnotationElement, _PolylineAnnotationEl);
  5773. function PolygonAnnotationElement(parameters) {
  5774. _classCallCheck(this, PolygonAnnotationElement);
  5775. var _this15 = _possibleConstructorReturn(this, (PolygonAnnotationElement.__proto__ || Object.getPrototypeOf(PolygonAnnotationElement)).call(this, parameters));
  5776. _this15.containerClassName = 'polygonAnnotation';
  5777. _this15.svgElementName = 'svg:polygon';
  5778. return _this15;
  5779. }
  5780. return PolygonAnnotationElement;
  5781. }(PolylineAnnotationElement);
  5782. var HighlightAnnotationElement = function (_AnnotationElement9) {
  5783. _inherits(HighlightAnnotationElement, _AnnotationElement9);
  5784. function HighlightAnnotationElement(parameters) {
  5785. _classCallCheck(this, HighlightAnnotationElement);
  5786. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  5787. return _possibleConstructorReturn(this, (HighlightAnnotationElement.__proto__ || Object.getPrototypeOf(HighlightAnnotationElement)).call(this, parameters, isRenderable, true));
  5788. }
  5789. _createClass(HighlightAnnotationElement, [{
  5790. key: 'render',
  5791. value: function render() {
  5792. this.container.className = 'highlightAnnotation';
  5793. if (!this.data.hasPopup) {
  5794. this._createPopup(this.container, null, this.data);
  5795. }
  5796. return this.container;
  5797. }
  5798. }]);
  5799. return HighlightAnnotationElement;
  5800. }(AnnotationElement);
  5801. var UnderlineAnnotationElement = function (_AnnotationElement10) {
  5802. _inherits(UnderlineAnnotationElement, _AnnotationElement10);
  5803. function UnderlineAnnotationElement(parameters) {
  5804. _classCallCheck(this, UnderlineAnnotationElement);
  5805. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  5806. return _possibleConstructorReturn(this, (UnderlineAnnotationElement.__proto__ || Object.getPrototypeOf(UnderlineAnnotationElement)).call(this, parameters, isRenderable, true));
  5807. }
  5808. _createClass(UnderlineAnnotationElement, [{
  5809. key: 'render',
  5810. value: function render() {
  5811. this.container.className = 'underlineAnnotation';
  5812. if (!this.data.hasPopup) {
  5813. this._createPopup(this.container, null, this.data);
  5814. }
  5815. return this.container;
  5816. }
  5817. }]);
  5818. return UnderlineAnnotationElement;
  5819. }(AnnotationElement);
  5820. var SquigglyAnnotationElement = function (_AnnotationElement11) {
  5821. _inherits(SquigglyAnnotationElement, _AnnotationElement11);
  5822. function SquigglyAnnotationElement(parameters) {
  5823. _classCallCheck(this, SquigglyAnnotationElement);
  5824. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  5825. return _possibleConstructorReturn(this, (SquigglyAnnotationElement.__proto__ || Object.getPrototypeOf(SquigglyAnnotationElement)).call(this, parameters, isRenderable, true));
  5826. }
  5827. _createClass(SquigglyAnnotationElement, [{
  5828. key: 'render',
  5829. value: function render() {
  5830. this.container.className = 'squigglyAnnotation';
  5831. if (!this.data.hasPopup) {
  5832. this._createPopup(this.container, null, this.data);
  5833. }
  5834. return this.container;
  5835. }
  5836. }]);
  5837. return SquigglyAnnotationElement;
  5838. }(AnnotationElement);
  5839. var StrikeOutAnnotationElement = function (_AnnotationElement12) {
  5840. _inherits(StrikeOutAnnotationElement, _AnnotationElement12);
  5841. function StrikeOutAnnotationElement(parameters) {
  5842. _classCallCheck(this, StrikeOutAnnotationElement);
  5843. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  5844. return _possibleConstructorReturn(this, (StrikeOutAnnotationElement.__proto__ || Object.getPrototypeOf(StrikeOutAnnotationElement)).call(this, parameters, isRenderable, true));
  5845. }
  5846. _createClass(StrikeOutAnnotationElement, [{
  5847. key: 'render',
  5848. value: function render() {
  5849. this.container.className = 'strikeoutAnnotation';
  5850. if (!this.data.hasPopup) {
  5851. this._createPopup(this.container, null, this.data);
  5852. }
  5853. return this.container;
  5854. }
  5855. }]);
  5856. return StrikeOutAnnotationElement;
  5857. }(AnnotationElement);
  5858. var StampAnnotationElement = function (_AnnotationElement13) {
  5859. _inherits(StampAnnotationElement, _AnnotationElement13);
  5860. function StampAnnotationElement(parameters) {
  5861. _classCallCheck(this, StampAnnotationElement);
  5862. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  5863. return _possibleConstructorReturn(this, (StampAnnotationElement.__proto__ || Object.getPrototypeOf(StampAnnotationElement)).call(this, parameters, isRenderable, true));
  5864. }
  5865. _createClass(StampAnnotationElement, [{
  5866. key: 'render',
  5867. value: function render() {
  5868. this.container.className = 'stampAnnotation';
  5869. if (!this.data.hasPopup) {
  5870. this._createPopup(this.container, null, this.data);
  5871. }
  5872. return this.container;
  5873. }
  5874. }]);
  5875. return StampAnnotationElement;
  5876. }(AnnotationElement);
  5877. var FileAttachmentAnnotationElement = function (_AnnotationElement14) {
  5878. _inherits(FileAttachmentAnnotationElement, _AnnotationElement14);
  5879. function FileAttachmentAnnotationElement(parameters) {
  5880. _classCallCheck(this, FileAttachmentAnnotationElement);
  5881. var _this21 = _possibleConstructorReturn(this, (FileAttachmentAnnotationElement.__proto__ || Object.getPrototypeOf(FileAttachmentAnnotationElement)).call(this, parameters, true));
  5882. var file = _this21.data.file;
  5883. _this21.filename = (0, _dom_utils.getFilenameFromUrl)(file.filename);
  5884. _this21.content = file.content;
  5885. _this21.linkService.onFileAttachmentAnnotation({
  5886. id: (0, _util.stringToPDFString)(file.filename),
  5887. filename: file.filename,
  5888. content: file.content
  5889. });
  5890. return _this21;
  5891. }
  5892. _createClass(FileAttachmentAnnotationElement, [{
  5893. key: 'render',
  5894. value: function render() {
  5895. this.container.className = 'fileAttachmentAnnotation';
  5896. var trigger = document.createElement('div');
  5897. trigger.style.height = this.container.style.height;
  5898. trigger.style.width = this.container.style.width;
  5899. trigger.addEventListener('dblclick', this._download.bind(this));
  5900. if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
  5901. this._createPopup(this.container, trigger, this.data);
  5902. }
  5903. this.container.appendChild(trigger);
  5904. return this.container;
  5905. }
  5906. }, {
  5907. key: '_download',
  5908. value: function _download() {
  5909. if (!this.downloadManager) {
  5910. (0, _util.warn)('Download cannot be started due to unavailable download manager');
  5911. return;
  5912. }
  5913. this.downloadManager.downloadData(this.content, this.filename, '');
  5914. }
  5915. }]);
  5916. return FileAttachmentAnnotationElement;
  5917. }(AnnotationElement);
  5918. var AnnotationLayer = function () {
  5919. function AnnotationLayer() {
  5920. _classCallCheck(this, AnnotationLayer);
  5921. }
  5922. _createClass(AnnotationLayer, null, [{
  5923. key: 'render',
  5924. value: function render(parameters) {
  5925. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  5926. var data = parameters.annotations[i];
  5927. if (!data) {
  5928. continue;
  5929. }
  5930. var element = AnnotationElementFactory.create({
  5931. data: data,
  5932. layer: parameters.div,
  5933. page: parameters.page,
  5934. viewport: parameters.viewport,
  5935. linkService: parameters.linkService,
  5936. downloadManager: parameters.downloadManager,
  5937. imageResourcesPath: parameters.imageResourcesPath || (0, _dom_utils.getDefaultSetting)('imageResourcesPath'),
  5938. renderInteractiveForms: parameters.renderInteractiveForms || false,
  5939. svgFactory: new _dom_utils.DOMSVGFactory()
  5940. });
  5941. if (element.isRenderable) {
  5942. parameters.div.appendChild(element.render());
  5943. }
  5944. }
  5945. }
  5946. }, {
  5947. key: 'update',
  5948. value: function update(parameters) {
  5949. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  5950. var data = parameters.annotations[i];
  5951. var element = parameters.div.querySelector('[data-annotation-id="' + data.id + '"]');
  5952. if (element) {
  5953. _dom_utils.CustomStyle.setProp('transform', element, 'matrix(' + parameters.viewport.transform.join(',') + ')');
  5954. }
  5955. }
  5956. parameters.div.removeAttribute('hidden');
  5957. }
  5958. }]);
  5959. return AnnotationLayer;
  5960. }();
  5961. exports.AnnotationLayer = AnnotationLayer;
  5962. /***/ }),
  5963. /* 73 */
  5964. /***/ (function(module, exports, __w_pdfjs_require__) {
  5965. "use strict";
  5966. Object.defineProperty(exports, "__esModule", {
  5967. value: true
  5968. });
  5969. exports.renderTextLayer = undefined;
  5970. var _util = __w_pdfjs_require__(0);
  5971. var _dom_utils = __w_pdfjs_require__(13);
  5972. var renderTextLayer = function renderTextLayerClosure() {
  5973. var MAX_TEXT_DIVS_TO_RENDER = 100000;
  5974. var NonWhitespaceRegexp = /\S/;
  5975. function isAllWhitespace(str) {
  5976. return !NonWhitespaceRegexp.test(str);
  5977. }
  5978. var styleBuf = ['left: ', 0, 'px; top: ', 0, 'px; font-size: ', 0, 'px; font-family: ', '', ';'];
  5979. function appendText(task, geom, styles) {
  5980. var textDiv = document.createElement('div');
  5981. var textDivProperties = {
  5982. style: null,
  5983. angle: 0,
  5984. canvasWidth: 0,
  5985. isWhitespace: false,
  5986. originalTransform: null,
  5987. paddingBottom: 0,
  5988. paddingLeft: 0,
  5989. paddingRight: 0,
  5990. paddingTop: 0,
  5991. scale: 1
  5992. };
  5993. task._textDivs.push(textDiv);
  5994. if (isAllWhitespace(geom.str)) {
  5995. textDivProperties.isWhitespace = true;
  5996. task._textDivProperties.set(textDiv, textDivProperties);
  5997. return;
  5998. }
  5999. var tx = _util.Util.transform(task._viewport.transform, geom.transform);
  6000. var angle = Math.atan2(tx[1], tx[0]);
  6001. var style = styles[geom.fontName];
  6002. if (style.vertical) {
  6003. angle += Math.PI / 2;
  6004. }
  6005. var fontHeight = Math.sqrt(tx[2] * tx[2] + tx[3] * tx[3]);
  6006. var fontAscent = fontHeight;
  6007. if (style.ascent) {
  6008. fontAscent = style.ascent * fontAscent;
  6009. } else if (style.descent) {
  6010. fontAscent = (1 + style.descent) * fontAscent;
  6011. }
  6012. var left;
  6013. var top;
  6014. if (angle === 0) {
  6015. left = tx[4];
  6016. top = tx[5] - fontAscent;
  6017. } else {
  6018. left = tx[4] + fontAscent * Math.sin(angle);
  6019. top = tx[5] - fontAscent * Math.cos(angle);
  6020. }
  6021. styleBuf[1] = left;
  6022. styleBuf[3] = top;
  6023. styleBuf[5] = fontHeight;
  6024. styleBuf[7] = style.fontFamily;
  6025. textDivProperties.style = styleBuf.join('');
  6026. textDiv.setAttribute('style', textDivProperties.style);
  6027. textDiv.textContent = geom.str;
  6028. if ((0, _dom_utils.getDefaultSetting)('pdfBug')) {
  6029. textDiv.dataset.fontName = geom.fontName;
  6030. }
  6031. if (angle !== 0) {
  6032. textDivProperties.angle = angle * (180 / Math.PI);
  6033. }
  6034. if (geom.str.length > 1) {
  6035. if (style.vertical) {
  6036. textDivProperties.canvasWidth = geom.height * task._viewport.scale;
  6037. } else {
  6038. textDivProperties.canvasWidth = geom.width * task._viewport.scale;
  6039. }
  6040. }
  6041. task._textDivProperties.set(textDiv, textDivProperties);
  6042. if (task._textContentStream) {
  6043. task._layoutText(textDiv);
  6044. }
  6045. if (task._enhanceTextSelection) {
  6046. var angleCos = 1,
  6047. angleSin = 0;
  6048. if (angle !== 0) {
  6049. angleCos = Math.cos(angle);
  6050. angleSin = Math.sin(angle);
  6051. }
  6052. var divWidth = (style.vertical ? geom.height : geom.width) * task._viewport.scale;
  6053. var divHeight = fontHeight;
  6054. var m, b;
  6055. if (angle !== 0) {
  6056. m = [angleCos, angleSin, -angleSin, angleCos, left, top];
  6057. b = _util.Util.getAxialAlignedBoundingBox([0, 0, divWidth, divHeight], m);
  6058. } else {
  6059. b = [left, top, left + divWidth, top + divHeight];
  6060. }
  6061. task._bounds.push({
  6062. left: b[0],
  6063. top: b[1],
  6064. right: b[2],
  6065. bottom: b[3],
  6066. div: textDiv,
  6067. size: [divWidth, divHeight],
  6068. m: m
  6069. });
  6070. }
  6071. }
  6072. function render(task) {
  6073. if (task._canceled) {
  6074. return;
  6075. }
  6076. var textDivs = task._textDivs;
  6077. var capability = task._capability;
  6078. var textDivsLength = textDivs.length;
  6079. if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) {
  6080. task._renderingDone = true;
  6081. capability.resolve();
  6082. return;
  6083. }
  6084. if (!task._textContentStream) {
  6085. for (var i = 0; i < textDivsLength; i++) {
  6086. task._layoutText(textDivs[i]);
  6087. }
  6088. }
  6089. task._renderingDone = true;
  6090. capability.resolve();
  6091. }
  6092. function expand(task) {
  6093. var bounds = task._bounds;
  6094. var viewport = task._viewport;
  6095. var expanded = expandBounds(viewport.width, viewport.height, bounds);
  6096. for (var i = 0; i < expanded.length; i++) {
  6097. var div = bounds[i].div;
  6098. var divProperties = task._textDivProperties.get(div);
  6099. if (divProperties.angle === 0) {
  6100. divProperties.paddingLeft = bounds[i].left - expanded[i].left;
  6101. divProperties.paddingTop = bounds[i].top - expanded[i].top;
  6102. divProperties.paddingRight = expanded[i].right - bounds[i].right;
  6103. divProperties.paddingBottom = expanded[i].bottom - bounds[i].bottom;
  6104. task._textDivProperties.set(div, divProperties);
  6105. continue;
  6106. }
  6107. var e = expanded[i],
  6108. b = bounds[i];
  6109. var m = b.m,
  6110. c = m[0],
  6111. s = m[1];
  6112. var points = [[0, 0], [0, b.size[1]], [b.size[0], 0], b.size];
  6113. var ts = new Float64Array(64);
  6114. points.forEach(function (p, i) {
  6115. var t = _util.Util.applyTransform(p, m);
  6116. ts[i + 0] = c && (e.left - t[0]) / c;
  6117. ts[i + 4] = s && (e.top - t[1]) / s;
  6118. ts[i + 8] = c && (e.right - t[0]) / c;
  6119. ts[i + 12] = s && (e.bottom - t[1]) / s;
  6120. ts[i + 16] = s && (e.left - t[0]) / -s;
  6121. ts[i + 20] = c && (e.top - t[1]) / c;
  6122. ts[i + 24] = s && (e.right - t[0]) / -s;
  6123. ts[i + 28] = c && (e.bottom - t[1]) / c;
  6124. ts[i + 32] = c && (e.left - t[0]) / -c;
  6125. ts[i + 36] = s && (e.top - t[1]) / -s;
  6126. ts[i + 40] = c && (e.right - t[0]) / -c;
  6127. ts[i + 44] = s && (e.bottom - t[1]) / -s;
  6128. ts[i + 48] = s && (e.left - t[0]) / s;
  6129. ts[i + 52] = c && (e.top - t[1]) / -c;
  6130. ts[i + 56] = s && (e.right - t[0]) / s;
  6131. ts[i + 60] = c && (e.bottom - t[1]) / -c;
  6132. });
  6133. var findPositiveMin = function findPositiveMin(ts, offset, count) {
  6134. var result = 0;
  6135. for (var i = 0; i < count; i++) {
  6136. var t = ts[offset++];
  6137. if (t > 0) {
  6138. result = result ? Math.min(t, result) : t;
  6139. }
  6140. }
  6141. return result;
  6142. };
  6143. var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s));
  6144. divProperties.paddingLeft = findPositiveMin(ts, 32, 16) / boxScale;
  6145. divProperties.paddingTop = findPositiveMin(ts, 48, 16) / boxScale;
  6146. divProperties.paddingRight = findPositiveMin(ts, 0, 16) / boxScale;
  6147. divProperties.paddingBottom = findPositiveMin(ts, 16, 16) / boxScale;
  6148. task._textDivProperties.set(div, divProperties);
  6149. }
  6150. }
  6151. function expandBounds(width, height, boxes) {
  6152. var bounds = boxes.map(function (box, i) {
  6153. return {
  6154. x1: box.left,
  6155. y1: box.top,
  6156. x2: box.right,
  6157. y2: box.bottom,
  6158. index: i,
  6159. x1New: undefined,
  6160. x2New: undefined
  6161. };
  6162. });
  6163. expandBoundsLTR(width, bounds);
  6164. var expanded = new Array(boxes.length);
  6165. bounds.forEach(function (b) {
  6166. var i = b.index;
  6167. expanded[i] = {
  6168. left: b.x1New,
  6169. top: 0,
  6170. right: b.x2New,
  6171. bottom: 0
  6172. };
  6173. });
  6174. boxes.map(function (box, i) {
  6175. var e = expanded[i],
  6176. b = bounds[i];
  6177. b.x1 = box.top;
  6178. b.y1 = width - e.right;
  6179. b.x2 = box.bottom;
  6180. b.y2 = width - e.left;
  6181. b.index = i;
  6182. b.x1New = undefined;
  6183. b.x2New = undefined;
  6184. });
  6185. expandBoundsLTR(height, bounds);
  6186. bounds.forEach(function (b) {
  6187. var i = b.index;
  6188. expanded[i].top = b.x1New;
  6189. expanded[i].bottom = b.x2New;
  6190. });
  6191. return expanded;
  6192. }
  6193. function expandBoundsLTR(width, bounds) {
  6194. bounds.sort(function (a, b) {
  6195. return a.x1 - b.x1 || a.index - b.index;
  6196. });
  6197. var fakeBoundary = {
  6198. x1: -Infinity,
  6199. y1: -Infinity,
  6200. x2: 0,
  6201. y2: Infinity,
  6202. index: -1,
  6203. x1New: 0,
  6204. x2New: 0
  6205. };
  6206. var horizon = [{
  6207. start: -Infinity,
  6208. end: Infinity,
  6209. boundary: fakeBoundary
  6210. }];
  6211. bounds.forEach(function (boundary) {
  6212. var i = 0;
  6213. while (i < horizon.length && horizon[i].end <= boundary.y1) {
  6214. i++;
  6215. }
  6216. var j = horizon.length - 1;
  6217. while (j >= 0 && horizon[j].start >= boundary.y2) {
  6218. j--;
  6219. }
  6220. var horizonPart, affectedBoundary;
  6221. var q,
  6222. k,
  6223. maxXNew = -Infinity;
  6224. for (q = i; q <= j; q++) {
  6225. horizonPart = horizon[q];
  6226. affectedBoundary = horizonPart.boundary;
  6227. var xNew;
  6228. if (affectedBoundary.x2 > boundary.x1) {
  6229. xNew = affectedBoundary.index > boundary.index ? affectedBoundary.x1New : boundary.x1;
  6230. } else if (affectedBoundary.x2New === undefined) {
  6231. xNew = (affectedBoundary.x2 + boundary.x1) / 2;
  6232. } else {
  6233. xNew = affectedBoundary.x2New;
  6234. }
  6235. if (xNew > maxXNew) {
  6236. maxXNew = xNew;
  6237. }
  6238. }
  6239. boundary.x1New = maxXNew;
  6240. for (q = i; q <= j; q++) {
  6241. horizonPart = horizon[q];
  6242. affectedBoundary = horizonPart.boundary;
  6243. if (affectedBoundary.x2New === undefined) {
  6244. if (affectedBoundary.x2 > boundary.x1) {
  6245. if (affectedBoundary.index > boundary.index) {
  6246. affectedBoundary.x2New = affectedBoundary.x2;
  6247. }
  6248. } else {
  6249. affectedBoundary.x2New = maxXNew;
  6250. }
  6251. } else if (affectedBoundary.x2New > maxXNew) {
  6252. affectedBoundary.x2New = Math.max(maxXNew, affectedBoundary.x2);
  6253. }
  6254. }
  6255. var changedHorizon = [],
  6256. lastBoundary = null;
  6257. for (q = i; q <= j; q++) {
  6258. horizonPart = horizon[q];
  6259. affectedBoundary = horizonPart.boundary;
  6260. var useBoundary = affectedBoundary.x2 > boundary.x2 ? affectedBoundary : boundary;
  6261. if (lastBoundary === useBoundary) {
  6262. changedHorizon[changedHorizon.length - 1].end = horizonPart.end;
  6263. } else {
  6264. changedHorizon.push({
  6265. start: horizonPart.start,
  6266. end: horizonPart.end,
  6267. boundary: useBoundary
  6268. });
  6269. lastBoundary = useBoundary;
  6270. }
  6271. }
  6272. if (horizon[i].start < boundary.y1) {
  6273. changedHorizon[0].start = boundary.y1;
  6274. changedHorizon.unshift({
  6275. start: horizon[i].start,
  6276. end: boundary.y1,
  6277. boundary: horizon[i].boundary
  6278. });
  6279. }
  6280. if (boundary.y2 < horizon[j].end) {
  6281. changedHorizon[changedHorizon.length - 1].end = boundary.y2;
  6282. changedHorizon.push({
  6283. start: boundary.y2,
  6284. end: horizon[j].end,
  6285. boundary: horizon[j].boundary
  6286. });
  6287. }
  6288. for (q = i; q <= j; q++) {
  6289. horizonPart = horizon[q];
  6290. affectedBoundary = horizonPart.boundary;
  6291. if (affectedBoundary.x2New !== undefined) {
  6292. continue;
  6293. }
  6294. var used = false;
  6295. for (k = i - 1; !used && k >= 0 && horizon[k].start >= affectedBoundary.y1; k--) {
  6296. used = horizon[k].boundary === affectedBoundary;
  6297. }
  6298. for (k = j + 1; !used && k < horizon.length && horizon[k].end <= affectedBoundary.y2; k++) {
  6299. used = horizon[k].boundary === affectedBoundary;
  6300. }
  6301. for (k = 0; !used && k < changedHorizon.length; k++) {
  6302. used = changedHorizon[k].boundary === affectedBoundary;
  6303. }
  6304. if (!used) {
  6305. affectedBoundary.x2New = maxXNew;
  6306. }
  6307. }
  6308. Array.prototype.splice.apply(horizon, [i, j - i + 1].concat(changedHorizon));
  6309. });
  6310. horizon.forEach(function (horizonPart) {
  6311. var affectedBoundary = horizonPart.boundary;
  6312. if (affectedBoundary.x2New === undefined) {
  6313. affectedBoundary.x2New = Math.max(width, affectedBoundary.x2);
  6314. }
  6315. });
  6316. }
  6317. function TextLayerRenderTask(_ref) {
  6318. var textContent = _ref.textContent,
  6319. textContentStream = _ref.textContentStream,
  6320. container = _ref.container,
  6321. viewport = _ref.viewport,
  6322. textDivs = _ref.textDivs,
  6323. textContentItemsStr = _ref.textContentItemsStr,
  6324. enhanceTextSelection = _ref.enhanceTextSelection;
  6325. this._textContent = textContent;
  6326. this._textContentStream = textContentStream;
  6327. this._container = container;
  6328. this._viewport = viewport;
  6329. this._textDivs = textDivs || [];
  6330. this._textContentItemsStr = textContentItemsStr || [];
  6331. this._enhanceTextSelection = !!enhanceTextSelection;
  6332. this._reader = null;
  6333. this._layoutTextLastFontSize = null;
  6334. this._layoutTextLastFontFamily = null;
  6335. this._layoutTextCtx = null;
  6336. this._textDivProperties = new WeakMap();
  6337. this._renderingDone = false;
  6338. this._canceled = false;
  6339. this._capability = (0, _util.createPromiseCapability)();
  6340. this._renderTimer = null;
  6341. this._bounds = [];
  6342. }
  6343. TextLayerRenderTask.prototype = {
  6344. get promise() {
  6345. return this._capability.promise;
  6346. },
  6347. cancel: function TextLayer_cancel() {
  6348. if (this._reader) {
  6349. this._reader.cancel(new _util.AbortException('text layer task cancelled'));
  6350. this._reader = null;
  6351. }
  6352. this._canceled = true;
  6353. if (this._renderTimer !== null) {
  6354. clearTimeout(this._renderTimer);
  6355. this._renderTimer = null;
  6356. }
  6357. this._capability.reject('canceled');
  6358. },
  6359. _processItems: function _processItems(items, styleCache) {
  6360. for (var i = 0, len = items.length; i < len; i++) {
  6361. this._textContentItemsStr.push(items[i].str);
  6362. appendText(this, items[i], styleCache);
  6363. }
  6364. },
  6365. _layoutText: function _layoutText(textDiv) {
  6366. var textLayerFrag = this._container;
  6367. var textDivProperties = this._textDivProperties.get(textDiv);
  6368. if (textDivProperties.isWhitespace) {
  6369. return;
  6370. }
  6371. var fontSize = textDiv.style.fontSize;
  6372. var fontFamily = textDiv.style.fontFamily;
  6373. if (fontSize !== this._layoutTextLastFontSize || fontFamily !== this._layoutTextLastFontFamily) {
  6374. this._layoutTextCtx.font = fontSize + ' ' + fontFamily;
  6375. this._lastFontSize = fontSize;
  6376. this._lastFontFamily = fontFamily;
  6377. }
  6378. var width = this._layoutTextCtx.measureText(textDiv.textContent).width;
  6379. var transform = '';
  6380. if (textDivProperties.canvasWidth !== 0 && width > 0) {
  6381. textDivProperties.scale = textDivProperties.canvasWidth / width;
  6382. transform = 'scaleX(' + textDivProperties.scale + ')';
  6383. }
  6384. if (textDivProperties.angle !== 0) {
  6385. transform = 'rotate(' + textDivProperties.angle + 'deg) ' + transform;
  6386. }
  6387. if (transform !== '') {
  6388. textDivProperties.originalTransform = transform;
  6389. _dom_utils.CustomStyle.setProp('transform', textDiv, transform);
  6390. }
  6391. this._textDivProperties.set(textDiv, textDivProperties);
  6392. textLayerFrag.appendChild(textDiv);
  6393. },
  6394. _render: function TextLayer_render(timeout) {
  6395. var _this = this;
  6396. var capability = (0, _util.createPromiseCapability)();
  6397. var styleCache = Object.create(null);
  6398. var canvas = document.createElement('canvas');
  6399. canvas.mozOpaque = true;
  6400. this._layoutTextCtx = canvas.getContext('2d', { alpha: false });
  6401. if (this._textContent) {
  6402. var textItems = this._textContent.items;
  6403. var textStyles = this._textContent.styles;
  6404. this._processItems(textItems, textStyles);
  6405. capability.resolve();
  6406. } else if (this._textContentStream) {
  6407. var pump = function pump() {
  6408. _this._reader.read().then(function (_ref2) {
  6409. var value = _ref2.value,
  6410. done = _ref2.done;
  6411. if (done) {
  6412. capability.resolve();
  6413. return;
  6414. }
  6415. _util.Util.extendObj(styleCache, value.styles);
  6416. _this._processItems(value.items, styleCache);
  6417. pump();
  6418. }, capability.reject);
  6419. };
  6420. this._reader = this._textContentStream.getReader();
  6421. pump();
  6422. } else {
  6423. throw new Error('Neither "textContent" nor "textContentStream"' + ' parameters specified.');
  6424. }
  6425. capability.promise.then(function () {
  6426. styleCache = null;
  6427. if (!timeout) {
  6428. render(_this);
  6429. } else {
  6430. _this._renderTimer = setTimeout(function () {
  6431. render(_this);
  6432. _this._renderTimer = null;
  6433. }, timeout);
  6434. }
  6435. }, this._capability.reject);
  6436. },
  6437. expandTextDivs: function TextLayer_expandTextDivs(expandDivs) {
  6438. if (!this._enhanceTextSelection || !this._renderingDone) {
  6439. return;
  6440. }
  6441. if (this._bounds !== null) {
  6442. expand(this);
  6443. this._bounds = null;
  6444. }
  6445. for (var i = 0, ii = this._textDivs.length; i < ii; i++) {
  6446. var div = this._textDivs[i];
  6447. var divProperties = this._textDivProperties.get(div);
  6448. if (divProperties.isWhitespace) {
  6449. continue;
  6450. }
  6451. if (expandDivs) {
  6452. var transform = '',
  6453. padding = '';
  6454. if (divProperties.scale !== 1) {
  6455. transform = 'scaleX(' + divProperties.scale + ')';
  6456. }
  6457. if (divProperties.angle !== 0) {
  6458. transform = 'rotate(' + divProperties.angle + 'deg) ' + transform;
  6459. }
  6460. if (divProperties.paddingLeft !== 0) {
  6461. padding += ' padding-left: ' + divProperties.paddingLeft / divProperties.scale + 'px;';
  6462. transform += ' translateX(' + -divProperties.paddingLeft / divProperties.scale + 'px)';
  6463. }
  6464. if (divProperties.paddingTop !== 0) {
  6465. padding += ' padding-top: ' + divProperties.paddingTop + 'px;';
  6466. transform += ' translateY(' + -divProperties.paddingTop + 'px)';
  6467. }
  6468. if (divProperties.paddingRight !== 0) {
  6469. padding += ' padding-right: ' + divProperties.paddingRight / divProperties.scale + 'px;';
  6470. }
  6471. if (divProperties.paddingBottom !== 0) {
  6472. padding += ' padding-bottom: ' + divProperties.paddingBottom + 'px;';
  6473. }
  6474. if (padding !== '') {
  6475. div.setAttribute('style', divProperties.style + padding);
  6476. }
  6477. if (transform !== '') {
  6478. _dom_utils.CustomStyle.setProp('transform', div, transform);
  6479. }
  6480. } else {
  6481. div.style.padding = 0;
  6482. _dom_utils.CustomStyle.setProp('transform', div, divProperties.originalTransform || '');
  6483. }
  6484. }
  6485. }
  6486. };
  6487. function renderTextLayer(renderParameters) {
  6488. var task = new TextLayerRenderTask({
  6489. textContent: renderParameters.textContent,
  6490. textContentStream: renderParameters.textContentStream,
  6491. container: renderParameters.container,
  6492. viewport: renderParameters.viewport,
  6493. textDivs: renderParameters.textDivs,
  6494. textContentItemsStr: renderParameters.textContentItemsStr,
  6495. enhanceTextSelection: renderParameters.enhanceTextSelection
  6496. });
  6497. task._render(renderParameters.timeout);
  6498. return task;
  6499. }
  6500. return renderTextLayer;
  6501. }();
  6502. exports.renderTextLayer = renderTextLayer;
  6503. /***/ }),
  6504. /* 74 */
  6505. /***/ (function(module, exports, __w_pdfjs_require__) {
  6506. "use strict";
  6507. Object.defineProperty(exports, "__esModule", {
  6508. value: true
  6509. });
  6510. exports.SVGGraphics = undefined;
  6511. var _util = __w_pdfjs_require__(0);
  6512. var _dom_utils = __w_pdfjs_require__(13);
  6513. var SVGGraphics = function SVGGraphics() {
  6514. throw new Error('Not implemented: SVGGraphics');
  6515. };
  6516. {
  6517. var SVG_DEFAULTS = {
  6518. fontStyle: 'normal',
  6519. fontWeight: 'normal',
  6520. fillColor: '#000000'
  6521. };
  6522. var convertImgDataToPng = function convertImgDataToPngClosure() {
  6523. var PNG_HEADER = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
  6524. var CHUNK_WRAPPER_SIZE = 12;
  6525. var crcTable = new Int32Array(256);
  6526. for (var i = 0; i < 256; i++) {
  6527. var c = i;
  6528. for (var h = 0; h < 8; h++) {
  6529. if (c & 1) {
  6530. c = 0xedB88320 ^ c >> 1 & 0x7fffffff;
  6531. } else {
  6532. c = c >> 1 & 0x7fffffff;
  6533. }
  6534. }
  6535. crcTable[i] = c;
  6536. }
  6537. function crc32(data, start, end) {
  6538. var crc = -1;
  6539. for (var i = start; i < end; i++) {
  6540. var a = (crc ^ data[i]) & 0xff;
  6541. var b = crcTable[a];
  6542. crc = crc >>> 8 ^ b;
  6543. }
  6544. return crc ^ -1;
  6545. }
  6546. function writePngChunk(type, body, data, offset) {
  6547. var p = offset;
  6548. var len = body.length;
  6549. data[p] = len >> 24 & 0xff;
  6550. data[p + 1] = len >> 16 & 0xff;
  6551. data[p + 2] = len >> 8 & 0xff;
  6552. data[p + 3] = len & 0xff;
  6553. p += 4;
  6554. data[p] = type.charCodeAt(0) & 0xff;
  6555. data[p + 1] = type.charCodeAt(1) & 0xff;
  6556. data[p + 2] = type.charCodeAt(2) & 0xff;
  6557. data[p + 3] = type.charCodeAt(3) & 0xff;
  6558. p += 4;
  6559. data.set(body, p);
  6560. p += body.length;
  6561. var crc = crc32(data, offset + 4, p);
  6562. data[p] = crc >> 24 & 0xff;
  6563. data[p + 1] = crc >> 16 & 0xff;
  6564. data[p + 2] = crc >> 8 & 0xff;
  6565. data[p + 3] = crc & 0xff;
  6566. }
  6567. function adler32(data, start, end) {
  6568. var a = 1;
  6569. var b = 0;
  6570. for (var i = start; i < end; ++i) {
  6571. a = (a + (data[i] & 0xff)) % 65521;
  6572. b = (b + a) % 65521;
  6573. }
  6574. return b << 16 | a;
  6575. }
  6576. function deflateSync(literals) {
  6577. if (!(0, _util.isNodeJS)()) {
  6578. return deflateSyncUncompressed(literals);
  6579. }
  6580. try {
  6581. var input;
  6582. if (parseInt(process.versions.node) >= 8) {
  6583. input = literals;
  6584. } else {
  6585. input = new Buffer(literals);
  6586. }
  6587. var output = require('zlib').deflateSync(input, { level: 9 });
  6588. return output instanceof Uint8Array ? output : new Uint8Array(output);
  6589. } catch (e) {
  6590. (0, _util.warn)('Not compressing PNG because zlib.deflateSync is unavailable: ' + e);
  6591. }
  6592. return deflateSyncUncompressed(literals);
  6593. }
  6594. function deflateSyncUncompressed(literals) {
  6595. var len = literals.length;
  6596. var maxBlockLength = 0xFFFF;
  6597. var deflateBlocks = Math.ceil(len / maxBlockLength);
  6598. var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
  6599. var pi = 0;
  6600. idat[pi++] = 0x78;
  6601. idat[pi++] = 0x9c;
  6602. var pos = 0;
  6603. while (len > maxBlockLength) {
  6604. idat[pi++] = 0x00;
  6605. idat[pi++] = 0xff;
  6606. idat[pi++] = 0xff;
  6607. idat[pi++] = 0x00;
  6608. idat[pi++] = 0x00;
  6609. idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
  6610. pi += maxBlockLength;
  6611. pos += maxBlockLength;
  6612. len -= maxBlockLength;
  6613. }
  6614. idat[pi++] = 0x01;
  6615. idat[pi++] = len & 0xff;
  6616. idat[pi++] = len >> 8 & 0xff;
  6617. idat[pi++] = ~len & 0xffff & 0xff;
  6618. idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
  6619. idat.set(literals.subarray(pos), pi);
  6620. pi += literals.length - pos;
  6621. var adler = adler32(literals, 0, literals.length);
  6622. idat[pi++] = adler >> 24 & 0xff;
  6623. idat[pi++] = adler >> 16 & 0xff;
  6624. idat[pi++] = adler >> 8 & 0xff;
  6625. idat[pi++] = adler & 0xff;
  6626. return idat;
  6627. }
  6628. function encode(imgData, kind, forceDataSchema) {
  6629. var width = imgData.width;
  6630. var height = imgData.height;
  6631. var bitDepth, colorType, lineSize;
  6632. var bytes = imgData.data;
  6633. switch (kind) {
  6634. case _util.ImageKind.GRAYSCALE_1BPP:
  6635. colorType = 0;
  6636. bitDepth = 1;
  6637. lineSize = width + 7 >> 3;
  6638. break;
  6639. case _util.ImageKind.RGB_24BPP:
  6640. colorType = 2;
  6641. bitDepth = 8;
  6642. lineSize = width * 3;
  6643. break;
  6644. case _util.ImageKind.RGBA_32BPP:
  6645. colorType = 6;
  6646. bitDepth = 8;
  6647. lineSize = width * 4;
  6648. break;
  6649. default:
  6650. throw new Error('invalid format');
  6651. }
  6652. var literals = new Uint8Array((1 + lineSize) * height);
  6653. var offsetLiterals = 0,
  6654. offsetBytes = 0;
  6655. var y, i;
  6656. for (y = 0; y < height; ++y) {
  6657. literals[offsetLiterals++] = 0;
  6658. literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals);
  6659. offsetBytes += lineSize;
  6660. offsetLiterals += lineSize;
  6661. }
  6662. if (kind === _util.ImageKind.GRAYSCALE_1BPP) {
  6663. offsetLiterals = 0;
  6664. for (y = 0; y < height; y++) {
  6665. offsetLiterals++;
  6666. for (i = 0; i < lineSize; i++) {
  6667. literals[offsetLiterals++] ^= 0xFF;
  6668. }
  6669. }
  6670. }
  6671. var ihdr = new Uint8Array([width >> 24 & 0xff, width >> 16 & 0xff, width >> 8 & 0xff, width & 0xff, height >> 24 & 0xff, height >> 16 & 0xff, height >> 8 & 0xff, height & 0xff, bitDepth, colorType, 0x00, 0x00, 0x00]);
  6672. var idat = deflateSync(literals);
  6673. var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
  6674. var data = new Uint8Array(pngLength);
  6675. var offset = 0;
  6676. data.set(PNG_HEADER, offset);
  6677. offset += PNG_HEADER.length;
  6678. writePngChunk('IHDR', ihdr, data, offset);
  6679. offset += CHUNK_WRAPPER_SIZE + ihdr.length;
  6680. writePngChunk('IDATA', idat, data, offset);
  6681. offset += CHUNK_WRAPPER_SIZE + idat.length;
  6682. writePngChunk('IEND', new Uint8Array(0), data, offset);
  6683. return (0, _util.createObjectURL)(data, 'image/png', forceDataSchema);
  6684. }
  6685. return function convertImgDataToPng(imgData, forceDataSchema) {
  6686. var kind = imgData.kind === undefined ? _util.ImageKind.GRAYSCALE_1BPP : imgData.kind;
  6687. return encode(imgData, kind, forceDataSchema);
  6688. };
  6689. }();
  6690. var SVGExtraState = function SVGExtraStateClosure() {
  6691. function SVGExtraState() {
  6692. this.fontSizeScale = 1;
  6693. this.fontWeight = SVG_DEFAULTS.fontWeight;
  6694. this.fontSize = 0;
  6695. this.textMatrix = _util.IDENTITY_MATRIX;
  6696. this.fontMatrix = _util.FONT_IDENTITY_MATRIX;
  6697. this.leading = 0;
  6698. this.x = 0;
  6699. this.y = 0;
  6700. this.lineX = 0;
  6701. this.lineY = 0;
  6702. this.charSpacing = 0;
  6703. this.wordSpacing = 0;
  6704. this.textHScale = 1;
  6705. this.textRise = 0;
  6706. this.fillColor = SVG_DEFAULTS.fillColor;
  6707. this.strokeColor = '#000000';
  6708. this.fillAlpha = 1;
  6709. this.strokeAlpha = 1;
  6710. this.lineWidth = 1;
  6711. this.lineJoin = '';
  6712. this.lineCap = '';
  6713. this.miterLimit = 0;
  6714. this.dashArray = [];
  6715. this.dashPhase = 0;
  6716. this.dependencies = [];
  6717. this.activeClipUrl = null;
  6718. this.clipGroup = null;
  6719. this.maskId = '';
  6720. }
  6721. SVGExtraState.prototype = {
  6722. clone: function SVGExtraState_clone() {
  6723. return Object.create(this);
  6724. },
  6725. setCurrentPoint: function SVGExtraState_setCurrentPoint(x, y) {
  6726. this.x = x;
  6727. this.y = y;
  6728. }
  6729. };
  6730. return SVGExtraState;
  6731. }();
  6732. exports.SVGGraphics = SVGGraphics = function SVGGraphicsClosure() {
  6733. function opListToTree(opList) {
  6734. var opTree = [];
  6735. var tmp = [];
  6736. var opListLen = opList.length;
  6737. for (var x = 0; x < opListLen; x++) {
  6738. if (opList[x].fn === 'save') {
  6739. opTree.push({
  6740. 'fnId': 92,
  6741. 'fn': 'group',
  6742. 'items': []
  6743. });
  6744. tmp.push(opTree);
  6745. opTree = opTree[opTree.length - 1].items;
  6746. continue;
  6747. }
  6748. if (opList[x].fn === 'restore') {
  6749. opTree = tmp.pop();
  6750. } else {
  6751. opTree.push(opList[x]);
  6752. }
  6753. }
  6754. return opTree;
  6755. }
  6756. function pf(value) {
  6757. if (Number.isInteger(value)) {
  6758. return value.toString();
  6759. }
  6760. var s = value.toFixed(10);
  6761. var i = s.length - 1;
  6762. if (s[i] !== '0') {
  6763. return s;
  6764. }
  6765. do {
  6766. i--;
  6767. } while (s[i] === '0');
  6768. return s.substr(0, s[i] === '.' ? i : i + 1);
  6769. }
  6770. function pm(m) {
  6771. if (m[4] === 0 && m[5] === 0) {
  6772. if (m[1] === 0 && m[2] === 0) {
  6773. if (m[0] === 1 && m[3] === 1) {
  6774. return '';
  6775. }
  6776. return 'scale(' + pf(m[0]) + ' ' + pf(m[3]) + ')';
  6777. }
  6778. if (m[0] === m[3] && m[1] === -m[2]) {
  6779. var a = Math.acos(m[0]) * 180 / Math.PI;
  6780. return 'rotate(' + pf(a) + ')';
  6781. }
  6782. } else {
  6783. if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
  6784. return 'translate(' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  6785. }
  6786. }
  6787. return 'matrix(' + pf(m[0]) + ' ' + pf(m[1]) + ' ' + pf(m[2]) + ' ' + pf(m[3]) + ' ' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  6788. }
  6789. function SVGGraphics(commonObjs, objs, forceDataSchema) {
  6790. this.svgFactory = new _dom_utils.DOMSVGFactory();
  6791. this.current = new SVGExtraState();
  6792. this.transformMatrix = _util.IDENTITY_MATRIX;
  6793. this.transformStack = [];
  6794. this.extraStack = [];
  6795. this.commonObjs = commonObjs;
  6796. this.objs = objs;
  6797. this.pendingClip = null;
  6798. this.pendingEOFill = false;
  6799. this.embedFonts = false;
  6800. this.embeddedFonts = Object.create(null);
  6801. this.cssStyle = null;
  6802. this.forceDataSchema = !!forceDataSchema;
  6803. }
  6804. var XML_NS = 'http://www.w3.org/XML/1998/namespace';
  6805. var XLINK_NS = 'http://www.w3.org/1999/xlink';
  6806. var LINE_CAP_STYLES = ['butt', 'round', 'square'];
  6807. var LINE_JOIN_STYLES = ['miter', 'round', 'bevel'];
  6808. var clipCount = 0;
  6809. var maskCount = 0;
  6810. SVGGraphics.prototype = {
  6811. save: function SVGGraphics_save() {
  6812. this.transformStack.push(this.transformMatrix);
  6813. var old = this.current;
  6814. this.extraStack.push(old);
  6815. this.current = old.clone();
  6816. },
  6817. restore: function SVGGraphics_restore() {
  6818. this.transformMatrix = this.transformStack.pop();
  6819. this.current = this.extraStack.pop();
  6820. this.pendingClip = null;
  6821. this.tgrp = null;
  6822. },
  6823. group: function SVGGraphics_group(items) {
  6824. this.save();
  6825. this.executeOpTree(items);
  6826. this.restore();
  6827. },
  6828. loadDependencies: function SVGGraphics_loadDependencies(operatorList) {
  6829. var _this = this;
  6830. var fnArray = operatorList.fnArray;
  6831. var fnArrayLen = fnArray.length;
  6832. var argsArray = operatorList.argsArray;
  6833. for (var i = 0; i < fnArrayLen; i++) {
  6834. if (_util.OPS.dependency === fnArray[i]) {
  6835. var deps = argsArray[i];
  6836. for (var n = 0, nn = deps.length; n < nn; n++) {
  6837. var obj = deps[n];
  6838. var common = obj.substring(0, 2) === 'g_';
  6839. var promise;
  6840. if (common) {
  6841. promise = new Promise(function (resolve) {
  6842. _this.commonObjs.get(obj, resolve);
  6843. });
  6844. } else {
  6845. promise = new Promise(function (resolve) {
  6846. _this.objs.get(obj, resolve);
  6847. });
  6848. }
  6849. this.current.dependencies.push(promise);
  6850. }
  6851. }
  6852. }
  6853. return Promise.all(this.current.dependencies);
  6854. },
  6855. transform: function SVGGraphics_transform(a, b, c, d, e, f) {
  6856. var transformMatrix = [a, b, c, d, e, f];
  6857. this.transformMatrix = _util.Util.transform(this.transformMatrix, transformMatrix);
  6858. this.tgrp = null;
  6859. },
  6860. getSVG: function SVGGraphics_getSVG(operatorList, viewport) {
  6861. var _this2 = this;
  6862. this.viewport = viewport;
  6863. var svgElement = this._initialize(viewport);
  6864. return this.loadDependencies(operatorList).then(function () {
  6865. _this2.transformMatrix = _util.IDENTITY_MATRIX;
  6866. var opTree = _this2.convertOpList(operatorList);
  6867. _this2.executeOpTree(opTree);
  6868. return svgElement;
  6869. });
  6870. },
  6871. convertOpList: function SVGGraphics_convertOpList(operatorList) {
  6872. var argsArray = operatorList.argsArray;
  6873. var fnArray = operatorList.fnArray;
  6874. var fnArrayLen = fnArray.length;
  6875. var REVOPS = [];
  6876. var opList = [];
  6877. for (var op in _util.OPS) {
  6878. REVOPS[_util.OPS[op]] = op;
  6879. }
  6880. for (var x = 0; x < fnArrayLen; x++) {
  6881. var fnId = fnArray[x];
  6882. opList.push({
  6883. 'fnId': fnId,
  6884. 'fn': REVOPS[fnId],
  6885. 'args': argsArray[x]
  6886. });
  6887. }
  6888. return opListToTree(opList);
  6889. },
  6890. executeOpTree: function SVGGraphics_executeOpTree(opTree) {
  6891. var opTreeLen = opTree.length;
  6892. for (var x = 0; x < opTreeLen; x++) {
  6893. var fn = opTree[x].fn;
  6894. var fnId = opTree[x].fnId;
  6895. var args = opTree[x].args;
  6896. switch (fnId | 0) {
  6897. case _util.OPS.beginText:
  6898. this.beginText();
  6899. break;
  6900. case _util.OPS.setLeading:
  6901. this.setLeading(args);
  6902. break;
  6903. case _util.OPS.setLeadingMoveText:
  6904. this.setLeadingMoveText(args[0], args[1]);
  6905. break;
  6906. case _util.OPS.setFont:
  6907. this.setFont(args);
  6908. break;
  6909. case _util.OPS.showText:
  6910. this.showText(args[0]);
  6911. break;
  6912. case _util.OPS.showSpacedText:
  6913. this.showText(args[0]);
  6914. break;
  6915. case _util.OPS.endText:
  6916. this.endText();
  6917. break;
  6918. case _util.OPS.moveText:
  6919. this.moveText(args[0], args[1]);
  6920. break;
  6921. case _util.OPS.setCharSpacing:
  6922. this.setCharSpacing(args[0]);
  6923. break;
  6924. case _util.OPS.setWordSpacing:
  6925. this.setWordSpacing(args[0]);
  6926. break;
  6927. case _util.OPS.setHScale:
  6928. this.setHScale(args[0]);
  6929. break;
  6930. case _util.OPS.setTextMatrix:
  6931. this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  6932. break;
  6933. case _util.OPS.setTextRise:
  6934. this.setTextRise(args[0]);
  6935. break;
  6936. case _util.OPS.setLineWidth:
  6937. this.setLineWidth(args[0]);
  6938. break;
  6939. case _util.OPS.setLineJoin:
  6940. this.setLineJoin(args[0]);
  6941. break;
  6942. case _util.OPS.setLineCap:
  6943. this.setLineCap(args[0]);
  6944. break;
  6945. case _util.OPS.setMiterLimit:
  6946. this.setMiterLimit(args[0]);
  6947. break;
  6948. case _util.OPS.setFillRGBColor:
  6949. this.setFillRGBColor(args[0], args[1], args[2]);
  6950. break;
  6951. case _util.OPS.setStrokeRGBColor:
  6952. this.setStrokeRGBColor(args[0], args[1], args[2]);
  6953. break;
  6954. case _util.OPS.setDash:
  6955. this.setDash(args[0], args[1]);
  6956. break;
  6957. case _util.OPS.setGState:
  6958. this.setGState(args[0]);
  6959. break;
  6960. case _util.OPS.fill:
  6961. this.fill();
  6962. break;
  6963. case _util.OPS.eoFill:
  6964. this.eoFill();
  6965. break;
  6966. case _util.OPS.stroke:
  6967. this.stroke();
  6968. break;
  6969. case _util.OPS.fillStroke:
  6970. this.fillStroke();
  6971. break;
  6972. case _util.OPS.eoFillStroke:
  6973. this.eoFillStroke();
  6974. break;
  6975. case _util.OPS.clip:
  6976. this.clip('nonzero');
  6977. break;
  6978. case _util.OPS.eoClip:
  6979. this.clip('evenodd');
  6980. break;
  6981. case _util.OPS.paintSolidColorImageMask:
  6982. this.paintSolidColorImageMask();
  6983. break;
  6984. case _util.OPS.paintJpegXObject:
  6985. this.paintJpegXObject(args[0], args[1], args[2]);
  6986. break;
  6987. case _util.OPS.paintImageXObject:
  6988. this.paintImageXObject(args[0]);
  6989. break;
  6990. case _util.OPS.paintInlineImageXObject:
  6991. this.paintInlineImageXObject(args[0]);
  6992. break;
  6993. case _util.OPS.paintImageMaskXObject:
  6994. this.paintImageMaskXObject(args[0]);
  6995. break;
  6996. case _util.OPS.paintFormXObjectBegin:
  6997. this.paintFormXObjectBegin(args[0], args[1]);
  6998. break;
  6999. case _util.OPS.paintFormXObjectEnd:
  7000. this.paintFormXObjectEnd();
  7001. break;
  7002. case _util.OPS.closePath:
  7003. this.closePath();
  7004. break;
  7005. case _util.OPS.closeStroke:
  7006. this.closeStroke();
  7007. break;
  7008. case _util.OPS.closeFillStroke:
  7009. this.closeFillStroke();
  7010. break;
  7011. case _util.OPS.nextLine:
  7012. this.nextLine();
  7013. break;
  7014. case _util.OPS.transform:
  7015. this.transform(args[0], args[1], args[2], args[3], args[4], args[5]);
  7016. break;
  7017. case _util.OPS.constructPath:
  7018. this.constructPath(args[0], args[1]);
  7019. break;
  7020. case _util.OPS.endPath:
  7021. this.endPath();
  7022. break;
  7023. case 92:
  7024. this.group(opTree[x].items);
  7025. break;
  7026. default:
  7027. (0, _util.warn)('Unimplemented operator ' + fn);
  7028. break;
  7029. }
  7030. }
  7031. },
  7032. setWordSpacing: function SVGGraphics_setWordSpacing(wordSpacing) {
  7033. this.current.wordSpacing = wordSpacing;
  7034. },
  7035. setCharSpacing: function SVGGraphics_setCharSpacing(charSpacing) {
  7036. this.current.charSpacing = charSpacing;
  7037. },
  7038. nextLine: function SVGGraphics_nextLine() {
  7039. this.moveText(0, this.current.leading);
  7040. },
  7041. setTextMatrix: function SVGGraphics_setTextMatrix(a, b, c, d, e, f) {
  7042. var current = this.current;
  7043. this.current.textMatrix = this.current.lineMatrix = [a, b, c, d, e, f];
  7044. this.current.x = this.current.lineX = 0;
  7045. this.current.y = this.current.lineY = 0;
  7046. current.xcoords = [];
  7047. current.tspan = this.svgFactory.createElement('svg:tspan');
  7048. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  7049. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  7050. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  7051. current.txtElement = this.svgFactory.createElement('svg:text');
  7052. current.txtElement.appendChild(current.tspan);
  7053. },
  7054. beginText: function SVGGraphics_beginText() {
  7055. this.current.x = this.current.lineX = 0;
  7056. this.current.y = this.current.lineY = 0;
  7057. this.current.textMatrix = _util.IDENTITY_MATRIX;
  7058. this.current.lineMatrix = _util.IDENTITY_MATRIX;
  7059. this.current.tspan = this.svgFactory.createElement('svg:tspan');
  7060. this.current.txtElement = this.svgFactory.createElement('svg:text');
  7061. this.current.txtgrp = this.svgFactory.createElement('svg:g');
  7062. this.current.xcoords = [];
  7063. },
  7064. moveText: function SVGGraphics_moveText(x, y) {
  7065. var current = this.current;
  7066. this.current.x = this.current.lineX += x;
  7067. this.current.y = this.current.lineY += y;
  7068. current.xcoords = [];
  7069. current.tspan = this.svgFactory.createElement('svg:tspan');
  7070. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  7071. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  7072. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  7073. },
  7074. showText: function SVGGraphics_showText(glyphs) {
  7075. var current = this.current;
  7076. var font = current.font;
  7077. var fontSize = current.fontSize;
  7078. if (fontSize === 0) {
  7079. return;
  7080. }
  7081. var charSpacing = current.charSpacing;
  7082. var wordSpacing = current.wordSpacing;
  7083. var fontDirection = current.fontDirection;
  7084. var textHScale = current.textHScale * fontDirection;
  7085. var glyphsLength = glyphs.length;
  7086. var vertical = font.vertical;
  7087. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  7088. var x = 0,
  7089. i;
  7090. for (i = 0; i < glyphsLength; ++i) {
  7091. var glyph = glyphs[i];
  7092. if (glyph === null) {
  7093. x += fontDirection * wordSpacing;
  7094. continue;
  7095. } else if ((0, _util.isNum)(glyph)) {
  7096. x += -glyph * fontSize * 0.001;
  7097. continue;
  7098. }
  7099. var width = glyph.width;
  7100. var character = glyph.fontChar;
  7101. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  7102. var charWidth = width * widthAdvanceScale + spacing * fontDirection;
  7103. if (!glyph.isInFont && !font.missingFile) {
  7104. x += charWidth;
  7105. continue;
  7106. }
  7107. current.xcoords.push(current.x + x * textHScale);
  7108. current.tspan.textContent += character;
  7109. x += charWidth;
  7110. }
  7111. if (vertical) {
  7112. current.y -= x * textHScale;
  7113. } else {
  7114. current.x += x * textHScale;
  7115. }
  7116. current.tspan.setAttributeNS(null, 'x', current.xcoords.map(pf).join(' '));
  7117. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  7118. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  7119. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  7120. if (current.fontStyle !== SVG_DEFAULTS.fontStyle) {
  7121. current.tspan.setAttributeNS(null, 'font-style', current.fontStyle);
  7122. }
  7123. if (current.fontWeight !== SVG_DEFAULTS.fontWeight) {
  7124. current.tspan.setAttributeNS(null, 'font-weight', current.fontWeight);
  7125. }
  7126. if (current.fillColor !== SVG_DEFAULTS.fillColor) {
  7127. current.tspan.setAttributeNS(null, 'fill', current.fillColor);
  7128. }
  7129. var textMatrix = current.textMatrix;
  7130. if (current.textRise !== 0) {
  7131. textMatrix = textMatrix.slice();
  7132. textMatrix[5] += current.textRise;
  7133. }
  7134. current.txtElement.setAttributeNS(null, 'transform', pm(textMatrix) + ' scale(1, -1)');
  7135. current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve');
  7136. current.txtElement.appendChild(current.tspan);
  7137. current.txtgrp.appendChild(current.txtElement);
  7138. this._ensureTransformGroup().appendChild(current.txtElement);
  7139. },
  7140. setLeadingMoveText: function SVGGraphics_setLeadingMoveText(x, y) {
  7141. this.setLeading(-y);
  7142. this.moveText(x, y);
  7143. },
  7144. addFontStyle: function SVGGraphics_addFontStyle(fontObj) {
  7145. if (!this.cssStyle) {
  7146. this.cssStyle = this.svgFactory.createElement('svg:style');
  7147. this.cssStyle.setAttributeNS(null, 'type', 'text/css');
  7148. this.defs.appendChild(this.cssStyle);
  7149. }
  7150. var url = (0, _util.createObjectURL)(fontObj.data, fontObj.mimetype, this.forceDataSchema);
  7151. this.cssStyle.textContent += '@font-face { font-family: "' + fontObj.loadedName + '";' + ' src: url(' + url + '); }\n';
  7152. },
  7153. setFont: function SVGGraphics_setFont(details) {
  7154. var current = this.current;
  7155. var fontObj = this.commonObjs.get(details[0]);
  7156. var size = details[1];
  7157. this.current.font = fontObj;
  7158. if (this.embedFonts && fontObj.data && !this.embeddedFonts[fontObj.loadedName]) {
  7159. this.addFontStyle(fontObj);
  7160. this.embeddedFonts[fontObj.loadedName] = fontObj;
  7161. }
  7162. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : _util.FONT_IDENTITY_MATRIX;
  7163. var bold = fontObj.black ? fontObj.bold ? 'bolder' : 'bold' : fontObj.bold ? 'bold' : 'normal';
  7164. var italic = fontObj.italic ? 'italic' : 'normal';
  7165. if (size < 0) {
  7166. size = -size;
  7167. current.fontDirection = -1;
  7168. } else {
  7169. current.fontDirection = 1;
  7170. }
  7171. current.fontSize = size;
  7172. current.fontFamily = fontObj.loadedName;
  7173. current.fontWeight = bold;
  7174. current.fontStyle = italic;
  7175. current.tspan = this.svgFactory.createElement('svg:tspan');
  7176. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  7177. current.xcoords = [];
  7178. },
  7179. endText: function SVGGraphics_endText() {},
  7180. setLineWidth: function SVGGraphics_setLineWidth(width) {
  7181. this.current.lineWidth = width;
  7182. },
  7183. setLineCap: function SVGGraphics_setLineCap(style) {
  7184. this.current.lineCap = LINE_CAP_STYLES[style];
  7185. },
  7186. setLineJoin: function SVGGraphics_setLineJoin(style) {
  7187. this.current.lineJoin = LINE_JOIN_STYLES[style];
  7188. },
  7189. setMiterLimit: function SVGGraphics_setMiterLimit(limit) {
  7190. this.current.miterLimit = limit;
  7191. },
  7192. setStrokeAlpha: function SVGGraphics_setStrokeAlpha(strokeAlpha) {
  7193. this.current.strokeAlpha = strokeAlpha;
  7194. },
  7195. setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) {
  7196. var color = _util.Util.makeCssRgb(r, g, b);
  7197. this.current.strokeColor = color;
  7198. },
  7199. setFillAlpha: function SVGGraphics_setFillAlpha(fillAlpha) {
  7200. this.current.fillAlpha = fillAlpha;
  7201. },
  7202. setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) {
  7203. var color = _util.Util.makeCssRgb(r, g, b);
  7204. this.current.fillColor = color;
  7205. this.current.tspan = this.svgFactory.createElement('svg:tspan');
  7206. this.current.xcoords = [];
  7207. },
  7208. setDash: function SVGGraphics_setDash(dashArray, dashPhase) {
  7209. this.current.dashArray = dashArray;
  7210. this.current.dashPhase = dashPhase;
  7211. },
  7212. constructPath: function SVGGraphics_constructPath(ops, args) {
  7213. var current = this.current;
  7214. var x = current.x,
  7215. y = current.y;
  7216. current.path = this.svgFactory.createElement('svg:path');
  7217. var d = [];
  7218. var opLength = ops.length;
  7219. for (var i = 0, j = 0; i < opLength; i++) {
  7220. switch (ops[i] | 0) {
  7221. case _util.OPS.rectangle:
  7222. x = args[j++];
  7223. y = args[j++];
  7224. var width = args[j++];
  7225. var height = args[j++];
  7226. var xw = x + width;
  7227. var yh = y + height;
  7228. d.push('M', pf(x), pf(y), 'L', pf(xw), pf(y), 'L', pf(xw), pf(yh), 'L', pf(x), pf(yh), 'Z');
  7229. break;
  7230. case _util.OPS.moveTo:
  7231. x = args[j++];
  7232. y = args[j++];
  7233. d.push('M', pf(x), pf(y));
  7234. break;
  7235. case _util.OPS.lineTo:
  7236. x = args[j++];
  7237. y = args[j++];
  7238. d.push('L', pf(x), pf(y));
  7239. break;
  7240. case _util.OPS.curveTo:
  7241. x = args[j + 4];
  7242. y = args[j + 5];
  7243. d.push('C', pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y));
  7244. j += 6;
  7245. break;
  7246. case _util.OPS.curveTo2:
  7247. x = args[j + 2];
  7248. y = args[j + 3];
  7249. d.push('C', pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]));
  7250. j += 4;
  7251. break;
  7252. case _util.OPS.curveTo3:
  7253. x = args[j + 2];
  7254. y = args[j + 3];
  7255. d.push('C', pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y));
  7256. j += 4;
  7257. break;
  7258. case _util.OPS.closePath:
  7259. d.push('Z');
  7260. break;
  7261. }
  7262. }
  7263. current.path.setAttributeNS(null, 'd', d.join(' '));
  7264. current.path.setAttributeNS(null, 'fill', 'none');
  7265. this._ensureTransformGroup().appendChild(current.path);
  7266. current.element = current.path;
  7267. current.setCurrentPoint(x, y);
  7268. },
  7269. endPath: function SVGGraphics_endPath() {
  7270. if (!this.pendingClip) {
  7271. return;
  7272. }
  7273. var current = this.current;
  7274. var clipId = 'clippath' + clipCount;
  7275. clipCount++;
  7276. var clipPath = this.svgFactory.createElement('svg:clipPath');
  7277. clipPath.setAttributeNS(null, 'id', clipId);
  7278. clipPath.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  7279. var clipElement = current.element.cloneNode();
  7280. if (this.pendingClip === 'evenodd') {
  7281. clipElement.setAttributeNS(null, 'clip-rule', 'evenodd');
  7282. } else {
  7283. clipElement.setAttributeNS(null, 'clip-rule', 'nonzero');
  7284. }
  7285. this.pendingClip = null;
  7286. clipPath.appendChild(clipElement);
  7287. this.defs.appendChild(clipPath);
  7288. if (current.activeClipUrl) {
  7289. current.clipGroup = null;
  7290. this.extraStack.forEach(function (prev) {
  7291. prev.clipGroup = null;
  7292. });
  7293. }
  7294. current.activeClipUrl = 'url(#' + clipId + ')';
  7295. this.tgrp = null;
  7296. },
  7297. clip: function SVGGraphics_clip(type) {
  7298. this.pendingClip = type;
  7299. },
  7300. closePath: function SVGGraphics_closePath() {
  7301. var current = this.current;
  7302. var d = current.path.getAttributeNS(null, 'd');
  7303. d += 'Z';
  7304. current.path.setAttributeNS(null, 'd', d);
  7305. },
  7306. setLeading: function SVGGraphics_setLeading(leading) {
  7307. this.current.leading = -leading;
  7308. },
  7309. setTextRise: function SVGGraphics_setTextRise(textRise) {
  7310. this.current.textRise = textRise;
  7311. },
  7312. setHScale: function SVGGraphics_setHScale(scale) {
  7313. this.current.textHScale = scale / 100;
  7314. },
  7315. setGState: function SVGGraphics_setGState(states) {
  7316. for (var i = 0, ii = states.length; i < ii; i++) {
  7317. var state = states[i];
  7318. var key = state[0];
  7319. var value = state[1];
  7320. switch (key) {
  7321. case 'LW':
  7322. this.setLineWidth(value);
  7323. break;
  7324. case 'LC':
  7325. this.setLineCap(value);
  7326. break;
  7327. case 'LJ':
  7328. this.setLineJoin(value);
  7329. break;
  7330. case 'ML':
  7331. this.setMiterLimit(value);
  7332. break;
  7333. case 'D':
  7334. this.setDash(value[0], value[1]);
  7335. break;
  7336. case 'Font':
  7337. this.setFont(value);
  7338. break;
  7339. case 'CA':
  7340. this.setStrokeAlpha(value);
  7341. break;
  7342. case 'ca':
  7343. this.setFillAlpha(value);
  7344. break;
  7345. default:
  7346. (0, _util.warn)('Unimplemented graphic state ' + key);
  7347. break;
  7348. }
  7349. }
  7350. },
  7351. fill: function SVGGraphics_fill() {
  7352. var current = this.current;
  7353. current.element.setAttributeNS(null, 'fill', current.fillColor);
  7354. current.element.setAttributeNS(null, 'fill-opacity', current.fillAlpha);
  7355. },
  7356. stroke: function SVGGraphics_stroke() {
  7357. var current = this.current;
  7358. current.element.setAttributeNS(null, 'stroke', current.strokeColor);
  7359. current.element.setAttributeNS(null, 'stroke-opacity', current.strokeAlpha);
  7360. current.element.setAttributeNS(null, 'stroke-miterlimit', pf(current.miterLimit));
  7361. current.element.setAttributeNS(null, 'stroke-linecap', current.lineCap);
  7362. current.element.setAttributeNS(null, 'stroke-linejoin', current.lineJoin);
  7363. current.element.setAttributeNS(null, 'stroke-width', pf(current.lineWidth) + 'px');
  7364. current.element.setAttributeNS(null, 'stroke-dasharray', current.dashArray.map(pf).join(' '));
  7365. current.element.setAttributeNS(null, 'stroke-dashoffset', pf(current.dashPhase) + 'px');
  7366. current.element.setAttributeNS(null, 'fill', 'none');
  7367. },
  7368. eoFill: function SVGGraphics_eoFill() {
  7369. this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  7370. this.fill();
  7371. },
  7372. fillStroke: function SVGGraphics_fillStroke() {
  7373. this.stroke();
  7374. this.fill();
  7375. },
  7376. eoFillStroke: function SVGGraphics_eoFillStroke() {
  7377. this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  7378. this.fillStroke();
  7379. },
  7380. closeStroke: function SVGGraphics_closeStroke() {
  7381. this.closePath();
  7382. this.stroke();
  7383. },
  7384. closeFillStroke: function SVGGraphics_closeFillStroke() {
  7385. this.closePath();
  7386. this.fillStroke();
  7387. },
  7388. paintSolidColorImageMask: function SVGGraphics_paintSolidColorImageMask() {
  7389. var current = this.current;
  7390. var rect = this.svgFactory.createElement('svg:rect');
  7391. rect.setAttributeNS(null, 'x', '0');
  7392. rect.setAttributeNS(null, 'y', '0');
  7393. rect.setAttributeNS(null, 'width', '1px');
  7394. rect.setAttributeNS(null, 'height', '1px');
  7395. rect.setAttributeNS(null, 'fill', current.fillColor);
  7396. this._ensureTransformGroup().appendChild(rect);
  7397. },
  7398. paintJpegXObject: function SVGGraphics_paintJpegXObject(objId, w, h) {
  7399. var imgObj = this.objs.get(objId);
  7400. var imgEl = this.svgFactory.createElement('svg:image');
  7401. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgObj.src);
  7402. imgEl.setAttributeNS(null, 'width', pf(w));
  7403. imgEl.setAttributeNS(null, 'height', pf(h));
  7404. imgEl.setAttributeNS(null, 'x', '0');
  7405. imgEl.setAttributeNS(null, 'y', pf(-h));
  7406. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / w) + ' ' + pf(-1 / h) + ')');
  7407. this._ensureTransformGroup().appendChild(imgEl);
  7408. },
  7409. paintImageXObject: function SVGGraphics_paintImageXObject(objId) {
  7410. var imgData = this.objs.get(objId);
  7411. if (!imgData) {
  7412. (0, _util.warn)('Dependent image isn\'t ready yet');
  7413. return;
  7414. }
  7415. this.paintInlineImageXObject(imgData);
  7416. },
  7417. paintInlineImageXObject: function SVGGraphics_paintInlineImageXObject(imgData, mask) {
  7418. var width = imgData.width;
  7419. var height = imgData.height;
  7420. var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema);
  7421. var cliprect = this.svgFactory.createElement('svg:rect');
  7422. cliprect.setAttributeNS(null, 'x', '0');
  7423. cliprect.setAttributeNS(null, 'y', '0');
  7424. cliprect.setAttributeNS(null, 'width', pf(width));
  7425. cliprect.setAttributeNS(null, 'height', pf(height));
  7426. this.current.element = cliprect;
  7427. this.clip('nonzero');
  7428. var imgEl = this.svgFactory.createElement('svg:image');
  7429. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgSrc);
  7430. imgEl.setAttributeNS(null, 'x', '0');
  7431. imgEl.setAttributeNS(null, 'y', pf(-height));
  7432. imgEl.setAttributeNS(null, 'width', pf(width) + 'px');
  7433. imgEl.setAttributeNS(null, 'height', pf(height) + 'px');
  7434. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / width) + ' ' + pf(-1 / height) + ')');
  7435. if (mask) {
  7436. mask.appendChild(imgEl);
  7437. } else {
  7438. this._ensureTransformGroup().appendChild(imgEl);
  7439. }
  7440. },
  7441. paintImageMaskXObject: function SVGGraphics_paintImageMaskXObject(imgData) {
  7442. var current = this.current;
  7443. var width = imgData.width;
  7444. var height = imgData.height;
  7445. var fillColor = current.fillColor;
  7446. current.maskId = 'mask' + maskCount++;
  7447. var mask = this.svgFactory.createElement('svg:mask');
  7448. mask.setAttributeNS(null, 'id', current.maskId);
  7449. var rect = this.svgFactory.createElement('svg:rect');
  7450. rect.setAttributeNS(null, 'x', '0');
  7451. rect.setAttributeNS(null, 'y', '0');
  7452. rect.setAttributeNS(null, 'width', pf(width));
  7453. rect.setAttributeNS(null, 'height', pf(height));
  7454. rect.setAttributeNS(null, 'fill', fillColor);
  7455. rect.setAttributeNS(null, 'mask', 'url(#' + current.maskId + ')');
  7456. this.defs.appendChild(mask);
  7457. this._ensureTransformGroup().appendChild(rect);
  7458. this.paintInlineImageXObject(imgData, mask);
  7459. },
  7460. paintFormXObjectBegin: function SVGGraphics_paintFormXObjectBegin(matrix, bbox) {
  7461. if (Array.isArray(matrix) && matrix.length === 6) {
  7462. this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
  7463. }
  7464. if (Array.isArray(bbox) && bbox.length === 4) {
  7465. var width = bbox[2] - bbox[0];
  7466. var height = bbox[3] - bbox[1];
  7467. var cliprect = this.svgFactory.createElement('svg:rect');
  7468. cliprect.setAttributeNS(null, 'x', bbox[0]);
  7469. cliprect.setAttributeNS(null, 'y', bbox[1]);
  7470. cliprect.setAttributeNS(null, 'width', pf(width));
  7471. cliprect.setAttributeNS(null, 'height', pf(height));
  7472. this.current.element = cliprect;
  7473. this.clip('nonzero');
  7474. this.endPath();
  7475. }
  7476. },
  7477. paintFormXObjectEnd: function SVGGraphics_paintFormXObjectEnd() {},
  7478. _initialize: function _initialize(viewport) {
  7479. var svg = this.svgFactory.create(viewport.width, viewport.height);
  7480. var definitions = this.svgFactory.createElement('svg:defs');
  7481. svg.appendChild(definitions);
  7482. this.defs = definitions;
  7483. var rootGroup = this.svgFactory.createElement('svg:g');
  7484. rootGroup.setAttributeNS(null, 'transform', pm(viewport.transform));
  7485. svg.appendChild(rootGroup);
  7486. this.svg = rootGroup;
  7487. return svg;
  7488. },
  7489. _ensureClipGroup: function SVGGraphics_ensureClipGroup() {
  7490. if (!this.current.clipGroup) {
  7491. var clipGroup = this.svgFactory.createElement('svg:g');
  7492. clipGroup.setAttributeNS(null, 'clip-path', this.current.activeClipUrl);
  7493. this.svg.appendChild(clipGroup);
  7494. this.current.clipGroup = clipGroup;
  7495. }
  7496. return this.current.clipGroup;
  7497. },
  7498. _ensureTransformGroup: function SVGGraphics_ensureTransformGroup() {
  7499. if (!this.tgrp) {
  7500. this.tgrp = this.svgFactory.createElement('svg:g');
  7501. this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  7502. if (this.current.activeClipUrl) {
  7503. this._ensureClipGroup().appendChild(this.tgrp);
  7504. } else {
  7505. this.svg.appendChild(this.tgrp);
  7506. }
  7507. }
  7508. return this.tgrp;
  7509. }
  7510. };
  7511. return SVGGraphics;
  7512. }();
  7513. }
  7514. exports.SVGGraphics = SVGGraphics;
  7515. /***/ }),
  7516. /* 75 */
  7517. /***/ (function(module, exports, __w_pdfjs_require__) {
  7518. "use strict";
  7519. var pdfjsVersion = '1.10.88';
  7520. var pdfjsBuild = 'c62a1938';
  7521. var pdfjsSharedUtil = __w_pdfjs_require__(0);
  7522. var pdfjsDisplayGlobal = __w_pdfjs_require__(117);
  7523. var pdfjsDisplayAPI = __w_pdfjs_require__(69);
  7524. var pdfjsDisplayTextLayer = __w_pdfjs_require__(73);
  7525. var pdfjsDisplayAnnotationLayer = __w_pdfjs_require__(72);
  7526. var pdfjsDisplayDOMUtils = __w_pdfjs_require__(13);
  7527. var pdfjsDisplaySVG = __w_pdfjs_require__(74);
  7528. {
  7529. if (pdfjsSharedUtil.isNodeJS()) {
  7530. var PDFNodeStream = __w_pdfjs_require__(122).PDFNodeStream;
  7531. pdfjsDisplayAPI.setPDFNetworkStreamClass(PDFNodeStream);
  7532. } else if (typeof Response !== 'undefined' && 'body' in Response.prototype && typeof ReadableStream !== 'undefined') {
  7533. var PDFFetchStream = __w_pdfjs_require__(123).PDFFetchStream;
  7534. pdfjsDisplayAPI.setPDFNetworkStreamClass(PDFFetchStream);
  7535. } else {
  7536. var PDFNetworkStream = __w_pdfjs_require__(124).PDFNetworkStream;
  7537. pdfjsDisplayAPI.setPDFNetworkStreamClass(PDFNetworkStream);
  7538. }
  7539. }
  7540. exports.PDFJS = pdfjsDisplayGlobal.PDFJS;
  7541. exports.build = pdfjsDisplayAPI.build;
  7542. exports.version = pdfjsDisplayAPI.version;
  7543. exports.getDocument = pdfjsDisplayAPI.getDocument;
  7544. exports.LoopbackPort = pdfjsDisplayAPI.LoopbackPort;
  7545. exports.PDFDataRangeTransport = pdfjsDisplayAPI.PDFDataRangeTransport;
  7546. exports.PDFWorker = pdfjsDisplayAPI.PDFWorker;
  7547. exports.renderTextLayer = pdfjsDisplayTextLayer.renderTextLayer;
  7548. exports.AnnotationLayer = pdfjsDisplayAnnotationLayer.AnnotationLayer;
  7549. exports.CustomStyle = pdfjsDisplayDOMUtils.CustomStyle;
  7550. exports.createPromiseCapability = pdfjsSharedUtil.createPromiseCapability;
  7551. exports.PasswordResponses = pdfjsSharedUtil.PasswordResponses;
  7552. exports.InvalidPDFException = pdfjsSharedUtil.InvalidPDFException;
  7553. exports.MissingPDFException = pdfjsSharedUtil.MissingPDFException;
  7554. exports.SVGGraphics = pdfjsDisplaySVG.SVGGraphics;
  7555. exports.NativeImageDecoding = pdfjsSharedUtil.NativeImageDecoding;
  7556. exports.UnexpectedResponseException = pdfjsSharedUtil.UnexpectedResponseException;
  7557. exports.OPS = pdfjsSharedUtil.OPS;
  7558. exports.UNSUPPORTED_FEATURES = pdfjsSharedUtil.UNSUPPORTED_FEATURES;
  7559. exports.isValidUrl = pdfjsDisplayDOMUtils.isValidUrl;
  7560. exports.createValidAbsoluteUrl = pdfjsSharedUtil.createValidAbsoluteUrl;
  7561. exports.createObjectURL = pdfjsSharedUtil.createObjectURL;
  7562. exports.removeNullCharacters = pdfjsSharedUtil.removeNullCharacters;
  7563. exports.shadow = pdfjsSharedUtil.shadow;
  7564. exports.createBlob = pdfjsSharedUtil.createBlob;
  7565. exports.RenderingCancelledException = pdfjsDisplayDOMUtils.RenderingCancelledException;
  7566. exports.getFilenameFromUrl = pdfjsDisplayDOMUtils.getFilenameFromUrl;
  7567. exports.addLinkAttributes = pdfjsDisplayDOMUtils.addLinkAttributes;
  7568. exports.StatTimer = pdfjsSharedUtil.StatTimer;
  7569. /***/ }),
  7570. /* 76 */
  7571. /***/ (function(module, exports, __w_pdfjs_require__) {
  7572. "use strict";
  7573. 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; };
  7574. if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
  7575. var globalScope = __w_pdfjs_require__(20);
  7576. var userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
  7577. var isAndroid = /Android/.test(userAgent);
  7578. var isAndroidPre3 = /Android\s[0-2][^\d]/.test(userAgent);
  7579. var isAndroidPre5 = /Android\s[0-4][^\d]/.test(userAgent);
  7580. var isChrome = userAgent.indexOf('Chrom') >= 0;
  7581. var isChromeWithRangeBug = /Chrome\/(39|40)\./.test(userAgent);
  7582. var isIOSChrome = userAgent.indexOf('CriOS') >= 0;
  7583. var isIE = userAgent.indexOf('Trident') >= 0;
  7584. var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent);
  7585. var isOpera = userAgent.indexOf('Opera') >= 0;
  7586. var isSafari = /Safari\//.test(userAgent) && !/(Chrome\/|Android\s)/.test(userAgent);
  7587. var hasDOM = (typeof window === 'undefined' ? 'undefined' : _typeof(window)) === 'object' && (typeof document === 'undefined' ? 'undefined' : _typeof(document)) === 'object';
  7588. if (typeof PDFJS === 'undefined') {
  7589. globalScope.PDFJS = {};
  7590. }
  7591. PDFJS.compatibilityChecked = true;
  7592. (function checkTypedArrayCompatibility() {
  7593. if (typeof Uint8ClampedArray === 'undefined') {
  7594. globalScope.Uint8ClampedArray = __w_pdfjs_require__(77);
  7595. }
  7596. if (typeof Uint8Array !== 'undefined') {
  7597. if (typeof Uint8Array.prototype.subarray === 'undefined') {
  7598. Uint8Array.prototype.subarray = function subarray(start, end) {
  7599. return new Uint8Array(this.slice(start, end));
  7600. };
  7601. Float32Array.prototype.subarray = function subarray(start, end) {
  7602. return new Float32Array(this.slice(start, end));
  7603. };
  7604. }
  7605. if (typeof Float64Array === 'undefined') {
  7606. globalScope.Float64Array = Float32Array;
  7607. }
  7608. return;
  7609. }
  7610. function subarray(start, end) {
  7611. return new TypedArray(this.slice(start, end));
  7612. }
  7613. function setArrayOffset(array, offset) {
  7614. if (arguments.length < 2) {
  7615. offset = 0;
  7616. }
  7617. for (var i = 0, n = array.length; i < n; ++i, ++offset) {
  7618. this[offset] = array[i] & 0xFF;
  7619. }
  7620. }
  7621. function Uint32ArrayView(buffer, length) {
  7622. this.buffer = buffer;
  7623. this.byteLength = buffer.length;
  7624. this.length = length;
  7625. ensureUint32ArrayViewProps(this.length);
  7626. }
  7627. Uint32ArrayView.prototype = Object.create(null);
  7628. var uint32ArrayViewSetters = 0;
  7629. function createUint32ArrayProp(index) {
  7630. return {
  7631. get: function get() {
  7632. var buffer = this.buffer,
  7633. offset = index << 2;
  7634. return (buffer[offset] | buffer[offset + 1] << 8 | buffer[offset + 2] << 16 | buffer[offset + 3] << 24) >>> 0;
  7635. },
  7636. set: function set(value) {
  7637. var buffer = this.buffer,
  7638. offset = index << 2;
  7639. buffer[offset] = value & 255;
  7640. buffer[offset + 1] = value >> 8 & 255;
  7641. buffer[offset + 2] = value >> 16 & 255;
  7642. buffer[offset + 3] = value >>> 24 & 255;
  7643. }
  7644. };
  7645. }
  7646. function ensureUint32ArrayViewProps(length) {
  7647. while (uint32ArrayViewSetters < length) {
  7648. Object.defineProperty(Uint32ArrayView.prototype, uint32ArrayViewSetters, createUint32ArrayProp(uint32ArrayViewSetters));
  7649. uint32ArrayViewSetters++;
  7650. }
  7651. }
  7652. function TypedArray(arg1) {
  7653. var result, i, n;
  7654. if (typeof arg1 === 'number') {
  7655. result = [];
  7656. for (i = 0; i < arg1; ++i) {
  7657. result[i] = 0;
  7658. }
  7659. } else if ('slice' in arg1) {
  7660. result = arg1.slice(0);
  7661. } else {
  7662. result = [];
  7663. for (i = 0, n = arg1.length; i < n; ++i) {
  7664. result[i] = arg1[i];
  7665. }
  7666. }
  7667. result.subarray = subarray;
  7668. result.buffer = result;
  7669. result.byteLength = result.length;
  7670. result.set = setArrayOffset;
  7671. if ((typeof arg1 === 'undefined' ? 'undefined' : _typeof(arg1)) === 'object' && arg1.buffer) {
  7672. result.buffer = arg1.buffer;
  7673. }
  7674. return result;
  7675. }
  7676. globalScope.Uint8Array = TypedArray;
  7677. globalScope.Int8Array = TypedArray;
  7678. globalScope.Int32Array = TypedArray;
  7679. globalScope.Uint16Array = TypedArray;
  7680. globalScope.Float32Array = TypedArray;
  7681. globalScope.Float64Array = TypedArray;
  7682. globalScope.Uint32Array = function () {
  7683. if (arguments.length === 3) {
  7684. if (arguments[1] !== 0) {
  7685. throw new Error('offset !== 0 is not supported');
  7686. }
  7687. return new Uint32ArrayView(arguments[0], arguments[2]);
  7688. }
  7689. return TypedArray.apply(this, arguments);
  7690. };
  7691. })();
  7692. (function canvasPixelArrayBuffer() {
  7693. if (!hasDOM || !window.CanvasPixelArray) {
  7694. return;
  7695. }
  7696. var cpaProto = window.CanvasPixelArray.prototype;
  7697. if ('buffer' in cpaProto) {
  7698. return;
  7699. }
  7700. Object.defineProperty(cpaProto, 'buffer', {
  7701. get: function get() {
  7702. return this;
  7703. },
  7704. enumerable: false,
  7705. configurable: true
  7706. });
  7707. Object.defineProperty(cpaProto, 'byteLength', {
  7708. get: function get() {
  7709. return this.length;
  7710. },
  7711. enumerable: false,
  7712. configurable: true
  7713. });
  7714. })();
  7715. (function normalizeURLObject() {
  7716. if (!globalScope.URL) {
  7717. globalScope.URL = globalScope.webkitURL;
  7718. }
  7719. })();
  7720. (function checkObjectDefinePropertyCompatibility() {
  7721. if (typeof Object.defineProperty !== 'undefined') {
  7722. var definePropertyPossible = true;
  7723. try {
  7724. if (hasDOM) {
  7725. Object.defineProperty(new Image(), 'id', { value: 'test' });
  7726. }
  7727. var Test = function Test() {};
  7728. Test.prototype = {
  7729. get id() {}
  7730. };
  7731. Object.defineProperty(new Test(), 'id', {
  7732. value: '',
  7733. configurable: true,
  7734. enumerable: true,
  7735. writable: false
  7736. });
  7737. } catch (e) {
  7738. definePropertyPossible = false;
  7739. }
  7740. if (definePropertyPossible) {
  7741. return;
  7742. }
  7743. }
  7744. Object.defineProperty = function objectDefineProperty(obj, name, def) {
  7745. delete obj[name];
  7746. if ('get' in def) {
  7747. obj.__defineGetter__(name, def['get']);
  7748. }
  7749. if ('set' in def) {
  7750. obj.__defineSetter__(name, def['set']);
  7751. }
  7752. if ('value' in def) {
  7753. obj.__defineSetter__(name, function objectDefinePropertySetter(value) {
  7754. this.__defineGetter__(name, function objectDefinePropertyGetter() {
  7755. return value;
  7756. });
  7757. return value;
  7758. });
  7759. obj[name] = def.value;
  7760. }
  7761. };
  7762. })();
  7763. (function checkXMLHttpRequestResponseCompatibility() {
  7764. if (typeof XMLHttpRequest === 'undefined') {
  7765. return;
  7766. }
  7767. var xhrPrototype = XMLHttpRequest.prototype;
  7768. var xhr = new XMLHttpRequest();
  7769. if (!('overrideMimeType' in xhr)) {
  7770. Object.defineProperty(xhrPrototype, 'overrideMimeType', {
  7771. value: function xmlHttpRequestOverrideMimeType(mimeType) {}
  7772. });
  7773. }
  7774. if ('responseType' in xhr) {
  7775. return;
  7776. }
  7777. Object.defineProperty(xhrPrototype, 'responseType', {
  7778. get: function xmlHttpRequestGetResponseType() {
  7779. return this._responseType || 'text';
  7780. },
  7781. set: function xmlHttpRequestSetResponseType(value) {
  7782. if (value === 'text' || value === 'arraybuffer') {
  7783. this._responseType = value;
  7784. if (value === 'arraybuffer' && typeof this.overrideMimeType === 'function') {
  7785. this.overrideMimeType('text/plain; charset=x-user-defined');
  7786. }
  7787. }
  7788. }
  7789. });
  7790. if (typeof VBArray !== 'undefined') {
  7791. Object.defineProperty(xhrPrototype, 'response', {
  7792. get: function xmlHttpRequestResponseGet() {
  7793. if (this.responseType === 'arraybuffer') {
  7794. return new Uint8Array(new VBArray(this.responseBody).toArray());
  7795. }
  7796. return this.responseText;
  7797. }
  7798. });
  7799. return;
  7800. }
  7801. Object.defineProperty(xhrPrototype, 'response', {
  7802. get: function xmlHttpRequestResponseGet() {
  7803. if (this.responseType !== 'arraybuffer') {
  7804. return this.responseText;
  7805. }
  7806. var text = this.responseText;
  7807. var i,
  7808. n = text.length;
  7809. var result = new Uint8Array(n);
  7810. for (i = 0; i < n; ++i) {
  7811. result[i] = text.charCodeAt(i) & 0xFF;
  7812. }
  7813. return result.buffer;
  7814. }
  7815. });
  7816. })();
  7817. (function checkWindowBtoaCompatibility() {
  7818. if ('btoa' in globalScope) {
  7819. return;
  7820. }
  7821. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  7822. globalScope.btoa = function (chars) {
  7823. var buffer = '';
  7824. var i, n;
  7825. for (i = 0, n = chars.length; i < n; i += 3) {
  7826. var b1 = chars.charCodeAt(i) & 0xFF;
  7827. var b2 = chars.charCodeAt(i + 1) & 0xFF;
  7828. var b3 = chars.charCodeAt(i + 2) & 0xFF;
  7829. var d1 = b1 >> 2,
  7830. d2 = (b1 & 3) << 4 | b2 >> 4;
  7831. var d3 = i + 1 < n ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
  7832. var d4 = i + 2 < n ? b3 & 0x3F : 64;
  7833. buffer += digits.charAt(d1) + digits.charAt(d2) + digits.charAt(d3) + digits.charAt(d4);
  7834. }
  7835. return buffer;
  7836. };
  7837. })();
  7838. (function checkWindowAtobCompatibility() {
  7839. if ('atob' in globalScope) {
  7840. return;
  7841. }
  7842. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  7843. globalScope.atob = function (input) {
  7844. input = input.replace(/=+$/, '');
  7845. if (input.length % 4 === 1) {
  7846. throw new Error('bad atob input');
  7847. }
  7848. for (var bc = 0, bs, buffer, idx = 0, output = ''; buffer = input.charAt(idx++); ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer, bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0) {
  7849. buffer = digits.indexOf(buffer);
  7850. }
  7851. return output;
  7852. };
  7853. })();
  7854. (function checkFunctionPrototypeBindCompatibility() {
  7855. if (typeof Function.prototype.bind !== 'undefined') {
  7856. return;
  7857. }
  7858. Function.prototype.bind = function functionPrototypeBind(obj) {
  7859. var fn = this,
  7860. headArgs = Array.prototype.slice.call(arguments, 1);
  7861. var bound = function functionPrototypeBindBound() {
  7862. var args = headArgs.concat(Array.prototype.slice.call(arguments));
  7863. return fn.apply(obj, args);
  7864. };
  7865. return bound;
  7866. };
  7867. })();
  7868. (function checkDatasetProperty() {
  7869. if (!hasDOM) {
  7870. return;
  7871. }
  7872. var div = document.createElement('div');
  7873. if ('dataset' in div) {
  7874. return;
  7875. }
  7876. Object.defineProperty(HTMLElement.prototype, 'dataset', {
  7877. get: function get() {
  7878. if (this._dataset) {
  7879. return this._dataset;
  7880. }
  7881. var dataset = {};
  7882. for (var j = 0, jj = this.attributes.length; j < jj; j++) {
  7883. var attribute = this.attributes[j];
  7884. if (attribute.name.substring(0, 5) !== 'data-') {
  7885. continue;
  7886. }
  7887. var key = attribute.name.substring(5).replace(/\-([a-z])/g, function (all, ch) {
  7888. return ch.toUpperCase();
  7889. });
  7890. dataset[key] = attribute.value;
  7891. }
  7892. Object.defineProperty(this, '_dataset', {
  7893. value: dataset,
  7894. writable: false,
  7895. enumerable: false
  7896. });
  7897. return dataset;
  7898. },
  7899. enumerable: true
  7900. });
  7901. })();
  7902. (function checkClassListProperty() {
  7903. function changeList(element, itemName, add, remove) {
  7904. var s = element.className || '';
  7905. var list = s.split(/\s+/g);
  7906. if (list[0] === '') {
  7907. list.shift();
  7908. }
  7909. var index = list.indexOf(itemName);
  7910. if (index < 0 && add) {
  7911. list.push(itemName);
  7912. }
  7913. if (index >= 0 && remove) {
  7914. list.splice(index, 1);
  7915. }
  7916. element.className = list.join(' ');
  7917. return index >= 0;
  7918. }
  7919. if (!hasDOM) {
  7920. return;
  7921. }
  7922. var div = document.createElement('div');
  7923. if ('classList' in div) {
  7924. return;
  7925. }
  7926. var classListPrototype = {
  7927. add: function add(name) {
  7928. changeList(this.element, name, true, false);
  7929. },
  7930. contains: function contains(name) {
  7931. return changeList(this.element, name, false, false);
  7932. },
  7933. remove: function remove(name) {
  7934. changeList(this.element, name, false, true);
  7935. },
  7936. toggle: function toggle(name) {
  7937. changeList(this.element, name, true, true);
  7938. }
  7939. };
  7940. Object.defineProperty(HTMLElement.prototype, 'classList', {
  7941. get: function get() {
  7942. if (this._classList) {
  7943. return this._classList;
  7944. }
  7945. var classList = Object.create(classListPrototype, {
  7946. element: {
  7947. value: this,
  7948. writable: false,
  7949. enumerable: true
  7950. }
  7951. });
  7952. Object.defineProperty(this, '_classList', {
  7953. value: classList,
  7954. writable: false,
  7955. enumerable: false
  7956. });
  7957. return classList;
  7958. },
  7959. enumerable: true
  7960. });
  7961. })();
  7962. (function checkWorkerConsoleCompatibility() {
  7963. if (typeof importScripts === 'undefined' || 'console' in globalScope) {
  7964. return;
  7965. }
  7966. var consoleTimer = {};
  7967. var workerConsole = {
  7968. log: function log() {
  7969. var args = Array.prototype.slice.call(arguments);
  7970. globalScope.postMessage({
  7971. targetName: 'main',
  7972. action: 'console_log',
  7973. data: args
  7974. });
  7975. },
  7976. error: function error() {
  7977. var args = Array.prototype.slice.call(arguments);
  7978. globalScope.postMessage({
  7979. targetName: 'main',
  7980. action: 'console_error',
  7981. data: args
  7982. });
  7983. },
  7984. time: function time(name) {
  7985. consoleTimer[name] = Date.now();
  7986. },
  7987. timeEnd: function timeEnd(name) {
  7988. var time = consoleTimer[name];
  7989. if (!time) {
  7990. throw new Error('Unknown timer name ' + name);
  7991. }
  7992. this.log('Timer:', name, Date.now() - time);
  7993. }
  7994. };
  7995. globalScope.console = workerConsole;
  7996. })();
  7997. (function checkConsoleCompatibility() {
  7998. if (!hasDOM) {
  7999. return;
  8000. }
  8001. if (!('console' in window)) {
  8002. window.console = {
  8003. log: function log() {},
  8004. error: function error() {},
  8005. warn: function warn() {}
  8006. };
  8007. return;
  8008. }
  8009. if (!('bind' in console.log)) {
  8010. console.log = function (fn) {
  8011. return function (msg) {
  8012. return fn(msg);
  8013. };
  8014. }(console.log);
  8015. console.error = function (fn) {
  8016. return function (msg) {
  8017. return fn(msg);
  8018. };
  8019. }(console.error);
  8020. console.warn = function (fn) {
  8021. return function (msg) {
  8022. return fn(msg);
  8023. };
  8024. }(console.warn);
  8025. return;
  8026. }
  8027. })();
  8028. (function checkOnClickCompatibility() {
  8029. function ignoreIfTargetDisabled(event) {
  8030. if (isDisabled(event.target)) {
  8031. event.stopPropagation();
  8032. }
  8033. }
  8034. function isDisabled(node) {
  8035. return node.disabled || node.parentNode && isDisabled(node.parentNode);
  8036. }
  8037. if (isOpera) {
  8038. document.addEventListener('click', ignoreIfTargetDisabled, true);
  8039. }
  8040. })();
  8041. (function checkOnBlobSupport() {
  8042. if (isIE || isIOSChrome) {
  8043. PDFJS.disableCreateObjectURL = true;
  8044. }
  8045. })();
  8046. (function checkNavigatorLanguage() {
  8047. if (typeof navigator === 'undefined') {
  8048. return;
  8049. }
  8050. if ('language' in navigator) {
  8051. return;
  8052. }
  8053. PDFJS.locale = navigator.userLanguage || 'en-US';
  8054. })();
  8055. (function checkRangeRequests() {
  8056. if (isSafari || isAndroidPre3 || isChromeWithRangeBug || isIOS) {
  8057. PDFJS.disableRange = true;
  8058. PDFJS.disableStream = true;
  8059. }
  8060. })();
  8061. (function checkHistoryManipulation() {
  8062. if (!hasDOM) {
  8063. return;
  8064. }
  8065. if (!history.pushState || isAndroidPre3) {
  8066. PDFJS.disableHistory = true;
  8067. }
  8068. })();
  8069. (function checkSetPresenceInImageData() {
  8070. if (!hasDOM) {
  8071. return;
  8072. }
  8073. if (window.CanvasPixelArray) {
  8074. if (typeof window.CanvasPixelArray.prototype.set !== 'function') {
  8075. window.CanvasPixelArray.prototype.set = function (arr) {
  8076. for (var i = 0, ii = this.length; i < ii; i++) {
  8077. this[i] = arr[i];
  8078. }
  8079. };
  8080. }
  8081. } else {
  8082. var polyfill = false,
  8083. versionMatch;
  8084. if (isChrome) {
  8085. versionMatch = userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
  8086. polyfill = versionMatch && parseInt(versionMatch[2]) < 21;
  8087. } else if (isAndroid) {
  8088. polyfill = isAndroidPre5;
  8089. } else if (isSafari) {
  8090. versionMatch = userAgent.match(/Version\/([0-9]+)\.([0-9]+)\.([0-9]+) Safari\//);
  8091. polyfill = versionMatch && parseInt(versionMatch[1]) < 6;
  8092. }
  8093. if (polyfill) {
  8094. var contextPrototype = window.CanvasRenderingContext2D.prototype;
  8095. var createImageData = contextPrototype.createImageData;
  8096. contextPrototype.createImageData = function (w, h) {
  8097. var imageData = createImageData.call(this, w, h);
  8098. imageData.data.set = function (arr) {
  8099. for (var i = 0, ii = this.length; i < ii; i++) {
  8100. this[i] = arr[i];
  8101. }
  8102. };
  8103. return imageData;
  8104. };
  8105. contextPrototype = null;
  8106. }
  8107. }
  8108. })();
  8109. (function checkRequestAnimationFrame() {
  8110. function installFakeAnimationFrameFunctions() {
  8111. window.requestAnimationFrame = function (callback) {
  8112. return window.setTimeout(callback, 20);
  8113. };
  8114. window.cancelAnimationFrame = function (timeoutID) {
  8115. window.clearTimeout(timeoutID);
  8116. };
  8117. }
  8118. if (!hasDOM) {
  8119. return;
  8120. }
  8121. if (isIOS) {
  8122. installFakeAnimationFrameFunctions();
  8123. return;
  8124. }
  8125. if ('requestAnimationFrame' in window) {
  8126. return;
  8127. }
  8128. window.requestAnimationFrame = window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame;
  8129. if (window.requestAnimationFrame) {
  8130. return;
  8131. }
  8132. installFakeAnimationFrameFunctions();
  8133. })();
  8134. (function checkCanvasSizeLimitation() {
  8135. if (isIOS || isAndroid) {
  8136. PDFJS.maxCanvasPixels = 5242880;
  8137. }
  8138. })();
  8139. (function checkFullscreenSupport() {
  8140. if (!hasDOM) {
  8141. return;
  8142. }
  8143. if (isIE && window.parent !== window) {
  8144. PDFJS.disableFullscreen = true;
  8145. }
  8146. })();
  8147. (function checkCurrentScript() {
  8148. if (!hasDOM) {
  8149. return;
  8150. }
  8151. if ('currentScript' in document) {
  8152. return;
  8153. }
  8154. Object.defineProperty(document, 'currentScript', {
  8155. get: function get() {
  8156. var scripts = document.getElementsByTagName('script');
  8157. return scripts[scripts.length - 1];
  8158. },
  8159. enumerable: true,
  8160. configurable: true
  8161. });
  8162. })();
  8163. (function checkInputTypeNumberAssign() {
  8164. if (!hasDOM) {
  8165. return;
  8166. }
  8167. var el = document.createElement('input');
  8168. try {
  8169. el.type = 'number';
  8170. } catch (ex) {
  8171. var inputProto = el.constructor.prototype;
  8172. var typeProperty = Object.getOwnPropertyDescriptor(inputProto, 'type');
  8173. Object.defineProperty(inputProto, 'type', {
  8174. get: function get() {
  8175. return typeProperty.get.call(this);
  8176. },
  8177. set: function set(value) {
  8178. typeProperty.set.call(this, value === 'number' ? 'text' : value);
  8179. },
  8180. enumerable: true,
  8181. configurable: true
  8182. });
  8183. }
  8184. })();
  8185. (function checkDocumentReadyState() {
  8186. if (!hasDOM) {
  8187. return;
  8188. }
  8189. if (!document.attachEvent) {
  8190. return;
  8191. }
  8192. var documentProto = document.constructor.prototype;
  8193. var readyStateProto = Object.getOwnPropertyDescriptor(documentProto, 'readyState');
  8194. Object.defineProperty(documentProto, 'readyState', {
  8195. get: function get() {
  8196. var value = readyStateProto.get.call(this);
  8197. return value === 'interactive' ? 'loading' : value;
  8198. },
  8199. set: function set(value) {
  8200. readyStateProto.set.call(this, value);
  8201. },
  8202. enumerable: true,
  8203. configurable: true
  8204. });
  8205. })();
  8206. (function checkChildNodeRemove() {
  8207. if (!hasDOM) {
  8208. return;
  8209. }
  8210. if (typeof Element.prototype.remove !== 'undefined') {
  8211. return;
  8212. }
  8213. Element.prototype.remove = function () {
  8214. if (this.parentNode) {
  8215. this.parentNode.removeChild(this);
  8216. }
  8217. };
  8218. })();
  8219. (function checkNumberIsNaN() {
  8220. if (Number.isNaN) {
  8221. return;
  8222. }
  8223. Number.isNaN = __w_pdfjs_require__(89);
  8224. })();
  8225. (function checkNumberIsInteger() {
  8226. if (Number.isInteger) {
  8227. return;
  8228. }
  8229. Number.isInteger = __w_pdfjs_require__(91);
  8230. })();
  8231. (function checkPromise() {
  8232. if (globalScope.Promise) {
  8233. return;
  8234. }
  8235. globalScope.Promise = __w_pdfjs_require__(94);
  8236. })();
  8237. (function checkWeakMap() {
  8238. if (globalScope.WeakMap) {
  8239. return;
  8240. }
  8241. globalScope.WeakMap = __w_pdfjs_require__(103);
  8242. })();
  8243. (function checkURLConstructor() {
  8244. var hasWorkingUrl = false;
  8245. try {
  8246. if (typeof URL === 'function' && _typeof(URL.prototype) === 'object' && 'origin' in URL.prototype) {
  8247. var u = new URL('b', 'http://a');
  8248. u.pathname = 'c%20d';
  8249. hasWorkingUrl = u.href === 'http://a/c%20d';
  8250. }
  8251. } catch (e) {}
  8252. if (hasWorkingUrl) {
  8253. return;
  8254. }
  8255. var relative = Object.create(null);
  8256. relative['ftp'] = 21;
  8257. relative['file'] = 0;
  8258. relative['gopher'] = 70;
  8259. relative['http'] = 80;
  8260. relative['https'] = 443;
  8261. relative['ws'] = 80;
  8262. relative['wss'] = 443;
  8263. var relativePathDotMapping = Object.create(null);
  8264. relativePathDotMapping['%2e'] = '.';
  8265. relativePathDotMapping['.%2e'] = '..';
  8266. relativePathDotMapping['%2e.'] = '..';
  8267. relativePathDotMapping['%2e%2e'] = '..';
  8268. function isRelativeScheme(scheme) {
  8269. return relative[scheme] !== undefined;
  8270. }
  8271. function invalid() {
  8272. clear.call(this);
  8273. this._isInvalid = true;
  8274. }
  8275. function IDNAToASCII(h) {
  8276. if (h === '') {
  8277. invalid.call(this);
  8278. }
  8279. return h.toLowerCase();
  8280. }
  8281. function percentEscape(c) {
  8282. var unicode = c.charCodeAt(0);
  8283. if (unicode > 0x20 && unicode < 0x7F && [0x22, 0x23, 0x3C, 0x3E, 0x3F, 0x60].indexOf(unicode) === -1) {
  8284. return c;
  8285. }
  8286. return encodeURIComponent(c);
  8287. }
  8288. function percentEscapeQuery(c) {
  8289. var unicode = c.charCodeAt(0);
  8290. if (unicode > 0x20 && unicode < 0x7F && [0x22, 0x23, 0x3C, 0x3E, 0x60].indexOf(unicode) === -1) {
  8291. return c;
  8292. }
  8293. return encodeURIComponent(c);
  8294. }
  8295. var EOF,
  8296. ALPHA = /[a-zA-Z]/,
  8297. ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/;
  8298. function parse(input, stateOverride, base) {
  8299. function err(message) {
  8300. errors.push(message);
  8301. }
  8302. var state = stateOverride || 'scheme start',
  8303. cursor = 0,
  8304. buffer = '',
  8305. seenAt = false,
  8306. seenBracket = false,
  8307. errors = [];
  8308. loop: while ((input[cursor - 1] !== EOF || cursor === 0) && !this._isInvalid) {
  8309. var c = input[cursor];
  8310. switch (state) {
  8311. case 'scheme start':
  8312. if (c && ALPHA.test(c)) {
  8313. buffer += c.toLowerCase();
  8314. state = 'scheme';
  8315. } else if (!stateOverride) {
  8316. buffer = '';
  8317. state = 'no scheme';
  8318. continue;
  8319. } else {
  8320. err('Invalid scheme.');
  8321. break loop;
  8322. }
  8323. break;
  8324. case 'scheme':
  8325. if (c && ALPHANUMERIC.test(c)) {
  8326. buffer += c.toLowerCase();
  8327. } else if (c === ':') {
  8328. this._scheme = buffer;
  8329. buffer = '';
  8330. if (stateOverride) {
  8331. break loop;
  8332. }
  8333. if (isRelativeScheme(this._scheme)) {
  8334. this._isRelative = true;
  8335. }
  8336. if (this._scheme === 'file') {
  8337. state = 'relative';
  8338. } else if (this._isRelative && base && base._scheme === this._scheme) {
  8339. state = 'relative or authority';
  8340. } else if (this._isRelative) {
  8341. state = 'authority first slash';
  8342. } else {
  8343. state = 'scheme data';
  8344. }
  8345. } else if (!stateOverride) {
  8346. buffer = '';
  8347. cursor = 0;
  8348. state = 'no scheme';
  8349. continue;
  8350. } else if (c === EOF) {
  8351. break loop;
  8352. } else {
  8353. err('Code point not allowed in scheme: ' + c);
  8354. break loop;
  8355. }
  8356. break;
  8357. case 'scheme data':
  8358. if (c === '?') {
  8359. this._query = '?';
  8360. state = 'query';
  8361. } else if (c === '#') {
  8362. this._fragment = '#';
  8363. state = 'fragment';
  8364. } else {
  8365. if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') {
  8366. this._schemeData += percentEscape(c);
  8367. }
  8368. }
  8369. break;
  8370. case 'no scheme':
  8371. if (!base || !isRelativeScheme(base._scheme)) {
  8372. err('Missing scheme.');
  8373. invalid.call(this);
  8374. } else {
  8375. state = 'relative';
  8376. continue;
  8377. }
  8378. break;
  8379. case 'relative or authority':
  8380. if (c === '/' && input[cursor + 1] === '/') {
  8381. state = 'authority ignore slashes';
  8382. } else {
  8383. err('Expected /, got: ' + c);
  8384. state = 'relative';
  8385. continue;
  8386. }
  8387. break;
  8388. case 'relative':
  8389. this._isRelative = true;
  8390. if (this._scheme !== 'file') {
  8391. this._scheme = base._scheme;
  8392. }
  8393. if (c === EOF) {
  8394. this._host = base._host;
  8395. this._port = base._port;
  8396. this._path = base._path.slice();
  8397. this._query = base._query;
  8398. this._username = base._username;
  8399. this._password = base._password;
  8400. break loop;
  8401. } else if (c === '/' || c === '\\') {
  8402. if (c === '\\') {
  8403. err('\\ is an invalid code point.');
  8404. }
  8405. state = 'relative slash';
  8406. } else if (c === '?') {
  8407. this._host = base._host;
  8408. this._port = base._port;
  8409. this._path = base._path.slice();
  8410. this._query = '?';
  8411. this._username = base._username;
  8412. this._password = base._password;
  8413. state = 'query';
  8414. } else if (c === '#') {
  8415. this._host = base._host;
  8416. this._port = base._port;
  8417. this._path = base._path.slice();
  8418. this._query = base._query;
  8419. this._fragment = '#';
  8420. this._username = base._username;
  8421. this._password = base._password;
  8422. state = 'fragment';
  8423. } else {
  8424. var nextC = input[cursor + 1];
  8425. var nextNextC = input[cursor + 2];
  8426. if (this._scheme !== 'file' || !ALPHA.test(c) || nextC !== ':' && nextC !== '|' || nextNextC !== EOF && nextNextC !== '/' && nextNextC !== '\\' && nextNextC !== '?' && nextNextC !== '#') {
  8427. this._host = base._host;
  8428. this._port = base._port;
  8429. this._username = base._username;
  8430. this._password = base._password;
  8431. this._path = base._path.slice();
  8432. this._path.pop();
  8433. }
  8434. state = 'relative path';
  8435. continue;
  8436. }
  8437. break;
  8438. case 'relative slash':
  8439. if (c === '/' || c === '\\') {
  8440. if (c === '\\') {
  8441. err('\\ is an invalid code point.');
  8442. }
  8443. if (this._scheme === 'file') {
  8444. state = 'file host';
  8445. } else {
  8446. state = 'authority ignore slashes';
  8447. }
  8448. } else {
  8449. if (this._scheme !== 'file') {
  8450. this._host = base._host;
  8451. this._port = base._port;
  8452. this._username = base._username;
  8453. this._password = base._password;
  8454. }
  8455. state = 'relative path';
  8456. continue;
  8457. }
  8458. break;
  8459. case 'authority first slash':
  8460. if (c === '/') {
  8461. state = 'authority second slash';
  8462. } else {
  8463. err('Expected \'/\', got: ' + c);
  8464. state = 'authority ignore slashes';
  8465. continue;
  8466. }
  8467. break;
  8468. case 'authority second slash':
  8469. state = 'authority ignore slashes';
  8470. if (c !== '/') {
  8471. err('Expected \'/\', got: ' + c);
  8472. continue;
  8473. }
  8474. break;
  8475. case 'authority ignore slashes':
  8476. if (c !== '/' && c !== '\\') {
  8477. state = 'authority';
  8478. continue;
  8479. } else {
  8480. err('Expected authority, got: ' + c);
  8481. }
  8482. break;
  8483. case 'authority':
  8484. if (c === '@') {
  8485. if (seenAt) {
  8486. err('@ already seen.');
  8487. buffer += '%40';
  8488. }
  8489. seenAt = true;
  8490. for (var i = 0; i < buffer.length; i++) {
  8491. var cp = buffer[i];
  8492. if (cp === '\t' || cp === '\n' || cp === '\r') {
  8493. err('Invalid whitespace in authority.');
  8494. continue;
  8495. }
  8496. if (cp === ':' && this._password === null) {
  8497. this._password = '';
  8498. continue;
  8499. }
  8500. var tempC = percentEscape(cp);
  8501. if (this._password !== null) {
  8502. this._password += tempC;
  8503. } else {
  8504. this._username += tempC;
  8505. }
  8506. }
  8507. buffer = '';
  8508. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  8509. cursor -= buffer.length;
  8510. buffer = '';
  8511. state = 'host';
  8512. continue;
  8513. } else {
  8514. buffer += c;
  8515. }
  8516. break;
  8517. case 'file host':
  8518. if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  8519. if (buffer.length === 2 && ALPHA.test(buffer[0]) && (buffer[1] === ':' || buffer[1] === '|')) {
  8520. state = 'relative path';
  8521. } else if (buffer.length === 0) {
  8522. state = 'relative path start';
  8523. } else {
  8524. this._host = IDNAToASCII.call(this, buffer);
  8525. buffer = '';
  8526. state = 'relative path start';
  8527. }
  8528. continue;
  8529. } else if (c === '\t' || c === '\n' || c === '\r') {
  8530. err('Invalid whitespace in file host.');
  8531. } else {
  8532. buffer += c;
  8533. }
  8534. break;
  8535. case 'host':
  8536. case 'hostname':
  8537. if (c === ':' && !seenBracket) {
  8538. this._host = IDNAToASCII.call(this, buffer);
  8539. buffer = '';
  8540. state = 'port';
  8541. if (stateOverride === 'hostname') {
  8542. break loop;
  8543. }
  8544. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  8545. this._host = IDNAToASCII.call(this, buffer);
  8546. buffer = '';
  8547. state = 'relative path start';
  8548. if (stateOverride) {
  8549. break loop;
  8550. }
  8551. continue;
  8552. } else if (c !== '\t' && c !== '\n' && c !== '\r') {
  8553. if (c === '[') {
  8554. seenBracket = true;
  8555. } else if (c === ']') {
  8556. seenBracket = false;
  8557. }
  8558. buffer += c;
  8559. } else {
  8560. err('Invalid code point in host/hostname: ' + c);
  8561. }
  8562. break;
  8563. case 'port':
  8564. if (/[0-9]/.test(c)) {
  8565. buffer += c;
  8566. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#' || stateOverride) {
  8567. if (buffer !== '') {
  8568. var temp = parseInt(buffer, 10);
  8569. if (temp !== relative[this._scheme]) {
  8570. this._port = temp + '';
  8571. }
  8572. buffer = '';
  8573. }
  8574. if (stateOverride) {
  8575. break loop;
  8576. }
  8577. state = 'relative path start';
  8578. continue;
  8579. } else if (c === '\t' || c === '\n' || c === '\r') {
  8580. err('Invalid code point in port: ' + c);
  8581. } else {
  8582. invalid.call(this);
  8583. }
  8584. break;
  8585. case 'relative path start':
  8586. if (c === '\\') {
  8587. err('\'\\\' not allowed in path.');
  8588. }
  8589. state = 'relative path';
  8590. if (c !== '/' && c !== '\\') {
  8591. continue;
  8592. }
  8593. break;
  8594. case 'relative path':
  8595. if (c === EOF || c === '/' || c === '\\' || !stateOverride && (c === '?' || c === '#')) {
  8596. if (c === '\\') {
  8597. err('\\ not allowed in relative path.');
  8598. }
  8599. var tmp;
  8600. if (tmp = relativePathDotMapping[buffer.toLowerCase()]) {
  8601. buffer = tmp;
  8602. }
  8603. if (buffer === '..') {
  8604. this._path.pop();
  8605. if (c !== '/' && c !== '\\') {
  8606. this._path.push('');
  8607. }
  8608. } else if (buffer === '.' && c !== '/' && c !== '\\') {
  8609. this._path.push('');
  8610. } else if (buffer !== '.') {
  8611. if (this._scheme === 'file' && this._path.length === 0 && buffer.length === 2 && ALPHA.test(buffer[0]) && buffer[1] === '|') {
  8612. buffer = buffer[0] + ':';
  8613. }
  8614. this._path.push(buffer);
  8615. }
  8616. buffer = '';
  8617. if (c === '?') {
  8618. this._query = '?';
  8619. state = 'query';
  8620. } else if (c === '#') {
  8621. this._fragment = '#';
  8622. state = 'fragment';
  8623. }
  8624. } else if (c !== '\t' && c !== '\n' && c !== '\r') {
  8625. buffer += percentEscape(c);
  8626. }
  8627. break;
  8628. case 'query':
  8629. if (!stateOverride && c === '#') {
  8630. this._fragment = '#';
  8631. state = 'fragment';
  8632. } else if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') {
  8633. this._query += percentEscapeQuery(c);
  8634. }
  8635. break;
  8636. case 'fragment':
  8637. if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') {
  8638. this._fragment += c;
  8639. }
  8640. break;
  8641. }
  8642. cursor++;
  8643. }
  8644. }
  8645. function clear() {
  8646. this._scheme = '';
  8647. this._schemeData = '';
  8648. this._username = '';
  8649. this._password = null;
  8650. this._host = '';
  8651. this._port = '';
  8652. this._path = [];
  8653. this._query = '';
  8654. this._fragment = '';
  8655. this._isInvalid = false;
  8656. this._isRelative = false;
  8657. }
  8658. function JURL(url, base) {
  8659. if (base !== undefined && !(base instanceof JURL)) {
  8660. base = new JURL(String(base));
  8661. }
  8662. this._url = url;
  8663. clear.call(this);
  8664. var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, '');
  8665. parse.call(this, input, null, base);
  8666. }
  8667. JURL.prototype = {
  8668. toString: function toString() {
  8669. return this.href;
  8670. },
  8671. get href() {
  8672. if (this._isInvalid) {
  8673. return this._url;
  8674. }
  8675. var authority = '';
  8676. if (this._username !== '' || this._password !== null) {
  8677. authority = this._username + (this._password !== null ? ':' + this._password : '') + '@';
  8678. }
  8679. return this.protocol + (this._isRelative ? '//' + authority + this.host : '') + this.pathname + this._query + this._fragment;
  8680. },
  8681. set href(value) {
  8682. clear.call(this);
  8683. parse.call(this, value);
  8684. },
  8685. get protocol() {
  8686. return this._scheme + ':';
  8687. },
  8688. set protocol(value) {
  8689. if (this._isInvalid) {
  8690. return;
  8691. }
  8692. parse.call(this, value + ':', 'scheme start');
  8693. },
  8694. get host() {
  8695. return this._isInvalid ? '' : this._port ? this._host + ':' + this._port : this._host;
  8696. },
  8697. set host(value) {
  8698. if (this._isInvalid || !this._isRelative) {
  8699. return;
  8700. }
  8701. parse.call(this, value, 'host');
  8702. },
  8703. get hostname() {
  8704. return this._host;
  8705. },
  8706. set hostname(value) {
  8707. if (this._isInvalid || !this._isRelative) {
  8708. return;
  8709. }
  8710. parse.call(this, value, 'hostname');
  8711. },
  8712. get port() {
  8713. return this._port;
  8714. },
  8715. set port(value) {
  8716. if (this._isInvalid || !this._isRelative) {
  8717. return;
  8718. }
  8719. parse.call(this, value, 'port');
  8720. },
  8721. get pathname() {
  8722. return this._isInvalid ? '' : this._isRelative ? '/' + this._path.join('/') : this._schemeData;
  8723. },
  8724. set pathname(value) {
  8725. if (this._isInvalid || !this._isRelative) {
  8726. return;
  8727. }
  8728. this._path = [];
  8729. parse.call(this, value, 'relative path start');
  8730. },
  8731. get search() {
  8732. return this._isInvalid || !this._query || this._query === '?' ? '' : this._query;
  8733. },
  8734. set search(value) {
  8735. if (this._isInvalid || !this._isRelative) {
  8736. return;
  8737. }
  8738. this._query = '?';
  8739. if (value[0] === '?') {
  8740. value = value.slice(1);
  8741. }
  8742. parse.call(this, value, 'query');
  8743. },
  8744. get hash() {
  8745. return this._isInvalid || !this._fragment || this._fragment === '#' ? '' : this._fragment;
  8746. },
  8747. set hash(value) {
  8748. if (this._isInvalid) {
  8749. return;
  8750. }
  8751. this._fragment = '#';
  8752. if (value[0] === '#') {
  8753. value = value.slice(1);
  8754. }
  8755. parse.call(this, value, 'fragment');
  8756. },
  8757. get origin() {
  8758. var host;
  8759. if (this._isInvalid || !this._scheme) {
  8760. return '';
  8761. }
  8762. switch (this._scheme) {
  8763. case 'data':
  8764. case 'file':
  8765. case 'javascript':
  8766. case 'mailto':
  8767. return 'null';
  8768. case 'blob':
  8769. try {
  8770. return new JURL(this._schemeData).origin || 'null';
  8771. } catch (_) {}
  8772. return 'null';
  8773. }
  8774. host = this.host;
  8775. if (!host) {
  8776. return '';
  8777. }
  8778. return this._scheme + '://' + host;
  8779. }
  8780. };
  8781. var OriginalURL = globalScope.URL;
  8782. if (OriginalURL) {
  8783. JURL.createObjectURL = function (blob) {
  8784. return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
  8785. };
  8786. JURL.revokeObjectURL = function (url) {
  8787. OriginalURL.revokeObjectURL(url);
  8788. };
  8789. }
  8790. globalScope.URL = JURL;
  8791. })();
  8792. }
  8793. /***/ }),
  8794. /* 77 */
  8795. /***/ (function(module, exports, __w_pdfjs_require__) {
  8796. "use strict";
  8797. __w_pdfjs_require__(78);
  8798. module.exports = __w_pdfjs_require__(5).Uint8ClampedArray;
  8799. /***/ }),
  8800. /* 78 */
  8801. /***/ (function(module, exports, __w_pdfjs_require__) {
  8802. "use strict";
  8803. __w_pdfjs_require__(79)('Uint8', 1, function (init) {
  8804. return function Uint8ClampedArray(data, byteOffset, length) {
  8805. return init(this, data, byteOffset, length);
  8806. };
  8807. }, true);
  8808. /***/ }),
  8809. /* 79 */
  8810. /***/ (function(module, exports, __w_pdfjs_require__) {
  8811. "use strict";
  8812. 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; };
  8813. if (__w_pdfjs_require__(9)) {
  8814. var LIBRARY = __w_pdfjs_require__(26);
  8815. var global = __w_pdfjs_require__(1);
  8816. var fails = __w_pdfjs_require__(10);
  8817. var $export = __w_pdfjs_require__(4);
  8818. var $typed = __w_pdfjs_require__(46);
  8819. var $buffer = __w_pdfjs_require__(80);
  8820. var ctx = __w_pdfjs_require__(11);
  8821. var anInstance = __w_pdfjs_require__(23);
  8822. var propertyDesc = __w_pdfjs_require__(27);
  8823. var hide = __w_pdfjs_require__(6);
  8824. var redefineAll = __w_pdfjs_require__(22);
  8825. var toInteger = __w_pdfjs_require__(17);
  8826. var toLength = __w_pdfjs_require__(12);
  8827. var toIndex = __w_pdfjs_require__(47);
  8828. var toAbsoluteIndex = __w_pdfjs_require__(29);
  8829. var toPrimitive = __w_pdfjs_require__(33);
  8830. var has = __w_pdfjs_require__(8);
  8831. var classof = __w_pdfjs_require__(30);
  8832. var isObject = __w_pdfjs_require__(2);
  8833. var toObject = __w_pdfjs_require__(18);
  8834. var isArrayIter = __w_pdfjs_require__(53);
  8835. var create = __w_pdfjs_require__(54);
  8836. var getPrototypeOf = __w_pdfjs_require__(56);
  8837. var gOPN = __w_pdfjs_require__(48).f;
  8838. var getIterFn = __w_pdfjs_require__(57);
  8839. var uid = __w_pdfjs_require__(16);
  8840. var wks = __w_pdfjs_require__(3);
  8841. var createArrayMethod = __w_pdfjs_require__(39);
  8842. var createArrayIncludes = __w_pdfjs_require__(50);
  8843. var speciesConstructor = __w_pdfjs_require__(40);
  8844. var ArrayIterators = __w_pdfjs_require__(58);
  8845. var Iterators = __w_pdfjs_require__(19);
  8846. var $iterDetect = __w_pdfjs_require__(41);
  8847. var setSpecies = __w_pdfjs_require__(60);
  8848. var arrayFill = __w_pdfjs_require__(52);
  8849. var arrayCopyWithin = __w_pdfjs_require__(88);
  8850. var $DP = __w_pdfjs_require__(14);
  8851. var $GOPD = __w_pdfjs_require__(61);
  8852. var dP = $DP.f;
  8853. var gOPD = $GOPD.f;
  8854. var RangeError = global.RangeError;
  8855. var TypeError = global.TypeError;
  8856. var Uint8Array = global.Uint8Array;
  8857. var ARRAY_BUFFER = 'ArrayBuffer';
  8858. var SHARED_BUFFER = 'Shared' + ARRAY_BUFFER;
  8859. var BYTES_PER_ELEMENT = 'BYTES_PER_ELEMENT';
  8860. var PROTOTYPE = 'prototype';
  8861. var ArrayProto = Array[PROTOTYPE];
  8862. var $ArrayBuffer = $buffer.ArrayBuffer;
  8863. var $DataView = $buffer.DataView;
  8864. var arrayForEach = createArrayMethod(0);
  8865. var arrayFilter = createArrayMethod(2);
  8866. var arraySome = createArrayMethod(3);
  8867. var arrayEvery = createArrayMethod(4);
  8868. var arrayFind = createArrayMethod(5);
  8869. var arrayFindIndex = createArrayMethod(6);
  8870. var arrayIncludes = createArrayIncludes(true);
  8871. var arrayIndexOf = createArrayIncludes(false);
  8872. var arrayValues = ArrayIterators.values;
  8873. var arrayKeys = ArrayIterators.keys;
  8874. var arrayEntries = ArrayIterators.entries;
  8875. var arrayLastIndexOf = ArrayProto.lastIndexOf;
  8876. var arrayReduce = ArrayProto.reduce;
  8877. var arrayReduceRight = ArrayProto.reduceRight;
  8878. var arrayJoin = ArrayProto.join;
  8879. var arraySort = ArrayProto.sort;
  8880. var arraySlice = ArrayProto.slice;
  8881. var arrayToString = ArrayProto.toString;
  8882. var arrayToLocaleString = ArrayProto.toLocaleString;
  8883. var ITERATOR = wks('iterator');
  8884. var TAG = wks('toStringTag');
  8885. var TYPED_CONSTRUCTOR = uid('typed_constructor');
  8886. var DEF_CONSTRUCTOR = uid('def_constructor');
  8887. var ALL_CONSTRUCTORS = $typed.CONSTR;
  8888. var TYPED_ARRAY = $typed.TYPED;
  8889. var VIEW = $typed.VIEW;
  8890. var WRONG_LENGTH = 'Wrong length!';
  8891. var $map = createArrayMethod(1, function (O, length) {
  8892. return allocate(speciesConstructor(O, O[DEF_CONSTRUCTOR]), length);
  8893. });
  8894. var LITTLE_ENDIAN = fails(function () {
  8895. return new Uint8Array(new Uint16Array([1]).buffer)[0] === 1;
  8896. });
  8897. var FORCED_SET = !!Uint8Array && !!Uint8Array[PROTOTYPE].set && fails(function () {
  8898. new Uint8Array(1).set({});
  8899. });
  8900. var toOffset = function toOffset(it, BYTES) {
  8901. var offset = toInteger(it);
  8902. if (offset < 0 || offset % BYTES) throw RangeError('Wrong offset!');
  8903. return offset;
  8904. };
  8905. var validate = function validate(it) {
  8906. if (isObject(it) && TYPED_ARRAY in it) return it;
  8907. throw TypeError(it + ' is not a typed array!');
  8908. };
  8909. var allocate = function allocate(C, length) {
  8910. if (!(isObject(C) && TYPED_CONSTRUCTOR in C)) {
  8911. throw TypeError('It is not a typed array constructor!');
  8912. }
  8913. return new C(length);
  8914. };
  8915. var speciesFromList = function speciesFromList(O, list) {
  8916. return fromList(speciesConstructor(O, O[DEF_CONSTRUCTOR]), list);
  8917. };
  8918. var fromList = function fromList(C, list) {
  8919. var index = 0;
  8920. var length = list.length;
  8921. var result = allocate(C, length);
  8922. while (length > index) {
  8923. result[index] = list[index++];
  8924. }return result;
  8925. };
  8926. var addGetter = function addGetter(it, key, internal) {
  8927. dP(it, key, {
  8928. get: function get() {
  8929. return this._d[internal];
  8930. }
  8931. });
  8932. };
  8933. var $from = function from(source) {
  8934. var O = toObject(source);
  8935. var aLen = arguments.length;
  8936. var mapfn = aLen > 1 ? arguments[1] : undefined;
  8937. var mapping = mapfn !== undefined;
  8938. var iterFn = getIterFn(O);
  8939. var i, length, values, result, step, iterator;
  8940. if (iterFn != undefined && !isArrayIter(iterFn)) {
  8941. for (iterator = iterFn.call(O), values = [], i = 0; !(step = iterator.next()).done; i++) {
  8942. values.push(step.value);
  8943. }
  8944. O = values;
  8945. }
  8946. if (mapping && aLen > 2) mapfn = ctx(mapfn, arguments[2], 2);
  8947. for (i = 0, length = toLength(O.length), result = allocate(this, length); length > i; i++) {
  8948. result[i] = mapping ? mapfn(O[i], i) : O[i];
  8949. }
  8950. return result;
  8951. };
  8952. var $of = function of() {
  8953. var index = 0;
  8954. var length = arguments.length;
  8955. var result = allocate(this, length);
  8956. while (length > index) {
  8957. result[index] = arguments[index++];
  8958. }return result;
  8959. };
  8960. var TO_LOCALE_BUG = !!Uint8Array && fails(function () {
  8961. arrayToLocaleString.call(new Uint8Array(1));
  8962. });
  8963. var $toLocaleString = function toLocaleString() {
  8964. return arrayToLocaleString.apply(TO_LOCALE_BUG ? arraySlice.call(validate(this)) : validate(this), arguments);
  8965. };
  8966. var proto = {
  8967. copyWithin: function copyWithin(target, start) {
  8968. return arrayCopyWithin.call(validate(this), target, start, arguments.length > 2 ? arguments[2] : undefined);
  8969. },
  8970. every: function every(callbackfn) {
  8971. return arrayEvery(validate(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  8972. },
  8973. fill: function fill(value) {
  8974. return arrayFill.apply(validate(this), arguments);
  8975. },
  8976. filter: function filter(callbackfn) {
  8977. return speciesFromList(this, arrayFilter(validate(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined));
  8978. },
  8979. find: function find(predicate) {
  8980. return arrayFind(validate(this), predicate, arguments.length > 1 ? arguments[1] : undefined);
  8981. },
  8982. findIndex: function findIndex(predicate) {
  8983. return arrayFindIndex(validate(this), predicate, arguments.length > 1 ? arguments[1] : undefined);
  8984. },
  8985. forEach: function forEach(callbackfn) {
  8986. arrayForEach(validate(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  8987. },
  8988. indexOf: function indexOf(searchElement) {
  8989. return arrayIndexOf(validate(this), searchElement, arguments.length > 1 ? arguments[1] : undefined);
  8990. },
  8991. includes: function includes(searchElement) {
  8992. return arrayIncludes(validate(this), searchElement, arguments.length > 1 ? arguments[1] : undefined);
  8993. },
  8994. join: function join(separator) {
  8995. return arrayJoin.apply(validate(this), arguments);
  8996. },
  8997. lastIndexOf: function lastIndexOf(searchElement) {
  8998. return arrayLastIndexOf.apply(validate(this), arguments);
  8999. },
  9000. map: function map(mapfn) {
  9001. return $map(validate(this), mapfn, arguments.length > 1 ? arguments[1] : undefined);
  9002. },
  9003. reduce: function reduce(callbackfn) {
  9004. return arrayReduce.apply(validate(this), arguments);
  9005. },
  9006. reduceRight: function reduceRight(callbackfn) {
  9007. return arrayReduceRight.apply(validate(this), arguments);
  9008. },
  9009. reverse: function reverse() {
  9010. var that = this;
  9011. var length = validate(that).length;
  9012. var middle = Math.floor(length / 2);
  9013. var index = 0;
  9014. var value;
  9015. while (index < middle) {
  9016. value = that[index];
  9017. that[index++] = that[--length];
  9018. that[length] = value;
  9019. }
  9020. return that;
  9021. },
  9022. some: function some(callbackfn) {
  9023. return arraySome(validate(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  9024. },
  9025. sort: function sort(comparefn) {
  9026. return arraySort.call(validate(this), comparefn);
  9027. },
  9028. subarray: function subarray(begin, end) {
  9029. var O = validate(this);
  9030. var length = O.length;
  9031. var $begin = toAbsoluteIndex(begin, length);
  9032. return new (speciesConstructor(O, O[DEF_CONSTRUCTOR]))(O.buffer, O.byteOffset + $begin * O.BYTES_PER_ELEMENT, toLength((end === undefined ? length : toAbsoluteIndex(end, length)) - $begin));
  9033. }
  9034. };
  9035. var $slice = function slice(start, end) {
  9036. return speciesFromList(this, arraySlice.call(validate(this), start, end));
  9037. };
  9038. var $set = function set(arrayLike) {
  9039. validate(this);
  9040. var offset = toOffset(arguments[1], 1);
  9041. var length = this.length;
  9042. var src = toObject(arrayLike);
  9043. var len = toLength(src.length);
  9044. var index = 0;
  9045. if (len + offset > length) throw RangeError(WRONG_LENGTH);
  9046. while (index < len) {
  9047. this[offset + index] = src[index++];
  9048. }
  9049. };
  9050. var $iterators = {
  9051. entries: function entries() {
  9052. return arrayEntries.call(validate(this));
  9053. },
  9054. keys: function keys() {
  9055. return arrayKeys.call(validate(this));
  9056. },
  9057. values: function values() {
  9058. return arrayValues.call(validate(this));
  9059. }
  9060. };
  9061. var isTAIndex = function isTAIndex(target, key) {
  9062. return isObject(target) && target[TYPED_ARRAY] && (typeof key === 'undefined' ? 'undefined' : _typeof(key)) != 'symbol' && key in target && String(+key) == String(key);
  9063. };
  9064. var $getDesc = function getOwnPropertyDescriptor(target, key) {
  9065. return isTAIndex(target, key = toPrimitive(key, true)) ? propertyDesc(2, target[key]) : gOPD(target, key);
  9066. };
  9067. var $setDesc = function defineProperty(target, key, desc) {
  9068. if (isTAIndex(target, key = toPrimitive(key, true)) && isObject(desc) && has(desc, 'value') && !has(desc, 'get') && !has(desc, 'set') && !desc.configurable && (!has(desc, 'writable') || desc.writable) && (!has(desc, 'enumerable') || desc.enumerable)) {
  9069. target[key] = desc.value;
  9070. return target;
  9071. }
  9072. return dP(target, key, desc);
  9073. };
  9074. if (!ALL_CONSTRUCTORS) {
  9075. $GOPD.f = $getDesc;
  9076. $DP.f = $setDesc;
  9077. }
  9078. $export($export.S + $export.F * !ALL_CONSTRUCTORS, 'Object', {
  9079. getOwnPropertyDescriptor: $getDesc,
  9080. defineProperty: $setDesc
  9081. });
  9082. if (fails(function () {
  9083. arrayToString.call({});
  9084. })) {
  9085. arrayToString = arrayToLocaleString = function toString() {
  9086. return arrayJoin.call(this);
  9087. };
  9088. }
  9089. var $TypedArrayPrototype$ = redefineAll({}, proto);
  9090. redefineAll($TypedArrayPrototype$, $iterators);
  9091. hide($TypedArrayPrototype$, ITERATOR, $iterators.values);
  9092. redefineAll($TypedArrayPrototype$, {
  9093. slice: $slice,
  9094. set: $set,
  9095. constructor: function constructor() {},
  9096. toString: arrayToString,
  9097. toLocaleString: $toLocaleString
  9098. });
  9099. addGetter($TypedArrayPrototype$, 'buffer', 'b');
  9100. addGetter($TypedArrayPrototype$, 'byteOffset', 'o');
  9101. addGetter($TypedArrayPrototype$, 'byteLength', 'l');
  9102. addGetter($TypedArrayPrototype$, 'length', 'e');
  9103. dP($TypedArrayPrototype$, TAG, {
  9104. get: function get() {
  9105. return this[TYPED_ARRAY];
  9106. }
  9107. });
  9108. module.exports = function (KEY, BYTES, wrapper, CLAMPED) {
  9109. CLAMPED = !!CLAMPED;
  9110. var NAME = KEY + (CLAMPED ? 'Clamped' : '') + 'Array';
  9111. var GETTER = 'get' + KEY;
  9112. var SETTER = 'set' + KEY;
  9113. var TypedArray = global[NAME];
  9114. var Base = TypedArray || {};
  9115. var TAC = TypedArray && getPrototypeOf(TypedArray);
  9116. var FORCED = !TypedArray || !$typed.ABV;
  9117. var O = {};
  9118. var TypedArrayPrototype = TypedArray && TypedArray[PROTOTYPE];
  9119. var getter = function getter(that, index) {
  9120. var data = that._d;
  9121. return data.v[GETTER](index * BYTES + data.o, LITTLE_ENDIAN);
  9122. };
  9123. var setter = function setter(that, index, value) {
  9124. var data = that._d;
  9125. if (CLAMPED) value = (value = Math.round(value)) < 0 ? 0 : value > 0xff ? 0xff : value & 0xff;
  9126. data.v[SETTER](index * BYTES + data.o, value, LITTLE_ENDIAN);
  9127. };
  9128. var addElement = function addElement(that, index) {
  9129. dP(that, index, {
  9130. get: function get() {
  9131. return getter(this, index);
  9132. },
  9133. set: function set(value) {
  9134. return setter(this, index, value);
  9135. },
  9136. enumerable: true
  9137. });
  9138. };
  9139. if (FORCED) {
  9140. TypedArray = wrapper(function (that, data, $offset, $length) {
  9141. anInstance(that, TypedArray, NAME, '_d');
  9142. var index = 0;
  9143. var offset = 0;
  9144. var buffer, byteLength, length, klass;
  9145. if (!isObject(data)) {
  9146. length = toIndex(data);
  9147. byteLength = length * BYTES;
  9148. buffer = new $ArrayBuffer(byteLength);
  9149. } else if (data instanceof $ArrayBuffer || (klass = classof(data)) == ARRAY_BUFFER || klass == SHARED_BUFFER) {
  9150. buffer = data;
  9151. offset = toOffset($offset, BYTES);
  9152. var $len = data.byteLength;
  9153. if ($length === undefined) {
  9154. if ($len % BYTES) throw RangeError(WRONG_LENGTH);
  9155. byteLength = $len - offset;
  9156. if (byteLength < 0) throw RangeError(WRONG_LENGTH);
  9157. } else {
  9158. byteLength = toLength($length) * BYTES;
  9159. if (byteLength + offset > $len) throw RangeError(WRONG_LENGTH);
  9160. }
  9161. length = byteLength / BYTES;
  9162. } else if (TYPED_ARRAY in data) {
  9163. return fromList(TypedArray, data);
  9164. } else {
  9165. return $from.call(TypedArray, data);
  9166. }
  9167. hide(that, '_d', {
  9168. b: buffer,
  9169. o: offset,
  9170. l: byteLength,
  9171. e: length,
  9172. v: new $DataView(buffer)
  9173. });
  9174. while (index < length) {
  9175. addElement(that, index++);
  9176. }
  9177. });
  9178. TypedArrayPrototype = TypedArray[PROTOTYPE] = create($TypedArrayPrototype$);
  9179. hide(TypedArrayPrototype, 'constructor', TypedArray);
  9180. } else if (!fails(function () {
  9181. TypedArray(1);
  9182. }) || !fails(function () {
  9183. new TypedArray(-1);
  9184. }) || !$iterDetect(function (iter) {
  9185. new TypedArray();
  9186. new TypedArray(null);
  9187. new TypedArray(1.5);
  9188. new TypedArray(iter);
  9189. }, true)) {
  9190. TypedArray = wrapper(function (that, data, $offset, $length) {
  9191. anInstance(that, TypedArray, NAME);
  9192. var klass;
  9193. if (!isObject(data)) return new Base(toIndex(data));
  9194. if (data instanceof $ArrayBuffer || (klass = classof(data)) == ARRAY_BUFFER || klass == SHARED_BUFFER) {
  9195. return $length !== undefined ? new Base(data, toOffset($offset, BYTES), $length) : $offset !== undefined ? new Base(data, toOffset($offset, BYTES)) : new Base(data);
  9196. }
  9197. if (TYPED_ARRAY in data) return fromList(TypedArray, data);
  9198. return $from.call(TypedArray, data);
  9199. });
  9200. arrayForEach(TAC !== Function.prototype ? gOPN(Base).concat(gOPN(TAC)) : gOPN(Base), function (key) {
  9201. if (!(key in TypedArray)) hide(TypedArray, key, Base[key]);
  9202. });
  9203. TypedArray[PROTOTYPE] = TypedArrayPrototype;
  9204. if (!LIBRARY) TypedArrayPrototype.constructor = TypedArray;
  9205. }
  9206. var $nativeIterator = TypedArrayPrototype[ITERATOR];
  9207. var CORRECT_ITER_NAME = !!$nativeIterator && ($nativeIterator.name == 'values' || $nativeIterator.name == undefined);
  9208. var $iterator = $iterators.values;
  9209. hide(TypedArray, TYPED_CONSTRUCTOR, true);
  9210. hide(TypedArrayPrototype, TYPED_ARRAY, NAME);
  9211. hide(TypedArrayPrototype, VIEW, true);
  9212. hide(TypedArrayPrototype, DEF_CONSTRUCTOR, TypedArray);
  9213. if (CLAMPED ? new TypedArray(1)[TAG] != NAME : !(TAG in TypedArrayPrototype)) {
  9214. dP(TypedArrayPrototype, TAG, {
  9215. get: function get() {
  9216. return NAME;
  9217. }
  9218. });
  9219. }
  9220. O[NAME] = TypedArray;
  9221. $export($export.G + $export.W + $export.F * (TypedArray != Base), O);
  9222. $export($export.S, NAME, { BYTES_PER_ELEMENT: BYTES });
  9223. $export($export.S + $export.F * fails(function () {
  9224. Base.of.call(TypedArray, 1);
  9225. }), NAME, {
  9226. from: $from,
  9227. of: $of
  9228. });
  9229. if (!(BYTES_PER_ELEMENT in TypedArrayPrototype)) hide(TypedArrayPrototype, BYTES_PER_ELEMENT, BYTES);
  9230. $export($export.P, NAME, proto);
  9231. setSpecies(NAME);
  9232. $export($export.P + $export.F * FORCED_SET, NAME, { set: $set });
  9233. $export($export.P + $export.F * !CORRECT_ITER_NAME, NAME, $iterators);
  9234. if (!LIBRARY && TypedArrayPrototype.toString != arrayToString) TypedArrayPrototype.toString = arrayToString;
  9235. $export($export.P + $export.F * fails(function () {
  9236. new TypedArray(1).slice();
  9237. }), NAME, { slice: $slice });
  9238. $export($export.P + $export.F * (fails(function () {
  9239. return [1, 2].toLocaleString() != new TypedArray([1, 2]).toLocaleString();
  9240. }) || !fails(function () {
  9241. TypedArrayPrototype.toLocaleString.call([1, 2]);
  9242. })), NAME, { toLocaleString: $toLocaleString });
  9243. Iterators[NAME] = CORRECT_ITER_NAME ? $nativeIterator : $iterator;
  9244. if (!LIBRARY && !CORRECT_ITER_NAME) hide(TypedArrayPrototype, ITERATOR, $iterator);
  9245. };
  9246. } else module.exports = function () {};
  9247. /***/ }),
  9248. /* 80 */
  9249. /***/ (function(module, exports, __w_pdfjs_require__) {
  9250. "use strict";
  9251. var global = __w_pdfjs_require__(1);
  9252. var DESCRIPTORS = __w_pdfjs_require__(9);
  9253. var LIBRARY = __w_pdfjs_require__(26);
  9254. var $typed = __w_pdfjs_require__(46);
  9255. var hide = __w_pdfjs_require__(6);
  9256. var redefineAll = __w_pdfjs_require__(22);
  9257. var fails = __w_pdfjs_require__(10);
  9258. var anInstance = __w_pdfjs_require__(23);
  9259. var toInteger = __w_pdfjs_require__(17);
  9260. var toLength = __w_pdfjs_require__(12);
  9261. var toIndex = __w_pdfjs_require__(47);
  9262. var gOPN = __w_pdfjs_require__(48).f;
  9263. var dP = __w_pdfjs_require__(14).f;
  9264. var arrayFill = __w_pdfjs_require__(52);
  9265. var setToStringTag = __w_pdfjs_require__(25);
  9266. var ARRAY_BUFFER = 'ArrayBuffer';
  9267. var DATA_VIEW = 'DataView';
  9268. var PROTOTYPE = 'prototype';
  9269. var WRONG_LENGTH = 'Wrong length!';
  9270. var WRONG_INDEX = 'Wrong index!';
  9271. var $ArrayBuffer = global[ARRAY_BUFFER];
  9272. var $DataView = global[DATA_VIEW];
  9273. var Math = global.Math;
  9274. var RangeError = global.RangeError;
  9275. var Infinity = global.Infinity;
  9276. var BaseBuffer = $ArrayBuffer;
  9277. var abs = Math.abs;
  9278. var pow = Math.pow;
  9279. var floor = Math.floor;
  9280. var log = Math.log;
  9281. var LN2 = Math.LN2;
  9282. var BUFFER = 'buffer';
  9283. var BYTE_LENGTH = 'byteLength';
  9284. var BYTE_OFFSET = 'byteOffset';
  9285. var $BUFFER = DESCRIPTORS ? '_b' : BUFFER;
  9286. var $LENGTH = DESCRIPTORS ? '_l' : BYTE_LENGTH;
  9287. var $OFFSET = DESCRIPTORS ? '_o' : BYTE_OFFSET;
  9288. function packIEEE754(value, mLen, nBytes) {
  9289. var buffer = Array(nBytes);
  9290. var eLen = nBytes * 8 - mLen - 1;
  9291. var eMax = (1 << eLen) - 1;
  9292. var eBias = eMax >> 1;
  9293. var rt = mLen === 23 ? pow(2, -24) - pow(2, -77) : 0;
  9294. var i = 0;
  9295. var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
  9296. var e, m, c;
  9297. value = abs(value);
  9298. if (value != value || value === Infinity) {
  9299. m = value != value ? 1 : 0;
  9300. e = eMax;
  9301. } else {
  9302. e = floor(log(value) / LN2);
  9303. if (value * (c = pow(2, -e)) < 1) {
  9304. e--;
  9305. c *= 2;
  9306. }
  9307. if (e + eBias >= 1) {
  9308. value += rt / c;
  9309. } else {
  9310. value += rt * pow(2, 1 - eBias);
  9311. }
  9312. if (value * c >= 2) {
  9313. e++;
  9314. c /= 2;
  9315. }
  9316. if (e + eBias >= eMax) {
  9317. m = 0;
  9318. e = eMax;
  9319. } else if (e + eBias >= 1) {
  9320. m = (value * c - 1) * pow(2, mLen);
  9321. e = e + eBias;
  9322. } else {
  9323. m = value * pow(2, eBias - 1) * pow(2, mLen);
  9324. e = 0;
  9325. }
  9326. }
  9327. for (; mLen >= 8; buffer[i++] = m & 255, m /= 256, mLen -= 8) {}
  9328. e = e << mLen | m;
  9329. eLen += mLen;
  9330. for (; eLen > 0; buffer[i++] = e & 255, e /= 256, eLen -= 8) {}
  9331. buffer[--i] |= s * 128;
  9332. return buffer;
  9333. }
  9334. function unpackIEEE754(buffer, mLen, nBytes) {
  9335. var eLen = nBytes * 8 - mLen - 1;
  9336. var eMax = (1 << eLen) - 1;
  9337. var eBias = eMax >> 1;
  9338. var nBits = eLen - 7;
  9339. var i = nBytes - 1;
  9340. var s = buffer[i--];
  9341. var e = s & 127;
  9342. var m;
  9343. s >>= 7;
  9344. for (; nBits > 0; e = e * 256 + buffer[i], i--, nBits -= 8) {}
  9345. m = e & (1 << -nBits) - 1;
  9346. e >>= -nBits;
  9347. nBits += mLen;
  9348. for (; nBits > 0; m = m * 256 + buffer[i], i--, nBits -= 8) {}
  9349. if (e === 0) {
  9350. e = 1 - eBias;
  9351. } else if (e === eMax) {
  9352. return m ? NaN : s ? -Infinity : Infinity;
  9353. } else {
  9354. m = m + pow(2, mLen);
  9355. e = e - eBias;
  9356. }
  9357. return (s ? -1 : 1) * m * pow(2, e - mLen);
  9358. }
  9359. function unpackI32(bytes) {
  9360. return bytes[3] << 24 | bytes[2] << 16 | bytes[1] << 8 | bytes[0];
  9361. }
  9362. function packI8(it) {
  9363. return [it & 0xff];
  9364. }
  9365. function packI16(it) {
  9366. return [it & 0xff, it >> 8 & 0xff];
  9367. }
  9368. function packI32(it) {
  9369. return [it & 0xff, it >> 8 & 0xff, it >> 16 & 0xff, it >> 24 & 0xff];
  9370. }
  9371. function packF64(it) {
  9372. return packIEEE754(it, 52, 8);
  9373. }
  9374. function packF32(it) {
  9375. return packIEEE754(it, 23, 4);
  9376. }
  9377. function addGetter(C, key, internal) {
  9378. dP(C[PROTOTYPE], key, {
  9379. get: function get() {
  9380. return this[internal];
  9381. }
  9382. });
  9383. }
  9384. function get(view, bytes, index, isLittleEndian) {
  9385. var numIndex = +index;
  9386. var intIndex = toIndex(numIndex);
  9387. if (intIndex + bytes > view[$LENGTH]) throw RangeError(WRONG_INDEX);
  9388. var store = view[$BUFFER]._b;
  9389. var start = intIndex + view[$OFFSET];
  9390. var pack = store.slice(start, start + bytes);
  9391. return isLittleEndian ? pack : pack.reverse();
  9392. }
  9393. function set(view, bytes, index, conversion, value, isLittleEndian) {
  9394. var numIndex = +index;
  9395. var intIndex = toIndex(numIndex);
  9396. if (intIndex + bytes > view[$LENGTH]) throw RangeError(WRONG_INDEX);
  9397. var store = view[$BUFFER]._b;
  9398. var start = intIndex + view[$OFFSET];
  9399. var pack = conversion(+value);
  9400. for (var i = 0; i < bytes; i++) {
  9401. store[start + i] = pack[isLittleEndian ? i : bytes - i - 1];
  9402. }
  9403. }
  9404. if (!$typed.ABV) {
  9405. $ArrayBuffer = function ArrayBuffer(length) {
  9406. anInstance(this, $ArrayBuffer, ARRAY_BUFFER);
  9407. var byteLength = toIndex(length);
  9408. this._b = arrayFill.call(Array(byteLength), 0);
  9409. this[$LENGTH] = byteLength;
  9410. };
  9411. $DataView = function DataView(buffer, byteOffset, byteLength) {
  9412. anInstance(this, $DataView, DATA_VIEW);
  9413. anInstance(buffer, $ArrayBuffer, DATA_VIEW);
  9414. var bufferLength = buffer[$LENGTH];
  9415. var offset = toInteger(byteOffset);
  9416. if (offset < 0 || offset > bufferLength) throw RangeError('Wrong offset!');
  9417. byteLength = byteLength === undefined ? bufferLength - offset : toLength(byteLength);
  9418. if (offset + byteLength > bufferLength) throw RangeError(WRONG_LENGTH);
  9419. this[$BUFFER] = buffer;
  9420. this[$OFFSET] = offset;
  9421. this[$LENGTH] = byteLength;
  9422. };
  9423. if (DESCRIPTORS) {
  9424. addGetter($ArrayBuffer, BYTE_LENGTH, '_l');
  9425. addGetter($DataView, BUFFER, '_b');
  9426. addGetter($DataView, BYTE_LENGTH, '_l');
  9427. addGetter($DataView, BYTE_OFFSET, '_o');
  9428. }
  9429. redefineAll($DataView[PROTOTYPE], {
  9430. getInt8: function getInt8(byteOffset) {
  9431. return get(this, 1, byteOffset)[0] << 24 >> 24;
  9432. },
  9433. getUint8: function getUint8(byteOffset) {
  9434. return get(this, 1, byteOffset)[0];
  9435. },
  9436. getInt16: function getInt16(byteOffset) {
  9437. var bytes = get(this, 2, byteOffset, arguments[1]);
  9438. return (bytes[1] << 8 | bytes[0]) << 16 >> 16;
  9439. },
  9440. getUint16: function getUint16(byteOffset) {
  9441. var bytes = get(this, 2, byteOffset, arguments[1]);
  9442. return bytes[1] << 8 | bytes[0];
  9443. },
  9444. getInt32: function getInt32(byteOffset) {
  9445. return unpackI32(get(this, 4, byteOffset, arguments[1]));
  9446. },
  9447. getUint32: function getUint32(byteOffset) {
  9448. return unpackI32(get(this, 4, byteOffset, arguments[1])) >>> 0;
  9449. },
  9450. getFloat32: function getFloat32(byteOffset) {
  9451. return unpackIEEE754(get(this, 4, byteOffset, arguments[1]), 23, 4);
  9452. },
  9453. getFloat64: function getFloat64(byteOffset) {
  9454. return unpackIEEE754(get(this, 8, byteOffset, arguments[1]), 52, 8);
  9455. },
  9456. setInt8: function setInt8(byteOffset, value) {
  9457. set(this, 1, byteOffset, packI8, value);
  9458. },
  9459. setUint8: function setUint8(byteOffset, value) {
  9460. set(this, 1, byteOffset, packI8, value);
  9461. },
  9462. setInt16: function setInt16(byteOffset, value) {
  9463. set(this, 2, byteOffset, packI16, value, arguments[2]);
  9464. },
  9465. setUint16: function setUint16(byteOffset, value) {
  9466. set(this, 2, byteOffset, packI16, value, arguments[2]);
  9467. },
  9468. setInt32: function setInt32(byteOffset, value) {
  9469. set(this, 4, byteOffset, packI32, value, arguments[2]);
  9470. },
  9471. setUint32: function setUint32(byteOffset, value) {
  9472. set(this, 4, byteOffset, packI32, value, arguments[2]);
  9473. },
  9474. setFloat32: function setFloat32(byteOffset, value) {
  9475. set(this, 4, byteOffset, packF32, value, arguments[2]);
  9476. },
  9477. setFloat64: function setFloat64(byteOffset, value) {
  9478. set(this, 8, byteOffset, packF64, value, arguments[2]);
  9479. }
  9480. });
  9481. } else {
  9482. if (!fails(function () {
  9483. $ArrayBuffer(1);
  9484. }) || !fails(function () {
  9485. new $ArrayBuffer(-1);
  9486. }) || fails(function () {
  9487. new $ArrayBuffer();
  9488. new $ArrayBuffer(1.5);
  9489. new $ArrayBuffer(NaN);
  9490. return $ArrayBuffer.name != ARRAY_BUFFER;
  9491. })) {
  9492. $ArrayBuffer = function ArrayBuffer(length) {
  9493. anInstance(this, $ArrayBuffer);
  9494. return new BaseBuffer(toIndex(length));
  9495. };
  9496. var ArrayBufferProto = $ArrayBuffer[PROTOTYPE] = BaseBuffer[PROTOTYPE];
  9497. for (var keys = gOPN(BaseBuffer), j = 0, key; keys.length > j;) {
  9498. if (!((key = keys[j++]) in $ArrayBuffer)) hide($ArrayBuffer, key, BaseBuffer[key]);
  9499. }
  9500. if (!LIBRARY) ArrayBufferProto.constructor = $ArrayBuffer;
  9501. }
  9502. var view = new $DataView(new $ArrayBuffer(2));
  9503. var $setInt8 = $DataView[PROTOTYPE].setInt8;
  9504. view.setInt8(0, 2147483648);
  9505. view.setInt8(1, 2147483649);
  9506. if (view.getInt8(0) || !view.getInt8(1)) redefineAll($DataView[PROTOTYPE], {
  9507. setInt8: function setInt8(byteOffset, value) {
  9508. $setInt8.call(this, byteOffset, value << 24 >> 24);
  9509. },
  9510. setUint8: function setUint8(byteOffset, value) {
  9511. $setInt8.call(this, byteOffset, value << 24 >> 24);
  9512. }
  9513. }, true);
  9514. }
  9515. setToStringTag($ArrayBuffer, ARRAY_BUFFER);
  9516. setToStringTag($DataView, DATA_VIEW);
  9517. hide($DataView[PROTOTYPE], $typed.VIEW, true);
  9518. exports[ARRAY_BUFFER] = $ArrayBuffer;
  9519. exports[DATA_VIEW] = $DataView;
  9520. /***/ }),
  9521. /* 81 */
  9522. /***/ (function(module, exports, __w_pdfjs_require__) {
  9523. "use strict";
  9524. var dP = __w_pdfjs_require__(14);
  9525. var anObject = __w_pdfjs_require__(7);
  9526. var getKeys = __w_pdfjs_require__(38);
  9527. module.exports = __w_pdfjs_require__(9) ? Object.defineProperties : function defineProperties(O, Properties) {
  9528. anObject(O);
  9529. var keys = getKeys(Properties);
  9530. var length = keys.length;
  9531. var i = 0;
  9532. var P;
  9533. while (length > i) {
  9534. dP.f(O, P = keys[i++], Properties[P]);
  9535. }return O;
  9536. };
  9537. /***/ }),
  9538. /* 82 */
  9539. /***/ (function(module, exports, __w_pdfjs_require__) {
  9540. "use strict";
  9541. var speciesConstructor = __w_pdfjs_require__(83);
  9542. module.exports = function (original, length) {
  9543. return new (speciesConstructor(original))(length);
  9544. };
  9545. /***/ }),
  9546. /* 83 */
  9547. /***/ (function(module, exports, __w_pdfjs_require__) {
  9548. "use strict";
  9549. var isObject = __w_pdfjs_require__(2);
  9550. var isArray = __w_pdfjs_require__(84);
  9551. var SPECIES = __w_pdfjs_require__(3)('species');
  9552. module.exports = function (original) {
  9553. var C;
  9554. if (isArray(original)) {
  9555. C = original.constructor;
  9556. if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
  9557. if (isObject(C)) {
  9558. C = C[SPECIES];
  9559. if (C === null) C = undefined;
  9560. }
  9561. }
  9562. return C === undefined ? Array : C;
  9563. };
  9564. /***/ }),
  9565. /* 84 */
  9566. /***/ (function(module, exports, __w_pdfjs_require__) {
  9567. "use strict";
  9568. var cof = __w_pdfjs_require__(24);
  9569. module.exports = Array.isArray || function isArray(arg) {
  9570. return cof(arg) == 'Array';
  9571. };
  9572. /***/ }),
  9573. /* 85 */
  9574. /***/ (function(module, exports, __w_pdfjs_require__) {
  9575. "use strict";
  9576. var UNSCOPABLES = __w_pdfjs_require__(3)('unscopables');
  9577. var ArrayProto = Array.prototype;
  9578. if (ArrayProto[UNSCOPABLES] == undefined) __w_pdfjs_require__(6)(ArrayProto, UNSCOPABLES, {});
  9579. module.exports = function (key) {
  9580. ArrayProto[UNSCOPABLES][key] = true;
  9581. };
  9582. /***/ }),
  9583. /* 86 */
  9584. /***/ (function(module, exports, __w_pdfjs_require__) {
  9585. "use strict";
  9586. module.exports = function (done, value) {
  9587. return {
  9588. value: value,
  9589. done: !!done
  9590. };
  9591. };
  9592. /***/ }),
  9593. /* 87 */
  9594. /***/ (function(module, exports, __w_pdfjs_require__) {
  9595. "use strict";
  9596. var create = __w_pdfjs_require__(54);
  9597. var descriptor = __w_pdfjs_require__(27);
  9598. var setToStringTag = __w_pdfjs_require__(25);
  9599. var IteratorPrototype = {};
  9600. __w_pdfjs_require__(6)(IteratorPrototype, __w_pdfjs_require__(3)('iterator'), function () {
  9601. return this;
  9602. });
  9603. module.exports = function (Constructor, NAME, next) {
  9604. Constructor.prototype = create(IteratorPrototype, { next: descriptor(1, next) });
  9605. setToStringTag(Constructor, NAME + ' Iterator');
  9606. };
  9607. /***/ }),
  9608. /* 88 */
  9609. /***/ (function(module, exports, __w_pdfjs_require__) {
  9610. "use strict";
  9611. var toObject = __w_pdfjs_require__(18);
  9612. var toAbsoluteIndex = __w_pdfjs_require__(29);
  9613. var toLength = __w_pdfjs_require__(12);
  9614. module.exports = [].copyWithin || function copyWithin(target, start) {
  9615. var O = toObject(this);
  9616. var len = toLength(O.length);
  9617. var to = toAbsoluteIndex(target, len);
  9618. var from = toAbsoluteIndex(start, len);
  9619. var end = arguments.length > 2 ? arguments[2] : undefined;
  9620. var count = Math.min((end === undefined ? len : toAbsoluteIndex(end, len)) - from, len - to);
  9621. var inc = 1;
  9622. if (from < to && to < from + count) {
  9623. inc = -1;
  9624. from += count - 1;
  9625. to += count - 1;
  9626. }
  9627. while (count-- > 0) {
  9628. if (from in O) O[to] = O[from];else delete O[to];
  9629. to += inc;
  9630. from += inc;
  9631. }
  9632. return O;
  9633. };
  9634. /***/ }),
  9635. /* 89 */
  9636. /***/ (function(module, exports, __w_pdfjs_require__) {
  9637. "use strict";
  9638. __w_pdfjs_require__(90);
  9639. module.exports = __w_pdfjs_require__(5).Number.isNaN;
  9640. /***/ }),
  9641. /* 90 */
  9642. /***/ (function(module, exports, __w_pdfjs_require__) {
  9643. "use strict";
  9644. var $export = __w_pdfjs_require__(4);
  9645. $export($export.S, 'Number', {
  9646. isNaN: function isNaN(number) {
  9647. return number != number;
  9648. }
  9649. });
  9650. /***/ }),
  9651. /* 91 */
  9652. /***/ (function(module, exports, __w_pdfjs_require__) {
  9653. "use strict";
  9654. __w_pdfjs_require__(92);
  9655. module.exports = __w_pdfjs_require__(5).Number.isInteger;
  9656. /***/ }),
  9657. /* 92 */
  9658. /***/ (function(module, exports, __w_pdfjs_require__) {
  9659. "use strict";
  9660. var $export = __w_pdfjs_require__(4);
  9661. $export($export.S, 'Number', { isInteger: __w_pdfjs_require__(93) });
  9662. /***/ }),
  9663. /* 93 */
  9664. /***/ (function(module, exports, __w_pdfjs_require__) {
  9665. "use strict";
  9666. var isObject = __w_pdfjs_require__(2);
  9667. var floor = Math.floor;
  9668. module.exports = function isInteger(it) {
  9669. return !isObject(it) && isFinite(it) && floor(it) === it;
  9670. };
  9671. /***/ }),
  9672. /* 94 */
  9673. /***/ (function(module, exports, __w_pdfjs_require__) {
  9674. "use strict";
  9675. __w_pdfjs_require__(63);
  9676. __w_pdfjs_require__(95);
  9677. __w_pdfjs_require__(64);
  9678. __w_pdfjs_require__(97);
  9679. __w_pdfjs_require__(101);
  9680. __w_pdfjs_require__(102);
  9681. module.exports = __w_pdfjs_require__(5).Promise;
  9682. /***/ }),
  9683. /* 95 */
  9684. /***/ (function(module, exports, __w_pdfjs_require__) {
  9685. "use strict";
  9686. var $at = __w_pdfjs_require__(96)(true);
  9687. __w_pdfjs_require__(59)(String, 'String', function (iterated) {
  9688. this._t = String(iterated);
  9689. this._i = 0;
  9690. }, function () {
  9691. var O = this._t;
  9692. var index = this._i;
  9693. var point;
  9694. if (index >= O.length) return {
  9695. value: undefined,
  9696. done: true
  9697. };
  9698. point = $at(O, index);
  9699. this._i += point.length;
  9700. return {
  9701. value: point,
  9702. done: false
  9703. };
  9704. });
  9705. /***/ }),
  9706. /* 96 */
  9707. /***/ (function(module, exports, __w_pdfjs_require__) {
  9708. "use strict";
  9709. var toInteger = __w_pdfjs_require__(17);
  9710. var defined = __w_pdfjs_require__(35);
  9711. module.exports = function (TO_STRING) {
  9712. return function (that, pos) {
  9713. var s = String(defined(that));
  9714. var i = toInteger(pos);
  9715. var l = s.length;
  9716. var a, b;
  9717. if (i < 0 || i >= l) return TO_STRING ? '' : undefined;
  9718. a = s.charCodeAt(i);
  9719. return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff ? TO_STRING ? s.charAt(i) : a : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
  9720. };
  9721. };
  9722. /***/ }),
  9723. /* 97 */
  9724. /***/ (function(module, exports, __w_pdfjs_require__) {
  9725. "use strict";
  9726. var LIBRARY = __w_pdfjs_require__(26);
  9727. var global = __w_pdfjs_require__(1);
  9728. var ctx = __w_pdfjs_require__(11);
  9729. var classof = __w_pdfjs_require__(30);
  9730. var $export = __w_pdfjs_require__(4);
  9731. var isObject = __w_pdfjs_require__(2);
  9732. var aFunction = __w_pdfjs_require__(21);
  9733. var anInstance = __w_pdfjs_require__(23);
  9734. var forOf = __w_pdfjs_require__(31);
  9735. var speciesConstructor = __w_pdfjs_require__(40);
  9736. var task = __w_pdfjs_require__(65).set;
  9737. var microtask = __w_pdfjs_require__(100)();
  9738. var newPromiseCapabilityModule = __w_pdfjs_require__(42);
  9739. var perform = __w_pdfjs_require__(66);
  9740. var promiseResolve = __w_pdfjs_require__(67);
  9741. var PROMISE = 'Promise';
  9742. var TypeError = global.TypeError;
  9743. var process = global.process;
  9744. var $Promise = global[PROMISE];
  9745. var isNode = classof(process) == 'process';
  9746. var empty = function empty() {};
  9747. var Internal, newGenericPromiseCapability, OwnPromiseCapability, Wrapper;
  9748. var newPromiseCapability = newGenericPromiseCapability = newPromiseCapabilityModule.f;
  9749. var USE_NATIVE = !!function () {
  9750. try {
  9751. var promise = $Promise.resolve(1);
  9752. var FakePromise = (promise.constructor = {})[__w_pdfjs_require__(3)('species')] = function (exec) {
  9753. exec(empty, empty);
  9754. };
  9755. return (isNode || typeof PromiseRejectionEvent == 'function') && promise.then(empty) instanceof FakePromise;
  9756. } catch (e) {}
  9757. }();
  9758. var isThenable = function isThenable(it) {
  9759. var then;
  9760. return isObject(it) && typeof (then = it.then) == 'function' ? then : false;
  9761. };
  9762. var notify = function notify(promise, isReject) {
  9763. if (promise._n) return;
  9764. promise._n = true;
  9765. var chain = promise._c;
  9766. microtask(function () {
  9767. var value = promise._v;
  9768. var ok = promise._s == 1;
  9769. var i = 0;
  9770. var run = function run(reaction) {
  9771. var handler = ok ? reaction.ok : reaction.fail;
  9772. var resolve = reaction.resolve;
  9773. var reject = reaction.reject;
  9774. var domain = reaction.domain;
  9775. var result, then;
  9776. try {
  9777. if (handler) {
  9778. if (!ok) {
  9779. if (promise._h == 2) onHandleUnhandled(promise);
  9780. promise._h = 1;
  9781. }
  9782. if (handler === true) result = value;else {
  9783. if (domain) domain.enter();
  9784. result = handler(value);
  9785. if (domain) domain.exit();
  9786. }
  9787. if (result === reaction.promise) {
  9788. reject(TypeError('Promise-chain cycle'));
  9789. } else if (then = isThenable(result)) {
  9790. then.call(result, resolve, reject);
  9791. } else resolve(result);
  9792. } else reject(value);
  9793. } catch (e) {
  9794. reject(e);
  9795. }
  9796. };
  9797. while (chain.length > i) {
  9798. run(chain[i++]);
  9799. }promise._c = [];
  9800. promise._n = false;
  9801. if (isReject && !promise._h) onUnhandled(promise);
  9802. });
  9803. };
  9804. var onUnhandled = function onUnhandled(promise) {
  9805. task.call(global, function () {
  9806. var value = promise._v;
  9807. var unhandled = isUnhandled(promise);
  9808. var result, handler, console;
  9809. if (unhandled) {
  9810. result = perform(function () {
  9811. if (isNode) {
  9812. process.emit('unhandledRejection', value, promise);
  9813. } else if (handler = global.onunhandledrejection) {
  9814. handler({
  9815. promise: promise,
  9816. reason: value
  9817. });
  9818. } else if ((console = global.console) && console.error) {
  9819. console.error('Unhandled promise rejection', value);
  9820. }
  9821. });
  9822. promise._h = isNode || isUnhandled(promise) ? 2 : 1;
  9823. }
  9824. promise._a = undefined;
  9825. if (unhandled && result.e) throw result.v;
  9826. });
  9827. };
  9828. var isUnhandled = function isUnhandled(promise) {
  9829. if (promise._h == 1) return false;
  9830. var chain = promise._a || promise._c;
  9831. var i = 0;
  9832. var reaction;
  9833. while (chain.length > i) {
  9834. reaction = chain[i++];
  9835. if (reaction.fail || !isUnhandled(reaction.promise)) return false;
  9836. }
  9837. return true;
  9838. };
  9839. var onHandleUnhandled = function onHandleUnhandled(promise) {
  9840. task.call(global, function () {
  9841. var handler;
  9842. if (isNode) {
  9843. process.emit('rejectionHandled', promise);
  9844. } else if (handler = global.onrejectionhandled) {
  9845. handler({
  9846. promise: promise,
  9847. reason: promise._v
  9848. });
  9849. }
  9850. });
  9851. };
  9852. var $reject = function $reject(value) {
  9853. var promise = this;
  9854. if (promise._d) return;
  9855. promise._d = true;
  9856. promise = promise._w || promise;
  9857. promise._v = value;
  9858. promise._s = 2;
  9859. if (!promise._a) promise._a = promise._c.slice();
  9860. notify(promise, true);
  9861. };
  9862. var $resolve = function $resolve(value) {
  9863. var promise = this;
  9864. var then;
  9865. if (promise._d) return;
  9866. promise._d = true;
  9867. promise = promise._w || promise;
  9868. try {
  9869. if (promise === value) throw TypeError("Promise can't be resolved itself");
  9870. if (then = isThenable(value)) {
  9871. microtask(function () {
  9872. var wrapper = {
  9873. _w: promise,
  9874. _d: false
  9875. };
  9876. try {
  9877. then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1));
  9878. } catch (e) {
  9879. $reject.call(wrapper, e);
  9880. }
  9881. });
  9882. } else {
  9883. promise._v = value;
  9884. promise._s = 1;
  9885. notify(promise, false);
  9886. }
  9887. } catch (e) {
  9888. $reject.call({
  9889. _w: promise,
  9890. _d: false
  9891. }, e);
  9892. }
  9893. };
  9894. if (!USE_NATIVE) {
  9895. $Promise = function Promise(executor) {
  9896. anInstance(this, $Promise, PROMISE, '_h');
  9897. aFunction(executor);
  9898. Internal.call(this);
  9899. try {
  9900. executor(ctx($resolve, this, 1), ctx($reject, this, 1));
  9901. } catch (err) {
  9902. $reject.call(this, err);
  9903. }
  9904. };
  9905. Internal = function Promise(executor) {
  9906. this._c = [];
  9907. this._a = undefined;
  9908. this._s = 0;
  9909. this._d = false;
  9910. this._v = undefined;
  9911. this._h = 0;
  9912. this._n = false;
  9913. };
  9914. Internal.prototype = __w_pdfjs_require__(22)($Promise.prototype, {
  9915. then: function then(onFulfilled, onRejected) {
  9916. var reaction = newPromiseCapability(speciesConstructor(this, $Promise));
  9917. reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
  9918. reaction.fail = typeof onRejected == 'function' && onRejected;
  9919. reaction.domain = isNode ? process.domain : undefined;
  9920. this._c.push(reaction);
  9921. if (this._a) this._a.push(reaction);
  9922. if (this._s) notify(this, false);
  9923. return reaction.promise;
  9924. },
  9925. 'catch': function _catch(onRejected) {
  9926. return this.then(undefined, onRejected);
  9927. }
  9928. });
  9929. OwnPromiseCapability = function OwnPromiseCapability() {
  9930. var promise = new Internal();
  9931. this.promise = promise;
  9932. this.resolve = ctx($resolve, promise, 1);
  9933. this.reject = ctx($reject, promise, 1);
  9934. };
  9935. newPromiseCapabilityModule.f = newPromiseCapability = function newPromiseCapability(C) {
  9936. return C === $Promise || C === Wrapper ? new OwnPromiseCapability(C) : newGenericPromiseCapability(C);
  9937. };
  9938. }
  9939. $export($export.G + $export.W + $export.F * !USE_NATIVE, { Promise: $Promise });
  9940. __w_pdfjs_require__(25)($Promise, PROMISE);
  9941. __w_pdfjs_require__(60)(PROMISE);
  9942. Wrapper = __w_pdfjs_require__(5)[PROMISE];
  9943. $export($export.S + $export.F * !USE_NATIVE, PROMISE, {
  9944. reject: function reject(r) {
  9945. var capability = newPromiseCapability(this);
  9946. var $$reject = capability.reject;
  9947. $$reject(r);
  9948. return capability.promise;
  9949. }
  9950. });
  9951. $export($export.S + $export.F * (LIBRARY || !USE_NATIVE), PROMISE, {
  9952. resolve: function resolve(x) {
  9953. return promiseResolve(LIBRARY && this === Wrapper ? $Promise : this, x);
  9954. }
  9955. });
  9956. $export($export.S + $export.F * !(USE_NATIVE && __w_pdfjs_require__(41)(function (iter) {
  9957. $Promise.all(iter)['catch'](empty);
  9958. })), PROMISE, {
  9959. all: function all(iterable) {
  9960. var C = this;
  9961. var capability = newPromiseCapability(C);
  9962. var resolve = capability.resolve;
  9963. var reject = capability.reject;
  9964. var result = perform(function () {
  9965. var values = [];
  9966. var index = 0;
  9967. var remaining = 1;
  9968. forOf(iterable, false, function (promise) {
  9969. var $index = index++;
  9970. var alreadyCalled = false;
  9971. values.push(undefined);
  9972. remaining++;
  9973. C.resolve(promise).then(function (value) {
  9974. if (alreadyCalled) return;
  9975. alreadyCalled = true;
  9976. values[$index] = value;
  9977. --remaining || resolve(values);
  9978. }, reject);
  9979. });
  9980. --remaining || resolve(values);
  9981. });
  9982. if (result.e) reject(result.v);
  9983. return capability.promise;
  9984. },
  9985. race: function race(iterable) {
  9986. var C = this;
  9987. var capability = newPromiseCapability(C);
  9988. var reject = capability.reject;
  9989. var result = perform(function () {
  9990. forOf(iterable, false, function (promise) {
  9991. C.resolve(promise).then(capability.resolve, reject);
  9992. });
  9993. });
  9994. if (result.e) reject(result.v);
  9995. return capability.promise;
  9996. }
  9997. });
  9998. /***/ }),
  9999. /* 98 */
  10000. /***/ (function(module, exports, __w_pdfjs_require__) {
  10001. "use strict";
  10002. var anObject = __w_pdfjs_require__(7);
  10003. module.exports = function (iterator, fn, value, entries) {
  10004. try {
  10005. return entries ? fn(anObject(value)[0], value[1]) : fn(value);
  10006. } catch (e) {
  10007. var ret = iterator['return'];
  10008. if (ret !== undefined) anObject(ret.call(iterator));
  10009. throw e;
  10010. }
  10011. };
  10012. /***/ }),
  10013. /* 99 */
  10014. /***/ (function(module, exports, __w_pdfjs_require__) {
  10015. "use strict";
  10016. module.exports = function (fn, args, that) {
  10017. var un = that === undefined;
  10018. switch (args.length) {
  10019. case 0:
  10020. return un ? fn() : fn.call(that);
  10021. case 1:
  10022. return un ? fn(args[0]) : fn.call(that, args[0]);
  10023. case 2:
  10024. return un ? fn(args[0], args[1]) : fn.call(that, args[0], args[1]);
  10025. case 3:
  10026. return un ? fn(args[0], args[1], args[2]) : fn.call(that, args[0], args[1], args[2]);
  10027. case 4:
  10028. return un ? fn(args[0], args[1], args[2], args[3]) : fn.call(that, args[0], args[1], args[2], args[3]);
  10029. }
  10030. return fn.apply(that, args);
  10031. };
  10032. /***/ }),
  10033. /* 100 */
  10034. /***/ (function(module, exports, __w_pdfjs_require__) {
  10035. "use strict";
  10036. var global = __w_pdfjs_require__(1);
  10037. var macrotask = __w_pdfjs_require__(65).set;
  10038. var Observer = global.MutationObserver || global.WebKitMutationObserver;
  10039. var process = global.process;
  10040. var Promise = global.Promise;
  10041. var isNode = __w_pdfjs_require__(24)(process) == 'process';
  10042. module.exports = function () {
  10043. var head, last, notify;
  10044. var flush = function flush() {
  10045. var parent, fn;
  10046. if (isNode && (parent = process.domain)) parent.exit();
  10047. while (head) {
  10048. fn = head.fn;
  10049. head = head.next;
  10050. try {
  10051. fn();
  10052. } catch (e) {
  10053. if (head) notify();else last = undefined;
  10054. throw e;
  10055. }
  10056. }
  10057. last = undefined;
  10058. if (parent) parent.enter();
  10059. };
  10060. if (isNode) {
  10061. notify = function notify() {
  10062. process.nextTick(flush);
  10063. };
  10064. } else if (Observer) {
  10065. var toggle = true;
  10066. var node = document.createTextNode('');
  10067. new Observer(flush).observe(node, { characterData: true });
  10068. notify = function notify() {
  10069. node.data = toggle = !toggle;
  10070. };
  10071. } else if (Promise && Promise.resolve) {
  10072. var promise = Promise.resolve();
  10073. notify = function notify() {
  10074. promise.then(flush);
  10075. };
  10076. } else {
  10077. notify = function notify() {
  10078. macrotask.call(global, flush);
  10079. };
  10080. }
  10081. return function (fn) {
  10082. var task = {
  10083. fn: fn,
  10084. next: undefined
  10085. };
  10086. if (last) last.next = task;
  10087. if (!head) {
  10088. head = task;
  10089. notify();
  10090. }
  10091. last = task;
  10092. };
  10093. };
  10094. /***/ }),
  10095. /* 101 */
  10096. /***/ (function(module, exports, __w_pdfjs_require__) {
  10097. "use strict";
  10098. var $export = __w_pdfjs_require__(4);
  10099. var core = __w_pdfjs_require__(5);
  10100. var global = __w_pdfjs_require__(1);
  10101. var speciesConstructor = __w_pdfjs_require__(40);
  10102. var promiseResolve = __w_pdfjs_require__(67);
  10103. $export($export.P + $export.R, 'Promise', {
  10104. 'finally': function _finally(onFinally) {
  10105. var C = speciesConstructor(this, core.Promise || global.Promise);
  10106. var isFunction = typeof onFinally == 'function';
  10107. return this.then(isFunction ? function (x) {
  10108. return promiseResolve(C, onFinally()).then(function () {
  10109. return x;
  10110. });
  10111. } : onFinally, isFunction ? function (e) {
  10112. return promiseResolve(C, onFinally()).then(function () {
  10113. throw e;
  10114. });
  10115. } : onFinally);
  10116. }
  10117. });
  10118. /***/ }),
  10119. /* 102 */
  10120. /***/ (function(module, exports, __w_pdfjs_require__) {
  10121. "use strict";
  10122. var $export = __w_pdfjs_require__(4);
  10123. var newPromiseCapability = __w_pdfjs_require__(42);
  10124. var perform = __w_pdfjs_require__(66);
  10125. $export($export.S, 'Promise', {
  10126. 'try': function _try(callbackfn) {
  10127. var promiseCapability = newPromiseCapability.f(this);
  10128. var result = perform(callbackfn);
  10129. (result.e ? promiseCapability.reject : promiseCapability.resolve)(result.v);
  10130. return promiseCapability.promise;
  10131. }
  10132. });
  10133. /***/ }),
  10134. /* 103 */
  10135. /***/ (function(module, exports, __w_pdfjs_require__) {
  10136. "use strict";
  10137. __w_pdfjs_require__(63);
  10138. __w_pdfjs_require__(64);
  10139. __w_pdfjs_require__(104);
  10140. __w_pdfjs_require__(111);
  10141. __w_pdfjs_require__(113);
  10142. module.exports = __w_pdfjs_require__(5).WeakMap;
  10143. /***/ }),
  10144. /* 104 */
  10145. /***/ (function(module, exports, __w_pdfjs_require__) {
  10146. "use strict";
  10147. var each = __w_pdfjs_require__(39)(0);
  10148. var redefine = __w_pdfjs_require__(15);
  10149. var meta = __w_pdfjs_require__(43);
  10150. var assign = __w_pdfjs_require__(105);
  10151. var weak = __w_pdfjs_require__(107);
  10152. var isObject = __w_pdfjs_require__(2);
  10153. var fails = __w_pdfjs_require__(10);
  10154. var validate = __w_pdfjs_require__(68);
  10155. var WEAK_MAP = 'WeakMap';
  10156. var getWeak = meta.getWeak;
  10157. var isExtensible = Object.isExtensible;
  10158. var uncaughtFrozenStore = weak.ufstore;
  10159. var tmp = {};
  10160. var InternalMap;
  10161. var wrapper = function wrapper(get) {
  10162. return function WeakMap() {
  10163. return get(this, arguments.length > 0 ? arguments[0] : undefined);
  10164. };
  10165. };
  10166. var methods = {
  10167. get: function get(key) {
  10168. if (isObject(key)) {
  10169. var data = getWeak(key);
  10170. if (data === true) return uncaughtFrozenStore(validate(this, WEAK_MAP)).get(key);
  10171. return data ? data[this._i] : undefined;
  10172. }
  10173. },
  10174. set: function set(key, value) {
  10175. return weak.def(validate(this, WEAK_MAP), key, value);
  10176. }
  10177. };
  10178. var $WeakMap = module.exports = __w_pdfjs_require__(108)(WEAK_MAP, wrapper, methods, weak, true, true);
  10179. if (fails(function () {
  10180. return new $WeakMap().set((Object.freeze || Object)(tmp), 7).get(tmp) != 7;
  10181. })) {
  10182. InternalMap = weak.getConstructor(wrapper, WEAK_MAP);
  10183. assign(InternalMap.prototype, methods);
  10184. meta.NEED = true;
  10185. each(['delete', 'has', 'get', 'set'], function (key) {
  10186. var proto = $WeakMap.prototype;
  10187. var method = proto[key];
  10188. redefine(proto, key, function (a, b) {
  10189. if (isObject(a) && !isExtensible(a)) {
  10190. if (!this._f) this._f = new InternalMap();
  10191. var result = this._f[key](a, b);
  10192. return key == 'set' ? this : result;
  10193. }
  10194. return method.call(this, a, b);
  10195. });
  10196. });
  10197. }
  10198. /***/ }),
  10199. /* 105 */
  10200. /***/ (function(module, exports, __w_pdfjs_require__) {
  10201. "use strict";
  10202. var getKeys = __w_pdfjs_require__(38);
  10203. var gOPS = __w_pdfjs_require__(106);
  10204. var pIE = __w_pdfjs_require__(62);
  10205. var toObject = __w_pdfjs_require__(18);
  10206. var IObject = __w_pdfjs_require__(34);
  10207. var $assign = Object.assign;
  10208. module.exports = !$assign || __w_pdfjs_require__(10)(function () {
  10209. var A = {};
  10210. var B = {};
  10211. var S = Symbol();
  10212. var K = 'abcdefghijklmnopqrst';
  10213. A[S] = 7;
  10214. K.split('').forEach(function (k) {
  10215. B[k] = k;
  10216. });
  10217. return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
  10218. }) ? function assign(target, source) {
  10219. var T = toObject(target);
  10220. var aLen = arguments.length;
  10221. var index = 1;
  10222. var getSymbols = gOPS.f;
  10223. var isEnum = pIE.f;
  10224. while (aLen > index) {
  10225. var S = IObject(arguments[index++]);
  10226. var keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S);
  10227. var length = keys.length;
  10228. var j = 0;
  10229. var key;
  10230. while (length > j) {
  10231. if (isEnum.call(S, key = keys[j++])) T[key] = S[key];
  10232. }
  10233. }
  10234. return T;
  10235. } : $assign;
  10236. /***/ }),
  10237. /* 106 */
  10238. /***/ (function(module, exports, __w_pdfjs_require__) {
  10239. "use strict";
  10240. exports.f = Object.getOwnPropertySymbols;
  10241. /***/ }),
  10242. /* 107 */
  10243. /***/ (function(module, exports, __w_pdfjs_require__) {
  10244. "use strict";
  10245. var redefineAll = __w_pdfjs_require__(22);
  10246. var getWeak = __w_pdfjs_require__(43).getWeak;
  10247. var anObject = __w_pdfjs_require__(7);
  10248. var isObject = __w_pdfjs_require__(2);
  10249. var anInstance = __w_pdfjs_require__(23);
  10250. var forOf = __w_pdfjs_require__(31);
  10251. var createArrayMethod = __w_pdfjs_require__(39);
  10252. var $has = __w_pdfjs_require__(8);
  10253. var validate = __w_pdfjs_require__(68);
  10254. var arrayFind = createArrayMethod(5);
  10255. var arrayFindIndex = createArrayMethod(6);
  10256. var id = 0;
  10257. var uncaughtFrozenStore = function uncaughtFrozenStore(that) {
  10258. return that._l || (that._l = new UncaughtFrozenStore());
  10259. };
  10260. var UncaughtFrozenStore = function UncaughtFrozenStore() {
  10261. this.a = [];
  10262. };
  10263. var findUncaughtFrozen = function findUncaughtFrozen(store, key) {
  10264. return arrayFind(store.a, function (it) {
  10265. return it[0] === key;
  10266. });
  10267. };
  10268. UncaughtFrozenStore.prototype = {
  10269. get: function get(key) {
  10270. var entry = findUncaughtFrozen(this, key);
  10271. if (entry) return entry[1];
  10272. },
  10273. has: function has(key) {
  10274. return !!findUncaughtFrozen(this, key);
  10275. },
  10276. set: function set(key, value) {
  10277. var entry = findUncaughtFrozen(this, key);
  10278. if (entry) entry[1] = value;else this.a.push([key, value]);
  10279. },
  10280. 'delete': function _delete(key) {
  10281. var index = arrayFindIndex(this.a, function (it) {
  10282. return it[0] === key;
  10283. });
  10284. if (~index) this.a.splice(index, 1);
  10285. return !!~index;
  10286. }
  10287. };
  10288. module.exports = {
  10289. getConstructor: function getConstructor(wrapper, NAME, IS_MAP, ADDER) {
  10290. var C = wrapper(function (that, iterable) {
  10291. anInstance(that, C, NAME, '_i');
  10292. that._t = NAME;
  10293. that._i = id++;
  10294. that._l = undefined;
  10295. if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);
  10296. });
  10297. redefineAll(C.prototype, {
  10298. 'delete': function _delete(key) {
  10299. if (!isObject(key)) return false;
  10300. var data = getWeak(key);
  10301. if (data === true) return uncaughtFrozenStore(validate(this, NAME))['delete'](key);
  10302. return data && $has(data, this._i) && delete data[this._i];
  10303. },
  10304. has: function has(key) {
  10305. if (!isObject(key)) return false;
  10306. var data = getWeak(key);
  10307. if (data === true) return uncaughtFrozenStore(validate(this, NAME)).has(key);
  10308. return data && $has(data, this._i);
  10309. }
  10310. });
  10311. return C;
  10312. },
  10313. def: function def(that, key, value) {
  10314. var data = getWeak(anObject(key), true);
  10315. if (data === true) uncaughtFrozenStore(that).set(key, value);else data[that._i] = value;
  10316. return that;
  10317. },
  10318. ufstore: uncaughtFrozenStore
  10319. };
  10320. /***/ }),
  10321. /* 108 */
  10322. /***/ (function(module, exports, __w_pdfjs_require__) {
  10323. "use strict";
  10324. var global = __w_pdfjs_require__(1);
  10325. var $export = __w_pdfjs_require__(4);
  10326. var redefine = __w_pdfjs_require__(15);
  10327. var redefineAll = __w_pdfjs_require__(22);
  10328. var meta = __w_pdfjs_require__(43);
  10329. var forOf = __w_pdfjs_require__(31);
  10330. var anInstance = __w_pdfjs_require__(23);
  10331. var isObject = __w_pdfjs_require__(2);
  10332. var fails = __w_pdfjs_require__(10);
  10333. var $iterDetect = __w_pdfjs_require__(41);
  10334. var setToStringTag = __w_pdfjs_require__(25);
  10335. var inheritIfRequired = __w_pdfjs_require__(109);
  10336. module.exports = function (NAME, wrapper, methods, common, IS_MAP, IS_WEAK) {
  10337. var Base = global[NAME];
  10338. var C = Base;
  10339. var ADDER = IS_MAP ? 'set' : 'add';
  10340. var proto = C && C.prototype;
  10341. var O = {};
  10342. var fixMethod = function fixMethod(KEY) {
  10343. var fn = proto[KEY];
  10344. redefine(proto, KEY, KEY == 'delete' ? function (a) {
  10345. return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
  10346. } : KEY == 'has' ? function has(a) {
  10347. return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
  10348. } : KEY == 'get' ? function get(a) {
  10349. return IS_WEAK && !isObject(a) ? undefined : fn.call(this, a === 0 ? 0 : a);
  10350. } : KEY == 'add' ? function add(a) {
  10351. fn.call(this, a === 0 ? 0 : a);
  10352. return this;
  10353. } : function set(a, b) {
  10354. fn.call(this, a === 0 ? 0 : a, b);
  10355. return this;
  10356. });
  10357. };
  10358. if (typeof C != 'function' || !(IS_WEAK || proto.forEach && !fails(function () {
  10359. new C().entries().next();
  10360. }))) {
  10361. C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER);
  10362. redefineAll(C.prototype, methods);
  10363. meta.NEED = true;
  10364. } else {
  10365. var instance = new C();
  10366. var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance;
  10367. var THROWS_ON_PRIMITIVES = fails(function () {
  10368. instance.has(1);
  10369. });
  10370. var ACCEPT_ITERABLES = $iterDetect(function (iter) {
  10371. new C(iter);
  10372. });
  10373. var BUGGY_ZERO = !IS_WEAK && fails(function () {
  10374. var $instance = new C();
  10375. var index = 5;
  10376. while (index--) {
  10377. $instance[ADDER](index, index);
  10378. }return !$instance.has(-0);
  10379. });
  10380. if (!ACCEPT_ITERABLES) {
  10381. C = wrapper(function (target, iterable) {
  10382. anInstance(target, C, NAME);
  10383. var that = inheritIfRequired(new Base(), target, C);
  10384. if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);
  10385. return that;
  10386. });
  10387. C.prototype = proto;
  10388. proto.constructor = C;
  10389. }
  10390. if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) {
  10391. fixMethod('delete');
  10392. fixMethod('has');
  10393. IS_MAP && fixMethod('get');
  10394. }
  10395. if (BUGGY_ZERO || HASNT_CHAINING) fixMethod(ADDER);
  10396. if (IS_WEAK && proto.clear) delete proto.clear;
  10397. }
  10398. setToStringTag(C, NAME);
  10399. O[NAME] = C;
  10400. $export($export.G + $export.W + $export.F * (C != Base), O);
  10401. if (!IS_WEAK) common.setStrong(C, NAME, IS_MAP);
  10402. return C;
  10403. };
  10404. /***/ }),
  10405. /* 109 */
  10406. /***/ (function(module, exports, __w_pdfjs_require__) {
  10407. "use strict";
  10408. var isObject = __w_pdfjs_require__(2);
  10409. var setPrototypeOf = __w_pdfjs_require__(110).set;
  10410. module.exports = function (that, target, C) {
  10411. var S = target.constructor;
  10412. var P;
  10413. if (S !== C && typeof S == 'function' && (P = S.prototype) !== C.prototype && isObject(P) && setPrototypeOf) {
  10414. setPrototypeOf(that, P);
  10415. }
  10416. return that;
  10417. };
  10418. /***/ }),
  10419. /* 110 */
  10420. /***/ (function(module, exports, __w_pdfjs_require__) {
  10421. "use strict";
  10422. var isObject = __w_pdfjs_require__(2);
  10423. var anObject = __w_pdfjs_require__(7);
  10424. var check = function check(O, proto) {
  10425. anObject(O);
  10426. if (!isObject(proto) && proto !== null) throw TypeError(proto + ": can't set as prototype!");
  10427. };
  10428. module.exports = {
  10429. set: Object.setPrototypeOf || ('__proto__' in {} ? function (test, buggy, set) {
  10430. try {
  10431. set = __w_pdfjs_require__(11)(Function.call, __w_pdfjs_require__(61).f(Object.prototype, '__proto__').set, 2);
  10432. set(test, []);
  10433. buggy = !(test instanceof Array);
  10434. } catch (e) {
  10435. buggy = true;
  10436. }
  10437. return function setPrototypeOf(O, proto) {
  10438. check(O, proto);
  10439. if (buggy) O.__proto__ = proto;else set(O, proto);
  10440. return O;
  10441. };
  10442. }({}, false) : undefined),
  10443. check: check
  10444. };
  10445. /***/ }),
  10446. /* 111 */
  10447. /***/ (function(module, exports, __w_pdfjs_require__) {
  10448. "use strict";
  10449. __w_pdfjs_require__(112)('WeakMap');
  10450. /***/ }),
  10451. /* 112 */
  10452. /***/ (function(module, exports, __w_pdfjs_require__) {
  10453. "use strict";
  10454. var $export = __w_pdfjs_require__(4);
  10455. module.exports = function (COLLECTION) {
  10456. $export($export.S, COLLECTION, {
  10457. of: function of() {
  10458. var length = arguments.length;
  10459. var A = Array(length);
  10460. while (length--) {
  10461. A[length] = arguments[length];
  10462. }return new this(A);
  10463. }
  10464. });
  10465. };
  10466. /***/ }),
  10467. /* 113 */
  10468. /***/ (function(module, exports, __w_pdfjs_require__) {
  10469. "use strict";
  10470. __w_pdfjs_require__(114)('WeakMap');
  10471. /***/ }),
  10472. /* 114 */
  10473. /***/ (function(module, exports, __w_pdfjs_require__) {
  10474. "use strict";
  10475. var $export = __w_pdfjs_require__(4);
  10476. var aFunction = __w_pdfjs_require__(21);
  10477. var ctx = __w_pdfjs_require__(11);
  10478. var forOf = __w_pdfjs_require__(31);
  10479. module.exports = function (COLLECTION) {
  10480. $export($export.S, COLLECTION, {
  10481. from: function from(source) {
  10482. var mapFn = arguments[1];
  10483. var mapping, A, n, cb;
  10484. aFunction(this);
  10485. mapping = mapFn !== undefined;
  10486. if (mapping) aFunction(mapFn);
  10487. if (source == undefined) return new this();
  10488. A = [];
  10489. if (mapping) {
  10490. n = 0;
  10491. cb = ctx(mapFn, arguments[2], 2);
  10492. forOf(source, false, function (nextItem) {
  10493. A.push(cb(nextItem, n++));
  10494. });
  10495. } else {
  10496. forOf(source, false, A.push, A);
  10497. }
  10498. return new this(A);
  10499. }
  10500. });
  10501. };
  10502. /***/ }),
  10503. /* 115 */
  10504. /***/ (function(module, exports, __w_pdfjs_require__) {
  10505. "use strict";
  10506. var isReadableStreamSupported = false;
  10507. if (typeof ReadableStream !== 'undefined') {
  10508. try {
  10509. new ReadableStream({
  10510. start: function start(controller) {
  10511. controller.close();
  10512. }
  10513. });
  10514. isReadableStreamSupported = true;
  10515. } catch (e) {}
  10516. }
  10517. if (isReadableStreamSupported) {
  10518. exports.ReadableStream = ReadableStream;
  10519. } else {
  10520. exports.ReadableStream = __w_pdfjs_require__(116).ReadableStream;
  10521. }
  10522. /***/ }),
  10523. /* 116 */
  10524. /***/ (function(module, exports, __w_pdfjs_require__) {
  10525. "use strict";
  10526. var _typeof2 = 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; };
  10527. (function (e, a) {
  10528. for (var i in a) {
  10529. e[i] = a[i];
  10530. }
  10531. })(exports, function (modules) {
  10532. var installedModules = {};
  10533. function __w_pdfjs_require__(moduleId) {
  10534. if (installedModules[moduleId]) return installedModules[moduleId].exports;
  10535. var module = installedModules[moduleId] = {
  10536. i: moduleId,
  10537. l: false,
  10538. exports: {}
  10539. };
  10540. modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);
  10541. module.l = true;
  10542. return module.exports;
  10543. }
  10544. __w_pdfjs_require__.m = modules;
  10545. __w_pdfjs_require__.c = installedModules;
  10546. __w_pdfjs_require__.i = function (value) {
  10547. return value;
  10548. };
  10549. __w_pdfjs_require__.d = function (exports, name, getter) {
  10550. if (!__w_pdfjs_require__.o(exports, name)) {
  10551. Object.defineProperty(exports, name, {
  10552. configurable: false,
  10553. enumerable: true,
  10554. get: getter
  10555. });
  10556. }
  10557. };
  10558. __w_pdfjs_require__.n = function (module) {
  10559. var getter = module && module.__esModule ? function getDefault() {
  10560. return module['default'];
  10561. } : function getModuleExports() {
  10562. return module;
  10563. };
  10564. __w_pdfjs_require__.d(getter, 'a', getter);
  10565. return getter;
  10566. };
  10567. __w_pdfjs_require__.o = function (object, property) {
  10568. return Object.prototype.hasOwnProperty.call(object, property);
  10569. };
  10570. __w_pdfjs_require__.p = "";
  10571. return __w_pdfjs_require__(__w_pdfjs_require__.s = 7);
  10572. }([function (module, exports, __w_pdfjs_require__) {
  10573. "use strict";
  10574. var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) {
  10575. return typeof obj === 'undefined' ? 'undefined' : _typeof2(obj);
  10576. } : function (obj) {
  10577. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof2(obj);
  10578. };
  10579. var _require = __w_pdfjs_require__(1),
  10580. assert = _require.assert;
  10581. function IsPropertyKey(argument) {
  10582. return typeof argument === 'string' || (typeof argument === 'undefined' ? 'undefined' : _typeof(argument)) === 'symbol';
  10583. }
  10584. exports.typeIsObject = function (x) {
  10585. return (typeof x === 'undefined' ? 'undefined' : _typeof(x)) === 'object' && x !== null || typeof x === 'function';
  10586. };
  10587. exports.createDataProperty = function (o, p, v) {
  10588. assert(exports.typeIsObject(o));
  10589. Object.defineProperty(o, p, {
  10590. value: v,
  10591. writable: true,
  10592. enumerable: true,
  10593. configurable: true
  10594. });
  10595. };
  10596. exports.createArrayFromList = function (elements) {
  10597. return elements.slice();
  10598. };
  10599. exports.ArrayBufferCopy = function (dest, destOffset, src, srcOffset, n) {
  10600. new Uint8Array(dest).set(new Uint8Array(src, srcOffset, n), destOffset);
  10601. };
  10602. exports.CreateIterResultObject = function (value, done) {
  10603. assert(typeof done === 'boolean');
  10604. var obj = {};
  10605. Object.defineProperty(obj, 'value', {
  10606. value: value,
  10607. enumerable: true,
  10608. writable: true,
  10609. configurable: true
  10610. });
  10611. Object.defineProperty(obj, 'done', {
  10612. value: done,
  10613. enumerable: true,
  10614. writable: true,
  10615. configurable: true
  10616. });
  10617. return obj;
  10618. };
  10619. exports.IsFiniteNonNegativeNumber = function (v) {
  10620. if (Number.isNaN(v)) {
  10621. return false;
  10622. }
  10623. if (v === Infinity) {
  10624. return false;
  10625. }
  10626. if (v < 0) {
  10627. return false;
  10628. }
  10629. return true;
  10630. };
  10631. function Call(F, V, args) {
  10632. if (typeof F !== 'function') {
  10633. throw new TypeError('Argument is not a function');
  10634. }
  10635. return Function.prototype.apply.call(F, V, args);
  10636. }
  10637. exports.InvokeOrNoop = function (O, P, args) {
  10638. assert(O !== undefined);
  10639. assert(IsPropertyKey(P));
  10640. assert(Array.isArray(args));
  10641. var method = O[P];
  10642. if (method === undefined) {
  10643. return undefined;
  10644. }
  10645. return Call(method, O, args);
  10646. };
  10647. exports.PromiseInvokeOrNoop = function (O, P, args) {
  10648. assert(O !== undefined);
  10649. assert(IsPropertyKey(P));
  10650. assert(Array.isArray(args));
  10651. try {
  10652. return Promise.resolve(exports.InvokeOrNoop(O, P, args));
  10653. } catch (returnValueE) {
  10654. return Promise.reject(returnValueE);
  10655. }
  10656. };
  10657. exports.PromiseInvokeOrPerformFallback = function (O, P, args, F, argsF) {
  10658. assert(O !== undefined);
  10659. assert(IsPropertyKey(P));
  10660. assert(Array.isArray(args));
  10661. assert(Array.isArray(argsF));
  10662. var method = void 0;
  10663. try {
  10664. method = O[P];
  10665. } catch (methodE) {
  10666. return Promise.reject(methodE);
  10667. }
  10668. if (method === undefined) {
  10669. return F.apply(null, argsF);
  10670. }
  10671. try {
  10672. return Promise.resolve(Call(method, O, args));
  10673. } catch (e) {
  10674. return Promise.reject(e);
  10675. }
  10676. };
  10677. exports.TransferArrayBuffer = function (O) {
  10678. return O.slice();
  10679. };
  10680. exports.ValidateAndNormalizeHighWaterMark = function (highWaterMark) {
  10681. highWaterMark = Number(highWaterMark);
  10682. if (Number.isNaN(highWaterMark) || highWaterMark < 0) {
  10683. throw new RangeError('highWaterMark property of a queuing strategy must be non-negative and non-NaN');
  10684. }
  10685. return highWaterMark;
  10686. };
  10687. exports.ValidateAndNormalizeQueuingStrategy = function (size, highWaterMark) {
  10688. if (size !== undefined && typeof size !== 'function') {
  10689. throw new TypeError('size property of a queuing strategy must be a function');
  10690. }
  10691. highWaterMark = exports.ValidateAndNormalizeHighWaterMark(highWaterMark);
  10692. return {
  10693. size: size,
  10694. highWaterMark: highWaterMark
  10695. };
  10696. };
  10697. }, function (module, exports, __w_pdfjs_require__) {
  10698. "use strict";
  10699. function rethrowAssertionErrorRejection(e) {
  10700. if (e && e.constructor === AssertionError) {
  10701. setTimeout(function () {
  10702. throw e;
  10703. }, 0);
  10704. }
  10705. }
  10706. function AssertionError(message) {
  10707. this.name = 'AssertionError';
  10708. this.message = message || '';
  10709. this.stack = new Error().stack;
  10710. }
  10711. AssertionError.prototype = Object.create(Error.prototype);
  10712. AssertionError.prototype.constructor = AssertionError;
  10713. function assert(value, message) {
  10714. if (!value) {
  10715. throw new AssertionError(message);
  10716. }
  10717. }
  10718. module.exports = {
  10719. rethrowAssertionErrorRejection: rethrowAssertionErrorRejection,
  10720. AssertionError: AssertionError,
  10721. assert: assert
  10722. };
  10723. }, function (module, exports, __w_pdfjs_require__) {
  10724. "use strict";
  10725. var _createClass = function () {
  10726. function defineProperties(target, props) {
  10727. for (var i = 0; i < props.length; i++) {
  10728. var descriptor = props[i];
  10729. descriptor.enumerable = descriptor.enumerable || false;
  10730. descriptor.configurable = true;
  10731. if ("value" in descriptor) descriptor.writable = true;
  10732. Object.defineProperty(target, descriptor.key, descriptor);
  10733. }
  10734. }
  10735. return function (Constructor, protoProps, staticProps) {
  10736. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  10737. if (staticProps) defineProperties(Constructor, staticProps);
  10738. return Constructor;
  10739. };
  10740. }();
  10741. function _classCallCheck(instance, Constructor) {
  10742. if (!(instance instanceof Constructor)) {
  10743. throw new TypeError("Cannot call a class as a function");
  10744. }
  10745. }
  10746. var _require = __w_pdfjs_require__(0),
  10747. InvokeOrNoop = _require.InvokeOrNoop,
  10748. PromiseInvokeOrNoop = _require.PromiseInvokeOrNoop,
  10749. ValidateAndNormalizeQueuingStrategy = _require.ValidateAndNormalizeQueuingStrategy,
  10750. typeIsObject = _require.typeIsObject;
  10751. var _require2 = __w_pdfjs_require__(1),
  10752. assert = _require2.assert,
  10753. rethrowAssertionErrorRejection = _require2.rethrowAssertionErrorRejection;
  10754. var _require3 = __w_pdfjs_require__(3),
  10755. DequeueValue = _require3.DequeueValue,
  10756. EnqueueValueWithSize = _require3.EnqueueValueWithSize,
  10757. PeekQueueValue = _require3.PeekQueueValue,
  10758. ResetQueue = _require3.ResetQueue;
  10759. var WritableStream = function () {
  10760. function WritableStream() {
  10761. var underlyingSink = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  10762. var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  10763. size = _ref.size,
  10764. _ref$highWaterMark = _ref.highWaterMark,
  10765. highWaterMark = _ref$highWaterMark === undefined ? 1 : _ref$highWaterMark;
  10766. _classCallCheck(this, WritableStream);
  10767. this._state = 'writable';
  10768. this._storedError = undefined;
  10769. this._writer = undefined;
  10770. this._writableStreamController = undefined;
  10771. this._writeRequests = [];
  10772. this._inFlightWriteRequest = undefined;
  10773. this._closeRequest = undefined;
  10774. this._inFlightCloseRequest = undefined;
  10775. this._pendingAbortRequest = undefined;
  10776. this._backpressure = false;
  10777. var type = underlyingSink.type;
  10778. if (type !== undefined) {
  10779. throw new RangeError('Invalid type is specified');
  10780. }
  10781. this._writableStreamController = new WritableStreamDefaultController(this, underlyingSink, size, highWaterMark);
  10782. this._writableStreamController.__startSteps();
  10783. }
  10784. _createClass(WritableStream, [{
  10785. key: 'abort',
  10786. value: function abort(reason) {
  10787. if (IsWritableStream(this) === false) {
  10788. return Promise.reject(streamBrandCheckException('abort'));
  10789. }
  10790. if (IsWritableStreamLocked(this) === true) {
  10791. return Promise.reject(new TypeError('Cannot abort a stream that already has a writer'));
  10792. }
  10793. return WritableStreamAbort(this, reason);
  10794. }
  10795. }, {
  10796. key: 'getWriter',
  10797. value: function getWriter() {
  10798. if (IsWritableStream(this) === false) {
  10799. throw streamBrandCheckException('getWriter');
  10800. }
  10801. return AcquireWritableStreamDefaultWriter(this);
  10802. }
  10803. }, {
  10804. key: 'locked',
  10805. get: function get() {
  10806. if (IsWritableStream(this) === false) {
  10807. throw streamBrandCheckException('locked');
  10808. }
  10809. return IsWritableStreamLocked(this);
  10810. }
  10811. }]);
  10812. return WritableStream;
  10813. }();
  10814. module.exports = {
  10815. AcquireWritableStreamDefaultWriter: AcquireWritableStreamDefaultWriter,
  10816. IsWritableStream: IsWritableStream,
  10817. IsWritableStreamLocked: IsWritableStreamLocked,
  10818. WritableStream: WritableStream,
  10819. WritableStreamAbort: WritableStreamAbort,
  10820. WritableStreamDefaultControllerError: WritableStreamDefaultControllerError,
  10821. WritableStreamDefaultWriterCloseWithErrorPropagation: WritableStreamDefaultWriterCloseWithErrorPropagation,
  10822. WritableStreamDefaultWriterRelease: WritableStreamDefaultWriterRelease,
  10823. WritableStreamDefaultWriterWrite: WritableStreamDefaultWriterWrite,
  10824. WritableStreamCloseQueuedOrInFlight: WritableStreamCloseQueuedOrInFlight
  10825. };
  10826. function AcquireWritableStreamDefaultWriter(stream) {
  10827. return new WritableStreamDefaultWriter(stream);
  10828. }
  10829. function IsWritableStream(x) {
  10830. if (!typeIsObject(x)) {
  10831. return false;
  10832. }
  10833. if (!Object.prototype.hasOwnProperty.call(x, '_writableStreamController')) {
  10834. return false;
  10835. }
  10836. return true;
  10837. }
  10838. function IsWritableStreamLocked(stream) {
  10839. assert(IsWritableStream(stream) === true, 'IsWritableStreamLocked should only be used on known writable streams');
  10840. if (stream._writer === undefined) {
  10841. return false;
  10842. }
  10843. return true;
  10844. }
  10845. function WritableStreamAbort(stream, reason) {
  10846. var state = stream._state;
  10847. if (state === 'closed') {
  10848. return Promise.resolve(undefined);
  10849. }
  10850. if (state === 'errored') {
  10851. return Promise.reject(stream._storedError);
  10852. }
  10853. var error = new TypeError('Requested to abort');
  10854. if (stream._pendingAbortRequest !== undefined) {
  10855. return Promise.reject(error);
  10856. }
  10857. assert(state === 'writable' || state === 'erroring', 'state must be writable or erroring');
  10858. var wasAlreadyErroring = false;
  10859. if (state === 'erroring') {
  10860. wasAlreadyErroring = true;
  10861. reason = undefined;
  10862. }
  10863. var promise = new Promise(function (resolve, reject) {
  10864. stream._pendingAbortRequest = {
  10865. _resolve: resolve,
  10866. _reject: reject,
  10867. _reason: reason,
  10868. _wasAlreadyErroring: wasAlreadyErroring
  10869. };
  10870. });
  10871. if (wasAlreadyErroring === false) {
  10872. WritableStreamStartErroring(stream, error);
  10873. }
  10874. return promise;
  10875. }
  10876. function WritableStreamAddWriteRequest(stream) {
  10877. assert(IsWritableStreamLocked(stream) === true);
  10878. assert(stream._state === 'writable');
  10879. var promise = new Promise(function (resolve, reject) {
  10880. var writeRequest = {
  10881. _resolve: resolve,
  10882. _reject: reject
  10883. };
  10884. stream._writeRequests.push(writeRequest);
  10885. });
  10886. return promise;
  10887. }
  10888. function WritableStreamDealWithRejection(stream, error) {
  10889. var state = stream._state;
  10890. if (state === 'writable') {
  10891. WritableStreamStartErroring(stream, error);
  10892. return;
  10893. }
  10894. assert(state === 'erroring');
  10895. WritableStreamFinishErroring(stream);
  10896. }
  10897. function WritableStreamStartErroring(stream, reason) {
  10898. assert(stream._storedError === undefined, 'stream._storedError === undefined');
  10899. assert(stream._state === 'writable', 'state must be writable');
  10900. var controller = stream._writableStreamController;
  10901. assert(controller !== undefined, 'controller must not be undefined');
  10902. stream._state = 'erroring';
  10903. stream._storedError = reason;
  10904. var writer = stream._writer;
  10905. if (writer !== undefined) {
  10906. WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, reason);
  10907. }
  10908. if (WritableStreamHasOperationMarkedInFlight(stream) === false && controller._started === true) {
  10909. WritableStreamFinishErroring(stream);
  10910. }
  10911. }
  10912. function WritableStreamFinishErroring(stream) {
  10913. assert(stream._state === 'erroring', 'stream._state === erroring');
  10914. assert(WritableStreamHasOperationMarkedInFlight(stream) === false, 'WritableStreamHasOperationMarkedInFlight(stream) === false');
  10915. stream._state = 'errored';
  10916. stream._writableStreamController.__errorSteps();
  10917. var storedError = stream._storedError;
  10918. for (var i = 0; i < stream._writeRequests.length; i++) {
  10919. var writeRequest = stream._writeRequests[i];
  10920. writeRequest._reject(storedError);
  10921. }
  10922. stream._writeRequests = [];
  10923. if (stream._pendingAbortRequest === undefined) {
  10924. WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
  10925. return;
  10926. }
  10927. var abortRequest = stream._pendingAbortRequest;
  10928. stream._pendingAbortRequest = undefined;
  10929. if (abortRequest._wasAlreadyErroring === true) {
  10930. abortRequest._reject(storedError);
  10931. WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
  10932. return;
  10933. }
  10934. var promise = stream._writableStreamController.__abortSteps(abortRequest._reason);
  10935. promise.then(function () {
  10936. abortRequest._resolve();
  10937. WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
  10938. }, function (reason) {
  10939. abortRequest._reject(reason);
  10940. WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
  10941. });
  10942. }
  10943. function WritableStreamFinishInFlightWrite(stream) {
  10944. assert(stream._inFlightWriteRequest !== undefined);
  10945. stream._inFlightWriteRequest._resolve(undefined);
  10946. stream._inFlightWriteRequest = undefined;
  10947. }
  10948. function WritableStreamFinishInFlightWriteWithError(stream, error) {
  10949. assert(stream._inFlightWriteRequest !== undefined);
  10950. stream._inFlightWriteRequest._reject(error);
  10951. stream._inFlightWriteRequest = undefined;
  10952. assert(stream._state === 'writable' || stream._state === 'erroring');
  10953. WritableStreamDealWithRejection(stream, error);
  10954. }
  10955. function WritableStreamFinishInFlightClose(stream) {
  10956. assert(stream._inFlightCloseRequest !== undefined);
  10957. stream._inFlightCloseRequest._resolve(undefined);
  10958. stream._inFlightCloseRequest = undefined;
  10959. var state = stream._state;
  10960. assert(state === 'writable' || state === 'erroring');
  10961. if (state === 'erroring') {
  10962. stream._storedError = undefined;
  10963. if (stream._pendingAbortRequest !== undefined) {
  10964. stream._pendingAbortRequest._resolve();
  10965. stream._pendingAbortRequest = undefined;
  10966. }
  10967. }
  10968. stream._state = 'closed';
  10969. var writer = stream._writer;
  10970. if (writer !== undefined) {
  10971. defaultWriterClosedPromiseResolve(writer);
  10972. }
  10973. assert(stream._pendingAbortRequest === undefined, 'stream._pendingAbortRequest === undefined');
  10974. assert(stream._storedError === undefined, 'stream._storedError === undefined');
  10975. }
  10976. function WritableStreamFinishInFlightCloseWithError(stream, error) {
  10977. assert(stream._inFlightCloseRequest !== undefined);
  10978. stream._inFlightCloseRequest._reject(error);
  10979. stream._inFlightCloseRequest = undefined;
  10980. assert(stream._state === 'writable' || stream._state === 'erroring');
  10981. if (stream._pendingAbortRequest !== undefined) {
  10982. stream._pendingAbortRequest._reject(error);
  10983. stream._pendingAbortRequest = undefined;
  10984. }
  10985. WritableStreamDealWithRejection(stream, error);
  10986. }
  10987. function WritableStreamCloseQueuedOrInFlight(stream) {
  10988. if (stream._closeRequest === undefined && stream._inFlightCloseRequest === undefined) {
  10989. return false;
  10990. }
  10991. return true;
  10992. }
  10993. function WritableStreamHasOperationMarkedInFlight(stream) {
  10994. if (stream._inFlightWriteRequest === undefined && stream._inFlightCloseRequest === undefined) {
  10995. return false;
  10996. }
  10997. return true;
  10998. }
  10999. function WritableStreamMarkCloseRequestInFlight(stream) {
  11000. assert(stream._inFlightCloseRequest === undefined);
  11001. assert(stream._closeRequest !== undefined);
  11002. stream._inFlightCloseRequest = stream._closeRequest;
  11003. stream._closeRequest = undefined;
  11004. }
  11005. function WritableStreamMarkFirstWriteRequestInFlight(stream) {
  11006. assert(stream._inFlightWriteRequest === undefined, 'there must be no pending write request');
  11007. assert(stream._writeRequests.length !== 0, 'writeRequests must not be empty');
  11008. stream._inFlightWriteRequest = stream._writeRequests.shift();
  11009. }
  11010. function WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream) {
  11011. assert(stream._state === 'errored', '_stream_.[[state]] is `"errored"`');
  11012. if (stream._closeRequest !== undefined) {
  11013. assert(stream._inFlightCloseRequest === undefined);
  11014. stream._closeRequest._reject(stream._storedError);
  11015. stream._closeRequest = undefined;
  11016. }
  11017. var writer = stream._writer;
  11018. if (writer !== undefined) {
  11019. defaultWriterClosedPromiseReject(writer, stream._storedError);
  11020. writer._closedPromise.catch(function () {});
  11021. }
  11022. }
  11023. function WritableStreamUpdateBackpressure(stream, backpressure) {
  11024. assert(stream._state === 'writable');
  11025. assert(WritableStreamCloseQueuedOrInFlight(stream) === false);
  11026. var writer = stream._writer;
  11027. if (writer !== undefined && backpressure !== stream._backpressure) {
  11028. if (backpressure === true) {
  11029. defaultWriterReadyPromiseReset(writer);
  11030. } else {
  11031. assert(backpressure === false);
  11032. defaultWriterReadyPromiseResolve(writer);
  11033. }
  11034. }
  11035. stream._backpressure = backpressure;
  11036. }
  11037. var WritableStreamDefaultWriter = function () {
  11038. function WritableStreamDefaultWriter(stream) {
  11039. _classCallCheck(this, WritableStreamDefaultWriter);
  11040. if (IsWritableStream(stream) === false) {
  11041. throw new TypeError('WritableStreamDefaultWriter can only be constructed with a WritableStream instance');
  11042. }
  11043. if (IsWritableStreamLocked(stream) === true) {
  11044. throw new TypeError('This stream has already been locked for exclusive writing by another writer');
  11045. }
  11046. this._ownerWritableStream = stream;
  11047. stream._writer = this;
  11048. var state = stream._state;
  11049. if (state === 'writable') {
  11050. if (WritableStreamCloseQueuedOrInFlight(stream) === false && stream._backpressure === true) {
  11051. defaultWriterReadyPromiseInitialize(this);
  11052. } else {
  11053. defaultWriterReadyPromiseInitializeAsResolved(this);
  11054. }
  11055. defaultWriterClosedPromiseInitialize(this);
  11056. } else if (state === 'erroring') {
  11057. defaultWriterReadyPromiseInitializeAsRejected(this, stream._storedError);
  11058. this._readyPromise.catch(function () {});
  11059. defaultWriterClosedPromiseInitialize(this);
  11060. } else if (state === 'closed') {
  11061. defaultWriterReadyPromiseInitializeAsResolved(this);
  11062. defaultWriterClosedPromiseInitializeAsResolved(this);
  11063. } else {
  11064. assert(state === 'errored', 'state must be errored');
  11065. var storedError = stream._storedError;
  11066. defaultWriterReadyPromiseInitializeAsRejected(this, storedError);
  11067. this._readyPromise.catch(function () {});
  11068. defaultWriterClosedPromiseInitializeAsRejected(this, storedError);
  11069. this._closedPromise.catch(function () {});
  11070. }
  11071. }
  11072. _createClass(WritableStreamDefaultWriter, [{
  11073. key: 'abort',
  11074. value: function abort(reason) {
  11075. if (IsWritableStreamDefaultWriter(this) === false) {
  11076. return Promise.reject(defaultWriterBrandCheckException('abort'));
  11077. }
  11078. if (this._ownerWritableStream === undefined) {
  11079. return Promise.reject(defaultWriterLockException('abort'));
  11080. }
  11081. return WritableStreamDefaultWriterAbort(this, reason);
  11082. }
  11083. }, {
  11084. key: 'close',
  11085. value: function close() {
  11086. if (IsWritableStreamDefaultWriter(this) === false) {
  11087. return Promise.reject(defaultWriterBrandCheckException('close'));
  11088. }
  11089. var stream = this._ownerWritableStream;
  11090. if (stream === undefined) {
  11091. return Promise.reject(defaultWriterLockException('close'));
  11092. }
  11093. if (WritableStreamCloseQueuedOrInFlight(stream) === true) {
  11094. return Promise.reject(new TypeError('cannot close an already-closing stream'));
  11095. }
  11096. return WritableStreamDefaultWriterClose(this);
  11097. }
  11098. }, {
  11099. key: 'releaseLock',
  11100. value: function releaseLock() {
  11101. if (IsWritableStreamDefaultWriter(this) === false) {
  11102. throw defaultWriterBrandCheckException('releaseLock');
  11103. }
  11104. var stream = this._ownerWritableStream;
  11105. if (stream === undefined) {
  11106. return;
  11107. }
  11108. assert(stream._writer !== undefined);
  11109. WritableStreamDefaultWriterRelease(this);
  11110. }
  11111. }, {
  11112. key: 'write',
  11113. value: function write(chunk) {
  11114. if (IsWritableStreamDefaultWriter(this) === false) {
  11115. return Promise.reject(defaultWriterBrandCheckException('write'));
  11116. }
  11117. if (this._ownerWritableStream === undefined) {
  11118. return Promise.reject(defaultWriterLockException('write to'));
  11119. }
  11120. return WritableStreamDefaultWriterWrite(this, chunk);
  11121. }
  11122. }, {
  11123. key: 'closed',
  11124. get: function get() {
  11125. if (IsWritableStreamDefaultWriter(this) === false) {
  11126. return Promise.reject(defaultWriterBrandCheckException('closed'));
  11127. }
  11128. return this._closedPromise;
  11129. }
  11130. }, {
  11131. key: 'desiredSize',
  11132. get: function get() {
  11133. if (IsWritableStreamDefaultWriter(this) === false) {
  11134. throw defaultWriterBrandCheckException('desiredSize');
  11135. }
  11136. if (this._ownerWritableStream === undefined) {
  11137. throw defaultWriterLockException('desiredSize');
  11138. }
  11139. return WritableStreamDefaultWriterGetDesiredSize(this);
  11140. }
  11141. }, {
  11142. key: 'ready',
  11143. get: function get() {
  11144. if (IsWritableStreamDefaultWriter(this) === false) {
  11145. return Promise.reject(defaultWriterBrandCheckException('ready'));
  11146. }
  11147. return this._readyPromise;
  11148. }
  11149. }]);
  11150. return WritableStreamDefaultWriter;
  11151. }();
  11152. function IsWritableStreamDefaultWriter(x) {
  11153. if (!typeIsObject(x)) {
  11154. return false;
  11155. }
  11156. if (!Object.prototype.hasOwnProperty.call(x, '_ownerWritableStream')) {
  11157. return false;
  11158. }
  11159. return true;
  11160. }
  11161. function WritableStreamDefaultWriterAbort(writer, reason) {
  11162. var stream = writer._ownerWritableStream;
  11163. assert(stream !== undefined);
  11164. return WritableStreamAbort(stream, reason);
  11165. }
  11166. function WritableStreamDefaultWriterClose(writer) {
  11167. var stream = writer._ownerWritableStream;
  11168. assert(stream !== undefined);
  11169. var state = stream._state;
  11170. if (state === 'closed' || state === 'errored') {
  11171. return Promise.reject(new TypeError('The stream (in ' + state + ' state) is not in the writable state and cannot be closed'));
  11172. }
  11173. assert(state === 'writable' || state === 'erroring');
  11174. assert(WritableStreamCloseQueuedOrInFlight(stream) === false);
  11175. var promise = new Promise(function (resolve, reject) {
  11176. var closeRequest = {
  11177. _resolve: resolve,
  11178. _reject: reject
  11179. };
  11180. stream._closeRequest = closeRequest;
  11181. });
  11182. if (stream._backpressure === true && state === 'writable') {
  11183. defaultWriterReadyPromiseResolve(writer);
  11184. }
  11185. WritableStreamDefaultControllerClose(stream._writableStreamController);
  11186. return promise;
  11187. }
  11188. function WritableStreamDefaultWriterCloseWithErrorPropagation(writer) {
  11189. var stream = writer._ownerWritableStream;
  11190. assert(stream !== undefined);
  11191. var state = stream._state;
  11192. if (WritableStreamCloseQueuedOrInFlight(stream) === true || state === 'closed') {
  11193. return Promise.resolve();
  11194. }
  11195. if (state === 'errored') {
  11196. return Promise.reject(stream._storedError);
  11197. }
  11198. assert(state === 'writable' || state === 'erroring');
  11199. return WritableStreamDefaultWriterClose(writer);
  11200. }
  11201. function WritableStreamDefaultWriterEnsureClosedPromiseRejected(writer, error) {
  11202. if (writer._closedPromiseState === 'pending') {
  11203. defaultWriterClosedPromiseReject(writer, error);
  11204. } else {
  11205. defaultWriterClosedPromiseResetToRejected(writer, error);
  11206. }
  11207. writer._closedPromise.catch(function () {});
  11208. }
  11209. function WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, error) {
  11210. if (writer._readyPromiseState === 'pending') {
  11211. defaultWriterReadyPromiseReject(writer, error);
  11212. } else {
  11213. defaultWriterReadyPromiseResetToRejected(writer, error);
  11214. }
  11215. writer._readyPromise.catch(function () {});
  11216. }
  11217. function WritableStreamDefaultWriterGetDesiredSize(writer) {
  11218. var stream = writer._ownerWritableStream;
  11219. var state = stream._state;
  11220. if (state === 'errored' || state === 'erroring') {
  11221. return null;
  11222. }
  11223. if (state === 'closed') {
  11224. return 0;
  11225. }
  11226. return WritableStreamDefaultControllerGetDesiredSize(stream._writableStreamController);
  11227. }
  11228. function WritableStreamDefaultWriterRelease(writer) {
  11229. var stream = writer._ownerWritableStream;
  11230. assert(stream !== undefined);
  11231. assert(stream._writer === writer);
  11232. var releasedError = new TypeError('Writer was released and can no longer be used to monitor the stream\'s closedness');
  11233. WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, releasedError);
  11234. WritableStreamDefaultWriterEnsureClosedPromiseRejected(writer, releasedError);
  11235. stream._writer = undefined;
  11236. writer._ownerWritableStream = undefined;
  11237. }
  11238. function WritableStreamDefaultWriterWrite(writer, chunk) {
  11239. var stream = writer._ownerWritableStream;
  11240. assert(stream !== undefined);
  11241. var controller = stream._writableStreamController;
  11242. var chunkSize = WritableStreamDefaultControllerGetChunkSize(controller, chunk);
  11243. if (stream !== writer._ownerWritableStream) {
  11244. return Promise.reject(defaultWriterLockException('write to'));
  11245. }
  11246. var state = stream._state;
  11247. if (state === 'errored') {
  11248. return Promise.reject(stream._storedError);
  11249. }
  11250. if (WritableStreamCloseQueuedOrInFlight(stream) === true || state === 'closed') {
  11251. return Promise.reject(new TypeError('The stream is closing or closed and cannot be written to'));
  11252. }
  11253. if (state === 'erroring') {
  11254. return Promise.reject(stream._storedError);
  11255. }
  11256. assert(state === 'writable');
  11257. var promise = WritableStreamAddWriteRequest(stream);
  11258. WritableStreamDefaultControllerWrite(controller, chunk, chunkSize);
  11259. return promise;
  11260. }
  11261. var WritableStreamDefaultController = function () {
  11262. function WritableStreamDefaultController(stream, underlyingSink, size, highWaterMark) {
  11263. _classCallCheck(this, WritableStreamDefaultController);
  11264. if (IsWritableStream(stream) === false) {
  11265. throw new TypeError('WritableStreamDefaultController can only be constructed with a WritableStream instance');
  11266. }
  11267. if (stream._writableStreamController !== undefined) {
  11268. throw new TypeError('WritableStreamDefaultController instances can only be created by the WritableStream constructor');
  11269. }
  11270. this._controlledWritableStream = stream;
  11271. this._underlyingSink = underlyingSink;
  11272. this._queue = undefined;
  11273. this._queueTotalSize = undefined;
  11274. ResetQueue(this);
  11275. this._started = false;
  11276. var normalizedStrategy = ValidateAndNormalizeQueuingStrategy(size, highWaterMark);
  11277. this._strategySize = normalizedStrategy.size;
  11278. this._strategyHWM = normalizedStrategy.highWaterMark;
  11279. var backpressure = WritableStreamDefaultControllerGetBackpressure(this);
  11280. WritableStreamUpdateBackpressure(stream, backpressure);
  11281. }
  11282. _createClass(WritableStreamDefaultController, [{
  11283. key: 'error',
  11284. value: function error(e) {
  11285. if (IsWritableStreamDefaultController(this) === false) {
  11286. throw new TypeError('WritableStreamDefaultController.prototype.error can only be used on a WritableStreamDefaultController');
  11287. }
  11288. var state = this._controlledWritableStream._state;
  11289. if (state !== 'writable') {
  11290. return;
  11291. }
  11292. WritableStreamDefaultControllerError(this, e);
  11293. }
  11294. }, {
  11295. key: '__abortSteps',
  11296. value: function __abortSteps(reason) {
  11297. return PromiseInvokeOrNoop(this._underlyingSink, 'abort', [reason]);
  11298. }
  11299. }, {
  11300. key: '__errorSteps',
  11301. value: function __errorSteps() {
  11302. ResetQueue(this);
  11303. }
  11304. }, {
  11305. key: '__startSteps',
  11306. value: function __startSteps() {
  11307. var _this = this;
  11308. var startResult = InvokeOrNoop(this._underlyingSink, 'start', [this]);
  11309. var stream = this._controlledWritableStream;
  11310. Promise.resolve(startResult).then(function () {
  11311. assert(stream._state === 'writable' || stream._state === 'erroring');
  11312. _this._started = true;
  11313. WritableStreamDefaultControllerAdvanceQueueIfNeeded(_this);
  11314. }, function (r) {
  11315. assert(stream._state === 'writable' || stream._state === 'erroring');
  11316. _this._started = true;
  11317. WritableStreamDealWithRejection(stream, r);
  11318. }).catch(rethrowAssertionErrorRejection);
  11319. }
  11320. }]);
  11321. return WritableStreamDefaultController;
  11322. }();
  11323. function WritableStreamDefaultControllerClose(controller) {
  11324. EnqueueValueWithSize(controller, 'close', 0);
  11325. WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
  11326. }
  11327. function WritableStreamDefaultControllerGetChunkSize(controller, chunk) {
  11328. var strategySize = controller._strategySize;
  11329. if (strategySize === undefined) {
  11330. return 1;
  11331. }
  11332. try {
  11333. return strategySize(chunk);
  11334. } catch (chunkSizeE) {
  11335. WritableStreamDefaultControllerErrorIfNeeded(controller, chunkSizeE);
  11336. return 1;
  11337. }
  11338. }
  11339. function WritableStreamDefaultControllerGetDesiredSize(controller) {
  11340. return controller._strategyHWM - controller._queueTotalSize;
  11341. }
  11342. function WritableStreamDefaultControllerWrite(controller, chunk, chunkSize) {
  11343. var writeRecord = { chunk: chunk };
  11344. try {
  11345. EnqueueValueWithSize(controller, writeRecord, chunkSize);
  11346. } catch (enqueueE) {
  11347. WritableStreamDefaultControllerErrorIfNeeded(controller, enqueueE);
  11348. return;
  11349. }
  11350. var stream = controller._controlledWritableStream;
  11351. if (WritableStreamCloseQueuedOrInFlight(stream) === false && stream._state === 'writable') {
  11352. var backpressure = WritableStreamDefaultControllerGetBackpressure(controller);
  11353. WritableStreamUpdateBackpressure(stream, backpressure);
  11354. }
  11355. WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
  11356. }
  11357. function IsWritableStreamDefaultController(x) {
  11358. if (!typeIsObject(x)) {
  11359. return false;
  11360. }
  11361. if (!Object.prototype.hasOwnProperty.call(x, '_underlyingSink')) {
  11362. return false;
  11363. }
  11364. return true;
  11365. }
  11366. function WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller) {
  11367. var stream = controller._controlledWritableStream;
  11368. if (controller._started === false) {
  11369. return;
  11370. }
  11371. if (stream._inFlightWriteRequest !== undefined) {
  11372. return;
  11373. }
  11374. var state = stream._state;
  11375. if (state === 'closed' || state === 'errored') {
  11376. return;
  11377. }
  11378. if (state === 'erroring') {
  11379. WritableStreamFinishErroring(stream);
  11380. return;
  11381. }
  11382. if (controller._queue.length === 0) {
  11383. return;
  11384. }
  11385. var writeRecord = PeekQueueValue(controller);
  11386. if (writeRecord === 'close') {
  11387. WritableStreamDefaultControllerProcessClose(controller);
  11388. } else {
  11389. WritableStreamDefaultControllerProcessWrite(controller, writeRecord.chunk);
  11390. }
  11391. }
  11392. function WritableStreamDefaultControllerErrorIfNeeded(controller, error) {
  11393. if (controller._controlledWritableStream._state === 'writable') {
  11394. WritableStreamDefaultControllerError(controller, error);
  11395. }
  11396. }
  11397. function WritableStreamDefaultControllerProcessClose(controller) {
  11398. var stream = controller._controlledWritableStream;
  11399. WritableStreamMarkCloseRequestInFlight(stream);
  11400. DequeueValue(controller);
  11401. assert(controller._queue.length === 0, 'queue must be empty once the final write record is dequeued');
  11402. var sinkClosePromise = PromiseInvokeOrNoop(controller._underlyingSink, 'close', []);
  11403. sinkClosePromise.then(function () {
  11404. WritableStreamFinishInFlightClose(stream);
  11405. }, function (reason) {
  11406. WritableStreamFinishInFlightCloseWithError(stream, reason);
  11407. }).catch(rethrowAssertionErrorRejection);
  11408. }
  11409. function WritableStreamDefaultControllerProcessWrite(controller, chunk) {
  11410. var stream = controller._controlledWritableStream;
  11411. WritableStreamMarkFirstWriteRequestInFlight(stream);
  11412. var sinkWritePromise = PromiseInvokeOrNoop(controller._underlyingSink, 'write', [chunk, controller]);
  11413. sinkWritePromise.then(function () {
  11414. WritableStreamFinishInFlightWrite(stream);
  11415. var state = stream._state;
  11416. assert(state === 'writable' || state === 'erroring');
  11417. DequeueValue(controller);
  11418. if (WritableStreamCloseQueuedOrInFlight(stream) === false && state === 'writable') {
  11419. var backpressure = WritableStreamDefaultControllerGetBackpressure(controller);
  11420. WritableStreamUpdateBackpressure(stream, backpressure);
  11421. }
  11422. WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
  11423. }, function (reason) {
  11424. WritableStreamFinishInFlightWriteWithError(stream, reason);
  11425. }).catch(rethrowAssertionErrorRejection);
  11426. }
  11427. function WritableStreamDefaultControllerGetBackpressure(controller) {
  11428. var desiredSize = WritableStreamDefaultControllerGetDesiredSize(controller);
  11429. return desiredSize <= 0;
  11430. }
  11431. function WritableStreamDefaultControllerError(controller, error) {
  11432. var stream = controller._controlledWritableStream;
  11433. assert(stream._state === 'writable');
  11434. WritableStreamStartErroring(stream, error);
  11435. }
  11436. function streamBrandCheckException(name) {
  11437. return new TypeError('WritableStream.prototype.' + name + ' can only be used on a WritableStream');
  11438. }
  11439. function defaultWriterBrandCheckException(name) {
  11440. return new TypeError('WritableStreamDefaultWriter.prototype.' + name + ' can only be used on a WritableStreamDefaultWriter');
  11441. }
  11442. function defaultWriterLockException(name) {
  11443. return new TypeError('Cannot ' + name + ' a stream using a released writer');
  11444. }
  11445. function defaultWriterClosedPromiseInitialize(writer) {
  11446. writer._closedPromise = new Promise(function (resolve, reject) {
  11447. writer._closedPromise_resolve = resolve;
  11448. writer._closedPromise_reject = reject;
  11449. writer._closedPromiseState = 'pending';
  11450. });
  11451. }
  11452. function defaultWriterClosedPromiseInitializeAsRejected(writer, reason) {
  11453. writer._closedPromise = Promise.reject(reason);
  11454. writer._closedPromise_resolve = undefined;
  11455. writer._closedPromise_reject = undefined;
  11456. writer._closedPromiseState = 'rejected';
  11457. }
  11458. function defaultWriterClosedPromiseInitializeAsResolved(writer) {
  11459. writer._closedPromise = Promise.resolve(undefined);
  11460. writer._closedPromise_resolve = undefined;
  11461. writer._closedPromise_reject = undefined;
  11462. writer._closedPromiseState = 'resolved';
  11463. }
  11464. function defaultWriterClosedPromiseReject(writer, reason) {
  11465. assert(writer._closedPromise_resolve !== undefined, 'writer._closedPromise_resolve !== undefined');
  11466. assert(writer._closedPromise_reject !== undefined, 'writer._closedPromise_reject !== undefined');
  11467. assert(writer._closedPromiseState === 'pending', 'writer._closedPromiseState is pending');
  11468. writer._closedPromise_reject(reason);
  11469. writer._closedPromise_resolve = undefined;
  11470. writer._closedPromise_reject = undefined;
  11471. writer._closedPromiseState = 'rejected';
  11472. }
  11473. function defaultWriterClosedPromiseResetToRejected(writer, reason) {
  11474. assert(writer._closedPromise_resolve === undefined, 'writer._closedPromise_resolve === undefined');
  11475. assert(writer._closedPromise_reject === undefined, 'writer._closedPromise_reject === undefined');
  11476. assert(writer._closedPromiseState !== 'pending', 'writer._closedPromiseState is not pending');
  11477. writer._closedPromise = Promise.reject(reason);
  11478. writer._closedPromiseState = 'rejected';
  11479. }
  11480. function defaultWriterClosedPromiseResolve(writer) {
  11481. assert(writer._closedPromise_resolve !== undefined, 'writer._closedPromise_resolve !== undefined');
  11482. assert(writer._closedPromise_reject !== undefined, 'writer._closedPromise_reject !== undefined');
  11483. assert(writer._closedPromiseState === 'pending', 'writer._closedPromiseState is pending');
  11484. writer._closedPromise_resolve(undefined);
  11485. writer._closedPromise_resolve = undefined;
  11486. writer._closedPromise_reject = undefined;
  11487. writer._closedPromiseState = 'resolved';
  11488. }
  11489. function defaultWriterReadyPromiseInitialize(writer) {
  11490. writer._readyPromise = new Promise(function (resolve, reject) {
  11491. writer._readyPromise_resolve = resolve;
  11492. writer._readyPromise_reject = reject;
  11493. });
  11494. writer._readyPromiseState = 'pending';
  11495. }
  11496. function defaultWriterReadyPromiseInitializeAsRejected(writer, reason) {
  11497. writer._readyPromise = Promise.reject(reason);
  11498. writer._readyPromise_resolve = undefined;
  11499. writer._readyPromise_reject = undefined;
  11500. writer._readyPromiseState = 'rejected';
  11501. }
  11502. function defaultWriterReadyPromiseInitializeAsResolved(writer) {
  11503. writer._readyPromise = Promise.resolve(undefined);
  11504. writer._readyPromise_resolve = undefined;
  11505. writer._readyPromise_reject = undefined;
  11506. writer._readyPromiseState = 'fulfilled';
  11507. }
  11508. function defaultWriterReadyPromiseReject(writer, reason) {
  11509. assert(writer._readyPromise_resolve !== undefined, 'writer._readyPromise_resolve !== undefined');
  11510. assert(writer._readyPromise_reject !== undefined, 'writer._readyPromise_reject !== undefined');
  11511. writer._readyPromise_reject(reason);
  11512. writer._readyPromise_resolve = undefined;
  11513. writer._readyPromise_reject = undefined;
  11514. writer._readyPromiseState = 'rejected';
  11515. }
  11516. function defaultWriterReadyPromiseReset(writer) {
  11517. assert(writer._readyPromise_resolve === undefined, 'writer._readyPromise_resolve === undefined');
  11518. assert(writer._readyPromise_reject === undefined, 'writer._readyPromise_reject === undefined');
  11519. writer._readyPromise = new Promise(function (resolve, reject) {
  11520. writer._readyPromise_resolve = resolve;
  11521. writer._readyPromise_reject = reject;
  11522. });
  11523. writer._readyPromiseState = 'pending';
  11524. }
  11525. function defaultWriterReadyPromiseResetToRejected(writer, reason) {
  11526. assert(writer._readyPromise_resolve === undefined, 'writer._readyPromise_resolve === undefined');
  11527. assert(writer._readyPromise_reject === undefined, 'writer._readyPromise_reject === undefined');
  11528. writer._readyPromise = Promise.reject(reason);
  11529. writer._readyPromiseState = 'rejected';
  11530. }
  11531. function defaultWriterReadyPromiseResolve(writer) {
  11532. assert(writer._readyPromise_resolve !== undefined, 'writer._readyPromise_resolve !== undefined');
  11533. assert(writer._readyPromise_reject !== undefined, 'writer._readyPromise_reject !== undefined');
  11534. writer._readyPromise_resolve(undefined);
  11535. writer._readyPromise_resolve = undefined;
  11536. writer._readyPromise_reject = undefined;
  11537. writer._readyPromiseState = 'fulfilled';
  11538. }
  11539. }, function (module, exports, __w_pdfjs_require__) {
  11540. "use strict";
  11541. var _require = __w_pdfjs_require__(0),
  11542. IsFiniteNonNegativeNumber = _require.IsFiniteNonNegativeNumber;
  11543. var _require2 = __w_pdfjs_require__(1),
  11544. assert = _require2.assert;
  11545. exports.DequeueValue = function (container) {
  11546. assert('_queue' in container && '_queueTotalSize' in container, 'Spec-level failure: DequeueValue should only be used on containers with [[queue]] and [[queueTotalSize]].');
  11547. assert(container._queue.length > 0, 'Spec-level failure: should never dequeue from an empty queue.');
  11548. var pair = container._queue.shift();
  11549. container._queueTotalSize -= pair.size;
  11550. if (container._queueTotalSize < 0) {
  11551. container._queueTotalSize = 0;
  11552. }
  11553. return pair.value;
  11554. };
  11555. exports.EnqueueValueWithSize = function (container, value, size) {
  11556. assert('_queue' in container && '_queueTotalSize' in container, 'Spec-level failure: EnqueueValueWithSize should only be used on containers with [[queue]] and ' + '[[queueTotalSize]].');
  11557. size = Number(size);
  11558. if (!IsFiniteNonNegativeNumber(size)) {
  11559. throw new RangeError('Size must be a finite, non-NaN, non-negative number.');
  11560. }
  11561. container._queue.push({
  11562. value: value,
  11563. size: size
  11564. });
  11565. container._queueTotalSize += size;
  11566. };
  11567. exports.PeekQueueValue = function (container) {
  11568. assert('_queue' in container && '_queueTotalSize' in container, 'Spec-level failure: PeekQueueValue should only be used on containers with [[queue]] and [[queueTotalSize]].');
  11569. assert(container._queue.length > 0, 'Spec-level failure: should never peek at an empty queue.');
  11570. var pair = container._queue[0];
  11571. return pair.value;
  11572. };
  11573. exports.ResetQueue = function (container) {
  11574. assert('_queue' in container && '_queueTotalSize' in container, 'Spec-level failure: ResetQueue should only be used on containers with [[queue]] and [[queueTotalSize]].');
  11575. container._queue = [];
  11576. container._queueTotalSize = 0;
  11577. };
  11578. }, function (module, exports, __w_pdfjs_require__) {
  11579. "use strict";
  11580. var _createClass = function () {
  11581. function defineProperties(target, props) {
  11582. for (var i = 0; i < props.length; i++) {
  11583. var descriptor = props[i];
  11584. descriptor.enumerable = descriptor.enumerable || false;
  11585. descriptor.configurable = true;
  11586. if ("value" in descriptor) descriptor.writable = true;
  11587. Object.defineProperty(target, descriptor.key, descriptor);
  11588. }
  11589. }
  11590. return function (Constructor, protoProps, staticProps) {
  11591. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  11592. if (staticProps) defineProperties(Constructor, staticProps);
  11593. return Constructor;
  11594. };
  11595. }();
  11596. function _classCallCheck(instance, Constructor) {
  11597. if (!(instance instanceof Constructor)) {
  11598. throw new TypeError("Cannot call a class as a function");
  11599. }
  11600. }
  11601. var _require = __w_pdfjs_require__(0),
  11602. ArrayBufferCopy = _require.ArrayBufferCopy,
  11603. CreateIterResultObject = _require.CreateIterResultObject,
  11604. IsFiniteNonNegativeNumber = _require.IsFiniteNonNegativeNumber,
  11605. InvokeOrNoop = _require.InvokeOrNoop,
  11606. PromiseInvokeOrNoop = _require.PromiseInvokeOrNoop,
  11607. TransferArrayBuffer = _require.TransferArrayBuffer,
  11608. ValidateAndNormalizeQueuingStrategy = _require.ValidateAndNormalizeQueuingStrategy,
  11609. ValidateAndNormalizeHighWaterMark = _require.ValidateAndNormalizeHighWaterMark;
  11610. var _require2 = __w_pdfjs_require__(0),
  11611. createArrayFromList = _require2.createArrayFromList,
  11612. createDataProperty = _require2.createDataProperty,
  11613. typeIsObject = _require2.typeIsObject;
  11614. var _require3 = __w_pdfjs_require__(1),
  11615. assert = _require3.assert,
  11616. rethrowAssertionErrorRejection = _require3.rethrowAssertionErrorRejection;
  11617. var _require4 = __w_pdfjs_require__(3),
  11618. DequeueValue = _require4.DequeueValue,
  11619. EnqueueValueWithSize = _require4.EnqueueValueWithSize,
  11620. ResetQueue = _require4.ResetQueue;
  11621. var _require5 = __w_pdfjs_require__(2),
  11622. AcquireWritableStreamDefaultWriter = _require5.AcquireWritableStreamDefaultWriter,
  11623. IsWritableStream = _require5.IsWritableStream,
  11624. IsWritableStreamLocked = _require5.IsWritableStreamLocked,
  11625. WritableStreamAbort = _require5.WritableStreamAbort,
  11626. WritableStreamDefaultWriterCloseWithErrorPropagation = _require5.WritableStreamDefaultWriterCloseWithErrorPropagation,
  11627. WritableStreamDefaultWriterRelease = _require5.WritableStreamDefaultWriterRelease,
  11628. WritableStreamDefaultWriterWrite = _require5.WritableStreamDefaultWriterWrite,
  11629. WritableStreamCloseQueuedOrInFlight = _require5.WritableStreamCloseQueuedOrInFlight;
  11630. var ReadableStream = function () {
  11631. function ReadableStream() {
  11632. var underlyingSource = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  11633. var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  11634. size = _ref.size,
  11635. highWaterMark = _ref.highWaterMark;
  11636. _classCallCheck(this, ReadableStream);
  11637. this._state = 'readable';
  11638. this._reader = undefined;
  11639. this._storedError = undefined;
  11640. this._disturbed = false;
  11641. this._readableStreamController = undefined;
  11642. var type = underlyingSource.type;
  11643. var typeString = String(type);
  11644. if (typeString === 'bytes') {
  11645. if (highWaterMark === undefined) {
  11646. highWaterMark = 0;
  11647. }
  11648. this._readableStreamController = new ReadableByteStreamController(this, underlyingSource, highWaterMark);
  11649. } else if (type === undefined) {
  11650. if (highWaterMark === undefined) {
  11651. highWaterMark = 1;
  11652. }
  11653. this._readableStreamController = new ReadableStreamDefaultController(this, underlyingSource, size, highWaterMark);
  11654. } else {
  11655. throw new RangeError('Invalid type is specified');
  11656. }
  11657. }
  11658. _createClass(ReadableStream, [{
  11659. key: 'cancel',
  11660. value: function cancel(reason) {
  11661. if (IsReadableStream(this) === false) {
  11662. return Promise.reject(streamBrandCheckException('cancel'));
  11663. }
  11664. if (IsReadableStreamLocked(this) === true) {
  11665. return Promise.reject(new TypeError('Cannot cancel a stream that already has a reader'));
  11666. }
  11667. return ReadableStreamCancel(this, reason);
  11668. }
  11669. }, {
  11670. key: 'getReader',
  11671. value: function getReader() {
  11672. var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  11673. mode = _ref2.mode;
  11674. if (IsReadableStream(this) === false) {
  11675. throw streamBrandCheckException('getReader');
  11676. }
  11677. if (mode === undefined) {
  11678. return AcquireReadableStreamDefaultReader(this);
  11679. }
  11680. mode = String(mode);
  11681. if (mode === 'byob') {
  11682. return AcquireReadableStreamBYOBReader(this);
  11683. }
  11684. throw new RangeError('Invalid mode is specified');
  11685. }
  11686. }, {
  11687. key: 'pipeThrough',
  11688. value: function pipeThrough(_ref3, options) {
  11689. var writable = _ref3.writable,
  11690. readable = _ref3.readable;
  11691. var promise = this.pipeTo(writable, options);
  11692. ifIsObjectAndHasAPromiseIsHandledInternalSlotSetPromiseIsHandledToTrue(promise);
  11693. return readable;
  11694. }
  11695. }, {
  11696. key: 'pipeTo',
  11697. value: function pipeTo(dest) {
  11698. var _this = this;
  11699. var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  11700. preventClose = _ref4.preventClose,
  11701. preventAbort = _ref4.preventAbort,
  11702. preventCancel = _ref4.preventCancel;
  11703. if (IsReadableStream(this) === false) {
  11704. return Promise.reject(streamBrandCheckException('pipeTo'));
  11705. }
  11706. if (IsWritableStream(dest) === false) {
  11707. return Promise.reject(new TypeError('ReadableStream.prototype.pipeTo\'s first argument must be a WritableStream'));
  11708. }
  11709. preventClose = Boolean(preventClose);
  11710. preventAbort = Boolean(preventAbort);
  11711. preventCancel = Boolean(preventCancel);
  11712. if (IsReadableStreamLocked(this) === true) {
  11713. return Promise.reject(new TypeError('ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream'));
  11714. }
  11715. if (IsWritableStreamLocked(dest) === true) {
  11716. return Promise.reject(new TypeError('ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream'));
  11717. }
  11718. var reader = AcquireReadableStreamDefaultReader(this);
  11719. var writer = AcquireWritableStreamDefaultWriter(dest);
  11720. var shuttingDown = false;
  11721. var currentWrite = Promise.resolve();
  11722. return new Promise(function (resolve, reject) {
  11723. function pipeLoop() {
  11724. currentWrite = Promise.resolve();
  11725. if (shuttingDown === true) {
  11726. return Promise.resolve();
  11727. }
  11728. return writer._readyPromise.then(function () {
  11729. return ReadableStreamDefaultReaderRead(reader).then(function (_ref5) {
  11730. var value = _ref5.value,
  11731. done = _ref5.done;
  11732. if (done === true) {
  11733. return;
  11734. }
  11735. currentWrite = WritableStreamDefaultWriterWrite(writer, value).catch(function () {});
  11736. });
  11737. }).then(pipeLoop);
  11738. }
  11739. isOrBecomesErrored(_this, reader._closedPromise, function (storedError) {
  11740. if (preventAbort === false) {
  11741. shutdownWithAction(function () {
  11742. return WritableStreamAbort(dest, storedError);
  11743. }, true, storedError);
  11744. } else {
  11745. shutdown(true, storedError);
  11746. }
  11747. });
  11748. isOrBecomesErrored(dest, writer._closedPromise, function (storedError) {
  11749. if (preventCancel === false) {
  11750. shutdownWithAction(function () {
  11751. return ReadableStreamCancel(_this, storedError);
  11752. }, true, storedError);
  11753. } else {
  11754. shutdown(true, storedError);
  11755. }
  11756. });
  11757. isOrBecomesClosed(_this, reader._closedPromise, function () {
  11758. if (preventClose === false) {
  11759. shutdownWithAction(function () {
  11760. return WritableStreamDefaultWriterCloseWithErrorPropagation(writer);
  11761. });
  11762. } else {
  11763. shutdown();
  11764. }
  11765. });
  11766. if (WritableStreamCloseQueuedOrInFlight(dest) === true || dest._state === 'closed') {
  11767. var destClosed = new TypeError('the destination writable stream closed before all data could be piped to it');
  11768. if (preventCancel === false) {
  11769. shutdownWithAction(function () {
  11770. return ReadableStreamCancel(_this, destClosed);
  11771. }, true, destClosed);
  11772. } else {
  11773. shutdown(true, destClosed);
  11774. }
  11775. }
  11776. pipeLoop().catch(function (err) {
  11777. currentWrite = Promise.resolve();
  11778. rethrowAssertionErrorRejection(err);
  11779. });
  11780. function waitForWritesToFinish() {
  11781. var oldCurrentWrite = currentWrite;
  11782. return currentWrite.then(function () {
  11783. return oldCurrentWrite !== currentWrite ? waitForWritesToFinish() : undefined;
  11784. });
  11785. }
  11786. function isOrBecomesErrored(stream, promise, action) {
  11787. if (stream._state === 'errored') {
  11788. action(stream._storedError);
  11789. } else {
  11790. promise.catch(action).catch(rethrowAssertionErrorRejection);
  11791. }
  11792. }
  11793. function isOrBecomesClosed(stream, promise, action) {
  11794. if (stream._state === 'closed') {
  11795. action();
  11796. } else {
  11797. promise.then(action).catch(rethrowAssertionErrorRejection);
  11798. }
  11799. }
  11800. function shutdownWithAction(action, originalIsError, originalError) {
  11801. if (shuttingDown === true) {
  11802. return;
  11803. }
  11804. shuttingDown = true;
  11805. if (dest._state === 'writable' && WritableStreamCloseQueuedOrInFlight(dest) === false) {
  11806. waitForWritesToFinish().then(doTheRest);
  11807. } else {
  11808. doTheRest();
  11809. }
  11810. function doTheRest() {
  11811. action().then(function () {
  11812. return finalize(originalIsError, originalError);
  11813. }, function (newError) {
  11814. return finalize(true, newError);
  11815. }).catch(rethrowAssertionErrorRejection);
  11816. }
  11817. }
  11818. function shutdown(isError, error) {
  11819. if (shuttingDown === true) {
  11820. return;
  11821. }
  11822. shuttingDown = true;
  11823. if (dest._state === 'writable' && WritableStreamCloseQueuedOrInFlight(dest) === false) {
  11824. waitForWritesToFinish().then(function () {
  11825. return finalize(isError, error);
  11826. }).catch(rethrowAssertionErrorRejection);
  11827. } else {
  11828. finalize(isError, error);
  11829. }
  11830. }
  11831. function finalize(isError, error) {
  11832. WritableStreamDefaultWriterRelease(writer);
  11833. ReadableStreamReaderGenericRelease(reader);
  11834. if (isError) {
  11835. reject(error);
  11836. } else {
  11837. resolve(undefined);
  11838. }
  11839. }
  11840. });
  11841. }
  11842. }, {
  11843. key: 'tee',
  11844. value: function tee() {
  11845. if (IsReadableStream(this) === false) {
  11846. throw streamBrandCheckException('tee');
  11847. }
  11848. var branches = ReadableStreamTee(this, false);
  11849. return createArrayFromList(branches);
  11850. }
  11851. }, {
  11852. key: 'locked',
  11853. get: function get() {
  11854. if (IsReadableStream(this) === false) {
  11855. throw streamBrandCheckException('locked');
  11856. }
  11857. return IsReadableStreamLocked(this);
  11858. }
  11859. }]);
  11860. return ReadableStream;
  11861. }();
  11862. module.exports = {
  11863. ReadableStream: ReadableStream,
  11864. IsReadableStreamDisturbed: IsReadableStreamDisturbed,
  11865. ReadableStreamDefaultControllerClose: ReadableStreamDefaultControllerClose,
  11866. ReadableStreamDefaultControllerEnqueue: ReadableStreamDefaultControllerEnqueue,
  11867. ReadableStreamDefaultControllerError: ReadableStreamDefaultControllerError,
  11868. ReadableStreamDefaultControllerGetDesiredSize: ReadableStreamDefaultControllerGetDesiredSize
  11869. };
  11870. function AcquireReadableStreamBYOBReader(stream) {
  11871. return new ReadableStreamBYOBReader(stream);
  11872. }
  11873. function AcquireReadableStreamDefaultReader(stream) {
  11874. return new ReadableStreamDefaultReader(stream);
  11875. }
  11876. function IsReadableStream(x) {
  11877. if (!typeIsObject(x)) {
  11878. return false;
  11879. }
  11880. if (!Object.prototype.hasOwnProperty.call(x, '_readableStreamController')) {
  11881. return false;
  11882. }
  11883. return true;
  11884. }
  11885. function IsReadableStreamDisturbed(stream) {
  11886. assert(IsReadableStream(stream) === true, 'IsReadableStreamDisturbed should only be used on known readable streams');
  11887. return stream._disturbed;
  11888. }
  11889. function IsReadableStreamLocked(stream) {
  11890. assert(IsReadableStream(stream) === true, 'IsReadableStreamLocked should only be used on known readable streams');
  11891. if (stream._reader === undefined) {
  11892. return false;
  11893. }
  11894. return true;
  11895. }
  11896. function ReadableStreamTee(stream, cloneForBranch2) {
  11897. assert(IsReadableStream(stream) === true);
  11898. assert(typeof cloneForBranch2 === 'boolean');
  11899. var reader = AcquireReadableStreamDefaultReader(stream);
  11900. var teeState = {
  11901. closedOrErrored: false,
  11902. canceled1: false,
  11903. canceled2: false,
  11904. reason1: undefined,
  11905. reason2: undefined
  11906. };
  11907. teeState.promise = new Promise(function (resolve) {
  11908. teeState._resolve = resolve;
  11909. });
  11910. var pull = create_ReadableStreamTeePullFunction();
  11911. pull._reader = reader;
  11912. pull._teeState = teeState;
  11913. pull._cloneForBranch2 = cloneForBranch2;
  11914. var cancel1 = create_ReadableStreamTeeBranch1CancelFunction();
  11915. cancel1._stream = stream;
  11916. cancel1._teeState = teeState;
  11917. var cancel2 = create_ReadableStreamTeeBranch2CancelFunction();
  11918. cancel2._stream = stream;
  11919. cancel2._teeState = teeState;
  11920. var underlyingSource1 = Object.create(Object.prototype);
  11921. createDataProperty(underlyingSource1, 'pull', pull);
  11922. createDataProperty(underlyingSource1, 'cancel', cancel1);
  11923. var branch1Stream = new ReadableStream(underlyingSource1);
  11924. var underlyingSource2 = Object.create(Object.prototype);
  11925. createDataProperty(underlyingSource2, 'pull', pull);
  11926. createDataProperty(underlyingSource2, 'cancel', cancel2);
  11927. var branch2Stream = new ReadableStream(underlyingSource2);
  11928. pull._branch1 = branch1Stream._readableStreamController;
  11929. pull._branch2 = branch2Stream._readableStreamController;
  11930. reader._closedPromise.catch(function (r) {
  11931. if (teeState.closedOrErrored === true) {
  11932. return;
  11933. }
  11934. ReadableStreamDefaultControllerError(pull._branch1, r);
  11935. ReadableStreamDefaultControllerError(pull._branch2, r);
  11936. teeState.closedOrErrored = true;
  11937. });
  11938. return [branch1Stream, branch2Stream];
  11939. }
  11940. function create_ReadableStreamTeePullFunction() {
  11941. function f() {
  11942. var reader = f._reader,
  11943. branch1 = f._branch1,
  11944. branch2 = f._branch2,
  11945. teeState = f._teeState;
  11946. return ReadableStreamDefaultReaderRead(reader).then(function (result) {
  11947. assert(typeIsObject(result));
  11948. var value = result.value;
  11949. var done = result.done;
  11950. assert(typeof done === 'boolean');
  11951. if (done === true && teeState.closedOrErrored === false) {
  11952. if (teeState.canceled1 === false) {
  11953. ReadableStreamDefaultControllerClose(branch1);
  11954. }
  11955. if (teeState.canceled2 === false) {
  11956. ReadableStreamDefaultControllerClose(branch2);
  11957. }
  11958. teeState.closedOrErrored = true;
  11959. }
  11960. if (teeState.closedOrErrored === true) {
  11961. return;
  11962. }
  11963. var value1 = value;
  11964. var value2 = value;
  11965. if (teeState.canceled1 === false) {
  11966. ReadableStreamDefaultControllerEnqueue(branch1, value1);
  11967. }
  11968. if (teeState.canceled2 === false) {
  11969. ReadableStreamDefaultControllerEnqueue(branch2, value2);
  11970. }
  11971. });
  11972. }
  11973. return f;
  11974. }
  11975. function create_ReadableStreamTeeBranch1CancelFunction() {
  11976. function f(reason) {
  11977. var stream = f._stream,
  11978. teeState = f._teeState;
  11979. teeState.canceled1 = true;
  11980. teeState.reason1 = reason;
  11981. if (teeState.canceled2 === true) {
  11982. var compositeReason = createArrayFromList([teeState.reason1, teeState.reason2]);
  11983. var cancelResult = ReadableStreamCancel(stream, compositeReason);
  11984. teeState._resolve(cancelResult);
  11985. }
  11986. return teeState.promise;
  11987. }
  11988. return f;
  11989. }
  11990. function create_ReadableStreamTeeBranch2CancelFunction() {
  11991. function f(reason) {
  11992. var stream = f._stream,
  11993. teeState = f._teeState;
  11994. teeState.canceled2 = true;
  11995. teeState.reason2 = reason;
  11996. if (teeState.canceled1 === true) {
  11997. var compositeReason = createArrayFromList([teeState.reason1, teeState.reason2]);
  11998. var cancelResult = ReadableStreamCancel(stream, compositeReason);
  11999. teeState._resolve(cancelResult);
  12000. }
  12001. return teeState.promise;
  12002. }
  12003. return f;
  12004. }
  12005. function ReadableStreamAddReadIntoRequest(stream) {
  12006. assert(IsReadableStreamBYOBReader(stream._reader) === true);
  12007. assert(stream._state === 'readable' || stream._state === 'closed');
  12008. var promise = new Promise(function (resolve, reject) {
  12009. var readIntoRequest = {
  12010. _resolve: resolve,
  12011. _reject: reject
  12012. };
  12013. stream._reader._readIntoRequests.push(readIntoRequest);
  12014. });
  12015. return promise;
  12016. }
  12017. function ReadableStreamAddReadRequest(stream) {
  12018. assert(IsReadableStreamDefaultReader(stream._reader) === true);
  12019. assert(stream._state === 'readable');
  12020. var promise = new Promise(function (resolve, reject) {
  12021. var readRequest = {
  12022. _resolve: resolve,
  12023. _reject: reject
  12024. };
  12025. stream._reader._readRequests.push(readRequest);
  12026. });
  12027. return promise;
  12028. }
  12029. function ReadableStreamCancel(stream, reason) {
  12030. stream._disturbed = true;
  12031. if (stream._state === 'closed') {
  12032. return Promise.resolve(undefined);
  12033. }
  12034. if (stream._state === 'errored') {
  12035. return Promise.reject(stream._storedError);
  12036. }
  12037. ReadableStreamClose(stream);
  12038. var sourceCancelPromise = stream._readableStreamController.__cancelSteps(reason);
  12039. return sourceCancelPromise.then(function () {
  12040. return undefined;
  12041. });
  12042. }
  12043. function ReadableStreamClose(stream) {
  12044. assert(stream._state === 'readable');
  12045. stream._state = 'closed';
  12046. var reader = stream._reader;
  12047. if (reader === undefined) {
  12048. return undefined;
  12049. }
  12050. if (IsReadableStreamDefaultReader(reader) === true) {
  12051. for (var i = 0; i < reader._readRequests.length; i++) {
  12052. var _resolve = reader._readRequests[i]._resolve;
  12053. _resolve(CreateIterResultObject(undefined, true));
  12054. }
  12055. reader._readRequests = [];
  12056. }
  12057. defaultReaderClosedPromiseResolve(reader);
  12058. return undefined;
  12059. }
  12060. function ReadableStreamError(stream, e) {
  12061. assert(IsReadableStream(stream) === true, 'stream must be ReadableStream');
  12062. assert(stream._state === 'readable', 'state must be readable');
  12063. stream._state = 'errored';
  12064. stream._storedError = e;
  12065. var reader = stream._reader;
  12066. if (reader === undefined) {
  12067. return undefined;
  12068. }
  12069. if (IsReadableStreamDefaultReader(reader) === true) {
  12070. for (var i = 0; i < reader._readRequests.length; i++) {
  12071. var readRequest = reader._readRequests[i];
  12072. readRequest._reject(e);
  12073. }
  12074. reader._readRequests = [];
  12075. } else {
  12076. assert(IsReadableStreamBYOBReader(reader), 'reader must be ReadableStreamBYOBReader');
  12077. for (var _i = 0; _i < reader._readIntoRequests.length; _i++) {
  12078. var readIntoRequest = reader._readIntoRequests[_i];
  12079. readIntoRequest._reject(e);
  12080. }
  12081. reader._readIntoRequests = [];
  12082. }
  12083. defaultReaderClosedPromiseReject(reader, e);
  12084. reader._closedPromise.catch(function () {});
  12085. }
  12086. function ReadableStreamFulfillReadIntoRequest(stream, chunk, done) {
  12087. var reader = stream._reader;
  12088. assert(reader._readIntoRequests.length > 0);
  12089. var readIntoRequest = reader._readIntoRequests.shift();
  12090. readIntoRequest._resolve(CreateIterResultObject(chunk, done));
  12091. }
  12092. function ReadableStreamFulfillReadRequest(stream, chunk, done) {
  12093. var reader = stream._reader;
  12094. assert(reader._readRequests.length > 0);
  12095. var readRequest = reader._readRequests.shift();
  12096. readRequest._resolve(CreateIterResultObject(chunk, done));
  12097. }
  12098. function ReadableStreamGetNumReadIntoRequests(stream) {
  12099. return stream._reader._readIntoRequests.length;
  12100. }
  12101. function ReadableStreamGetNumReadRequests(stream) {
  12102. return stream._reader._readRequests.length;
  12103. }
  12104. function ReadableStreamHasBYOBReader(stream) {
  12105. var reader = stream._reader;
  12106. if (reader === undefined) {
  12107. return false;
  12108. }
  12109. if (IsReadableStreamBYOBReader(reader) === false) {
  12110. return false;
  12111. }
  12112. return true;
  12113. }
  12114. function ReadableStreamHasDefaultReader(stream) {
  12115. var reader = stream._reader;
  12116. if (reader === undefined) {
  12117. return false;
  12118. }
  12119. if (IsReadableStreamDefaultReader(reader) === false) {
  12120. return false;
  12121. }
  12122. return true;
  12123. }
  12124. var ReadableStreamDefaultReader = function () {
  12125. function ReadableStreamDefaultReader(stream) {
  12126. _classCallCheck(this, ReadableStreamDefaultReader);
  12127. if (IsReadableStream(stream) === false) {
  12128. throw new TypeError('ReadableStreamDefaultReader can only be constructed with a ReadableStream instance');
  12129. }
  12130. if (IsReadableStreamLocked(stream) === true) {
  12131. throw new TypeError('This stream has already been locked for exclusive reading by another reader');
  12132. }
  12133. ReadableStreamReaderGenericInitialize(this, stream);
  12134. this._readRequests = [];
  12135. }
  12136. _createClass(ReadableStreamDefaultReader, [{
  12137. key: 'cancel',
  12138. value: function cancel(reason) {
  12139. if (IsReadableStreamDefaultReader(this) === false) {
  12140. return Promise.reject(defaultReaderBrandCheckException('cancel'));
  12141. }
  12142. if (this._ownerReadableStream === undefined) {
  12143. return Promise.reject(readerLockException('cancel'));
  12144. }
  12145. return ReadableStreamReaderGenericCancel(this, reason);
  12146. }
  12147. }, {
  12148. key: 'read',
  12149. value: function read() {
  12150. if (IsReadableStreamDefaultReader(this) === false) {
  12151. return Promise.reject(defaultReaderBrandCheckException('read'));
  12152. }
  12153. if (this._ownerReadableStream === undefined) {
  12154. return Promise.reject(readerLockException('read from'));
  12155. }
  12156. return ReadableStreamDefaultReaderRead(this);
  12157. }
  12158. }, {
  12159. key: 'releaseLock',
  12160. value: function releaseLock() {
  12161. if (IsReadableStreamDefaultReader(this) === false) {
  12162. throw defaultReaderBrandCheckException('releaseLock');
  12163. }
  12164. if (this._ownerReadableStream === undefined) {
  12165. return;
  12166. }
  12167. if (this._readRequests.length > 0) {
  12168. throw new TypeError('Tried to release a reader lock when that reader has pending read() calls un-settled');
  12169. }
  12170. ReadableStreamReaderGenericRelease(this);
  12171. }
  12172. }, {
  12173. key: 'closed',
  12174. get: function get() {
  12175. if (IsReadableStreamDefaultReader(this) === false) {
  12176. return Promise.reject(defaultReaderBrandCheckException('closed'));
  12177. }
  12178. return this._closedPromise;
  12179. }
  12180. }]);
  12181. return ReadableStreamDefaultReader;
  12182. }();
  12183. var ReadableStreamBYOBReader = function () {
  12184. function ReadableStreamBYOBReader(stream) {
  12185. _classCallCheck(this, ReadableStreamBYOBReader);
  12186. if (!IsReadableStream(stream)) {
  12187. throw new TypeError('ReadableStreamBYOBReader can only be constructed with a ReadableStream instance given a ' + 'byte source');
  12188. }
  12189. if (IsReadableByteStreamController(stream._readableStreamController) === false) {
  12190. throw new TypeError('Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte ' + 'source');
  12191. }
  12192. if (IsReadableStreamLocked(stream)) {
  12193. throw new TypeError('This stream has already been locked for exclusive reading by another reader');
  12194. }
  12195. ReadableStreamReaderGenericInitialize(this, stream);
  12196. this._readIntoRequests = [];
  12197. }
  12198. _createClass(ReadableStreamBYOBReader, [{
  12199. key: 'cancel',
  12200. value: function cancel(reason) {
  12201. if (!IsReadableStreamBYOBReader(this)) {
  12202. return Promise.reject(byobReaderBrandCheckException('cancel'));
  12203. }
  12204. if (this._ownerReadableStream === undefined) {
  12205. return Promise.reject(readerLockException('cancel'));
  12206. }
  12207. return ReadableStreamReaderGenericCancel(this, reason);
  12208. }
  12209. }, {
  12210. key: 'read',
  12211. value: function read(view) {
  12212. if (!IsReadableStreamBYOBReader(this)) {
  12213. return Promise.reject(byobReaderBrandCheckException('read'));
  12214. }
  12215. if (this._ownerReadableStream === undefined) {
  12216. return Promise.reject(readerLockException('read from'));
  12217. }
  12218. if (!ArrayBuffer.isView(view)) {
  12219. return Promise.reject(new TypeError('view must be an array buffer view'));
  12220. }
  12221. if (view.byteLength === 0) {
  12222. return Promise.reject(new TypeError('view must have non-zero byteLength'));
  12223. }
  12224. return ReadableStreamBYOBReaderRead(this, view);
  12225. }
  12226. }, {
  12227. key: 'releaseLock',
  12228. value: function releaseLock() {
  12229. if (!IsReadableStreamBYOBReader(this)) {
  12230. throw byobReaderBrandCheckException('releaseLock');
  12231. }
  12232. if (this._ownerReadableStream === undefined) {
  12233. return;
  12234. }
  12235. if (this._readIntoRequests.length > 0) {
  12236. throw new TypeError('Tried to release a reader lock when that reader has pending read() calls un-settled');
  12237. }
  12238. ReadableStreamReaderGenericRelease(this);
  12239. }
  12240. }, {
  12241. key: 'closed',
  12242. get: function get() {
  12243. if (!IsReadableStreamBYOBReader(this)) {
  12244. return Promise.reject(byobReaderBrandCheckException('closed'));
  12245. }
  12246. return this._closedPromise;
  12247. }
  12248. }]);
  12249. return ReadableStreamBYOBReader;
  12250. }();
  12251. function IsReadableStreamBYOBReader(x) {
  12252. if (!typeIsObject(x)) {
  12253. return false;
  12254. }
  12255. if (!Object.prototype.hasOwnProperty.call(x, '_readIntoRequests')) {
  12256. return false;
  12257. }
  12258. return true;
  12259. }
  12260. function IsReadableStreamDefaultReader(x) {
  12261. if (!typeIsObject(x)) {
  12262. return false;
  12263. }
  12264. if (!Object.prototype.hasOwnProperty.call(x, '_readRequests')) {
  12265. return false;
  12266. }
  12267. return true;
  12268. }
  12269. function ReadableStreamReaderGenericInitialize(reader, stream) {
  12270. reader._ownerReadableStream = stream;
  12271. stream._reader = reader;
  12272. if (stream._state === 'readable') {
  12273. defaultReaderClosedPromiseInitialize(reader);
  12274. } else if (stream._state === 'closed') {
  12275. defaultReaderClosedPromiseInitializeAsResolved(reader);
  12276. } else {
  12277. assert(stream._state === 'errored', 'state must be errored');
  12278. defaultReaderClosedPromiseInitializeAsRejected(reader, stream._storedError);
  12279. reader._closedPromise.catch(function () {});
  12280. }
  12281. }
  12282. function ReadableStreamReaderGenericCancel(reader, reason) {
  12283. var stream = reader._ownerReadableStream;
  12284. assert(stream !== undefined);
  12285. return ReadableStreamCancel(stream, reason);
  12286. }
  12287. function ReadableStreamReaderGenericRelease(reader) {
  12288. assert(reader._ownerReadableStream !== undefined);
  12289. assert(reader._ownerReadableStream._reader === reader);
  12290. if (reader._ownerReadableStream._state === 'readable') {
  12291. defaultReaderClosedPromiseReject(reader, new TypeError('Reader was released and can no longer be used to monitor the stream\'s closedness'));
  12292. } else {
  12293. defaultReaderClosedPromiseResetToRejected(reader, new TypeError('Reader was released and can no longer be used to monitor the stream\'s closedness'));
  12294. }
  12295. reader._closedPromise.catch(function () {});
  12296. reader._ownerReadableStream._reader = undefined;
  12297. reader._ownerReadableStream = undefined;
  12298. }
  12299. function ReadableStreamBYOBReaderRead(reader, view) {
  12300. var stream = reader._ownerReadableStream;
  12301. assert(stream !== undefined);
  12302. stream._disturbed = true;
  12303. if (stream._state === 'errored') {
  12304. return Promise.reject(stream._storedError);
  12305. }
  12306. return ReadableByteStreamControllerPullInto(stream._readableStreamController, view);
  12307. }
  12308. function ReadableStreamDefaultReaderRead(reader) {
  12309. var stream = reader._ownerReadableStream;
  12310. assert(stream !== undefined);
  12311. stream._disturbed = true;
  12312. if (stream._state === 'closed') {
  12313. return Promise.resolve(CreateIterResultObject(undefined, true));
  12314. }
  12315. if (stream._state === 'errored') {
  12316. return Promise.reject(stream._storedError);
  12317. }
  12318. assert(stream._state === 'readable');
  12319. return stream._readableStreamController.__pullSteps();
  12320. }
  12321. var ReadableStreamDefaultController = function () {
  12322. function ReadableStreamDefaultController(stream, underlyingSource, size, highWaterMark) {
  12323. _classCallCheck(this, ReadableStreamDefaultController);
  12324. if (IsReadableStream(stream) === false) {
  12325. throw new TypeError('ReadableStreamDefaultController can only be constructed with a ReadableStream instance');
  12326. }
  12327. if (stream._readableStreamController !== undefined) {
  12328. throw new TypeError('ReadableStreamDefaultController instances can only be created by the ReadableStream constructor');
  12329. }
  12330. this._controlledReadableStream = stream;
  12331. this._underlyingSource = underlyingSource;
  12332. this._queue = undefined;
  12333. this._queueTotalSize = undefined;
  12334. ResetQueue(this);
  12335. this._started = false;
  12336. this._closeRequested = false;
  12337. this._pullAgain = false;
  12338. this._pulling = false;
  12339. var normalizedStrategy = ValidateAndNormalizeQueuingStrategy(size, highWaterMark);
  12340. this._strategySize = normalizedStrategy.size;
  12341. this._strategyHWM = normalizedStrategy.highWaterMark;
  12342. var controller = this;
  12343. var startResult = InvokeOrNoop(underlyingSource, 'start', [this]);
  12344. Promise.resolve(startResult).then(function () {
  12345. controller._started = true;
  12346. assert(controller._pulling === false);
  12347. assert(controller._pullAgain === false);
  12348. ReadableStreamDefaultControllerCallPullIfNeeded(controller);
  12349. }, function (r) {
  12350. ReadableStreamDefaultControllerErrorIfNeeded(controller, r);
  12351. }).catch(rethrowAssertionErrorRejection);
  12352. }
  12353. _createClass(ReadableStreamDefaultController, [{
  12354. key: 'close',
  12355. value: function close() {
  12356. if (IsReadableStreamDefaultController(this) === false) {
  12357. throw defaultControllerBrandCheckException('close');
  12358. }
  12359. if (this._closeRequested === true) {
  12360. throw new TypeError('The stream has already been closed; do not close it again!');
  12361. }
  12362. var state = this._controlledReadableStream._state;
  12363. if (state !== 'readable') {
  12364. throw new TypeError('The stream (in ' + state + ' state) is not in the readable state and cannot be closed');
  12365. }
  12366. ReadableStreamDefaultControllerClose(this);
  12367. }
  12368. }, {
  12369. key: 'enqueue',
  12370. value: function enqueue(chunk) {
  12371. if (IsReadableStreamDefaultController(this) === false) {
  12372. throw defaultControllerBrandCheckException('enqueue');
  12373. }
  12374. if (this._closeRequested === true) {
  12375. throw new TypeError('stream is closed or draining');
  12376. }
  12377. var state = this._controlledReadableStream._state;
  12378. if (state !== 'readable') {
  12379. throw new TypeError('The stream (in ' + state + ' state) is not in the readable state and cannot be enqueued to');
  12380. }
  12381. return ReadableStreamDefaultControllerEnqueue(this, chunk);
  12382. }
  12383. }, {
  12384. key: 'error',
  12385. value: function error(e) {
  12386. if (IsReadableStreamDefaultController(this) === false) {
  12387. throw defaultControllerBrandCheckException('error');
  12388. }
  12389. var stream = this._controlledReadableStream;
  12390. if (stream._state !== 'readable') {
  12391. throw new TypeError('The stream is ' + stream._state + ' and so cannot be errored');
  12392. }
  12393. ReadableStreamDefaultControllerError(this, e);
  12394. }
  12395. }, {
  12396. key: '__cancelSteps',
  12397. value: function __cancelSteps(reason) {
  12398. ResetQueue(this);
  12399. return PromiseInvokeOrNoop(this._underlyingSource, 'cancel', [reason]);
  12400. }
  12401. }, {
  12402. key: '__pullSteps',
  12403. value: function __pullSteps() {
  12404. var stream = this._controlledReadableStream;
  12405. if (this._queue.length > 0) {
  12406. var chunk = DequeueValue(this);
  12407. if (this._closeRequested === true && this._queue.length === 0) {
  12408. ReadableStreamClose(stream);
  12409. } else {
  12410. ReadableStreamDefaultControllerCallPullIfNeeded(this);
  12411. }
  12412. return Promise.resolve(CreateIterResultObject(chunk, false));
  12413. }
  12414. var pendingPromise = ReadableStreamAddReadRequest(stream);
  12415. ReadableStreamDefaultControllerCallPullIfNeeded(this);
  12416. return pendingPromise;
  12417. }
  12418. }, {
  12419. key: 'desiredSize',
  12420. get: function get() {
  12421. if (IsReadableStreamDefaultController(this) === false) {
  12422. throw defaultControllerBrandCheckException('desiredSize');
  12423. }
  12424. return ReadableStreamDefaultControllerGetDesiredSize(this);
  12425. }
  12426. }]);
  12427. return ReadableStreamDefaultController;
  12428. }();
  12429. function IsReadableStreamDefaultController(x) {
  12430. if (!typeIsObject(x)) {
  12431. return false;
  12432. }
  12433. if (!Object.prototype.hasOwnProperty.call(x, '_underlyingSource')) {
  12434. return false;
  12435. }
  12436. return true;
  12437. }
  12438. function ReadableStreamDefaultControllerCallPullIfNeeded(controller) {
  12439. var shouldPull = ReadableStreamDefaultControllerShouldCallPull(controller);
  12440. if (shouldPull === false) {
  12441. return undefined;
  12442. }
  12443. if (controller._pulling === true) {
  12444. controller._pullAgain = true;
  12445. return undefined;
  12446. }
  12447. assert(controller._pullAgain === false);
  12448. controller._pulling = true;
  12449. var pullPromise = PromiseInvokeOrNoop(controller._underlyingSource, 'pull', [controller]);
  12450. pullPromise.then(function () {
  12451. controller._pulling = false;
  12452. if (controller._pullAgain === true) {
  12453. controller._pullAgain = false;
  12454. return ReadableStreamDefaultControllerCallPullIfNeeded(controller);
  12455. }
  12456. return undefined;
  12457. }, function (e) {
  12458. ReadableStreamDefaultControllerErrorIfNeeded(controller, e);
  12459. }).catch(rethrowAssertionErrorRejection);
  12460. return undefined;
  12461. }
  12462. function ReadableStreamDefaultControllerShouldCallPull(controller) {
  12463. var stream = controller._controlledReadableStream;
  12464. if (stream._state === 'closed' || stream._state === 'errored') {
  12465. return false;
  12466. }
  12467. if (controller._closeRequested === true) {
  12468. return false;
  12469. }
  12470. if (controller._started === false) {
  12471. return false;
  12472. }
  12473. if (IsReadableStreamLocked(stream) === true && ReadableStreamGetNumReadRequests(stream) > 0) {
  12474. return true;
  12475. }
  12476. var desiredSize = ReadableStreamDefaultControllerGetDesiredSize(controller);
  12477. if (desiredSize > 0) {
  12478. return true;
  12479. }
  12480. return false;
  12481. }
  12482. function ReadableStreamDefaultControllerClose(controller) {
  12483. var stream = controller._controlledReadableStream;
  12484. assert(controller._closeRequested === false);
  12485. assert(stream._state === 'readable');
  12486. controller._closeRequested = true;
  12487. if (controller._queue.length === 0) {
  12488. ReadableStreamClose(stream);
  12489. }
  12490. }
  12491. function ReadableStreamDefaultControllerEnqueue(controller, chunk) {
  12492. var stream = controller._controlledReadableStream;
  12493. assert(controller._closeRequested === false);
  12494. assert(stream._state === 'readable');
  12495. if (IsReadableStreamLocked(stream) === true && ReadableStreamGetNumReadRequests(stream) > 0) {
  12496. ReadableStreamFulfillReadRequest(stream, chunk, false);
  12497. } else {
  12498. var chunkSize = 1;
  12499. if (controller._strategySize !== undefined) {
  12500. var strategySize = controller._strategySize;
  12501. try {
  12502. chunkSize = strategySize(chunk);
  12503. } catch (chunkSizeE) {
  12504. ReadableStreamDefaultControllerErrorIfNeeded(controller, chunkSizeE);
  12505. throw chunkSizeE;
  12506. }
  12507. }
  12508. try {
  12509. EnqueueValueWithSize(controller, chunk, chunkSize);
  12510. } catch (enqueueE) {
  12511. ReadableStreamDefaultControllerErrorIfNeeded(controller, enqueueE);
  12512. throw enqueueE;
  12513. }
  12514. }
  12515. ReadableStreamDefaultControllerCallPullIfNeeded(controller);
  12516. return undefined;
  12517. }
  12518. function ReadableStreamDefaultControllerError(controller, e) {
  12519. var stream = controller._controlledReadableStream;
  12520. assert(stream._state === 'readable');
  12521. ResetQueue(controller);
  12522. ReadableStreamError(stream, e);
  12523. }
  12524. function ReadableStreamDefaultControllerErrorIfNeeded(controller, e) {
  12525. if (controller._controlledReadableStream._state === 'readable') {
  12526. ReadableStreamDefaultControllerError(controller, e);
  12527. }
  12528. }
  12529. function ReadableStreamDefaultControllerGetDesiredSize(controller) {
  12530. var stream = controller._controlledReadableStream;
  12531. var state = stream._state;
  12532. if (state === 'errored') {
  12533. return null;
  12534. }
  12535. if (state === 'closed') {
  12536. return 0;
  12537. }
  12538. return controller._strategyHWM - controller._queueTotalSize;
  12539. }
  12540. var ReadableStreamBYOBRequest = function () {
  12541. function ReadableStreamBYOBRequest(controller, view) {
  12542. _classCallCheck(this, ReadableStreamBYOBRequest);
  12543. this._associatedReadableByteStreamController = controller;
  12544. this._view = view;
  12545. }
  12546. _createClass(ReadableStreamBYOBRequest, [{
  12547. key: 'respond',
  12548. value: function respond(bytesWritten) {
  12549. if (IsReadableStreamBYOBRequest(this) === false) {
  12550. throw byobRequestBrandCheckException('respond');
  12551. }
  12552. if (this._associatedReadableByteStreamController === undefined) {
  12553. throw new TypeError('This BYOB request has been invalidated');
  12554. }
  12555. ReadableByteStreamControllerRespond(this._associatedReadableByteStreamController, bytesWritten);
  12556. }
  12557. }, {
  12558. key: 'respondWithNewView',
  12559. value: function respondWithNewView(view) {
  12560. if (IsReadableStreamBYOBRequest(this) === false) {
  12561. throw byobRequestBrandCheckException('respond');
  12562. }
  12563. if (this._associatedReadableByteStreamController === undefined) {
  12564. throw new TypeError('This BYOB request has been invalidated');
  12565. }
  12566. if (!ArrayBuffer.isView(view)) {
  12567. throw new TypeError('You can only respond with array buffer views');
  12568. }
  12569. ReadableByteStreamControllerRespondWithNewView(this._associatedReadableByteStreamController, view);
  12570. }
  12571. }, {
  12572. key: 'view',
  12573. get: function get() {
  12574. return this._view;
  12575. }
  12576. }]);
  12577. return ReadableStreamBYOBRequest;
  12578. }();
  12579. var ReadableByteStreamController = function () {
  12580. function ReadableByteStreamController(stream, underlyingByteSource, highWaterMark) {
  12581. _classCallCheck(this, ReadableByteStreamController);
  12582. if (IsReadableStream(stream) === false) {
  12583. throw new TypeError('ReadableByteStreamController can only be constructed with a ReadableStream instance given ' + 'a byte source');
  12584. }
  12585. if (stream._readableStreamController !== undefined) {
  12586. throw new TypeError('ReadableByteStreamController instances can only be created by the ReadableStream constructor given a byte ' + 'source');
  12587. }
  12588. this._controlledReadableStream = stream;
  12589. this._underlyingByteSource = underlyingByteSource;
  12590. this._pullAgain = false;
  12591. this._pulling = false;
  12592. ReadableByteStreamControllerClearPendingPullIntos(this);
  12593. this._queue = this._queueTotalSize = undefined;
  12594. ResetQueue(this);
  12595. this._closeRequested = false;
  12596. this._started = false;
  12597. this._strategyHWM = ValidateAndNormalizeHighWaterMark(highWaterMark);
  12598. var autoAllocateChunkSize = underlyingByteSource.autoAllocateChunkSize;
  12599. if (autoAllocateChunkSize !== undefined) {
  12600. if (Number.isInteger(autoAllocateChunkSize) === false || autoAllocateChunkSize <= 0) {
  12601. throw new RangeError('autoAllocateChunkSize must be a positive integer');
  12602. }
  12603. }
  12604. this._autoAllocateChunkSize = autoAllocateChunkSize;
  12605. this._pendingPullIntos = [];
  12606. var controller = this;
  12607. var startResult = InvokeOrNoop(underlyingByteSource, 'start', [this]);
  12608. Promise.resolve(startResult).then(function () {
  12609. controller._started = true;
  12610. assert(controller._pulling === false);
  12611. assert(controller._pullAgain === false);
  12612. ReadableByteStreamControllerCallPullIfNeeded(controller);
  12613. }, function (r) {
  12614. if (stream._state === 'readable') {
  12615. ReadableByteStreamControllerError(controller, r);
  12616. }
  12617. }).catch(rethrowAssertionErrorRejection);
  12618. }
  12619. _createClass(ReadableByteStreamController, [{
  12620. key: 'close',
  12621. value: function close() {
  12622. if (IsReadableByteStreamController(this) === false) {
  12623. throw byteStreamControllerBrandCheckException('close');
  12624. }
  12625. if (this._closeRequested === true) {
  12626. throw new TypeError('The stream has already been closed; do not close it again!');
  12627. }
  12628. var state = this._controlledReadableStream._state;
  12629. if (state !== 'readable') {
  12630. throw new TypeError('The stream (in ' + state + ' state) is not in the readable state and cannot be closed');
  12631. }
  12632. ReadableByteStreamControllerClose(this);
  12633. }
  12634. }, {
  12635. key: 'enqueue',
  12636. value: function enqueue(chunk) {
  12637. if (IsReadableByteStreamController(this) === false) {
  12638. throw byteStreamControllerBrandCheckException('enqueue');
  12639. }
  12640. if (this._closeRequested === true) {
  12641. throw new TypeError('stream is closed or draining');
  12642. }
  12643. var state = this._controlledReadableStream._state;
  12644. if (state !== 'readable') {
  12645. throw new TypeError('The stream (in ' + state + ' state) is not in the readable state and cannot be enqueued to');
  12646. }
  12647. if (!ArrayBuffer.isView(chunk)) {
  12648. throw new TypeError('You can only enqueue array buffer views when using a ReadableByteStreamController');
  12649. }
  12650. ReadableByteStreamControllerEnqueue(this, chunk);
  12651. }
  12652. }, {
  12653. key: 'error',
  12654. value: function error(e) {
  12655. if (IsReadableByteStreamController(this) === false) {
  12656. throw byteStreamControllerBrandCheckException('error');
  12657. }
  12658. var stream = this._controlledReadableStream;
  12659. if (stream._state !== 'readable') {
  12660. throw new TypeError('The stream is ' + stream._state + ' and so cannot be errored');
  12661. }
  12662. ReadableByteStreamControllerError(this, e);
  12663. }
  12664. }, {
  12665. key: '__cancelSteps',
  12666. value: function __cancelSteps(reason) {
  12667. if (this._pendingPullIntos.length > 0) {
  12668. var firstDescriptor = this._pendingPullIntos[0];
  12669. firstDescriptor.bytesFilled = 0;
  12670. }
  12671. ResetQueue(this);
  12672. return PromiseInvokeOrNoop(this._underlyingByteSource, 'cancel', [reason]);
  12673. }
  12674. }, {
  12675. key: '__pullSteps',
  12676. value: function __pullSteps() {
  12677. var stream = this._controlledReadableStream;
  12678. assert(ReadableStreamHasDefaultReader(stream) === true);
  12679. if (this._queueTotalSize > 0) {
  12680. assert(ReadableStreamGetNumReadRequests(stream) === 0);
  12681. var entry = this._queue.shift();
  12682. this._queueTotalSize -= entry.byteLength;
  12683. ReadableByteStreamControllerHandleQueueDrain(this);
  12684. var view = void 0;
  12685. try {
  12686. view = new Uint8Array(entry.buffer, entry.byteOffset, entry.byteLength);
  12687. } catch (viewE) {
  12688. return Promise.reject(viewE);
  12689. }
  12690. return Promise.resolve(CreateIterResultObject(view, false));
  12691. }
  12692. var autoAllocateChunkSize = this._autoAllocateChunkSize;
  12693. if (autoAllocateChunkSize !== undefined) {
  12694. var buffer = void 0;
  12695. try {
  12696. buffer = new ArrayBuffer(autoAllocateChunkSize);
  12697. } catch (bufferE) {
  12698. return Promise.reject(bufferE);
  12699. }
  12700. var pullIntoDescriptor = {
  12701. buffer: buffer,
  12702. byteOffset: 0,
  12703. byteLength: autoAllocateChunkSize,
  12704. bytesFilled: 0,
  12705. elementSize: 1,
  12706. ctor: Uint8Array,
  12707. readerType: 'default'
  12708. };
  12709. this._pendingPullIntos.push(pullIntoDescriptor);
  12710. }
  12711. var promise = ReadableStreamAddReadRequest(stream);
  12712. ReadableByteStreamControllerCallPullIfNeeded(this);
  12713. return promise;
  12714. }
  12715. }, {
  12716. key: 'byobRequest',
  12717. get: function get() {
  12718. if (IsReadableByteStreamController(this) === false) {
  12719. throw byteStreamControllerBrandCheckException('byobRequest');
  12720. }
  12721. if (this._byobRequest === undefined && this._pendingPullIntos.length > 0) {
  12722. var firstDescriptor = this._pendingPullIntos[0];
  12723. var view = new Uint8Array(firstDescriptor.buffer, firstDescriptor.byteOffset + firstDescriptor.bytesFilled, firstDescriptor.byteLength - firstDescriptor.bytesFilled);
  12724. this._byobRequest = new ReadableStreamBYOBRequest(this, view);
  12725. }
  12726. return this._byobRequest;
  12727. }
  12728. }, {
  12729. key: 'desiredSize',
  12730. get: function get() {
  12731. if (IsReadableByteStreamController(this) === false) {
  12732. throw byteStreamControllerBrandCheckException('desiredSize');
  12733. }
  12734. return ReadableByteStreamControllerGetDesiredSize(this);
  12735. }
  12736. }]);
  12737. return ReadableByteStreamController;
  12738. }();
  12739. function IsReadableByteStreamController(x) {
  12740. if (!typeIsObject(x)) {
  12741. return false;
  12742. }
  12743. if (!Object.prototype.hasOwnProperty.call(x, '_underlyingByteSource')) {
  12744. return false;
  12745. }
  12746. return true;
  12747. }
  12748. function IsReadableStreamBYOBRequest(x) {
  12749. if (!typeIsObject(x)) {
  12750. return false;
  12751. }
  12752. if (!Object.prototype.hasOwnProperty.call(x, '_associatedReadableByteStreamController')) {
  12753. return false;
  12754. }
  12755. return true;
  12756. }
  12757. function ReadableByteStreamControllerCallPullIfNeeded(controller) {
  12758. var shouldPull = ReadableByteStreamControllerShouldCallPull(controller);
  12759. if (shouldPull === false) {
  12760. return undefined;
  12761. }
  12762. if (controller._pulling === true) {
  12763. controller._pullAgain = true;
  12764. return undefined;
  12765. }
  12766. assert(controller._pullAgain === false);
  12767. controller._pulling = true;
  12768. var pullPromise = PromiseInvokeOrNoop(controller._underlyingByteSource, 'pull', [controller]);
  12769. pullPromise.then(function () {
  12770. controller._pulling = false;
  12771. if (controller._pullAgain === true) {
  12772. controller._pullAgain = false;
  12773. ReadableByteStreamControllerCallPullIfNeeded(controller);
  12774. }
  12775. }, function (e) {
  12776. if (controller._controlledReadableStream._state === 'readable') {
  12777. ReadableByteStreamControllerError(controller, e);
  12778. }
  12779. }).catch(rethrowAssertionErrorRejection);
  12780. return undefined;
  12781. }
  12782. function ReadableByteStreamControllerClearPendingPullIntos(controller) {
  12783. ReadableByteStreamControllerInvalidateBYOBRequest(controller);
  12784. controller._pendingPullIntos = [];
  12785. }
  12786. function ReadableByteStreamControllerCommitPullIntoDescriptor(stream, pullIntoDescriptor) {
  12787. assert(stream._state !== 'errored', 'state must not be errored');
  12788. var done = false;
  12789. if (stream._state === 'closed') {
  12790. assert(pullIntoDescriptor.bytesFilled === 0);
  12791. done = true;
  12792. }
  12793. var filledView = ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor);
  12794. if (pullIntoDescriptor.readerType === 'default') {
  12795. ReadableStreamFulfillReadRequest(stream, filledView, done);
  12796. } else {
  12797. assert(pullIntoDescriptor.readerType === 'byob');
  12798. ReadableStreamFulfillReadIntoRequest(stream, filledView, done);
  12799. }
  12800. }
  12801. function ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor) {
  12802. var bytesFilled = pullIntoDescriptor.bytesFilled;
  12803. var elementSize = pullIntoDescriptor.elementSize;
  12804. assert(bytesFilled <= pullIntoDescriptor.byteLength);
  12805. assert(bytesFilled % elementSize === 0);
  12806. return new pullIntoDescriptor.ctor(pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, bytesFilled / elementSize);
  12807. }
  12808. function ReadableByteStreamControllerEnqueueChunkToQueue(controller, buffer, byteOffset, byteLength) {
  12809. controller._queue.push({
  12810. buffer: buffer,
  12811. byteOffset: byteOffset,
  12812. byteLength: byteLength
  12813. });
  12814. controller._queueTotalSize += byteLength;
  12815. }
  12816. function ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) {
  12817. var elementSize = pullIntoDescriptor.elementSize;
  12818. var currentAlignedBytes = pullIntoDescriptor.bytesFilled - pullIntoDescriptor.bytesFilled % elementSize;
  12819. var maxBytesToCopy = Math.min(controller._queueTotalSize, pullIntoDescriptor.byteLength - pullIntoDescriptor.bytesFilled);
  12820. var maxBytesFilled = pullIntoDescriptor.bytesFilled + maxBytesToCopy;
  12821. var maxAlignedBytes = maxBytesFilled - maxBytesFilled % elementSize;
  12822. var totalBytesToCopyRemaining = maxBytesToCopy;
  12823. var ready = false;
  12824. if (maxAlignedBytes > currentAlignedBytes) {
  12825. totalBytesToCopyRemaining = maxAlignedBytes - pullIntoDescriptor.bytesFilled;
  12826. ready = true;
  12827. }
  12828. var queue = controller._queue;
  12829. while (totalBytesToCopyRemaining > 0) {
  12830. var headOfQueue = queue[0];
  12831. var bytesToCopy = Math.min(totalBytesToCopyRemaining, headOfQueue.byteLength);
  12832. var destStart = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;
  12833. ArrayBufferCopy(pullIntoDescriptor.buffer, destStart, headOfQueue.buffer, headOfQueue.byteOffset, bytesToCopy);
  12834. if (headOfQueue.byteLength === bytesToCopy) {
  12835. queue.shift();
  12836. } else {
  12837. headOfQueue.byteOffset += bytesToCopy;
  12838. headOfQueue.byteLength -= bytesToCopy;
  12839. }
  12840. controller._queueTotalSize -= bytesToCopy;
  12841. ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, bytesToCopy, pullIntoDescriptor);
  12842. totalBytesToCopyRemaining -= bytesToCopy;
  12843. }
  12844. if (ready === false) {
  12845. assert(controller._queueTotalSize === 0, 'queue must be empty');
  12846. assert(pullIntoDescriptor.bytesFilled > 0);
  12847. assert(pullIntoDescriptor.bytesFilled < pullIntoDescriptor.elementSize);
  12848. }
  12849. return ready;
  12850. }
  12851. function ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, size, pullIntoDescriptor) {
  12852. assert(controller._pendingPullIntos.length === 0 || controller._pendingPullIntos[0] === pullIntoDescriptor);
  12853. ReadableByteStreamControllerInvalidateBYOBRequest(controller);
  12854. pullIntoDescriptor.bytesFilled += size;
  12855. }
  12856. function ReadableByteStreamControllerHandleQueueDrain(controller) {
  12857. assert(controller._controlledReadableStream._state === 'readable');
  12858. if (controller._queueTotalSize === 0 && controller._closeRequested === true) {
  12859. ReadableStreamClose(controller._controlledReadableStream);
  12860. } else {
  12861. ReadableByteStreamControllerCallPullIfNeeded(controller);
  12862. }
  12863. }
  12864. function ReadableByteStreamControllerInvalidateBYOBRequest(controller) {
  12865. if (controller._byobRequest === undefined) {
  12866. return;
  12867. }
  12868. controller._byobRequest._associatedReadableByteStreamController = undefined;
  12869. controller._byobRequest._view = undefined;
  12870. controller._byobRequest = undefined;
  12871. }
  12872. function ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller) {
  12873. assert(controller._closeRequested === false);
  12874. while (controller._pendingPullIntos.length > 0) {
  12875. if (controller._queueTotalSize === 0) {
  12876. return;
  12877. }
  12878. var pullIntoDescriptor = controller._pendingPullIntos[0];
  12879. if (ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) === true) {
  12880. ReadableByteStreamControllerShiftPendingPullInto(controller);
  12881. ReadableByteStreamControllerCommitPullIntoDescriptor(controller._controlledReadableStream, pullIntoDescriptor);
  12882. }
  12883. }
  12884. }
  12885. function ReadableByteStreamControllerPullInto(controller, view) {
  12886. var stream = controller._controlledReadableStream;
  12887. var elementSize = 1;
  12888. if (view.constructor !== DataView) {
  12889. elementSize = view.constructor.BYTES_PER_ELEMENT;
  12890. }
  12891. var ctor = view.constructor;
  12892. var pullIntoDescriptor = {
  12893. buffer: view.buffer,
  12894. byteOffset: view.byteOffset,
  12895. byteLength: view.byteLength,
  12896. bytesFilled: 0,
  12897. elementSize: elementSize,
  12898. ctor: ctor,
  12899. readerType: 'byob'
  12900. };
  12901. if (controller._pendingPullIntos.length > 0) {
  12902. pullIntoDescriptor.buffer = TransferArrayBuffer(pullIntoDescriptor.buffer);
  12903. controller._pendingPullIntos.push(pullIntoDescriptor);
  12904. return ReadableStreamAddReadIntoRequest(stream);
  12905. }
  12906. if (stream._state === 'closed') {
  12907. var emptyView = new view.constructor(pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, 0);
  12908. return Promise.resolve(CreateIterResultObject(emptyView, true));
  12909. }
  12910. if (controller._queueTotalSize > 0) {
  12911. if (ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) === true) {
  12912. var filledView = ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor);
  12913. ReadableByteStreamControllerHandleQueueDrain(controller);
  12914. return Promise.resolve(CreateIterResultObject(filledView, false));
  12915. }
  12916. if (controller._closeRequested === true) {
  12917. var e = new TypeError('Insufficient bytes to fill elements in the given buffer');
  12918. ReadableByteStreamControllerError(controller, e);
  12919. return Promise.reject(e);
  12920. }
  12921. }
  12922. pullIntoDescriptor.buffer = TransferArrayBuffer(pullIntoDescriptor.buffer);
  12923. controller._pendingPullIntos.push(pullIntoDescriptor);
  12924. var promise = ReadableStreamAddReadIntoRequest(stream);
  12925. ReadableByteStreamControllerCallPullIfNeeded(controller);
  12926. return promise;
  12927. }
  12928. function ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor) {
  12929. firstDescriptor.buffer = TransferArrayBuffer(firstDescriptor.buffer);
  12930. assert(firstDescriptor.bytesFilled === 0, 'bytesFilled must be 0');
  12931. var stream = controller._controlledReadableStream;
  12932. if (ReadableStreamHasBYOBReader(stream) === true) {
  12933. while (ReadableStreamGetNumReadIntoRequests(stream) > 0) {
  12934. var pullIntoDescriptor = ReadableByteStreamControllerShiftPendingPullInto(controller);
  12935. ReadableByteStreamControllerCommitPullIntoDescriptor(stream, pullIntoDescriptor);
  12936. }
  12937. }
  12938. }
  12939. function ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, pullIntoDescriptor) {
  12940. if (pullIntoDescriptor.bytesFilled + bytesWritten > pullIntoDescriptor.byteLength) {
  12941. throw new RangeError('bytesWritten out of range');
  12942. }
  12943. ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, bytesWritten, pullIntoDescriptor);
  12944. if (pullIntoDescriptor.bytesFilled < pullIntoDescriptor.elementSize) {
  12945. return;
  12946. }
  12947. ReadableByteStreamControllerShiftPendingPullInto(controller);
  12948. var remainderSize = pullIntoDescriptor.bytesFilled % pullIntoDescriptor.elementSize;
  12949. if (remainderSize > 0) {
  12950. var end = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;
  12951. var remainder = pullIntoDescriptor.buffer.slice(end - remainderSize, end);
  12952. ReadableByteStreamControllerEnqueueChunkToQueue(controller, remainder, 0, remainder.byteLength);
  12953. }
  12954. pullIntoDescriptor.buffer = TransferArrayBuffer(pullIntoDescriptor.buffer);
  12955. pullIntoDescriptor.bytesFilled -= remainderSize;
  12956. ReadableByteStreamControllerCommitPullIntoDescriptor(controller._controlledReadableStream, pullIntoDescriptor);
  12957. ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller);
  12958. }
  12959. function ReadableByteStreamControllerRespondInternal(controller, bytesWritten) {
  12960. var firstDescriptor = controller._pendingPullIntos[0];
  12961. var stream = controller._controlledReadableStream;
  12962. if (stream._state === 'closed') {
  12963. if (bytesWritten !== 0) {
  12964. throw new TypeError('bytesWritten must be 0 when calling respond() on a closed stream');
  12965. }
  12966. ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor);
  12967. } else {
  12968. assert(stream._state === 'readable');
  12969. ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, firstDescriptor);
  12970. }
  12971. }
  12972. function ReadableByteStreamControllerShiftPendingPullInto(controller) {
  12973. var descriptor = controller._pendingPullIntos.shift();
  12974. ReadableByteStreamControllerInvalidateBYOBRequest(controller);
  12975. return descriptor;
  12976. }
  12977. function ReadableByteStreamControllerShouldCallPull(controller) {
  12978. var stream = controller._controlledReadableStream;
  12979. if (stream._state !== 'readable') {
  12980. return false;
  12981. }
  12982. if (controller._closeRequested === true) {
  12983. return false;
  12984. }
  12985. if (controller._started === false) {
  12986. return false;
  12987. }
  12988. if (ReadableStreamHasDefaultReader(stream) === true && ReadableStreamGetNumReadRequests(stream) > 0) {
  12989. return true;
  12990. }
  12991. if (ReadableStreamHasBYOBReader(stream) === true && ReadableStreamGetNumReadIntoRequests(stream) > 0) {
  12992. return true;
  12993. }
  12994. if (ReadableByteStreamControllerGetDesiredSize(controller) > 0) {
  12995. return true;
  12996. }
  12997. return false;
  12998. }
  12999. function ReadableByteStreamControllerClose(controller) {
  13000. var stream = controller._controlledReadableStream;
  13001. assert(controller._closeRequested === false);
  13002. assert(stream._state === 'readable');
  13003. if (controller._queueTotalSize > 0) {
  13004. controller._closeRequested = true;
  13005. return;
  13006. }
  13007. if (controller._pendingPullIntos.length > 0) {
  13008. var firstPendingPullInto = controller._pendingPullIntos[0];
  13009. if (firstPendingPullInto.bytesFilled > 0) {
  13010. var e = new TypeError('Insufficient bytes to fill elements in the given buffer');
  13011. ReadableByteStreamControllerError(controller, e);
  13012. throw e;
  13013. }
  13014. }
  13015. ReadableStreamClose(stream);
  13016. }
  13017. function ReadableByteStreamControllerEnqueue(controller, chunk) {
  13018. var stream = controller._controlledReadableStream;
  13019. assert(controller._closeRequested === false);
  13020. assert(stream._state === 'readable');
  13021. var buffer = chunk.buffer;
  13022. var byteOffset = chunk.byteOffset;
  13023. var byteLength = chunk.byteLength;
  13024. var transferredBuffer = TransferArrayBuffer(buffer);
  13025. if (ReadableStreamHasDefaultReader(stream) === true) {
  13026. if (ReadableStreamGetNumReadRequests(stream) === 0) {
  13027. ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
  13028. } else {
  13029. assert(controller._queue.length === 0);
  13030. var transferredView = new Uint8Array(transferredBuffer, byteOffset, byteLength);
  13031. ReadableStreamFulfillReadRequest(stream, transferredView, false);
  13032. }
  13033. } else if (ReadableStreamHasBYOBReader(stream) === true) {
  13034. ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
  13035. ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller);
  13036. } else {
  13037. assert(IsReadableStreamLocked(stream) === false, 'stream must not be locked');
  13038. ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
  13039. }
  13040. }
  13041. function ReadableByteStreamControllerError(controller, e) {
  13042. var stream = controller._controlledReadableStream;
  13043. assert(stream._state === 'readable');
  13044. ReadableByteStreamControllerClearPendingPullIntos(controller);
  13045. ResetQueue(controller);
  13046. ReadableStreamError(stream, e);
  13047. }
  13048. function ReadableByteStreamControllerGetDesiredSize(controller) {
  13049. var stream = controller._controlledReadableStream;
  13050. var state = stream._state;
  13051. if (state === 'errored') {
  13052. return null;
  13053. }
  13054. if (state === 'closed') {
  13055. return 0;
  13056. }
  13057. return controller._strategyHWM - controller._queueTotalSize;
  13058. }
  13059. function ReadableByteStreamControllerRespond(controller, bytesWritten) {
  13060. bytesWritten = Number(bytesWritten);
  13061. if (IsFiniteNonNegativeNumber(bytesWritten) === false) {
  13062. throw new RangeError('bytesWritten must be a finite');
  13063. }
  13064. assert(controller._pendingPullIntos.length > 0);
  13065. ReadableByteStreamControllerRespondInternal(controller, bytesWritten);
  13066. }
  13067. function ReadableByteStreamControllerRespondWithNewView(controller, view) {
  13068. assert(controller._pendingPullIntos.length > 0);
  13069. var firstDescriptor = controller._pendingPullIntos[0];
  13070. if (firstDescriptor.byteOffset + firstDescriptor.bytesFilled !== view.byteOffset) {
  13071. throw new RangeError('The region specified by view does not match byobRequest');
  13072. }
  13073. if (firstDescriptor.byteLength !== view.byteLength) {
  13074. throw new RangeError('The buffer of view has different capacity than byobRequest');
  13075. }
  13076. firstDescriptor.buffer = view.buffer;
  13077. ReadableByteStreamControllerRespondInternal(controller, view.byteLength);
  13078. }
  13079. function streamBrandCheckException(name) {
  13080. return new TypeError('ReadableStream.prototype.' + name + ' can only be used on a ReadableStream');
  13081. }
  13082. function readerLockException(name) {
  13083. return new TypeError('Cannot ' + name + ' a stream using a released reader');
  13084. }
  13085. function defaultReaderBrandCheckException(name) {
  13086. return new TypeError('ReadableStreamDefaultReader.prototype.' + name + ' can only be used on a ReadableStreamDefaultReader');
  13087. }
  13088. function defaultReaderClosedPromiseInitialize(reader) {
  13089. reader._closedPromise = new Promise(function (resolve, reject) {
  13090. reader._closedPromise_resolve = resolve;
  13091. reader._closedPromise_reject = reject;
  13092. });
  13093. }
  13094. function defaultReaderClosedPromiseInitializeAsRejected(reader, reason) {
  13095. reader._closedPromise = Promise.reject(reason);
  13096. reader._closedPromise_resolve = undefined;
  13097. reader._closedPromise_reject = undefined;
  13098. }
  13099. function defaultReaderClosedPromiseInitializeAsResolved(reader) {
  13100. reader._closedPromise = Promise.resolve(undefined);
  13101. reader._closedPromise_resolve = undefined;
  13102. reader._closedPromise_reject = undefined;
  13103. }
  13104. function defaultReaderClosedPromiseReject(reader, reason) {
  13105. assert(reader._closedPromise_resolve !== undefined);
  13106. assert(reader._closedPromise_reject !== undefined);
  13107. reader._closedPromise_reject(reason);
  13108. reader._closedPromise_resolve = undefined;
  13109. reader._closedPromise_reject = undefined;
  13110. }
  13111. function defaultReaderClosedPromiseResetToRejected(reader, reason) {
  13112. assert(reader._closedPromise_resolve === undefined);
  13113. assert(reader._closedPromise_reject === undefined);
  13114. reader._closedPromise = Promise.reject(reason);
  13115. }
  13116. function defaultReaderClosedPromiseResolve(reader) {
  13117. assert(reader._closedPromise_resolve !== undefined);
  13118. assert(reader._closedPromise_reject !== undefined);
  13119. reader._closedPromise_resolve(undefined);
  13120. reader._closedPromise_resolve = undefined;
  13121. reader._closedPromise_reject = undefined;
  13122. }
  13123. function byobReaderBrandCheckException(name) {
  13124. return new TypeError('ReadableStreamBYOBReader.prototype.' + name + ' can only be used on a ReadableStreamBYOBReader');
  13125. }
  13126. function defaultControllerBrandCheckException(name) {
  13127. return new TypeError('ReadableStreamDefaultController.prototype.' + name + ' can only be used on a ReadableStreamDefaultController');
  13128. }
  13129. function byobRequestBrandCheckException(name) {
  13130. return new TypeError('ReadableStreamBYOBRequest.prototype.' + name + ' can only be used on a ReadableStreamBYOBRequest');
  13131. }
  13132. function byteStreamControllerBrandCheckException(name) {
  13133. return new TypeError('ReadableByteStreamController.prototype.' + name + ' can only be used on a ReadableByteStreamController');
  13134. }
  13135. function ifIsObjectAndHasAPromiseIsHandledInternalSlotSetPromiseIsHandledToTrue(promise) {
  13136. try {
  13137. Promise.prototype.then.call(promise, undefined, function () {});
  13138. } catch (e) {}
  13139. }
  13140. }, function (module, exports, __w_pdfjs_require__) {
  13141. "use strict";
  13142. var transformStream = __w_pdfjs_require__(6);
  13143. var readableStream = __w_pdfjs_require__(4);
  13144. var writableStream = __w_pdfjs_require__(2);
  13145. exports.TransformStream = transformStream.TransformStream;
  13146. exports.ReadableStream = readableStream.ReadableStream;
  13147. exports.IsReadableStreamDisturbed = readableStream.IsReadableStreamDisturbed;
  13148. exports.ReadableStreamDefaultControllerClose = readableStream.ReadableStreamDefaultControllerClose;
  13149. exports.ReadableStreamDefaultControllerEnqueue = readableStream.ReadableStreamDefaultControllerEnqueue;
  13150. exports.ReadableStreamDefaultControllerError = readableStream.ReadableStreamDefaultControllerError;
  13151. exports.ReadableStreamDefaultControllerGetDesiredSize = readableStream.ReadableStreamDefaultControllerGetDesiredSize;
  13152. exports.AcquireWritableStreamDefaultWriter = writableStream.AcquireWritableStreamDefaultWriter;
  13153. exports.IsWritableStream = writableStream.IsWritableStream;
  13154. exports.IsWritableStreamLocked = writableStream.IsWritableStreamLocked;
  13155. exports.WritableStream = writableStream.WritableStream;
  13156. exports.WritableStreamAbort = writableStream.WritableStreamAbort;
  13157. exports.WritableStreamDefaultControllerError = writableStream.WritableStreamDefaultControllerError;
  13158. exports.WritableStreamDefaultWriterCloseWithErrorPropagation = writableStream.WritableStreamDefaultWriterCloseWithErrorPropagation;
  13159. exports.WritableStreamDefaultWriterRelease = writableStream.WritableStreamDefaultWriterRelease;
  13160. exports.WritableStreamDefaultWriterWrite = writableStream.WritableStreamDefaultWriterWrite;
  13161. }, function (module, exports, __w_pdfjs_require__) {
  13162. "use strict";
  13163. var _createClass = function () {
  13164. function defineProperties(target, props) {
  13165. for (var i = 0; i < props.length; i++) {
  13166. var descriptor = props[i];
  13167. descriptor.enumerable = descriptor.enumerable || false;
  13168. descriptor.configurable = true;
  13169. if ("value" in descriptor) descriptor.writable = true;
  13170. Object.defineProperty(target, descriptor.key, descriptor);
  13171. }
  13172. }
  13173. return function (Constructor, protoProps, staticProps) {
  13174. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  13175. if (staticProps) defineProperties(Constructor, staticProps);
  13176. return Constructor;
  13177. };
  13178. }();
  13179. function _classCallCheck(instance, Constructor) {
  13180. if (!(instance instanceof Constructor)) {
  13181. throw new TypeError("Cannot call a class as a function");
  13182. }
  13183. }
  13184. var _require = __w_pdfjs_require__(1),
  13185. assert = _require.assert;
  13186. var _require2 = __w_pdfjs_require__(0),
  13187. InvokeOrNoop = _require2.InvokeOrNoop,
  13188. PromiseInvokeOrPerformFallback = _require2.PromiseInvokeOrPerformFallback,
  13189. PromiseInvokeOrNoop = _require2.PromiseInvokeOrNoop,
  13190. typeIsObject = _require2.typeIsObject;
  13191. var _require3 = __w_pdfjs_require__(4),
  13192. ReadableStream = _require3.ReadableStream,
  13193. ReadableStreamDefaultControllerClose = _require3.ReadableStreamDefaultControllerClose,
  13194. ReadableStreamDefaultControllerEnqueue = _require3.ReadableStreamDefaultControllerEnqueue,
  13195. ReadableStreamDefaultControllerError = _require3.ReadableStreamDefaultControllerError,
  13196. ReadableStreamDefaultControllerGetDesiredSize = _require3.ReadableStreamDefaultControllerGetDesiredSize;
  13197. var _require4 = __w_pdfjs_require__(2),
  13198. WritableStream = _require4.WritableStream,
  13199. WritableStreamDefaultControllerError = _require4.WritableStreamDefaultControllerError;
  13200. function TransformStreamCloseReadable(transformStream) {
  13201. if (transformStream._errored === true) {
  13202. throw new TypeError('TransformStream is already errored');
  13203. }
  13204. if (transformStream._readableClosed === true) {
  13205. throw new TypeError('Readable side is already closed');
  13206. }
  13207. TransformStreamCloseReadableInternal(transformStream);
  13208. }
  13209. function TransformStreamEnqueueToReadable(transformStream, chunk) {
  13210. if (transformStream._errored === true) {
  13211. throw new TypeError('TransformStream is already errored');
  13212. }
  13213. if (transformStream._readableClosed === true) {
  13214. throw new TypeError('Readable side is already closed');
  13215. }
  13216. var controller = transformStream._readableController;
  13217. try {
  13218. ReadableStreamDefaultControllerEnqueue(controller, chunk);
  13219. } catch (e) {
  13220. transformStream._readableClosed = true;
  13221. TransformStreamErrorIfNeeded(transformStream, e);
  13222. throw transformStream._storedError;
  13223. }
  13224. var desiredSize = ReadableStreamDefaultControllerGetDesiredSize(controller);
  13225. var maybeBackpressure = desiredSize <= 0;
  13226. if (maybeBackpressure === true && transformStream._backpressure === false) {
  13227. TransformStreamSetBackpressure(transformStream, true);
  13228. }
  13229. }
  13230. function TransformStreamError(transformStream, e) {
  13231. if (transformStream._errored === true) {
  13232. throw new TypeError('TransformStream is already errored');
  13233. }
  13234. TransformStreamErrorInternal(transformStream, e);
  13235. }
  13236. function TransformStreamCloseReadableInternal(transformStream) {
  13237. assert(transformStream._errored === false);
  13238. assert(transformStream._readableClosed === false);
  13239. try {
  13240. ReadableStreamDefaultControllerClose(transformStream._readableController);
  13241. } catch (e) {
  13242. assert(false);
  13243. }
  13244. transformStream._readableClosed = true;
  13245. }
  13246. function TransformStreamErrorIfNeeded(transformStream, e) {
  13247. if (transformStream._errored === false) {
  13248. TransformStreamErrorInternal(transformStream, e);
  13249. }
  13250. }
  13251. function TransformStreamErrorInternal(transformStream, e) {
  13252. assert(transformStream._errored === false);
  13253. transformStream._errored = true;
  13254. transformStream._storedError = e;
  13255. if (transformStream._writableDone === false) {
  13256. WritableStreamDefaultControllerError(transformStream._writableController, e);
  13257. }
  13258. if (transformStream._readableClosed === false) {
  13259. ReadableStreamDefaultControllerError(transformStream._readableController, e);
  13260. }
  13261. }
  13262. function TransformStreamReadableReadyPromise(transformStream) {
  13263. assert(transformStream._backpressureChangePromise !== undefined, '_backpressureChangePromise should have been initialized');
  13264. if (transformStream._backpressure === false) {
  13265. return Promise.resolve();
  13266. }
  13267. assert(transformStream._backpressure === true, '_backpressure should have been initialized');
  13268. return transformStream._backpressureChangePromise;
  13269. }
  13270. function TransformStreamSetBackpressure(transformStream, backpressure) {
  13271. assert(transformStream._backpressure !== backpressure, 'TransformStreamSetBackpressure() should be called only when backpressure is changed');
  13272. if (transformStream._backpressureChangePromise !== undefined) {
  13273. transformStream._backpressureChangePromise_resolve(backpressure);
  13274. }
  13275. transformStream._backpressureChangePromise = new Promise(function (resolve) {
  13276. transformStream._backpressureChangePromise_resolve = resolve;
  13277. });
  13278. transformStream._backpressureChangePromise.then(function (resolution) {
  13279. assert(resolution !== backpressure, '_backpressureChangePromise should be fulfilled only when backpressure is changed');
  13280. });
  13281. transformStream._backpressure = backpressure;
  13282. }
  13283. function TransformStreamDefaultTransform(chunk, transformStreamController) {
  13284. var transformStream = transformStreamController._controlledTransformStream;
  13285. TransformStreamEnqueueToReadable(transformStream, chunk);
  13286. return Promise.resolve();
  13287. }
  13288. function TransformStreamTransform(transformStream, chunk) {
  13289. assert(transformStream._errored === false);
  13290. assert(transformStream._transforming === false);
  13291. assert(transformStream._backpressure === false);
  13292. transformStream._transforming = true;
  13293. var transformer = transformStream._transformer;
  13294. var controller = transformStream._transformStreamController;
  13295. var transformPromise = PromiseInvokeOrPerformFallback(transformer, 'transform', [chunk, controller], TransformStreamDefaultTransform, [chunk, controller]);
  13296. return transformPromise.then(function () {
  13297. transformStream._transforming = false;
  13298. return TransformStreamReadableReadyPromise(transformStream);
  13299. }, function (e) {
  13300. TransformStreamErrorIfNeeded(transformStream, e);
  13301. return Promise.reject(e);
  13302. });
  13303. }
  13304. function IsTransformStreamDefaultController(x) {
  13305. if (!typeIsObject(x)) {
  13306. return false;
  13307. }
  13308. if (!Object.prototype.hasOwnProperty.call(x, '_controlledTransformStream')) {
  13309. return false;
  13310. }
  13311. return true;
  13312. }
  13313. function IsTransformStream(x) {
  13314. if (!typeIsObject(x)) {
  13315. return false;
  13316. }
  13317. if (!Object.prototype.hasOwnProperty.call(x, '_transformStreamController')) {
  13318. return false;
  13319. }
  13320. return true;
  13321. }
  13322. var TransformStreamSink = function () {
  13323. function TransformStreamSink(transformStream, startPromise) {
  13324. _classCallCheck(this, TransformStreamSink);
  13325. this._transformStream = transformStream;
  13326. this._startPromise = startPromise;
  13327. }
  13328. _createClass(TransformStreamSink, [{
  13329. key: 'start',
  13330. value: function start(c) {
  13331. var transformStream = this._transformStream;
  13332. transformStream._writableController = c;
  13333. return this._startPromise.then(function () {
  13334. return TransformStreamReadableReadyPromise(transformStream);
  13335. });
  13336. }
  13337. }, {
  13338. key: 'write',
  13339. value: function write(chunk) {
  13340. var transformStream = this._transformStream;
  13341. return TransformStreamTransform(transformStream, chunk);
  13342. }
  13343. }, {
  13344. key: 'abort',
  13345. value: function abort() {
  13346. var transformStream = this._transformStream;
  13347. transformStream._writableDone = true;
  13348. TransformStreamErrorInternal(transformStream, new TypeError('Writable side aborted'));
  13349. }
  13350. }, {
  13351. key: 'close',
  13352. value: function close() {
  13353. var transformStream = this._transformStream;
  13354. assert(transformStream._transforming === false);
  13355. transformStream._writableDone = true;
  13356. var flushPromise = PromiseInvokeOrNoop(transformStream._transformer, 'flush', [transformStream._transformStreamController]);
  13357. return flushPromise.then(function () {
  13358. if (transformStream._errored === true) {
  13359. return Promise.reject(transformStream._storedError);
  13360. }
  13361. if (transformStream._readableClosed === false) {
  13362. TransformStreamCloseReadableInternal(transformStream);
  13363. }
  13364. return Promise.resolve();
  13365. }).catch(function (r) {
  13366. TransformStreamErrorIfNeeded(transformStream, r);
  13367. return Promise.reject(transformStream._storedError);
  13368. });
  13369. }
  13370. }]);
  13371. return TransformStreamSink;
  13372. }();
  13373. var TransformStreamSource = function () {
  13374. function TransformStreamSource(transformStream, startPromise) {
  13375. _classCallCheck(this, TransformStreamSource);
  13376. this._transformStream = transformStream;
  13377. this._startPromise = startPromise;
  13378. }
  13379. _createClass(TransformStreamSource, [{
  13380. key: 'start',
  13381. value: function start(c) {
  13382. var transformStream = this._transformStream;
  13383. transformStream._readableController = c;
  13384. return this._startPromise.then(function () {
  13385. assert(transformStream._backpressureChangePromise !== undefined, '_backpressureChangePromise should have been initialized');
  13386. if (transformStream._backpressure === true) {
  13387. return Promise.resolve();
  13388. }
  13389. assert(transformStream._backpressure === false, '_backpressure should have been initialized');
  13390. return transformStream._backpressureChangePromise;
  13391. });
  13392. }
  13393. }, {
  13394. key: 'pull',
  13395. value: function pull() {
  13396. var transformStream = this._transformStream;
  13397. assert(transformStream._backpressure === true, 'pull() should be never called while _backpressure is false');
  13398. assert(transformStream._backpressureChangePromise !== undefined, '_backpressureChangePromise should have been initialized');
  13399. TransformStreamSetBackpressure(transformStream, false);
  13400. return transformStream._backpressureChangePromise;
  13401. }
  13402. }, {
  13403. key: 'cancel',
  13404. value: function cancel() {
  13405. var transformStream = this._transformStream;
  13406. transformStream._readableClosed = true;
  13407. TransformStreamErrorInternal(transformStream, new TypeError('Readable side canceled'));
  13408. }
  13409. }]);
  13410. return TransformStreamSource;
  13411. }();
  13412. var TransformStreamDefaultController = function () {
  13413. function TransformStreamDefaultController(transformStream) {
  13414. _classCallCheck(this, TransformStreamDefaultController);
  13415. if (IsTransformStream(transformStream) === false) {
  13416. throw new TypeError('TransformStreamDefaultController can only be ' + 'constructed with a TransformStream instance');
  13417. }
  13418. if (transformStream._transformStreamController !== undefined) {
  13419. throw new TypeError('TransformStreamDefaultController instances can ' + 'only be created by the TransformStream constructor');
  13420. }
  13421. this._controlledTransformStream = transformStream;
  13422. }
  13423. _createClass(TransformStreamDefaultController, [{
  13424. key: 'enqueue',
  13425. value: function enqueue(chunk) {
  13426. if (IsTransformStreamDefaultController(this) === false) {
  13427. throw defaultControllerBrandCheckException('enqueue');
  13428. }
  13429. TransformStreamEnqueueToReadable(this._controlledTransformStream, chunk);
  13430. }
  13431. }, {
  13432. key: 'close',
  13433. value: function close() {
  13434. if (IsTransformStreamDefaultController(this) === false) {
  13435. throw defaultControllerBrandCheckException('close');
  13436. }
  13437. TransformStreamCloseReadable(this._controlledTransformStream);
  13438. }
  13439. }, {
  13440. key: 'error',
  13441. value: function error(reason) {
  13442. if (IsTransformStreamDefaultController(this) === false) {
  13443. throw defaultControllerBrandCheckException('error');
  13444. }
  13445. TransformStreamError(this._controlledTransformStream, reason);
  13446. }
  13447. }, {
  13448. key: 'desiredSize',
  13449. get: function get() {
  13450. if (IsTransformStreamDefaultController(this) === false) {
  13451. throw defaultControllerBrandCheckException('desiredSize');
  13452. }
  13453. var transformStream = this._controlledTransformStream;
  13454. var readableController = transformStream._readableController;
  13455. return ReadableStreamDefaultControllerGetDesiredSize(readableController);
  13456. }
  13457. }]);
  13458. return TransformStreamDefaultController;
  13459. }();
  13460. var TransformStream = function () {
  13461. function TransformStream() {
  13462. var transformer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  13463. _classCallCheck(this, TransformStream);
  13464. this._transformer = transformer;
  13465. var readableStrategy = transformer.readableStrategy,
  13466. writableStrategy = transformer.writableStrategy;
  13467. this._transforming = false;
  13468. this._errored = false;
  13469. this._storedError = undefined;
  13470. this._writableController = undefined;
  13471. this._readableController = undefined;
  13472. this._transformStreamController = undefined;
  13473. this._writableDone = false;
  13474. this._readableClosed = false;
  13475. this._backpressure = undefined;
  13476. this._backpressureChangePromise = undefined;
  13477. this._backpressureChangePromise_resolve = undefined;
  13478. this._transformStreamController = new TransformStreamDefaultController(this);
  13479. var startPromise_resolve = void 0;
  13480. var startPromise = new Promise(function (resolve) {
  13481. startPromise_resolve = resolve;
  13482. });
  13483. var source = new TransformStreamSource(this, startPromise);
  13484. this._readable = new ReadableStream(source, readableStrategy);
  13485. var sink = new TransformStreamSink(this, startPromise);
  13486. this._writable = new WritableStream(sink, writableStrategy);
  13487. assert(this._writableController !== undefined);
  13488. assert(this._readableController !== undefined);
  13489. var desiredSize = ReadableStreamDefaultControllerGetDesiredSize(this._readableController);
  13490. TransformStreamSetBackpressure(this, desiredSize <= 0);
  13491. var transformStream = this;
  13492. var startResult = InvokeOrNoop(transformer, 'start', [transformStream._transformStreamController]);
  13493. startPromise_resolve(startResult);
  13494. startPromise.catch(function (e) {
  13495. if (transformStream._errored === false) {
  13496. transformStream._errored = true;
  13497. transformStream._storedError = e;
  13498. }
  13499. });
  13500. }
  13501. _createClass(TransformStream, [{
  13502. key: 'readable',
  13503. get: function get() {
  13504. if (IsTransformStream(this) === false) {
  13505. throw streamBrandCheckException('readable');
  13506. }
  13507. return this._readable;
  13508. }
  13509. }, {
  13510. key: 'writable',
  13511. get: function get() {
  13512. if (IsTransformStream(this) === false) {
  13513. throw streamBrandCheckException('writable');
  13514. }
  13515. return this._writable;
  13516. }
  13517. }]);
  13518. return TransformStream;
  13519. }();
  13520. module.exports = { TransformStream: TransformStream };
  13521. function defaultControllerBrandCheckException(name) {
  13522. return new TypeError('TransformStreamDefaultController.prototype.' + name + ' can only be used on a TransformStreamDefaultController');
  13523. }
  13524. function streamBrandCheckException(name) {
  13525. return new TypeError('TransformStream.prototype.' + name + ' can only be used on a TransformStream');
  13526. }
  13527. }, function (module, exports, __w_pdfjs_require__) {
  13528. module.exports = __w_pdfjs_require__(5);
  13529. }]));
  13530. /***/ }),
  13531. /* 117 */
  13532. /***/ (function(module, exports, __w_pdfjs_require__) {
  13533. "use strict";
  13534. Object.defineProperty(exports, "__esModule", {
  13535. value: true
  13536. });
  13537. exports.PDFJS = exports.globalScope = undefined;
  13538. var _api = __w_pdfjs_require__(69);
  13539. var _dom_utils = __w_pdfjs_require__(13);
  13540. var _util = __w_pdfjs_require__(0);
  13541. var _annotation_layer = __w_pdfjs_require__(72);
  13542. var _global_scope = __w_pdfjs_require__(20);
  13543. var _global_scope2 = _interopRequireDefault(_global_scope);
  13544. var _metadata = __w_pdfjs_require__(71);
  13545. var _text_layer = __w_pdfjs_require__(73);
  13546. var _svg = __w_pdfjs_require__(74);
  13547. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  13548. if (!_global_scope2.default.PDFJS) {
  13549. _global_scope2.default.PDFJS = {};
  13550. }
  13551. var PDFJS = _global_scope2.default.PDFJS;
  13552. {
  13553. PDFJS.version = '1.10.88';
  13554. PDFJS.build = 'c62a1938';
  13555. }
  13556. PDFJS.pdfBug = false;
  13557. if (PDFJS.verbosity !== undefined) {
  13558. (0, _util.setVerbosityLevel)(PDFJS.verbosity);
  13559. }
  13560. delete PDFJS.verbosity;
  13561. Object.defineProperty(PDFJS, 'verbosity', {
  13562. get: function get() {
  13563. return (0, _util.getVerbosityLevel)();
  13564. },
  13565. set: function set(level) {
  13566. (0, _util.setVerbosityLevel)(level);
  13567. },
  13568. enumerable: true,
  13569. configurable: true
  13570. });
  13571. PDFJS.VERBOSITY_LEVELS = _util.VERBOSITY_LEVELS;
  13572. PDFJS.OPS = _util.OPS;
  13573. PDFJS.UNSUPPORTED_FEATURES = _util.UNSUPPORTED_FEATURES;
  13574. PDFJS.isValidUrl = _dom_utils.isValidUrl;
  13575. PDFJS.shadow = _util.shadow;
  13576. PDFJS.createBlob = _util.createBlob;
  13577. PDFJS.createObjectURL = function PDFJS_createObjectURL(data, contentType) {
  13578. return (0, _util.createObjectURL)(data, contentType, PDFJS.disableCreateObjectURL);
  13579. };
  13580. Object.defineProperty(PDFJS, 'isLittleEndian', {
  13581. configurable: true,
  13582. get: function PDFJS_isLittleEndian() {
  13583. return (0, _util.shadow)(PDFJS, 'isLittleEndian', (0, _util.isLittleEndian)());
  13584. }
  13585. });
  13586. PDFJS.removeNullCharacters = _util.removeNullCharacters;
  13587. PDFJS.PasswordResponses = _util.PasswordResponses;
  13588. PDFJS.PasswordException = _util.PasswordException;
  13589. PDFJS.UnknownErrorException = _util.UnknownErrorException;
  13590. PDFJS.InvalidPDFException = _util.InvalidPDFException;
  13591. PDFJS.MissingPDFException = _util.MissingPDFException;
  13592. PDFJS.UnexpectedResponseException = _util.UnexpectedResponseException;
  13593. PDFJS.Util = _util.Util;
  13594. PDFJS.PageViewport = _util.PageViewport;
  13595. PDFJS.createPromiseCapability = _util.createPromiseCapability;
  13596. PDFJS.maxImageSize = PDFJS.maxImageSize === undefined ? -1 : PDFJS.maxImageSize;
  13597. PDFJS.cMapUrl = PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl;
  13598. PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked;
  13599. PDFJS.disableFontFace = PDFJS.disableFontFace === undefined ? false : PDFJS.disableFontFace;
  13600. PDFJS.imageResourcesPath = PDFJS.imageResourcesPath === undefined ? '' : PDFJS.imageResourcesPath;
  13601. PDFJS.disableWorker = PDFJS.disableWorker === undefined ? false : PDFJS.disableWorker;
  13602. PDFJS.workerSrc = PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc;
  13603. PDFJS.workerPort = PDFJS.workerPort === undefined ? null : PDFJS.workerPort;
  13604. PDFJS.disableRange = PDFJS.disableRange === undefined ? false : PDFJS.disableRange;
  13605. PDFJS.disableStream = PDFJS.disableStream === undefined ? false : PDFJS.disableStream;
  13606. PDFJS.disableAutoFetch = PDFJS.disableAutoFetch === undefined ? false : PDFJS.disableAutoFetch;
  13607. PDFJS.pdfBug = PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug;
  13608. PDFJS.postMessageTransfers = PDFJS.postMessageTransfers === undefined ? true : PDFJS.postMessageTransfers;
  13609. PDFJS.disableCreateObjectURL = PDFJS.disableCreateObjectURL === undefined ? false : PDFJS.disableCreateObjectURL;
  13610. PDFJS.disableWebGL = PDFJS.disableWebGL === undefined ? true : PDFJS.disableWebGL;
  13611. PDFJS.externalLinkTarget = PDFJS.externalLinkTarget === undefined ? _dom_utils.LinkTarget.NONE : PDFJS.externalLinkTarget;
  13612. PDFJS.externalLinkRel = PDFJS.externalLinkRel === undefined ? _dom_utils.DEFAULT_LINK_REL : PDFJS.externalLinkRel;
  13613. PDFJS.isEvalSupported = PDFJS.isEvalSupported === undefined ? true : PDFJS.isEvalSupported;
  13614. PDFJS.pdfjsNext = PDFJS.pdfjsNext === undefined ? false : PDFJS.pdfjsNext;
  13615. {
  13616. var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow;
  13617. delete PDFJS.openExternalLinksInNewWindow;
  13618. Object.defineProperty(PDFJS, 'openExternalLinksInNewWindow', {
  13619. get: function get() {
  13620. return PDFJS.externalLinkTarget === _dom_utils.LinkTarget.BLANK;
  13621. },
  13622. set: function set(value) {
  13623. if (value) {
  13624. (0, _util.deprecated)('PDFJS.openExternalLinksInNewWindow, please use ' + '"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.');
  13625. }
  13626. if (PDFJS.externalLinkTarget !== _dom_utils.LinkTarget.NONE) {
  13627. (0, _util.warn)('PDFJS.externalLinkTarget is already initialized');
  13628. return;
  13629. }
  13630. PDFJS.externalLinkTarget = value ? _dom_utils.LinkTarget.BLANK : _dom_utils.LinkTarget.NONE;
  13631. },
  13632. enumerable: true,
  13633. configurable: true
  13634. });
  13635. if (savedOpenExternalLinksInNewWindow) {
  13636. PDFJS.openExternalLinksInNewWindow = savedOpenExternalLinksInNewWindow;
  13637. }
  13638. }
  13639. PDFJS.getDocument = _api.getDocument;
  13640. PDFJS.LoopbackPort = _api.LoopbackPort;
  13641. PDFJS.PDFDataRangeTransport = _api.PDFDataRangeTransport;
  13642. PDFJS.PDFWorker = _api.PDFWorker;
  13643. PDFJS.hasCanvasTypedArrays = true;
  13644. PDFJS.CustomStyle = _dom_utils.CustomStyle;
  13645. PDFJS.LinkTarget = _dom_utils.LinkTarget;
  13646. PDFJS.addLinkAttributes = _dom_utils.addLinkAttributes;
  13647. PDFJS.getFilenameFromUrl = _dom_utils.getFilenameFromUrl;
  13648. PDFJS.isExternalLinkTargetSet = _dom_utils.isExternalLinkTargetSet;
  13649. PDFJS.AnnotationLayer = _annotation_layer.AnnotationLayer;
  13650. PDFJS.renderTextLayer = _text_layer.renderTextLayer;
  13651. PDFJS.Metadata = _metadata.Metadata;
  13652. PDFJS.SVGGraphics = _svg.SVGGraphics;
  13653. PDFJS.UnsupportedManager = _api._UnsupportedManager;
  13654. exports.globalScope = _global_scope2.default;
  13655. exports.PDFJS = PDFJS;
  13656. /***/ }),
  13657. /* 118 */
  13658. /***/ (function(module, exports, __w_pdfjs_require__) {
  13659. "use strict";
  13660. Object.defineProperty(exports, "__esModule", {
  13661. value: true
  13662. });
  13663. exports.FontLoader = exports.FontFaceObject = undefined;
  13664. var _util = __w_pdfjs_require__(0);
  13665. function FontLoader(docId) {
  13666. this.docId = docId;
  13667. this.styleElement = null;
  13668. this.nativeFontFaces = [];
  13669. this.loadTestFontId = 0;
  13670. this.loadingContext = {
  13671. requests: [],
  13672. nextRequestId: 0
  13673. };
  13674. }
  13675. FontLoader.prototype = {
  13676. insertRule: function fontLoaderInsertRule(rule) {
  13677. var styleElement = this.styleElement;
  13678. if (!styleElement) {
  13679. styleElement = this.styleElement = document.createElement('style');
  13680. styleElement.id = 'PDFJS_FONT_STYLE_TAG_' + this.docId;
  13681. document.documentElement.getElementsByTagName('head')[0].appendChild(styleElement);
  13682. }
  13683. var styleSheet = styleElement.sheet;
  13684. styleSheet.insertRule(rule, styleSheet.cssRules.length);
  13685. },
  13686. clear: function fontLoaderClear() {
  13687. if (this.styleElement) {
  13688. this.styleElement.remove();
  13689. this.styleElement = null;
  13690. }
  13691. this.nativeFontFaces.forEach(function (nativeFontFace) {
  13692. document.fonts.delete(nativeFontFace);
  13693. });
  13694. this.nativeFontFaces.length = 0;
  13695. }
  13696. };
  13697. {
  13698. var getLoadTestFont = function getLoadTestFont() {
  13699. return atob('T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQ' + 'AABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwA' + 'AAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbm' + 'FtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAA' + 'AADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6A' + 'ABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAA' + 'MQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAA' + 'AAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAA' + 'AAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQ' + 'AAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMA' + 'AQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAA' + 'EAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAA' + 'AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAA' + 'AAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgc' + 'A/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWF' + 'hYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQA' + 'AAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAg' + 'ABAAAAAAAAAAAD6AAAAAAAAA==');
  13700. };
  13701. Object.defineProperty(FontLoader.prototype, 'loadTestFont', {
  13702. get: function get() {
  13703. return (0, _util.shadow)(this, 'loadTestFont', getLoadTestFont());
  13704. },
  13705. configurable: true
  13706. });
  13707. FontLoader.prototype.addNativeFontFace = function fontLoader_addNativeFontFace(nativeFontFace) {
  13708. this.nativeFontFaces.push(nativeFontFace);
  13709. document.fonts.add(nativeFontFace);
  13710. };
  13711. FontLoader.prototype.bind = function fontLoaderBind(fonts, callback) {
  13712. var rules = [];
  13713. var fontsToLoad = [];
  13714. var fontLoadPromises = [];
  13715. var getNativeFontPromise = function getNativeFontPromise(nativeFontFace) {
  13716. return nativeFontFace.loaded.catch(function (e) {
  13717. (0, _util.warn)('Failed to load font "' + nativeFontFace.family + '": ' + e);
  13718. });
  13719. };
  13720. var isFontLoadingAPISupported = FontLoader.isFontLoadingAPISupported && !FontLoader.isSyncFontLoadingSupported;
  13721. for (var i = 0, ii = fonts.length; i < ii; i++) {
  13722. var font = fonts[i];
  13723. if (font.attached || font.loading === false) {
  13724. continue;
  13725. }
  13726. font.attached = true;
  13727. if (isFontLoadingAPISupported) {
  13728. var nativeFontFace = font.createNativeFontFace();
  13729. if (nativeFontFace) {
  13730. this.addNativeFontFace(nativeFontFace);
  13731. fontLoadPromises.push(getNativeFontPromise(nativeFontFace));
  13732. }
  13733. } else {
  13734. var rule = font.createFontFaceRule();
  13735. if (rule) {
  13736. this.insertRule(rule);
  13737. rules.push(rule);
  13738. fontsToLoad.push(font);
  13739. }
  13740. }
  13741. }
  13742. var request = this.queueLoadingCallback(callback);
  13743. if (isFontLoadingAPISupported) {
  13744. Promise.all(fontLoadPromises).then(function () {
  13745. request.complete();
  13746. });
  13747. } else if (rules.length > 0 && !FontLoader.isSyncFontLoadingSupported) {
  13748. this.prepareFontLoadEvent(rules, fontsToLoad, request);
  13749. } else {
  13750. request.complete();
  13751. }
  13752. };
  13753. FontLoader.prototype.queueLoadingCallback = function FontLoader_queueLoadingCallback(callback) {
  13754. function LoadLoader_completeRequest() {
  13755. (0, _util.assert)(!request.end, 'completeRequest() cannot be called twice');
  13756. request.end = Date.now();
  13757. while (context.requests.length > 0 && context.requests[0].end) {
  13758. var otherRequest = context.requests.shift();
  13759. setTimeout(otherRequest.callback, 0);
  13760. }
  13761. }
  13762. var context = this.loadingContext;
  13763. var requestId = 'pdfjs-font-loading-' + context.nextRequestId++;
  13764. var request = {
  13765. id: requestId,
  13766. complete: LoadLoader_completeRequest,
  13767. callback: callback,
  13768. started: Date.now()
  13769. };
  13770. context.requests.push(request);
  13771. return request;
  13772. };
  13773. FontLoader.prototype.prepareFontLoadEvent = function fontLoaderPrepareFontLoadEvent(rules, fonts, request) {
  13774. function int32(data, offset) {
  13775. return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff;
  13776. }
  13777. function spliceString(s, offset, remove, insert) {
  13778. var chunk1 = s.substr(0, offset);
  13779. var chunk2 = s.substr(offset + remove);
  13780. return chunk1 + insert + chunk2;
  13781. }
  13782. var i, ii;
  13783. var canvas = document.createElement('canvas');
  13784. canvas.width = 1;
  13785. canvas.height = 1;
  13786. var ctx = canvas.getContext('2d');
  13787. var called = 0;
  13788. function isFontReady(name, callback) {
  13789. called++;
  13790. if (called > 30) {
  13791. (0, _util.warn)('Load test font never loaded.');
  13792. callback();
  13793. return;
  13794. }
  13795. ctx.font = '30px ' + name;
  13796. ctx.fillText('.', 0, 20);
  13797. var imageData = ctx.getImageData(0, 0, 1, 1);
  13798. if (imageData.data[3] > 0) {
  13799. callback();
  13800. return;
  13801. }
  13802. setTimeout(isFontReady.bind(null, name, callback));
  13803. }
  13804. var loadTestFontId = 'lt' + Date.now() + this.loadTestFontId++;
  13805. var data = this.loadTestFont;
  13806. var COMMENT_OFFSET = 976;
  13807. data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId);
  13808. var CFF_CHECKSUM_OFFSET = 16;
  13809. var XXXX_VALUE = 0x58585858;
  13810. var checksum = int32(data, CFF_CHECKSUM_OFFSET);
  13811. for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
  13812. checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0;
  13813. }
  13814. if (i < loadTestFontId.length) {
  13815. checksum = checksum - XXXX_VALUE + int32(loadTestFontId + 'XXX', i) | 0;
  13816. }
  13817. data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, (0, _util.string32)(checksum));
  13818. var url = 'url(data:font/opentype;base64,' + btoa(data) + ');';
  13819. var rule = '@font-face { font-family:"' + loadTestFontId + '";src:' + url + '}';
  13820. this.insertRule(rule);
  13821. var names = [];
  13822. for (i = 0, ii = fonts.length; i < ii; i++) {
  13823. names.push(fonts[i].loadedName);
  13824. }
  13825. names.push(loadTestFontId);
  13826. var div = document.createElement('div');
  13827. div.setAttribute('style', 'visibility: hidden;' + 'width: 10px; height: 10px;' + 'position: absolute; top: 0px; left: 0px;');
  13828. for (i = 0, ii = names.length; i < ii; ++i) {
  13829. var span = document.createElement('span');
  13830. span.textContent = 'Hi';
  13831. span.style.fontFamily = names[i];
  13832. div.appendChild(span);
  13833. }
  13834. document.body.appendChild(div);
  13835. isFontReady(loadTestFontId, function () {
  13836. document.body.removeChild(div);
  13837. request.complete();
  13838. });
  13839. };
  13840. }
  13841. {
  13842. FontLoader.isFontLoadingAPISupported = typeof document !== 'undefined' && !!document.fonts;
  13843. }
  13844. {
  13845. var isSyncFontLoadingSupported = function isSyncFontLoadingSupported() {
  13846. if (typeof navigator === 'undefined') {
  13847. return true;
  13848. }
  13849. var supported = false;
  13850. var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
  13851. if (m && m[1] >= 14) {
  13852. supported = true;
  13853. }
  13854. return supported;
  13855. };
  13856. Object.defineProperty(FontLoader, 'isSyncFontLoadingSupported', {
  13857. get: function get() {
  13858. return (0, _util.shadow)(FontLoader, 'isSyncFontLoadingSupported', isSyncFontLoadingSupported());
  13859. },
  13860. enumerable: true,
  13861. configurable: true
  13862. });
  13863. }
  13864. var IsEvalSupportedCached = {
  13865. get value() {
  13866. return (0, _util.shadow)(this, 'value', (0, _util.isEvalSupported)());
  13867. }
  13868. };
  13869. var FontFaceObject = function FontFaceObjectClosure() {
  13870. function FontFaceObject(translatedData, options) {
  13871. this.compiledGlyphs = Object.create(null);
  13872. for (var i in translatedData) {
  13873. this[i] = translatedData[i];
  13874. }
  13875. this.options = options;
  13876. }
  13877. FontFaceObject.prototype = {
  13878. createNativeFontFace: function FontFaceObject_createNativeFontFace() {
  13879. if (!this.data) {
  13880. return null;
  13881. }
  13882. if (this.options.disableFontFace) {
  13883. this.disableFontFace = true;
  13884. return null;
  13885. }
  13886. var nativeFontFace = new FontFace(this.loadedName, this.data, {});
  13887. if (this.options.fontRegistry) {
  13888. this.options.fontRegistry.registerFont(this);
  13889. }
  13890. return nativeFontFace;
  13891. },
  13892. createFontFaceRule: function FontFaceObject_createFontFaceRule() {
  13893. if (!this.data) {
  13894. return null;
  13895. }
  13896. if (this.options.disableFontFace) {
  13897. this.disableFontFace = true;
  13898. return null;
  13899. }
  13900. var data = (0, _util.bytesToString)(new Uint8Array(this.data));
  13901. var fontName = this.loadedName;
  13902. var url = 'url(data:' + this.mimetype + ';base64,' + btoa(data) + ');';
  13903. var rule = '@font-face { font-family:"' + fontName + '";src:' + url + '}';
  13904. if (this.options.fontRegistry) {
  13905. this.options.fontRegistry.registerFont(this, url);
  13906. }
  13907. return rule;
  13908. },
  13909. getPathGenerator: function FontFaceObject_getPathGenerator(objs, character) {
  13910. if (!(character in this.compiledGlyphs)) {
  13911. var cmds = objs.get(this.loadedName + '_path_' + character);
  13912. var current, i, len;
  13913. if (this.options.isEvalSupported && IsEvalSupportedCached.value) {
  13914. var args,
  13915. js = '';
  13916. for (i = 0, len = cmds.length; i < len; i++) {
  13917. current = cmds[i];
  13918. if (current.args !== undefined) {
  13919. args = current.args.join(',');
  13920. } else {
  13921. args = '';
  13922. }
  13923. js += 'c.' + current.cmd + '(' + args + ');\n';
  13924. }
  13925. this.compiledGlyphs[character] = new Function('c', 'size', js);
  13926. } else {
  13927. this.compiledGlyphs[character] = function (c, size) {
  13928. for (i = 0, len = cmds.length; i < len; i++) {
  13929. current = cmds[i];
  13930. if (current.cmd === 'scale') {
  13931. current.args = [size, -size];
  13932. }
  13933. c[current.cmd].apply(c, current.args);
  13934. }
  13935. };
  13936. }
  13937. }
  13938. return this.compiledGlyphs[character];
  13939. }
  13940. };
  13941. return FontFaceObject;
  13942. }();
  13943. exports.FontFaceObject = FontFaceObject;
  13944. exports.FontLoader = FontLoader;
  13945. /***/ }),
  13946. /* 119 */
  13947. /***/ (function(module, exports, __w_pdfjs_require__) {
  13948. "use strict";
  13949. Object.defineProperty(exports, "__esModule", {
  13950. value: true
  13951. });
  13952. exports.CanvasGraphics = undefined;
  13953. var _util = __w_pdfjs_require__(0);
  13954. var _pattern_helper = __w_pdfjs_require__(120);
  13955. var _webgl = __w_pdfjs_require__(70);
  13956. var MIN_FONT_SIZE = 16;
  13957. var MAX_FONT_SIZE = 100;
  13958. var MAX_GROUP_SIZE = 4096;
  13959. var MIN_WIDTH_FACTOR = 0.65;
  13960. var COMPILE_TYPE3_GLYPHS = true;
  13961. var MAX_SIZE_TO_COMPILE = 1000;
  13962. var FULL_CHUNK_HEIGHT = 16;
  13963. var IsLittleEndianCached = {
  13964. get value() {
  13965. return (0, _util.shadow)(IsLittleEndianCached, 'value', (0, _util.isLittleEndian)());
  13966. }
  13967. };
  13968. function addContextCurrentTransform(ctx) {
  13969. if (!ctx.mozCurrentTransform) {
  13970. ctx._originalSave = ctx.save;
  13971. ctx._originalRestore = ctx.restore;
  13972. ctx._originalRotate = ctx.rotate;
  13973. ctx._originalScale = ctx.scale;
  13974. ctx._originalTranslate = ctx.translate;
  13975. ctx._originalTransform = ctx.transform;
  13976. ctx._originalSetTransform = ctx.setTransform;
  13977. ctx._transformMatrix = ctx._transformMatrix || [1, 0, 0, 1, 0, 0];
  13978. ctx._transformStack = [];
  13979. Object.defineProperty(ctx, 'mozCurrentTransform', {
  13980. get: function getCurrentTransform() {
  13981. return this._transformMatrix;
  13982. }
  13983. });
  13984. Object.defineProperty(ctx, 'mozCurrentTransformInverse', {
  13985. get: function getCurrentTransformInverse() {
  13986. var m = this._transformMatrix;
  13987. var a = m[0],
  13988. b = m[1],
  13989. c = m[2],
  13990. d = m[3],
  13991. e = m[4],
  13992. f = m[5];
  13993. var ad_bc = a * d - b * c;
  13994. var bc_ad = b * c - a * d;
  13995. return [d / ad_bc, b / bc_ad, c / bc_ad, a / ad_bc, (d * e - c * f) / bc_ad, (b * e - a * f) / ad_bc];
  13996. }
  13997. });
  13998. ctx.save = function ctxSave() {
  13999. var old = this._transformMatrix;
  14000. this._transformStack.push(old);
  14001. this._transformMatrix = old.slice(0, 6);
  14002. this._originalSave();
  14003. };
  14004. ctx.restore = function ctxRestore() {
  14005. var prev = this._transformStack.pop();
  14006. if (prev) {
  14007. this._transformMatrix = prev;
  14008. this._originalRestore();
  14009. }
  14010. };
  14011. ctx.translate = function ctxTranslate(x, y) {
  14012. var m = this._transformMatrix;
  14013. m[4] = m[0] * x + m[2] * y + m[4];
  14014. m[5] = m[1] * x + m[3] * y + m[5];
  14015. this._originalTranslate(x, y);
  14016. };
  14017. ctx.scale = function ctxScale(x, y) {
  14018. var m = this._transformMatrix;
  14019. m[0] = m[0] * x;
  14020. m[1] = m[1] * x;
  14021. m[2] = m[2] * y;
  14022. m[3] = m[3] * y;
  14023. this._originalScale(x, y);
  14024. };
  14025. ctx.transform = function ctxTransform(a, b, c, d, e, f) {
  14026. var m = this._transformMatrix;
  14027. this._transformMatrix = [m[0] * a + m[2] * b, m[1] * a + m[3] * b, m[0] * c + m[2] * d, m[1] * c + m[3] * d, m[0] * e + m[2] * f + m[4], m[1] * e + m[3] * f + m[5]];
  14028. ctx._originalTransform(a, b, c, d, e, f);
  14029. };
  14030. ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
  14031. this._transformMatrix = [a, b, c, d, e, f];
  14032. ctx._originalSetTransform(a, b, c, d, e, f);
  14033. };
  14034. ctx.rotate = function ctxRotate(angle) {
  14035. var cosValue = Math.cos(angle);
  14036. var sinValue = Math.sin(angle);
  14037. var m = this._transformMatrix;
  14038. this._transformMatrix = [m[0] * cosValue + m[2] * sinValue, m[1] * cosValue + m[3] * sinValue, m[0] * -sinValue + m[2] * cosValue, m[1] * -sinValue + m[3] * cosValue, m[4], m[5]];
  14039. this._originalRotate(angle);
  14040. };
  14041. }
  14042. }
  14043. var CachedCanvases = function CachedCanvasesClosure() {
  14044. function CachedCanvases(canvasFactory) {
  14045. this.canvasFactory = canvasFactory;
  14046. this.cache = Object.create(null);
  14047. }
  14048. CachedCanvases.prototype = {
  14049. getCanvas: function CachedCanvases_getCanvas(id, width, height, trackTransform) {
  14050. var canvasEntry;
  14051. if (this.cache[id] !== undefined) {
  14052. canvasEntry = this.cache[id];
  14053. this.canvasFactory.reset(canvasEntry, width, height);
  14054. canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0);
  14055. } else {
  14056. canvasEntry = this.canvasFactory.create(width, height);
  14057. this.cache[id] = canvasEntry;
  14058. }
  14059. if (trackTransform) {
  14060. addContextCurrentTransform(canvasEntry.context);
  14061. }
  14062. return canvasEntry;
  14063. },
  14064. clear: function clear() {
  14065. for (var id in this.cache) {
  14066. var canvasEntry = this.cache[id];
  14067. this.canvasFactory.destroy(canvasEntry);
  14068. delete this.cache[id];
  14069. }
  14070. }
  14071. };
  14072. return CachedCanvases;
  14073. }();
  14074. function compileType3Glyph(imgData) {
  14075. var POINT_TO_PROCESS_LIMIT = 1000;
  14076. var width = imgData.width,
  14077. height = imgData.height;
  14078. var i,
  14079. j,
  14080. j0,
  14081. width1 = width + 1;
  14082. var points = new Uint8Array(width1 * (height + 1));
  14083. var POINT_TYPES = new Uint8Array([0, 2, 4, 0, 1, 0, 5, 4, 8, 10, 0, 8, 0, 2, 1, 0]);
  14084. var lineSize = width + 7 & ~7,
  14085. data0 = imgData.data;
  14086. var data = new Uint8Array(lineSize * height),
  14087. pos = 0,
  14088. ii;
  14089. for (i = 0, ii = data0.length; i < ii; i++) {
  14090. var mask = 128,
  14091. elem = data0[i];
  14092. while (mask > 0) {
  14093. data[pos++] = elem & mask ? 0 : 255;
  14094. mask >>= 1;
  14095. }
  14096. }
  14097. var count = 0;
  14098. pos = 0;
  14099. if (data[pos] !== 0) {
  14100. points[0] = 1;
  14101. ++count;
  14102. }
  14103. for (j = 1; j < width; j++) {
  14104. if (data[pos] !== data[pos + 1]) {
  14105. points[j] = data[pos] ? 2 : 1;
  14106. ++count;
  14107. }
  14108. pos++;
  14109. }
  14110. if (data[pos] !== 0) {
  14111. points[j] = 2;
  14112. ++count;
  14113. }
  14114. for (i = 1; i < height; i++) {
  14115. pos = i * lineSize;
  14116. j0 = i * width1;
  14117. if (data[pos - lineSize] !== data[pos]) {
  14118. points[j0] = data[pos] ? 1 : 8;
  14119. ++count;
  14120. }
  14121. var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
  14122. for (j = 1; j < width; j++) {
  14123. sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
  14124. if (POINT_TYPES[sum]) {
  14125. points[j0 + j] = POINT_TYPES[sum];
  14126. ++count;
  14127. }
  14128. pos++;
  14129. }
  14130. if (data[pos - lineSize] !== data[pos]) {
  14131. points[j0 + j] = data[pos] ? 2 : 4;
  14132. ++count;
  14133. }
  14134. if (count > POINT_TO_PROCESS_LIMIT) {
  14135. return null;
  14136. }
  14137. }
  14138. pos = lineSize * (height - 1);
  14139. j0 = i * width1;
  14140. if (data[pos] !== 0) {
  14141. points[j0] = 8;
  14142. ++count;
  14143. }
  14144. for (j = 1; j < width; j++) {
  14145. if (data[pos] !== data[pos + 1]) {
  14146. points[j0 + j] = data[pos] ? 4 : 8;
  14147. ++count;
  14148. }
  14149. pos++;
  14150. }
  14151. if (data[pos] !== 0) {
  14152. points[j0 + j] = 4;
  14153. ++count;
  14154. }
  14155. if (count > POINT_TO_PROCESS_LIMIT) {
  14156. return null;
  14157. }
  14158. var steps = new Int32Array([0, width1, -1, 0, -width1, 0, 0, 0, 1]);
  14159. var outlines = [];
  14160. for (i = 0; count && i <= height; i++) {
  14161. var p = i * width1;
  14162. var end = p + width;
  14163. while (p < end && !points[p]) {
  14164. p++;
  14165. }
  14166. if (p === end) {
  14167. continue;
  14168. }
  14169. var coords = [p % width1, i];
  14170. var type = points[p],
  14171. p0 = p,
  14172. pp;
  14173. do {
  14174. var step = steps[type];
  14175. do {
  14176. p += step;
  14177. } while (!points[p]);
  14178. pp = points[p];
  14179. if (pp !== 5 && pp !== 10) {
  14180. type = pp;
  14181. points[p] = 0;
  14182. } else {
  14183. type = pp & 0x33 * type >> 4;
  14184. points[p] &= type >> 2 | type << 2;
  14185. }
  14186. coords.push(p % width1);
  14187. coords.push(p / width1 | 0);
  14188. --count;
  14189. } while (p0 !== p);
  14190. outlines.push(coords);
  14191. --i;
  14192. }
  14193. var drawOutline = function drawOutline(c) {
  14194. c.save();
  14195. c.scale(1 / width, -1 / height);
  14196. c.translate(0, -height);
  14197. c.beginPath();
  14198. for (var i = 0, ii = outlines.length; i < ii; i++) {
  14199. var o = outlines[i];
  14200. c.moveTo(o[0], o[1]);
  14201. for (var j = 2, jj = o.length; j < jj; j += 2) {
  14202. c.lineTo(o[j], o[j + 1]);
  14203. }
  14204. }
  14205. c.fill();
  14206. c.beginPath();
  14207. c.restore();
  14208. };
  14209. return drawOutline;
  14210. }
  14211. var CanvasExtraState = function CanvasExtraStateClosure() {
  14212. function CanvasExtraState() {
  14213. this.alphaIsShape = false;
  14214. this.fontSize = 0;
  14215. this.fontSizeScale = 1;
  14216. this.textMatrix = _util.IDENTITY_MATRIX;
  14217. this.textMatrixScale = 1;
  14218. this.fontMatrix = _util.FONT_IDENTITY_MATRIX;
  14219. this.leading = 0;
  14220. this.x = 0;
  14221. this.y = 0;
  14222. this.lineX = 0;
  14223. this.lineY = 0;
  14224. this.charSpacing = 0;
  14225. this.wordSpacing = 0;
  14226. this.textHScale = 1;
  14227. this.textRenderingMode = _util.TextRenderingMode.FILL;
  14228. this.textRise = 0;
  14229. this.fillColor = '#000000';
  14230. this.strokeColor = '#000000';
  14231. this.patternFill = false;
  14232. this.fillAlpha = 1;
  14233. this.strokeAlpha = 1;
  14234. this.lineWidth = 1;
  14235. this.activeSMask = null;
  14236. this.resumeSMaskCtx = null;
  14237. }
  14238. CanvasExtraState.prototype = {
  14239. clone: function CanvasExtraState_clone() {
  14240. return Object.create(this);
  14241. },
  14242. setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) {
  14243. this.x = x;
  14244. this.y = y;
  14245. }
  14246. };
  14247. return CanvasExtraState;
  14248. }();
  14249. var CanvasGraphics = function CanvasGraphicsClosure() {
  14250. var EXECUTION_TIME = 15;
  14251. var EXECUTION_STEPS = 10;
  14252. function CanvasGraphics(canvasCtx, commonObjs, objs, canvasFactory, imageLayer) {
  14253. this.ctx = canvasCtx;
  14254. this.current = new CanvasExtraState();
  14255. this.stateStack = [];
  14256. this.pendingClip = null;
  14257. this.pendingEOFill = false;
  14258. this.res = null;
  14259. this.xobjs = null;
  14260. this.commonObjs = commonObjs;
  14261. this.objs = objs;
  14262. this.canvasFactory = canvasFactory;
  14263. this.imageLayer = imageLayer;
  14264. this.groupStack = [];
  14265. this.processingType3 = null;
  14266. this.baseTransform = null;
  14267. this.baseTransformStack = [];
  14268. this.groupLevel = 0;
  14269. this.smaskStack = [];
  14270. this.smaskCounter = 0;
  14271. this.tempSMask = null;
  14272. this.cachedCanvases = new CachedCanvases(this.canvasFactory);
  14273. if (canvasCtx) {
  14274. addContextCurrentTransform(canvasCtx);
  14275. }
  14276. this.cachedGetSinglePixelWidth = null;
  14277. }
  14278. function putBinaryImageData(ctx, imgData) {
  14279. if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) {
  14280. ctx.putImageData(imgData, 0, 0);
  14281. return;
  14282. }
  14283. var height = imgData.height,
  14284. width = imgData.width;
  14285. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  14286. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  14287. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  14288. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  14289. var srcPos = 0,
  14290. destPos;
  14291. var src = imgData.data;
  14292. var dest = chunkImgData.data;
  14293. var i, j, thisChunkHeight, elemsInThisChunk;
  14294. if (imgData.kind === _util.ImageKind.GRAYSCALE_1BPP) {
  14295. var srcLength = src.byteLength;
  14296. var dest32 = new Uint32Array(dest.buffer, 0, dest.byteLength >> 2);
  14297. var dest32DataLength = dest32.length;
  14298. var fullSrcDiff = width + 7 >> 3;
  14299. var white = 0xFFFFFFFF;
  14300. var black = IsLittleEndianCached.value ? 0xFF000000 : 0x000000FF;
  14301. for (i = 0; i < totalChunks; i++) {
  14302. thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  14303. destPos = 0;
  14304. for (j = 0; j < thisChunkHeight; j++) {
  14305. var srcDiff = srcLength - srcPos;
  14306. var k = 0;
  14307. var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
  14308. var kEndUnrolled = kEnd & ~7;
  14309. var mask = 0;
  14310. var srcByte = 0;
  14311. for (; k < kEndUnrolled; k += 8) {
  14312. srcByte = src[srcPos++];
  14313. dest32[destPos++] = srcByte & 128 ? white : black;
  14314. dest32[destPos++] = srcByte & 64 ? white : black;
  14315. dest32[destPos++] = srcByte & 32 ? white : black;
  14316. dest32[destPos++] = srcByte & 16 ? white : black;
  14317. dest32[destPos++] = srcByte & 8 ? white : black;
  14318. dest32[destPos++] = srcByte & 4 ? white : black;
  14319. dest32[destPos++] = srcByte & 2 ? white : black;
  14320. dest32[destPos++] = srcByte & 1 ? white : black;
  14321. }
  14322. for (; k < kEnd; k++) {
  14323. if (mask === 0) {
  14324. srcByte = src[srcPos++];
  14325. mask = 128;
  14326. }
  14327. dest32[destPos++] = srcByte & mask ? white : black;
  14328. mask >>= 1;
  14329. }
  14330. }
  14331. while (destPos < dest32DataLength) {
  14332. dest32[destPos++] = 0;
  14333. }
  14334. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  14335. }
  14336. } else if (imgData.kind === _util.ImageKind.RGBA_32BPP) {
  14337. j = 0;
  14338. elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
  14339. for (i = 0; i < fullChunks; i++) {
  14340. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  14341. srcPos += elemsInThisChunk;
  14342. ctx.putImageData(chunkImgData, 0, j);
  14343. j += FULL_CHUNK_HEIGHT;
  14344. }
  14345. if (i < totalChunks) {
  14346. elemsInThisChunk = width * partialChunkHeight * 4;
  14347. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  14348. ctx.putImageData(chunkImgData, 0, j);
  14349. }
  14350. } else if (imgData.kind === _util.ImageKind.RGB_24BPP) {
  14351. thisChunkHeight = FULL_CHUNK_HEIGHT;
  14352. elemsInThisChunk = width * thisChunkHeight;
  14353. for (i = 0; i < totalChunks; i++) {
  14354. if (i >= fullChunks) {
  14355. thisChunkHeight = partialChunkHeight;
  14356. elemsInThisChunk = width * thisChunkHeight;
  14357. }
  14358. destPos = 0;
  14359. for (j = elemsInThisChunk; j--;) {
  14360. dest[destPos++] = src[srcPos++];
  14361. dest[destPos++] = src[srcPos++];
  14362. dest[destPos++] = src[srcPos++];
  14363. dest[destPos++] = 255;
  14364. }
  14365. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  14366. }
  14367. } else {
  14368. throw new Error('bad image kind: ' + imgData.kind);
  14369. }
  14370. }
  14371. function putBinaryImageMask(ctx, imgData) {
  14372. var height = imgData.height,
  14373. width = imgData.width;
  14374. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  14375. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  14376. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  14377. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  14378. var srcPos = 0;
  14379. var src = imgData.data;
  14380. var dest = chunkImgData.data;
  14381. for (var i = 0; i < totalChunks; i++) {
  14382. var thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  14383. var destPos = 3;
  14384. for (var j = 0; j < thisChunkHeight; j++) {
  14385. var mask = 0;
  14386. for (var k = 0; k < width; k++) {
  14387. if (!mask) {
  14388. var elem = src[srcPos++];
  14389. mask = 128;
  14390. }
  14391. dest[destPos] = elem & mask ? 0 : 255;
  14392. destPos += 4;
  14393. mask >>= 1;
  14394. }
  14395. }
  14396. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  14397. }
  14398. }
  14399. function copyCtxState(sourceCtx, destCtx) {
  14400. var properties = ['strokeStyle', 'fillStyle', 'fillRule', 'globalAlpha', 'lineWidth', 'lineCap', 'lineJoin', 'miterLimit', 'globalCompositeOperation', 'font'];
  14401. for (var i = 0, ii = properties.length; i < ii; i++) {
  14402. var property = properties[i];
  14403. if (sourceCtx[property] !== undefined) {
  14404. destCtx[property] = sourceCtx[property];
  14405. }
  14406. }
  14407. if (sourceCtx.setLineDash !== undefined) {
  14408. destCtx.setLineDash(sourceCtx.getLineDash());
  14409. destCtx.lineDashOffset = sourceCtx.lineDashOffset;
  14410. }
  14411. }
  14412. function resetCtxToDefault(ctx) {
  14413. ctx.strokeStyle = '#000000';
  14414. ctx.fillStyle = '#000000';
  14415. ctx.fillRule = 'nonzero';
  14416. ctx.globalAlpha = 1;
  14417. ctx.lineWidth = 1;
  14418. ctx.lineCap = 'butt';
  14419. ctx.lineJoin = 'miter';
  14420. ctx.miterLimit = 10;
  14421. ctx.globalCompositeOperation = 'source-over';
  14422. ctx.font = '10px sans-serif';
  14423. if (ctx.setLineDash !== undefined) {
  14424. ctx.setLineDash([]);
  14425. ctx.lineDashOffset = 0;
  14426. }
  14427. }
  14428. function composeSMaskBackdrop(bytes, r0, g0, b0) {
  14429. var length = bytes.length;
  14430. for (var i = 3; i < length; i += 4) {
  14431. var alpha = bytes[i];
  14432. if (alpha === 0) {
  14433. bytes[i - 3] = r0;
  14434. bytes[i - 2] = g0;
  14435. bytes[i - 1] = b0;
  14436. } else if (alpha < 255) {
  14437. var alpha_ = 255 - alpha;
  14438. bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8;
  14439. bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8;
  14440. bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8;
  14441. }
  14442. }
  14443. }
  14444. function composeSMaskAlpha(maskData, layerData, transferMap) {
  14445. var length = maskData.length;
  14446. var scale = 1 / 255;
  14447. for (var i = 3; i < length; i += 4) {
  14448. var alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
  14449. layerData[i] = layerData[i] * alpha * scale | 0;
  14450. }
  14451. }
  14452. function composeSMaskLuminosity(maskData, layerData, transferMap) {
  14453. var length = maskData.length;
  14454. for (var i = 3; i < length; i += 4) {
  14455. var y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28;
  14456. layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16;
  14457. }
  14458. }
  14459. function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap) {
  14460. var hasBackdrop = !!backdrop;
  14461. var r0 = hasBackdrop ? backdrop[0] : 0;
  14462. var g0 = hasBackdrop ? backdrop[1] : 0;
  14463. var b0 = hasBackdrop ? backdrop[2] : 0;
  14464. var composeFn;
  14465. if (subtype === 'Luminosity') {
  14466. composeFn = composeSMaskLuminosity;
  14467. } else {
  14468. composeFn = composeSMaskAlpha;
  14469. }
  14470. var PIXELS_TO_PROCESS = 1048576;
  14471. var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
  14472. for (var row = 0; row < height; row += chunkSize) {
  14473. var chunkHeight = Math.min(chunkSize, height - row);
  14474. var maskData = maskCtx.getImageData(0, row, width, chunkHeight);
  14475. var layerData = layerCtx.getImageData(0, row, width, chunkHeight);
  14476. if (hasBackdrop) {
  14477. composeSMaskBackdrop(maskData.data, r0, g0, b0);
  14478. }
  14479. composeFn(maskData.data, layerData.data, transferMap);
  14480. maskCtx.putImageData(layerData, 0, row);
  14481. }
  14482. }
  14483. function composeSMask(ctx, smask, layerCtx) {
  14484. var mask = smask.canvas;
  14485. var maskCtx = smask.context;
  14486. ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY, smask.offsetX, smask.offsetY);
  14487. var backdrop = smask.backdrop || null;
  14488. if (!smask.transferMap && _webgl.WebGLUtils.isEnabled) {
  14489. var composed = _webgl.WebGLUtils.composeSMask(layerCtx.canvas, mask, {
  14490. subtype: smask.subtype,
  14491. backdrop: backdrop
  14492. });
  14493. ctx.setTransform(1, 0, 0, 1, 0, 0);
  14494. ctx.drawImage(composed, smask.offsetX, smask.offsetY);
  14495. return;
  14496. }
  14497. genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height, smask.subtype, backdrop, smask.transferMap);
  14498. ctx.drawImage(mask, 0, 0);
  14499. }
  14500. var LINE_CAP_STYLES = ['butt', 'round', 'square'];
  14501. var LINE_JOIN_STYLES = ['miter', 'round', 'bevel'];
  14502. var NORMAL_CLIP = {};
  14503. var EO_CLIP = {};
  14504. CanvasGraphics.prototype = {
  14505. beginDrawing: function beginDrawing(_ref) {
  14506. var transform = _ref.transform,
  14507. viewport = _ref.viewport,
  14508. transparency = _ref.transparency,
  14509. _ref$background = _ref.background,
  14510. background = _ref$background === undefined ? null : _ref$background;
  14511. var width = this.ctx.canvas.width;
  14512. var height = this.ctx.canvas.height;
  14513. this.ctx.save();
  14514. this.ctx.fillStyle = background || 'rgb(255, 255, 255)';
  14515. this.ctx.fillRect(0, 0, width, height);
  14516. this.ctx.restore();
  14517. if (transparency) {
  14518. var transparentCanvas = this.cachedCanvases.getCanvas('transparent', width, height, true);
  14519. this.compositeCtx = this.ctx;
  14520. this.transparentCanvas = transparentCanvas.canvas;
  14521. this.ctx = transparentCanvas.context;
  14522. this.ctx.save();
  14523. this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform);
  14524. }
  14525. this.ctx.save();
  14526. resetCtxToDefault(this.ctx);
  14527. if (transform) {
  14528. this.ctx.transform.apply(this.ctx, transform);
  14529. }
  14530. this.ctx.transform.apply(this.ctx, viewport.transform);
  14531. this.baseTransform = this.ctx.mozCurrentTransform.slice();
  14532. if (this.imageLayer) {
  14533. this.imageLayer.beginLayout();
  14534. }
  14535. },
  14536. executeOperatorList: function CanvasGraphics_executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
  14537. var argsArray = operatorList.argsArray;
  14538. var fnArray = operatorList.fnArray;
  14539. var i = executionStartIdx || 0;
  14540. var argsArrayLen = argsArray.length;
  14541. if (argsArrayLen === i) {
  14542. return i;
  14543. }
  14544. var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === 'function';
  14545. var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
  14546. var steps = 0;
  14547. var commonObjs = this.commonObjs;
  14548. var objs = this.objs;
  14549. var fnId;
  14550. while (true) {
  14551. if (stepper !== undefined && i === stepper.nextBreakPoint) {
  14552. stepper.breakIt(i, continueCallback);
  14553. return i;
  14554. }
  14555. fnId = fnArray[i];
  14556. if (fnId !== _util.OPS.dependency) {
  14557. this[fnId].apply(this, argsArray[i]);
  14558. } else {
  14559. var deps = argsArray[i];
  14560. for (var n = 0, nn = deps.length; n < nn; n++) {
  14561. var depObjId = deps[n];
  14562. var common = depObjId[0] === 'g' && depObjId[1] === '_';
  14563. var objsPool = common ? commonObjs : objs;
  14564. if (!objsPool.isResolved(depObjId)) {
  14565. objsPool.get(depObjId, continueCallback);
  14566. return i;
  14567. }
  14568. }
  14569. }
  14570. i++;
  14571. if (i === argsArrayLen) {
  14572. return i;
  14573. }
  14574. if (chunkOperations && ++steps > EXECUTION_STEPS) {
  14575. if (Date.now() > endTime) {
  14576. continueCallback();
  14577. return i;
  14578. }
  14579. steps = 0;
  14580. }
  14581. }
  14582. },
  14583. endDrawing: function CanvasGraphics_endDrawing() {
  14584. if (this.current.activeSMask !== null) {
  14585. this.endSMaskGroup();
  14586. }
  14587. this.ctx.restore();
  14588. if (this.transparentCanvas) {
  14589. this.ctx = this.compositeCtx;
  14590. this.ctx.save();
  14591. this.ctx.setTransform(1, 0, 0, 1, 0, 0);
  14592. this.ctx.drawImage(this.transparentCanvas, 0, 0);
  14593. this.ctx.restore();
  14594. this.transparentCanvas = null;
  14595. }
  14596. this.cachedCanvases.clear();
  14597. _webgl.WebGLUtils.clear();
  14598. if (this.imageLayer) {
  14599. this.imageLayer.endLayout();
  14600. }
  14601. },
  14602. setLineWidth: function CanvasGraphics_setLineWidth(width) {
  14603. this.current.lineWidth = width;
  14604. this.ctx.lineWidth = width;
  14605. },
  14606. setLineCap: function CanvasGraphics_setLineCap(style) {
  14607. this.ctx.lineCap = LINE_CAP_STYLES[style];
  14608. },
  14609. setLineJoin: function CanvasGraphics_setLineJoin(style) {
  14610. this.ctx.lineJoin = LINE_JOIN_STYLES[style];
  14611. },
  14612. setMiterLimit: function CanvasGraphics_setMiterLimit(limit) {
  14613. this.ctx.miterLimit = limit;
  14614. },
  14615. setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
  14616. var ctx = this.ctx;
  14617. if (ctx.setLineDash !== undefined) {
  14618. ctx.setLineDash(dashArray);
  14619. ctx.lineDashOffset = dashPhase;
  14620. }
  14621. },
  14622. setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {},
  14623. setFlatness: function CanvasGraphics_setFlatness(flatness) {},
  14624. setGState: function CanvasGraphics_setGState(states) {
  14625. for (var i = 0, ii = states.length; i < ii; i++) {
  14626. var state = states[i];
  14627. var key = state[0];
  14628. var value = state[1];
  14629. switch (key) {
  14630. case 'LW':
  14631. this.setLineWidth(value);
  14632. break;
  14633. case 'LC':
  14634. this.setLineCap(value);
  14635. break;
  14636. case 'LJ':
  14637. this.setLineJoin(value);
  14638. break;
  14639. case 'ML':
  14640. this.setMiterLimit(value);
  14641. break;
  14642. case 'D':
  14643. this.setDash(value[0], value[1]);
  14644. break;
  14645. case 'RI':
  14646. this.setRenderingIntent(value);
  14647. break;
  14648. case 'FL':
  14649. this.setFlatness(value);
  14650. break;
  14651. case 'Font':
  14652. this.setFont(value[0], value[1]);
  14653. break;
  14654. case 'CA':
  14655. this.current.strokeAlpha = state[1];
  14656. break;
  14657. case 'ca':
  14658. this.current.fillAlpha = state[1];
  14659. this.ctx.globalAlpha = state[1];
  14660. break;
  14661. case 'BM':
  14662. this.ctx.globalCompositeOperation = value;
  14663. break;
  14664. case 'SMask':
  14665. if (this.current.activeSMask) {
  14666. if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) {
  14667. this.suspendSMaskGroup();
  14668. } else {
  14669. this.endSMaskGroup();
  14670. }
  14671. }
  14672. this.current.activeSMask = value ? this.tempSMask : null;
  14673. if (this.current.activeSMask) {
  14674. this.beginSMaskGroup();
  14675. }
  14676. this.tempSMask = null;
  14677. break;
  14678. }
  14679. }
  14680. },
  14681. beginSMaskGroup: function CanvasGraphics_beginSMaskGroup() {
  14682. var activeSMask = this.current.activeSMask;
  14683. var drawnWidth = activeSMask.canvas.width;
  14684. var drawnHeight = activeSMask.canvas.height;
  14685. var cacheId = 'smaskGroupAt' + this.groupLevel;
  14686. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  14687. var currentCtx = this.ctx;
  14688. var currentTransform = currentCtx.mozCurrentTransform;
  14689. this.ctx.save();
  14690. var groupCtx = scratchCanvas.context;
  14691. groupCtx.scale(1 / activeSMask.scaleX, 1 / activeSMask.scaleY);
  14692. groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY);
  14693. groupCtx.transform.apply(groupCtx, currentTransform);
  14694. activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
  14695. copyCtxState(currentCtx, groupCtx);
  14696. this.ctx = groupCtx;
  14697. this.setGState([['BM', 'source-over'], ['ca', 1], ['CA', 1]]);
  14698. this.groupStack.push(currentCtx);
  14699. this.groupLevel++;
  14700. },
  14701. suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  14702. var groupCtx = this.ctx;
  14703. this.groupLevel--;
  14704. this.ctx = this.groupStack.pop();
  14705. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  14706. this.ctx.restore();
  14707. this.ctx.save();
  14708. copyCtxState(groupCtx, this.ctx);
  14709. this.current.resumeSMaskCtx = groupCtx;
  14710. var deltaTransform = _util.Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  14711. this.ctx.transform.apply(this.ctx, deltaTransform);
  14712. groupCtx.save();
  14713. groupCtx.setTransform(1, 0, 0, 1, 0, 0);
  14714. groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height);
  14715. groupCtx.restore();
  14716. },
  14717. resumeSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  14718. var groupCtx = this.current.resumeSMaskCtx;
  14719. var currentCtx = this.ctx;
  14720. this.ctx = groupCtx;
  14721. this.groupStack.push(currentCtx);
  14722. this.groupLevel++;
  14723. },
  14724. endSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  14725. var groupCtx = this.ctx;
  14726. this.groupLevel--;
  14727. this.ctx = this.groupStack.pop();
  14728. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  14729. this.ctx.restore();
  14730. copyCtxState(groupCtx, this.ctx);
  14731. var deltaTransform = _util.Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  14732. this.ctx.transform.apply(this.ctx, deltaTransform);
  14733. },
  14734. save: function CanvasGraphics_save() {
  14735. this.ctx.save();
  14736. var old = this.current;
  14737. this.stateStack.push(old);
  14738. this.current = old.clone();
  14739. this.current.resumeSMaskCtx = null;
  14740. },
  14741. restore: function CanvasGraphics_restore() {
  14742. if (this.current.resumeSMaskCtx) {
  14743. this.resumeSMaskGroup();
  14744. }
  14745. if (this.current.activeSMask !== null && (this.stateStack.length === 0 || this.stateStack[this.stateStack.length - 1].activeSMask !== this.current.activeSMask)) {
  14746. this.endSMaskGroup();
  14747. }
  14748. if (this.stateStack.length !== 0) {
  14749. this.current = this.stateStack.pop();
  14750. this.ctx.restore();
  14751. this.pendingClip = null;
  14752. this.cachedGetSinglePixelWidth = null;
  14753. }
  14754. },
  14755. transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
  14756. this.ctx.transform(a, b, c, d, e, f);
  14757. this.cachedGetSinglePixelWidth = null;
  14758. },
  14759. constructPath: function CanvasGraphics_constructPath(ops, args) {
  14760. var ctx = this.ctx;
  14761. var current = this.current;
  14762. var x = current.x,
  14763. y = current.y;
  14764. for (var i = 0, j = 0, ii = ops.length; i < ii; i++) {
  14765. switch (ops[i] | 0) {
  14766. case _util.OPS.rectangle:
  14767. x = args[j++];
  14768. y = args[j++];
  14769. var width = args[j++];
  14770. var height = args[j++];
  14771. if (width === 0) {
  14772. width = this.getSinglePixelWidth();
  14773. }
  14774. if (height === 0) {
  14775. height = this.getSinglePixelWidth();
  14776. }
  14777. var xw = x + width;
  14778. var yh = y + height;
  14779. this.ctx.moveTo(x, y);
  14780. this.ctx.lineTo(xw, y);
  14781. this.ctx.lineTo(xw, yh);
  14782. this.ctx.lineTo(x, yh);
  14783. this.ctx.lineTo(x, y);
  14784. this.ctx.closePath();
  14785. break;
  14786. case _util.OPS.moveTo:
  14787. x = args[j++];
  14788. y = args[j++];
  14789. ctx.moveTo(x, y);
  14790. break;
  14791. case _util.OPS.lineTo:
  14792. x = args[j++];
  14793. y = args[j++];
  14794. ctx.lineTo(x, y);
  14795. break;
  14796. case _util.OPS.curveTo:
  14797. x = args[j + 4];
  14798. y = args[j + 5];
  14799. ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y);
  14800. j += 6;
  14801. break;
  14802. case _util.OPS.curveTo2:
  14803. ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]);
  14804. x = args[j + 2];
  14805. y = args[j + 3];
  14806. j += 4;
  14807. break;
  14808. case _util.OPS.curveTo3:
  14809. x = args[j + 2];
  14810. y = args[j + 3];
  14811. ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
  14812. j += 4;
  14813. break;
  14814. case _util.OPS.closePath:
  14815. ctx.closePath();
  14816. break;
  14817. }
  14818. }
  14819. current.setCurrentPoint(x, y);
  14820. },
  14821. closePath: function CanvasGraphics_closePath() {
  14822. this.ctx.closePath();
  14823. },
  14824. stroke: function CanvasGraphics_stroke(consumePath) {
  14825. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  14826. var ctx = this.ctx;
  14827. var strokeColor = this.current.strokeColor;
  14828. ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
  14829. ctx.globalAlpha = this.current.strokeAlpha;
  14830. if (strokeColor && strokeColor.hasOwnProperty('type') && strokeColor.type === 'Pattern') {
  14831. ctx.save();
  14832. ctx.strokeStyle = strokeColor.getPattern(ctx, this);
  14833. ctx.stroke();
  14834. ctx.restore();
  14835. } else {
  14836. ctx.stroke();
  14837. }
  14838. if (consumePath) {
  14839. this.consumePath();
  14840. }
  14841. ctx.globalAlpha = this.current.fillAlpha;
  14842. },
  14843. closeStroke: function CanvasGraphics_closeStroke() {
  14844. this.closePath();
  14845. this.stroke();
  14846. },
  14847. fill: function CanvasGraphics_fill(consumePath) {
  14848. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  14849. var ctx = this.ctx;
  14850. var fillColor = this.current.fillColor;
  14851. var isPatternFill = this.current.patternFill;
  14852. var needRestore = false;
  14853. if (isPatternFill) {
  14854. ctx.save();
  14855. if (this.baseTransform) {
  14856. ctx.setTransform.apply(ctx, this.baseTransform);
  14857. }
  14858. ctx.fillStyle = fillColor.getPattern(ctx, this);
  14859. needRestore = true;
  14860. }
  14861. if (this.pendingEOFill) {
  14862. ctx.fill('evenodd');
  14863. this.pendingEOFill = false;
  14864. } else {
  14865. ctx.fill();
  14866. }
  14867. if (needRestore) {
  14868. ctx.restore();
  14869. }
  14870. if (consumePath) {
  14871. this.consumePath();
  14872. }
  14873. },
  14874. eoFill: function CanvasGraphics_eoFill() {
  14875. this.pendingEOFill = true;
  14876. this.fill();
  14877. },
  14878. fillStroke: function CanvasGraphics_fillStroke() {
  14879. this.fill(false);
  14880. this.stroke(false);
  14881. this.consumePath();
  14882. },
  14883. eoFillStroke: function CanvasGraphics_eoFillStroke() {
  14884. this.pendingEOFill = true;
  14885. this.fillStroke();
  14886. },
  14887. closeFillStroke: function CanvasGraphics_closeFillStroke() {
  14888. this.closePath();
  14889. this.fillStroke();
  14890. },
  14891. closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() {
  14892. this.pendingEOFill = true;
  14893. this.closePath();
  14894. this.fillStroke();
  14895. },
  14896. endPath: function CanvasGraphics_endPath() {
  14897. this.consumePath();
  14898. },
  14899. clip: function CanvasGraphics_clip() {
  14900. this.pendingClip = NORMAL_CLIP;
  14901. },
  14902. eoClip: function CanvasGraphics_eoClip() {
  14903. this.pendingClip = EO_CLIP;
  14904. },
  14905. beginText: function CanvasGraphics_beginText() {
  14906. this.current.textMatrix = _util.IDENTITY_MATRIX;
  14907. this.current.textMatrixScale = 1;
  14908. this.current.x = this.current.lineX = 0;
  14909. this.current.y = this.current.lineY = 0;
  14910. },
  14911. endText: function CanvasGraphics_endText() {
  14912. var paths = this.pendingTextPaths;
  14913. var ctx = this.ctx;
  14914. if (paths === undefined) {
  14915. ctx.beginPath();
  14916. return;
  14917. }
  14918. ctx.save();
  14919. ctx.beginPath();
  14920. for (var i = 0; i < paths.length; i++) {
  14921. var path = paths[i];
  14922. ctx.setTransform.apply(ctx, path.transform);
  14923. ctx.translate(path.x, path.y);
  14924. path.addToPath(ctx, path.fontSize);
  14925. }
  14926. ctx.restore();
  14927. ctx.clip();
  14928. ctx.beginPath();
  14929. delete this.pendingTextPaths;
  14930. },
  14931. setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) {
  14932. this.current.charSpacing = spacing;
  14933. },
  14934. setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) {
  14935. this.current.wordSpacing = spacing;
  14936. },
  14937. setHScale: function CanvasGraphics_setHScale(scale) {
  14938. this.current.textHScale = scale / 100;
  14939. },
  14940. setLeading: function CanvasGraphics_setLeading(leading) {
  14941. this.current.leading = -leading;
  14942. },
  14943. setFont: function CanvasGraphics_setFont(fontRefName, size) {
  14944. var fontObj = this.commonObjs.get(fontRefName);
  14945. var current = this.current;
  14946. if (!fontObj) {
  14947. throw new Error('Can\'t find font for ' + fontRefName);
  14948. }
  14949. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : _util.FONT_IDENTITY_MATRIX;
  14950. if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
  14951. (0, _util.warn)('Invalid font matrix for font ' + fontRefName);
  14952. }
  14953. if (size < 0) {
  14954. size = -size;
  14955. current.fontDirection = -1;
  14956. } else {
  14957. current.fontDirection = 1;
  14958. }
  14959. this.current.font = fontObj;
  14960. this.current.fontSize = size;
  14961. if (fontObj.isType3Font) {
  14962. return;
  14963. }
  14964. var name = fontObj.loadedName || 'sans-serif';
  14965. var bold = fontObj.black ? '900' : fontObj.bold ? 'bold' : 'normal';
  14966. var italic = fontObj.italic ? 'italic' : 'normal';
  14967. var typeface = '"' + name + '", ' + fontObj.fallbackName;
  14968. var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
  14969. this.current.fontSizeScale = size / browserFontSize;
  14970. var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
  14971. this.ctx.font = rule;
  14972. },
  14973. setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
  14974. this.current.textRenderingMode = mode;
  14975. },
  14976. setTextRise: function CanvasGraphics_setTextRise(rise) {
  14977. this.current.textRise = rise;
  14978. },
  14979. moveText: function CanvasGraphics_moveText(x, y) {
  14980. this.current.x = this.current.lineX += x;
  14981. this.current.y = this.current.lineY += y;
  14982. },
  14983. setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) {
  14984. this.setLeading(-y);
  14985. this.moveText(x, y);
  14986. },
  14987. setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) {
  14988. this.current.textMatrix = [a, b, c, d, e, f];
  14989. this.current.textMatrixScale = Math.sqrt(a * a + b * b);
  14990. this.current.x = this.current.lineX = 0;
  14991. this.current.y = this.current.lineY = 0;
  14992. },
  14993. nextLine: function CanvasGraphics_nextLine() {
  14994. this.moveText(0, this.current.leading);
  14995. },
  14996. paintChar: function CanvasGraphics_paintChar(character, x, y) {
  14997. var ctx = this.ctx;
  14998. var current = this.current;
  14999. var font = current.font;
  15000. var textRenderingMode = current.textRenderingMode;
  15001. var fontSize = current.fontSize / current.fontSizeScale;
  15002. var fillStrokeMode = textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
  15003. var isAddToPathSet = !!(textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG);
  15004. var addToPath;
  15005. if (font.disableFontFace || isAddToPathSet) {
  15006. addToPath = font.getPathGenerator(this.commonObjs, character);
  15007. }
  15008. if (font.disableFontFace) {
  15009. ctx.save();
  15010. ctx.translate(x, y);
  15011. ctx.beginPath();
  15012. addToPath(ctx, fontSize);
  15013. if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  15014. ctx.fill();
  15015. }
  15016. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  15017. ctx.stroke();
  15018. }
  15019. ctx.restore();
  15020. } else {
  15021. if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  15022. ctx.fillText(character, x, y);
  15023. }
  15024. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  15025. ctx.strokeText(character, x, y);
  15026. }
  15027. }
  15028. if (isAddToPathSet) {
  15029. var paths = this.pendingTextPaths || (this.pendingTextPaths = []);
  15030. paths.push({
  15031. transform: ctx.mozCurrentTransform,
  15032. x: x,
  15033. y: y,
  15034. fontSize: fontSize,
  15035. addToPath: addToPath
  15036. });
  15037. }
  15038. },
  15039. get isFontSubpixelAAEnabled() {
  15040. var ctx = this.canvasFactory.create(10, 10).context;
  15041. ctx.scale(1.5, 1);
  15042. ctx.fillText('I', 0, 10);
  15043. var data = ctx.getImageData(0, 0, 10, 10).data;
  15044. var enabled = false;
  15045. for (var i = 3; i < data.length; i += 4) {
  15046. if (data[i] > 0 && data[i] < 255) {
  15047. enabled = true;
  15048. break;
  15049. }
  15050. }
  15051. return (0, _util.shadow)(this, 'isFontSubpixelAAEnabled', enabled);
  15052. },
  15053. showText: function CanvasGraphics_showText(glyphs) {
  15054. var current = this.current;
  15055. var font = current.font;
  15056. if (font.isType3Font) {
  15057. return this.showType3Text(glyphs);
  15058. }
  15059. var fontSize = current.fontSize;
  15060. if (fontSize === 0) {
  15061. return;
  15062. }
  15063. var ctx = this.ctx;
  15064. var fontSizeScale = current.fontSizeScale;
  15065. var charSpacing = current.charSpacing;
  15066. var wordSpacing = current.wordSpacing;
  15067. var fontDirection = current.fontDirection;
  15068. var textHScale = current.textHScale * fontDirection;
  15069. var glyphsLength = glyphs.length;
  15070. var vertical = font.vertical;
  15071. var spacingDir = vertical ? 1 : -1;
  15072. var defaultVMetrics = font.defaultVMetrics;
  15073. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  15074. var simpleFillText = current.textRenderingMode === _util.TextRenderingMode.FILL && !font.disableFontFace;
  15075. ctx.save();
  15076. ctx.transform.apply(ctx, current.textMatrix);
  15077. ctx.translate(current.x, current.y + current.textRise);
  15078. if (current.patternFill) {
  15079. ctx.fillStyle = current.fillColor.getPattern(ctx, this);
  15080. }
  15081. if (fontDirection > 0) {
  15082. ctx.scale(textHScale, -1);
  15083. } else {
  15084. ctx.scale(textHScale, 1);
  15085. }
  15086. var lineWidth = current.lineWidth;
  15087. var scale = current.textMatrixScale;
  15088. if (scale === 0 || lineWidth === 0) {
  15089. var fillStrokeMode = current.textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
  15090. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  15091. this.cachedGetSinglePixelWidth = null;
  15092. lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR;
  15093. }
  15094. } else {
  15095. lineWidth /= scale;
  15096. }
  15097. if (fontSizeScale !== 1.0) {
  15098. ctx.scale(fontSizeScale, fontSizeScale);
  15099. lineWidth /= fontSizeScale;
  15100. }
  15101. ctx.lineWidth = lineWidth;
  15102. var x = 0,
  15103. i;
  15104. for (i = 0; i < glyphsLength; ++i) {
  15105. var glyph = glyphs[i];
  15106. if ((0, _util.isNum)(glyph)) {
  15107. x += spacingDir * glyph * fontSize / 1000;
  15108. continue;
  15109. }
  15110. var restoreNeeded = false;
  15111. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  15112. var character = glyph.fontChar;
  15113. var accent = glyph.accent;
  15114. var scaledX, scaledY, scaledAccentX, scaledAccentY;
  15115. var width = glyph.width;
  15116. if (vertical) {
  15117. var vmetric, vx, vy;
  15118. vmetric = glyph.vmetric || defaultVMetrics;
  15119. vx = glyph.vmetric ? vmetric[1] : width * 0.5;
  15120. vx = -vx * widthAdvanceScale;
  15121. vy = vmetric[2] * widthAdvanceScale;
  15122. width = vmetric ? -vmetric[0] : width;
  15123. scaledX = vx / fontSizeScale;
  15124. scaledY = (x + vy) / fontSizeScale;
  15125. } else {
  15126. scaledX = x / fontSizeScale;
  15127. scaledY = 0;
  15128. }
  15129. if (font.remeasure && width > 0) {
  15130. var measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale;
  15131. if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
  15132. var characterScaleX = width / measuredWidth;
  15133. restoreNeeded = true;
  15134. ctx.save();
  15135. ctx.scale(characterScaleX, 1);
  15136. scaledX /= characterScaleX;
  15137. } else if (width !== measuredWidth) {
  15138. scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale;
  15139. }
  15140. }
  15141. if (glyph.isInFont || font.missingFile) {
  15142. if (simpleFillText && !accent) {
  15143. ctx.fillText(character, scaledX, scaledY);
  15144. } else {
  15145. this.paintChar(character, scaledX, scaledY);
  15146. if (accent) {
  15147. scaledAccentX = scaledX + accent.offset.x / fontSizeScale;
  15148. scaledAccentY = scaledY - accent.offset.y / fontSizeScale;
  15149. this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY);
  15150. }
  15151. }
  15152. }
  15153. var charWidth = width * widthAdvanceScale + spacing * fontDirection;
  15154. x += charWidth;
  15155. if (restoreNeeded) {
  15156. ctx.restore();
  15157. }
  15158. }
  15159. if (vertical) {
  15160. current.y -= x * textHScale;
  15161. } else {
  15162. current.x += x * textHScale;
  15163. }
  15164. ctx.restore();
  15165. },
  15166. showType3Text: function CanvasGraphics_showType3Text(glyphs) {
  15167. var ctx = this.ctx;
  15168. var current = this.current;
  15169. var font = current.font;
  15170. var fontSize = current.fontSize;
  15171. var fontDirection = current.fontDirection;
  15172. var spacingDir = font.vertical ? 1 : -1;
  15173. var charSpacing = current.charSpacing;
  15174. var wordSpacing = current.wordSpacing;
  15175. var textHScale = current.textHScale * fontDirection;
  15176. var fontMatrix = current.fontMatrix || _util.FONT_IDENTITY_MATRIX;
  15177. var glyphsLength = glyphs.length;
  15178. var isTextInvisible = current.textRenderingMode === _util.TextRenderingMode.INVISIBLE;
  15179. var i, glyph, width, spacingLength;
  15180. if (isTextInvisible || fontSize === 0) {
  15181. return;
  15182. }
  15183. this.cachedGetSinglePixelWidth = null;
  15184. ctx.save();
  15185. ctx.transform.apply(ctx, current.textMatrix);
  15186. ctx.translate(current.x, current.y);
  15187. ctx.scale(textHScale, fontDirection);
  15188. for (i = 0; i < glyphsLength; ++i) {
  15189. glyph = glyphs[i];
  15190. if ((0, _util.isNum)(glyph)) {
  15191. spacingLength = spacingDir * glyph * fontSize / 1000;
  15192. this.ctx.translate(spacingLength, 0);
  15193. current.x += spacingLength * textHScale;
  15194. continue;
  15195. }
  15196. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  15197. var operatorList = font.charProcOperatorList[glyph.operatorListId];
  15198. if (!operatorList) {
  15199. (0, _util.warn)('Type3 character "' + glyph.operatorListId + '" is not available.');
  15200. continue;
  15201. }
  15202. this.processingType3 = glyph;
  15203. this.save();
  15204. ctx.scale(fontSize, fontSize);
  15205. ctx.transform.apply(ctx, fontMatrix);
  15206. this.executeOperatorList(operatorList);
  15207. this.restore();
  15208. var transformed = _util.Util.applyTransform([glyph.width, 0], fontMatrix);
  15209. width = transformed[0] * fontSize + spacing;
  15210. ctx.translate(width, 0);
  15211. current.x += width * textHScale;
  15212. }
  15213. ctx.restore();
  15214. this.processingType3 = null;
  15215. },
  15216. setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) {},
  15217. setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
  15218. this.ctx.rect(llx, lly, urx - llx, ury - lly);
  15219. this.clip();
  15220. this.endPath();
  15221. },
  15222. getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
  15223. var _this = this;
  15224. var pattern;
  15225. if (IR[0] === 'TilingPattern') {
  15226. var color = IR[1];
  15227. var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
  15228. var canvasGraphicsFactory = {
  15229. createCanvasGraphics: function createCanvasGraphics(ctx) {
  15230. return new CanvasGraphics(ctx, _this.commonObjs, _this.objs, _this.canvasFactory);
  15231. }
  15232. };
  15233. pattern = new _pattern_helper.TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
  15234. } else {
  15235. pattern = (0, _pattern_helper.getShadingPatternFromIR)(IR);
  15236. }
  15237. return pattern;
  15238. },
  15239. setStrokeColorN: function CanvasGraphics_setStrokeColorN() {
  15240. this.current.strokeColor = this.getColorN_Pattern(arguments);
  15241. },
  15242. setFillColorN: function CanvasGraphics_setFillColorN() {
  15243. this.current.fillColor = this.getColorN_Pattern(arguments);
  15244. this.current.patternFill = true;
  15245. },
  15246. setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
  15247. var color = _util.Util.makeCssRgb(r, g, b);
  15248. this.ctx.strokeStyle = color;
  15249. this.current.strokeColor = color;
  15250. },
  15251. setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
  15252. var color = _util.Util.makeCssRgb(r, g, b);
  15253. this.ctx.fillStyle = color;
  15254. this.current.fillColor = color;
  15255. this.current.patternFill = false;
  15256. },
  15257. shadingFill: function CanvasGraphics_shadingFill(patternIR) {
  15258. var ctx = this.ctx;
  15259. this.save();
  15260. var pattern = (0, _pattern_helper.getShadingPatternFromIR)(patternIR);
  15261. ctx.fillStyle = pattern.getPattern(ctx, this, true);
  15262. var inv = ctx.mozCurrentTransformInverse;
  15263. if (inv) {
  15264. var canvas = ctx.canvas;
  15265. var width = canvas.width;
  15266. var height = canvas.height;
  15267. var bl = _util.Util.applyTransform([0, 0], inv);
  15268. var br = _util.Util.applyTransform([0, height], inv);
  15269. var ul = _util.Util.applyTransform([width, 0], inv);
  15270. var ur = _util.Util.applyTransform([width, height], inv);
  15271. var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
  15272. var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
  15273. var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
  15274. var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
  15275. this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
  15276. } else {
  15277. this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
  15278. }
  15279. this.restore();
  15280. },
  15281. beginInlineImage: function CanvasGraphics_beginInlineImage() {
  15282. throw new Error('Should not call beginInlineImage');
  15283. },
  15284. beginImageData: function CanvasGraphics_beginImageData() {
  15285. throw new Error('Should not call beginImageData');
  15286. },
  15287. paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
  15288. this.save();
  15289. this.baseTransformStack.push(this.baseTransform);
  15290. if (Array.isArray(matrix) && matrix.length === 6) {
  15291. this.transform.apply(this, matrix);
  15292. }
  15293. this.baseTransform = this.ctx.mozCurrentTransform;
  15294. if (Array.isArray(bbox) && bbox.length === 4) {
  15295. var width = bbox[2] - bbox[0];
  15296. var height = bbox[3] - bbox[1];
  15297. this.ctx.rect(bbox[0], bbox[1], width, height);
  15298. this.clip();
  15299. this.endPath();
  15300. }
  15301. },
  15302. paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() {
  15303. this.restore();
  15304. this.baseTransform = this.baseTransformStack.pop();
  15305. },
  15306. beginGroup: function CanvasGraphics_beginGroup(group) {
  15307. this.save();
  15308. var currentCtx = this.ctx;
  15309. if (!group.isolated) {
  15310. (0, _util.info)('TODO: Support non-isolated groups.');
  15311. }
  15312. if (group.knockout) {
  15313. (0, _util.warn)('Knockout groups not supported.');
  15314. }
  15315. var currentTransform = currentCtx.mozCurrentTransform;
  15316. if (group.matrix) {
  15317. currentCtx.transform.apply(currentCtx, group.matrix);
  15318. }
  15319. if (!group.bbox) {
  15320. throw new Error('Bounding box is required.');
  15321. }
  15322. var bounds = _util.Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
  15323. var canvasBounds = [0, 0, currentCtx.canvas.width, currentCtx.canvas.height];
  15324. bounds = _util.Util.intersect(bounds, canvasBounds) || [0, 0, 0, 0];
  15325. var offsetX = Math.floor(bounds[0]);
  15326. var offsetY = Math.floor(bounds[1]);
  15327. var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
  15328. var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
  15329. var scaleX = 1,
  15330. scaleY = 1;
  15331. if (drawnWidth > MAX_GROUP_SIZE) {
  15332. scaleX = drawnWidth / MAX_GROUP_SIZE;
  15333. drawnWidth = MAX_GROUP_SIZE;
  15334. }
  15335. if (drawnHeight > MAX_GROUP_SIZE) {
  15336. scaleY = drawnHeight / MAX_GROUP_SIZE;
  15337. drawnHeight = MAX_GROUP_SIZE;
  15338. }
  15339. var cacheId = 'groupAt' + this.groupLevel;
  15340. if (group.smask) {
  15341. cacheId += '_smask_' + this.smaskCounter++ % 2;
  15342. }
  15343. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  15344. var groupCtx = scratchCanvas.context;
  15345. groupCtx.scale(1 / scaleX, 1 / scaleY);
  15346. groupCtx.translate(-offsetX, -offsetY);
  15347. groupCtx.transform.apply(groupCtx, currentTransform);
  15348. if (group.smask) {
  15349. this.smaskStack.push({
  15350. canvas: scratchCanvas.canvas,
  15351. context: groupCtx,
  15352. offsetX: offsetX,
  15353. offsetY: offsetY,
  15354. scaleX: scaleX,
  15355. scaleY: scaleY,
  15356. subtype: group.smask.subtype,
  15357. backdrop: group.smask.backdrop,
  15358. transferMap: group.smask.transferMap || null,
  15359. startTransformInverse: null
  15360. });
  15361. } else {
  15362. currentCtx.setTransform(1, 0, 0, 1, 0, 0);
  15363. currentCtx.translate(offsetX, offsetY);
  15364. currentCtx.scale(scaleX, scaleY);
  15365. }
  15366. copyCtxState(currentCtx, groupCtx);
  15367. this.ctx = groupCtx;
  15368. this.setGState([['BM', 'source-over'], ['ca', 1], ['CA', 1]]);
  15369. this.groupStack.push(currentCtx);
  15370. this.groupLevel++;
  15371. this.current.activeSMask = null;
  15372. },
  15373. endGroup: function CanvasGraphics_endGroup(group) {
  15374. this.groupLevel--;
  15375. var groupCtx = this.ctx;
  15376. this.ctx = this.groupStack.pop();
  15377. if (this.ctx.imageSmoothingEnabled !== undefined) {
  15378. this.ctx.imageSmoothingEnabled = false;
  15379. } else {
  15380. this.ctx.mozImageSmoothingEnabled = false;
  15381. }
  15382. if (group.smask) {
  15383. this.tempSMask = this.smaskStack.pop();
  15384. } else {
  15385. this.ctx.drawImage(groupCtx.canvas, 0, 0);
  15386. }
  15387. this.restore();
  15388. },
  15389. beginAnnotations: function CanvasGraphics_beginAnnotations() {
  15390. this.save();
  15391. if (this.baseTransform) {
  15392. this.ctx.setTransform.apply(this.ctx, this.baseTransform);
  15393. }
  15394. },
  15395. endAnnotations: function CanvasGraphics_endAnnotations() {
  15396. this.restore();
  15397. },
  15398. beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform, matrix) {
  15399. this.save();
  15400. resetCtxToDefault(this.ctx);
  15401. this.current = new CanvasExtraState();
  15402. if (Array.isArray(rect) && rect.length === 4) {
  15403. var width = rect[2] - rect[0];
  15404. var height = rect[3] - rect[1];
  15405. this.ctx.rect(rect[0], rect[1], width, height);
  15406. this.clip();
  15407. this.endPath();
  15408. }
  15409. this.transform.apply(this, transform);
  15410. this.transform.apply(this, matrix);
  15411. },
  15412. endAnnotation: function CanvasGraphics_endAnnotation() {
  15413. this.restore();
  15414. },
  15415. paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
  15416. var domImage = this.objs.get(objId);
  15417. if (!domImage) {
  15418. (0, _util.warn)('Dependent image isn\'t ready yet');
  15419. return;
  15420. }
  15421. this.save();
  15422. var ctx = this.ctx;
  15423. ctx.scale(1 / w, -1 / h);
  15424. ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, 0, -h, w, h);
  15425. if (this.imageLayer) {
  15426. var currentTransform = ctx.mozCurrentTransformInverse;
  15427. var position = this.getCanvasPosition(0, 0);
  15428. this.imageLayer.appendImage({
  15429. objId: objId,
  15430. left: position[0],
  15431. top: position[1],
  15432. width: w / currentTransform[0],
  15433. height: h / currentTransform[3]
  15434. });
  15435. }
  15436. this.restore();
  15437. },
  15438. paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
  15439. var ctx = this.ctx;
  15440. var width = img.width,
  15441. height = img.height;
  15442. var fillColor = this.current.fillColor;
  15443. var isPatternFill = this.current.patternFill;
  15444. var glyph = this.processingType3;
  15445. if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
  15446. if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
  15447. glyph.compiled = compileType3Glyph({
  15448. data: img.data,
  15449. width: width,
  15450. height: height
  15451. });
  15452. } else {
  15453. glyph.compiled = null;
  15454. }
  15455. }
  15456. if (glyph && glyph.compiled) {
  15457. glyph.compiled(ctx);
  15458. return;
  15459. }
  15460. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  15461. var maskCtx = maskCanvas.context;
  15462. maskCtx.save();
  15463. putBinaryImageMask(maskCtx, img);
  15464. maskCtx.globalCompositeOperation = 'source-in';
  15465. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  15466. maskCtx.fillRect(0, 0, width, height);
  15467. maskCtx.restore();
  15468. this.paintInlineImageXObject(maskCanvas.canvas);
  15469. },
  15470. paintImageMaskXObjectRepeat: function CanvasGraphics_paintImageMaskXObjectRepeat(imgData, scaleX, scaleY, positions) {
  15471. var width = imgData.width;
  15472. var height = imgData.height;
  15473. var fillColor = this.current.fillColor;
  15474. var isPatternFill = this.current.patternFill;
  15475. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  15476. var maskCtx = maskCanvas.context;
  15477. maskCtx.save();
  15478. putBinaryImageMask(maskCtx, imgData);
  15479. maskCtx.globalCompositeOperation = 'source-in';
  15480. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  15481. maskCtx.fillRect(0, 0, width, height);
  15482. maskCtx.restore();
  15483. var ctx = this.ctx;
  15484. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  15485. ctx.save();
  15486. ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
  15487. ctx.scale(1, -1);
  15488. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  15489. ctx.restore();
  15490. }
  15491. },
  15492. paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(images) {
  15493. var ctx = this.ctx;
  15494. var fillColor = this.current.fillColor;
  15495. var isPatternFill = this.current.patternFill;
  15496. for (var i = 0, ii = images.length; i < ii; i++) {
  15497. var image = images[i];
  15498. var width = image.width,
  15499. height = image.height;
  15500. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  15501. var maskCtx = maskCanvas.context;
  15502. maskCtx.save();
  15503. putBinaryImageMask(maskCtx, image);
  15504. maskCtx.globalCompositeOperation = 'source-in';
  15505. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  15506. maskCtx.fillRect(0, 0, width, height);
  15507. maskCtx.restore();
  15508. ctx.save();
  15509. ctx.transform.apply(ctx, image.transform);
  15510. ctx.scale(1, -1);
  15511. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  15512. ctx.restore();
  15513. }
  15514. },
  15515. paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
  15516. var imgData = this.objs.get(objId);
  15517. if (!imgData) {
  15518. (0, _util.warn)('Dependent image isn\'t ready yet');
  15519. return;
  15520. }
  15521. this.paintInlineImageXObject(imgData);
  15522. },
  15523. paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
  15524. var imgData = this.objs.get(objId);
  15525. if (!imgData) {
  15526. (0, _util.warn)('Dependent image isn\'t ready yet');
  15527. return;
  15528. }
  15529. var width = imgData.width;
  15530. var height = imgData.height;
  15531. var map = [];
  15532. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  15533. map.push({
  15534. transform: [scaleX, 0, 0, scaleY, positions[i], positions[i + 1]],
  15535. x: 0,
  15536. y: 0,
  15537. w: width,
  15538. h: height
  15539. });
  15540. }
  15541. this.paintInlineImageXObjectGroup(imgData, map);
  15542. },
  15543. paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) {
  15544. var width = imgData.width;
  15545. var height = imgData.height;
  15546. var ctx = this.ctx;
  15547. this.save();
  15548. ctx.scale(1 / width, -1 / height);
  15549. var currentTransform = ctx.mozCurrentTransformInverse;
  15550. var a = currentTransform[0],
  15551. b = currentTransform[1];
  15552. var widthScale = Math.max(Math.sqrt(a * a + b * b), 1);
  15553. var c = currentTransform[2],
  15554. d = currentTransform[3];
  15555. var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
  15556. var imgToPaint, tmpCanvas;
  15557. if (imgData instanceof HTMLElement || !imgData.data) {
  15558. imgToPaint = imgData;
  15559. } else {
  15560. tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', width, height);
  15561. var tmpCtx = tmpCanvas.context;
  15562. putBinaryImageData(tmpCtx, imgData);
  15563. imgToPaint = tmpCanvas.canvas;
  15564. }
  15565. var paintWidth = width,
  15566. paintHeight = height;
  15567. var tmpCanvasId = 'prescale1';
  15568. while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
  15569. var newWidth = paintWidth,
  15570. newHeight = paintHeight;
  15571. if (widthScale > 2 && paintWidth > 1) {
  15572. newWidth = Math.ceil(paintWidth / 2);
  15573. widthScale /= paintWidth / newWidth;
  15574. }
  15575. if (heightScale > 2 && paintHeight > 1) {
  15576. newHeight = Math.ceil(paintHeight / 2);
  15577. heightScale /= paintHeight / newHeight;
  15578. }
  15579. tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
  15580. tmpCtx = tmpCanvas.context;
  15581. tmpCtx.clearRect(0, 0, newWidth, newHeight);
  15582. tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight);
  15583. imgToPaint = tmpCanvas.canvas;
  15584. paintWidth = newWidth;
  15585. paintHeight = newHeight;
  15586. tmpCanvasId = tmpCanvasId === 'prescale1' ? 'prescale2' : 'prescale1';
  15587. }
  15588. ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height);
  15589. if (this.imageLayer) {
  15590. var position = this.getCanvasPosition(0, -height);
  15591. this.imageLayer.appendImage({
  15592. imgData: imgData,
  15593. left: position[0],
  15594. top: position[1],
  15595. width: width / currentTransform[0],
  15596. height: height / currentTransform[3]
  15597. });
  15598. }
  15599. this.restore();
  15600. },
  15601. paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) {
  15602. var ctx = this.ctx;
  15603. var w = imgData.width;
  15604. var h = imgData.height;
  15605. var tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', w, h);
  15606. var tmpCtx = tmpCanvas.context;
  15607. putBinaryImageData(tmpCtx, imgData);
  15608. for (var i = 0, ii = map.length; i < ii; i++) {
  15609. var entry = map[i];
  15610. ctx.save();
  15611. ctx.transform.apply(ctx, entry.transform);
  15612. ctx.scale(1, -1);
  15613. ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
  15614. if (this.imageLayer) {
  15615. var position = this.getCanvasPosition(entry.x, entry.y);
  15616. this.imageLayer.appendImage({
  15617. imgData: imgData,
  15618. left: position[0],
  15619. top: position[1],
  15620. width: w,
  15621. height: h
  15622. });
  15623. }
  15624. ctx.restore();
  15625. }
  15626. },
  15627. paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() {
  15628. this.ctx.fillRect(0, 0, 1, 1);
  15629. },
  15630. paintXObject: function CanvasGraphics_paintXObject() {
  15631. (0, _util.warn)('Unsupported \'paintXObject\' command.');
  15632. },
  15633. markPoint: function CanvasGraphics_markPoint(tag) {},
  15634. markPointProps: function CanvasGraphics_markPointProps(tag, properties) {},
  15635. beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {},
  15636. beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(tag, properties) {},
  15637. endMarkedContent: function CanvasGraphics_endMarkedContent() {},
  15638. beginCompat: function CanvasGraphics_beginCompat() {},
  15639. endCompat: function CanvasGraphics_endCompat() {},
  15640. consumePath: function CanvasGraphics_consumePath() {
  15641. var ctx = this.ctx;
  15642. if (this.pendingClip) {
  15643. if (this.pendingClip === EO_CLIP) {
  15644. ctx.clip('evenodd');
  15645. } else {
  15646. ctx.clip();
  15647. }
  15648. this.pendingClip = null;
  15649. }
  15650. ctx.beginPath();
  15651. },
  15652. getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) {
  15653. if (this.cachedGetSinglePixelWidth === null) {
  15654. this.ctx.save();
  15655. var inverse = this.ctx.mozCurrentTransformInverse;
  15656. this.ctx.restore();
  15657. this.cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3]));
  15658. }
  15659. return this.cachedGetSinglePixelWidth;
  15660. },
  15661. getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
  15662. var transform = this.ctx.mozCurrentTransform;
  15663. return [transform[0] * x + transform[2] * y + transform[4], transform[1] * x + transform[3] * y + transform[5]];
  15664. }
  15665. };
  15666. for (var op in _util.OPS) {
  15667. CanvasGraphics.prototype[_util.OPS[op]] = CanvasGraphics.prototype[op];
  15668. }
  15669. return CanvasGraphics;
  15670. }();
  15671. exports.CanvasGraphics = CanvasGraphics;
  15672. /***/ }),
  15673. /* 120 */
  15674. /***/ (function(module, exports, __w_pdfjs_require__) {
  15675. "use strict";
  15676. Object.defineProperty(exports, "__esModule", {
  15677. value: true
  15678. });
  15679. exports.TilingPattern = exports.getShadingPatternFromIR = undefined;
  15680. var _util = __w_pdfjs_require__(0);
  15681. var _webgl = __w_pdfjs_require__(70);
  15682. var ShadingIRs = {};
  15683. ShadingIRs.RadialAxial = {
  15684. fromIR: function RadialAxial_fromIR(raw) {
  15685. var type = raw[1];
  15686. var colorStops = raw[2];
  15687. var p0 = raw[3];
  15688. var p1 = raw[4];
  15689. var r0 = raw[5];
  15690. var r1 = raw[6];
  15691. return {
  15692. type: 'Pattern',
  15693. getPattern: function RadialAxial_getPattern(ctx) {
  15694. var grad;
  15695. if (type === 'axial') {
  15696. grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]);
  15697. } else if (type === 'radial') {
  15698. grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1);
  15699. }
  15700. for (var i = 0, ii = colorStops.length; i < ii; ++i) {
  15701. var c = colorStops[i];
  15702. grad.addColorStop(c[0], c[1]);
  15703. }
  15704. return grad;
  15705. }
  15706. };
  15707. }
  15708. };
  15709. var createMeshCanvas = function createMeshCanvasClosure() {
  15710. function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {
  15711. var coords = context.coords,
  15712. colors = context.colors;
  15713. var bytes = data.data,
  15714. rowSize = data.width * 4;
  15715. var tmp;
  15716. if (coords[p1 + 1] > coords[p2 + 1]) {
  15717. tmp = p1;
  15718. p1 = p2;
  15719. p2 = tmp;
  15720. tmp = c1;
  15721. c1 = c2;
  15722. c2 = tmp;
  15723. }
  15724. if (coords[p2 + 1] > coords[p3 + 1]) {
  15725. tmp = p2;
  15726. p2 = p3;
  15727. p3 = tmp;
  15728. tmp = c2;
  15729. c2 = c3;
  15730. c3 = tmp;
  15731. }
  15732. if (coords[p1 + 1] > coords[p2 + 1]) {
  15733. tmp = p1;
  15734. p1 = p2;
  15735. p2 = tmp;
  15736. tmp = c1;
  15737. c1 = c2;
  15738. c2 = tmp;
  15739. }
  15740. var x1 = (coords[p1] + context.offsetX) * context.scaleX;
  15741. var y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY;
  15742. var x2 = (coords[p2] + context.offsetX) * context.scaleX;
  15743. var y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY;
  15744. var x3 = (coords[p3] + context.offsetX) * context.scaleX;
  15745. var y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY;
  15746. if (y1 >= y3) {
  15747. return;
  15748. }
  15749. var c1r = colors[c1],
  15750. c1g = colors[c1 + 1],
  15751. c1b = colors[c1 + 2];
  15752. var c2r = colors[c2],
  15753. c2g = colors[c2 + 1],
  15754. c2b = colors[c2 + 2];
  15755. var c3r = colors[c3],
  15756. c3g = colors[c3 + 1],
  15757. c3b = colors[c3 + 2];
  15758. var minY = Math.round(y1),
  15759. maxY = Math.round(y3);
  15760. var xa, car, cag, cab;
  15761. var xb, cbr, cbg, cbb;
  15762. var k;
  15763. for (var y = minY; y <= maxY; y++) {
  15764. if (y < y2) {
  15765. k = y < y1 ? 0 : y1 === y2 ? 1 : (y1 - y) / (y1 - y2);
  15766. xa = x1 - (x1 - x2) * k;
  15767. car = c1r - (c1r - c2r) * k;
  15768. cag = c1g - (c1g - c2g) * k;
  15769. cab = c1b - (c1b - c2b) * k;
  15770. } else {
  15771. k = y > y3 ? 1 : y2 === y3 ? 0 : (y2 - y) / (y2 - y3);
  15772. xa = x2 - (x2 - x3) * k;
  15773. car = c2r - (c2r - c3r) * k;
  15774. cag = c2g - (c2g - c3g) * k;
  15775. cab = c2b - (c2b - c3b) * k;
  15776. }
  15777. k = y < y1 ? 0 : y > y3 ? 1 : (y1 - y) / (y1 - y3);
  15778. xb = x1 - (x1 - x3) * k;
  15779. cbr = c1r - (c1r - c3r) * k;
  15780. cbg = c1g - (c1g - c3g) * k;
  15781. cbb = c1b - (c1b - c3b) * k;
  15782. var x1_ = Math.round(Math.min(xa, xb));
  15783. var x2_ = Math.round(Math.max(xa, xb));
  15784. var j = rowSize * y + x1_ * 4;
  15785. for (var x = x1_; x <= x2_; x++) {
  15786. k = (xa - x) / (xa - xb);
  15787. k = k < 0 ? 0 : k > 1 ? 1 : k;
  15788. bytes[j++] = car - (car - cbr) * k | 0;
  15789. bytes[j++] = cag - (cag - cbg) * k | 0;
  15790. bytes[j++] = cab - (cab - cbb) * k | 0;
  15791. bytes[j++] = 255;
  15792. }
  15793. }
  15794. }
  15795. function drawFigure(data, figure, context) {
  15796. var ps = figure.coords;
  15797. var cs = figure.colors;
  15798. var i, ii;
  15799. switch (figure.type) {
  15800. case 'lattice':
  15801. var verticesPerRow = figure.verticesPerRow;
  15802. var rows = Math.floor(ps.length / verticesPerRow) - 1;
  15803. var cols = verticesPerRow - 1;
  15804. for (i = 0; i < rows; i++) {
  15805. var q = i * verticesPerRow;
  15806. for (var j = 0; j < cols; j++, q++) {
  15807. drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]);
  15808. drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]);
  15809. }
  15810. }
  15811. break;
  15812. case 'triangles':
  15813. for (i = 0, ii = ps.length; i < ii; i += 3) {
  15814. drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]);
  15815. }
  15816. break;
  15817. default:
  15818. throw new Error('illegal figure');
  15819. }
  15820. }
  15821. function createMeshCanvas(bounds, combinesScale, coords, colors, figures, backgroundColor, cachedCanvases) {
  15822. var EXPECTED_SCALE = 1.1;
  15823. var MAX_PATTERN_SIZE = 3000;
  15824. var BORDER_SIZE = 2;
  15825. var offsetX = Math.floor(bounds[0]);
  15826. var offsetY = Math.floor(bounds[1]);
  15827. var boundsWidth = Math.ceil(bounds[2]) - offsetX;
  15828. var boundsHeight = Math.ceil(bounds[3]) - offsetY;
  15829. var width = Math.min(Math.ceil(Math.abs(boundsWidth * combinesScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  15830. var height = Math.min(Math.ceil(Math.abs(boundsHeight * combinesScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  15831. var scaleX = boundsWidth / width;
  15832. var scaleY = boundsHeight / height;
  15833. var context = {
  15834. coords: coords,
  15835. colors: colors,
  15836. offsetX: -offsetX,
  15837. offsetY: -offsetY,
  15838. scaleX: 1 / scaleX,
  15839. scaleY: 1 / scaleY
  15840. };
  15841. var paddedWidth = width + BORDER_SIZE * 2;
  15842. var paddedHeight = height + BORDER_SIZE * 2;
  15843. var canvas, tmpCanvas, i, ii;
  15844. if (_webgl.WebGLUtils.isEnabled) {
  15845. canvas = _webgl.WebGLUtils.drawFigures(width, height, backgroundColor, figures, context);
  15846. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  15847. tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE);
  15848. canvas = tmpCanvas.canvas;
  15849. } else {
  15850. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  15851. var tmpCtx = tmpCanvas.context;
  15852. var data = tmpCtx.createImageData(width, height);
  15853. if (backgroundColor) {
  15854. var bytes = data.data;
  15855. for (i = 0, ii = bytes.length; i < ii; i += 4) {
  15856. bytes[i] = backgroundColor[0];
  15857. bytes[i + 1] = backgroundColor[1];
  15858. bytes[i + 2] = backgroundColor[2];
  15859. bytes[i + 3] = 255;
  15860. }
  15861. }
  15862. for (i = 0; i < figures.length; i++) {
  15863. drawFigure(data, figures[i], context);
  15864. }
  15865. tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);
  15866. canvas = tmpCanvas.canvas;
  15867. }
  15868. return {
  15869. canvas: canvas,
  15870. offsetX: offsetX - BORDER_SIZE * scaleX,
  15871. offsetY: offsetY - BORDER_SIZE * scaleY,
  15872. scaleX: scaleX,
  15873. scaleY: scaleY
  15874. };
  15875. }
  15876. return createMeshCanvas;
  15877. }();
  15878. ShadingIRs.Mesh = {
  15879. fromIR: function Mesh_fromIR(raw) {
  15880. var coords = raw[2];
  15881. var colors = raw[3];
  15882. var figures = raw[4];
  15883. var bounds = raw[5];
  15884. var matrix = raw[6];
  15885. var background = raw[8];
  15886. return {
  15887. type: 'Pattern',
  15888. getPattern: function Mesh_getPattern(ctx, owner, shadingFill) {
  15889. var scale;
  15890. if (shadingFill) {
  15891. scale = _util.Util.singularValueDecompose2dScale(ctx.mozCurrentTransform);
  15892. } else {
  15893. scale = _util.Util.singularValueDecompose2dScale(owner.baseTransform);
  15894. if (matrix) {
  15895. var matrixScale = _util.Util.singularValueDecompose2dScale(matrix);
  15896. scale = [scale[0] * matrixScale[0], scale[1] * matrixScale[1]];
  15897. }
  15898. }
  15899. var temporaryPatternCanvas = createMeshCanvas(bounds, scale, coords, colors, figures, shadingFill ? null : background, owner.cachedCanvases);
  15900. if (!shadingFill) {
  15901. ctx.setTransform.apply(ctx, owner.baseTransform);
  15902. if (matrix) {
  15903. ctx.transform.apply(ctx, matrix);
  15904. }
  15905. }
  15906. ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
  15907. ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY);
  15908. return ctx.createPattern(temporaryPatternCanvas.canvas, 'no-repeat');
  15909. }
  15910. };
  15911. }
  15912. };
  15913. ShadingIRs.Dummy = {
  15914. fromIR: function Dummy_fromIR() {
  15915. return {
  15916. type: 'Pattern',
  15917. getPattern: function Dummy_fromIR_getPattern() {
  15918. return 'hotpink';
  15919. }
  15920. };
  15921. }
  15922. };
  15923. function getShadingPatternFromIR(raw) {
  15924. var shadingIR = ShadingIRs[raw[0]];
  15925. if (!shadingIR) {
  15926. throw new Error('Unknown IR type: ' + raw[0]);
  15927. }
  15928. return shadingIR.fromIR(raw);
  15929. }
  15930. var TilingPattern = function TilingPatternClosure() {
  15931. var PaintType = {
  15932. COLORED: 1,
  15933. UNCOLORED: 2
  15934. };
  15935. var MAX_PATTERN_SIZE = 3000;
  15936. function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
  15937. this.operatorList = IR[2];
  15938. this.matrix = IR[3] || [1, 0, 0, 1, 0, 0];
  15939. this.bbox = IR[4];
  15940. this.xstep = IR[5];
  15941. this.ystep = IR[6];
  15942. this.paintType = IR[7];
  15943. this.tilingType = IR[8];
  15944. this.color = color;
  15945. this.canvasGraphicsFactory = canvasGraphicsFactory;
  15946. this.baseTransform = baseTransform;
  15947. this.type = 'Pattern';
  15948. this.ctx = ctx;
  15949. }
  15950. TilingPattern.prototype = {
  15951. createPatternCanvas: function TilinPattern_createPatternCanvas(owner) {
  15952. var operatorList = this.operatorList;
  15953. var bbox = this.bbox;
  15954. var xstep = this.xstep;
  15955. var ystep = this.ystep;
  15956. var paintType = this.paintType;
  15957. var tilingType = this.tilingType;
  15958. var color = this.color;
  15959. var canvasGraphicsFactory = this.canvasGraphicsFactory;
  15960. (0, _util.info)('TilingType: ' + tilingType);
  15961. var x0 = bbox[0],
  15962. y0 = bbox[1],
  15963. x1 = bbox[2],
  15964. y1 = bbox[3];
  15965. var topLeft = [x0, y0];
  15966. var botRight = [x0 + xstep, y0 + ystep];
  15967. var width = botRight[0] - topLeft[0];
  15968. var height = botRight[1] - topLeft[1];
  15969. var matrixScale = _util.Util.singularValueDecompose2dScale(this.matrix);
  15970. var curMatrixScale = _util.Util.singularValueDecompose2dScale(this.baseTransform);
  15971. var combinedScale = [matrixScale[0] * curMatrixScale[0], matrixScale[1] * curMatrixScale[1]];
  15972. width = Math.min(Math.ceil(Math.abs(width * combinedScale[0])), MAX_PATTERN_SIZE);
  15973. height = Math.min(Math.ceil(Math.abs(height * combinedScale[1])), MAX_PATTERN_SIZE);
  15974. var tmpCanvas = owner.cachedCanvases.getCanvas('pattern', width, height, true);
  15975. var tmpCtx = tmpCanvas.context;
  15976. var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx);
  15977. graphics.groupLevel = owner.groupLevel;
  15978. this.setFillAndStrokeStyleToContext(graphics, paintType, color);
  15979. this.setScale(width, height, xstep, ystep);
  15980. this.transformToScale(graphics);
  15981. var tmpTranslate = [1, 0, 0, 1, -topLeft[0], -topLeft[1]];
  15982. graphics.transform.apply(graphics, tmpTranslate);
  15983. this.clipBbox(graphics, bbox, x0, y0, x1, y1);
  15984. graphics.executeOperatorList(operatorList);
  15985. return tmpCanvas.canvas;
  15986. },
  15987. setScale: function TilingPattern_setScale(width, height, xstep, ystep) {
  15988. this.scale = [width / xstep, height / ystep];
  15989. },
  15990. transformToScale: function TilingPattern_transformToScale(graphics) {
  15991. var scale = this.scale;
  15992. var tmpScale = [scale[0], 0, 0, scale[1], 0, 0];
  15993. graphics.transform.apply(graphics, tmpScale);
  15994. },
  15995. scaleToContext: function TilingPattern_scaleToContext() {
  15996. var scale = this.scale;
  15997. this.ctx.scale(1 / scale[0], 1 / scale[1]);
  15998. },
  15999. clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) {
  16000. if (Array.isArray(bbox) && bbox.length === 4) {
  16001. var bboxWidth = x1 - x0;
  16002. var bboxHeight = y1 - y0;
  16003. graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
  16004. graphics.clip();
  16005. graphics.endPath();
  16006. }
  16007. },
  16008. setFillAndStrokeStyleToContext: function setFillAndStrokeStyleToContext(graphics, paintType, color) {
  16009. var context = graphics.ctx,
  16010. current = graphics.current;
  16011. switch (paintType) {
  16012. case PaintType.COLORED:
  16013. var ctx = this.ctx;
  16014. context.fillStyle = ctx.fillStyle;
  16015. context.strokeStyle = ctx.strokeStyle;
  16016. current.fillColor = ctx.fillStyle;
  16017. current.strokeColor = ctx.strokeStyle;
  16018. break;
  16019. case PaintType.UNCOLORED:
  16020. var cssColor = _util.Util.makeCssRgb(color[0], color[1], color[2]);
  16021. context.fillStyle = cssColor;
  16022. context.strokeStyle = cssColor;
  16023. current.fillColor = cssColor;
  16024. current.strokeColor = cssColor;
  16025. break;
  16026. default:
  16027. throw new _util.FormatError('Unsupported paint type: ' + paintType);
  16028. }
  16029. },
  16030. getPattern: function TilingPattern_getPattern(ctx, owner) {
  16031. var temporaryPatternCanvas = this.createPatternCanvas(owner);
  16032. ctx = this.ctx;
  16033. ctx.setTransform.apply(ctx, this.baseTransform);
  16034. ctx.transform.apply(ctx, this.matrix);
  16035. this.scaleToContext();
  16036. return ctx.createPattern(temporaryPatternCanvas, 'repeat');
  16037. }
  16038. };
  16039. return TilingPattern;
  16040. }();
  16041. exports.getShadingPatternFromIR = getShadingPatternFromIR;
  16042. exports.TilingPattern = TilingPattern;
  16043. /***/ }),
  16044. /* 121 */
  16045. /***/ (function(module, exports, __w_pdfjs_require__) {
  16046. "use strict";
  16047. Object.defineProperty(exports, "__esModule", {
  16048. value: true
  16049. });
  16050. exports.PDFDataTransportStream = undefined;
  16051. var _util = __w_pdfjs_require__(0);
  16052. var PDFDataTransportStream = function PDFDataTransportStreamClosure() {
  16053. function PDFDataTransportStream(params, pdfDataRangeTransport) {
  16054. var _this = this;
  16055. (0, _util.assert)(pdfDataRangeTransport);
  16056. this._queuedChunks = [];
  16057. var initialData = params.initialData;
  16058. if (initialData && initialData.length > 0) {
  16059. var buffer = new Uint8Array(initialData).buffer;
  16060. this._queuedChunks.push(buffer);
  16061. }
  16062. this._pdfDataRangeTransport = pdfDataRangeTransport;
  16063. this._isRangeSupported = !params.disableRange;
  16064. this._isStreamingSupported = !params.disableStream;
  16065. this._contentLength = params.length;
  16066. this._fullRequestReader = null;
  16067. this._rangeReaders = [];
  16068. this._pdfDataRangeTransport.addRangeListener(function (begin, chunk) {
  16069. _this._onReceiveData({
  16070. begin: begin,
  16071. chunk: chunk
  16072. });
  16073. });
  16074. this._pdfDataRangeTransport.addProgressListener(function (loaded) {
  16075. _this._onProgress({ loaded: loaded });
  16076. });
  16077. this._pdfDataRangeTransport.addProgressiveReadListener(function (chunk) {
  16078. _this._onReceiveData({ chunk: chunk });
  16079. });
  16080. this._pdfDataRangeTransport.transportReady();
  16081. }
  16082. PDFDataTransportStream.prototype = {
  16083. _onReceiveData: function PDFDataTransportStream_onReceiveData(args) {
  16084. var buffer = new Uint8Array(args.chunk).buffer;
  16085. if (args.begin === undefined) {
  16086. if (this._fullRequestReader) {
  16087. this._fullRequestReader._enqueue(buffer);
  16088. } else {
  16089. this._queuedChunks.push(buffer);
  16090. }
  16091. } else {
  16092. var found = this._rangeReaders.some(function (rangeReader) {
  16093. if (rangeReader._begin !== args.begin) {
  16094. return false;
  16095. }
  16096. rangeReader._enqueue(buffer);
  16097. return true;
  16098. });
  16099. (0, _util.assert)(found);
  16100. }
  16101. },
  16102. _onProgress: function PDFDataTransportStream_onDataProgress(evt) {
  16103. if (this._rangeReaders.length > 0) {
  16104. var firstReader = this._rangeReaders[0];
  16105. if (firstReader.onProgress) {
  16106. firstReader.onProgress({ loaded: evt.loaded });
  16107. }
  16108. }
  16109. },
  16110. _removeRangeReader: function PDFDataTransportStream_removeRangeReader(reader) {
  16111. var i = this._rangeReaders.indexOf(reader);
  16112. if (i >= 0) {
  16113. this._rangeReaders.splice(i, 1);
  16114. }
  16115. },
  16116. getFullReader: function PDFDataTransportStream_getFullReader() {
  16117. (0, _util.assert)(!this._fullRequestReader);
  16118. var queuedChunks = this._queuedChunks;
  16119. this._queuedChunks = null;
  16120. return new PDFDataTransportStreamReader(this, queuedChunks);
  16121. },
  16122. getRangeReader: function PDFDataTransportStream_getRangeReader(begin, end) {
  16123. var reader = new PDFDataTransportStreamRangeReader(this, begin, end);
  16124. this._pdfDataRangeTransport.requestDataRange(begin, end);
  16125. this._rangeReaders.push(reader);
  16126. return reader;
  16127. },
  16128. cancelAllRequests: function PDFDataTransportStream_cancelAllRequests(reason) {
  16129. if (this._fullRequestReader) {
  16130. this._fullRequestReader.cancel(reason);
  16131. }
  16132. var readers = this._rangeReaders.slice(0);
  16133. readers.forEach(function (rangeReader) {
  16134. rangeReader.cancel(reason);
  16135. });
  16136. this._pdfDataRangeTransport.abort();
  16137. }
  16138. };
  16139. function PDFDataTransportStreamReader(stream, queuedChunks) {
  16140. this._stream = stream;
  16141. this._done = false;
  16142. this._queuedChunks = queuedChunks || [];
  16143. this._requests = [];
  16144. this._headersReady = Promise.resolve();
  16145. stream._fullRequestReader = this;
  16146. this.onProgress = null;
  16147. }
  16148. PDFDataTransportStreamReader.prototype = {
  16149. _enqueue: function PDFDataTransportStreamReader_enqueue(chunk) {
  16150. if (this._done) {
  16151. return;
  16152. }
  16153. if (this._requests.length > 0) {
  16154. var requestCapability = this._requests.shift();
  16155. requestCapability.resolve({
  16156. value: chunk,
  16157. done: false
  16158. });
  16159. return;
  16160. }
  16161. this._queuedChunks.push(chunk);
  16162. },
  16163. get headersReady() {
  16164. return this._headersReady;
  16165. },
  16166. get isRangeSupported() {
  16167. return this._stream._isRangeSupported;
  16168. },
  16169. get isStreamingSupported() {
  16170. return this._stream._isStreamingSupported;
  16171. },
  16172. get contentLength() {
  16173. return this._stream._contentLength;
  16174. },
  16175. read: function PDFDataTransportStreamReader_read() {
  16176. if (this._queuedChunks.length > 0) {
  16177. var chunk = this._queuedChunks.shift();
  16178. return Promise.resolve({
  16179. value: chunk,
  16180. done: false
  16181. });
  16182. }
  16183. if (this._done) {
  16184. return Promise.resolve({
  16185. value: undefined,
  16186. done: true
  16187. });
  16188. }
  16189. var requestCapability = (0, _util.createPromiseCapability)();
  16190. this._requests.push(requestCapability);
  16191. return requestCapability.promise;
  16192. },
  16193. cancel: function PDFDataTransportStreamReader_cancel(reason) {
  16194. this._done = true;
  16195. this._requests.forEach(function (requestCapability) {
  16196. requestCapability.resolve({
  16197. value: undefined,
  16198. done: true
  16199. });
  16200. });
  16201. this._requests = [];
  16202. }
  16203. };
  16204. function PDFDataTransportStreamRangeReader(stream, begin, end) {
  16205. this._stream = stream;
  16206. this._begin = begin;
  16207. this._end = end;
  16208. this._queuedChunk = null;
  16209. this._requests = [];
  16210. this._done = false;
  16211. this.onProgress = null;
  16212. }
  16213. PDFDataTransportStreamRangeReader.prototype = {
  16214. _enqueue: function PDFDataTransportStreamRangeReader_enqueue(chunk) {
  16215. if (this._done) {
  16216. return;
  16217. }
  16218. if (this._requests.length === 0) {
  16219. this._queuedChunk = chunk;
  16220. } else {
  16221. var requestsCapability = this._requests.shift();
  16222. requestsCapability.resolve({
  16223. value: chunk,
  16224. done: false
  16225. });
  16226. this._requests.forEach(function (requestCapability) {
  16227. requestCapability.resolve({
  16228. value: undefined,
  16229. done: true
  16230. });
  16231. });
  16232. this._requests = [];
  16233. }
  16234. this._done = true;
  16235. this._stream._removeRangeReader(this);
  16236. },
  16237. get isStreamingSupported() {
  16238. return false;
  16239. },
  16240. read: function PDFDataTransportStreamRangeReader_read() {
  16241. if (this._queuedChunk) {
  16242. var chunk = this._queuedChunk;
  16243. this._queuedChunk = null;
  16244. return Promise.resolve({
  16245. value: chunk,
  16246. done: false
  16247. });
  16248. }
  16249. if (this._done) {
  16250. return Promise.resolve({
  16251. value: undefined,
  16252. done: true
  16253. });
  16254. }
  16255. var requestCapability = (0, _util.createPromiseCapability)();
  16256. this._requests.push(requestCapability);
  16257. return requestCapability.promise;
  16258. },
  16259. cancel: function PDFDataTransportStreamRangeReader_cancel(reason) {
  16260. this._done = true;
  16261. this._requests.forEach(function (requestCapability) {
  16262. requestCapability.resolve({
  16263. value: undefined,
  16264. done: true
  16265. });
  16266. });
  16267. this._requests = [];
  16268. this._stream._removeRangeReader(this);
  16269. }
  16270. };
  16271. return PDFDataTransportStream;
  16272. }();
  16273. exports.PDFDataTransportStream = PDFDataTransportStream;
  16274. /***/ }),
  16275. /* 122 */
  16276. /***/ (function(module, exports, __w_pdfjs_require__) {
  16277. "use strict";
  16278. Object.defineProperty(exports, "__esModule", {
  16279. value: true
  16280. });
  16281. exports.PDFNodeStream = undefined;
  16282. 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; }; }();
  16283. var _util = __w_pdfjs_require__(0);
  16284. var _network_utils = __w_pdfjs_require__(44);
  16285. 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; }
  16286. 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; }
  16287. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  16288. var fs = require('fs');
  16289. var http = require('http');
  16290. var https = require('https');
  16291. var url = require('url');
  16292. var PDFNodeStream = function () {
  16293. function PDFNodeStream(options) {
  16294. _classCallCheck(this, PDFNodeStream);
  16295. this.options = options;
  16296. this.source = options.source;
  16297. this.url = url.parse(this.source.url);
  16298. this.isHttp = this.url.protocol === 'http:' || this.url.protocol === 'https:';
  16299. this.isFsUrl = this.url.protocol === 'file:' || !this.url.host;
  16300. this.httpHeaders = this.isHttp && this.source.httpHeaders || {};
  16301. this._fullRequest = null;
  16302. this._rangeRequestReaders = [];
  16303. }
  16304. _createClass(PDFNodeStream, [{
  16305. key: 'getFullReader',
  16306. value: function getFullReader() {
  16307. (0, _util.assert)(!this._fullRequest);
  16308. this._fullRequest = this.isFsUrl ? new PDFNodeStreamFsFullReader(this) : new PDFNodeStreamFullReader(this);
  16309. return this._fullRequest;
  16310. }
  16311. }, {
  16312. key: 'getRangeReader',
  16313. value: function getRangeReader(start, end) {
  16314. var rangeReader = this.isFsUrl ? new PDFNodeStreamFsRangeReader(this, start, end) : new PDFNodeStreamRangeReader(this, start, end);
  16315. this._rangeRequestReaders.push(rangeReader);
  16316. return rangeReader;
  16317. }
  16318. }, {
  16319. key: 'cancelAllRequests',
  16320. value: function cancelAllRequests(reason) {
  16321. if (this._fullRequest) {
  16322. this._fullRequest.cancel(reason);
  16323. }
  16324. var readers = this._rangeRequestReaders.slice(0);
  16325. readers.forEach(function (reader) {
  16326. reader.cancel(reason);
  16327. });
  16328. }
  16329. }]);
  16330. return PDFNodeStream;
  16331. }();
  16332. var BaseFullReader = function () {
  16333. function BaseFullReader(stream) {
  16334. _classCallCheck(this, BaseFullReader);
  16335. this._url = stream.url;
  16336. this._done = false;
  16337. this._errored = false;
  16338. this._reason = null;
  16339. this.onProgress = null;
  16340. this._contentLength = stream.source.length;
  16341. this._loaded = 0;
  16342. this._disableRange = stream.options.disableRange || false;
  16343. this._rangeChunkSize = stream.source.rangeChunkSize;
  16344. if (!this._rangeChunkSize && !this._disableRange) {
  16345. this._disableRange = true;
  16346. }
  16347. this._isStreamingSupported = !stream.source.disableStream;
  16348. this._isRangeSupported = !stream.options.disableRange;
  16349. this._readableStream = null;
  16350. this._readCapability = (0, _util.createPromiseCapability)();
  16351. this._headersCapability = (0, _util.createPromiseCapability)();
  16352. }
  16353. _createClass(BaseFullReader, [{
  16354. key: 'read',
  16355. value: function read() {
  16356. var _this = this;
  16357. return this._readCapability.promise.then(function () {
  16358. if (_this._done) {
  16359. return Promise.resolve({
  16360. value: undefined,
  16361. done: true
  16362. });
  16363. }
  16364. if (_this._errored) {
  16365. return Promise.reject(_this._reason);
  16366. }
  16367. var chunk = _this._readableStream.read();
  16368. if (chunk === null) {
  16369. _this._readCapability = (0, _util.createPromiseCapability)();
  16370. return _this.read();
  16371. }
  16372. _this._loaded += chunk.length;
  16373. if (_this.onProgress) {
  16374. _this.onProgress({
  16375. loaded: _this._loaded,
  16376. total: _this._contentLength
  16377. });
  16378. }
  16379. var buffer = new Uint8Array(chunk).buffer;
  16380. return Promise.resolve({
  16381. value: buffer,
  16382. done: false
  16383. });
  16384. });
  16385. }
  16386. }, {
  16387. key: 'cancel',
  16388. value: function cancel(reason) {
  16389. if (!this._readableStream) {
  16390. this._error(reason);
  16391. return;
  16392. }
  16393. this._readableStream.destroy(reason);
  16394. }
  16395. }, {
  16396. key: '_error',
  16397. value: function _error(reason) {
  16398. this._errored = true;
  16399. this._reason = reason;
  16400. this._readCapability.resolve();
  16401. }
  16402. }, {
  16403. key: '_setReadableStream',
  16404. value: function _setReadableStream(readableStream) {
  16405. var _this2 = this;
  16406. this._readableStream = readableStream;
  16407. readableStream.on('readable', function () {
  16408. _this2._readCapability.resolve();
  16409. });
  16410. readableStream.on('end', function () {
  16411. readableStream.destroy();
  16412. _this2._done = true;
  16413. _this2._readCapability.resolve();
  16414. });
  16415. readableStream.on('error', function (reason) {
  16416. _this2._error(reason);
  16417. });
  16418. if (!this._isStreamingSupported && this._isRangeSupported) {
  16419. this._error(new _util.AbortException('streaming is disabled'));
  16420. }
  16421. if (this._errored) {
  16422. this._readableStream.destroy(this._reason);
  16423. }
  16424. }
  16425. }, {
  16426. key: 'headersReady',
  16427. get: function get() {
  16428. return this._headersCapability.promise;
  16429. }
  16430. }, {
  16431. key: 'contentLength',
  16432. get: function get() {
  16433. return this._contentLength;
  16434. }
  16435. }, {
  16436. key: 'isRangeSupported',
  16437. get: function get() {
  16438. return this._isRangeSupported;
  16439. }
  16440. }, {
  16441. key: 'isStreamingSupported',
  16442. get: function get() {
  16443. return this._isStreamingSupported;
  16444. }
  16445. }]);
  16446. return BaseFullReader;
  16447. }();
  16448. var BaseRangeReader = function () {
  16449. function BaseRangeReader(stream) {
  16450. _classCallCheck(this, BaseRangeReader);
  16451. this._url = stream.url;
  16452. this._done = false;
  16453. this._errored = false;
  16454. this._reason = null;
  16455. this.onProgress = null;
  16456. this._loaded = 0;
  16457. this._readableStream = null;
  16458. this._readCapability = (0, _util.createPromiseCapability)();
  16459. this._isStreamingSupported = !stream.source.disableStream;
  16460. }
  16461. _createClass(BaseRangeReader, [{
  16462. key: 'read',
  16463. value: function read() {
  16464. var _this3 = this;
  16465. return this._readCapability.promise.then(function () {
  16466. if (_this3._done) {
  16467. return Promise.resolve({
  16468. value: undefined,
  16469. done: true
  16470. });
  16471. }
  16472. if (_this3._errored) {
  16473. return Promise.reject(_this3._reason);
  16474. }
  16475. var chunk = _this3._readableStream.read();
  16476. if (chunk === null) {
  16477. _this3._readCapability = (0, _util.createPromiseCapability)();
  16478. return _this3.read();
  16479. }
  16480. _this3._loaded += chunk.length;
  16481. if (_this3.onProgress) {
  16482. _this3.onProgress({ loaded: _this3._loaded });
  16483. }
  16484. var buffer = new Uint8Array(chunk).buffer;
  16485. return Promise.resolve({
  16486. value: buffer,
  16487. done: false
  16488. });
  16489. });
  16490. }
  16491. }, {
  16492. key: 'cancel',
  16493. value: function cancel(reason) {
  16494. if (!this._readableStream) {
  16495. this._error(reason);
  16496. return;
  16497. }
  16498. this._readableStream.destroy(reason);
  16499. }
  16500. }, {
  16501. key: '_error',
  16502. value: function _error(reason) {
  16503. this._errored = true;
  16504. this._reason = reason;
  16505. this._readCapability.resolve();
  16506. }
  16507. }, {
  16508. key: '_setReadableStream',
  16509. value: function _setReadableStream(readableStream) {
  16510. var _this4 = this;
  16511. this._readableStream = readableStream;
  16512. readableStream.on('readable', function () {
  16513. _this4._readCapability.resolve();
  16514. });
  16515. readableStream.on('end', function () {
  16516. readableStream.destroy();
  16517. _this4._done = true;
  16518. _this4._readCapability.resolve();
  16519. });
  16520. readableStream.on('error', function (reason) {
  16521. _this4._error(reason);
  16522. });
  16523. if (this._errored) {
  16524. this._readableStream.destroy(this._reason);
  16525. }
  16526. }
  16527. }, {
  16528. key: 'isStreamingSupported',
  16529. get: function get() {
  16530. return this._isStreamingSupported;
  16531. }
  16532. }]);
  16533. return BaseRangeReader;
  16534. }();
  16535. function createRequestOptions(url, headers) {
  16536. return {
  16537. protocol: url.protocol,
  16538. auth: url.auth,
  16539. host: url.hostname,
  16540. port: url.port,
  16541. path: url.path,
  16542. method: 'GET',
  16543. headers: headers
  16544. };
  16545. }
  16546. var PDFNodeStreamFullReader = function (_BaseFullReader) {
  16547. _inherits(PDFNodeStreamFullReader, _BaseFullReader);
  16548. function PDFNodeStreamFullReader(stream) {
  16549. _classCallCheck(this, PDFNodeStreamFullReader);
  16550. var _this5 = _possibleConstructorReturn(this, (PDFNodeStreamFullReader.__proto__ || Object.getPrototypeOf(PDFNodeStreamFullReader)).call(this, stream));
  16551. var handleResponse = function handleResponse(response) {
  16552. _this5._headersCapability.resolve();
  16553. _this5._setReadableStream(response);
  16554. var _validateRangeRequest = (0, _network_utils.validateRangeRequestCapabilities)({
  16555. getResponseHeader: function getResponseHeader(name) {
  16556. return _this5._readableStream.headers[name.toLowerCase()];
  16557. },
  16558. isHttp: stream.isHttp,
  16559. rangeChunkSize: _this5._rangeChunkSize,
  16560. disableRange: _this5._disableRange
  16561. }),
  16562. allowRangeRequests = _validateRangeRequest.allowRangeRequests,
  16563. suggestedLength = _validateRangeRequest.suggestedLength;
  16564. if (allowRangeRequests) {
  16565. _this5._isRangeSupported = true;
  16566. }
  16567. _this5._contentLength = suggestedLength;
  16568. };
  16569. _this5._request = null;
  16570. if (_this5._url.protocol === 'http:') {
  16571. _this5._request = http.request(createRequestOptions(_this5._url, stream.httpHeaders), handleResponse);
  16572. } else {
  16573. _this5._request = https.request(createRequestOptions(_this5._url, stream.httpHeaders), handleResponse);
  16574. }
  16575. _this5._request.on('error', function (reason) {
  16576. _this5._errored = true;
  16577. _this5._reason = reason;
  16578. _this5._headersCapability.reject(reason);
  16579. });
  16580. _this5._request.end();
  16581. return _this5;
  16582. }
  16583. return PDFNodeStreamFullReader;
  16584. }(BaseFullReader);
  16585. var PDFNodeStreamRangeReader = function (_BaseRangeReader) {
  16586. _inherits(PDFNodeStreamRangeReader, _BaseRangeReader);
  16587. function PDFNodeStreamRangeReader(stream, start, end) {
  16588. _classCallCheck(this, PDFNodeStreamRangeReader);
  16589. var _this6 = _possibleConstructorReturn(this, (PDFNodeStreamRangeReader.__proto__ || Object.getPrototypeOf(PDFNodeStreamRangeReader)).call(this, stream));
  16590. _this6._httpHeaders = {};
  16591. for (var property in stream.httpHeaders) {
  16592. var value = stream.httpHeaders[property];
  16593. if (typeof value === 'undefined') {
  16594. continue;
  16595. }
  16596. _this6._httpHeaders[property] = value;
  16597. }
  16598. _this6._httpHeaders['Range'] = 'bytes=' + start + '-' + (end - 1);
  16599. _this6._request = null;
  16600. if (_this6._url.protocol === 'http:') {
  16601. _this6._request = http.request(createRequestOptions(_this6._url, _this6._httpHeaders), function (response) {
  16602. _this6._setReadableStream(response);
  16603. });
  16604. } else {
  16605. _this6._request = https.request(createRequestOptions(_this6._url, _this6._httpHeaders), function (response) {
  16606. _this6._setReadableStream(response);
  16607. });
  16608. }
  16609. _this6._request.on('error', function (reason) {
  16610. _this6._errored = true;
  16611. _this6._reason = reason;
  16612. });
  16613. _this6._request.end();
  16614. return _this6;
  16615. }
  16616. return PDFNodeStreamRangeReader;
  16617. }(BaseRangeReader);
  16618. var PDFNodeStreamFsFullReader = function (_BaseFullReader2) {
  16619. _inherits(PDFNodeStreamFsFullReader, _BaseFullReader2);
  16620. function PDFNodeStreamFsFullReader(stream) {
  16621. _classCallCheck(this, PDFNodeStreamFsFullReader);
  16622. var _this7 = _possibleConstructorReturn(this, (PDFNodeStreamFsFullReader.__proto__ || Object.getPrototypeOf(PDFNodeStreamFsFullReader)).call(this, stream));
  16623. var path = decodeURI(_this7._url.path);
  16624. fs.lstat(path, function (error, stat) {
  16625. if (error) {
  16626. _this7._errored = true;
  16627. _this7._reason = error;
  16628. _this7._headersCapability.reject(error);
  16629. return;
  16630. }
  16631. _this7._contentLength = stat.size;
  16632. _this7._setReadableStream(fs.createReadStream(path));
  16633. _this7._headersCapability.resolve();
  16634. });
  16635. return _this7;
  16636. }
  16637. return PDFNodeStreamFsFullReader;
  16638. }(BaseFullReader);
  16639. var PDFNodeStreamFsRangeReader = function (_BaseRangeReader2) {
  16640. _inherits(PDFNodeStreamFsRangeReader, _BaseRangeReader2);
  16641. function PDFNodeStreamFsRangeReader(stream, start, end) {
  16642. _classCallCheck(this, PDFNodeStreamFsRangeReader);
  16643. var _this8 = _possibleConstructorReturn(this, (PDFNodeStreamFsRangeReader.__proto__ || Object.getPrototypeOf(PDFNodeStreamFsRangeReader)).call(this, stream));
  16644. _this8._setReadableStream(fs.createReadStream(decodeURI(_this8._url.path), {
  16645. start: start,
  16646. end: end - 1
  16647. }));
  16648. return _this8;
  16649. }
  16650. return PDFNodeStreamFsRangeReader;
  16651. }(BaseRangeReader);
  16652. exports.PDFNodeStream = PDFNodeStream;
  16653. /***/ }),
  16654. /* 123 */
  16655. /***/ (function(module, exports, __w_pdfjs_require__) {
  16656. "use strict";
  16657. Object.defineProperty(exports, "__esModule", {
  16658. value: true
  16659. });
  16660. exports.PDFFetchStream = undefined;
  16661. 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; }; }();
  16662. var _util = __w_pdfjs_require__(0);
  16663. var _network_utils = __w_pdfjs_require__(44);
  16664. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  16665. function createFetchOptions(headers, withCredentials) {
  16666. return {
  16667. method: 'GET',
  16668. headers: headers,
  16669. mode: 'cors',
  16670. credentials: withCredentials ? 'include' : 'same-origin',
  16671. redirect: 'follow'
  16672. };
  16673. }
  16674. var PDFFetchStream = function () {
  16675. function PDFFetchStream(options) {
  16676. _classCallCheck(this, PDFFetchStream);
  16677. this.options = options;
  16678. this.source = options.source;
  16679. this.isHttp = /^https?:/i.test(this.source.url);
  16680. this.httpHeaders = this.isHttp && this.source.httpHeaders || {};
  16681. this._fullRequestReader = null;
  16682. this._rangeRequestReaders = [];
  16683. }
  16684. _createClass(PDFFetchStream, [{
  16685. key: 'getFullReader',
  16686. value: function getFullReader() {
  16687. (0, _util.assert)(!this._fullRequestReader);
  16688. this._fullRequestReader = new PDFFetchStreamReader(this);
  16689. return this._fullRequestReader;
  16690. }
  16691. }, {
  16692. key: 'getRangeReader',
  16693. value: function getRangeReader(begin, end) {
  16694. var reader = new PDFFetchStreamRangeReader(this, begin, end);
  16695. this._rangeRequestReaders.push(reader);
  16696. return reader;
  16697. }
  16698. }, {
  16699. key: 'cancelAllRequests',
  16700. value: function cancelAllRequests(reason) {
  16701. if (this._fullRequestReader) {
  16702. this._fullRequestReader.cancel(reason);
  16703. }
  16704. var readers = this._rangeRequestReaders.slice(0);
  16705. readers.forEach(function (reader) {
  16706. reader.cancel(reason);
  16707. });
  16708. }
  16709. }]);
  16710. return PDFFetchStream;
  16711. }();
  16712. var PDFFetchStreamReader = function () {
  16713. function PDFFetchStreamReader(stream) {
  16714. var _this = this;
  16715. _classCallCheck(this, PDFFetchStreamReader);
  16716. this._stream = stream;
  16717. this._reader = null;
  16718. this._loaded = 0;
  16719. this._withCredentials = stream.source.withCredentials;
  16720. this._contentLength = this._stream.source.length;
  16721. this._headersCapability = (0, _util.createPromiseCapability)();
  16722. this._disableRange = this._stream.options.disableRange;
  16723. this._rangeChunkSize = this._stream.source.rangeChunkSize;
  16724. if (!this._rangeChunkSize && !this._disableRange) {
  16725. this._disableRange = true;
  16726. }
  16727. this._isRangeSupported = !this._stream.options.disableRange;
  16728. this._isStreamingSupported = !this._stream.source.disableStream;
  16729. this._headers = new Headers();
  16730. for (var property in this._stream.httpHeaders) {
  16731. var value = this._stream.httpHeaders[property];
  16732. if (typeof value === 'undefined') {
  16733. continue;
  16734. }
  16735. this._headers.append(property, value);
  16736. }
  16737. var url = this._stream.source.url;
  16738. fetch(url, createFetchOptions(this._headers, this._withCredentials)).then(function (response) {
  16739. if (!(0, _network_utils.validateResponseStatus)(response.status)) {
  16740. throw (0, _network_utils.createResponseStatusError)(response.status, url);
  16741. }
  16742. _this._reader = response.body.getReader();
  16743. _this._headersCapability.resolve();
  16744. var _validateRangeRequest = (0, _network_utils.validateRangeRequestCapabilities)({
  16745. getResponseHeader: function getResponseHeader(name) {
  16746. return response.headers.get(name);
  16747. },
  16748. isHttp: _this._stream.isHttp,
  16749. rangeChunkSize: _this._rangeChunkSize,
  16750. disableRange: _this._disableRange
  16751. }),
  16752. allowRangeRequests = _validateRangeRequest.allowRangeRequests,
  16753. suggestedLength = _validateRangeRequest.suggestedLength;
  16754. _this._contentLength = suggestedLength;
  16755. _this._isRangeSupported = allowRangeRequests;
  16756. if (!_this._isStreamingSupported && _this._isRangeSupported) {
  16757. _this.cancel(new _util.AbortException('streaming is disabled'));
  16758. }
  16759. }).catch(this._headersCapability.reject);
  16760. this.onProgress = null;
  16761. }
  16762. _createClass(PDFFetchStreamReader, [{
  16763. key: 'read',
  16764. value: function read() {
  16765. var _this2 = this;
  16766. return this._headersCapability.promise.then(function () {
  16767. return _this2._reader.read().then(function (_ref) {
  16768. var value = _ref.value,
  16769. done = _ref.done;
  16770. if (done) {
  16771. return Promise.resolve({
  16772. value: value,
  16773. done: done
  16774. });
  16775. }
  16776. _this2._loaded += value.byteLength;
  16777. if (_this2.onProgress) {
  16778. _this2.onProgress({
  16779. loaded: _this2._loaded,
  16780. total: _this2._contentLength
  16781. });
  16782. }
  16783. var buffer = new Uint8Array(value).buffer;
  16784. return Promise.resolve({
  16785. value: buffer,
  16786. done: false
  16787. });
  16788. });
  16789. });
  16790. }
  16791. }, {
  16792. key: 'cancel',
  16793. value: function cancel(reason) {
  16794. if (this._reader) {
  16795. this._reader.cancel(reason);
  16796. }
  16797. }
  16798. }, {
  16799. key: 'headersReady',
  16800. get: function get() {
  16801. return this._headersCapability.promise;
  16802. }
  16803. }, {
  16804. key: 'contentLength',
  16805. get: function get() {
  16806. return this._contentLength;
  16807. }
  16808. }, {
  16809. key: 'isRangeSupported',
  16810. get: function get() {
  16811. return this._isRangeSupported;
  16812. }
  16813. }, {
  16814. key: 'isStreamingSupported',
  16815. get: function get() {
  16816. return this._isStreamingSupported;
  16817. }
  16818. }]);
  16819. return PDFFetchStreamReader;
  16820. }();
  16821. var PDFFetchStreamRangeReader = function () {
  16822. function PDFFetchStreamRangeReader(stream, begin, end) {
  16823. var _this3 = this;
  16824. _classCallCheck(this, PDFFetchStreamRangeReader);
  16825. this._stream = stream;
  16826. this._reader = null;
  16827. this._loaded = 0;
  16828. this._withCredentials = stream.source.withCredentials;
  16829. this._readCapability = (0, _util.createPromiseCapability)();
  16830. this._isStreamingSupported = !stream.source.disableStream;
  16831. this._headers = new Headers();
  16832. for (var property in this._stream.httpHeaders) {
  16833. var value = this._stream.httpHeaders[property];
  16834. if (typeof value === 'undefined') {
  16835. continue;
  16836. }
  16837. this._headers.append(property, value);
  16838. }
  16839. var rangeStr = begin + '-' + (end - 1);
  16840. this._headers.append('Range', 'bytes=' + rangeStr);
  16841. var url = this._stream.source.url;
  16842. fetch(url, createFetchOptions(this._headers, this._withCredentials)).then(function (response) {
  16843. if (!(0, _network_utils.validateResponseStatus)(response.status)) {
  16844. throw (0, _network_utils.createResponseStatusError)(response.status, url);
  16845. }
  16846. _this3._readCapability.resolve();
  16847. _this3._reader = response.body.getReader();
  16848. });
  16849. this.onProgress = null;
  16850. }
  16851. _createClass(PDFFetchStreamRangeReader, [{
  16852. key: 'read',
  16853. value: function read() {
  16854. var _this4 = this;
  16855. return this._readCapability.promise.then(function () {
  16856. return _this4._reader.read().then(function (_ref2) {
  16857. var value = _ref2.value,
  16858. done = _ref2.done;
  16859. if (done) {
  16860. return Promise.resolve({
  16861. value: value,
  16862. done: done
  16863. });
  16864. }
  16865. _this4._loaded += value.byteLength;
  16866. if (_this4.onProgress) {
  16867. _this4.onProgress({ loaded: _this4._loaded });
  16868. }
  16869. var buffer = new Uint8Array(value).buffer;
  16870. return Promise.resolve({
  16871. value: buffer,
  16872. done: false
  16873. });
  16874. });
  16875. });
  16876. }
  16877. }, {
  16878. key: 'cancel',
  16879. value: function cancel(reason) {
  16880. if (this._reader) {
  16881. this._reader.cancel(reason);
  16882. }
  16883. }
  16884. }, {
  16885. key: 'isStreamingSupported',
  16886. get: function get() {
  16887. return this._isStreamingSupported;
  16888. }
  16889. }]);
  16890. return PDFFetchStreamRangeReader;
  16891. }();
  16892. exports.PDFFetchStream = PDFFetchStream;
  16893. /***/ }),
  16894. /* 124 */
  16895. /***/ (function(module, exports, __w_pdfjs_require__) {
  16896. "use strict";
  16897. Object.defineProperty(exports, "__esModule", {
  16898. value: true
  16899. });
  16900. exports.NetworkManager = exports.PDFNetworkStream = undefined;
  16901. var _util = __w_pdfjs_require__(0);
  16902. var _network_utils = __w_pdfjs_require__(44);
  16903. var _global_scope = __w_pdfjs_require__(20);
  16904. var _global_scope2 = _interopRequireDefault(_global_scope);
  16905. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  16906. ;
  16907. var OK_RESPONSE = 200;
  16908. var PARTIAL_CONTENT_RESPONSE = 206;
  16909. function NetworkManager(url, args) {
  16910. this.url = url;
  16911. args = args || {};
  16912. this.isHttp = /^https?:/i.test(url);
  16913. this.httpHeaders = this.isHttp && args.httpHeaders || {};
  16914. this.withCredentials = args.withCredentials || false;
  16915. this.getXhr = args.getXhr || function NetworkManager_getXhr() {
  16916. return new XMLHttpRequest();
  16917. };
  16918. this.currXhrId = 0;
  16919. this.pendingRequests = Object.create(null);
  16920. this.loadedRequests = Object.create(null);
  16921. }
  16922. function getArrayBuffer(xhr) {
  16923. var data = xhr.response;
  16924. if (typeof data !== 'string') {
  16925. return data;
  16926. }
  16927. var array = (0, _util.stringToBytes)(data);
  16928. return array.buffer;
  16929. }
  16930. var supportsMozChunked = function supportsMozChunkedClosure() {
  16931. try {
  16932. var x = new XMLHttpRequest();
  16933. x.open('GET', _global_scope2.default.location.href);
  16934. x.responseType = 'moz-chunked-arraybuffer';
  16935. return x.responseType === 'moz-chunked-arraybuffer';
  16936. } catch (e) {
  16937. return false;
  16938. }
  16939. }();
  16940. NetworkManager.prototype = {
  16941. requestRange: function NetworkManager_requestRange(begin, end, listeners) {
  16942. var args = {
  16943. begin: begin,
  16944. end: end
  16945. };
  16946. for (var prop in listeners) {
  16947. args[prop] = listeners[prop];
  16948. }
  16949. return this.request(args);
  16950. },
  16951. requestFull: function NetworkManager_requestFull(listeners) {
  16952. return this.request(listeners);
  16953. },
  16954. request: function NetworkManager_request(args) {
  16955. var xhr = this.getXhr();
  16956. var xhrId = this.currXhrId++;
  16957. var pendingRequest = this.pendingRequests[xhrId] = { xhr: xhr };
  16958. xhr.open('GET', this.url);
  16959. xhr.withCredentials = this.withCredentials;
  16960. for (var property in this.httpHeaders) {
  16961. var value = this.httpHeaders[property];
  16962. if (typeof value === 'undefined') {
  16963. continue;
  16964. }
  16965. xhr.setRequestHeader(property, value);
  16966. }
  16967. if (this.isHttp && 'begin' in args && 'end' in args) {
  16968. var rangeStr = args.begin + '-' + (args.end - 1);
  16969. xhr.setRequestHeader('Range', 'bytes=' + rangeStr);
  16970. pendingRequest.expectedStatus = 206;
  16971. } else {
  16972. pendingRequest.expectedStatus = 200;
  16973. }
  16974. var useMozChunkedLoading = supportsMozChunked && !!args.onProgressiveData;
  16975. if (useMozChunkedLoading) {
  16976. xhr.responseType = 'moz-chunked-arraybuffer';
  16977. pendingRequest.onProgressiveData = args.onProgressiveData;
  16978. pendingRequest.mozChunked = true;
  16979. } else {
  16980. xhr.responseType = 'arraybuffer';
  16981. }
  16982. if (args.onError) {
  16983. xhr.onerror = function (evt) {
  16984. args.onError(xhr.status);
  16985. };
  16986. }
  16987. xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
  16988. xhr.onprogress = this.onProgress.bind(this, xhrId);
  16989. pendingRequest.onHeadersReceived = args.onHeadersReceived;
  16990. pendingRequest.onDone = args.onDone;
  16991. pendingRequest.onError = args.onError;
  16992. pendingRequest.onProgress = args.onProgress;
  16993. xhr.send(null);
  16994. return xhrId;
  16995. },
  16996. onProgress: function NetworkManager_onProgress(xhrId, evt) {
  16997. var pendingRequest = this.pendingRequests[xhrId];
  16998. if (!pendingRequest) {
  16999. return;
  17000. }
  17001. if (pendingRequest.mozChunked) {
  17002. var chunk = getArrayBuffer(pendingRequest.xhr);
  17003. pendingRequest.onProgressiveData(chunk);
  17004. }
  17005. var onProgress = pendingRequest.onProgress;
  17006. if (onProgress) {
  17007. onProgress(evt);
  17008. }
  17009. },
  17010. onStateChange: function NetworkManager_onStateChange(xhrId, evt) {
  17011. var pendingRequest = this.pendingRequests[xhrId];
  17012. if (!pendingRequest) {
  17013. return;
  17014. }
  17015. var xhr = pendingRequest.xhr;
  17016. if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
  17017. pendingRequest.onHeadersReceived();
  17018. delete pendingRequest.onHeadersReceived;
  17019. }
  17020. if (xhr.readyState !== 4) {
  17021. return;
  17022. }
  17023. if (!(xhrId in this.pendingRequests)) {
  17024. return;
  17025. }
  17026. delete this.pendingRequests[xhrId];
  17027. if (xhr.status === 0 && this.isHttp) {
  17028. if (pendingRequest.onError) {
  17029. pendingRequest.onError(xhr.status);
  17030. }
  17031. return;
  17032. }
  17033. var xhrStatus = xhr.status || OK_RESPONSE;
  17034. var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
  17035. if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
  17036. if (pendingRequest.onError) {
  17037. pendingRequest.onError(xhr.status);
  17038. }
  17039. return;
  17040. }
  17041. this.loadedRequests[xhrId] = true;
  17042. var chunk = getArrayBuffer(xhr);
  17043. if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
  17044. var rangeHeader = xhr.getResponseHeader('Content-Range');
  17045. var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
  17046. var begin = parseInt(matches[1], 10);
  17047. pendingRequest.onDone({
  17048. begin: begin,
  17049. chunk: chunk
  17050. });
  17051. } else if (pendingRequest.onProgressiveData) {
  17052. pendingRequest.onDone(null);
  17053. } else if (chunk) {
  17054. pendingRequest.onDone({
  17055. begin: 0,
  17056. chunk: chunk
  17057. });
  17058. } else if (pendingRequest.onError) {
  17059. pendingRequest.onError(xhr.status);
  17060. }
  17061. },
  17062. hasPendingRequests: function NetworkManager_hasPendingRequests() {
  17063. for (var xhrId in this.pendingRequests) {
  17064. return true;
  17065. }
  17066. return false;
  17067. },
  17068. getRequestXhr: function NetworkManager_getXhr(xhrId) {
  17069. return this.pendingRequests[xhrId].xhr;
  17070. },
  17071. isStreamingRequest: function NetworkManager_isStreamingRequest(xhrId) {
  17072. return !!this.pendingRequests[xhrId].onProgressiveData;
  17073. },
  17074. isPendingRequest: function NetworkManager_isPendingRequest(xhrId) {
  17075. return xhrId in this.pendingRequests;
  17076. },
  17077. isLoadedRequest: function NetworkManager_isLoadedRequest(xhrId) {
  17078. return xhrId in this.loadedRequests;
  17079. },
  17080. abortAllRequests: function NetworkManager_abortAllRequests() {
  17081. for (var xhrId in this.pendingRequests) {
  17082. this.abortRequest(xhrId | 0);
  17083. }
  17084. },
  17085. abortRequest: function NetworkManager_abortRequest(xhrId) {
  17086. var xhr = this.pendingRequests[xhrId].xhr;
  17087. delete this.pendingRequests[xhrId];
  17088. xhr.abort();
  17089. }
  17090. };
  17091. function PDFNetworkStream(options) {
  17092. this._options = options;
  17093. var source = options.source;
  17094. this._manager = new NetworkManager(source.url, {
  17095. httpHeaders: source.httpHeaders,
  17096. withCredentials: source.withCredentials
  17097. });
  17098. this._rangeChunkSize = source.rangeChunkSize;
  17099. this._fullRequestReader = null;
  17100. this._rangeRequestReaders = [];
  17101. }
  17102. PDFNetworkStream.prototype = {
  17103. _onRangeRequestReaderClosed: function PDFNetworkStream_onRangeRequestReaderClosed(reader) {
  17104. var i = this._rangeRequestReaders.indexOf(reader);
  17105. if (i >= 0) {
  17106. this._rangeRequestReaders.splice(i, 1);
  17107. }
  17108. },
  17109. getFullReader: function PDFNetworkStream_getFullReader() {
  17110. (0, _util.assert)(!this._fullRequestReader);
  17111. this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._options);
  17112. return this._fullRequestReader;
  17113. },
  17114. getRangeReader: function PDFNetworkStream_getRangeReader(begin, end) {
  17115. var reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
  17116. reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
  17117. this._rangeRequestReaders.push(reader);
  17118. return reader;
  17119. },
  17120. cancelAllRequests: function PDFNetworkStream_cancelAllRequests(reason) {
  17121. if (this._fullRequestReader) {
  17122. this._fullRequestReader.cancel(reason);
  17123. }
  17124. var readers = this._rangeRequestReaders.slice(0);
  17125. readers.forEach(function (reader) {
  17126. reader.cancel(reason);
  17127. });
  17128. }
  17129. };
  17130. function PDFNetworkStreamFullRequestReader(manager, options) {
  17131. this._manager = manager;
  17132. var source = options.source;
  17133. var args = {
  17134. onHeadersReceived: this._onHeadersReceived.bind(this),
  17135. onProgressiveData: source.disableStream ? null : this._onProgressiveData.bind(this),
  17136. onDone: this._onDone.bind(this),
  17137. onError: this._onError.bind(this),
  17138. onProgress: this._onProgress.bind(this)
  17139. };
  17140. this._url = source.url;
  17141. this._fullRequestId = manager.requestFull(args);
  17142. this._headersReceivedCapability = (0, _util.createPromiseCapability)();
  17143. this._disableRange = options.disableRange || false;
  17144. this._contentLength = source.length;
  17145. this._rangeChunkSize = source.rangeChunkSize;
  17146. if (!this._rangeChunkSize && !this._disableRange) {
  17147. this._disableRange = true;
  17148. }
  17149. this._isStreamingSupported = false;
  17150. this._isRangeSupported = false;
  17151. this._cachedChunks = [];
  17152. this._requests = [];
  17153. this._done = false;
  17154. this._storedError = undefined;
  17155. this.onProgress = null;
  17156. }
  17157. PDFNetworkStreamFullRequestReader.prototype = {
  17158. _onHeadersReceived: function PDFNetworkStreamFullRequestReader_onHeadersReceived() {
  17159. var fullRequestXhrId = this._fullRequestId;
  17160. var fullRequestXhr = this._manager.getRequestXhr(fullRequestXhrId);
  17161. var _validateRangeRequest = (0, _network_utils.validateRangeRequestCapabilities)({
  17162. getResponseHeader: function getResponseHeader(name) {
  17163. return fullRequestXhr.getResponseHeader(name);
  17164. },
  17165. isHttp: this._manager.isHttp,
  17166. rangeChunkSize: this._rangeChunkSize,
  17167. disableRange: this._disableRange
  17168. }),
  17169. allowRangeRequests = _validateRangeRequest.allowRangeRequests,
  17170. suggestedLength = _validateRangeRequest.suggestedLength;
  17171. this._contentLength = suggestedLength || this._contentLength;
  17172. if (allowRangeRequests) {
  17173. this._isRangeSupported = true;
  17174. }
  17175. var networkManager = this._manager;
  17176. if (networkManager.isStreamingRequest(fullRequestXhrId)) {
  17177. this._isStreamingSupported = true;
  17178. } else if (this._isRangeSupported) {
  17179. networkManager.abortRequest(fullRequestXhrId);
  17180. }
  17181. this._headersReceivedCapability.resolve();
  17182. },
  17183. _onProgressiveData: function PDFNetworkStreamFullRequestReader_onProgressiveData(chunk) {
  17184. if (this._requests.length > 0) {
  17185. var requestCapability = this._requests.shift();
  17186. requestCapability.resolve({
  17187. value: chunk,
  17188. done: false
  17189. });
  17190. } else {
  17191. this._cachedChunks.push(chunk);
  17192. }
  17193. },
  17194. _onDone: function PDFNetworkStreamFullRequestReader_onDone(args) {
  17195. if (args) {
  17196. this._onProgressiveData(args.chunk);
  17197. }
  17198. this._done = true;
  17199. if (this._cachedChunks.length > 0) {
  17200. return;
  17201. }
  17202. this._requests.forEach(function (requestCapability) {
  17203. requestCapability.resolve({
  17204. value: undefined,
  17205. done: true
  17206. });
  17207. });
  17208. this._requests = [];
  17209. },
  17210. _onError: function PDFNetworkStreamFullRequestReader_onError(status) {
  17211. var url = this._url;
  17212. var exception = (0, _network_utils.createResponseStatusError)(status, url);
  17213. this._storedError = exception;
  17214. this._headersReceivedCapability.reject(exception);
  17215. this._requests.forEach(function (requestCapability) {
  17216. requestCapability.reject(exception);
  17217. });
  17218. this._requests = [];
  17219. this._cachedChunks = [];
  17220. },
  17221. _onProgress: function PDFNetworkStreamFullRequestReader_onProgress(data) {
  17222. if (this.onProgress) {
  17223. this.onProgress({
  17224. loaded: data.loaded,
  17225. total: data.lengthComputable ? data.total : this._contentLength
  17226. });
  17227. }
  17228. },
  17229. get isRangeSupported() {
  17230. return this._isRangeSupported;
  17231. },
  17232. get isStreamingSupported() {
  17233. return this._isStreamingSupported;
  17234. },
  17235. get contentLength() {
  17236. return this._contentLength;
  17237. },
  17238. get headersReady() {
  17239. return this._headersReceivedCapability.promise;
  17240. },
  17241. read: function PDFNetworkStreamFullRequestReader_read() {
  17242. if (this._storedError) {
  17243. return Promise.reject(this._storedError);
  17244. }
  17245. if (this._cachedChunks.length > 0) {
  17246. var chunk = this._cachedChunks.shift();
  17247. return Promise.resolve({
  17248. value: chunk,
  17249. done: false
  17250. });
  17251. }
  17252. if (this._done) {
  17253. return Promise.resolve({
  17254. value: undefined,
  17255. done: true
  17256. });
  17257. }
  17258. var requestCapability = (0, _util.createPromiseCapability)();
  17259. this._requests.push(requestCapability);
  17260. return requestCapability.promise;
  17261. },
  17262. cancel: function PDFNetworkStreamFullRequestReader_cancel(reason) {
  17263. this._done = true;
  17264. this._headersReceivedCapability.reject(reason);
  17265. this._requests.forEach(function (requestCapability) {
  17266. requestCapability.resolve({
  17267. value: undefined,
  17268. done: true
  17269. });
  17270. });
  17271. this._requests = [];
  17272. if (this._manager.isPendingRequest(this._fullRequestId)) {
  17273. this._manager.abortRequest(this._fullRequestId);
  17274. }
  17275. this._fullRequestReader = null;
  17276. }
  17277. };
  17278. function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
  17279. this._manager = manager;
  17280. var args = {
  17281. onDone: this._onDone.bind(this),
  17282. onProgress: this._onProgress.bind(this)
  17283. };
  17284. this._requestId = manager.requestRange(begin, end, args);
  17285. this._requests = [];
  17286. this._queuedChunk = null;
  17287. this._done = false;
  17288. this.onProgress = null;
  17289. this.onClosed = null;
  17290. }
  17291. PDFNetworkStreamRangeRequestReader.prototype = {
  17292. _close: function PDFNetworkStreamRangeRequestReader_close() {
  17293. if (this.onClosed) {
  17294. this.onClosed(this);
  17295. }
  17296. },
  17297. _onDone: function PDFNetworkStreamRangeRequestReader_onDone(data) {
  17298. var chunk = data.chunk;
  17299. if (this._requests.length > 0) {
  17300. var requestCapability = this._requests.shift();
  17301. requestCapability.resolve({
  17302. value: chunk,
  17303. done: false
  17304. });
  17305. } else {
  17306. this._queuedChunk = chunk;
  17307. }
  17308. this._done = true;
  17309. this._requests.forEach(function (requestCapability) {
  17310. requestCapability.resolve({
  17311. value: undefined,
  17312. done: true
  17313. });
  17314. });
  17315. this._requests = [];
  17316. this._close();
  17317. },
  17318. _onProgress: function PDFNetworkStreamRangeRequestReader_onProgress(evt) {
  17319. if (!this.isStreamingSupported && this.onProgress) {
  17320. this.onProgress({ loaded: evt.loaded });
  17321. }
  17322. },
  17323. get isStreamingSupported() {
  17324. return false;
  17325. },
  17326. read: function PDFNetworkStreamRangeRequestReader_read() {
  17327. if (this._queuedChunk !== null) {
  17328. var chunk = this._queuedChunk;
  17329. this._queuedChunk = null;
  17330. return Promise.resolve({
  17331. value: chunk,
  17332. done: false
  17333. });
  17334. }
  17335. if (this._done) {
  17336. return Promise.resolve({
  17337. value: undefined,
  17338. done: true
  17339. });
  17340. }
  17341. var requestCapability = (0, _util.createPromiseCapability)();
  17342. this._requests.push(requestCapability);
  17343. return requestCapability.promise;
  17344. },
  17345. cancel: function PDFNetworkStreamRangeRequestReader_cancel(reason) {
  17346. this._done = true;
  17347. this._requests.forEach(function (requestCapability) {
  17348. requestCapability.resolve({
  17349. value: undefined,
  17350. done: true
  17351. });
  17352. });
  17353. this._requests = [];
  17354. if (this._manager.isPendingRequest(this._requestId)) {
  17355. this._manager.abortRequest(this._requestId);
  17356. }
  17357. this._close();
  17358. }
  17359. };
  17360. exports.PDFNetworkStream = PDFNetworkStream;
  17361. exports.NetworkManager = NetworkManager;
  17362. /***/ })
  17363. /******/ ]);
  17364. });
  17365. //# sourceMappingURL=pdf.js.map