pdf.js 655 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2018 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * Javascript code in this page
  21. */
  22. (function webpackUniversalModuleDefinition(root, factory) {
  23. if(typeof exports === 'object' && typeof module === 'object')
  24. module.exports = factory();
  25. else if(typeof define === 'function' && define.amd)
  26. define("pdfjs-dist/build/pdf", [], factory);
  27. else if(typeof exports === 'object')
  28. exports["pdfjs-dist/build/pdf"] = factory();
  29. else
  30. root["pdfjs-dist/build/pdf"] = root.pdfjsLib = factory();
  31. })(this, function() {
  32. return /******/ (function(modules) { // webpackBootstrap
  33. /******/ // The module cache
  34. /******/ var installedModules = {};
  35. /******/
  36. /******/ // The require function
  37. /******/ function __w_pdfjs_require__(moduleId) {
  38. /******/
  39. /******/ // Check if module is in cache
  40. /******/ if(installedModules[moduleId]) {
  41. /******/ return installedModules[moduleId].exports;
  42. /******/ }
  43. /******/ // Create a new module (and put it into the cache)
  44. /******/ var module = installedModules[moduleId] = {
  45. /******/ i: moduleId,
  46. /******/ l: false,
  47. /******/ exports: {}
  48. /******/ };
  49. /******/
  50. /******/ // Execute the module function
  51. /******/ modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);
  52. /******/
  53. /******/ // Flag the module as loaded
  54. /******/ module.l = true;
  55. /******/
  56. /******/ // Return the exports of the module
  57. /******/ return module.exports;
  58. /******/ }
  59. /******/
  60. /******/
  61. /******/ // expose the modules object (__webpack_modules__)
  62. /******/ __w_pdfjs_require__.m = modules;
  63. /******/
  64. /******/ // expose the module cache
  65. /******/ __w_pdfjs_require__.c = installedModules;
  66. /******/
  67. /******/ // define getter function for harmony exports
  68. /******/ __w_pdfjs_require__.d = function(exports, name, getter) {
  69. /******/ if(!__w_pdfjs_require__.o(exports, name)) {
  70. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  71. /******/ }
  72. /******/ };
  73. /******/
  74. /******/ // define __esModule on exports
  75. /******/ __w_pdfjs_require__.r = function(exports) {
  76. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  77. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  78. /******/ }
  79. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  80. /******/ };
  81. /******/
  82. /******/ // create a fake namespace object
  83. /******/ // mode & 1: value is a module id, require it
  84. /******/ // mode & 2: merge all properties of value into the ns
  85. /******/ // mode & 4: return value when already ns object
  86. /******/ // mode & 8|1: behave like require
  87. /******/ __w_pdfjs_require__.t = function(value, mode) {
  88. /******/ if(mode & 1) value = __w_pdfjs_require__(value);
  89. /******/ if(mode & 8) return value;
  90. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  91. /******/ var ns = Object.create(null);
  92. /******/ __w_pdfjs_require__.r(ns);
  93. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  94. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __w_pdfjs_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  95. /******/ return ns;
  96. /******/ };
  97. /******/
  98. /******/ // getDefaultExport function for compatibility with non-harmony modules
  99. /******/ __w_pdfjs_require__.n = function(module) {
  100. /******/ var getter = module && module.__esModule ?
  101. /******/ function getDefault() { return module['default']; } :
  102. /******/ function getModuleExports() { return module; };
  103. /******/ __w_pdfjs_require__.d(getter, 'a', getter);
  104. /******/ return getter;
  105. /******/ };
  106. /******/
  107. /******/ // Object.prototype.hasOwnProperty.call
  108. /******/ __w_pdfjs_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  109. /******/
  110. /******/ // __webpack_public_path__
  111. /******/ __w_pdfjs_require__.p = "";
  112. /******/
  113. /******/
  114. /******/ // Load entry module and return exports
  115. /******/ return __w_pdfjs_require__(__w_pdfjs_require__.s = 0);
  116. /******/ })
  117. /************************************************************************/
  118. /******/ ([
  119. /* 0 */
  120. /***/ (function(module, exports, __w_pdfjs_require__) {
  121. "use strict";
  122. var pdfjsVersion = '2.0.943';
  123. var pdfjsBuild = 'dc98bf76';
  124. var pdfjsSharedUtil = __w_pdfjs_require__(1);
  125. var pdfjsDisplayAPI = __w_pdfjs_require__(129);
  126. var pdfjsDisplayTextLayer = __w_pdfjs_require__(145);
  127. var pdfjsDisplayAnnotationLayer = __w_pdfjs_require__(146);
  128. var pdfjsDisplayDOMUtils = __w_pdfjs_require__(130);
  129. var pdfjsDisplaySVG = __w_pdfjs_require__(147);
  130. var pdfjsDisplayWorkerOptions = __w_pdfjs_require__(135);
  131. var pdfjsDisplayAPICompatibility = __w_pdfjs_require__(132);
  132. {
  133. var isNodeJS = __w_pdfjs_require__(4);
  134. if (isNodeJS()) {
  135. var PDFNodeStream = __w_pdfjs_require__(148).PDFNodeStream;
  136. pdfjsDisplayAPI.setPDFNetworkStreamFactory(function (params) {
  137. return new PDFNodeStream(params);
  138. });
  139. } else if (typeof Response !== 'undefined' && 'body' in Response.prototype && typeof ReadableStream !== 'undefined') {
  140. var PDFFetchStream = __w_pdfjs_require__(151).PDFFetchStream;
  141. pdfjsDisplayAPI.setPDFNetworkStreamFactory(function (params) {
  142. return new PDFFetchStream(params);
  143. });
  144. } else {
  145. var PDFNetworkStream = __w_pdfjs_require__(152).PDFNetworkStream;
  146. pdfjsDisplayAPI.setPDFNetworkStreamFactory(function (params) {
  147. return new PDFNetworkStream(params);
  148. });
  149. }
  150. }
  151. exports.build = pdfjsDisplayAPI.build;
  152. exports.version = pdfjsDisplayAPI.version;
  153. exports.getDocument = pdfjsDisplayAPI.getDocument;
  154. exports.LoopbackPort = pdfjsDisplayAPI.LoopbackPort;
  155. exports.PDFDataRangeTransport = pdfjsDisplayAPI.PDFDataRangeTransport;
  156. exports.PDFWorker = pdfjsDisplayAPI.PDFWorker;
  157. exports.renderTextLayer = pdfjsDisplayTextLayer.renderTextLayer;
  158. exports.AnnotationLayer = pdfjsDisplayAnnotationLayer.AnnotationLayer;
  159. exports.createPromiseCapability = pdfjsSharedUtil.createPromiseCapability;
  160. exports.PasswordResponses = pdfjsSharedUtil.PasswordResponses;
  161. exports.InvalidPDFException = pdfjsSharedUtil.InvalidPDFException;
  162. exports.MissingPDFException = pdfjsSharedUtil.MissingPDFException;
  163. exports.SVGGraphics = pdfjsDisplaySVG.SVGGraphics;
  164. exports.NativeImageDecoding = pdfjsSharedUtil.NativeImageDecoding;
  165. exports.CMapCompressionType = pdfjsSharedUtil.CMapCompressionType;
  166. exports.PermissionFlag = pdfjsSharedUtil.PermissionFlag;
  167. exports.UnexpectedResponseException = pdfjsSharedUtil.UnexpectedResponseException;
  168. exports.OPS = pdfjsSharedUtil.OPS;
  169. exports.VerbosityLevel = pdfjsSharedUtil.VerbosityLevel;
  170. exports.UNSUPPORTED_FEATURES = pdfjsSharedUtil.UNSUPPORTED_FEATURES;
  171. exports.createValidAbsoluteUrl = pdfjsSharedUtil.createValidAbsoluteUrl;
  172. exports.createObjectURL = pdfjsSharedUtil.createObjectURL;
  173. exports.removeNullCharacters = pdfjsSharedUtil.removeNullCharacters;
  174. exports.shadow = pdfjsSharedUtil.shadow;
  175. exports.Util = pdfjsSharedUtil.Util;
  176. exports.ReadableStream = pdfjsSharedUtil.ReadableStream;
  177. exports.URL = pdfjsSharedUtil.URL;
  178. exports.RenderingCancelledException = pdfjsDisplayDOMUtils.RenderingCancelledException;
  179. exports.getFilenameFromUrl = pdfjsDisplayDOMUtils.getFilenameFromUrl;
  180. exports.LinkTarget = pdfjsDisplayDOMUtils.LinkTarget;
  181. exports.addLinkAttributes = pdfjsDisplayDOMUtils.addLinkAttributes;
  182. exports.loadScript = pdfjsDisplayDOMUtils.loadScript;
  183. exports.GlobalWorkerOptions = pdfjsDisplayWorkerOptions.GlobalWorkerOptions;
  184. exports.apiCompatibilityParams = pdfjsDisplayAPICompatibility.apiCompatibilityParams;
  185. /***/ }),
  186. /* 1 */
  187. /***/ (function(module, exports, __w_pdfjs_require__) {
  188. "use strict";
  189. Object.defineProperty(exports, "__esModule", {
  190. value: true
  191. });
  192. exports.unreachable = exports.warn = exports.utf8StringToString = exports.stringToUTF8String = exports.stringToPDFString = exports.stringToBytes = exports.string32 = exports.shadow = exports.setVerbosityLevel = exports.URL = exports.ReadableStream = exports.removeNullCharacters = exports.readUint32 = exports.readUint16 = exports.readInt8 = exports.log2 = exports.isEvalSupported = exports.isLittleEndian = exports.createValidAbsoluteUrl = exports.isSameOrigin = exports.isSpace = exports.isString = exports.isNum = exports.isEmptyObj = exports.isBool = exports.isArrayBuffer = exports.info = exports.getVerbosityLevel = exports.getLookupTableFactory = exports.getInheritableProperty = exports.deprecated = exports.createObjectURL = exports.createPromiseCapability = exports.bytesToString = exports.assert = exports.arraysToBytes = exports.arrayByteLength = exports.FormatError = exports.XRefParseException = exports.toRomanNumerals = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.PermissionFlag = exports.PasswordResponses = exports.PasswordException = exports.NativeImageDecoding = exports.MissingPDFException = exports.MissingDataException = exports.InvalidPDFException = exports.AbortException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VerbosityLevel = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = undefined;
  193. 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; };
  194. __w_pdfjs_require__(2);
  195. var _streams_polyfill = __w_pdfjs_require__(125);
  196. var _url_polyfill = __w_pdfjs_require__(127);
  197. var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
  198. var FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
  199. var NativeImageDecoding = {
  200. NONE: 'none',
  201. DECODE: 'decode',
  202. DISPLAY: 'display'
  203. };
  204. var PermissionFlag = {
  205. PRINT: 0x04,
  206. MODIFY_CONTENTS: 0x08,
  207. COPY: 0x10,
  208. MODIFY_ANNOTATIONS: 0x20,
  209. FILL_INTERACTIVE_FORMS: 0x100,
  210. COPY_FOR_ACCESSIBILITY: 0x200,
  211. ASSEMBLE: 0x400,
  212. PRINT_HIGH_QUALITY: 0x800
  213. };
  214. var TextRenderingMode = {
  215. FILL: 0,
  216. STROKE: 1,
  217. FILL_STROKE: 2,
  218. INVISIBLE: 3,
  219. FILL_ADD_TO_PATH: 4,
  220. STROKE_ADD_TO_PATH: 5,
  221. FILL_STROKE_ADD_TO_PATH: 6,
  222. ADD_TO_PATH: 7,
  223. FILL_STROKE_MASK: 3,
  224. ADD_TO_PATH_FLAG: 4
  225. };
  226. var ImageKind = {
  227. GRAYSCALE_1BPP: 1,
  228. RGB_24BPP: 2,
  229. RGBA_32BPP: 3
  230. };
  231. var AnnotationType = {
  232. TEXT: 1,
  233. LINK: 2,
  234. FREETEXT: 3,
  235. LINE: 4,
  236. SQUARE: 5,
  237. CIRCLE: 6,
  238. POLYGON: 7,
  239. POLYLINE: 8,
  240. HIGHLIGHT: 9,
  241. UNDERLINE: 10,
  242. SQUIGGLY: 11,
  243. STRIKEOUT: 12,
  244. STAMP: 13,
  245. CARET: 14,
  246. INK: 15,
  247. POPUP: 16,
  248. FILEATTACHMENT: 17,
  249. SOUND: 18,
  250. MOVIE: 19,
  251. WIDGET: 20,
  252. SCREEN: 21,
  253. PRINTERMARK: 22,
  254. TRAPNET: 23,
  255. WATERMARK: 24,
  256. THREED: 25,
  257. REDACT: 26
  258. };
  259. var AnnotationFlag = {
  260. INVISIBLE: 0x01,
  261. HIDDEN: 0x02,
  262. PRINT: 0x04,
  263. NOZOOM: 0x08,
  264. NOROTATE: 0x10,
  265. NOVIEW: 0x20,
  266. READONLY: 0x40,
  267. LOCKED: 0x80,
  268. TOGGLENOVIEW: 0x100,
  269. LOCKEDCONTENTS: 0x200
  270. };
  271. var AnnotationFieldFlag = {
  272. READONLY: 0x0000001,
  273. REQUIRED: 0x0000002,
  274. NOEXPORT: 0x0000004,
  275. MULTILINE: 0x0001000,
  276. PASSWORD: 0x0002000,
  277. NOTOGGLETOOFF: 0x0004000,
  278. RADIO: 0x0008000,
  279. PUSHBUTTON: 0x0010000,
  280. COMBO: 0x0020000,
  281. EDIT: 0x0040000,
  282. SORT: 0x0080000,
  283. FILESELECT: 0x0100000,
  284. MULTISELECT: 0x0200000,
  285. DONOTSPELLCHECK: 0x0400000,
  286. DONOTSCROLL: 0x0800000,
  287. COMB: 0x1000000,
  288. RICHTEXT: 0x2000000,
  289. RADIOSINUNISON: 0x2000000,
  290. COMMITONSELCHANGE: 0x4000000
  291. };
  292. var AnnotationBorderStyleType = {
  293. SOLID: 1,
  294. DASHED: 2,
  295. BEVELED: 3,
  296. INSET: 4,
  297. UNDERLINE: 5
  298. };
  299. var StreamType = {
  300. UNKNOWN: 0,
  301. FLATE: 1,
  302. LZW: 2,
  303. DCT: 3,
  304. JPX: 4,
  305. JBIG: 5,
  306. A85: 6,
  307. AHX: 7,
  308. CCF: 8,
  309. RL: 9
  310. };
  311. var FontType = {
  312. UNKNOWN: 0,
  313. TYPE1: 1,
  314. TYPE1C: 2,
  315. CIDFONTTYPE0: 3,
  316. CIDFONTTYPE0C: 4,
  317. TRUETYPE: 5,
  318. CIDFONTTYPE2: 6,
  319. TYPE3: 7,
  320. OPENTYPE: 8,
  321. TYPE0: 9,
  322. MMTYPE1: 10
  323. };
  324. var VerbosityLevel = {
  325. ERRORS: 0,
  326. WARNINGS: 1,
  327. INFOS: 5
  328. };
  329. var CMapCompressionType = {
  330. NONE: 0,
  331. BINARY: 1,
  332. STREAM: 2
  333. };
  334. var OPS = {
  335. dependency: 1,
  336. setLineWidth: 2,
  337. setLineCap: 3,
  338. setLineJoin: 4,
  339. setMiterLimit: 5,
  340. setDash: 6,
  341. setRenderingIntent: 7,
  342. setFlatness: 8,
  343. setGState: 9,
  344. save: 10,
  345. restore: 11,
  346. transform: 12,
  347. moveTo: 13,
  348. lineTo: 14,
  349. curveTo: 15,
  350. curveTo2: 16,
  351. curveTo3: 17,
  352. closePath: 18,
  353. rectangle: 19,
  354. stroke: 20,
  355. closeStroke: 21,
  356. fill: 22,
  357. eoFill: 23,
  358. fillStroke: 24,
  359. eoFillStroke: 25,
  360. closeFillStroke: 26,
  361. closeEOFillStroke: 27,
  362. endPath: 28,
  363. clip: 29,
  364. eoClip: 30,
  365. beginText: 31,
  366. endText: 32,
  367. setCharSpacing: 33,
  368. setWordSpacing: 34,
  369. setHScale: 35,
  370. setLeading: 36,
  371. setFont: 37,
  372. setTextRenderingMode: 38,
  373. setTextRise: 39,
  374. moveText: 40,
  375. setLeadingMoveText: 41,
  376. setTextMatrix: 42,
  377. nextLine: 43,
  378. showText: 44,
  379. showSpacedText: 45,
  380. nextLineShowText: 46,
  381. nextLineSetSpacingShowText: 47,
  382. setCharWidth: 48,
  383. setCharWidthAndBounds: 49,
  384. setStrokeColorSpace: 50,
  385. setFillColorSpace: 51,
  386. setStrokeColor: 52,
  387. setStrokeColorN: 53,
  388. setFillColor: 54,
  389. setFillColorN: 55,
  390. setStrokeGray: 56,
  391. setFillGray: 57,
  392. setStrokeRGBColor: 58,
  393. setFillRGBColor: 59,
  394. setStrokeCMYKColor: 60,
  395. setFillCMYKColor: 61,
  396. shadingFill: 62,
  397. beginInlineImage: 63,
  398. beginImageData: 64,
  399. endInlineImage: 65,
  400. paintXObject: 66,
  401. markPoint: 67,
  402. markPointProps: 68,
  403. beginMarkedContent: 69,
  404. beginMarkedContentProps: 70,
  405. endMarkedContent: 71,
  406. beginCompat: 72,
  407. endCompat: 73,
  408. paintFormXObjectBegin: 74,
  409. paintFormXObjectEnd: 75,
  410. beginGroup: 76,
  411. endGroup: 77,
  412. beginAnnotations: 78,
  413. endAnnotations: 79,
  414. beginAnnotation: 80,
  415. endAnnotation: 81,
  416. paintJpegXObject: 82,
  417. paintImageMaskXObject: 83,
  418. paintImageMaskXObjectGroup: 84,
  419. paintImageXObject: 85,
  420. paintInlineImageXObject: 86,
  421. paintInlineImageXObjectGroup: 87,
  422. paintImageXObjectRepeat: 88,
  423. paintImageMaskXObjectRepeat: 89,
  424. paintSolidColorImageMask: 90,
  425. constructPath: 91
  426. };
  427. var UNSUPPORTED_FEATURES = {
  428. unknown: 'unknown',
  429. forms: 'forms',
  430. javaScript: 'javaScript',
  431. smask: 'smask',
  432. shadingPattern: 'shadingPattern',
  433. font: 'font'
  434. };
  435. var PasswordResponses = {
  436. NEED_PASSWORD: 1,
  437. INCORRECT_PASSWORD: 2
  438. };
  439. var verbosity = VerbosityLevel.WARNINGS;
  440. function setVerbosityLevel(level) {
  441. if (Number.isInteger(level)) {
  442. verbosity = level;
  443. }
  444. }
  445. function getVerbosityLevel() {
  446. return verbosity;
  447. }
  448. function info(msg) {
  449. if (verbosity >= VerbosityLevel.INFOS) {
  450. console.log('Info: ' + msg);
  451. }
  452. }
  453. function warn(msg) {
  454. if (verbosity >= VerbosityLevel.WARNINGS) {
  455. console.log('Warning: ' + msg);
  456. }
  457. }
  458. function deprecated(details) {
  459. console.log('Deprecated API usage: ' + details);
  460. }
  461. function unreachable(msg) {
  462. throw new Error(msg);
  463. }
  464. function assert(cond, msg) {
  465. if (!cond) {
  466. unreachable(msg);
  467. }
  468. }
  469. function isSameOrigin(baseUrl, otherUrl) {
  470. try {
  471. var base = new _url_polyfill.URL(baseUrl);
  472. if (!base.origin || base.origin === 'null') {
  473. return false;
  474. }
  475. } catch (e) {
  476. return false;
  477. }
  478. var other = new _url_polyfill.URL(otherUrl, base);
  479. return base.origin === other.origin;
  480. }
  481. function _isValidProtocol(url) {
  482. if (!url) {
  483. return false;
  484. }
  485. switch (url.protocol) {
  486. case 'http:':
  487. case 'https:':
  488. case 'ftp:':
  489. case 'mailto:':
  490. case 'tel:':
  491. return true;
  492. default:
  493. return false;
  494. }
  495. }
  496. function createValidAbsoluteUrl(url, baseUrl) {
  497. if (!url) {
  498. return null;
  499. }
  500. try {
  501. var absoluteUrl = baseUrl ? new _url_polyfill.URL(url, baseUrl) : new _url_polyfill.URL(url);
  502. if (_isValidProtocol(absoluteUrl)) {
  503. return absoluteUrl;
  504. }
  505. } catch (ex) {}
  506. return null;
  507. }
  508. function shadow(obj, prop, value) {
  509. Object.defineProperty(obj, prop, {
  510. value: value,
  511. enumerable: true,
  512. configurable: true,
  513. writable: false
  514. });
  515. return value;
  516. }
  517. function getLookupTableFactory(initializer) {
  518. var lookup;
  519. return function () {
  520. if (initializer) {
  521. lookup = Object.create(null);
  522. initializer(lookup);
  523. initializer = null;
  524. }
  525. return lookup;
  526. };
  527. }
  528. var PasswordException = function PasswordExceptionClosure() {
  529. function PasswordException(msg, code) {
  530. this.name = 'PasswordException';
  531. this.message = msg;
  532. this.code = code;
  533. }
  534. PasswordException.prototype = new Error();
  535. PasswordException.constructor = PasswordException;
  536. return PasswordException;
  537. }();
  538. var UnknownErrorException = function UnknownErrorExceptionClosure() {
  539. function UnknownErrorException(msg, details) {
  540. this.name = 'UnknownErrorException';
  541. this.message = msg;
  542. this.details = details;
  543. }
  544. UnknownErrorException.prototype = new Error();
  545. UnknownErrorException.constructor = UnknownErrorException;
  546. return UnknownErrorException;
  547. }();
  548. var InvalidPDFException = function InvalidPDFExceptionClosure() {
  549. function InvalidPDFException(msg) {
  550. this.name = 'InvalidPDFException';
  551. this.message = msg;
  552. }
  553. InvalidPDFException.prototype = new Error();
  554. InvalidPDFException.constructor = InvalidPDFException;
  555. return InvalidPDFException;
  556. }();
  557. var MissingPDFException = function MissingPDFExceptionClosure() {
  558. function MissingPDFException(msg) {
  559. this.name = 'MissingPDFException';
  560. this.message = msg;
  561. }
  562. MissingPDFException.prototype = new Error();
  563. MissingPDFException.constructor = MissingPDFException;
  564. return MissingPDFException;
  565. }();
  566. var UnexpectedResponseException = function UnexpectedResponseExceptionClosure() {
  567. function UnexpectedResponseException(msg, status) {
  568. this.name = 'UnexpectedResponseException';
  569. this.message = msg;
  570. this.status = status;
  571. }
  572. UnexpectedResponseException.prototype = new Error();
  573. UnexpectedResponseException.constructor = UnexpectedResponseException;
  574. return UnexpectedResponseException;
  575. }();
  576. var MissingDataException = function MissingDataExceptionClosure() {
  577. function MissingDataException(begin, end) {
  578. this.begin = begin;
  579. this.end = end;
  580. this.message = 'Missing data [' + begin + ', ' + end + ')';
  581. }
  582. MissingDataException.prototype = new Error();
  583. MissingDataException.prototype.name = 'MissingDataException';
  584. MissingDataException.constructor = MissingDataException;
  585. return MissingDataException;
  586. }();
  587. var XRefParseException = function XRefParseExceptionClosure() {
  588. function XRefParseException(msg) {
  589. this.message = msg;
  590. }
  591. XRefParseException.prototype = new Error();
  592. XRefParseException.prototype.name = 'XRefParseException';
  593. XRefParseException.constructor = XRefParseException;
  594. return XRefParseException;
  595. }();
  596. var FormatError = function FormatErrorClosure() {
  597. function FormatError(msg) {
  598. this.message = msg;
  599. }
  600. FormatError.prototype = new Error();
  601. FormatError.prototype.name = 'FormatError';
  602. FormatError.constructor = FormatError;
  603. return FormatError;
  604. }();
  605. var AbortException = function AbortExceptionClosure() {
  606. function AbortException(msg) {
  607. this.name = 'AbortException';
  608. this.message = msg;
  609. }
  610. AbortException.prototype = new Error();
  611. AbortException.constructor = AbortException;
  612. return AbortException;
  613. }();
  614. var NullCharactersRegExp = /\x00/g;
  615. function removeNullCharacters(str) {
  616. if (typeof str !== 'string') {
  617. warn('The argument for removeNullCharacters must be a string.');
  618. return str;
  619. }
  620. return str.replace(NullCharactersRegExp, '');
  621. }
  622. function bytesToString(bytes) {
  623. assert(bytes !== null && (typeof bytes === 'undefined' ? 'undefined' : _typeof(bytes)) === 'object' && bytes.length !== undefined, 'Invalid argument for bytesToString');
  624. var length = bytes.length;
  625. var MAX_ARGUMENT_COUNT = 8192;
  626. if (length < MAX_ARGUMENT_COUNT) {
  627. return String.fromCharCode.apply(null, bytes);
  628. }
  629. var strBuf = [];
  630. for (var i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
  631. var chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
  632. var chunk = bytes.subarray(i, chunkEnd);
  633. strBuf.push(String.fromCharCode.apply(null, chunk));
  634. }
  635. return strBuf.join('');
  636. }
  637. function stringToBytes(str) {
  638. assert(typeof str === 'string', 'Invalid argument for stringToBytes');
  639. var length = str.length;
  640. var bytes = new Uint8Array(length);
  641. for (var i = 0; i < length; ++i) {
  642. bytes[i] = str.charCodeAt(i) & 0xFF;
  643. }
  644. return bytes;
  645. }
  646. function arrayByteLength(arr) {
  647. if (arr.length !== undefined) {
  648. return arr.length;
  649. }
  650. assert(arr.byteLength !== undefined);
  651. return arr.byteLength;
  652. }
  653. function arraysToBytes(arr) {
  654. if (arr.length === 1 && arr[0] instanceof Uint8Array) {
  655. return arr[0];
  656. }
  657. var resultLength = 0;
  658. var i,
  659. ii = arr.length;
  660. var item, itemLength;
  661. for (i = 0; i < ii; i++) {
  662. item = arr[i];
  663. itemLength = arrayByteLength(item);
  664. resultLength += itemLength;
  665. }
  666. var pos = 0;
  667. var data = new Uint8Array(resultLength);
  668. for (i = 0; i < ii; i++) {
  669. item = arr[i];
  670. if (!(item instanceof Uint8Array)) {
  671. if (typeof item === 'string') {
  672. item = stringToBytes(item);
  673. } else {
  674. item = new Uint8Array(item);
  675. }
  676. }
  677. itemLength = item.byteLength;
  678. data.set(item, pos);
  679. pos += itemLength;
  680. }
  681. return data;
  682. }
  683. function string32(value) {
  684. return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
  685. }
  686. function log2(x) {
  687. if (x <= 0) {
  688. return 0;
  689. }
  690. return Math.ceil(Math.log2(x));
  691. }
  692. function readInt8(data, start) {
  693. return data[start] << 24 >> 24;
  694. }
  695. function readUint16(data, offset) {
  696. return data[offset] << 8 | data[offset + 1];
  697. }
  698. function readUint32(data, offset) {
  699. return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
  700. }
  701. function isLittleEndian() {
  702. var buffer8 = new Uint8Array(4);
  703. buffer8[0] = 1;
  704. var view32 = new Uint32Array(buffer8.buffer, 0, 1);
  705. return view32[0] === 1;
  706. }
  707. function isEvalSupported() {
  708. try {
  709. new Function('');
  710. return true;
  711. } catch (e) {
  712. return false;
  713. }
  714. }
  715. function getInheritableProperty(_ref) {
  716. var dict = _ref.dict,
  717. key = _ref.key,
  718. _ref$getArray = _ref.getArray,
  719. getArray = _ref$getArray === undefined ? false : _ref$getArray,
  720. _ref$stopWhenFound = _ref.stopWhenFound,
  721. stopWhenFound = _ref$stopWhenFound === undefined ? true : _ref$stopWhenFound;
  722. var LOOP_LIMIT = 100;
  723. var loopCount = 0;
  724. var values = void 0;
  725. while (dict) {
  726. var value = getArray ? dict.getArray(key) : dict.get(key);
  727. if (value !== undefined) {
  728. if (stopWhenFound) {
  729. return value;
  730. }
  731. if (!values) {
  732. values = [];
  733. }
  734. values.push(value);
  735. }
  736. if (++loopCount > LOOP_LIMIT) {
  737. warn('getInheritableProperty: maximum loop count exceeded for "' + key + '"');
  738. break;
  739. }
  740. dict = dict.get('Parent');
  741. }
  742. return values;
  743. }
  744. var Util = function UtilClosure() {
  745. function Util() {}
  746. var rgbBuf = ['rgb(', 0, ',', 0, ',', 0, ')'];
  747. Util.makeCssRgb = function Util_makeCssRgb(r, g, b) {
  748. rgbBuf[1] = r;
  749. rgbBuf[3] = g;
  750. rgbBuf[5] = b;
  751. return rgbBuf.join('');
  752. };
  753. Util.transform = function Util_transform(m1, m2) {
  754. 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]];
  755. };
  756. Util.applyTransform = function Util_applyTransform(p, m) {
  757. var xt = p[0] * m[0] + p[1] * m[2] + m[4];
  758. var yt = p[0] * m[1] + p[1] * m[3] + m[5];
  759. return [xt, yt];
  760. };
  761. Util.applyInverseTransform = function Util_applyInverseTransform(p, m) {
  762. var d = m[0] * m[3] - m[1] * m[2];
  763. var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
  764. var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
  765. return [xt, yt];
  766. };
  767. Util.getAxialAlignedBoundingBox = function Util_getAxialAlignedBoundingBox(r, m) {
  768. var p1 = Util.applyTransform(r, m);
  769. var p2 = Util.applyTransform(r.slice(2, 4), m);
  770. var p3 = Util.applyTransform([r[0], r[3]], m);
  771. var p4 = Util.applyTransform([r[2], r[1]], m);
  772. 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])];
  773. };
  774. Util.inverseTransform = function Util_inverseTransform(m) {
  775. var d = m[0] * m[3] - m[1] * m[2];
  776. 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];
  777. };
  778. Util.apply3dTransform = function Util_apply3dTransform(m, v) {
  779. 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]];
  780. };
  781. Util.singularValueDecompose2dScale = function Util_singularValueDecompose2dScale(m) {
  782. var transpose = [m[0], m[2], m[1], m[3]];
  783. var a = m[0] * transpose[0] + m[1] * transpose[2];
  784. var b = m[0] * transpose[1] + m[1] * transpose[3];
  785. var c = m[2] * transpose[0] + m[3] * transpose[2];
  786. var d = m[2] * transpose[1] + m[3] * transpose[3];
  787. var first = (a + d) / 2;
  788. var second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;
  789. var sx = first + second || 1;
  790. var sy = first - second || 1;
  791. return [Math.sqrt(sx), Math.sqrt(sy)];
  792. };
  793. Util.normalizeRect = function Util_normalizeRect(rect) {
  794. var r = rect.slice(0);
  795. if (rect[0] > rect[2]) {
  796. r[0] = rect[2];
  797. r[2] = rect[0];
  798. }
  799. if (rect[1] > rect[3]) {
  800. r[1] = rect[3];
  801. r[3] = rect[1];
  802. }
  803. return r;
  804. };
  805. Util.intersect = function Util_intersect(rect1, rect2) {
  806. function compare(a, b) {
  807. return a - b;
  808. }
  809. var orderedX = [rect1[0], rect1[2], rect2[0], rect2[2]].sort(compare),
  810. orderedY = [rect1[1], rect1[3], rect2[1], rect2[3]].sort(compare),
  811. result = [];
  812. rect1 = Util.normalizeRect(rect1);
  813. rect2 = Util.normalizeRect(rect2);
  814. if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) {
  815. result[0] = orderedX[1];
  816. result[2] = orderedX[2];
  817. } else {
  818. return false;
  819. }
  820. if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) {
  821. result[1] = orderedY[1];
  822. result[3] = orderedY[2];
  823. } else {
  824. return false;
  825. }
  826. return result;
  827. };
  828. return Util;
  829. }();
  830. 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'];
  831. function toRomanNumerals(number) {
  832. var lowerCase = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  833. assert(Number.isInteger(number) && number > 0, 'The number should be a positive integer.');
  834. var pos = void 0,
  835. romanBuf = [];
  836. while (number >= 1000) {
  837. number -= 1000;
  838. romanBuf.push('M');
  839. }
  840. pos = number / 100 | 0;
  841. number %= 100;
  842. romanBuf.push(ROMAN_NUMBER_MAP[pos]);
  843. pos = number / 10 | 0;
  844. number %= 10;
  845. romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]);
  846. romanBuf.push(ROMAN_NUMBER_MAP[20 + number]);
  847. var romanStr = romanBuf.join('');
  848. return lowerCase ? romanStr.toLowerCase() : romanStr;
  849. }
  850. 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];
  851. function stringToPDFString(str) {
  852. var i,
  853. n = str.length,
  854. strBuf = [];
  855. if (str[0] === '\xFE' && str[1] === '\xFF') {
  856. for (i = 2; i < n; i += 2) {
  857. strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1)));
  858. }
  859. } else {
  860. for (i = 0; i < n; ++i) {
  861. var code = PDFStringTranslateTable[str.charCodeAt(i)];
  862. strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
  863. }
  864. }
  865. return strBuf.join('');
  866. }
  867. function stringToUTF8String(str) {
  868. return decodeURIComponent(escape(str));
  869. }
  870. function utf8StringToString(str) {
  871. return unescape(encodeURIComponent(str));
  872. }
  873. function isEmptyObj(obj) {
  874. for (var key in obj) {
  875. return false;
  876. }
  877. return true;
  878. }
  879. function isBool(v) {
  880. return typeof v === 'boolean';
  881. }
  882. function isNum(v) {
  883. return typeof v === 'number';
  884. }
  885. function isString(v) {
  886. return typeof v === 'string';
  887. }
  888. function isArrayBuffer(v) {
  889. return (typeof v === 'undefined' ? 'undefined' : _typeof(v)) === 'object' && v !== null && v.byteLength !== undefined;
  890. }
  891. function isSpace(ch) {
  892. return ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A;
  893. }
  894. function createPromiseCapability() {
  895. var capability = {};
  896. capability.promise = new Promise(function (resolve, reject) {
  897. capability.resolve = resolve;
  898. capability.reject = reject;
  899. });
  900. return capability;
  901. }
  902. var createObjectURL = function createObjectURLClosure() {
  903. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  904. return function createObjectURL(data, contentType) {
  905. var forceDataSchema = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  906. if (!forceDataSchema && _url_polyfill.URL.createObjectURL) {
  907. var blob = new Blob([data], { type: contentType });
  908. return _url_polyfill.URL.createObjectURL(blob);
  909. }
  910. var buffer = 'data:' + contentType + ';base64,';
  911. for (var i = 0, ii = data.length; i < ii; i += 3) {
  912. var b1 = data[i] & 0xFF;
  913. var b2 = data[i + 1] & 0xFF;
  914. var b3 = data[i + 2] & 0xFF;
  915. var d1 = b1 >> 2,
  916. d2 = (b1 & 3) << 4 | b2 >> 4;
  917. var d3 = i + 1 < ii ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
  918. var d4 = i + 2 < ii ? b3 & 0x3F : 64;
  919. buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
  920. }
  921. return buffer;
  922. };
  923. }();
  924. exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
  925. exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
  926. exports.OPS = OPS;
  927. exports.VerbosityLevel = VerbosityLevel;
  928. exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
  929. exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
  930. exports.AnnotationFieldFlag = AnnotationFieldFlag;
  931. exports.AnnotationFlag = AnnotationFlag;
  932. exports.AnnotationType = AnnotationType;
  933. exports.FontType = FontType;
  934. exports.ImageKind = ImageKind;
  935. exports.CMapCompressionType = CMapCompressionType;
  936. exports.AbortException = AbortException;
  937. exports.InvalidPDFException = InvalidPDFException;
  938. exports.MissingDataException = MissingDataException;
  939. exports.MissingPDFException = MissingPDFException;
  940. exports.NativeImageDecoding = NativeImageDecoding;
  941. exports.PasswordException = PasswordException;
  942. exports.PasswordResponses = PasswordResponses;
  943. exports.PermissionFlag = PermissionFlag;
  944. exports.StreamType = StreamType;
  945. exports.TextRenderingMode = TextRenderingMode;
  946. exports.UnexpectedResponseException = UnexpectedResponseException;
  947. exports.UnknownErrorException = UnknownErrorException;
  948. exports.Util = Util;
  949. exports.toRomanNumerals = toRomanNumerals;
  950. exports.XRefParseException = XRefParseException;
  951. exports.FormatError = FormatError;
  952. exports.arrayByteLength = arrayByteLength;
  953. exports.arraysToBytes = arraysToBytes;
  954. exports.assert = assert;
  955. exports.bytesToString = bytesToString;
  956. exports.createPromiseCapability = createPromiseCapability;
  957. exports.createObjectURL = createObjectURL;
  958. exports.deprecated = deprecated;
  959. exports.getInheritableProperty = getInheritableProperty;
  960. exports.getLookupTableFactory = getLookupTableFactory;
  961. exports.getVerbosityLevel = getVerbosityLevel;
  962. exports.info = info;
  963. exports.isArrayBuffer = isArrayBuffer;
  964. exports.isBool = isBool;
  965. exports.isEmptyObj = isEmptyObj;
  966. exports.isNum = isNum;
  967. exports.isString = isString;
  968. exports.isSpace = isSpace;
  969. exports.isSameOrigin = isSameOrigin;
  970. exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
  971. exports.isLittleEndian = isLittleEndian;
  972. exports.isEvalSupported = isEvalSupported;
  973. exports.log2 = log2;
  974. exports.readInt8 = readInt8;
  975. exports.readUint16 = readUint16;
  976. exports.readUint32 = readUint32;
  977. exports.removeNullCharacters = removeNullCharacters;
  978. exports.ReadableStream = _streams_polyfill.ReadableStream;
  979. exports.URL = _url_polyfill.URL;
  980. exports.setVerbosityLevel = setVerbosityLevel;
  981. exports.shadow = shadow;
  982. exports.string32 = string32;
  983. exports.stringToBytes = stringToBytes;
  984. exports.stringToPDFString = stringToPDFString;
  985. exports.stringToUTF8String = stringToUTF8String;
  986. exports.utf8StringToString = utf8StringToString;
  987. exports.warn = warn;
  988. exports.unreachable = unreachable;
  989. /***/ }),
  990. /* 2 */
  991. /***/ (function(module, exports, __w_pdfjs_require__) {
  992. "use strict";
  993. 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; };
  994. var globalScope = __w_pdfjs_require__(3);
  995. if (!globalScope._pdfjsCompatibilityChecked) {
  996. globalScope._pdfjsCompatibilityChecked = true;
  997. var isNodeJS = __w_pdfjs_require__(4);
  998. var hasDOM = (typeof window === 'undefined' ? 'undefined' : _typeof(window)) === 'object' && (typeof document === 'undefined' ? 'undefined' : _typeof(document)) === 'object';
  999. (function checkNodeBtoa() {
  1000. if (globalScope.btoa || !isNodeJS()) {
  1001. return;
  1002. }
  1003. globalScope.btoa = function (chars) {
  1004. return Buffer.from(chars, 'binary').toString('base64');
  1005. };
  1006. })();
  1007. (function checkNodeAtob() {
  1008. if (globalScope.atob || !isNodeJS()) {
  1009. return;
  1010. }
  1011. globalScope.atob = function (input) {
  1012. return Buffer.from(input, 'base64').toString('binary');
  1013. };
  1014. })();
  1015. (function checkCurrentScript() {
  1016. if (!hasDOM) {
  1017. return;
  1018. }
  1019. if ('currentScript' in document) {
  1020. return;
  1021. }
  1022. Object.defineProperty(document, 'currentScript', {
  1023. get: function get() {
  1024. var scripts = document.getElementsByTagName('script');
  1025. return scripts[scripts.length - 1];
  1026. },
  1027. enumerable: true,
  1028. configurable: true
  1029. });
  1030. })();
  1031. (function checkChildNodeRemove() {
  1032. if (!hasDOM) {
  1033. return;
  1034. }
  1035. if (typeof Element.prototype.remove !== 'undefined') {
  1036. return;
  1037. }
  1038. Element.prototype.remove = function () {
  1039. if (this.parentNode) {
  1040. this.parentNode.removeChild(this);
  1041. }
  1042. };
  1043. })();
  1044. (function checkDOMTokenListToggle() {
  1045. if (!hasDOM || isNodeJS()) {
  1046. return;
  1047. }
  1048. var div = document.createElement('div');
  1049. if (div.classList.toggle('test', 0) === false) {
  1050. return;
  1051. }
  1052. var originalDOMTokenListToggle = DOMTokenList.prototype.toggle;
  1053. DOMTokenList.prototype.toggle = function (token) {
  1054. if (arguments.length > 1) {
  1055. var force = !!arguments[1];
  1056. return this[force ? 'add' : 'remove'](token), force;
  1057. }
  1058. return originalDOMTokenListToggle(token);
  1059. };
  1060. })();
  1061. (function checkStringIncludes() {
  1062. if (String.prototype.includes) {
  1063. return;
  1064. }
  1065. __w_pdfjs_require__(5);
  1066. })();
  1067. (function checkArrayIncludes() {
  1068. if (Array.prototype.includes) {
  1069. return;
  1070. }
  1071. __w_pdfjs_require__(33);
  1072. })();
  1073. (function checkObjectAssign() {
  1074. if (Object.assign) {
  1075. return;
  1076. }
  1077. __w_pdfjs_require__(42);
  1078. })();
  1079. (function checkMathLog2() {
  1080. if (Math.log2) {
  1081. return;
  1082. }
  1083. Math.log2 = __w_pdfjs_require__(52);
  1084. })();
  1085. (function checkNumberIsNaN() {
  1086. if (Number.isNaN) {
  1087. return;
  1088. }
  1089. Number.isNaN = __w_pdfjs_require__(54);
  1090. })();
  1091. (function checkNumberIsInteger() {
  1092. if (Number.isInteger) {
  1093. return;
  1094. }
  1095. Number.isInteger = __w_pdfjs_require__(56);
  1096. })();
  1097. (function checkPromise() {
  1098. if (globalScope.Promise) {
  1099. return;
  1100. }
  1101. globalScope.Promise = __w_pdfjs_require__(59);
  1102. })();
  1103. (function checkWeakMap() {
  1104. if (globalScope.WeakMap) {
  1105. return;
  1106. }
  1107. globalScope.WeakMap = __w_pdfjs_require__(94);
  1108. })();
  1109. (function checkStringCodePointAt() {
  1110. if (String.codePointAt) {
  1111. return;
  1112. }
  1113. String.codePointAt = __w_pdfjs_require__(111);
  1114. })();
  1115. (function checkStringFromCodePoint() {
  1116. if (String.fromCodePoint) {
  1117. return;
  1118. }
  1119. String.fromCodePoint = __w_pdfjs_require__(113);
  1120. })();
  1121. (function checkSymbol() {
  1122. if (globalScope.Symbol) {
  1123. return;
  1124. }
  1125. __w_pdfjs_require__(115);
  1126. })();
  1127. (function checkObjectValues() {
  1128. if (Object.values) {
  1129. return;
  1130. }
  1131. Object.values = __w_pdfjs_require__(122);
  1132. })();
  1133. }
  1134. /***/ }),
  1135. /* 3 */
  1136. /***/ (function(module, exports, __w_pdfjs_require__) {
  1137. "use strict";
  1138. module.exports = typeof window !== 'undefined' && window.Math === Math ? window : typeof global !== 'undefined' && global.Math === Math ? global : typeof self !== 'undefined' && self.Math === Math ? self : {};
  1139. /***/ }),
  1140. /* 4 */
  1141. /***/ (function(module, exports, __w_pdfjs_require__) {
  1142. "use strict";
  1143. 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; };
  1144. module.exports = function isNodeJS() {
  1145. return (typeof process === 'undefined' ? 'undefined' : _typeof(process)) === 'object' && process + '' === '[object process]';
  1146. };
  1147. /***/ }),
  1148. /* 5 */
  1149. /***/ (function(module, exports, __w_pdfjs_require__) {
  1150. "use strict";
  1151. __w_pdfjs_require__(6);
  1152. module.exports = __w_pdfjs_require__(9).String.includes;
  1153. /***/ }),
  1154. /* 6 */
  1155. /***/ (function(module, exports, __w_pdfjs_require__) {
  1156. "use strict";
  1157. var $export = __w_pdfjs_require__(7);
  1158. var context = __w_pdfjs_require__(25);
  1159. var INCLUDES = 'includes';
  1160. $export($export.P + $export.F * __w_pdfjs_require__(32)(INCLUDES), 'String', {
  1161. includes: function includes(searchString) {
  1162. return !!~context(this, searchString, INCLUDES).indexOf(searchString, arguments.length > 1 ? arguments[1] : undefined);
  1163. }
  1164. });
  1165. /***/ }),
  1166. /* 7 */
  1167. /***/ (function(module, exports, __w_pdfjs_require__) {
  1168. "use strict";
  1169. var global = __w_pdfjs_require__(8);
  1170. var core = __w_pdfjs_require__(9);
  1171. var hide = __w_pdfjs_require__(10);
  1172. var redefine = __w_pdfjs_require__(20);
  1173. var ctx = __w_pdfjs_require__(23);
  1174. var PROTOTYPE = 'prototype';
  1175. var $export = function $export(type, name, source) {
  1176. var IS_FORCED = type & $export.F;
  1177. var IS_GLOBAL = type & $export.G;
  1178. var IS_STATIC = type & $export.S;
  1179. var IS_PROTO = type & $export.P;
  1180. var IS_BIND = type & $export.B;
  1181. var target = IS_GLOBAL ? global : IS_STATIC ? global[name] || (global[name] = {}) : (global[name] || {})[PROTOTYPE];
  1182. var exports = IS_GLOBAL ? core : core[name] || (core[name] = {});
  1183. var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {});
  1184. var key, own, out, exp;
  1185. if (IS_GLOBAL) source = name;
  1186. for (key in source) {
  1187. own = !IS_FORCED && target && target[key] !== undefined;
  1188. out = (own ? target : source)[key];
  1189. exp = IS_BIND && own ? ctx(out, global) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
  1190. if (target) redefine(target, key, out, type & $export.U);
  1191. if (exports[key] != out) hide(exports, key, exp);
  1192. if (IS_PROTO && expProto[key] != out) expProto[key] = out;
  1193. }
  1194. };
  1195. global.core = core;
  1196. $export.F = 1;
  1197. $export.G = 2;
  1198. $export.S = 4;
  1199. $export.P = 8;
  1200. $export.B = 16;
  1201. $export.W = 32;
  1202. $export.U = 64;
  1203. $export.R = 128;
  1204. module.exports = $export;
  1205. /***/ }),
  1206. /* 8 */
  1207. /***/ (function(module, exports, __w_pdfjs_require__) {
  1208. "use strict";
  1209. var global = module.exports = typeof window != 'undefined' && window.Math == Math ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')();
  1210. if (typeof __g == 'number') __g = global;
  1211. /***/ }),
  1212. /* 9 */
  1213. /***/ (function(module, exports, __w_pdfjs_require__) {
  1214. "use strict";
  1215. var core = module.exports = { version: '2.5.7' };
  1216. if (typeof __e == 'number') __e = core;
  1217. /***/ }),
  1218. /* 10 */
  1219. /***/ (function(module, exports, __w_pdfjs_require__) {
  1220. "use strict";
  1221. var dP = __w_pdfjs_require__(11);
  1222. var createDesc = __w_pdfjs_require__(19);
  1223. module.exports = __w_pdfjs_require__(15) ? function (object, key, value) {
  1224. return dP.f(object, key, createDesc(1, value));
  1225. } : function (object, key, value) {
  1226. object[key] = value;
  1227. return object;
  1228. };
  1229. /***/ }),
  1230. /* 11 */
  1231. /***/ (function(module, exports, __w_pdfjs_require__) {
  1232. "use strict";
  1233. var anObject = __w_pdfjs_require__(12);
  1234. var IE8_DOM_DEFINE = __w_pdfjs_require__(14);
  1235. var toPrimitive = __w_pdfjs_require__(18);
  1236. var dP = Object.defineProperty;
  1237. exports.f = __w_pdfjs_require__(15) ? Object.defineProperty : function defineProperty(O, P, Attributes) {
  1238. anObject(O);
  1239. P = toPrimitive(P, true);
  1240. anObject(Attributes);
  1241. if (IE8_DOM_DEFINE) try {
  1242. return dP(O, P, Attributes);
  1243. } catch (e) {}
  1244. if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
  1245. if ('value' in Attributes) O[P] = Attributes.value;
  1246. return O;
  1247. };
  1248. /***/ }),
  1249. /* 12 */
  1250. /***/ (function(module, exports, __w_pdfjs_require__) {
  1251. "use strict";
  1252. var isObject = __w_pdfjs_require__(13);
  1253. module.exports = function (it) {
  1254. if (!isObject(it)) throw TypeError(it + ' is not an object!');
  1255. return it;
  1256. };
  1257. /***/ }),
  1258. /* 13 */
  1259. /***/ (function(module, exports, __w_pdfjs_require__) {
  1260. "use strict";
  1261. 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; };
  1262. module.exports = function (it) {
  1263. return (typeof it === 'undefined' ? 'undefined' : _typeof(it)) === 'object' ? it !== null : typeof it === 'function';
  1264. };
  1265. /***/ }),
  1266. /* 14 */
  1267. /***/ (function(module, exports, __w_pdfjs_require__) {
  1268. "use strict";
  1269. module.exports = !__w_pdfjs_require__(15) && !__w_pdfjs_require__(16)(function () {
  1270. return Object.defineProperty(__w_pdfjs_require__(17)('div'), 'a', {
  1271. get: function get() {
  1272. return 7;
  1273. }
  1274. }).a != 7;
  1275. });
  1276. /***/ }),
  1277. /* 15 */
  1278. /***/ (function(module, exports, __w_pdfjs_require__) {
  1279. "use strict";
  1280. module.exports = !__w_pdfjs_require__(16)(function () {
  1281. return Object.defineProperty({}, 'a', {
  1282. get: function get() {
  1283. return 7;
  1284. }
  1285. }).a != 7;
  1286. });
  1287. /***/ }),
  1288. /* 16 */
  1289. /***/ (function(module, exports, __w_pdfjs_require__) {
  1290. "use strict";
  1291. module.exports = function (exec) {
  1292. try {
  1293. return !!exec();
  1294. } catch (e) {
  1295. return true;
  1296. }
  1297. };
  1298. /***/ }),
  1299. /* 17 */
  1300. /***/ (function(module, exports, __w_pdfjs_require__) {
  1301. "use strict";
  1302. var isObject = __w_pdfjs_require__(13);
  1303. var document = __w_pdfjs_require__(8).document;
  1304. var is = isObject(document) && isObject(document.createElement);
  1305. module.exports = function (it) {
  1306. return is ? document.createElement(it) : {};
  1307. };
  1308. /***/ }),
  1309. /* 18 */
  1310. /***/ (function(module, exports, __w_pdfjs_require__) {
  1311. "use strict";
  1312. var isObject = __w_pdfjs_require__(13);
  1313. module.exports = function (it, S) {
  1314. if (!isObject(it)) return it;
  1315. var fn, val;
  1316. if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  1317. if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;
  1318. if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  1319. throw TypeError("Can't convert object to primitive value");
  1320. };
  1321. /***/ }),
  1322. /* 19 */
  1323. /***/ (function(module, exports, __w_pdfjs_require__) {
  1324. "use strict";
  1325. module.exports = function (bitmap, value) {
  1326. return {
  1327. enumerable: !(bitmap & 1),
  1328. configurable: !(bitmap & 2),
  1329. writable: !(bitmap & 4),
  1330. value: value
  1331. };
  1332. };
  1333. /***/ }),
  1334. /* 20 */
  1335. /***/ (function(module, exports, __w_pdfjs_require__) {
  1336. "use strict";
  1337. var global = __w_pdfjs_require__(8);
  1338. var hide = __w_pdfjs_require__(10);
  1339. var has = __w_pdfjs_require__(21);
  1340. var SRC = __w_pdfjs_require__(22)('src');
  1341. var TO_STRING = 'toString';
  1342. var $toString = Function[TO_STRING];
  1343. var TPL = ('' + $toString).split(TO_STRING);
  1344. __w_pdfjs_require__(9).inspectSource = function (it) {
  1345. return $toString.call(it);
  1346. };
  1347. (module.exports = function (O, key, val, safe) {
  1348. var isFunction = typeof val == 'function';
  1349. if (isFunction) has(val, 'name') || hide(val, 'name', key);
  1350. if (O[key] === val) return;
  1351. if (isFunction) has(val, SRC) || hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key)));
  1352. if (O === global) {
  1353. O[key] = val;
  1354. } else if (!safe) {
  1355. delete O[key];
  1356. hide(O, key, val);
  1357. } else if (O[key]) {
  1358. O[key] = val;
  1359. } else {
  1360. hide(O, key, val);
  1361. }
  1362. })(Function.prototype, TO_STRING, function toString() {
  1363. return typeof this == 'function' && this[SRC] || $toString.call(this);
  1364. });
  1365. /***/ }),
  1366. /* 21 */
  1367. /***/ (function(module, exports, __w_pdfjs_require__) {
  1368. "use strict";
  1369. var hasOwnProperty = {}.hasOwnProperty;
  1370. module.exports = function (it, key) {
  1371. return hasOwnProperty.call(it, key);
  1372. };
  1373. /***/ }),
  1374. /* 22 */
  1375. /***/ (function(module, exports, __w_pdfjs_require__) {
  1376. "use strict";
  1377. var id = 0;
  1378. var px = Math.random();
  1379. module.exports = function (key) {
  1380. return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
  1381. };
  1382. /***/ }),
  1383. /* 23 */
  1384. /***/ (function(module, exports, __w_pdfjs_require__) {
  1385. "use strict";
  1386. var aFunction = __w_pdfjs_require__(24);
  1387. module.exports = function (fn, that, length) {
  1388. aFunction(fn);
  1389. if (that === undefined) return fn;
  1390. switch (length) {
  1391. case 1:
  1392. return function (a) {
  1393. return fn.call(that, a);
  1394. };
  1395. case 2:
  1396. return function (a, b) {
  1397. return fn.call(that, a, b);
  1398. };
  1399. case 3:
  1400. return function (a, b, c) {
  1401. return fn.call(that, a, b, c);
  1402. };
  1403. }
  1404. return function () {
  1405. return fn.apply(that, arguments);
  1406. };
  1407. };
  1408. /***/ }),
  1409. /* 24 */
  1410. /***/ (function(module, exports, __w_pdfjs_require__) {
  1411. "use strict";
  1412. module.exports = function (it) {
  1413. if (typeof it != 'function') throw TypeError(it + ' is not a function!');
  1414. return it;
  1415. };
  1416. /***/ }),
  1417. /* 25 */
  1418. /***/ (function(module, exports, __w_pdfjs_require__) {
  1419. "use strict";
  1420. var isRegExp = __w_pdfjs_require__(26);
  1421. var defined = __w_pdfjs_require__(31);
  1422. module.exports = function (that, searchString, NAME) {
  1423. if (isRegExp(searchString)) throw TypeError('String#' + NAME + " doesn't accept regex!");
  1424. return String(defined(that));
  1425. };
  1426. /***/ }),
  1427. /* 26 */
  1428. /***/ (function(module, exports, __w_pdfjs_require__) {
  1429. "use strict";
  1430. var isObject = __w_pdfjs_require__(13);
  1431. var cof = __w_pdfjs_require__(27);
  1432. var MATCH = __w_pdfjs_require__(28)('match');
  1433. module.exports = function (it) {
  1434. var isRegExp;
  1435. return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : cof(it) == 'RegExp');
  1436. };
  1437. /***/ }),
  1438. /* 27 */
  1439. /***/ (function(module, exports, __w_pdfjs_require__) {
  1440. "use strict";
  1441. var toString = {}.toString;
  1442. module.exports = function (it) {
  1443. return toString.call(it).slice(8, -1);
  1444. };
  1445. /***/ }),
  1446. /* 28 */
  1447. /***/ (function(module, exports, __w_pdfjs_require__) {
  1448. "use strict";
  1449. var store = __w_pdfjs_require__(29)('wks');
  1450. var uid = __w_pdfjs_require__(22);
  1451. var _Symbol = __w_pdfjs_require__(8).Symbol;
  1452. var USE_SYMBOL = typeof _Symbol == 'function';
  1453. var $exports = module.exports = function (name) {
  1454. return store[name] || (store[name] = USE_SYMBOL && _Symbol[name] || (USE_SYMBOL ? _Symbol : uid)('Symbol.' + name));
  1455. };
  1456. $exports.store = store;
  1457. /***/ }),
  1458. /* 29 */
  1459. /***/ (function(module, exports, __w_pdfjs_require__) {
  1460. "use strict";
  1461. var core = __w_pdfjs_require__(9);
  1462. var global = __w_pdfjs_require__(8);
  1463. var SHARED = '__core-js_shared__';
  1464. var store = global[SHARED] || (global[SHARED] = {});
  1465. (module.exports = function (key, value) {
  1466. return store[key] || (store[key] = value !== undefined ? value : {});
  1467. })('versions', []).push({
  1468. version: core.version,
  1469. mode: __w_pdfjs_require__(30) ? 'pure' : 'global',
  1470. copyright: '© 2018 Denis Pushkarev (zloirock.ru)'
  1471. });
  1472. /***/ }),
  1473. /* 30 */
  1474. /***/ (function(module, exports, __w_pdfjs_require__) {
  1475. "use strict";
  1476. module.exports = false;
  1477. /***/ }),
  1478. /* 31 */
  1479. /***/ (function(module, exports, __w_pdfjs_require__) {
  1480. "use strict";
  1481. module.exports = function (it) {
  1482. if (it == undefined) throw TypeError("Can't call method on " + it);
  1483. return it;
  1484. };
  1485. /***/ }),
  1486. /* 32 */
  1487. /***/ (function(module, exports, __w_pdfjs_require__) {
  1488. "use strict";
  1489. var MATCH = __w_pdfjs_require__(28)('match');
  1490. module.exports = function (KEY) {
  1491. var re = /./;
  1492. try {
  1493. '/./'[KEY](re);
  1494. } catch (e) {
  1495. try {
  1496. re[MATCH] = false;
  1497. return !'/./'[KEY](re);
  1498. } catch (f) {}
  1499. }
  1500. return true;
  1501. };
  1502. /***/ }),
  1503. /* 33 */
  1504. /***/ (function(module, exports, __w_pdfjs_require__) {
  1505. "use strict";
  1506. __w_pdfjs_require__(34);
  1507. module.exports = __w_pdfjs_require__(9).Array.includes;
  1508. /***/ }),
  1509. /* 34 */
  1510. /***/ (function(module, exports, __w_pdfjs_require__) {
  1511. "use strict";
  1512. var $export = __w_pdfjs_require__(7);
  1513. var $includes = __w_pdfjs_require__(35)(true);
  1514. $export($export.P, 'Array', {
  1515. includes: function includes(el) {
  1516. return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
  1517. }
  1518. });
  1519. __w_pdfjs_require__(41)('includes');
  1520. /***/ }),
  1521. /* 35 */
  1522. /***/ (function(module, exports, __w_pdfjs_require__) {
  1523. "use strict";
  1524. var toIObject = __w_pdfjs_require__(36);
  1525. var toLength = __w_pdfjs_require__(38);
  1526. var toAbsoluteIndex = __w_pdfjs_require__(40);
  1527. module.exports = function (IS_INCLUDES) {
  1528. return function ($this, el, fromIndex) {
  1529. var O = toIObject($this);
  1530. var length = toLength(O.length);
  1531. var index = toAbsoluteIndex(fromIndex, length);
  1532. var value;
  1533. if (IS_INCLUDES && el != el) while (length > index) {
  1534. value = O[index++];
  1535. if (value != value) return true;
  1536. } else for (; length > index; index++) {
  1537. if (IS_INCLUDES || index in O) {
  1538. if (O[index] === el) return IS_INCLUDES || index || 0;
  1539. }
  1540. }return !IS_INCLUDES && -1;
  1541. };
  1542. };
  1543. /***/ }),
  1544. /* 36 */
  1545. /***/ (function(module, exports, __w_pdfjs_require__) {
  1546. "use strict";
  1547. var IObject = __w_pdfjs_require__(37);
  1548. var defined = __w_pdfjs_require__(31);
  1549. module.exports = function (it) {
  1550. return IObject(defined(it));
  1551. };
  1552. /***/ }),
  1553. /* 37 */
  1554. /***/ (function(module, exports, __w_pdfjs_require__) {
  1555. "use strict";
  1556. var cof = __w_pdfjs_require__(27);
  1557. module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
  1558. return cof(it) == 'String' ? it.split('') : Object(it);
  1559. };
  1560. /***/ }),
  1561. /* 38 */
  1562. /***/ (function(module, exports, __w_pdfjs_require__) {
  1563. "use strict";
  1564. var toInteger = __w_pdfjs_require__(39);
  1565. var min = Math.min;
  1566. module.exports = function (it) {
  1567. return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0;
  1568. };
  1569. /***/ }),
  1570. /* 39 */
  1571. /***/ (function(module, exports, __w_pdfjs_require__) {
  1572. "use strict";
  1573. var ceil = Math.ceil;
  1574. var floor = Math.floor;
  1575. module.exports = function (it) {
  1576. return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
  1577. };
  1578. /***/ }),
  1579. /* 40 */
  1580. /***/ (function(module, exports, __w_pdfjs_require__) {
  1581. "use strict";
  1582. var toInteger = __w_pdfjs_require__(39);
  1583. var max = Math.max;
  1584. var min = Math.min;
  1585. module.exports = function (index, length) {
  1586. index = toInteger(index);
  1587. return index < 0 ? max(index + length, 0) : min(index, length);
  1588. };
  1589. /***/ }),
  1590. /* 41 */
  1591. /***/ (function(module, exports, __w_pdfjs_require__) {
  1592. "use strict";
  1593. var UNSCOPABLES = __w_pdfjs_require__(28)('unscopables');
  1594. var ArrayProto = Array.prototype;
  1595. if (ArrayProto[UNSCOPABLES] == undefined) __w_pdfjs_require__(10)(ArrayProto, UNSCOPABLES, {});
  1596. module.exports = function (key) {
  1597. ArrayProto[UNSCOPABLES][key] = true;
  1598. };
  1599. /***/ }),
  1600. /* 42 */
  1601. /***/ (function(module, exports, __w_pdfjs_require__) {
  1602. "use strict";
  1603. __w_pdfjs_require__(43);
  1604. module.exports = __w_pdfjs_require__(9).Object.assign;
  1605. /***/ }),
  1606. /* 43 */
  1607. /***/ (function(module, exports, __w_pdfjs_require__) {
  1608. "use strict";
  1609. var $export = __w_pdfjs_require__(7);
  1610. $export($export.S + $export.F, 'Object', { assign: __w_pdfjs_require__(44) });
  1611. /***/ }),
  1612. /* 44 */
  1613. /***/ (function(module, exports, __w_pdfjs_require__) {
  1614. "use strict";
  1615. var getKeys = __w_pdfjs_require__(45);
  1616. var gOPS = __w_pdfjs_require__(49);
  1617. var pIE = __w_pdfjs_require__(50);
  1618. var toObject = __w_pdfjs_require__(51);
  1619. var IObject = __w_pdfjs_require__(37);
  1620. var $assign = Object.assign;
  1621. module.exports = !$assign || __w_pdfjs_require__(16)(function () {
  1622. var A = {};
  1623. var B = {};
  1624. var S = Symbol();
  1625. var K = 'abcdefghijklmnopqrst';
  1626. A[S] = 7;
  1627. K.split('').forEach(function (k) {
  1628. B[k] = k;
  1629. });
  1630. return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
  1631. }) ? function assign(target, source) {
  1632. var T = toObject(target);
  1633. var aLen = arguments.length;
  1634. var index = 1;
  1635. var getSymbols = gOPS.f;
  1636. var isEnum = pIE.f;
  1637. while (aLen > index) {
  1638. var S = IObject(arguments[index++]);
  1639. var keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S);
  1640. var length = keys.length;
  1641. var j = 0;
  1642. var key;
  1643. while (length > j) {
  1644. if (isEnum.call(S, key = keys[j++])) T[key] = S[key];
  1645. }
  1646. }
  1647. return T;
  1648. } : $assign;
  1649. /***/ }),
  1650. /* 45 */
  1651. /***/ (function(module, exports, __w_pdfjs_require__) {
  1652. "use strict";
  1653. var $keys = __w_pdfjs_require__(46);
  1654. var enumBugKeys = __w_pdfjs_require__(48);
  1655. module.exports = Object.keys || function keys(O) {
  1656. return $keys(O, enumBugKeys);
  1657. };
  1658. /***/ }),
  1659. /* 46 */
  1660. /***/ (function(module, exports, __w_pdfjs_require__) {
  1661. "use strict";
  1662. var has = __w_pdfjs_require__(21);
  1663. var toIObject = __w_pdfjs_require__(36);
  1664. var arrayIndexOf = __w_pdfjs_require__(35)(false);
  1665. var IE_PROTO = __w_pdfjs_require__(47)('IE_PROTO');
  1666. module.exports = function (object, names) {
  1667. var O = toIObject(object);
  1668. var i = 0;
  1669. var result = [];
  1670. var key;
  1671. for (key in O) {
  1672. if (key != IE_PROTO) has(O, key) && result.push(key);
  1673. }while (names.length > i) {
  1674. if (has(O, key = names[i++])) {
  1675. ~arrayIndexOf(result, key) || result.push(key);
  1676. }
  1677. }return result;
  1678. };
  1679. /***/ }),
  1680. /* 47 */
  1681. /***/ (function(module, exports, __w_pdfjs_require__) {
  1682. "use strict";
  1683. var shared = __w_pdfjs_require__(29)('keys');
  1684. var uid = __w_pdfjs_require__(22);
  1685. module.exports = function (key) {
  1686. return shared[key] || (shared[key] = uid(key));
  1687. };
  1688. /***/ }),
  1689. /* 48 */
  1690. /***/ (function(module, exports, __w_pdfjs_require__) {
  1691. "use strict";
  1692. module.exports = 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'.split(',');
  1693. /***/ }),
  1694. /* 49 */
  1695. /***/ (function(module, exports, __w_pdfjs_require__) {
  1696. "use strict";
  1697. exports.f = Object.getOwnPropertySymbols;
  1698. /***/ }),
  1699. /* 50 */
  1700. /***/ (function(module, exports, __w_pdfjs_require__) {
  1701. "use strict";
  1702. exports.f = {}.propertyIsEnumerable;
  1703. /***/ }),
  1704. /* 51 */
  1705. /***/ (function(module, exports, __w_pdfjs_require__) {
  1706. "use strict";
  1707. var defined = __w_pdfjs_require__(31);
  1708. module.exports = function (it) {
  1709. return Object(defined(it));
  1710. };
  1711. /***/ }),
  1712. /* 52 */
  1713. /***/ (function(module, exports, __w_pdfjs_require__) {
  1714. "use strict";
  1715. __w_pdfjs_require__(53);
  1716. module.exports = __w_pdfjs_require__(9).Math.log2;
  1717. /***/ }),
  1718. /* 53 */
  1719. /***/ (function(module, exports, __w_pdfjs_require__) {
  1720. "use strict";
  1721. var $export = __w_pdfjs_require__(7);
  1722. $export($export.S, 'Math', {
  1723. log2: function log2(x) {
  1724. return Math.log(x) / Math.LN2;
  1725. }
  1726. });
  1727. /***/ }),
  1728. /* 54 */
  1729. /***/ (function(module, exports, __w_pdfjs_require__) {
  1730. "use strict";
  1731. __w_pdfjs_require__(55);
  1732. module.exports = __w_pdfjs_require__(9).Number.isNaN;
  1733. /***/ }),
  1734. /* 55 */
  1735. /***/ (function(module, exports, __w_pdfjs_require__) {
  1736. "use strict";
  1737. var $export = __w_pdfjs_require__(7);
  1738. $export($export.S, 'Number', {
  1739. isNaN: function isNaN(number) {
  1740. return number != number;
  1741. }
  1742. });
  1743. /***/ }),
  1744. /* 56 */
  1745. /***/ (function(module, exports, __w_pdfjs_require__) {
  1746. "use strict";
  1747. __w_pdfjs_require__(57);
  1748. module.exports = __w_pdfjs_require__(9).Number.isInteger;
  1749. /***/ }),
  1750. /* 57 */
  1751. /***/ (function(module, exports, __w_pdfjs_require__) {
  1752. "use strict";
  1753. var $export = __w_pdfjs_require__(7);
  1754. $export($export.S, 'Number', { isInteger: __w_pdfjs_require__(58) });
  1755. /***/ }),
  1756. /* 58 */
  1757. /***/ (function(module, exports, __w_pdfjs_require__) {
  1758. "use strict";
  1759. var isObject = __w_pdfjs_require__(13);
  1760. var floor = Math.floor;
  1761. module.exports = function isInteger(it) {
  1762. return !isObject(it) && isFinite(it) && floor(it) === it;
  1763. };
  1764. /***/ }),
  1765. /* 59 */
  1766. /***/ (function(module, exports, __w_pdfjs_require__) {
  1767. "use strict";
  1768. __w_pdfjs_require__(60);
  1769. __w_pdfjs_require__(62);
  1770. __w_pdfjs_require__(72);
  1771. __w_pdfjs_require__(75);
  1772. __w_pdfjs_require__(92);
  1773. __w_pdfjs_require__(93);
  1774. module.exports = __w_pdfjs_require__(9).Promise;
  1775. /***/ }),
  1776. /* 60 */
  1777. /***/ (function(module, exports, __w_pdfjs_require__) {
  1778. "use strict";
  1779. var classof = __w_pdfjs_require__(61);
  1780. var test = {};
  1781. test[__w_pdfjs_require__(28)('toStringTag')] = 'z';
  1782. if (test + '' != '[object z]') {
  1783. __w_pdfjs_require__(20)(Object.prototype, 'toString', function toString() {
  1784. return '[object ' + classof(this) + ']';
  1785. }, true);
  1786. }
  1787. /***/ }),
  1788. /* 61 */
  1789. /***/ (function(module, exports, __w_pdfjs_require__) {
  1790. "use strict";
  1791. var cof = __w_pdfjs_require__(27);
  1792. var TAG = __w_pdfjs_require__(28)('toStringTag');
  1793. var ARG = cof(function () {
  1794. return arguments;
  1795. }()) == 'Arguments';
  1796. var tryGet = function tryGet(it, key) {
  1797. try {
  1798. return it[key];
  1799. } catch (e) {}
  1800. };
  1801. module.exports = function (it) {
  1802. var O, T, B;
  1803. 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;
  1804. };
  1805. /***/ }),
  1806. /* 62 */
  1807. /***/ (function(module, exports, __w_pdfjs_require__) {
  1808. "use strict";
  1809. var $at = __w_pdfjs_require__(63)(true);
  1810. __w_pdfjs_require__(64)(String, 'String', function (iterated) {
  1811. this._t = String(iterated);
  1812. this._i = 0;
  1813. }, function () {
  1814. var O = this._t;
  1815. var index = this._i;
  1816. var point;
  1817. if (index >= O.length) return {
  1818. value: undefined,
  1819. done: true
  1820. };
  1821. point = $at(O, index);
  1822. this._i += point.length;
  1823. return {
  1824. value: point,
  1825. done: false
  1826. };
  1827. });
  1828. /***/ }),
  1829. /* 63 */
  1830. /***/ (function(module, exports, __w_pdfjs_require__) {
  1831. "use strict";
  1832. var toInteger = __w_pdfjs_require__(39);
  1833. var defined = __w_pdfjs_require__(31);
  1834. module.exports = function (TO_STRING) {
  1835. return function (that, pos) {
  1836. var s = String(defined(that));
  1837. var i = toInteger(pos);
  1838. var l = s.length;
  1839. var a, b;
  1840. if (i < 0 || i >= l) return TO_STRING ? '' : undefined;
  1841. a = s.charCodeAt(i);
  1842. 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;
  1843. };
  1844. };
  1845. /***/ }),
  1846. /* 64 */
  1847. /***/ (function(module, exports, __w_pdfjs_require__) {
  1848. "use strict";
  1849. var LIBRARY = __w_pdfjs_require__(30);
  1850. var $export = __w_pdfjs_require__(7);
  1851. var redefine = __w_pdfjs_require__(20);
  1852. var hide = __w_pdfjs_require__(10);
  1853. var Iterators = __w_pdfjs_require__(65);
  1854. var $iterCreate = __w_pdfjs_require__(66);
  1855. var setToStringTag = __w_pdfjs_require__(70);
  1856. var getPrototypeOf = __w_pdfjs_require__(71);
  1857. var ITERATOR = __w_pdfjs_require__(28)('iterator');
  1858. var BUGGY = !([].keys && 'next' in [].keys());
  1859. var FF_ITERATOR = '@@iterator';
  1860. var KEYS = 'keys';
  1861. var VALUES = 'values';
  1862. var returnThis = function returnThis() {
  1863. return this;
  1864. };
  1865. module.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
  1866. $iterCreate(Constructor, NAME, next);
  1867. var getMethod = function getMethod(kind) {
  1868. if (!BUGGY && kind in proto) return proto[kind];
  1869. switch (kind) {
  1870. case KEYS:
  1871. return function keys() {
  1872. return new Constructor(this, kind);
  1873. };
  1874. case VALUES:
  1875. return function values() {
  1876. return new Constructor(this, kind);
  1877. };
  1878. }
  1879. return function entries() {
  1880. return new Constructor(this, kind);
  1881. };
  1882. };
  1883. var TAG = NAME + ' Iterator';
  1884. var DEF_VALUES = DEFAULT == VALUES;
  1885. var VALUES_BUG = false;
  1886. var proto = Base.prototype;
  1887. var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
  1888. var $default = $native || getMethod(DEFAULT);
  1889. var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
  1890. var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
  1891. var methods, key, IteratorPrototype;
  1892. if ($anyNative) {
  1893. IteratorPrototype = getPrototypeOf($anyNative.call(new Base()));
  1894. if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
  1895. setToStringTag(IteratorPrototype, TAG, true);
  1896. if (!LIBRARY && typeof IteratorPrototype[ITERATOR] != 'function') hide(IteratorPrototype, ITERATOR, returnThis);
  1897. }
  1898. }
  1899. if (DEF_VALUES && $native && $native.name !== VALUES) {
  1900. VALUES_BUG = true;
  1901. $default = function values() {
  1902. return $native.call(this);
  1903. };
  1904. }
  1905. if ((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {
  1906. hide(proto, ITERATOR, $default);
  1907. }
  1908. Iterators[NAME] = $default;
  1909. Iterators[TAG] = returnThis;
  1910. if (DEFAULT) {
  1911. methods = {
  1912. values: DEF_VALUES ? $default : getMethod(VALUES),
  1913. keys: IS_SET ? $default : getMethod(KEYS),
  1914. entries: $entries
  1915. };
  1916. if (FORCED) for (key in methods) {
  1917. if (!(key in proto)) redefine(proto, key, methods[key]);
  1918. } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);
  1919. }
  1920. return methods;
  1921. };
  1922. /***/ }),
  1923. /* 65 */
  1924. /***/ (function(module, exports, __w_pdfjs_require__) {
  1925. "use strict";
  1926. module.exports = {};
  1927. /***/ }),
  1928. /* 66 */
  1929. /***/ (function(module, exports, __w_pdfjs_require__) {
  1930. "use strict";
  1931. var create = __w_pdfjs_require__(67);
  1932. var descriptor = __w_pdfjs_require__(19);
  1933. var setToStringTag = __w_pdfjs_require__(70);
  1934. var IteratorPrototype = {};
  1935. __w_pdfjs_require__(10)(IteratorPrototype, __w_pdfjs_require__(28)('iterator'), function () {
  1936. return this;
  1937. });
  1938. module.exports = function (Constructor, NAME, next) {
  1939. Constructor.prototype = create(IteratorPrototype, { next: descriptor(1, next) });
  1940. setToStringTag(Constructor, NAME + ' Iterator');
  1941. };
  1942. /***/ }),
  1943. /* 67 */
  1944. /***/ (function(module, exports, __w_pdfjs_require__) {
  1945. "use strict";
  1946. var anObject = __w_pdfjs_require__(12);
  1947. var dPs = __w_pdfjs_require__(68);
  1948. var enumBugKeys = __w_pdfjs_require__(48);
  1949. var IE_PROTO = __w_pdfjs_require__(47)('IE_PROTO');
  1950. var Empty = function Empty() {};
  1951. var PROTOTYPE = 'prototype';
  1952. var _createDict = function createDict() {
  1953. var iframe = __w_pdfjs_require__(17)('iframe');
  1954. var i = enumBugKeys.length;
  1955. var lt = '<';
  1956. var gt = '>';
  1957. var iframeDocument;
  1958. iframe.style.display = 'none';
  1959. __w_pdfjs_require__(69).appendChild(iframe);
  1960. iframe.src = 'javascript:';
  1961. iframeDocument = iframe.contentWindow.document;
  1962. iframeDocument.open();
  1963. iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
  1964. iframeDocument.close();
  1965. _createDict = iframeDocument.F;
  1966. while (i--) {
  1967. delete _createDict[PROTOTYPE][enumBugKeys[i]];
  1968. }return _createDict();
  1969. };
  1970. module.exports = Object.create || function create(O, Properties) {
  1971. var result;
  1972. if (O !== null) {
  1973. Empty[PROTOTYPE] = anObject(O);
  1974. result = new Empty();
  1975. Empty[PROTOTYPE] = null;
  1976. result[IE_PROTO] = O;
  1977. } else result = _createDict();
  1978. return Properties === undefined ? result : dPs(result, Properties);
  1979. };
  1980. /***/ }),
  1981. /* 68 */
  1982. /***/ (function(module, exports, __w_pdfjs_require__) {
  1983. "use strict";
  1984. var dP = __w_pdfjs_require__(11);
  1985. var anObject = __w_pdfjs_require__(12);
  1986. var getKeys = __w_pdfjs_require__(45);
  1987. module.exports = __w_pdfjs_require__(15) ? Object.defineProperties : function defineProperties(O, Properties) {
  1988. anObject(O);
  1989. var keys = getKeys(Properties);
  1990. var length = keys.length;
  1991. var i = 0;
  1992. var P;
  1993. while (length > i) {
  1994. dP.f(O, P = keys[i++], Properties[P]);
  1995. }return O;
  1996. };
  1997. /***/ }),
  1998. /* 69 */
  1999. /***/ (function(module, exports, __w_pdfjs_require__) {
  2000. "use strict";
  2001. var document = __w_pdfjs_require__(8).document;
  2002. module.exports = document && document.documentElement;
  2003. /***/ }),
  2004. /* 70 */
  2005. /***/ (function(module, exports, __w_pdfjs_require__) {
  2006. "use strict";
  2007. var def = __w_pdfjs_require__(11).f;
  2008. var has = __w_pdfjs_require__(21);
  2009. var TAG = __w_pdfjs_require__(28)('toStringTag');
  2010. module.exports = function (it, tag, stat) {
  2011. if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, {
  2012. configurable: true,
  2013. value: tag
  2014. });
  2015. };
  2016. /***/ }),
  2017. /* 71 */
  2018. /***/ (function(module, exports, __w_pdfjs_require__) {
  2019. "use strict";
  2020. var has = __w_pdfjs_require__(21);
  2021. var toObject = __w_pdfjs_require__(51);
  2022. var IE_PROTO = __w_pdfjs_require__(47)('IE_PROTO');
  2023. var ObjectProto = Object.prototype;
  2024. module.exports = Object.getPrototypeOf || function (O) {
  2025. O = toObject(O);
  2026. if (has(O, IE_PROTO)) return O[IE_PROTO];
  2027. if (typeof O.constructor == 'function' && O instanceof O.constructor) {
  2028. return O.constructor.prototype;
  2029. }
  2030. return O instanceof Object ? ObjectProto : null;
  2031. };
  2032. /***/ }),
  2033. /* 72 */
  2034. /***/ (function(module, exports, __w_pdfjs_require__) {
  2035. "use strict";
  2036. var $iterators = __w_pdfjs_require__(73);
  2037. var getKeys = __w_pdfjs_require__(45);
  2038. var redefine = __w_pdfjs_require__(20);
  2039. var global = __w_pdfjs_require__(8);
  2040. var hide = __w_pdfjs_require__(10);
  2041. var Iterators = __w_pdfjs_require__(65);
  2042. var wks = __w_pdfjs_require__(28);
  2043. var ITERATOR = wks('iterator');
  2044. var TO_STRING_TAG = wks('toStringTag');
  2045. var ArrayValues = Iterators.Array;
  2046. var DOMIterables = {
  2047. CSSRuleList: true,
  2048. CSSStyleDeclaration: false,
  2049. CSSValueList: false,
  2050. ClientRectList: false,
  2051. DOMRectList: false,
  2052. DOMStringList: false,
  2053. DOMTokenList: true,
  2054. DataTransferItemList: false,
  2055. FileList: false,
  2056. HTMLAllCollection: false,
  2057. HTMLCollection: false,
  2058. HTMLFormElement: false,
  2059. HTMLSelectElement: false,
  2060. MediaList: true,
  2061. MimeTypeArray: false,
  2062. NamedNodeMap: false,
  2063. NodeList: true,
  2064. PaintRequestList: false,
  2065. Plugin: false,
  2066. PluginArray: false,
  2067. SVGLengthList: false,
  2068. SVGNumberList: false,
  2069. SVGPathSegList: false,
  2070. SVGPointList: false,
  2071. SVGStringList: false,
  2072. SVGTransformList: false,
  2073. SourceBufferList: false,
  2074. StyleSheetList: true,
  2075. TextTrackCueList: false,
  2076. TextTrackList: false,
  2077. TouchList: false
  2078. };
  2079. for (var collections = getKeys(DOMIterables), i = 0; i < collections.length; i++) {
  2080. var NAME = collections[i];
  2081. var explicit = DOMIterables[NAME];
  2082. var Collection = global[NAME];
  2083. var proto = Collection && Collection.prototype;
  2084. var key;
  2085. if (proto) {
  2086. if (!proto[ITERATOR]) hide(proto, ITERATOR, ArrayValues);
  2087. if (!proto[TO_STRING_TAG]) hide(proto, TO_STRING_TAG, NAME);
  2088. Iterators[NAME] = ArrayValues;
  2089. if (explicit) for (key in $iterators) {
  2090. if (!proto[key]) redefine(proto, key, $iterators[key], true);
  2091. }
  2092. }
  2093. }
  2094. /***/ }),
  2095. /* 73 */
  2096. /***/ (function(module, exports, __w_pdfjs_require__) {
  2097. "use strict";
  2098. var addToUnscopables = __w_pdfjs_require__(41);
  2099. var step = __w_pdfjs_require__(74);
  2100. var Iterators = __w_pdfjs_require__(65);
  2101. var toIObject = __w_pdfjs_require__(36);
  2102. module.exports = __w_pdfjs_require__(64)(Array, 'Array', function (iterated, kind) {
  2103. this._t = toIObject(iterated);
  2104. this._i = 0;
  2105. this._k = kind;
  2106. }, function () {
  2107. var O = this._t;
  2108. var kind = this._k;
  2109. var index = this._i++;
  2110. if (!O || index >= O.length) {
  2111. this._t = undefined;
  2112. return step(1);
  2113. }
  2114. if (kind == 'keys') return step(0, index);
  2115. if (kind == 'values') return step(0, O[index]);
  2116. return step(0, [index, O[index]]);
  2117. }, 'values');
  2118. Iterators.Arguments = Iterators.Array;
  2119. addToUnscopables('keys');
  2120. addToUnscopables('values');
  2121. addToUnscopables('entries');
  2122. /***/ }),
  2123. /* 74 */
  2124. /***/ (function(module, exports, __w_pdfjs_require__) {
  2125. "use strict";
  2126. module.exports = function (done, value) {
  2127. return {
  2128. value: value,
  2129. done: !!done
  2130. };
  2131. };
  2132. /***/ }),
  2133. /* 75 */
  2134. /***/ (function(module, exports, __w_pdfjs_require__) {
  2135. "use strict";
  2136. var LIBRARY = __w_pdfjs_require__(30);
  2137. var global = __w_pdfjs_require__(8);
  2138. var ctx = __w_pdfjs_require__(23);
  2139. var classof = __w_pdfjs_require__(61);
  2140. var $export = __w_pdfjs_require__(7);
  2141. var isObject = __w_pdfjs_require__(13);
  2142. var aFunction = __w_pdfjs_require__(24);
  2143. var anInstance = __w_pdfjs_require__(76);
  2144. var forOf = __w_pdfjs_require__(77);
  2145. var speciesConstructor = __w_pdfjs_require__(81);
  2146. var task = __w_pdfjs_require__(82).set;
  2147. var microtask = __w_pdfjs_require__(84)();
  2148. var newPromiseCapabilityModule = __w_pdfjs_require__(85);
  2149. var perform = __w_pdfjs_require__(86);
  2150. var userAgent = __w_pdfjs_require__(87);
  2151. var promiseResolve = __w_pdfjs_require__(88);
  2152. var PROMISE = 'Promise';
  2153. var TypeError = global.TypeError;
  2154. var process = global.process;
  2155. var versions = process && process.versions;
  2156. var v8 = versions && versions.v8 || '';
  2157. var $Promise = global[PROMISE];
  2158. var isNode = classof(process) == 'process';
  2159. var empty = function empty() {};
  2160. var Internal, newGenericPromiseCapability, OwnPromiseCapability, Wrapper;
  2161. var newPromiseCapability = newGenericPromiseCapability = newPromiseCapabilityModule.f;
  2162. var USE_NATIVE = !!function () {
  2163. try {
  2164. var promise = $Promise.resolve(1);
  2165. var FakePromise = (promise.constructor = {})[__w_pdfjs_require__(28)('species')] = function (exec) {
  2166. exec(empty, empty);
  2167. };
  2168. return (isNode || typeof PromiseRejectionEvent == 'function') && promise.then(empty) instanceof FakePromise && v8.indexOf('6.6') !== 0 && userAgent.indexOf('Chrome/66') === -1;
  2169. } catch (e) {}
  2170. }();
  2171. var isThenable = function isThenable(it) {
  2172. var then;
  2173. return isObject(it) && typeof (then = it.then) == 'function' ? then : false;
  2174. };
  2175. var notify = function notify(promise, isReject) {
  2176. if (promise._n) return;
  2177. promise._n = true;
  2178. var chain = promise._c;
  2179. microtask(function () {
  2180. var value = promise._v;
  2181. var ok = promise._s == 1;
  2182. var i = 0;
  2183. var run = function run(reaction) {
  2184. var handler = ok ? reaction.ok : reaction.fail;
  2185. var resolve = reaction.resolve;
  2186. var reject = reaction.reject;
  2187. var domain = reaction.domain;
  2188. var result, then, exited;
  2189. try {
  2190. if (handler) {
  2191. if (!ok) {
  2192. if (promise._h == 2) onHandleUnhandled(promise);
  2193. promise._h = 1;
  2194. }
  2195. if (handler === true) result = value;else {
  2196. if (domain) domain.enter();
  2197. result = handler(value);
  2198. if (domain) {
  2199. domain.exit();
  2200. exited = true;
  2201. }
  2202. }
  2203. if (result === reaction.promise) {
  2204. reject(TypeError('Promise-chain cycle'));
  2205. } else if (then = isThenable(result)) {
  2206. then.call(result, resolve, reject);
  2207. } else resolve(result);
  2208. } else reject(value);
  2209. } catch (e) {
  2210. if (domain && !exited) domain.exit();
  2211. reject(e);
  2212. }
  2213. };
  2214. while (chain.length > i) {
  2215. run(chain[i++]);
  2216. }promise._c = [];
  2217. promise._n = false;
  2218. if (isReject && !promise._h) onUnhandled(promise);
  2219. });
  2220. };
  2221. var onUnhandled = function onUnhandled(promise) {
  2222. task.call(global, function () {
  2223. var value = promise._v;
  2224. var unhandled = isUnhandled(promise);
  2225. var result, handler, console;
  2226. if (unhandled) {
  2227. result = perform(function () {
  2228. if (isNode) {
  2229. process.emit('unhandledRejection', value, promise);
  2230. } else if (handler = global.onunhandledrejection) {
  2231. handler({
  2232. promise: promise,
  2233. reason: value
  2234. });
  2235. } else if ((console = global.console) && console.error) {
  2236. console.error('Unhandled promise rejection', value);
  2237. }
  2238. });
  2239. promise._h = isNode || isUnhandled(promise) ? 2 : 1;
  2240. }
  2241. promise._a = undefined;
  2242. if (unhandled && result.e) throw result.v;
  2243. });
  2244. };
  2245. var isUnhandled = function isUnhandled(promise) {
  2246. return promise._h !== 1 && (promise._a || promise._c).length === 0;
  2247. };
  2248. var onHandleUnhandled = function onHandleUnhandled(promise) {
  2249. task.call(global, function () {
  2250. var handler;
  2251. if (isNode) {
  2252. process.emit('rejectionHandled', promise);
  2253. } else if (handler = global.onrejectionhandled) {
  2254. handler({
  2255. promise: promise,
  2256. reason: promise._v
  2257. });
  2258. }
  2259. });
  2260. };
  2261. var $reject = function $reject(value) {
  2262. var promise = this;
  2263. if (promise._d) return;
  2264. promise._d = true;
  2265. promise = promise._w || promise;
  2266. promise._v = value;
  2267. promise._s = 2;
  2268. if (!promise._a) promise._a = promise._c.slice();
  2269. notify(promise, true);
  2270. };
  2271. var $resolve = function $resolve(value) {
  2272. var promise = this;
  2273. var then;
  2274. if (promise._d) return;
  2275. promise._d = true;
  2276. promise = promise._w || promise;
  2277. try {
  2278. if (promise === value) throw TypeError("Promise can't be resolved itself");
  2279. if (then = isThenable(value)) {
  2280. microtask(function () {
  2281. var wrapper = {
  2282. _w: promise,
  2283. _d: false
  2284. };
  2285. try {
  2286. then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1));
  2287. } catch (e) {
  2288. $reject.call(wrapper, e);
  2289. }
  2290. });
  2291. } else {
  2292. promise._v = value;
  2293. promise._s = 1;
  2294. notify(promise, false);
  2295. }
  2296. } catch (e) {
  2297. $reject.call({
  2298. _w: promise,
  2299. _d: false
  2300. }, e);
  2301. }
  2302. };
  2303. if (!USE_NATIVE) {
  2304. $Promise = function Promise(executor) {
  2305. anInstance(this, $Promise, PROMISE, '_h');
  2306. aFunction(executor);
  2307. Internal.call(this);
  2308. try {
  2309. executor(ctx($resolve, this, 1), ctx($reject, this, 1));
  2310. } catch (err) {
  2311. $reject.call(this, err);
  2312. }
  2313. };
  2314. Internal = function Promise(executor) {
  2315. this._c = [];
  2316. this._a = undefined;
  2317. this._s = 0;
  2318. this._d = false;
  2319. this._v = undefined;
  2320. this._h = 0;
  2321. this._n = false;
  2322. };
  2323. Internal.prototype = __w_pdfjs_require__(89)($Promise.prototype, {
  2324. then: function then(onFulfilled, onRejected) {
  2325. var reaction = newPromiseCapability(speciesConstructor(this, $Promise));
  2326. reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
  2327. reaction.fail = typeof onRejected == 'function' && onRejected;
  2328. reaction.domain = isNode ? process.domain : undefined;
  2329. this._c.push(reaction);
  2330. if (this._a) this._a.push(reaction);
  2331. if (this._s) notify(this, false);
  2332. return reaction.promise;
  2333. },
  2334. 'catch': function _catch(onRejected) {
  2335. return this.then(undefined, onRejected);
  2336. }
  2337. });
  2338. OwnPromiseCapability = function OwnPromiseCapability() {
  2339. var promise = new Internal();
  2340. this.promise = promise;
  2341. this.resolve = ctx($resolve, promise, 1);
  2342. this.reject = ctx($reject, promise, 1);
  2343. };
  2344. newPromiseCapabilityModule.f = newPromiseCapability = function newPromiseCapability(C) {
  2345. return C === $Promise || C === Wrapper ? new OwnPromiseCapability(C) : newGenericPromiseCapability(C);
  2346. };
  2347. }
  2348. $export($export.G + $export.W + $export.F * !USE_NATIVE, { Promise: $Promise });
  2349. __w_pdfjs_require__(70)($Promise, PROMISE);
  2350. __w_pdfjs_require__(90)(PROMISE);
  2351. Wrapper = __w_pdfjs_require__(9)[PROMISE];
  2352. $export($export.S + $export.F * !USE_NATIVE, PROMISE, {
  2353. reject: function reject(r) {
  2354. var capability = newPromiseCapability(this);
  2355. var $$reject = capability.reject;
  2356. $$reject(r);
  2357. return capability.promise;
  2358. }
  2359. });
  2360. $export($export.S + $export.F * (LIBRARY || !USE_NATIVE), PROMISE, {
  2361. resolve: function resolve(x) {
  2362. return promiseResolve(LIBRARY && this === Wrapper ? $Promise : this, x);
  2363. }
  2364. });
  2365. $export($export.S + $export.F * !(USE_NATIVE && __w_pdfjs_require__(91)(function (iter) {
  2366. $Promise.all(iter)['catch'](empty);
  2367. })), PROMISE, {
  2368. all: function all(iterable) {
  2369. var C = this;
  2370. var capability = newPromiseCapability(C);
  2371. var resolve = capability.resolve;
  2372. var reject = capability.reject;
  2373. var result = perform(function () {
  2374. var values = [];
  2375. var index = 0;
  2376. var remaining = 1;
  2377. forOf(iterable, false, function (promise) {
  2378. var $index = index++;
  2379. var alreadyCalled = false;
  2380. values.push(undefined);
  2381. remaining++;
  2382. C.resolve(promise).then(function (value) {
  2383. if (alreadyCalled) return;
  2384. alreadyCalled = true;
  2385. values[$index] = value;
  2386. --remaining || resolve(values);
  2387. }, reject);
  2388. });
  2389. --remaining || resolve(values);
  2390. });
  2391. if (result.e) reject(result.v);
  2392. return capability.promise;
  2393. },
  2394. race: function race(iterable) {
  2395. var C = this;
  2396. var capability = newPromiseCapability(C);
  2397. var reject = capability.reject;
  2398. var result = perform(function () {
  2399. forOf(iterable, false, function (promise) {
  2400. C.resolve(promise).then(capability.resolve, reject);
  2401. });
  2402. });
  2403. if (result.e) reject(result.v);
  2404. return capability.promise;
  2405. }
  2406. });
  2407. /***/ }),
  2408. /* 76 */
  2409. /***/ (function(module, exports, __w_pdfjs_require__) {
  2410. "use strict";
  2411. module.exports = function (it, Constructor, name, forbiddenField) {
  2412. if (!(it instanceof Constructor) || forbiddenField !== undefined && forbiddenField in it) {
  2413. throw TypeError(name + ': incorrect invocation!');
  2414. }
  2415. return it;
  2416. };
  2417. /***/ }),
  2418. /* 77 */
  2419. /***/ (function(module, exports, __w_pdfjs_require__) {
  2420. "use strict";
  2421. var ctx = __w_pdfjs_require__(23);
  2422. var call = __w_pdfjs_require__(78);
  2423. var isArrayIter = __w_pdfjs_require__(79);
  2424. var anObject = __w_pdfjs_require__(12);
  2425. var toLength = __w_pdfjs_require__(38);
  2426. var getIterFn = __w_pdfjs_require__(80);
  2427. var BREAK = {};
  2428. var RETURN = {};
  2429. var _exports = module.exports = function (iterable, entries, fn, that, ITERATOR) {
  2430. var iterFn = ITERATOR ? function () {
  2431. return iterable;
  2432. } : getIterFn(iterable);
  2433. var f = ctx(fn, that, entries ? 2 : 1);
  2434. var index = 0;
  2435. var length, step, iterator, result;
  2436. if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!');
  2437. if (isArrayIter(iterFn)) for (length = toLength(iterable.length); length > index; index++) {
  2438. result = entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
  2439. if (result === BREAK || result === RETURN) return result;
  2440. } else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) {
  2441. result = call(iterator, f, step.value, entries);
  2442. if (result === BREAK || result === RETURN) return result;
  2443. }
  2444. };
  2445. _exports.BREAK = BREAK;
  2446. _exports.RETURN = RETURN;
  2447. /***/ }),
  2448. /* 78 */
  2449. /***/ (function(module, exports, __w_pdfjs_require__) {
  2450. "use strict";
  2451. var anObject = __w_pdfjs_require__(12);
  2452. module.exports = function (iterator, fn, value, entries) {
  2453. try {
  2454. return entries ? fn(anObject(value)[0], value[1]) : fn(value);
  2455. } catch (e) {
  2456. var ret = iterator['return'];
  2457. if (ret !== undefined) anObject(ret.call(iterator));
  2458. throw e;
  2459. }
  2460. };
  2461. /***/ }),
  2462. /* 79 */
  2463. /***/ (function(module, exports, __w_pdfjs_require__) {
  2464. "use strict";
  2465. var Iterators = __w_pdfjs_require__(65);
  2466. var ITERATOR = __w_pdfjs_require__(28)('iterator');
  2467. var ArrayProto = Array.prototype;
  2468. module.exports = function (it) {
  2469. return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it);
  2470. };
  2471. /***/ }),
  2472. /* 80 */
  2473. /***/ (function(module, exports, __w_pdfjs_require__) {
  2474. "use strict";
  2475. var classof = __w_pdfjs_require__(61);
  2476. var ITERATOR = __w_pdfjs_require__(28)('iterator');
  2477. var Iterators = __w_pdfjs_require__(65);
  2478. module.exports = __w_pdfjs_require__(9).getIteratorMethod = function (it) {
  2479. if (it != undefined) return it[ITERATOR] || it['@@iterator'] || Iterators[classof(it)];
  2480. };
  2481. /***/ }),
  2482. /* 81 */
  2483. /***/ (function(module, exports, __w_pdfjs_require__) {
  2484. "use strict";
  2485. var anObject = __w_pdfjs_require__(12);
  2486. var aFunction = __w_pdfjs_require__(24);
  2487. var SPECIES = __w_pdfjs_require__(28)('species');
  2488. module.exports = function (O, D) {
  2489. var C = anObject(O).constructor;
  2490. var S;
  2491. return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S);
  2492. };
  2493. /***/ }),
  2494. /* 82 */
  2495. /***/ (function(module, exports, __w_pdfjs_require__) {
  2496. "use strict";
  2497. var ctx = __w_pdfjs_require__(23);
  2498. var invoke = __w_pdfjs_require__(83);
  2499. var html = __w_pdfjs_require__(69);
  2500. var cel = __w_pdfjs_require__(17);
  2501. var global = __w_pdfjs_require__(8);
  2502. var process = global.process;
  2503. var setTask = global.setImmediate;
  2504. var clearTask = global.clearImmediate;
  2505. var MessageChannel = global.MessageChannel;
  2506. var Dispatch = global.Dispatch;
  2507. var counter = 0;
  2508. var queue = {};
  2509. var ONREADYSTATECHANGE = 'onreadystatechange';
  2510. var defer, channel, port;
  2511. var run = function run() {
  2512. var id = +this;
  2513. if (queue.hasOwnProperty(id)) {
  2514. var fn = queue[id];
  2515. delete queue[id];
  2516. fn();
  2517. }
  2518. };
  2519. var listener = function listener(event) {
  2520. run.call(event.data);
  2521. };
  2522. if (!setTask || !clearTask) {
  2523. setTask = function setImmediate(fn) {
  2524. var args = [];
  2525. var i = 1;
  2526. while (arguments.length > i) {
  2527. args.push(arguments[i++]);
  2528. }queue[++counter] = function () {
  2529. invoke(typeof fn == 'function' ? fn : Function(fn), args);
  2530. };
  2531. defer(counter);
  2532. return counter;
  2533. };
  2534. clearTask = function clearImmediate(id) {
  2535. delete queue[id];
  2536. };
  2537. if (__w_pdfjs_require__(27)(process) == 'process') {
  2538. defer = function defer(id) {
  2539. process.nextTick(ctx(run, id, 1));
  2540. };
  2541. } else if (Dispatch && Dispatch.now) {
  2542. defer = function defer(id) {
  2543. Dispatch.now(ctx(run, id, 1));
  2544. };
  2545. } else if (MessageChannel) {
  2546. channel = new MessageChannel();
  2547. port = channel.port2;
  2548. channel.port1.onmessage = listener;
  2549. defer = ctx(port.postMessage, port, 1);
  2550. } else if (global.addEventListener && typeof postMessage == 'function' && !global.importScripts) {
  2551. defer = function defer(id) {
  2552. global.postMessage(id + '', '*');
  2553. };
  2554. global.addEventListener('message', listener, false);
  2555. } else if (ONREADYSTATECHANGE in cel('script')) {
  2556. defer = function defer(id) {
  2557. html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function () {
  2558. html.removeChild(this);
  2559. run.call(id);
  2560. };
  2561. };
  2562. } else {
  2563. defer = function defer(id) {
  2564. setTimeout(ctx(run, id, 1), 0);
  2565. };
  2566. }
  2567. }
  2568. module.exports = {
  2569. set: setTask,
  2570. clear: clearTask
  2571. };
  2572. /***/ }),
  2573. /* 83 */
  2574. /***/ (function(module, exports, __w_pdfjs_require__) {
  2575. "use strict";
  2576. module.exports = function (fn, args, that) {
  2577. var un = that === undefined;
  2578. switch (args.length) {
  2579. case 0:
  2580. return un ? fn() : fn.call(that);
  2581. case 1:
  2582. return un ? fn(args[0]) : fn.call(that, args[0]);
  2583. case 2:
  2584. return un ? fn(args[0], args[1]) : fn.call(that, args[0], args[1]);
  2585. case 3:
  2586. return un ? fn(args[0], args[1], args[2]) : fn.call(that, args[0], args[1], args[2]);
  2587. case 4:
  2588. return un ? fn(args[0], args[1], args[2], args[3]) : fn.call(that, args[0], args[1], args[2], args[3]);
  2589. }
  2590. return fn.apply(that, args);
  2591. };
  2592. /***/ }),
  2593. /* 84 */
  2594. /***/ (function(module, exports, __w_pdfjs_require__) {
  2595. "use strict";
  2596. var global = __w_pdfjs_require__(8);
  2597. var macrotask = __w_pdfjs_require__(82).set;
  2598. var Observer = global.MutationObserver || global.WebKitMutationObserver;
  2599. var process = global.process;
  2600. var Promise = global.Promise;
  2601. var isNode = __w_pdfjs_require__(27)(process) == 'process';
  2602. module.exports = function () {
  2603. var head, last, notify;
  2604. var flush = function flush() {
  2605. var parent, fn;
  2606. if (isNode && (parent = process.domain)) parent.exit();
  2607. while (head) {
  2608. fn = head.fn;
  2609. head = head.next;
  2610. try {
  2611. fn();
  2612. } catch (e) {
  2613. if (head) notify();else last = undefined;
  2614. throw e;
  2615. }
  2616. }
  2617. last = undefined;
  2618. if (parent) parent.enter();
  2619. };
  2620. if (isNode) {
  2621. notify = function notify() {
  2622. process.nextTick(flush);
  2623. };
  2624. } else if (Observer && !(global.navigator && global.navigator.standalone)) {
  2625. var toggle = true;
  2626. var node = document.createTextNode('');
  2627. new Observer(flush).observe(node, { characterData: true });
  2628. notify = function notify() {
  2629. node.data = toggle = !toggle;
  2630. };
  2631. } else if (Promise && Promise.resolve) {
  2632. var promise = Promise.resolve(undefined);
  2633. notify = function notify() {
  2634. promise.then(flush);
  2635. };
  2636. } else {
  2637. notify = function notify() {
  2638. macrotask.call(global, flush);
  2639. };
  2640. }
  2641. return function (fn) {
  2642. var task = {
  2643. fn: fn,
  2644. next: undefined
  2645. };
  2646. if (last) last.next = task;
  2647. if (!head) {
  2648. head = task;
  2649. notify();
  2650. }
  2651. last = task;
  2652. };
  2653. };
  2654. /***/ }),
  2655. /* 85 */
  2656. /***/ (function(module, exports, __w_pdfjs_require__) {
  2657. "use strict";
  2658. var aFunction = __w_pdfjs_require__(24);
  2659. function PromiseCapability(C) {
  2660. var resolve, reject;
  2661. this.promise = new C(function ($$resolve, $$reject) {
  2662. if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');
  2663. resolve = $$resolve;
  2664. reject = $$reject;
  2665. });
  2666. this.resolve = aFunction(resolve);
  2667. this.reject = aFunction(reject);
  2668. }
  2669. module.exports.f = function (C) {
  2670. return new PromiseCapability(C);
  2671. };
  2672. /***/ }),
  2673. /* 86 */
  2674. /***/ (function(module, exports, __w_pdfjs_require__) {
  2675. "use strict";
  2676. module.exports = function (exec) {
  2677. try {
  2678. return {
  2679. e: false,
  2680. v: exec()
  2681. };
  2682. } catch (e) {
  2683. return {
  2684. e: true,
  2685. v: e
  2686. };
  2687. }
  2688. };
  2689. /***/ }),
  2690. /* 87 */
  2691. /***/ (function(module, exports, __w_pdfjs_require__) {
  2692. "use strict";
  2693. var global = __w_pdfjs_require__(8);
  2694. var navigator = global.navigator;
  2695. module.exports = navigator && navigator.userAgent || '';
  2696. /***/ }),
  2697. /* 88 */
  2698. /***/ (function(module, exports, __w_pdfjs_require__) {
  2699. "use strict";
  2700. var anObject = __w_pdfjs_require__(12);
  2701. var isObject = __w_pdfjs_require__(13);
  2702. var newPromiseCapability = __w_pdfjs_require__(85);
  2703. module.exports = function (C, x) {
  2704. anObject(C);
  2705. if (isObject(x) && x.constructor === C) return x;
  2706. var promiseCapability = newPromiseCapability.f(C);
  2707. var resolve = promiseCapability.resolve;
  2708. resolve(x);
  2709. return promiseCapability.promise;
  2710. };
  2711. /***/ }),
  2712. /* 89 */
  2713. /***/ (function(module, exports, __w_pdfjs_require__) {
  2714. "use strict";
  2715. var redefine = __w_pdfjs_require__(20);
  2716. module.exports = function (target, src, safe) {
  2717. for (var key in src) {
  2718. redefine(target, key, src[key], safe);
  2719. }return target;
  2720. };
  2721. /***/ }),
  2722. /* 90 */
  2723. /***/ (function(module, exports, __w_pdfjs_require__) {
  2724. "use strict";
  2725. var global = __w_pdfjs_require__(8);
  2726. var dP = __w_pdfjs_require__(11);
  2727. var DESCRIPTORS = __w_pdfjs_require__(15);
  2728. var SPECIES = __w_pdfjs_require__(28)('species');
  2729. module.exports = function (KEY) {
  2730. var C = global[KEY];
  2731. if (DESCRIPTORS && C && !C[SPECIES]) dP.f(C, SPECIES, {
  2732. configurable: true,
  2733. get: function get() {
  2734. return this;
  2735. }
  2736. });
  2737. };
  2738. /***/ }),
  2739. /* 91 */
  2740. /***/ (function(module, exports, __w_pdfjs_require__) {
  2741. "use strict";
  2742. var ITERATOR = __w_pdfjs_require__(28)('iterator');
  2743. var SAFE_CLOSING = false;
  2744. try {
  2745. var riter = [7][ITERATOR]();
  2746. riter['return'] = function () {
  2747. SAFE_CLOSING = true;
  2748. };
  2749. Array.from(riter, function () {
  2750. throw 2;
  2751. });
  2752. } catch (e) {}
  2753. module.exports = function (exec, skipClosing) {
  2754. if (!skipClosing && !SAFE_CLOSING) return false;
  2755. var safe = false;
  2756. try {
  2757. var arr = [7];
  2758. var iter = arr[ITERATOR]();
  2759. iter.next = function () {
  2760. return { done: safe = true };
  2761. };
  2762. arr[ITERATOR] = function () {
  2763. return iter;
  2764. };
  2765. exec(arr);
  2766. } catch (e) {}
  2767. return safe;
  2768. };
  2769. /***/ }),
  2770. /* 92 */
  2771. /***/ (function(module, exports, __w_pdfjs_require__) {
  2772. "use strict";
  2773. var $export = __w_pdfjs_require__(7);
  2774. var core = __w_pdfjs_require__(9);
  2775. var global = __w_pdfjs_require__(8);
  2776. var speciesConstructor = __w_pdfjs_require__(81);
  2777. var promiseResolve = __w_pdfjs_require__(88);
  2778. $export($export.P + $export.R, 'Promise', {
  2779. 'finally': function _finally(onFinally) {
  2780. var C = speciesConstructor(this, core.Promise || global.Promise);
  2781. var isFunction = typeof onFinally == 'function';
  2782. return this.then(isFunction ? function (x) {
  2783. return promiseResolve(C, onFinally()).then(function () {
  2784. return x;
  2785. });
  2786. } : onFinally, isFunction ? function (e) {
  2787. return promiseResolve(C, onFinally()).then(function () {
  2788. throw e;
  2789. });
  2790. } : onFinally);
  2791. }
  2792. });
  2793. /***/ }),
  2794. /* 93 */
  2795. /***/ (function(module, exports, __w_pdfjs_require__) {
  2796. "use strict";
  2797. var $export = __w_pdfjs_require__(7);
  2798. var newPromiseCapability = __w_pdfjs_require__(85);
  2799. var perform = __w_pdfjs_require__(86);
  2800. $export($export.S, 'Promise', {
  2801. 'try': function _try(callbackfn) {
  2802. var promiseCapability = newPromiseCapability.f(this);
  2803. var result = perform(callbackfn);
  2804. (result.e ? promiseCapability.reject : promiseCapability.resolve)(result.v);
  2805. return promiseCapability.promise;
  2806. }
  2807. });
  2808. /***/ }),
  2809. /* 94 */
  2810. /***/ (function(module, exports, __w_pdfjs_require__) {
  2811. "use strict";
  2812. __w_pdfjs_require__(60);
  2813. __w_pdfjs_require__(72);
  2814. __w_pdfjs_require__(95);
  2815. __w_pdfjs_require__(107);
  2816. __w_pdfjs_require__(109);
  2817. module.exports = __w_pdfjs_require__(9).WeakMap;
  2818. /***/ }),
  2819. /* 95 */
  2820. /***/ (function(module, exports, __w_pdfjs_require__) {
  2821. "use strict";
  2822. var each = __w_pdfjs_require__(96)(0);
  2823. var redefine = __w_pdfjs_require__(20);
  2824. var meta = __w_pdfjs_require__(100);
  2825. var assign = __w_pdfjs_require__(44);
  2826. var weak = __w_pdfjs_require__(101);
  2827. var isObject = __w_pdfjs_require__(13);
  2828. var fails = __w_pdfjs_require__(16);
  2829. var validate = __w_pdfjs_require__(102);
  2830. var WEAK_MAP = 'WeakMap';
  2831. var getWeak = meta.getWeak;
  2832. var isExtensible = Object.isExtensible;
  2833. var uncaughtFrozenStore = weak.ufstore;
  2834. var tmp = {};
  2835. var InternalMap;
  2836. var wrapper = function wrapper(get) {
  2837. return function WeakMap() {
  2838. return get(this, arguments.length > 0 ? arguments[0] : undefined);
  2839. };
  2840. };
  2841. var methods = {
  2842. get: function get(key) {
  2843. if (isObject(key)) {
  2844. var data = getWeak(key);
  2845. if (data === true) return uncaughtFrozenStore(validate(this, WEAK_MAP)).get(key);
  2846. return data ? data[this._i] : undefined;
  2847. }
  2848. },
  2849. set: function set(key, value) {
  2850. return weak.def(validate(this, WEAK_MAP), key, value);
  2851. }
  2852. };
  2853. var $WeakMap = module.exports = __w_pdfjs_require__(103)(WEAK_MAP, wrapper, methods, weak, true, true);
  2854. if (fails(function () {
  2855. return new $WeakMap().set((Object.freeze || Object)(tmp), 7).get(tmp) != 7;
  2856. })) {
  2857. InternalMap = weak.getConstructor(wrapper, WEAK_MAP);
  2858. assign(InternalMap.prototype, methods);
  2859. meta.NEED = true;
  2860. each(['delete', 'has', 'get', 'set'], function (key) {
  2861. var proto = $WeakMap.prototype;
  2862. var method = proto[key];
  2863. redefine(proto, key, function (a, b) {
  2864. if (isObject(a) && !isExtensible(a)) {
  2865. if (!this._f) this._f = new InternalMap();
  2866. var result = this._f[key](a, b);
  2867. return key == 'set' ? this : result;
  2868. }
  2869. return method.call(this, a, b);
  2870. });
  2871. });
  2872. }
  2873. /***/ }),
  2874. /* 96 */
  2875. /***/ (function(module, exports, __w_pdfjs_require__) {
  2876. "use strict";
  2877. var ctx = __w_pdfjs_require__(23);
  2878. var IObject = __w_pdfjs_require__(37);
  2879. var toObject = __w_pdfjs_require__(51);
  2880. var toLength = __w_pdfjs_require__(38);
  2881. var asc = __w_pdfjs_require__(97);
  2882. module.exports = function (TYPE, $create) {
  2883. var IS_MAP = TYPE == 1;
  2884. var IS_FILTER = TYPE == 2;
  2885. var IS_SOME = TYPE == 3;
  2886. var IS_EVERY = TYPE == 4;
  2887. var IS_FIND_INDEX = TYPE == 6;
  2888. var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
  2889. var create = $create || asc;
  2890. return function ($this, callbackfn, that) {
  2891. var O = toObject($this);
  2892. var self = IObject(O);
  2893. var f = ctx(callbackfn, that, 3);
  2894. var length = toLength(self.length);
  2895. var index = 0;
  2896. var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
  2897. var val, res;
  2898. for (; length > index; index++) {
  2899. if (NO_HOLES || index in self) {
  2900. val = self[index];
  2901. res = f(val, index, O);
  2902. if (TYPE) {
  2903. if (IS_MAP) result[index] = res;else if (res) switch (TYPE) {
  2904. case 3:
  2905. return true;
  2906. case 5:
  2907. return val;
  2908. case 6:
  2909. return index;
  2910. case 2:
  2911. result.push(val);
  2912. } else if (IS_EVERY) return false;
  2913. }
  2914. }
  2915. }return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;
  2916. };
  2917. };
  2918. /***/ }),
  2919. /* 97 */
  2920. /***/ (function(module, exports, __w_pdfjs_require__) {
  2921. "use strict";
  2922. var speciesConstructor = __w_pdfjs_require__(98);
  2923. module.exports = function (original, length) {
  2924. return new (speciesConstructor(original))(length);
  2925. };
  2926. /***/ }),
  2927. /* 98 */
  2928. /***/ (function(module, exports, __w_pdfjs_require__) {
  2929. "use strict";
  2930. var isObject = __w_pdfjs_require__(13);
  2931. var isArray = __w_pdfjs_require__(99);
  2932. var SPECIES = __w_pdfjs_require__(28)('species');
  2933. module.exports = function (original) {
  2934. var C;
  2935. if (isArray(original)) {
  2936. C = original.constructor;
  2937. if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
  2938. if (isObject(C)) {
  2939. C = C[SPECIES];
  2940. if (C === null) C = undefined;
  2941. }
  2942. }
  2943. return C === undefined ? Array : C;
  2944. };
  2945. /***/ }),
  2946. /* 99 */
  2947. /***/ (function(module, exports, __w_pdfjs_require__) {
  2948. "use strict";
  2949. var cof = __w_pdfjs_require__(27);
  2950. module.exports = Array.isArray || function isArray(arg) {
  2951. return cof(arg) == 'Array';
  2952. };
  2953. /***/ }),
  2954. /* 100 */
  2955. /***/ (function(module, exports, __w_pdfjs_require__) {
  2956. "use strict";
  2957. 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; };
  2958. var META = __w_pdfjs_require__(22)('meta');
  2959. var isObject = __w_pdfjs_require__(13);
  2960. var has = __w_pdfjs_require__(21);
  2961. var setDesc = __w_pdfjs_require__(11).f;
  2962. var id = 0;
  2963. var isExtensible = Object.isExtensible || function () {
  2964. return true;
  2965. };
  2966. var FREEZE = !__w_pdfjs_require__(16)(function () {
  2967. return isExtensible(Object.preventExtensions({}));
  2968. });
  2969. var setMeta = function setMeta(it) {
  2970. setDesc(it, META, {
  2971. value: {
  2972. i: 'O' + ++id,
  2973. w: {}
  2974. }
  2975. });
  2976. };
  2977. var fastKey = function fastKey(it, create) {
  2978. if (!isObject(it)) return (typeof it === 'undefined' ? 'undefined' : _typeof(it)) == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
  2979. if (!has(it, META)) {
  2980. if (!isExtensible(it)) return 'F';
  2981. if (!create) return 'E';
  2982. setMeta(it);
  2983. }
  2984. return it[META].i;
  2985. };
  2986. var getWeak = function getWeak(it, create) {
  2987. if (!has(it, META)) {
  2988. if (!isExtensible(it)) return true;
  2989. if (!create) return false;
  2990. setMeta(it);
  2991. }
  2992. return it[META].w;
  2993. };
  2994. var onFreeze = function onFreeze(it) {
  2995. if (FREEZE && meta.NEED && isExtensible(it) && !has(it, META)) setMeta(it);
  2996. return it;
  2997. };
  2998. var meta = module.exports = {
  2999. KEY: META,
  3000. NEED: false,
  3001. fastKey: fastKey,
  3002. getWeak: getWeak,
  3003. onFreeze: onFreeze
  3004. };
  3005. /***/ }),
  3006. /* 101 */
  3007. /***/ (function(module, exports, __w_pdfjs_require__) {
  3008. "use strict";
  3009. var redefineAll = __w_pdfjs_require__(89);
  3010. var getWeak = __w_pdfjs_require__(100).getWeak;
  3011. var anObject = __w_pdfjs_require__(12);
  3012. var isObject = __w_pdfjs_require__(13);
  3013. var anInstance = __w_pdfjs_require__(76);
  3014. var forOf = __w_pdfjs_require__(77);
  3015. var createArrayMethod = __w_pdfjs_require__(96);
  3016. var $has = __w_pdfjs_require__(21);
  3017. var validate = __w_pdfjs_require__(102);
  3018. var arrayFind = createArrayMethod(5);
  3019. var arrayFindIndex = createArrayMethod(6);
  3020. var id = 0;
  3021. var uncaughtFrozenStore = function uncaughtFrozenStore(that) {
  3022. return that._l || (that._l = new UncaughtFrozenStore());
  3023. };
  3024. var UncaughtFrozenStore = function UncaughtFrozenStore() {
  3025. this.a = [];
  3026. };
  3027. var findUncaughtFrozen = function findUncaughtFrozen(store, key) {
  3028. return arrayFind(store.a, function (it) {
  3029. return it[0] === key;
  3030. });
  3031. };
  3032. UncaughtFrozenStore.prototype = {
  3033. get: function get(key) {
  3034. var entry = findUncaughtFrozen(this, key);
  3035. if (entry) return entry[1];
  3036. },
  3037. has: function has(key) {
  3038. return !!findUncaughtFrozen(this, key);
  3039. },
  3040. set: function set(key, value) {
  3041. var entry = findUncaughtFrozen(this, key);
  3042. if (entry) entry[1] = value;else this.a.push([key, value]);
  3043. },
  3044. 'delete': function _delete(key) {
  3045. var index = arrayFindIndex(this.a, function (it) {
  3046. return it[0] === key;
  3047. });
  3048. if (~index) this.a.splice(index, 1);
  3049. return !!~index;
  3050. }
  3051. };
  3052. module.exports = {
  3053. getConstructor: function getConstructor(wrapper, NAME, IS_MAP, ADDER) {
  3054. var C = wrapper(function (that, iterable) {
  3055. anInstance(that, C, NAME, '_i');
  3056. that._t = NAME;
  3057. that._i = id++;
  3058. that._l = undefined;
  3059. if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);
  3060. });
  3061. redefineAll(C.prototype, {
  3062. 'delete': function _delete(key) {
  3063. if (!isObject(key)) return false;
  3064. var data = getWeak(key);
  3065. if (data === true) return uncaughtFrozenStore(validate(this, NAME))['delete'](key);
  3066. return data && $has(data, this._i) && delete data[this._i];
  3067. },
  3068. has: function has(key) {
  3069. if (!isObject(key)) return false;
  3070. var data = getWeak(key);
  3071. if (data === true) return uncaughtFrozenStore(validate(this, NAME)).has(key);
  3072. return data && $has(data, this._i);
  3073. }
  3074. });
  3075. return C;
  3076. },
  3077. def: function def(that, key, value) {
  3078. var data = getWeak(anObject(key), true);
  3079. if (data === true) uncaughtFrozenStore(that).set(key, value);else data[that._i] = value;
  3080. return that;
  3081. },
  3082. ufstore: uncaughtFrozenStore
  3083. };
  3084. /***/ }),
  3085. /* 102 */
  3086. /***/ (function(module, exports, __w_pdfjs_require__) {
  3087. "use strict";
  3088. var isObject = __w_pdfjs_require__(13);
  3089. module.exports = function (it, TYPE) {
  3090. if (!isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!');
  3091. return it;
  3092. };
  3093. /***/ }),
  3094. /* 103 */
  3095. /***/ (function(module, exports, __w_pdfjs_require__) {
  3096. "use strict";
  3097. var global = __w_pdfjs_require__(8);
  3098. var $export = __w_pdfjs_require__(7);
  3099. var redefine = __w_pdfjs_require__(20);
  3100. var redefineAll = __w_pdfjs_require__(89);
  3101. var meta = __w_pdfjs_require__(100);
  3102. var forOf = __w_pdfjs_require__(77);
  3103. var anInstance = __w_pdfjs_require__(76);
  3104. var isObject = __w_pdfjs_require__(13);
  3105. var fails = __w_pdfjs_require__(16);
  3106. var $iterDetect = __w_pdfjs_require__(91);
  3107. var setToStringTag = __w_pdfjs_require__(70);
  3108. var inheritIfRequired = __w_pdfjs_require__(104);
  3109. module.exports = function (NAME, wrapper, methods, common, IS_MAP, IS_WEAK) {
  3110. var Base = global[NAME];
  3111. var C = Base;
  3112. var ADDER = IS_MAP ? 'set' : 'add';
  3113. var proto = C && C.prototype;
  3114. var O = {};
  3115. var fixMethod = function fixMethod(KEY) {
  3116. var fn = proto[KEY];
  3117. redefine(proto, KEY, KEY == 'delete' ? function (a) {
  3118. return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
  3119. } : KEY == 'has' ? function has(a) {
  3120. return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
  3121. } : KEY == 'get' ? function get(a) {
  3122. return IS_WEAK && !isObject(a) ? undefined : fn.call(this, a === 0 ? 0 : a);
  3123. } : KEY == 'add' ? function add(a) {
  3124. fn.call(this, a === 0 ? 0 : a);
  3125. return this;
  3126. } : function set(a, b) {
  3127. fn.call(this, a === 0 ? 0 : a, b);
  3128. return this;
  3129. });
  3130. };
  3131. if (typeof C != 'function' || !(IS_WEAK || proto.forEach && !fails(function () {
  3132. new C().entries().next();
  3133. }))) {
  3134. C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER);
  3135. redefineAll(C.prototype, methods);
  3136. meta.NEED = true;
  3137. } else {
  3138. var instance = new C();
  3139. var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance;
  3140. var THROWS_ON_PRIMITIVES = fails(function () {
  3141. instance.has(1);
  3142. });
  3143. var ACCEPT_ITERABLES = $iterDetect(function (iter) {
  3144. new C(iter);
  3145. });
  3146. var BUGGY_ZERO = !IS_WEAK && fails(function () {
  3147. var $instance = new C();
  3148. var index = 5;
  3149. while (index--) {
  3150. $instance[ADDER](index, index);
  3151. }return !$instance.has(-0);
  3152. });
  3153. if (!ACCEPT_ITERABLES) {
  3154. C = wrapper(function (target, iterable) {
  3155. anInstance(target, C, NAME);
  3156. var that = inheritIfRequired(new Base(), target, C);
  3157. if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);
  3158. return that;
  3159. });
  3160. C.prototype = proto;
  3161. proto.constructor = C;
  3162. }
  3163. if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) {
  3164. fixMethod('delete');
  3165. fixMethod('has');
  3166. IS_MAP && fixMethod('get');
  3167. }
  3168. if (BUGGY_ZERO || HASNT_CHAINING) fixMethod(ADDER);
  3169. if (IS_WEAK && proto.clear) delete proto.clear;
  3170. }
  3171. setToStringTag(C, NAME);
  3172. O[NAME] = C;
  3173. $export($export.G + $export.W + $export.F * (C != Base), O);
  3174. if (!IS_WEAK) common.setStrong(C, NAME, IS_MAP);
  3175. return C;
  3176. };
  3177. /***/ }),
  3178. /* 104 */
  3179. /***/ (function(module, exports, __w_pdfjs_require__) {
  3180. "use strict";
  3181. var isObject = __w_pdfjs_require__(13);
  3182. var setPrototypeOf = __w_pdfjs_require__(105).set;
  3183. module.exports = function (that, target, C) {
  3184. var S = target.constructor;
  3185. var P;
  3186. if (S !== C && typeof S == 'function' && (P = S.prototype) !== C.prototype && isObject(P) && setPrototypeOf) {
  3187. setPrototypeOf(that, P);
  3188. }
  3189. return that;
  3190. };
  3191. /***/ }),
  3192. /* 105 */
  3193. /***/ (function(module, exports, __w_pdfjs_require__) {
  3194. "use strict";
  3195. var isObject = __w_pdfjs_require__(13);
  3196. var anObject = __w_pdfjs_require__(12);
  3197. var check = function check(O, proto) {
  3198. anObject(O);
  3199. if (!isObject(proto) && proto !== null) throw TypeError(proto + ": can't set as prototype!");
  3200. };
  3201. module.exports = {
  3202. set: Object.setPrototypeOf || ('__proto__' in {} ? function (test, buggy, set) {
  3203. try {
  3204. set = __w_pdfjs_require__(23)(Function.call, __w_pdfjs_require__(106).f(Object.prototype, '__proto__').set, 2);
  3205. set(test, []);
  3206. buggy = !(test instanceof Array);
  3207. } catch (e) {
  3208. buggy = true;
  3209. }
  3210. return function setPrototypeOf(O, proto) {
  3211. check(O, proto);
  3212. if (buggy) O.__proto__ = proto;else set(O, proto);
  3213. return O;
  3214. };
  3215. }({}, false) : undefined),
  3216. check: check
  3217. };
  3218. /***/ }),
  3219. /* 106 */
  3220. /***/ (function(module, exports, __w_pdfjs_require__) {
  3221. "use strict";
  3222. var pIE = __w_pdfjs_require__(50);
  3223. var createDesc = __w_pdfjs_require__(19);
  3224. var toIObject = __w_pdfjs_require__(36);
  3225. var toPrimitive = __w_pdfjs_require__(18);
  3226. var has = __w_pdfjs_require__(21);
  3227. var IE8_DOM_DEFINE = __w_pdfjs_require__(14);
  3228. var gOPD = Object.getOwnPropertyDescriptor;
  3229. exports.f = __w_pdfjs_require__(15) ? gOPD : function getOwnPropertyDescriptor(O, P) {
  3230. O = toIObject(O);
  3231. P = toPrimitive(P, true);
  3232. if (IE8_DOM_DEFINE) try {
  3233. return gOPD(O, P);
  3234. } catch (e) {}
  3235. if (has(O, P)) return createDesc(!pIE.f.call(O, P), O[P]);
  3236. };
  3237. /***/ }),
  3238. /* 107 */
  3239. /***/ (function(module, exports, __w_pdfjs_require__) {
  3240. "use strict";
  3241. __w_pdfjs_require__(108)('WeakMap');
  3242. /***/ }),
  3243. /* 108 */
  3244. /***/ (function(module, exports, __w_pdfjs_require__) {
  3245. "use strict";
  3246. var $export = __w_pdfjs_require__(7);
  3247. module.exports = function (COLLECTION) {
  3248. $export($export.S, COLLECTION, {
  3249. of: function of() {
  3250. var length = arguments.length;
  3251. var A = new Array(length);
  3252. while (length--) {
  3253. A[length] = arguments[length];
  3254. }return new this(A);
  3255. }
  3256. });
  3257. };
  3258. /***/ }),
  3259. /* 109 */
  3260. /***/ (function(module, exports, __w_pdfjs_require__) {
  3261. "use strict";
  3262. __w_pdfjs_require__(110)('WeakMap');
  3263. /***/ }),
  3264. /* 110 */
  3265. /***/ (function(module, exports, __w_pdfjs_require__) {
  3266. "use strict";
  3267. var $export = __w_pdfjs_require__(7);
  3268. var aFunction = __w_pdfjs_require__(24);
  3269. var ctx = __w_pdfjs_require__(23);
  3270. var forOf = __w_pdfjs_require__(77);
  3271. module.exports = function (COLLECTION) {
  3272. $export($export.S, COLLECTION, {
  3273. from: function from(source) {
  3274. var mapFn = arguments[1];
  3275. var mapping, A, n, cb;
  3276. aFunction(this);
  3277. mapping = mapFn !== undefined;
  3278. if (mapping) aFunction(mapFn);
  3279. if (source == undefined) return new this();
  3280. A = [];
  3281. if (mapping) {
  3282. n = 0;
  3283. cb = ctx(mapFn, arguments[2], 2);
  3284. forOf(source, false, function (nextItem) {
  3285. A.push(cb(nextItem, n++));
  3286. });
  3287. } else {
  3288. forOf(source, false, A.push, A);
  3289. }
  3290. return new this(A);
  3291. }
  3292. });
  3293. };
  3294. /***/ }),
  3295. /* 111 */
  3296. /***/ (function(module, exports, __w_pdfjs_require__) {
  3297. "use strict";
  3298. __w_pdfjs_require__(112);
  3299. module.exports = __w_pdfjs_require__(9).String.codePointAt;
  3300. /***/ }),
  3301. /* 112 */
  3302. /***/ (function(module, exports, __w_pdfjs_require__) {
  3303. "use strict";
  3304. var $export = __w_pdfjs_require__(7);
  3305. var $at = __w_pdfjs_require__(63)(false);
  3306. $export($export.P, 'String', {
  3307. codePointAt: function codePointAt(pos) {
  3308. return $at(this, pos);
  3309. }
  3310. });
  3311. /***/ }),
  3312. /* 113 */
  3313. /***/ (function(module, exports, __w_pdfjs_require__) {
  3314. "use strict";
  3315. __w_pdfjs_require__(114);
  3316. module.exports = __w_pdfjs_require__(9).String.fromCodePoint;
  3317. /***/ }),
  3318. /* 114 */
  3319. /***/ (function(module, exports, __w_pdfjs_require__) {
  3320. "use strict";
  3321. var $export = __w_pdfjs_require__(7);
  3322. var toAbsoluteIndex = __w_pdfjs_require__(40);
  3323. var fromCharCode = String.fromCharCode;
  3324. var $fromCodePoint = String.fromCodePoint;
  3325. $export($export.S + $export.F * (!!$fromCodePoint && $fromCodePoint.length != 1), 'String', {
  3326. fromCodePoint: function fromCodePoint(x) {
  3327. var res = [];
  3328. var aLen = arguments.length;
  3329. var i = 0;
  3330. var code;
  3331. while (aLen > i) {
  3332. code = +arguments[i++];
  3333. if (toAbsoluteIndex(code, 0x10ffff) !== code) throw RangeError(code + ' is not a valid code point');
  3334. res.push(code < 0x10000 ? fromCharCode(code) : fromCharCode(((code -= 0x10000) >> 10) + 0xd800, code % 0x400 + 0xdc00));
  3335. }
  3336. return res.join('');
  3337. }
  3338. });
  3339. /***/ }),
  3340. /* 115 */
  3341. /***/ (function(module, exports, __w_pdfjs_require__) {
  3342. "use strict";
  3343. __w_pdfjs_require__(116);
  3344. __w_pdfjs_require__(60);
  3345. module.exports = __w_pdfjs_require__(9).Symbol;
  3346. /***/ }),
  3347. /* 116 */
  3348. /***/ (function(module, exports, __w_pdfjs_require__) {
  3349. "use strict";
  3350. 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; };
  3351. var global = __w_pdfjs_require__(8);
  3352. var has = __w_pdfjs_require__(21);
  3353. var DESCRIPTORS = __w_pdfjs_require__(15);
  3354. var $export = __w_pdfjs_require__(7);
  3355. var redefine = __w_pdfjs_require__(20);
  3356. var META = __w_pdfjs_require__(100).KEY;
  3357. var $fails = __w_pdfjs_require__(16);
  3358. var shared = __w_pdfjs_require__(29);
  3359. var setToStringTag = __w_pdfjs_require__(70);
  3360. var uid = __w_pdfjs_require__(22);
  3361. var wks = __w_pdfjs_require__(28);
  3362. var wksExt = __w_pdfjs_require__(117);
  3363. var wksDefine = __w_pdfjs_require__(118);
  3364. var enumKeys = __w_pdfjs_require__(119);
  3365. var isArray = __w_pdfjs_require__(99);
  3366. var anObject = __w_pdfjs_require__(12);
  3367. var isObject = __w_pdfjs_require__(13);
  3368. var toIObject = __w_pdfjs_require__(36);
  3369. var toPrimitive = __w_pdfjs_require__(18);
  3370. var createDesc = __w_pdfjs_require__(19);
  3371. var _create = __w_pdfjs_require__(67);
  3372. var gOPNExt = __w_pdfjs_require__(120);
  3373. var $GOPD = __w_pdfjs_require__(106);
  3374. var $DP = __w_pdfjs_require__(11);
  3375. var $keys = __w_pdfjs_require__(45);
  3376. var gOPD = $GOPD.f;
  3377. var dP = $DP.f;
  3378. var gOPN = gOPNExt.f;
  3379. var $Symbol = global.Symbol;
  3380. var $JSON = global.JSON;
  3381. var _stringify = $JSON && $JSON.stringify;
  3382. var PROTOTYPE = 'prototype';
  3383. var HIDDEN = wks('_hidden');
  3384. var TO_PRIMITIVE = wks('toPrimitive');
  3385. var isEnum = {}.propertyIsEnumerable;
  3386. var SymbolRegistry = shared('symbol-registry');
  3387. var AllSymbols = shared('symbols');
  3388. var OPSymbols = shared('op-symbols');
  3389. var ObjectProto = Object[PROTOTYPE];
  3390. var USE_NATIVE = typeof $Symbol == 'function';
  3391. var QObject = global.QObject;
  3392. var setter = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;
  3393. var setSymbolDesc = DESCRIPTORS && $fails(function () {
  3394. return _create(dP({}, 'a', {
  3395. get: function get() {
  3396. return dP(this, 'a', { value: 7 }).a;
  3397. }
  3398. })).a != 7;
  3399. }) ? function (it, key, D) {
  3400. var protoDesc = gOPD(ObjectProto, key);
  3401. if (protoDesc) delete ObjectProto[key];
  3402. dP(it, key, D);
  3403. if (protoDesc && it !== ObjectProto) dP(ObjectProto, key, protoDesc);
  3404. } : dP;
  3405. var wrap = function wrap(tag) {
  3406. var sym = AllSymbols[tag] = _create($Symbol[PROTOTYPE]);
  3407. sym._k = tag;
  3408. return sym;
  3409. };
  3410. var isSymbol = USE_NATIVE && _typeof($Symbol.iterator) == 'symbol' ? function (it) {
  3411. return (typeof it === 'undefined' ? 'undefined' : _typeof(it)) == 'symbol';
  3412. } : function (it) {
  3413. return it instanceof $Symbol;
  3414. };
  3415. var $defineProperty = function defineProperty(it, key, D) {
  3416. if (it === ObjectProto) $defineProperty(OPSymbols, key, D);
  3417. anObject(it);
  3418. key = toPrimitive(key, true);
  3419. anObject(D);
  3420. if (has(AllSymbols, key)) {
  3421. if (!D.enumerable) {
  3422. if (!has(it, HIDDEN)) dP(it, HIDDEN, createDesc(1, {}));
  3423. it[HIDDEN][key] = true;
  3424. } else {
  3425. if (has(it, HIDDEN) && it[HIDDEN][key]) it[HIDDEN][key] = false;
  3426. D = _create(D, { enumerable: createDesc(0, false) });
  3427. }
  3428. return setSymbolDesc(it, key, D);
  3429. }
  3430. return dP(it, key, D);
  3431. };
  3432. var $defineProperties = function defineProperties(it, P) {
  3433. anObject(it);
  3434. var keys = enumKeys(P = toIObject(P));
  3435. var i = 0;
  3436. var l = keys.length;
  3437. var key;
  3438. while (l > i) {
  3439. $defineProperty(it, key = keys[i++], P[key]);
  3440. }return it;
  3441. };
  3442. var $create = function create(it, P) {
  3443. return P === undefined ? _create(it) : $defineProperties(_create(it), P);
  3444. };
  3445. var $propertyIsEnumerable = function propertyIsEnumerable(key) {
  3446. var E = isEnum.call(this, key = toPrimitive(key, true));
  3447. if (this === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return false;
  3448. return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] ? E : true;
  3449. };
  3450. var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key) {
  3451. it = toIObject(it);
  3452. key = toPrimitive(key, true);
  3453. if (it === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return;
  3454. var D = gOPD(it, key);
  3455. if (D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key])) D.enumerable = true;
  3456. return D;
  3457. };
  3458. var $getOwnPropertyNames = function getOwnPropertyNames(it) {
  3459. var names = gOPN(toIObject(it));
  3460. var result = [];
  3461. var i = 0;
  3462. var key;
  3463. while (names.length > i) {
  3464. if (!has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META) result.push(key);
  3465. }
  3466. return result;
  3467. };
  3468. var $getOwnPropertySymbols = function getOwnPropertySymbols(it) {
  3469. var IS_OP = it === ObjectProto;
  3470. var names = gOPN(IS_OP ? OPSymbols : toIObject(it));
  3471. var result = [];
  3472. var i = 0;
  3473. var key;
  3474. while (names.length > i) {
  3475. if (has(AllSymbols, key = names[i++]) && (IS_OP ? has(ObjectProto, key) : true)) result.push(AllSymbols[key]);
  3476. }
  3477. return result;
  3478. };
  3479. if (!USE_NATIVE) {
  3480. $Symbol = function _Symbol() {
  3481. if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor!');
  3482. var tag = uid(arguments.length > 0 ? arguments[0] : undefined);
  3483. var $set = function $set(value) {
  3484. if (this === ObjectProto) $set.call(OPSymbols, value);
  3485. if (has(this, HIDDEN) && has(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
  3486. setSymbolDesc(this, tag, createDesc(1, value));
  3487. };
  3488. if (DESCRIPTORS && setter) setSymbolDesc(ObjectProto, tag, {
  3489. configurable: true,
  3490. set: $set
  3491. });
  3492. return wrap(tag);
  3493. };
  3494. redefine($Symbol[PROTOTYPE], 'toString', function toString() {
  3495. return this._k;
  3496. });
  3497. $GOPD.f = $getOwnPropertyDescriptor;
  3498. $DP.f = $defineProperty;
  3499. __w_pdfjs_require__(121).f = gOPNExt.f = $getOwnPropertyNames;
  3500. __w_pdfjs_require__(50).f = $propertyIsEnumerable;
  3501. __w_pdfjs_require__(49).f = $getOwnPropertySymbols;
  3502. if (DESCRIPTORS && !__w_pdfjs_require__(30)) {
  3503. redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true);
  3504. }
  3505. wksExt.f = function (name) {
  3506. return wrap(wks(name));
  3507. };
  3508. }
  3509. $export($export.G + $export.W + $export.F * !USE_NATIVE, { Symbol: $Symbol });
  3510. for (var es6Symbols = 'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables'.split(','), j = 0; es6Symbols.length > j;) {
  3511. wks(es6Symbols[j++]);
  3512. }for (var wellKnownSymbols = $keys(wks.store), k = 0; wellKnownSymbols.length > k;) {
  3513. wksDefine(wellKnownSymbols[k++]);
  3514. }$export($export.S + $export.F * !USE_NATIVE, 'Symbol', {
  3515. 'for': function _for(key) {
  3516. return has(SymbolRegistry, key += '') ? SymbolRegistry[key] : SymbolRegistry[key] = $Symbol(key);
  3517. },
  3518. keyFor: function keyFor(sym) {
  3519. if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol!');
  3520. for (var key in SymbolRegistry) {
  3521. if (SymbolRegistry[key] === sym) return key;
  3522. }
  3523. },
  3524. useSetter: function useSetter() {
  3525. setter = true;
  3526. },
  3527. useSimple: function useSimple() {
  3528. setter = false;
  3529. }
  3530. });
  3531. $export($export.S + $export.F * !USE_NATIVE, 'Object', {
  3532. create: $create,
  3533. defineProperty: $defineProperty,
  3534. defineProperties: $defineProperties,
  3535. getOwnPropertyDescriptor: $getOwnPropertyDescriptor,
  3536. getOwnPropertyNames: $getOwnPropertyNames,
  3537. getOwnPropertySymbols: $getOwnPropertySymbols
  3538. });
  3539. $JSON && $export($export.S + $export.F * (!USE_NATIVE || $fails(function () {
  3540. var S = $Symbol();
  3541. return _stringify([S]) != '[null]' || _stringify({ a: S }) != '{}' || _stringify(Object(S)) != '{}';
  3542. })), 'JSON', {
  3543. stringify: function stringify(it) {
  3544. var args = [it];
  3545. var i = 1;
  3546. var replacer, $replacer;
  3547. while (arguments.length > i) {
  3548. args.push(arguments[i++]);
  3549. }$replacer = replacer = args[1];
  3550. if (!isObject(replacer) && it === undefined || isSymbol(it)) return;
  3551. if (!isArray(replacer)) replacer = function replacer(key, value) {
  3552. if (typeof $replacer == 'function') value = $replacer.call(this, key, value);
  3553. if (!isSymbol(value)) return value;
  3554. };
  3555. args[1] = replacer;
  3556. return _stringify.apply($JSON, args);
  3557. }
  3558. });
  3559. $Symbol[PROTOTYPE][TO_PRIMITIVE] || __w_pdfjs_require__(10)($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf);
  3560. setToStringTag($Symbol, 'Symbol');
  3561. setToStringTag(Math, 'Math', true);
  3562. setToStringTag(global.JSON, 'JSON', true);
  3563. /***/ }),
  3564. /* 117 */
  3565. /***/ (function(module, exports, __w_pdfjs_require__) {
  3566. "use strict";
  3567. exports.f = __w_pdfjs_require__(28);
  3568. /***/ }),
  3569. /* 118 */
  3570. /***/ (function(module, exports, __w_pdfjs_require__) {
  3571. "use strict";
  3572. var global = __w_pdfjs_require__(8);
  3573. var core = __w_pdfjs_require__(9);
  3574. var LIBRARY = __w_pdfjs_require__(30);
  3575. var wksExt = __w_pdfjs_require__(117);
  3576. var defineProperty = __w_pdfjs_require__(11).f;
  3577. module.exports = function (name) {
  3578. var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {});
  3579. if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, { value: wksExt.f(name) });
  3580. };
  3581. /***/ }),
  3582. /* 119 */
  3583. /***/ (function(module, exports, __w_pdfjs_require__) {
  3584. "use strict";
  3585. var getKeys = __w_pdfjs_require__(45);
  3586. var gOPS = __w_pdfjs_require__(49);
  3587. var pIE = __w_pdfjs_require__(50);
  3588. module.exports = function (it) {
  3589. var result = getKeys(it);
  3590. var getSymbols = gOPS.f;
  3591. if (getSymbols) {
  3592. var symbols = getSymbols(it);
  3593. var isEnum = pIE.f;
  3594. var i = 0;
  3595. var key;
  3596. while (symbols.length > i) {
  3597. if (isEnum.call(it, key = symbols[i++])) result.push(key);
  3598. }
  3599. }
  3600. return result;
  3601. };
  3602. /***/ }),
  3603. /* 120 */
  3604. /***/ (function(module, exports, __w_pdfjs_require__) {
  3605. "use strict";
  3606. 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; };
  3607. var toIObject = __w_pdfjs_require__(36);
  3608. var gOPN = __w_pdfjs_require__(121).f;
  3609. var toString = {}.toString;
  3610. var windowNames = (typeof window === 'undefined' ? 'undefined' : _typeof(window)) == 'object' && window && Object.getOwnPropertyNames ? Object.getOwnPropertyNames(window) : [];
  3611. var getWindowNames = function getWindowNames(it) {
  3612. try {
  3613. return gOPN(it);
  3614. } catch (e) {
  3615. return windowNames.slice();
  3616. }
  3617. };
  3618. module.exports.f = function getOwnPropertyNames(it) {
  3619. return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it));
  3620. };
  3621. /***/ }),
  3622. /* 121 */
  3623. /***/ (function(module, exports, __w_pdfjs_require__) {
  3624. "use strict";
  3625. var $keys = __w_pdfjs_require__(46);
  3626. var hiddenKeys = __w_pdfjs_require__(48).concat('length', 'prototype');
  3627. exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  3628. return $keys(O, hiddenKeys);
  3629. };
  3630. /***/ }),
  3631. /* 122 */
  3632. /***/ (function(module, exports, __w_pdfjs_require__) {
  3633. "use strict";
  3634. __w_pdfjs_require__(123);
  3635. module.exports = __w_pdfjs_require__(9).Object.values;
  3636. /***/ }),
  3637. /* 123 */
  3638. /***/ (function(module, exports, __w_pdfjs_require__) {
  3639. "use strict";
  3640. var $export = __w_pdfjs_require__(7);
  3641. var $values = __w_pdfjs_require__(124)(false);
  3642. $export($export.S, 'Object', {
  3643. values: function values(it) {
  3644. return $values(it);
  3645. }
  3646. });
  3647. /***/ }),
  3648. /* 124 */
  3649. /***/ (function(module, exports, __w_pdfjs_require__) {
  3650. "use strict";
  3651. var getKeys = __w_pdfjs_require__(45);
  3652. var toIObject = __w_pdfjs_require__(36);
  3653. var isEnum = __w_pdfjs_require__(50).f;
  3654. module.exports = function (isEntries) {
  3655. return function (it) {
  3656. var O = toIObject(it);
  3657. var keys = getKeys(O);
  3658. var length = keys.length;
  3659. var i = 0;
  3660. var result = [];
  3661. var key;
  3662. while (length > i) {
  3663. if (isEnum.call(O, key = keys[i++])) {
  3664. result.push(isEntries ? [key, O[key]] : O[key]);
  3665. }
  3666. }return result;
  3667. };
  3668. };
  3669. /***/ }),
  3670. /* 125 */
  3671. /***/ (function(module, exports, __w_pdfjs_require__) {
  3672. "use strict";
  3673. var isReadableStreamSupported = false;
  3674. if (typeof ReadableStream !== 'undefined') {
  3675. try {
  3676. new ReadableStream({
  3677. start: function start(controller) {
  3678. controller.close();
  3679. }
  3680. });
  3681. isReadableStreamSupported = true;
  3682. } catch (e) {}
  3683. }
  3684. if (isReadableStreamSupported) {
  3685. exports.ReadableStream = ReadableStream;
  3686. } else {
  3687. exports.ReadableStream = __w_pdfjs_require__(126).ReadableStream;
  3688. }
  3689. /***/ }),
  3690. /* 126 */
  3691. /***/ (function(module, exports, __w_pdfjs_require__) {
  3692. "use strict";
  3693. 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; };
  3694. (function (e, a) {
  3695. for (var i in a) {
  3696. e[i] = a[i];
  3697. }
  3698. })(exports, function (modules) {
  3699. var installedModules = {};
  3700. function __w_pdfjs_require__(moduleId) {
  3701. if (installedModules[moduleId]) return installedModules[moduleId].exports;
  3702. var module = installedModules[moduleId] = {
  3703. i: moduleId,
  3704. l: false,
  3705. exports: {}
  3706. };
  3707. modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);
  3708. module.l = true;
  3709. return module.exports;
  3710. }
  3711. __w_pdfjs_require__.m = modules;
  3712. __w_pdfjs_require__.c = installedModules;
  3713. __w_pdfjs_require__.i = function (value) {
  3714. return value;
  3715. };
  3716. __w_pdfjs_require__.d = function (exports, name, getter) {
  3717. if (!__w_pdfjs_require__.o(exports, name)) {
  3718. Object.defineProperty(exports, name, {
  3719. configurable: false,
  3720. enumerable: true,
  3721. get: getter
  3722. });
  3723. }
  3724. };
  3725. __w_pdfjs_require__.n = function (module) {
  3726. var getter = module && module.__esModule ? function getDefault() {
  3727. return module['default'];
  3728. } : function getModuleExports() {
  3729. return module;
  3730. };
  3731. __w_pdfjs_require__.d(getter, 'a', getter);
  3732. return getter;
  3733. };
  3734. __w_pdfjs_require__.o = function (object, property) {
  3735. return Object.prototype.hasOwnProperty.call(object, property);
  3736. };
  3737. __w_pdfjs_require__.p = "";
  3738. return __w_pdfjs_require__(__w_pdfjs_require__.s = 7);
  3739. }([function (module, exports, __w_pdfjs_require__) {
  3740. "use strict";
  3741. var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) {
  3742. return typeof obj === 'undefined' ? 'undefined' : _typeof2(obj);
  3743. } : function (obj) {
  3744. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof2(obj);
  3745. };
  3746. var _require = __w_pdfjs_require__(1),
  3747. assert = _require.assert;
  3748. function IsPropertyKey(argument) {
  3749. return typeof argument === 'string' || (typeof argument === 'undefined' ? 'undefined' : _typeof(argument)) === 'symbol';
  3750. }
  3751. exports.typeIsObject = function (x) {
  3752. return (typeof x === 'undefined' ? 'undefined' : _typeof(x)) === 'object' && x !== null || typeof x === 'function';
  3753. };
  3754. exports.createDataProperty = function (o, p, v) {
  3755. assert(exports.typeIsObject(o));
  3756. Object.defineProperty(o, p, {
  3757. value: v,
  3758. writable: true,
  3759. enumerable: true,
  3760. configurable: true
  3761. });
  3762. };
  3763. exports.createArrayFromList = function (elements) {
  3764. return elements.slice();
  3765. };
  3766. exports.ArrayBufferCopy = function (dest, destOffset, src, srcOffset, n) {
  3767. new Uint8Array(dest).set(new Uint8Array(src, srcOffset, n), destOffset);
  3768. };
  3769. exports.CreateIterResultObject = function (value, done) {
  3770. assert(typeof done === 'boolean');
  3771. var obj = {};
  3772. Object.defineProperty(obj, 'value', {
  3773. value: value,
  3774. enumerable: true,
  3775. writable: true,
  3776. configurable: true
  3777. });
  3778. Object.defineProperty(obj, 'done', {
  3779. value: done,
  3780. enumerable: true,
  3781. writable: true,
  3782. configurable: true
  3783. });
  3784. return obj;
  3785. };
  3786. exports.IsFiniteNonNegativeNumber = function (v) {
  3787. if (Number.isNaN(v)) {
  3788. return false;
  3789. }
  3790. if (v === Infinity) {
  3791. return false;
  3792. }
  3793. if (v < 0) {
  3794. return false;
  3795. }
  3796. return true;
  3797. };
  3798. function Call(F, V, args) {
  3799. if (typeof F !== 'function') {
  3800. throw new TypeError('Argument is not a function');
  3801. }
  3802. return Function.prototype.apply.call(F, V, args);
  3803. }
  3804. exports.InvokeOrNoop = function (O, P, args) {
  3805. assert(O !== undefined);
  3806. assert(IsPropertyKey(P));
  3807. assert(Array.isArray(args));
  3808. var method = O[P];
  3809. if (method === undefined) {
  3810. return undefined;
  3811. }
  3812. return Call(method, O, args);
  3813. };
  3814. exports.PromiseInvokeOrNoop = function (O, P, args) {
  3815. assert(O !== undefined);
  3816. assert(IsPropertyKey(P));
  3817. assert(Array.isArray(args));
  3818. try {
  3819. return Promise.resolve(exports.InvokeOrNoop(O, P, args));
  3820. } catch (returnValueE) {
  3821. return Promise.reject(returnValueE);
  3822. }
  3823. };
  3824. exports.PromiseInvokeOrPerformFallback = function (O, P, args, F, argsF) {
  3825. assert(O !== undefined);
  3826. assert(IsPropertyKey(P));
  3827. assert(Array.isArray(args));
  3828. assert(Array.isArray(argsF));
  3829. var method = void 0;
  3830. try {
  3831. method = O[P];
  3832. } catch (methodE) {
  3833. return Promise.reject(methodE);
  3834. }
  3835. if (method === undefined) {
  3836. return F.apply(null, argsF);
  3837. }
  3838. try {
  3839. return Promise.resolve(Call(method, O, args));
  3840. } catch (e) {
  3841. return Promise.reject(e);
  3842. }
  3843. };
  3844. exports.TransferArrayBuffer = function (O) {
  3845. return O.slice();
  3846. };
  3847. exports.ValidateAndNormalizeHighWaterMark = function (highWaterMark) {
  3848. highWaterMark = Number(highWaterMark);
  3849. if (Number.isNaN(highWaterMark) || highWaterMark < 0) {
  3850. throw new RangeError('highWaterMark property of a queuing strategy must be non-negative and non-NaN');
  3851. }
  3852. return highWaterMark;
  3853. };
  3854. exports.ValidateAndNormalizeQueuingStrategy = function (size, highWaterMark) {
  3855. if (size !== undefined && typeof size !== 'function') {
  3856. throw new TypeError('size property of a queuing strategy must be a function');
  3857. }
  3858. highWaterMark = exports.ValidateAndNormalizeHighWaterMark(highWaterMark);
  3859. return {
  3860. size: size,
  3861. highWaterMark: highWaterMark
  3862. };
  3863. };
  3864. }, function (module, exports, __w_pdfjs_require__) {
  3865. "use strict";
  3866. function rethrowAssertionErrorRejection(e) {
  3867. if (e && e.constructor === AssertionError) {
  3868. setTimeout(function () {
  3869. throw e;
  3870. }, 0);
  3871. }
  3872. }
  3873. function AssertionError(message) {
  3874. this.name = 'AssertionError';
  3875. this.message = message || '';
  3876. this.stack = new Error().stack;
  3877. }
  3878. AssertionError.prototype = Object.create(Error.prototype);
  3879. AssertionError.prototype.constructor = AssertionError;
  3880. function assert(value, message) {
  3881. if (!value) {
  3882. throw new AssertionError(message);
  3883. }
  3884. }
  3885. module.exports = {
  3886. rethrowAssertionErrorRejection: rethrowAssertionErrorRejection,
  3887. AssertionError: AssertionError,
  3888. assert: assert
  3889. };
  3890. }, function (module, exports, __w_pdfjs_require__) {
  3891. "use strict";
  3892. var _createClass = function () {
  3893. function defineProperties(target, props) {
  3894. for (var i = 0; i < props.length; i++) {
  3895. var descriptor = props[i];
  3896. descriptor.enumerable = descriptor.enumerable || false;
  3897. descriptor.configurable = true;
  3898. if ("value" in descriptor) descriptor.writable = true;
  3899. Object.defineProperty(target, descriptor.key, descriptor);
  3900. }
  3901. }
  3902. return function (Constructor, protoProps, staticProps) {
  3903. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  3904. if (staticProps) defineProperties(Constructor, staticProps);
  3905. return Constructor;
  3906. };
  3907. }();
  3908. function _classCallCheck(instance, Constructor) {
  3909. if (!(instance instanceof Constructor)) {
  3910. throw new TypeError("Cannot call a class as a function");
  3911. }
  3912. }
  3913. var _require = __w_pdfjs_require__(0),
  3914. InvokeOrNoop = _require.InvokeOrNoop,
  3915. PromiseInvokeOrNoop = _require.PromiseInvokeOrNoop,
  3916. ValidateAndNormalizeQueuingStrategy = _require.ValidateAndNormalizeQueuingStrategy,
  3917. typeIsObject = _require.typeIsObject;
  3918. var _require2 = __w_pdfjs_require__(1),
  3919. assert = _require2.assert,
  3920. rethrowAssertionErrorRejection = _require2.rethrowAssertionErrorRejection;
  3921. var _require3 = __w_pdfjs_require__(3),
  3922. DequeueValue = _require3.DequeueValue,
  3923. EnqueueValueWithSize = _require3.EnqueueValueWithSize,
  3924. PeekQueueValue = _require3.PeekQueueValue,
  3925. ResetQueue = _require3.ResetQueue;
  3926. var WritableStream = function () {
  3927. function WritableStream() {
  3928. var underlyingSink = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  3929. var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  3930. size = _ref.size,
  3931. _ref$highWaterMark = _ref.highWaterMark,
  3932. highWaterMark = _ref$highWaterMark === undefined ? 1 : _ref$highWaterMark;
  3933. _classCallCheck(this, WritableStream);
  3934. this._state = 'writable';
  3935. this._storedError = undefined;
  3936. this._writer = undefined;
  3937. this._writableStreamController = undefined;
  3938. this._writeRequests = [];
  3939. this._inFlightWriteRequest = undefined;
  3940. this._closeRequest = undefined;
  3941. this._inFlightCloseRequest = undefined;
  3942. this._pendingAbortRequest = undefined;
  3943. this._backpressure = false;
  3944. var type = underlyingSink.type;
  3945. if (type !== undefined) {
  3946. throw new RangeError('Invalid type is specified');
  3947. }
  3948. this._writableStreamController = new WritableStreamDefaultController(this, underlyingSink, size, highWaterMark);
  3949. this._writableStreamController.__startSteps();
  3950. }
  3951. _createClass(WritableStream, [{
  3952. key: 'abort',
  3953. value: function abort(reason) {
  3954. if (IsWritableStream(this) === false) {
  3955. return Promise.reject(streamBrandCheckException('abort'));
  3956. }
  3957. if (IsWritableStreamLocked(this) === true) {
  3958. return Promise.reject(new TypeError('Cannot abort a stream that already has a writer'));
  3959. }
  3960. return WritableStreamAbort(this, reason);
  3961. }
  3962. }, {
  3963. key: 'getWriter',
  3964. value: function getWriter() {
  3965. if (IsWritableStream(this) === false) {
  3966. throw streamBrandCheckException('getWriter');
  3967. }
  3968. return AcquireWritableStreamDefaultWriter(this);
  3969. }
  3970. }, {
  3971. key: 'locked',
  3972. get: function get() {
  3973. if (IsWritableStream(this) === false) {
  3974. throw streamBrandCheckException('locked');
  3975. }
  3976. return IsWritableStreamLocked(this);
  3977. }
  3978. }]);
  3979. return WritableStream;
  3980. }();
  3981. module.exports = {
  3982. AcquireWritableStreamDefaultWriter: AcquireWritableStreamDefaultWriter,
  3983. IsWritableStream: IsWritableStream,
  3984. IsWritableStreamLocked: IsWritableStreamLocked,
  3985. WritableStream: WritableStream,
  3986. WritableStreamAbort: WritableStreamAbort,
  3987. WritableStreamDefaultControllerError: WritableStreamDefaultControllerError,
  3988. WritableStreamDefaultWriterCloseWithErrorPropagation: WritableStreamDefaultWriterCloseWithErrorPropagation,
  3989. WritableStreamDefaultWriterRelease: WritableStreamDefaultWriterRelease,
  3990. WritableStreamDefaultWriterWrite: WritableStreamDefaultWriterWrite,
  3991. WritableStreamCloseQueuedOrInFlight: WritableStreamCloseQueuedOrInFlight
  3992. };
  3993. function AcquireWritableStreamDefaultWriter(stream) {
  3994. return new WritableStreamDefaultWriter(stream);
  3995. }
  3996. function IsWritableStream(x) {
  3997. if (!typeIsObject(x)) {
  3998. return false;
  3999. }
  4000. if (!Object.prototype.hasOwnProperty.call(x, '_writableStreamController')) {
  4001. return false;
  4002. }
  4003. return true;
  4004. }
  4005. function IsWritableStreamLocked(stream) {
  4006. assert(IsWritableStream(stream) === true, 'IsWritableStreamLocked should only be used on known writable streams');
  4007. if (stream._writer === undefined) {
  4008. return false;
  4009. }
  4010. return true;
  4011. }
  4012. function WritableStreamAbort(stream, reason) {
  4013. var state = stream._state;
  4014. if (state === 'closed') {
  4015. return Promise.resolve(undefined);
  4016. }
  4017. if (state === 'errored') {
  4018. return Promise.reject(stream._storedError);
  4019. }
  4020. var error = new TypeError('Requested to abort');
  4021. if (stream._pendingAbortRequest !== undefined) {
  4022. return Promise.reject(error);
  4023. }
  4024. assert(state === 'writable' || state === 'erroring', 'state must be writable or erroring');
  4025. var wasAlreadyErroring = false;
  4026. if (state === 'erroring') {
  4027. wasAlreadyErroring = true;
  4028. reason = undefined;
  4029. }
  4030. var promise = new Promise(function (resolve, reject) {
  4031. stream._pendingAbortRequest = {
  4032. _resolve: resolve,
  4033. _reject: reject,
  4034. _reason: reason,
  4035. _wasAlreadyErroring: wasAlreadyErroring
  4036. };
  4037. });
  4038. if (wasAlreadyErroring === false) {
  4039. WritableStreamStartErroring(stream, error);
  4040. }
  4041. return promise;
  4042. }
  4043. function WritableStreamAddWriteRequest(stream) {
  4044. assert(IsWritableStreamLocked(stream) === true);
  4045. assert(stream._state === 'writable');
  4046. var promise = new Promise(function (resolve, reject) {
  4047. var writeRequest = {
  4048. _resolve: resolve,
  4049. _reject: reject
  4050. };
  4051. stream._writeRequests.push(writeRequest);
  4052. });
  4053. return promise;
  4054. }
  4055. function WritableStreamDealWithRejection(stream, error) {
  4056. var state = stream._state;
  4057. if (state === 'writable') {
  4058. WritableStreamStartErroring(stream, error);
  4059. return;
  4060. }
  4061. assert(state === 'erroring');
  4062. WritableStreamFinishErroring(stream);
  4063. }
  4064. function WritableStreamStartErroring(stream, reason) {
  4065. assert(stream._storedError === undefined, 'stream._storedError === undefined');
  4066. assert(stream._state === 'writable', 'state must be writable');
  4067. var controller = stream._writableStreamController;
  4068. assert(controller !== undefined, 'controller must not be undefined');
  4069. stream._state = 'erroring';
  4070. stream._storedError = reason;
  4071. var writer = stream._writer;
  4072. if (writer !== undefined) {
  4073. WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, reason);
  4074. }
  4075. if (WritableStreamHasOperationMarkedInFlight(stream) === false && controller._started === true) {
  4076. WritableStreamFinishErroring(stream);
  4077. }
  4078. }
  4079. function WritableStreamFinishErroring(stream) {
  4080. assert(stream._state === 'erroring', 'stream._state === erroring');
  4081. assert(WritableStreamHasOperationMarkedInFlight(stream) === false, 'WritableStreamHasOperationMarkedInFlight(stream) === false');
  4082. stream._state = 'errored';
  4083. stream._writableStreamController.__errorSteps();
  4084. var storedError = stream._storedError;
  4085. for (var i = 0; i < stream._writeRequests.length; i++) {
  4086. var writeRequest = stream._writeRequests[i];
  4087. writeRequest._reject(storedError);
  4088. }
  4089. stream._writeRequests = [];
  4090. if (stream._pendingAbortRequest === undefined) {
  4091. WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
  4092. return;
  4093. }
  4094. var abortRequest = stream._pendingAbortRequest;
  4095. stream._pendingAbortRequest = undefined;
  4096. if (abortRequest._wasAlreadyErroring === true) {
  4097. abortRequest._reject(storedError);
  4098. WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
  4099. return;
  4100. }
  4101. var promise = stream._writableStreamController.__abortSteps(abortRequest._reason);
  4102. promise.then(function () {
  4103. abortRequest._resolve();
  4104. WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
  4105. }, function (reason) {
  4106. abortRequest._reject(reason);
  4107. WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
  4108. });
  4109. }
  4110. function WritableStreamFinishInFlightWrite(stream) {
  4111. assert(stream._inFlightWriteRequest !== undefined);
  4112. stream._inFlightWriteRequest._resolve(undefined);
  4113. stream._inFlightWriteRequest = undefined;
  4114. }
  4115. function WritableStreamFinishInFlightWriteWithError(stream, error) {
  4116. assert(stream._inFlightWriteRequest !== undefined);
  4117. stream._inFlightWriteRequest._reject(error);
  4118. stream._inFlightWriteRequest = undefined;
  4119. assert(stream._state === 'writable' || stream._state === 'erroring');
  4120. WritableStreamDealWithRejection(stream, error);
  4121. }
  4122. function WritableStreamFinishInFlightClose(stream) {
  4123. assert(stream._inFlightCloseRequest !== undefined);
  4124. stream._inFlightCloseRequest._resolve(undefined);
  4125. stream._inFlightCloseRequest = undefined;
  4126. var state = stream._state;
  4127. assert(state === 'writable' || state === 'erroring');
  4128. if (state === 'erroring') {
  4129. stream._storedError = undefined;
  4130. if (stream._pendingAbortRequest !== undefined) {
  4131. stream._pendingAbortRequest._resolve();
  4132. stream._pendingAbortRequest = undefined;
  4133. }
  4134. }
  4135. stream._state = 'closed';
  4136. var writer = stream._writer;
  4137. if (writer !== undefined) {
  4138. defaultWriterClosedPromiseResolve(writer);
  4139. }
  4140. assert(stream._pendingAbortRequest === undefined, 'stream._pendingAbortRequest === undefined');
  4141. assert(stream._storedError === undefined, 'stream._storedError === undefined');
  4142. }
  4143. function WritableStreamFinishInFlightCloseWithError(stream, error) {
  4144. assert(stream._inFlightCloseRequest !== undefined);
  4145. stream._inFlightCloseRequest._reject(error);
  4146. stream._inFlightCloseRequest = undefined;
  4147. assert(stream._state === 'writable' || stream._state === 'erroring');
  4148. if (stream._pendingAbortRequest !== undefined) {
  4149. stream._pendingAbortRequest._reject(error);
  4150. stream._pendingAbortRequest = undefined;
  4151. }
  4152. WritableStreamDealWithRejection(stream, error);
  4153. }
  4154. function WritableStreamCloseQueuedOrInFlight(stream) {
  4155. if (stream._closeRequest === undefined && stream._inFlightCloseRequest === undefined) {
  4156. return false;
  4157. }
  4158. return true;
  4159. }
  4160. function WritableStreamHasOperationMarkedInFlight(stream) {
  4161. if (stream._inFlightWriteRequest === undefined && stream._inFlightCloseRequest === undefined) {
  4162. return false;
  4163. }
  4164. return true;
  4165. }
  4166. function WritableStreamMarkCloseRequestInFlight(stream) {
  4167. assert(stream._inFlightCloseRequest === undefined);
  4168. assert(stream._closeRequest !== undefined);
  4169. stream._inFlightCloseRequest = stream._closeRequest;
  4170. stream._closeRequest = undefined;
  4171. }
  4172. function WritableStreamMarkFirstWriteRequestInFlight(stream) {
  4173. assert(stream._inFlightWriteRequest === undefined, 'there must be no pending write request');
  4174. assert(stream._writeRequests.length !== 0, 'writeRequests must not be empty');
  4175. stream._inFlightWriteRequest = stream._writeRequests.shift();
  4176. }
  4177. function WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream) {
  4178. assert(stream._state === 'errored', '_stream_.[[state]] is `"errored"`');
  4179. if (stream._closeRequest !== undefined) {
  4180. assert(stream._inFlightCloseRequest === undefined);
  4181. stream._closeRequest._reject(stream._storedError);
  4182. stream._closeRequest = undefined;
  4183. }
  4184. var writer = stream._writer;
  4185. if (writer !== undefined) {
  4186. defaultWriterClosedPromiseReject(writer, stream._storedError);
  4187. writer._closedPromise.catch(function () {});
  4188. }
  4189. }
  4190. function WritableStreamUpdateBackpressure(stream, backpressure) {
  4191. assert(stream._state === 'writable');
  4192. assert(WritableStreamCloseQueuedOrInFlight(stream) === false);
  4193. var writer = stream._writer;
  4194. if (writer !== undefined && backpressure !== stream._backpressure) {
  4195. if (backpressure === true) {
  4196. defaultWriterReadyPromiseReset(writer);
  4197. } else {
  4198. assert(backpressure === false);
  4199. defaultWriterReadyPromiseResolve(writer);
  4200. }
  4201. }
  4202. stream._backpressure = backpressure;
  4203. }
  4204. var WritableStreamDefaultWriter = function () {
  4205. function WritableStreamDefaultWriter(stream) {
  4206. _classCallCheck(this, WritableStreamDefaultWriter);
  4207. if (IsWritableStream(stream) === false) {
  4208. throw new TypeError('WritableStreamDefaultWriter can only be constructed with a WritableStream instance');
  4209. }
  4210. if (IsWritableStreamLocked(stream) === true) {
  4211. throw new TypeError('This stream has already been locked for exclusive writing by another writer');
  4212. }
  4213. this._ownerWritableStream = stream;
  4214. stream._writer = this;
  4215. var state = stream._state;
  4216. if (state === 'writable') {
  4217. if (WritableStreamCloseQueuedOrInFlight(stream) === false && stream._backpressure === true) {
  4218. defaultWriterReadyPromiseInitialize(this);
  4219. } else {
  4220. defaultWriterReadyPromiseInitializeAsResolved(this);
  4221. }
  4222. defaultWriterClosedPromiseInitialize(this);
  4223. } else if (state === 'erroring') {
  4224. defaultWriterReadyPromiseInitializeAsRejected(this, stream._storedError);
  4225. this._readyPromise.catch(function () {});
  4226. defaultWriterClosedPromiseInitialize(this);
  4227. } else if (state === 'closed') {
  4228. defaultWriterReadyPromiseInitializeAsResolved(this);
  4229. defaultWriterClosedPromiseInitializeAsResolved(this);
  4230. } else {
  4231. assert(state === 'errored', 'state must be errored');
  4232. var storedError = stream._storedError;
  4233. defaultWriterReadyPromiseInitializeAsRejected(this, storedError);
  4234. this._readyPromise.catch(function () {});
  4235. defaultWriterClosedPromiseInitializeAsRejected(this, storedError);
  4236. this._closedPromise.catch(function () {});
  4237. }
  4238. }
  4239. _createClass(WritableStreamDefaultWriter, [{
  4240. key: 'abort',
  4241. value: function abort(reason) {
  4242. if (IsWritableStreamDefaultWriter(this) === false) {
  4243. return Promise.reject(defaultWriterBrandCheckException('abort'));
  4244. }
  4245. if (this._ownerWritableStream === undefined) {
  4246. return Promise.reject(defaultWriterLockException('abort'));
  4247. }
  4248. return WritableStreamDefaultWriterAbort(this, reason);
  4249. }
  4250. }, {
  4251. key: 'close',
  4252. value: function close() {
  4253. if (IsWritableStreamDefaultWriter(this) === false) {
  4254. return Promise.reject(defaultWriterBrandCheckException('close'));
  4255. }
  4256. var stream = this._ownerWritableStream;
  4257. if (stream === undefined) {
  4258. return Promise.reject(defaultWriterLockException('close'));
  4259. }
  4260. if (WritableStreamCloseQueuedOrInFlight(stream) === true) {
  4261. return Promise.reject(new TypeError('cannot close an already-closing stream'));
  4262. }
  4263. return WritableStreamDefaultWriterClose(this);
  4264. }
  4265. }, {
  4266. key: 'releaseLock',
  4267. value: function releaseLock() {
  4268. if (IsWritableStreamDefaultWriter(this) === false) {
  4269. throw defaultWriterBrandCheckException('releaseLock');
  4270. }
  4271. var stream = this._ownerWritableStream;
  4272. if (stream === undefined) {
  4273. return;
  4274. }
  4275. assert(stream._writer !== undefined);
  4276. WritableStreamDefaultWriterRelease(this);
  4277. }
  4278. }, {
  4279. key: 'write',
  4280. value: function write(chunk) {
  4281. if (IsWritableStreamDefaultWriter(this) === false) {
  4282. return Promise.reject(defaultWriterBrandCheckException('write'));
  4283. }
  4284. if (this._ownerWritableStream === undefined) {
  4285. return Promise.reject(defaultWriterLockException('write to'));
  4286. }
  4287. return WritableStreamDefaultWriterWrite(this, chunk);
  4288. }
  4289. }, {
  4290. key: 'closed',
  4291. get: function get() {
  4292. if (IsWritableStreamDefaultWriter(this) === false) {
  4293. return Promise.reject(defaultWriterBrandCheckException('closed'));
  4294. }
  4295. return this._closedPromise;
  4296. }
  4297. }, {
  4298. key: 'desiredSize',
  4299. get: function get() {
  4300. if (IsWritableStreamDefaultWriter(this) === false) {
  4301. throw defaultWriterBrandCheckException('desiredSize');
  4302. }
  4303. if (this._ownerWritableStream === undefined) {
  4304. throw defaultWriterLockException('desiredSize');
  4305. }
  4306. return WritableStreamDefaultWriterGetDesiredSize(this);
  4307. }
  4308. }, {
  4309. key: 'ready',
  4310. get: function get() {
  4311. if (IsWritableStreamDefaultWriter(this) === false) {
  4312. return Promise.reject(defaultWriterBrandCheckException('ready'));
  4313. }
  4314. return this._readyPromise;
  4315. }
  4316. }]);
  4317. return WritableStreamDefaultWriter;
  4318. }();
  4319. function IsWritableStreamDefaultWriter(x) {
  4320. if (!typeIsObject(x)) {
  4321. return false;
  4322. }
  4323. if (!Object.prototype.hasOwnProperty.call(x, '_ownerWritableStream')) {
  4324. return false;
  4325. }
  4326. return true;
  4327. }
  4328. function WritableStreamDefaultWriterAbort(writer, reason) {
  4329. var stream = writer._ownerWritableStream;
  4330. assert(stream !== undefined);
  4331. return WritableStreamAbort(stream, reason);
  4332. }
  4333. function WritableStreamDefaultWriterClose(writer) {
  4334. var stream = writer._ownerWritableStream;
  4335. assert(stream !== undefined);
  4336. var state = stream._state;
  4337. if (state === 'closed' || state === 'errored') {
  4338. return Promise.reject(new TypeError('The stream (in ' + state + ' state) is not in the writable state and cannot be closed'));
  4339. }
  4340. assert(state === 'writable' || state === 'erroring');
  4341. assert(WritableStreamCloseQueuedOrInFlight(stream) === false);
  4342. var promise = new Promise(function (resolve, reject) {
  4343. var closeRequest = {
  4344. _resolve: resolve,
  4345. _reject: reject
  4346. };
  4347. stream._closeRequest = closeRequest;
  4348. });
  4349. if (stream._backpressure === true && state === 'writable') {
  4350. defaultWriterReadyPromiseResolve(writer);
  4351. }
  4352. WritableStreamDefaultControllerClose(stream._writableStreamController);
  4353. return promise;
  4354. }
  4355. function WritableStreamDefaultWriterCloseWithErrorPropagation(writer) {
  4356. var stream = writer._ownerWritableStream;
  4357. assert(stream !== undefined);
  4358. var state = stream._state;
  4359. if (WritableStreamCloseQueuedOrInFlight(stream) === true || state === 'closed') {
  4360. return Promise.resolve();
  4361. }
  4362. if (state === 'errored') {
  4363. return Promise.reject(stream._storedError);
  4364. }
  4365. assert(state === 'writable' || state === 'erroring');
  4366. return WritableStreamDefaultWriterClose(writer);
  4367. }
  4368. function WritableStreamDefaultWriterEnsureClosedPromiseRejected(writer, error) {
  4369. if (writer._closedPromiseState === 'pending') {
  4370. defaultWriterClosedPromiseReject(writer, error);
  4371. } else {
  4372. defaultWriterClosedPromiseResetToRejected(writer, error);
  4373. }
  4374. writer._closedPromise.catch(function () {});
  4375. }
  4376. function WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, error) {
  4377. if (writer._readyPromiseState === 'pending') {
  4378. defaultWriterReadyPromiseReject(writer, error);
  4379. } else {
  4380. defaultWriterReadyPromiseResetToRejected(writer, error);
  4381. }
  4382. writer._readyPromise.catch(function () {});
  4383. }
  4384. function WritableStreamDefaultWriterGetDesiredSize(writer) {
  4385. var stream = writer._ownerWritableStream;
  4386. var state = stream._state;
  4387. if (state === 'errored' || state === 'erroring') {
  4388. return null;
  4389. }
  4390. if (state === 'closed') {
  4391. return 0;
  4392. }
  4393. return WritableStreamDefaultControllerGetDesiredSize(stream._writableStreamController);
  4394. }
  4395. function WritableStreamDefaultWriterRelease(writer) {
  4396. var stream = writer._ownerWritableStream;
  4397. assert(stream !== undefined);
  4398. assert(stream._writer === writer);
  4399. var releasedError = new TypeError('Writer was released and can no longer be used to monitor the stream\'s closedness');
  4400. WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, releasedError);
  4401. WritableStreamDefaultWriterEnsureClosedPromiseRejected(writer, releasedError);
  4402. stream._writer = undefined;
  4403. writer._ownerWritableStream = undefined;
  4404. }
  4405. function WritableStreamDefaultWriterWrite(writer, chunk) {
  4406. var stream = writer._ownerWritableStream;
  4407. assert(stream !== undefined);
  4408. var controller = stream._writableStreamController;
  4409. var chunkSize = WritableStreamDefaultControllerGetChunkSize(controller, chunk);
  4410. if (stream !== writer._ownerWritableStream) {
  4411. return Promise.reject(defaultWriterLockException('write to'));
  4412. }
  4413. var state = stream._state;
  4414. if (state === 'errored') {
  4415. return Promise.reject(stream._storedError);
  4416. }
  4417. if (WritableStreamCloseQueuedOrInFlight(stream) === true || state === 'closed') {
  4418. return Promise.reject(new TypeError('The stream is closing or closed and cannot be written to'));
  4419. }
  4420. if (state === 'erroring') {
  4421. return Promise.reject(stream._storedError);
  4422. }
  4423. assert(state === 'writable');
  4424. var promise = WritableStreamAddWriteRequest(stream);
  4425. WritableStreamDefaultControllerWrite(controller, chunk, chunkSize);
  4426. return promise;
  4427. }
  4428. var WritableStreamDefaultController = function () {
  4429. function WritableStreamDefaultController(stream, underlyingSink, size, highWaterMark) {
  4430. _classCallCheck(this, WritableStreamDefaultController);
  4431. if (IsWritableStream(stream) === false) {
  4432. throw new TypeError('WritableStreamDefaultController can only be constructed with a WritableStream instance');
  4433. }
  4434. if (stream._writableStreamController !== undefined) {
  4435. throw new TypeError('WritableStreamDefaultController instances can only be created by the WritableStream constructor');
  4436. }
  4437. this._controlledWritableStream = stream;
  4438. this._underlyingSink = underlyingSink;
  4439. this._queue = undefined;
  4440. this._queueTotalSize = undefined;
  4441. ResetQueue(this);
  4442. this._started = false;
  4443. var normalizedStrategy = ValidateAndNormalizeQueuingStrategy(size, highWaterMark);
  4444. this._strategySize = normalizedStrategy.size;
  4445. this._strategyHWM = normalizedStrategy.highWaterMark;
  4446. var backpressure = WritableStreamDefaultControllerGetBackpressure(this);
  4447. WritableStreamUpdateBackpressure(stream, backpressure);
  4448. }
  4449. _createClass(WritableStreamDefaultController, [{
  4450. key: 'error',
  4451. value: function error(e) {
  4452. if (IsWritableStreamDefaultController(this) === false) {
  4453. throw new TypeError('WritableStreamDefaultController.prototype.error can only be used on a WritableStreamDefaultController');
  4454. }
  4455. var state = this._controlledWritableStream._state;
  4456. if (state !== 'writable') {
  4457. return;
  4458. }
  4459. WritableStreamDefaultControllerError(this, e);
  4460. }
  4461. }, {
  4462. key: '__abortSteps',
  4463. value: function __abortSteps(reason) {
  4464. return PromiseInvokeOrNoop(this._underlyingSink, 'abort', [reason]);
  4465. }
  4466. }, {
  4467. key: '__errorSteps',
  4468. value: function __errorSteps() {
  4469. ResetQueue(this);
  4470. }
  4471. }, {
  4472. key: '__startSteps',
  4473. value: function __startSteps() {
  4474. var _this = this;
  4475. var startResult = InvokeOrNoop(this._underlyingSink, 'start', [this]);
  4476. var stream = this._controlledWritableStream;
  4477. Promise.resolve(startResult).then(function () {
  4478. assert(stream._state === 'writable' || stream._state === 'erroring');
  4479. _this._started = true;
  4480. WritableStreamDefaultControllerAdvanceQueueIfNeeded(_this);
  4481. }, function (r) {
  4482. assert(stream._state === 'writable' || stream._state === 'erroring');
  4483. _this._started = true;
  4484. WritableStreamDealWithRejection(stream, r);
  4485. }).catch(rethrowAssertionErrorRejection);
  4486. }
  4487. }]);
  4488. return WritableStreamDefaultController;
  4489. }();
  4490. function WritableStreamDefaultControllerClose(controller) {
  4491. EnqueueValueWithSize(controller, 'close', 0);
  4492. WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
  4493. }
  4494. function WritableStreamDefaultControllerGetChunkSize(controller, chunk) {
  4495. var strategySize = controller._strategySize;
  4496. if (strategySize === undefined) {
  4497. return 1;
  4498. }
  4499. try {
  4500. return strategySize(chunk);
  4501. } catch (chunkSizeE) {
  4502. WritableStreamDefaultControllerErrorIfNeeded(controller, chunkSizeE);
  4503. return 1;
  4504. }
  4505. }
  4506. function WritableStreamDefaultControllerGetDesiredSize(controller) {
  4507. return controller._strategyHWM - controller._queueTotalSize;
  4508. }
  4509. function WritableStreamDefaultControllerWrite(controller, chunk, chunkSize) {
  4510. var writeRecord = { chunk: chunk };
  4511. try {
  4512. EnqueueValueWithSize(controller, writeRecord, chunkSize);
  4513. } catch (enqueueE) {
  4514. WritableStreamDefaultControllerErrorIfNeeded(controller, enqueueE);
  4515. return;
  4516. }
  4517. var stream = controller._controlledWritableStream;
  4518. if (WritableStreamCloseQueuedOrInFlight(stream) === false && stream._state === 'writable') {
  4519. var backpressure = WritableStreamDefaultControllerGetBackpressure(controller);
  4520. WritableStreamUpdateBackpressure(stream, backpressure);
  4521. }
  4522. WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
  4523. }
  4524. function IsWritableStreamDefaultController(x) {
  4525. if (!typeIsObject(x)) {
  4526. return false;
  4527. }
  4528. if (!Object.prototype.hasOwnProperty.call(x, '_underlyingSink')) {
  4529. return false;
  4530. }
  4531. return true;
  4532. }
  4533. function WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller) {
  4534. var stream = controller._controlledWritableStream;
  4535. if (controller._started === false) {
  4536. return;
  4537. }
  4538. if (stream._inFlightWriteRequest !== undefined) {
  4539. return;
  4540. }
  4541. var state = stream._state;
  4542. if (state === 'closed' || state === 'errored') {
  4543. return;
  4544. }
  4545. if (state === 'erroring') {
  4546. WritableStreamFinishErroring(stream);
  4547. return;
  4548. }
  4549. if (controller._queue.length === 0) {
  4550. return;
  4551. }
  4552. var writeRecord = PeekQueueValue(controller);
  4553. if (writeRecord === 'close') {
  4554. WritableStreamDefaultControllerProcessClose(controller);
  4555. } else {
  4556. WritableStreamDefaultControllerProcessWrite(controller, writeRecord.chunk);
  4557. }
  4558. }
  4559. function WritableStreamDefaultControllerErrorIfNeeded(controller, error) {
  4560. if (controller._controlledWritableStream._state === 'writable') {
  4561. WritableStreamDefaultControllerError(controller, error);
  4562. }
  4563. }
  4564. function WritableStreamDefaultControllerProcessClose(controller) {
  4565. var stream = controller._controlledWritableStream;
  4566. WritableStreamMarkCloseRequestInFlight(stream);
  4567. DequeueValue(controller);
  4568. assert(controller._queue.length === 0, 'queue must be empty once the final write record is dequeued');
  4569. var sinkClosePromise = PromiseInvokeOrNoop(controller._underlyingSink, 'close', []);
  4570. sinkClosePromise.then(function () {
  4571. WritableStreamFinishInFlightClose(stream);
  4572. }, function (reason) {
  4573. WritableStreamFinishInFlightCloseWithError(stream, reason);
  4574. }).catch(rethrowAssertionErrorRejection);
  4575. }
  4576. function WritableStreamDefaultControllerProcessWrite(controller, chunk) {
  4577. var stream = controller._controlledWritableStream;
  4578. WritableStreamMarkFirstWriteRequestInFlight(stream);
  4579. var sinkWritePromise = PromiseInvokeOrNoop(controller._underlyingSink, 'write', [chunk, controller]);
  4580. sinkWritePromise.then(function () {
  4581. WritableStreamFinishInFlightWrite(stream);
  4582. var state = stream._state;
  4583. assert(state === 'writable' || state === 'erroring');
  4584. DequeueValue(controller);
  4585. if (WritableStreamCloseQueuedOrInFlight(stream) === false && state === 'writable') {
  4586. var backpressure = WritableStreamDefaultControllerGetBackpressure(controller);
  4587. WritableStreamUpdateBackpressure(stream, backpressure);
  4588. }
  4589. WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
  4590. }, function (reason) {
  4591. WritableStreamFinishInFlightWriteWithError(stream, reason);
  4592. }).catch(rethrowAssertionErrorRejection);
  4593. }
  4594. function WritableStreamDefaultControllerGetBackpressure(controller) {
  4595. var desiredSize = WritableStreamDefaultControllerGetDesiredSize(controller);
  4596. return desiredSize <= 0;
  4597. }
  4598. function WritableStreamDefaultControllerError(controller, error) {
  4599. var stream = controller._controlledWritableStream;
  4600. assert(stream._state === 'writable');
  4601. WritableStreamStartErroring(stream, error);
  4602. }
  4603. function streamBrandCheckException(name) {
  4604. return new TypeError('WritableStream.prototype.' + name + ' can only be used on a WritableStream');
  4605. }
  4606. function defaultWriterBrandCheckException(name) {
  4607. return new TypeError('WritableStreamDefaultWriter.prototype.' + name + ' can only be used on a WritableStreamDefaultWriter');
  4608. }
  4609. function defaultWriterLockException(name) {
  4610. return new TypeError('Cannot ' + name + ' a stream using a released writer');
  4611. }
  4612. function defaultWriterClosedPromiseInitialize(writer) {
  4613. writer._closedPromise = new Promise(function (resolve, reject) {
  4614. writer._closedPromise_resolve = resolve;
  4615. writer._closedPromise_reject = reject;
  4616. writer._closedPromiseState = 'pending';
  4617. });
  4618. }
  4619. function defaultWriterClosedPromiseInitializeAsRejected(writer, reason) {
  4620. writer._closedPromise = Promise.reject(reason);
  4621. writer._closedPromise_resolve = undefined;
  4622. writer._closedPromise_reject = undefined;
  4623. writer._closedPromiseState = 'rejected';
  4624. }
  4625. function defaultWriterClosedPromiseInitializeAsResolved(writer) {
  4626. writer._closedPromise = Promise.resolve(undefined);
  4627. writer._closedPromise_resolve = undefined;
  4628. writer._closedPromise_reject = undefined;
  4629. writer._closedPromiseState = 'resolved';
  4630. }
  4631. function defaultWriterClosedPromiseReject(writer, reason) {
  4632. assert(writer._closedPromise_resolve !== undefined, 'writer._closedPromise_resolve !== undefined');
  4633. assert(writer._closedPromise_reject !== undefined, 'writer._closedPromise_reject !== undefined');
  4634. assert(writer._closedPromiseState === 'pending', 'writer._closedPromiseState is pending');
  4635. writer._closedPromise_reject(reason);
  4636. writer._closedPromise_resolve = undefined;
  4637. writer._closedPromise_reject = undefined;
  4638. writer._closedPromiseState = 'rejected';
  4639. }
  4640. function defaultWriterClosedPromiseResetToRejected(writer, reason) {
  4641. assert(writer._closedPromise_resolve === undefined, 'writer._closedPromise_resolve === undefined');
  4642. assert(writer._closedPromise_reject === undefined, 'writer._closedPromise_reject === undefined');
  4643. assert(writer._closedPromiseState !== 'pending', 'writer._closedPromiseState is not pending');
  4644. writer._closedPromise = Promise.reject(reason);
  4645. writer._closedPromiseState = 'rejected';
  4646. }
  4647. function defaultWriterClosedPromiseResolve(writer) {
  4648. assert(writer._closedPromise_resolve !== undefined, 'writer._closedPromise_resolve !== undefined');
  4649. assert(writer._closedPromise_reject !== undefined, 'writer._closedPromise_reject !== undefined');
  4650. assert(writer._closedPromiseState === 'pending', 'writer._closedPromiseState is pending');
  4651. writer._closedPromise_resolve(undefined);
  4652. writer._closedPromise_resolve = undefined;
  4653. writer._closedPromise_reject = undefined;
  4654. writer._closedPromiseState = 'resolved';
  4655. }
  4656. function defaultWriterReadyPromiseInitialize(writer) {
  4657. writer._readyPromise = new Promise(function (resolve, reject) {
  4658. writer._readyPromise_resolve = resolve;
  4659. writer._readyPromise_reject = reject;
  4660. });
  4661. writer._readyPromiseState = 'pending';
  4662. }
  4663. function defaultWriterReadyPromiseInitializeAsRejected(writer, reason) {
  4664. writer._readyPromise = Promise.reject(reason);
  4665. writer._readyPromise_resolve = undefined;
  4666. writer._readyPromise_reject = undefined;
  4667. writer._readyPromiseState = 'rejected';
  4668. }
  4669. function defaultWriterReadyPromiseInitializeAsResolved(writer) {
  4670. writer._readyPromise = Promise.resolve(undefined);
  4671. writer._readyPromise_resolve = undefined;
  4672. writer._readyPromise_reject = undefined;
  4673. writer._readyPromiseState = 'fulfilled';
  4674. }
  4675. function defaultWriterReadyPromiseReject(writer, reason) {
  4676. assert(writer._readyPromise_resolve !== undefined, 'writer._readyPromise_resolve !== undefined');
  4677. assert(writer._readyPromise_reject !== undefined, 'writer._readyPromise_reject !== undefined');
  4678. writer._readyPromise_reject(reason);
  4679. writer._readyPromise_resolve = undefined;
  4680. writer._readyPromise_reject = undefined;
  4681. writer._readyPromiseState = 'rejected';
  4682. }
  4683. function defaultWriterReadyPromiseReset(writer) {
  4684. assert(writer._readyPromise_resolve === undefined, 'writer._readyPromise_resolve === undefined');
  4685. assert(writer._readyPromise_reject === undefined, 'writer._readyPromise_reject === undefined');
  4686. writer._readyPromise = new Promise(function (resolve, reject) {
  4687. writer._readyPromise_resolve = resolve;
  4688. writer._readyPromise_reject = reject;
  4689. });
  4690. writer._readyPromiseState = 'pending';
  4691. }
  4692. function defaultWriterReadyPromiseResetToRejected(writer, reason) {
  4693. assert(writer._readyPromise_resolve === undefined, 'writer._readyPromise_resolve === undefined');
  4694. assert(writer._readyPromise_reject === undefined, 'writer._readyPromise_reject === undefined');
  4695. writer._readyPromise = Promise.reject(reason);
  4696. writer._readyPromiseState = 'rejected';
  4697. }
  4698. function defaultWriterReadyPromiseResolve(writer) {
  4699. assert(writer._readyPromise_resolve !== undefined, 'writer._readyPromise_resolve !== undefined');
  4700. assert(writer._readyPromise_reject !== undefined, 'writer._readyPromise_reject !== undefined');
  4701. writer._readyPromise_resolve(undefined);
  4702. writer._readyPromise_resolve = undefined;
  4703. writer._readyPromise_reject = undefined;
  4704. writer._readyPromiseState = 'fulfilled';
  4705. }
  4706. }, function (module, exports, __w_pdfjs_require__) {
  4707. "use strict";
  4708. var _require = __w_pdfjs_require__(0),
  4709. IsFiniteNonNegativeNumber = _require.IsFiniteNonNegativeNumber;
  4710. var _require2 = __w_pdfjs_require__(1),
  4711. assert = _require2.assert;
  4712. exports.DequeueValue = function (container) {
  4713. assert('_queue' in container && '_queueTotalSize' in container, 'Spec-level failure: DequeueValue should only be used on containers with [[queue]] and [[queueTotalSize]].');
  4714. assert(container._queue.length > 0, 'Spec-level failure: should never dequeue from an empty queue.');
  4715. var pair = container._queue.shift();
  4716. container._queueTotalSize -= pair.size;
  4717. if (container._queueTotalSize < 0) {
  4718. container._queueTotalSize = 0;
  4719. }
  4720. return pair.value;
  4721. };
  4722. exports.EnqueueValueWithSize = function (container, value, size) {
  4723. assert('_queue' in container && '_queueTotalSize' in container, 'Spec-level failure: EnqueueValueWithSize should only be used on containers with [[queue]] and ' + '[[queueTotalSize]].');
  4724. size = Number(size);
  4725. if (!IsFiniteNonNegativeNumber(size)) {
  4726. throw new RangeError('Size must be a finite, non-NaN, non-negative number.');
  4727. }
  4728. container._queue.push({
  4729. value: value,
  4730. size: size
  4731. });
  4732. container._queueTotalSize += size;
  4733. };
  4734. exports.PeekQueueValue = function (container) {
  4735. assert('_queue' in container && '_queueTotalSize' in container, 'Spec-level failure: PeekQueueValue should only be used on containers with [[queue]] and [[queueTotalSize]].');
  4736. assert(container._queue.length > 0, 'Spec-level failure: should never peek at an empty queue.');
  4737. var pair = container._queue[0];
  4738. return pair.value;
  4739. };
  4740. exports.ResetQueue = function (container) {
  4741. assert('_queue' in container && '_queueTotalSize' in container, 'Spec-level failure: ResetQueue should only be used on containers with [[queue]] and [[queueTotalSize]].');
  4742. container._queue = [];
  4743. container._queueTotalSize = 0;
  4744. };
  4745. }, function (module, exports, __w_pdfjs_require__) {
  4746. "use strict";
  4747. var _createClass = function () {
  4748. function defineProperties(target, props) {
  4749. for (var i = 0; i < props.length; i++) {
  4750. var descriptor = props[i];
  4751. descriptor.enumerable = descriptor.enumerable || false;
  4752. descriptor.configurable = true;
  4753. if ("value" in descriptor) descriptor.writable = true;
  4754. Object.defineProperty(target, descriptor.key, descriptor);
  4755. }
  4756. }
  4757. return function (Constructor, protoProps, staticProps) {
  4758. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  4759. if (staticProps) defineProperties(Constructor, staticProps);
  4760. return Constructor;
  4761. };
  4762. }();
  4763. function _classCallCheck(instance, Constructor) {
  4764. if (!(instance instanceof Constructor)) {
  4765. throw new TypeError("Cannot call a class as a function");
  4766. }
  4767. }
  4768. var _require = __w_pdfjs_require__(0),
  4769. ArrayBufferCopy = _require.ArrayBufferCopy,
  4770. CreateIterResultObject = _require.CreateIterResultObject,
  4771. IsFiniteNonNegativeNumber = _require.IsFiniteNonNegativeNumber,
  4772. InvokeOrNoop = _require.InvokeOrNoop,
  4773. PromiseInvokeOrNoop = _require.PromiseInvokeOrNoop,
  4774. TransferArrayBuffer = _require.TransferArrayBuffer,
  4775. ValidateAndNormalizeQueuingStrategy = _require.ValidateAndNormalizeQueuingStrategy,
  4776. ValidateAndNormalizeHighWaterMark = _require.ValidateAndNormalizeHighWaterMark;
  4777. var _require2 = __w_pdfjs_require__(0),
  4778. createArrayFromList = _require2.createArrayFromList,
  4779. createDataProperty = _require2.createDataProperty,
  4780. typeIsObject = _require2.typeIsObject;
  4781. var _require3 = __w_pdfjs_require__(1),
  4782. assert = _require3.assert,
  4783. rethrowAssertionErrorRejection = _require3.rethrowAssertionErrorRejection;
  4784. var _require4 = __w_pdfjs_require__(3),
  4785. DequeueValue = _require4.DequeueValue,
  4786. EnqueueValueWithSize = _require4.EnqueueValueWithSize,
  4787. ResetQueue = _require4.ResetQueue;
  4788. var _require5 = __w_pdfjs_require__(2),
  4789. AcquireWritableStreamDefaultWriter = _require5.AcquireWritableStreamDefaultWriter,
  4790. IsWritableStream = _require5.IsWritableStream,
  4791. IsWritableStreamLocked = _require5.IsWritableStreamLocked,
  4792. WritableStreamAbort = _require5.WritableStreamAbort,
  4793. WritableStreamDefaultWriterCloseWithErrorPropagation = _require5.WritableStreamDefaultWriterCloseWithErrorPropagation,
  4794. WritableStreamDefaultWriterRelease = _require5.WritableStreamDefaultWriterRelease,
  4795. WritableStreamDefaultWriterWrite = _require5.WritableStreamDefaultWriterWrite,
  4796. WritableStreamCloseQueuedOrInFlight = _require5.WritableStreamCloseQueuedOrInFlight;
  4797. var ReadableStream = function () {
  4798. function ReadableStream() {
  4799. var underlyingSource = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  4800. var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  4801. size = _ref.size,
  4802. highWaterMark = _ref.highWaterMark;
  4803. _classCallCheck(this, ReadableStream);
  4804. this._state = 'readable';
  4805. this._reader = undefined;
  4806. this._storedError = undefined;
  4807. this._disturbed = false;
  4808. this._readableStreamController = undefined;
  4809. var type = underlyingSource.type;
  4810. var typeString = String(type);
  4811. if (typeString === 'bytes') {
  4812. if (highWaterMark === undefined) {
  4813. highWaterMark = 0;
  4814. }
  4815. this._readableStreamController = new ReadableByteStreamController(this, underlyingSource, highWaterMark);
  4816. } else if (type === undefined) {
  4817. if (highWaterMark === undefined) {
  4818. highWaterMark = 1;
  4819. }
  4820. this._readableStreamController = new ReadableStreamDefaultController(this, underlyingSource, size, highWaterMark);
  4821. } else {
  4822. throw new RangeError('Invalid type is specified');
  4823. }
  4824. }
  4825. _createClass(ReadableStream, [{
  4826. key: 'cancel',
  4827. value: function cancel(reason) {
  4828. if (IsReadableStream(this) === false) {
  4829. return Promise.reject(streamBrandCheckException('cancel'));
  4830. }
  4831. if (IsReadableStreamLocked(this) === true) {
  4832. return Promise.reject(new TypeError('Cannot cancel a stream that already has a reader'));
  4833. }
  4834. return ReadableStreamCancel(this, reason);
  4835. }
  4836. }, {
  4837. key: 'getReader',
  4838. value: function getReader() {
  4839. var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  4840. mode = _ref2.mode;
  4841. if (IsReadableStream(this) === false) {
  4842. throw streamBrandCheckException('getReader');
  4843. }
  4844. if (mode === undefined) {
  4845. return AcquireReadableStreamDefaultReader(this);
  4846. }
  4847. mode = String(mode);
  4848. if (mode === 'byob') {
  4849. return AcquireReadableStreamBYOBReader(this);
  4850. }
  4851. throw new RangeError('Invalid mode is specified');
  4852. }
  4853. }, {
  4854. key: 'pipeThrough',
  4855. value: function pipeThrough(_ref3, options) {
  4856. var writable = _ref3.writable,
  4857. readable = _ref3.readable;
  4858. var promise = this.pipeTo(writable, options);
  4859. ifIsObjectAndHasAPromiseIsHandledInternalSlotSetPromiseIsHandledToTrue(promise);
  4860. return readable;
  4861. }
  4862. }, {
  4863. key: 'pipeTo',
  4864. value: function pipeTo(dest) {
  4865. var _this = this;
  4866. var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  4867. preventClose = _ref4.preventClose,
  4868. preventAbort = _ref4.preventAbort,
  4869. preventCancel = _ref4.preventCancel;
  4870. if (IsReadableStream(this) === false) {
  4871. return Promise.reject(streamBrandCheckException('pipeTo'));
  4872. }
  4873. if (IsWritableStream(dest) === false) {
  4874. return Promise.reject(new TypeError('ReadableStream.prototype.pipeTo\'s first argument must be a WritableStream'));
  4875. }
  4876. preventClose = Boolean(preventClose);
  4877. preventAbort = Boolean(preventAbort);
  4878. preventCancel = Boolean(preventCancel);
  4879. if (IsReadableStreamLocked(this) === true) {
  4880. return Promise.reject(new TypeError('ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream'));
  4881. }
  4882. if (IsWritableStreamLocked(dest) === true) {
  4883. return Promise.reject(new TypeError('ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream'));
  4884. }
  4885. var reader = AcquireReadableStreamDefaultReader(this);
  4886. var writer = AcquireWritableStreamDefaultWriter(dest);
  4887. var shuttingDown = false;
  4888. var currentWrite = Promise.resolve();
  4889. return new Promise(function (resolve, reject) {
  4890. function pipeLoop() {
  4891. currentWrite = Promise.resolve();
  4892. if (shuttingDown === true) {
  4893. return Promise.resolve();
  4894. }
  4895. return writer._readyPromise.then(function () {
  4896. return ReadableStreamDefaultReaderRead(reader).then(function (_ref5) {
  4897. var value = _ref5.value,
  4898. done = _ref5.done;
  4899. if (done === true) {
  4900. return;
  4901. }
  4902. currentWrite = WritableStreamDefaultWriterWrite(writer, value).catch(function () {});
  4903. });
  4904. }).then(pipeLoop);
  4905. }
  4906. isOrBecomesErrored(_this, reader._closedPromise, function (storedError) {
  4907. if (preventAbort === false) {
  4908. shutdownWithAction(function () {
  4909. return WritableStreamAbort(dest, storedError);
  4910. }, true, storedError);
  4911. } else {
  4912. shutdown(true, storedError);
  4913. }
  4914. });
  4915. isOrBecomesErrored(dest, writer._closedPromise, function (storedError) {
  4916. if (preventCancel === false) {
  4917. shutdownWithAction(function () {
  4918. return ReadableStreamCancel(_this, storedError);
  4919. }, true, storedError);
  4920. } else {
  4921. shutdown(true, storedError);
  4922. }
  4923. });
  4924. isOrBecomesClosed(_this, reader._closedPromise, function () {
  4925. if (preventClose === false) {
  4926. shutdownWithAction(function () {
  4927. return WritableStreamDefaultWriterCloseWithErrorPropagation(writer);
  4928. });
  4929. } else {
  4930. shutdown();
  4931. }
  4932. });
  4933. if (WritableStreamCloseQueuedOrInFlight(dest) === true || dest._state === 'closed') {
  4934. var destClosed = new TypeError('the destination writable stream closed before all data could be piped to it');
  4935. if (preventCancel === false) {
  4936. shutdownWithAction(function () {
  4937. return ReadableStreamCancel(_this, destClosed);
  4938. }, true, destClosed);
  4939. } else {
  4940. shutdown(true, destClosed);
  4941. }
  4942. }
  4943. pipeLoop().catch(function (err) {
  4944. currentWrite = Promise.resolve();
  4945. rethrowAssertionErrorRejection(err);
  4946. });
  4947. function waitForWritesToFinish() {
  4948. var oldCurrentWrite = currentWrite;
  4949. return currentWrite.then(function () {
  4950. return oldCurrentWrite !== currentWrite ? waitForWritesToFinish() : undefined;
  4951. });
  4952. }
  4953. function isOrBecomesErrored(stream, promise, action) {
  4954. if (stream._state === 'errored') {
  4955. action(stream._storedError);
  4956. } else {
  4957. promise.catch(action).catch(rethrowAssertionErrorRejection);
  4958. }
  4959. }
  4960. function isOrBecomesClosed(stream, promise, action) {
  4961. if (stream._state === 'closed') {
  4962. action();
  4963. } else {
  4964. promise.then(action).catch(rethrowAssertionErrorRejection);
  4965. }
  4966. }
  4967. function shutdownWithAction(action, originalIsError, originalError) {
  4968. if (shuttingDown === true) {
  4969. return;
  4970. }
  4971. shuttingDown = true;
  4972. if (dest._state === 'writable' && WritableStreamCloseQueuedOrInFlight(dest) === false) {
  4973. waitForWritesToFinish().then(doTheRest);
  4974. } else {
  4975. doTheRest();
  4976. }
  4977. function doTheRest() {
  4978. action().then(function () {
  4979. return finalize(originalIsError, originalError);
  4980. }, function (newError) {
  4981. return finalize(true, newError);
  4982. }).catch(rethrowAssertionErrorRejection);
  4983. }
  4984. }
  4985. function shutdown(isError, error) {
  4986. if (shuttingDown === true) {
  4987. return;
  4988. }
  4989. shuttingDown = true;
  4990. if (dest._state === 'writable' && WritableStreamCloseQueuedOrInFlight(dest) === false) {
  4991. waitForWritesToFinish().then(function () {
  4992. return finalize(isError, error);
  4993. }).catch(rethrowAssertionErrorRejection);
  4994. } else {
  4995. finalize(isError, error);
  4996. }
  4997. }
  4998. function finalize(isError, error) {
  4999. WritableStreamDefaultWriterRelease(writer);
  5000. ReadableStreamReaderGenericRelease(reader);
  5001. if (isError) {
  5002. reject(error);
  5003. } else {
  5004. resolve(undefined);
  5005. }
  5006. }
  5007. });
  5008. }
  5009. }, {
  5010. key: 'tee',
  5011. value: function tee() {
  5012. if (IsReadableStream(this) === false) {
  5013. throw streamBrandCheckException('tee');
  5014. }
  5015. var branches = ReadableStreamTee(this, false);
  5016. return createArrayFromList(branches);
  5017. }
  5018. }, {
  5019. key: 'locked',
  5020. get: function get() {
  5021. if (IsReadableStream(this) === false) {
  5022. throw streamBrandCheckException('locked');
  5023. }
  5024. return IsReadableStreamLocked(this);
  5025. }
  5026. }]);
  5027. return ReadableStream;
  5028. }();
  5029. module.exports = {
  5030. ReadableStream: ReadableStream,
  5031. IsReadableStreamDisturbed: IsReadableStreamDisturbed,
  5032. ReadableStreamDefaultControllerClose: ReadableStreamDefaultControllerClose,
  5033. ReadableStreamDefaultControllerEnqueue: ReadableStreamDefaultControllerEnqueue,
  5034. ReadableStreamDefaultControllerError: ReadableStreamDefaultControllerError,
  5035. ReadableStreamDefaultControllerGetDesiredSize: ReadableStreamDefaultControllerGetDesiredSize
  5036. };
  5037. function AcquireReadableStreamBYOBReader(stream) {
  5038. return new ReadableStreamBYOBReader(stream);
  5039. }
  5040. function AcquireReadableStreamDefaultReader(stream) {
  5041. return new ReadableStreamDefaultReader(stream);
  5042. }
  5043. function IsReadableStream(x) {
  5044. if (!typeIsObject(x)) {
  5045. return false;
  5046. }
  5047. if (!Object.prototype.hasOwnProperty.call(x, '_readableStreamController')) {
  5048. return false;
  5049. }
  5050. return true;
  5051. }
  5052. function IsReadableStreamDisturbed(stream) {
  5053. assert(IsReadableStream(stream) === true, 'IsReadableStreamDisturbed should only be used on known readable streams');
  5054. return stream._disturbed;
  5055. }
  5056. function IsReadableStreamLocked(stream) {
  5057. assert(IsReadableStream(stream) === true, 'IsReadableStreamLocked should only be used on known readable streams');
  5058. if (stream._reader === undefined) {
  5059. return false;
  5060. }
  5061. return true;
  5062. }
  5063. function ReadableStreamTee(stream, cloneForBranch2) {
  5064. assert(IsReadableStream(stream) === true);
  5065. assert(typeof cloneForBranch2 === 'boolean');
  5066. var reader = AcquireReadableStreamDefaultReader(stream);
  5067. var teeState = {
  5068. closedOrErrored: false,
  5069. canceled1: false,
  5070. canceled2: false,
  5071. reason1: undefined,
  5072. reason2: undefined
  5073. };
  5074. teeState.promise = new Promise(function (resolve) {
  5075. teeState._resolve = resolve;
  5076. });
  5077. var pull = create_ReadableStreamTeePullFunction();
  5078. pull._reader = reader;
  5079. pull._teeState = teeState;
  5080. pull._cloneForBranch2 = cloneForBranch2;
  5081. var cancel1 = create_ReadableStreamTeeBranch1CancelFunction();
  5082. cancel1._stream = stream;
  5083. cancel1._teeState = teeState;
  5084. var cancel2 = create_ReadableStreamTeeBranch2CancelFunction();
  5085. cancel2._stream = stream;
  5086. cancel2._teeState = teeState;
  5087. var underlyingSource1 = Object.create(Object.prototype);
  5088. createDataProperty(underlyingSource1, 'pull', pull);
  5089. createDataProperty(underlyingSource1, 'cancel', cancel1);
  5090. var branch1Stream = new ReadableStream(underlyingSource1);
  5091. var underlyingSource2 = Object.create(Object.prototype);
  5092. createDataProperty(underlyingSource2, 'pull', pull);
  5093. createDataProperty(underlyingSource2, 'cancel', cancel2);
  5094. var branch2Stream = new ReadableStream(underlyingSource2);
  5095. pull._branch1 = branch1Stream._readableStreamController;
  5096. pull._branch2 = branch2Stream._readableStreamController;
  5097. reader._closedPromise.catch(function (r) {
  5098. if (teeState.closedOrErrored === true) {
  5099. return;
  5100. }
  5101. ReadableStreamDefaultControllerError(pull._branch1, r);
  5102. ReadableStreamDefaultControllerError(pull._branch2, r);
  5103. teeState.closedOrErrored = true;
  5104. });
  5105. return [branch1Stream, branch2Stream];
  5106. }
  5107. function create_ReadableStreamTeePullFunction() {
  5108. function f() {
  5109. var reader = f._reader,
  5110. branch1 = f._branch1,
  5111. branch2 = f._branch2,
  5112. teeState = f._teeState;
  5113. return ReadableStreamDefaultReaderRead(reader).then(function (result) {
  5114. assert(typeIsObject(result));
  5115. var value = result.value;
  5116. var done = result.done;
  5117. assert(typeof done === 'boolean');
  5118. if (done === true && teeState.closedOrErrored === false) {
  5119. if (teeState.canceled1 === false) {
  5120. ReadableStreamDefaultControllerClose(branch1);
  5121. }
  5122. if (teeState.canceled2 === false) {
  5123. ReadableStreamDefaultControllerClose(branch2);
  5124. }
  5125. teeState.closedOrErrored = true;
  5126. }
  5127. if (teeState.closedOrErrored === true) {
  5128. return;
  5129. }
  5130. var value1 = value;
  5131. var value2 = value;
  5132. if (teeState.canceled1 === false) {
  5133. ReadableStreamDefaultControllerEnqueue(branch1, value1);
  5134. }
  5135. if (teeState.canceled2 === false) {
  5136. ReadableStreamDefaultControllerEnqueue(branch2, value2);
  5137. }
  5138. });
  5139. }
  5140. return f;
  5141. }
  5142. function create_ReadableStreamTeeBranch1CancelFunction() {
  5143. function f(reason) {
  5144. var stream = f._stream,
  5145. teeState = f._teeState;
  5146. teeState.canceled1 = true;
  5147. teeState.reason1 = reason;
  5148. if (teeState.canceled2 === true) {
  5149. var compositeReason = createArrayFromList([teeState.reason1, teeState.reason2]);
  5150. var cancelResult = ReadableStreamCancel(stream, compositeReason);
  5151. teeState._resolve(cancelResult);
  5152. }
  5153. return teeState.promise;
  5154. }
  5155. return f;
  5156. }
  5157. function create_ReadableStreamTeeBranch2CancelFunction() {
  5158. function f(reason) {
  5159. var stream = f._stream,
  5160. teeState = f._teeState;
  5161. teeState.canceled2 = true;
  5162. teeState.reason2 = reason;
  5163. if (teeState.canceled1 === true) {
  5164. var compositeReason = createArrayFromList([teeState.reason1, teeState.reason2]);
  5165. var cancelResult = ReadableStreamCancel(stream, compositeReason);
  5166. teeState._resolve(cancelResult);
  5167. }
  5168. return teeState.promise;
  5169. }
  5170. return f;
  5171. }
  5172. function ReadableStreamAddReadIntoRequest(stream) {
  5173. assert(IsReadableStreamBYOBReader(stream._reader) === true);
  5174. assert(stream._state === 'readable' || stream._state === 'closed');
  5175. var promise = new Promise(function (resolve, reject) {
  5176. var readIntoRequest = {
  5177. _resolve: resolve,
  5178. _reject: reject
  5179. };
  5180. stream._reader._readIntoRequests.push(readIntoRequest);
  5181. });
  5182. return promise;
  5183. }
  5184. function ReadableStreamAddReadRequest(stream) {
  5185. assert(IsReadableStreamDefaultReader(stream._reader) === true);
  5186. assert(stream._state === 'readable');
  5187. var promise = new Promise(function (resolve, reject) {
  5188. var readRequest = {
  5189. _resolve: resolve,
  5190. _reject: reject
  5191. };
  5192. stream._reader._readRequests.push(readRequest);
  5193. });
  5194. return promise;
  5195. }
  5196. function ReadableStreamCancel(stream, reason) {
  5197. stream._disturbed = true;
  5198. if (stream._state === 'closed') {
  5199. return Promise.resolve(undefined);
  5200. }
  5201. if (stream._state === 'errored') {
  5202. return Promise.reject(stream._storedError);
  5203. }
  5204. ReadableStreamClose(stream);
  5205. var sourceCancelPromise = stream._readableStreamController.__cancelSteps(reason);
  5206. return sourceCancelPromise.then(function () {
  5207. return undefined;
  5208. });
  5209. }
  5210. function ReadableStreamClose(stream) {
  5211. assert(stream._state === 'readable');
  5212. stream._state = 'closed';
  5213. var reader = stream._reader;
  5214. if (reader === undefined) {
  5215. return undefined;
  5216. }
  5217. if (IsReadableStreamDefaultReader(reader) === true) {
  5218. for (var i = 0; i < reader._readRequests.length; i++) {
  5219. var _resolve = reader._readRequests[i]._resolve;
  5220. _resolve(CreateIterResultObject(undefined, true));
  5221. }
  5222. reader._readRequests = [];
  5223. }
  5224. defaultReaderClosedPromiseResolve(reader);
  5225. return undefined;
  5226. }
  5227. function ReadableStreamError(stream, e) {
  5228. assert(IsReadableStream(stream) === true, 'stream must be ReadableStream');
  5229. assert(stream._state === 'readable', 'state must be readable');
  5230. stream._state = 'errored';
  5231. stream._storedError = e;
  5232. var reader = stream._reader;
  5233. if (reader === undefined) {
  5234. return undefined;
  5235. }
  5236. if (IsReadableStreamDefaultReader(reader) === true) {
  5237. for (var i = 0; i < reader._readRequests.length; i++) {
  5238. var readRequest = reader._readRequests[i];
  5239. readRequest._reject(e);
  5240. }
  5241. reader._readRequests = [];
  5242. } else {
  5243. assert(IsReadableStreamBYOBReader(reader), 'reader must be ReadableStreamBYOBReader');
  5244. for (var _i = 0; _i < reader._readIntoRequests.length; _i++) {
  5245. var readIntoRequest = reader._readIntoRequests[_i];
  5246. readIntoRequest._reject(e);
  5247. }
  5248. reader._readIntoRequests = [];
  5249. }
  5250. defaultReaderClosedPromiseReject(reader, e);
  5251. reader._closedPromise.catch(function () {});
  5252. }
  5253. function ReadableStreamFulfillReadIntoRequest(stream, chunk, done) {
  5254. var reader = stream._reader;
  5255. assert(reader._readIntoRequests.length > 0);
  5256. var readIntoRequest = reader._readIntoRequests.shift();
  5257. readIntoRequest._resolve(CreateIterResultObject(chunk, done));
  5258. }
  5259. function ReadableStreamFulfillReadRequest(stream, chunk, done) {
  5260. var reader = stream._reader;
  5261. assert(reader._readRequests.length > 0);
  5262. var readRequest = reader._readRequests.shift();
  5263. readRequest._resolve(CreateIterResultObject(chunk, done));
  5264. }
  5265. function ReadableStreamGetNumReadIntoRequests(stream) {
  5266. return stream._reader._readIntoRequests.length;
  5267. }
  5268. function ReadableStreamGetNumReadRequests(stream) {
  5269. return stream._reader._readRequests.length;
  5270. }
  5271. function ReadableStreamHasBYOBReader(stream) {
  5272. var reader = stream._reader;
  5273. if (reader === undefined) {
  5274. return false;
  5275. }
  5276. if (IsReadableStreamBYOBReader(reader) === false) {
  5277. return false;
  5278. }
  5279. return true;
  5280. }
  5281. function ReadableStreamHasDefaultReader(stream) {
  5282. var reader = stream._reader;
  5283. if (reader === undefined) {
  5284. return false;
  5285. }
  5286. if (IsReadableStreamDefaultReader(reader) === false) {
  5287. return false;
  5288. }
  5289. return true;
  5290. }
  5291. var ReadableStreamDefaultReader = function () {
  5292. function ReadableStreamDefaultReader(stream) {
  5293. _classCallCheck(this, ReadableStreamDefaultReader);
  5294. if (IsReadableStream(stream) === false) {
  5295. throw new TypeError('ReadableStreamDefaultReader can only be constructed with a ReadableStream instance');
  5296. }
  5297. if (IsReadableStreamLocked(stream) === true) {
  5298. throw new TypeError('This stream has already been locked for exclusive reading by another reader');
  5299. }
  5300. ReadableStreamReaderGenericInitialize(this, stream);
  5301. this._readRequests = [];
  5302. }
  5303. _createClass(ReadableStreamDefaultReader, [{
  5304. key: 'cancel',
  5305. value: function cancel(reason) {
  5306. if (IsReadableStreamDefaultReader(this) === false) {
  5307. return Promise.reject(defaultReaderBrandCheckException('cancel'));
  5308. }
  5309. if (this._ownerReadableStream === undefined) {
  5310. return Promise.reject(readerLockException('cancel'));
  5311. }
  5312. return ReadableStreamReaderGenericCancel(this, reason);
  5313. }
  5314. }, {
  5315. key: 'read',
  5316. value: function read() {
  5317. if (IsReadableStreamDefaultReader(this) === false) {
  5318. return Promise.reject(defaultReaderBrandCheckException('read'));
  5319. }
  5320. if (this._ownerReadableStream === undefined) {
  5321. return Promise.reject(readerLockException('read from'));
  5322. }
  5323. return ReadableStreamDefaultReaderRead(this);
  5324. }
  5325. }, {
  5326. key: 'releaseLock',
  5327. value: function releaseLock() {
  5328. if (IsReadableStreamDefaultReader(this) === false) {
  5329. throw defaultReaderBrandCheckException('releaseLock');
  5330. }
  5331. if (this._ownerReadableStream === undefined) {
  5332. return;
  5333. }
  5334. if (this._readRequests.length > 0) {
  5335. throw new TypeError('Tried to release a reader lock when that reader has pending read() calls un-settled');
  5336. }
  5337. ReadableStreamReaderGenericRelease(this);
  5338. }
  5339. }, {
  5340. key: 'closed',
  5341. get: function get() {
  5342. if (IsReadableStreamDefaultReader(this) === false) {
  5343. return Promise.reject(defaultReaderBrandCheckException('closed'));
  5344. }
  5345. return this._closedPromise;
  5346. }
  5347. }]);
  5348. return ReadableStreamDefaultReader;
  5349. }();
  5350. var ReadableStreamBYOBReader = function () {
  5351. function ReadableStreamBYOBReader(stream) {
  5352. _classCallCheck(this, ReadableStreamBYOBReader);
  5353. if (!IsReadableStream(stream)) {
  5354. throw new TypeError('ReadableStreamBYOBReader can only be constructed with a ReadableStream instance given a ' + 'byte source');
  5355. }
  5356. if (IsReadableByteStreamController(stream._readableStreamController) === false) {
  5357. throw new TypeError('Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte ' + 'source');
  5358. }
  5359. if (IsReadableStreamLocked(stream)) {
  5360. throw new TypeError('This stream has already been locked for exclusive reading by another reader');
  5361. }
  5362. ReadableStreamReaderGenericInitialize(this, stream);
  5363. this._readIntoRequests = [];
  5364. }
  5365. _createClass(ReadableStreamBYOBReader, [{
  5366. key: 'cancel',
  5367. value: function cancel(reason) {
  5368. if (!IsReadableStreamBYOBReader(this)) {
  5369. return Promise.reject(byobReaderBrandCheckException('cancel'));
  5370. }
  5371. if (this._ownerReadableStream === undefined) {
  5372. return Promise.reject(readerLockException('cancel'));
  5373. }
  5374. return ReadableStreamReaderGenericCancel(this, reason);
  5375. }
  5376. }, {
  5377. key: 'read',
  5378. value: function read(view) {
  5379. if (!IsReadableStreamBYOBReader(this)) {
  5380. return Promise.reject(byobReaderBrandCheckException('read'));
  5381. }
  5382. if (this._ownerReadableStream === undefined) {
  5383. return Promise.reject(readerLockException('read from'));
  5384. }
  5385. if (!ArrayBuffer.isView(view)) {
  5386. return Promise.reject(new TypeError('view must be an array buffer view'));
  5387. }
  5388. if (view.byteLength === 0) {
  5389. return Promise.reject(new TypeError('view must have non-zero byteLength'));
  5390. }
  5391. return ReadableStreamBYOBReaderRead(this, view);
  5392. }
  5393. }, {
  5394. key: 'releaseLock',
  5395. value: function releaseLock() {
  5396. if (!IsReadableStreamBYOBReader(this)) {
  5397. throw byobReaderBrandCheckException('releaseLock');
  5398. }
  5399. if (this._ownerReadableStream === undefined) {
  5400. return;
  5401. }
  5402. if (this._readIntoRequests.length > 0) {
  5403. throw new TypeError('Tried to release a reader lock when that reader has pending read() calls un-settled');
  5404. }
  5405. ReadableStreamReaderGenericRelease(this);
  5406. }
  5407. }, {
  5408. key: 'closed',
  5409. get: function get() {
  5410. if (!IsReadableStreamBYOBReader(this)) {
  5411. return Promise.reject(byobReaderBrandCheckException('closed'));
  5412. }
  5413. return this._closedPromise;
  5414. }
  5415. }]);
  5416. return ReadableStreamBYOBReader;
  5417. }();
  5418. function IsReadableStreamBYOBReader(x) {
  5419. if (!typeIsObject(x)) {
  5420. return false;
  5421. }
  5422. if (!Object.prototype.hasOwnProperty.call(x, '_readIntoRequests')) {
  5423. return false;
  5424. }
  5425. return true;
  5426. }
  5427. function IsReadableStreamDefaultReader(x) {
  5428. if (!typeIsObject(x)) {
  5429. return false;
  5430. }
  5431. if (!Object.prototype.hasOwnProperty.call(x, '_readRequests')) {
  5432. return false;
  5433. }
  5434. return true;
  5435. }
  5436. function ReadableStreamReaderGenericInitialize(reader, stream) {
  5437. reader._ownerReadableStream = stream;
  5438. stream._reader = reader;
  5439. if (stream._state === 'readable') {
  5440. defaultReaderClosedPromiseInitialize(reader);
  5441. } else if (stream._state === 'closed') {
  5442. defaultReaderClosedPromiseInitializeAsResolved(reader);
  5443. } else {
  5444. assert(stream._state === 'errored', 'state must be errored');
  5445. defaultReaderClosedPromiseInitializeAsRejected(reader, stream._storedError);
  5446. reader._closedPromise.catch(function () {});
  5447. }
  5448. }
  5449. function ReadableStreamReaderGenericCancel(reader, reason) {
  5450. var stream = reader._ownerReadableStream;
  5451. assert(stream !== undefined);
  5452. return ReadableStreamCancel(stream, reason);
  5453. }
  5454. function ReadableStreamReaderGenericRelease(reader) {
  5455. assert(reader._ownerReadableStream !== undefined);
  5456. assert(reader._ownerReadableStream._reader === reader);
  5457. if (reader._ownerReadableStream._state === 'readable') {
  5458. defaultReaderClosedPromiseReject(reader, new TypeError('Reader was released and can no longer be used to monitor the stream\'s closedness'));
  5459. } else {
  5460. defaultReaderClosedPromiseResetToRejected(reader, new TypeError('Reader was released and can no longer be used to monitor the stream\'s closedness'));
  5461. }
  5462. reader._closedPromise.catch(function () {});
  5463. reader._ownerReadableStream._reader = undefined;
  5464. reader._ownerReadableStream = undefined;
  5465. }
  5466. function ReadableStreamBYOBReaderRead(reader, view) {
  5467. var stream = reader._ownerReadableStream;
  5468. assert(stream !== undefined);
  5469. stream._disturbed = true;
  5470. if (stream._state === 'errored') {
  5471. return Promise.reject(stream._storedError);
  5472. }
  5473. return ReadableByteStreamControllerPullInto(stream._readableStreamController, view);
  5474. }
  5475. function ReadableStreamDefaultReaderRead(reader) {
  5476. var stream = reader._ownerReadableStream;
  5477. assert(stream !== undefined);
  5478. stream._disturbed = true;
  5479. if (stream._state === 'closed') {
  5480. return Promise.resolve(CreateIterResultObject(undefined, true));
  5481. }
  5482. if (stream._state === 'errored') {
  5483. return Promise.reject(stream._storedError);
  5484. }
  5485. assert(stream._state === 'readable');
  5486. return stream._readableStreamController.__pullSteps();
  5487. }
  5488. var ReadableStreamDefaultController = function () {
  5489. function ReadableStreamDefaultController(stream, underlyingSource, size, highWaterMark) {
  5490. _classCallCheck(this, ReadableStreamDefaultController);
  5491. if (IsReadableStream(stream) === false) {
  5492. throw new TypeError('ReadableStreamDefaultController can only be constructed with a ReadableStream instance');
  5493. }
  5494. if (stream._readableStreamController !== undefined) {
  5495. throw new TypeError('ReadableStreamDefaultController instances can only be created by the ReadableStream constructor');
  5496. }
  5497. this._controlledReadableStream = stream;
  5498. this._underlyingSource = underlyingSource;
  5499. this._queue = undefined;
  5500. this._queueTotalSize = undefined;
  5501. ResetQueue(this);
  5502. this._started = false;
  5503. this._closeRequested = false;
  5504. this._pullAgain = false;
  5505. this._pulling = false;
  5506. var normalizedStrategy = ValidateAndNormalizeQueuingStrategy(size, highWaterMark);
  5507. this._strategySize = normalizedStrategy.size;
  5508. this._strategyHWM = normalizedStrategy.highWaterMark;
  5509. var controller = this;
  5510. var startResult = InvokeOrNoop(underlyingSource, 'start', [this]);
  5511. Promise.resolve(startResult).then(function () {
  5512. controller._started = true;
  5513. assert(controller._pulling === false);
  5514. assert(controller._pullAgain === false);
  5515. ReadableStreamDefaultControllerCallPullIfNeeded(controller);
  5516. }, function (r) {
  5517. ReadableStreamDefaultControllerErrorIfNeeded(controller, r);
  5518. }).catch(rethrowAssertionErrorRejection);
  5519. }
  5520. _createClass(ReadableStreamDefaultController, [{
  5521. key: 'close',
  5522. value: function close() {
  5523. if (IsReadableStreamDefaultController(this) === false) {
  5524. throw defaultControllerBrandCheckException('close');
  5525. }
  5526. if (this._closeRequested === true) {
  5527. throw new TypeError('The stream has already been closed; do not close it again!');
  5528. }
  5529. var state = this._controlledReadableStream._state;
  5530. if (state !== 'readable') {
  5531. throw new TypeError('The stream (in ' + state + ' state) is not in the readable state and cannot be closed');
  5532. }
  5533. ReadableStreamDefaultControllerClose(this);
  5534. }
  5535. }, {
  5536. key: 'enqueue',
  5537. value: function enqueue(chunk) {
  5538. if (IsReadableStreamDefaultController(this) === false) {
  5539. throw defaultControllerBrandCheckException('enqueue');
  5540. }
  5541. if (this._closeRequested === true) {
  5542. throw new TypeError('stream is closed or draining');
  5543. }
  5544. var state = this._controlledReadableStream._state;
  5545. if (state !== 'readable') {
  5546. throw new TypeError('The stream (in ' + state + ' state) is not in the readable state and cannot be enqueued to');
  5547. }
  5548. return ReadableStreamDefaultControllerEnqueue(this, chunk);
  5549. }
  5550. }, {
  5551. key: 'error',
  5552. value: function error(e) {
  5553. if (IsReadableStreamDefaultController(this) === false) {
  5554. throw defaultControllerBrandCheckException('error');
  5555. }
  5556. var stream = this._controlledReadableStream;
  5557. if (stream._state !== 'readable') {
  5558. throw new TypeError('The stream is ' + stream._state + ' and so cannot be errored');
  5559. }
  5560. ReadableStreamDefaultControllerError(this, e);
  5561. }
  5562. }, {
  5563. key: '__cancelSteps',
  5564. value: function __cancelSteps(reason) {
  5565. ResetQueue(this);
  5566. return PromiseInvokeOrNoop(this._underlyingSource, 'cancel', [reason]);
  5567. }
  5568. }, {
  5569. key: '__pullSteps',
  5570. value: function __pullSteps() {
  5571. var stream = this._controlledReadableStream;
  5572. if (this._queue.length > 0) {
  5573. var chunk = DequeueValue(this);
  5574. if (this._closeRequested === true && this._queue.length === 0) {
  5575. ReadableStreamClose(stream);
  5576. } else {
  5577. ReadableStreamDefaultControllerCallPullIfNeeded(this);
  5578. }
  5579. return Promise.resolve(CreateIterResultObject(chunk, false));
  5580. }
  5581. var pendingPromise = ReadableStreamAddReadRequest(stream);
  5582. ReadableStreamDefaultControllerCallPullIfNeeded(this);
  5583. return pendingPromise;
  5584. }
  5585. }, {
  5586. key: 'desiredSize',
  5587. get: function get() {
  5588. if (IsReadableStreamDefaultController(this) === false) {
  5589. throw defaultControllerBrandCheckException('desiredSize');
  5590. }
  5591. return ReadableStreamDefaultControllerGetDesiredSize(this);
  5592. }
  5593. }]);
  5594. return ReadableStreamDefaultController;
  5595. }();
  5596. function IsReadableStreamDefaultController(x) {
  5597. if (!typeIsObject(x)) {
  5598. return false;
  5599. }
  5600. if (!Object.prototype.hasOwnProperty.call(x, '_underlyingSource')) {
  5601. return false;
  5602. }
  5603. return true;
  5604. }
  5605. function ReadableStreamDefaultControllerCallPullIfNeeded(controller) {
  5606. var shouldPull = ReadableStreamDefaultControllerShouldCallPull(controller);
  5607. if (shouldPull === false) {
  5608. return undefined;
  5609. }
  5610. if (controller._pulling === true) {
  5611. controller._pullAgain = true;
  5612. return undefined;
  5613. }
  5614. assert(controller._pullAgain === false);
  5615. controller._pulling = true;
  5616. var pullPromise = PromiseInvokeOrNoop(controller._underlyingSource, 'pull', [controller]);
  5617. pullPromise.then(function () {
  5618. controller._pulling = false;
  5619. if (controller._pullAgain === true) {
  5620. controller._pullAgain = false;
  5621. return ReadableStreamDefaultControllerCallPullIfNeeded(controller);
  5622. }
  5623. return undefined;
  5624. }, function (e) {
  5625. ReadableStreamDefaultControllerErrorIfNeeded(controller, e);
  5626. }).catch(rethrowAssertionErrorRejection);
  5627. return undefined;
  5628. }
  5629. function ReadableStreamDefaultControllerShouldCallPull(controller) {
  5630. var stream = controller._controlledReadableStream;
  5631. if (stream._state === 'closed' || stream._state === 'errored') {
  5632. return false;
  5633. }
  5634. if (controller._closeRequested === true) {
  5635. return false;
  5636. }
  5637. if (controller._started === false) {
  5638. return false;
  5639. }
  5640. if (IsReadableStreamLocked(stream) === true && ReadableStreamGetNumReadRequests(stream) > 0) {
  5641. return true;
  5642. }
  5643. var desiredSize = ReadableStreamDefaultControllerGetDesiredSize(controller);
  5644. if (desiredSize > 0) {
  5645. return true;
  5646. }
  5647. return false;
  5648. }
  5649. function ReadableStreamDefaultControllerClose(controller) {
  5650. var stream = controller._controlledReadableStream;
  5651. assert(controller._closeRequested === false);
  5652. assert(stream._state === 'readable');
  5653. controller._closeRequested = true;
  5654. if (controller._queue.length === 0) {
  5655. ReadableStreamClose(stream);
  5656. }
  5657. }
  5658. function ReadableStreamDefaultControllerEnqueue(controller, chunk) {
  5659. var stream = controller._controlledReadableStream;
  5660. assert(controller._closeRequested === false);
  5661. assert(stream._state === 'readable');
  5662. if (IsReadableStreamLocked(stream) === true && ReadableStreamGetNumReadRequests(stream) > 0) {
  5663. ReadableStreamFulfillReadRequest(stream, chunk, false);
  5664. } else {
  5665. var chunkSize = 1;
  5666. if (controller._strategySize !== undefined) {
  5667. var strategySize = controller._strategySize;
  5668. try {
  5669. chunkSize = strategySize(chunk);
  5670. } catch (chunkSizeE) {
  5671. ReadableStreamDefaultControllerErrorIfNeeded(controller, chunkSizeE);
  5672. throw chunkSizeE;
  5673. }
  5674. }
  5675. try {
  5676. EnqueueValueWithSize(controller, chunk, chunkSize);
  5677. } catch (enqueueE) {
  5678. ReadableStreamDefaultControllerErrorIfNeeded(controller, enqueueE);
  5679. throw enqueueE;
  5680. }
  5681. }
  5682. ReadableStreamDefaultControllerCallPullIfNeeded(controller);
  5683. return undefined;
  5684. }
  5685. function ReadableStreamDefaultControllerError(controller, e) {
  5686. var stream = controller._controlledReadableStream;
  5687. assert(stream._state === 'readable');
  5688. ResetQueue(controller);
  5689. ReadableStreamError(stream, e);
  5690. }
  5691. function ReadableStreamDefaultControllerErrorIfNeeded(controller, e) {
  5692. if (controller._controlledReadableStream._state === 'readable') {
  5693. ReadableStreamDefaultControllerError(controller, e);
  5694. }
  5695. }
  5696. function ReadableStreamDefaultControllerGetDesiredSize(controller) {
  5697. var stream = controller._controlledReadableStream;
  5698. var state = stream._state;
  5699. if (state === 'errored') {
  5700. return null;
  5701. }
  5702. if (state === 'closed') {
  5703. return 0;
  5704. }
  5705. return controller._strategyHWM - controller._queueTotalSize;
  5706. }
  5707. var ReadableStreamBYOBRequest = function () {
  5708. function ReadableStreamBYOBRequest(controller, view) {
  5709. _classCallCheck(this, ReadableStreamBYOBRequest);
  5710. this._associatedReadableByteStreamController = controller;
  5711. this._view = view;
  5712. }
  5713. _createClass(ReadableStreamBYOBRequest, [{
  5714. key: 'respond',
  5715. value: function respond(bytesWritten) {
  5716. if (IsReadableStreamBYOBRequest(this) === false) {
  5717. throw byobRequestBrandCheckException('respond');
  5718. }
  5719. if (this._associatedReadableByteStreamController === undefined) {
  5720. throw new TypeError('This BYOB request has been invalidated');
  5721. }
  5722. ReadableByteStreamControllerRespond(this._associatedReadableByteStreamController, bytesWritten);
  5723. }
  5724. }, {
  5725. key: 'respondWithNewView',
  5726. value: function respondWithNewView(view) {
  5727. if (IsReadableStreamBYOBRequest(this) === false) {
  5728. throw byobRequestBrandCheckException('respond');
  5729. }
  5730. if (this._associatedReadableByteStreamController === undefined) {
  5731. throw new TypeError('This BYOB request has been invalidated');
  5732. }
  5733. if (!ArrayBuffer.isView(view)) {
  5734. throw new TypeError('You can only respond with array buffer views');
  5735. }
  5736. ReadableByteStreamControllerRespondWithNewView(this._associatedReadableByteStreamController, view);
  5737. }
  5738. }, {
  5739. key: 'view',
  5740. get: function get() {
  5741. return this._view;
  5742. }
  5743. }]);
  5744. return ReadableStreamBYOBRequest;
  5745. }();
  5746. var ReadableByteStreamController = function () {
  5747. function ReadableByteStreamController(stream, underlyingByteSource, highWaterMark) {
  5748. _classCallCheck(this, ReadableByteStreamController);
  5749. if (IsReadableStream(stream) === false) {
  5750. throw new TypeError('ReadableByteStreamController can only be constructed with a ReadableStream instance given ' + 'a byte source');
  5751. }
  5752. if (stream._readableStreamController !== undefined) {
  5753. throw new TypeError('ReadableByteStreamController instances can only be created by the ReadableStream constructor given a byte ' + 'source');
  5754. }
  5755. this._controlledReadableStream = stream;
  5756. this._underlyingByteSource = underlyingByteSource;
  5757. this._pullAgain = false;
  5758. this._pulling = false;
  5759. ReadableByteStreamControllerClearPendingPullIntos(this);
  5760. this._queue = this._queueTotalSize = undefined;
  5761. ResetQueue(this);
  5762. this._closeRequested = false;
  5763. this._started = false;
  5764. this._strategyHWM = ValidateAndNormalizeHighWaterMark(highWaterMark);
  5765. var autoAllocateChunkSize = underlyingByteSource.autoAllocateChunkSize;
  5766. if (autoAllocateChunkSize !== undefined) {
  5767. if (Number.isInteger(autoAllocateChunkSize) === false || autoAllocateChunkSize <= 0) {
  5768. throw new RangeError('autoAllocateChunkSize must be a positive integer');
  5769. }
  5770. }
  5771. this._autoAllocateChunkSize = autoAllocateChunkSize;
  5772. this._pendingPullIntos = [];
  5773. var controller = this;
  5774. var startResult = InvokeOrNoop(underlyingByteSource, 'start', [this]);
  5775. Promise.resolve(startResult).then(function () {
  5776. controller._started = true;
  5777. assert(controller._pulling === false);
  5778. assert(controller._pullAgain === false);
  5779. ReadableByteStreamControllerCallPullIfNeeded(controller);
  5780. }, function (r) {
  5781. if (stream._state === 'readable') {
  5782. ReadableByteStreamControllerError(controller, r);
  5783. }
  5784. }).catch(rethrowAssertionErrorRejection);
  5785. }
  5786. _createClass(ReadableByteStreamController, [{
  5787. key: 'close',
  5788. value: function close() {
  5789. if (IsReadableByteStreamController(this) === false) {
  5790. throw byteStreamControllerBrandCheckException('close');
  5791. }
  5792. if (this._closeRequested === true) {
  5793. throw new TypeError('The stream has already been closed; do not close it again!');
  5794. }
  5795. var state = this._controlledReadableStream._state;
  5796. if (state !== 'readable') {
  5797. throw new TypeError('The stream (in ' + state + ' state) is not in the readable state and cannot be closed');
  5798. }
  5799. ReadableByteStreamControllerClose(this);
  5800. }
  5801. }, {
  5802. key: 'enqueue',
  5803. value: function enqueue(chunk) {
  5804. if (IsReadableByteStreamController(this) === false) {
  5805. throw byteStreamControllerBrandCheckException('enqueue');
  5806. }
  5807. if (this._closeRequested === true) {
  5808. throw new TypeError('stream is closed or draining');
  5809. }
  5810. var state = this._controlledReadableStream._state;
  5811. if (state !== 'readable') {
  5812. throw new TypeError('The stream (in ' + state + ' state) is not in the readable state and cannot be enqueued to');
  5813. }
  5814. if (!ArrayBuffer.isView(chunk)) {
  5815. throw new TypeError('You can only enqueue array buffer views when using a ReadableByteStreamController');
  5816. }
  5817. ReadableByteStreamControllerEnqueue(this, chunk);
  5818. }
  5819. }, {
  5820. key: 'error',
  5821. value: function error(e) {
  5822. if (IsReadableByteStreamController(this) === false) {
  5823. throw byteStreamControllerBrandCheckException('error');
  5824. }
  5825. var stream = this._controlledReadableStream;
  5826. if (stream._state !== 'readable') {
  5827. throw new TypeError('The stream is ' + stream._state + ' and so cannot be errored');
  5828. }
  5829. ReadableByteStreamControllerError(this, e);
  5830. }
  5831. }, {
  5832. key: '__cancelSteps',
  5833. value: function __cancelSteps(reason) {
  5834. if (this._pendingPullIntos.length > 0) {
  5835. var firstDescriptor = this._pendingPullIntos[0];
  5836. firstDescriptor.bytesFilled = 0;
  5837. }
  5838. ResetQueue(this);
  5839. return PromiseInvokeOrNoop(this._underlyingByteSource, 'cancel', [reason]);
  5840. }
  5841. }, {
  5842. key: '__pullSteps',
  5843. value: function __pullSteps() {
  5844. var stream = this._controlledReadableStream;
  5845. assert(ReadableStreamHasDefaultReader(stream) === true);
  5846. if (this._queueTotalSize > 0) {
  5847. assert(ReadableStreamGetNumReadRequests(stream) === 0);
  5848. var entry = this._queue.shift();
  5849. this._queueTotalSize -= entry.byteLength;
  5850. ReadableByteStreamControllerHandleQueueDrain(this);
  5851. var view = void 0;
  5852. try {
  5853. view = new Uint8Array(entry.buffer, entry.byteOffset, entry.byteLength);
  5854. } catch (viewE) {
  5855. return Promise.reject(viewE);
  5856. }
  5857. return Promise.resolve(CreateIterResultObject(view, false));
  5858. }
  5859. var autoAllocateChunkSize = this._autoAllocateChunkSize;
  5860. if (autoAllocateChunkSize !== undefined) {
  5861. var buffer = void 0;
  5862. try {
  5863. buffer = new ArrayBuffer(autoAllocateChunkSize);
  5864. } catch (bufferE) {
  5865. return Promise.reject(bufferE);
  5866. }
  5867. var pullIntoDescriptor = {
  5868. buffer: buffer,
  5869. byteOffset: 0,
  5870. byteLength: autoAllocateChunkSize,
  5871. bytesFilled: 0,
  5872. elementSize: 1,
  5873. ctor: Uint8Array,
  5874. readerType: 'default'
  5875. };
  5876. this._pendingPullIntos.push(pullIntoDescriptor);
  5877. }
  5878. var promise = ReadableStreamAddReadRequest(stream);
  5879. ReadableByteStreamControllerCallPullIfNeeded(this);
  5880. return promise;
  5881. }
  5882. }, {
  5883. key: 'byobRequest',
  5884. get: function get() {
  5885. if (IsReadableByteStreamController(this) === false) {
  5886. throw byteStreamControllerBrandCheckException('byobRequest');
  5887. }
  5888. if (this._byobRequest === undefined && this._pendingPullIntos.length > 0) {
  5889. var firstDescriptor = this._pendingPullIntos[0];
  5890. var view = new Uint8Array(firstDescriptor.buffer, firstDescriptor.byteOffset + firstDescriptor.bytesFilled, firstDescriptor.byteLength - firstDescriptor.bytesFilled);
  5891. this._byobRequest = new ReadableStreamBYOBRequest(this, view);
  5892. }
  5893. return this._byobRequest;
  5894. }
  5895. }, {
  5896. key: 'desiredSize',
  5897. get: function get() {
  5898. if (IsReadableByteStreamController(this) === false) {
  5899. throw byteStreamControllerBrandCheckException('desiredSize');
  5900. }
  5901. return ReadableByteStreamControllerGetDesiredSize(this);
  5902. }
  5903. }]);
  5904. return ReadableByteStreamController;
  5905. }();
  5906. function IsReadableByteStreamController(x) {
  5907. if (!typeIsObject(x)) {
  5908. return false;
  5909. }
  5910. if (!Object.prototype.hasOwnProperty.call(x, '_underlyingByteSource')) {
  5911. return false;
  5912. }
  5913. return true;
  5914. }
  5915. function IsReadableStreamBYOBRequest(x) {
  5916. if (!typeIsObject(x)) {
  5917. return false;
  5918. }
  5919. if (!Object.prototype.hasOwnProperty.call(x, '_associatedReadableByteStreamController')) {
  5920. return false;
  5921. }
  5922. return true;
  5923. }
  5924. function ReadableByteStreamControllerCallPullIfNeeded(controller) {
  5925. var shouldPull = ReadableByteStreamControllerShouldCallPull(controller);
  5926. if (shouldPull === false) {
  5927. return undefined;
  5928. }
  5929. if (controller._pulling === true) {
  5930. controller._pullAgain = true;
  5931. return undefined;
  5932. }
  5933. assert(controller._pullAgain === false);
  5934. controller._pulling = true;
  5935. var pullPromise = PromiseInvokeOrNoop(controller._underlyingByteSource, 'pull', [controller]);
  5936. pullPromise.then(function () {
  5937. controller._pulling = false;
  5938. if (controller._pullAgain === true) {
  5939. controller._pullAgain = false;
  5940. ReadableByteStreamControllerCallPullIfNeeded(controller);
  5941. }
  5942. }, function (e) {
  5943. if (controller._controlledReadableStream._state === 'readable') {
  5944. ReadableByteStreamControllerError(controller, e);
  5945. }
  5946. }).catch(rethrowAssertionErrorRejection);
  5947. return undefined;
  5948. }
  5949. function ReadableByteStreamControllerClearPendingPullIntos(controller) {
  5950. ReadableByteStreamControllerInvalidateBYOBRequest(controller);
  5951. controller._pendingPullIntos = [];
  5952. }
  5953. function ReadableByteStreamControllerCommitPullIntoDescriptor(stream, pullIntoDescriptor) {
  5954. assert(stream._state !== 'errored', 'state must not be errored');
  5955. var done = false;
  5956. if (stream._state === 'closed') {
  5957. assert(pullIntoDescriptor.bytesFilled === 0);
  5958. done = true;
  5959. }
  5960. var filledView = ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor);
  5961. if (pullIntoDescriptor.readerType === 'default') {
  5962. ReadableStreamFulfillReadRequest(stream, filledView, done);
  5963. } else {
  5964. assert(pullIntoDescriptor.readerType === 'byob');
  5965. ReadableStreamFulfillReadIntoRequest(stream, filledView, done);
  5966. }
  5967. }
  5968. function ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor) {
  5969. var bytesFilled = pullIntoDescriptor.bytesFilled;
  5970. var elementSize = pullIntoDescriptor.elementSize;
  5971. assert(bytesFilled <= pullIntoDescriptor.byteLength);
  5972. assert(bytesFilled % elementSize === 0);
  5973. return new pullIntoDescriptor.ctor(pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, bytesFilled / elementSize);
  5974. }
  5975. function ReadableByteStreamControllerEnqueueChunkToQueue(controller, buffer, byteOffset, byteLength) {
  5976. controller._queue.push({
  5977. buffer: buffer,
  5978. byteOffset: byteOffset,
  5979. byteLength: byteLength
  5980. });
  5981. controller._queueTotalSize += byteLength;
  5982. }
  5983. function ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) {
  5984. var elementSize = pullIntoDescriptor.elementSize;
  5985. var currentAlignedBytes = pullIntoDescriptor.bytesFilled - pullIntoDescriptor.bytesFilled % elementSize;
  5986. var maxBytesToCopy = Math.min(controller._queueTotalSize, pullIntoDescriptor.byteLength - pullIntoDescriptor.bytesFilled);
  5987. var maxBytesFilled = pullIntoDescriptor.bytesFilled + maxBytesToCopy;
  5988. var maxAlignedBytes = maxBytesFilled - maxBytesFilled % elementSize;
  5989. var totalBytesToCopyRemaining = maxBytesToCopy;
  5990. var ready = false;
  5991. if (maxAlignedBytes > currentAlignedBytes) {
  5992. totalBytesToCopyRemaining = maxAlignedBytes - pullIntoDescriptor.bytesFilled;
  5993. ready = true;
  5994. }
  5995. var queue = controller._queue;
  5996. while (totalBytesToCopyRemaining > 0) {
  5997. var headOfQueue = queue[0];
  5998. var bytesToCopy = Math.min(totalBytesToCopyRemaining, headOfQueue.byteLength);
  5999. var destStart = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;
  6000. ArrayBufferCopy(pullIntoDescriptor.buffer, destStart, headOfQueue.buffer, headOfQueue.byteOffset, bytesToCopy);
  6001. if (headOfQueue.byteLength === bytesToCopy) {
  6002. queue.shift();
  6003. } else {
  6004. headOfQueue.byteOffset += bytesToCopy;
  6005. headOfQueue.byteLength -= bytesToCopy;
  6006. }
  6007. controller._queueTotalSize -= bytesToCopy;
  6008. ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, bytesToCopy, pullIntoDescriptor);
  6009. totalBytesToCopyRemaining -= bytesToCopy;
  6010. }
  6011. if (ready === false) {
  6012. assert(controller._queueTotalSize === 0, 'queue must be empty');
  6013. assert(pullIntoDescriptor.bytesFilled > 0);
  6014. assert(pullIntoDescriptor.bytesFilled < pullIntoDescriptor.elementSize);
  6015. }
  6016. return ready;
  6017. }
  6018. function ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, size, pullIntoDescriptor) {
  6019. assert(controller._pendingPullIntos.length === 0 || controller._pendingPullIntos[0] === pullIntoDescriptor);
  6020. ReadableByteStreamControllerInvalidateBYOBRequest(controller);
  6021. pullIntoDescriptor.bytesFilled += size;
  6022. }
  6023. function ReadableByteStreamControllerHandleQueueDrain(controller) {
  6024. assert(controller._controlledReadableStream._state === 'readable');
  6025. if (controller._queueTotalSize === 0 && controller._closeRequested === true) {
  6026. ReadableStreamClose(controller._controlledReadableStream);
  6027. } else {
  6028. ReadableByteStreamControllerCallPullIfNeeded(controller);
  6029. }
  6030. }
  6031. function ReadableByteStreamControllerInvalidateBYOBRequest(controller) {
  6032. if (controller._byobRequest === undefined) {
  6033. return;
  6034. }
  6035. controller._byobRequest._associatedReadableByteStreamController = undefined;
  6036. controller._byobRequest._view = undefined;
  6037. controller._byobRequest = undefined;
  6038. }
  6039. function ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller) {
  6040. assert(controller._closeRequested === false);
  6041. while (controller._pendingPullIntos.length > 0) {
  6042. if (controller._queueTotalSize === 0) {
  6043. return;
  6044. }
  6045. var pullIntoDescriptor = controller._pendingPullIntos[0];
  6046. if (ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) === true) {
  6047. ReadableByteStreamControllerShiftPendingPullInto(controller);
  6048. ReadableByteStreamControllerCommitPullIntoDescriptor(controller._controlledReadableStream, pullIntoDescriptor);
  6049. }
  6050. }
  6051. }
  6052. function ReadableByteStreamControllerPullInto(controller, view) {
  6053. var stream = controller._controlledReadableStream;
  6054. var elementSize = 1;
  6055. if (view.constructor !== DataView) {
  6056. elementSize = view.constructor.BYTES_PER_ELEMENT;
  6057. }
  6058. var ctor = view.constructor;
  6059. var pullIntoDescriptor = {
  6060. buffer: view.buffer,
  6061. byteOffset: view.byteOffset,
  6062. byteLength: view.byteLength,
  6063. bytesFilled: 0,
  6064. elementSize: elementSize,
  6065. ctor: ctor,
  6066. readerType: 'byob'
  6067. };
  6068. if (controller._pendingPullIntos.length > 0) {
  6069. pullIntoDescriptor.buffer = TransferArrayBuffer(pullIntoDescriptor.buffer);
  6070. controller._pendingPullIntos.push(pullIntoDescriptor);
  6071. return ReadableStreamAddReadIntoRequest(stream);
  6072. }
  6073. if (stream._state === 'closed') {
  6074. var emptyView = new view.constructor(pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, 0);
  6075. return Promise.resolve(CreateIterResultObject(emptyView, true));
  6076. }
  6077. if (controller._queueTotalSize > 0) {
  6078. if (ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) === true) {
  6079. var filledView = ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor);
  6080. ReadableByteStreamControllerHandleQueueDrain(controller);
  6081. return Promise.resolve(CreateIterResultObject(filledView, false));
  6082. }
  6083. if (controller._closeRequested === true) {
  6084. var e = new TypeError('Insufficient bytes to fill elements in the given buffer');
  6085. ReadableByteStreamControllerError(controller, e);
  6086. return Promise.reject(e);
  6087. }
  6088. }
  6089. pullIntoDescriptor.buffer = TransferArrayBuffer(pullIntoDescriptor.buffer);
  6090. controller._pendingPullIntos.push(pullIntoDescriptor);
  6091. var promise = ReadableStreamAddReadIntoRequest(stream);
  6092. ReadableByteStreamControllerCallPullIfNeeded(controller);
  6093. return promise;
  6094. }
  6095. function ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor) {
  6096. firstDescriptor.buffer = TransferArrayBuffer(firstDescriptor.buffer);
  6097. assert(firstDescriptor.bytesFilled === 0, 'bytesFilled must be 0');
  6098. var stream = controller._controlledReadableStream;
  6099. if (ReadableStreamHasBYOBReader(stream) === true) {
  6100. while (ReadableStreamGetNumReadIntoRequests(stream) > 0) {
  6101. var pullIntoDescriptor = ReadableByteStreamControllerShiftPendingPullInto(controller);
  6102. ReadableByteStreamControllerCommitPullIntoDescriptor(stream, pullIntoDescriptor);
  6103. }
  6104. }
  6105. }
  6106. function ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, pullIntoDescriptor) {
  6107. if (pullIntoDescriptor.bytesFilled + bytesWritten > pullIntoDescriptor.byteLength) {
  6108. throw new RangeError('bytesWritten out of range');
  6109. }
  6110. ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, bytesWritten, pullIntoDescriptor);
  6111. if (pullIntoDescriptor.bytesFilled < pullIntoDescriptor.elementSize) {
  6112. return;
  6113. }
  6114. ReadableByteStreamControllerShiftPendingPullInto(controller);
  6115. var remainderSize = pullIntoDescriptor.bytesFilled % pullIntoDescriptor.elementSize;
  6116. if (remainderSize > 0) {
  6117. var end = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;
  6118. var remainder = pullIntoDescriptor.buffer.slice(end - remainderSize, end);
  6119. ReadableByteStreamControllerEnqueueChunkToQueue(controller, remainder, 0, remainder.byteLength);
  6120. }
  6121. pullIntoDescriptor.buffer = TransferArrayBuffer(pullIntoDescriptor.buffer);
  6122. pullIntoDescriptor.bytesFilled -= remainderSize;
  6123. ReadableByteStreamControllerCommitPullIntoDescriptor(controller._controlledReadableStream, pullIntoDescriptor);
  6124. ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller);
  6125. }
  6126. function ReadableByteStreamControllerRespondInternal(controller, bytesWritten) {
  6127. var firstDescriptor = controller._pendingPullIntos[0];
  6128. var stream = controller._controlledReadableStream;
  6129. if (stream._state === 'closed') {
  6130. if (bytesWritten !== 0) {
  6131. throw new TypeError('bytesWritten must be 0 when calling respond() on a closed stream');
  6132. }
  6133. ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor);
  6134. } else {
  6135. assert(stream._state === 'readable');
  6136. ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, firstDescriptor);
  6137. }
  6138. }
  6139. function ReadableByteStreamControllerShiftPendingPullInto(controller) {
  6140. var descriptor = controller._pendingPullIntos.shift();
  6141. ReadableByteStreamControllerInvalidateBYOBRequest(controller);
  6142. return descriptor;
  6143. }
  6144. function ReadableByteStreamControllerShouldCallPull(controller) {
  6145. var stream = controller._controlledReadableStream;
  6146. if (stream._state !== 'readable') {
  6147. return false;
  6148. }
  6149. if (controller._closeRequested === true) {
  6150. return false;
  6151. }
  6152. if (controller._started === false) {
  6153. return false;
  6154. }
  6155. if (ReadableStreamHasDefaultReader(stream) === true && ReadableStreamGetNumReadRequests(stream) > 0) {
  6156. return true;
  6157. }
  6158. if (ReadableStreamHasBYOBReader(stream) === true && ReadableStreamGetNumReadIntoRequests(stream) > 0) {
  6159. return true;
  6160. }
  6161. if (ReadableByteStreamControllerGetDesiredSize(controller) > 0) {
  6162. return true;
  6163. }
  6164. return false;
  6165. }
  6166. function ReadableByteStreamControllerClose(controller) {
  6167. var stream = controller._controlledReadableStream;
  6168. assert(controller._closeRequested === false);
  6169. assert(stream._state === 'readable');
  6170. if (controller._queueTotalSize > 0) {
  6171. controller._closeRequested = true;
  6172. return;
  6173. }
  6174. if (controller._pendingPullIntos.length > 0) {
  6175. var firstPendingPullInto = controller._pendingPullIntos[0];
  6176. if (firstPendingPullInto.bytesFilled > 0) {
  6177. var e = new TypeError('Insufficient bytes to fill elements in the given buffer');
  6178. ReadableByteStreamControllerError(controller, e);
  6179. throw e;
  6180. }
  6181. }
  6182. ReadableStreamClose(stream);
  6183. }
  6184. function ReadableByteStreamControllerEnqueue(controller, chunk) {
  6185. var stream = controller._controlledReadableStream;
  6186. assert(controller._closeRequested === false);
  6187. assert(stream._state === 'readable');
  6188. var buffer = chunk.buffer;
  6189. var byteOffset = chunk.byteOffset;
  6190. var byteLength = chunk.byteLength;
  6191. var transferredBuffer = TransferArrayBuffer(buffer);
  6192. if (ReadableStreamHasDefaultReader(stream) === true) {
  6193. if (ReadableStreamGetNumReadRequests(stream) === 0) {
  6194. ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
  6195. } else {
  6196. assert(controller._queue.length === 0);
  6197. var transferredView = new Uint8Array(transferredBuffer, byteOffset, byteLength);
  6198. ReadableStreamFulfillReadRequest(stream, transferredView, false);
  6199. }
  6200. } else if (ReadableStreamHasBYOBReader(stream) === true) {
  6201. ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
  6202. ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller);
  6203. } else {
  6204. assert(IsReadableStreamLocked(stream) === false, 'stream must not be locked');
  6205. ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
  6206. }
  6207. }
  6208. function ReadableByteStreamControllerError(controller, e) {
  6209. var stream = controller._controlledReadableStream;
  6210. assert(stream._state === 'readable');
  6211. ReadableByteStreamControllerClearPendingPullIntos(controller);
  6212. ResetQueue(controller);
  6213. ReadableStreamError(stream, e);
  6214. }
  6215. function ReadableByteStreamControllerGetDesiredSize(controller) {
  6216. var stream = controller._controlledReadableStream;
  6217. var state = stream._state;
  6218. if (state === 'errored') {
  6219. return null;
  6220. }
  6221. if (state === 'closed') {
  6222. return 0;
  6223. }
  6224. return controller._strategyHWM - controller._queueTotalSize;
  6225. }
  6226. function ReadableByteStreamControllerRespond(controller, bytesWritten) {
  6227. bytesWritten = Number(bytesWritten);
  6228. if (IsFiniteNonNegativeNumber(bytesWritten) === false) {
  6229. throw new RangeError('bytesWritten must be a finite');
  6230. }
  6231. assert(controller._pendingPullIntos.length > 0);
  6232. ReadableByteStreamControllerRespondInternal(controller, bytesWritten);
  6233. }
  6234. function ReadableByteStreamControllerRespondWithNewView(controller, view) {
  6235. assert(controller._pendingPullIntos.length > 0);
  6236. var firstDescriptor = controller._pendingPullIntos[0];
  6237. if (firstDescriptor.byteOffset + firstDescriptor.bytesFilled !== view.byteOffset) {
  6238. throw new RangeError('The region specified by view does not match byobRequest');
  6239. }
  6240. if (firstDescriptor.byteLength !== view.byteLength) {
  6241. throw new RangeError('The buffer of view has different capacity than byobRequest');
  6242. }
  6243. firstDescriptor.buffer = view.buffer;
  6244. ReadableByteStreamControllerRespondInternal(controller, view.byteLength);
  6245. }
  6246. function streamBrandCheckException(name) {
  6247. return new TypeError('ReadableStream.prototype.' + name + ' can only be used on a ReadableStream');
  6248. }
  6249. function readerLockException(name) {
  6250. return new TypeError('Cannot ' + name + ' a stream using a released reader');
  6251. }
  6252. function defaultReaderBrandCheckException(name) {
  6253. return new TypeError('ReadableStreamDefaultReader.prototype.' + name + ' can only be used on a ReadableStreamDefaultReader');
  6254. }
  6255. function defaultReaderClosedPromiseInitialize(reader) {
  6256. reader._closedPromise = new Promise(function (resolve, reject) {
  6257. reader._closedPromise_resolve = resolve;
  6258. reader._closedPromise_reject = reject;
  6259. });
  6260. }
  6261. function defaultReaderClosedPromiseInitializeAsRejected(reader, reason) {
  6262. reader._closedPromise = Promise.reject(reason);
  6263. reader._closedPromise_resolve = undefined;
  6264. reader._closedPromise_reject = undefined;
  6265. }
  6266. function defaultReaderClosedPromiseInitializeAsResolved(reader) {
  6267. reader._closedPromise = Promise.resolve(undefined);
  6268. reader._closedPromise_resolve = undefined;
  6269. reader._closedPromise_reject = undefined;
  6270. }
  6271. function defaultReaderClosedPromiseReject(reader, reason) {
  6272. assert(reader._closedPromise_resolve !== undefined);
  6273. assert(reader._closedPromise_reject !== undefined);
  6274. reader._closedPromise_reject(reason);
  6275. reader._closedPromise_resolve = undefined;
  6276. reader._closedPromise_reject = undefined;
  6277. }
  6278. function defaultReaderClosedPromiseResetToRejected(reader, reason) {
  6279. assert(reader._closedPromise_resolve === undefined);
  6280. assert(reader._closedPromise_reject === undefined);
  6281. reader._closedPromise = Promise.reject(reason);
  6282. }
  6283. function defaultReaderClosedPromiseResolve(reader) {
  6284. assert(reader._closedPromise_resolve !== undefined);
  6285. assert(reader._closedPromise_reject !== undefined);
  6286. reader._closedPromise_resolve(undefined);
  6287. reader._closedPromise_resolve = undefined;
  6288. reader._closedPromise_reject = undefined;
  6289. }
  6290. function byobReaderBrandCheckException(name) {
  6291. return new TypeError('ReadableStreamBYOBReader.prototype.' + name + ' can only be used on a ReadableStreamBYOBReader');
  6292. }
  6293. function defaultControllerBrandCheckException(name) {
  6294. return new TypeError('ReadableStreamDefaultController.prototype.' + name + ' can only be used on a ReadableStreamDefaultController');
  6295. }
  6296. function byobRequestBrandCheckException(name) {
  6297. return new TypeError('ReadableStreamBYOBRequest.prototype.' + name + ' can only be used on a ReadableStreamBYOBRequest');
  6298. }
  6299. function byteStreamControllerBrandCheckException(name) {
  6300. return new TypeError('ReadableByteStreamController.prototype.' + name + ' can only be used on a ReadableByteStreamController');
  6301. }
  6302. function ifIsObjectAndHasAPromiseIsHandledInternalSlotSetPromiseIsHandledToTrue(promise) {
  6303. try {
  6304. Promise.prototype.then.call(promise, undefined, function () {});
  6305. } catch (e) {}
  6306. }
  6307. }, function (module, exports, __w_pdfjs_require__) {
  6308. "use strict";
  6309. var transformStream = __w_pdfjs_require__(6);
  6310. var readableStream = __w_pdfjs_require__(4);
  6311. var writableStream = __w_pdfjs_require__(2);
  6312. exports.TransformStream = transformStream.TransformStream;
  6313. exports.ReadableStream = readableStream.ReadableStream;
  6314. exports.IsReadableStreamDisturbed = readableStream.IsReadableStreamDisturbed;
  6315. exports.ReadableStreamDefaultControllerClose = readableStream.ReadableStreamDefaultControllerClose;
  6316. exports.ReadableStreamDefaultControllerEnqueue = readableStream.ReadableStreamDefaultControllerEnqueue;
  6317. exports.ReadableStreamDefaultControllerError = readableStream.ReadableStreamDefaultControllerError;
  6318. exports.ReadableStreamDefaultControllerGetDesiredSize = readableStream.ReadableStreamDefaultControllerGetDesiredSize;
  6319. exports.AcquireWritableStreamDefaultWriter = writableStream.AcquireWritableStreamDefaultWriter;
  6320. exports.IsWritableStream = writableStream.IsWritableStream;
  6321. exports.IsWritableStreamLocked = writableStream.IsWritableStreamLocked;
  6322. exports.WritableStream = writableStream.WritableStream;
  6323. exports.WritableStreamAbort = writableStream.WritableStreamAbort;
  6324. exports.WritableStreamDefaultControllerError = writableStream.WritableStreamDefaultControllerError;
  6325. exports.WritableStreamDefaultWriterCloseWithErrorPropagation = writableStream.WritableStreamDefaultWriterCloseWithErrorPropagation;
  6326. exports.WritableStreamDefaultWriterRelease = writableStream.WritableStreamDefaultWriterRelease;
  6327. exports.WritableStreamDefaultWriterWrite = writableStream.WritableStreamDefaultWriterWrite;
  6328. }, function (module, exports, __w_pdfjs_require__) {
  6329. "use strict";
  6330. var _createClass = function () {
  6331. function defineProperties(target, props) {
  6332. for (var i = 0; i < props.length; i++) {
  6333. var descriptor = props[i];
  6334. descriptor.enumerable = descriptor.enumerable || false;
  6335. descriptor.configurable = true;
  6336. if ("value" in descriptor) descriptor.writable = true;
  6337. Object.defineProperty(target, descriptor.key, descriptor);
  6338. }
  6339. }
  6340. return function (Constructor, protoProps, staticProps) {
  6341. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  6342. if (staticProps) defineProperties(Constructor, staticProps);
  6343. return Constructor;
  6344. };
  6345. }();
  6346. function _classCallCheck(instance, Constructor) {
  6347. if (!(instance instanceof Constructor)) {
  6348. throw new TypeError("Cannot call a class as a function");
  6349. }
  6350. }
  6351. var _require = __w_pdfjs_require__(1),
  6352. assert = _require.assert;
  6353. var _require2 = __w_pdfjs_require__(0),
  6354. InvokeOrNoop = _require2.InvokeOrNoop,
  6355. PromiseInvokeOrPerformFallback = _require2.PromiseInvokeOrPerformFallback,
  6356. PromiseInvokeOrNoop = _require2.PromiseInvokeOrNoop,
  6357. typeIsObject = _require2.typeIsObject;
  6358. var _require3 = __w_pdfjs_require__(4),
  6359. ReadableStream = _require3.ReadableStream,
  6360. ReadableStreamDefaultControllerClose = _require3.ReadableStreamDefaultControllerClose,
  6361. ReadableStreamDefaultControllerEnqueue = _require3.ReadableStreamDefaultControllerEnqueue,
  6362. ReadableStreamDefaultControllerError = _require3.ReadableStreamDefaultControllerError,
  6363. ReadableStreamDefaultControllerGetDesiredSize = _require3.ReadableStreamDefaultControllerGetDesiredSize;
  6364. var _require4 = __w_pdfjs_require__(2),
  6365. WritableStream = _require4.WritableStream,
  6366. WritableStreamDefaultControllerError = _require4.WritableStreamDefaultControllerError;
  6367. function TransformStreamCloseReadable(transformStream) {
  6368. if (transformStream._errored === true) {
  6369. throw new TypeError('TransformStream is already errored');
  6370. }
  6371. if (transformStream._readableClosed === true) {
  6372. throw new TypeError('Readable side is already closed');
  6373. }
  6374. TransformStreamCloseReadableInternal(transformStream);
  6375. }
  6376. function TransformStreamEnqueueToReadable(transformStream, chunk) {
  6377. if (transformStream._errored === true) {
  6378. throw new TypeError('TransformStream is already errored');
  6379. }
  6380. if (transformStream._readableClosed === true) {
  6381. throw new TypeError('Readable side is already closed');
  6382. }
  6383. var controller = transformStream._readableController;
  6384. try {
  6385. ReadableStreamDefaultControllerEnqueue(controller, chunk);
  6386. } catch (e) {
  6387. transformStream._readableClosed = true;
  6388. TransformStreamErrorIfNeeded(transformStream, e);
  6389. throw transformStream._storedError;
  6390. }
  6391. var desiredSize = ReadableStreamDefaultControllerGetDesiredSize(controller);
  6392. var maybeBackpressure = desiredSize <= 0;
  6393. if (maybeBackpressure === true && transformStream._backpressure === false) {
  6394. TransformStreamSetBackpressure(transformStream, true);
  6395. }
  6396. }
  6397. function TransformStreamError(transformStream, e) {
  6398. if (transformStream._errored === true) {
  6399. throw new TypeError('TransformStream is already errored');
  6400. }
  6401. TransformStreamErrorInternal(transformStream, e);
  6402. }
  6403. function TransformStreamCloseReadableInternal(transformStream) {
  6404. assert(transformStream._errored === false);
  6405. assert(transformStream._readableClosed === false);
  6406. try {
  6407. ReadableStreamDefaultControllerClose(transformStream._readableController);
  6408. } catch (e) {
  6409. assert(false);
  6410. }
  6411. transformStream._readableClosed = true;
  6412. }
  6413. function TransformStreamErrorIfNeeded(transformStream, e) {
  6414. if (transformStream._errored === false) {
  6415. TransformStreamErrorInternal(transformStream, e);
  6416. }
  6417. }
  6418. function TransformStreamErrorInternal(transformStream, e) {
  6419. assert(transformStream._errored === false);
  6420. transformStream._errored = true;
  6421. transformStream._storedError = e;
  6422. if (transformStream._writableDone === false) {
  6423. WritableStreamDefaultControllerError(transformStream._writableController, e);
  6424. }
  6425. if (transformStream._readableClosed === false) {
  6426. ReadableStreamDefaultControllerError(transformStream._readableController, e);
  6427. }
  6428. }
  6429. function TransformStreamReadableReadyPromise(transformStream) {
  6430. assert(transformStream._backpressureChangePromise !== undefined, '_backpressureChangePromise should have been initialized');
  6431. if (transformStream._backpressure === false) {
  6432. return Promise.resolve();
  6433. }
  6434. assert(transformStream._backpressure === true, '_backpressure should have been initialized');
  6435. return transformStream._backpressureChangePromise;
  6436. }
  6437. function TransformStreamSetBackpressure(transformStream, backpressure) {
  6438. assert(transformStream._backpressure !== backpressure, 'TransformStreamSetBackpressure() should be called only when backpressure is changed');
  6439. if (transformStream._backpressureChangePromise !== undefined) {
  6440. transformStream._backpressureChangePromise_resolve(backpressure);
  6441. }
  6442. transformStream._backpressureChangePromise = new Promise(function (resolve) {
  6443. transformStream._backpressureChangePromise_resolve = resolve;
  6444. });
  6445. transformStream._backpressureChangePromise.then(function (resolution) {
  6446. assert(resolution !== backpressure, '_backpressureChangePromise should be fulfilled only when backpressure is changed');
  6447. });
  6448. transformStream._backpressure = backpressure;
  6449. }
  6450. function TransformStreamDefaultTransform(chunk, transformStreamController) {
  6451. var transformStream = transformStreamController._controlledTransformStream;
  6452. TransformStreamEnqueueToReadable(transformStream, chunk);
  6453. return Promise.resolve();
  6454. }
  6455. function TransformStreamTransform(transformStream, chunk) {
  6456. assert(transformStream._errored === false);
  6457. assert(transformStream._transforming === false);
  6458. assert(transformStream._backpressure === false);
  6459. transformStream._transforming = true;
  6460. var transformer = transformStream._transformer;
  6461. var controller = transformStream._transformStreamController;
  6462. var transformPromise = PromiseInvokeOrPerformFallback(transformer, 'transform', [chunk, controller], TransformStreamDefaultTransform, [chunk, controller]);
  6463. return transformPromise.then(function () {
  6464. transformStream._transforming = false;
  6465. return TransformStreamReadableReadyPromise(transformStream);
  6466. }, function (e) {
  6467. TransformStreamErrorIfNeeded(transformStream, e);
  6468. return Promise.reject(e);
  6469. });
  6470. }
  6471. function IsTransformStreamDefaultController(x) {
  6472. if (!typeIsObject(x)) {
  6473. return false;
  6474. }
  6475. if (!Object.prototype.hasOwnProperty.call(x, '_controlledTransformStream')) {
  6476. return false;
  6477. }
  6478. return true;
  6479. }
  6480. function IsTransformStream(x) {
  6481. if (!typeIsObject(x)) {
  6482. return false;
  6483. }
  6484. if (!Object.prototype.hasOwnProperty.call(x, '_transformStreamController')) {
  6485. return false;
  6486. }
  6487. return true;
  6488. }
  6489. var TransformStreamSink = function () {
  6490. function TransformStreamSink(transformStream, startPromise) {
  6491. _classCallCheck(this, TransformStreamSink);
  6492. this._transformStream = transformStream;
  6493. this._startPromise = startPromise;
  6494. }
  6495. _createClass(TransformStreamSink, [{
  6496. key: 'start',
  6497. value: function start(c) {
  6498. var transformStream = this._transformStream;
  6499. transformStream._writableController = c;
  6500. return this._startPromise.then(function () {
  6501. return TransformStreamReadableReadyPromise(transformStream);
  6502. });
  6503. }
  6504. }, {
  6505. key: 'write',
  6506. value: function write(chunk) {
  6507. var transformStream = this._transformStream;
  6508. return TransformStreamTransform(transformStream, chunk);
  6509. }
  6510. }, {
  6511. key: 'abort',
  6512. value: function abort() {
  6513. var transformStream = this._transformStream;
  6514. transformStream._writableDone = true;
  6515. TransformStreamErrorInternal(transformStream, new TypeError('Writable side aborted'));
  6516. }
  6517. }, {
  6518. key: 'close',
  6519. value: function close() {
  6520. var transformStream = this._transformStream;
  6521. assert(transformStream._transforming === false);
  6522. transformStream._writableDone = true;
  6523. var flushPromise = PromiseInvokeOrNoop(transformStream._transformer, 'flush', [transformStream._transformStreamController]);
  6524. return flushPromise.then(function () {
  6525. if (transformStream._errored === true) {
  6526. return Promise.reject(transformStream._storedError);
  6527. }
  6528. if (transformStream._readableClosed === false) {
  6529. TransformStreamCloseReadableInternal(transformStream);
  6530. }
  6531. return Promise.resolve();
  6532. }).catch(function (r) {
  6533. TransformStreamErrorIfNeeded(transformStream, r);
  6534. return Promise.reject(transformStream._storedError);
  6535. });
  6536. }
  6537. }]);
  6538. return TransformStreamSink;
  6539. }();
  6540. var TransformStreamSource = function () {
  6541. function TransformStreamSource(transformStream, startPromise) {
  6542. _classCallCheck(this, TransformStreamSource);
  6543. this._transformStream = transformStream;
  6544. this._startPromise = startPromise;
  6545. }
  6546. _createClass(TransformStreamSource, [{
  6547. key: 'start',
  6548. value: function start(c) {
  6549. var transformStream = this._transformStream;
  6550. transformStream._readableController = c;
  6551. return this._startPromise.then(function () {
  6552. assert(transformStream._backpressureChangePromise !== undefined, '_backpressureChangePromise should have been initialized');
  6553. if (transformStream._backpressure === true) {
  6554. return Promise.resolve();
  6555. }
  6556. assert(transformStream._backpressure === false, '_backpressure should have been initialized');
  6557. return transformStream._backpressureChangePromise;
  6558. });
  6559. }
  6560. }, {
  6561. key: 'pull',
  6562. value: function pull() {
  6563. var transformStream = this._transformStream;
  6564. assert(transformStream._backpressure === true, 'pull() should be never called while _backpressure is false');
  6565. assert(transformStream._backpressureChangePromise !== undefined, '_backpressureChangePromise should have been initialized');
  6566. TransformStreamSetBackpressure(transformStream, false);
  6567. return transformStream._backpressureChangePromise;
  6568. }
  6569. }, {
  6570. key: 'cancel',
  6571. value: function cancel() {
  6572. var transformStream = this._transformStream;
  6573. transformStream._readableClosed = true;
  6574. TransformStreamErrorInternal(transformStream, new TypeError('Readable side canceled'));
  6575. }
  6576. }]);
  6577. return TransformStreamSource;
  6578. }();
  6579. var TransformStreamDefaultController = function () {
  6580. function TransformStreamDefaultController(transformStream) {
  6581. _classCallCheck(this, TransformStreamDefaultController);
  6582. if (IsTransformStream(transformStream) === false) {
  6583. throw new TypeError('TransformStreamDefaultController can only be ' + 'constructed with a TransformStream instance');
  6584. }
  6585. if (transformStream._transformStreamController !== undefined) {
  6586. throw new TypeError('TransformStreamDefaultController instances can ' + 'only be created by the TransformStream constructor');
  6587. }
  6588. this._controlledTransformStream = transformStream;
  6589. }
  6590. _createClass(TransformStreamDefaultController, [{
  6591. key: 'enqueue',
  6592. value: function enqueue(chunk) {
  6593. if (IsTransformStreamDefaultController(this) === false) {
  6594. throw defaultControllerBrandCheckException('enqueue');
  6595. }
  6596. TransformStreamEnqueueToReadable(this._controlledTransformStream, chunk);
  6597. }
  6598. }, {
  6599. key: 'close',
  6600. value: function close() {
  6601. if (IsTransformStreamDefaultController(this) === false) {
  6602. throw defaultControllerBrandCheckException('close');
  6603. }
  6604. TransformStreamCloseReadable(this._controlledTransformStream);
  6605. }
  6606. }, {
  6607. key: 'error',
  6608. value: function error(reason) {
  6609. if (IsTransformStreamDefaultController(this) === false) {
  6610. throw defaultControllerBrandCheckException('error');
  6611. }
  6612. TransformStreamError(this._controlledTransformStream, reason);
  6613. }
  6614. }, {
  6615. key: 'desiredSize',
  6616. get: function get() {
  6617. if (IsTransformStreamDefaultController(this) === false) {
  6618. throw defaultControllerBrandCheckException('desiredSize');
  6619. }
  6620. var transformStream = this._controlledTransformStream;
  6621. var readableController = transformStream._readableController;
  6622. return ReadableStreamDefaultControllerGetDesiredSize(readableController);
  6623. }
  6624. }]);
  6625. return TransformStreamDefaultController;
  6626. }();
  6627. var TransformStream = function () {
  6628. function TransformStream() {
  6629. var transformer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  6630. _classCallCheck(this, TransformStream);
  6631. this._transformer = transformer;
  6632. var readableStrategy = transformer.readableStrategy,
  6633. writableStrategy = transformer.writableStrategy;
  6634. this._transforming = false;
  6635. this._errored = false;
  6636. this._storedError = undefined;
  6637. this._writableController = undefined;
  6638. this._readableController = undefined;
  6639. this._transformStreamController = undefined;
  6640. this._writableDone = false;
  6641. this._readableClosed = false;
  6642. this._backpressure = undefined;
  6643. this._backpressureChangePromise = undefined;
  6644. this._backpressureChangePromise_resolve = undefined;
  6645. this._transformStreamController = new TransformStreamDefaultController(this);
  6646. var startPromise_resolve = void 0;
  6647. var startPromise = new Promise(function (resolve) {
  6648. startPromise_resolve = resolve;
  6649. });
  6650. var source = new TransformStreamSource(this, startPromise);
  6651. this._readable = new ReadableStream(source, readableStrategy);
  6652. var sink = new TransformStreamSink(this, startPromise);
  6653. this._writable = new WritableStream(sink, writableStrategy);
  6654. assert(this._writableController !== undefined);
  6655. assert(this._readableController !== undefined);
  6656. var desiredSize = ReadableStreamDefaultControllerGetDesiredSize(this._readableController);
  6657. TransformStreamSetBackpressure(this, desiredSize <= 0);
  6658. var transformStream = this;
  6659. var startResult = InvokeOrNoop(transformer, 'start', [transformStream._transformStreamController]);
  6660. startPromise_resolve(startResult);
  6661. startPromise.catch(function (e) {
  6662. if (transformStream._errored === false) {
  6663. transformStream._errored = true;
  6664. transformStream._storedError = e;
  6665. }
  6666. });
  6667. }
  6668. _createClass(TransformStream, [{
  6669. key: 'readable',
  6670. get: function get() {
  6671. if (IsTransformStream(this) === false) {
  6672. throw streamBrandCheckException('readable');
  6673. }
  6674. return this._readable;
  6675. }
  6676. }, {
  6677. key: 'writable',
  6678. get: function get() {
  6679. if (IsTransformStream(this) === false) {
  6680. throw streamBrandCheckException('writable');
  6681. }
  6682. return this._writable;
  6683. }
  6684. }]);
  6685. return TransformStream;
  6686. }();
  6687. module.exports = { TransformStream: TransformStream };
  6688. function defaultControllerBrandCheckException(name) {
  6689. return new TypeError('TransformStreamDefaultController.prototype.' + name + ' can only be used on a TransformStreamDefaultController');
  6690. }
  6691. function streamBrandCheckException(name) {
  6692. return new TypeError('TransformStream.prototype.' + name + ' can only be used on a TransformStream');
  6693. }
  6694. }, function (module, exports, __w_pdfjs_require__) {
  6695. module.exports = __w_pdfjs_require__(5);
  6696. }]));
  6697. /***/ }),
  6698. /* 127 */
  6699. /***/ (function(module, exports, __w_pdfjs_require__) {
  6700. "use strict";
  6701. 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; };
  6702. {
  6703. var isURLSupported = false;
  6704. try {
  6705. if (typeof URL === 'function' && _typeof(URL.prototype) === 'object' && 'origin' in URL.prototype) {
  6706. var u = new URL('b', 'http://a');
  6707. u.pathname = 'c%20d';
  6708. isURLSupported = u.href === 'http://a/c%20d';
  6709. }
  6710. } catch (ex) {}
  6711. if (isURLSupported) {
  6712. exports.URL = URL;
  6713. } else {
  6714. var PolyfillURL = __w_pdfjs_require__(128).URL;
  6715. var OriginalURL = __w_pdfjs_require__(3).URL;
  6716. if (OriginalURL) {
  6717. PolyfillURL.createObjectURL = function (blob) {
  6718. return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
  6719. };
  6720. PolyfillURL.revokeObjectURL = function (url) {
  6721. OriginalURL.revokeObjectURL(url);
  6722. };
  6723. }
  6724. exports.URL = PolyfillURL;
  6725. }
  6726. }
  6727. /***/ }),
  6728. /* 128 */
  6729. /***/ (function(module, exports, __w_pdfjs_require__) {
  6730. "use strict";
  6731. (function URLConstructorClosure() {
  6732. 'use strict';
  6733. var relative = Object.create(null);
  6734. relative['ftp'] = 21;
  6735. relative['file'] = 0;
  6736. relative['gopher'] = 70;
  6737. relative['http'] = 80;
  6738. relative['https'] = 443;
  6739. relative['ws'] = 80;
  6740. relative['wss'] = 443;
  6741. var relativePathDotMapping = Object.create(null);
  6742. relativePathDotMapping['%2e'] = '.';
  6743. relativePathDotMapping['.%2e'] = '..';
  6744. relativePathDotMapping['%2e.'] = '..';
  6745. relativePathDotMapping['%2e%2e'] = '..';
  6746. function isRelativeScheme(scheme) {
  6747. return relative[scheme] !== undefined;
  6748. }
  6749. function invalid() {
  6750. clear.call(this);
  6751. this._isInvalid = true;
  6752. }
  6753. function IDNAToASCII(h) {
  6754. if (h === '') {
  6755. invalid.call(this);
  6756. }
  6757. return h.toLowerCase();
  6758. }
  6759. function percentEscape(c) {
  6760. var unicode = c.charCodeAt(0);
  6761. if (unicode > 0x20 && unicode < 0x7F && [0x22, 0x23, 0x3C, 0x3E, 0x3F, 0x60].indexOf(unicode) === -1) {
  6762. return c;
  6763. }
  6764. return encodeURIComponent(c);
  6765. }
  6766. function percentEscapeQuery(c) {
  6767. var unicode = c.charCodeAt(0);
  6768. if (unicode > 0x20 && unicode < 0x7F && [0x22, 0x23, 0x3C, 0x3E, 0x60].indexOf(unicode) === -1) {
  6769. return c;
  6770. }
  6771. return encodeURIComponent(c);
  6772. }
  6773. var EOF,
  6774. ALPHA = /[a-zA-Z]/,
  6775. ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/;
  6776. function parse(input, stateOverride, base) {
  6777. function err(message) {
  6778. errors.push(message);
  6779. }
  6780. var state = stateOverride || 'scheme start',
  6781. cursor = 0,
  6782. buffer = '',
  6783. seenAt = false,
  6784. seenBracket = false,
  6785. errors = [];
  6786. loop: while ((input[cursor - 1] !== EOF || cursor === 0) && !this._isInvalid) {
  6787. var c = input[cursor];
  6788. switch (state) {
  6789. case 'scheme start':
  6790. if (c && ALPHA.test(c)) {
  6791. buffer += c.toLowerCase();
  6792. state = 'scheme';
  6793. } else if (!stateOverride) {
  6794. buffer = '';
  6795. state = 'no scheme';
  6796. continue;
  6797. } else {
  6798. err('Invalid scheme.');
  6799. break loop;
  6800. }
  6801. break;
  6802. case 'scheme':
  6803. if (c && ALPHANUMERIC.test(c)) {
  6804. buffer += c.toLowerCase();
  6805. } else if (c === ':') {
  6806. this._scheme = buffer;
  6807. buffer = '';
  6808. if (stateOverride) {
  6809. break loop;
  6810. }
  6811. if (isRelativeScheme(this._scheme)) {
  6812. this._isRelative = true;
  6813. }
  6814. if (this._scheme === 'file') {
  6815. state = 'relative';
  6816. } else if (this._isRelative && base && base._scheme === this._scheme) {
  6817. state = 'relative or authority';
  6818. } else if (this._isRelative) {
  6819. state = 'authority first slash';
  6820. } else {
  6821. state = 'scheme data';
  6822. }
  6823. } else if (!stateOverride) {
  6824. buffer = '';
  6825. cursor = 0;
  6826. state = 'no scheme';
  6827. continue;
  6828. } else if (c === EOF) {
  6829. break loop;
  6830. } else {
  6831. err('Code point not allowed in scheme: ' + c);
  6832. break loop;
  6833. }
  6834. break;
  6835. case 'scheme data':
  6836. if (c === '?') {
  6837. this._query = '?';
  6838. state = 'query';
  6839. } else if (c === '#') {
  6840. this._fragment = '#';
  6841. state = 'fragment';
  6842. } else {
  6843. if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') {
  6844. this._schemeData += percentEscape(c);
  6845. }
  6846. }
  6847. break;
  6848. case 'no scheme':
  6849. if (!base || !isRelativeScheme(base._scheme)) {
  6850. err('Missing scheme.');
  6851. invalid.call(this);
  6852. } else {
  6853. state = 'relative';
  6854. continue;
  6855. }
  6856. break;
  6857. case 'relative or authority':
  6858. if (c === '/' && input[cursor + 1] === '/') {
  6859. state = 'authority ignore slashes';
  6860. } else {
  6861. err('Expected /, got: ' + c);
  6862. state = 'relative';
  6863. continue;
  6864. }
  6865. break;
  6866. case 'relative':
  6867. this._isRelative = true;
  6868. if (this._scheme !== 'file') {
  6869. this._scheme = base._scheme;
  6870. }
  6871. if (c === EOF) {
  6872. this._host = base._host;
  6873. this._port = base._port;
  6874. this._path = base._path.slice();
  6875. this._query = base._query;
  6876. this._username = base._username;
  6877. this._password = base._password;
  6878. break loop;
  6879. } else if (c === '/' || c === '\\') {
  6880. if (c === '\\') {
  6881. err('\\ is an invalid code point.');
  6882. }
  6883. state = 'relative slash';
  6884. } else if (c === '?') {
  6885. this._host = base._host;
  6886. this._port = base._port;
  6887. this._path = base._path.slice();
  6888. this._query = '?';
  6889. this._username = base._username;
  6890. this._password = base._password;
  6891. state = 'query';
  6892. } else if (c === '#') {
  6893. this._host = base._host;
  6894. this._port = base._port;
  6895. this._path = base._path.slice();
  6896. this._query = base._query;
  6897. this._fragment = '#';
  6898. this._username = base._username;
  6899. this._password = base._password;
  6900. state = 'fragment';
  6901. } else {
  6902. var nextC = input[cursor + 1];
  6903. var nextNextC = input[cursor + 2];
  6904. if (this._scheme !== 'file' || !ALPHA.test(c) || nextC !== ':' && nextC !== '|' || nextNextC !== EOF && nextNextC !== '/' && nextNextC !== '\\' && nextNextC !== '?' && nextNextC !== '#') {
  6905. this._host = base._host;
  6906. this._port = base._port;
  6907. this._username = base._username;
  6908. this._password = base._password;
  6909. this._path = base._path.slice();
  6910. this._path.pop();
  6911. }
  6912. state = 'relative path';
  6913. continue;
  6914. }
  6915. break;
  6916. case 'relative slash':
  6917. if (c === '/' || c === '\\') {
  6918. if (c === '\\') {
  6919. err('\\ is an invalid code point.');
  6920. }
  6921. if (this._scheme === 'file') {
  6922. state = 'file host';
  6923. } else {
  6924. state = 'authority ignore slashes';
  6925. }
  6926. } else {
  6927. if (this._scheme !== 'file') {
  6928. this._host = base._host;
  6929. this._port = base._port;
  6930. this._username = base._username;
  6931. this._password = base._password;
  6932. }
  6933. state = 'relative path';
  6934. continue;
  6935. }
  6936. break;
  6937. case 'authority first slash':
  6938. if (c === '/') {
  6939. state = 'authority second slash';
  6940. } else {
  6941. err('Expected \'/\', got: ' + c);
  6942. state = 'authority ignore slashes';
  6943. continue;
  6944. }
  6945. break;
  6946. case 'authority second slash':
  6947. state = 'authority ignore slashes';
  6948. if (c !== '/') {
  6949. err('Expected \'/\', got: ' + c);
  6950. continue;
  6951. }
  6952. break;
  6953. case 'authority ignore slashes':
  6954. if (c !== '/' && c !== '\\') {
  6955. state = 'authority';
  6956. continue;
  6957. } else {
  6958. err('Expected authority, got: ' + c);
  6959. }
  6960. break;
  6961. case 'authority':
  6962. if (c === '@') {
  6963. if (seenAt) {
  6964. err('@ already seen.');
  6965. buffer += '%40';
  6966. }
  6967. seenAt = true;
  6968. for (var i = 0; i < buffer.length; i++) {
  6969. var cp = buffer[i];
  6970. if (cp === '\t' || cp === '\n' || cp === '\r') {
  6971. err('Invalid whitespace in authority.');
  6972. continue;
  6973. }
  6974. if (cp === ':' && this._password === null) {
  6975. this._password = '';
  6976. continue;
  6977. }
  6978. var tempC = percentEscape(cp);
  6979. if (this._password !== null) {
  6980. this._password += tempC;
  6981. } else {
  6982. this._username += tempC;
  6983. }
  6984. }
  6985. buffer = '';
  6986. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  6987. cursor -= buffer.length;
  6988. buffer = '';
  6989. state = 'host';
  6990. continue;
  6991. } else {
  6992. buffer += c;
  6993. }
  6994. break;
  6995. case 'file host':
  6996. if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  6997. if (buffer.length === 2 && ALPHA.test(buffer[0]) && (buffer[1] === ':' || buffer[1] === '|')) {
  6998. state = 'relative path';
  6999. } else if (buffer.length === 0) {
  7000. state = 'relative path start';
  7001. } else {
  7002. this._host = IDNAToASCII.call(this, buffer);
  7003. buffer = '';
  7004. state = 'relative path start';
  7005. }
  7006. continue;
  7007. } else if (c === '\t' || c === '\n' || c === '\r') {
  7008. err('Invalid whitespace in file host.');
  7009. } else {
  7010. buffer += c;
  7011. }
  7012. break;
  7013. case 'host':
  7014. case 'hostname':
  7015. if (c === ':' && !seenBracket) {
  7016. this._host = IDNAToASCII.call(this, buffer);
  7017. buffer = '';
  7018. state = 'port';
  7019. if (stateOverride === 'hostname') {
  7020. break loop;
  7021. }
  7022. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  7023. this._host = IDNAToASCII.call(this, buffer);
  7024. buffer = '';
  7025. state = 'relative path start';
  7026. if (stateOverride) {
  7027. break loop;
  7028. }
  7029. continue;
  7030. } else if (c !== '\t' && c !== '\n' && c !== '\r') {
  7031. if (c === '[') {
  7032. seenBracket = true;
  7033. } else if (c === ']') {
  7034. seenBracket = false;
  7035. }
  7036. buffer += c;
  7037. } else {
  7038. err('Invalid code point in host/hostname: ' + c);
  7039. }
  7040. break;
  7041. case 'port':
  7042. if (/[0-9]/.test(c)) {
  7043. buffer += c;
  7044. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#' || stateOverride) {
  7045. if (buffer !== '') {
  7046. var temp = parseInt(buffer, 10);
  7047. if (temp !== relative[this._scheme]) {
  7048. this._port = temp + '';
  7049. }
  7050. buffer = '';
  7051. }
  7052. if (stateOverride) {
  7053. break loop;
  7054. }
  7055. state = 'relative path start';
  7056. continue;
  7057. } else if (c === '\t' || c === '\n' || c === '\r') {
  7058. err('Invalid code point in port: ' + c);
  7059. } else {
  7060. invalid.call(this);
  7061. }
  7062. break;
  7063. case 'relative path start':
  7064. if (c === '\\') {
  7065. err('\'\\\' not allowed in path.');
  7066. }
  7067. state = 'relative path';
  7068. if (c !== '/' && c !== '\\') {
  7069. continue;
  7070. }
  7071. break;
  7072. case 'relative path':
  7073. if (c === EOF || c === '/' || c === '\\' || !stateOverride && (c === '?' || c === '#')) {
  7074. if (c === '\\') {
  7075. err('\\ not allowed in relative path.');
  7076. }
  7077. var tmp;
  7078. if (tmp = relativePathDotMapping[buffer.toLowerCase()]) {
  7079. buffer = tmp;
  7080. }
  7081. if (buffer === '..') {
  7082. this._path.pop();
  7083. if (c !== '/' && c !== '\\') {
  7084. this._path.push('');
  7085. }
  7086. } else if (buffer === '.' && c !== '/' && c !== '\\') {
  7087. this._path.push('');
  7088. } else if (buffer !== '.') {
  7089. if (this._scheme === 'file' && this._path.length === 0 && buffer.length === 2 && ALPHA.test(buffer[0]) && buffer[1] === '|') {
  7090. buffer = buffer[0] + ':';
  7091. }
  7092. this._path.push(buffer);
  7093. }
  7094. buffer = '';
  7095. if (c === '?') {
  7096. this._query = '?';
  7097. state = 'query';
  7098. } else if (c === '#') {
  7099. this._fragment = '#';
  7100. state = 'fragment';
  7101. }
  7102. } else if (c !== '\t' && c !== '\n' && c !== '\r') {
  7103. buffer += percentEscape(c);
  7104. }
  7105. break;
  7106. case 'query':
  7107. if (!stateOverride && c === '#') {
  7108. this._fragment = '#';
  7109. state = 'fragment';
  7110. } else if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') {
  7111. this._query += percentEscapeQuery(c);
  7112. }
  7113. break;
  7114. case 'fragment':
  7115. if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') {
  7116. this._fragment += c;
  7117. }
  7118. break;
  7119. }
  7120. cursor++;
  7121. }
  7122. }
  7123. function clear() {
  7124. this._scheme = '';
  7125. this._schemeData = '';
  7126. this._username = '';
  7127. this._password = null;
  7128. this._host = '';
  7129. this._port = '';
  7130. this._path = [];
  7131. this._query = '';
  7132. this._fragment = '';
  7133. this._isInvalid = false;
  7134. this._isRelative = false;
  7135. }
  7136. function JURL(url, base) {
  7137. if (base !== undefined && !(base instanceof JURL)) {
  7138. base = new JURL(String(base));
  7139. }
  7140. this._url = url;
  7141. clear.call(this);
  7142. var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, '');
  7143. parse.call(this, input, null, base);
  7144. }
  7145. JURL.prototype = {
  7146. toString: function toString() {
  7147. return this.href;
  7148. },
  7149. get href() {
  7150. if (this._isInvalid) {
  7151. return this._url;
  7152. }
  7153. var authority = '';
  7154. if (this._username !== '' || this._password !== null) {
  7155. authority = this._username + (this._password !== null ? ':' + this._password : '') + '@';
  7156. }
  7157. return this.protocol + (this._isRelative ? '//' + authority + this.host : '') + this.pathname + this._query + this._fragment;
  7158. },
  7159. set href(value) {
  7160. clear.call(this);
  7161. parse.call(this, value);
  7162. },
  7163. get protocol() {
  7164. return this._scheme + ':';
  7165. },
  7166. set protocol(value) {
  7167. if (this._isInvalid) {
  7168. return;
  7169. }
  7170. parse.call(this, value + ':', 'scheme start');
  7171. },
  7172. get host() {
  7173. return this._isInvalid ? '' : this._port ? this._host + ':' + this._port : this._host;
  7174. },
  7175. set host(value) {
  7176. if (this._isInvalid || !this._isRelative) {
  7177. return;
  7178. }
  7179. parse.call(this, value, 'host');
  7180. },
  7181. get hostname() {
  7182. return this._host;
  7183. },
  7184. set hostname(value) {
  7185. if (this._isInvalid || !this._isRelative) {
  7186. return;
  7187. }
  7188. parse.call(this, value, 'hostname');
  7189. },
  7190. get port() {
  7191. return this._port;
  7192. },
  7193. set port(value) {
  7194. if (this._isInvalid || !this._isRelative) {
  7195. return;
  7196. }
  7197. parse.call(this, value, 'port');
  7198. },
  7199. get pathname() {
  7200. return this._isInvalid ? '' : this._isRelative ? '/' + this._path.join('/') : this._schemeData;
  7201. },
  7202. set pathname(value) {
  7203. if (this._isInvalid || !this._isRelative) {
  7204. return;
  7205. }
  7206. this._path = [];
  7207. parse.call(this, value, 'relative path start');
  7208. },
  7209. get search() {
  7210. return this._isInvalid || !this._query || this._query === '?' ? '' : this._query;
  7211. },
  7212. set search(value) {
  7213. if (this._isInvalid || !this._isRelative) {
  7214. return;
  7215. }
  7216. this._query = '?';
  7217. if (value[0] === '?') {
  7218. value = value.slice(1);
  7219. }
  7220. parse.call(this, value, 'query');
  7221. },
  7222. get hash() {
  7223. return this._isInvalid || !this._fragment || this._fragment === '#' ? '' : this._fragment;
  7224. },
  7225. set hash(value) {
  7226. if (this._isInvalid) {
  7227. return;
  7228. }
  7229. this._fragment = '#';
  7230. if (value[0] === '#') {
  7231. value = value.slice(1);
  7232. }
  7233. parse.call(this, value, 'fragment');
  7234. },
  7235. get origin() {
  7236. var host;
  7237. if (this._isInvalid || !this._scheme) {
  7238. return '';
  7239. }
  7240. switch (this._scheme) {
  7241. case 'data':
  7242. case 'file':
  7243. case 'javascript':
  7244. case 'mailto':
  7245. return 'null';
  7246. case 'blob':
  7247. try {
  7248. return new JURL(this._schemeData).origin || 'null';
  7249. } catch (_) {}
  7250. return 'null';
  7251. }
  7252. host = this.host;
  7253. if (!host) {
  7254. return '';
  7255. }
  7256. return this._scheme + '://' + host;
  7257. }
  7258. };
  7259. exports.URL = JURL;
  7260. })();
  7261. /***/ }),
  7262. /* 129 */
  7263. /***/ (function(module, exports, __w_pdfjs_require__) {
  7264. "use strict";
  7265. Object.defineProperty(exports, "__esModule", {
  7266. value: true
  7267. });
  7268. exports.build = exports.version = exports.setPDFNetworkStreamFactory = exports.PDFPageProxy = exports.PDFDocumentProxy = exports.PDFWorker = exports.PDFDataRangeTransport = exports.LoopbackPort = exports.getDocument = undefined;
  7269. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  7270. 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; }; }();
  7271. 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; };
  7272. var _util = __w_pdfjs_require__(1);
  7273. var _dom_utils = __w_pdfjs_require__(130);
  7274. var _font_loader = __w_pdfjs_require__(131);
  7275. var _api_compatibility = __w_pdfjs_require__(132);
  7276. var _canvas = __w_pdfjs_require__(133);
  7277. var _global_scope = __w_pdfjs_require__(3);
  7278. var _global_scope2 = _interopRequireDefault(_global_scope);
  7279. var _worker_options = __w_pdfjs_require__(135);
  7280. var _message_handler = __w_pdfjs_require__(136);
  7281. var _metadata = __w_pdfjs_require__(141);
  7282. var _transport_stream = __w_pdfjs_require__(143);
  7283. var _webgl = __w_pdfjs_require__(144);
  7284. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7285. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  7286. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7287. var DEFAULT_RANGE_CHUNK_SIZE = 65536;
  7288. var isWorkerDisabled = false;
  7289. var fallbackWorkerSrc = void 0;
  7290. var fakeWorkerFilesLoader = null;
  7291. {
  7292. var useRequireEnsure = false;
  7293. if (typeof window === 'undefined') {
  7294. isWorkerDisabled = true;
  7295. if (typeof require.ensure === 'undefined') {
  7296. require.ensure = require('node-ensure');
  7297. }
  7298. useRequireEnsure = true;
  7299. } else if (typeof require !== 'undefined' && typeof require.ensure === 'function') {
  7300. useRequireEnsure = true;
  7301. }
  7302. if (typeof requirejs !== 'undefined' && requirejs.toUrl) {
  7303. fallbackWorkerSrc = requirejs.toUrl('pdfjs-dist/build/pdf.worker.js');
  7304. }
  7305. var dynamicLoaderSupported = typeof requirejs !== 'undefined' && requirejs.load;
  7306. fakeWorkerFilesLoader = useRequireEnsure ? function () {
  7307. return new Promise(function (resolve, reject) {
  7308. require.ensure([], function () {
  7309. try {
  7310. var worker = void 0;
  7311. worker = require('./pdf.worker.js');
  7312. resolve(worker.WorkerMessageHandler);
  7313. } catch (ex) {
  7314. reject(ex);
  7315. }
  7316. }, reject, 'pdfjsWorker');
  7317. });
  7318. } : dynamicLoaderSupported ? function () {
  7319. return new Promise(function (resolve, reject) {
  7320. requirejs(['pdfjs-dist/build/pdf.worker'], function (worker) {
  7321. try {
  7322. resolve(worker.WorkerMessageHandler);
  7323. } catch (ex) {
  7324. reject(ex);
  7325. }
  7326. }, reject);
  7327. });
  7328. } : null;
  7329. if (!fallbackWorkerSrc && typeof document !== 'undefined') {
  7330. var pdfjsFilePath = document.currentScript && document.currentScript.src;
  7331. if (pdfjsFilePath) {
  7332. fallbackWorkerSrc = pdfjsFilePath.replace(/(\.(?:min\.)?js)(\?.*)?$/i, '.worker$1$2');
  7333. }
  7334. }
  7335. }
  7336. var createPDFNetworkStream;
  7337. function setPDFNetworkStreamFactory(pdfNetworkStreamFactory) {
  7338. createPDFNetworkStream = pdfNetworkStreamFactory;
  7339. }
  7340. function getDocument(src) {
  7341. var task = new PDFDocumentLoadingTask();
  7342. var source;
  7343. if (typeof src === 'string') {
  7344. source = { url: src };
  7345. } else if ((0, _util.isArrayBuffer)(src)) {
  7346. source = { data: src };
  7347. } else if (src instanceof PDFDataRangeTransport) {
  7348. source = { range: src };
  7349. } else {
  7350. if ((typeof src === 'undefined' ? 'undefined' : _typeof(src)) !== 'object') {
  7351. throw new Error('Invalid parameter in getDocument, ' + 'need either Uint8Array, string or a parameter object');
  7352. }
  7353. if (!src.url && !src.data && !src.range) {
  7354. throw new Error('Invalid parameter object: need either .data, .range or .url');
  7355. }
  7356. source = src;
  7357. }
  7358. var params = Object.create(null);
  7359. var rangeTransport = null;
  7360. var worker = null;
  7361. for (var key in source) {
  7362. if (key === 'url' && typeof window !== 'undefined') {
  7363. params[key] = new _util.URL(source[key], window.location).href;
  7364. continue;
  7365. } else if (key === 'range') {
  7366. rangeTransport = source[key];
  7367. continue;
  7368. } else if (key === 'worker') {
  7369. worker = source[key];
  7370. continue;
  7371. } else if (key === 'data' && !(source[key] instanceof Uint8Array)) {
  7372. var pdfBytes = source[key];
  7373. if (typeof pdfBytes === 'string') {
  7374. params[key] = (0, _util.stringToBytes)(pdfBytes);
  7375. } else if ((typeof pdfBytes === 'undefined' ? 'undefined' : _typeof(pdfBytes)) === 'object' && pdfBytes !== null && !isNaN(pdfBytes.length)) {
  7376. params[key] = new Uint8Array(pdfBytes);
  7377. } else if ((0, _util.isArrayBuffer)(pdfBytes)) {
  7378. params[key] = new Uint8Array(pdfBytes);
  7379. } else {
  7380. throw new Error('Invalid PDF binary data: either typed array, ' + 'string or array-like object is expected in the ' + 'data property.');
  7381. }
  7382. continue;
  7383. }
  7384. params[key] = source[key];
  7385. }
  7386. params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
  7387. params.CMapReaderFactory = params.CMapReaderFactory || _dom_utils.DOMCMapReaderFactory;
  7388. params.ignoreErrors = params.stopAtErrors !== true;
  7389. params.pdfBug = params.pdfBug === true;
  7390. var NativeImageDecoderValues = Object.values(_util.NativeImageDecoding);
  7391. if (params.nativeImageDecoderSupport === undefined || !NativeImageDecoderValues.includes(params.nativeImageDecoderSupport)) {
  7392. params.nativeImageDecoderSupport = _api_compatibility.apiCompatibilityParams.nativeImageDecoderSupport || _util.NativeImageDecoding.DECODE;
  7393. }
  7394. if (!Number.isInteger(params.maxImageSize)) {
  7395. params.maxImageSize = -1;
  7396. }
  7397. if (typeof params.isEvalSupported !== 'boolean') {
  7398. params.isEvalSupported = true;
  7399. }
  7400. if (typeof params.disableFontFace !== 'boolean') {
  7401. params.disableFontFace = _api_compatibility.apiCompatibilityParams.disableFontFace || false;
  7402. }
  7403. if (typeof params.disableRange !== 'boolean') {
  7404. params.disableRange = false;
  7405. }
  7406. if (typeof params.disableStream !== 'boolean') {
  7407. params.disableStream = false;
  7408. }
  7409. if (typeof params.disableAutoFetch !== 'boolean') {
  7410. params.disableAutoFetch = false;
  7411. }
  7412. if (typeof params.disableCreateObjectURL !== 'boolean') {
  7413. params.disableCreateObjectURL = _api_compatibility.apiCompatibilityParams.disableCreateObjectURL || false;
  7414. }
  7415. (0, _util.setVerbosityLevel)(params.verbosity);
  7416. if (!worker) {
  7417. var workerParams = {
  7418. postMessageTransfers: params.postMessageTransfers,
  7419. verbosity: params.verbosity
  7420. };
  7421. var workerPort = _worker_options.GlobalWorkerOptions.workerPort;
  7422. if (workerPort) {
  7423. workerParams.port = workerPort;
  7424. worker = PDFWorker.fromPort(workerParams);
  7425. } else {
  7426. worker = new PDFWorker(workerParams);
  7427. }
  7428. task._worker = worker;
  7429. }
  7430. var docId = task.docId;
  7431. worker.promise.then(function () {
  7432. if (task.destroyed) {
  7433. throw new Error('Loading aborted');
  7434. }
  7435. return _fetchDocument(worker, params, rangeTransport, docId).then(function (workerId) {
  7436. if (task.destroyed) {
  7437. throw new Error('Loading aborted');
  7438. }
  7439. var networkStream = void 0;
  7440. if (rangeTransport) {
  7441. networkStream = new _transport_stream.PDFDataTransportStream({
  7442. length: params.length,
  7443. initialData: params.initialData,
  7444. disableRange: params.disableRange,
  7445. disableStream: params.disableStream
  7446. }, rangeTransport);
  7447. } else if (!params.data) {
  7448. networkStream = createPDFNetworkStream({
  7449. url: params.url,
  7450. length: params.length,
  7451. httpHeaders: params.httpHeaders,
  7452. withCredentials: params.withCredentials,
  7453. rangeChunkSize: params.rangeChunkSize,
  7454. disableRange: params.disableRange,
  7455. disableStream: params.disableStream
  7456. });
  7457. }
  7458. var messageHandler = new _message_handler.MessageHandler(docId, workerId, worker.port);
  7459. messageHandler.postMessageTransfers = worker.postMessageTransfers;
  7460. var transport = new WorkerTransport(messageHandler, task, networkStream, params);
  7461. task._transport = transport;
  7462. messageHandler.send('Ready', null);
  7463. });
  7464. }).catch(task._capability.reject);
  7465. return task;
  7466. }
  7467. function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
  7468. if (worker.destroyed) {
  7469. return Promise.reject(new Error('Worker was destroyed'));
  7470. }
  7471. if (pdfDataRangeTransport) {
  7472. source.length = pdfDataRangeTransport.length;
  7473. source.initialData = pdfDataRangeTransport.initialData;
  7474. }
  7475. return worker.messageHandler.sendWithPromise('GetDocRequest', {
  7476. docId: docId,
  7477. apiVersion: '2.0.943',
  7478. source: {
  7479. data: source.data,
  7480. url: source.url,
  7481. password: source.password,
  7482. disableAutoFetch: source.disableAutoFetch,
  7483. rangeChunkSize: source.rangeChunkSize,
  7484. length: source.length
  7485. },
  7486. maxImageSize: source.maxImageSize,
  7487. disableFontFace: source.disableFontFace,
  7488. disableCreateObjectURL: source.disableCreateObjectURL,
  7489. postMessageTransfers: worker.postMessageTransfers,
  7490. docBaseUrl: source.docBaseUrl,
  7491. nativeImageDecoderSupport: source.nativeImageDecoderSupport,
  7492. ignoreErrors: source.ignoreErrors,
  7493. isEvalSupported: source.isEvalSupported
  7494. }).then(function (workerId) {
  7495. if (worker.destroyed) {
  7496. throw new Error('Worker was destroyed');
  7497. }
  7498. return workerId;
  7499. });
  7500. }
  7501. var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() {
  7502. var nextDocumentId = 0;
  7503. function PDFDocumentLoadingTask() {
  7504. this._capability = (0, _util.createPromiseCapability)();
  7505. this._transport = null;
  7506. this._worker = null;
  7507. this.docId = 'd' + nextDocumentId++;
  7508. this.destroyed = false;
  7509. this.onPassword = null;
  7510. this.onProgress = null;
  7511. this.onUnsupportedFeature = null;
  7512. }
  7513. PDFDocumentLoadingTask.prototype = {
  7514. get promise() {
  7515. return this._capability.promise;
  7516. },
  7517. destroy: function destroy() {
  7518. var _this = this;
  7519. this.destroyed = true;
  7520. var transportDestroyed = !this._transport ? Promise.resolve() : this._transport.destroy();
  7521. return transportDestroyed.then(function () {
  7522. _this._transport = null;
  7523. if (_this._worker) {
  7524. _this._worker.destroy();
  7525. _this._worker = null;
  7526. }
  7527. });
  7528. },
  7529. then: function PDFDocumentLoadingTask_then(onFulfilled, onRejected) {
  7530. return this.promise.then.apply(this.promise, arguments);
  7531. }
  7532. };
  7533. return PDFDocumentLoadingTask;
  7534. }();
  7535. var PDFDataRangeTransport = function () {
  7536. function PDFDataRangeTransport(length, initialData) {
  7537. _classCallCheck(this, PDFDataRangeTransport);
  7538. this.length = length;
  7539. this.initialData = initialData;
  7540. this._rangeListeners = [];
  7541. this._progressListeners = [];
  7542. this._progressiveReadListeners = [];
  7543. this._readyCapability = (0, _util.createPromiseCapability)();
  7544. }
  7545. _createClass(PDFDataRangeTransport, [{
  7546. key: 'addRangeListener',
  7547. value: function addRangeListener(listener) {
  7548. this._rangeListeners.push(listener);
  7549. }
  7550. }, {
  7551. key: 'addProgressListener',
  7552. value: function addProgressListener(listener) {
  7553. this._progressListeners.push(listener);
  7554. }
  7555. }, {
  7556. key: 'addProgressiveReadListener',
  7557. value: function addProgressiveReadListener(listener) {
  7558. this._progressiveReadListeners.push(listener);
  7559. }
  7560. }, {
  7561. key: 'onDataRange',
  7562. value: function onDataRange(begin, chunk) {
  7563. var _iteratorNormalCompletion = true;
  7564. var _didIteratorError = false;
  7565. var _iteratorError = undefined;
  7566. try {
  7567. for (var _iterator = this._rangeListeners[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  7568. var listener = _step.value;
  7569. listener(begin, chunk);
  7570. }
  7571. } catch (err) {
  7572. _didIteratorError = true;
  7573. _iteratorError = err;
  7574. } finally {
  7575. try {
  7576. if (!_iteratorNormalCompletion && _iterator.return) {
  7577. _iterator.return();
  7578. }
  7579. } finally {
  7580. if (_didIteratorError) {
  7581. throw _iteratorError;
  7582. }
  7583. }
  7584. }
  7585. }
  7586. }, {
  7587. key: 'onDataProgress',
  7588. value: function onDataProgress(loaded) {
  7589. var _this2 = this;
  7590. this._readyCapability.promise.then(function () {
  7591. var _iteratorNormalCompletion2 = true;
  7592. var _didIteratorError2 = false;
  7593. var _iteratorError2 = undefined;
  7594. try {
  7595. for (var _iterator2 = _this2._progressListeners[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  7596. var listener = _step2.value;
  7597. listener(loaded);
  7598. }
  7599. } catch (err) {
  7600. _didIteratorError2 = true;
  7601. _iteratorError2 = err;
  7602. } finally {
  7603. try {
  7604. if (!_iteratorNormalCompletion2 && _iterator2.return) {
  7605. _iterator2.return();
  7606. }
  7607. } finally {
  7608. if (_didIteratorError2) {
  7609. throw _iteratorError2;
  7610. }
  7611. }
  7612. }
  7613. });
  7614. }
  7615. }, {
  7616. key: 'onDataProgressiveRead',
  7617. value: function onDataProgressiveRead(chunk) {
  7618. var _this3 = this;
  7619. this._readyCapability.promise.then(function () {
  7620. var _iteratorNormalCompletion3 = true;
  7621. var _didIteratorError3 = false;
  7622. var _iteratorError3 = undefined;
  7623. try {
  7624. for (var _iterator3 = _this3._progressiveReadListeners[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  7625. var listener = _step3.value;
  7626. listener(chunk);
  7627. }
  7628. } catch (err) {
  7629. _didIteratorError3 = true;
  7630. _iteratorError3 = err;
  7631. } finally {
  7632. try {
  7633. if (!_iteratorNormalCompletion3 && _iterator3.return) {
  7634. _iterator3.return();
  7635. }
  7636. } finally {
  7637. if (_didIteratorError3) {
  7638. throw _iteratorError3;
  7639. }
  7640. }
  7641. }
  7642. });
  7643. }
  7644. }, {
  7645. key: 'transportReady',
  7646. value: function transportReady() {
  7647. this._readyCapability.resolve();
  7648. }
  7649. }, {
  7650. key: 'requestDataRange',
  7651. value: function requestDataRange(begin, end) {
  7652. (0, _util.unreachable)('Abstract method PDFDataRangeTransport.requestDataRange');
  7653. }
  7654. }, {
  7655. key: 'abort',
  7656. value: function abort() {}
  7657. }]);
  7658. return PDFDataRangeTransport;
  7659. }();
  7660. var PDFDocumentProxy = function () {
  7661. function PDFDocumentProxy(pdfInfo, transport, loadingTask) {
  7662. _classCallCheck(this, PDFDocumentProxy);
  7663. this.loadingTask = loadingTask;
  7664. this._pdfInfo = pdfInfo;
  7665. this._transport = transport;
  7666. }
  7667. _createClass(PDFDocumentProxy, [{
  7668. key: 'getPage',
  7669. value: function getPage(pageNumber) {
  7670. return this._transport.getPage(pageNumber);
  7671. }
  7672. }, {
  7673. key: 'getPageIndex',
  7674. value: function getPageIndex(ref) {
  7675. return this._transport.getPageIndex(ref);
  7676. }
  7677. }, {
  7678. key: 'getDestinations',
  7679. value: function getDestinations() {
  7680. return this._transport.getDestinations();
  7681. }
  7682. }, {
  7683. key: 'getDestination',
  7684. value: function getDestination(id) {
  7685. return this._transport.getDestination(id);
  7686. }
  7687. }, {
  7688. key: 'getPageLabels',
  7689. value: function getPageLabels() {
  7690. return this._transport.getPageLabels();
  7691. }
  7692. }, {
  7693. key: 'getPageMode',
  7694. value: function getPageMode() {
  7695. return this._transport.getPageMode();
  7696. }
  7697. }, {
  7698. key: 'getAttachments',
  7699. value: function getAttachments() {
  7700. return this._transport.getAttachments();
  7701. }
  7702. }, {
  7703. key: 'getJavaScript',
  7704. value: function getJavaScript() {
  7705. return this._transport.getJavaScript();
  7706. }
  7707. }, {
  7708. key: 'getOutline',
  7709. value: function getOutline() {
  7710. return this._transport.getOutline();
  7711. }
  7712. }, {
  7713. key: 'getPermissions',
  7714. value: function getPermissions() {
  7715. return this._transport.getPermissions();
  7716. }
  7717. }, {
  7718. key: 'getMetadata',
  7719. value: function getMetadata() {
  7720. return this._transport.getMetadata();
  7721. }
  7722. }, {
  7723. key: 'getData',
  7724. value: function getData() {
  7725. return this._transport.getData();
  7726. }
  7727. }, {
  7728. key: 'getDownloadInfo',
  7729. value: function getDownloadInfo() {
  7730. return this._transport.downloadInfoCapability.promise;
  7731. }
  7732. }, {
  7733. key: 'getStats',
  7734. value: function getStats() {
  7735. return this._transport.getStats();
  7736. }
  7737. }, {
  7738. key: 'cleanup',
  7739. value: function cleanup() {
  7740. this._transport.startCleanup();
  7741. }
  7742. }, {
  7743. key: 'destroy',
  7744. value: function destroy() {
  7745. return this.loadingTask.destroy();
  7746. }
  7747. }, {
  7748. key: 'numPages',
  7749. get: function get() {
  7750. return this._pdfInfo.numPages;
  7751. }
  7752. }, {
  7753. key: 'fingerprint',
  7754. get: function get() {
  7755. return this._pdfInfo.fingerprint;
  7756. }
  7757. }, {
  7758. key: 'loadingParams',
  7759. get: function get() {
  7760. return this._transport.loadingParams;
  7761. }
  7762. }]);
  7763. return PDFDocumentProxy;
  7764. }();
  7765. var PDFPageProxy = function PDFPageProxyClosure() {
  7766. function PDFPageProxy(pageIndex, pageInfo, transport) {
  7767. var pdfBug = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  7768. this.pageIndex = pageIndex;
  7769. this._pageInfo = pageInfo;
  7770. this.transport = transport;
  7771. this._stats = pdfBug ? new _dom_utils.StatTimer() : _dom_utils.DummyStatTimer;
  7772. this._pdfBug = pdfBug;
  7773. this.commonObjs = transport.commonObjs;
  7774. this.objs = new PDFObjects();
  7775. this.cleanupAfterRender = false;
  7776. this.pendingCleanup = false;
  7777. this.intentStates = Object.create(null);
  7778. this.destroyed = false;
  7779. }
  7780. PDFPageProxy.prototype = {
  7781. get pageNumber() {
  7782. return this.pageIndex + 1;
  7783. },
  7784. get rotate() {
  7785. return this._pageInfo.rotate;
  7786. },
  7787. get ref() {
  7788. return this._pageInfo.ref;
  7789. },
  7790. get userUnit() {
  7791. return this._pageInfo.userUnit;
  7792. },
  7793. get view() {
  7794. return this._pageInfo.view;
  7795. },
  7796. getViewport: function getViewport(scale) {
  7797. var rotate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.rotate;
  7798. var dontFlip = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  7799. return new _dom_utils.PageViewport({
  7800. viewBox: this.view,
  7801. scale: scale,
  7802. rotation: rotate,
  7803. dontFlip: dontFlip
  7804. });
  7805. },
  7806. getAnnotations: function PDFPageProxy_getAnnotations(params) {
  7807. var intent = params && params.intent || null;
  7808. if (!this.annotationsPromise || this.annotationsIntent !== intent) {
  7809. this.annotationsPromise = this.transport.getAnnotations(this.pageIndex, intent);
  7810. this.annotationsIntent = intent;
  7811. }
  7812. return this.annotationsPromise;
  7813. },
  7814. render: function PDFPageProxy_render(params) {
  7815. var _this4 = this;
  7816. var stats = this._stats;
  7817. stats.time('Overall');
  7818. this.pendingCleanup = false;
  7819. var renderingIntent = params.intent === 'print' ? 'print' : 'display';
  7820. var canvasFactory = params.canvasFactory || new _dom_utils.DOMCanvasFactory();
  7821. var webGLContext = new _webgl.WebGLContext({ enable: params.enableWebGL });
  7822. if (!this.intentStates[renderingIntent]) {
  7823. this.intentStates[renderingIntent] = Object.create(null);
  7824. }
  7825. var intentState = this.intentStates[renderingIntent];
  7826. if (!intentState.displayReadyCapability) {
  7827. intentState.receivingOperatorList = true;
  7828. intentState.displayReadyCapability = (0, _util.createPromiseCapability)();
  7829. intentState.operatorList = {
  7830. fnArray: [],
  7831. argsArray: [],
  7832. lastChunk: false
  7833. };
  7834. stats.time('Page Request');
  7835. this.transport.messageHandler.send('RenderPageRequest', {
  7836. pageIndex: this.pageNumber - 1,
  7837. intent: renderingIntent,
  7838. renderInteractiveForms: params.renderInteractiveForms === true
  7839. });
  7840. }
  7841. var complete = function complete(error) {
  7842. var i = intentState.renderTasks.indexOf(internalRenderTask);
  7843. if (i >= 0) {
  7844. intentState.renderTasks.splice(i, 1);
  7845. }
  7846. if (_this4.cleanupAfterRender) {
  7847. _this4.pendingCleanup = true;
  7848. }
  7849. _this4._tryCleanup();
  7850. if (error) {
  7851. internalRenderTask.capability.reject(error);
  7852. } else {
  7853. internalRenderTask.capability.resolve();
  7854. }
  7855. stats.timeEnd('Rendering');
  7856. stats.timeEnd('Overall');
  7857. };
  7858. var internalRenderTask = new InternalRenderTask(complete, params, this.objs, this.commonObjs, intentState.operatorList, this.pageNumber, canvasFactory, webGLContext, this._pdfBug);
  7859. internalRenderTask.useRequestAnimationFrame = renderingIntent !== 'print';
  7860. if (!intentState.renderTasks) {
  7861. intentState.renderTasks = [];
  7862. }
  7863. intentState.renderTasks.push(internalRenderTask);
  7864. var renderTask = internalRenderTask.task;
  7865. intentState.displayReadyCapability.promise.then(function (transparency) {
  7866. if (_this4.pendingCleanup) {
  7867. complete();
  7868. return;
  7869. }
  7870. stats.time('Rendering');
  7871. internalRenderTask.initializeGraphics(transparency);
  7872. internalRenderTask.operatorListChanged();
  7873. }).catch(complete);
  7874. return renderTask;
  7875. },
  7876. getOperatorList: function PDFPageProxy_getOperatorList() {
  7877. function operatorListChanged() {
  7878. if (intentState.operatorList.lastChunk) {
  7879. intentState.opListReadCapability.resolve(intentState.operatorList);
  7880. var i = intentState.renderTasks.indexOf(opListTask);
  7881. if (i >= 0) {
  7882. intentState.renderTasks.splice(i, 1);
  7883. }
  7884. }
  7885. }
  7886. var renderingIntent = 'oplist';
  7887. if (!this.intentStates[renderingIntent]) {
  7888. this.intentStates[renderingIntent] = Object.create(null);
  7889. }
  7890. var intentState = this.intentStates[renderingIntent];
  7891. var opListTask;
  7892. if (!intentState.opListReadCapability) {
  7893. opListTask = {};
  7894. opListTask.operatorListChanged = operatorListChanged;
  7895. intentState.receivingOperatorList = true;
  7896. intentState.opListReadCapability = (0, _util.createPromiseCapability)();
  7897. intentState.renderTasks = [];
  7898. intentState.renderTasks.push(opListTask);
  7899. intentState.operatorList = {
  7900. fnArray: [],
  7901. argsArray: [],
  7902. lastChunk: false
  7903. };
  7904. this._stats.time('Page Request');
  7905. this.transport.messageHandler.send('RenderPageRequest', {
  7906. pageIndex: this.pageIndex,
  7907. intent: renderingIntent
  7908. });
  7909. }
  7910. return intentState.opListReadCapability.promise;
  7911. },
  7912. streamTextContent: function streamTextContent() {
  7913. var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  7914. var TEXT_CONTENT_CHUNK_SIZE = 100;
  7915. return this.transport.messageHandler.sendWithStream('GetTextContent', {
  7916. pageIndex: this.pageNumber - 1,
  7917. normalizeWhitespace: params.normalizeWhitespace === true,
  7918. combineTextItems: params.disableCombineTextItems !== true
  7919. }, {
  7920. highWaterMark: TEXT_CONTENT_CHUNK_SIZE,
  7921. size: function size(textContent) {
  7922. return textContent.items.length;
  7923. }
  7924. });
  7925. },
  7926. getTextContent: function PDFPageProxy_getTextContent(params) {
  7927. params = params || {};
  7928. var readableStream = this.streamTextContent(params);
  7929. return new Promise(function (resolve, reject) {
  7930. function pump() {
  7931. reader.read().then(function (_ref) {
  7932. var _textContent$items;
  7933. var value = _ref.value,
  7934. done = _ref.done;
  7935. if (done) {
  7936. resolve(textContent);
  7937. return;
  7938. }
  7939. Object.assign(textContent.styles, value.styles);
  7940. (_textContent$items = textContent.items).push.apply(_textContent$items, _toConsumableArray(value.items));
  7941. pump();
  7942. }, reject);
  7943. }
  7944. var reader = readableStream.getReader();
  7945. var textContent = {
  7946. items: [],
  7947. styles: Object.create(null)
  7948. };
  7949. pump();
  7950. });
  7951. },
  7952. _destroy: function PDFPageProxy_destroy() {
  7953. this.destroyed = true;
  7954. this.transport.pageCache[this.pageIndex] = null;
  7955. var waitOn = [];
  7956. Object.keys(this.intentStates).forEach(function (intent) {
  7957. if (intent === 'oplist') {
  7958. return;
  7959. }
  7960. var intentState = this.intentStates[intent];
  7961. intentState.renderTasks.forEach(function (renderTask) {
  7962. var renderCompleted = renderTask.capability.promise.catch(function () {});
  7963. waitOn.push(renderCompleted);
  7964. renderTask.cancel();
  7965. });
  7966. }, this);
  7967. this.objs.clear();
  7968. this.annotationsPromise = null;
  7969. this.pendingCleanup = false;
  7970. return Promise.all(waitOn);
  7971. },
  7972. cleanup: function cleanup() {
  7973. var resetStats = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  7974. this.pendingCleanup = true;
  7975. this._tryCleanup(resetStats);
  7976. },
  7977. _tryCleanup: function _tryCleanup() {
  7978. var resetStats = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  7979. if (!this.pendingCleanup || Object.keys(this.intentStates).some(function (intent) {
  7980. var intentState = this.intentStates[intent];
  7981. return intentState.renderTasks.length !== 0 || intentState.receivingOperatorList;
  7982. }, this)) {
  7983. return;
  7984. }
  7985. Object.keys(this.intentStates).forEach(function (intent) {
  7986. delete this.intentStates[intent];
  7987. }, this);
  7988. this.objs.clear();
  7989. this.annotationsPromise = null;
  7990. if (resetStats && this._stats instanceof _dom_utils.StatTimer) {
  7991. this._stats = new _dom_utils.StatTimer();
  7992. }
  7993. this.pendingCleanup = false;
  7994. },
  7995. _startRenderPage: function PDFPageProxy_startRenderPage(transparency, intent) {
  7996. var intentState = this.intentStates[intent];
  7997. if (intentState.displayReadyCapability) {
  7998. intentState.displayReadyCapability.resolve(transparency);
  7999. }
  8000. },
  8001. _renderPageChunk: function PDFPageProxy_renderPageChunk(operatorListChunk, intent) {
  8002. var intentState = this.intentStates[intent];
  8003. var i, ii;
  8004. for (i = 0, ii = operatorListChunk.length; i < ii; i++) {
  8005. intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
  8006. intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]);
  8007. }
  8008. intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
  8009. for (i = 0; i < intentState.renderTasks.length; i++) {
  8010. intentState.renderTasks[i].operatorListChanged();
  8011. }
  8012. if (operatorListChunk.lastChunk) {
  8013. intentState.receivingOperatorList = false;
  8014. this._tryCleanup();
  8015. }
  8016. },
  8017. get stats() {
  8018. return this._stats instanceof _dom_utils.StatTimer ? this._stats : null;
  8019. }
  8020. };
  8021. return PDFPageProxy;
  8022. }();
  8023. var LoopbackPort = function () {
  8024. function LoopbackPort() {
  8025. var defer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  8026. _classCallCheck(this, LoopbackPort);
  8027. this._listeners = [];
  8028. this._defer = defer;
  8029. this._deferred = Promise.resolve(undefined);
  8030. }
  8031. _createClass(LoopbackPort, [{
  8032. key: 'postMessage',
  8033. value: function postMessage(obj, transfers) {
  8034. var _this5 = this;
  8035. function cloneValue(value) {
  8036. if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) !== 'object' || value === null) {
  8037. return value;
  8038. }
  8039. if (cloned.has(value)) {
  8040. return cloned.get(value);
  8041. }
  8042. var result;
  8043. var buffer;
  8044. if ((buffer = value.buffer) && (0, _util.isArrayBuffer)(buffer)) {
  8045. var transferable = transfers && transfers.includes(buffer);
  8046. if (value === buffer) {
  8047. result = value;
  8048. } else if (transferable) {
  8049. result = new value.constructor(buffer, value.byteOffset, value.byteLength);
  8050. } else {
  8051. result = new value.constructor(value);
  8052. }
  8053. cloned.set(value, result);
  8054. return result;
  8055. }
  8056. result = Array.isArray(value) ? [] : {};
  8057. cloned.set(value, result);
  8058. for (var i in value) {
  8059. var desc,
  8060. p = value;
  8061. while (!(desc = Object.getOwnPropertyDescriptor(p, i))) {
  8062. p = Object.getPrototypeOf(p);
  8063. }
  8064. if (typeof desc.value === 'undefined' || typeof desc.value === 'function') {
  8065. continue;
  8066. }
  8067. result[i] = cloneValue(desc.value);
  8068. }
  8069. return result;
  8070. }
  8071. if (!this._defer) {
  8072. this._listeners.forEach(function (listener) {
  8073. listener.call(this, { data: obj });
  8074. }, this);
  8075. return;
  8076. }
  8077. var cloned = new WeakMap();
  8078. var e = { data: cloneValue(obj) };
  8079. this._deferred.then(function () {
  8080. _this5._listeners.forEach(function (listener) {
  8081. listener.call(this, e);
  8082. }, _this5);
  8083. });
  8084. }
  8085. }, {
  8086. key: 'addEventListener',
  8087. value: function addEventListener(name, listener) {
  8088. this._listeners.push(listener);
  8089. }
  8090. }, {
  8091. key: 'removeEventListener',
  8092. value: function removeEventListener(name, listener) {
  8093. var i = this._listeners.indexOf(listener);
  8094. this._listeners.splice(i, 1);
  8095. }
  8096. }, {
  8097. key: 'terminate',
  8098. value: function terminate() {
  8099. this._listeners = [];
  8100. }
  8101. }]);
  8102. return LoopbackPort;
  8103. }();
  8104. var PDFWorker = function PDFWorkerClosure() {
  8105. var nextFakeWorkerId = 0;
  8106. function getWorkerSrc() {
  8107. if (_worker_options.GlobalWorkerOptions.workerSrc) {
  8108. return _worker_options.GlobalWorkerOptions.workerSrc;
  8109. }
  8110. if (typeof fallbackWorkerSrc !== 'undefined') {
  8111. return fallbackWorkerSrc;
  8112. }
  8113. throw new Error('No "GlobalWorkerOptions.workerSrc" specified.');
  8114. }
  8115. function getMainThreadWorkerMessageHandler() {
  8116. try {
  8117. if (typeof window !== 'undefined') {
  8118. return window.pdfjsWorker && window.pdfjsWorker.WorkerMessageHandler;
  8119. }
  8120. } catch (ex) {}
  8121. return null;
  8122. }
  8123. var fakeWorkerFilesLoadedCapability = void 0;
  8124. function setupFakeWorkerGlobal() {
  8125. if (fakeWorkerFilesLoadedCapability) {
  8126. return fakeWorkerFilesLoadedCapability.promise;
  8127. }
  8128. fakeWorkerFilesLoadedCapability = (0, _util.createPromiseCapability)();
  8129. var mainWorkerMessageHandler = getMainThreadWorkerMessageHandler();
  8130. if (mainWorkerMessageHandler) {
  8131. fakeWorkerFilesLoadedCapability.resolve(mainWorkerMessageHandler);
  8132. return fakeWorkerFilesLoadedCapability.promise;
  8133. }
  8134. var loader = fakeWorkerFilesLoader || function () {
  8135. return (0, _dom_utils.loadScript)(getWorkerSrc()).then(function () {
  8136. return window.pdfjsWorker.WorkerMessageHandler;
  8137. });
  8138. };
  8139. loader().then(fakeWorkerFilesLoadedCapability.resolve, fakeWorkerFilesLoadedCapability.reject);
  8140. return fakeWorkerFilesLoadedCapability.promise;
  8141. }
  8142. function createCDNWrapper(url) {
  8143. var wrapper = 'importScripts(\'' + url + '\');';
  8144. return _util.URL.createObjectURL(new Blob([wrapper]));
  8145. }
  8146. var pdfWorkerPorts = new WeakMap();
  8147. function PDFWorker() {
  8148. var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  8149. _ref2$name = _ref2.name,
  8150. name = _ref2$name === undefined ? null : _ref2$name,
  8151. _ref2$port = _ref2.port,
  8152. port = _ref2$port === undefined ? null : _ref2$port,
  8153. _ref2$postMessageTran = _ref2.postMessageTransfers,
  8154. postMessageTransfers = _ref2$postMessageTran === undefined ? true : _ref2$postMessageTran,
  8155. _ref2$verbosity = _ref2.verbosity,
  8156. verbosity = _ref2$verbosity === undefined ? (0, _util.getVerbosityLevel)() : _ref2$verbosity;
  8157. if (port && pdfWorkerPorts.has(port)) {
  8158. throw new Error('Cannot use more than one PDFWorker per port');
  8159. }
  8160. this.name = name;
  8161. this.destroyed = false;
  8162. this.postMessageTransfers = postMessageTransfers !== false;
  8163. this.verbosity = verbosity;
  8164. this._readyCapability = (0, _util.createPromiseCapability)();
  8165. this._port = null;
  8166. this._webWorker = null;
  8167. this._messageHandler = null;
  8168. if (port) {
  8169. pdfWorkerPorts.set(port, this);
  8170. this._initializeFromPort(port);
  8171. return;
  8172. }
  8173. this._initialize();
  8174. }
  8175. PDFWorker.prototype = {
  8176. get promise() {
  8177. return this._readyCapability.promise;
  8178. },
  8179. get port() {
  8180. return this._port;
  8181. },
  8182. get messageHandler() {
  8183. return this._messageHandler;
  8184. },
  8185. _initializeFromPort: function PDFWorker_initializeFromPort(port) {
  8186. this._port = port;
  8187. this._messageHandler = new _message_handler.MessageHandler('main', 'worker', port);
  8188. this._messageHandler.on('ready', function () {});
  8189. this._readyCapability.resolve();
  8190. },
  8191. _initialize: function PDFWorker_initialize() {
  8192. var _this6 = this;
  8193. if (typeof Worker !== 'undefined' && !isWorkerDisabled && !getMainThreadWorkerMessageHandler()) {
  8194. var workerSrc = getWorkerSrc();
  8195. try {
  8196. if (!(0, _util.isSameOrigin)(window.location.href, workerSrc)) {
  8197. workerSrc = createCDNWrapper(new _util.URL(workerSrc, window.location).href);
  8198. }
  8199. var worker = new Worker(workerSrc);
  8200. var messageHandler = new _message_handler.MessageHandler('main', 'worker', worker);
  8201. var terminateEarly = function terminateEarly() {
  8202. worker.removeEventListener('error', onWorkerError);
  8203. messageHandler.destroy();
  8204. worker.terminate();
  8205. if (_this6.destroyed) {
  8206. _this6._readyCapability.reject(new Error('Worker was destroyed'));
  8207. } else {
  8208. _this6._setupFakeWorker();
  8209. }
  8210. };
  8211. var onWorkerError = function onWorkerError() {
  8212. if (!_this6._webWorker) {
  8213. terminateEarly();
  8214. }
  8215. };
  8216. worker.addEventListener('error', onWorkerError);
  8217. messageHandler.on('test', function (data) {
  8218. worker.removeEventListener('error', onWorkerError);
  8219. if (_this6.destroyed) {
  8220. terminateEarly();
  8221. return;
  8222. }
  8223. if (data && data.supportTypedArray) {
  8224. _this6._messageHandler = messageHandler;
  8225. _this6._port = worker;
  8226. _this6._webWorker = worker;
  8227. if (!data.supportTransfers) {
  8228. _this6.postMessageTransfers = false;
  8229. }
  8230. _this6._readyCapability.resolve();
  8231. messageHandler.send('configure', { verbosity: _this6.verbosity });
  8232. } else {
  8233. _this6._setupFakeWorker();
  8234. messageHandler.destroy();
  8235. worker.terminate();
  8236. }
  8237. });
  8238. messageHandler.on('ready', function (data) {
  8239. worker.removeEventListener('error', onWorkerError);
  8240. if (_this6.destroyed) {
  8241. terminateEarly();
  8242. return;
  8243. }
  8244. try {
  8245. sendTest();
  8246. } catch (e) {
  8247. _this6._setupFakeWorker();
  8248. }
  8249. });
  8250. var sendTest = function sendTest() {
  8251. var testObj = new Uint8Array([_this6.postMessageTransfers ? 255 : 0]);
  8252. try {
  8253. messageHandler.send('test', testObj, [testObj.buffer]);
  8254. } catch (ex) {
  8255. (0, _util.info)('Cannot use postMessage transfers');
  8256. testObj[0] = 0;
  8257. messageHandler.send('test', testObj);
  8258. }
  8259. };
  8260. sendTest();
  8261. return;
  8262. } catch (e) {
  8263. (0, _util.info)('The worker has been disabled.');
  8264. }
  8265. }
  8266. this._setupFakeWorker();
  8267. },
  8268. _setupFakeWorker: function PDFWorker_setupFakeWorker() {
  8269. var _this7 = this;
  8270. if (!isWorkerDisabled) {
  8271. (0, _util.warn)('Setting up fake worker.');
  8272. isWorkerDisabled = true;
  8273. }
  8274. setupFakeWorkerGlobal().then(function (WorkerMessageHandler) {
  8275. if (_this7.destroyed) {
  8276. _this7._readyCapability.reject(new Error('Worker was destroyed'));
  8277. return;
  8278. }
  8279. var port = new LoopbackPort();
  8280. _this7._port = port;
  8281. var id = 'fake' + nextFakeWorkerId++;
  8282. var workerHandler = new _message_handler.MessageHandler(id + '_worker', id, port);
  8283. WorkerMessageHandler.setup(workerHandler, port);
  8284. var messageHandler = new _message_handler.MessageHandler(id, id + '_worker', port);
  8285. _this7._messageHandler = messageHandler;
  8286. _this7._readyCapability.resolve();
  8287. }).catch(function (reason) {
  8288. _this7._readyCapability.reject(new Error('Setting up fake worker failed: "' + reason.message + '".'));
  8289. });
  8290. },
  8291. destroy: function PDFWorker_destroy() {
  8292. this.destroyed = true;
  8293. if (this._webWorker) {
  8294. this._webWorker.terminate();
  8295. this._webWorker = null;
  8296. }
  8297. pdfWorkerPorts.delete(this._port);
  8298. this._port = null;
  8299. if (this._messageHandler) {
  8300. this._messageHandler.destroy();
  8301. this._messageHandler = null;
  8302. }
  8303. }
  8304. };
  8305. PDFWorker.fromPort = function (params) {
  8306. if (!params || !params.port) {
  8307. throw new Error('PDFWorker.fromPort - invalid method signature.');
  8308. }
  8309. if (pdfWorkerPorts.has(params.port)) {
  8310. return pdfWorkerPorts.get(params.port);
  8311. }
  8312. return new PDFWorker(params);
  8313. };
  8314. PDFWorker.getWorkerSrc = function () {
  8315. return getWorkerSrc();
  8316. };
  8317. return PDFWorker;
  8318. }();
  8319. var WorkerTransport = function () {
  8320. function WorkerTransport(messageHandler, loadingTask, networkStream, params) {
  8321. _classCallCheck(this, WorkerTransport);
  8322. this.messageHandler = messageHandler;
  8323. this.loadingTask = loadingTask;
  8324. this.commonObjs = new PDFObjects();
  8325. this.fontLoader = new _font_loader.FontLoader(loadingTask.docId);
  8326. this._params = params;
  8327. this.CMapReaderFactory = new params.CMapReaderFactory({
  8328. baseUrl: params.cMapUrl,
  8329. isCompressed: params.cMapPacked
  8330. });
  8331. this.destroyed = false;
  8332. this.destroyCapability = null;
  8333. this._passwordCapability = null;
  8334. this._networkStream = networkStream;
  8335. this._fullReader = null;
  8336. this._lastProgress = null;
  8337. this.pageCache = [];
  8338. this.pagePromises = [];
  8339. this.downloadInfoCapability = (0, _util.createPromiseCapability)();
  8340. this.setupMessageHandler();
  8341. }
  8342. _createClass(WorkerTransport, [{
  8343. key: 'destroy',
  8344. value: function destroy() {
  8345. var _this8 = this;
  8346. if (this.destroyCapability) {
  8347. return this.destroyCapability.promise;
  8348. }
  8349. this.destroyed = true;
  8350. this.destroyCapability = (0, _util.createPromiseCapability)();
  8351. if (this._passwordCapability) {
  8352. this._passwordCapability.reject(new Error('Worker was destroyed during onPassword callback'));
  8353. }
  8354. var waitOn = [];
  8355. this.pageCache.forEach(function (page) {
  8356. if (page) {
  8357. waitOn.push(page._destroy());
  8358. }
  8359. });
  8360. this.pageCache = [];
  8361. this.pagePromises = [];
  8362. var terminated = this.messageHandler.sendWithPromise('Terminate', null);
  8363. waitOn.push(terminated);
  8364. Promise.all(waitOn).then(function () {
  8365. _this8.fontLoader.clear();
  8366. if (_this8._networkStream) {
  8367. _this8._networkStream.cancelAllRequests();
  8368. }
  8369. if (_this8.messageHandler) {
  8370. _this8.messageHandler.destroy();
  8371. _this8.messageHandler = null;
  8372. }
  8373. _this8.destroyCapability.resolve();
  8374. }, this.destroyCapability.reject);
  8375. return this.destroyCapability.promise;
  8376. }
  8377. }, {
  8378. key: 'setupMessageHandler',
  8379. value: function setupMessageHandler() {
  8380. var messageHandler = this.messageHandler,
  8381. loadingTask = this.loadingTask;
  8382. messageHandler.on('GetReader', function (data, sink) {
  8383. var _this9 = this;
  8384. (0, _util.assert)(this._networkStream);
  8385. this._fullReader = this._networkStream.getFullReader();
  8386. this._fullReader.onProgress = function (evt) {
  8387. _this9._lastProgress = {
  8388. loaded: evt.loaded,
  8389. total: evt.total
  8390. };
  8391. };
  8392. sink.onPull = function () {
  8393. _this9._fullReader.read().then(function (_ref3) {
  8394. var value = _ref3.value,
  8395. done = _ref3.done;
  8396. if (done) {
  8397. sink.close();
  8398. return;
  8399. }
  8400. (0, _util.assert)((0, _util.isArrayBuffer)(value));
  8401. sink.enqueue(new Uint8Array(value), 1, [value]);
  8402. }).catch(function (reason) {
  8403. sink.error(reason);
  8404. });
  8405. };
  8406. sink.onCancel = function (reason) {
  8407. _this9._fullReader.cancel(reason);
  8408. };
  8409. }, this);
  8410. messageHandler.on('ReaderHeadersReady', function (data) {
  8411. var _this10 = this;
  8412. var headersCapability = (0, _util.createPromiseCapability)();
  8413. var fullReader = this._fullReader;
  8414. fullReader.headersReady.then(function () {
  8415. if (!fullReader.isStreamingSupported || !fullReader.isRangeSupported) {
  8416. if (_this10._lastProgress && loadingTask.onProgress) {
  8417. loadingTask.onProgress(_this10._lastProgress);
  8418. }
  8419. fullReader.onProgress = function (evt) {
  8420. if (loadingTask.onProgress) {
  8421. loadingTask.onProgress({
  8422. loaded: evt.loaded,
  8423. total: evt.total
  8424. });
  8425. }
  8426. };
  8427. }
  8428. headersCapability.resolve({
  8429. isStreamingSupported: fullReader.isStreamingSupported,
  8430. isRangeSupported: fullReader.isRangeSupported,
  8431. contentLength: fullReader.contentLength
  8432. });
  8433. }, headersCapability.reject);
  8434. return headersCapability.promise;
  8435. }, this);
  8436. messageHandler.on('GetRangeReader', function (data, sink) {
  8437. (0, _util.assert)(this._networkStream);
  8438. var rangeReader = this._networkStream.getRangeReader(data.begin, data.end);
  8439. sink.onPull = function () {
  8440. rangeReader.read().then(function (_ref4) {
  8441. var value = _ref4.value,
  8442. done = _ref4.done;
  8443. if (done) {
  8444. sink.close();
  8445. return;
  8446. }
  8447. (0, _util.assert)((0, _util.isArrayBuffer)(value));
  8448. sink.enqueue(new Uint8Array(value), 1, [value]);
  8449. }).catch(function (reason) {
  8450. sink.error(reason);
  8451. });
  8452. };
  8453. sink.onCancel = function (reason) {
  8454. rangeReader.cancel(reason);
  8455. };
  8456. }, this);
  8457. messageHandler.on('GetDoc', function (_ref5) {
  8458. var pdfInfo = _ref5.pdfInfo;
  8459. this.numPages = pdfInfo.numPages;
  8460. this.pdfDocument = new PDFDocumentProxy(pdfInfo, this, loadingTask);
  8461. loadingTask._capability.resolve(this.pdfDocument);
  8462. }, this);
  8463. messageHandler.on('PasswordRequest', function (exception) {
  8464. var _this11 = this;
  8465. this._passwordCapability = (0, _util.createPromiseCapability)();
  8466. if (loadingTask.onPassword) {
  8467. var updatePassword = function updatePassword(password) {
  8468. _this11._passwordCapability.resolve({ password: password });
  8469. };
  8470. try {
  8471. loadingTask.onPassword(updatePassword, exception.code);
  8472. } catch (ex) {
  8473. this._passwordCapability.reject(ex);
  8474. }
  8475. } else {
  8476. this._passwordCapability.reject(new _util.PasswordException(exception.message, exception.code));
  8477. }
  8478. return this._passwordCapability.promise;
  8479. }, this);
  8480. messageHandler.on('PasswordException', function (exception) {
  8481. loadingTask._capability.reject(new _util.PasswordException(exception.message, exception.code));
  8482. }, this);
  8483. messageHandler.on('InvalidPDF', function (exception) {
  8484. loadingTask._capability.reject(new _util.InvalidPDFException(exception.message));
  8485. }, this);
  8486. messageHandler.on('MissingPDF', function (exception) {
  8487. loadingTask._capability.reject(new _util.MissingPDFException(exception.message));
  8488. }, this);
  8489. messageHandler.on('UnexpectedResponse', function (exception) {
  8490. loadingTask._capability.reject(new _util.UnexpectedResponseException(exception.message, exception.status));
  8491. }, this);
  8492. messageHandler.on('UnknownError', function (exception) {
  8493. loadingTask._capability.reject(new _util.UnknownErrorException(exception.message, exception.details));
  8494. }, this);
  8495. messageHandler.on('DataLoaded', function (data) {
  8496. if (loadingTask.onProgress) {
  8497. loadingTask.onProgress({
  8498. loaded: data.length,
  8499. total: data.length
  8500. });
  8501. }
  8502. this.downloadInfoCapability.resolve(data);
  8503. }, this);
  8504. messageHandler.on('StartRenderPage', function (data) {
  8505. if (this.destroyed) {
  8506. return;
  8507. }
  8508. var page = this.pageCache[data.pageIndex];
  8509. page._stats.timeEnd('Page Request');
  8510. page._startRenderPage(data.transparency, data.intent);
  8511. }, this);
  8512. messageHandler.on('RenderPageChunk', function (data) {
  8513. if (this.destroyed) {
  8514. return;
  8515. }
  8516. var page = this.pageCache[data.pageIndex];
  8517. page._renderPageChunk(data.operatorList, data.intent);
  8518. }, this);
  8519. messageHandler.on('commonobj', function (data) {
  8520. var _this12 = this;
  8521. if (this.destroyed) {
  8522. return;
  8523. }
  8524. var _data = _slicedToArray(data, 3),
  8525. id = _data[0],
  8526. type = _data[1],
  8527. exportedData = _data[2];
  8528. if (this.commonObjs.hasData(id)) {
  8529. return;
  8530. }
  8531. switch (type) {
  8532. case 'Font':
  8533. var params = this._params;
  8534. if ('error' in exportedData) {
  8535. var exportedError = exportedData.error;
  8536. (0, _util.warn)('Error during font loading: ' + exportedError);
  8537. this.commonObjs.resolve(id, exportedError);
  8538. break;
  8539. }
  8540. var fontRegistry = null;
  8541. if (params.pdfBug && _global_scope2.default.FontInspector && _global_scope2.default.FontInspector.enabled) {
  8542. fontRegistry = {
  8543. registerFont: function registerFont(font, url) {
  8544. _global_scope2.default['FontInspector'].fontAdded(font, url);
  8545. }
  8546. };
  8547. }
  8548. var font = new _font_loader.FontFaceObject(exportedData, {
  8549. isEvalSupported: params.isEvalSupported,
  8550. disableFontFace: params.disableFontFace,
  8551. ignoreErrors: params.ignoreErrors,
  8552. onUnsupportedFeature: this._onUnsupportedFeature.bind(this),
  8553. fontRegistry: fontRegistry
  8554. });
  8555. var fontReady = function fontReady(fontObjs) {
  8556. _this12.commonObjs.resolve(id, font);
  8557. };
  8558. this.fontLoader.bind([font], fontReady);
  8559. break;
  8560. case 'FontPath':
  8561. this.commonObjs.resolve(id, exportedData);
  8562. break;
  8563. default:
  8564. throw new Error('Got unknown common object type ' + type);
  8565. }
  8566. }, this);
  8567. messageHandler.on('obj', function (data) {
  8568. if (this.destroyed) {
  8569. return;
  8570. }
  8571. var _data2 = _slicedToArray(data, 4),
  8572. id = _data2[0],
  8573. pageIndex = _data2[1],
  8574. type = _data2[2],
  8575. imageData = _data2[3];
  8576. var pageProxy = this.pageCache[pageIndex];
  8577. if (pageProxy.objs.hasData(id)) {
  8578. return;
  8579. }
  8580. switch (type) {
  8581. case 'JpegStream':
  8582. return new Promise(function (resolve, reject) {
  8583. var img = new Image();
  8584. img.onload = function () {
  8585. resolve(img);
  8586. };
  8587. img.onerror = function () {
  8588. reject(new Error('Error during JPEG image loading'));
  8589. };
  8590. img.src = imageData;
  8591. }).then(function (img) {
  8592. pageProxy.objs.resolve(id, img);
  8593. });
  8594. case 'Image':
  8595. pageProxy.objs.resolve(id, imageData);
  8596. var MAX_IMAGE_SIZE_TO_STORE = 8000000;
  8597. if (imageData && 'data' in imageData && imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) {
  8598. pageProxy.cleanupAfterRender = true;
  8599. }
  8600. break;
  8601. default:
  8602. throw new Error('Got unknown object type ' + type);
  8603. }
  8604. }, this);
  8605. messageHandler.on('DocProgress', function (data) {
  8606. if (this.destroyed) {
  8607. return;
  8608. }
  8609. if (loadingTask.onProgress) {
  8610. loadingTask.onProgress({
  8611. loaded: data.loaded,
  8612. total: data.total
  8613. });
  8614. }
  8615. }, this);
  8616. messageHandler.on('PageError', function (data) {
  8617. if (this.destroyed) {
  8618. return;
  8619. }
  8620. var page = this.pageCache[data.pageNum - 1];
  8621. var intentState = page.intentStates[data.intent];
  8622. if (intentState.displayReadyCapability) {
  8623. intentState.displayReadyCapability.reject(data.error);
  8624. } else {
  8625. throw new Error(data.error);
  8626. }
  8627. if (intentState.operatorList) {
  8628. intentState.operatorList.lastChunk = true;
  8629. for (var i = 0; i < intentState.renderTasks.length; i++) {
  8630. intentState.renderTasks[i].operatorListChanged();
  8631. }
  8632. }
  8633. }, this);
  8634. messageHandler.on('UnsupportedFeature', this._onUnsupportedFeature, this);
  8635. messageHandler.on('JpegDecode', function (data) {
  8636. if (this.destroyed) {
  8637. return Promise.reject(new Error('Worker was destroyed'));
  8638. }
  8639. if (typeof document === 'undefined') {
  8640. return Promise.reject(new Error('"document" is not defined.'));
  8641. }
  8642. var _data3 = _slicedToArray(data, 2),
  8643. imageUrl = _data3[0],
  8644. components = _data3[1];
  8645. if (components !== 3 && components !== 1) {
  8646. return Promise.reject(new Error('Only 3 components or 1 component can be returned'));
  8647. }
  8648. return new Promise(function (resolve, reject) {
  8649. var img = new Image();
  8650. img.onload = function () {
  8651. var width = img.width;
  8652. var height = img.height;
  8653. var size = width * height;
  8654. var rgbaLength = size * 4;
  8655. var buf = new Uint8ClampedArray(size * components);
  8656. var tmpCanvas = document.createElement('canvas');
  8657. tmpCanvas.width = width;
  8658. tmpCanvas.height = height;
  8659. var tmpCtx = tmpCanvas.getContext('2d');
  8660. tmpCtx.drawImage(img, 0, 0);
  8661. var data = tmpCtx.getImageData(0, 0, width, height).data;
  8662. if (components === 3) {
  8663. for (var i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
  8664. buf[j] = data[i];
  8665. buf[j + 1] = data[i + 1];
  8666. buf[j + 2] = data[i + 2];
  8667. }
  8668. } else if (components === 1) {
  8669. for (var _i = 0, _j = 0; _i < rgbaLength; _i += 4, _j++) {
  8670. buf[_j] = data[_i];
  8671. }
  8672. }
  8673. resolve({
  8674. data: buf,
  8675. width: width,
  8676. height: height
  8677. });
  8678. };
  8679. img.onerror = function () {
  8680. reject(new Error('JpegDecode failed to load image'));
  8681. };
  8682. img.src = imageUrl;
  8683. });
  8684. }, this);
  8685. messageHandler.on('FetchBuiltInCMap', function (data) {
  8686. if (this.destroyed) {
  8687. return Promise.reject(new Error('Worker was destroyed'));
  8688. }
  8689. return this.CMapReaderFactory.fetch({ name: data.name });
  8690. }, this);
  8691. }
  8692. }, {
  8693. key: '_onUnsupportedFeature',
  8694. value: function _onUnsupportedFeature(_ref6) {
  8695. var featureId = _ref6.featureId;
  8696. if (this.destroyed) {
  8697. return;
  8698. }
  8699. if (this.loadingTask.onUnsupportedFeature) {
  8700. this.loadingTask.onUnsupportedFeature(featureId);
  8701. }
  8702. }
  8703. }, {
  8704. key: 'getData',
  8705. value: function getData() {
  8706. return this.messageHandler.sendWithPromise('GetData', null);
  8707. }
  8708. }, {
  8709. key: 'getPage',
  8710. value: function getPage(pageNumber) {
  8711. var _this13 = this;
  8712. if (!Number.isInteger(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) {
  8713. return Promise.reject(new Error('Invalid page request'));
  8714. }
  8715. var pageIndex = pageNumber - 1;
  8716. if (pageIndex in this.pagePromises) {
  8717. return this.pagePromises[pageIndex];
  8718. }
  8719. var promise = this.messageHandler.sendWithPromise('GetPage', { pageIndex: pageIndex }).then(function (pageInfo) {
  8720. if (_this13.destroyed) {
  8721. throw new Error('Transport destroyed');
  8722. }
  8723. var page = new PDFPageProxy(pageIndex, pageInfo, _this13, _this13._params.pdfBug);
  8724. _this13.pageCache[pageIndex] = page;
  8725. return page;
  8726. });
  8727. this.pagePromises[pageIndex] = promise;
  8728. return promise;
  8729. }
  8730. }, {
  8731. key: 'getPageIndex',
  8732. value: function getPageIndex(ref) {
  8733. return this.messageHandler.sendWithPromise('GetPageIndex', { ref: ref }).catch(function (reason) {
  8734. return Promise.reject(new Error(reason));
  8735. });
  8736. }
  8737. }, {
  8738. key: 'getAnnotations',
  8739. value: function getAnnotations(pageIndex, intent) {
  8740. return this.messageHandler.sendWithPromise('GetAnnotations', {
  8741. pageIndex: pageIndex,
  8742. intent: intent
  8743. });
  8744. }
  8745. }, {
  8746. key: 'getDestinations',
  8747. value: function getDestinations() {
  8748. return this.messageHandler.sendWithPromise('GetDestinations', null);
  8749. }
  8750. }, {
  8751. key: 'getDestination',
  8752. value: function getDestination(id) {
  8753. if (typeof id !== 'string') {
  8754. return Promise.reject(new Error('Invalid destination request.'));
  8755. }
  8756. return this.messageHandler.sendWithPromise('GetDestination', { id: id });
  8757. }
  8758. }, {
  8759. key: 'getPageLabels',
  8760. value: function getPageLabels() {
  8761. return this.messageHandler.sendWithPromise('GetPageLabels', null);
  8762. }
  8763. }, {
  8764. key: 'getPageMode',
  8765. value: function getPageMode() {
  8766. return this.messageHandler.sendWithPromise('GetPageMode', null);
  8767. }
  8768. }, {
  8769. key: 'getAttachments',
  8770. value: function getAttachments() {
  8771. return this.messageHandler.sendWithPromise('GetAttachments', null);
  8772. }
  8773. }, {
  8774. key: 'getJavaScript',
  8775. value: function getJavaScript() {
  8776. return this.messageHandler.sendWithPromise('GetJavaScript', null);
  8777. }
  8778. }, {
  8779. key: 'getOutline',
  8780. value: function getOutline() {
  8781. return this.messageHandler.sendWithPromise('GetOutline', null);
  8782. }
  8783. }, {
  8784. key: 'getPermissions',
  8785. value: function getPermissions() {
  8786. return this.messageHandler.sendWithPromise('GetPermissions', null);
  8787. }
  8788. }, {
  8789. key: 'getMetadata',
  8790. value: function getMetadata() {
  8791. var _this14 = this;
  8792. return this.messageHandler.sendWithPromise('GetMetadata', null).then(function (results) {
  8793. return {
  8794. info: results[0],
  8795. metadata: results[1] ? new _metadata.Metadata(results[1]) : null,
  8796. contentDispositionFilename: _this14._fullReader ? _this14._fullReader.filename : null
  8797. };
  8798. });
  8799. }
  8800. }, {
  8801. key: 'getStats',
  8802. value: function getStats() {
  8803. return this.messageHandler.sendWithPromise('GetStats', null);
  8804. }
  8805. }, {
  8806. key: 'startCleanup',
  8807. value: function startCleanup() {
  8808. var _this15 = this;
  8809. this.messageHandler.sendWithPromise('Cleanup', null).then(function () {
  8810. for (var i = 0, ii = _this15.pageCache.length; i < ii; i++) {
  8811. var page = _this15.pageCache[i];
  8812. if (page) {
  8813. page.cleanup();
  8814. }
  8815. }
  8816. _this15.commonObjs.clear();
  8817. _this15.fontLoader.clear();
  8818. });
  8819. }
  8820. }, {
  8821. key: 'loadingParams',
  8822. get: function get() {
  8823. var params = this._params;
  8824. return (0, _util.shadow)(this, 'loadingParams', {
  8825. disableAutoFetch: params.disableAutoFetch,
  8826. disableCreateObjectURL: params.disableCreateObjectURL,
  8827. disableFontFace: params.disableFontFace,
  8828. nativeImageDecoderSupport: params.nativeImageDecoderSupport
  8829. });
  8830. }
  8831. }]);
  8832. return WorkerTransport;
  8833. }();
  8834. var PDFObjects = function PDFObjectsClosure() {
  8835. function PDFObjects() {
  8836. this.objs = Object.create(null);
  8837. }
  8838. PDFObjects.prototype = {
  8839. ensureObj: function PDFObjects_ensureObj(objId) {
  8840. if (this.objs[objId]) {
  8841. return this.objs[objId];
  8842. }
  8843. var obj = {
  8844. capability: (0, _util.createPromiseCapability)(),
  8845. data: null,
  8846. resolved: false
  8847. };
  8848. this.objs[objId] = obj;
  8849. return obj;
  8850. },
  8851. get: function PDFObjects_get(objId, callback) {
  8852. if (callback) {
  8853. this.ensureObj(objId).capability.promise.then(callback);
  8854. return null;
  8855. }
  8856. var obj = this.objs[objId];
  8857. if (!obj || !obj.resolved) {
  8858. throw new Error('Requesting object that isn\'t resolved yet ' + objId);
  8859. }
  8860. return obj.data;
  8861. },
  8862. resolve: function PDFObjects_resolve(objId, data) {
  8863. var obj = this.ensureObj(objId);
  8864. obj.resolved = true;
  8865. obj.data = data;
  8866. obj.capability.resolve(data);
  8867. },
  8868. isResolved: function PDFObjects_isResolved(objId) {
  8869. var objs = this.objs;
  8870. if (!objs[objId]) {
  8871. return false;
  8872. }
  8873. return objs[objId].resolved;
  8874. },
  8875. hasData: function PDFObjects_hasData(objId) {
  8876. return this.isResolved(objId);
  8877. },
  8878. getData: function PDFObjects_getData(objId) {
  8879. var objs = this.objs;
  8880. if (!objs[objId] || !objs[objId].resolved) {
  8881. return null;
  8882. }
  8883. return objs[objId].data;
  8884. },
  8885. clear: function PDFObjects_clear() {
  8886. this.objs = Object.create(null);
  8887. }
  8888. };
  8889. return PDFObjects;
  8890. }();
  8891. var RenderTask = function RenderTaskClosure() {
  8892. function RenderTask(internalRenderTask) {
  8893. this._internalRenderTask = internalRenderTask;
  8894. this.onContinue = null;
  8895. }
  8896. RenderTask.prototype = {
  8897. get promise() {
  8898. return this._internalRenderTask.capability.promise;
  8899. },
  8900. cancel: function RenderTask_cancel() {
  8901. this._internalRenderTask.cancel();
  8902. },
  8903. then: function RenderTask_then(onFulfilled, onRejected) {
  8904. return this.promise.then.apply(this.promise, arguments);
  8905. }
  8906. };
  8907. return RenderTask;
  8908. }();
  8909. var InternalRenderTask = function InternalRenderTaskClosure() {
  8910. var canvasInRendering = new WeakMap();
  8911. function InternalRenderTask(callback, params, objs, commonObjs, operatorList, pageNumber, canvasFactory, webGLContext) {
  8912. var pdfBug = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : false;
  8913. this.callback = callback;
  8914. this.params = params;
  8915. this.objs = objs;
  8916. this.commonObjs = commonObjs;
  8917. this.operatorListIdx = null;
  8918. this.operatorList = operatorList;
  8919. this.pageNumber = pageNumber;
  8920. this.canvasFactory = canvasFactory;
  8921. this.webGLContext = webGLContext;
  8922. this._pdfBug = pdfBug;
  8923. this.running = false;
  8924. this.graphicsReadyCallback = null;
  8925. this.graphicsReady = false;
  8926. this.useRequestAnimationFrame = false;
  8927. this.cancelled = false;
  8928. this.capability = (0, _util.createPromiseCapability)();
  8929. this.task = new RenderTask(this);
  8930. this._continueBound = this._continue.bind(this);
  8931. this._scheduleNextBound = this._scheduleNext.bind(this);
  8932. this._nextBound = this._next.bind(this);
  8933. this._canvas = params.canvasContext.canvas;
  8934. }
  8935. InternalRenderTask.prototype = {
  8936. initializeGraphics: function initializeGraphics(transparency) {
  8937. if (this.cancelled) {
  8938. return;
  8939. }
  8940. if (this._canvas) {
  8941. if (canvasInRendering.has(this._canvas)) {
  8942. throw new Error('Cannot use the same canvas during multiple render() operations. ' + 'Use different canvas or ensure previous operations were ' + 'cancelled or completed.');
  8943. }
  8944. canvasInRendering.set(this._canvas, this);
  8945. }
  8946. if (this._pdfBug && _global_scope2.default.StepperManager && _global_scope2.default.StepperManager.enabled) {
  8947. this.stepper = _global_scope2.default.StepperManager.create(this.pageNumber - 1);
  8948. this.stepper.init(this.operatorList);
  8949. this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
  8950. }
  8951. var params = this.params;
  8952. this.gfx = new _canvas.CanvasGraphics(params.canvasContext, this.commonObjs, this.objs, this.canvasFactory, this.webGLContext, params.imageLayer);
  8953. this.gfx.beginDrawing({
  8954. transform: params.transform,
  8955. viewport: params.viewport,
  8956. transparency: transparency,
  8957. background: params.background
  8958. });
  8959. this.operatorListIdx = 0;
  8960. this.graphicsReady = true;
  8961. if (this.graphicsReadyCallback) {
  8962. this.graphicsReadyCallback();
  8963. }
  8964. },
  8965. cancel: function InternalRenderTask_cancel() {
  8966. this.running = false;
  8967. this.cancelled = true;
  8968. if (this._canvas) {
  8969. canvasInRendering.delete(this._canvas);
  8970. }
  8971. this.callback(new _dom_utils.RenderingCancelledException('Rendering cancelled, page ' + this.pageNumber, 'canvas'));
  8972. },
  8973. operatorListChanged: function InternalRenderTask_operatorListChanged() {
  8974. if (!this.graphicsReady) {
  8975. if (!this.graphicsReadyCallback) {
  8976. this.graphicsReadyCallback = this._continueBound;
  8977. }
  8978. return;
  8979. }
  8980. if (this.stepper) {
  8981. this.stepper.updateOperatorList(this.operatorList);
  8982. }
  8983. if (this.running) {
  8984. return;
  8985. }
  8986. this._continue();
  8987. },
  8988. _continue: function InternalRenderTask__continue() {
  8989. this.running = true;
  8990. if (this.cancelled) {
  8991. return;
  8992. }
  8993. if (this.task.onContinue) {
  8994. this.task.onContinue(this._scheduleNextBound);
  8995. } else {
  8996. this._scheduleNext();
  8997. }
  8998. },
  8999. _scheduleNext: function InternalRenderTask__scheduleNext() {
  9000. var _this16 = this;
  9001. if (this.useRequestAnimationFrame && typeof window !== 'undefined') {
  9002. window.requestAnimationFrame(function () {
  9003. _this16._nextBound().catch(_this16.callback);
  9004. });
  9005. } else {
  9006. Promise.resolve().then(this._nextBound).catch(this.callback);
  9007. }
  9008. },
  9009. _next: function InternalRenderTask__next() {
  9010. var _this17 = this;
  9011. return new Promise(function () {
  9012. if (_this17.cancelled) {
  9013. return;
  9014. }
  9015. _this17.operatorListIdx = _this17.gfx.executeOperatorList(_this17.operatorList, _this17.operatorListIdx, _this17._continueBound, _this17.stepper);
  9016. if (_this17.operatorListIdx === _this17.operatorList.argsArray.length) {
  9017. _this17.running = false;
  9018. if (_this17.operatorList.lastChunk) {
  9019. _this17.gfx.endDrawing();
  9020. if (_this17._canvas) {
  9021. canvasInRendering.delete(_this17._canvas);
  9022. }
  9023. _this17.callback();
  9024. }
  9025. }
  9026. });
  9027. }
  9028. };
  9029. return InternalRenderTask;
  9030. }();
  9031. var version, build;
  9032. {
  9033. exports.version = version = '2.0.943';
  9034. exports.build = build = 'dc98bf76';
  9035. }
  9036. exports.getDocument = getDocument;
  9037. exports.LoopbackPort = LoopbackPort;
  9038. exports.PDFDataRangeTransport = PDFDataRangeTransport;
  9039. exports.PDFWorker = PDFWorker;
  9040. exports.PDFDocumentProxy = PDFDocumentProxy;
  9041. exports.PDFPageProxy = PDFPageProxy;
  9042. exports.setPDFNetworkStreamFactory = setPDFNetworkStreamFactory;
  9043. exports.version = version;
  9044. exports.build = build;
  9045. /***/ }),
  9046. /* 130 */
  9047. /***/ (function(module, exports, __w_pdfjs_require__) {
  9048. "use strict";
  9049. Object.defineProperty(exports, "__esModule", {
  9050. value: true
  9051. });
  9052. exports.loadScript = exports.DummyStatTimer = exports.StatTimer = exports.DOMSVGFactory = exports.DOMCMapReaderFactory = exports.DOMCanvasFactory = exports.DEFAULT_LINK_REL = exports.LinkTarget = exports.getFilenameFromUrl = exports.addLinkAttributes = exports.RenderingCancelledException = exports.PageViewport = undefined;
  9053. 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; }; }();
  9054. var _util = __w_pdfjs_require__(1);
  9055. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9056. var DEFAULT_LINK_REL = 'noopener noreferrer nofollow';
  9057. var SVG_NS = 'http://www.w3.org/2000/svg';
  9058. var DOMCanvasFactory = function () {
  9059. function DOMCanvasFactory() {
  9060. _classCallCheck(this, DOMCanvasFactory);
  9061. }
  9062. _createClass(DOMCanvasFactory, [{
  9063. key: 'create',
  9064. value: function create(width, height) {
  9065. if (width <= 0 || height <= 0) {
  9066. throw new Error('invalid canvas size');
  9067. }
  9068. var canvas = document.createElement('canvas');
  9069. var context = canvas.getContext('2d');
  9070. canvas.width = width;
  9071. canvas.height = height;
  9072. return {
  9073. canvas: canvas,
  9074. context: context
  9075. };
  9076. }
  9077. }, {
  9078. key: 'reset',
  9079. value: function reset(canvasAndContext, width, height) {
  9080. if (!canvasAndContext.canvas) {
  9081. throw new Error('canvas is not specified');
  9082. }
  9083. if (width <= 0 || height <= 0) {
  9084. throw new Error('invalid canvas size');
  9085. }
  9086. canvasAndContext.canvas.width = width;
  9087. canvasAndContext.canvas.height = height;
  9088. }
  9089. }, {
  9090. key: 'destroy',
  9091. value: function destroy(canvasAndContext) {
  9092. if (!canvasAndContext.canvas) {
  9093. throw new Error('canvas is not specified');
  9094. }
  9095. canvasAndContext.canvas.width = 0;
  9096. canvasAndContext.canvas.height = 0;
  9097. canvasAndContext.canvas = null;
  9098. canvasAndContext.context = null;
  9099. }
  9100. }]);
  9101. return DOMCanvasFactory;
  9102. }();
  9103. var DOMCMapReaderFactory = function () {
  9104. function DOMCMapReaderFactory(_ref) {
  9105. var _ref$baseUrl = _ref.baseUrl,
  9106. baseUrl = _ref$baseUrl === undefined ? null : _ref$baseUrl,
  9107. _ref$isCompressed = _ref.isCompressed,
  9108. isCompressed = _ref$isCompressed === undefined ? false : _ref$isCompressed;
  9109. _classCallCheck(this, DOMCMapReaderFactory);
  9110. this.baseUrl = baseUrl;
  9111. this.isCompressed = isCompressed;
  9112. }
  9113. _createClass(DOMCMapReaderFactory, [{
  9114. key: 'fetch',
  9115. value: function fetch(_ref2) {
  9116. var _this = this;
  9117. var name = _ref2.name;
  9118. if (!this.baseUrl) {
  9119. return Promise.reject(new Error('The CMap "baseUrl" parameter must be specified, ensure that ' + 'the "cMapUrl" and "cMapPacked" API parameters are provided.'));
  9120. }
  9121. if (!name) {
  9122. return Promise.reject(new Error('CMap name must be specified.'));
  9123. }
  9124. return new Promise(function (resolve, reject) {
  9125. var url = _this.baseUrl + name + (_this.isCompressed ? '.bcmap' : '');
  9126. var request = new XMLHttpRequest();
  9127. request.open('GET', url, true);
  9128. if (_this.isCompressed) {
  9129. request.responseType = 'arraybuffer';
  9130. }
  9131. request.onreadystatechange = function () {
  9132. if (request.readyState !== XMLHttpRequest.DONE) {
  9133. return;
  9134. }
  9135. if (request.status === 200 || request.status === 0) {
  9136. var data = void 0;
  9137. if (_this.isCompressed && request.response) {
  9138. data = new Uint8Array(request.response);
  9139. } else if (!_this.isCompressed && request.responseText) {
  9140. data = (0, _util.stringToBytes)(request.responseText);
  9141. }
  9142. if (data) {
  9143. resolve({
  9144. cMapData: data,
  9145. compressionType: _this.isCompressed ? _util.CMapCompressionType.BINARY : _util.CMapCompressionType.NONE
  9146. });
  9147. return;
  9148. }
  9149. }
  9150. reject(new Error('Unable to load ' + (_this.isCompressed ? 'binary ' : '') + 'CMap at: ' + url));
  9151. };
  9152. request.send(null);
  9153. });
  9154. }
  9155. }]);
  9156. return DOMCMapReaderFactory;
  9157. }();
  9158. var DOMSVGFactory = function () {
  9159. function DOMSVGFactory() {
  9160. _classCallCheck(this, DOMSVGFactory);
  9161. }
  9162. _createClass(DOMSVGFactory, [{
  9163. key: 'create',
  9164. value: function create(width, height) {
  9165. (0, _util.assert)(width > 0 && height > 0, 'Invalid SVG dimensions');
  9166. var svg = document.createElementNS(SVG_NS, 'svg:svg');
  9167. svg.setAttribute('version', '1.1');
  9168. svg.setAttribute('width', width + 'px');
  9169. svg.setAttribute('height', height + 'px');
  9170. svg.setAttribute('preserveAspectRatio', 'none');
  9171. svg.setAttribute('viewBox', '0 0 ' + width + ' ' + height);
  9172. return svg;
  9173. }
  9174. }, {
  9175. key: 'createElement',
  9176. value: function createElement(type) {
  9177. (0, _util.assert)(typeof type === 'string', 'Invalid SVG element type');
  9178. return document.createElementNS(SVG_NS, type);
  9179. }
  9180. }]);
  9181. return DOMSVGFactory;
  9182. }();
  9183. var PageViewport = function () {
  9184. function PageViewport(_ref3) {
  9185. var viewBox = _ref3.viewBox,
  9186. scale = _ref3.scale,
  9187. rotation = _ref3.rotation,
  9188. _ref3$offsetX = _ref3.offsetX,
  9189. offsetX = _ref3$offsetX === undefined ? 0 : _ref3$offsetX,
  9190. _ref3$offsetY = _ref3.offsetY,
  9191. offsetY = _ref3$offsetY === undefined ? 0 : _ref3$offsetY,
  9192. _ref3$dontFlip = _ref3.dontFlip,
  9193. dontFlip = _ref3$dontFlip === undefined ? false : _ref3$dontFlip;
  9194. _classCallCheck(this, PageViewport);
  9195. this.viewBox = viewBox;
  9196. this.scale = scale;
  9197. this.rotation = rotation;
  9198. this.offsetX = offsetX;
  9199. this.offsetY = offsetY;
  9200. var centerX = (viewBox[2] + viewBox[0]) / 2;
  9201. var centerY = (viewBox[3] + viewBox[1]) / 2;
  9202. var rotateA = void 0,
  9203. rotateB = void 0,
  9204. rotateC = void 0,
  9205. rotateD = void 0;
  9206. rotation = rotation % 360;
  9207. rotation = rotation < 0 ? rotation + 360 : rotation;
  9208. switch (rotation) {
  9209. case 180:
  9210. rotateA = -1;
  9211. rotateB = 0;
  9212. rotateC = 0;
  9213. rotateD = 1;
  9214. break;
  9215. case 90:
  9216. rotateA = 0;
  9217. rotateB = 1;
  9218. rotateC = 1;
  9219. rotateD = 0;
  9220. break;
  9221. case 270:
  9222. rotateA = 0;
  9223. rotateB = -1;
  9224. rotateC = -1;
  9225. rotateD = 0;
  9226. break;
  9227. default:
  9228. rotateA = 1;
  9229. rotateB = 0;
  9230. rotateC = 0;
  9231. rotateD = -1;
  9232. break;
  9233. }
  9234. if (dontFlip) {
  9235. rotateC = -rotateC;
  9236. rotateD = -rotateD;
  9237. }
  9238. var offsetCanvasX = void 0,
  9239. offsetCanvasY = void 0;
  9240. var width = void 0,
  9241. height = void 0;
  9242. if (rotateA === 0) {
  9243. offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
  9244. offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
  9245. width = Math.abs(viewBox[3] - viewBox[1]) * scale;
  9246. height = Math.abs(viewBox[2] - viewBox[0]) * scale;
  9247. } else {
  9248. offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
  9249. offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
  9250. width = Math.abs(viewBox[2] - viewBox[0]) * scale;
  9251. height = Math.abs(viewBox[3] - viewBox[1]) * scale;
  9252. }
  9253. this.transform = [rotateA * scale, rotateB * scale, rotateC * scale, rotateD * scale, offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY, offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY];
  9254. this.width = width;
  9255. this.height = height;
  9256. }
  9257. _createClass(PageViewport, [{
  9258. key: 'clone',
  9259. value: function clone() {
  9260. var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  9261. _ref4$scale = _ref4.scale,
  9262. scale = _ref4$scale === undefined ? this.scale : _ref4$scale,
  9263. _ref4$rotation = _ref4.rotation,
  9264. rotation = _ref4$rotation === undefined ? this.rotation : _ref4$rotation,
  9265. _ref4$dontFlip = _ref4.dontFlip,
  9266. dontFlip = _ref4$dontFlip === undefined ? false : _ref4$dontFlip;
  9267. return new PageViewport({
  9268. viewBox: this.viewBox.slice(),
  9269. scale: scale,
  9270. rotation: rotation,
  9271. offsetX: this.offsetX,
  9272. offsetY: this.offsetY,
  9273. dontFlip: dontFlip
  9274. });
  9275. }
  9276. }, {
  9277. key: 'convertToViewportPoint',
  9278. value: function convertToViewportPoint(x, y) {
  9279. return _util.Util.applyTransform([x, y], this.transform);
  9280. }
  9281. }, {
  9282. key: 'convertToViewportRectangle',
  9283. value: function convertToViewportRectangle(rect) {
  9284. var tl = _util.Util.applyTransform([rect[0], rect[1]], this.transform);
  9285. var br = _util.Util.applyTransform([rect[2], rect[3]], this.transform);
  9286. return [tl[0], tl[1], br[0], br[1]];
  9287. }
  9288. }, {
  9289. key: 'convertToPdfPoint',
  9290. value: function convertToPdfPoint(x, y) {
  9291. return _util.Util.applyInverseTransform([x, y], this.transform);
  9292. }
  9293. }]);
  9294. return PageViewport;
  9295. }();
  9296. var RenderingCancelledException = function RenderingCancelledException() {
  9297. function RenderingCancelledException(msg, type) {
  9298. this.message = msg;
  9299. this.type = type;
  9300. }
  9301. RenderingCancelledException.prototype = new Error();
  9302. RenderingCancelledException.prototype.name = 'RenderingCancelledException';
  9303. RenderingCancelledException.constructor = RenderingCancelledException;
  9304. return RenderingCancelledException;
  9305. }();
  9306. var LinkTarget = {
  9307. NONE: 0,
  9308. SELF: 1,
  9309. BLANK: 2,
  9310. PARENT: 3,
  9311. TOP: 4
  9312. };
  9313. var LinkTargetStringMap = ['', '_self', '_blank', '_parent', '_top'];
  9314. function addLinkAttributes(link) {
  9315. var _ref5 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  9316. url = _ref5.url,
  9317. target = _ref5.target,
  9318. rel = _ref5.rel;
  9319. link.href = link.title = url ? (0, _util.removeNullCharacters)(url) : '';
  9320. if (url) {
  9321. var LinkTargetValues = Object.values(LinkTarget);
  9322. var targetIndex = LinkTargetValues.includes(target) ? target : LinkTarget.NONE;
  9323. link.target = LinkTargetStringMap[targetIndex];
  9324. link.rel = typeof rel === 'string' ? rel : DEFAULT_LINK_REL;
  9325. }
  9326. }
  9327. function getFilenameFromUrl(url) {
  9328. var anchor = url.indexOf('#');
  9329. var query = url.indexOf('?');
  9330. var end = Math.min(anchor > 0 ? anchor : url.length, query > 0 ? query : url.length);
  9331. return url.substring(url.lastIndexOf('/', end) + 1, end);
  9332. }
  9333. var StatTimer = function () {
  9334. function StatTimer() {
  9335. var enable = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  9336. _classCallCheck(this, StatTimer);
  9337. this.enabled = !!enable;
  9338. this.started = Object.create(null);
  9339. this.times = [];
  9340. }
  9341. _createClass(StatTimer, [{
  9342. key: 'time',
  9343. value: function time(name) {
  9344. if (!this.enabled) {
  9345. return;
  9346. }
  9347. if (name in this.started) {
  9348. (0, _util.warn)('Timer is already running for ' + name);
  9349. }
  9350. this.started[name] = Date.now();
  9351. }
  9352. }, {
  9353. key: 'timeEnd',
  9354. value: function timeEnd(name) {
  9355. if (!this.enabled) {
  9356. return;
  9357. }
  9358. if (!(name in this.started)) {
  9359. (0, _util.warn)('Timer has not been started for ' + name);
  9360. }
  9361. this.times.push({
  9362. 'name': name,
  9363. 'start': this.started[name],
  9364. 'end': Date.now()
  9365. });
  9366. delete this.started[name];
  9367. }
  9368. }, {
  9369. key: 'toString',
  9370. value: function toString() {
  9371. var times = this.times;
  9372. var out = '',
  9373. longest = 0;
  9374. for (var i = 0, ii = times.length; i < ii; ++i) {
  9375. var name = times[i]['name'];
  9376. if (name.length > longest) {
  9377. longest = name.length;
  9378. }
  9379. }
  9380. for (var _i = 0, _ii = times.length; _i < _ii; ++_i) {
  9381. var span = times[_i];
  9382. var duration = span.end - span.start;
  9383. out += span['name'].padEnd(longest) + ' ' + duration + 'ms\n';
  9384. }
  9385. return out;
  9386. }
  9387. }]);
  9388. return StatTimer;
  9389. }();
  9390. var DummyStatTimer = function () {
  9391. function DummyStatTimer() {
  9392. _classCallCheck(this, DummyStatTimer);
  9393. (0, _util.unreachable)('Cannot initialize DummyStatTimer.');
  9394. }
  9395. _createClass(DummyStatTimer, null, [{
  9396. key: 'time',
  9397. value: function time(name) {}
  9398. }, {
  9399. key: 'timeEnd',
  9400. value: function timeEnd(name) {}
  9401. }, {
  9402. key: 'toString',
  9403. value: function toString() {
  9404. return '';
  9405. }
  9406. }]);
  9407. return DummyStatTimer;
  9408. }();
  9409. function loadScript(src) {
  9410. return new Promise(function (resolve, reject) {
  9411. var script = document.createElement('script');
  9412. script.src = src;
  9413. script.onload = resolve;
  9414. script.onerror = function () {
  9415. reject(new Error('Cannot load script at: ' + script.src));
  9416. };
  9417. (document.head || document.documentElement).appendChild(script);
  9418. });
  9419. }
  9420. exports.PageViewport = PageViewport;
  9421. exports.RenderingCancelledException = RenderingCancelledException;
  9422. exports.addLinkAttributes = addLinkAttributes;
  9423. exports.getFilenameFromUrl = getFilenameFromUrl;
  9424. exports.LinkTarget = LinkTarget;
  9425. exports.DEFAULT_LINK_REL = DEFAULT_LINK_REL;
  9426. exports.DOMCanvasFactory = DOMCanvasFactory;
  9427. exports.DOMCMapReaderFactory = DOMCMapReaderFactory;
  9428. exports.DOMSVGFactory = DOMSVGFactory;
  9429. exports.StatTimer = StatTimer;
  9430. exports.DummyStatTimer = DummyStatTimer;
  9431. exports.loadScript = loadScript;
  9432. /***/ }),
  9433. /* 131 */
  9434. /***/ (function(module, exports, __w_pdfjs_require__) {
  9435. "use strict";
  9436. Object.defineProperty(exports, "__esModule", {
  9437. value: true
  9438. });
  9439. exports.FontLoader = exports.FontFaceObject = undefined;
  9440. 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; }; }();
  9441. var _util = __w_pdfjs_require__(1);
  9442. 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; }
  9443. 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; }
  9444. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9445. var BaseFontLoader = function () {
  9446. function BaseFontLoader(docId) {
  9447. _classCallCheck(this, BaseFontLoader);
  9448. if (this.constructor === BaseFontLoader) {
  9449. (0, _util.unreachable)('Cannot initialize BaseFontLoader.');
  9450. }
  9451. this.docId = docId;
  9452. this.nativeFontFaces = [];
  9453. this.styleElement = null;
  9454. this.loadingContext = {
  9455. requests: [],
  9456. nextRequestId: 0
  9457. };
  9458. }
  9459. _createClass(BaseFontLoader, [{
  9460. key: 'addNativeFontFace',
  9461. value: function addNativeFontFace(nativeFontFace) {
  9462. this.nativeFontFaces.push(nativeFontFace);
  9463. document.fonts.add(nativeFontFace);
  9464. }
  9465. }, {
  9466. key: 'insertRule',
  9467. value: function insertRule(rule) {
  9468. var styleElement = this.styleElement;
  9469. if (!styleElement) {
  9470. styleElement = this.styleElement = document.createElement('style');
  9471. styleElement.id = 'PDFJS_FONT_STYLE_TAG_' + this.docId;
  9472. document.documentElement.getElementsByTagName('head')[0].appendChild(styleElement);
  9473. }
  9474. var styleSheet = styleElement.sheet;
  9475. styleSheet.insertRule(rule, styleSheet.cssRules.length);
  9476. }
  9477. }, {
  9478. key: 'clear',
  9479. value: function clear() {
  9480. this.nativeFontFaces.forEach(function (nativeFontFace) {
  9481. document.fonts.delete(nativeFontFace);
  9482. });
  9483. this.nativeFontFaces.length = 0;
  9484. if (this.styleElement) {
  9485. this.styleElement.remove();
  9486. this.styleElement = null;
  9487. }
  9488. }
  9489. }, {
  9490. key: 'bind',
  9491. value: function bind(fonts, callback) {
  9492. var rules = [];
  9493. var fontsToLoad = [];
  9494. var fontLoadPromises = [];
  9495. var getNativeFontPromise = function getNativeFontPromise(nativeFontFace) {
  9496. return nativeFontFace.loaded.catch(function (reason) {
  9497. (0, _util.warn)('Failed to load font "' + nativeFontFace.family + '": ' + reason);
  9498. });
  9499. };
  9500. var _iteratorNormalCompletion = true;
  9501. var _didIteratorError = false;
  9502. var _iteratorError = undefined;
  9503. try {
  9504. for (var _iterator = fonts[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  9505. var font = _step.value;
  9506. if (font.attached || font.missingFile) {
  9507. continue;
  9508. }
  9509. font.attached = true;
  9510. if (this.isFontLoadingAPISupported) {
  9511. var nativeFontFace = font.createNativeFontFace();
  9512. if (nativeFontFace) {
  9513. this.addNativeFontFace(nativeFontFace);
  9514. fontLoadPromises.push(getNativeFontPromise(nativeFontFace));
  9515. }
  9516. } else {
  9517. var rule = font.createFontFaceRule();
  9518. if (rule) {
  9519. this.insertRule(rule);
  9520. rules.push(rule);
  9521. fontsToLoad.push(font);
  9522. }
  9523. }
  9524. }
  9525. } catch (err) {
  9526. _didIteratorError = true;
  9527. _iteratorError = err;
  9528. } finally {
  9529. try {
  9530. if (!_iteratorNormalCompletion && _iterator.return) {
  9531. _iterator.return();
  9532. }
  9533. } finally {
  9534. if (_didIteratorError) {
  9535. throw _iteratorError;
  9536. }
  9537. }
  9538. }
  9539. var request = this._queueLoadingCallback(callback);
  9540. if (this.isFontLoadingAPISupported) {
  9541. Promise.all(fontLoadPromises).then(request.complete);
  9542. } else if (rules.length > 0 && !this.isSyncFontLoadingSupported) {
  9543. this._prepareFontLoadEvent(rules, fontsToLoad, request);
  9544. } else {
  9545. request.complete();
  9546. }
  9547. }
  9548. }, {
  9549. key: '_queueLoadingCallback',
  9550. value: function _queueLoadingCallback(callback) {
  9551. function completeRequest() {
  9552. (0, _util.assert)(!request.done, 'completeRequest() cannot be called twice.');
  9553. request.done = true;
  9554. while (context.requests.length > 0 && context.requests[0].done) {
  9555. var otherRequest = context.requests.shift();
  9556. setTimeout(otherRequest.callback, 0);
  9557. }
  9558. }
  9559. var context = this.loadingContext;
  9560. var request = {
  9561. id: 'pdfjs-font-loading-' + context.nextRequestId++,
  9562. done: false,
  9563. complete: completeRequest,
  9564. callback: callback
  9565. };
  9566. context.requests.push(request);
  9567. return request;
  9568. }
  9569. }, {
  9570. key: '_prepareFontLoadEvent',
  9571. value: function _prepareFontLoadEvent(rules, fontsToLoad, request) {
  9572. (0, _util.unreachable)('Abstract method `_prepareFontLoadEvent`.');
  9573. }
  9574. }, {
  9575. key: 'isFontLoadingAPISupported',
  9576. get: function get() {
  9577. (0, _util.unreachable)('Abstract method `isFontLoadingAPISupported`.');
  9578. }
  9579. }, {
  9580. key: 'isSyncFontLoadingSupported',
  9581. get: function get() {
  9582. (0, _util.unreachable)('Abstract method `isSyncFontLoadingSupported`.');
  9583. }
  9584. }, {
  9585. key: '_loadTestFont',
  9586. get: function get() {
  9587. (0, _util.unreachable)('Abstract method `_loadTestFont`.');
  9588. }
  9589. }]);
  9590. return BaseFontLoader;
  9591. }();
  9592. var FontLoader = void 0;
  9593. {
  9594. exports.FontLoader = FontLoader = function (_BaseFontLoader) {
  9595. _inherits(GenericFontLoader, _BaseFontLoader);
  9596. function GenericFontLoader(docId) {
  9597. _classCallCheck(this, GenericFontLoader);
  9598. var _this = _possibleConstructorReturn(this, (GenericFontLoader.__proto__ || Object.getPrototypeOf(GenericFontLoader)).call(this, docId));
  9599. _this.loadTestFontId = 0;
  9600. return _this;
  9601. }
  9602. _createClass(GenericFontLoader, [{
  9603. key: '_prepareFontLoadEvent',
  9604. value: function _prepareFontLoadEvent(rules, fonts, request) {
  9605. function int32(data, offset) {
  9606. return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff;
  9607. }
  9608. function spliceString(s, offset, remove, insert) {
  9609. var chunk1 = s.substring(0, offset);
  9610. var chunk2 = s.substring(offset + remove);
  9611. return chunk1 + insert + chunk2;
  9612. }
  9613. var i = void 0,
  9614. ii = void 0;
  9615. var canvas = document.createElement('canvas');
  9616. canvas.width = 1;
  9617. canvas.height = 1;
  9618. var ctx = canvas.getContext('2d');
  9619. var called = 0;
  9620. function isFontReady(name, callback) {
  9621. called++;
  9622. if (called > 30) {
  9623. (0, _util.warn)('Load test font never loaded.');
  9624. callback();
  9625. return;
  9626. }
  9627. ctx.font = '30px ' + name;
  9628. ctx.fillText('.', 0, 20);
  9629. var imageData = ctx.getImageData(0, 0, 1, 1);
  9630. if (imageData.data[3] > 0) {
  9631. callback();
  9632. return;
  9633. }
  9634. setTimeout(isFontReady.bind(null, name, callback));
  9635. }
  9636. var loadTestFontId = 'lt' + Date.now() + this.loadTestFontId++;
  9637. var data = this._loadTestFont;
  9638. var COMMENT_OFFSET = 976;
  9639. data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId);
  9640. var CFF_CHECKSUM_OFFSET = 16;
  9641. var XXXX_VALUE = 0x58585858;
  9642. var checksum = int32(data, CFF_CHECKSUM_OFFSET);
  9643. for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
  9644. checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0;
  9645. }
  9646. if (i < loadTestFontId.length) {
  9647. checksum = checksum - XXXX_VALUE + int32(loadTestFontId + 'XXX', i) | 0;
  9648. }
  9649. data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, (0, _util.string32)(checksum));
  9650. var url = 'url(data:font/opentype;base64,' + btoa(data) + ');';
  9651. var rule = '@font-face {font-family:"' + loadTestFontId + '";src:' + url + '}';
  9652. this.insertRule(rule);
  9653. var names = [];
  9654. for (i = 0, ii = fonts.length; i < ii; i++) {
  9655. names.push(fonts[i].loadedName);
  9656. }
  9657. names.push(loadTestFontId);
  9658. var div = document.createElement('div');
  9659. div.setAttribute('style', 'visibility: hidden;' + 'width: 10px; height: 10px;' + 'position: absolute; top: 0px; left: 0px;');
  9660. for (i = 0, ii = names.length; i < ii; ++i) {
  9661. var span = document.createElement('span');
  9662. span.textContent = 'Hi';
  9663. span.style.fontFamily = names[i];
  9664. div.appendChild(span);
  9665. }
  9666. document.body.appendChild(div);
  9667. isFontReady(loadTestFontId, function () {
  9668. document.body.removeChild(div);
  9669. request.complete();
  9670. });
  9671. }
  9672. }, {
  9673. key: 'isFontLoadingAPISupported',
  9674. get: function get() {
  9675. var supported = typeof document !== 'undefined' && !!document.fonts;
  9676. if (supported && typeof navigator !== 'undefined') {
  9677. var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
  9678. if (m && m[1] < 63) {
  9679. supported = false;
  9680. }
  9681. }
  9682. return (0, _util.shadow)(this, 'isFontLoadingAPISupported', supported);
  9683. }
  9684. }, {
  9685. key: 'isSyncFontLoadingSupported',
  9686. get: function get() {
  9687. var supported = false;
  9688. if (typeof navigator === 'undefined') {
  9689. supported = true;
  9690. } else {
  9691. var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
  9692. if (m && m[1] >= 14) {
  9693. supported = true;
  9694. }
  9695. }
  9696. return (0, _util.shadow)(this, 'isSyncFontLoadingSupported', supported);
  9697. }
  9698. }, {
  9699. key: '_loadTestFont',
  9700. get: function get() {
  9701. var getLoadTestFont = function getLoadTestFont() {
  9702. return atob('T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQA' + 'FQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAA' + 'ALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgA' + 'AAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1' + 'AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD' + '6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACM' + 'AooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4D' + 'IP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAA' + 'AAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUA' + 'AQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgAB' + 'AAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABY' + 'AAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAA' + 'AC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAA' + 'AAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQAC' + 'AQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3' + 'Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTj' + 'FQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==');
  9703. };
  9704. return (0, _util.shadow)(this, '_loadTestFont', getLoadTestFont());
  9705. }
  9706. }]);
  9707. return GenericFontLoader;
  9708. }(BaseFontLoader);
  9709. }
  9710. var IsEvalSupportedCached = {
  9711. get value() {
  9712. return (0, _util.shadow)(this, 'value', (0, _util.isEvalSupported)());
  9713. }
  9714. };
  9715. var FontFaceObject = function () {
  9716. function FontFaceObject(translatedData, _ref) {
  9717. var _ref$isEvalSupported = _ref.isEvalSupported,
  9718. isEvalSupported = _ref$isEvalSupported === undefined ? true : _ref$isEvalSupported,
  9719. _ref$disableFontFace = _ref.disableFontFace,
  9720. disableFontFace = _ref$disableFontFace === undefined ? false : _ref$disableFontFace,
  9721. _ref$ignoreErrors = _ref.ignoreErrors,
  9722. ignoreErrors = _ref$ignoreErrors === undefined ? false : _ref$ignoreErrors,
  9723. _ref$onUnsupportedFea = _ref.onUnsupportedFeature,
  9724. onUnsupportedFeature = _ref$onUnsupportedFea === undefined ? null : _ref$onUnsupportedFea,
  9725. _ref$fontRegistry = _ref.fontRegistry,
  9726. fontRegistry = _ref$fontRegistry === undefined ? null : _ref$fontRegistry;
  9727. _classCallCheck(this, FontFaceObject);
  9728. this.compiledGlyphs = Object.create(null);
  9729. for (var i in translatedData) {
  9730. this[i] = translatedData[i];
  9731. }
  9732. this.isEvalSupported = isEvalSupported !== false;
  9733. this.disableFontFace = disableFontFace === true;
  9734. this.ignoreErrors = ignoreErrors === true;
  9735. this._onUnsupportedFeature = onUnsupportedFeature;
  9736. this.fontRegistry = fontRegistry;
  9737. }
  9738. _createClass(FontFaceObject, [{
  9739. key: 'createNativeFontFace',
  9740. value: function createNativeFontFace() {
  9741. if (!this.data || this.disableFontFace) {
  9742. return null;
  9743. }
  9744. var nativeFontFace = new FontFace(this.loadedName, this.data, {});
  9745. if (this.fontRegistry) {
  9746. this.fontRegistry.registerFont(this);
  9747. }
  9748. return nativeFontFace;
  9749. }
  9750. }, {
  9751. key: 'createFontFaceRule',
  9752. value: function createFontFaceRule() {
  9753. if (!this.data || this.disableFontFace) {
  9754. return null;
  9755. }
  9756. var data = (0, _util.bytesToString)(new Uint8Array(this.data));
  9757. var url = 'url(data:' + this.mimetype + ';base64,' + btoa(data) + ');';
  9758. var rule = '@font-face {font-family:"' + this.loadedName + '";src:' + url + '}';
  9759. if (this.fontRegistry) {
  9760. this.fontRegistry.registerFont(this, url);
  9761. }
  9762. return rule;
  9763. }
  9764. }, {
  9765. key: 'getPathGenerator',
  9766. value: function getPathGenerator(objs, character) {
  9767. if (this.compiledGlyphs[character] !== undefined) {
  9768. return this.compiledGlyphs[character];
  9769. }
  9770. var cmds = void 0,
  9771. current = void 0;
  9772. try {
  9773. cmds = objs.get(this.loadedName + '_path_' + character);
  9774. } catch (ex) {
  9775. if (!this.ignoreErrors) {
  9776. throw ex;
  9777. }
  9778. if (this._onUnsupportedFeature) {
  9779. this._onUnsupportedFeature({ featureId: _util.UNSUPPORTED_FEATURES.font });
  9780. }
  9781. (0, _util.warn)('getPathGenerator - ignoring character: "' + ex + '".');
  9782. return this.compiledGlyphs[character] = function (c, size) {};
  9783. }
  9784. if (this.isEvalSupported && IsEvalSupportedCached.value) {
  9785. var args = void 0,
  9786. js = '';
  9787. for (var i = 0, ii = cmds.length; i < ii; i++) {
  9788. current = cmds[i];
  9789. if (current.args !== undefined) {
  9790. args = current.args.join(',');
  9791. } else {
  9792. args = '';
  9793. }
  9794. js += 'c.' + current.cmd + '(' + args + ');\n';
  9795. }
  9796. return this.compiledGlyphs[character] = new Function('c', 'size', js);
  9797. }
  9798. return this.compiledGlyphs[character] = function (c, size) {
  9799. for (var _i = 0, _ii = cmds.length; _i < _ii; _i++) {
  9800. current = cmds[_i];
  9801. if (current.cmd === 'scale') {
  9802. current.args = [size, -size];
  9803. }
  9804. c[current.cmd].apply(c, current.args);
  9805. }
  9806. };
  9807. }
  9808. }]);
  9809. return FontFaceObject;
  9810. }();
  9811. exports.FontFaceObject = FontFaceObject;
  9812. exports.FontLoader = FontLoader;
  9813. /***/ }),
  9814. /* 132 */
  9815. /***/ (function(module, exports, __w_pdfjs_require__) {
  9816. "use strict";
  9817. var compatibilityParams = Object.create(null);
  9818. {
  9819. var isNodeJS = __w_pdfjs_require__(4);
  9820. var userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
  9821. var isIE = /Trident/.test(userAgent);
  9822. var isIOSChrome = /CriOS/.test(userAgent);
  9823. (function checkOnBlobSupport() {
  9824. if (isIE || isIOSChrome) {
  9825. compatibilityParams.disableCreateObjectURL = true;
  9826. }
  9827. })();
  9828. (function checkFontFaceAndImage() {
  9829. if (isNodeJS()) {
  9830. compatibilityParams.disableFontFace = true;
  9831. compatibilityParams.nativeImageDecoderSupport = 'none';
  9832. }
  9833. })();
  9834. }
  9835. exports.apiCompatibilityParams = Object.freeze(compatibilityParams);
  9836. /***/ }),
  9837. /* 133 */
  9838. /***/ (function(module, exports, __w_pdfjs_require__) {
  9839. "use strict";
  9840. Object.defineProperty(exports, "__esModule", {
  9841. value: true
  9842. });
  9843. exports.CanvasGraphics = undefined;
  9844. var _util = __w_pdfjs_require__(1);
  9845. var _pattern_helper = __w_pdfjs_require__(134);
  9846. var MIN_FONT_SIZE = 16;
  9847. var MAX_FONT_SIZE = 100;
  9848. var MAX_GROUP_SIZE = 4096;
  9849. var MIN_WIDTH_FACTOR = 0.65;
  9850. var COMPILE_TYPE3_GLYPHS = true;
  9851. var MAX_SIZE_TO_COMPILE = 1000;
  9852. var FULL_CHUNK_HEIGHT = 16;
  9853. var IsLittleEndianCached = {
  9854. get value() {
  9855. return (0, _util.shadow)(IsLittleEndianCached, 'value', (0, _util.isLittleEndian)());
  9856. }
  9857. };
  9858. function addContextCurrentTransform(ctx) {
  9859. if (!ctx.mozCurrentTransform) {
  9860. ctx._originalSave = ctx.save;
  9861. ctx._originalRestore = ctx.restore;
  9862. ctx._originalRotate = ctx.rotate;
  9863. ctx._originalScale = ctx.scale;
  9864. ctx._originalTranslate = ctx.translate;
  9865. ctx._originalTransform = ctx.transform;
  9866. ctx._originalSetTransform = ctx.setTransform;
  9867. ctx._transformMatrix = ctx._transformMatrix || [1, 0, 0, 1, 0, 0];
  9868. ctx._transformStack = [];
  9869. Object.defineProperty(ctx, 'mozCurrentTransform', {
  9870. get: function getCurrentTransform() {
  9871. return this._transformMatrix;
  9872. }
  9873. });
  9874. Object.defineProperty(ctx, 'mozCurrentTransformInverse', {
  9875. get: function getCurrentTransformInverse() {
  9876. var m = this._transformMatrix;
  9877. var a = m[0],
  9878. b = m[1],
  9879. c = m[2],
  9880. d = m[3],
  9881. e = m[4],
  9882. f = m[5];
  9883. var ad_bc = a * d - b * c;
  9884. var bc_ad = b * c - a * d;
  9885. 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];
  9886. }
  9887. });
  9888. ctx.save = function ctxSave() {
  9889. var old = this._transformMatrix;
  9890. this._transformStack.push(old);
  9891. this._transformMatrix = old.slice(0, 6);
  9892. this._originalSave();
  9893. };
  9894. ctx.restore = function ctxRestore() {
  9895. var prev = this._transformStack.pop();
  9896. if (prev) {
  9897. this._transformMatrix = prev;
  9898. this._originalRestore();
  9899. }
  9900. };
  9901. ctx.translate = function ctxTranslate(x, y) {
  9902. var m = this._transformMatrix;
  9903. m[4] = m[0] * x + m[2] * y + m[4];
  9904. m[5] = m[1] * x + m[3] * y + m[5];
  9905. this._originalTranslate(x, y);
  9906. };
  9907. ctx.scale = function ctxScale(x, y) {
  9908. var m = this._transformMatrix;
  9909. m[0] = m[0] * x;
  9910. m[1] = m[1] * x;
  9911. m[2] = m[2] * y;
  9912. m[3] = m[3] * y;
  9913. this._originalScale(x, y);
  9914. };
  9915. ctx.transform = function ctxTransform(a, b, c, d, e, f) {
  9916. var m = this._transformMatrix;
  9917. 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]];
  9918. ctx._originalTransform(a, b, c, d, e, f);
  9919. };
  9920. ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
  9921. this._transformMatrix = [a, b, c, d, e, f];
  9922. ctx._originalSetTransform(a, b, c, d, e, f);
  9923. };
  9924. ctx.rotate = function ctxRotate(angle) {
  9925. var cosValue = Math.cos(angle);
  9926. var sinValue = Math.sin(angle);
  9927. var m = this._transformMatrix;
  9928. 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]];
  9929. this._originalRotate(angle);
  9930. };
  9931. }
  9932. }
  9933. var CachedCanvases = function CachedCanvasesClosure() {
  9934. function CachedCanvases(canvasFactory) {
  9935. this.canvasFactory = canvasFactory;
  9936. this.cache = Object.create(null);
  9937. }
  9938. CachedCanvases.prototype = {
  9939. getCanvas: function CachedCanvases_getCanvas(id, width, height, trackTransform) {
  9940. var canvasEntry;
  9941. if (this.cache[id] !== undefined) {
  9942. canvasEntry = this.cache[id];
  9943. this.canvasFactory.reset(canvasEntry, width, height);
  9944. canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0);
  9945. } else {
  9946. canvasEntry = this.canvasFactory.create(width, height);
  9947. this.cache[id] = canvasEntry;
  9948. }
  9949. if (trackTransform) {
  9950. addContextCurrentTransform(canvasEntry.context);
  9951. }
  9952. return canvasEntry;
  9953. },
  9954. clear: function clear() {
  9955. for (var id in this.cache) {
  9956. var canvasEntry = this.cache[id];
  9957. this.canvasFactory.destroy(canvasEntry);
  9958. delete this.cache[id];
  9959. }
  9960. }
  9961. };
  9962. return CachedCanvases;
  9963. }();
  9964. function compileType3Glyph(imgData) {
  9965. var POINT_TO_PROCESS_LIMIT = 1000;
  9966. var width = imgData.width,
  9967. height = imgData.height;
  9968. var i,
  9969. j,
  9970. j0,
  9971. width1 = width + 1;
  9972. var points = new Uint8Array(width1 * (height + 1));
  9973. var POINT_TYPES = new Uint8Array([0, 2, 4, 0, 1, 0, 5, 4, 8, 10, 0, 8, 0, 2, 1, 0]);
  9974. var lineSize = width + 7 & ~7,
  9975. data0 = imgData.data;
  9976. var data = new Uint8Array(lineSize * height),
  9977. pos = 0,
  9978. ii;
  9979. for (i = 0, ii = data0.length; i < ii; i++) {
  9980. var mask = 128,
  9981. elem = data0[i];
  9982. while (mask > 0) {
  9983. data[pos++] = elem & mask ? 0 : 255;
  9984. mask >>= 1;
  9985. }
  9986. }
  9987. var count = 0;
  9988. pos = 0;
  9989. if (data[pos] !== 0) {
  9990. points[0] = 1;
  9991. ++count;
  9992. }
  9993. for (j = 1; j < width; j++) {
  9994. if (data[pos] !== data[pos + 1]) {
  9995. points[j] = data[pos] ? 2 : 1;
  9996. ++count;
  9997. }
  9998. pos++;
  9999. }
  10000. if (data[pos] !== 0) {
  10001. points[j] = 2;
  10002. ++count;
  10003. }
  10004. for (i = 1; i < height; i++) {
  10005. pos = i * lineSize;
  10006. j0 = i * width1;
  10007. if (data[pos - lineSize] !== data[pos]) {
  10008. points[j0] = data[pos] ? 1 : 8;
  10009. ++count;
  10010. }
  10011. var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
  10012. for (j = 1; j < width; j++) {
  10013. sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
  10014. if (POINT_TYPES[sum]) {
  10015. points[j0 + j] = POINT_TYPES[sum];
  10016. ++count;
  10017. }
  10018. pos++;
  10019. }
  10020. if (data[pos - lineSize] !== data[pos]) {
  10021. points[j0 + j] = data[pos] ? 2 : 4;
  10022. ++count;
  10023. }
  10024. if (count > POINT_TO_PROCESS_LIMIT) {
  10025. return null;
  10026. }
  10027. }
  10028. pos = lineSize * (height - 1);
  10029. j0 = i * width1;
  10030. if (data[pos] !== 0) {
  10031. points[j0] = 8;
  10032. ++count;
  10033. }
  10034. for (j = 1; j < width; j++) {
  10035. if (data[pos] !== data[pos + 1]) {
  10036. points[j0 + j] = data[pos] ? 4 : 8;
  10037. ++count;
  10038. }
  10039. pos++;
  10040. }
  10041. if (data[pos] !== 0) {
  10042. points[j0 + j] = 4;
  10043. ++count;
  10044. }
  10045. if (count > POINT_TO_PROCESS_LIMIT) {
  10046. return null;
  10047. }
  10048. var steps = new Int32Array([0, width1, -1, 0, -width1, 0, 0, 0, 1]);
  10049. var outlines = [];
  10050. for (i = 0; count && i <= height; i++) {
  10051. var p = i * width1;
  10052. var end = p + width;
  10053. while (p < end && !points[p]) {
  10054. p++;
  10055. }
  10056. if (p === end) {
  10057. continue;
  10058. }
  10059. var coords = [p % width1, i];
  10060. var type = points[p],
  10061. p0 = p,
  10062. pp;
  10063. do {
  10064. var step = steps[type];
  10065. do {
  10066. p += step;
  10067. } while (!points[p]);
  10068. pp = points[p];
  10069. if (pp !== 5 && pp !== 10) {
  10070. type = pp;
  10071. points[p] = 0;
  10072. } else {
  10073. type = pp & 0x33 * type >> 4;
  10074. points[p] &= type >> 2 | type << 2;
  10075. }
  10076. coords.push(p % width1);
  10077. coords.push(p / width1 | 0);
  10078. --count;
  10079. } while (p0 !== p);
  10080. outlines.push(coords);
  10081. --i;
  10082. }
  10083. var drawOutline = function drawOutline(c) {
  10084. c.save();
  10085. c.scale(1 / width, -1 / height);
  10086. c.translate(0, -height);
  10087. c.beginPath();
  10088. for (var i = 0, ii = outlines.length; i < ii; i++) {
  10089. var o = outlines[i];
  10090. c.moveTo(o[0], o[1]);
  10091. for (var j = 2, jj = o.length; j < jj; j += 2) {
  10092. c.lineTo(o[j], o[j + 1]);
  10093. }
  10094. }
  10095. c.fill();
  10096. c.beginPath();
  10097. c.restore();
  10098. };
  10099. return drawOutline;
  10100. }
  10101. var CanvasExtraState = function CanvasExtraStateClosure() {
  10102. function CanvasExtraState() {
  10103. this.alphaIsShape = false;
  10104. this.fontSize = 0;
  10105. this.fontSizeScale = 1;
  10106. this.textMatrix = _util.IDENTITY_MATRIX;
  10107. this.textMatrixScale = 1;
  10108. this.fontMatrix = _util.FONT_IDENTITY_MATRIX;
  10109. this.leading = 0;
  10110. this.x = 0;
  10111. this.y = 0;
  10112. this.lineX = 0;
  10113. this.lineY = 0;
  10114. this.charSpacing = 0;
  10115. this.wordSpacing = 0;
  10116. this.textHScale = 1;
  10117. this.textRenderingMode = _util.TextRenderingMode.FILL;
  10118. this.textRise = 0;
  10119. this.fillColor = '#000000';
  10120. this.strokeColor = '#000000';
  10121. this.patternFill = false;
  10122. this.fillAlpha = 1;
  10123. this.strokeAlpha = 1;
  10124. this.lineWidth = 1;
  10125. this.activeSMask = null;
  10126. this.resumeSMaskCtx = null;
  10127. }
  10128. CanvasExtraState.prototype = {
  10129. clone: function CanvasExtraState_clone() {
  10130. return Object.create(this);
  10131. },
  10132. setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) {
  10133. this.x = x;
  10134. this.y = y;
  10135. }
  10136. };
  10137. return CanvasExtraState;
  10138. }();
  10139. var CanvasGraphics = function CanvasGraphicsClosure() {
  10140. var EXECUTION_TIME = 15;
  10141. var EXECUTION_STEPS = 10;
  10142. function CanvasGraphics(canvasCtx, commonObjs, objs, canvasFactory, webGLContext, imageLayer) {
  10143. this.ctx = canvasCtx;
  10144. this.current = new CanvasExtraState();
  10145. this.stateStack = [];
  10146. this.pendingClip = null;
  10147. this.pendingEOFill = false;
  10148. this.res = null;
  10149. this.xobjs = null;
  10150. this.commonObjs = commonObjs;
  10151. this.objs = objs;
  10152. this.canvasFactory = canvasFactory;
  10153. this.webGLContext = webGLContext;
  10154. this.imageLayer = imageLayer;
  10155. this.groupStack = [];
  10156. this.processingType3 = null;
  10157. this.baseTransform = null;
  10158. this.baseTransformStack = [];
  10159. this.groupLevel = 0;
  10160. this.smaskStack = [];
  10161. this.smaskCounter = 0;
  10162. this.tempSMask = null;
  10163. this.cachedCanvases = new CachedCanvases(this.canvasFactory);
  10164. if (canvasCtx) {
  10165. addContextCurrentTransform(canvasCtx);
  10166. }
  10167. this._cachedGetSinglePixelWidth = null;
  10168. }
  10169. function putBinaryImageData(ctx, imgData) {
  10170. if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) {
  10171. ctx.putImageData(imgData, 0, 0);
  10172. return;
  10173. }
  10174. var height = imgData.height,
  10175. width = imgData.width;
  10176. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  10177. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  10178. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  10179. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  10180. var srcPos = 0,
  10181. destPos;
  10182. var src = imgData.data;
  10183. var dest = chunkImgData.data;
  10184. var i, j, thisChunkHeight, elemsInThisChunk;
  10185. if (imgData.kind === _util.ImageKind.GRAYSCALE_1BPP) {
  10186. var srcLength = src.byteLength;
  10187. var dest32 = new Uint32Array(dest.buffer, 0, dest.byteLength >> 2);
  10188. var dest32DataLength = dest32.length;
  10189. var fullSrcDiff = width + 7 >> 3;
  10190. var white = 0xFFFFFFFF;
  10191. var black = IsLittleEndianCached.value ? 0xFF000000 : 0x000000FF;
  10192. for (i = 0; i < totalChunks; i++) {
  10193. thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  10194. destPos = 0;
  10195. for (j = 0; j < thisChunkHeight; j++) {
  10196. var srcDiff = srcLength - srcPos;
  10197. var k = 0;
  10198. var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
  10199. var kEndUnrolled = kEnd & ~7;
  10200. var mask = 0;
  10201. var srcByte = 0;
  10202. for (; k < kEndUnrolled; k += 8) {
  10203. srcByte = src[srcPos++];
  10204. dest32[destPos++] = srcByte & 128 ? white : black;
  10205. dest32[destPos++] = srcByte & 64 ? white : black;
  10206. dest32[destPos++] = srcByte & 32 ? white : black;
  10207. dest32[destPos++] = srcByte & 16 ? white : black;
  10208. dest32[destPos++] = srcByte & 8 ? white : black;
  10209. dest32[destPos++] = srcByte & 4 ? white : black;
  10210. dest32[destPos++] = srcByte & 2 ? white : black;
  10211. dest32[destPos++] = srcByte & 1 ? white : black;
  10212. }
  10213. for (; k < kEnd; k++) {
  10214. if (mask === 0) {
  10215. srcByte = src[srcPos++];
  10216. mask = 128;
  10217. }
  10218. dest32[destPos++] = srcByte & mask ? white : black;
  10219. mask >>= 1;
  10220. }
  10221. }
  10222. while (destPos < dest32DataLength) {
  10223. dest32[destPos++] = 0;
  10224. }
  10225. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  10226. }
  10227. } else if (imgData.kind === _util.ImageKind.RGBA_32BPP) {
  10228. j = 0;
  10229. elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
  10230. for (i = 0; i < fullChunks; i++) {
  10231. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  10232. srcPos += elemsInThisChunk;
  10233. ctx.putImageData(chunkImgData, 0, j);
  10234. j += FULL_CHUNK_HEIGHT;
  10235. }
  10236. if (i < totalChunks) {
  10237. elemsInThisChunk = width * partialChunkHeight * 4;
  10238. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  10239. ctx.putImageData(chunkImgData, 0, j);
  10240. }
  10241. } else if (imgData.kind === _util.ImageKind.RGB_24BPP) {
  10242. thisChunkHeight = FULL_CHUNK_HEIGHT;
  10243. elemsInThisChunk = width * thisChunkHeight;
  10244. for (i = 0; i < totalChunks; i++) {
  10245. if (i >= fullChunks) {
  10246. thisChunkHeight = partialChunkHeight;
  10247. elemsInThisChunk = width * thisChunkHeight;
  10248. }
  10249. destPos = 0;
  10250. for (j = elemsInThisChunk; j--;) {
  10251. dest[destPos++] = src[srcPos++];
  10252. dest[destPos++] = src[srcPos++];
  10253. dest[destPos++] = src[srcPos++];
  10254. dest[destPos++] = 255;
  10255. }
  10256. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  10257. }
  10258. } else {
  10259. throw new Error('bad image kind: ' + imgData.kind);
  10260. }
  10261. }
  10262. function putBinaryImageMask(ctx, imgData) {
  10263. var height = imgData.height,
  10264. width = imgData.width;
  10265. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  10266. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  10267. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  10268. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  10269. var srcPos = 0;
  10270. var src = imgData.data;
  10271. var dest = chunkImgData.data;
  10272. for (var i = 0; i < totalChunks; i++) {
  10273. var thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  10274. var destPos = 3;
  10275. for (var j = 0; j < thisChunkHeight; j++) {
  10276. var mask = 0;
  10277. for (var k = 0; k < width; k++) {
  10278. if (!mask) {
  10279. var elem = src[srcPos++];
  10280. mask = 128;
  10281. }
  10282. dest[destPos] = elem & mask ? 0 : 255;
  10283. destPos += 4;
  10284. mask >>= 1;
  10285. }
  10286. }
  10287. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  10288. }
  10289. }
  10290. function copyCtxState(sourceCtx, destCtx) {
  10291. var properties = ['strokeStyle', 'fillStyle', 'fillRule', 'globalAlpha', 'lineWidth', 'lineCap', 'lineJoin', 'miterLimit', 'globalCompositeOperation', 'font'];
  10292. for (var i = 0, ii = properties.length; i < ii; i++) {
  10293. var property = properties[i];
  10294. if (sourceCtx[property] !== undefined) {
  10295. destCtx[property] = sourceCtx[property];
  10296. }
  10297. }
  10298. if (sourceCtx.setLineDash !== undefined) {
  10299. destCtx.setLineDash(sourceCtx.getLineDash());
  10300. destCtx.lineDashOffset = sourceCtx.lineDashOffset;
  10301. }
  10302. }
  10303. function resetCtxToDefault(ctx) {
  10304. ctx.strokeStyle = '#000000';
  10305. ctx.fillStyle = '#000000';
  10306. ctx.fillRule = 'nonzero';
  10307. ctx.globalAlpha = 1;
  10308. ctx.lineWidth = 1;
  10309. ctx.lineCap = 'butt';
  10310. ctx.lineJoin = 'miter';
  10311. ctx.miterLimit = 10;
  10312. ctx.globalCompositeOperation = 'source-over';
  10313. ctx.font = '10px sans-serif';
  10314. if (ctx.setLineDash !== undefined) {
  10315. ctx.setLineDash([]);
  10316. ctx.lineDashOffset = 0;
  10317. }
  10318. }
  10319. function composeSMaskBackdrop(bytes, r0, g0, b0) {
  10320. var length = bytes.length;
  10321. for (var i = 3; i < length; i += 4) {
  10322. var alpha = bytes[i];
  10323. if (alpha === 0) {
  10324. bytes[i - 3] = r0;
  10325. bytes[i - 2] = g0;
  10326. bytes[i - 1] = b0;
  10327. } else if (alpha < 255) {
  10328. var alpha_ = 255 - alpha;
  10329. bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8;
  10330. bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8;
  10331. bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8;
  10332. }
  10333. }
  10334. }
  10335. function composeSMaskAlpha(maskData, layerData, transferMap) {
  10336. var length = maskData.length;
  10337. var scale = 1 / 255;
  10338. for (var i = 3; i < length; i += 4) {
  10339. var alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
  10340. layerData[i] = layerData[i] * alpha * scale | 0;
  10341. }
  10342. }
  10343. function composeSMaskLuminosity(maskData, layerData, transferMap) {
  10344. var length = maskData.length;
  10345. for (var i = 3; i < length; i += 4) {
  10346. var y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28;
  10347. layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16;
  10348. }
  10349. }
  10350. function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap) {
  10351. var hasBackdrop = !!backdrop;
  10352. var r0 = hasBackdrop ? backdrop[0] : 0;
  10353. var g0 = hasBackdrop ? backdrop[1] : 0;
  10354. var b0 = hasBackdrop ? backdrop[2] : 0;
  10355. var composeFn;
  10356. if (subtype === 'Luminosity') {
  10357. composeFn = composeSMaskLuminosity;
  10358. } else {
  10359. composeFn = composeSMaskAlpha;
  10360. }
  10361. var PIXELS_TO_PROCESS = 1048576;
  10362. var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
  10363. for (var row = 0; row < height; row += chunkSize) {
  10364. var chunkHeight = Math.min(chunkSize, height - row);
  10365. var maskData = maskCtx.getImageData(0, row, width, chunkHeight);
  10366. var layerData = layerCtx.getImageData(0, row, width, chunkHeight);
  10367. if (hasBackdrop) {
  10368. composeSMaskBackdrop(maskData.data, r0, g0, b0);
  10369. }
  10370. composeFn(maskData.data, layerData.data, transferMap);
  10371. maskCtx.putImageData(layerData, 0, row);
  10372. }
  10373. }
  10374. function composeSMask(ctx, smask, layerCtx, webGLContext) {
  10375. var mask = smask.canvas;
  10376. var maskCtx = smask.context;
  10377. ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY, smask.offsetX, smask.offsetY);
  10378. var backdrop = smask.backdrop || null;
  10379. if (!smask.transferMap && webGLContext.isEnabled) {
  10380. var composed = webGLContext.composeSMask({
  10381. layer: layerCtx.canvas,
  10382. mask: mask,
  10383. properties: {
  10384. subtype: smask.subtype,
  10385. backdrop: backdrop
  10386. }
  10387. });
  10388. ctx.setTransform(1, 0, 0, 1, 0, 0);
  10389. ctx.drawImage(composed, smask.offsetX, smask.offsetY);
  10390. return;
  10391. }
  10392. genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height, smask.subtype, backdrop, smask.transferMap);
  10393. ctx.drawImage(mask, 0, 0);
  10394. }
  10395. var LINE_CAP_STYLES = ['butt', 'round', 'square'];
  10396. var LINE_JOIN_STYLES = ['miter', 'round', 'bevel'];
  10397. var NORMAL_CLIP = {};
  10398. var EO_CLIP = {};
  10399. CanvasGraphics.prototype = {
  10400. beginDrawing: function beginDrawing(_ref) {
  10401. var transform = _ref.transform,
  10402. viewport = _ref.viewport,
  10403. transparency = _ref.transparency,
  10404. _ref$background = _ref.background,
  10405. background = _ref$background === undefined ? null : _ref$background;
  10406. var width = this.ctx.canvas.width;
  10407. var height = this.ctx.canvas.height;
  10408. this.ctx.save();
  10409. this.ctx.fillStyle = background || 'rgb(255, 255, 255)';
  10410. this.ctx.fillRect(0, 0, width, height);
  10411. this.ctx.restore();
  10412. if (transparency) {
  10413. var transparentCanvas = this.cachedCanvases.getCanvas('transparent', width, height, true);
  10414. this.compositeCtx = this.ctx;
  10415. this.transparentCanvas = transparentCanvas.canvas;
  10416. this.ctx = transparentCanvas.context;
  10417. this.ctx.save();
  10418. this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform);
  10419. }
  10420. this.ctx.save();
  10421. resetCtxToDefault(this.ctx);
  10422. if (transform) {
  10423. this.ctx.transform.apply(this.ctx, transform);
  10424. }
  10425. this.ctx.transform.apply(this.ctx, viewport.transform);
  10426. this.baseTransform = this.ctx.mozCurrentTransform.slice();
  10427. if (this.imageLayer) {
  10428. this.imageLayer.beginLayout();
  10429. }
  10430. },
  10431. executeOperatorList: function CanvasGraphics_executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
  10432. var argsArray = operatorList.argsArray;
  10433. var fnArray = operatorList.fnArray;
  10434. var i = executionStartIdx || 0;
  10435. var argsArrayLen = argsArray.length;
  10436. if (argsArrayLen === i) {
  10437. return i;
  10438. }
  10439. var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === 'function';
  10440. var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
  10441. var steps = 0;
  10442. var commonObjs = this.commonObjs;
  10443. var objs = this.objs;
  10444. var fnId;
  10445. while (true) {
  10446. if (stepper !== undefined && i === stepper.nextBreakPoint) {
  10447. stepper.breakIt(i, continueCallback);
  10448. return i;
  10449. }
  10450. fnId = fnArray[i];
  10451. if (fnId !== _util.OPS.dependency) {
  10452. this[fnId].apply(this, argsArray[i]);
  10453. } else {
  10454. var deps = argsArray[i];
  10455. for (var n = 0, nn = deps.length; n < nn; n++) {
  10456. var depObjId = deps[n];
  10457. var common = depObjId[0] === 'g' && depObjId[1] === '_';
  10458. var objsPool = common ? commonObjs : objs;
  10459. if (!objsPool.isResolved(depObjId)) {
  10460. objsPool.get(depObjId, continueCallback);
  10461. return i;
  10462. }
  10463. }
  10464. }
  10465. i++;
  10466. if (i === argsArrayLen) {
  10467. return i;
  10468. }
  10469. if (chunkOperations && ++steps > EXECUTION_STEPS) {
  10470. if (Date.now() > endTime) {
  10471. continueCallback();
  10472. return i;
  10473. }
  10474. steps = 0;
  10475. }
  10476. }
  10477. },
  10478. endDrawing: function CanvasGraphics_endDrawing() {
  10479. if (this.current.activeSMask !== null) {
  10480. this.endSMaskGroup();
  10481. }
  10482. this.ctx.restore();
  10483. if (this.transparentCanvas) {
  10484. this.ctx = this.compositeCtx;
  10485. this.ctx.save();
  10486. this.ctx.setTransform(1, 0, 0, 1, 0, 0);
  10487. this.ctx.drawImage(this.transparentCanvas, 0, 0);
  10488. this.ctx.restore();
  10489. this.transparentCanvas = null;
  10490. }
  10491. this.cachedCanvases.clear();
  10492. this.webGLContext.clear();
  10493. if (this.imageLayer) {
  10494. this.imageLayer.endLayout();
  10495. }
  10496. },
  10497. setLineWidth: function CanvasGraphics_setLineWidth(width) {
  10498. this.current.lineWidth = width;
  10499. this.ctx.lineWidth = width;
  10500. },
  10501. setLineCap: function CanvasGraphics_setLineCap(style) {
  10502. this.ctx.lineCap = LINE_CAP_STYLES[style];
  10503. },
  10504. setLineJoin: function CanvasGraphics_setLineJoin(style) {
  10505. this.ctx.lineJoin = LINE_JOIN_STYLES[style];
  10506. },
  10507. setMiterLimit: function CanvasGraphics_setMiterLimit(limit) {
  10508. this.ctx.miterLimit = limit;
  10509. },
  10510. setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
  10511. var ctx = this.ctx;
  10512. if (ctx.setLineDash !== undefined) {
  10513. ctx.setLineDash(dashArray);
  10514. ctx.lineDashOffset = dashPhase;
  10515. }
  10516. },
  10517. setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {},
  10518. setFlatness: function CanvasGraphics_setFlatness(flatness) {},
  10519. setGState: function CanvasGraphics_setGState(states) {
  10520. for (var i = 0, ii = states.length; i < ii; i++) {
  10521. var state = states[i];
  10522. var key = state[0];
  10523. var value = state[1];
  10524. switch (key) {
  10525. case 'LW':
  10526. this.setLineWidth(value);
  10527. break;
  10528. case 'LC':
  10529. this.setLineCap(value);
  10530. break;
  10531. case 'LJ':
  10532. this.setLineJoin(value);
  10533. break;
  10534. case 'ML':
  10535. this.setMiterLimit(value);
  10536. break;
  10537. case 'D':
  10538. this.setDash(value[0], value[1]);
  10539. break;
  10540. case 'RI':
  10541. this.setRenderingIntent(value);
  10542. break;
  10543. case 'FL':
  10544. this.setFlatness(value);
  10545. break;
  10546. case 'Font':
  10547. this.setFont(value[0], value[1]);
  10548. break;
  10549. case 'CA':
  10550. this.current.strokeAlpha = state[1];
  10551. break;
  10552. case 'ca':
  10553. this.current.fillAlpha = state[1];
  10554. this.ctx.globalAlpha = state[1];
  10555. break;
  10556. case 'BM':
  10557. this.ctx.globalCompositeOperation = value;
  10558. break;
  10559. case 'SMask':
  10560. if (this.current.activeSMask) {
  10561. if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) {
  10562. this.suspendSMaskGroup();
  10563. } else {
  10564. this.endSMaskGroup();
  10565. }
  10566. }
  10567. this.current.activeSMask = value ? this.tempSMask : null;
  10568. if (this.current.activeSMask) {
  10569. this.beginSMaskGroup();
  10570. }
  10571. this.tempSMask = null;
  10572. break;
  10573. }
  10574. }
  10575. },
  10576. beginSMaskGroup: function CanvasGraphics_beginSMaskGroup() {
  10577. var activeSMask = this.current.activeSMask;
  10578. var drawnWidth = activeSMask.canvas.width;
  10579. var drawnHeight = activeSMask.canvas.height;
  10580. var cacheId = 'smaskGroupAt' + this.groupLevel;
  10581. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  10582. var currentCtx = this.ctx;
  10583. var currentTransform = currentCtx.mozCurrentTransform;
  10584. this.ctx.save();
  10585. var groupCtx = scratchCanvas.context;
  10586. groupCtx.scale(1 / activeSMask.scaleX, 1 / activeSMask.scaleY);
  10587. groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY);
  10588. groupCtx.transform.apply(groupCtx, currentTransform);
  10589. activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
  10590. copyCtxState(currentCtx, groupCtx);
  10591. this.ctx = groupCtx;
  10592. this.setGState([['BM', 'source-over'], ['ca', 1], ['CA', 1]]);
  10593. this.groupStack.push(currentCtx);
  10594. this.groupLevel++;
  10595. },
  10596. suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  10597. var groupCtx = this.ctx;
  10598. this.groupLevel--;
  10599. this.ctx = this.groupStack.pop();
  10600. composeSMask(this.ctx, this.current.activeSMask, groupCtx, this.webGLContext);
  10601. this.ctx.restore();
  10602. this.ctx.save();
  10603. copyCtxState(groupCtx, this.ctx);
  10604. this.current.resumeSMaskCtx = groupCtx;
  10605. var deltaTransform = _util.Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  10606. this.ctx.transform.apply(this.ctx, deltaTransform);
  10607. groupCtx.save();
  10608. groupCtx.setTransform(1, 0, 0, 1, 0, 0);
  10609. groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height);
  10610. groupCtx.restore();
  10611. },
  10612. resumeSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  10613. var groupCtx = this.current.resumeSMaskCtx;
  10614. var currentCtx = this.ctx;
  10615. this.ctx = groupCtx;
  10616. this.groupStack.push(currentCtx);
  10617. this.groupLevel++;
  10618. },
  10619. endSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  10620. var groupCtx = this.ctx;
  10621. this.groupLevel--;
  10622. this.ctx = this.groupStack.pop();
  10623. composeSMask(this.ctx, this.current.activeSMask, groupCtx, this.webGLContext);
  10624. this.ctx.restore();
  10625. copyCtxState(groupCtx, this.ctx);
  10626. var deltaTransform = _util.Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  10627. this.ctx.transform.apply(this.ctx, deltaTransform);
  10628. },
  10629. save: function CanvasGraphics_save() {
  10630. this.ctx.save();
  10631. var old = this.current;
  10632. this.stateStack.push(old);
  10633. this.current = old.clone();
  10634. this.current.resumeSMaskCtx = null;
  10635. },
  10636. restore: function CanvasGraphics_restore() {
  10637. if (this.current.resumeSMaskCtx) {
  10638. this.resumeSMaskGroup();
  10639. }
  10640. if (this.current.activeSMask !== null && (this.stateStack.length === 0 || this.stateStack[this.stateStack.length - 1].activeSMask !== this.current.activeSMask)) {
  10641. this.endSMaskGroup();
  10642. }
  10643. if (this.stateStack.length !== 0) {
  10644. this.current = this.stateStack.pop();
  10645. this.ctx.restore();
  10646. this.pendingClip = null;
  10647. this._cachedGetSinglePixelWidth = null;
  10648. }
  10649. },
  10650. transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
  10651. this.ctx.transform(a, b, c, d, e, f);
  10652. this._cachedGetSinglePixelWidth = null;
  10653. },
  10654. constructPath: function CanvasGraphics_constructPath(ops, args) {
  10655. var ctx = this.ctx;
  10656. var current = this.current;
  10657. var x = current.x,
  10658. y = current.y;
  10659. for (var i = 0, j = 0, ii = ops.length; i < ii; i++) {
  10660. switch (ops[i] | 0) {
  10661. case _util.OPS.rectangle:
  10662. x = args[j++];
  10663. y = args[j++];
  10664. var width = args[j++];
  10665. var height = args[j++];
  10666. if (width === 0) {
  10667. width = this.getSinglePixelWidth();
  10668. }
  10669. if (height === 0) {
  10670. height = this.getSinglePixelWidth();
  10671. }
  10672. var xw = x + width;
  10673. var yh = y + height;
  10674. this.ctx.moveTo(x, y);
  10675. this.ctx.lineTo(xw, y);
  10676. this.ctx.lineTo(xw, yh);
  10677. this.ctx.lineTo(x, yh);
  10678. this.ctx.lineTo(x, y);
  10679. this.ctx.closePath();
  10680. break;
  10681. case _util.OPS.moveTo:
  10682. x = args[j++];
  10683. y = args[j++];
  10684. ctx.moveTo(x, y);
  10685. break;
  10686. case _util.OPS.lineTo:
  10687. x = args[j++];
  10688. y = args[j++];
  10689. ctx.lineTo(x, y);
  10690. break;
  10691. case _util.OPS.curveTo:
  10692. x = args[j + 4];
  10693. y = args[j + 5];
  10694. ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y);
  10695. j += 6;
  10696. break;
  10697. case _util.OPS.curveTo2:
  10698. ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]);
  10699. x = args[j + 2];
  10700. y = args[j + 3];
  10701. j += 4;
  10702. break;
  10703. case _util.OPS.curveTo3:
  10704. x = args[j + 2];
  10705. y = args[j + 3];
  10706. ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
  10707. j += 4;
  10708. break;
  10709. case _util.OPS.closePath:
  10710. ctx.closePath();
  10711. break;
  10712. }
  10713. }
  10714. current.setCurrentPoint(x, y);
  10715. },
  10716. closePath: function CanvasGraphics_closePath() {
  10717. this.ctx.closePath();
  10718. },
  10719. stroke: function CanvasGraphics_stroke(consumePath) {
  10720. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  10721. var ctx = this.ctx;
  10722. var strokeColor = this.current.strokeColor;
  10723. ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
  10724. ctx.globalAlpha = this.current.strokeAlpha;
  10725. if (strokeColor && strokeColor.hasOwnProperty('type') && strokeColor.type === 'Pattern') {
  10726. ctx.save();
  10727. ctx.strokeStyle = strokeColor.getPattern(ctx, this);
  10728. ctx.stroke();
  10729. ctx.restore();
  10730. } else {
  10731. ctx.stroke();
  10732. }
  10733. if (consumePath) {
  10734. this.consumePath();
  10735. }
  10736. ctx.globalAlpha = this.current.fillAlpha;
  10737. },
  10738. closeStroke: function CanvasGraphics_closeStroke() {
  10739. this.closePath();
  10740. this.stroke();
  10741. },
  10742. fill: function CanvasGraphics_fill(consumePath) {
  10743. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  10744. var ctx = this.ctx;
  10745. var fillColor = this.current.fillColor;
  10746. var isPatternFill = this.current.patternFill;
  10747. var needRestore = false;
  10748. if (isPatternFill) {
  10749. ctx.save();
  10750. if (this.baseTransform) {
  10751. ctx.setTransform.apply(ctx, this.baseTransform);
  10752. }
  10753. ctx.fillStyle = fillColor.getPattern(ctx, this);
  10754. needRestore = true;
  10755. }
  10756. if (this.pendingEOFill) {
  10757. ctx.fill('evenodd');
  10758. this.pendingEOFill = false;
  10759. } else {
  10760. ctx.fill();
  10761. }
  10762. if (needRestore) {
  10763. ctx.restore();
  10764. }
  10765. if (consumePath) {
  10766. this.consumePath();
  10767. }
  10768. },
  10769. eoFill: function CanvasGraphics_eoFill() {
  10770. this.pendingEOFill = true;
  10771. this.fill();
  10772. },
  10773. fillStroke: function CanvasGraphics_fillStroke() {
  10774. this.fill(false);
  10775. this.stroke(false);
  10776. this.consumePath();
  10777. },
  10778. eoFillStroke: function CanvasGraphics_eoFillStroke() {
  10779. this.pendingEOFill = true;
  10780. this.fillStroke();
  10781. },
  10782. closeFillStroke: function CanvasGraphics_closeFillStroke() {
  10783. this.closePath();
  10784. this.fillStroke();
  10785. },
  10786. closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() {
  10787. this.pendingEOFill = true;
  10788. this.closePath();
  10789. this.fillStroke();
  10790. },
  10791. endPath: function CanvasGraphics_endPath() {
  10792. this.consumePath();
  10793. },
  10794. clip: function CanvasGraphics_clip() {
  10795. this.pendingClip = NORMAL_CLIP;
  10796. },
  10797. eoClip: function CanvasGraphics_eoClip() {
  10798. this.pendingClip = EO_CLIP;
  10799. },
  10800. beginText: function CanvasGraphics_beginText() {
  10801. this.current.textMatrix = _util.IDENTITY_MATRIX;
  10802. this.current.textMatrixScale = 1;
  10803. this.current.x = this.current.lineX = 0;
  10804. this.current.y = this.current.lineY = 0;
  10805. },
  10806. endText: function CanvasGraphics_endText() {
  10807. var paths = this.pendingTextPaths;
  10808. var ctx = this.ctx;
  10809. if (paths === undefined) {
  10810. ctx.beginPath();
  10811. return;
  10812. }
  10813. ctx.save();
  10814. ctx.beginPath();
  10815. for (var i = 0; i < paths.length; i++) {
  10816. var path = paths[i];
  10817. ctx.setTransform.apply(ctx, path.transform);
  10818. ctx.translate(path.x, path.y);
  10819. path.addToPath(ctx, path.fontSize);
  10820. }
  10821. ctx.restore();
  10822. ctx.clip();
  10823. ctx.beginPath();
  10824. delete this.pendingTextPaths;
  10825. },
  10826. setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) {
  10827. this.current.charSpacing = spacing;
  10828. },
  10829. setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) {
  10830. this.current.wordSpacing = spacing;
  10831. },
  10832. setHScale: function CanvasGraphics_setHScale(scale) {
  10833. this.current.textHScale = scale / 100;
  10834. },
  10835. setLeading: function CanvasGraphics_setLeading(leading) {
  10836. this.current.leading = -leading;
  10837. },
  10838. setFont: function CanvasGraphics_setFont(fontRefName, size) {
  10839. var fontObj = this.commonObjs.get(fontRefName);
  10840. var current = this.current;
  10841. if (!fontObj) {
  10842. throw new Error('Can\'t find font for ' + fontRefName);
  10843. }
  10844. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : _util.FONT_IDENTITY_MATRIX;
  10845. if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
  10846. (0, _util.warn)('Invalid font matrix for font ' + fontRefName);
  10847. }
  10848. if (size < 0) {
  10849. size = -size;
  10850. current.fontDirection = -1;
  10851. } else {
  10852. current.fontDirection = 1;
  10853. }
  10854. this.current.font = fontObj;
  10855. this.current.fontSize = size;
  10856. if (fontObj.isType3Font) {
  10857. return;
  10858. }
  10859. var name = fontObj.loadedName || 'sans-serif';
  10860. var bold = fontObj.black ? '900' : fontObj.bold ? 'bold' : 'normal';
  10861. var italic = fontObj.italic ? 'italic' : 'normal';
  10862. var typeface = '"' + name + '", ' + fontObj.fallbackName;
  10863. var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
  10864. this.current.fontSizeScale = size / browserFontSize;
  10865. var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
  10866. this.ctx.font = rule;
  10867. },
  10868. setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
  10869. this.current.textRenderingMode = mode;
  10870. },
  10871. setTextRise: function CanvasGraphics_setTextRise(rise) {
  10872. this.current.textRise = rise;
  10873. },
  10874. moveText: function CanvasGraphics_moveText(x, y) {
  10875. this.current.x = this.current.lineX += x;
  10876. this.current.y = this.current.lineY += y;
  10877. },
  10878. setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) {
  10879. this.setLeading(-y);
  10880. this.moveText(x, y);
  10881. },
  10882. setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) {
  10883. this.current.textMatrix = [a, b, c, d, e, f];
  10884. this.current.textMatrixScale = Math.sqrt(a * a + b * b);
  10885. this.current.x = this.current.lineX = 0;
  10886. this.current.y = this.current.lineY = 0;
  10887. },
  10888. nextLine: function CanvasGraphics_nextLine() {
  10889. this.moveText(0, this.current.leading);
  10890. },
  10891. paintChar: function paintChar(character, x, y, patternTransform) {
  10892. var ctx = this.ctx;
  10893. var current = this.current;
  10894. var font = current.font;
  10895. var textRenderingMode = current.textRenderingMode;
  10896. var fontSize = current.fontSize / current.fontSizeScale;
  10897. var fillStrokeMode = textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
  10898. var isAddToPathSet = !!(textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG);
  10899. var patternFill = current.patternFill && font.data;
  10900. var addToPath;
  10901. if (font.disableFontFace || isAddToPathSet || patternFill) {
  10902. addToPath = font.getPathGenerator(this.commonObjs, character);
  10903. }
  10904. if (font.disableFontFace || patternFill) {
  10905. ctx.save();
  10906. ctx.translate(x, y);
  10907. ctx.beginPath();
  10908. addToPath(ctx, fontSize);
  10909. if (patternTransform) {
  10910. ctx.setTransform.apply(ctx, patternTransform);
  10911. }
  10912. if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  10913. ctx.fill();
  10914. }
  10915. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  10916. ctx.stroke();
  10917. }
  10918. ctx.restore();
  10919. } else {
  10920. if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  10921. ctx.fillText(character, x, y);
  10922. }
  10923. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  10924. ctx.strokeText(character, x, y);
  10925. }
  10926. }
  10927. if (isAddToPathSet) {
  10928. var paths = this.pendingTextPaths || (this.pendingTextPaths = []);
  10929. paths.push({
  10930. transform: ctx.mozCurrentTransform,
  10931. x: x,
  10932. y: y,
  10933. fontSize: fontSize,
  10934. addToPath: addToPath
  10935. });
  10936. }
  10937. },
  10938. get isFontSubpixelAAEnabled() {
  10939. var ctx = this.canvasFactory.create(10, 10).context;
  10940. ctx.scale(1.5, 1);
  10941. ctx.fillText('I', 0, 10);
  10942. var data = ctx.getImageData(0, 0, 10, 10).data;
  10943. var enabled = false;
  10944. for (var i = 3; i < data.length; i += 4) {
  10945. if (data[i] > 0 && data[i] < 255) {
  10946. enabled = true;
  10947. break;
  10948. }
  10949. }
  10950. return (0, _util.shadow)(this, 'isFontSubpixelAAEnabled', enabled);
  10951. },
  10952. showText: function CanvasGraphics_showText(glyphs) {
  10953. var current = this.current;
  10954. var font = current.font;
  10955. if (font.isType3Font) {
  10956. return this.showType3Text(glyphs);
  10957. }
  10958. var fontSize = current.fontSize;
  10959. if (fontSize === 0) {
  10960. return;
  10961. }
  10962. var ctx = this.ctx;
  10963. var fontSizeScale = current.fontSizeScale;
  10964. var charSpacing = current.charSpacing;
  10965. var wordSpacing = current.wordSpacing;
  10966. var fontDirection = current.fontDirection;
  10967. var textHScale = current.textHScale * fontDirection;
  10968. var glyphsLength = glyphs.length;
  10969. var vertical = font.vertical;
  10970. var spacingDir = vertical ? 1 : -1;
  10971. var defaultVMetrics = font.defaultVMetrics;
  10972. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  10973. var simpleFillText = current.textRenderingMode === _util.TextRenderingMode.FILL && !font.disableFontFace && !current.patternFill;
  10974. ctx.save();
  10975. var patternTransform = void 0;
  10976. if (current.patternFill) {
  10977. ctx.save();
  10978. var pattern = current.fillColor.getPattern(ctx, this);
  10979. patternTransform = ctx.mozCurrentTransform;
  10980. ctx.restore();
  10981. ctx.fillStyle = pattern;
  10982. }
  10983. ctx.transform.apply(ctx, current.textMatrix);
  10984. ctx.translate(current.x, current.y + current.textRise);
  10985. if (fontDirection > 0) {
  10986. ctx.scale(textHScale, -1);
  10987. } else {
  10988. ctx.scale(textHScale, 1);
  10989. }
  10990. var lineWidth = current.lineWidth;
  10991. var scale = current.textMatrixScale;
  10992. if (scale === 0 || lineWidth === 0) {
  10993. var fillStrokeMode = current.textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
  10994. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  10995. this._cachedGetSinglePixelWidth = null;
  10996. lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR;
  10997. }
  10998. } else {
  10999. lineWidth /= scale;
  11000. }
  11001. if (fontSizeScale !== 1.0) {
  11002. ctx.scale(fontSizeScale, fontSizeScale);
  11003. lineWidth /= fontSizeScale;
  11004. }
  11005. ctx.lineWidth = lineWidth;
  11006. var x = 0,
  11007. i;
  11008. for (i = 0; i < glyphsLength; ++i) {
  11009. var glyph = glyphs[i];
  11010. if ((0, _util.isNum)(glyph)) {
  11011. x += spacingDir * glyph * fontSize / 1000;
  11012. continue;
  11013. }
  11014. var restoreNeeded = false;
  11015. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  11016. var character = glyph.fontChar;
  11017. var accent = glyph.accent;
  11018. var scaledX, scaledY, scaledAccentX, scaledAccentY;
  11019. var width = glyph.width;
  11020. if (vertical) {
  11021. var vmetric, vx, vy;
  11022. vmetric = glyph.vmetric || defaultVMetrics;
  11023. vx = glyph.vmetric ? vmetric[1] : width * 0.5;
  11024. vx = -vx * widthAdvanceScale;
  11025. vy = vmetric[2] * widthAdvanceScale;
  11026. width = vmetric ? -vmetric[0] : width;
  11027. scaledX = vx / fontSizeScale;
  11028. scaledY = (x + vy) / fontSizeScale;
  11029. } else {
  11030. scaledX = x / fontSizeScale;
  11031. scaledY = 0;
  11032. }
  11033. if (font.remeasure && width > 0) {
  11034. var measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale;
  11035. if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
  11036. var characterScaleX = width / measuredWidth;
  11037. restoreNeeded = true;
  11038. ctx.save();
  11039. ctx.scale(characterScaleX, 1);
  11040. scaledX /= characterScaleX;
  11041. } else if (width !== measuredWidth) {
  11042. scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale;
  11043. }
  11044. }
  11045. if (glyph.isInFont || font.missingFile) {
  11046. if (simpleFillText && !accent) {
  11047. ctx.fillText(character, scaledX, scaledY);
  11048. } else {
  11049. this.paintChar(character, scaledX, scaledY, patternTransform);
  11050. if (accent) {
  11051. scaledAccentX = scaledX + accent.offset.x / fontSizeScale;
  11052. scaledAccentY = scaledY - accent.offset.y / fontSizeScale;
  11053. this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY, patternTransform);
  11054. }
  11055. }
  11056. }
  11057. var charWidth = width * widthAdvanceScale + spacing * fontDirection;
  11058. x += charWidth;
  11059. if (restoreNeeded) {
  11060. ctx.restore();
  11061. }
  11062. }
  11063. if (vertical) {
  11064. current.y -= x * textHScale;
  11065. } else {
  11066. current.x += x * textHScale;
  11067. }
  11068. ctx.restore();
  11069. },
  11070. showType3Text: function CanvasGraphics_showType3Text(glyphs) {
  11071. var ctx = this.ctx;
  11072. var current = this.current;
  11073. var font = current.font;
  11074. var fontSize = current.fontSize;
  11075. var fontDirection = current.fontDirection;
  11076. var spacingDir = font.vertical ? 1 : -1;
  11077. var charSpacing = current.charSpacing;
  11078. var wordSpacing = current.wordSpacing;
  11079. var textHScale = current.textHScale * fontDirection;
  11080. var fontMatrix = current.fontMatrix || _util.FONT_IDENTITY_MATRIX;
  11081. var glyphsLength = glyphs.length;
  11082. var isTextInvisible = current.textRenderingMode === _util.TextRenderingMode.INVISIBLE;
  11083. var i, glyph, width, spacingLength;
  11084. if (isTextInvisible || fontSize === 0) {
  11085. return;
  11086. }
  11087. this._cachedGetSinglePixelWidth = null;
  11088. ctx.save();
  11089. ctx.transform.apply(ctx, current.textMatrix);
  11090. ctx.translate(current.x, current.y);
  11091. ctx.scale(textHScale, fontDirection);
  11092. for (i = 0; i < glyphsLength; ++i) {
  11093. glyph = glyphs[i];
  11094. if ((0, _util.isNum)(glyph)) {
  11095. spacingLength = spacingDir * glyph * fontSize / 1000;
  11096. this.ctx.translate(spacingLength, 0);
  11097. current.x += spacingLength * textHScale;
  11098. continue;
  11099. }
  11100. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  11101. var operatorList = font.charProcOperatorList[glyph.operatorListId];
  11102. if (!operatorList) {
  11103. (0, _util.warn)('Type3 character "' + glyph.operatorListId + '" is not available.');
  11104. continue;
  11105. }
  11106. this.processingType3 = glyph;
  11107. this.save();
  11108. ctx.scale(fontSize, fontSize);
  11109. ctx.transform.apply(ctx, fontMatrix);
  11110. this.executeOperatorList(operatorList);
  11111. this.restore();
  11112. var transformed = _util.Util.applyTransform([glyph.width, 0], fontMatrix);
  11113. width = transformed[0] * fontSize + spacing;
  11114. ctx.translate(width, 0);
  11115. current.x += width * textHScale;
  11116. }
  11117. ctx.restore();
  11118. this.processingType3 = null;
  11119. },
  11120. setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) {},
  11121. setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
  11122. this.ctx.rect(llx, lly, urx - llx, ury - lly);
  11123. this.clip();
  11124. this.endPath();
  11125. },
  11126. getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
  11127. var _this = this;
  11128. var pattern;
  11129. if (IR[0] === 'TilingPattern') {
  11130. var color = IR[1];
  11131. var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
  11132. var canvasGraphicsFactory = {
  11133. createCanvasGraphics: function createCanvasGraphics(ctx) {
  11134. return new CanvasGraphics(ctx, _this.commonObjs, _this.objs, _this.canvasFactory, _this.webGLContext);
  11135. }
  11136. };
  11137. pattern = new _pattern_helper.TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
  11138. } else {
  11139. pattern = (0, _pattern_helper.getShadingPatternFromIR)(IR);
  11140. }
  11141. return pattern;
  11142. },
  11143. setStrokeColorN: function CanvasGraphics_setStrokeColorN() {
  11144. this.current.strokeColor = this.getColorN_Pattern(arguments);
  11145. },
  11146. setFillColorN: function CanvasGraphics_setFillColorN() {
  11147. this.current.fillColor = this.getColorN_Pattern(arguments);
  11148. this.current.patternFill = true;
  11149. },
  11150. setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
  11151. var color = _util.Util.makeCssRgb(r, g, b);
  11152. this.ctx.strokeStyle = color;
  11153. this.current.strokeColor = color;
  11154. },
  11155. setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
  11156. var color = _util.Util.makeCssRgb(r, g, b);
  11157. this.ctx.fillStyle = color;
  11158. this.current.fillColor = color;
  11159. this.current.patternFill = false;
  11160. },
  11161. shadingFill: function CanvasGraphics_shadingFill(patternIR) {
  11162. var ctx = this.ctx;
  11163. this.save();
  11164. var pattern = (0, _pattern_helper.getShadingPatternFromIR)(patternIR);
  11165. ctx.fillStyle = pattern.getPattern(ctx, this, true);
  11166. var inv = ctx.mozCurrentTransformInverse;
  11167. if (inv) {
  11168. var canvas = ctx.canvas;
  11169. var width = canvas.width;
  11170. var height = canvas.height;
  11171. var bl = _util.Util.applyTransform([0, 0], inv);
  11172. var br = _util.Util.applyTransform([0, height], inv);
  11173. var ul = _util.Util.applyTransform([width, 0], inv);
  11174. var ur = _util.Util.applyTransform([width, height], inv);
  11175. var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
  11176. var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
  11177. var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
  11178. var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
  11179. this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
  11180. } else {
  11181. this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
  11182. }
  11183. this.restore();
  11184. },
  11185. beginInlineImage: function CanvasGraphics_beginInlineImage() {
  11186. (0, _util.unreachable)('Should not call beginInlineImage');
  11187. },
  11188. beginImageData: function CanvasGraphics_beginImageData() {
  11189. (0, _util.unreachable)('Should not call beginImageData');
  11190. },
  11191. paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
  11192. this.save();
  11193. this.baseTransformStack.push(this.baseTransform);
  11194. if (Array.isArray(matrix) && matrix.length === 6) {
  11195. this.transform.apply(this, matrix);
  11196. }
  11197. this.baseTransform = this.ctx.mozCurrentTransform;
  11198. if (Array.isArray(bbox) && bbox.length === 4) {
  11199. var width = bbox[2] - bbox[0];
  11200. var height = bbox[3] - bbox[1];
  11201. this.ctx.rect(bbox[0], bbox[1], width, height);
  11202. this.clip();
  11203. this.endPath();
  11204. }
  11205. },
  11206. paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() {
  11207. this.restore();
  11208. this.baseTransform = this.baseTransformStack.pop();
  11209. },
  11210. beginGroup: function CanvasGraphics_beginGroup(group) {
  11211. this.save();
  11212. var currentCtx = this.ctx;
  11213. if (!group.isolated) {
  11214. (0, _util.info)('TODO: Support non-isolated groups.');
  11215. }
  11216. if (group.knockout) {
  11217. (0, _util.warn)('Knockout groups not supported.');
  11218. }
  11219. var currentTransform = currentCtx.mozCurrentTransform;
  11220. if (group.matrix) {
  11221. currentCtx.transform.apply(currentCtx, group.matrix);
  11222. }
  11223. if (!group.bbox) {
  11224. throw new Error('Bounding box is required.');
  11225. }
  11226. var bounds = _util.Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
  11227. var canvasBounds = [0, 0, currentCtx.canvas.width, currentCtx.canvas.height];
  11228. bounds = _util.Util.intersect(bounds, canvasBounds) || [0, 0, 0, 0];
  11229. var offsetX = Math.floor(bounds[0]);
  11230. var offsetY = Math.floor(bounds[1]);
  11231. var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
  11232. var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
  11233. var scaleX = 1,
  11234. scaleY = 1;
  11235. if (drawnWidth > MAX_GROUP_SIZE) {
  11236. scaleX = drawnWidth / MAX_GROUP_SIZE;
  11237. drawnWidth = MAX_GROUP_SIZE;
  11238. }
  11239. if (drawnHeight > MAX_GROUP_SIZE) {
  11240. scaleY = drawnHeight / MAX_GROUP_SIZE;
  11241. drawnHeight = MAX_GROUP_SIZE;
  11242. }
  11243. var cacheId = 'groupAt' + this.groupLevel;
  11244. if (group.smask) {
  11245. cacheId += '_smask_' + this.smaskCounter++ % 2;
  11246. }
  11247. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  11248. var groupCtx = scratchCanvas.context;
  11249. groupCtx.scale(1 / scaleX, 1 / scaleY);
  11250. groupCtx.translate(-offsetX, -offsetY);
  11251. groupCtx.transform.apply(groupCtx, currentTransform);
  11252. if (group.smask) {
  11253. this.smaskStack.push({
  11254. canvas: scratchCanvas.canvas,
  11255. context: groupCtx,
  11256. offsetX: offsetX,
  11257. offsetY: offsetY,
  11258. scaleX: scaleX,
  11259. scaleY: scaleY,
  11260. subtype: group.smask.subtype,
  11261. backdrop: group.smask.backdrop,
  11262. transferMap: group.smask.transferMap || null,
  11263. startTransformInverse: null
  11264. });
  11265. } else {
  11266. currentCtx.setTransform(1, 0, 0, 1, 0, 0);
  11267. currentCtx.translate(offsetX, offsetY);
  11268. currentCtx.scale(scaleX, scaleY);
  11269. }
  11270. copyCtxState(currentCtx, groupCtx);
  11271. this.ctx = groupCtx;
  11272. this.setGState([['BM', 'source-over'], ['ca', 1], ['CA', 1]]);
  11273. this.groupStack.push(currentCtx);
  11274. this.groupLevel++;
  11275. this.current.activeSMask = null;
  11276. },
  11277. endGroup: function CanvasGraphics_endGroup(group) {
  11278. this.groupLevel--;
  11279. var groupCtx = this.ctx;
  11280. this.ctx = this.groupStack.pop();
  11281. if (this.ctx.imageSmoothingEnabled !== undefined) {
  11282. this.ctx.imageSmoothingEnabled = false;
  11283. } else {
  11284. this.ctx.mozImageSmoothingEnabled = false;
  11285. }
  11286. if (group.smask) {
  11287. this.tempSMask = this.smaskStack.pop();
  11288. } else {
  11289. this.ctx.drawImage(groupCtx.canvas, 0, 0);
  11290. }
  11291. this.restore();
  11292. },
  11293. beginAnnotations: function CanvasGraphics_beginAnnotations() {
  11294. this.save();
  11295. if (this.baseTransform) {
  11296. this.ctx.setTransform.apply(this.ctx, this.baseTransform);
  11297. }
  11298. },
  11299. endAnnotations: function CanvasGraphics_endAnnotations() {
  11300. this.restore();
  11301. },
  11302. beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform, matrix) {
  11303. this.save();
  11304. resetCtxToDefault(this.ctx);
  11305. this.current = new CanvasExtraState();
  11306. if (Array.isArray(rect) && rect.length === 4) {
  11307. var width = rect[2] - rect[0];
  11308. var height = rect[3] - rect[1];
  11309. this.ctx.rect(rect[0], rect[1], width, height);
  11310. this.clip();
  11311. this.endPath();
  11312. }
  11313. this.transform.apply(this, transform);
  11314. this.transform.apply(this, matrix);
  11315. },
  11316. endAnnotation: function CanvasGraphics_endAnnotation() {
  11317. this.restore();
  11318. },
  11319. paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
  11320. var domImage = this.objs.get(objId);
  11321. if (!domImage) {
  11322. (0, _util.warn)('Dependent image isn\'t ready yet');
  11323. return;
  11324. }
  11325. this.save();
  11326. var ctx = this.ctx;
  11327. ctx.scale(1 / w, -1 / h);
  11328. ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, 0, -h, w, h);
  11329. if (this.imageLayer) {
  11330. var currentTransform = ctx.mozCurrentTransformInverse;
  11331. var position = this.getCanvasPosition(0, 0);
  11332. this.imageLayer.appendImage({
  11333. objId: objId,
  11334. left: position[0],
  11335. top: position[1],
  11336. width: w / currentTransform[0],
  11337. height: h / currentTransform[3]
  11338. });
  11339. }
  11340. this.restore();
  11341. },
  11342. paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
  11343. var ctx = this.ctx;
  11344. var width = img.width,
  11345. height = img.height;
  11346. var fillColor = this.current.fillColor;
  11347. var isPatternFill = this.current.patternFill;
  11348. var glyph = this.processingType3;
  11349. if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
  11350. if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
  11351. glyph.compiled = compileType3Glyph({
  11352. data: img.data,
  11353. width: width,
  11354. height: height
  11355. });
  11356. } else {
  11357. glyph.compiled = null;
  11358. }
  11359. }
  11360. if (glyph && glyph.compiled) {
  11361. glyph.compiled(ctx);
  11362. return;
  11363. }
  11364. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  11365. var maskCtx = maskCanvas.context;
  11366. maskCtx.save();
  11367. putBinaryImageMask(maskCtx, img);
  11368. maskCtx.globalCompositeOperation = 'source-in';
  11369. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  11370. maskCtx.fillRect(0, 0, width, height);
  11371. maskCtx.restore();
  11372. this.paintInlineImageXObject(maskCanvas.canvas);
  11373. },
  11374. paintImageMaskXObjectRepeat: function CanvasGraphics_paintImageMaskXObjectRepeat(imgData, scaleX, scaleY, positions) {
  11375. var width = imgData.width;
  11376. var height = imgData.height;
  11377. var fillColor = this.current.fillColor;
  11378. var isPatternFill = this.current.patternFill;
  11379. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  11380. var maskCtx = maskCanvas.context;
  11381. maskCtx.save();
  11382. putBinaryImageMask(maskCtx, imgData);
  11383. maskCtx.globalCompositeOperation = 'source-in';
  11384. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  11385. maskCtx.fillRect(0, 0, width, height);
  11386. maskCtx.restore();
  11387. var ctx = this.ctx;
  11388. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  11389. ctx.save();
  11390. ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
  11391. ctx.scale(1, -1);
  11392. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  11393. ctx.restore();
  11394. }
  11395. },
  11396. paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(images) {
  11397. var ctx = this.ctx;
  11398. var fillColor = this.current.fillColor;
  11399. var isPatternFill = this.current.patternFill;
  11400. for (var i = 0, ii = images.length; i < ii; i++) {
  11401. var image = images[i];
  11402. var width = image.width,
  11403. height = image.height;
  11404. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  11405. var maskCtx = maskCanvas.context;
  11406. maskCtx.save();
  11407. putBinaryImageMask(maskCtx, image);
  11408. maskCtx.globalCompositeOperation = 'source-in';
  11409. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  11410. maskCtx.fillRect(0, 0, width, height);
  11411. maskCtx.restore();
  11412. ctx.save();
  11413. ctx.transform.apply(ctx, image.transform);
  11414. ctx.scale(1, -1);
  11415. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  11416. ctx.restore();
  11417. }
  11418. },
  11419. paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
  11420. var imgData = this.objs.get(objId);
  11421. if (!imgData) {
  11422. (0, _util.warn)('Dependent image isn\'t ready yet');
  11423. return;
  11424. }
  11425. this.paintInlineImageXObject(imgData);
  11426. },
  11427. paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
  11428. var imgData = this.objs.get(objId);
  11429. if (!imgData) {
  11430. (0, _util.warn)('Dependent image isn\'t ready yet');
  11431. return;
  11432. }
  11433. var width = imgData.width;
  11434. var height = imgData.height;
  11435. var map = [];
  11436. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  11437. map.push({
  11438. transform: [scaleX, 0, 0, scaleY, positions[i], positions[i + 1]],
  11439. x: 0,
  11440. y: 0,
  11441. w: width,
  11442. h: height
  11443. });
  11444. }
  11445. this.paintInlineImageXObjectGroup(imgData, map);
  11446. },
  11447. paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) {
  11448. var width = imgData.width;
  11449. var height = imgData.height;
  11450. var ctx = this.ctx;
  11451. this.save();
  11452. ctx.scale(1 / width, -1 / height);
  11453. var currentTransform = ctx.mozCurrentTransformInverse;
  11454. var a = currentTransform[0],
  11455. b = currentTransform[1];
  11456. var widthScale = Math.max(Math.sqrt(a * a + b * b), 1);
  11457. var c = currentTransform[2],
  11458. d = currentTransform[3];
  11459. var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
  11460. var imgToPaint, tmpCanvas;
  11461. if (typeof HTMLElement === 'function' && imgData instanceof HTMLElement || !imgData.data) {
  11462. imgToPaint = imgData;
  11463. } else {
  11464. tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', width, height);
  11465. var tmpCtx = tmpCanvas.context;
  11466. putBinaryImageData(tmpCtx, imgData);
  11467. imgToPaint = tmpCanvas.canvas;
  11468. }
  11469. var paintWidth = width,
  11470. paintHeight = height;
  11471. var tmpCanvasId = 'prescale1';
  11472. while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
  11473. var newWidth = paintWidth,
  11474. newHeight = paintHeight;
  11475. if (widthScale > 2 && paintWidth > 1) {
  11476. newWidth = Math.ceil(paintWidth / 2);
  11477. widthScale /= paintWidth / newWidth;
  11478. }
  11479. if (heightScale > 2 && paintHeight > 1) {
  11480. newHeight = Math.ceil(paintHeight / 2);
  11481. heightScale /= paintHeight / newHeight;
  11482. }
  11483. tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
  11484. tmpCtx = tmpCanvas.context;
  11485. tmpCtx.clearRect(0, 0, newWidth, newHeight);
  11486. tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight);
  11487. imgToPaint = tmpCanvas.canvas;
  11488. paintWidth = newWidth;
  11489. paintHeight = newHeight;
  11490. tmpCanvasId = tmpCanvasId === 'prescale1' ? 'prescale2' : 'prescale1';
  11491. }
  11492. ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height);
  11493. if (this.imageLayer) {
  11494. var position = this.getCanvasPosition(0, -height);
  11495. this.imageLayer.appendImage({
  11496. imgData: imgData,
  11497. left: position[0],
  11498. top: position[1],
  11499. width: width / currentTransform[0],
  11500. height: height / currentTransform[3]
  11501. });
  11502. }
  11503. this.restore();
  11504. },
  11505. paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) {
  11506. var ctx = this.ctx;
  11507. var w = imgData.width;
  11508. var h = imgData.height;
  11509. var tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', w, h);
  11510. var tmpCtx = tmpCanvas.context;
  11511. putBinaryImageData(tmpCtx, imgData);
  11512. for (var i = 0, ii = map.length; i < ii; i++) {
  11513. var entry = map[i];
  11514. ctx.save();
  11515. ctx.transform.apply(ctx, entry.transform);
  11516. ctx.scale(1, -1);
  11517. ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
  11518. if (this.imageLayer) {
  11519. var position = this.getCanvasPosition(entry.x, entry.y);
  11520. this.imageLayer.appendImage({
  11521. imgData: imgData,
  11522. left: position[0],
  11523. top: position[1],
  11524. width: w,
  11525. height: h
  11526. });
  11527. }
  11528. ctx.restore();
  11529. }
  11530. },
  11531. paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() {
  11532. this.ctx.fillRect(0, 0, 1, 1);
  11533. },
  11534. paintXObject: function CanvasGraphics_paintXObject() {
  11535. (0, _util.warn)('Unsupported \'paintXObject\' command.');
  11536. },
  11537. markPoint: function CanvasGraphics_markPoint(tag) {},
  11538. markPointProps: function CanvasGraphics_markPointProps(tag, properties) {},
  11539. beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {},
  11540. beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(tag, properties) {},
  11541. endMarkedContent: function CanvasGraphics_endMarkedContent() {},
  11542. beginCompat: function CanvasGraphics_beginCompat() {},
  11543. endCompat: function CanvasGraphics_endCompat() {},
  11544. consumePath: function CanvasGraphics_consumePath() {
  11545. var ctx = this.ctx;
  11546. if (this.pendingClip) {
  11547. if (this.pendingClip === EO_CLIP) {
  11548. ctx.clip('evenodd');
  11549. } else {
  11550. ctx.clip();
  11551. }
  11552. this.pendingClip = null;
  11553. }
  11554. ctx.beginPath();
  11555. },
  11556. getSinglePixelWidth: function getSinglePixelWidth(scale) {
  11557. if (this._cachedGetSinglePixelWidth === null) {
  11558. var inverse = this.ctx.mozCurrentTransformInverse;
  11559. this._cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3]));
  11560. }
  11561. return this._cachedGetSinglePixelWidth;
  11562. },
  11563. getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
  11564. var transform = this.ctx.mozCurrentTransform;
  11565. return [transform[0] * x + transform[2] * y + transform[4], transform[1] * x + transform[3] * y + transform[5]];
  11566. }
  11567. };
  11568. for (var op in _util.OPS) {
  11569. CanvasGraphics.prototype[_util.OPS[op]] = CanvasGraphics.prototype[op];
  11570. }
  11571. return CanvasGraphics;
  11572. }();
  11573. exports.CanvasGraphics = CanvasGraphics;
  11574. /***/ }),
  11575. /* 134 */
  11576. /***/ (function(module, exports, __w_pdfjs_require__) {
  11577. "use strict";
  11578. Object.defineProperty(exports, "__esModule", {
  11579. value: true
  11580. });
  11581. exports.TilingPattern = exports.getShadingPatternFromIR = undefined;
  11582. var _util = __w_pdfjs_require__(1);
  11583. var ShadingIRs = {};
  11584. ShadingIRs.RadialAxial = {
  11585. fromIR: function RadialAxial_fromIR(raw) {
  11586. var type = raw[1];
  11587. var colorStops = raw[2];
  11588. var p0 = raw[3];
  11589. var p1 = raw[4];
  11590. var r0 = raw[5];
  11591. var r1 = raw[6];
  11592. return {
  11593. type: 'Pattern',
  11594. getPattern: function RadialAxial_getPattern(ctx) {
  11595. var grad;
  11596. if (type === 'axial') {
  11597. grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]);
  11598. } else if (type === 'radial') {
  11599. grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1);
  11600. }
  11601. for (var i = 0, ii = colorStops.length; i < ii; ++i) {
  11602. var c = colorStops[i];
  11603. grad.addColorStop(c[0], c[1]);
  11604. }
  11605. return grad;
  11606. }
  11607. };
  11608. }
  11609. };
  11610. var createMeshCanvas = function createMeshCanvasClosure() {
  11611. function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {
  11612. var coords = context.coords,
  11613. colors = context.colors;
  11614. var bytes = data.data,
  11615. rowSize = data.width * 4;
  11616. var tmp;
  11617. if (coords[p1 + 1] > coords[p2 + 1]) {
  11618. tmp = p1;
  11619. p1 = p2;
  11620. p2 = tmp;
  11621. tmp = c1;
  11622. c1 = c2;
  11623. c2 = tmp;
  11624. }
  11625. if (coords[p2 + 1] > coords[p3 + 1]) {
  11626. tmp = p2;
  11627. p2 = p3;
  11628. p3 = tmp;
  11629. tmp = c2;
  11630. c2 = c3;
  11631. c3 = tmp;
  11632. }
  11633. if (coords[p1 + 1] > coords[p2 + 1]) {
  11634. tmp = p1;
  11635. p1 = p2;
  11636. p2 = tmp;
  11637. tmp = c1;
  11638. c1 = c2;
  11639. c2 = tmp;
  11640. }
  11641. var x1 = (coords[p1] + context.offsetX) * context.scaleX;
  11642. var y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY;
  11643. var x2 = (coords[p2] + context.offsetX) * context.scaleX;
  11644. var y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY;
  11645. var x3 = (coords[p3] + context.offsetX) * context.scaleX;
  11646. var y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY;
  11647. if (y1 >= y3) {
  11648. return;
  11649. }
  11650. var c1r = colors[c1],
  11651. c1g = colors[c1 + 1],
  11652. c1b = colors[c1 + 2];
  11653. var c2r = colors[c2],
  11654. c2g = colors[c2 + 1],
  11655. c2b = colors[c2 + 2];
  11656. var c3r = colors[c3],
  11657. c3g = colors[c3 + 1],
  11658. c3b = colors[c3 + 2];
  11659. var minY = Math.round(y1),
  11660. maxY = Math.round(y3);
  11661. var xa, car, cag, cab;
  11662. var xb, cbr, cbg, cbb;
  11663. var k;
  11664. for (var y = minY; y <= maxY; y++) {
  11665. if (y < y2) {
  11666. k = y < y1 ? 0 : y1 === y2 ? 1 : (y1 - y) / (y1 - y2);
  11667. xa = x1 - (x1 - x2) * k;
  11668. car = c1r - (c1r - c2r) * k;
  11669. cag = c1g - (c1g - c2g) * k;
  11670. cab = c1b - (c1b - c2b) * k;
  11671. } else {
  11672. k = y > y3 ? 1 : y2 === y3 ? 0 : (y2 - y) / (y2 - y3);
  11673. xa = x2 - (x2 - x3) * k;
  11674. car = c2r - (c2r - c3r) * k;
  11675. cag = c2g - (c2g - c3g) * k;
  11676. cab = c2b - (c2b - c3b) * k;
  11677. }
  11678. k = y < y1 ? 0 : y > y3 ? 1 : (y1 - y) / (y1 - y3);
  11679. xb = x1 - (x1 - x3) * k;
  11680. cbr = c1r - (c1r - c3r) * k;
  11681. cbg = c1g - (c1g - c3g) * k;
  11682. cbb = c1b - (c1b - c3b) * k;
  11683. var x1_ = Math.round(Math.min(xa, xb));
  11684. var x2_ = Math.round(Math.max(xa, xb));
  11685. var j = rowSize * y + x1_ * 4;
  11686. for (var x = x1_; x <= x2_; x++) {
  11687. k = (xa - x) / (xa - xb);
  11688. k = k < 0 ? 0 : k > 1 ? 1 : k;
  11689. bytes[j++] = car - (car - cbr) * k | 0;
  11690. bytes[j++] = cag - (cag - cbg) * k | 0;
  11691. bytes[j++] = cab - (cab - cbb) * k | 0;
  11692. bytes[j++] = 255;
  11693. }
  11694. }
  11695. }
  11696. function drawFigure(data, figure, context) {
  11697. var ps = figure.coords;
  11698. var cs = figure.colors;
  11699. var i, ii;
  11700. switch (figure.type) {
  11701. case 'lattice':
  11702. var verticesPerRow = figure.verticesPerRow;
  11703. var rows = Math.floor(ps.length / verticesPerRow) - 1;
  11704. var cols = verticesPerRow - 1;
  11705. for (i = 0; i < rows; i++) {
  11706. var q = i * verticesPerRow;
  11707. for (var j = 0; j < cols; j++, q++) {
  11708. drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]);
  11709. drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]);
  11710. }
  11711. }
  11712. break;
  11713. case 'triangles':
  11714. for (i = 0, ii = ps.length; i < ii; i += 3) {
  11715. drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]);
  11716. }
  11717. break;
  11718. default:
  11719. throw new Error('illegal figure');
  11720. }
  11721. }
  11722. function createMeshCanvas(bounds, combinesScale, coords, colors, figures, backgroundColor, cachedCanvases, webGLContext) {
  11723. var EXPECTED_SCALE = 1.1;
  11724. var MAX_PATTERN_SIZE = 3000;
  11725. var BORDER_SIZE = 2;
  11726. var offsetX = Math.floor(bounds[0]);
  11727. var offsetY = Math.floor(bounds[1]);
  11728. var boundsWidth = Math.ceil(bounds[2]) - offsetX;
  11729. var boundsHeight = Math.ceil(bounds[3]) - offsetY;
  11730. var width = Math.min(Math.ceil(Math.abs(boundsWidth * combinesScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  11731. var height = Math.min(Math.ceil(Math.abs(boundsHeight * combinesScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  11732. var scaleX = boundsWidth / width;
  11733. var scaleY = boundsHeight / height;
  11734. var context = {
  11735. coords: coords,
  11736. colors: colors,
  11737. offsetX: -offsetX,
  11738. offsetY: -offsetY,
  11739. scaleX: 1 / scaleX,
  11740. scaleY: 1 / scaleY
  11741. };
  11742. var paddedWidth = width + BORDER_SIZE * 2;
  11743. var paddedHeight = height + BORDER_SIZE * 2;
  11744. var canvas, tmpCanvas, i, ii;
  11745. if (webGLContext.isEnabled) {
  11746. canvas = webGLContext.drawFigures({
  11747. width: width,
  11748. height: height,
  11749. backgroundColor: backgroundColor,
  11750. figures: figures,
  11751. context: context
  11752. });
  11753. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  11754. tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE);
  11755. canvas = tmpCanvas.canvas;
  11756. } else {
  11757. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  11758. var tmpCtx = tmpCanvas.context;
  11759. var data = tmpCtx.createImageData(width, height);
  11760. if (backgroundColor) {
  11761. var bytes = data.data;
  11762. for (i = 0, ii = bytes.length; i < ii; i += 4) {
  11763. bytes[i] = backgroundColor[0];
  11764. bytes[i + 1] = backgroundColor[1];
  11765. bytes[i + 2] = backgroundColor[2];
  11766. bytes[i + 3] = 255;
  11767. }
  11768. }
  11769. for (i = 0; i < figures.length; i++) {
  11770. drawFigure(data, figures[i], context);
  11771. }
  11772. tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);
  11773. canvas = tmpCanvas.canvas;
  11774. }
  11775. return {
  11776. canvas: canvas,
  11777. offsetX: offsetX - BORDER_SIZE * scaleX,
  11778. offsetY: offsetY - BORDER_SIZE * scaleY,
  11779. scaleX: scaleX,
  11780. scaleY: scaleY
  11781. };
  11782. }
  11783. return createMeshCanvas;
  11784. }();
  11785. ShadingIRs.Mesh = {
  11786. fromIR: function Mesh_fromIR(raw) {
  11787. var coords = raw[2];
  11788. var colors = raw[3];
  11789. var figures = raw[4];
  11790. var bounds = raw[5];
  11791. var matrix = raw[6];
  11792. var background = raw[8];
  11793. return {
  11794. type: 'Pattern',
  11795. getPattern: function Mesh_getPattern(ctx, owner, shadingFill) {
  11796. var scale;
  11797. if (shadingFill) {
  11798. scale = _util.Util.singularValueDecompose2dScale(ctx.mozCurrentTransform);
  11799. } else {
  11800. scale = _util.Util.singularValueDecompose2dScale(owner.baseTransform);
  11801. if (matrix) {
  11802. var matrixScale = _util.Util.singularValueDecompose2dScale(matrix);
  11803. scale = [scale[0] * matrixScale[0], scale[1] * matrixScale[1]];
  11804. }
  11805. }
  11806. var temporaryPatternCanvas = createMeshCanvas(bounds, scale, coords, colors, figures, shadingFill ? null : background, owner.cachedCanvases, owner.webGLContext);
  11807. if (!shadingFill) {
  11808. ctx.setTransform.apply(ctx, owner.baseTransform);
  11809. if (matrix) {
  11810. ctx.transform.apply(ctx, matrix);
  11811. }
  11812. }
  11813. ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
  11814. ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY);
  11815. return ctx.createPattern(temporaryPatternCanvas.canvas, 'no-repeat');
  11816. }
  11817. };
  11818. }
  11819. };
  11820. ShadingIRs.Dummy = {
  11821. fromIR: function Dummy_fromIR() {
  11822. return {
  11823. type: 'Pattern',
  11824. getPattern: function Dummy_fromIR_getPattern() {
  11825. return 'hotpink';
  11826. }
  11827. };
  11828. }
  11829. };
  11830. function getShadingPatternFromIR(raw) {
  11831. var shadingIR = ShadingIRs[raw[0]];
  11832. if (!shadingIR) {
  11833. throw new Error('Unknown IR type: ' + raw[0]);
  11834. }
  11835. return shadingIR.fromIR(raw);
  11836. }
  11837. var TilingPattern = function TilingPatternClosure() {
  11838. var PaintType = {
  11839. COLORED: 1,
  11840. UNCOLORED: 2
  11841. };
  11842. var MAX_PATTERN_SIZE = 3000;
  11843. function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
  11844. this.operatorList = IR[2];
  11845. this.matrix = IR[3] || [1, 0, 0, 1, 0, 0];
  11846. this.bbox = IR[4];
  11847. this.xstep = IR[5];
  11848. this.ystep = IR[6];
  11849. this.paintType = IR[7];
  11850. this.tilingType = IR[8];
  11851. this.color = color;
  11852. this.canvasGraphicsFactory = canvasGraphicsFactory;
  11853. this.baseTransform = baseTransform;
  11854. this.type = 'Pattern';
  11855. this.ctx = ctx;
  11856. }
  11857. TilingPattern.prototype = {
  11858. createPatternCanvas: function TilinPattern_createPatternCanvas(owner) {
  11859. var operatorList = this.operatorList;
  11860. var bbox = this.bbox;
  11861. var xstep = this.xstep;
  11862. var ystep = this.ystep;
  11863. var paintType = this.paintType;
  11864. var tilingType = this.tilingType;
  11865. var color = this.color;
  11866. var canvasGraphicsFactory = this.canvasGraphicsFactory;
  11867. (0, _util.info)('TilingType: ' + tilingType);
  11868. var x0 = bbox[0],
  11869. y0 = bbox[1],
  11870. x1 = bbox[2],
  11871. y1 = bbox[3];
  11872. var topLeft = [x0, y0];
  11873. var botRight = [x0 + xstep, y0 + ystep];
  11874. var width = botRight[0] - topLeft[0];
  11875. var height = botRight[1] - topLeft[1];
  11876. var matrixScale = _util.Util.singularValueDecompose2dScale(this.matrix);
  11877. var curMatrixScale = _util.Util.singularValueDecompose2dScale(this.baseTransform);
  11878. var combinedScale = [matrixScale[0] * curMatrixScale[0], matrixScale[1] * curMatrixScale[1]];
  11879. width = Math.min(Math.ceil(Math.abs(width * combinedScale[0])), MAX_PATTERN_SIZE);
  11880. height = Math.min(Math.ceil(Math.abs(height * combinedScale[1])), MAX_PATTERN_SIZE);
  11881. var tmpCanvas = owner.cachedCanvases.getCanvas('pattern', width, height, true);
  11882. var tmpCtx = tmpCanvas.context;
  11883. var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx);
  11884. graphics.groupLevel = owner.groupLevel;
  11885. this.setFillAndStrokeStyleToContext(graphics, paintType, color);
  11886. this.setScale(width, height, xstep, ystep);
  11887. this.transformToScale(graphics);
  11888. var tmpTranslate = [1, 0, 0, 1, -topLeft[0], -topLeft[1]];
  11889. graphics.transform.apply(graphics, tmpTranslate);
  11890. this.clipBbox(graphics, bbox, x0, y0, x1, y1);
  11891. graphics.executeOperatorList(operatorList);
  11892. return tmpCanvas.canvas;
  11893. },
  11894. setScale: function TilingPattern_setScale(width, height, xstep, ystep) {
  11895. this.scale = [width / xstep, height / ystep];
  11896. },
  11897. transformToScale: function TilingPattern_transformToScale(graphics) {
  11898. var scale = this.scale;
  11899. var tmpScale = [scale[0], 0, 0, scale[1], 0, 0];
  11900. graphics.transform.apply(graphics, tmpScale);
  11901. },
  11902. scaleToContext: function TilingPattern_scaleToContext() {
  11903. var scale = this.scale;
  11904. this.ctx.scale(1 / scale[0], 1 / scale[1]);
  11905. },
  11906. clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) {
  11907. if (Array.isArray(bbox) && bbox.length === 4) {
  11908. var bboxWidth = x1 - x0;
  11909. var bboxHeight = y1 - y0;
  11910. graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
  11911. graphics.clip();
  11912. graphics.endPath();
  11913. }
  11914. },
  11915. setFillAndStrokeStyleToContext: function setFillAndStrokeStyleToContext(graphics, paintType, color) {
  11916. var context = graphics.ctx,
  11917. current = graphics.current;
  11918. switch (paintType) {
  11919. case PaintType.COLORED:
  11920. var ctx = this.ctx;
  11921. context.fillStyle = ctx.fillStyle;
  11922. context.strokeStyle = ctx.strokeStyle;
  11923. current.fillColor = ctx.fillStyle;
  11924. current.strokeColor = ctx.strokeStyle;
  11925. break;
  11926. case PaintType.UNCOLORED:
  11927. var cssColor = _util.Util.makeCssRgb(color[0], color[1], color[2]);
  11928. context.fillStyle = cssColor;
  11929. context.strokeStyle = cssColor;
  11930. current.fillColor = cssColor;
  11931. current.strokeColor = cssColor;
  11932. break;
  11933. default:
  11934. throw new _util.FormatError('Unsupported paint type: ' + paintType);
  11935. }
  11936. },
  11937. getPattern: function TilingPattern_getPattern(ctx, owner) {
  11938. var temporaryPatternCanvas = this.createPatternCanvas(owner);
  11939. ctx = this.ctx;
  11940. ctx.setTransform.apply(ctx, this.baseTransform);
  11941. ctx.transform.apply(ctx, this.matrix);
  11942. this.scaleToContext();
  11943. return ctx.createPattern(temporaryPatternCanvas, 'repeat');
  11944. }
  11945. };
  11946. return TilingPattern;
  11947. }();
  11948. exports.getShadingPatternFromIR = getShadingPatternFromIR;
  11949. exports.TilingPattern = TilingPattern;
  11950. /***/ }),
  11951. /* 135 */
  11952. /***/ (function(module, exports, __w_pdfjs_require__) {
  11953. "use strict";
  11954. Object.defineProperty(exports, "__esModule", {
  11955. value: true
  11956. });
  11957. var GlobalWorkerOptions = Object.create(null);
  11958. GlobalWorkerOptions.workerPort = GlobalWorkerOptions.workerPort === undefined ? null : GlobalWorkerOptions.workerPort;
  11959. GlobalWorkerOptions.workerSrc = GlobalWorkerOptions.workerSrc === undefined ? '' : GlobalWorkerOptions.workerSrc;
  11960. exports.GlobalWorkerOptions = GlobalWorkerOptions;
  11961. /***/ }),
  11962. /* 136 */
  11963. /***/ (function(module, exports, __w_pdfjs_require__) {
  11964. "use strict";
  11965. Object.defineProperty(exports, "__esModule", {
  11966. value: true
  11967. });
  11968. exports.MessageHandler = undefined;
  11969. var _regenerator = __w_pdfjs_require__(137);
  11970. var _regenerator2 = _interopRequireDefault(_regenerator);
  11971. 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; };
  11972. var resolveCall = function () {
  11973. var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee(fn, args) {
  11974. var thisArg = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  11975. return _regenerator2.default.wrap(function _callee$(_context) {
  11976. while (1) {
  11977. switch (_context.prev = _context.next) {
  11978. case 0:
  11979. if (fn) {
  11980. _context.next = 2;
  11981. break;
  11982. }
  11983. return _context.abrupt('return');
  11984. case 2:
  11985. return _context.abrupt('return', fn.apply(thisArg, args));
  11986. case 3:
  11987. case 'end':
  11988. return _context.stop();
  11989. }
  11990. }
  11991. }, _callee, this);
  11992. }));
  11993. return function resolveCall(_x2, _x3) {
  11994. return _ref.apply(this, arguments);
  11995. };
  11996. }();
  11997. var _util = __w_pdfjs_require__(1);
  11998. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11999. function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
  12000. function wrapReason(reason) {
  12001. if ((typeof reason === 'undefined' ? 'undefined' : _typeof(reason)) !== 'object') {
  12002. return reason;
  12003. }
  12004. switch (reason.name) {
  12005. case 'AbortException':
  12006. return new _util.AbortException(reason.message);
  12007. case 'MissingPDFException':
  12008. return new _util.MissingPDFException(reason.message);
  12009. case 'UnexpectedResponseException':
  12010. return new _util.UnexpectedResponseException(reason.message, reason.status);
  12011. default:
  12012. return new _util.UnknownErrorException(reason.message, reason.details);
  12013. }
  12014. }
  12015. function makeReasonSerializable(reason) {
  12016. if (!(reason instanceof Error) || reason instanceof _util.AbortException || reason instanceof _util.MissingPDFException || reason instanceof _util.UnexpectedResponseException || reason instanceof _util.UnknownErrorException) {
  12017. return reason;
  12018. }
  12019. return new _util.UnknownErrorException(reason.message, reason.toString());
  12020. }
  12021. function resolveOrReject(capability, success, reason) {
  12022. if (success) {
  12023. capability.resolve();
  12024. } else {
  12025. capability.reject(reason);
  12026. }
  12027. }
  12028. function finalize(promise) {
  12029. return Promise.resolve(promise).catch(function () {});
  12030. }
  12031. function MessageHandler(sourceName, targetName, comObj) {
  12032. var _this = this;
  12033. this.sourceName = sourceName;
  12034. this.targetName = targetName;
  12035. this.comObj = comObj;
  12036. this.callbackId = 1;
  12037. this.streamId = 1;
  12038. this.postMessageTransfers = true;
  12039. this.streamSinks = Object.create(null);
  12040. this.streamControllers = Object.create(null);
  12041. var callbacksCapabilities = this.callbacksCapabilities = Object.create(null);
  12042. var ah = this.actionHandler = Object.create(null);
  12043. this._onComObjOnMessage = function (event) {
  12044. var data = event.data;
  12045. if (data.targetName !== _this.sourceName) {
  12046. return;
  12047. }
  12048. if (data.stream) {
  12049. _this._processStreamMessage(data);
  12050. } else if (data.isReply) {
  12051. var callbackId = data.callbackId;
  12052. if (data.callbackId in callbacksCapabilities) {
  12053. var callback = callbacksCapabilities[callbackId];
  12054. delete callbacksCapabilities[callbackId];
  12055. if ('error' in data) {
  12056. callback.reject(wrapReason(data.error));
  12057. } else {
  12058. callback.resolve(data.data);
  12059. }
  12060. } else {
  12061. throw new Error('Cannot resolve callback ' + callbackId);
  12062. }
  12063. } else if (data.action in ah) {
  12064. var action = ah[data.action];
  12065. if (data.callbackId) {
  12066. var _sourceName = _this.sourceName;
  12067. var _targetName = data.sourceName;
  12068. Promise.resolve().then(function () {
  12069. return action[0].call(action[1], data.data);
  12070. }).then(function (result) {
  12071. comObj.postMessage({
  12072. sourceName: _sourceName,
  12073. targetName: _targetName,
  12074. isReply: true,
  12075. callbackId: data.callbackId,
  12076. data: result
  12077. });
  12078. }, function (reason) {
  12079. comObj.postMessage({
  12080. sourceName: _sourceName,
  12081. targetName: _targetName,
  12082. isReply: true,
  12083. callbackId: data.callbackId,
  12084. error: makeReasonSerializable(reason)
  12085. });
  12086. });
  12087. } else if (data.streamId) {
  12088. _this._createStreamSink(data);
  12089. } else {
  12090. action[0].call(action[1], data.data);
  12091. }
  12092. } else {
  12093. throw new Error('Unknown action from worker: ' + data.action);
  12094. }
  12095. };
  12096. comObj.addEventListener('message', this._onComObjOnMessage);
  12097. }
  12098. MessageHandler.prototype = {
  12099. on: function on(actionName, handler, scope) {
  12100. var ah = this.actionHandler;
  12101. if (ah[actionName]) {
  12102. throw new Error('There is already an actionName called "' + actionName + '"');
  12103. }
  12104. ah[actionName] = [handler, scope];
  12105. },
  12106. send: function send(actionName, data, transfers) {
  12107. var message = {
  12108. sourceName: this.sourceName,
  12109. targetName: this.targetName,
  12110. action: actionName,
  12111. data: data
  12112. };
  12113. this.postMessage(message, transfers);
  12114. },
  12115. sendWithPromise: function sendWithPromise(actionName, data, transfers) {
  12116. var callbackId = this.callbackId++;
  12117. var message = {
  12118. sourceName: this.sourceName,
  12119. targetName: this.targetName,
  12120. action: actionName,
  12121. data: data,
  12122. callbackId: callbackId
  12123. };
  12124. var capability = (0, _util.createPromiseCapability)();
  12125. this.callbacksCapabilities[callbackId] = capability;
  12126. try {
  12127. this.postMessage(message, transfers);
  12128. } catch (e) {
  12129. capability.reject(e);
  12130. }
  12131. return capability.promise;
  12132. },
  12133. sendWithStream: function sendWithStream(actionName, data, queueingStrategy, transfers) {
  12134. var _this2 = this;
  12135. var streamId = this.streamId++;
  12136. var sourceName = this.sourceName;
  12137. var targetName = this.targetName;
  12138. return new _util.ReadableStream({
  12139. start: function start(controller) {
  12140. var startCapability = (0, _util.createPromiseCapability)();
  12141. _this2.streamControllers[streamId] = {
  12142. controller: controller,
  12143. startCall: startCapability,
  12144. isClosed: false
  12145. };
  12146. _this2.postMessage({
  12147. sourceName: sourceName,
  12148. targetName: targetName,
  12149. action: actionName,
  12150. streamId: streamId,
  12151. data: data,
  12152. desiredSize: controller.desiredSize
  12153. });
  12154. return startCapability.promise;
  12155. },
  12156. pull: function pull(controller) {
  12157. var pullCapability = (0, _util.createPromiseCapability)();
  12158. _this2.streamControllers[streamId].pullCall = pullCapability;
  12159. _this2.postMessage({
  12160. sourceName: sourceName,
  12161. targetName: targetName,
  12162. stream: 'pull',
  12163. streamId: streamId,
  12164. desiredSize: controller.desiredSize
  12165. });
  12166. return pullCapability.promise;
  12167. },
  12168. cancel: function cancel(reason) {
  12169. var cancelCapability = (0, _util.createPromiseCapability)();
  12170. _this2.streamControllers[streamId].cancelCall = cancelCapability;
  12171. _this2.streamControllers[streamId].isClosed = true;
  12172. _this2.postMessage({
  12173. sourceName: sourceName,
  12174. targetName: targetName,
  12175. stream: 'cancel',
  12176. reason: reason,
  12177. streamId: streamId
  12178. });
  12179. return cancelCapability.promise;
  12180. }
  12181. }, queueingStrategy);
  12182. },
  12183. _createStreamSink: function _createStreamSink(data) {
  12184. var _this3 = this;
  12185. var self = this;
  12186. var action = this.actionHandler[data.action];
  12187. var streamId = data.streamId;
  12188. var desiredSize = data.desiredSize;
  12189. var sourceName = this.sourceName;
  12190. var targetName = data.sourceName;
  12191. var capability = (0, _util.createPromiseCapability)();
  12192. var sendStreamRequest = function sendStreamRequest(_ref2) {
  12193. var stream = _ref2.stream,
  12194. chunk = _ref2.chunk,
  12195. transfers = _ref2.transfers,
  12196. success = _ref2.success,
  12197. reason = _ref2.reason;
  12198. _this3.postMessage({
  12199. sourceName: sourceName,
  12200. targetName: targetName,
  12201. stream: stream,
  12202. streamId: streamId,
  12203. chunk: chunk,
  12204. success: success,
  12205. reason: reason
  12206. }, transfers);
  12207. };
  12208. var streamSink = {
  12209. enqueue: function enqueue(chunk) {
  12210. var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  12211. var transfers = arguments[2];
  12212. if (this.isCancelled) {
  12213. return;
  12214. }
  12215. var lastDesiredSize = this.desiredSize;
  12216. this.desiredSize -= size;
  12217. if (lastDesiredSize > 0 && this.desiredSize <= 0) {
  12218. this.sinkCapability = (0, _util.createPromiseCapability)();
  12219. this.ready = this.sinkCapability.promise;
  12220. }
  12221. sendStreamRequest({
  12222. stream: 'enqueue',
  12223. chunk: chunk,
  12224. transfers: transfers
  12225. });
  12226. },
  12227. close: function close() {
  12228. if (this.isCancelled) {
  12229. return;
  12230. }
  12231. this.isCancelled = true;
  12232. sendStreamRequest({ stream: 'close' });
  12233. delete self.streamSinks[streamId];
  12234. },
  12235. error: function error(reason) {
  12236. if (this.isCancelled) {
  12237. return;
  12238. }
  12239. this.isCancelled = true;
  12240. sendStreamRequest({
  12241. stream: 'error',
  12242. reason: reason
  12243. });
  12244. },
  12245. sinkCapability: capability,
  12246. onPull: null,
  12247. onCancel: null,
  12248. isCancelled: false,
  12249. desiredSize: desiredSize,
  12250. ready: null
  12251. };
  12252. streamSink.sinkCapability.resolve();
  12253. streamSink.ready = streamSink.sinkCapability.promise;
  12254. this.streamSinks[streamId] = streamSink;
  12255. resolveCall(action[0], [data.data, streamSink], action[1]).then(function () {
  12256. sendStreamRequest({
  12257. stream: 'start_complete',
  12258. success: true
  12259. });
  12260. }, function (reason) {
  12261. sendStreamRequest({
  12262. stream: 'start_complete',
  12263. success: false,
  12264. reason: reason
  12265. });
  12266. });
  12267. },
  12268. _processStreamMessage: function _processStreamMessage(data) {
  12269. var _this4 = this;
  12270. var sourceName = this.sourceName;
  12271. var targetName = data.sourceName;
  12272. var streamId = data.streamId;
  12273. var sendStreamResponse = function sendStreamResponse(_ref3) {
  12274. var stream = _ref3.stream,
  12275. success = _ref3.success,
  12276. reason = _ref3.reason;
  12277. _this4.comObj.postMessage({
  12278. sourceName: sourceName,
  12279. targetName: targetName,
  12280. stream: stream,
  12281. success: success,
  12282. streamId: streamId,
  12283. reason: reason
  12284. });
  12285. };
  12286. var deleteStreamController = function deleteStreamController() {
  12287. Promise.all([_this4.streamControllers[data.streamId].startCall, _this4.streamControllers[data.streamId].pullCall, _this4.streamControllers[data.streamId].cancelCall].map(function (capability) {
  12288. return capability && finalize(capability.promise);
  12289. })).then(function () {
  12290. delete _this4.streamControllers[data.streamId];
  12291. });
  12292. };
  12293. switch (data.stream) {
  12294. case 'start_complete':
  12295. resolveOrReject(this.streamControllers[data.streamId].startCall, data.success, wrapReason(data.reason));
  12296. break;
  12297. case 'pull_complete':
  12298. resolveOrReject(this.streamControllers[data.streamId].pullCall, data.success, wrapReason(data.reason));
  12299. break;
  12300. case 'pull':
  12301. if (!this.streamSinks[data.streamId]) {
  12302. sendStreamResponse({
  12303. stream: 'pull_complete',
  12304. success: true
  12305. });
  12306. break;
  12307. }
  12308. if (this.streamSinks[data.streamId].desiredSize <= 0 && data.desiredSize > 0) {
  12309. this.streamSinks[data.streamId].sinkCapability.resolve();
  12310. }
  12311. this.streamSinks[data.streamId].desiredSize = data.desiredSize;
  12312. resolveCall(this.streamSinks[data.streamId].onPull).then(function () {
  12313. sendStreamResponse({
  12314. stream: 'pull_complete',
  12315. success: true
  12316. });
  12317. }, function (reason) {
  12318. sendStreamResponse({
  12319. stream: 'pull_complete',
  12320. success: false,
  12321. reason: reason
  12322. });
  12323. });
  12324. break;
  12325. case 'enqueue':
  12326. (0, _util.assert)(this.streamControllers[data.streamId], 'enqueue should have stream controller');
  12327. if (!this.streamControllers[data.streamId].isClosed) {
  12328. this.streamControllers[data.streamId].controller.enqueue(data.chunk);
  12329. }
  12330. break;
  12331. case 'close':
  12332. (0, _util.assert)(this.streamControllers[data.streamId], 'close should have stream controller');
  12333. if (this.streamControllers[data.streamId].isClosed) {
  12334. break;
  12335. }
  12336. this.streamControllers[data.streamId].isClosed = true;
  12337. this.streamControllers[data.streamId].controller.close();
  12338. deleteStreamController();
  12339. break;
  12340. case 'error':
  12341. (0, _util.assert)(this.streamControllers[data.streamId], 'error should have stream controller');
  12342. this.streamControllers[data.streamId].controller.error(wrapReason(data.reason));
  12343. deleteStreamController();
  12344. break;
  12345. case 'cancel_complete':
  12346. resolveOrReject(this.streamControllers[data.streamId].cancelCall, data.success, wrapReason(data.reason));
  12347. deleteStreamController();
  12348. break;
  12349. case 'cancel':
  12350. if (!this.streamSinks[data.streamId]) {
  12351. break;
  12352. }
  12353. resolveCall(this.streamSinks[data.streamId].onCancel, [wrapReason(data.reason)]).then(function () {
  12354. sendStreamResponse({
  12355. stream: 'cancel_complete',
  12356. success: true
  12357. });
  12358. }, function (reason) {
  12359. sendStreamResponse({
  12360. stream: 'cancel_complete',
  12361. success: false,
  12362. reason: reason
  12363. });
  12364. });
  12365. this.streamSinks[data.streamId].sinkCapability.reject(wrapReason(data.reason));
  12366. this.streamSinks[data.streamId].isCancelled = true;
  12367. delete this.streamSinks[data.streamId];
  12368. break;
  12369. default:
  12370. throw new Error('Unexpected stream case');
  12371. }
  12372. },
  12373. postMessage: function postMessage(message, transfers) {
  12374. if (transfers && this.postMessageTransfers) {
  12375. this.comObj.postMessage(message, transfers);
  12376. } else {
  12377. this.comObj.postMessage(message);
  12378. }
  12379. },
  12380. destroy: function destroy() {
  12381. this.comObj.removeEventListener('message', this._onComObjOnMessage);
  12382. }
  12383. };
  12384. exports.MessageHandler = MessageHandler;
  12385. /***/ }),
  12386. /* 137 */
  12387. /***/ (function(module, exports, __w_pdfjs_require__) {
  12388. "use strict";
  12389. module.exports = __w_pdfjs_require__(138);
  12390. /***/ }),
  12391. /* 138 */
  12392. /***/ (function(module, exports, __w_pdfjs_require__) {
  12393. "use strict";
  12394. var g = function () {
  12395. return this;
  12396. }() || Function("return this")();
  12397. var hadRuntime = g.regeneratorRuntime && Object.getOwnPropertyNames(g).indexOf("regeneratorRuntime") >= 0;
  12398. var oldRuntime = hadRuntime && g.regeneratorRuntime;
  12399. g.regeneratorRuntime = undefined;
  12400. module.exports = __w_pdfjs_require__(139);
  12401. if (hadRuntime) {
  12402. g.regeneratorRuntime = oldRuntime;
  12403. } else {
  12404. try {
  12405. delete g.regeneratorRuntime;
  12406. } catch (e) {
  12407. g.regeneratorRuntime = undefined;
  12408. }
  12409. }
  12410. /***/ }),
  12411. /* 139 */
  12412. /***/ (function(module, exports, __w_pdfjs_require__) {
  12413. "use strict";
  12414. /* WEBPACK VAR INJECTION */(function(module) {
  12415. 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; };
  12416. !function (global) {
  12417. "use strict";
  12418. var Op = Object.prototype;
  12419. var hasOwn = Op.hasOwnProperty;
  12420. var undefined;
  12421. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  12422. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  12423. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  12424. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  12425. var inModule = ( false ? undefined : _typeof(module)) === "object";
  12426. var runtime = global.regeneratorRuntime;
  12427. if (runtime) {
  12428. if (inModule) {
  12429. module.exports = runtime;
  12430. }
  12431. return;
  12432. }
  12433. runtime = global.regeneratorRuntime = inModule ? module.exports : {};
  12434. function wrap(innerFn, outerFn, self, tryLocsList) {
  12435. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  12436. var generator = Object.create(protoGenerator.prototype);
  12437. var context = new Context(tryLocsList || []);
  12438. generator._invoke = makeInvokeMethod(innerFn, self, context);
  12439. return generator;
  12440. }
  12441. runtime.wrap = wrap;
  12442. function tryCatch(fn, obj, arg) {
  12443. try {
  12444. return {
  12445. type: "normal",
  12446. arg: fn.call(obj, arg)
  12447. };
  12448. } catch (err) {
  12449. return {
  12450. type: "throw",
  12451. arg: err
  12452. };
  12453. }
  12454. }
  12455. var GenStateSuspendedStart = "suspendedStart";
  12456. var GenStateSuspendedYield = "suspendedYield";
  12457. var GenStateExecuting = "executing";
  12458. var GenStateCompleted = "completed";
  12459. var ContinueSentinel = {};
  12460. function Generator() {}
  12461. function GeneratorFunction() {}
  12462. function GeneratorFunctionPrototype() {}
  12463. var IteratorPrototype = {};
  12464. IteratorPrototype[iteratorSymbol] = function () {
  12465. return this;
  12466. };
  12467. var getProto = Object.getPrototypeOf;
  12468. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  12469. if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  12470. IteratorPrototype = NativeIteratorPrototype;
  12471. }
  12472. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
  12473. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  12474. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  12475. GeneratorFunctionPrototype[toStringTagSymbol] = GeneratorFunction.displayName = "GeneratorFunction";
  12476. function defineIteratorMethods(prototype) {
  12477. ["next", "throw", "return"].forEach(function (method) {
  12478. prototype[method] = function (arg) {
  12479. return this._invoke(method, arg);
  12480. };
  12481. });
  12482. }
  12483. runtime.isGeneratorFunction = function (genFun) {
  12484. var ctor = typeof genFun === "function" && genFun.constructor;
  12485. return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
  12486. };
  12487. runtime.mark = function (genFun) {
  12488. if (Object.setPrototypeOf) {
  12489. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  12490. } else {
  12491. genFun.__proto__ = GeneratorFunctionPrototype;
  12492. if (!(toStringTagSymbol in genFun)) {
  12493. genFun[toStringTagSymbol] = "GeneratorFunction";
  12494. }
  12495. }
  12496. genFun.prototype = Object.create(Gp);
  12497. return genFun;
  12498. };
  12499. runtime.awrap = function (arg) {
  12500. return { __await: arg };
  12501. };
  12502. function AsyncIterator(generator) {
  12503. function invoke(method, arg, resolve, reject) {
  12504. var record = tryCatch(generator[method], generator, arg);
  12505. if (record.type === "throw") {
  12506. reject(record.arg);
  12507. } else {
  12508. var result = record.arg;
  12509. var value = result.value;
  12510. if (value && (typeof value === "undefined" ? "undefined" : _typeof(value)) === "object" && hasOwn.call(value, "__await")) {
  12511. return Promise.resolve(value.__await).then(function (value) {
  12512. invoke("next", value, resolve, reject);
  12513. }, function (err) {
  12514. invoke("throw", err, resolve, reject);
  12515. });
  12516. }
  12517. return Promise.resolve(value).then(function (unwrapped) {
  12518. result.value = unwrapped;
  12519. resolve(result);
  12520. }, reject);
  12521. }
  12522. }
  12523. var previousPromise;
  12524. function enqueue(method, arg) {
  12525. function callInvokeWithMethodAndArg() {
  12526. return new Promise(function (resolve, reject) {
  12527. invoke(method, arg, resolve, reject);
  12528. });
  12529. }
  12530. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  12531. }
  12532. this._invoke = enqueue;
  12533. }
  12534. defineIteratorMethods(AsyncIterator.prototype);
  12535. AsyncIterator.prototype[asyncIteratorSymbol] = function () {
  12536. return this;
  12537. };
  12538. runtime.AsyncIterator = AsyncIterator;
  12539. runtime.async = function (innerFn, outerFn, self, tryLocsList) {
  12540. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList));
  12541. return runtime.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  12542. return result.done ? result.value : iter.next();
  12543. });
  12544. };
  12545. function makeInvokeMethod(innerFn, self, context) {
  12546. var state = GenStateSuspendedStart;
  12547. return function invoke(method, arg) {
  12548. if (state === GenStateExecuting) {
  12549. throw new Error("Generator is already running");
  12550. }
  12551. if (state === GenStateCompleted) {
  12552. if (method === "throw") {
  12553. throw arg;
  12554. }
  12555. return doneResult();
  12556. }
  12557. context.method = method;
  12558. context.arg = arg;
  12559. while (true) {
  12560. var delegate = context.delegate;
  12561. if (delegate) {
  12562. var delegateResult = maybeInvokeDelegate(delegate, context);
  12563. if (delegateResult) {
  12564. if (delegateResult === ContinueSentinel) continue;
  12565. return delegateResult;
  12566. }
  12567. }
  12568. if (context.method === "next") {
  12569. context.sent = context._sent = context.arg;
  12570. } else if (context.method === "throw") {
  12571. if (state === GenStateSuspendedStart) {
  12572. state = GenStateCompleted;
  12573. throw context.arg;
  12574. }
  12575. context.dispatchException(context.arg);
  12576. } else if (context.method === "return") {
  12577. context.abrupt("return", context.arg);
  12578. }
  12579. state = GenStateExecuting;
  12580. var record = tryCatch(innerFn, self, context);
  12581. if (record.type === "normal") {
  12582. state = context.done ? GenStateCompleted : GenStateSuspendedYield;
  12583. if (record.arg === ContinueSentinel) {
  12584. continue;
  12585. }
  12586. return {
  12587. value: record.arg,
  12588. done: context.done
  12589. };
  12590. } else if (record.type === "throw") {
  12591. state = GenStateCompleted;
  12592. context.method = "throw";
  12593. context.arg = record.arg;
  12594. }
  12595. }
  12596. };
  12597. }
  12598. function maybeInvokeDelegate(delegate, context) {
  12599. var method = delegate.iterator[context.method];
  12600. if (method === undefined) {
  12601. context.delegate = null;
  12602. if (context.method === "throw") {
  12603. if (delegate.iterator.return) {
  12604. context.method = "return";
  12605. context.arg = undefined;
  12606. maybeInvokeDelegate(delegate, context);
  12607. if (context.method === "throw") {
  12608. return ContinueSentinel;
  12609. }
  12610. }
  12611. context.method = "throw";
  12612. context.arg = new TypeError("The iterator does not provide a 'throw' method");
  12613. }
  12614. return ContinueSentinel;
  12615. }
  12616. var record = tryCatch(method, delegate.iterator, context.arg);
  12617. if (record.type === "throw") {
  12618. context.method = "throw";
  12619. context.arg = record.arg;
  12620. context.delegate = null;
  12621. return ContinueSentinel;
  12622. }
  12623. var info = record.arg;
  12624. if (!info) {
  12625. context.method = "throw";
  12626. context.arg = new TypeError("iterator result is not an object");
  12627. context.delegate = null;
  12628. return ContinueSentinel;
  12629. }
  12630. if (info.done) {
  12631. context[delegate.resultName] = info.value;
  12632. context.next = delegate.nextLoc;
  12633. if (context.method !== "return") {
  12634. context.method = "next";
  12635. context.arg = undefined;
  12636. }
  12637. } else {
  12638. return info;
  12639. }
  12640. context.delegate = null;
  12641. return ContinueSentinel;
  12642. }
  12643. defineIteratorMethods(Gp);
  12644. Gp[toStringTagSymbol] = "Generator";
  12645. Gp[iteratorSymbol] = function () {
  12646. return this;
  12647. };
  12648. Gp.toString = function () {
  12649. return "[object Generator]";
  12650. };
  12651. function pushTryEntry(locs) {
  12652. var entry = { tryLoc: locs[0] };
  12653. if (1 in locs) {
  12654. entry.catchLoc = locs[1];
  12655. }
  12656. if (2 in locs) {
  12657. entry.finallyLoc = locs[2];
  12658. entry.afterLoc = locs[3];
  12659. }
  12660. this.tryEntries.push(entry);
  12661. }
  12662. function resetTryEntry(entry) {
  12663. var record = entry.completion || {};
  12664. record.type = "normal";
  12665. delete record.arg;
  12666. entry.completion = record;
  12667. }
  12668. function Context(tryLocsList) {
  12669. this.tryEntries = [{ tryLoc: "root" }];
  12670. tryLocsList.forEach(pushTryEntry, this);
  12671. this.reset(true);
  12672. }
  12673. runtime.keys = function (object) {
  12674. var keys = [];
  12675. for (var key in object) {
  12676. keys.push(key);
  12677. }
  12678. keys.reverse();
  12679. return function next() {
  12680. while (keys.length) {
  12681. var key = keys.pop();
  12682. if (key in object) {
  12683. next.value = key;
  12684. next.done = false;
  12685. return next;
  12686. }
  12687. }
  12688. next.done = true;
  12689. return next;
  12690. };
  12691. };
  12692. function values(iterable) {
  12693. if (iterable) {
  12694. var iteratorMethod = iterable[iteratorSymbol];
  12695. if (iteratorMethod) {
  12696. return iteratorMethod.call(iterable);
  12697. }
  12698. if (typeof iterable.next === "function") {
  12699. return iterable;
  12700. }
  12701. if (!isNaN(iterable.length)) {
  12702. var i = -1,
  12703. next = function next() {
  12704. while (++i < iterable.length) {
  12705. if (hasOwn.call(iterable, i)) {
  12706. next.value = iterable[i];
  12707. next.done = false;
  12708. return next;
  12709. }
  12710. }
  12711. next.value = undefined;
  12712. next.done = true;
  12713. return next;
  12714. };
  12715. return next.next = next;
  12716. }
  12717. }
  12718. return { next: doneResult };
  12719. }
  12720. runtime.values = values;
  12721. function doneResult() {
  12722. return {
  12723. value: undefined,
  12724. done: true
  12725. };
  12726. }
  12727. Context.prototype = {
  12728. constructor: Context,
  12729. reset: function reset(skipTempReset) {
  12730. this.prev = 0;
  12731. this.next = 0;
  12732. this.sent = this._sent = undefined;
  12733. this.done = false;
  12734. this.delegate = null;
  12735. this.method = "next";
  12736. this.arg = undefined;
  12737. this.tryEntries.forEach(resetTryEntry);
  12738. if (!skipTempReset) {
  12739. for (var name in this) {
  12740. if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
  12741. this[name] = undefined;
  12742. }
  12743. }
  12744. }
  12745. },
  12746. stop: function stop() {
  12747. this.done = true;
  12748. var rootEntry = this.tryEntries[0];
  12749. var rootRecord = rootEntry.completion;
  12750. if (rootRecord.type === "throw") {
  12751. throw rootRecord.arg;
  12752. }
  12753. return this.rval;
  12754. },
  12755. dispatchException: function dispatchException(exception) {
  12756. if (this.done) {
  12757. throw exception;
  12758. }
  12759. var context = this;
  12760. function handle(loc, caught) {
  12761. record.type = "throw";
  12762. record.arg = exception;
  12763. context.next = loc;
  12764. if (caught) {
  12765. context.method = "next";
  12766. context.arg = undefined;
  12767. }
  12768. return !!caught;
  12769. }
  12770. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  12771. var entry = this.tryEntries[i];
  12772. var record = entry.completion;
  12773. if (entry.tryLoc === "root") {
  12774. return handle("end");
  12775. }
  12776. if (entry.tryLoc <= this.prev) {
  12777. var hasCatch = hasOwn.call(entry, "catchLoc");
  12778. var hasFinally = hasOwn.call(entry, "finallyLoc");
  12779. if (hasCatch && hasFinally) {
  12780. if (this.prev < entry.catchLoc) {
  12781. return handle(entry.catchLoc, true);
  12782. } else if (this.prev < entry.finallyLoc) {
  12783. return handle(entry.finallyLoc);
  12784. }
  12785. } else if (hasCatch) {
  12786. if (this.prev < entry.catchLoc) {
  12787. return handle(entry.catchLoc, true);
  12788. }
  12789. } else if (hasFinally) {
  12790. if (this.prev < entry.finallyLoc) {
  12791. return handle(entry.finallyLoc);
  12792. }
  12793. } else {
  12794. throw new Error("try statement without catch or finally");
  12795. }
  12796. }
  12797. }
  12798. },
  12799. abrupt: function abrupt(type, arg) {
  12800. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  12801. var entry = this.tryEntries[i];
  12802. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  12803. var finallyEntry = entry;
  12804. break;
  12805. }
  12806. }
  12807. if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
  12808. finallyEntry = null;
  12809. }
  12810. var record = finallyEntry ? finallyEntry.completion : {};
  12811. record.type = type;
  12812. record.arg = arg;
  12813. if (finallyEntry) {
  12814. this.method = "next";
  12815. this.next = finallyEntry.finallyLoc;
  12816. return ContinueSentinel;
  12817. }
  12818. return this.complete(record);
  12819. },
  12820. complete: function complete(record, afterLoc) {
  12821. if (record.type === "throw") {
  12822. throw record.arg;
  12823. }
  12824. if (record.type === "break" || record.type === "continue") {
  12825. this.next = record.arg;
  12826. } else if (record.type === "return") {
  12827. this.rval = this.arg = record.arg;
  12828. this.method = "return";
  12829. this.next = "end";
  12830. } else if (record.type === "normal" && afterLoc) {
  12831. this.next = afterLoc;
  12832. }
  12833. return ContinueSentinel;
  12834. },
  12835. finish: function finish(finallyLoc) {
  12836. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  12837. var entry = this.tryEntries[i];
  12838. if (entry.finallyLoc === finallyLoc) {
  12839. this.complete(entry.completion, entry.afterLoc);
  12840. resetTryEntry(entry);
  12841. return ContinueSentinel;
  12842. }
  12843. }
  12844. },
  12845. "catch": function _catch(tryLoc) {
  12846. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  12847. var entry = this.tryEntries[i];
  12848. if (entry.tryLoc === tryLoc) {
  12849. var record = entry.completion;
  12850. if (record.type === "throw") {
  12851. var thrown = record.arg;
  12852. resetTryEntry(entry);
  12853. }
  12854. return thrown;
  12855. }
  12856. }
  12857. throw new Error("illegal catch attempt");
  12858. },
  12859. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  12860. this.delegate = {
  12861. iterator: values(iterable),
  12862. resultName: resultName,
  12863. nextLoc: nextLoc
  12864. };
  12865. if (this.method === "next") {
  12866. this.arg = undefined;
  12867. }
  12868. return ContinueSentinel;
  12869. }
  12870. };
  12871. }(function () {
  12872. return this;
  12873. }() || Function("return this")());
  12874. /* WEBPACK VAR INJECTION */}.call(this, __w_pdfjs_require__(140)(module)))
  12875. /***/ }),
  12876. /* 140 */
  12877. /***/ (function(module, exports, __w_pdfjs_require__) {
  12878. "use strict";
  12879. module.exports = function (module) {
  12880. if (!module.webpackPolyfill) {
  12881. module.deprecate = function () {};
  12882. module.paths = [];
  12883. if (!module.children) module.children = [];
  12884. Object.defineProperty(module, "loaded", {
  12885. enumerable: true,
  12886. get: function get() {
  12887. return module.l;
  12888. }
  12889. });
  12890. Object.defineProperty(module, "id", {
  12891. enumerable: true,
  12892. get: function get() {
  12893. return module.i;
  12894. }
  12895. });
  12896. module.webpackPolyfill = 1;
  12897. }
  12898. return module;
  12899. };
  12900. /***/ }),
  12901. /* 141 */
  12902. /***/ (function(module, exports, __w_pdfjs_require__) {
  12903. "use strict";
  12904. Object.defineProperty(exports, "__esModule", {
  12905. value: true
  12906. });
  12907. exports.Metadata = undefined;
  12908. 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; }; }();
  12909. var _util = __w_pdfjs_require__(1);
  12910. var _xml_parser = __w_pdfjs_require__(142);
  12911. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12912. var Metadata = function () {
  12913. function Metadata(data) {
  12914. _classCallCheck(this, Metadata);
  12915. (0, _util.assert)(typeof data === 'string', 'Metadata: input is not a string');
  12916. data = this._repair(data);
  12917. var parser = new _xml_parser.SimpleXMLParser();
  12918. var xmlDocument = parser.parseFromString(data);
  12919. this._metadata = Object.create(null);
  12920. if (xmlDocument) {
  12921. this._parse(xmlDocument);
  12922. }
  12923. }
  12924. _createClass(Metadata, [{
  12925. key: '_repair',
  12926. value: function _repair(data) {
  12927. return data.replace(/>\\376\\377([^<]+)/g, function (all, codes) {
  12928. var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) {
  12929. return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
  12930. }).replace(/&(amp|apos|gt|lt|quot);/g, function (str, name) {
  12931. switch (name) {
  12932. case 'amp':
  12933. return '&';
  12934. case 'apos':
  12935. return '\'';
  12936. case 'gt':
  12937. return '>';
  12938. case 'lt':
  12939. return '<';
  12940. case 'quot':
  12941. return '\"';
  12942. }
  12943. throw new Error('_repair: ' + name + ' isn\'t defined.');
  12944. });
  12945. var chars = '';
  12946. for (var i = 0, ii = bytes.length; i < ii; i += 2) {
  12947. var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
  12948. if (code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38) {
  12949. chars += String.fromCharCode(code);
  12950. } else {
  12951. chars += '&#x' + (0x10000 + code).toString(16).substring(1) + ';';
  12952. }
  12953. }
  12954. return '>' + chars;
  12955. });
  12956. }
  12957. }, {
  12958. key: '_parse',
  12959. value: function _parse(xmlDocument) {
  12960. var rdf = xmlDocument.documentElement;
  12961. if (rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  12962. rdf = rdf.firstChild;
  12963. while (rdf && rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  12964. rdf = rdf.nextSibling;
  12965. }
  12966. }
  12967. var nodeName = rdf ? rdf.nodeName.toLowerCase() : null;
  12968. if (!rdf || nodeName !== 'rdf:rdf' || !rdf.hasChildNodes()) {
  12969. return;
  12970. }
  12971. var children = rdf.childNodes;
  12972. for (var i = 0, ii = children.length; i < ii; i++) {
  12973. var desc = children[i];
  12974. if (desc.nodeName.toLowerCase() !== 'rdf:description') {
  12975. continue;
  12976. }
  12977. for (var j = 0, jj = desc.childNodes.length; j < jj; j++) {
  12978. if (desc.childNodes[j].nodeName.toLowerCase() !== '#text') {
  12979. var entry = desc.childNodes[j];
  12980. var name = entry.nodeName.toLowerCase();
  12981. this._metadata[name] = entry.textContent.trim();
  12982. }
  12983. }
  12984. }
  12985. }
  12986. }, {
  12987. key: 'get',
  12988. value: function get(name) {
  12989. return this._metadata[name] || null;
  12990. }
  12991. }, {
  12992. key: 'getAll',
  12993. value: function getAll() {
  12994. return this._metadata;
  12995. }
  12996. }, {
  12997. key: 'has',
  12998. value: function has(name) {
  12999. return typeof this._metadata[name] !== 'undefined';
  13000. }
  13001. }]);
  13002. return Metadata;
  13003. }();
  13004. exports.Metadata = Metadata;
  13005. /***/ }),
  13006. /* 142 */
  13007. /***/ (function(module, exports, __w_pdfjs_require__) {
  13008. "use strict";
  13009. Object.defineProperty(exports, "__esModule", {
  13010. value: true
  13011. });
  13012. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  13013. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  13014. 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; }; }();
  13015. 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; }
  13016. 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; }
  13017. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13018. var XMLParserErrorCode = {
  13019. NoError: 0,
  13020. EndOfDocument: -1,
  13021. UnterminatedCdat: -2,
  13022. UnterminatedXmlDeclaration: -3,
  13023. UnterminatedDoctypeDeclaration: -4,
  13024. UnterminatedComment: -5,
  13025. MalformedElement: -6,
  13026. OutOfMemory: -7,
  13027. UnterminatedAttributeValue: -8,
  13028. UnterminatedElement: -9,
  13029. ElementNeverBegun: -10
  13030. };
  13031. function isWhitespace(s, index) {
  13032. var ch = s[index];
  13033. return ch === ' ' || ch === '\n' || ch === '\r' || ch === '\t';
  13034. }
  13035. function isWhitespaceString(s) {
  13036. for (var i = 0, ii = s.length; i < ii; i++) {
  13037. if (!isWhitespace(s, i)) {
  13038. return false;
  13039. }
  13040. }
  13041. return true;
  13042. }
  13043. var XMLParserBase = function () {
  13044. function XMLParserBase() {
  13045. _classCallCheck(this, XMLParserBase);
  13046. }
  13047. _createClass(XMLParserBase, [{
  13048. key: '_resolveEntities',
  13049. value: function _resolveEntities(s) {
  13050. return s.replace(/&([^;]+);/g, function (all, entity) {
  13051. if (entity.substring(0, 2) === '#x') {
  13052. return String.fromCharCode(parseInt(entity.substring(2), 16));
  13053. } else if (entity.substring(0, 1) === '#') {
  13054. return String.fromCharCode(parseInt(entity.substring(1), 10));
  13055. }
  13056. switch (entity) {
  13057. case 'lt':
  13058. return '<';
  13059. case 'gt':
  13060. return '>';
  13061. case 'amp':
  13062. return '&';
  13063. case 'quot':
  13064. return '\"';
  13065. }
  13066. return this.onResolveEntity(entity);
  13067. });
  13068. }
  13069. }, {
  13070. key: '_parseContent',
  13071. value: function _parseContent(s, start) {
  13072. var pos = start,
  13073. name = void 0,
  13074. attributes = [];
  13075. function skipWs() {
  13076. while (pos < s.length && isWhitespace(s, pos)) {
  13077. ++pos;
  13078. }
  13079. }
  13080. while (pos < s.length && !isWhitespace(s, pos) && s[pos] !== '>' && s[pos] !== '/') {
  13081. ++pos;
  13082. }
  13083. name = s.substring(start, pos);
  13084. skipWs();
  13085. while (pos < s.length && s[pos] !== '>' && s[pos] !== '/' && s[pos] !== '?') {
  13086. skipWs();
  13087. var attrName = '',
  13088. attrValue = '';
  13089. while (pos < s.length && !isWhitespace(s, pos) && s[pos] !== '=') {
  13090. attrName += s[pos];
  13091. ++pos;
  13092. }
  13093. skipWs();
  13094. if (s[pos] !== '=') {
  13095. return null;
  13096. }
  13097. ++pos;
  13098. skipWs();
  13099. var attrEndChar = s[pos];
  13100. if (attrEndChar !== '\"' && attrEndChar !== '\'') {
  13101. return null;
  13102. }
  13103. var attrEndIndex = s.indexOf(attrEndChar, ++pos);
  13104. if (attrEndIndex < 0) {
  13105. return null;
  13106. }
  13107. attrValue = s.substring(pos, attrEndIndex);
  13108. attributes.push({
  13109. name: attrName,
  13110. value: this._resolveEntities(attrValue)
  13111. });
  13112. pos = attrEndIndex + 1;
  13113. skipWs();
  13114. }
  13115. return {
  13116. name: name,
  13117. attributes: attributes,
  13118. parsed: pos - start
  13119. };
  13120. }
  13121. }, {
  13122. key: '_parseProcessingInstruction',
  13123. value: function _parseProcessingInstruction(s, start) {
  13124. var pos = start,
  13125. name = void 0,
  13126. value = void 0;
  13127. function skipWs() {
  13128. while (pos < s.length && isWhitespace(s, pos)) {
  13129. ++pos;
  13130. }
  13131. }
  13132. while (pos < s.length && !isWhitespace(s, pos) && s[pos] !== '>' && s[pos] !== '/') {
  13133. ++pos;
  13134. }
  13135. name = s.substring(start, pos);
  13136. skipWs();
  13137. var attrStart = pos;
  13138. while (pos < s.length && (s[pos] !== '?' || s[pos + 1] !== '>')) {
  13139. ++pos;
  13140. }
  13141. value = s.substring(attrStart, pos);
  13142. return {
  13143. name: name,
  13144. value: value,
  13145. parsed: pos - start
  13146. };
  13147. }
  13148. }, {
  13149. key: 'parseXml',
  13150. value: function parseXml(s) {
  13151. var i = 0;
  13152. while (i < s.length) {
  13153. var ch = s[i];
  13154. var j = i;
  13155. if (ch === '<') {
  13156. ++j;
  13157. var ch2 = s[j];
  13158. var q = void 0;
  13159. switch (ch2) {
  13160. case '/':
  13161. ++j;
  13162. q = s.indexOf('>', j);
  13163. if (q < 0) {
  13164. this.onError(XMLParserErrorCode.UnterminatedElement);
  13165. return;
  13166. }
  13167. this.onEndElement(s.substring(j, q));
  13168. j = q + 1;
  13169. break;
  13170. case '?':
  13171. ++j;
  13172. var pi = this._parseProcessingInstruction(s, j);
  13173. if (s.substring(j + pi.parsed, j + pi.parsed + 2) !== '?>') {
  13174. this.onError(XMLParserErrorCode.UnterminatedXmlDeclaration);
  13175. return;
  13176. }
  13177. this.onPi(pi.name, pi.value);
  13178. j += pi.parsed + 2;
  13179. break;
  13180. case '!':
  13181. if (s.substring(j + 1, j + 3) === '--') {
  13182. q = s.indexOf('-->', j + 3);
  13183. if (q < 0) {
  13184. this.onError(XMLParserErrorCode.UnterminatedComment);
  13185. return;
  13186. }
  13187. this.onComment(s.substring(j + 3, q));
  13188. j = q + 3;
  13189. } else if (s.substring(j + 1, j + 8) === '[CDATA[') {
  13190. q = s.indexOf(']]>', j + 8);
  13191. if (q < 0) {
  13192. this.onError(XMLParserErrorCode.UnterminatedCdat);
  13193. return;
  13194. }
  13195. this.onCdata(s.substring(j + 8, q));
  13196. j = q + 3;
  13197. } else if (s.substring(j + 1, j + 8) === 'DOCTYPE') {
  13198. var q2 = s.indexOf('[', j + 8);
  13199. var complexDoctype = false;
  13200. q = s.indexOf('>', j + 8);
  13201. if (q < 0) {
  13202. this.onError(XMLParserErrorCode.UnterminatedDoctypeDeclaration);
  13203. return;
  13204. }
  13205. if (q2 > 0 && q > q2) {
  13206. q = s.indexOf(']>', j + 8);
  13207. if (q < 0) {
  13208. this.onError(XMLParserErrorCode.UnterminatedDoctypeDeclaration);
  13209. return;
  13210. }
  13211. complexDoctype = true;
  13212. }
  13213. var doctypeContent = s.substring(j + 8, q + (complexDoctype ? 1 : 0));
  13214. this.onDoctype(doctypeContent);
  13215. j = q + (complexDoctype ? 2 : 1);
  13216. } else {
  13217. this.onError(XMLParserErrorCode.MalformedElement);
  13218. return;
  13219. }
  13220. break;
  13221. default:
  13222. var content = this._parseContent(s, j);
  13223. if (content === null) {
  13224. this.onError(XMLParserErrorCode.MalformedElement);
  13225. return;
  13226. }
  13227. var isClosed = false;
  13228. if (s.substring(j + content.parsed, j + content.parsed + 2) === '/>') {
  13229. isClosed = true;
  13230. } else if (s.substring(j + content.parsed, j + content.parsed + 1) !== '>') {
  13231. this.onError(XMLParserErrorCode.UnterminatedElement);
  13232. return;
  13233. }
  13234. this.onBeginElement(content.name, content.attributes, isClosed);
  13235. j += content.parsed + (isClosed ? 2 : 1);
  13236. break;
  13237. }
  13238. } else {
  13239. while (j < s.length && s[j] !== '<') {
  13240. j++;
  13241. }
  13242. var text = s.substring(i, j);
  13243. this.onText(this._resolveEntities(text));
  13244. }
  13245. i = j;
  13246. }
  13247. }
  13248. }, {
  13249. key: 'onResolveEntity',
  13250. value: function onResolveEntity(name) {
  13251. return '&' + name + ';';
  13252. }
  13253. }, {
  13254. key: 'onPi',
  13255. value: function onPi(name, value) {}
  13256. }, {
  13257. key: 'onComment',
  13258. value: function onComment(text) {}
  13259. }, {
  13260. key: 'onCdata',
  13261. value: function onCdata(text) {}
  13262. }, {
  13263. key: 'onDoctype',
  13264. value: function onDoctype(doctypeContent) {}
  13265. }, {
  13266. key: 'onText',
  13267. value: function onText(text) {}
  13268. }, {
  13269. key: 'onBeginElement',
  13270. value: function onBeginElement(name, attributes, isEmpty) {}
  13271. }, {
  13272. key: 'onEndElement',
  13273. value: function onEndElement(name) {}
  13274. }, {
  13275. key: 'onError',
  13276. value: function onError(code) {}
  13277. }]);
  13278. return XMLParserBase;
  13279. }();
  13280. var SimpleDOMNode = function () {
  13281. function SimpleDOMNode(nodeName, nodeValue) {
  13282. _classCallCheck(this, SimpleDOMNode);
  13283. this.nodeName = nodeName;
  13284. this.nodeValue = nodeValue;
  13285. Object.defineProperty(this, 'parentNode', {
  13286. value: null,
  13287. writable: true
  13288. });
  13289. }
  13290. _createClass(SimpleDOMNode, [{
  13291. key: 'hasChildNodes',
  13292. value: function hasChildNodes() {
  13293. return this.childNodes && this.childNodes.length > 0;
  13294. }
  13295. }, {
  13296. key: 'firstChild',
  13297. get: function get() {
  13298. return this.childNodes[0];
  13299. }
  13300. }, {
  13301. key: 'nextSibling',
  13302. get: function get() {
  13303. var index = this.parentNode.childNodes.indexOf(this);
  13304. return this.parentNode.childNodes[index + 1];
  13305. }
  13306. }, {
  13307. key: 'textContent',
  13308. get: function get() {
  13309. if (!this.childNodes) {
  13310. return this.nodeValue || '';
  13311. }
  13312. return this.childNodes.map(function (child) {
  13313. return child.textContent;
  13314. }).join('');
  13315. }
  13316. }]);
  13317. return SimpleDOMNode;
  13318. }();
  13319. var SimpleXMLParser = function (_XMLParserBase) {
  13320. _inherits(SimpleXMLParser, _XMLParserBase);
  13321. function SimpleXMLParser() {
  13322. _classCallCheck(this, SimpleXMLParser);
  13323. var _this = _possibleConstructorReturn(this, (SimpleXMLParser.__proto__ || Object.getPrototypeOf(SimpleXMLParser)).call(this));
  13324. _this._currentFragment = null;
  13325. _this._stack = null;
  13326. _this._errorCode = XMLParserErrorCode.NoError;
  13327. return _this;
  13328. }
  13329. _createClass(SimpleXMLParser, [{
  13330. key: 'parseFromString',
  13331. value: function parseFromString(data) {
  13332. this._currentFragment = [];
  13333. this._stack = [];
  13334. this._errorCode = XMLParserErrorCode.NoError;
  13335. this.parseXml(data);
  13336. if (this._errorCode !== XMLParserErrorCode.NoError) {
  13337. return undefined;
  13338. }
  13339. var _currentFragment = _slicedToArray(this._currentFragment, 1),
  13340. documentElement = _currentFragment[0];
  13341. if (!documentElement) {
  13342. return undefined;
  13343. }
  13344. return { documentElement: documentElement };
  13345. }
  13346. }, {
  13347. key: 'onResolveEntity',
  13348. value: function onResolveEntity(name) {
  13349. switch (name) {
  13350. case 'apos':
  13351. return '\'';
  13352. }
  13353. return _get(SimpleXMLParser.prototype.__proto__ || Object.getPrototypeOf(SimpleXMLParser.prototype), 'onResolveEntity', this).call(this, name);
  13354. }
  13355. }, {
  13356. key: 'onText',
  13357. value: function onText(text) {
  13358. if (isWhitespaceString(text)) {
  13359. return;
  13360. }
  13361. var node = new SimpleDOMNode('#text', text);
  13362. this._currentFragment.push(node);
  13363. }
  13364. }, {
  13365. key: 'onCdata',
  13366. value: function onCdata(text) {
  13367. var node = new SimpleDOMNode('#text', text);
  13368. this._currentFragment.push(node);
  13369. }
  13370. }, {
  13371. key: 'onBeginElement',
  13372. value: function onBeginElement(name, attributes, isEmpty) {
  13373. var node = new SimpleDOMNode(name);
  13374. node.childNodes = [];
  13375. this._currentFragment.push(node);
  13376. if (isEmpty) {
  13377. return;
  13378. }
  13379. this._stack.push(this._currentFragment);
  13380. this._currentFragment = node.childNodes;
  13381. }
  13382. }, {
  13383. key: 'onEndElement',
  13384. value: function onEndElement(name) {
  13385. this._currentFragment = this._stack.pop();
  13386. var lastElement = this._currentFragment[this._currentFragment.length - 1];
  13387. for (var i = 0, ii = lastElement.childNodes.length; i < ii; i++) {
  13388. lastElement.childNodes[i].parentNode = lastElement;
  13389. }
  13390. }
  13391. }, {
  13392. key: 'onError',
  13393. value: function onError(code) {
  13394. this._errorCode = code;
  13395. }
  13396. }]);
  13397. return SimpleXMLParser;
  13398. }(XMLParserBase);
  13399. exports.SimpleXMLParser = SimpleXMLParser;
  13400. /***/ }),
  13401. /* 143 */
  13402. /***/ (function(module, exports, __w_pdfjs_require__) {
  13403. "use strict";
  13404. Object.defineProperty(exports, "__esModule", {
  13405. value: true
  13406. });
  13407. exports.PDFDataTransportStream = undefined;
  13408. var _regenerator = __w_pdfjs_require__(137);
  13409. var _regenerator2 = _interopRequireDefault(_regenerator);
  13410. var _util = __w_pdfjs_require__(1);
  13411. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  13412. function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
  13413. var PDFDataTransportStream = function PDFDataTransportStreamClosure() {
  13414. function PDFDataTransportStream(params, pdfDataRangeTransport) {
  13415. var _this = this;
  13416. (0, _util.assert)(pdfDataRangeTransport);
  13417. this._queuedChunks = [];
  13418. var initialData = params.initialData;
  13419. if (initialData && initialData.length > 0) {
  13420. var buffer = new Uint8Array(initialData).buffer;
  13421. this._queuedChunks.push(buffer);
  13422. }
  13423. this._pdfDataRangeTransport = pdfDataRangeTransport;
  13424. this._isStreamingSupported = !params.disableStream;
  13425. this._isRangeSupported = !params.disableRange;
  13426. this._contentLength = params.length;
  13427. this._fullRequestReader = null;
  13428. this._rangeReaders = [];
  13429. this._pdfDataRangeTransport.addRangeListener(function (begin, chunk) {
  13430. _this._onReceiveData({
  13431. begin: begin,
  13432. chunk: chunk
  13433. });
  13434. });
  13435. this._pdfDataRangeTransport.addProgressListener(function (loaded) {
  13436. _this._onProgress({ loaded: loaded });
  13437. });
  13438. this._pdfDataRangeTransport.addProgressiveReadListener(function (chunk) {
  13439. _this._onReceiveData({ chunk: chunk });
  13440. });
  13441. this._pdfDataRangeTransport.transportReady();
  13442. }
  13443. PDFDataTransportStream.prototype = {
  13444. _onReceiveData: function PDFDataTransportStream_onReceiveData(args) {
  13445. var buffer = new Uint8Array(args.chunk).buffer;
  13446. if (args.begin === undefined) {
  13447. if (this._fullRequestReader) {
  13448. this._fullRequestReader._enqueue(buffer);
  13449. } else {
  13450. this._queuedChunks.push(buffer);
  13451. }
  13452. } else {
  13453. var found = this._rangeReaders.some(function (rangeReader) {
  13454. if (rangeReader._begin !== args.begin) {
  13455. return false;
  13456. }
  13457. rangeReader._enqueue(buffer);
  13458. return true;
  13459. });
  13460. (0, _util.assert)(found);
  13461. }
  13462. },
  13463. _onProgress: function PDFDataTransportStream_onDataProgress(evt) {
  13464. if (this._rangeReaders.length > 0) {
  13465. var firstReader = this._rangeReaders[0];
  13466. if (firstReader.onProgress) {
  13467. firstReader.onProgress({ loaded: evt.loaded });
  13468. }
  13469. }
  13470. },
  13471. _removeRangeReader: function PDFDataTransportStream_removeRangeReader(reader) {
  13472. var i = this._rangeReaders.indexOf(reader);
  13473. if (i >= 0) {
  13474. this._rangeReaders.splice(i, 1);
  13475. }
  13476. },
  13477. getFullReader: function PDFDataTransportStream_getFullReader() {
  13478. (0, _util.assert)(!this._fullRequestReader);
  13479. var queuedChunks = this._queuedChunks;
  13480. this._queuedChunks = null;
  13481. return new PDFDataTransportStreamReader(this, queuedChunks);
  13482. },
  13483. getRangeReader: function PDFDataTransportStream_getRangeReader(begin, end) {
  13484. var reader = new PDFDataTransportStreamRangeReader(this, begin, end);
  13485. this._pdfDataRangeTransport.requestDataRange(begin, end);
  13486. this._rangeReaders.push(reader);
  13487. return reader;
  13488. },
  13489. cancelAllRequests: function PDFDataTransportStream_cancelAllRequests(reason) {
  13490. if (this._fullRequestReader) {
  13491. this._fullRequestReader.cancel(reason);
  13492. }
  13493. var readers = this._rangeReaders.slice(0);
  13494. readers.forEach(function (rangeReader) {
  13495. rangeReader.cancel(reason);
  13496. });
  13497. this._pdfDataRangeTransport.abort();
  13498. }
  13499. };
  13500. function PDFDataTransportStreamReader(stream, queuedChunks) {
  13501. this._stream = stream;
  13502. this._done = false;
  13503. this._filename = null;
  13504. this._queuedChunks = queuedChunks || [];
  13505. this._requests = [];
  13506. this._headersReady = Promise.resolve();
  13507. stream._fullRequestReader = this;
  13508. this.onProgress = null;
  13509. }
  13510. PDFDataTransportStreamReader.prototype = {
  13511. _enqueue: function PDFDataTransportStreamReader_enqueue(chunk) {
  13512. if (this._done) {
  13513. return;
  13514. }
  13515. if (this._requests.length > 0) {
  13516. var requestCapability = this._requests.shift();
  13517. requestCapability.resolve({
  13518. value: chunk,
  13519. done: false
  13520. });
  13521. return;
  13522. }
  13523. this._queuedChunks.push(chunk);
  13524. },
  13525. get headersReady() {
  13526. return this._headersReady;
  13527. },
  13528. get filename() {
  13529. return this._filename;
  13530. },
  13531. get isRangeSupported() {
  13532. return this._stream._isRangeSupported;
  13533. },
  13534. get isStreamingSupported() {
  13535. return this._stream._isStreamingSupported;
  13536. },
  13537. get contentLength() {
  13538. return this._stream._contentLength;
  13539. },
  13540. read: function () {
  13541. var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee() {
  13542. var chunk, requestCapability;
  13543. return _regenerator2.default.wrap(function _callee$(_context) {
  13544. while (1) {
  13545. switch (_context.prev = _context.next) {
  13546. case 0:
  13547. if (!(this._queuedChunks.length > 0)) {
  13548. _context.next = 3;
  13549. break;
  13550. }
  13551. chunk = this._queuedChunks.shift();
  13552. return _context.abrupt('return', {
  13553. value: chunk,
  13554. done: false
  13555. });
  13556. case 3:
  13557. if (!this._done) {
  13558. _context.next = 5;
  13559. break;
  13560. }
  13561. return _context.abrupt('return', {
  13562. value: undefined,
  13563. done: true
  13564. });
  13565. case 5:
  13566. requestCapability = (0, _util.createPromiseCapability)();
  13567. this._requests.push(requestCapability);
  13568. return _context.abrupt('return', requestCapability.promise);
  13569. case 8:
  13570. case 'end':
  13571. return _context.stop();
  13572. }
  13573. }
  13574. }, _callee, this);
  13575. }));
  13576. function read() {
  13577. return _ref.apply(this, arguments);
  13578. }
  13579. return read;
  13580. }(),
  13581. cancel: function PDFDataTransportStreamReader_cancel(reason) {
  13582. this._done = true;
  13583. this._requests.forEach(function (requestCapability) {
  13584. requestCapability.resolve({
  13585. value: undefined,
  13586. done: true
  13587. });
  13588. });
  13589. this._requests = [];
  13590. }
  13591. };
  13592. function PDFDataTransportStreamRangeReader(stream, begin, end) {
  13593. this._stream = stream;
  13594. this._begin = begin;
  13595. this._end = end;
  13596. this._queuedChunk = null;
  13597. this._requests = [];
  13598. this._done = false;
  13599. this.onProgress = null;
  13600. }
  13601. PDFDataTransportStreamRangeReader.prototype = {
  13602. _enqueue: function PDFDataTransportStreamRangeReader_enqueue(chunk) {
  13603. if (this._done) {
  13604. return;
  13605. }
  13606. if (this._requests.length === 0) {
  13607. this._queuedChunk = chunk;
  13608. } else {
  13609. var requestsCapability = this._requests.shift();
  13610. requestsCapability.resolve({
  13611. value: chunk,
  13612. done: false
  13613. });
  13614. this._requests.forEach(function (requestCapability) {
  13615. requestCapability.resolve({
  13616. value: undefined,
  13617. done: true
  13618. });
  13619. });
  13620. this._requests = [];
  13621. }
  13622. this._done = true;
  13623. this._stream._removeRangeReader(this);
  13624. },
  13625. get isStreamingSupported() {
  13626. return false;
  13627. },
  13628. read: function () {
  13629. var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2() {
  13630. var chunk, requestCapability;
  13631. return _regenerator2.default.wrap(function _callee2$(_context2) {
  13632. while (1) {
  13633. switch (_context2.prev = _context2.next) {
  13634. case 0:
  13635. if (!this._queuedChunk) {
  13636. _context2.next = 4;
  13637. break;
  13638. }
  13639. chunk = this._queuedChunk;
  13640. this._queuedChunk = null;
  13641. return _context2.abrupt('return', {
  13642. value: chunk,
  13643. done: false
  13644. });
  13645. case 4:
  13646. if (!this._done) {
  13647. _context2.next = 6;
  13648. break;
  13649. }
  13650. return _context2.abrupt('return', {
  13651. value: undefined,
  13652. done: true
  13653. });
  13654. case 6:
  13655. requestCapability = (0, _util.createPromiseCapability)();
  13656. this._requests.push(requestCapability);
  13657. return _context2.abrupt('return', requestCapability.promise);
  13658. case 9:
  13659. case 'end':
  13660. return _context2.stop();
  13661. }
  13662. }
  13663. }, _callee2, this);
  13664. }));
  13665. function read() {
  13666. return _ref2.apply(this, arguments);
  13667. }
  13668. return read;
  13669. }(),
  13670. cancel: function PDFDataTransportStreamRangeReader_cancel(reason) {
  13671. this._done = true;
  13672. this._requests.forEach(function (requestCapability) {
  13673. requestCapability.resolve({
  13674. value: undefined,
  13675. done: true
  13676. });
  13677. });
  13678. this._requests = [];
  13679. this._stream._removeRangeReader(this);
  13680. }
  13681. };
  13682. return PDFDataTransportStream;
  13683. }();
  13684. exports.PDFDataTransportStream = PDFDataTransportStream;
  13685. /***/ }),
  13686. /* 144 */
  13687. /***/ (function(module, exports, __w_pdfjs_require__) {
  13688. "use strict";
  13689. Object.defineProperty(exports, "__esModule", {
  13690. value: true
  13691. });
  13692. exports.WebGLContext = undefined;
  13693. 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; }; }();
  13694. var _util = __w_pdfjs_require__(1);
  13695. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13696. var WebGLContext = function () {
  13697. function WebGLContext(_ref) {
  13698. var _ref$enable = _ref.enable,
  13699. enable = _ref$enable === undefined ? false : _ref$enable;
  13700. _classCallCheck(this, WebGLContext);
  13701. this._enabled = enable === true;
  13702. }
  13703. _createClass(WebGLContext, [{
  13704. key: 'composeSMask',
  13705. value: function composeSMask(_ref2) {
  13706. var layer = _ref2.layer,
  13707. mask = _ref2.mask,
  13708. properties = _ref2.properties;
  13709. return WebGLUtils.composeSMask(layer, mask, properties);
  13710. }
  13711. }, {
  13712. key: 'drawFigures',
  13713. value: function drawFigures(_ref3) {
  13714. var width = _ref3.width,
  13715. height = _ref3.height,
  13716. backgroundColor = _ref3.backgroundColor,
  13717. figures = _ref3.figures,
  13718. context = _ref3.context;
  13719. return WebGLUtils.drawFigures(width, height, backgroundColor, figures, context);
  13720. }
  13721. }, {
  13722. key: 'clear',
  13723. value: function clear() {
  13724. WebGLUtils.cleanup();
  13725. }
  13726. }, {
  13727. key: 'isEnabled',
  13728. get: function get() {
  13729. var enabled = this._enabled;
  13730. if (enabled) {
  13731. enabled = WebGLUtils.tryInitGL();
  13732. }
  13733. return (0, _util.shadow)(this, 'isEnabled', enabled);
  13734. }
  13735. }]);
  13736. return WebGLContext;
  13737. }();
  13738. var WebGLUtils = function WebGLUtilsClosure() {
  13739. function loadShader(gl, code, shaderType) {
  13740. var shader = gl.createShader(shaderType);
  13741. gl.shaderSource(shader, code);
  13742. gl.compileShader(shader);
  13743. var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
  13744. if (!compiled) {
  13745. var errorMsg = gl.getShaderInfoLog(shader);
  13746. throw new Error('Error during shader compilation: ' + errorMsg);
  13747. }
  13748. return shader;
  13749. }
  13750. function createVertexShader(gl, code) {
  13751. return loadShader(gl, code, gl.VERTEX_SHADER);
  13752. }
  13753. function createFragmentShader(gl, code) {
  13754. return loadShader(gl, code, gl.FRAGMENT_SHADER);
  13755. }
  13756. function createProgram(gl, shaders) {
  13757. var program = gl.createProgram();
  13758. for (var i = 0, ii = shaders.length; i < ii; ++i) {
  13759. gl.attachShader(program, shaders[i]);
  13760. }
  13761. gl.linkProgram(program);
  13762. var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
  13763. if (!linked) {
  13764. var errorMsg = gl.getProgramInfoLog(program);
  13765. throw new Error('Error during program linking: ' + errorMsg);
  13766. }
  13767. return program;
  13768. }
  13769. function createTexture(gl, image, textureId) {
  13770. gl.activeTexture(textureId);
  13771. var texture = gl.createTexture();
  13772. gl.bindTexture(gl.TEXTURE_2D, texture);
  13773. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  13774. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  13775. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  13776. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  13777. gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
  13778. return texture;
  13779. }
  13780. var currentGL, currentCanvas;
  13781. function generateGL() {
  13782. if (currentGL) {
  13783. return;
  13784. }
  13785. currentCanvas = document.createElement('canvas');
  13786. currentGL = currentCanvas.getContext('webgl', { premultipliedalpha: false });
  13787. }
  13788. var smaskVertexShaderCode = '\
  13789. attribute vec2 a_position; \
  13790. attribute vec2 a_texCoord; \
  13791. \
  13792. uniform vec2 u_resolution; \
  13793. \
  13794. varying vec2 v_texCoord; \
  13795. \
  13796. void main() { \
  13797. vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; \
  13798. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  13799. \
  13800. v_texCoord = a_texCoord; \
  13801. } ';
  13802. var smaskFragmentShaderCode = '\
  13803. precision mediump float; \
  13804. \
  13805. uniform vec4 u_backdrop; \
  13806. uniform int u_subtype; \
  13807. uniform sampler2D u_image; \
  13808. uniform sampler2D u_mask; \
  13809. \
  13810. varying vec2 v_texCoord; \
  13811. \
  13812. void main() { \
  13813. vec4 imageColor = texture2D(u_image, v_texCoord); \
  13814. vec4 maskColor = texture2D(u_mask, v_texCoord); \
  13815. if (u_backdrop.a > 0.0) { \
  13816. maskColor.rgb = maskColor.rgb * maskColor.a + \
  13817. u_backdrop.rgb * (1.0 - maskColor.a); \
  13818. } \
  13819. float lum; \
  13820. if (u_subtype == 0) { \
  13821. lum = maskColor.a; \
  13822. } else { \
  13823. lum = maskColor.r * 0.3 + maskColor.g * 0.59 + \
  13824. maskColor.b * 0.11; \
  13825. } \
  13826. imageColor.a *= lum; \
  13827. imageColor.rgb *= imageColor.a; \
  13828. gl_FragColor = imageColor; \
  13829. } ';
  13830. var smaskCache = null;
  13831. function initSmaskGL() {
  13832. var canvas, gl;
  13833. generateGL();
  13834. canvas = currentCanvas;
  13835. currentCanvas = null;
  13836. gl = currentGL;
  13837. currentGL = null;
  13838. var vertexShader = createVertexShader(gl, smaskVertexShaderCode);
  13839. var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode);
  13840. var program = createProgram(gl, [vertexShader, fragmentShader]);
  13841. gl.useProgram(program);
  13842. var cache = {};
  13843. cache.gl = gl;
  13844. cache.canvas = canvas;
  13845. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  13846. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  13847. cache.backdropLocation = gl.getUniformLocation(program, 'u_backdrop');
  13848. cache.subtypeLocation = gl.getUniformLocation(program, 'u_subtype');
  13849. var texCoordLocation = gl.getAttribLocation(program, 'a_texCoord');
  13850. var texLayerLocation = gl.getUniformLocation(program, 'u_image');
  13851. var texMaskLocation = gl.getUniformLocation(program, 'u_mask');
  13852. var texCoordBuffer = gl.createBuffer();
  13853. gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);
  13854. 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);
  13855. gl.enableVertexAttribArray(texCoordLocation);
  13856. gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0);
  13857. gl.uniform1i(texLayerLocation, 0);
  13858. gl.uniform1i(texMaskLocation, 1);
  13859. smaskCache = cache;
  13860. }
  13861. function composeSMask(layer, mask, properties) {
  13862. var width = layer.width,
  13863. height = layer.height;
  13864. if (!smaskCache) {
  13865. initSmaskGL();
  13866. }
  13867. var cache = smaskCache,
  13868. canvas = cache.canvas,
  13869. gl = cache.gl;
  13870. canvas.width = width;
  13871. canvas.height = height;
  13872. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  13873. gl.uniform2f(cache.resolutionLocation, width, height);
  13874. if (properties.backdrop) {
  13875. gl.uniform4f(cache.resolutionLocation, properties.backdrop[0], properties.backdrop[1], properties.backdrop[2], 1);
  13876. } else {
  13877. gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0);
  13878. }
  13879. gl.uniform1i(cache.subtypeLocation, properties.subtype === 'Luminosity' ? 1 : 0);
  13880. var texture = createTexture(gl, layer, gl.TEXTURE0);
  13881. var maskTexture = createTexture(gl, mask, gl.TEXTURE1);
  13882. var buffer = gl.createBuffer();
  13883. gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
  13884. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([0, 0, width, 0, 0, height, 0, height, width, 0, width, height]), gl.STATIC_DRAW);
  13885. gl.enableVertexAttribArray(cache.positionLocation);
  13886. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  13887. gl.clearColor(0, 0, 0, 0);
  13888. gl.enable(gl.BLEND);
  13889. gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
  13890. gl.clear(gl.COLOR_BUFFER_BIT);
  13891. gl.drawArrays(gl.TRIANGLES, 0, 6);
  13892. gl.flush();
  13893. gl.deleteTexture(texture);
  13894. gl.deleteTexture(maskTexture);
  13895. gl.deleteBuffer(buffer);
  13896. return canvas;
  13897. }
  13898. var figuresVertexShaderCode = '\
  13899. attribute vec2 a_position; \
  13900. attribute vec3 a_color; \
  13901. \
  13902. uniform vec2 u_resolution; \
  13903. uniform vec2 u_scale; \
  13904. uniform vec2 u_offset; \
  13905. \
  13906. varying vec4 v_color; \
  13907. \
  13908. void main() { \
  13909. vec2 position = (a_position + u_offset) * u_scale; \
  13910. vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; \
  13911. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  13912. \
  13913. v_color = vec4(a_color / 255.0, 1.0); \
  13914. } ';
  13915. var figuresFragmentShaderCode = '\
  13916. precision mediump float; \
  13917. \
  13918. varying vec4 v_color; \
  13919. \
  13920. void main() { \
  13921. gl_FragColor = v_color; \
  13922. } ';
  13923. var figuresCache = null;
  13924. function initFiguresGL() {
  13925. var canvas, gl;
  13926. generateGL();
  13927. canvas = currentCanvas;
  13928. currentCanvas = null;
  13929. gl = currentGL;
  13930. currentGL = null;
  13931. var vertexShader = createVertexShader(gl, figuresVertexShaderCode);
  13932. var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode);
  13933. var program = createProgram(gl, [vertexShader, fragmentShader]);
  13934. gl.useProgram(program);
  13935. var cache = {};
  13936. cache.gl = gl;
  13937. cache.canvas = canvas;
  13938. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  13939. cache.scaleLocation = gl.getUniformLocation(program, 'u_scale');
  13940. cache.offsetLocation = gl.getUniformLocation(program, 'u_offset');
  13941. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  13942. cache.colorLocation = gl.getAttribLocation(program, 'a_color');
  13943. figuresCache = cache;
  13944. }
  13945. function drawFigures(width, height, backgroundColor, figures, context) {
  13946. if (!figuresCache) {
  13947. initFiguresGL();
  13948. }
  13949. var cache = figuresCache,
  13950. canvas = cache.canvas,
  13951. gl = cache.gl;
  13952. canvas.width = width;
  13953. canvas.height = height;
  13954. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  13955. gl.uniform2f(cache.resolutionLocation, width, height);
  13956. var count = 0;
  13957. var i, ii, rows;
  13958. for (i = 0, ii = figures.length; i < ii; i++) {
  13959. switch (figures[i].type) {
  13960. case 'lattice':
  13961. rows = figures[i].coords.length / figures[i].verticesPerRow | 0;
  13962. count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6;
  13963. break;
  13964. case 'triangles':
  13965. count += figures[i].coords.length;
  13966. break;
  13967. }
  13968. }
  13969. var coords = new Float32Array(count * 2);
  13970. var colors = new Uint8Array(count * 3);
  13971. var coordsMap = context.coords,
  13972. colorsMap = context.colors;
  13973. var pIndex = 0,
  13974. cIndex = 0;
  13975. for (i = 0, ii = figures.length; i < ii; i++) {
  13976. var figure = figures[i],
  13977. ps = figure.coords,
  13978. cs = figure.colors;
  13979. switch (figure.type) {
  13980. case 'lattice':
  13981. var cols = figure.verticesPerRow;
  13982. rows = ps.length / cols | 0;
  13983. for (var row = 1; row < rows; row++) {
  13984. var offset = row * cols + 1;
  13985. for (var col = 1; col < cols; col++, offset++) {
  13986. coords[pIndex] = coordsMap[ps[offset - cols - 1]];
  13987. coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1];
  13988. coords[pIndex + 2] = coordsMap[ps[offset - cols]];
  13989. coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1];
  13990. coords[pIndex + 4] = coordsMap[ps[offset - 1]];
  13991. coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1];
  13992. colors[cIndex] = colorsMap[cs[offset - cols - 1]];
  13993. colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1];
  13994. colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2];
  13995. colors[cIndex + 3] = colorsMap[cs[offset - cols]];
  13996. colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1];
  13997. colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2];
  13998. colors[cIndex + 6] = colorsMap[cs[offset - 1]];
  13999. colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1];
  14000. colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2];
  14001. coords[pIndex + 6] = coords[pIndex + 2];
  14002. coords[pIndex + 7] = coords[pIndex + 3];
  14003. coords[pIndex + 8] = coords[pIndex + 4];
  14004. coords[pIndex + 9] = coords[pIndex + 5];
  14005. coords[pIndex + 10] = coordsMap[ps[offset]];
  14006. coords[pIndex + 11] = coordsMap[ps[offset] + 1];
  14007. colors[cIndex + 9] = colors[cIndex + 3];
  14008. colors[cIndex + 10] = colors[cIndex + 4];
  14009. colors[cIndex + 11] = colors[cIndex + 5];
  14010. colors[cIndex + 12] = colors[cIndex + 6];
  14011. colors[cIndex + 13] = colors[cIndex + 7];
  14012. colors[cIndex + 14] = colors[cIndex + 8];
  14013. colors[cIndex + 15] = colorsMap[cs[offset]];
  14014. colors[cIndex + 16] = colorsMap[cs[offset] + 1];
  14015. colors[cIndex + 17] = colorsMap[cs[offset] + 2];
  14016. pIndex += 12;
  14017. cIndex += 18;
  14018. }
  14019. }
  14020. break;
  14021. case 'triangles':
  14022. for (var j = 0, jj = ps.length; j < jj; j++) {
  14023. coords[pIndex] = coordsMap[ps[j]];
  14024. coords[pIndex + 1] = coordsMap[ps[j] + 1];
  14025. colors[cIndex] = colorsMap[cs[j]];
  14026. colors[cIndex + 1] = colorsMap[cs[j] + 1];
  14027. colors[cIndex + 2] = colorsMap[cs[j] + 2];
  14028. pIndex += 2;
  14029. cIndex += 3;
  14030. }
  14031. break;
  14032. }
  14033. }
  14034. if (backgroundColor) {
  14035. gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255, backgroundColor[2] / 255, 1.0);
  14036. } else {
  14037. gl.clearColor(0, 0, 0, 0);
  14038. }
  14039. gl.clear(gl.COLOR_BUFFER_BIT);
  14040. var coordsBuffer = gl.createBuffer();
  14041. gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer);
  14042. gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW);
  14043. gl.enableVertexAttribArray(cache.positionLocation);
  14044. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  14045. var colorsBuffer = gl.createBuffer();
  14046. gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer);
  14047. gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW);
  14048. gl.enableVertexAttribArray(cache.colorLocation);
  14049. gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false, 0, 0);
  14050. gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY);
  14051. gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY);
  14052. gl.drawArrays(gl.TRIANGLES, 0, count);
  14053. gl.flush();
  14054. gl.deleteBuffer(coordsBuffer);
  14055. gl.deleteBuffer(colorsBuffer);
  14056. return canvas;
  14057. }
  14058. return {
  14059. tryInitGL: function tryInitGL() {
  14060. try {
  14061. generateGL();
  14062. return !!currentGL;
  14063. } catch (ex) {}
  14064. return false;
  14065. },
  14066. composeSMask: composeSMask,
  14067. drawFigures: drawFigures,
  14068. cleanup: function cleanup() {
  14069. if (smaskCache && smaskCache.canvas) {
  14070. smaskCache.canvas.width = 0;
  14071. smaskCache.canvas.height = 0;
  14072. }
  14073. if (figuresCache && figuresCache.canvas) {
  14074. figuresCache.canvas.width = 0;
  14075. figuresCache.canvas.height = 0;
  14076. }
  14077. smaskCache = null;
  14078. figuresCache = null;
  14079. }
  14080. };
  14081. }();
  14082. exports.WebGLContext = WebGLContext;
  14083. /***/ }),
  14084. /* 145 */
  14085. /***/ (function(module, exports, __w_pdfjs_require__) {
  14086. "use strict";
  14087. Object.defineProperty(exports, "__esModule", {
  14088. value: true
  14089. });
  14090. exports.renderTextLayer = undefined;
  14091. var _util = __w_pdfjs_require__(1);
  14092. var _global_scope = __w_pdfjs_require__(3);
  14093. var _global_scope2 = _interopRequireDefault(_global_scope);
  14094. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  14095. var renderTextLayer = function renderTextLayerClosure() {
  14096. var MAX_TEXT_DIVS_TO_RENDER = 100000;
  14097. var NonWhitespaceRegexp = /\S/;
  14098. function isAllWhitespace(str) {
  14099. return !NonWhitespaceRegexp.test(str);
  14100. }
  14101. var styleBuf = ['left: ', 0, 'px; top: ', 0, 'px; font-size: ', 0, 'px; font-family: ', '', ';'];
  14102. function appendText(task, geom, styles) {
  14103. var textDiv = document.createElement('div');
  14104. var textDivProperties = {
  14105. style: null,
  14106. angle: 0,
  14107. canvasWidth: 0,
  14108. isWhitespace: false,
  14109. originalTransform: null,
  14110. paddingBottom: 0,
  14111. paddingLeft: 0,
  14112. paddingRight: 0,
  14113. paddingTop: 0,
  14114. scale: 1
  14115. };
  14116. task._textDivs.push(textDiv);
  14117. if (isAllWhitespace(geom.str)) {
  14118. textDivProperties.isWhitespace = true;
  14119. task._textDivProperties.set(textDiv, textDivProperties);
  14120. return;
  14121. }
  14122. var tx = _util.Util.transform(task._viewport.transform, geom.transform);
  14123. var angle = Math.atan2(tx[1], tx[0]);
  14124. var style = styles[geom.fontName];
  14125. if (style.vertical) {
  14126. angle += Math.PI / 2;
  14127. }
  14128. var fontHeight = Math.sqrt(tx[2] * tx[2] + tx[3] * tx[3]);
  14129. var fontAscent = fontHeight;
  14130. if (style.ascent) {
  14131. fontAscent = style.ascent * fontAscent;
  14132. } else if (style.descent) {
  14133. fontAscent = (1 + style.descent) * fontAscent;
  14134. }
  14135. var left;
  14136. var top;
  14137. if (angle === 0) {
  14138. left = tx[4];
  14139. top = tx[5] - fontAscent;
  14140. } else {
  14141. left = tx[4] + fontAscent * Math.sin(angle);
  14142. top = tx[5] - fontAscent * Math.cos(angle);
  14143. }
  14144. styleBuf[1] = left;
  14145. styleBuf[3] = top;
  14146. styleBuf[5] = fontHeight;
  14147. styleBuf[7] = style.fontFamily;
  14148. textDivProperties.style = styleBuf.join('');
  14149. textDiv.setAttribute('style', textDivProperties.style);
  14150. textDiv.textContent = geom.str;
  14151. if (task._fontInspectorEnabled) {
  14152. textDiv.dataset.fontName = geom.fontName;
  14153. }
  14154. if (angle !== 0) {
  14155. textDivProperties.angle = angle * (180 / Math.PI);
  14156. }
  14157. if (geom.str.length > 1) {
  14158. if (style.vertical) {
  14159. textDivProperties.canvasWidth = geom.height * task._viewport.scale;
  14160. } else {
  14161. textDivProperties.canvasWidth = geom.width * task._viewport.scale;
  14162. }
  14163. }
  14164. task._textDivProperties.set(textDiv, textDivProperties);
  14165. if (task._textContentStream) {
  14166. task._layoutText(textDiv);
  14167. }
  14168. if (task._enhanceTextSelection) {
  14169. var angleCos = 1,
  14170. angleSin = 0;
  14171. if (angle !== 0) {
  14172. angleCos = Math.cos(angle);
  14173. angleSin = Math.sin(angle);
  14174. }
  14175. var divWidth = (style.vertical ? geom.height : geom.width) * task._viewport.scale;
  14176. var divHeight = fontHeight;
  14177. var m, b;
  14178. if (angle !== 0) {
  14179. m = [angleCos, angleSin, -angleSin, angleCos, left, top];
  14180. b = _util.Util.getAxialAlignedBoundingBox([0, 0, divWidth, divHeight], m);
  14181. } else {
  14182. b = [left, top, left + divWidth, top + divHeight];
  14183. }
  14184. task._bounds.push({
  14185. left: b[0],
  14186. top: b[1],
  14187. right: b[2],
  14188. bottom: b[3],
  14189. div: textDiv,
  14190. size: [divWidth, divHeight],
  14191. m: m
  14192. });
  14193. }
  14194. }
  14195. function render(task) {
  14196. if (task._canceled) {
  14197. return;
  14198. }
  14199. var textDivs = task._textDivs;
  14200. var capability = task._capability;
  14201. var textDivsLength = textDivs.length;
  14202. if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) {
  14203. task._renderingDone = true;
  14204. capability.resolve();
  14205. return;
  14206. }
  14207. if (!task._textContentStream) {
  14208. for (var i = 0; i < textDivsLength; i++) {
  14209. task._layoutText(textDivs[i]);
  14210. }
  14211. }
  14212. task._renderingDone = true;
  14213. capability.resolve();
  14214. }
  14215. function expand(task) {
  14216. var bounds = task._bounds;
  14217. var viewport = task._viewport;
  14218. var expanded = expandBounds(viewport.width, viewport.height, bounds);
  14219. for (var i = 0; i < expanded.length; i++) {
  14220. var div = bounds[i].div;
  14221. var divProperties = task._textDivProperties.get(div);
  14222. if (divProperties.angle === 0) {
  14223. divProperties.paddingLeft = bounds[i].left - expanded[i].left;
  14224. divProperties.paddingTop = bounds[i].top - expanded[i].top;
  14225. divProperties.paddingRight = expanded[i].right - bounds[i].right;
  14226. divProperties.paddingBottom = expanded[i].bottom - bounds[i].bottom;
  14227. task._textDivProperties.set(div, divProperties);
  14228. continue;
  14229. }
  14230. var e = expanded[i],
  14231. b = bounds[i];
  14232. var m = b.m,
  14233. c = m[0],
  14234. s = m[1];
  14235. var points = [[0, 0], [0, b.size[1]], [b.size[0], 0], b.size];
  14236. var ts = new Float64Array(64);
  14237. points.forEach(function (p, i) {
  14238. var t = _util.Util.applyTransform(p, m);
  14239. ts[i + 0] = c && (e.left - t[0]) / c;
  14240. ts[i + 4] = s && (e.top - t[1]) / s;
  14241. ts[i + 8] = c && (e.right - t[0]) / c;
  14242. ts[i + 12] = s && (e.bottom - t[1]) / s;
  14243. ts[i + 16] = s && (e.left - t[0]) / -s;
  14244. ts[i + 20] = c && (e.top - t[1]) / c;
  14245. ts[i + 24] = s && (e.right - t[0]) / -s;
  14246. ts[i + 28] = c && (e.bottom - t[1]) / c;
  14247. ts[i + 32] = c && (e.left - t[0]) / -c;
  14248. ts[i + 36] = s && (e.top - t[1]) / -s;
  14249. ts[i + 40] = c && (e.right - t[0]) / -c;
  14250. ts[i + 44] = s && (e.bottom - t[1]) / -s;
  14251. ts[i + 48] = s && (e.left - t[0]) / s;
  14252. ts[i + 52] = c && (e.top - t[1]) / -c;
  14253. ts[i + 56] = s && (e.right - t[0]) / s;
  14254. ts[i + 60] = c && (e.bottom - t[1]) / -c;
  14255. });
  14256. var findPositiveMin = function findPositiveMin(ts, offset, count) {
  14257. var result = 0;
  14258. for (var i = 0; i < count; i++) {
  14259. var t = ts[offset++];
  14260. if (t > 0) {
  14261. result = result ? Math.min(t, result) : t;
  14262. }
  14263. }
  14264. return result;
  14265. };
  14266. var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s));
  14267. divProperties.paddingLeft = findPositiveMin(ts, 32, 16) / boxScale;
  14268. divProperties.paddingTop = findPositiveMin(ts, 48, 16) / boxScale;
  14269. divProperties.paddingRight = findPositiveMin(ts, 0, 16) / boxScale;
  14270. divProperties.paddingBottom = findPositiveMin(ts, 16, 16) / boxScale;
  14271. task._textDivProperties.set(div, divProperties);
  14272. }
  14273. }
  14274. function expandBounds(width, height, boxes) {
  14275. var bounds = boxes.map(function (box, i) {
  14276. return {
  14277. x1: box.left,
  14278. y1: box.top,
  14279. x2: box.right,
  14280. y2: box.bottom,
  14281. index: i,
  14282. x1New: undefined,
  14283. x2New: undefined
  14284. };
  14285. });
  14286. expandBoundsLTR(width, bounds);
  14287. var expanded = new Array(boxes.length);
  14288. bounds.forEach(function (b) {
  14289. var i = b.index;
  14290. expanded[i] = {
  14291. left: b.x1New,
  14292. top: 0,
  14293. right: b.x2New,
  14294. bottom: 0
  14295. };
  14296. });
  14297. boxes.map(function (box, i) {
  14298. var e = expanded[i],
  14299. b = bounds[i];
  14300. b.x1 = box.top;
  14301. b.y1 = width - e.right;
  14302. b.x2 = box.bottom;
  14303. b.y2 = width - e.left;
  14304. b.index = i;
  14305. b.x1New = undefined;
  14306. b.x2New = undefined;
  14307. });
  14308. expandBoundsLTR(height, bounds);
  14309. bounds.forEach(function (b) {
  14310. var i = b.index;
  14311. expanded[i].top = b.x1New;
  14312. expanded[i].bottom = b.x2New;
  14313. });
  14314. return expanded;
  14315. }
  14316. function expandBoundsLTR(width, bounds) {
  14317. bounds.sort(function (a, b) {
  14318. return a.x1 - b.x1 || a.index - b.index;
  14319. });
  14320. var fakeBoundary = {
  14321. x1: -Infinity,
  14322. y1: -Infinity,
  14323. x2: 0,
  14324. y2: Infinity,
  14325. index: -1,
  14326. x1New: 0,
  14327. x2New: 0
  14328. };
  14329. var horizon = [{
  14330. start: -Infinity,
  14331. end: Infinity,
  14332. boundary: fakeBoundary
  14333. }];
  14334. bounds.forEach(function (boundary) {
  14335. var i = 0;
  14336. while (i < horizon.length && horizon[i].end <= boundary.y1) {
  14337. i++;
  14338. }
  14339. var j = horizon.length - 1;
  14340. while (j >= 0 && horizon[j].start >= boundary.y2) {
  14341. j--;
  14342. }
  14343. var horizonPart, affectedBoundary;
  14344. var q,
  14345. k,
  14346. maxXNew = -Infinity;
  14347. for (q = i; q <= j; q++) {
  14348. horizonPart = horizon[q];
  14349. affectedBoundary = horizonPart.boundary;
  14350. var xNew;
  14351. if (affectedBoundary.x2 > boundary.x1) {
  14352. xNew = affectedBoundary.index > boundary.index ? affectedBoundary.x1New : boundary.x1;
  14353. } else if (affectedBoundary.x2New === undefined) {
  14354. xNew = (affectedBoundary.x2 + boundary.x1) / 2;
  14355. } else {
  14356. xNew = affectedBoundary.x2New;
  14357. }
  14358. if (xNew > maxXNew) {
  14359. maxXNew = xNew;
  14360. }
  14361. }
  14362. boundary.x1New = maxXNew;
  14363. for (q = i; q <= j; q++) {
  14364. horizonPart = horizon[q];
  14365. affectedBoundary = horizonPart.boundary;
  14366. if (affectedBoundary.x2New === undefined) {
  14367. if (affectedBoundary.x2 > boundary.x1) {
  14368. if (affectedBoundary.index > boundary.index) {
  14369. affectedBoundary.x2New = affectedBoundary.x2;
  14370. }
  14371. } else {
  14372. affectedBoundary.x2New = maxXNew;
  14373. }
  14374. } else if (affectedBoundary.x2New > maxXNew) {
  14375. affectedBoundary.x2New = Math.max(maxXNew, affectedBoundary.x2);
  14376. }
  14377. }
  14378. var changedHorizon = [],
  14379. lastBoundary = null;
  14380. for (q = i; q <= j; q++) {
  14381. horizonPart = horizon[q];
  14382. affectedBoundary = horizonPart.boundary;
  14383. var useBoundary = affectedBoundary.x2 > boundary.x2 ? affectedBoundary : boundary;
  14384. if (lastBoundary === useBoundary) {
  14385. changedHorizon[changedHorizon.length - 1].end = horizonPart.end;
  14386. } else {
  14387. changedHorizon.push({
  14388. start: horizonPart.start,
  14389. end: horizonPart.end,
  14390. boundary: useBoundary
  14391. });
  14392. lastBoundary = useBoundary;
  14393. }
  14394. }
  14395. if (horizon[i].start < boundary.y1) {
  14396. changedHorizon[0].start = boundary.y1;
  14397. changedHorizon.unshift({
  14398. start: horizon[i].start,
  14399. end: boundary.y1,
  14400. boundary: horizon[i].boundary
  14401. });
  14402. }
  14403. if (boundary.y2 < horizon[j].end) {
  14404. changedHorizon[changedHorizon.length - 1].end = boundary.y2;
  14405. changedHorizon.push({
  14406. start: boundary.y2,
  14407. end: horizon[j].end,
  14408. boundary: horizon[j].boundary
  14409. });
  14410. }
  14411. for (q = i; q <= j; q++) {
  14412. horizonPart = horizon[q];
  14413. affectedBoundary = horizonPart.boundary;
  14414. if (affectedBoundary.x2New !== undefined) {
  14415. continue;
  14416. }
  14417. var used = false;
  14418. for (k = i - 1; !used && k >= 0 && horizon[k].start >= affectedBoundary.y1; k--) {
  14419. used = horizon[k].boundary === affectedBoundary;
  14420. }
  14421. for (k = j + 1; !used && k < horizon.length && horizon[k].end <= affectedBoundary.y2; k++) {
  14422. used = horizon[k].boundary === affectedBoundary;
  14423. }
  14424. for (k = 0; !used && k < changedHorizon.length; k++) {
  14425. used = changedHorizon[k].boundary === affectedBoundary;
  14426. }
  14427. if (!used) {
  14428. affectedBoundary.x2New = maxXNew;
  14429. }
  14430. }
  14431. Array.prototype.splice.apply(horizon, [i, j - i + 1].concat(changedHorizon));
  14432. });
  14433. horizon.forEach(function (horizonPart) {
  14434. var affectedBoundary = horizonPart.boundary;
  14435. if (affectedBoundary.x2New === undefined) {
  14436. affectedBoundary.x2New = Math.max(width, affectedBoundary.x2);
  14437. }
  14438. });
  14439. }
  14440. function TextLayerRenderTask(_ref) {
  14441. var textContent = _ref.textContent,
  14442. textContentStream = _ref.textContentStream,
  14443. container = _ref.container,
  14444. viewport = _ref.viewport,
  14445. textDivs = _ref.textDivs,
  14446. textContentItemsStr = _ref.textContentItemsStr,
  14447. enhanceTextSelection = _ref.enhanceTextSelection;
  14448. this._textContent = textContent;
  14449. this._textContentStream = textContentStream;
  14450. this._container = container;
  14451. this._viewport = viewport;
  14452. this._textDivs = textDivs || [];
  14453. this._textContentItemsStr = textContentItemsStr || [];
  14454. this._enhanceTextSelection = !!enhanceTextSelection;
  14455. this._fontInspectorEnabled = !!(_global_scope2.default.FontInspector && _global_scope2.default.FontInspector.enabled);
  14456. this._reader = null;
  14457. this._layoutTextLastFontSize = null;
  14458. this._layoutTextLastFontFamily = null;
  14459. this._layoutTextCtx = null;
  14460. this._textDivProperties = new WeakMap();
  14461. this._renderingDone = false;
  14462. this._canceled = false;
  14463. this._capability = (0, _util.createPromiseCapability)();
  14464. this._renderTimer = null;
  14465. this._bounds = [];
  14466. }
  14467. TextLayerRenderTask.prototype = {
  14468. get promise() {
  14469. return this._capability.promise;
  14470. },
  14471. cancel: function TextLayer_cancel() {
  14472. if (this._reader) {
  14473. this._reader.cancel(new _util.AbortException('text layer task cancelled'));
  14474. this._reader = null;
  14475. }
  14476. this._canceled = true;
  14477. if (this._renderTimer !== null) {
  14478. clearTimeout(this._renderTimer);
  14479. this._renderTimer = null;
  14480. }
  14481. this._capability.reject('canceled');
  14482. },
  14483. _processItems: function _processItems(items, styleCache) {
  14484. for (var i = 0, len = items.length; i < len; i++) {
  14485. this._textContentItemsStr.push(items[i].str);
  14486. appendText(this, items[i], styleCache);
  14487. }
  14488. },
  14489. _layoutText: function _layoutText(textDiv) {
  14490. var textLayerFrag = this._container;
  14491. var textDivProperties = this._textDivProperties.get(textDiv);
  14492. if (textDivProperties.isWhitespace) {
  14493. return;
  14494. }
  14495. var fontSize = textDiv.style.fontSize;
  14496. var fontFamily = textDiv.style.fontFamily;
  14497. if (fontSize !== this._layoutTextLastFontSize || fontFamily !== this._layoutTextLastFontFamily) {
  14498. this._layoutTextCtx.font = fontSize + ' ' + fontFamily;
  14499. this._layoutTextLastFontSize = fontSize;
  14500. this._layoutTextLastFontFamily = fontFamily;
  14501. }
  14502. var width = this._layoutTextCtx.measureText(textDiv.textContent).width;
  14503. var transform = '';
  14504. if (textDivProperties.canvasWidth !== 0 && width > 0) {
  14505. textDivProperties.scale = textDivProperties.canvasWidth / width;
  14506. transform = 'scaleX(' + textDivProperties.scale + ')';
  14507. }
  14508. if (textDivProperties.angle !== 0) {
  14509. transform = 'rotate(' + textDivProperties.angle + 'deg) ' + transform;
  14510. }
  14511. if (transform !== '') {
  14512. textDivProperties.originalTransform = transform;
  14513. textDiv.style.transform = transform;
  14514. }
  14515. this._textDivProperties.set(textDiv, textDivProperties);
  14516. textLayerFrag.appendChild(textDiv);
  14517. },
  14518. _render: function TextLayer_render(timeout) {
  14519. var _this = this;
  14520. var capability = (0, _util.createPromiseCapability)();
  14521. var styleCache = Object.create(null);
  14522. var canvas = document.createElement('canvas');
  14523. canvas.mozOpaque = true;
  14524. this._layoutTextCtx = canvas.getContext('2d', { alpha: false });
  14525. if (this._textContent) {
  14526. var textItems = this._textContent.items;
  14527. var textStyles = this._textContent.styles;
  14528. this._processItems(textItems, textStyles);
  14529. capability.resolve();
  14530. } else if (this._textContentStream) {
  14531. var pump = function pump() {
  14532. _this._reader.read().then(function (_ref2) {
  14533. var value = _ref2.value,
  14534. done = _ref2.done;
  14535. if (done) {
  14536. capability.resolve();
  14537. return;
  14538. }
  14539. Object.assign(styleCache, value.styles);
  14540. _this._processItems(value.items, styleCache);
  14541. pump();
  14542. }, capability.reject);
  14543. };
  14544. this._reader = this._textContentStream.getReader();
  14545. pump();
  14546. } else {
  14547. throw new Error('Neither "textContent" nor "textContentStream"' + ' parameters specified.');
  14548. }
  14549. capability.promise.then(function () {
  14550. styleCache = null;
  14551. if (!timeout) {
  14552. render(_this);
  14553. } else {
  14554. _this._renderTimer = setTimeout(function () {
  14555. render(_this);
  14556. _this._renderTimer = null;
  14557. }, timeout);
  14558. }
  14559. }, this._capability.reject);
  14560. },
  14561. expandTextDivs: function TextLayer_expandTextDivs(expandDivs) {
  14562. if (!this._enhanceTextSelection || !this._renderingDone) {
  14563. return;
  14564. }
  14565. if (this._bounds !== null) {
  14566. expand(this);
  14567. this._bounds = null;
  14568. }
  14569. for (var i = 0, ii = this._textDivs.length; i < ii; i++) {
  14570. var div = this._textDivs[i];
  14571. var divProperties = this._textDivProperties.get(div);
  14572. if (divProperties.isWhitespace) {
  14573. continue;
  14574. }
  14575. if (expandDivs) {
  14576. var transform = '',
  14577. padding = '';
  14578. if (divProperties.scale !== 1) {
  14579. transform = 'scaleX(' + divProperties.scale + ')';
  14580. }
  14581. if (divProperties.angle !== 0) {
  14582. transform = 'rotate(' + divProperties.angle + 'deg) ' + transform;
  14583. }
  14584. if (divProperties.paddingLeft !== 0) {
  14585. padding += ' padding-left: ' + divProperties.paddingLeft / divProperties.scale + 'px;';
  14586. transform += ' translateX(' + -divProperties.paddingLeft / divProperties.scale + 'px)';
  14587. }
  14588. if (divProperties.paddingTop !== 0) {
  14589. padding += ' padding-top: ' + divProperties.paddingTop + 'px;';
  14590. transform += ' translateY(' + -divProperties.paddingTop + 'px)';
  14591. }
  14592. if (divProperties.paddingRight !== 0) {
  14593. padding += ' padding-right: ' + divProperties.paddingRight / divProperties.scale + 'px;';
  14594. }
  14595. if (divProperties.paddingBottom !== 0) {
  14596. padding += ' padding-bottom: ' + divProperties.paddingBottom + 'px;';
  14597. }
  14598. if (padding !== '') {
  14599. div.setAttribute('style', divProperties.style + padding);
  14600. }
  14601. if (transform !== '') {
  14602. div.style.transform = transform;
  14603. }
  14604. } else {
  14605. div.style.padding = 0;
  14606. div.style.transform = divProperties.originalTransform || '';
  14607. }
  14608. }
  14609. }
  14610. };
  14611. function renderTextLayer(renderParameters) {
  14612. var task = new TextLayerRenderTask({
  14613. textContent: renderParameters.textContent,
  14614. textContentStream: renderParameters.textContentStream,
  14615. container: renderParameters.container,
  14616. viewport: renderParameters.viewport,
  14617. textDivs: renderParameters.textDivs,
  14618. textContentItemsStr: renderParameters.textContentItemsStr,
  14619. enhanceTextSelection: renderParameters.enhanceTextSelection
  14620. });
  14621. task._render(renderParameters.timeout);
  14622. return task;
  14623. }
  14624. return renderTextLayer;
  14625. }();
  14626. exports.renderTextLayer = renderTextLayer;
  14627. /***/ }),
  14628. /* 146 */
  14629. /***/ (function(module, exports, __w_pdfjs_require__) {
  14630. "use strict";
  14631. Object.defineProperty(exports, "__esModule", {
  14632. value: true
  14633. });
  14634. exports.AnnotationLayer = undefined;
  14635. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  14636. 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; }; }();
  14637. var _dom_utils = __w_pdfjs_require__(130);
  14638. var _util = __w_pdfjs_require__(1);
  14639. 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; }
  14640. 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; }
  14641. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14642. var AnnotationElementFactory = function () {
  14643. function AnnotationElementFactory() {
  14644. _classCallCheck(this, AnnotationElementFactory);
  14645. }
  14646. _createClass(AnnotationElementFactory, null, [{
  14647. key: 'create',
  14648. value: function create(parameters) {
  14649. var subtype = parameters.data.annotationType;
  14650. switch (subtype) {
  14651. case _util.AnnotationType.LINK:
  14652. return new LinkAnnotationElement(parameters);
  14653. case _util.AnnotationType.TEXT:
  14654. return new TextAnnotationElement(parameters);
  14655. case _util.AnnotationType.WIDGET:
  14656. var fieldType = parameters.data.fieldType;
  14657. switch (fieldType) {
  14658. case 'Tx':
  14659. return new TextWidgetAnnotationElement(parameters);
  14660. case 'Btn':
  14661. if (parameters.data.radioButton) {
  14662. return new RadioButtonWidgetAnnotationElement(parameters);
  14663. } else if (parameters.data.checkBox) {
  14664. return new CheckboxWidgetAnnotationElement(parameters);
  14665. }
  14666. return new PushButtonWidgetAnnotationElement(parameters);
  14667. case 'Ch':
  14668. return new ChoiceWidgetAnnotationElement(parameters);
  14669. }
  14670. return new WidgetAnnotationElement(parameters);
  14671. case _util.AnnotationType.POPUP:
  14672. return new PopupAnnotationElement(parameters);
  14673. case _util.AnnotationType.LINE:
  14674. return new LineAnnotationElement(parameters);
  14675. case _util.AnnotationType.SQUARE:
  14676. return new SquareAnnotationElement(parameters);
  14677. case _util.AnnotationType.CIRCLE:
  14678. return new CircleAnnotationElement(parameters);
  14679. case _util.AnnotationType.POLYLINE:
  14680. return new PolylineAnnotationElement(parameters);
  14681. case _util.AnnotationType.INK:
  14682. return new InkAnnotationElement(parameters);
  14683. case _util.AnnotationType.POLYGON:
  14684. return new PolygonAnnotationElement(parameters);
  14685. case _util.AnnotationType.HIGHLIGHT:
  14686. return new HighlightAnnotationElement(parameters);
  14687. case _util.AnnotationType.UNDERLINE:
  14688. return new UnderlineAnnotationElement(parameters);
  14689. case _util.AnnotationType.SQUIGGLY:
  14690. return new SquigglyAnnotationElement(parameters);
  14691. case _util.AnnotationType.STRIKEOUT:
  14692. return new StrikeOutAnnotationElement(parameters);
  14693. case _util.AnnotationType.STAMP:
  14694. return new StampAnnotationElement(parameters);
  14695. case _util.AnnotationType.FILEATTACHMENT:
  14696. return new FileAttachmentAnnotationElement(parameters);
  14697. default:
  14698. return new AnnotationElement(parameters);
  14699. }
  14700. }
  14701. }]);
  14702. return AnnotationElementFactory;
  14703. }();
  14704. var AnnotationElement = function () {
  14705. function AnnotationElement(parameters) {
  14706. var isRenderable = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  14707. var ignoreBorder = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  14708. _classCallCheck(this, AnnotationElement);
  14709. this.isRenderable = isRenderable;
  14710. this.data = parameters.data;
  14711. this.layer = parameters.layer;
  14712. this.page = parameters.page;
  14713. this.viewport = parameters.viewport;
  14714. this.linkService = parameters.linkService;
  14715. this.downloadManager = parameters.downloadManager;
  14716. this.imageResourcesPath = parameters.imageResourcesPath;
  14717. this.renderInteractiveForms = parameters.renderInteractiveForms;
  14718. this.svgFactory = parameters.svgFactory;
  14719. if (isRenderable) {
  14720. this.container = this._createContainer(ignoreBorder);
  14721. }
  14722. }
  14723. _createClass(AnnotationElement, [{
  14724. key: '_createContainer',
  14725. value: function _createContainer() {
  14726. var ignoreBorder = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  14727. var data = this.data,
  14728. page = this.page,
  14729. viewport = this.viewport;
  14730. var container = document.createElement('section');
  14731. var width = data.rect[2] - data.rect[0];
  14732. var height = data.rect[3] - data.rect[1];
  14733. container.setAttribute('data-annotation-id', data.id);
  14734. 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]]);
  14735. container.style.transform = 'matrix(' + viewport.transform.join(',') + ')';
  14736. container.style.transformOrigin = -rect[0] + 'px ' + -rect[1] + 'px';
  14737. if (!ignoreBorder && data.borderStyle.width > 0) {
  14738. container.style.borderWidth = data.borderStyle.width + 'px';
  14739. if (data.borderStyle.style !== _util.AnnotationBorderStyleType.UNDERLINE) {
  14740. width = width - 2 * data.borderStyle.width;
  14741. height = height - 2 * data.borderStyle.width;
  14742. }
  14743. var horizontalRadius = data.borderStyle.horizontalCornerRadius;
  14744. var verticalRadius = data.borderStyle.verticalCornerRadius;
  14745. if (horizontalRadius > 0 || verticalRadius > 0) {
  14746. var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';
  14747. container.style.borderRadius = radius;
  14748. }
  14749. switch (data.borderStyle.style) {
  14750. case _util.AnnotationBorderStyleType.SOLID:
  14751. container.style.borderStyle = 'solid';
  14752. break;
  14753. case _util.AnnotationBorderStyleType.DASHED:
  14754. container.style.borderStyle = 'dashed';
  14755. break;
  14756. case _util.AnnotationBorderStyleType.BEVELED:
  14757. (0, _util.warn)('Unimplemented border style: beveled');
  14758. break;
  14759. case _util.AnnotationBorderStyleType.INSET:
  14760. (0, _util.warn)('Unimplemented border style: inset');
  14761. break;
  14762. case _util.AnnotationBorderStyleType.UNDERLINE:
  14763. container.style.borderBottomStyle = 'solid';
  14764. break;
  14765. default:
  14766. break;
  14767. }
  14768. if (data.color) {
  14769. container.style.borderColor = _util.Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
  14770. } else {
  14771. container.style.borderWidth = 0;
  14772. }
  14773. }
  14774. container.style.left = rect[0] + 'px';
  14775. container.style.top = rect[1] + 'px';
  14776. container.style.width = width + 'px';
  14777. container.style.height = height + 'px';
  14778. return container;
  14779. }
  14780. }, {
  14781. key: '_createPopup',
  14782. value: function _createPopup(container, trigger, data) {
  14783. if (!trigger) {
  14784. trigger = document.createElement('div');
  14785. trigger.style.height = container.style.height;
  14786. trigger.style.width = container.style.width;
  14787. container.appendChild(trigger);
  14788. }
  14789. var popupElement = new PopupElement({
  14790. container: container,
  14791. trigger: trigger,
  14792. color: data.color,
  14793. title: data.title,
  14794. contents: data.contents,
  14795. hideWrapper: true
  14796. });
  14797. var popup = popupElement.render();
  14798. popup.style.left = container.style.width;
  14799. container.appendChild(popup);
  14800. }
  14801. }, {
  14802. key: 'render',
  14803. value: function render() {
  14804. (0, _util.unreachable)('Abstract method `AnnotationElement.render` called');
  14805. }
  14806. }]);
  14807. return AnnotationElement;
  14808. }();
  14809. var LinkAnnotationElement = function (_AnnotationElement) {
  14810. _inherits(LinkAnnotationElement, _AnnotationElement);
  14811. function LinkAnnotationElement(parameters) {
  14812. _classCallCheck(this, LinkAnnotationElement);
  14813. var isRenderable = !!(parameters.data.url || parameters.data.dest || parameters.data.action);
  14814. return _possibleConstructorReturn(this, (LinkAnnotationElement.__proto__ || Object.getPrototypeOf(LinkAnnotationElement)).call(this, parameters, isRenderable));
  14815. }
  14816. _createClass(LinkAnnotationElement, [{
  14817. key: 'render',
  14818. value: function render() {
  14819. this.container.className = 'linkAnnotation';
  14820. var data = this.data,
  14821. linkService = this.linkService;
  14822. var link = document.createElement('a');
  14823. (0, _dom_utils.addLinkAttributes)(link, {
  14824. url: data.url,
  14825. target: data.newWindow ? _dom_utils.LinkTarget.BLANK : linkService.externalLinkTarget,
  14826. rel: linkService.externalLinkRel
  14827. });
  14828. if (!data.url) {
  14829. if (data.action) {
  14830. this._bindNamedAction(link, data.action);
  14831. } else {
  14832. this._bindLink(link, data.dest);
  14833. }
  14834. }
  14835. this.container.appendChild(link);
  14836. return this.container;
  14837. }
  14838. }, {
  14839. key: '_bindLink',
  14840. value: function _bindLink(link, destination) {
  14841. var _this2 = this;
  14842. link.href = this.linkService.getDestinationHash(destination);
  14843. link.onclick = function () {
  14844. if (destination) {
  14845. _this2.linkService.navigateTo(destination);
  14846. }
  14847. return false;
  14848. };
  14849. if (destination) {
  14850. link.className = 'internalLink';
  14851. }
  14852. }
  14853. }, {
  14854. key: '_bindNamedAction',
  14855. value: function _bindNamedAction(link, action) {
  14856. var _this3 = this;
  14857. link.href = this.linkService.getAnchorUrl('');
  14858. link.onclick = function () {
  14859. _this3.linkService.executeNamedAction(action);
  14860. return false;
  14861. };
  14862. link.className = 'internalLink';
  14863. }
  14864. }]);
  14865. return LinkAnnotationElement;
  14866. }(AnnotationElement);
  14867. var TextAnnotationElement = function (_AnnotationElement2) {
  14868. _inherits(TextAnnotationElement, _AnnotationElement2);
  14869. function TextAnnotationElement(parameters) {
  14870. _classCallCheck(this, TextAnnotationElement);
  14871. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  14872. return _possibleConstructorReturn(this, (TextAnnotationElement.__proto__ || Object.getPrototypeOf(TextAnnotationElement)).call(this, parameters, isRenderable));
  14873. }
  14874. _createClass(TextAnnotationElement, [{
  14875. key: 'render',
  14876. value: function render() {
  14877. this.container.className = 'textAnnotation';
  14878. var image = document.createElement('img');
  14879. image.style.height = this.container.style.height;
  14880. image.style.width = this.container.style.width;
  14881. image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg';
  14882. image.alt = '[{{type}} Annotation]';
  14883. image.dataset.l10nId = 'text_annotation_type';
  14884. image.dataset.l10nArgs = JSON.stringify({ type: this.data.name });
  14885. if (!this.data.hasPopup) {
  14886. this._createPopup(this.container, image, this.data);
  14887. }
  14888. this.container.appendChild(image);
  14889. return this.container;
  14890. }
  14891. }]);
  14892. return TextAnnotationElement;
  14893. }(AnnotationElement);
  14894. var WidgetAnnotationElement = function (_AnnotationElement3) {
  14895. _inherits(WidgetAnnotationElement, _AnnotationElement3);
  14896. function WidgetAnnotationElement() {
  14897. _classCallCheck(this, WidgetAnnotationElement);
  14898. return _possibleConstructorReturn(this, (WidgetAnnotationElement.__proto__ || Object.getPrototypeOf(WidgetAnnotationElement)).apply(this, arguments));
  14899. }
  14900. _createClass(WidgetAnnotationElement, [{
  14901. key: 'render',
  14902. value: function render() {
  14903. return this.container;
  14904. }
  14905. }]);
  14906. return WidgetAnnotationElement;
  14907. }(AnnotationElement);
  14908. var TextWidgetAnnotationElement = function (_WidgetAnnotationElem) {
  14909. _inherits(TextWidgetAnnotationElement, _WidgetAnnotationElem);
  14910. function TextWidgetAnnotationElement(parameters) {
  14911. _classCallCheck(this, TextWidgetAnnotationElement);
  14912. var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
  14913. return _possibleConstructorReturn(this, (TextWidgetAnnotationElement.__proto__ || Object.getPrototypeOf(TextWidgetAnnotationElement)).call(this, parameters, isRenderable));
  14914. }
  14915. _createClass(TextWidgetAnnotationElement, [{
  14916. key: 'render',
  14917. value: function render() {
  14918. var TEXT_ALIGNMENT = ['left', 'center', 'right'];
  14919. this.container.className = 'textWidgetAnnotation';
  14920. var element = null;
  14921. if (this.renderInteractiveForms) {
  14922. if (this.data.multiLine) {
  14923. element = document.createElement('textarea');
  14924. element.textContent = this.data.fieldValue;
  14925. } else {
  14926. element = document.createElement('input');
  14927. element.type = 'text';
  14928. element.setAttribute('value', this.data.fieldValue);
  14929. }
  14930. element.disabled = this.data.readOnly;
  14931. if (this.data.maxLen !== null) {
  14932. element.maxLength = this.data.maxLen;
  14933. }
  14934. if (this.data.comb) {
  14935. var fieldWidth = this.data.rect[2] - this.data.rect[0];
  14936. var combWidth = fieldWidth / this.data.maxLen;
  14937. element.classList.add('comb');
  14938. element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)';
  14939. }
  14940. } else {
  14941. element = document.createElement('div');
  14942. element.textContent = this.data.fieldValue;
  14943. element.style.verticalAlign = 'middle';
  14944. element.style.display = 'table-cell';
  14945. var font = null;
  14946. if (this.data.fontRefName) {
  14947. font = this.page.commonObjs.getData(this.data.fontRefName);
  14948. }
  14949. this._setTextStyle(element, font);
  14950. }
  14951. if (this.data.textAlignment !== null) {
  14952. element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
  14953. }
  14954. this.container.appendChild(element);
  14955. return this.container;
  14956. }
  14957. }, {
  14958. key: '_setTextStyle',
  14959. value: function _setTextStyle(element, font) {
  14960. var style = element.style;
  14961. style.fontSize = this.data.fontSize + 'px';
  14962. style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr';
  14963. if (!font) {
  14964. return;
  14965. }
  14966. style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal';
  14967. style.fontStyle = font.italic ? 'italic' : 'normal';
  14968. var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : '';
  14969. var fallbackName = font.fallbackName || 'Helvetica, sans-serif';
  14970. style.fontFamily = fontFamily + fallbackName;
  14971. }
  14972. }]);
  14973. return TextWidgetAnnotationElement;
  14974. }(WidgetAnnotationElement);
  14975. var CheckboxWidgetAnnotationElement = function (_WidgetAnnotationElem2) {
  14976. _inherits(CheckboxWidgetAnnotationElement, _WidgetAnnotationElem2);
  14977. function CheckboxWidgetAnnotationElement(parameters) {
  14978. _classCallCheck(this, CheckboxWidgetAnnotationElement);
  14979. return _possibleConstructorReturn(this, (CheckboxWidgetAnnotationElement.__proto__ || Object.getPrototypeOf(CheckboxWidgetAnnotationElement)).call(this, parameters, parameters.renderInteractiveForms));
  14980. }
  14981. _createClass(CheckboxWidgetAnnotationElement, [{
  14982. key: 'render',
  14983. value: function render() {
  14984. this.container.className = 'buttonWidgetAnnotation checkBox';
  14985. var element = document.createElement('input');
  14986. element.disabled = this.data.readOnly;
  14987. element.type = 'checkbox';
  14988. if (this.data.fieldValue && this.data.fieldValue !== 'Off') {
  14989. element.setAttribute('checked', true);
  14990. }
  14991. this.container.appendChild(element);
  14992. return this.container;
  14993. }
  14994. }]);
  14995. return CheckboxWidgetAnnotationElement;
  14996. }(WidgetAnnotationElement);
  14997. var RadioButtonWidgetAnnotationElement = function (_WidgetAnnotationElem3) {
  14998. _inherits(RadioButtonWidgetAnnotationElement, _WidgetAnnotationElem3);
  14999. function RadioButtonWidgetAnnotationElement(parameters) {
  15000. _classCallCheck(this, RadioButtonWidgetAnnotationElement);
  15001. return _possibleConstructorReturn(this, (RadioButtonWidgetAnnotationElement.__proto__ || Object.getPrototypeOf(RadioButtonWidgetAnnotationElement)).call(this, parameters, parameters.renderInteractiveForms));
  15002. }
  15003. _createClass(RadioButtonWidgetAnnotationElement, [{
  15004. key: 'render',
  15005. value: function render() {
  15006. this.container.className = 'buttonWidgetAnnotation radioButton';
  15007. var element = document.createElement('input');
  15008. element.disabled = this.data.readOnly;
  15009. element.type = 'radio';
  15010. element.name = this.data.fieldName;
  15011. if (this.data.fieldValue === this.data.buttonValue) {
  15012. element.setAttribute('checked', true);
  15013. }
  15014. this.container.appendChild(element);
  15015. return this.container;
  15016. }
  15017. }]);
  15018. return RadioButtonWidgetAnnotationElement;
  15019. }(WidgetAnnotationElement);
  15020. var PushButtonWidgetAnnotationElement = function (_LinkAnnotationElemen) {
  15021. _inherits(PushButtonWidgetAnnotationElement, _LinkAnnotationElemen);
  15022. function PushButtonWidgetAnnotationElement() {
  15023. _classCallCheck(this, PushButtonWidgetAnnotationElement);
  15024. return _possibleConstructorReturn(this, (PushButtonWidgetAnnotationElement.__proto__ || Object.getPrototypeOf(PushButtonWidgetAnnotationElement)).apply(this, arguments));
  15025. }
  15026. _createClass(PushButtonWidgetAnnotationElement, [{
  15027. key: 'render',
  15028. value: function render() {
  15029. var container = _get(PushButtonWidgetAnnotationElement.prototype.__proto__ || Object.getPrototypeOf(PushButtonWidgetAnnotationElement.prototype), 'render', this).call(this);
  15030. container.className = 'buttonWidgetAnnotation pushButton';
  15031. return container;
  15032. }
  15033. }]);
  15034. return PushButtonWidgetAnnotationElement;
  15035. }(LinkAnnotationElement);
  15036. var ChoiceWidgetAnnotationElement = function (_WidgetAnnotationElem4) {
  15037. _inherits(ChoiceWidgetAnnotationElement, _WidgetAnnotationElem4);
  15038. function ChoiceWidgetAnnotationElement(parameters) {
  15039. _classCallCheck(this, ChoiceWidgetAnnotationElement);
  15040. return _possibleConstructorReturn(this, (ChoiceWidgetAnnotationElement.__proto__ || Object.getPrototypeOf(ChoiceWidgetAnnotationElement)).call(this, parameters, parameters.renderInteractiveForms));
  15041. }
  15042. _createClass(ChoiceWidgetAnnotationElement, [{
  15043. key: 'render',
  15044. value: function render() {
  15045. this.container.className = 'choiceWidgetAnnotation';
  15046. var selectElement = document.createElement('select');
  15047. selectElement.disabled = this.data.readOnly;
  15048. if (!this.data.combo) {
  15049. selectElement.size = this.data.options.length;
  15050. if (this.data.multiSelect) {
  15051. selectElement.multiple = true;
  15052. }
  15053. }
  15054. for (var i = 0, ii = this.data.options.length; i < ii; i++) {
  15055. var option = this.data.options[i];
  15056. var optionElement = document.createElement('option');
  15057. optionElement.textContent = option.displayValue;
  15058. optionElement.value = option.exportValue;
  15059. if (this.data.fieldValue.includes(option.displayValue)) {
  15060. optionElement.setAttribute('selected', true);
  15061. }
  15062. selectElement.appendChild(optionElement);
  15063. }
  15064. this.container.appendChild(selectElement);
  15065. return this.container;
  15066. }
  15067. }]);
  15068. return ChoiceWidgetAnnotationElement;
  15069. }(WidgetAnnotationElement);
  15070. var PopupAnnotationElement = function (_AnnotationElement4) {
  15071. _inherits(PopupAnnotationElement, _AnnotationElement4);
  15072. function PopupAnnotationElement(parameters) {
  15073. _classCallCheck(this, PopupAnnotationElement);
  15074. var isRenderable = !!(parameters.data.title || parameters.data.contents);
  15075. return _possibleConstructorReturn(this, (PopupAnnotationElement.__proto__ || Object.getPrototypeOf(PopupAnnotationElement)).call(this, parameters, isRenderable));
  15076. }
  15077. _createClass(PopupAnnotationElement, [{
  15078. key: 'render',
  15079. value: function render() {
  15080. var IGNORE_TYPES = ['Line', 'Square', 'Circle', 'PolyLine', 'Polygon', 'Ink'];
  15081. this.container.className = 'popupAnnotation';
  15082. if (IGNORE_TYPES.includes(this.data.parentType)) {
  15083. return this.container;
  15084. }
  15085. var selector = '[data-annotation-id="' + this.data.parentId + '"]';
  15086. var parentElement = this.layer.querySelector(selector);
  15087. if (!parentElement) {
  15088. return this.container;
  15089. }
  15090. var popup = new PopupElement({
  15091. container: this.container,
  15092. trigger: parentElement,
  15093. color: this.data.color,
  15094. title: this.data.title,
  15095. contents: this.data.contents
  15096. });
  15097. var parentLeft = parseFloat(parentElement.style.left);
  15098. var parentWidth = parseFloat(parentElement.style.width);
  15099. this.container.style.transformOrigin = -(parentLeft + parentWidth) + 'px -' + parentElement.style.top;
  15100. this.container.style.left = parentLeft + parentWidth + 'px';
  15101. this.container.appendChild(popup.render());
  15102. return this.container;
  15103. }
  15104. }]);
  15105. return PopupAnnotationElement;
  15106. }(AnnotationElement);
  15107. var PopupElement = function () {
  15108. function PopupElement(parameters) {
  15109. _classCallCheck(this, PopupElement);
  15110. this.container = parameters.container;
  15111. this.trigger = parameters.trigger;
  15112. this.color = parameters.color;
  15113. this.title = parameters.title;
  15114. this.contents = parameters.contents;
  15115. this.hideWrapper = parameters.hideWrapper || false;
  15116. this.pinned = false;
  15117. }
  15118. _createClass(PopupElement, [{
  15119. key: 'render',
  15120. value: function render() {
  15121. var BACKGROUND_ENLIGHT = 0.7;
  15122. var wrapper = document.createElement('div');
  15123. wrapper.className = 'popupWrapper';
  15124. this.hideElement = this.hideWrapper ? wrapper : this.container;
  15125. this.hideElement.setAttribute('hidden', true);
  15126. var popup = document.createElement('div');
  15127. popup.className = 'popup';
  15128. var color = this.color;
  15129. if (color) {
  15130. var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
  15131. var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
  15132. var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
  15133. popup.style.backgroundColor = _util.Util.makeCssRgb(r | 0, g | 0, b | 0);
  15134. }
  15135. var contents = this._formatContents(this.contents);
  15136. var title = document.createElement('h1');
  15137. title.textContent = this.title;
  15138. this.trigger.addEventListener('click', this._toggle.bind(this));
  15139. this.trigger.addEventListener('mouseover', this._show.bind(this, false));
  15140. this.trigger.addEventListener('mouseout', this._hide.bind(this, false));
  15141. popup.addEventListener('click', this._hide.bind(this, true));
  15142. popup.appendChild(title);
  15143. popup.appendChild(contents);
  15144. wrapper.appendChild(popup);
  15145. return wrapper;
  15146. }
  15147. }, {
  15148. key: '_formatContents',
  15149. value: function _formatContents(contents) {
  15150. var p = document.createElement('p');
  15151. var lines = contents.split(/(?:\r\n?|\n)/);
  15152. for (var i = 0, ii = lines.length; i < ii; ++i) {
  15153. var line = lines[i];
  15154. p.appendChild(document.createTextNode(line));
  15155. if (i < ii - 1) {
  15156. p.appendChild(document.createElement('br'));
  15157. }
  15158. }
  15159. return p;
  15160. }
  15161. }, {
  15162. key: '_toggle',
  15163. value: function _toggle() {
  15164. if (this.pinned) {
  15165. this._hide(true);
  15166. } else {
  15167. this._show(true);
  15168. }
  15169. }
  15170. }, {
  15171. key: '_show',
  15172. value: function _show() {
  15173. var pin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  15174. if (pin) {
  15175. this.pinned = true;
  15176. }
  15177. if (this.hideElement.hasAttribute('hidden')) {
  15178. this.hideElement.removeAttribute('hidden');
  15179. this.container.style.zIndex += 1;
  15180. }
  15181. }
  15182. }, {
  15183. key: '_hide',
  15184. value: function _hide() {
  15185. var unpin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  15186. if (unpin) {
  15187. this.pinned = false;
  15188. }
  15189. if (!this.hideElement.hasAttribute('hidden') && !this.pinned) {
  15190. this.hideElement.setAttribute('hidden', true);
  15191. this.container.style.zIndex -= 1;
  15192. }
  15193. }
  15194. }]);
  15195. return PopupElement;
  15196. }();
  15197. var LineAnnotationElement = function (_AnnotationElement5) {
  15198. _inherits(LineAnnotationElement, _AnnotationElement5);
  15199. function LineAnnotationElement(parameters) {
  15200. _classCallCheck(this, LineAnnotationElement);
  15201. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  15202. return _possibleConstructorReturn(this, (LineAnnotationElement.__proto__ || Object.getPrototypeOf(LineAnnotationElement)).call(this, parameters, isRenderable, true));
  15203. }
  15204. _createClass(LineAnnotationElement, [{
  15205. key: 'render',
  15206. value: function render() {
  15207. this.container.className = 'lineAnnotation';
  15208. var data = this.data;
  15209. var width = data.rect[2] - data.rect[0];
  15210. var height = data.rect[3] - data.rect[1];
  15211. var svg = this.svgFactory.create(width, height);
  15212. var line = this.svgFactory.createElement('svg:line');
  15213. line.setAttribute('x1', data.rect[2] - data.lineCoordinates[0]);
  15214. line.setAttribute('y1', data.rect[3] - data.lineCoordinates[1]);
  15215. line.setAttribute('x2', data.rect[2] - data.lineCoordinates[2]);
  15216. line.setAttribute('y2', data.rect[3] - data.lineCoordinates[3]);
  15217. line.setAttribute('stroke-width', data.borderStyle.width);
  15218. line.setAttribute('stroke', 'transparent');
  15219. svg.appendChild(line);
  15220. this.container.append(svg);
  15221. this._createPopup(this.container, line, data);
  15222. return this.container;
  15223. }
  15224. }]);
  15225. return LineAnnotationElement;
  15226. }(AnnotationElement);
  15227. var SquareAnnotationElement = function (_AnnotationElement6) {
  15228. _inherits(SquareAnnotationElement, _AnnotationElement6);
  15229. function SquareAnnotationElement(parameters) {
  15230. _classCallCheck(this, SquareAnnotationElement);
  15231. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  15232. return _possibleConstructorReturn(this, (SquareAnnotationElement.__proto__ || Object.getPrototypeOf(SquareAnnotationElement)).call(this, parameters, isRenderable, true));
  15233. }
  15234. _createClass(SquareAnnotationElement, [{
  15235. key: 'render',
  15236. value: function render() {
  15237. this.container.className = 'squareAnnotation';
  15238. var data = this.data;
  15239. var width = data.rect[2] - data.rect[0];
  15240. var height = data.rect[3] - data.rect[1];
  15241. var svg = this.svgFactory.create(width, height);
  15242. var borderWidth = data.borderStyle.width;
  15243. var square = this.svgFactory.createElement('svg:rect');
  15244. square.setAttribute('x', borderWidth / 2);
  15245. square.setAttribute('y', borderWidth / 2);
  15246. square.setAttribute('width', width - borderWidth);
  15247. square.setAttribute('height', height - borderWidth);
  15248. square.setAttribute('stroke-width', borderWidth);
  15249. square.setAttribute('stroke', 'transparent');
  15250. square.setAttribute('fill', 'none');
  15251. svg.appendChild(square);
  15252. this.container.append(svg);
  15253. this._createPopup(this.container, square, data);
  15254. return this.container;
  15255. }
  15256. }]);
  15257. return SquareAnnotationElement;
  15258. }(AnnotationElement);
  15259. var CircleAnnotationElement = function (_AnnotationElement7) {
  15260. _inherits(CircleAnnotationElement, _AnnotationElement7);
  15261. function CircleAnnotationElement(parameters) {
  15262. _classCallCheck(this, CircleAnnotationElement);
  15263. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  15264. return _possibleConstructorReturn(this, (CircleAnnotationElement.__proto__ || Object.getPrototypeOf(CircleAnnotationElement)).call(this, parameters, isRenderable, true));
  15265. }
  15266. _createClass(CircleAnnotationElement, [{
  15267. key: 'render',
  15268. value: function render() {
  15269. this.container.className = 'circleAnnotation';
  15270. var data = this.data;
  15271. var width = data.rect[2] - data.rect[0];
  15272. var height = data.rect[3] - data.rect[1];
  15273. var svg = this.svgFactory.create(width, height);
  15274. var borderWidth = data.borderStyle.width;
  15275. var circle = this.svgFactory.createElement('svg:ellipse');
  15276. circle.setAttribute('cx', width / 2);
  15277. circle.setAttribute('cy', height / 2);
  15278. circle.setAttribute('rx', width / 2 - borderWidth / 2);
  15279. circle.setAttribute('ry', height / 2 - borderWidth / 2);
  15280. circle.setAttribute('stroke-width', borderWidth);
  15281. circle.setAttribute('stroke', 'transparent');
  15282. circle.setAttribute('fill', 'none');
  15283. svg.appendChild(circle);
  15284. this.container.append(svg);
  15285. this._createPopup(this.container, circle, data);
  15286. return this.container;
  15287. }
  15288. }]);
  15289. return CircleAnnotationElement;
  15290. }(AnnotationElement);
  15291. var PolylineAnnotationElement = function (_AnnotationElement8) {
  15292. _inherits(PolylineAnnotationElement, _AnnotationElement8);
  15293. function PolylineAnnotationElement(parameters) {
  15294. _classCallCheck(this, PolylineAnnotationElement);
  15295. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  15296. var _this15 = _possibleConstructorReturn(this, (PolylineAnnotationElement.__proto__ || Object.getPrototypeOf(PolylineAnnotationElement)).call(this, parameters, isRenderable, true));
  15297. _this15.containerClassName = 'polylineAnnotation';
  15298. _this15.svgElementName = 'svg:polyline';
  15299. return _this15;
  15300. }
  15301. _createClass(PolylineAnnotationElement, [{
  15302. key: 'render',
  15303. value: function render() {
  15304. this.container.className = this.containerClassName;
  15305. var data = this.data;
  15306. var width = data.rect[2] - data.rect[0];
  15307. var height = data.rect[3] - data.rect[1];
  15308. var svg = this.svgFactory.create(width, height);
  15309. var vertices = data.vertices;
  15310. var points = [];
  15311. for (var i = 0, ii = vertices.length; i < ii; i++) {
  15312. var x = vertices[i].x - data.rect[0];
  15313. var y = data.rect[3] - vertices[i].y;
  15314. points.push(x + ',' + y);
  15315. }
  15316. points = points.join(' ');
  15317. var borderWidth = data.borderStyle.width;
  15318. var polyline = this.svgFactory.createElement(this.svgElementName);
  15319. polyline.setAttribute('points', points);
  15320. polyline.setAttribute('stroke-width', borderWidth);
  15321. polyline.setAttribute('stroke', 'transparent');
  15322. polyline.setAttribute('fill', 'none');
  15323. svg.appendChild(polyline);
  15324. this.container.append(svg);
  15325. this._createPopup(this.container, polyline, data);
  15326. return this.container;
  15327. }
  15328. }]);
  15329. return PolylineAnnotationElement;
  15330. }(AnnotationElement);
  15331. var PolygonAnnotationElement = function (_PolylineAnnotationEl) {
  15332. _inherits(PolygonAnnotationElement, _PolylineAnnotationEl);
  15333. function PolygonAnnotationElement(parameters) {
  15334. _classCallCheck(this, PolygonAnnotationElement);
  15335. var _this16 = _possibleConstructorReturn(this, (PolygonAnnotationElement.__proto__ || Object.getPrototypeOf(PolygonAnnotationElement)).call(this, parameters));
  15336. _this16.containerClassName = 'polygonAnnotation';
  15337. _this16.svgElementName = 'svg:polygon';
  15338. return _this16;
  15339. }
  15340. return PolygonAnnotationElement;
  15341. }(PolylineAnnotationElement);
  15342. var InkAnnotationElement = function (_AnnotationElement9) {
  15343. _inherits(InkAnnotationElement, _AnnotationElement9);
  15344. function InkAnnotationElement(parameters) {
  15345. _classCallCheck(this, InkAnnotationElement);
  15346. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  15347. var _this17 = _possibleConstructorReturn(this, (InkAnnotationElement.__proto__ || Object.getPrototypeOf(InkAnnotationElement)).call(this, parameters, isRenderable, true));
  15348. _this17.containerClassName = 'inkAnnotation';
  15349. _this17.svgElementName = 'svg:polyline';
  15350. return _this17;
  15351. }
  15352. _createClass(InkAnnotationElement, [{
  15353. key: 'render',
  15354. value: function render() {
  15355. this.container.className = this.containerClassName;
  15356. var data = this.data;
  15357. var width = data.rect[2] - data.rect[0];
  15358. var height = data.rect[3] - data.rect[1];
  15359. var svg = this.svgFactory.create(width, height);
  15360. var inkLists = data.inkLists;
  15361. for (var i = 0, ii = inkLists.length; i < ii; i++) {
  15362. var inkList = inkLists[i];
  15363. var points = [];
  15364. for (var j = 0, jj = inkList.length; j < jj; j++) {
  15365. var x = inkList[j].x - data.rect[0];
  15366. var y = data.rect[3] - inkList[j].y;
  15367. points.push(x + ',' + y);
  15368. }
  15369. points = points.join(' ');
  15370. var borderWidth = data.borderStyle.width;
  15371. var polyline = this.svgFactory.createElement(this.svgElementName);
  15372. polyline.setAttribute('points', points);
  15373. polyline.setAttribute('stroke-width', borderWidth);
  15374. polyline.setAttribute('stroke', 'transparent');
  15375. polyline.setAttribute('fill', 'none');
  15376. this._createPopup(this.container, polyline, data);
  15377. svg.appendChild(polyline);
  15378. }
  15379. this.container.append(svg);
  15380. return this.container;
  15381. }
  15382. }]);
  15383. return InkAnnotationElement;
  15384. }(AnnotationElement);
  15385. var HighlightAnnotationElement = function (_AnnotationElement10) {
  15386. _inherits(HighlightAnnotationElement, _AnnotationElement10);
  15387. function HighlightAnnotationElement(parameters) {
  15388. _classCallCheck(this, HighlightAnnotationElement);
  15389. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  15390. return _possibleConstructorReturn(this, (HighlightAnnotationElement.__proto__ || Object.getPrototypeOf(HighlightAnnotationElement)).call(this, parameters, isRenderable, true));
  15391. }
  15392. _createClass(HighlightAnnotationElement, [{
  15393. key: 'render',
  15394. value: function render() {
  15395. this.container.className = 'highlightAnnotation';
  15396. if (!this.data.hasPopup) {
  15397. this._createPopup(this.container, null, this.data);
  15398. }
  15399. return this.container;
  15400. }
  15401. }]);
  15402. return HighlightAnnotationElement;
  15403. }(AnnotationElement);
  15404. var UnderlineAnnotationElement = function (_AnnotationElement11) {
  15405. _inherits(UnderlineAnnotationElement, _AnnotationElement11);
  15406. function UnderlineAnnotationElement(parameters) {
  15407. _classCallCheck(this, UnderlineAnnotationElement);
  15408. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  15409. return _possibleConstructorReturn(this, (UnderlineAnnotationElement.__proto__ || Object.getPrototypeOf(UnderlineAnnotationElement)).call(this, parameters, isRenderable, true));
  15410. }
  15411. _createClass(UnderlineAnnotationElement, [{
  15412. key: 'render',
  15413. value: function render() {
  15414. this.container.className = 'underlineAnnotation';
  15415. if (!this.data.hasPopup) {
  15416. this._createPopup(this.container, null, this.data);
  15417. }
  15418. return this.container;
  15419. }
  15420. }]);
  15421. return UnderlineAnnotationElement;
  15422. }(AnnotationElement);
  15423. var SquigglyAnnotationElement = function (_AnnotationElement12) {
  15424. _inherits(SquigglyAnnotationElement, _AnnotationElement12);
  15425. function SquigglyAnnotationElement(parameters) {
  15426. _classCallCheck(this, SquigglyAnnotationElement);
  15427. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  15428. return _possibleConstructorReturn(this, (SquigglyAnnotationElement.__proto__ || Object.getPrototypeOf(SquigglyAnnotationElement)).call(this, parameters, isRenderable, true));
  15429. }
  15430. _createClass(SquigglyAnnotationElement, [{
  15431. key: 'render',
  15432. value: function render() {
  15433. this.container.className = 'squigglyAnnotation';
  15434. if (!this.data.hasPopup) {
  15435. this._createPopup(this.container, null, this.data);
  15436. }
  15437. return this.container;
  15438. }
  15439. }]);
  15440. return SquigglyAnnotationElement;
  15441. }(AnnotationElement);
  15442. var StrikeOutAnnotationElement = function (_AnnotationElement13) {
  15443. _inherits(StrikeOutAnnotationElement, _AnnotationElement13);
  15444. function StrikeOutAnnotationElement(parameters) {
  15445. _classCallCheck(this, StrikeOutAnnotationElement);
  15446. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  15447. return _possibleConstructorReturn(this, (StrikeOutAnnotationElement.__proto__ || Object.getPrototypeOf(StrikeOutAnnotationElement)).call(this, parameters, isRenderable, true));
  15448. }
  15449. _createClass(StrikeOutAnnotationElement, [{
  15450. key: 'render',
  15451. value: function render() {
  15452. this.container.className = 'strikeoutAnnotation';
  15453. if (!this.data.hasPopup) {
  15454. this._createPopup(this.container, null, this.data);
  15455. }
  15456. return this.container;
  15457. }
  15458. }]);
  15459. return StrikeOutAnnotationElement;
  15460. }(AnnotationElement);
  15461. var StampAnnotationElement = function (_AnnotationElement14) {
  15462. _inherits(StampAnnotationElement, _AnnotationElement14);
  15463. function StampAnnotationElement(parameters) {
  15464. _classCallCheck(this, StampAnnotationElement);
  15465. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  15466. return _possibleConstructorReturn(this, (StampAnnotationElement.__proto__ || Object.getPrototypeOf(StampAnnotationElement)).call(this, parameters, isRenderable, true));
  15467. }
  15468. _createClass(StampAnnotationElement, [{
  15469. key: 'render',
  15470. value: function render() {
  15471. this.container.className = 'stampAnnotation';
  15472. if (!this.data.hasPopup) {
  15473. this._createPopup(this.container, null, this.data);
  15474. }
  15475. return this.container;
  15476. }
  15477. }]);
  15478. return StampAnnotationElement;
  15479. }(AnnotationElement);
  15480. var FileAttachmentAnnotationElement = function (_AnnotationElement15) {
  15481. _inherits(FileAttachmentAnnotationElement, _AnnotationElement15);
  15482. function FileAttachmentAnnotationElement(parameters) {
  15483. _classCallCheck(this, FileAttachmentAnnotationElement);
  15484. var _this23 = _possibleConstructorReturn(this, (FileAttachmentAnnotationElement.__proto__ || Object.getPrototypeOf(FileAttachmentAnnotationElement)).call(this, parameters, true));
  15485. var _this23$data$file = _this23.data.file,
  15486. filename = _this23$data$file.filename,
  15487. content = _this23$data$file.content;
  15488. _this23.filename = (0, _dom_utils.getFilenameFromUrl)(filename);
  15489. _this23.content = content;
  15490. if (_this23.linkService.eventBus) {
  15491. _this23.linkService.eventBus.dispatch('fileattachmentannotation', {
  15492. source: _this23,
  15493. id: (0, _util.stringToPDFString)(filename),
  15494. filename: filename,
  15495. content: content
  15496. });
  15497. }
  15498. return _this23;
  15499. }
  15500. _createClass(FileAttachmentAnnotationElement, [{
  15501. key: 'render',
  15502. value: function render() {
  15503. this.container.className = 'fileAttachmentAnnotation';
  15504. var trigger = document.createElement('div');
  15505. trigger.style.height = this.container.style.height;
  15506. trigger.style.width = this.container.style.width;
  15507. trigger.addEventListener('dblclick', this._download.bind(this));
  15508. if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
  15509. this._createPopup(this.container, trigger, this.data);
  15510. }
  15511. this.container.appendChild(trigger);
  15512. return this.container;
  15513. }
  15514. }, {
  15515. key: '_download',
  15516. value: function _download() {
  15517. if (!this.downloadManager) {
  15518. (0, _util.warn)('Download cannot be started due to unavailable download manager');
  15519. return;
  15520. }
  15521. this.downloadManager.downloadData(this.content, this.filename, '');
  15522. }
  15523. }]);
  15524. return FileAttachmentAnnotationElement;
  15525. }(AnnotationElement);
  15526. var AnnotationLayer = function () {
  15527. function AnnotationLayer() {
  15528. _classCallCheck(this, AnnotationLayer);
  15529. }
  15530. _createClass(AnnotationLayer, null, [{
  15531. key: 'render',
  15532. value: function render(parameters) {
  15533. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  15534. var data = parameters.annotations[i];
  15535. if (!data) {
  15536. continue;
  15537. }
  15538. var element = AnnotationElementFactory.create({
  15539. data: data,
  15540. layer: parameters.div,
  15541. page: parameters.page,
  15542. viewport: parameters.viewport,
  15543. linkService: parameters.linkService,
  15544. downloadManager: parameters.downloadManager,
  15545. imageResourcesPath: parameters.imageResourcesPath || '',
  15546. renderInteractiveForms: parameters.renderInteractiveForms || false,
  15547. svgFactory: new _dom_utils.DOMSVGFactory()
  15548. });
  15549. if (element.isRenderable) {
  15550. parameters.div.appendChild(element.render());
  15551. }
  15552. }
  15553. }
  15554. }, {
  15555. key: 'update',
  15556. value: function update(parameters) {
  15557. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  15558. var data = parameters.annotations[i];
  15559. var element = parameters.div.querySelector('[data-annotation-id="' + data.id + '"]');
  15560. if (element) {
  15561. element.style.transform = 'matrix(' + parameters.viewport.transform.join(',') + ')';
  15562. }
  15563. }
  15564. parameters.div.removeAttribute('hidden');
  15565. }
  15566. }]);
  15567. return AnnotationLayer;
  15568. }();
  15569. exports.AnnotationLayer = AnnotationLayer;
  15570. /***/ }),
  15571. /* 147 */
  15572. /***/ (function(module, exports, __w_pdfjs_require__) {
  15573. "use strict";
  15574. Object.defineProperty(exports, "__esModule", {
  15575. value: true
  15576. });
  15577. exports.SVGGraphics = undefined;
  15578. var _util = __w_pdfjs_require__(1);
  15579. var _dom_utils = __w_pdfjs_require__(130);
  15580. var _is_node = __w_pdfjs_require__(4);
  15581. var _is_node2 = _interopRequireDefault(_is_node);
  15582. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  15583. var SVGGraphics = function SVGGraphics() {
  15584. throw new Error('Not implemented: SVGGraphics');
  15585. };
  15586. {
  15587. var SVG_DEFAULTS = {
  15588. fontStyle: 'normal',
  15589. fontWeight: 'normal',
  15590. fillColor: '#000000'
  15591. };
  15592. var convertImgDataToPng = function convertImgDataToPngClosure() {
  15593. var PNG_HEADER = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
  15594. var CHUNK_WRAPPER_SIZE = 12;
  15595. var crcTable = new Int32Array(256);
  15596. for (var i = 0; i < 256; i++) {
  15597. var c = i;
  15598. for (var h = 0; h < 8; h++) {
  15599. if (c & 1) {
  15600. c = 0xedB88320 ^ c >> 1 & 0x7fffffff;
  15601. } else {
  15602. c = c >> 1 & 0x7fffffff;
  15603. }
  15604. }
  15605. crcTable[i] = c;
  15606. }
  15607. function crc32(data, start, end) {
  15608. var crc = -1;
  15609. for (var i = start; i < end; i++) {
  15610. var a = (crc ^ data[i]) & 0xff;
  15611. var b = crcTable[a];
  15612. crc = crc >>> 8 ^ b;
  15613. }
  15614. return crc ^ -1;
  15615. }
  15616. function writePngChunk(type, body, data, offset) {
  15617. var p = offset;
  15618. var len = body.length;
  15619. data[p] = len >> 24 & 0xff;
  15620. data[p + 1] = len >> 16 & 0xff;
  15621. data[p + 2] = len >> 8 & 0xff;
  15622. data[p + 3] = len & 0xff;
  15623. p += 4;
  15624. data[p] = type.charCodeAt(0) & 0xff;
  15625. data[p + 1] = type.charCodeAt(1) & 0xff;
  15626. data[p + 2] = type.charCodeAt(2) & 0xff;
  15627. data[p + 3] = type.charCodeAt(3) & 0xff;
  15628. p += 4;
  15629. data.set(body, p);
  15630. p += body.length;
  15631. var crc = crc32(data, offset + 4, p);
  15632. data[p] = crc >> 24 & 0xff;
  15633. data[p + 1] = crc >> 16 & 0xff;
  15634. data[p + 2] = crc >> 8 & 0xff;
  15635. data[p + 3] = crc & 0xff;
  15636. }
  15637. function adler32(data, start, end) {
  15638. var a = 1;
  15639. var b = 0;
  15640. for (var i = start; i < end; ++i) {
  15641. a = (a + (data[i] & 0xff)) % 65521;
  15642. b = (b + a) % 65521;
  15643. }
  15644. return b << 16 | a;
  15645. }
  15646. function deflateSync(literals) {
  15647. if (!(0, _is_node2.default)()) {
  15648. return deflateSyncUncompressed(literals);
  15649. }
  15650. try {
  15651. var input;
  15652. if (parseInt(process.versions.node) >= 8) {
  15653. input = literals;
  15654. } else {
  15655. input = new Buffer(literals);
  15656. }
  15657. var output = require('zlib').deflateSync(input, { level: 9 });
  15658. return output instanceof Uint8Array ? output : new Uint8Array(output);
  15659. } catch (e) {
  15660. (0, _util.warn)('Not compressing PNG because zlib.deflateSync is unavailable: ' + e);
  15661. }
  15662. return deflateSyncUncompressed(literals);
  15663. }
  15664. function deflateSyncUncompressed(literals) {
  15665. var len = literals.length;
  15666. var maxBlockLength = 0xFFFF;
  15667. var deflateBlocks = Math.ceil(len / maxBlockLength);
  15668. var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
  15669. var pi = 0;
  15670. idat[pi++] = 0x78;
  15671. idat[pi++] = 0x9c;
  15672. var pos = 0;
  15673. while (len > maxBlockLength) {
  15674. idat[pi++] = 0x00;
  15675. idat[pi++] = 0xff;
  15676. idat[pi++] = 0xff;
  15677. idat[pi++] = 0x00;
  15678. idat[pi++] = 0x00;
  15679. idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
  15680. pi += maxBlockLength;
  15681. pos += maxBlockLength;
  15682. len -= maxBlockLength;
  15683. }
  15684. idat[pi++] = 0x01;
  15685. idat[pi++] = len & 0xff;
  15686. idat[pi++] = len >> 8 & 0xff;
  15687. idat[pi++] = ~len & 0xffff & 0xff;
  15688. idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
  15689. idat.set(literals.subarray(pos), pi);
  15690. pi += literals.length - pos;
  15691. var adler = adler32(literals, 0, literals.length);
  15692. idat[pi++] = adler >> 24 & 0xff;
  15693. idat[pi++] = adler >> 16 & 0xff;
  15694. idat[pi++] = adler >> 8 & 0xff;
  15695. idat[pi++] = adler & 0xff;
  15696. return idat;
  15697. }
  15698. function encode(imgData, kind, forceDataSchema, isMask) {
  15699. var width = imgData.width;
  15700. var height = imgData.height;
  15701. var bitDepth, colorType, lineSize;
  15702. var bytes = imgData.data;
  15703. switch (kind) {
  15704. case _util.ImageKind.GRAYSCALE_1BPP:
  15705. colorType = 0;
  15706. bitDepth = 1;
  15707. lineSize = width + 7 >> 3;
  15708. break;
  15709. case _util.ImageKind.RGB_24BPP:
  15710. colorType = 2;
  15711. bitDepth = 8;
  15712. lineSize = width * 3;
  15713. break;
  15714. case _util.ImageKind.RGBA_32BPP:
  15715. colorType = 6;
  15716. bitDepth = 8;
  15717. lineSize = width * 4;
  15718. break;
  15719. default:
  15720. throw new Error('invalid format');
  15721. }
  15722. var literals = new Uint8Array((1 + lineSize) * height);
  15723. var offsetLiterals = 0,
  15724. offsetBytes = 0;
  15725. var y, i;
  15726. for (y = 0; y < height; ++y) {
  15727. literals[offsetLiterals++] = 0;
  15728. literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals);
  15729. offsetBytes += lineSize;
  15730. offsetLiterals += lineSize;
  15731. }
  15732. if (kind === _util.ImageKind.GRAYSCALE_1BPP && isMask) {
  15733. offsetLiterals = 0;
  15734. for (y = 0; y < height; y++) {
  15735. offsetLiterals++;
  15736. for (i = 0; i < lineSize; i++) {
  15737. literals[offsetLiterals++] ^= 0xFF;
  15738. }
  15739. }
  15740. }
  15741. 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]);
  15742. var idat = deflateSync(literals);
  15743. var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
  15744. var data = new Uint8Array(pngLength);
  15745. var offset = 0;
  15746. data.set(PNG_HEADER, offset);
  15747. offset += PNG_HEADER.length;
  15748. writePngChunk('IHDR', ihdr, data, offset);
  15749. offset += CHUNK_WRAPPER_SIZE + ihdr.length;
  15750. writePngChunk('IDATA', idat, data, offset);
  15751. offset += CHUNK_WRAPPER_SIZE + idat.length;
  15752. writePngChunk('IEND', new Uint8Array(0), data, offset);
  15753. return (0, _util.createObjectURL)(data, 'image/png', forceDataSchema);
  15754. }
  15755. return function convertImgDataToPng(imgData, forceDataSchema, isMask) {
  15756. var kind = imgData.kind === undefined ? _util.ImageKind.GRAYSCALE_1BPP : imgData.kind;
  15757. return encode(imgData, kind, forceDataSchema, isMask);
  15758. };
  15759. }();
  15760. var SVGExtraState = function SVGExtraStateClosure() {
  15761. function SVGExtraState() {
  15762. this.fontSizeScale = 1;
  15763. this.fontWeight = SVG_DEFAULTS.fontWeight;
  15764. this.fontSize = 0;
  15765. this.textMatrix = _util.IDENTITY_MATRIX;
  15766. this.fontMatrix = _util.FONT_IDENTITY_MATRIX;
  15767. this.leading = 0;
  15768. this.textRenderingMode = _util.TextRenderingMode.FILL;
  15769. this.x = 0;
  15770. this.y = 0;
  15771. this.lineX = 0;
  15772. this.lineY = 0;
  15773. this.charSpacing = 0;
  15774. this.wordSpacing = 0;
  15775. this.textHScale = 1;
  15776. this.textRise = 0;
  15777. this.fillColor = SVG_DEFAULTS.fillColor;
  15778. this.strokeColor = '#000000';
  15779. this.fillAlpha = 1;
  15780. this.strokeAlpha = 1;
  15781. this.lineWidth = 1;
  15782. this.lineJoin = '';
  15783. this.lineCap = '';
  15784. this.miterLimit = 0;
  15785. this.dashArray = [];
  15786. this.dashPhase = 0;
  15787. this.dependencies = [];
  15788. this.activeClipUrl = null;
  15789. this.clipGroup = null;
  15790. this.maskId = '';
  15791. }
  15792. SVGExtraState.prototype = {
  15793. clone: function SVGExtraState_clone() {
  15794. return Object.create(this);
  15795. },
  15796. setCurrentPoint: function SVGExtraState_setCurrentPoint(x, y) {
  15797. this.x = x;
  15798. this.y = y;
  15799. }
  15800. };
  15801. return SVGExtraState;
  15802. }();
  15803. exports.SVGGraphics = SVGGraphics = function SVGGraphicsClosure() {
  15804. function opListToTree(opList) {
  15805. var opTree = [];
  15806. var tmp = [];
  15807. var opListLen = opList.length;
  15808. for (var x = 0; x < opListLen; x++) {
  15809. if (opList[x].fn === 'save') {
  15810. opTree.push({
  15811. 'fnId': 92,
  15812. 'fn': 'group',
  15813. 'items': []
  15814. });
  15815. tmp.push(opTree);
  15816. opTree = opTree[opTree.length - 1].items;
  15817. continue;
  15818. }
  15819. if (opList[x].fn === 'restore') {
  15820. opTree = tmp.pop();
  15821. } else {
  15822. opTree.push(opList[x]);
  15823. }
  15824. }
  15825. return opTree;
  15826. }
  15827. function pf(value) {
  15828. if (Number.isInteger(value)) {
  15829. return value.toString();
  15830. }
  15831. var s = value.toFixed(10);
  15832. var i = s.length - 1;
  15833. if (s[i] !== '0') {
  15834. return s;
  15835. }
  15836. do {
  15837. i--;
  15838. } while (s[i] === '0');
  15839. return s.substring(0, s[i] === '.' ? i : i + 1);
  15840. }
  15841. function pm(m) {
  15842. if (m[4] === 0 && m[5] === 0) {
  15843. if (m[1] === 0 && m[2] === 0) {
  15844. if (m[0] === 1 && m[3] === 1) {
  15845. return '';
  15846. }
  15847. return 'scale(' + pf(m[0]) + ' ' + pf(m[3]) + ')';
  15848. }
  15849. if (m[0] === m[3] && m[1] === -m[2]) {
  15850. var a = Math.acos(m[0]) * 180 / Math.PI;
  15851. return 'rotate(' + pf(a) + ')';
  15852. }
  15853. } else {
  15854. if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
  15855. return 'translate(' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  15856. }
  15857. }
  15858. return 'matrix(' + pf(m[0]) + ' ' + pf(m[1]) + ' ' + pf(m[2]) + ' ' + pf(m[3]) + ' ' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  15859. }
  15860. function SVGGraphics(commonObjs, objs, forceDataSchema) {
  15861. this.svgFactory = new _dom_utils.DOMSVGFactory();
  15862. this.current = new SVGExtraState();
  15863. this.transformMatrix = _util.IDENTITY_MATRIX;
  15864. this.transformStack = [];
  15865. this.extraStack = [];
  15866. this.commonObjs = commonObjs;
  15867. this.objs = objs;
  15868. this.pendingClip = null;
  15869. this.pendingEOFill = false;
  15870. this.embedFonts = false;
  15871. this.embeddedFonts = Object.create(null);
  15872. this.cssStyle = null;
  15873. this.forceDataSchema = !!forceDataSchema;
  15874. }
  15875. var XML_NS = 'http://www.w3.org/XML/1998/namespace';
  15876. var XLINK_NS = 'http://www.w3.org/1999/xlink';
  15877. var LINE_CAP_STYLES = ['butt', 'round', 'square'];
  15878. var LINE_JOIN_STYLES = ['miter', 'round', 'bevel'];
  15879. var clipCount = 0;
  15880. var maskCount = 0;
  15881. SVGGraphics.prototype = {
  15882. save: function SVGGraphics_save() {
  15883. this.transformStack.push(this.transformMatrix);
  15884. var old = this.current;
  15885. this.extraStack.push(old);
  15886. this.current = old.clone();
  15887. },
  15888. restore: function SVGGraphics_restore() {
  15889. this.transformMatrix = this.transformStack.pop();
  15890. this.current = this.extraStack.pop();
  15891. this.pendingClip = null;
  15892. this.tgrp = null;
  15893. },
  15894. group: function SVGGraphics_group(items) {
  15895. this.save();
  15896. this.executeOpTree(items);
  15897. this.restore();
  15898. },
  15899. loadDependencies: function SVGGraphics_loadDependencies(operatorList) {
  15900. var _this = this;
  15901. var fnArray = operatorList.fnArray;
  15902. var fnArrayLen = fnArray.length;
  15903. var argsArray = operatorList.argsArray;
  15904. for (var i = 0; i < fnArrayLen; i++) {
  15905. if (_util.OPS.dependency === fnArray[i]) {
  15906. var deps = argsArray[i];
  15907. for (var n = 0, nn = deps.length; n < nn; n++) {
  15908. var obj = deps[n];
  15909. var common = obj.substring(0, 2) === 'g_';
  15910. var promise;
  15911. if (common) {
  15912. promise = new Promise(function (resolve) {
  15913. _this.commonObjs.get(obj, resolve);
  15914. });
  15915. } else {
  15916. promise = new Promise(function (resolve) {
  15917. _this.objs.get(obj, resolve);
  15918. });
  15919. }
  15920. this.current.dependencies.push(promise);
  15921. }
  15922. }
  15923. }
  15924. return Promise.all(this.current.dependencies);
  15925. },
  15926. transform: function SVGGraphics_transform(a, b, c, d, e, f) {
  15927. var transformMatrix = [a, b, c, d, e, f];
  15928. this.transformMatrix = _util.Util.transform(this.transformMatrix, transformMatrix);
  15929. this.tgrp = null;
  15930. },
  15931. getSVG: function SVGGraphics_getSVG(operatorList, viewport) {
  15932. var _this2 = this;
  15933. this.viewport = viewport;
  15934. var svgElement = this._initialize(viewport);
  15935. return this.loadDependencies(operatorList).then(function () {
  15936. _this2.transformMatrix = _util.IDENTITY_MATRIX;
  15937. var opTree = _this2.convertOpList(operatorList);
  15938. _this2.executeOpTree(opTree);
  15939. return svgElement;
  15940. });
  15941. },
  15942. convertOpList: function SVGGraphics_convertOpList(operatorList) {
  15943. var argsArray = operatorList.argsArray;
  15944. var fnArray = operatorList.fnArray;
  15945. var fnArrayLen = fnArray.length;
  15946. var REVOPS = [];
  15947. var opList = [];
  15948. for (var op in _util.OPS) {
  15949. REVOPS[_util.OPS[op]] = op;
  15950. }
  15951. for (var x = 0; x < fnArrayLen; x++) {
  15952. var fnId = fnArray[x];
  15953. opList.push({
  15954. 'fnId': fnId,
  15955. 'fn': REVOPS[fnId],
  15956. 'args': argsArray[x]
  15957. });
  15958. }
  15959. return opListToTree(opList);
  15960. },
  15961. executeOpTree: function SVGGraphics_executeOpTree(opTree) {
  15962. var opTreeLen = opTree.length;
  15963. for (var x = 0; x < opTreeLen; x++) {
  15964. var fn = opTree[x].fn;
  15965. var fnId = opTree[x].fnId;
  15966. var args = opTree[x].args;
  15967. switch (fnId | 0) {
  15968. case _util.OPS.beginText:
  15969. this.beginText();
  15970. break;
  15971. case _util.OPS.dependency:
  15972. break;
  15973. case _util.OPS.setLeading:
  15974. this.setLeading(args);
  15975. break;
  15976. case _util.OPS.setLeadingMoveText:
  15977. this.setLeadingMoveText(args[0], args[1]);
  15978. break;
  15979. case _util.OPS.setFont:
  15980. this.setFont(args);
  15981. break;
  15982. case _util.OPS.showText:
  15983. this.showText(args[0]);
  15984. break;
  15985. case _util.OPS.showSpacedText:
  15986. this.showText(args[0]);
  15987. break;
  15988. case _util.OPS.endText:
  15989. this.endText();
  15990. break;
  15991. case _util.OPS.moveText:
  15992. this.moveText(args[0], args[1]);
  15993. break;
  15994. case _util.OPS.setCharSpacing:
  15995. this.setCharSpacing(args[0]);
  15996. break;
  15997. case _util.OPS.setWordSpacing:
  15998. this.setWordSpacing(args[0]);
  15999. break;
  16000. case _util.OPS.setHScale:
  16001. this.setHScale(args[0]);
  16002. break;
  16003. case _util.OPS.setTextMatrix:
  16004. this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  16005. break;
  16006. case _util.OPS.setTextRise:
  16007. this.setTextRise(args[0]);
  16008. break;
  16009. case _util.OPS.setTextRenderingMode:
  16010. this.setTextRenderingMode(args[0]);
  16011. break;
  16012. case _util.OPS.setLineWidth:
  16013. this.setLineWidth(args[0]);
  16014. break;
  16015. case _util.OPS.setLineJoin:
  16016. this.setLineJoin(args[0]);
  16017. break;
  16018. case _util.OPS.setLineCap:
  16019. this.setLineCap(args[0]);
  16020. break;
  16021. case _util.OPS.setMiterLimit:
  16022. this.setMiterLimit(args[0]);
  16023. break;
  16024. case _util.OPS.setFillRGBColor:
  16025. this.setFillRGBColor(args[0], args[1], args[2]);
  16026. break;
  16027. case _util.OPS.setStrokeRGBColor:
  16028. this.setStrokeRGBColor(args[0], args[1], args[2]);
  16029. break;
  16030. case _util.OPS.setDash:
  16031. this.setDash(args[0], args[1]);
  16032. break;
  16033. case _util.OPS.setGState:
  16034. this.setGState(args[0]);
  16035. break;
  16036. case _util.OPS.fill:
  16037. this.fill();
  16038. break;
  16039. case _util.OPS.eoFill:
  16040. this.eoFill();
  16041. break;
  16042. case _util.OPS.stroke:
  16043. this.stroke();
  16044. break;
  16045. case _util.OPS.fillStroke:
  16046. this.fillStroke();
  16047. break;
  16048. case _util.OPS.eoFillStroke:
  16049. this.eoFillStroke();
  16050. break;
  16051. case _util.OPS.clip:
  16052. this.clip('nonzero');
  16053. break;
  16054. case _util.OPS.eoClip:
  16055. this.clip('evenodd');
  16056. break;
  16057. case _util.OPS.paintSolidColorImageMask:
  16058. this.paintSolidColorImageMask();
  16059. break;
  16060. case _util.OPS.paintJpegXObject:
  16061. this.paintJpegXObject(args[0], args[1], args[2]);
  16062. break;
  16063. case _util.OPS.paintImageXObject:
  16064. this.paintImageXObject(args[0]);
  16065. break;
  16066. case _util.OPS.paintInlineImageXObject:
  16067. this.paintInlineImageXObject(args[0]);
  16068. break;
  16069. case _util.OPS.paintImageMaskXObject:
  16070. this.paintImageMaskXObject(args[0]);
  16071. break;
  16072. case _util.OPS.paintFormXObjectBegin:
  16073. this.paintFormXObjectBegin(args[0], args[1]);
  16074. break;
  16075. case _util.OPS.paintFormXObjectEnd:
  16076. this.paintFormXObjectEnd();
  16077. break;
  16078. case _util.OPS.closePath:
  16079. this.closePath();
  16080. break;
  16081. case _util.OPS.closeStroke:
  16082. this.closeStroke();
  16083. break;
  16084. case _util.OPS.closeFillStroke:
  16085. this.closeFillStroke();
  16086. break;
  16087. case _util.OPS.closeEOFillStroke:
  16088. this.closeEOFillStroke();
  16089. break;
  16090. case _util.OPS.nextLine:
  16091. this.nextLine();
  16092. break;
  16093. case _util.OPS.transform:
  16094. this.transform(args[0], args[1], args[2], args[3], args[4], args[5]);
  16095. break;
  16096. case _util.OPS.constructPath:
  16097. this.constructPath(args[0], args[1]);
  16098. break;
  16099. case _util.OPS.endPath:
  16100. this.endPath();
  16101. break;
  16102. case 92:
  16103. this.group(opTree[x].items);
  16104. break;
  16105. default:
  16106. (0, _util.warn)('Unimplemented operator ' + fn);
  16107. break;
  16108. }
  16109. }
  16110. },
  16111. setWordSpacing: function SVGGraphics_setWordSpacing(wordSpacing) {
  16112. this.current.wordSpacing = wordSpacing;
  16113. },
  16114. setCharSpacing: function SVGGraphics_setCharSpacing(charSpacing) {
  16115. this.current.charSpacing = charSpacing;
  16116. },
  16117. nextLine: function SVGGraphics_nextLine() {
  16118. this.moveText(0, this.current.leading);
  16119. },
  16120. setTextMatrix: function SVGGraphics_setTextMatrix(a, b, c, d, e, f) {
  16121. var current = this.current;
  16122. this.current.textMatrix = this.current.lineMatrix = [a, b, c, d, e, f];
  16123. this.current.x = this.current.lineX = 0;
  16124. this.current.y = this.current.lineY = 0;
  16125. current.xcoords = [];
  16126. current.tspan = this.svgFactory.createElement('svg:tspan');
  16127. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  16128. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  16129. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  16130. current.txtElement = this.svgFactory.createElement('svg:text');
  16131. current.txtElement.appendChild(current.tspan);
  16132. },
  16133. beginText: function SVGGraphics_beginText() {
  16134. this.current.x = this.current.lineX = 0;
  16135. this.current.y = this.current.lineY = 0;
  16136. this.current.textMatrix = _util.IDENTITY_MATRIX;
  16137. this.current.lineMatrix = _util.IDENTITY_MATRIX;
  16138. this.current.tspan = this.svgFactory.createElement('svg:tspan');
  16139. this.current.txtElement = this.svgFactory.createElement('svg:text');
  16140. this.current.txtgrp = this.svgFactory.createElement('svg:g');
  16141. this.current.xcoords = [];
  16142. },
  16143. moveText: function SVGGraphics_moveText(x, y) {
  16144. var current = this.current;
  16145. this.current.x = this.current.lineX += x;
  16146. this.current.y = this.current.lineY += y;
  16147. current.xcoords = [];
  16148. current.tspan = this.svgFactory.createElement('svg:tspan');
  16149. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  16150. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  16151. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  16152. },
  16153. showText: function SVGGraphics_showText(glyphs) {
  16154. var current = this.current;
  16155. var font = current.font;
  16156. var fontSize = current.fontSize;
  16157. if (fontSize === 0) {
  16158. return;
  16159. }
  16160. var charSpacing = current.charSpacing;
  16161. var wordSpacing = current.wordSpacing;
  16162. var fontDirection = current.fontDirection;
  16163. var textHScale = current.textHScale * fontDirection;
  16164. var glyphsLength = glyphs.length;
  16165. var vertical = font.vertical;
  16166. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  16167. var x = 0,
  16168. i;
  16169. for (i = 0; i < glyphsLength; ++i) {
  16170. var glyph = glyphs[i];
  16171. if (glyph === null) {
  16172. x += fontDirection * wordSpacing;
  16173. continue;
  16174. } else if ((0, _util.isNum)(glyph)) {
  16175. x += -glyph * fontSize * 0.001;
  16176. continue;
  16177. }
  16178. var width = glyph.width;
  16179. var character = glyph.fontChar;
  16180. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  16181. var charWidth = width * widthAdvanceScale + spacing * fontDirection;
  16182. if (!glyph.isInFont && !font.missingFile) {
  16183. x += charWidth;
  16184. continue;
  16185. }
  16186. current.xcoords.push(current.x + x * textHScale);
  16187. current.tspan.textContent += character;
  16188. x += charWidth;
  16189. }
  16190. if (vertical) {
  16191. current.y -= x * textHScale;
  16192. } else {
  16193. current.x += x * textHScale;
  16194. }
  16195. current.tspan.setAttributeNS(null, 'x', current.xcoords.map(pf).join(' '));
  16196. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  16197. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  16198. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  16199. if (current.fontStyle !== SVG_DEFAULTS.fontStyle) {
  16200. current.tspan.setAttributeNS(null, 'font-style', current.fontStyle);
  16201. }
  16202. if (current.fontWeight !== SVG_DEFAULTS.fontWeight) {
  16203. current.tspan.setAttributeNS(null, 'font-weight', current.fontWeight);
  16204. }
  16205. var fillStrokeMode = current.textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
  16206. if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  16207. if (current.fillColor !== SVG_DEFAULTS.fillColor) {
  16208. current.tspan.setAttributeNS(null, 'fill', current.fillColor);
  16209. }
  16210. if (current.fillAlpha < 1) {
  16211. current.tspan.setAttributeNS(null, 'fill-opacity', current.fillAlpha);
  16212. }
  16213. } else if (current.textRenderingMode === _util.TextRenderingMode.ADD_TO_PATH) {
  16214. current.tspan.setAttributeNS(null, 'fill', 'transparent');
  16215. } else {
  16216. current.tspan.setAttributeNS(null, 'fill', 'none');
  16217. }
  16218. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  16219. this._setStrokeAttributes(current.tspan);
  16220. }
  16221. var textMatrix = current.textMatrix;
  16222. if (current.textRise !== 0) {
  16223. textMatrix = textMatrix.slice();
  16224. textMatrix[5] += current.textRise;
  16225. }
  16226. current.txtElement.setAttributeNS(null, 'transform', pm(textMatrix) + ' scale(1, -1)');
  16227. current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve');
  16228. current.txtElement.appendChild(current.tspan);
  16229. current.txtgrp.appendChild(current.txtElement);
  16230. this._ensureTransformGroup().appendChild(current.txtElement);
  16231. },
  16232. setLeadingMoveText: function SVGGraphics_setLeadingMoveText(x, y) {
  16233. this.setLeading(-y);
  16234. this.moveText(x, y);
  16235. },
  16236. addFontStyle: function SVGGraphics_addFontStyle(fontObj) {
  16237. if (!this.cssStyle) {
  16238. this.cssStyle = this.svgFactory.createElement('svg:style');
  16239. this.cssStyle.setAttributeNS(null, 'type', 'text/css');
  16240. this.defs.appendChild(this.cssStyle);
  16241. }
  16242. var url = (0, _util.createObjectURL)(fontObj.data, fontObj.mimetype, this.forceDataSchema);
  16243. this.cssStyle.textContent += '@font-face { font-family: "' + fontObj.loadedName + '";' + ' src: url(' + url + '); }\n';
  16244. },
  16245. setFont: function SVGGraphics_setFont(details) {
  16246. var current = this.current;
  16247. var fontObj = this.commonObjs.get(details[0]);
  16248. var size = details[1];
  16249. this.current.font = fontObj;
  16250. if (this.embedFonts && fontObj.data && !this.embeddedFonts[fontObj.loadedName]) {
  16251. this.addFontStyle(fontObj);
  16252. this.embeddedFonts[fontObj.loadedName] = fontObj;
  16253. }
  16254. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : _util.FONT_IDENTITY_MATRIX;
  16255. var bold = fontObj.black ? fontObj.bold ? 'bolder' : 'bold' : fontObj.bold ? 'bold' : 'normal';
  16256. var italic = fontObj.italic ? 'italic' : 'normal';
  16257. if (size < 0) {
  16258. size = -size;
  16259. current.fontDirection = -1;
  16260. } else {
  16261. current.fontDirection = 1;
  16262. }
  16263. current.fontSize = size;
  16264. current.fontFamily = fontObj.loadedName;
  16265. current.fontWeight = bold;
  16266. current.fontStyle = italic;
  16267. current.tspan = this.svgFactory.createElement('svg:tspan');
  16268. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  16269. current.xcoords = [];
  16270. },
  16271. endText: function endText() {
  16272. var current = this.current;
  16273. if (current.textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG && current.txtElement && current.txtElement.hasChildNodes()) {
  16274. current.element = current.txtElement;
  16275. this.clip('nonzero');
  16276. this.endPath();
  16277. }
  16278. },
  16279. setLineWidth: function SVGGraphics_setLineWidth(width) {
  16280. this.current.lineWidth = width;
  16281. },
  16282. setLineCap: function SVGGraphics_setLineCap(style) {
  16283. this.current.lineCap = LINE_CAP_STYLES[style];
  16284. },
  16285. setLineJoin: function SVGGraphics_setLineJoin(style) {
  16286. this.current.lineJoin = LINE_JOIN_STYLES[style];
  16287. },
  16288. setMiterLimit: function SVGGraphics_setMiterLimit(limit) {
  16289. this.current.miterLimit = limit;
  16290. },
  16291. setStrokeAlpha: function SVGGraphics_setStrokeAlpha(strokeAlpha) {
  16292. this.current.strokeAlpha = strokeAlpha;
  16293. },
  16294. setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) {
  16295. var color = _util.Util.makeCssRgb(r, g, b);
  16296. this.current.strokeColor = color;
  16297. },
  16298. setFillAlpha: function SVGGraphics_setFillAlpha(fillAlpha) {
  16299. this.current.fillAlpha = fillAlpha;
  16300. },
  16301. setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) {
  16302. var color = _util.Util.makeCssRgb(r, g, b);
  16303. this.current.fillColor = color;
  16304. this.current.tspan = this.svgFactory.createElement('svg:tspan');
  16305. this.current.xcoords = [];
  16306. },
  16307. setDash: function SVGGraphics_setDash(dashArray, dashPhase) {
  16308. this.current.dashArray = dashArray;
  16309. this.current.dashPhase = dashPhase;
  16310. },
  16311. constructPath: function SVGGraphics_constructPath(ops, args) {
  16312. var current = this.current;
  16313. var x = current.x,
  16314. y = current.y;
  16315. current.path = this.svgFactory.createElement('svg:path');
  16316. var d = [];
  16317. var opLength = ops.length;
  16318. for (var i = 0, j = 0; i < opLength; i++) {
  16319. switch (ops[i] | 0) {
  16320. case _util.OPS.rectangle:
  16321. x = args[j++];
  16322. y = args[j++];
  16323. var width = args[j++];
  16324. var height = args[j++];
  16325. var xw = x + width;
  16326. var yh = y + height;
  16327. d.push('M', pf(x), pf(y), 'L', pf(xw), pf(y), 'L', pf(xw), pf(yh), 'L', pf(x), pf(yh), 'Z');
  16328. break;
  16329. case _util.OPS.moveTo:
  16330. x = args[j++];
  16331. y = args[j++];
  16332. d.push('M', pf(x), pf(y));
  16333. break;
  16334. case _util.OPS.lineTo:
  16335. x = args[j++];
  16336. y = args[j++];
  16337. d.push('L', pf(x), pf(y));
  16338. break;
  16339. case _util.OPS.curveTo:
  16340. x = args[j + 4];
  16341. y = args[j + 5];
  16342. d.push('C', pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y));
  16343. j += 6;
  16344. break;
  16345. case _util.OPS.curveTo2:
  16346. x = args[j + 2];
  16347. y = args[j + 3];
  16348. d.push('C', pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]));
  16349. j += 4;
  16350. break;
  16351. case _util.OPS.curveTo3:
  16352. x = args[j + 2];
  16353. y = args[j + 3];
  16354. d.push('C', pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y));
  16355. j += 4;
  16356. break;
  16357. case _util.OPS.closePath:
  16358. d.push('Z');
  16359. break;
  16360. }
  16361. }
  16362. current.path.setAttributeNS(null, 'd', d.join(' '));
  16363. current.path.setAttributeNS(null, 'fill', 'none');
  16364. this._ensureTransformGroup().appendChild(current.path);
  16365. current.element = current.path;
  16366. current.setCurrentPoint(x, y);
  16367. },
  16368. endPath: function SVGGraphics_endPath() {
  16369. if (!this.pendingClip) {
  16370. return;
  16371. }
  16372. var current = this.current;
  16373. var clipId = 'clippath' + clipCount;
  16374. clipCount++;
  16375. var clipPath = this.svgFactory.createElement('svg:clipPath');
  16376. clipPath.setAttributeNS(null, 'id', clipId);
  16377. clipPath.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  16378. var clipElement = current.element.cloneNode(true);
  16379. if (this.pendingClip === 'evenodd') {
  16380. clipElement.setAttributeNS(null, 'clip-rule', 'evenodd');
  16381. } else {
  16382. clipElement.setAttributeNS(null, 'clip-rule', 'nonzero');
  16383. }
  16384. this.pendingClip = null;
  16385. clipPath.appendChild(clipElement);
  16386. this.defs.appendChild(clipPath);
  16387. if (current.activeClipUrl) {
  16388. current.clipGroup = null;
  16389. this.extraStack.forEach(function (prev) {
  16390. prev.clipGroup = null;
  16391. });
  16392. clipPath.setAttributeNS(null, 'clip-path', current.activeClipUrl);
  16393. }
  16394. current.activeClipUrl = 'url(#' + clipId + ')';
  16395. this.tgrp = null;
  16396. },
  16397. clip: function SVGGraphics_clip(type) {
  16398. this.pendingClip = type;
  16399. },
  16400. closePath: function SVGGraphics_closePath() {
  16401. var current = this.current;
  16402. if (current.path) {
  16403. var d = current.path.getAttributeNS(null, 'd');
  16404. d += 'Z';
  16405. current.path.setAttributeNS(null, 'd', d);
  16406. }
  16407. },
  16408. setLeading: function SVGGraphics_setLeading(leading) {
  16409. this.current.leading = -leading;
  16410. },
  16411. setTextRise: function SVGGraphics_setTextRise(textRise) {
  16412. this.current.textRise = textRise;
  16413. },
  16414. setTextRenderingMode: function setTextRenderingMode(textRenderingMode) {
  16415. this.current.textRenderingMode = textRenderingMode;
  16416. },
  16417. setHScale: function SVGGraphics_setHScale(scale) {
  16418. this.current.textHScale = scale / 100;
  16419. },
  16420. setGState: function SVGGraphics_setGState(states) {
  16421. for (var i = 0, ii = states.length; i < ii; i++) {
  16422. var state = states[i];
  16423. var key = state[0];
  16424. var value = state[1];
  16425. switch (key) {
  16426. case 'LW':
  16427. this.setLineWidth(value);
  16428. break;
  16429. case 'LC':
  16430. this.setLineCap(value);
  16431. break;
  16432. case 'LJ':
  16433. this.setLineJoin(value);
  16434. break;
  16435. case 'ML':
  16436. this.setMiterLimit(value);
  16437. break;
  16438. case 'D':
  16439. this.setDash(value[0], value[1]);
  16440. break;
  16441. case 'Font':
  16442. this.setFont(value);
  16443. break;
  16444. case 'CA':
  16445. this.setStrokeAlpha(value);
  16446. break;
  16447. case 'ca':
  16448. this.setFillAlpha(value);
  16449. break;
  16450. default:
  16451. (0, _util.warn)('Unimplemented graphic state ' + key);
  16452. break;
  16453. }
  16454. }
  16455. },
  16456. fill: function SVGGraphics_fill() {
  16457. var current = this.current;
  16458. if (current.element) {
  16459. current.element.setAttributeNS(null, 'fill', current.fillColor);
  16460. current.element.setAttributeNS(null, 'fill-opacity', current.fillAlpha);
  16461. this.endPath();
  16462. }
  16463. },
  16464. stroke: function SVGGraphics_stroke() {
  16465. var current = this.current;
  16466. if (current.element) {
  16467. this._setStrokeAttributes(current.element);
  16468. current.element.setAttributeNS(null, 'fill', 'none');
  16469. this.endPath();
  16470. }
  16471. },
  16472. _setStrokeAttributes: function _setStrokeAttributes(element) {
  16473. var current = this.current;
  16474. element.setAttributeNS(null, 'stroke', current.strokeColor);
  16475. element.setAttributeNS(null, 'stroke-opacity', current.strokeAlpha);
  16476. element.setAttributeNS(null, 'stroke-miterlimit', pf(current.miterLimit));
  16477. element.setAttributeNS(null, 'stroke-linecap', current.lineCap);
  16478. element.setAttributeNS(null, 'stroke-linejoin', current.lineJoin);
  16479. element.setAttributeNS(null, 'stroke-width', pf(current.lineWidth) + 'px');
  16480. element.setAttributeNS(null, 'stroke-dasharray', current.dashArray.map(pf).join(' '));
  16481. element.setAttributeNS(null, 'stroke-dashoffset', pf(current.dashPhase) + 'px');
  16482. },
  16483. eoFill: function SVGGraphics_eoFill() {
  16484. if (this.current.element) {
  16485. this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  16486. }
  16487. this.fill();
  16488. },
  16489. fillStroke: function SVGGraphics_fillStroke() {
  16490. this.stroke();
  16491. this.fill();
  16492. },
  16493. eoFillStroke: function SVGGraphics_eoFillStroke() {
  16494. if (this.current.element) {
  16495. this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  16496. }
  16497. this.fillStroke();
  16498. },
  16499. closeStroke: function SVGGraphics_closeStroke() {
  16500. this.closePath();
  16501. this.stroke();
  16502. },
  16503. closeFillStroke: function SVGGraphics_closeFillStroke() {
  16504. this.closePath();
  16505. this.fillStroke();
  16506. },
  16507. closeEOFillStroke: function closeEOFillStroke() {
  16508. this.closePath();
  16509. this.eoFillStroke();
  16510. },
  16511. paintSolidColorImageMask: function SVGGraphics_paintSolidColorImageMask() {
  16512. var current = this.current;
  16513. var rect = this.svgFactory.createElement('svg:rect');
  16514. rect.setAttributeNS(null, 'x', '0');
  16515. rect.setAttributeNS(null, 'y', '0');
  16516. rect.setAttributeNS(null, 'width', '1px');
  16517. rect.setAttributeNS(null, 'height', '1px');
  16518. rect.setAttributeNS(null, 'fill', current.fillColor);
  16519. this._ensureTransformGroup().appendChild(rect);
  16520. },
  16521. paintJpegXObject: function SVGGraphics_paintJpegXObject(objId, w, h) {
  16522. var imgObj = this.objs.get(objId);
  16523. var imgEl = this.svgFactory.createElement('svg:image');
  16524. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgObj.src);
  16525. imgEl.setAttributeNS(null, 'width', pf(w));
  16526. imgEl.setAttributeNS(null, 'height', pf(h));
  16527. imgEl.setAttributeNS(null, 'x', '0');
  16528. imgEl.setAttributeNS(null, 'y', pf(-h));
  16529. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / w) + ' ' + pf(-1 / h) + ')');
  16530. this._ensureTransformGroup().appendChild(imgEl);
  16531. },
  16532. paintImageXObject: function SVGGraphics_paintImageXObject(objId) {
  16533. var imgData = this.objs.get(objId);
  16534. if (!imgData) {
  16535. (0, _util.warn)('Dependent image isn\'t ready yet');
  16536. return;
  16537. }
  16538. this.paintInlineImageXObject(imgData);
  16539. },
  16540. paintInlineImageXObject: function SVGGraphics_paintInlineImageXObject(imgData, mask) {
  16541. var width = imgData.width;
  16542. var height = imgData.height;
  16543. var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema, !!mask);
  16544. var cliprect = this.svgFactory.createElement('svg:rect');
  16545. cliprect.setAttributeNS(null, 'x', '0');
  16546. cliprect.setAttributeNS(null, 'y', '0');
  16547. cliprect.setAttributeNS(null, 'width', pf(width));
  16548. cliprect.setAttributeNS(null, 'height', pf(height));
  16549. this.current.element = cliprect;
  16550. this.clip('nonzero');
  16551. var imgEl = this.svgFactory.createElement('svg:image');
  16552. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgSrc);
  16553. imgEl.setAttributeNS(null, 'x', '0');
  16554. imgEl.setAttributeNS(null, 'y', pf(-height));
  16555. imgEl.setAttributeNS(null, 'width', pf(width) + 'px');
  16556. imgEl.setAttributeNS(null, 'height', pf(height) + 'px');
  16557. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / width) + ' ' + pf(-1 / height) + ')');
  16558. if (mask) {
  16559. mask.appendChild(imgEl);
  16560. } else {
  16561. this._ensureTransformGroup().appendChild(imgEl);
  16562. }
  16563. },
  16564. paintImageMaskXObject: function SVGGraphics_paintImageMaskXObject(imgData) {
  16565. var current = this.current;
  16566. var width = imgData.width;
  16567. var height = imgData.height;
  16568. var fillColor = current.fillColor;
  16569. current.maskId = 'mask' + maskCount++;
  16570. var mask = this.svgFactory.createElement('svg:mask');
  16571. mask.setAttributeNS(null, 'id', current.maskId);
  16572. var rect = this.svgFactory.createElement('svg:rect');
  16573. rect.setAttributeNS(null, 'x', '0');
  16574. rect.setAttributeNS(null, 'y', '0');
  16575. rect.setAttributeNS(null, 'width', pf(width));
  16576. rect.setAttributeNS(null, 'height', pf(height));
  16577. rect.setAttributeNS(null, 'fill', fillColor);
  16578. rect.setAttributeNS(null, 'mask', 'url(#' + current.maskId + ')');
  16579. this.defs.appendChild(mask);
  16580. this._ensureTransformGroup().appendChild(rect);
  16581. this.paintInlineImageXObject(imgData, mask);
  16582. },
  16583. paintFormXObjectBegin: function SVGGraphics_paintFormXObjectBegin(matrix, bbox) {
  16584. if (Array.isArray(matrix) && matrix.length === 6) {
  16585. this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
  16586. }
  16587. if (Array.isArray(bbox) && bbox.length === 4) {
  16588. var width = bbox[2] - bbox[0];
  16589. var height = bbox[3] - bbox[1];
  16590. var cliprect = this.svgFactory.createElement('svg:rect');
  16591. cliprect.setAttributeNS(null, 'x', bbox[0]);
  16592. cliprect.setAttributeNS(null, 'y', bbox[1]);
  16593. cliprect.setAttributeNS(null, 'width', pf(width));
  16594. cliprect.setAttributeNS(null, 'height', pf(height));
  16595. this.current.element = cliprect;
  16596. this.clip('nonzero');
  16597. this.endPath();
  16598. }
  16599. },
  16600. paintFormXObjectEnd: function SVGGraphics_paintFormXObjectEnd() {},
  16601. _initialize: function _initialize(viewport) {
  16602. var svg = this.svgFactory.create(viewport.width, viewport.height);
  16603. var definitions = this.svgFactory.createElement('svg:defs');
  16604. svg.appendChild(definitions);
  16605. this.defs = definitions;
  16606. var rootGroup = this.svgFactory.createElement('svg:g');
  16607. rootGroup.setAttributeNS(null, 'transform', pm(viewport.transform));
  16608. svg.appendChild(rootGroup);
  16609. this.svg = rootGroup;
  16610. return svg;
  16611. },
  16612. _ensureClipGroup: function SVGGraphics_ensureClipGroup() {
  16613. if (!this.current.clipGroup) {
  16614. var clipGroup = this.svgFactory.createElement('svg:g');
  16615. clipGroup.setAttributeNS(null, 'clip-path', this.current.activeClipUrl);
  16616. this.svg.appendChild(clipGroup);
  16617. this.current.clipGroup = clipGroup;
  16618. }
  16619. return this.current.clipGroup;
  16620. },
  16621. _ensureTransformGroup: function SVGGraphics_ensureTransformGroup() {
  16622. if (!this.tgrp) {
  16623. this.tgrp = this.svgFactory.createElement('svg:g');
  16624. this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  16625. if (this.current.activeClipUrl) {
  16626. this._ensureClipGroup().appendChild(this.tgrp);
  16627. } else {
  16628. this.svg.appendChild(this.tgrp);
  16629. }
  16630. }
  16631. return this.tgrp;
  16632. }
  16633. };
  16634. return SVGGraphics;
  16635. }();
  16636. }
  16637. exports.SVGGraphics = SVGGraphics;
  16638. /***/ }),
  16639. /* 148 */
  16640. /***/ (function(module, exports, __w_pdfjs_require__) {
  16641. "use strict";
  16642. Object.defineProperty(exports, "__esModule", {
  16643. value: true
  16644. });
  16645. exports.PDFNodeStream = undefined;
  16646. var _regenerator = __w_pdfjs_require__(137);
  16647. var _regenerator2 = _interopRequireDefault(_regenerator);
  16648. 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; }; }();
  16649. var _util = __w_pdfjs_require__(1);
  16650. var _network_utils = __w_pdfjs_require__(149);
  16651. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  16652. 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; }
  16653. 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; }
  16654. function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
  16655. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  16656. var fs = require('fs');
  16657. var http = require('http');
  16658. var https = require('https');
  16659. var url = require('url');
  16660. var fileUriRegex = /^file:\/\/\/[a-zA-Z]:\//;
  16661. function parseUrl(sourceUrl) {
  16662. var parsedUrl = url.parse(sourceUrl);
  16663. if (parsedUrl.protocol === 'file:' || parsedUrl.host) {
  16664. return parsedUrl;
  16665. }
  16666. if (/^[a-z]:[/\\]/i.test(sourceUrl)) {
  16667. return url.parse('file:///' + sourceUrl);
  16668. }
  16669. if (!parsedUrl.host) {
  16670. parsedUrl.protocol = 'file:';
  16671. }
  16672. return parsedUrl;
  16673. }
  16674. var PDFNodeStream = function () {
  16675. function PDFNodeStream(source) {
  16676. _classCallCheck(this, PDFNodeStream);
  16677. this.source = source;
  16678. this.url = parseUrl(source.url);
  16679. this.isHttp = this.url.protocol === 'http:' || this.url.protocol === 'https:';
  16680. this.isFsUrl = this.url.protocol === 'file:';
  16681. this.httpHeaders = this.isHttp && source.httpHeaders || {};
  16682. this._fullRequest = null;
  16683. this._rangeRequestReaders = [];
  16684. }
  16685. _createClass(PDFNodeStream, [{
  16686. key: 'getFullReader',
  16687. value: function getFullReader() {
  16688. (0, _util.assert)(!this._fullRequest);
  16689. this._fullRequest = this.isFsUrl ? new PDFNodeStreamFsFullReader(this) : new PDFNodeStreamFullReader(this);
  16690. return this._fullRequest;
  16691. }
  16692. }, {
  16693. key: 'getRangeReader',
  16694. value: function getRangeReader(start, end) {
  16695. var rangeReader = this.isFsUrl ? new PDFNodeStreamFsRangeReader(this, start, end) : new PDFNodeStreamRangeReader(this, start, end);
  16696. this._rangeRequestReaders.push(rangeReader);
  16697. return rangeReader;
  16698. }
  16699. }, {
  16700. key: 'cancelAllRequests',
  16701. value: function cancelAllRequests(reason) {
  16702. if (this._fullRequest) {
  16703. this._fullRequest.cancel(reason);
  16704. }
  16705. var readers = this._rangeRequestReaders.slice(0);
  16706. readers.forEach(function (reader) {
  16707. reader.cancel(reason);
  16708. });
  16709. }
  16710. }]);
  16711. return PDFNodeStream;
  16712. }();
  16713. var BaseFullReader = function () {
  16714. function BaseFullReader(stream) {
  16715. _classCallCheck(this, BaseFullReader);
  16716. this._url = stream.url;
  16717. this._done = false;
  16718. this._storedError = null;
  16719. this.onProgress = null;
  16720. var source = stream.source;
  16721. this._contentLength = source.length;
  16722. this._loaded = 0;
  16723. this._filename = null;
  16724. this._disableRange = source.disableRange || false;
  16725. this._rangeChunkSize = source.rangeChunkSize;
  16726. if (!this._rangeChunkSize && !this._disableRange) {
  16727. this._disableRange = true;
  16728. }
  16729. this._isStreamingSupported = !source.disableStream;
  16730. this._isRangeSupported = !source.disableRange;
  16731. this._readableStream = null;
  16732. this._readCapability = (0, _util.createPromiseCapability)();
  16733. this._headersCapability = (0, _util.createPromiseCapability)();
  16734. }
  16735. _createClass(BaseFullReader, [{
  16736. key: 'read',
  16737. value: function () {
  16738. var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee() {
  16739. var chunk, buffer;
  16740. return _regenerator2.default.wrap(function _callee$(_context) {
  16741. while (1) {
  16742. switch (_context.prev = _context.next) {
  16743. case 0:
  16744. _context.next = 2;
  16745. return this._readCapability.promise;
  16746. case 2:
  16747. if (!this._done) {
  16748. _context.next = 4;
  16749. break;
  16750. }
  16751. return _context.abrupt('return', {
  16752. value: undefined,
  16753. done: true
  16754. });
  16755. case 4:
  16756. if (!this._storedError) {
  16757. _context.next = 6;
  16758. break;
  16759. }
  16760. throw this._storedError;
  16761. case 6:
  16762. chunk = this._readableStream.read();
  16763. if (!(chunk === null)) {
  16764. _context.next = 10;
  16765. break;
  16766. }
  16767. this._readCapability = (0, _util.createPromiseCapability)();
  16768. return _context.abrupt('return', this.read());
  16769. case 10:
  16770. this._loaded += chunk.length;
  16771. if (this.onProgress) {
  16772. this.onProgress({
  16773. loaded: this._loaded,
  16774. total: this._contentLength
  16775. });
  16776. }
  16777. buffer = new Uint8Array(chunk).buffer;
  16778. return _context.abrupt('return', {
  16779. value: buffer,
  16780. done: false
  16781. });
  16782. case 14:
  16783. case 'end':
  16784. return _context.stop();
  16785. }
  16786. }
  16787. }, _callee, this);
  16788. }));
  16789. function read() {
  16790. return _ref.apply(this, arguments);
  16791. }
  16792. return read;
  16793. }()
  16794. }, {
  16795. key: 'cancel',
  16796. value: function cancel(reason) {
  16797. if (!this._readableStream) {
  16798. this._error(reason);
  16799. return;
  16800. }
  16801. this._readableStream.destroy(reason);
  16802. }
  16803. }, {
  16804. key: '_error',
  16805. value: function _error(reason) {
  16806. this._storedError = reason;
  16807. this._readCapability.resolve();
  16808. }
  16809. }, {
  16810. key: '_setReadableStream',
  16811. value: function _setReadableStream(readableStream) {
  16812. var _this = this;
  16813. this._readableStream = readableStream;
  16814. readableStream.on('readable', function () {
  16815. _this._readCapability.resolve();
  16816. });
  16817. readableStream.on('end', function () {
  16818. readableStream.destroy();
  16819. _this._done = true;
  16820. _this._readCapability.resolve();
  16821. });
  16822. readableStream.on('error', function (reason) {
  16823. _this._error(reason);
  16824. });
  16825. if (!this._isStreamingSupported && this._isRangeSupported) {
  16826. this._error(new _util.AbortException('streaming is disabled'));
  16827. }
  16828. if (this._storedError) {
  16829. this._readableStream.destroy(this._storedError);
  16830. }
  16831. }
  16832. }, {
  16833. key: 'headersReady',
  16834. get: function get() {
  16835. return this._headersCapability.promise;
  16836. }
  16837. }, {
  16838. key: 'filename',
  16839. get: function get() {
  16840. return this._filename;
  16841. }
  16842. }, {
  16843. key: 'contentLength',
  16844. get: function get() {
  16845. return this._contentLength;
  16846. }
  16847. }, {
  16848. key: 'isRangeSupported',
  16849. get: function get() {
  16850. return this._isRangeSupported;
  16851. }
  16852. }, {
  16853. key: 'isStreamingSupported',
  16854. get: function get() {
  16855. return this._isStreamingSupported;
  16856. }
  16857. }]);
  16858. return BaseFullReader;
  16859. }();
  16860. var BaseRangeReader = function () {
  16861. function BaseRangeReader(stream) {
  16862. _classCallCheck(this, BaseRangeReader);
  16863. this._url = stream.url;
  16864. this._done = false;
  16865. this._storedError = null;
  16866. this.onProgress = null;
  16867. this._loaded = 0;
  16868. this._readableStream = null;
  16869. this._readCapability = (0, _util.createPromiseCapability)();
  16870. var source = stream.source;
  16871. this._isStreamingSupported = !source.disableStream;
  16872. }
  16873. _createClass(BaseRangeReader, [{
  16874. key: 'read',
  16875. value: function () {
  16876. var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2() {
  16877. var chunk, buffer;
  16878. return _regenerator2.default.wrap(function _callee2$(_context2) {
  16879. while (1) {
  16880. switch (_context2.prev = _context2.next) {
  16881. case 0:
  16882. _context2.next = 2;
  16883. return this._readCapability.promise;
  16884. case 2:
  16885. if (!this._done) {
  16886. _context2.next = 4;
  16887. break;
  16888. }
  16889. return _context2.abrupt('return', {
  16890. value: undefined,
  16891. done: true
  16892. });
  16893. case 4:
  16894. if (!this._storedError) {
  16895. _context2.next = 6;
  16896. break;
  16897. }
  16898. throw this._storedError;
  16899. case 6:
  16900. chunk = this._readableStream.read();
  16901. if (!(chunk === null)) {
  16902. _context2.next = 10;
  16903. break;
  16904. }
  16905. this._readCapability = (0, _util.createPromiseCapability)();
  16906. return _context2.abrupt('return', this.read());
  16907. case 10:
  16908. this._loaded += chunk.length;
  16909. if (this.onProgress) {
  16910. this.onProgress({ loaded: this._loaded });
  16911. }
  16912. buffer = new Uint8Array(chunk).buffer;
  16913. return _context2.abrupt('return', {
  16914. value: buffer,
  16915. done: false
  16916. });
  16917. case 14:
  16918. case 'end':
  16919. return _context2.stop();
  16920. }
  16921. }
  16922. }, _callee2, this);
  16923. }));
  16924. function read() {
  16925. return _ref2.apply(this, arguments);
  16926. }
  16927. return read;
  16928. }()
  16929. }, {
  16930. key: 'cancel',
  16931. value: function cancel(reason) {
  16932. if (!this._readableStream) {
  16933. this._error(reason);
  16934. return;
  16935. }
  16936. this._readableStream.destroy(reason);
  16937. }
  16938. }, {
  16939. key: '_error',
  16940. value: function _error(reason) {
  16941. this._storedError = reason;
  16942. this._readCapability.resolve();
  16943. }
  16944. }, {
  16945. key: '_setReadableStream',
  16946. value: function _setReadableStream(readableStream) {
  16947. var _this2 = this;
  16948. this._readableStream = readableStream;
  16949. readableStream.on('readable', function () {
  16950. _this2._readCapability.resolve();
  16951. });
  16952. readableStream.on('end', function () {
  16953. readableStream.destroy();
  16954. _this2._done = true;
  16955. _this2._readCapability.resolve();
  16956. });
  16957. readableStream.on('error', function (reason) {
  16958. _this2._error(reason);
  16959. });
  16960. if (this._storedError) {
  16961. this._readableStream.destroy(this._storedError);
  16962. }
  16963. }
  16964. }, {
  16965. key: 'isStreamingSupported',
  16966. get: function get() {
  16967. return this._isStreamingSupported;
  16968. }
  16969. }]);
  16970. return BaseRangeReader;
  16971. }();
  16972. function createRequestOptions(url, headers) {
  16973. return {
  16974. protocol: url.protocol,
  16975. auth: url.auth,
  16976. host: url.hostname,
  16977. port: url.port,
  16978. path: url.path,
  16979. method: 'GET',
  16980. headers: headers
  16981. };
  16982. }
  16983. var PDFNodeStreamFullReader = function (_BaseFullReader) {
  16984. _inherits(PDFNodeStreamFullReader, _BaseFullReader);
  16985. function PDFNodeStreamFullReader(stream) {
  16986. _classCallCheck(this, PDFNodeStreamFullReader);
  16987. var _this3 = _possibleConstructorReturn(this, (PDFNodeStreamFullReader.__proto__ || Object.getPrototypeOf(PDFNodeStreamFullReader)).call(this, stream));
  16988. var handleResponse = function handleResponse(response) {
  16989. if (response.statusCode === 404) {
  16990. var error = new _util.MissingPDFException('Missing PDF "' + _this3._url + '".');
  16991. _this3._storedError = error;
  16992. _this3._headersCapability.reject(error);
  16993. return;
  16994. }
  16995. _this3._headersCapability.resolve();
  16996. _this3._setReadableStream(response);
  16997. var getResponseHeader = function getResponseHeader(name) {
  16998. return _this3._readableStream.headers[name.toLowerCase()];
  16999. };
  17000. var _validateRangeRequest = (0, _network_utils.validateRangeRequestCapabilities)({
  17001. getResponseHeader: getResponseHeader,
  17002. isHttp: stream.isHttp,
  17003. rangeChunkSize: _this3._rangeChunkSize,
  17004. disableRange: _this3._disableRange
  17005. }),
  17006. allowRangeRequests = _validateRangeRequest.allowRangeRequests,
  17007. suggestedLength = _validateRangeRequest.suggestedLength;
  17008. _this3._isRangeSupported = allowRangeRequests;
  17009. _this3._contentLength = suggestedLength || _this3._contentLength;
  17010. _this3._filename = (0, _network_utils.extractFilenameFromHeader)(getResponseHeader);
  17011. };
  17012. _this3._request = null;
  17013. if (_this3._url.protocol === 'http:') {
  17014. _this3._request = http.request(createRequestOptions(_this3._url, stream.httpHeaders), handleResponse);
  17015. } else {
  17016. _this3._request = https.request(createRequestOptions(_this3._url, stream.httpHeaders), handleResponse);
  17017. }
  17018. _this3._request.on('error', function (reason) {
  17019. _this3._storedError = reason;
  17020. _this3._headersCapability.reject(reason);
  17021. });
  17022. _this3._request.end();
  17023. return _this3;
  17024. }
  17025. return PDFNodeStreamFullReader;
  17026. }(BaseFullReader);
  17027. var PDFNodeStreamRangeReader = function (_BaseRangeReader) {
  17028. _inherits(PDFNodeStreamRangeReader, _BaseRangeReader);
  17029. function PDFNodeStreamRangeReader(stream, start, end) {
  17030. _classCallCheck(this, PDFNodeStreamRangeReader);
  17031. var _this4 = _possibleConstructorReturn(this, (PDFNodeStreamRangeReader.__proto__ || Object.getPrototypeOf(PDFNodeStreamRangeReader)).call(this, stream));
  17032. _this4._httpHeaders = {};
  17033. for (var property in stream.httpHeaders) {
  17034. var value = stream.httpHeaders[property];
  17035. if (typeof value === 'undefined') {
  17036. continue;
  17037. }
  17038. _this4._httpHeaders[property] = value;
  17039. }
  17040. _this4._httpHeaders['Range'] = 'bytes=' + start + '-' + (end - 1);
  17041. var handleResponse = function handleResponse(response) {
  17042. if (response.statusCode === 404) {
  17043. var error = new _util.MissingPDFException('Missing PDF "' + _this4._url + '".');
  17044. _this4._storedError = error;
  17045. return;
  17046. }
  17047. _this4._setReadableStream(response);
  17048. };
  17049. _this4._request = null;
  17050. if (_this4._url.protocol === 'http:') {
  17051. _this4._request = http.request(createRequestOptions(_this4._url, _this4._httpHeaders), handleResponse);
  17052. } else {
  17053. _this4._request = https.request(createRequestOptions(_this4._url, _this4._httpHeaders), handleResponse);
  17054. }
  17055. _this4._request.on('error', function (reason) {
  17056. _this4._storedError = reason;
  17057. });
  17058. _this4._request.end();
  17059. return _this4;
  17060. }
  17061. return PDFNodeStreamRangeReader;
  17062. }(BaseRangeReader);
  17063. var PDFNodeStreamFsFullReader = function (_BaseFullReader2) {
  17064. _inherits(PDFNodeStreamFsFullReader, _BaseFullReader2);
  17065. function PDFNodeStreamFsFullReader(stream) {
  17066. _classCallCheck(this, PDFNodeStreamFsFullReader);
  17067. var _this5 = _possibleConstructorReturn(this, (PDFNodeStreamFsFullReader.__proto__ || Object.getPrototypeOf(PDFNodeStreamFsFullReader)).call(this, stream));
  17068. var path = decodeURIComponent(_this5._url.path);
  17069. if (fileUriRegex.test(_this5._url.href)) {
  17070. path = path.replace(/^\//, '');
  17071. }
  17072. fs.lstat(path, function (error, stat) {
  17073. if (error) {
  17074. if (error.code === 'ENOENT') {
  17075. error = new _util.MissingPDFException('Missing PDF "' + path + '".');
  17076. }
  17077. _this5._storedError = error;
  17078. _this5._headersCapability.reject(error);
  17079. return;
  17080. }
  17081. _this5._contentLength = stat.size;
  17082. _this5._setReadableStream(fs.createReadStream(path));
  17083. _this5._headersCapability.resolve();
  17084. });
  17085. return _this5;
  17086. }
  17087. return PDFNodeStreamFsFullReader;
  17088. }(BaseFullReader);
  17089. var PDFNodeStreamFsRangeReader = function (_BaseRangeReader2) {
  17090. _inherits(PDFNodeStreamFsRangeReader, _BaseRangeReader2);
  17091. function PDFNodeStreamFsRangeReader(stream, start, end) {
  17092. _classCallCheck(this, PDFNodeStreamFsRangeReader);
  17093. var _this6 = _possibleConstructorReturn(this, (PDFNodeStreamFsRangeReader.__proto__ || Object.getPrototypeOf(PDFNodeStreamFsRangeReader)).call(this, stream));
  17094. var path = decodeURIComponent(_this6._url.path);
  17095. if (fileUriRegex.test(_this6._url.href)) {
  17096. path = path.replace(/^\//, '');
  17097. }
  17098. _this6._setReadableStream(fs.createReadStream(path, {
  17099. start: start,
  17100. end: end - 1
  17101. }));
  17102. return _this6;
  17103. }
  17104. return PDFNodeStreamFsRangeReader;
  17105. }(BaseRangeReader);
  17106. exports.PDFNodeStream = PDFNodeStream;
  17107. /***/ }),
  17108. /* 149 */
  17109. /***/ (function(module, exports, __w_pdfjs_require__) {
  17110. "use strict";
  17111. Object.defineProperty(exports, "__esModule", {
  17112. value: true
  17113. });
  17114. exports.validateResponseStatus = exports.validateRangeRequestCapabilities = exports.extractFilenameFromHeader = exports.createResponseStatusError = undefined;
  17115. var _util = __w_pdfjs_require__(1);
  17116. var _content_disposition = __w_pdfjs_require__(150);
  17117. function validateRangeRequestCapabilities(_ref) {
  17118. var getResponseHeader = _ref.getResponseHeader,
  17119. isHttp = _ref.isHttp,
  17120. rangeChunkSize = _ref.rangeChunkSize,
  17121. disableRange = _ref.disableRange;
  17122. (0, _util.assert)(rangeChunkSize > 0, 'Range chunk size must be larger than zero');
  17123. var returnValues = {
  17124. allowRangeRequests: false,
  17125. suggestedLength: undefined
  17126. };
  17127. var length = parseInt(getResponseHeader('Content-Length'), 10);
  17128. if (!Number.isInteger(length)) {
  17129. return returnValues;
  17130. }
  17131. returnValues.suggestedLength = length;
  17132. if (length <= 2 * rangeChunkSize) {
  17133. return returnValues;
  17134. }
  17135. if (disableRange || !isHttp) {
  17136. return returnValues;
  17137. }
  17138. if (getResponseHeader('Accept-Ranges') !== 'bytes') {
  17139. return returnValues;
  17140. }
  17141. var contentEncoding = getResponseHeader('Content-Encoding') || 'identity';
  17142. if (contentEncoding !== 'identity') {
  17143. return returnValues;
  17144. }
  17145. returnValues.allowRangeRequests = true;
  17146. return returnValues;
  17147. }
  17148. function extractFilenameFromHeader(getResponseHeader) {
  17149. var contentDisposition = getResponseHeader('Content-Disposition');
  17150. if (contentDisposition) {
  17151. var filename = (0, _content_disposition.getFilenameFromContentDispositionHeader)(contentDisposition);
  17152. if (/\.pdf$/i.test(filename)) {
  17153. return filename;
  17154. }
  17155. }
  17156. return null;
  17157. }
  17158. function createResponseStatusError(status, url) {
  17159. if (status === 404 || status === 0 && /^file:/.test(url)) {
  17160. return new _util.MissingPDFException('Missing PDF "' + url + '".');
  17161. }
  17162. return new _util.UnexpectedResponseException('Unexpected server response (' + status + ') while retrieving PDF "' + url + '".', status);
  17163. }
  17164. function validateResponseStatus(status) {
  17165. return status === 200 || status === 206;
  17166. }
  17167. exports.createResponseStatusError = createResponseStatusError;
  17168. exports.extractFilenameFromHeader = extractFilenameFromHeader;
  17169. exports.validateRangeRequestCapabilities = validateRangeRequestCapabilities;
  17170. exports.validateResponseStatus = validateResponseStatus;
  17171. /***/ }),
  17172. /* 150 */
  17173. /***/ (function(module, exports, __w_pdfjs_require__) {
  17174. "use strict";
  17175. Object.defineProperty(exports, "__esModule", {
  17176. value: true
  17177. });
  17178. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  17179. function getFilenameFromContentDispositionHeader(contentDisposition) {
  17180. var needsEncodingFixup = true;
  17181. var tmp = toParamRegExp('filename\\*', 'i').exec(contentDisposition);
  17182. if (tmp) {
  17183. tmp = tmp[1];
  17184. var filename = rfc2616unquote(tmp);
  17185. filename = unescape(filename);
  17186. filename = rfc5987decode(filename);
  17187. filename = rfc2047decode(filename);
  17188. return fixupEncoding(filename);
  17189. }
  17190. tmp = rfc2231getparam(contentDisposition);
  17191. if (tmp) {
  17192. var _filename = rfc2047decode(tmp);
  17193. return fixupEncoding(_filename);
  17194. }
  17195. tmp = toParamRegExp('filename', 'i').exec(contentDisposition);
  17196. if (tmp) {
  17197. tmp = tmp[1];
  17198. var _filename2 = rfc2616unquote(tmp);
  17199. _filename2 = rfc2047decode(_filename2);
  17200. return fixupEncoding(_filename2);
  17201. }
  17202. function toParamRegExp(attributePattern, flags) {
  17203. return new RegExp('(?:^|;)\\s*' + attributePattern + '\\s*=\\s*' + '(' + '[^";\\s][^;\\s]*' + '|' + '"(?:[^"\\\\]|\\\\"?)+"?' + ')', flags);
  17204. }
  17205. function textdecode(encoding, value) {
  17206. if (encoding) {
  17207. if (!/^[\x00-\xFF]+$/.test(value)) {
  17208. return value;
  17209. }
  17210. try {
  17211. var decoder = new TextDecoder(encoding, { fatal: true });
  17212. var bytes = new Array(value.length);
  17213. for (var i = 0; i < value.length; ++i) {
  17214. bytes[i] = value.charCodeAt(i);
  17215. }
  17216. value = decoder.decode(new Uint8Array(bytes));
  17217. needsEncodingFixup = false;
  17218. } catch (e) {
  17219. if (/^utf-?8$/i.test(encoding)) {
  17220. try {
  17221. value = decodeURIComponent(escape(value));
  17222. needsEncodingFixup = false;
  17223. } catch (err) {}
  17224. }
  17225. }
  17226. }
  17227. return value;
  17228. }
  17229. function fixupEncoding(value) {
  17230. if (needsEncodingFixup && /[\x80-\xff]/.test(value)) {
  17231. value = textdecode('utf-8', value);
  17232. if (needsEncodingFixup) {
  17233. value = textdecode('iso-8859-1', value);
  17234. }
  17235. }
  17236. return value;
  17237. }
  17238. function rfc2231getparam(contentDisposition) {
  17239. var matches = [],
  17240. match = void 0;
  17241. var iter = toParamRegExp('filename\\*((?!0\\d)\\d+)(\\*?)', 'ig');
  17242. while ((match = iter.exec(contentDisposition)) !== null) {
  17243. var _match = match,
  17244. _match2 = _slicedToArray(_match, 4),
  17245. n = _match2[1],
  17246. quot = _match2[2],
  17247. part = _match2[3];
  17248. n = parseInt(n, 10);
  17249. if (n in matches) {
  17250. if (n === 0) {
  17251. break;
  17252. }
  17253. continue;
  17254. }
  17255. matches[n] = [quot, part];
  17256. }
  17257. var parts = [];
  17258. for (var _n = 0; _n < matches.length; ++_n) {
  17259. if (!(_n in matches)) {
  17260. break;
  17261. }
  17262. var _matches$_n = _slicedToArray(matches[_n], 2),
  17263. _quot = _matches$_n[0],
  17264. _part = _matches$_n[1];
  17265. _part = rfc2616unquote(_part);
  17266. if (_quot) {
  17267. _part = unescape(_part);
  17268. if (_n === 0) {
  17269. _part = rfc5987decode(_part);
  17270. }
  17271. }
  17272. parts.push(_part);
  17273. }
  17274. return parts.join('');
  17275. }
  17276. function rfc2616unquote(value) {
  17277. if (value.charAt(0) === '"') {
  17278. var parts = value.slice(1).split('\\"');
  17279. for (var i = 0; i < parts.length; ++i) {
  17280. var quotindex = parts[i].indexOf('"');
  17281. if (quotindex !== -1) {
  17282. parts[i] = parts[i].slice(0, quotindex);
  17283. parts.length = i + 1;
  17284. }
  17285. parts[i] = parts[i].replace(/\\(.)/g, '$1');
  17286. }
  17287. value = parts.join('"');
  17288. }
  17289. return value;
  17290. }
  17291. function rfc5987decode(extvalue) {
  17292. var encodingend = extvalue.indexOf('\'');
  17293. if (encodingend === -1) {
  17294. return extvalue;
  17295. }
  17296. var encoding = extvalue.slice(0, encodingend);
  17297. var langvalue = extvalue.slice(encodingend + 1);
  17298. var value = langvalue.replace(/^[^']*'/, '');
  17299. return textdecode(encoding, value);
  17300. }
  17301. function rfc2047decode(value) {
  17302. if (value.slice(0, 2) !== '=?' || /[\x00-\x19\x80-\xff]/.test(value)) {
  17303. return value;
  17304. }
  17305. return value.replace(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g, function (_, charset, encoding, text) {
  17306. if (encoding === 'q' || encoding === 'Q') {
  17307. text = text.replace(/_/g, ' ');
  17308. text = text.replace(/=([0-9a-fA-F]{2})/g, function (_, hex) {
  17309. return String.fromCharCode(parseInt(hex, 16));
  17310. });
  17311. return textdecode(charset, text);
  17312. }
  17313. try {
  17314. text = atob(text);
  17315. } catch (e) {}
  17316. return textdecode(charset, text);
  17317. });
  17318. }
  17319. return '';
  17320. }
  17321. exports.getFilenameFromContentDispositionHeader = getFilenameFromContentDispositionHeader;
  17322. /***/ }),
  17323. /* 151 */
  17324. /***/ (function(module, exports, __w_pdfjs_require__) {
  17325. "use strict";
  17326. Object.defineProperty(exports, "__esModule", {
  17327. value: true
  17328. });
  17329. exports.PDFFetchStream = undefined;
  17330. var _regenerator = __w_pdfjs_require__(137);
  17331. var _regenerator2 = _interopRequireDefault(_regenerator);
  17332. 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; }; }();
  17333. var _util = __w_pdfjs_require__(1);
  17334. var _network_utils = __w_pdfjs_require__(149);
  17335. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  17336. function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
  17337. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  17338. function createFetchOptions(headers, withCredentials, abortController) {
  17339. return {
  17340. method: 'GET',
  17341. headers: headers,
  17342. signal: abortController && abortController.signal,
  17343. mode: 'cors',
  17344. credentials: withCredentials ? 'include' : 'same-origin',
  17345. redirect: 'follow'
  17346. };
  17347. }
  17348. var PDFFetchStream = function () {
  17349. function PDFFetchStream(source) {
  17350. _classCallCheck(this, PDFFetchStream);
  17351. this.source = source;
  17352. this.isHttp = /^https?:/i.test(source.url);
  17353. this.httpHeaders = this.isHttp && source.httpHeaders || {};
  17354. this._fullRequestReader = null;
  17355. this._rangeRequestReaders = [];
  17356. }
  17357. _createClass(PDFFetchStream, [{
  17358. key: 'getFullReader',
  17359. value: function getFullReader() {
  17360. (0, _util.assert)(!this._fullRequestReader);
  17361. this._fullRequestReader = new PDFFetchStreamReader(this);
  17362. return this._fullRequestReader;
  17363. }
  17364. }, {
  17365. key: 'getRangeReader',
  17366. value: function getRangeReader(begin, end) {
  17367. var reader = new PDFFetchStreamRangeReader(this, begin, end);
  17368. this._rangeRequestReaders.push(reader);
  17369. return reader;
  17370. }
  17371. }, {
  17372. key: 'cancelAllRequests',
  17373. value: function cancelAllRequests(reason) {
  17374. if (this._fullRequestReader) {
  17375. this._fullRequestReader.cancel(reason);
  17376. }
  17377. var readers = this._rangeRequestReaders.slice(0);
  17378. readers.forEach(function (reader) {
  17379. reader.cancel(reason);
  17380. });
  17381. }
  17382. }]);
  17383. return PDFFetchStream;
  17384. }();
  17385. var PDFFetchStreamReader = function () {
  17386. function PDFFetchStreamReader(stream) {
  17387. var _this = this;
  17388. _classCallCheck(this, PDFFetchStreamReader);
  17389. this._stream = stream;
  17390. this._reader = null;
  17391. this._loaded = 0;
  17392. this._filename = null;
  17393. var source = stream.source;
  17394. this._withCredentials = source.withCredentials;
  17395. this._contentLength = source.length;
  17396. this._headersCapability = (0, _util.createPromiseCapability)();
  17397. this._disableRange = source.disableRange || false;
  17398. this._rangeChunkSize = source.rangeChunkSize;
  17399. if (!this._rangeChunkSize && !this._disableRange) {
  17400. this._disableRange = true;
  17401. }
  17402. if (typeof AbortController !== 'undefined') {
  17403. this._abortController = new AbortController();
  17404. }
  17405. this._isStreamingSupported = !source.disableStream;
  17406. this._isRangeSupported = !source.disableRange;
  17407. this._headers = new Headers();
  17408. for (var property in this._stream.httpHeaders) {
  17409. var value = this._stream.httpHeaders[property];
  17410. if (typeof value === 'undefined') {
  17411. continue;
  17412. }
  17413. this._headers.append(property, value);
  17414. }
  17415. var url = source.url;
  17416. fetch(url, createFetchOptions(this._headers, this._withCredentials, this._abortController)).then(function (response) {
  17417. if (!(0, _network_utils.validateResponseStatus)(response.status)) {
  17418. throw (0, _network_utils.createResponseStatusError)(response.status, url);
  17419. }
  17420. _this._reader = response.body.getReader();
  17421. _this._headersCapability.resolve();
  17422. var getResponseHeader = function getResponseHeader(name) {
  17423. return response.headers.get(name);
  17424. };
  17425. var _validateRangeRequest = (0, _network_utils.validateRangeRequestCapabilities)({
  17426. getResponseHeader: getResponseHeader,
  17427. isHttp: _this._stream.isHttp,
  17428. rangeChunkSize: _this._rangeChunkSize,
  17429. disableRange: _this._disableRange
  17430. }),
  17431. allowRangeRequests = _validateRangeRequest.allowRangeRequests,
  17432. suggestedLength = _validateRangeRequest.suggestedLength;
  17433. _this._isRangeSupported = allowRangeRequests;
  17434. _this._contentLength = suggestedLength || _this._contentLength;
  17435. _this._filename = (0, _network_utils.extractFilenameFromHeader)(getResponseHeader);
  17436. if (!_this._isStreamingSupported && _this._isRangeSupported) {
  17437. _this.cancel(new _util.AbortException('streaming is disabled'));
  17438. }
  17439. }).catch(this._headersCapability.reject);
  17440. this.onProgress = null;
  17441. }
  17442. _createClass(PDFFetchStreamReader, [{
  17443. key: 'read',
  17444. value: function () {
  17445. var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee() {
  17446. var _ref2, value, done, buffer;
  17447. return _regenerator2.default.wrap(function _callee$(_context) {
  17448. while (1) {
  17449. switch (_context.prev = _context.next) {
  17450. case 0:
  17451. _context.next = 2;
  17452. return this._headersCapability.promise;
  17453. case 2:
  17454. _context.next = 4;
  17455. return this._reader.read();
  17456. case 4:
  17457. _ref2 = _context.sent;
  17458. value = _ref2.value;
  17459. done = _ref2.done;
  17460. if (!done) {
  17461. _context.next = 9;
  17462. break;
  17463. }
  17464. return _context.abrupt('return', {
  17465. value: value,
  17466. done: done
  17467. });
  17468. case 9:
  17469. this._loaded += value.byteLength;
  17470. if (this.onProgress) {
  17471. this.onProgress({
  17472. loaded: this._loaded,
  17473. total: this._contentLength
  17474. });
  17475. }
  17476. buffer = new Uint8Array(value).buffer;
  17477. return _context.abrupt('return', {
  17478. value: buffer,
  17479. done: false
  17480. });
  17481. case 13:
  17482. case 'end':
  17483. return _context.stop();
  17484. }
  17485. }
  17486. }, _callee, this);
  17487. }));
  17488. function read() {
  17489. return _ref.apply(this, arguments);
  17490. }
  17491. return read;
  17492. }()
  17493. }, {
  17494. key: 'cancel',
  17495. value: function cancel(reason) {
  17496. if (this._reader) {
  17497. this._reader.cancel(reason);
  17498. }
  17499. if (this._abortController) {
  17500. this._abortController.abort();
  17501. }
  17502. }
  17503. }, {
  17504. key: 'headersReady',
  17505. get: function get() {
  17506. return this._headersCapability.promise;
  17507. }
  17508. }, {
  17509. key: 'filename',
  17510. get: function get() {
  17511. return this._filename;
  17512. }
  17513. }, {
  17514. key: 'contentLength',
  17515. get: function get() {
  17516. return this._contentLength;
  17517. }
  17518. }, {
  17519. key: 'isRangeSupported',
  17520. get: function get() {
  17521. return this._isRangeSupported;
  17522. }
  17523. }, {
  17524. key: 'isStreamingSupported',
  17525. get: function get() {
  17526. return this._isStreamingSupported;
  17527. }
  17528. }]);
  17529. return PDFFetchStreamReader;
  17530. }();
  17531. var PDFFetchStreamRangeReader = function () {
  17532. function PDFFetchStreamRangeReader(stream, begin, end) {
  17533. var _this2 = this;
  17534. _classCallCheck(this, PDFFetchStreamRangeReader);
  17535. this._stream = stream;
  17536. this._reader = null;
  17537. this._loaded = 0;
  17538. var source = stream.source;
  17539. this._withCredentials = source.withCredentials;
  17540. this._readCapability = (0, _util.createPromiseCapability)();
  17541. this._isStreamingSupported = !source.disableStream;
  17542. if (typeof AbortController !== 'undefined') {
  17543. this._abortController = new AbortController();
  17544. }
  17545. this._headers = new Headers();
  17546. for (var property in this._stream.httpHeaders) {
  17547. var value = this._stream.httpHeaders[property];
  17548. if (typeof value === 'undefined') {
  17549. continue;
  17550. }
  17551. this._headers.append(property, value);
  17552. }
  17553. var rangeStr = begin + '-' + (end - 1);
  17554. this._headers.append('Range', 'bytes=' + rangeStr);
  17555. var url = source.url;
  17556. fetch(url, createFetchOptions(this._headers, this._withCredentials, this._abortController)).then(function (response) {
  17557. if (!(0, _network_utils.validateResponseStatus)(response.status)) {
  17558. throw (0, _network_utils.createResponseStatusError)(response.status, url);
  17559. }
  17560. _this2._readCapability.resolve();
  17561. _this2._reader = response.body.getReader();
  17562. });
  17563. this.onProgress = null;
  17564. }
  17565. _createClass(PDFFetchStreamRangeReader, [{
  17566. key: 'read',
  17567. value: function () {
  17568. var _ref3 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2() {
  17569. var _ref4, value, done, buffer;
  17570. return _regenerator2.default.wrap(function _callee2$(_context2) {
  17571. while (1) {
  17572. switch (_context2.prev = _context2.next) {
  17573. case 0:
  17574. _context2.next = 2;
  17575. return this._readCapability.promise;
  17576. case 2:
  17577. _context2.next = 4;
  17578. return this._reader.read();
  17579. case 4:
  17580. _ref4 = _context2.sent;
  17581. value = _ref4.value;
  17582. done = _ref4.done;
  17583. if (!done) {
  17584. _context2.next = 9;
  17585. break;
  17586. }
  17587. return _context2.abrupt('return', {
  17588. value: value,
  17589. done: done
  17590. });
  17591. case 9:
  17592. this._loaded += value.byteLength;
  17593. if (this.onProgress) {
  17594. this.onProgress({ loaded: this._loaded });
  17595. }
  17596. buffer = new Uint8Array(value).buffer;
  17597. return _context2.abrupt('return', {
  17598. value: buffer,
  17599. done: false
  17600. });
  17601. case 13:
  17602. case 'end':
  17603. return _context2.stop();
  17604. }
  17605. }
  17606. }, _callee2, this);
  17607. }));
  17608. function read() {
  17609. return _ref3.apply(this, arguments);
  17610. }
  17611. return read;
  17612. }()
  17613. }, {
  17614. key: 'cancel',
  17615. value: function cancel(reason) {
  17616. if (this._reader) {
  17617. this._reader.cancel(reason);
  17618. }
  17619. if (this._abortController) {
  17620. this._abortController.abort();
  17621. }
  17622. }
  17623. }, {
  17624. key: 'isStreamingSupported',
  17625. get: function get() {
  17626. return this._isStreamingSupported;
  17627. }
  17628. }]);
  17629. return PDFFetchStreamRangeReader;
  17630. }();
  17631. exports.PDFFetchStream = PDFFetchStream;
  17632. /***/ }),
  17633. /* 152 */
  17634. /***/ (function(module, exports, __w_pdfjs_require__) {
  17635. "use strict";
  17636. Object.defineProperty(exports, "__esModule", {
  17637. value: true
  17638. });
  17639. exports.NetworkManager = exports.PDFNetworkStream = undefined;
  17640. var _regenerator = __w_pdfjs_require__(137);
  17641. var _regenerator2 = _interopRequireDefault(_regenerator);
  17642. var _util = __w_pdfjs_require__(1);
  17643. var _network_utils = __w_pdfjs_require__(149);
  17644. var _global_scope = __w_pdfjs_require__(3);
  17645. var _global_scope2 = _interopRequireDefault(_global_scope);
  17646. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  17647. function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
  17648. ;
  17649. var OK_RESPONSE = 200;
  17650. var PARTIAL_CONTENT_RESPONSE = 206;
  17651. function NetworkManager(url, args) {
  17652. this.url = url;
  17653. args = args || {};
  17654. this.isHttp = /^https?:/i.test(url);
  17655. this.httpHeaders = this.isHttp && args.httpHeaders || {};
  17656. this.withCredentials = args.withCredentials || false;
  17657. this.getXhr = args.getXhr || function NetworkManager_getXhr() {
  17658. return new XMLHttpRequest();
  17659. };
  17660. this.currXhrId = 0;
  17661. this.pendingRequests = Object.create(null);
  17662. this.loadedRequests = Object.create(null);
  17663. }
  17664. function getArrayBuffer(xhr) {
  17665. var data = xhr.response;
  17666. if (typeof data !== 'string') {
  17667. return data;
  17668. }
  17669. var array = (0, _util.stringToBytes)(data);
  17670. return array.buffer;
  17671. }
  17672. var supportsMozChunked = function supportsMozChunkedClosure() {
  17673. try {
  17674. var x = new XMLHttpRequest();
  17675. x.open('GET', _global_scope2.default.location.href);
  17676. x.responseType = 'moz-chunked-arraybuffer';
  17677. return x.responseType === 'moz-chunked-arraybuffer';
  17678. } catch (e) {
  17679. return false;
  17680. }
  17681. }();
  17682. NetworkManager.prototype = {
  17683. requestRange: function NetworkManager_requestRange(begin, end, listeners) {
  17684. var args = {
  17685. begin: begin,
  17686. end: end
  17687. };
  17688. for (var prop in listeners) {
  17689. args[prop] = listeners[prop];
  17690. }
  17691. return this.request(args);
  17692. },
  17693. requestFull: function NetworkManager_requestFull(listeners) {
  17694. return this.request(listeners);
  17695. },
  17696. request: function NetworkManager_request(args) {
  17697. var xhr = this.getXhr();
  17698. var xhrId = this.currXhrId++;
  17699. var pendingRequest = this.pendingRequests[xhrId] = { xhr: xhr };
  17700. xhr.open('GET', this.url);
  17701. xhr.withCredentials = this.withCredentials;
  17702. for (var property in this.httpHeaders) {
  17703. var value = this.httpHeaders[property];
  17704. if (typeof value === 'undefined') {
  17705. continue;
  17706. }
  17707. xhr.setRequestHeader(property, value);
  17708. }
  17709. if (this.isHttp && 'begin' in args && 'end' in args) {
  17710. var rangeStr = args.begin + '-' + (args.end - 1);
  17711. xhr.setRequestHeader('Range', 'bytes=' + rangeStr);
  17712. pendingRequest.expectedStatus = 206;
  17713. } else {
  17714. pendingRequest.expectedStatus = 200;
  17715. }
  17716. var useMozChunkedLoading = supportsMozChunked && !!args.onProgressiveData;
  17717. if (useMozChunkedLoading) {
  17718. xhr.responseType = 'moz-chunked-arraybuffer';
  17719. pendingRequest.onProgressiveData = args.onProgressiveData;
  17720. pendingRequest.mozChunked = true;
  17721. } else {
  17722. xhr.responseType = 'arraybuffer';
  17723. }
  17724. if (args.onError) {
  17725. xhr.onerror = function (evt) {
  17726. args.onError(xhr.status);
  17727. };
  17728. }
  17729. xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
  17730. xhr.onprogress = this.onProgress.bind(this, xhrId);
  17731. pendingRequest.onHeadersReceived = args.onHeadersReceived;
  17732. pendingRequest.onDone = args.onDone;
  17733. pendingRequest.onError = args.onError;
  17734. pendingRequest.onProgress = args.onProgress;
  17735. xhr.send(null);
  17736. return xhrId;
  17737. },
  17738. onProgress: function NetworkManager_onProgress(xhrId, evt) {
  17739. var pendingRequest = this.pendingRequests[xhrId];
  17740. if (!pendingRequest) {
  17741. return;
  17742. }
  17743. if (pendingRequest.mozChunked) {
  17744. var chunk = getArrayBuffer(pendingRequest.xhr);
  17745. pendingRequest.onProgressiveData(chunk);
  17746. }
  17747. var onProgress = pendingRequest.onProgress;
  17748. if (onProgress) {
  17749. onProgress(evt);
  17750. }
  17751. },
  17752. onStateChange: function NetworkManager_onStateChange(xhrId, evt) {
  17753. var pendingRequest = this.pendingRequests[xhrId];
  17754. if (!pendingRequest) {
  17755. return;
  17756. }
  17757. var xhr = pendingRequest.xhr;
  17758. if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
  17759. pendingRequest.onHeadersReceived();
  17760. delete pendingRequest.onHeadersReceived;
  17761. }
  17762. if (xhr.readyState !== 4) {
  17763. return;
  17764. }
  17765. if (!(xhrId in this.pendingRequests)) {
  17766. return;
  17767. }
  17768. delete this.pendingRequests[xhrId];
  17769. if (xhr.status === 0 && this.isHttp) {
  17770. if (pendingRequest.onError) {
  17771. pendingRequest.onError(xhr.status);
  17772. }
  17773. return;
  17774. }
  17775. var xhrStatus = xhr.status || OK_RESPONSE;
  17776. var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
  17777. if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
  17778. if (pendingRequest.onError) {
  17779. pendingRequest.onError(xhr.status);
  17780. }
  17781. return;
  17782. }
  17783. this.loadedRequests[xhrId] = true;
  17784. var chunk = getArrayBuffer(xhr);
  17785. if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
  17786. var rangeHeader = xhr.getResponseHeader('Content-Range');
  17787. var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
  17788. var begin = parseInt(matches[1], 10);
  17789. pendingRequest.onDone({
  17790. begin: begin,
  17791. chunk: chunk
  17792. });
  17793. } else if (pendingRequest.onProgressiveData) {
  17794. pendingRequest.onDone(null);
  17795. } else if (chunk) {
  17796. pendingRequest.onDone({
  17797. begin: 0,
  17798. chunk: chunk
  17799. });
  17800. } else if (pendingRequest.onError) {
  17801. pendingRequest.onError(xhr.status);
  17802. }
  17803. },
  17804. hasPendingRequests: function NetworkManager_hasPendingRequests() {
  17805. for (var xhrId in this.pendingRequests) {
  17806. return true;
  17807. }
  17808. return false;
  17809. },
  17810. getRequestXhr: function NetworkManager_getXhr(xhrId) {
  17811. return this.pendingRequests[xhrId].xhr;
  17812. },
  17813. isStreamingRequest: function NetworkManager_isStreamingRequest(xhrId) {
  17814. return !!this.pendingRequests[xhrId].onProgressiveData;
  17815. },
  17816. isPendingRequest: function NetworkManager_isPendingRequest(xhrId) {
  17817. return xhrId in this.pendingRequests;
  17818. },
  17819. isLoadedRequest: function NetworkManager_isLoadedRequest(xhrId) {
  17820. return xhrId in this.loadedRequests;
  17821. },
  17822. abortAllRequests: function NetworkManager_abortAllRequests() {
  17823. for (var xhrId in this.pendingRequests) {
  17824. this.abortRequest(xhrId | 0);
  17825. }
  17826. },
  17827. abortRequest: function NetworkManager_abortRequest(xhrId) {
  17828. var xhr = this.pendingRequests[xhrId].xhr;
  17829. delete this.pendingRequests[xhrId];
  17830. xhr.abort();
  17831. }
  17832. };
  17833. function PDFNetworkStream(source) {
  17834. this._source = source;
  17835. this._manager = new NetworkManager(source.url, {
  17836. httpHeaders: source.httpHeaders,
  17837. withCredentials: source.withCredentials
  17838. });
  17839. this._rangeChunkSize = source.rangeChunkSize;
  17840. this._fullRequestReader = null;
  17841. this._rangeRequestReaders = [];
  17842. }
  17843. PDFNetworkStream.prototype = {
  17844. _onRangeRequestReaderClosed: function PDFNetworkStream_onRangeRequestReaderClosed(reader) {
  17845. var i = this._rangeRequestReaders.indexOf(reader);
  17846. if (i >= 0) {
  17847. this._rangeRequestReaders.splice(i, 1);
  17848. }
  17849. },
  17850. getFullReader: function PDFNetworkStream_getFullReader() {
  17851. (0, _util.assert)(!this._fullRequestReader);
  17852. this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._source);
  17853. return this._fullRequestReader;
  17854. },
  17855. getRangeReader: function PDFNetworkStream_getRangeReader(begin, end) {
  17856. var reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
  17857. reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
  17858. this._rangeRequestReaders.push(reader);
  17859. return reader;
  17860. },
  17861. cancelAllRequests: function PDFNetworkStream_cancelAllRequests(reason) {
  17862. if (this._fullRequestReader) {
  17863. this._fullRequestReader.cancel(reason);
  17864. }
  17865. var readers = this._rangeRequestReaders.slice(0);
  17866. readers.forEach(function (reader) {
  17867. reader.cancel(reason);
  17868. });
  17869. }
  17870. };
  17871. function PDFNetworkStreamFullRequestReader(manager, source) {
  17872. this._manager = manager;
  17873. var args = {
  17874. onHeadersReceived: this._onHeadersReceived.bind(this),
  17875. onProgressiveData: source.disableStream ? null : this._onProgressiveData.bind(this),
  17876. onDone: this._onDone.bind(this),
  17877. onError: this._onError.bind(this),
  17878. onProgress: this._onProgress.bind(this)
  17879. };
  17880. this._url = source.url;
  17881. this._fullRequestId = manager.requestFull(args);
  17882. this._headersReceivedCapability = (0, _util.createPromiseCapability)();
  17883. this._disableRange = source.disableRange || false;
  17884. this._contentLength = source.length;
  17885. this._rangeChunkSize = source.rangeChunkSize;
  17886. if (!this._rangeChunkSize && !this._disableRange) {
  17887. this._disableRange = true;
  17888. }
  17889. this._isStreamingSupported = false;
  17890. this._isRangeSupported = false;
  17891. this._cachedChunks = [];
  17892. this._requests = [];
  17893. this._done = false;
  17894. this._storedError = undefined;
  17895. this._filename = null;
  17896. this.onProgress = null;
  17897. }
  17898. PDFNetworkStreamFullRequestReader.prototype = {
  17899. _onHeadersReceived: function PDFNetworkStreamFullRequestReader_onHeadersReceived() {
  17900. var fullRequestXhrId = this._fullRequestId;
  17901. var fullRequestXhr = this._manager.getRequestXhr(fullRequestXhrId);
  17902. var getResponseHeader = function getResponseHeader(name) {
  17903. return fullRequestXhr.getResponseHeader(name);
  17904. };
  17905. var _validateRangeRequest = (0, _network_utils.validateRangeRequestCapabilities)({
  17906. getResponseHeader: getResponseHeader,
  17907. isHttp: this._manager.isHttp,
  17908. rangeChunkSize: this._rangeChunkSize,
  17909. disableRange: this._disableRange
  17910. }),
  17911. allowRangeRequests = _validateRangeRequest.allowRangeRequests,
  17912. suggestedLength = _validateRangeRequest.suggestedLength;
  17913. if (allowRangeRequests) {
  17914. this._isRangeSupported = true;
  17915. }
  17916. this._contentLength = suggestedLength || this._contentLength;
  17917. this._filename = (0, _network_utils.extractFilenameFromHeader)(getResponseHeader);
  17918. var networkManager = this._manager;
  17919. if (networkManager.isStreamingRequest(fullRequestXhrId)) {
  17920. this._isStreamingSupported = true;
  17921. } else if (this._isRangeSupported) {
  17922. networkManager.abortRequest(fullRequestXhrId);
  17923. }
  17924. this._headersReceivedCapability.resolve();
  17925. },
  17926. _onProgressiveData: function PDFNetworkStreamFullRequestReader_onProgressiveData(chunk) {
  17927. if (this._requests.length > 0) {
  17928. var requestCapability = this._requests.shift();
  17929. requestCapability.resolve({
  17930. value: chunk,
  17931. done: false
  17932. });
  17933. } else {
  17934. this._cachedChunks.push(chunk);
  17935. }
  17936. },
  17937. _onDone: function PDFNetworkStreamFullRequestReader_onDone(args) {
  17938. if (args) {
  17939. this._onProgressiveData(args.chunk);
  17940. }
  17941. this._done = true;
  17942. if (this._cachedChunks.length > 0) {
  17943. return;
  17944. }
  17945. this._requests.forEach(function (requestCapability) {
  17946. requestCapability.resolve({
  17947. value: undefined,
  17948. done: true
  17949. });
  17950. });
  17951. this._requests = [];
  17952. },
  17953. _onError: function PDFNetworkStreamFullRequestReader_onError(status) {
  17954. var url = this._url;
  17955. var exception = (0, _network_utils.createResponseStatusError)(status, url);
  17956. this._storedError = exception;
  17957. this._headersReceivedCapability.reject(exception);
  17958. this._requests.forEach(function (requestCapability) {
  17959. requestCapability.reject(exception);
  17960. });
  17961. this._requests = [];
  17962. this._cachedChunks = [];
  17963. },
  17964. _onProgress: function PDFNetworkStreamFullRequestReader_onProgress(data) {
  17965. if (this.onProgress) {
  17966. this.onProgress({
  17967. loaded: data.loaded,
  17968. total: data.lengthComputable ? data.total : this._contentLength
  17969. });
  17970. }
  17971. },
  17972. get filename() {
  17973. return this._filename;
  17974. },
  17975. get isRangeSupported() {
  17976. return this._isRangeSupported;
  17977. },
  17978. get isStreamingSupported() {
  17979. return this._isStreamingSupported;
  17980. },
  17981. get contentLength() {
  17982. return this._contentLength;
  17983. },
  17984. get headersReady() {
  17985. return this._headersReceivedCapability.promise;
  17986. },
  17987. read: function () {
  17988. var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee() {
  17989. var chunk, requestCapability;
  17990. return _regenerator2.default.wrap(function _callee$(_context) {
  17991. while (1) {
  17992. switch (_context.prev = _context.next) {
  17993. case 0:
  17994. if (!this._storedError) {
  17995. _context.next = 2;
  17996. break;
  17997. }
  17998. throw this._storedError;
  17999. case 2:
  18000. if (!(this._cachedChunks.length > 0)) {
  18001. _context.next = 5;
  18002. break;
  18003. }
  18004. chunk = this._cachedChunks.shift();
  18005. return _context.abrupt('return', {
  18006. value: chunk,
  18007. done: false
  18008. });
  18009. case 5:
  18010. if (!this._done) {
  18011. _context.next = 7;
  18012. break;
  18013. }
  18014. return _context.abrupt('return', {
  18015. value: undefined,
  18016. done: true
  18017. });
  18018. case 7:
  18019. requestCapability = (0, _util.createPromiseCapability)();
  18020. this._requests.push(requestCapability);
  18021. return _context.abrupt('return', requestCapability.promise);
  18022. case 10:
  18023. case 'end':
  18024. return _context.stop();
  18025. }
  18026. }
  18027. }, _callee, this);
  18028. }));
  18029. function read() {
  18030. return _ref.apply(this, arguments);
  18031. }
  18032. return read;
  18033. }(),
  18034. cancel: function PDFNetworkStreamFullRequestReader_cancel(reason) {
  18035. this._done = true;
  18036. this._headersReceivedCapability.reject(reason);
  18037. this._requests.forEach(function (requestCapability) {
  18038. requestCapability.resolve({
  18039. value: undefined,
  18040. done: true
  18041. });
  18042. });
  18043. this._requests = [];
  18044. if (this._manager.isPendingRequest(this._fullRequestId)) {
  18045. this._manager.abortRequest(this._fullRequestId);
  18046. }
  18047. this._fullRequestReader = null;
  18048. }
  18049. };
  18050. function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
  18051. this._manager = manager;
  18052. var args = {
  18053. onDone: this._onDone.bind(this),
  18054. onProgress: this._onProgress.bind(this)
  18055. };
  18056. this._requestId = manager.requestRange(begin, end, args);
  18057. this._requests = [];
  18058. this._queuedChunk = null;
  18059. this._done = false;
  18060. this.onProgress = null;
  18061. this.onClosed = null;
  18062. }
  18063. PDFNetworkStreamRangeRequestReader.prototype = {
  18064. _close: function PDFNetworkStreamRangeRequestReader_close() {
  18065. if (this.onClosed) {
  18066. this.onClosed(this);
  18067. }
  18068. },
  18069. _onDone: function PDFNetworkStreamRangeRequestReader_onDone(data) {
  18070. var chunk = data.chunk;
  18071. if (this._requests.length > 0) {
  18072. var requestCapability = this._requests.shift();
  18073. requestCapability.resolve({
  18074. value: chunk,
  18075. done: false
  18076. });
  18077. } else {
  18078. this._queuedChunk = chunk;
  18079. }
  18080. this._done = true;
  18081. this._requests.forEach(function (requestCapability) {
  18082. requestCapability.resolve({
  18083. value: undefined,
  18084. done: true
  18085. });
  18086. });
  18087. this._requests = [];
  18088. this._close();
  18089. },
  18090. _onProgress: function PDFNetworkStreamRangeRequestReader_onProgress(evt) {
  18091. if (!this.isStreamingSupported && this.onProgress) {
  18092. this.onProgress({ loaded: evt.loaded });
  18093. }
  18094. },
  18095. get isStreamingSupported() {
  18096. return false;
  18097. },
  18098. read: function () {
  18099. var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2() {
  18100. var chunk, requestCapability;
  18101. return _regenerator2.default.wrap(function _callee2$(_context2) {
  18102. while (1) {
  18103. switch (_context2.prev = _context2.next) {
  18104. case 0:
  18105. if (!(this._queuedChunk !== null)) {
  18106. _context2.next = 4;
  18107. break;
  18108. }
  18109. chunk = this._queuedChunk;
  18110. this._queuedChunk = null;
  18111. return _context2.abrupt('return', {
  18112. value: chunk,
  18113. done: false
  18114. });
  18115. case 4:
  18116. if (!this._done) {
  18117. _context2.next = 6;
  18118. break;
  18119. }
  18120. return _context2.abrupt('return', {
  18121. value: undefined,
  18122. done: true
  18123. });
  18124. case 6:
  18125. requestCapability = (0, _util.createPromiseCapability)();
  18126. this._requests.push(requestCapability);
  18127. return _context2.abrupt('return', requestCapability.promise);
  18128. case 9:
  18129. case 'end':
  18130. return _context2.stop();
  18131. }
  18132. }
  18133. }, _callee2, this);
  18134. }));
  18135. function read() {
  18136. return _ref2.apply(this, arguments);
  18137. }
  18138. return read;
  18139. }(),
  18140. cancel: function PDFNetworkStreamRangeRequestReader_cancel(reason) {
  18141. this._done = true;
  18142. this._requests.forEach(function (requestCapability) {
  18143. requestCapability.resolve({
  18144. value: undefined,
  18145. done: true
  18146. });
  18147. });
  18148. this._requests = [];
  18149. if (this._manager.isPendingRequest(this._requestId)) {
  18150. this._manager.abortRequest(this._requestId);
  18151. }
  18152. this._close();
  18153. }
  18154. };
  18155. exports.PDFNetworkStream = PDFNetworkStream;
  18156. exports.NetworkManager = NetworkManager;
  18157. /***/ })
  18158. /******/ ]);
  18159. });
  18160. //# sourceMappingURL=pdf.js.map